From 05650b210f893670760b33f94cd3fc0e8b5d7b1f Mon Sep 17 00:00:00 2001 From: Gregory Trullemans Date: Sat, 15 Oct 2022 09:13:13 +0200 Subject: [PATCH] Update D3 and D3-DAG library --- static/js/plugins/D3-dag/d3-dag_0.8.2.min.js | 16 ---------------- static/js/plugins/D3-dag/d3-dag_0.9.0.min.js | 16 ---------------- templates/objectives/skills/learning_line.html | 4 ++-- 3 files changed, 2 insertions(+), 34 deletions(-) delete mode 100644 static/js/plugins/D3-dag/d3-dag_0.8.2.min.js delete mode 100644 static/js/plugins/D3-dag/d3-dag_0.9.0.min.js diff --git a/static/js/plugins/D3-dag/d3-dag_0.8.2.min.js b/static/js/plugins/D3-dag/d3-dag_0.8.2.min.js deleted file mode 100644 index 9ad6409112..0000000000 --- a/static/js/plugins/D3-dag/d3-dag_0.8.2.min.js +++ /dev/null @@ -1,16 +0,0 @@ -// d3-dag Version 0.8.2. Copyright 2021 Erik Brinkman. -var d3 = Object.assign(d3 || {}, (() => { -var d3=(()=>{var li=Object.create;var dt=Object.defineProperty;var hi=Object.getOwnPropertyDescriptor;var fi=Object.getOwnPropertyNames;var ui=Object.getPrototypeOf,ci=Object.prototype.hasOwnProperty;var de=t=>dt(t,"__esModule",{value:!0});var pe=t=>{if(typeof require!="undefined")return require(t);throw new Error('Dynamic require of "'+t+'" is not supported')};var A=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),di=(t,e)=>{de(t);for(var r in e)dt(t,r,{get:e[r],enumerable:!0})},pi=(t,e,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of fi(e))!ci.call(t,i)&&i!=="default"&&dt(t,i,{get:()=>e[i],enumerable:!(r=hi(e,i))||r.enumerable});return t},rt=t=>pi(de(dt(t!=null?li(ui(t)):{},"default",t&&t.__esModule&&"default"in t?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ge=A((ln,ve)=>{"use strict";function P(t,e){var e=e||{};this._head=0,this._tail=0,this._capacity=e.capacity,this._capacityMask=3,this._list=new Array(4),Array.isArray(t)&&this._fromArray(t)}P.prototype.peekAt=function(e){var r=e;if(r===(r|0)){var i=this.size();if(!(r>=i||r<-i))return r<0&&(r+=i),r=this._head+r&this._capacityMask,this._list[r]}};P.prototype.get=function(e){return this.peekAt(e)};P.prototype.peek=function(){if(this._head!==this._tail)return this._list[this._head]};P.prototype.peekFront=function(){return this.peek()};P.prototype.peekBack=function(){return this.peekAt(-1)};Object.defineProperty(P.prototype,"length",{get:function(){return this.size()}});P.prototype.size=function(){return this._head===this._tail?0:this._headthis._capacity&&this.pop(),this._head1e4&&this._tail<=this._list.length>>>2&&this._shrinkArray(),r}};P.prototype.push=function(e){if(e===void 0)return this.size();var r=this._tail;return this._list[r]=e,this._tail=r+1&this._capacityMask,this._tail===this._head&&this._growArray(),this._capacity&&this.size()>this._capacity&&this.shift(),this._head1e4&&e<=r>>>2&&this._shrinkArray(),i}};P.prototype.removeOne=function(e){var r=e;if(r===(r|0)&&this._head!==this._tail){var i=this.size(),n=this._list.length;if(!(r>=i||r<-i)){r<0&&(r+=i),r=this._head+r&this._capacityMask;var s=this._list[r],o;if(e0;o--)this._list[r]=this._list[r=r-1+n&this._capacityMask];this._list[r]=void 0,this._head=this._head+1+n&this._capacityMask}else{for(o=i-1-e;o>0;o--)this._list[r]=this._list[r=r+1+n&this._capacityMask];this._list[r]=void 0,this._tail=this._tail-1+n&this._capacityMask}return s}}};P.prototype.remove=function(e,r){var i=e,n,s=r;if(i===(i|0)&&this._head!==this._tail){var o=this.size(),a=this._list.length;if(!(i>=o||i<-o||r<1)){if(i<0&&(i+=o),r===1||!r)return n=new Array(1),n[0]=this.removeOne(i),n;if(i===0&&i+r>=o)return n=this.toArray(),this.clear(),n;i+r>o&&(r=o-i);var l;for(n=new Array(r),l=0;l0;l--)this._list[i=i+1+a&this._capacityMask]=void 0;return n}if(e===0){for(this._head=this._head+r+a&this._capacityMask,l=r-1;l>0;l--)this._list[i=i+1+a&this._capacityMask]=void 0;return n}if(i0;l--)this.unshift(this._list[i=i-1+a&this._capacityMask]);for(i=this._head-1+a&this._capacityMask;s>0;)this._list[i=i-1+a&this._capacityMask]=void 0,s--;e<0&&(this._tail=i)}else{for(this._tail=i,i=i+r+a&this._capacityMask,l=o-(r+e);l>0;l--)this.push(this._list[i++]);for(i=this._tail;s>0;)this._list[i=i+1+a&this._capacityMask]=void 0,s--}return this._head<2&&this._tail>1e4&&this._tail<=a>>>2&&this._shrinkArray(),n}}};P.prototype.splice=function(e,r){var i=e;if(i===(i|0)){var n=this.size();if(i<0&&(i+=n),!(i>n))if(arguments.length>2){var s,o,a,l=arguments.length,u=this._list.length,h=2;if(!n||i0&&(this._head=this._head+i+u&this._capacityMask)):(a=this.remove(i,r),this._head=this._head+i+u&this._capacityMask);l>h;)this.unshift(arguments[--l]);for(s=i;s>0;s--)this.unshift(o[s-1])}else{o=new Array(n-(i+r));var f=o.length;for(s=0;sthis._tail){for(s=this._head;s>>=1,this._capacityMask>>>=1};ve.exports=P});var Ee=A((mn,ze)=>{"use strict";var lt=1e-60,Ce,Be;do lt+=lt,Ce=1+.1*lt,Be=1+.2*lt;while(Ce<=1||Be<=1);ze.exports=lt});var Se=A((yn,Ve)=>{"use strict";function Ci(t,e,r){let i,n;for(let s=1;s<=r;s+=1){t[s][s]=1/t[s][s],n=-t[s][s];for(let o=1;o{"use strict";function Bi(t,e,r,i){let n,s;for(n=1;n<=r;n+=1){s=0;for(let o=1;o{"use strict";function zi(t,e,r,i){let n,s,o;for(let a=1;a<=r;a+=1){if(i[1]=a,o=0,n=a-1,n<1){if(o=t[a][a]-o,o<=0)break;t[a][a]=Math.sqrt(o)}else{for(let l=1;l<=n;l+=1){s=t[l][a];for(let u=1;u{"use strict";var Ut=Ee(),Ei=Se(),Vi=Ae(),Si=Te();function qi(t,e,r,i,n,s,o,a,l,u,h,f,d,v=0,g,c,I){let y,m,b,_,w,x,z,M,C,O,E,V,S,N,R=Math.min(i,h),q=2*i+R*(R+5)/2+2*h+1;for(let p=1;p<=i;p+=1)c[p]=e[p];for(let p=i+1;p<=q;p+=1)c[p]=0;for(let p=1;p<=h;p+=1)d[p]=0,s[p]=0;let G=[];if(I[1]===0){if(Si(t,r,i,G),G[1]!==0){I[1]=2;return}Vi(t,r,i,e),Ei(t,r,i)}else{for(let p=1;p<=i;p+=1){n[p]=0;for(let B=1;B<=p;B+=1)n[p]+=t[B][p]*e[B]}for(let p=1;p<=i;p+=1){e[p]=0;for(let B=p;B<=i;B+=1)e[p]+=t[p][B]*n[B]}}o[1]=0;for(let p=1;p<=i;p+=1){n[p]=e[p],o[1]+=c[p]*n[p],c[p]=0;for(let B=p+1;B<=i;B+=1)t[B][p]=0}o[1]=-o[1]/2,I[1]=0;let L=i,H=L+i,$=H+R,Q=$+R+1,X=Q+R*(R+1)/2,Dt=X+h;for(let p=1;p<=h;p+=1){x=0;for(let B=1;B<=i;B+=1)x+=a[B][p]*a[B][p];c[Dt+p]=Math.sqrt(x)}_=v,g[1]=0,g[2]=0;function ni(){g[1]+=1,q=X;for(let p=1;p<=h;p+=1){q+=1,x=-l[p];for(let B=1;B<=i;B+=1)x+=a[B][p]*n[B];if(Math.abs(x)f)c[q]=x;else if(c[q]=-Math.abs(x),x>0){for(let B=1;B<=i;B+=1)a[B][p]=-a[B][p];l[p]=-l[p]}}for(let p=1;p<=_;p+=1)c[X+d[p]]=0;b=0,w=0;for(let p=1;p<=h;p+=1)c[X+p]=1;p-=1){x=c[p],q=Q+p*(p+3)/2,y=q-p;for(let B=p+1;B<=_;B+=1)x-=c[q]*c[H+B],q+=B;x/=c[y],c[H+p]=x,!(d[p]<=f)&&(x<=0||(V=!1,m=p))}if(!V){z=c[$+m]/c[H+m];for(let p=1;p<=_;p+=1)d[p]<=f||c[H+p]<=0||(w=c[$+p]/c[H+p],w=_+1;p-=1)if(c[p]!==0&&(C=Math.max(Math.abs(c[p-1]),Math.abs(c[p])),O=Math.min(Math.abs(c[p-1]),Math.abs(c[p])),c[p-1]>=0?w=Math.abs(C*Math.sqrt(1+O*O/(C*C))):w=-Math.abs(C*Math.sqrt(1+O*O/(C*C))),C=c[p-1]/w,O=c[p]/w,C!==1))if(C===0){c[p-1]=O*w;for(let B=1;B<=i;B+=1)w=t[B][p-1],t[B][p-1]=t[B][p],t[B][p]=w}else{c[p-1]=w,E=O/(1+C);for(let B=1;B<=i;B+=1)w=C*t[B][p-1]+O*t[B][p],t[B][p]=E*(t[B][p-1]+w)-t[B][p],t[B][p-1]=w}c[q]=c[_]}}else{x=-l[b];for(let p=1;p<=i;p+=1)x+=n[p]*a[p][b];if(b>f)c[X+b]=x;else if(c[X+b]=-Math.abs(x),x>0){for(let p=1;p<=i;p+=1)a[p][b]=-a[p][b];l[b]=-l[b]}return 700}return 0}function oi(){if(q=Q+m*(m+1)/2+1,y=q+m,c[y]===0||(C=Math.max(Math.abs(c[y-1]),Math.abs(c[y])),O=Math.min(Math.abs(c[y-1]),Math.abs(c[y])),c[y-1]>=0?w=Math.abs(C*Math.sqrt(1+O*O/(C*C))):w=-Math.abs(C*Math.sqrt(1+O*O/(C*C))),C=c[y-1]/w,O=c[y]/w,C===1))return 798;if(C===0){for(let p=m+1;p<=_;p+=1)w=c[y-1],c[y-1]=c[y],c[y]=w,y+=p;for(let p=1;p<=i;p+=1)w=t[p][m],t[p][m]=t[p][m+1],t[p][m+1]=w}else{E=O/(1+C);for(let p=m+1;p<=_;p+=1)w=C*c[y-1]+O*c[y],c[y]=E*(c[y-1]+w)-c[y],c[y-1]=w,y+=p;for(let p=1;p<=i;p+=1)w=C*t[p][m]+O*t[p][m+1],t[p][m+1]=E*(t[p][m]+w)-t[p][m+1],t[p][m]=w}return 0}function ai(){y=q-m;for(let p=1;p<=m;p+=1)c[y]=c[q],q+=1,y+=1;return c[$+m]=c[$+m+1],d[m]=d[m+1],m+=1,m<_?797:0}function ce(){return c[$+_]=c[$+_+1],c[$+_+1]=0,d[_]=0,_-=1,g[2]+=1,0}for(N=0;;){if(N=ni(),N===999)return;for(;N=si(),N!==0;){if(N===999)return;if(N===700)if(m===_)ce();else{for(;oi(),N=ai(),N===797;);ce()}}}}ke.exports=qi});var $e=A(Re=>{"use strict";var Ai=Pe();function Ni(t,e,r,i=[],n=0,s=[0,0]){let o=[],a=[],l=[],u=[],h=[],f=[],d="",v=t.length-1,g=r[1].length-1;if(!i)for(let y=1;y<=g;y+=1)i[y]=0;if(v!==t[1].length-1&&(d="Dmat is not symmetric!"),v!==e.length-1&&(d="Dmat and dvec are incompatible!"),v!==r.length-1&&(d="Amat and dvec are incompatible!"),g!==i.length-1&&(d="Amat and bvec are incompatible!"),(n>g||n<0)&&(d="Value of meq is invalid!"),d!=="")return{message:d};for(let y=1;y<=g;y+=1)a[y]=0,u[y]=0;let c=0,I=Math.min(v,g);for(let y=1;y<=v;y+=1)l[y]=0;o[1]=0;for(let y=1;y<=2*v+I*(I+5)/2+2*g+1;y+=1)h[y]=0;for(let y=1;y<=2;y+=1)f[y]=0;return Ai(t,e,v,v,l,u,o,r,i,v,g,n,a,c,f,h,s),s[1]===1&&(d="constraints are inconsistent, no solution!"),s[1]===2&&(d="matrix D in quadratic function is not positive definite!"),{solution:l,Lagrangian:u,value:o,unconstrained_solution:e,iterations:f,iact:a,message:d}}Re.solveQP=Ni});var Fe=A((In,De)=>{"use strict";De.exports=$e()});var Wt=A((zn,We)=>{function Ge(t,e,r,i){this.feasible=r,this.evaluation=e,this.bounded=i,this._tableau=t}We.exports=Ge;Ge.prototype.generateSolutionSet=function(){for(var t={},e=this._tableau,r=e.varIndexByRow,i=e.variablesPerIndex,n=e.matrix,s=e.rhsColumn,o=e.height-1,a=Math.round(1/e.precision),l=1;l<=o;l+=1){var u=r[l],h=i[u];if(!(h===void 0||h.isSlack===!0)){var f=n[l][s];t[h.id]=Math.round((Number.EPSILON+f)*a)/a}}return t}});var Ze=A((En,Je)=>{var He=Wt();function Mt(t,e,r,i,n){He.call(this,t,e,r,i),this.iter=n}Je.exports=Mt;Mt.prototype=Object.create(He.prototype);Mt.constructor=Mt});var J=A((Vn,Ye)=>{var Ri=Wt(),$i=Ze();function Z(t){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=t||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}Ye.exports=Z;Z.prototype.solve=function(){return this.model.getNumberOfIntegerVariables()>0?this.branchAndCut():this.simplex(),this.updateVariableValues(),this.getSolution()};function Ht(t,e){this.priority=t,this.reducedCosts=new Array(e);for(var r=0;r0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t};Z.prototype.density=function(){for(var t=0,e=this.matrix,r=0;r0?new $i(this,t,this.feasible,this.bounded,this.branchAndCutIterations):new Ri(this,t,this.feasible,this.bounded)}});var Xe=A(()=>{var ht=J();ht.prototype.simplex=function(){return this.bounded=!0,this.phase1(),this.feasible===!0&&this.phase2(),this};ht.prototype.phase1=function(){for(var t=this.model.checkForCycles,e=[],r=this.matrix,i=this.rhsColumn,n=this.width-1,s=this.height-1,o,a=0;;){for(var l=0,u=-this.precision,h=1;h<=s;h++){o=this.unrestrictedVars[this.varIndexByRow[h]]===!0;var f=r[h][i];f0)return this.model.messages.push("Cycle in phase 1"),this.model.messages.push("Start :"+b[0]),this.model.messages.push("Length :"+b[1]),this.feasible=!1,a}this.pivot(l,d),a+=1}};ht.prototype.phase2=function(){for(var t=this.model.checkForCycles,e=[],r=this.matrix,i=this.rhsColumn,n=this.width-1,s=this.height-1,o=this.precision,a=this.optionalObjectives.length,l=null,u=0,h,f;;){var d=r[this.costRowIndex];a>0&&(l=[]);for(var v=0,g=o,c=!1,I=1;I<=n;I++){if(h=d[I],f=this.unrestrictedVars[this.varIndexByCol[I]]===!0,a>0&&-og&&(g=-h,v=I,c=!0);continue}h>g&&(g=h,v=I,c=!1)}if(a>0)for(var y=0;v===0&&l.length>0&&yg&&(g=-h,v=I,c=!0);continue}h>g&&(g=h,v=I,c=!1)}l=m,y+=1}if(v===0)return this.setEvaluation(),this.simplexIters+=1,u;for(var w=0,x=1/0,z=this.varIndexByRow,M=1;M<=s;M++){var C=r[M],O=C[i],E=C[v];if(!(-o0&&o>O&&O>-o){x=0,w=M;break}var V=c?-O/E:O/E;V>o&&x>V&&(x=V,w=M)}}if(x===1/0)return this.evaluation=-1/0,this.bounded=!1,this.unboundedVarIndex=this.varIndexByCol[v],u;if(t){e.push([this.varIndexByRow[w],this.varIndexByCol[v]]);var S=this.checkForCycles(e);if(S.length>0)return this.model.messages.push("Cycle in phase 2"),this.model.messages.push("Start :"+S[0]),this.model.messages.push("Length :"+S[1]),this.feasible=!1,u}this.pivot(w,v,!0),u+=1}};var Jt=[];ht.prototype.pivot=function(t,e){var r=this.matrix,i=r[t][e],n=this.height-1,s=this.width-1,o=this.varIndexByRow[t],a=this.varIndexByCol[e];this.varIndexByRow[t]=a,this.varIndexByCol[e]=o,this.rowByVarIndex[a]=t,this.rowByVarIndex[o]=-1,this.colByVarIndex[a]=-1,this.colByVarIndex[o]=e;for(var l=r[t],u=0,h=0;h<=s;h++)l[h]>=-1e-16&&l[h]<=1e-16?l[h]=0:(l[h]/=i,Jt[u]=h,u+=1);l[e]=1/i;for(var f,d,v,g=this.precision,c=0;c<=n;c++)if(c!==t&&!(r[c][e]>=-1e-16&&r[c][e]<=1e-16)){var I=r[c];if(f=I[e],f>=-1e-16&&f<=1e-16)f!==0&&(I[e]=0);else{for(d=0;d=-1e-16&&v<=1e-16?v!==0&&(l[h]=0):I[h]=I[h]-f*v;I[e]=-f/i}}var y=this.optionalObjectives.length;if(y>0)for(var m=0;mt.length-r)break;for(var s=!0,o=1;o{function Zt(t,e,r,i){this.id=t,this.cost=e,this.index=r,this.value=0,this.priority=i}function Ke(t,e,r,i){Zt.call(this,t,e,r,i)}Ke.prototype.isInteger=!0;function Yt(t,e){Zt.call(this,t,0,e,0)}Yt.prototype.isSlack=!0;function Qe(t,e){this.variable=t,this.coefficient=e}function tr(t,e,r){return r===0||r==="required"?null:(e=e||1,r=r||1,t.isMinimization===!1&&(e=-e),t.addVariable(e,"r"+t.relaxationIndex++,!1,!1,r))}function tt(t,e,r,i){this.slack=new Yt("s"+r,r),this.index=r,this.model=i,this.rhs=t,this.isUpperBound=e,this.terms=[],this.termsByVarIndex={},this.relaxation=null}tt.prototype.addTerm=function(t,e){var r=e.index,i=this.termsByVarIndex[r];if(i===void 0)i=new Qe(e,t),this.termsByVarIndex[r]=i,this.terms.push(i),this.isUpperBound===!0&&(t=-t),this.model.updateConstraintCoefficient(this,e,t);else{var n=i.coefficient+t;this.setVariableCoefficient(n,e)}return this};tt.prototype.removeTerm=function(t){return this};tt.prototype.setRightHandSide=function(t){if(t!==this.rhs){var e=t-this.rhs;this.isUpperBound===!0&&(e=-e),this.rhs=t,this.model.updateRightHandSide(this,e)}return this};tt.prototype.setVariableCoefficient=function(t,e){var r=e.index;if(r===-1){console.warn("[Constraint.setVariableCoefficient] Trying to change coefficient of inexistant variable.");return}var i=this.termsByVarIndex[r];if(i===void 0)this.addTerm(t,e);else if(t!==i.coefficient){var n=t-i.coefficient;this.isUpperBound===!0&&(n=-n),i.coefficient=t,this.model.updateConstraintCoefficient(this,e,n)}return this};tt.prototype.relax=function(t,e){this.relaxation=tr(this.model,t,e),this._relax(this.relaxation)};tt.prototype._relax=function(t){t!==null&&(this.isUpperBound?this.setVariableCoefficient(-1,t):this.setVariableCoefficient(1,t))};function it(t,e){this.upperBound=t,this.lowerBound=e,this.model=t.model,this.rhs=t.rhs,this.relaxation=null}it.prototype.isEquality=!0;it.prototype.addTerm=function(t,e){return this.upperBound.addTerm(t,e),this.lowerBound.addTerm(t,e),this};it.prototype.removeTerm=function(t){return this.upperBound.removeTerm(t),this.lowerBound.removeTerm(t),this};it.prototype.setRightHandSide=function(t){this.upperBound.setRightHandSide(t),this.lowerBound.setRightHandSide(t),this.rhs=t};it.prototype.relax=function(t,e){this.relaxation=tr(this.model,t,e),this.upperBound.relaxation=this.relaxation,this.upperBound._relax(this.relaxation),this.lowerBound.relaxation=this.relaxation,this.lowerBound._relax(this.relaxation)};er.exports={Constraint:tt,Variable:Zt,IntegerVariable:Ke,SlackVariable:Yt,Equality:it,Term:Qe}});var rr=A(()=>{var Ct=J(),Xt=Ot().SlackVariable;Ct.prototype.addCutConstraints=function(t){for(var e=t.length,r=this.height,i=r+e,n=r;n=0?r[o][l]=-h:r[o][l]=h*s/(1-s)}return!0};Ct.prototype.applyMIRCuts=function(){}});var ir=A(()=>{var Y=J();Y.prototype._putInBase=function(t){var e=this.rowByVarIndex[t];if(e===-1){for(var r=this.colByVarIndex[t],i=1;i0)for(var l=0;l0)for(var o=0;o0)for(var l=0;l{var Di=J();Di.prototype.log=function(t,e){console.log("****",t,"****"),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,i="",n=[" "],s,o,a,l,u,h,f,d,v,g,c,I,y;for(o=1;o5?g+=" ":c+=" ",n[o]=g,i+=c+f;console.log(i);var m,b=this.matrix[this.costRowIndex],_=" ";for(s=1;s0){console.log(" Optional objectives:");for(var x=0;x{var Bt=J();Bt.prototype.copy=function(){var t=new Bt(this.precision);t.width=this.width,t.height=this.height,t.nVars=this.nVars,t.model=this.model,t.variables=this.variables,t.variablesPerIndex=this.variablesPerIndex,t.unrestrictedVars=this.unrestrictedVars,t.lastElementIndex=this.lastElementIndex,t.varIndexByRow=this.varIndexByRow.slice(),t.varIndexByCol=this.varIndexByCol.slice(),t.rowByVarIndex=this.rowByVarIndex.slice(),t.colByVarIndex=this.colByVarIndex.slice(),t.availableIndexes=this.availableIndexes.slice();for(var e=[],r=0;rthis.height;)this.varIndexByRow.pop();var a=t.varIndexByCol;for(r=0;rthis.width;)this.varIndexByCol.pop();for(var l=t.rowByVarIndex,u=t.colByVarIndex,h=0;h0&&this.optionalObjectives.length>0){this.optionalObjectives=[],this.optionalObjectivePerPriority={};for(var f=0;f{var or=J();function ar(t,e){this.index=t,this.value=e}or.prototype.getMostFractionalVar=function(){for(var t=0,e=null,r=null,i=.5,n=this.model.integerVariables,s=n.length,o=0;othis.precision){var h=o.cost;t>h&&(t=h,e=a,r=u)}}}return new ar(e,r)}});var hr=A(()=>{var Kt=J();Kt.prototype.countIntegerValues=function(){for(var t=0,e=1;ethis.precision)return!1}}return!0};Kt.prototype.computeFractionalVolume=function(t){for(var e=-1,r=1;r{Xe();rr();ir();nr();sr();lr();hr();fr.exports=J()});var te=A(()=>{var cr=J();function dr(t,e,r){this.type=t,this.varIndex=e,this.value=r}function Qt(t,e){this.relaxedEvaluation=t,this.cuts=e}function Fi(t,e){return e.relaxedEvaluation-t.relaxedEvaluation}cr.prototype.applyCuts=function(t){if(this.restore(),this.addCutConstraints(t),this.simplex(),this.model.useMIRCuts)for(var e=!0;e;){var r=this.computeFractionalVolume(!0);this.applyMIRCuts(),this.simplex();var i=this.computeFractionalVolume(!0);i>=.9*r&&(e=!1)}};cr.prototype.branchAndCut=function(){var t=[],e=0,r=this.model.tolerance,i=!0,n=1e99;this.model.timeout&&(n=Date.now()+this.model.timeout);for(var s=1/0,o=null,a=[],l=0;l0&&i===!0&&Date.now()0&&ss)){var f=u.cuts;if(this.applyCuts(f),e++,this.feasible!==!1){var d=this.evaluation;if(!(d>s)){if(d===s){for(var v=!0,g=0;ga[g]);g+=1)if(this.optionalObjectives[g].reducedCosts[0]{var Li=J(),Yn=te(),ft=Ot(),zt=ft.Constraint,pr=ft.Equality,Ui=ft.Variable,Gi=ft.IntegerVariable,Xn=ft.Term;function k(t,e){this.tableau=new Li(t),this.name=e,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=[]}vr.exports=k;k.prototype.minimize=function(){return this.isMinimization=!0,this};k.prototype.maximize=function(){return this.isMinimization=!1,this};k.prototype._getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t};k.prototype._addConstraint=function(t){var e=t.slack;this.tableau.variablesPerIndex[e.index]=e,this.constraints.push(t),this.nConstraints+=1,this.tableauInitialized===!0&&this.tableau.addConstraint(t)};k.prototype.smallerThan=function(t){var e=new zt(t,!0,this.tableau.getNewElementIndex(),this);return this._addConstraint(e),e};k.prototype.greaterThan=function(t){var e=new zt(t,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(e),e};k.prototype.equal=function(t){var e=new zt(t,!0,this.tableau.getNewElementIndex(),this);this._addConstraint(e);var r=new zt(t,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(r),new pr(e,r)};k.prototype.addVariable=function(t,e,r,i,n){if(typeof n=="string")switch(n){case"required":n=0;break;case"strong":n=1;break;case"medium":n=2;break;case"weak":n=3;break;default:n=0;break}var s=this.tableau.getNewElementIndex();e==null&&(e="v"+s),t==null&&(t=0),n==null&&(n=0);var o;return r?(o=new Gi(e,t,s,n),this.integerVariables.push(o)):o=new Ui(e,t,s,n),this.variables.push(o),this.tableau.variablesPerIndex[s]=o,i&&(this.unrestrictedVariables[s]=!0),this.nVariables+=1,this.tableauInitialized===!0&&this.tableau.addVariable(o),o};k.prototype._removeConstraint=function(t){var e=this.constraints.indexOf(t);if(e===-1){console.warn("[Model.removeConstraint] Constraint not present in model");return}this.constraints.splice(e,1),this.nConstraints-=1,this.tableauInitialized===!0&&this.tableau.removeConstraint(t),t.relaxation&&this.removeVariable(t.relaxation)};k.prototype.removeConstraint=function(t){return t.isEquality?(this._removeConstraint(t.upperBound),this._removeConstraint(t.lowerBound)):this._removeConstraint(t),this};k.prototype.removeVariable=function(t){var e=this.variables.indexOf(t);if(e===-1){console.warn("[Model.removeVariable] Variable not present in model");return}return this.variables.splice(e,1),this.tableauInitialized===!0&&this.tableau.removeVariable(t),this};k.prototype.updateRightHandSide=function(t,e){return this.tableauInitialized===!0&&this.tableau.updateRightHandSide(t,e),this};k.prototype.updateConstraintCoefficient=function(t,e,r){return this.tableauInitialized===!0&&this.tableau.updateConstraintCoefficient(t,e,r),this};k.prototype.setCost=function(t,e){var r=t-e.cost;return this.isMinimization===!1&&(r=-r),e.cost=t,this.tableau.updateCost(e,r),this};k.prototype.loadJson=function(t){this.isMinimization=t.opType!=="max";for(var e=t.variables,r=t.constraints,i={},n={},s=Object.keys(r),o=s.length,a=0;a{mr.CleanObjectiveAttributes=function(t){var e,r,i;if(typeof t.optimize=="string")if(t.constraints[t.optimize]){e=Math.random();for(r in t.variables)t.variables[r][t.optimize]&&(t.variables[r][e]=t.variables[r][t.optimize]);return t.constraints[e]=t.constraints[t.optimize],delete t.constraints[t.optimize],t}else return t;else{for(i in t.optimize)if(t.constraints[i])if(t.constraints[i]==="equal")delete t.optimize[i];else{e=Math.random();for(r in t.variables)t.variables[r][i]&&(t.variables[r][e]=t.variables[r][i]);t.constraints[e]=t.constraints[i],delete t.constraints[i]}return t}}});var Et=A((ts,br)=>{function Wi(t){var e={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:{}},i={">=":"min","<=":"max","=":"equal"},n="",s=0,o=null,a="",l="",u="",h=0;typeof t=="string"&&(t=t.split(` -`));for(var f=0;f=",equal:"="},s=new RegExp("[^A-Za-z0-9_[{}/.&#$%~'@^]","gi");if(t.opType){e+=t.opType+":";for(var o in t.variables)t.variables[o][o]=t.variables[o][o]?t.variables[o][o]:1,t.variables[o][t.optimize]&&(e+=" "+t.variables[o][t.optimize]+" "+o.replace(s,"_"))}else e+="max:";e+=`; - -`;for(var a in t.constraints)for(var l in t.constraints[a])if(typeof n[l]!="undefined"){for(var u in t.variables)typeof t.variables[u][a]!="undefined"&&(e+=" "+t.variables[u][a]+" "+u.replace(s,"_"));e+=" "+n[l]+" "+t.constraints[a][l],e+=`; -`}if(t.ints){e+=` - -`;for(var h in t.ints)e+="int "+h.replace(s,"_")+`; -`}if(t.unrestricted){e+=` - -`;for(var f in t.unrestricted)e+="unrestricted "+f.replace(s,"_")+`; -`}return e}br.exports=function(t){return t.length?Wi(t):Hi(t)}});var wr=A(ee=>{ee.reformat=Et();function xr(t){return t=t.replace("\\r\\n",`\r -`),t=t.split(`\r -`),t=t.filter(function(e){var r;return r=new RegExp(" 0$","gi"),!(r.test(e)===!0||(r=new RegExp("\\d$","gi"),r.test(e)===!1))}).map(function(e){return e.split(/\:{0,1} +(?=\d)/)}).reduce(function(e,r,i){return e[r[0]]=r[1],e},{}),t}ee.solve=function(t){return new Promise(function(e,r){typeof window!="undefined"&&r("Function Not Available in Browser");var i=Et()(t);t.external||r("Data for this function must be contained in the 'external' attribute. Not seeing anything there."),t.external.binPath||r("No Executable | Binary path provided in arguments as 'binPath'"),t.external.args||r("No arguments array for cli | bash provided on 'args' attribute"),t.external.tempName||r("No 'tempName' given. This is necessary to produce a staging file for the solver to operate on");var n=pe("fs");n.writeFile(t.external.tempName,i,function(s,o){if(s)r(s);else{var a=pe("child_process").execFile;t.external.args.push(t.external.tempName),a(t.external.binPath,t.external.args,function(l,u){if(l)if(l.code===1)e(xr(u));else{var h={"-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"},f={code:l.code,meaning:h[l.code],data:u};r(f)}else e(xr(u))})}})})}});var Ir=A((rs,_r)=>{_r.exports={lpsolve:wr()}});var re=A((is,jr)=>{jr.exports=function(t,e){var r=e.optimize,i=JSON.parse(JSON.stringify(e.optimize)),n=Object.keys(e.optimize),s,o=0,a={},l="",u={},h=[],f,d,v,g,c;for(delete e.optimize,f=0;fu[f].max&&(u[f].max=h[v][f]),h[v][f]{var Ji=ur(),ie=gr(),Zi=te(),Vt=Ot(),Mr=yr(),Yi=Vt.Constraint,Xi=Vt.Variable,Ki=Vt.Numeral,Qi=Vt.Term,St=Ir(),qt=function(){"use strict";this.Model=ie,this.branchAndCut=Zi,this.Constraint=Yi,this.Variable=Xi,this.Numeral=Ki,this.Term=Qi,this.Tableau=Ji,this.lastSolvedModel=null,this.External=St,this.Solve=function(t,e,r,i){if(i)for(var n in Mr)t=Mr[n](t);if(!t)throw new Error("Solver requires a model to operate on");if(typeof t.optimize=="object"&&Object.keys(t.optimize>1))return re()(this,t);if(t.external){var s=Object.keys(St);if(s=JSON.stringify(s),!t.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:"+s);if(!St[t.external.solver])throw new Error("No support (yet) for "+t.external.solver+". Please use one of these instead:"+s);return St[t.external.solver].solve(t)}else{t instanceof ie||(t=new ie(e).loadJson(t));var o=t.solve();if(this.lastSolvedModel=t,o.solutionSet=o.generateSolutionSet(),r)return o;var a={};return a.feasible=o.feasible,a.result=o.evaluation,a.bounded=o.bounded,o._tableau.__isIntegral&&(a.isIntegral=!0),Object.keys(o.solutionSet).forEach(function(l){o.solutionSet[l]!==0&&(a[l]=o.solutionSet[l])}),a}},this.ReformatLP=Et(),this.MultiObjective=function(t){return re()(this,t)}};typeof define=="function"?define([],function(){return new qt}):typeof window=="object"?window.solver=new qt:typeof self=="object"&&(self.solver=new qt);Or.exports=new qt});var Lr=A((Ps,Fr)=>{"use strict";var nn=function(t,e){return t0&&(r=e-1>>1,i=this.array[r],!!this.compare(t,i));)this.array[e]=i,e=r;this.array[e]=t};D.prototype.heapify=function(t){this.array=t,this.size=t.length;var e;for(e=this.size>>1;e>=0;e--)this._percolateDown(e)};D.prototype._percolateUp=function(t,e){for(var r=this.array[t],i,n;t>0&&(i=t-1>>1,n=this.array[i],!(!e&&!this.compare(r,n)));)this.array[t]=n,t=i;this.array[t]=r};D.prototype._percolateDown=function(t){for(var e=this.size,r=this.size>>>1,i=this.array[t],n,s,o;tthis.size-1||t<0))return this._percolateUp(t,!0),this.poll()};D.prototype.remove=function(t){for(var e=0;e1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,t}};D.prototype.replaceTop=function(t){if(this.size!=0){var e=this.array[0];return this.array[0]=t,this._percolateDown(0),e}};D.prototype.trim=function(){this.array=this.array.slice(0,this.size)};D.prototype.isEmpty=function(){return this.size===0};D.prototype.forEach=function(t){if(!(this.isEmpty()||typeof t!="function"))for(var e=0,r=this.clone();!r.isEmpty();)t(r.poll(),e++)};D.prototype.kSmallest=function(t){if(this.size==0)return[];t=Math.min(this.size,t);var e=new D(this.compare);let r=Math.min((t>0?Math.pow(2,t-1):0)+1,this.size);e.size=r,e.array=this.array.slice(0,r);for(var i=new Array(t),n=0;nSr,aggMedianFactory:()=>le,coordCenter:()=>Zr,coordGreedy:()=>Yr,coordQuad:()=>jt,coordTopological:()=>Xr,dagConnect:()=>xe,dagHierarchy:()=>mt,dagStratify:()=>Me,decrossOpt:()=>Jr,decrossTwoLayer:()=>$t,layeringCoffmanGraham:()=>Wr,layeringLongestPath:()=>Dr,layeringSimplex:()=>Nt,layeringTopological:()=>Rr,sugiyama:()=>Pr,twolayerAgg:()=>Rt,twolayerOpt:()=>Qr,zherebko:()=>ii});var nt=rt(ge()),me=class{constructor(e){this.base=e}[Symbol.iterator](){return this.base[Symbol.iterator]()}*gconcat(...e){yield*this;for(let r of e)yield*r}concat(...e){return T(this.gconcat(...e))}*gentries(){let e=0;for(let r of this)yield[e++,r]}entries(){return T(this.gentries())}every(e){return!this.some((r,i)=>!e(r,i))}fill(e){return this.map(()=>e)}*gfilter(e){for(let[r,i]of this.gentries())e(i,r)&&(yield i)}filter(e){return T(this.gfilter(e))}find(e){return this.filter(e).shift()}findIndex(e){for(let[r,i]of this.gentries())if(e(i,r))return r;return-1}*gflatMap(e){for(let[r,i]of this.gentries())yield*e(i,r)}flatMap(e){return T(this.gflatMap(e))}forEach(e){for(let[r,i]of this.gentries())e(i,r)}includes(e,r=0){return this.indexOf(e,r)>=0}indexOf(e,r=0){if(r<0){let i=0,n=new nt.default;for(let o of this)i>=-r&&n.shift(),n.push(o),i++;let s=n.toArray().indexOf(e);return s===-1?-1:s+i+r}else{for(let[i,n]of this.gentries())if(i>=r&&n===e)return i;return-1}}join(e=","){return[...this].join(e)}*gkeys(){let e=0;for(let r of this)yield e++}keys(){return T(this.gkeys())}lastIndexOf(e,r=1/0){let i=-1;if(r<0){let n=new nt.default;for(let[s,o]of this.gentries()){o===e&&n.push(s);let a=n.peekFront();a!==void 0&&a<=s+r+1&&(n.shift(),i=a)}}else for(let[n,s]of this.gentries())n<=r&&s===e&&(i=n);return i}get length(){return this.reduce(e=>e+1,0)}*gmap(e){for(let[r,i]of this.gentries())yield e(i,r)}map(e){return T(this.gmap(e))}pop(){let e;for(e of this);return e}push(...e){return this.concat(e)}reduce(e,r){if(r===void 0){let i=e,n=!0,s;for(let[o,a]of this.gentries())n?(s=a,n=!1):s=i(s,a,o);if(n)throw new TypeError("Reduce of empty iterable with no initial value");return s}else{let i=e,n=r;for(let[s,o]of this.gentries())n=i(n,o,s);return n}}reverse(){return T([...this].reverse())}shift(){for(let e of this)return e}*gslice(e,r){for(let[i,n]of this.gentries()){if(i>=r)break;i>=e&&(yield n)}}*gnegslice(e,r){let i=new nt.default,n=e-r;for(let[s,o]of this.gentries())s>=n?(yield i.shift(),i.push(o)):s>=e&&i.push(o)}slice(e=0,r=1/0){if(e<0){let i=0,n=new nt.default;for(let a of this)i>=-e&&n.shift(),n.push(a),i++;let s=n.toArray(),o=r-i-e;return r<0?T(s.slice(0,r)):o>0?T(s.slice(0,o)):T()}else return r<0?T(this.gnegslice(e,r)):T(this.gslice(e,r))}some(e){for(let[r,i]of this.gentries())if(e(i,r))return!0;return!1}sort(e){return T([...this].sort(e))}*gsplice(e,r,...i){for(let[n,s]of this.gentries())n===e&&(yield*i),(n=e+r)&&(yield s)}splice(e,r=0,...i){return T(this.gsplice(e,r,...i))}unshift(...e){return T(e).concat(this)}values(){return this}};function T(t=[]){return new me(t)}function j(t){if(t!==void 0)return t;throw new Error("internal error: got unexpected undefined value")}function F(t){if(!t)throw new Error("internal error: failed assert")}function ye(t,e){e.size{if(typeof r=="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r}}function U(t,...e){let[r,...i]=t;return[r].concat(...i.map((n,s)=>[JSON.stringify(e[s],vi()),n])).join("")}function*W(t){let[e,...r]=t;for(let i of r)yield[e,i],e=i}function*st(t,...e){let r=new Set,i;for(;i=e.pop();)r.has(i)||(yield i,r.add(i),e.push(...t(i)))}var ot=window&&window.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);nr.ichildren(),...this.iroots())}*gbreadth(){let e=new Set,r=this.roots(),i=[];do{i=r.reverse(),r=[];let n;for(;n=i.pop();)e.has(n)||(e.add(n),yield n,r.push(...n.ichildren()))}while(r.length)}*gbefore(){let e=new Map;for(let n of this)for(let s of n.ichildren())e.set(s,(e.get(s)||0)+1);let r=this.roots(),i;for(;i=r.pop();){yield i;for(let n of i.ichildren()){let s=j(e.get(n));s>1?e.set(n,s-1):r.push(n)}}}*gafter(){let e=this.roots(),r=new Set,i;for(;i=e.pop();)r.has(i)||(i.ichildren().every(n=>r.has(n))?(r.add(i),yield i):(e.push(i),e.push(...i.ichildren())))}idescendants(e="depth"){if(e==="depth")return T(this.gdepth());if(e==="breadth")return T(this.gbreadth());if(e==="before")return T(this.gbefore());if(e==="after")return T(this.gafter());throw new Error(`unknown iteration style: ${e}`)}descendants(e="depth"){return[...this.idescendants(e)]}ilinks(){return this.idescendants().flatMap(e=>e.ichildLinks())}links(){return[...this.ilinks()]}size(){return this.idescendants().reduce(e=>e+1,0)}sum(e){let r=new Map;for(let[i,n]of this.idescendants("after").entries()){let s=e(n,i),o=new Map;o.set(n,s);for(let a of n.ichildren()){let l=j(r.get(a));for(let[u,h]of l.entries())o.set(u,h)}n.value=T(o.values()).reduce((a,l)=>a+l),r.set(n,o)}return this}count(){let e=new Map;for(let r of this.idescendants("after"))if(r.ichildren()[Symbol.iterator]().next().done)e.set(r,new Set([r])),r.value=1;else{let i=new Set;for(let n of r.ichildren()){let s=j(e.get(n));for(let o of s)i.add(o)}e.set(r,i),r.value=i.size}return this}height(){for(let e of this.idescendants("after"))e.value=Math.max(0,...e.ichildren().map(r=>j(r.value)+1));return this}depth(){let e=new Map;for(let r of this)for(let i of r.ichildren()){let n=e.get(i);n?n.push(r):e.set(i,[r])}for(let r of this.idescendants("before"))r.value=Math.max(0,...(e.get(r)||[]).map(i=>j(i.value)+1));return this}*gsplit(){let e=new Map;for(let n of this)for(let s of n.ichildren()){let o=e.get(s);o?o.push(n):e.set(s,[n])}function*r(n){yield*n.ichildren(),yield*e.get(n)||[]}let i=new Set(this.iroots());for(let n of this.iroots()){if(!i.delete(n))continue;let s=[n];for(let o of st(r,n))i.delete(o)&&s.push(o);yield s.length>1?new K(s):s[0]}}isplit(){return T(this.gsplit())}split(){return[...this.isplit()]}connected(){let e=this.isplit()[Symbol.iterator](),{done:r}=e.next();return F(!r),{done:r}=e.next(),!!r}},at=class extends K{constructor(e){super();this.data=e,this.dataChildren=[]}iroots(){return T([this])}*gchildren(){for(let{child:e}of this.dataChildren)yield e}ichildren(){return T(this.gchildren())}children(){return[...this.ichildren()]}*gchildLinks(){for(let{child:e,data:r,points:i}of this.dataChildren)yield new be(this,e,r,i)}ichildLinks(){return T(this.gchildLinks())}childLinks(){return[...this.ichildLinks()]}isplit(){return T([this])}split(){return[this]}connected(){return!0}};function Ft(t){if(typeof t!="string")throw new Error(`id is supposed to be string but got type ${typeof t}`);return t}function Lt(t){if(!t.length)throw new Error("dag contained no roots; this often indicates a cycle");for(let s of new K(t))if(new Set(s.ichildren()).size!==s.ichildren().length)throw new Error(U`node '${s.data}' contained duplicate children`);let e=new Set,r=new Set,i=null;function n(s){if(e.has(s))return[];if(r.has(s))return i=s,[s];{r.add(s);let o=[];for(let a of s.ichildren())if(o=n(a),o.length)break;return r.delete(s),e.add(s),o.length&&i!==null&&o.push(s),i===s&&(i=null),o}}for(let s of t){let o=n(s);if(o.length){let a=o.reverse().map(({data:l})=>U`'${l}'`).join(" -> ");throw new Error(`dag contained a cycle: ${a}`)}}}function vt(t){function e(s){if(!s.length)throw new Error("can't connect empty data");let o=new Map,a=new Set;for(let[u,h]of s.entries()){let f=Ft(t.sourceId(h,u)),d=o.get(f);d===void 0&&(d=new at({id:f}),o.set(f,d));let v=Ft(t.targetId(h,u)),g=o.get(v);g===void 0&&(g=new at({id:v}),o.set(v,g)),(f!==v||!t.single)&&(d.dataChildren.push(new pt(g,h)),a.add(v))}let l=[];for(let[u,h]of o.entries())a.has(u)||l.push(h);return Lt(l),l.length>1?new K(l):l[0]}function r(s){if(s===void 0)return t.sourceId;{let{sourceId:o}=t,a=ot(t,["sourceId"]);return vt(Object.assign(Object.assign({},a),{sourceId:s}))}}e.sourceId=r;function i(s){if(s===void 0)return t.targetId;{let{targetId:o}=t,a=ot(t,["targetId"]);return vt(Object.assign(Object.assign({},a),{targetId:s}))}}e.targetId=i;function n(s){return s===void 0?t.single:vt(Object.assign(Object.assign({},t),{single:s}))}return e.single=n,e}function gi(t){try{return typeof t[0]=="string"}catch(e){return!1}}function mi(t){if(gi(t))return t[0];throw new Error(`default source id expected datum[0] to be a string but got datum: ${t}`)}function yi(t){try{return typeof t[1]=="string"}catch(e){return!1}}function bi(t){if(yi(t))return t[1];throw new Error(`default target id expected datum[1] to be a string but got datum: ${t}`)}function xe(...t){if(t.length)throw new Error(`got arguments to connect(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as connect()(...)`);return vt({sourceId:mi,targetId:bi,single:!1})}function gt(t){function e(...s){if(!s.length)throw new Error("must pass in at least one node");let o=new Map,a=[];function l(g){let c=o.get(g);return c===void 0&&(c=new at(g),o.set(g,c),a.push(c)),c}let u=s.map(l),h,f=0;for(;h=a.pop();)h.dataChildren=(t.childrenData(h.data,f++)||[]).map(([g,c])=>new pt(l(g),c));let d=new Set(u);for(let g of o.values())for(let c of g.ichildren())if(d.delete(c)&&t.roots)throw new Error(U`node '${g.data}' pointed to a root`);let v=d.size&&d.size!==u.length?[...d]:u;return Lt(v),v.length>1?new K(v):v[0]}function r(s){return s===void 0?t.children:gt({children:s,childrenData:we(s),roots:t.roots})}e.children=r;function i(s){return s===void 0?t.childrenData:gt({children:xi(s),childrenData:s,roots:t.roots})}e.childrenData=i;function n(s){return s===void 0?t.roots:gt(Object.assign(Object.assign({},t),{roots:s}))}return e.roots=n,e}function we(t){function e(r,i){return(t(r,i)||[]).map(n=>[n,void 0])}return e.wrapped=t,e}function xi(t){function e(r,i){return(t(r,i)||[]).map(([n])=>n)}return e.wrapped=t,e}function wi(t){try{let e=t.children;return e===void 0||e instanceof Array}catch(e){return!1}}function _e(t){if(wi(t))return t.children;throw new Error(U`default children function expected datum to have a children field but got: ${t}`)}function mt(...t){if(t.length)throw new Error(`got arguments to hierarchy(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as hierarchy()(...)`);return gt({children:_e,childrenData:we(_e),roots:!0})}function yt(t){function e(s){if(!s.length)throw new Error("can't stratify empty data");let o=new Map;for(let[l,u]of s.entries()){let h=Ft(t.id(u,l)),f=t.parentData(u,l)||[],d=new at(u);if(o.has(h))throw new Error(`found a duplicate id: ${r}`);o.set(h,[d,f])}let a=[];for(let[l,u]of o.values()){for(let[h,f]of u){let d=o.get(h);if(!d)throw new Error(`missing id: ${h}`);let[v]=d;v.dataChildren.push(new pt(l,f))}u.length||a.push(l)}return Lt(a),a.length>1?new K(a):a[0]}function r(s){if(s===void 0)return t.id;{let{id:o}=t,a=ot(t,["id"]);return yt(Object.assign(Object.assign({},a),{id:s}))}}e.id=r;function i(s){if(s===void 0)return t.parentData;{let{parentIds:o,parentData:a}=t,l=ot(t,["parentIds","parentData"]);return yt(Object.assign(Object.assign({},l),{parentIds:_i(s),parentData:s}))}}e.parentData=i;function n(s){if(s===void 0)return t.parentIds;{let{parentIds:o,parentData:a}=t,l=ot(t,["parentIds","parentData"]);return yt(Object.assign(Object.assign({},l),{parentIds:s,parentData:Ie(s)}))}}return e.parentIds=n,e}function Ie(t){function e(r,i){return(t(r,i)||[]).map(n=>[n,void 0])}return e.wrapped=t,e}function _i(t){function e(r,i){return(t(r,i)||[]).map(([n])=>n)}return e.wrapped=t,e}function Ii(t){try{return typeof t.id=="string"}catch(e){return!1}}function ji(t){if(Ii(t))return t.id;throw new Error(U`default id function expected datum to have an id field but got '${t}'`)}function Mi(t){try{let e=t.parentIds;return e===void 0||e instanceof Array&&e.every(r=>typeof r=="string")}catch(e){return!1}}function je(t){if(Mi(t))return t.parentIds;throw new Error(`default parentIds function expected datum to have a parentIds field but got: ${t}`)}function Me(...t){if(t.length)throw new Error(`got arguments to stratify(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as stratify()(...)`);return yt({id:ji,parentIds:je,parentData:Ie(je)})}function Oi(t){if(t.value===void 0)throw new Error(U`node with data '${t.data}' did not get a defined value during layering`);if(t.value<0)throw new Error(U`node with data '${t.data}' got an invalid (negative) value during layering: ${t.value}`);return t.value}function Oe(t){let e=new Map(t.idescendants().map(s=>[s,{node:s,layer:Oi(s)}]));function r(s){let o=s.layer+1,a="node"in s?s.node.children():[s.target],l="node"in s?s.node:s.source;return a.map(u=>{let h=j(e.get(u));if(h.layerj(e.get(s)))),n=[];for(let s of i)(n[s.data.layer]||(n[s.data.layer]=[])).push(s);if(!n[0]||!n[0].length)throw new Error("no nodes were assigned to layer 0");for(let s of n)F(s&&s.length);return n}var Le=rt(Fe());function Ti(t,e,r,i,n){if(!e.length)return[];let s=[[0]],o=[0],a=[[0]],l=[0];for(let f of t){let d=[0];d.push(...f),s.push(d)}o.push(...e),a.push(...e.map(()=>[0]));for(let f of r)for(let[d,v]of f.entries())a[d+1].push(-v);l.push(...i.map(f=>-f));let{solution:u,message:h}=(0,Le.solveQP)(s,o,a,l,n);return F(!h.length),u.shift(),u}function bt(t,e,r,i,n=0){e.pop(),t.pop(),t.forEach(o=>o.pop()),r.forEach(o=>o.pop());let s=Ti(t,e,r,i,n);return s.push(0),s}function Ue(t){return new Map(t.flatMap(e=>e).map((e,r)=>[e,r]))}function xt(t,e,r){let i=1+Math.max(...e.values()),n=[],s=[];for(let l of t)for(let[u,h]of W(l)){let f=j(e.get(u)),d=j(e.get(h)),v=new Array(i).fill(0);v[f]=1,v[d]=-1,n.push(v),s.push(-(r(u)+r(h))/2)}let o=new Array(i).fill(0);return[[...new Array(i)].map(()=>new Array(i).fill(0)),o,n,s]}function Gt(t,e,r,i){t[r][r]+=i,t[r][e]-=i,t[e][r]-=i,t[e][e]+=i}function wt(t,e,r,i,n){t[i][i]+=n,t[i][r]-=2*n,t[i][e]+=n,t[r][i]-=2*n,t[r][r]+=4*n,t[r][e]-=2*n,t[e][i]+=n,t[e][r]-=2*n,t[e][e]+=n}function _t(t,e,r,i){let n=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let o of t){let a=o[0],l=o[o.length-1];n=Math.min(n,i[j(r.get(a))]-e(a)/2),s=Math.max(s,i[j(r.get(l))]+e(l)/2)}for(let o of t)for(let a of o)a.x=i[j(r.get(a))]-n;return s-n}function ki(t){let e=new Map;for(let s of t)for(let o of s)for(let a of o.ichildren()){let l=e.get(a);l?l.push(o):e.set(a,[o])}function*r(s){yield*s.ichildren(),yield*e.get(s)||[]}let i=0,n=new Map;for(let s of t)for(let o of s)if(!n.has(o)){for(let a of st(r,o))n.set(a,i);i++}return n}function Pi(t,e){let r=[],i=[],n=new Set;for(let s of t){let o=new Set(s.map(a=>j(e.get(a))));ye(n,o)||r.push(i=[]),i.push(s),n=o}return r}function It(t){function e(o,a,l){let{vertNode:u,vertDummy:h,curveNode:f,curveDummy:d,comp:v}=t,g=Ue(o),[c,I,y,m]=xt(o,g,a);for(let _ of o)for(let w of _){let x=j(g.get(w)),z="node"in w.data?u:h;for(let M of w.ichildren()){let C=j(g.get(M)),O="node"in M.data?u:h,E="node"in M.data?f:d;Gt(c,x,C,z+O);for(let V of M.ichildren()){let S=j(g.get(V));wt(c,x,C,S,E)}}}for(let _ of o)for(let[w,x]of W(_))j(l.get(w))!==j(l.get(x))&&Gt(c,j(g.get(w)),j(g.get(x)),v);let b=bt(c,I,y,m);return _t(o,a,g,b)}function r(o,a){let{vertNode:l,vertDummy:u,curveNode:h,curveDummy:f}=t;if(l===0&&h===0)throw new Error("node vertical weight or node curve weight needs to be positive");if(u===0&&f===0)throw new Error("dummy vertical weight or dummy curve weight needs to be positive");let d=ki(o),v=Pi(o,d),g=v.map(I=>e(I,a,d)),c=Math.max(...g);if(c<=0)throw new Error("must assign nonzero width to at least one node");for(let[I,y]of v.entries()){let m=(c-g[I])/2;for(let b of y)for(let _ of b)_.x=j(_.x)+m}return c}function i(o){if(o===void 0){let{vertNode:u,vertDummy:h}=t;return[u,h]}let[a,l]=o;if(a<0||l<0)throw new Error(`weights must be non-negative, but were ${a} and ${l}`);return It(Object.assign(Object.assign({},t),{vertNode:a,vertDummy:l}))}r.vertical=i;function n(o){if(o===void 0){let{curveNode:u,curveDummy:h}=t;return[u,h]}let[a,l]=o;if(a<0||l<0)throw new Error(`weights must be non-negative, but were ${a} and ${l}`);return It(Object.assign(Object.assign({},t),{curveNode:a,curveDummy:l}))}r.curve=n;function s(o){if(o===void 0)return t.comp;if(o<=0)throw new Error(`weight must be positive, but was ${o}`);return It(Object.assign(Object.assign({},t),{comp:o}))}return r.component=s,r}function jt(...t){if(t.length)throw new Error(`got arguments to quad(${t}), but constructor takes no aruguments.`);return It({vertNode:1,vertDummy:0,curveNode:0,curveDummy:1,comp:1})}var Cr=rt(At());var ne=window&&window.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n[_,b.toString()]));function u(b){return j(l.get(b))}function h(b){return s[u(b)]}function f(b,_,w,x=!0){let z=h(_),M=h(w),C=`${b}: ${j(u(_))} -> ${j(u(w))}`;a[C]={min:+x},z[C]=-1,M[C]=1}function d(b,_,w){f(`${b} before`,_,w,!1),f(`${b} after`,w,_,!1)}let v=[],g=new Map;for(let b of n){let _=u(b);o[_]=1,s[_]={opt:b.children.length};let w=t.rank(b);w!==void 0&&v.push([w,b]);let x=t.group(b);if(x!==void 0){let z=g.get(x);z?z.push(b):g.set(x,[b])}}for(let b of n.ilinks())f("link",b.source,b.target),++h(b.source).opt,--h(b.target).opt;let c=v.sort(([b],[_])=>b-_);for(let[[b,_],[w,x]]of W(c))be?1:t>=e?0:NaN}function*Er(t,e){if(e===void 0)for(let r of t)r!=null&&(r=+r)>=r&&(yield r);else{let r=-1;for(let i of t)(i=e(i,++r,t))!=null&&(i=+i)>=i&&(yield i)}}function Tt(t,e){let r;if(e===void 0)for(let i of t)i!=null&&(r=i)&&(r=i);else{let i=-1;for(let n of t)(n=e(n,++i,t))!=null&&(r=n)&&(r=n)}return r}function kt(t,e){let r;if(e===void 0)for(let i of t)i!=null&&(r>i||r===void 0&&i>=i)&&(r=i);else{let i=-1;for(let n of t)(n=e(n,++i,t))!=null&&(r>n||r===void 0&&n>=n)&&(r=n)}return r}function Pt(t,e,r=0,i=t.length-1,n=zr){for(;i>r;){if(i-r>600){let l=i-r+1,u=e-r+1,h=Math.log(l),f=.5*Math.exp(2*h/3),d=.5*Math.sqrt(h*f*(l-f)/l)*(u-l/2<0?-1:1),v=Math.max(r,Math.floor(e-u*f/l+d)),g=Math.min(i,Math.floor(e+(l-u)*f/l+d));Pt(t,e,v,g,n)}let s=t[e],o=r,a=i;for(ut(t,r,e),n(t[i],s)>0&&ut(t,r,i);o0;)--a}n(t[r],s)===0?ut(t,r,a):(++a,ut(t,a,i)),a<=e&&(r=a+1),e<=a&&(i=a-1)}return t}function ut(t,e,r){let i=t[e];t[e]=t[r],t[r]=i}function oe(t,e,r){if(t=Float64Array.from(Er(t,r)),!!(i=t.length)){if((e=+e)<=0||i<2)return kt(t);if(e>=1)return Tt(t);var i,n=(i-1)*e,s=Math.floor(n),o=Tt(Pt(t,s).subarray(0,s+1)),a=kt(t.subarray(s+1));return o+(a-o)*(n-s)}}function ae(t,e){return oe(t,.5,e)}var Vr=class{constructor(){this.mean=0,this.count=0}add(e){this.mean+=(e-this.mean)/++this.count}val(){return this.count?this.mean:void 0}},Sr=()=>new Vr,qr=class{constructor(){this.vals=[]}add(e){this.vals.push(e)}val(){return ae(this.vals)}},le=()=>new qr;function tn(t,e){let r=t();for(let i of e)r.add(i);return r.val()}function Ar(t,e){let r=new Map;for(let h of t){let f=e.get(h);if(f===void 0)continue;let d=r.get(f);d===void 0?r.set(f,[h]):d.push(h)}let i=[...r.entries()].sort(([h],[f])=>h-f).flatMap(([,h])=>h),n=new Map(t.map((h,f)=>[h,f])),s=t.filter(h=>e.get(h)===void 0),o=new Array(s.length).fill(null);function a(h,f,d,v){if(f<=h)return;let g=Math.floor((h+f)/2),c=s[g],I=j(n.get(c)),y=0,m=[y];for(let _=d;_[l,t()]));for(let[l,u]of i.entries())for(let h of u.ichildren())j(o.get(h)).add(l);let a=new Map([...o.entries()].map(([l,u])=>[l,u.val()]));Ar(n,a)}else{let o=new Map(n.map((l,u)=>[l,u])),a=new Map(i.map(l=>{let u=tn(t,l.ichildren().map(h=>j(o.get(h))));return[l,u]}));Ar(i,a)}}function r(i){return i===void 0?t:Nr({factory:i})}return e.aggregator=r,e}function Rt(...t){if(t.length)throw new Error(`got arguments to agg(${t}), but constructor takes no aruguments.`);return Nr({factory:le})}var en=window&&window.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);n[f,d]));t.order(l,u,!0),u.some((f,d)=>j(h.get(f))!==d)&&(o=!0)}for(let[l,u]of W(s)){let h=new Map(u.map((f,d)=>[f,d]));t.order(u,l,!1),u.some((f,d)=>j(h.get(f))!==d)&&(o=!0)}}}function r(n){if(n===void 0)return t.order;{let{order:s}=t,o=en(t,["order"]);return he(Object.assign(Object.assign({},o),{order:n}))}}e.order=r;function i(n){if(n===void 0)return t.passes;if(n<=0)throw new Error("number of passes must be positive");return he(Object.assign(Object.assign({},t),{passes:n}))}return e.passes=i,e}function $t(...t){if(t.length)throw new Error(`got arguments to twoLayer(${t}), but constructor takes no aruguments.`);return he({order:Rt(),passes:1})}var ct=window&&window.__rest||function(t,e){var r={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(r[i]=t[i]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var n=0,i=Object.getOwnPropertySymbols(t);nr(s)[0],s=>r(s)[1]]}function et(t){function e(l){t.layering(l);let u=Oe(l),[h,f]=rn(t.sugiNodeSize),d=0;for(let g of u){let c=Math.max(...g.map(f));for(let I of g)I.y=d+c/2;d+=c}if(d<=0)throw new Error("at least one node must have positive height, but total height was zero");t.decross(u);let v=t.coord(u,h);for(let g of u)for(let c of g){if(c.x===void 0)throw new Error(U`coord didn't assign an x to node '${c}'`);if(c.x<0||c.x>v)throw new Error(`coord assgined an x (${c.x}) outside of [0, ${v}]`)}if(t.size!==null){let[g,c]=t.size;for(let I of u)for(let y of I)F(y.x!==void 0&&y.y!==void 0),y.x*=g/v,y.y*=c/d;v=g,d=c}for(let g of u)for(let c of g){if(F(c.x!==void 0&&c.y!==void 0),"target"in c.data)continue;c.data.node.x=c.x,c.data.node.y=c.y;let I=new Map(c.data.node.ichildLinks().map(({points:y,target:m})=>[m,y]));for(let y of c.ichildren()){let m=[{x:c.x,y:c.y}];for(;"target"in y.data;)F(y.x!==void 0&&y.y!==void 0),m.push({x:y.x,y:y.y}),[y]=y.ichildren();F(y.x!==void 0&&y.y!==void 0),m.push({x:y.x,y:y.y});let b=j(I.get(y.data.node));b.splice(0,b.length,...m)}}return{width:v,height:d}}function r(l){if(l===void 0)return t.layering;{let{layering:u}=t,h=ct(t,["layering"]);return et(Object.assign(Object.assign({},h),{layering:l}))}}e.layering=r;function i(l){if(l===void 0)return t.decross;{let{decross:u}=t,h=ct(t,["decross"]);return et(Object.assign(Object.assign({},h),{decross:l}))}}e.decross=i;function n(l){if(l===void 0)return t.coord;{let{coord:u}=t,h=ct(t,["coord"]);return et(Object.assign(Object.assign({},h),{coord:l}))}}e.coord=n;function s(l){return l!==void 0?et(Object.assign(Object.assign({},t),{size:l})):t.size}e.size=s;function o(l){if(l!==void 0){let{nodeSize:u,sugiNodeSize:h}=t,f=ct(t,["nodeSize","sugiNodeSize"]);return et(Object.assign(Object.assign({},f),{nodeSize:l,sugiNodeSize:Tr(l)}))}else return t.nodeSize}e.nodeSize=o;function a(l){if(l!==void 0){let{sugiNodeSize:u,nodeSize:h}=t,f=ct(t,["sugiNodeSize","nodeSize"]);return et(Object.assign(Object.assign({},f),{sugiNodeSize:l,nodeSize:null}))}else return t.sugiNodeSize}return e.sugiNodeSize=a,e}function kr(t){return[+(t!==void 0),1]}function Pr(...t){if(t.length)throw new Error(`got arguments to sugiyama(${t}), but constructor takes no aruguments.`);return et({layering:Nt(),decross:$t(),coord:jt(),size:null,nodeSize:kr,sugiNodeSize:Tr(kr)})}function Rr(...t){if(t.length)throw new Error(`got arguments to topological(${t}), but constructor takes no aruguments.`);function e(r){for(let[i,n]of r.idescendants("before").entries())n.value=i}return e}function $r(t){function e(i){if(t.topDown)i.depth();else{i.height();let n=Math.max(...i.iroots().map(s=>j(s.value)));for(let s of i)s.value=n-j(s.value)}}function r(i){return i===void 0?t.topDown:$r(Object.assign(Object.assign({},t),{topDown:i}))}return e.topDown=r,e}function Dr(...t){if(t.length)throw new Error(`got arguments to longestPath(${t}), but constructor takes no aruguments.`);return $r({topDown:!0})}var Ur=rt(Lr());function Gr(t){function e(i){let n=t.width||Math.floor(Math.sqrt(i.size()+.5)),s=new Map(i.idescendants().map(d=>[d,{before:[],parents:[]}]));for(let d of i)for(let v of d.ichildren())j(s.get(v)).parents.push(d);function o(d,v){let g=j(s.get(d)).before,c=j(s.get(v)).before;for(let[I,y]of g.entries()){let m=c[I];if(m===void 0)return!1;if(yj(d.value)I-c),a.add(d))}l++}}function r(i){if(i===void 0)return t.width;if(i<0)throw new Error(`width must be non-negative: ${i}`);return Gr(Object.assign(Object.assign({},t),{width:i}))}return e.width=r,e}function Wr(...t){if(t.length)throw new Error(`got arguments to coffmanGraham(${t}), but constructor takes no aruguments.`);return Gr({width:0})}var Hr=rt(At());function fe(t){function e(n){let s=n.reduce((m,b)=>m+b.length*Math.max(b.length-1,0)/2,0),o=n.reduce((m,b)=>m+b.reduce((_,w)=>_+w.ichildren().length,0),0);if(t.large!=="large"&&s>1200)throw new Error('size of dag to decrossOpt is too large and will likely crash instead of complete, enable "large" grahps to run anyway');if(t.large!=="large"&&t.large!=="medium"&&(s>400||o>100))throw new Error('size of dag to decrossOpt is too large and will likely not complete, enable "medium" grahps to run anyway');let a=[];for(let[m,b]of W(n)){let _=new Set(m.flatMap(O=>O.children())),w=b.filter(O=>!_.has(O)),x=m.map(O=>O.children()).filter(O=>O.length>1);a.push([w,x]);let z=m.filter(O=>!O.ichildren().length),M=new Map;for(let O of m)for(let E of O.ichildren()){let V=M.get(E);V?V.push(O):M.set(E,[O])}let C=[...M.values()];a.push([z,C])}let l=a.reduce((m,[b,_])=>_.reduce((w,x)=>w+x.length*x.length,0)*b.length,0)/4,u=1/(l+1),h=u/(s+1),f={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},d=new Map;{let m=0;for(let b of n)for(let _ of b)d.set(_,m++)}function v(...m){return m.map(b=>j(d.get(b))).sort((b,_)=>b-_).join(" => ")}function g(m){for(let[b,_]of m.slice(0,m.length-1).entries())for(let w of m.slice(b+1)){let x=v(_,w);f.ints[x]=1,f.constraints[x]={max:1},f.variables[x]={opt:-h,[x]:1}}for(let[b,_]of m.slice(0,m.length-1).entries())for(let[w,x]of m.slice(b+1).entries())for(let z of m.slice(b+w+2)){let M=v(_,x),C=v(_,z),O=v(x,z),E=v(_,x,z),V=E+"+";f.constraints[V]={max:1},f.variables[M][V]=1,f.variables[C][V]=-1,f.variables[O][V]=1;let S=E+"-";f.constraints[S]={min:0},f.variables[M][S]=1,f.variables[C][S]=-1,f.variables[O][S]=1}}function c(m){for(let[b,_]of m.slice(0,m.length-1).entries())for(let w of m.slice(b+1)){let x=v(_,w);for(let z of _.ichildren())for(let M of w.ichildren()){if(z===M)continue;let C=v(z,M),O=`slack (${x}) (${C})`,E=`${O} +`,V=`${O} -`;f.variables[O]={opt:1,[E]:1,[V]:1};let S=Math.sign(j(d.get(z))-j(d.get(M))),N=Math.max(S,0);f.constraints[E]={min:N},f.variables[x][E]=1,f.variables[C][E]=S,f.constraints[V]={min:-N},f.variables[x][V]=-1,f.variables[C][V]=-S}}}function I(m,b){for(let _ of m)for(let w of b)for(let[x,z]of w.entries())for(let M of w.slice(x+1)){let O=`dist ${[z,_,M].map(N=>j(d.get(N))).join(" => ")}`,E=`${O} normal`,V=`${O} reversed`;f.variables[O]={opt:u,[E]:1,[V]:1};let S=0;for(let[N,R]of[[z,_],[z,M],[_,M]]){let q=v(N,R),G=Math.sign(j(d.get(N))-j(d.get(R)));S+=+(G>0),f.variables[q][E]=-G,f.variables[q][V]=G}f.constraints[E]={min:1-S},f.constraints[V]={min:S-2}}}for(let m of n)g(m);for(let m of n.slice(0,n.length-1))c(m);if(t.dist)for(let[m,b]of a)I(m,b);let y=Hr.Solve.call({},f);for(let m of n)m.sort((b,_)=>y[v(b,_)]||-1)}function r(n){return n===void 0?t.large:fe(Object.assign(Object.assign({},t),{large:n}))}e.large=r;function i(n){return n===void 0?t.dist:fe(Object.assign(Object.assign({},t),{dist:n}))}return e.dist=i,e}function Jr(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return fe({large:"small",dist:!1})}function Zr(...t){if(t.length)throw new Error(`got arguments to center(${t}), but constructor takes no aruguments.`);function e(r,i){let n=r.map(o=>{let a=0;for(let l of o){let u=i(l);l.x=a+u/2,a+=u}return a}),s=Math.max(...n);if(s<=0)throw new Error("must assign nonzero width to at least one node");for(let[o,a]of r.entries()){let l=n[o],u=(s-l)/2;for(let h of a)h.x=j(h.x)+u}return s}return e}function Yr(...t){if(t.length)throw new Error(`got arguments to greedy(${t}), but constructor takes no aruguments.`);function e(r,i){let n=sn,s=new Map;for(let f of r)for(let d of f)s.set(d,d.ichildren().length+("node"in d.data?0:-3));for(let f of r)for(let d of f)for(let v of d.ichildren())s.set(v,j(s.get(v))+1);let[o,...a]=r,l=0,u=0;for(let f of o){let d=i(f);f.x=u+d/2,u+=d}for(let f of a){n(o,f);let d=f.map((v,g)=>[g,v]).sort(([v,g],[c,I])=>{let y=j(s.get(g)),m=j(s.get(I));return y===m?v-c:m-y});for(let[v,g]of d){let c=i(g),I=j(g.x)+c/2;for(let m of f.slice(v+1)){let b=i(m)/2;I=(m.x=Math.max(j(m.x),I+b))+b}u=Math.max(u,I);let y=j(g.x)-c/2;for(let m of f.slice(0,v).reverse()){let b=i(m)/2;y=(m.x=Math.min(j(m.x),y-b))-b}l=Math.min(l,y)}o=f}for(let f of r)for(let d of f)d.x=j(d.x)-l;let h=u-l;if(h<=0)throw new Error("must assign nonzero width to at least one node");return h}return e}function sn(t,e){for(let i of e)i.x=0;let r=new Map;for(let i of t){F(i.x!==void 0);for(let n of i.ichildren()){F(n.x!==void 0);let s=(r.get(n)||0)+1;r.set(n,s),n.x+=(i.x-n.x)/s}}}function Xr(...t){if(t.length)throw new Error(`got arguments to topological(${t}), but constructor takes no aruguments.`);function e(r,i){for(let d of r)if(d.reduce((g,c)=>g+ +("node"in c.data),0)!==1)throw new Error("topological() only works with a topological layering");let n=new Map,s=0;for(let d of r)for(let v of d)"target"in v.data&&n.set(v,s++);for(let d of r)for(let v of d)"node"in v.data&&n.set(v,s);let[o,a,l,u]=xt(r,n,i);for(let d of r)for(let v of d){let g=j(n.get(v));for(let c of v.ichildren()){let I=j(n.get(c));if("target"in c.data)for(let y of c.ichildren()){let m=j(n.get(y));wt(o,g,I,m,1)}}}let h=bt(o,a,l,u),f=_t(r,i,n,h);if(f<=0)throw new Error("must assign nonzero width to at least one node");return f}return e}var Kr=rt(At());function ue(t){function e(n,s,o){let a=o?s:n,l=a.length*Math.max(a.length-1,0)/2,u=n.reduce((w,x)=>w+x.ichildren().length,0);if(t.large!=="large"&&l>1200)throw new Error('size of dag to twolayerOpt is too large and will likely crash, enable "large" dags to run anyway');if(t.large!=="large"&&t.large!=="medium"&&(l>400||u>100))throw new Error('size of dag to twolayerOpt is too large and will likely not finish, enable "medium" dags to run anyway');let h={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},f=new Map(a.map((w,x)=>[w,x]));function d(...w){return w.map(x=>j(f.get(x))).sort((x,z)=>x-z).join(" => ")}let v,g;if(o){let w=new Set(n.flatMap(x=>x.children()));v=s.filter(x=>!w.has(x)),g=n.map(x=>x.children()).filter(x=>x.length>1)}else{v=n.filter(x=>!x.ichildren().length);let w=new Map;for(let x of n)for(let z of x.ichildren()){let M=w.get(z);M?M.push(x):w.set(z,[x])}g=[...w.values()]}let I=g.reduce((w,x)=>w+x.length*x.length,0)*v.length/4,y=1/(I+1),m=y/(l+1),b=new Map(s.map((w,x)=>[w,x]));for(let[w,x]of a.slice(0,a.length-1).entries())for(let z of a.slice(w+1)){let M=d(x,z);h.ints[M]=1,h.constraints[M]={max:1},h.variables[M]={opt:-m,[M]:1}}for(let[w,x]of a.slice(0,a.length-1).entries())for(let[z,M]of a.slice(w+1).entries())for(let C of a.slice(w+z+2)){let O=d(x,M),E=d(x,C),V=d(M,C),S=d(x,M,C),N=S+"+";h.constraints[N]={max:1},h.variables[O][N]=1,h.variables[E][N]=-1,h.variables[V][N]=1;let R=S+"-";h.constraints[R]={min:0},h.variables[O][R]=1,h.variables[E][R]=-1,h.variables[V][R]=1}for(let[w,x]of n.slice(0,n.length-1).entries())for(let z of n.slice(w+1))for(let M of x.ichildren())for(let C of z.ichildren()){if(M===C)continue;let O=o?d(M,C):d(x,z);h.variables[O].opt+=Math.sign(j(b.get(M))-j(b.get(C)))}if(t.dist)for(let w of v)for(let x of g)for(let[z,M]of x.entries())for(let C of x.slice(z+1)){let E=`dist ${[M,w,C].map(R=>j(f.get(R))).join(" => ")}`,V=`${E} normal`,S=`${E} reversed`;h.variables[E]={opt:y,[V]:1,[S]:1};let N=0;for(let[R,q]of[[M,w],[M,C],[w,C]]){let G=d(R,q),L=Math.sign(j(f.get(R))-j(f.get(q)));N+=+(L>0),h.variables[G][V]=-L,h.variables[G][S]=L}h.constraints[V]={min:1-N},h.constraints[S]={min:N-2}}let _=Kr.Solve.call({},h);a.sort((w,x)=>_[d(w,x)]||-1)}function r(n){return n===void 0?t.large:ue(Object.assign(Object.assign({},t),{large:n}))}e.large=r;function i(n){return n===void 0?t.dist:ue(Object.assign(Object.assign({},t),{dist:n}))}return e.dist=i,e}function Qr(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return ue({large:"small",dist:!1})}function ti(t,e){let r=t.findIndex(i=>i<=e);return r>=0?r:t.length}function ei(t){let e=new Map(t.map((o,a)=>[o,a])),r=[];for(let[o,a]of t.entries())for(let l of a.ichildren()){let u=j(e.get(l));u>o+1&&r.push([a,o,l,u])}r.sort(([,o,,a],[,l,,u])=>a===u?l-o:a-u);let i=new Map,n=[],s=[];for(let[o,a,l,u]of r){let h=i.get(o);h===void 0&&(h=new Map,i.set(o,h));let f=ti(s,a),d=ti(n,a);fd/2?c.push({x:y,y:m},{x:y,y:b}):c.push({x:y,y:m})}c.push({x:g.x,y:g.y})}}function i(n){if(n===void 0)return[t,e];{let[s,o]=n;return ri(s,o)}}return r.size=i,r}function ii(...t){if(t.length)throw new Error(`got arguments to zherebko(${t}), but constructor takes no aruguments.`);return ri(1,1)}return on;})(); -return d3; })()) \ No newline at end of file diff --git a/static/js/plugins/D3-dag/d3-dag_0.9.0.min.js b/static/js/plugins/D3-dag/d3-dag_0.9.0.min.js deleted file mode 100644 index d0fbbc6b16..0000000000 --- a/static/js/plugins/D3-dag/d3-dag_0.9.0.min.js +++ /dev/null @@ -1,16 +0,0 @@ -// d3-dag Version 0.9.0. Copyright 2021 Erik Brinkman. -var d3 = Object.assign(d3 || {}, (() => { -var d3=(()=>{var Mn=Object.create;var mt=Object.defineProperty;var Cn=Object.getOwnPropertyDescriptor;var En=Object.getOwnPropertyNames;var Bn=Object.getPrototypeOf,Sn=Object.prototype.hasOwnProperty;var Ie=t=>mt(t,"__esModule",{value:!0});var Oe=(t=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(t,{get:(e,r)=>(typeof require!="undefined"?require:e)[r]}):t)(function(t){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+t+'" is not supported')});var P=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),_n=(t,e)=>{for(var r in e)mt(t,r,{get:e[r],enumerable:!0})},Me=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of En(e))!Sn.call(t,i)&&(r||i!=="default")&&mt(t,i,{get:()=>e[i],enumerable:!(n=Cn(e,i))||n.enumerable});return t},it=(t,e)=>Me(Ie(mt(t!=null?Mn(Bn(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),jn=(t=>(e,r)=>t&&t.get(e)||(r=Me(Ie({}),e,1),t&&t.set(e,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var Qt=P((ls,Le)=>{function Fe(t,e,r,n){this.feasible=r,this.evaluation=e,this.bounded=n,this._tableau=t}Le.exports=Fe;Fe.prototype.generateSolutionSet=function(){for(var t={},e=this._tableau,r=e.varIndexByRow,n=e.variablesPerIndex,i=e.matrix,s=e.rhsColumn,o=e.height-1,a=Math.round(1/e.precision),f=1;f<=o;f+=1){var l=r[f],u=n[l];if(!(u===void 0||u.isSlack===!0)){var c=i[f][s];t[u.id]=Math.round((Number.EPSILON+c)*a)/a}}return t}});var We=P((us,Ge)=>{var Ue=Qt();function jt(t,e,r,n,i){Ue.call(this,t,e,r,n),this.iter=i}Ge.exports=jt;jt.prototype=Object.create(Ue.prototype);jt.constructor=jt});var J=P((cs,Je)=>{var Wn=Qt(),Jn=We();function H(t){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=t||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}Je.exports=H;H.prototype.solve=function(){return this.model.getNumberOfIntegerVariables()>0?this.branchAndCut():this.simplex(),this.updateVariableValues(),this.getSolution()};function te(t,e){this.priority=t,this.reducedCosts=new Array(e);for(var r=0;r0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t};H.prototype.density=function(){for(var t=0,e=this.matrix,r=0;r0?new Jn(this,t,this.feasible,this.bounded,this.branchAndCutIterations):new Wn(this,t,this.feasible,this.bounded)}});var Ze=P(()=>{var ht=J();ht.prototype.simplex=function(){return this.bounded=!0,this.phase1(),this.feasible===!0&&this.phase2(),this};ht.prototype.phase1=function(){for(var t=this.model.checkForCycles,e=[],r=this.matrix,n=this.rhsColumn,i=this.width-1,s=this.height-1,o,a=0;;){for(var f=0,l=-this.precision,u=1;u<=s;u++){o=this.unrestrictedVars[this.varIndexByRow[u]]===!0;var c=r[u][n];c0)return this.model.messages.push("Cycle in phase 1"),this.model.messages.push("Start :"+b[0]),this.model.messages.push("Length :"+b[1]),this.feasible=!1,a}this.pivot(f,d),a+=1}};ht.prototype.phase2=function(){for(var t=this.model.checkForCycles,e=[],r=this.matrix,n=this.rhsColumn,i=this.width-1,s=this.height-1,o=this.precision,a=this.optionalObjectives.length,f=null,l=0,u,c;;){var d=r[this.costRowIndex];a>0&&(f=[]);for(var v=0,g=o,h=!1,O=1;O<=i;O++){if(u=d[O],c=this.unrestrictedVars[this.varIndexByCol[O]]===!0,a>0&&-og&&(g=-u,v=O,h=!0);continue}u>g&&(g=u,v=O,h=!1)}if(a>0)for(var x=0;v===0&&f.length>0&&xg&&(g=-u,v=O,h=!0);continue}u>g&&(g=u,v=O,h=!1)}f=m,x+=1}if(v===0)return this.setEvaluation(),this.simplexIters+=1,l;for(var w=0,y=1/0,S=this.varIndexByRow,E=1;E<=s;E++){var B=r[E],C=B[n],j=B[v];if(!(-o0&&o>C&&C>-o){y=0,w=E;break}var z=h?-C/j:C/j;z>o&&y>z&&(y=z,w=E)}}if(y===1/0)return this.evaluation=-1/0,this.bounded=!1,this.unboundedVarIndex=this.varIndexByCol[v],l;if(t){e.push([this.varIndexByRow[w],this.varIndexByCol[v]]);var V=this.checkForCycles(e);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,l}this.pivot(w,v,!0),l+=1}};var ee=[];ht.prototype.pivot=function(t,e){var r=this.matrix,n=r[t][e],i=this.height-1,s=this.width-1,o=this.varIndexByRow[t],a=this.varIndexByCol[e];this.varIndexByRow[t]=a,this.varIndexByCol[e]=o,this.rowByVarIndex[a]=t,this.rowByVarIndex[o]=-1,this.colByVarIndex[a]=-1,this.colByVarIndex[o]=e;for(var f=r[t],l=0,u=0;u<=s;u++)f[u]>=-1e-16&&f[u]<=1e-16?f[u]=0:(f[u]/=n,ee[l]=u,l+=1);f[e]=1/n;for(var c,d,v,g=this.precision,h=0;h<=i;h++)if(h!==t&&!(r[h][e]>=-1e-16&&r[h][e]<=1e-16)){var O=r[h];if(c=O[e],c>=-1e-16&&c<=1e-16)c!==0&&(O[e]=0);else{for(d=0;d=-1e-16&&v<=1e-16?v!==0&&(f[u]=0):O[u]=O[u]-c*v;O[e]=-c/n}}var x=this.optionalObjectives.length;if(x>0)for(var m=0;mt.length-r)break;for(var s=!0,o=1;o{function re(t,e,r,n){this.id=t,this.cost=e,this.index=r,this.value=0,this.priority=n}function Ye(t,e,r,n){re.call(this,t,e,r,n)}Ye.prototype.isInteger=!0;function ne(t,e){re.call(this,t,0,e,0)}ne.prototype.isSlack=!0;function He(t,e){this.variable=t,this.coefficient=e}function Xe(t,e,r){return r===0||r==="required"?null:(e=e||1,r=r||1,t.isMinimization===!1&&(e=-e),t.addVariable(e,"r"+t.relaxationIndex++,!1,!1,r))}function rt(t,e,r,n){this.slack=new ne("s"+r,r),this.index=r,this.model=n,this.rhs=t,this.isUpperBound=e,this.terms=[],this.termsByVarIndex={},this.relaxation=null}rt.prototype.addTerm=function(t,e){var r=e.index,n=this.termsByVarIndex[r];if(n===void 0)n=new He(e,t),this.termsByVarIndex[r]=n,this.terms.push(n),this.isUpperBound===!0&&(t=-t),this.model.updateConstraintCoefficient(this,e,t);else{var i=n.coefficient+t;this.setVariableCoefficient(i,e)}return this};rt.prototype.removeTerm=function(t){return this};rt.prototype.setRightHandSide=function(t){if(t!==this.rhs){var e=t-this.rhs;this.isUpperBound===!0&&(e=-e),this.rhs=t,this.model.updateRightHandSide(this,e)}return this};rt.prototype.setVariableCoefficient=function(t,e){var r=e.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(t,e);else if(t!==n.coefficient){var i=t-n.coefficient;this.isUpperBound===!0&&(i=-i),n.coefficient=t,this.model.updateConstraintCoefficient(this,e,i)}return this};rt.prototype.relax=function(t,e){this.relaxation=Xe(this.model,t,e),this._relax(this.relaxation)};rt.prototype._relax=function(t){t!==null&&(this.isUpperBound?this.setVariableCoefficient(-1,t):this.setVariableCoefficient(1,t))};function ot(t,e){this.upperBound=t,this.lowerBound=e,this.model=t.model,this.rhs=t.rhs,this.relaxation=null}ot.prototype.isEquality=!0;ot.prototype.addTerm=function(t,e){return this.upperBound.addTerm(t,e),this.lowerBound.addTerm(t,e),this};ot.prototype.removeTerm=function(t){return this.upperBound.removeTerm(t),this.lowerBound.removeTerm(t),this};ot.prototype.setRightHandSide=function(t){this.upperBound.setRightHandSide(t),this.lowerBound.setRightHandSide(t),this.rhs=t};ot.prototype.relax=function(t,e){this.relaxation=Xe(this.model,t,e),this.upperBound.relaxation=this.relaxation,this.upperBound._relax(this.relaxation),this.lowerBound.relaxation=this.relaxation,this.lowerBound._relax(this.relaxation)};Ke.exports={Constraint:rt,Variable:re,IntegerVariable:Ye,SlackVariable:ne,Equality:ot,Term:He}});var Qe=P(()=>{var Vt=J(),ie=zt().SlackVariable;Vt.prototype.addCutConstraints=function(t){for(var e=t.length,r=this.height,n=r+e,i=r;i=0?r[o][f]=-u:r[o][f]=u*s/(1-s)}return!0};Vt.prototype.applyMIRCuts=function(){}});var tr=P(()=>{var X=J();X.prototype._putInBase=function(t){var e=this.rowByVarIndex[t];if(e===-1){for(var r=this.colByVarIndex[t],n=1;n0)for(var f=0;f0)for(var o=0;o0)for(var f=0;f{var Zn=J();Zn.prototype.log=function(t,e){console.log("****",t,"****"),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="",i=[" "],s,o,a,f,l,u,c,d,v,g,h,O,x;for(o=1;o5?g+=" ":h+=" ",i[o]=g,n+=h+c;console.log(n);var m,b=this.matrix[this.costRowIndex],I=" ";for(s=1;s0){console.log(" Optional objectives:");for(var y=0;y{var Nt=J();Nt.prototype.copy=function(){var t=new Nt(this.precision);t.width=this.width,t.height=this.height,t.nVars=this.nVars,t.model=this.model,t.variables=this.variables,t.variablesPerIndex=this.variablesPerIndex,t.unrestrictedVars=this.unrestrictedVars,t.lastElementIndex=this.lastElementIndex,t.varIndexByRow=this.varIndexByRow.slice(),t.varIndexByCol=this.varIndexByCol.slice(),t.rowByVarIndex=this.rowByVarIndex.slice(),t.colByVarIndex=this.colByVarIndex.slice(),t.availableIndexes=this.availableIndexes.slice();for(var e=[],r=0;rthis.height;)this.varIndexByRow.pop();var a=t.varIndexByCol;for(r=0;rthis.width;)this.varIndexByCol.pop();for(var f=t.rowByVarIndex,l=t.colByVarIndex,u=0;u0&&this.optionalObjectives.length>0){this.optionalObjectives=[],this.optionalObjectivePerPriority={};for(var c=0;c{var nr=J();function ir(t,e){this.index=t,this.value=e}nr.prototype.getMostFractionalVar=function(){for(var t=0,e=null,r=null,n=.5,i=this.model.integerVariables,s=i.length,o=0;othis.precision){var u=o.cost;t>u&&(t=u,e=a,r=l)}}}return new ir(e,r)}});var or=P(()=>{var se=J();se.prototype.countIntegerValues=function(){for(var t=0,e=1;ethis.precision)return!1}}return!0};se.prototype.computeFractionalVolume=function(t){for(var e=-1,r=1;r{Ze();Qe();tr();er();rr();sr();or();ar.exports=J()});var ae=P(()=>{var lr=J();function ur(t,e,r){this.type=t,this.varIndex=e,this.value=r}function oe(t,e){this.relaxedEvaluation=t,this.cuts=e}function Yn(t,e){return e.relaxedEvaluation-t.relaxedEvaluation}lr.prototype.applyCuts=function(t){if(this.restore(),this.addCutConstraints(t),this.simplex(),this.model.useMIRCuts)for(var e=!0;e;){var r=this.computeFractionalVolume(!0);this.applyMIRCuts(),this.simplex();var n=this.computeFractionalVolume(!0);n>=.9*r&&(e=!1)}};lr.prototype.branchAndCut=function(){var t=[],e=0,r=this.model.tolerance,n=!0,i=1e99;this.model.timeout&&(i=Date.now()+this.model.timeout);for(var s=1/0,o=null,a=[],f=0;f0&&n===!0&&Date.now()0&&ss)){var c=l.cuts;if(this.applyCuts(c),e++,this.feasible!==!1){var d=this.evaluation;if(!(d>s)){if(d===s){for(var v=!0,g=0;ga[g]);g+=1)if(this.optionalObjectives[g].reducedCosts[0]{var Hn=J(),js=ae(),dt=zt(),$t=dt.Constraint,cr=dt.Equality,Xn=dt.Variable,Kn=dt.IntegerVariable,zs=dt.Term;function R(t,e){this.tableau=new Hn(t),this.name=e,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=[]}hr.exports=R;R.prototype.minimize=function(){return this.isMinimization=!0,this};R.prototype.maximize=function(){return this.isMinimization=!1,this};R.prototype._getNewElementIndex=function(){if(this.availableIndexes.length>0)return this.availableIndexes.pop();var t=this.lastElementIndex;return this.lastElementIndex+=1,t};R.prototype._addConstraint=function(t){var e=t.slack;this.tableau.variablesPerIndex[e.index]=e,this.constraints.push(t),this.nConstraints+=1,this.tableauInitialized===!0&&this.tableau.addConstraint(t)};R.prototype.smallerThan=function(t){var e=new $t(t,!0,this.tableau.getNewElementIndex(),this);return this._addConstraint(e),e};R.prototype.greaterThan=function(t){var e=new $t(t,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(e),e};R.prototype.equal=function(t){var e=new $t(t,!0,this.tableau.getNewElementIndex(),this);this._addConstraint(e);var r=new $t(t,!1,this.tableau.getNewElementIndex(),this);return this._addConstraint(r),new cr(e,r)};R.prototype.addVariable=function(t,e,r,n,i){if(typeof i=="string")switch(i){case"required":i=0;break;case"strong":i=1;break;case"medium":i=2;break;case"weak":i=3;break;default:i=0;break}var s=this.tableau.getNewElementIndex();e==null&&(e="v"+s),t==null&&(t=0),i==null&&(i=0);var o;return r?(o=new Kn(e,t,s,i),this.integerVariables.push(o)):o=new Xn(e,t,s,i),this.variables.push(o),this.tableau.variablesPerIndex[s]=o,n&&(this.unrestrictedVariables[s]=!0),this.nVariables+=1,this.tableauInitialized===!0&&this.tableau.addVariable(o),o};R.prototype._removeConstraint=function(t){var e=this.constraints.indexOf(t);if(e===-1){console.warn("[Model.removeConstraint] Constraint not present in model");return}this.constraints.splice(e,1),this.nConstraints-=1,this.tableauInitialized===!0&&this.tableau.removeConstraint(t),t.relaxation&&this.removeVariable(t.relaxation)};R.prototype.removeConstraint=function(t){return t.isEquality?(this._removeConstraint(t.upperBound),this._removeConstraint(t.lowerBound)):this._removeConstraint(t),this};R.prototype.removeVariable=function(t){var e=this.variables.indexOf(t);if(e===-1){console.warn("[Model.removeVariable] Variable not present in model");return}return this.variables.splice(e,1),this.tableauInitialized===!0&&this.tableau.removeVariable(t),this};R.prototype.updateRightHandSide=function(t,e){return this.tableauInitialized===!0&&this.tableau.updateRightHandSide(t,e),this};R.prototype.updateConstraintCoefficient=function(t,e,r){return this.tableauInitialized===!0&&this.tableau.updateConstraintCoefficient(t,e,r),this};R.prototype.setCost=function(t,e){var r=t-e.cost;return this.isMinimization===!1&&(r=-r),e.cost=t,this.tableau.updateCost(e,r),this};R.prototype.loadJson=function(t){this.isMinimization=t.opType!=="max";for(var e=t.variables,r=t.constraints,n={},i={},s=Object.keys(r),o=s.length,a=0;a{pr.CleanObjectiveAttributes=function(t){var e,r,n;if(typeof t.optimize=="string")if(t.constraints[t.optimize]){e=Math.random();for(r in t.variables)t.variables[r][t.optimize]&&(t.variables[r][e]=t.variables[r][t.optimize]);return t.constraints[e]=t.constraints[t.optimize],delete t.constraints[t.optimize],t}else return t;else{for(n in t.optimize)if(t.constraints[n])if(t.constraints[n]==="equal")delete t.optimize[n];else{e=Math.random();for(r in t.variables)t.variables[r][n]&&(t.variables[r][e]=t.variables[r][n]);t.constraints[e]=t.constraints[n],delete t.constraints[n]}return t}}});var qt=P(($s,gr)=>{function Qn(t){var e={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"},i="",s=0,o=null,a="",f="",l="",u=0;typeof t=="string"&&(t=t.split(` -`));for(var c=0;c=",equal:"="},s=new RegExp("[^A-Za-z0-9_[{}/.&#$%~'@^]","gi");if(t.opType){e+=t.opType+":";for(var o in t.variables)t.variables[o][o]=t.variables[o][o]?t.variables[o][o]:1,t.variables[o][t.optimize]&&(e+=" "+t.variables[o][t.optimize]+" "+o.replace(s,"_"))}else e+="max:";e+=`; - -`;for(var a in t.constraints)for(var f in t.constraints[a])if(typeof i[f]!="undefined"){for(var l in t.variables)typeof t.variables[l][a]!="undefined"&&(e+=" "+t.variables[l][a]+" "+l.replace(s,"_"));e+=" "+i[f]+" "+t.constraints[a][f],e+=`; -`}if(t.ints){e+=` - -`;for(var u in t.ints)e+="int "+u.replace(s,"_")+`; -`}if(t.unrestricted){e+=` - -`;for(var c in t.unrestricted)e+="unrestricted "+c.replace(s,"_")+`; -`}return e}gr.exports=function(t){return t.length?Qn(t):ti(t)}});var xr=P(fe=>{fe.reformat=qt();function mr(t){return t=t.replace("\\r\\n",`\r -`),t=t.split(`\r -`),t=t.filter(function(e){var r;return r=new RegExp(" 0$","gi"),!(r.test(e)===!0||(r=new RegExp("\\d$","gi"),r.test(e)===!1))}).map(function(e){return e.split(/\:{0,1} +(?=\d)/)}).reduce(function(e,r,n){return e[r[0]]=r[1],e},{}),t}fe.solve=function(t){return new Promise(function(e,r){typeof window!="undefined"&&r("Function Not Available in Browser");var n=qt()(t);t.external||r("Data for this function must be contained in the 'external' attribute. Not seeing anything there."),t.external.binPath||r("No Executable | Binary path provided in arguments as 'binPath'"),t.external.args||r("No arguments array for cli | bash provided on 'args' attribute"),t.external.tempName||r("No 'tempName' given. This is necessary to produce a staging file for the solver to operate on");var i=Oe("fs");i.writeFile(t.external.tempName,n,function(s,o){if(s)r(s);else{var a=Oe("child_process").execFile;t.external.args.push(t.external.tempName),a(t.external.binPath,t.external.args,function(f,l){if(f)if(f.code===1)e(mr(l));else{var u={"-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"},c={code:f.code,meaning:u[f.code],data:l};r(c)}else e(mr(l))})}})})}});var yr=P((Ps,br)=>{br.exports={lpsolve:xr()}});var le=P((Ts,wr)=>{wr.exports=function(t,e){var r=e.optimize,n=JSON.parse(JSON.stringify(e.optimize)),i=Object.keys(e.optimize),s,o=0,a={},f="",l={},u=[],c,d,v,g,h;for(delete e.optimize,c=0;cl[c].max&&(l[c].max=u[v][c]),u[v][c]{var ei=fr(),ue=dr(),ri=ae(),Pt=zt(),Ir=vr(),ni=Pt.Constraint,ii=Pt.Variable,si=Pt.Numeral,oi=Pt.Term,Tt=yr(),Rt=function(){"use strict";this.Model=ue,this.branchAndCut=ri,this.Constraint=ni,this.Variable=ii,this.Numeral=si,this.Term=oi,this.Tableau=ei,this.lastSolvedModel=null,this.External=Tt,this.Solve=function(t,e,r,n){if(n)for(var i in Ir)t=Ir[i](t);if(!t)throw new Error("Solver requires a model to operate on");if(typeof t.optimize=="object"&&Object.keys(t.optimize>1))return le()(this,t);if(t.external){var s=Object.keys(Tt);if(s=JSON.stringify(s),!t.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:"+s);if(!Tt[t.external.solver])throw new Error("No support (yet) for "+t.external.solver+". Please use one of these instead:"+s);return Tt[t.external.solver].solve(t)}else{t instanceof ue||(t=new ue(e).loadJson(t));var o=t.solve();if(this.lastSolvedModel=t,o.solutionSet=o.generateSolutionSet(),r)return o;var a={};return a.feasible=o.feasible,a.result=o.evaluation,a.bounded=o.bounded,o._tableau.__isIntegral&&(a.isIntegral=!0),Object.keys(o.solutionSet).forEach(function(f){o.solutionSet[f]!==0&&(a[f]=o.solutionSet[f])}),a}},this.ReformatLP=qt(),this.MultiObjective=function(t){return le()(this,t)}};typeof define=="function"?define([],function(){return new Rt}):typeof window=="object"?window.solver=new Rt:typeof self=="object"&&(self.solver=new Rt);Or.exports=new Rt});var _r=P((Fs,Sr)=>{"use strict";var vt=1e-60,Er,Br;do vt+=vt,Er=1+.1*vt,Br=1+.2*vt;while(Er<=1||Br<=1);Sr.exports=vt});var zr=P((Ls,jr)=>{"use strict";function li(t,e,r){let n,i;for(let s=1;s<=r;s+=1){t[s][s]=1/t[s][s],i=-t[s][s];for(let o=1;o{"use strict";function ui(t,e,r,n){let i,s;for(i=1;i<=r;i+=1){s=0;for(let o=1;o{"use strict";function ci(t,e,r,n){let i,s,o;for(let a=1;a<=r;a+=1){if(n[1]=a,o=0,i=a-1,i<1){if(o=t[a][a]-o,o<=0)break;t[a][a]=Math.sqrt(o)}else{for(let f=1;f<=i;f+=1){s=t[f][a];for(let l=1;l{"use strict";var he=_r(),hi=zr(),di=Nr(),pi=qr();function vi(t,e,r,n,i,s,o,a,f,l,u,c,d,v=0,g,h,O){let x,m,b,I,w,y,S,E,B,C,j,z,V,q,A=Math.min(n,u),N=2*n+A*(A+5)/2+2*u+1;for(let p=1;p<=n;p+=1)h[p]=e[p];for(let p=n+1;p<=N;p+=1)h[p]=0;for(let p=1;p<=u;p+=1)d[p]=0,s[p]=0;let U=[];if(O[1]===0){if(pi(t,r,n,U),U[1]!==0){O[1]=2;return}di(t,r,n,e),hi(t,r,n)}else{for(let p=1;p<=n;p+=1){i[p]=0;for(let _=1;_<=p;_+=1)i[p]+=t[_][p]*e[_]}for(let p=1;p<=n;p+=1){e[p]=0;for(let _=p;_<=n;_+=1)e[p]+=t[p][_]*i[_]}}o[1]=0;for(let p=1;p<=n;p+=1){i[p]=e[p],o[1]+=h[p]*i[p],h[p]=0;for(let _=p+1;_<=n;_+=1)t[_][p]=0}o[1]=-o[1]/2,O[1]=0;let L=n,W=L+n,D=W+A,et=D+A+1,K=et+A*(A+1)/2,Zt=K+u;for(let p=1;p<=u;p+=1){y=0;for(let _=1;_<=n;_+=1)y+=a[_][p]*a[_][p];h[Zt+p]=Math.sqrt(y)}I=v,g[1]=0,g[2]=0;function yn(){g[1]+=1,N=K;for(let p=1;p<=u;p+=1){N+=1,y=-f[p];for(let _=1;_<=n;_+=1)y+=a[_][p]*i[_];if(Math.abs(y)c)h[N]=y;else if(h[N]=-Math.abs(y),y>0){for(let _=1;_<=n;_+=1)a[_][p]=-a[_][p];f[p]=-f[p]}}for(let p=1;p<=I;p+=1)h[K+d[p]]=0;b=0,w=0;for(let p=1;p<=u;p+=1)h[K+p]=1;p-=1){y=h[p],N=et+p*(p+3)/2,x=N-p;for(let _=p+1;_<=I;_+=1)y-=h[N]*h[W+_],N+=_;y/=h[x],h[W+p]=y,!(d[p]<=c)&&(y<=0||(z=!1,m=p))}if(!z){S=h[D+m]/h[W+m];for(let p=1;p<=I;p+=1)d[p]<=c||h[W+p]<=0||(w=h[D+p]/h[W+p],w=I+1;p-=1)if(h[p]!==0&&(B=Math.max(Math.abs(h[p-1]),Math.abs(h[p])),C=Math.min(Math.abs(h[p-1]),Math.abs(h[p])),h[p-1]>=0?w=Math.abs(B*Math.sqrt(1+C*C/(B*B))):w=-Math.abs(B*Math.sqrt(1+C*C/(B*B))),B=h[p-1]/w,C=h[p]/w,B!==1))if(B===0){h[p-1]=C*w;for(let _=1;_<=n;_+=1)w=t[_][p-1],t[_][p-1]=t[_][p],t[_][p]=w}else{h[p-1]=w,j=C/(1+B);for(let _=1;_<=n;_+=1)w=B*t[_][p-1]+C*t[_][p],t[_][p]=j*(t[_][p-1]+w)-t[_][p],t[_][p-1]=w}h[N]=h[I]}}else{y=-f[b];for(let p=1;p<=n;p+=1)y+=i[p]*a[p][b];if(b>c)h[K+b]=y;else if(h[K+b]=-Math.abs(y),y>0){for(let p=1;p<=n;p+=1)a[p][b]=-a[p][b];f[b]=-f[b]}return 700}return 0}function In(){if(N=et+m*(m+1)/2+1,x=N+m,h[x]===0||(B=Math.max(Math.abs(h[x-1]),Math.abs(h[x])),C=Math.min(Math.abs(h[x-1]),Math.abs(h[x])),h[x-1]>=0?w=Math.abs(B*Math.sqrt(1+C*C/(B*B))):w=-Math.abs(B*Math.sqrt(1+C*C/(B*B))),B=h[x-1]/w,C=h[x]/w,B===1))return 798;if(B===0){for(let p=m+1;p<=I;p+=1)w=h[x-1],h[x-1]=h[x],h[x]=w,x+=p;for(let p=1;p<=n;p+=1)w=t[p][m],t[p][m]=t[p][m+1],t[p][m+1]=w}else{j=C/(1+B);for(let p=m+1;p<=I;p+=1)w=B*h[x-1]+C*h[x],h[x]=j*(h[x-1]+w)-h[x],h[x-1]=w,x+=p;for(let p=1;p<=n;p+=1)w=B*t[p][m]+C*t[p][m+1],t[p][m+1]=j*(t[p][m]+w)-t[p][m+1],t[p][m]=w}return 0}function On(){x=N-m;for(let p=1;p<=m;p+=1)h[x]=h[N],N+=1,x+=1;return h[D+m]=h[D+m+1],d[m]=d[m+1],m+=1,m{"use strict";var gi=Tr();function mi(t,e,r,n=[],i=0,s=[0,0]){let o=[],a=[],f=[],l=[],u=[],c=[],d="",v=t.length-1,g=r[1].length-1;if(!n)for(let x=1;x<=g;x+=1)n[x]=0;if(v!==t[1].length-1&&(d="Dmat is not symmetric!"),v!==e.length-1&&(d="Dmat and dvec are incompatible!"),v!==r.length-1&&(d="Amat and dvec are incompatible!"),g!==n.length-1&&(d="Amat and bvec are incompatible!"),(i>g||i<0)&&(d="Value of meq is invalid!"),d!=="")return{message:d};for(let x=1;x<=g;x+=1)a[x]=0,l[x]=0;let h=0,O=Math.min(v,g);for(let x=1;x<=v;x+=1)f[x]=0;o[1]=0;for(let x=1;x<=2*v+O*(O+5)/2+2*g+1;x+=1)u[x]=0;for(let x=1;x<=2;x+=1)c[x]=0;return gi(t,e,v,v,f,l,o,r,n,v,g,i,a,h,c,u,s),s[1]===1&&(d="constraints are inconsistent, no solution!"),s[1]===2&&(d="matrix D in quadratic function is not positive definite!"),{solution:f,Lagrangian:l,value:o,unconstrained_solution:e,iterations:c,iact:a,message:d}}Rr.solveQP=mi});var kr=P((Zs,Dr)=>{"use strict";Dr.exports=Ar()});var fn=P((No,an)=>{"use strict";var Ei=function(t,e){return t0&&(r=e-1>>1,n=this.array[r],!!this.compare(t,n));)this.array[e]=n,e=r;this.array[e]=t};k.prototype.heapify=function(t){this.array=t,this.size=t.length;var e;for(e=this.size>>1;e>=0;e--)this._percolateDown(e)};k.prototype._percolateUp=function(t,e){for(var r=this.array[t],n,i;t>0&&(n=t-1>>1,i=this.array[n],!(!e&&!this.compare(r,i)));)this.array[t]=i,t=n;this.array[t]=r};k.prototype._percolateDown=function(t){for(var e=this.size,r=this.size>>>1,n=this.array[t],i,s,o;tthis.size-1||t<0))return this._percolateUp(t,!0),this.poll()};k.prototype.remove=function(t){for(var e=0;e1?(this.array[0]=this.array[--this.size],this._percolateDown(0)):this.size-=1,t}};k.prototype.replaceTop=function(t){if(this.size!=0){var e=this.array[0];return this.array[0]=t,this._percolateDown(0),e}};k.prototype.trim=function(){this.array=this.array.slice(0,this.size)};k.prototype.isEmpty=function(){return this.size===0};k.prototype.forEach=function(t){if(!(this.isEmpty()||typeof t!="function"))for(var e=0,r=this.clone();!r.isEmpty();)t(r.poll(),e++)};k.prototype.kSmallest=function(t){if(this.size==0)return[];t=Math.min(this.size,t);var e=new k(this.compare);let r=Math.min((t>0?Math.pow(2,t-1):0)+1,this.size);e.size=r,e.array=this.array.slice(0,r);for(var n=new Array(t),i=0;iGr,aggMedianFactory:()=>pe,coordCenter:()=>en,coordGreedy:()=>rn,coordQuad:()=>Ut,coordTopological:()=>nn,dagConnect:()=>ze,dagHierarchy:()=>It,dagStratify:()=>Pe,decrossOpt:()=>on,decrossTwoLayer:()=>Wt,grid:()=>ke,laneGreedy:()=>St,laneOpt:()=>Cr,layeringCoffmanGraham:()=>cn,layeringLongestPath:()=>dn,layeringSimplex:()=>Jt,layeringTopological:()=>pn,sugiyama:()=>tn,twolayerAgg:()=>Gt,twolayerOpt:()=>gn,zherebko:()=>bn});function*Z(t){let e=0;for(let r of t)yield[e++,r]}function*Ce(t,e){for(let[r,n]of Z(t))yield*e(n,r)}function xt(t,e,r){let n=e,i=r;for(let[s,o]of Z(t))i=n(i,o,s);return i}function*T(t,e){for(let[r,n]of Z(t))yield e(n,r)}function Ee(t,e){for(let[r,n]of Z(t))if(!e(n,r))return!1;return!0}function*Be(t){for(let e=t.length;e!=0;)yield t[--e]}function Y(t){return xt(t,e=>e+1,0)}function M(t){if(t!==void 0)return t;throw new Error("internal error: got unexpected undefined value")}function $(t){if(!t)throw new Error("internal error: failed assert")}function Se(t,e){if(e.size!==t.size)return!1;for(let r of t)if(!e.has(r))return!1;return!0}function _e(t,e){e.size{if(typeof r=="object"&&r!==null){if(t.has(r))return"[circular]";t.add(r)}return r}}function F(t,...e){let[r,...n]=t;return[r].concat(...n.map((i,s)=>[JSON.stringify(e[s],zn()),i])).join("")}function*G(t){let[e,...r]=t;for(let n of r)yield[e,n],e=n}function*at(t,...e){let r=new Set,n;for(;n=e.pop();)r.has(n)||(yield n,r.add(n),e.push(...t(n)))}var ft=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ie[Symbol.iterator]()}}roots(){return[...this.iroots()]}*idepth(){yield*at(r=>r.ichildren(),...this.iroots())}*ibreadth(){let e=new Set,r=this.roots(),n=[];do{n=r.reverse(),r=[];let i;for(;i=n.pop();)e.has(i)||(e.add(i),yield i,r.push(...i.ichildren()))}while(r.length)}*ibefore(){let e=new Map;for(let i of this)for(let s of i.ichildren())e.set(s,(e.get(s)||0)+1);let r=this.roots(),n;for(;n=r.pop();){yield n;for(let i of n.ichildren()){let s=M(e.get(i));s>1?e.set(i,s-1):r.push(i)}}}*iafter(){let e=this.roots(),r=new Set,n;for(;n=e.pop();)r.has(n)||(Ee(n.ichildren(),i=>r.has(i))?(r.add(n),yield n):(e.push(n),e.push(...n.ichildren())))}idescendants(e="depth"){if(e==="depth")return this.idepth();if(e==="breadth")return this.ibreadth();if(e==="before")return this.ibefore();if(e==="after")return this.iafter();throw new Error(`unknown iteration style: ${e}`)}descendants(e="depth"){return[...this.idescendants(e)]}ilinks(){return Ce(this.idescendants(),e=>e.ichildLinks())}links(){return[...this.ilinks()]}size(){return xt(this.idescendants(),e=>e+1,0)}sum(e){let r=new Map;for(let[n,i]of Z(this.idescendants("after"))){let s=e(i,n),o=new Map;o.set(i,s);for(let a of i.ichildren()){let f=M(r.get(a));for(let[l,u]of f.entries())o.set(l,u)}i.value=xt(o.values(),(a,f)=>a+f,0),r.set(i,o)}return this}count(){let e=new Map;for(let r of this.idescendants("after"))if(r.ichildren()[Symbol.iterator]().next().done)e.set(r,new Set([r])),r.value=1;else{let n=new Set;for(let i of r.ichildren()){let s=M(e.get(i));for(let o of s)n.add(o)}e.set(r,n),r.value=n.size}return this}height(){for(let e of this.idescendants("after"))e.value=Math.max(0,...T(e.ichildren(),r=>M(r.value)+1));return this}depth(){let e=new Map;for(let r of this)for(let n of r.ichildren()){let i=e.get(n);i?i.push(r):e.set(n,[r])}for(let r of this.idescendants("before"))r.value=Math.max(0,...T(e.get(r)||[],n=>M(n.value)+1));return this}*isplit(){let e=new Map;for(let i of this)for(let s of i.ichildren()){let o=e.get(s);o?o.push(i):e.set(s,[i])}function*r(i){yield*i.ichildren(),yield*e.get(i)||[]}let n=new Set(this.iroots());for(let i of this.iroots()){if(!n.delete(i))continue;let s=[i];for(let o of at(r,i))n.delete(o)&&s.push(o);yield s.length>1?new Q(s):s[0]}}split(){return[...this.isplit()]}connected(){let e=this.isplit()[Symbol.iterator](),{done:r}=e.next();return $(!r),{done:r}=e.next(),!!r}},lt=class extends Q{constructor(e){super();this.data=e,this.dataChildren=[]}iroots(){let e=[this];return{[Symbol.iterator]:()=>e[Symbol.iterator]()}}*ichildren(){for(let{child:e}of this.dataChildren)yield e}children(){return[...this.ichildren()]}*ichildLinks(){for(let{child:e,data:r,points:n}of this.dataChildren)yield new je(this,e,r,n)}childLinks(){return[...this.ichildLinks()]}isplit(){return this.iroots()}split(){return this.roots()}connected(){return!0}};function Yt(t){if(typeof t!="string")throw new Error(`id is supposed to be string but got type ${typeof t}`);return t}function Ht(t){if(!t.length)throw new Error("dag contained no roots; this often indicates a cycle");for(let s of new Q(t))if(new Set(s.ichildren()).size!==Y(s.ichildren()))throw new Error(F`node '${s.data}' contained duplicate children`);let e=new Set,r=new Set,n=null;function i(s){if(e.has(s))return[];if(r.has(s))return n=s,[s];{r.add(s);let o=[];for(let a of s.ichildren())if(o=i(a),o.length)break;return r.delete(s),e.add(s),o.length&&n!==null&&o.push(s),n===s&&(n=null),o}}for(let s of t){let o=i(s);if(o.length){let a=o.reverse().map(({data:f})=>F`'${f}'`).join(" -> ");throw new Error(`dag contained a cycle: ${a}`)}}}function yt(t){function e(s){if(!s.length)throw new Error("can't connect empty data");let o=new Map,a=new Set;for(let[l,u]of s.entries()){let c=Yt(t.sourceId(u,l)),d=o.get(c);d===void 0&&(d=new lt({id:c}),o.set(c,d));let v=Yt(t.targetId(u,l)),g=o.get(v);g===void 0&&(g=new lt({id:v}),o.set(v,g)),(c!==v||!t.single)&&(d.dataChildren.push(new bt(g,u)),a.add(v))}let f=[];for(let[l,u]of o.entries())a.has(l)||f.push(u);return Ht(f),f.length>1?new Q(f):f[0]}function r(s){if(s===void 0)return t.sourceId;{let{sourceId:o}=t,a=ft(t,["sourceId"]);return yt(Object.assign(Object.assign({},a),{sourceId:s}))}}e.sourceId=r;function n(s){if(s===void 0)return t.targetId;{let{targetId:o}=t,a=ft(t,["targetId"]);return yt(Object.assign(Object.assign({},a),{targetId:s}))}}e.targetId=n;function i(s){return s===void 0?t.single:yt(Object.assign(Object.assign({},t),{single:s}))}return e.single=i,e}function Vn(t){try{return typeof t[0]=="string"}catch(e){return!1}}function Nn(t){if(Vn(t))return t[0];throw new Error(`default source id expected datum[0] to be a string but got datum: ${t}`)}function $n(t){try{return typeof t[1]=="string"}catch(e){return!1}}function qn(t){if($n(t))return t[1];throw new Error(`default target id expected datum[1] to be a string but got datum: ${t}`)}function ze(...t){if(t.length)throw new Error(`got arguments to connect(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as connect()(...)`);return yt({sourceId:Nn,targetId:qn,single:!1})}function wt(t){function e(...s){if(!s.length)throw new Error("must pass in at least one node");let o=new Map,a=[];function f(g){let h=o.get(g);return h===void 0&&(h=new lt(g),o.set(g,h),a.push(h)),h}let l=s.map(f),u,c=0;for(;u=a.pop();)u.dataChildren=(t.childrenData(u.data,c++)||[]).map(([g,h])=>new bt(f(g),h));let d=new Set(l);for(let g of o.values())for(let h of g.ichildren())if(d.delete(h)&&t.roots)throw new Error(F`node '${g.data}' pointed to a root`);let v=d.size&&d.size!==l.length?[...d]:l;return Ht(v),v.length>1?new Q(v):v[0]}function r(s){return s===void 0?t.children:wt({children:s,childrenData:Ve(s),roots:t.roots})}e.children=r;function n(s){return s===void 0?t.childrenData:wt({children:Pn(s),childrenData:s,roots:t.roots})}e.childrenData=n;function i(s){return s===void 0?t.roots:wt(Object.assign(Object.assign({},t),{roots:s}))}return e.roots=i,e}function Ve(t){function e(r,n){return(t(r,n)||[]).map(i=>[i,void 0])}return e.wrapped=t,e}function Pn(t){function e(r,n){return(t(r,n)||[]).map(([i])=>i)}return e.wrapped=t,e}function Tn(t){try{let e=t.children;return e===void 0||e instanceof Array}catch(e){return!1}}function Ne(t){if(Tn(t))return t.children;throw new Error(F`default children function expected datum to have a children field but got: ${t}`)}function It(...t){if(t.length)throw new Error(`got arguments to hierarchy(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as hierarchy()(...)`);return wt({children:Ne,childrenData:Ve(Ne),roots:!0})}function Ot(t){function e(s){if(!s.length)throw new Error("can't stratify empty data");let o=new Map;for(let[f,l]of s.entries()){let u=Yt(t.id(l,f)),c=t.parentData(l,f)||[],d=new lt(l);if(o.has(u))throw new Error(`found a duplicate id: ${r}`);o.set(u,[d,c])}let a=[];for(let[f,l]of o.values()){for(let[u,c]of l){let d=o.get(u);if(!d)throw new Error(`missing id: ${u}`);let[v]=d;v.dataChildren.push(new bt(f,c))}l.length||a.push(f)}return Ht(a),a.length>1?new Q(a):a[0]}function r(s){if(s===void 0)return t.id;{let{id:o}=t,a=ft(t,["id"]);return Ot(Object.assign(Object.assign({},a),{id:s}))}}e.id=r;function n(s){if(s===void 0)return t.parentData;{let{parentIds:o,parentData:a}=t,f=ft(t,["parentIds","parentData"]);return Ot(Object.assign(Object.assign({},f),{parentIds:Rn(s),parentData:s}))}}e.parentData=n;function i(s){if(s===void 0)return t.parentIds;{let{parentIds:o,parentData:a}=t,f=ft(t,["parentIds","parentData"]);return Ot(Object.assign(Object.assign({},f),{parentIds:s,parentData:$e(s)}))}}return e.parentIds=i,e}function $e(t){function e(r,n){return(t(r,n)||[]).map(i=>[i,void 0])}return e.wrapped=t,e}function Rn(t){function e(r,n){return(t(r,n)||[]).map(([i])=>i)}return e.wrapped=t,e}function An(t){try{return typeof t.id=="string"}catch(e){return!1}}function Dn(t){if(An(t))return t.id;throw new Error(F`default id function expected datum to have an id field but got '${t}'`)}function kn(t){try{let e=t.parentIds;return e===void 0||e instanceof Array&&e.every(r=>typeof r=="string")}catch(e){return!1}}function qe(t){if(kn(t))return t.parentIds;throw new Error(`default parentIds function expected datum to have a parentIds field but got: ${t}`)}function Pe(...t){if(t.length)throw new Error(`got arguments to stratify(${t}), but constructor takes no aruguments. These were probably meant as data which should be called as stratify()(...)`);return Ot({id:Dn,parentIds:qe,parentData:$e(qe)})}function tt(t,e){return t==null||e==null?NaN:te?1:t>=e?0:NaN}function*Te(t,e){if(e===void 0)for(let r of t)r!=null&&(r=+r)>=r&&(yield r);else{let r=-1;for(let n of t)(n=e(n,++r,t))!=null&&(n=+n)>=n&&(yield n)}}function Re(t=tt){if(t===tt)return Xt;if(typeof t!="function")throw new TypeError("compare is not a function");return(e,r)=>{let n=t(e,r);return n||n===0?n:(t(r,r)===0)-(t(e,e)===0)}}function Xt(t,e){return(t==null||!(t>=t))-(e==null||!(e>=e))||(te?1:0)}function Mt(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r=n)&&(r=n);else{let n=-1;for(let i of t)(i=e(i,++n,t))!=null&&(r=i)&&(r=i)}return r}function Ct(t,e){let r;if(e===void 0)for(let n of t)n!=null&&(r>n||r===void 0&&n>=n)&&(r=n);else{let n=-1;for(let i of t)(i=e(i,++n,t))!=null&&(r>i||r===void 0&&i>=i)&&(r=i)}return r}function Et(t,e,r=0,n=t.length-1,i){for(i=i===void 0?Xt:Re(i);n>r;){if(n-r>600){let f=n-r+1,l=e-r+1,u=Math.log(f),c=.5*Math.exp(2*u/3),d=.5*Math.sqrt(u*c*(f-c)/f)*(l-f/2<0?-1:1),v=Math.max(r,Math.floor(e-l*c/f+d)),g=Math.min(n,Math.floor(e+(f-l)*c/f+d));Et(t,e,v,g,i)}let s=t[e],o=r,a=n;for(ut(t,r,e),i(t[n],s)>0&&ut(t,r,n);o0;)--a}i(t[r],s)===0?ut(t,r,a):(++a,ut(t,a,n)),a<=e&&(r=a+1),e<=a&&(n=a-1)}return t}function ut(t,e,r){let n=t[e];t[e]=t[r],t[r]=n}function Kt(t,e,r){if(t=Float64Array.from(Te(t,r)),!!(n=t.length)){if((e=+e)<=0||n<2)return Ct(t);if(e>=1)return Mt(t);var n,i=(n-1)*e,s=Math.floor(i),o=Mt(Et(t,s).subarray(0,s+1)),a=Ct(t.subarray(s+1));return o+(a-o)*(i-s)}}function st(t,e){return Kt(t,.5,e)}function ct(t,e=tt){let r,n=!1;if(e.length===1){let i;for(let s of t){let o=e(s);(n?tt(o,i)<0:tt(o,o)===0)&&(r=s,i=o,n=!0)}}else for(let i of t)(n?e(i,r)<0:e(i,i)===0)&&(r=i,n=!0);return r}var Ae=class{constructor(e){this.uncompressed=e,this.indices=[]}getIndex(e,r){var n;let i=[];for(let[a,f]of this.indices.entries())f<=e&&i.push(a);this.uncompressed&&i.push(this.indices.length);let s=r!=null?r:0,o=(n=ct(i,a=>[Math.abs(s-a),a]))!==null&&n!==void 0?n:this.indices.length;return this.setIndex(o,e),o}setIndex(e,r){this.indices[e]=r}offset(){return 0}},De=class{constructor(e){this.uncompressed=e,this.posIndices=[0],this.negIndices=[]}nextNeg(){return-this.negIndices.length-1}nextPos(){return this.posIndices.length}getIndex(e,r){var n;let i=[];for(let[f,l]of this.negIndices.entries())l<=e&&i.push(-f-1);for(let[f,l]of this.posIndices.entries())l<=e&&i.push(f);this.uncompressed&&(i.push(this.nextNeg()),i.push(this.nextPos()));let s=r!=null?r:0,o=this.negIndices.length[Math.abs(s-f),Math.abs(f),-f]))!==null&&n!==void 0?n:o;return this.setIndex(a,e),a}setIndex(e,r){e<0?this.negIndices[-e-1]=r:this.posIndices[e]=r}offset(){return this.negIndices.length}};function Fn(t,e){return e?new De(!t):new Ae(!t)}function Ln(t,e){for(let n of t)n.x=void 0;for(let n of t){$(n.y!==void 0),n.x===void 0&&(n.x=e.getIndex(n.y));for(let[i,s]of[...T(n.ichildren(),o=>[o,M(o.y)])].sort(([,o],[,a])=>a-o))i.x===void 0&&(i.x=e.getIndex(n.y,n.x),e.setIndex(i.x,s))}let r=e.offset();for(let n of t)$(n.x!==void 0),n.x+=r}function Un(t,e){var r;let n=new Map;for(let s of t){s.x=void 0,$(s.y!==void 0);for(let o of s.ichildren()){let a=n.get(o);(a===void 0||s.yf.x));s.x=e.getIndex(t.length-M(s.y),a)}let o=n.get(s);o!==void 0&&((r=o.x)!==null&&r!==void 0||(o.x=s.x),e.setIndex(s.x,t.length-M(o.y)))}let i=e.offset();for(let s of t)$(s.x!=null),s.x+=i}function Bt(t,e,r){function n(a){let f=Fn(e,r);t?Ln(a,f):Un(a,f)}function i(a){return a===void 0?t:Bt(a,e,r)}n.topDown=i;function s(a){return a===void 0?e:Bt(t,a,r)}n.compressed=s;function o(a){return a===void 0?r:Bt(t,e,a)}return n.bidirectional=o,n}function St(...t){if(t.length)throw new Error(`got arguments to greedy(${t}), but constructor takes no aruguments.`);return Bt(!0,!0,!1)}function Gn(t){for(let n of t){if(n.x===void 0)throw new Error(F`coord didn't assign an x to node '${n}'`);if(n.x<0)throw new Error(`coord assgined an x (${n.x}) less than 0`)}let e=new Set(t.map(n=>n.x));if(!Se(e,new Set(T(e,(n,i)=>i)))){let n=[...e].join(", ");throw new Error(`didn't assign increasing positive integers for x coordinates: ${n}`)}let r=new Map;for(let[n,i]of t.entries()){let s=r.get(i);if(s!==void 0){for(let o of t.slice(s+1,n))if(o.x===i.x)throw new Error(F`node ${o} was assigned an overlapping lane with ${i}`)}for(let o of i.ichildren())r.has(o)||r.set(o,n)}return e.size}function _t(t,e,r,n){function i(f){let l=[...f.idescendants("before")];for(let[v,g]of l.entries())g.y=v;t(l);let u=Gn(l);for(let v of l)v.x=(M(v.x)+.5)*e,v.y=(M(v.y)+.5)*r;let c=u*e,d=l.length*r;if(n!==null){let[v,g]=n;for(let h of l)$(h.x!==void 0&&h.y!==void 0),h.x*=v/c,h.y*=g/d;c=v,d=g}for(let{source:v,target:g,points:h}of f.ilinks())h.length=0,$(v.x!==void 0&&v.y!==void 0),$(g.x!==void 0&&g.y!==void 0),v.x!=g.x&&h.push({x:v.x,y:v.y}),h.push({x:g.x,y:v.y}),h.push({x:g.x,y:g.y});return{width:c,height:d}}function s(f){return f===void 0?t:_t(f,e,r,n)}i.lane=s;function o(f){if(f===void 0)return[e,r];{let[l,u]=f;return _t(t,l,u,n)}}i.nodeSize=o;function a(f){if(f!==void 0)return _t(t,e,r,f);if(n===null)return null;{let[l,u]=n;return[l,u]}}return i.size=a,i}function ke(...t){if(t.length)throw new Error(`got arguments to grid(${t}), but constructor takes no aruguments.`);return _t(St(),1,1,null)}var Mr=it(pt());var ai=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ia<=i),o=s===-1?e.length:s;e[o]=i}for(let[s,o]of[...T(n.ichildren(),a=>[a,M(a.y)])].sort(([,a],[,f])=>f-a))if(!r.has(s)){let a=e.findIndex(l=>l<=i),f=a===-1?e.length:a;e[f]=o,r.add(s)}}return e.length}function ce(t,e){function r(s){var o,a,f;let l={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},u=new Map(T(s,(O,x)=>[O,x])),c=t?fi(s):s.length-1;for(let O of s.keys())l.variables[O]={opt:0,[O]:1},l.constraints[O]={max:c-1};let d=new Map;for(let[O,x]of s.entries()){let m=d.get(x);if(m!==void 0)for(let[b,I]of s.slice(m+1,O).entries()){let w=b+m+1,y=`${O}-${w}-above`;l.variables[y]={opt:0,[y]:1},l.constraints[y]={max:1},l.ints[y]=1;let S=`${y}-span`;l.variables[O][S]=1,l.variables[w][S]=-1,l.variables[y][S]=-c,l.constraints[S]={min:1-c,max:-1};for(let E of I.ichildren()){if(E===x)continue;let B=M(u.get(E)),C=`${y}-${B}-cross`;l.variables[C]={opt:1,[C]:1},l.constraints[C]={max:1},l.ints[C]=1;let j=`${C}-left`;l.variables[O][j]=-1,l.variables[B][j]=1,l.variables[y][j]=c,l.variables[C][j]=-c,l.constraints[j]={max:c};let z=`${C}-right`;l.variables[O][z]=-1,l.variables[B][z]=1,l.variables[y][z]=c,l.variables[C][z]=c,l.constraints[z]={min:0}}}for(let b of x.ichildren())d.has(b)||d.set(b,O)}if(e){let O=s.reduce((x,m)=>x+m.children().length,0);for(let[x,m]of s.entries())for(let b of m.ichildren()){let I=M(u.get(b)),w=`${x}-${I}-dist`;l.variables[w]={opt:1/O};let y=`${w}-upper`;l.variables[x][y]=1,l.variables[I][y]=-1,l.variables[w][y]=-c,l.constraints[y]={max:0};let S=`${w}-lower`;l.variables[x][S]=1,l.variables[I][S]=-1,l.variables[w][S]=c,l.constraints[S]={min:0}}}let v=Mr.Solve.call({},l),{feasible:g}=v,h=ai(v,["feasible"]);if(!g)throw new Error("internal error: couldn't find a feasible solution");if(e||t)for(let[O,x]of s.entries())x.x=(o=h[O])!==null&&o!==void 0?o:0;else{let O=new Set;for(let m of s.keys())O.add((a=h[m])!==null&&a!==void 0?a:0);let x=new Map(T([...O].sort(),(m,b)=>[m,b]));for(let[m,b]of s.entries())b.x=M(x.get((f=h[m])!==null&&f!==void 0?f:0))}}function n(s){return s===void 0?t:ce(s,e)}r.compressed=n;function i(s){return s===void 0?e:ce(t,s)}return r.dist=i,r}function Cr(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return ce(!1,!0)}var Fr=it(kr());function xi(t,e,r,n,i){if(!e.length)return[];let s=[[0]],o=[0],a=[[0]],f=[0];for(let c of t){let d=[0];d.push(...c),s.push(d)}o.push(...e),a.push(...e.map(()=>[0]));for(let c of r)for(let[d,v]of c.entries())a[d+1].push(-v);f.push(...n.map(c=>-c));let{solution:l,message:u}=(0,Fr.solveQP)(s,o,a,f,i);return $(!u.length),l.shift(),l}function At(t,e,r,n,i=0){e.pop(),t.pop(),t.forEach(o=>o.pop()),r.forEach(o=>o.pop());let s=xi(t,e,r,n,i);return s.push(0),s}function Lr(t){return new Map(t.flatMap(e=>e).map((e,r)=>[e,r]))}function Dt(t,e,r){let n=1+Math.max(...e.values()),i=[],s=[];for(let f of t)for(let[l,u]of G(f)){let c=M(e.get(l)),d=M(e.get(u)),v=new Array(n).fill(0);v[c]=1,v[d]=-1,i.push(v),s.push(-(r(l)+r(u))/2)}let o=new Array(n).fill(0);return[[...new Array(n)].map(()=>new Array(n).fill(0)),o,i,s]}function de(t,e,r,n){t[r][r]+=n,t[r][e]-=n,t[e][r]-=n,t[e][e]+=n}function kt(t,e,r,n,i){t[n][n]+=i,t[n][r]-=2*i,t[n][e]+=i,t[r][n]-=2*i,t[r][r]+=4*i,t[r][e]-=2*i,t[e][n]+=i,t[e][r]-=2*i,t[e][e]+=i}function Ft(t,e,r,n){let i=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(let a of t){let f=a[0],l=a[a.length-1];i=Math.min(i,n[M(r.get(f))]-e(f)/2),s=Math.max(s,n[M(r.get(l))]+e(l)/2)}let o=s-i;for(let a of t)for(let f of a)f.x=Math.min(Math.max(0,n[M(r.get(f))]-i),o);return o}function bi(t){let e=new Map;for(let s of t)for(let o of s)for(let a of o.ichildren()){let f=e.get(a);f?f.push(o):e.set(a,[o])}function*r(s){yield*s.ichildren(),yield*e.get(s)||[]}let n=0,i=new Map;for(let s of t)for(let o of s)if(!i.has(o)){for(let a of at(r,o))i.set(a,n);n++}return i}function yi(t,e){let r=[],n=[],i=new Set;for(let s of t){let o=new Set(s.map(a=>M(e.get(a))));_e(i,o)||r.push(n=[]),n.push(s),i=o}return r}function Lt(t){function e(o,a,f){let{vertNode:l,vertDummy:u,curveNode:c,curveDummy:d,comp:v}=t,g=Lr(o),[h,O,x,m]=Dt(o,g,a);for(let I of o)for(let w of I){let y=M(g.get(w)),S="node"in w.data?l:u;for(let E of w.ichildren()){let B=M(g.get(E)),C="node"in E.data?l:u,j="node"in E.data?c:d;de(h,y,B,S+C);for(let z of E.ichildren()){let V=M(g.get(z));kt(h,y,B,V,j)}}}for(let I of o)for(let[w,y]of G(I))M(f.get(w))!==M(f.get(y))&&de(h,M(g.get(w)),M(g.get(y)),v);let b=At(h,O,x,m);return Ft(o,a,g,b)}function r(o,a){let{vertNode:f,vertDummy:l,curveNode:u,curveDummy:c}=t;if(f===0&&u===0)throw new Error("node vertical weight or node curve weight needs to be positive");if(l===0&&c===0)throw new Error("dummy vertical weight or dummy curve weight needs to be positive");let d=bi(o),v=yi(o,d),g=v.map(O=>e(O,a,d)),h=Math.max(...g);if(h<=0)throw new Error("must assign nonzero width to at least one node");for(let[O,x]of v.entries()){let m=(h-g[O])/2;for(let b of x)for(let I of b)I.x=M(I.x)+m}return h}function n(o){if(o===void 0){let{vertNode:l,vertDummy:u}=t;return[l,u]}let[a,f]=o;if(a<0||f<0)throw new Error(`weights must be non-negative, but were ${a} and ${f}`);return Lt(Object.assign(Object.assign({},t),{vertNode:a,vertDummy:f}))}r.vertical=n;function i(o){if(o===void 0){let{curveNode:l,curveDummy:u}=t;return[l,u]}let[a,f]=o;if(a<0||f<0)throw new Error(`weights must be non-negative, but were ${a} and ${f}`);return Lt(Object.assign(Object.assign({},t),{curveNode:a,curveDummy:f}))}r.curve=i;function s(o){if(o===void 0)return t.comp;if(o<=0)throw new Error(`weight must be positive, but was ${o}`);return Lt(Object.assign(Object.assign({},t),{comp:o}))}return r.component=s,r}function Ut(...t){if(t.length)throw new Error(`got arguments to quad(${t}), but constructor takes no aruguments.`);return Lt({vertNode:1,vertDummy:0,curveNode:0,curveDummy:1,comp:1})}var Ur=class{constructor(){this.mean=0,this.count=0}add(e){this.mean+=(e-this.mean)/++this.count}val(){return this.count?this.mean:void 0}},Gr=()=>new Ur,Wr=class{constructor(){this.vals=[]}add(e){this.vals.push(e)}val(){return st(this.vals)}},pe=()=>new Wr;function wi(t,e){let r=t();for(let n of e)r.add(n);return r.val()}function Jr(t,e){let r=new Map;for(let u of t){let c=e.get(u);if(c===void 0)continue;let d=r.get(c);d===void 0?r.set(c,[u]):d.push(u)}let n=[...r.entries()].sort(([u],[c])=>u-c).flatMap(([,u])=>u),i=new Map(t.map((u,c)=>[u,c])),s=t.filter(u=>e.get(u)===void 0),o=new Array(s.length).fill(null);function a(u,c,d,v){if(c<=u)return;let g=Math.floor((u+c)/2),h=s[g],O=M(i.get(h)),x=0,m=[x];for(let I=d;I[f,t()]));for(let[f,l]of n.entries())for(let u of l.ichildren())M(o.get(u)).add(f);let a=new Map([...o.entries()].map(([f,l])=>[f,l.val()]));Jr(i,a)}else{let o=new Map(i.map((f,l)=>[f,l])),a=new Map(n.map(f=>{let l=wi(t,T(f.ichildren(),u=>M(o.get(u))));return[f,l]}));Jr(n,a)}}function r(n){return n===void 0?t:Zr({factory:n})}return e.aggregator=r,e}function Gt(...t){if(t.length)throw new Error(`got arguments to agg(${t}), but constructor takes no aruguments.`);return Zr({factory:pe})}var Ii=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i[c,d]));t.order(f,l,!0),l.some((c,d)=>M(u.get(c))!==d)&&(o=!0)}for(let[f,l]of G(s)){let u=new Map(l.map((c,d)=>[c,d]));t.order(l,f,!1),l.some((c,d)=>M(u.get(c))!==d)&&(o=!0)}}}function r(i){if(i===void 0)return t.order;{let{order:s}=t,o=Ii(t,["order"]);return ve(Object.assign(Object.assign({},o),{order:i}))}}e.order=r;function n(i){if(i===void 0)return t.passes;if(i<=0)throw new Error("number of passes must be positive");return ve(Object.assign(Object.assign({},t),{passes:i}))}return e.passes=n,e}function Wt(...t){if(t.length)throw new Error(`got arguments to twoLayer(${t}), but constructor takes no aruguments.`);return ve({order:Gt(),passes:1})}var Yr=it(pt());var ge=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i[I,b.toString()]));function l(b){return M(f.get(b))}function u(b){return s[l(b)]}function c(b,I,w,y=!0){let S=u(I),E=u(w),B=`${b}: ${M(l(I))} -> ${M(l(w))}`;a[B]={min:+y},S[B]=-1,E[B]=1}function d(b,I,w){c(`${b} before`,I,w,!1),c(`${b} after`,w,I,!1)}let v=[],g=new Map;for(let b of i){let I=l(b);o[I]=1,s[I]={opt:b.children.length};let w=t.rank(b);w!==void 0&&v.push([w,b]);let y=t.group(b);if(y!==void 0){let S=g.get(y);S?S.push(b):g.set(y,[b])}}for(let b of i.ilinks())c("link",b.source,b.target),++u(b.source).opt,--u(b.target).opt;let h=v.sort(([b],[I])=>b-I);for(let[[b,I],[w,y]]of G(h))b[s,{node:s,layer:Oi(s)}]));function r(s){let o=s.layer+1,a="node"in s?s.node.children():[s.target],f="node"in s?s.node:s.source;return a.map(l=>{let u=M(e.get(l));if(u.layerM(e.get(s)))),i=[];for(let s of n)(i[s.data.layer]||(i[s.data.layer]=[])).push(s);if(!i[0]||!i[0].length)throw new Error("no nodes were assigned to layer 0");for(let s of i)$(s&&s.length);return i}var gt=window&&window.__rest||function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);ir(s)[0],s=>r(s)[1]]}function nt(t){function e(f){t.layering(f);let l=Xr(f),[u,c]=Mi(t.sugiNodeSize),d=0;for(let g of l){let h=Math.max(...g.map(c));for(let O of g)O.y=d+h/2;d+=h}if(d<=0)throw new Error("at least one node must have positive height, but total height was zero");t.decross(l);let v=t.coord(l,u);for(let g of l)for(let h of g){if(h.x===void 0)throw new Error(F`coord didn't assign an x to node '${h}'`);if(h.x<0||h.x>v)throw new Error(`coord assgined an x (${h.x}) outside of [0, ${v}]`)}if(t.size!==null){let[g,h]=t.size;for(let O of l)for(let x of O)$(x.x!==void 0&&x.y!==void 0),x.x*=g/v,x.y*=h/d;v=g,d=h}for(let g of l)for(let h of g){if($(h.x!==void 0&&h.y!==void 0),"target"in h.data)continue;h.data.node.x=h.x,h.data.node.y=h.y;let O=new Map(T(h.data.node.ichildLinks(),({points:x,target:m})=>[m,x]));for(let x of h.ichildren()){let m=[{x:h.x,y:h.y}];for(;"target"in x.data;)$(x.x!==void 0&&x.y!==void 0),m.push({x:x.x,y:x.y}),[x]=x.ichildren();$(x.x!==void 0&&x.y!==void 0),m.push({x:x.x,y:x.y});let b=M(O.get(x.data.node));b.splice(0,b.length,...m)}}return{width:v,height:d}}function r(f){if(f===void 0)return t.layering;{let{layering:l}=t,u=gt(t,["layering"]);return nt(Object.assign(Object.assign({},u),{layering:f}))}}e.layering=r;function n(f){if(f===void 0)return t.decross;{let{decross:l}=t,u=gt(t,["decross"]);return nt(Object.assign(Object.assign({},u),{decross:f}))}}e.decross=n;function i(f){if(f===void 0)return t.coord;{let{coord:l}=t,u=gt(t,["coord"]);return nt(Object.assign(Object.assign({},u),{coord:f}))}}e.coord=i;function s(f){return f!==void 0?nt(Object.assign(Object.assign({},t),{size:f})):t.size}e.size=s;function o(f){if(f!==void 0){let{nodeSize:l,sugiNodeSize:u}=t,c=gt(t,["nodeSize","sugiNodeSize"]);return nt(Object.assign(Object.assign({},c),{nodeSize:f,sugiNodeSize:Kr(f)}))}else return t.nodeSize}e.nodeSize=o;function a(f){if(f!==void 0){let{sugiNodeSize:l,nodeSize:u}=t,c=gt(t,["sugiNodeSize","nodeSize"]);return nt(Object.assign(Object.assign({},c),{sugiNodeSize:f,nodeSize:null}))}else return t.sugiNodeSize}return e.sugiNodeSize=a,e}function Qr(t){return[+(t!==void 0),1]}function tn(...t){if(t.length)throw new Error(`got arguments to sugiyama(${t}), but constructor takes no aruguments.`);return nt({layering:Jt(),decross:Wt(),coord:Ut(),size:null,nodeSize:Qr,sugiNodeSize:Kr(Qr)})}function en(...t){if(t.length)throw new Error(`got arguments to center(${t}), but constructor takes no aruguments.`);function e(r,n){let i=r.map(o=>{let a=0;for(let f of o){let l=n(f);f.x=a+l/2,a+=l}return a}),s=Math.max(...i);if(s<=0)throw new Error("must assign nonzero width to at least one node");for(let[o,a]of r.entries()){let f=i[o],l=(s-f)/2;for(let u of a)u.x=M(u.x)+l}return s}return e}function rn(...t){if(t.length)throw new Error(`got arguments to greedy(${t}), but constructor takes no aruguments.`);function e(r,n){let i=Ci,s=new Map;for(let c of r)for(let d of c)s.set(d,Y(d.ichildren())+("node"in d.data?0:-3));for(let c of r)for(let d of c)for(let v of d.ichildren())s.set(v,M(s.get(v))+1);let[o,...a]=r,f=0,l=0;for(let c of o){let d=n(c);c.x=l+d/2,l+=d}for(let c of a){i(o,c);let d=c.map((v,g)=>[g,v]).sort(([v,g],[h,O])=>{let x=M(s.get(g)),m=M(s.get(O));return x===m?v-h:m-x});for(let[v,g]of d){let h=n(g),O=M(g.x)+h/2;for(let m of c.slice(v+1)){let b=n(m)/2;O=(m.x=Math.max(M(m.x),O+b))+b}l=Math.max(l,O);let x=M(g.x)-h/2;for(let m of c.slice(0,v).reverse()){let b=n(m)/2;x=(m.x=Math.min(M(m.x),x-b))-b}f=Math.min(f,x)}o=c}for(let c of r)for(let d of c)d.x=M(d.x)-f;let u=l-f;if(u<=0)throw new Error("must assign nonzero width to at least one node");return u}return e}function Ci(t,e){for(let n of e)n.x=0;let r=new Map;for(let n of t){$(n.x!==void 0);for(let i of n.ichildren()){$(i.x!==void 0);let s=(r.get(i)||0)+1;r.set(i,s),i.x+=(n.x-i.x)/s}}}function nn(...t){if(t.length)throw new Error(`got arguments to topological(${t}), but constructor takes no aruguments.`);function e(r,n){for(let d of r)if(d.reduce((g,h)=>g+ +("node"in h.data),0)!==1)throw new Error("topological() only works with a topological layering");let i=new Map,s=0;for(let d of r)for(let v of d)"target"in v.data&&i.set(v,s++);for(let d of r)for(let v of d)"node"in v.data&&i.set(v,s);let[o,a,f,l]=Dt(r,i,n);for(let d of r)for(let v of d){let g=M(i.get(v));for(let h of v.ichildren()){let O=M(i.get(h));if("target"in h.data)for(let x of h.ichildren()){let m=M(i.get(x));kt(o,g,O,m,1)}}}let u=At(o,a,f,l),c=Ft(r,n,i,u);if(c<=0)throw new Error("must assign nonzero width to at least one node");return c}return e}var sn=it(pt());function xe(t){function e(i){let s=i.reduce((m,b)=>m+b.length*Math.max(b.length-1,0)/2,0),o=i.reduce((m,b)=>m+b.reduce((I,w)=>I+Y(w.ichildren()),0),0);if(t.large!=="large"&&s>1200)throw new Error('size of dag to decrossOpt is too large and will likely crash instead of complete, enable "large" grahps to run anyway');if(t.large!=="large"&&t.large!=="medium"&&(s>400||o>100))throw new Error('size of dag to decrossOpt is too large and will likely not complete, enable "medium" grahps to run anyway');let a=[];for(let[m,b]of G(i)){let I=new Set(m.flatMap(C=>C.children())),w=b.filter(C=>!I.has(C)),y=m.map(C=>C.children()).filter(C=>C.length>1);a.push([w,y]);let S=m.filter(C=>!Y(C.ichildren())),E=new Map;for(let C of m)for(let j of C.ichildren()){let z=E.get(j);z?z.push(C):E.set(j,[C])}let B=[...E.values()];a.push([S,B])}let f=a.reduce((m,[b,I])=>I.reduce((w,y)=>w+y.length*y.length,0)*b.length,0)/4,l=1/(f+1),u=l/(s+1),c={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},d=new Map;{let m=0;for(let b of i)for(let I of b)d.set(I,m++)}function v(...m){return m.map(b=>M(d.get(b))).sort((b,I)=>b-I).join(" => ")}function g(m){for(let[b,I]of m.slice(0,m.length-1).entries())for(let w of m.slice(b+1)){let y=v(I,w);c.ints[y]=1,c.constraints[y]={max:1},c.variables[y]={opt:-u,[y]:1}}for(let[b,I]of m.slice(0,m.length-1).entries())for(let[w,y]of m.slice(b+1).entries())for(let S of m.slice(b+w+2)){let E=v(I,y),B=v(I,S),C=v(y,S),j=v(I,y,S),z=j+"+";c.constraints[z]={max:1},c.variables[E][z]=1,c.variables[B][z]=-1,c.variables[C][z]=1;let V=j+"-";c.constraints[V]={min:0},c.variables[E][V]=1,c.variables[B][V]=-1,c.variables[C][V]=1}}function h(m){for(let[b,I]of m.slice(0,m.length-1).entries())for(let w of m.slice(b+1)){let y=v(I,w);for(let S of I.ichildren())for(let E of w.ichildren()){if(S===E)continue;let B=v(S,E),C=`slack (${y}) (${B})`,j=`${C} +`,z=`${C} -`;c.variables[C]={opt:1,[j]:1,[z]:1};let V=Math.sign(M(d.get(S))-M(d.get(E))),q=Math.max(V,0);c.constraints[j]={min:q},c.variables[y][j]=1,c.variables[B][j]=V,c.constraints[z]={min:-q},c.variables[y][z]=-1,c.variables[B][z]=-V}}}function O(m,b){for(let I of m)for(let w of b)for(let[y,S]of w.entries())for(let E of w.slice(y+1)){let C=`dist ${[S,I,E].map(q=>M(d.get(q))).join(" => ")}`,j=`${C} normal`,z=`${C} reversed`;c.variables[C]={opt:l,[j]:1,[z]:1};let V=0;for(let[q,A]of[[S,I],[S,E],[I,E]]){let N=v(q,A),U=Math.sign(M(d.get(q))-M(d.get(A)));V+=+(U>0),c.variables[N][j]=-U,c.variables[N][z]=U}c.constraints[j]={min:1-V},c.constraints[z]={min:V-2}}}for(let m of i)g(m);for(let m of i.slice(0,i.length-1))h(m);if(t.dist)for(let[m,b]of a)O(m,b);let x=sn.Solve.call({},c);for(let m of i)m.sort((b,I)=>x[v(b,I)]||-1)}function r(i){return i===void 0?t.large:xe(Object.assign(Object.assign({},t),{large:i}))}e.large=r;function n(i){return i===void 0?t.dist:xe(Object.assign(Object.assign({},t),{dist:i}))}return e.dist=n,e}function on(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return xe({large:"small",dist:!1})}var ln=it(fn());function un(t){function e(n){let i=t.width||Math.floor(Math.sqrt(n.size()+.5)),s=new Map(T(n.idescendants(),d=>[d,{before:[],parents:[]}]));for(let d of n)for(let v of d.ichildren())M(s.get(v)).parents.push(d);function o(d,v){let g=M(s.get(d)).before,h=M(s.get(v)).before;for(let[O,x]of g.entries()){let m=h[O];if(m===void 0)return!1;if(xM(d.value)O-h),a.add(d))}f++}}function r(n){if(n===void 0)return t.width;if(n<0)throw new Error(`width must be non-negative: ${n}`);return un(Object.assign(Object.assign({},t),{width:n}))}return e.width=r,e}function cn(...t){if(t.length)throw new Error(`got arguments to coffmanGraham(${t}), but constructor takes no aruguments.`);return un({width:0})}function hn(t){function e(n){if(t.topDown)n.depth();else{n.height();let i=Math.max(...T(n.iroots(),s=>M(s.value)));for(let s of n)s.value=i-M(s.value)}}function r(n){return n===void 0?t.topDown:hn(Object.assign(Object.assign({},t),{topDown:n}))}return e.topDown=r,e}function dn(...t){if(t.length)throw new Error(`got arguments to longestPath(${t}), but constructor takes no aruguments.`);return hn({topDown:!0})}function pn(...t){if(t.length)throw new Error(`got arguments to topological(${t}), but constructor takes no aruguments.`);function e(r){for(let[n,i]of Z(r.idescendants("before")))i.value=n}return e}var vn=it(pt());function be(t){function e(i,s,o){let a=o?s:i,f=a.length*Math.max(a.length-1,0)/2,l=i.reduce((w,y)=>w+Y(y.ichildren()),0);if(t.large!=="large"&&f>1200)throw new Error('size of dag to twolayerOpt is too large and will likely crash, enable "large" dags to run anyway');if(t.large!=="large"&&t.large!=="medium"&&(f>400||l>100))throw new Error('size of dag to twolayerOpt is too large and will likely not finish, enable "medium" dags to run anyway');let u={optimize:"opt",opType:"min",constraints:{},variables:{},ints:{}},c=new Map(a.map((w,y)=>[w,y]));function d(...w){return w.map(y=>M(c.get(y))).sort((y,S)=>y-S).join(" => ")}let v,g;if(o){let w=new Set(i.flatMap(y=>y.children()));v=s.filter(y=>!w.has(y)),g=i.map(y=>y.children()).filter(y=>y.length>1)}else{v=i.filter(y=>!Y(y.ichildren()));let w=new Map;for(let y of i)for(let S of y.ichildren()){let E=w.get(S);E?E.push(y):w.set(S,[y])}g=[...w.values()]}let O=g.reduce((w,y)=>w+y.length*y.length,0)*v.length/4,x=1/(O+1),m=x/(f+1),b=new Map(s.map((w,y)=>[w,y]));for(let[w,y]of a.slice(0,a.length-1).entries())for(let S of a.slice(w+1)){let E=d(y,S);u.ints[E]=1,u.constraints[E]={max:1},u.variables[E]={opt:-m,[E]:1}}for(let[w,y]of a.slice(0,a.length-1).entries())for(let[S,E]of a.slice(w+1).entries())for(let B of a.slice(w+S+2)){let C=d(y,E),j=d(y,B),z=d(E,B),V=d(y,E,B),q=V+"+";u.constraints[q]={max:1},u.variables[C][q]=1,u.variables[j][q]=-1,u.variables[z][q]=1;let A=V+"-";u.constraints[A]={min:0},u.variables[C][A]=1,u.variables[j][A]=-1,u.variables[z][A]=1}for(let[w,y]of i.slice(0,i.length-1).entries())for(let S of i.slice(w+1))for(let E of y.ichildren())for(let B of S.ichildren()){if(E===B)continue;let C=o?d(E,B):d(y,S);u.variables[C].opt+=Math.sign(M(b.get(E))-M(b.get(B)))}if(t.dist)for(let w of v)for(let y of g)for(let[S,E]of y.entries())for(let B of y.slice(S+1)){let j=`dist ${[E,w,B].map(A=>M(c.get(A))).join(" => ")}`,z=`${j} normal`,V=`${j} reversed`;u.variables[j]={opt:x,[z]:1,[V]:1};let q=0;for(let[A,N]of[[E,w],[E,B],[w,B]]){let U=d(A,N),L=Math.sign(M(c.get(A))-M(c.get(N)));q+=+(L>0),u.variables[U][z]=-L,u.variables[U][V]=L}u.constraints[z]={min:1-q},u.constraints[V]={min:q-2}}let I=vn.Solve.call({},u);a.sort((w,y)=>I[d(w,y)]||-1)}function r(i){return i===void 0?t.large:be(Object.assign(Object.assign({},t),{large:i}))}e.large=r;function n(i){return i===void 0?t.dist:be(Object.assign(Object.assign({},t),{dist:i}))}return e.dist=n,e}function gn(...t){if(t.length)throw new Error(`got arguments to opt(${t}), but constructor takes no aruguments.`);return be({large:"small",dist:!1})}function mn(t,e){let r=t.findIndex(n=>n<=e);return r>=0?r:t.length}function xn(t){let e=new Map(t.map((o,a)=>[o,a])),r=[];for(let[o,a]of t.entries())for(let f of a.ichildren()){let l=M(e.get(f));l>o+1&&r.push([a,o,f,l])}r.sort(([,o,,a],[,f,,l])=>a===l?f-o:a-l);let n=new Map,i=[],s=[];for(let[o,a,f,l]of r){let u=n.get(o);u===void 0&&(u=new Map,n.set(o,u));let c=mn(s,a),d=mn(i,a);c0?t-r:0),y=x.y+e,S=m.y-e;S-y>e/2?b.push({x:w,y},{x:w,y:S}):b.push({x:w,y})}b.push({x:m.x,y:m.y})}let h=(v-d)*r+t,O=u.length*e;if(n===null)return{width:h,height:O};{let[x,m]=n;for(let b of u)$(b.x!==void 0&&b.y!==void 0),b.x*=x/h,b.y*=m/O;for(let{points:b}of a.ilinks()){let I=b.map(({x:w,y})=>({x:M(w)*x/h,y:M(y)*m/O}));b.splice(0,b.length,...I)}return{width:x,height:m}}}function s(a){if(a===void 0)return[t,e,r];{let[f,l,u]=a;return ye(f,l,u,n)}}i.nodeSize=s;function o(a){if(a!==void 0)return ye(t,e,r,a);if(n===null)return n;{let[f,l]=n;return[f,l]}}return i.size=o,i}function bn(...t){if(t.length)throw new Error(`got arguments to zherebko(${t}), but constructor takes no aruguments.`);return ye(1,1,1,null)}return jn(Bi);})(); -return d3; })()) diff --git a/templates/objectives/skills/learning_line.html b/templates/objectives/skills/learning_line.html index e680a02292..78744252ea 100644 --- a/templates/objectives/skills/learning_line.html +++ b/templates/objectives/skills/learning_line.html @@ -29,7 +29,7 @@ {% block footerscript %} - +