cc-viewer 1.6.261 → 1.6.263

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +80 -81
  2. package/cli.js +1 -0
  3. package/dist/assets/{App-Co-5BI9q.js → App-CX6bF6ke.js} +1 -1
  4. package/dist/assets/{MdxEditorPanel-DFNyQW6b.js → MdxEditorPanel--reKHew0.js} +1 -1
  5. package/dist/assets/{Mobile-DwYIskc6.js → Mobile-YwIGAQWc.js} +1 -1
  6. package/dist/assets/{_baseUniq-DGKwdzTD.js → _baseUniq-DiLy7vi3.js} +1 -1
  7. package/dist/assets/{arc-nTLBi2ib.js → arc-CAB2oIHx.js} +1 -1
  8. package/dist/assets/{architectureDiagram-Q4EWVU46-pWWvthzV.js → architectureDiagram-Q4EWVU46-Cijl_JpW.js} +1 -1
  9. package/dist/assets/{blockDiagram-DXYQGD6D-CpU6v2gv.js → blockDiagram-DXYQGD6D-Bk4yWCPQ.js} +1 -1
  10. package/dist/assets/{c4Diagram-AHTNJAMY-zdTsx1jJ.js → c4Diagram-AHTNJAMY-Vz4JKuzi.js} +1 -1
  11. package/dist/assets/{channel-Cq1UANGu.js → channel-BnYKz_zI.js} +1 -1
  12. package/dist/assets/{chunk-4BX2VUAB-D6w9m5kB.js → chunk-4BX2VUAB-DM3ZjqKX.js} +1 -1
  13. package/dist/assets/{chunk-4TB4RGXK-DjZZc11c.js → chunk-4TB4RGXK-BTiJOoNa.js} +1 -1
  14. package/dist/assets/{chunk-55IACEB6-Cw2U09Tu.js → chunk-55IACEB6-B4fMQcTE.js} +1 -1
  15. package/dist/assets/{chunk-EDXVE4YY-Cv-G70H7.js → chunk-EDXVE4YY-B_WylnyS.js} +1 -1
  16. package/dist/assets/{chunk-FMBD7UC4-Dykxux6b.js → chunk-FMBD7UC4-Cx2lqZi9.js} +1 -1
  17. package/dist/assets/{chunk-OYMX7WX6-Cn9oAaEC.js → chunk-OYMX7WX6-CPZm7o6V.js} +1 -1
  18. package/dist/assets/{chunk-QZHKN3VN-CA1IccbG.js → chunk-QZHKN3VN-DuYVzv7E.js} +1 -1
  19. package/dist/assets/{chunk-YZCP3GAM-CbReBNg5.js → chunk-YZCP3GAM-Bk3OysLK.js} +1 -1
  20. package/dist/assets/classDiagram-6PBFFD2Q-CeAAXpgl.js +1 -0
  21. package/dist/assets/classDiagram-v2-HSJHXN6E-CeAAXpgl.js +1 -0
  22. package/dist/assets/clone-BcGHaFBY.js +1 -0
  23. package/dist/assets/{cose-bilkent-S5V4N54A-TwxpCIwM.js → cose-bilkent-S5V4N54A-CQuaqKHt.js} +1 -1
  24. package/dist/assets/{dagre-KV5264BT-CxuHKd9a.js → dagre-KV5264BT-BFdoRcuo.js} +1 -1
  25. package/dist/assets/{diagram-5BDNPKRD-BzR9Peib.js → diagram-5BDNPKRD-ByFdSFIu.js} +1 -1
  26. package/dist/assets/{diagram-G4DWMVQ6-PWFXrQqF.js → diagram-G4DWMVQ6-C1TcKWp0.js} +1 -1
  27. package/dist/assets/{diagram-MMDJMWI5-CqnrwtNB.js → diagram-MMDJMWI5-B5N1Sn5F.js} +1 -1
  28. package/dist/assets/{diagram-TYMM5635-Do2MhBCf.js → diagram-TYMM5635-B-payI0e.js} +1 -1
  29. package/dist/assets/{erDiagram-SMLLAGMA-CklZI6kO.js → erDiagram-SMLLAGMA-zziefklH.js} +1 -1
  30. package/dist/assets/{flowDiagram-DWJPFMVM-C_SKJN0d.js → flowDiagram-DWJPFMVM-BOSomu1b.js} +1 -1
  31. package/dist/assets/{ganttDiagram-T4ZO3ILL-ChhhqFiR.js → ganttDiagram-T4ZO3ILL-DILUsv0T.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-UUTBAWPF-HarEJVSI.js → gitGraphDiagram-UUTBAWPF-BKp2DE69.js} +1 -1
  33. package/dist/assets/{graph-BTcI3kpi.js → graph-NObGxitU.js} +1 -1
  34. package/dist/assets/{index-B0NtFDg2.js → index-0aPBVZuP.js} +1 -1
  35. package/dist/assets/{index-B7-pqPyp.js → index-BI-0Lyyt.js} +1 -1
  36. package/dist/assets/{index-CQ579eP2.js → index-BbXZgnby.js} +1 -1
  37. package/dist/assets/{index-BG6Hzhck.js → index-Bq9Sic2n.js} +1 -1
  38. package/dist/assets/{index-NNx0667m.js → index-C88BDuL0.js} +1 -1
  39. package/dist/assets/index-DHUf_c1w.js +2 -0
  40. package/dist/assets/{index-CF0YP7s8.js → index-PsZiLKrC.js} +1 -1
  41. package/dist/assets/{index-Bzp41aRh.js → index-VqFARC4A.js} +1 -1
  42. package/dist/assets/{index-Dzkxj8m_.css → index-_4BCXKKF.css} +1 -1
  43. package/dist/assets/{infoDiagram-42DDH7IO-DOcCtSEj.js → infoDiagram-42DDH7IO-D409o-BL.js} +1 -1
  44. package/dist/assets/{ishikawaDiagram-UXIWVN3A-Crb_pmG4.js → ishikawaDiagram-UXIWVN3A-CMVPOGr3.js} +1 -1
  45. package/dist/assets/{journeyDiagram-VCZTEJTY-BUv2Exj_.js → journeyDiagram-VCZTEJTY-Bl_5WlaZ.js} +1 -1
  46. package/dist/assets/{jszip.min-BuZCDHia.js → jszip.min-C2654z9i.js} +1 -1
  47. package/dist/assets/{kanban-definition-6JOO6SKY-DwSHz9oV.js → kanban-definition-6JOO6SKY-BfCyUP29.js} +1 -1
  48. package/dist/assets/{layout-Dp3N3WRT.js → layout-CgAMa0xE.js} +1 -1
  49. package/dist/assets/{linear-JU5ltHCp.js → linear-J1N1npGr.js} +1 -1
  50. package/dist/assets/{mermaid.core-f1mZHh7u.js → mermaid.core-YnqOkuoS.js} +2 -2
  51. package/dist/assets/{min-CDzial6q.js → min-CowkZam8.js} +1 -1
  52. package/dist/assets/{mindmap-definition-QFDTVHPH-DnhPHplB.js → mindmap-definition-QFDTVHPH-D7yMfot2.js} +1 -1
  53. package/dist/assets/{pieDiagram-DEJITSTG-dMhPj5wG.js → pieDiagram-DEJITSTG-DKUHBCwB.js} +1 -1
  54. package/dist/assets/{quadrantDiagram-34T5L4WZ-GCi1_zHo.js → quadrantDiagram-34T5L4WZ-DhRqBNfT.js} +1 -1
  55. package/dist/assets/{requirementDiagram-MS252O5E-WeErs64x.js → requirementDiagram-MS252O5E-DVE3wKT7.js} +1 -1
  56. package/dist/assets/{sankeyDiagram-XADWPNL6-BKpP6-8Q.js → sankeyDiagram-XADWPNL6-Rn_9b5V_.js} +1 -1
  57. package/dist/assets/seqResourceLoaders-B9D4RGth.js +2 -0
  58. package/dist/assets/{seqResourceLoaders-B8CyM6Ul.css → seqResourceLoaders-DZvMjXCl.css} +2 -2
  59. package/dist/assets/{sequenceDiagram-FGHM5R23-CAC5BKbx.js → sequenceDiagram-FGHM5R23-CemLRaXC.js} +1 -1
  60. package/dist/assets/{stateDiagram-FHFEXIEX-Cxrg604Z.js → stateDiagram-FHFEXIEX-DNT1gAty.js} +1 -1
  61. package/dist/assets/{stateDiagram-v2-QKLJ7IA2-DaUpf340.js → stateDiagram-v2-QKLJ7IA2-DPlMhu-M.js} +1 -1
  62. package/dist/assets/{timeline-definition-GMOUNBTQ-DbvXGDTU.js → timeline-definition-GMOUNBTQ-B-F8vgZN.js} +1 -1
  63. package/dist/assets/{vendor-antd-jGWxgt_-.js → vendor-antd-Dq3DHFa-.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-9gysGjWj.js → vendor-codemirror-DjMkT0sn.js} +1 -1
  65. package/dist/assets/{vendor-mdxeditor-BFiCaYAL.js → vendor-mdxeditor-CrZ9SWce.js} +2 -2
  66. package/dist/assets/{vendor-qrcode-DjZ-VpGR.js → vendor-qrcode-C_77dtHg.js} +1 -1
  67. package/dist/assets/{vendor-virtuoso-DB1J9xKG.js → vendor-virtuoso-aMZPf2fi.js} +1 -1
  68. package/dist/assets/{vennDiagram-DHZGUBPP-BoIw-nWl.js → vennDiagram-DHZGUBPP-K67JHnnN.js} +1 -1
  69. package/dist/assets/{wardley-RL74JXVD-4PjirsHP.js → wardley-RL74JXVD-CCis01LD.js} +1 -1
  70. package/dist/assets/{wardleyDiagram-NUSXRM2D-C8RzJmfU.js → wardleyDiagram-NUSXRM2D-BjqRIOpN.js} +1 -1
  71. package/dist/assets/{xychartDiagram-5P7HB3ND-Ct6fDXwq.js → xychartDiagram-5P7HB3ND-CaXETYTI.js} +1 -1
  72. package/dist/index.html +5 -5
  73. package/lib/ask-bridge.js +19 -1
  74. package/lib/sdk-manager.js +48 -5
  75. package/package.json +1 -1
  76. package/pty-manager.js +1 -1
  77. package/scratch-pty-manager.js +2 -2
  78. package/server.js +110 -11
  79. package/dist/assets/classDiagram-6PBFFD2Q-PgwmelQQ.js +0 -1
  80. package/dist/assets/classDiagram-v2-HSJHXN6E-PgwmelQQ.js +0 -1
  81. package/dist/assets/clone-Dnu1HdEX.js +0 -1
  82. package/dist/assets/index-C6MrFmhs.js +0 -2
  83. package/dist/assets/seqResourceLoaders-80G7f5Kr.js +0 -2
@@ -1 +1 @@
1
- import{b as baseClone,G as Graph,i as isUndefined,v as values}from"./graph-BTcI3kpi.js";import{i as isSymbol,c as baseIteratee,k as keys,o as baseFindIndex,p as castFunction,q as baseForOwn,t as hasPath,u as castPath,v as toKey,w as baseGet,d as arrayMap,x as hasIn,b as baseFlatten,y as toString,n as forEach,m as filter,r as reduce}from"./_baseUniq-DGKwdzTD.js";import{f as flatten,b as baseExtremum,a as baseLt,c as baseMap,m as map,d as min}from"./min-CDzial6q.js";import{a_ as isObject,bw as setToString,bx as overRest,b5 as baseRest,by as isIterateeCall,aR as keysIn,bp as eq,aF as isArrayLike,bu as baseFor,bz as baseAssignValue,aH as identity,bt as isIndex,b4 as assignValue,aG as isArray,aY as baseUnary,b7 as constant,bA as merge}from"./mermaid.core-f1mZHh7u.js";var reWhitespace=/\s/;var reTrimStart=/^\s+/;function baseTrim(string){return string?string.slice(0,function(string){for(var index=string.length;index--&&reWhitespace.test(string.charAt(index)););return index}(string)+1).replace(reTrimStart,""):string}var reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toFinite(value){return value?Infinity===(value=function(value){if("number"==typeof value)return value;if(isSymbol(value))return NaN;if(isObject(value)){var other="function"==typeof value.valueOf?value.valueOf():value;value=isObject(other)?other+"":other}if("string"!=typeof value)return 0===value?value:+value;value=baseTrim(value);var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NaN:+value}(value))||-Infinity===value?17976931348623157e292*(value<0?-1:1):value==value?value:0:0===value?value:0}function cloneDeep(value){return baseClone(value,5)}var objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty,defaults=baseRest(function(object,sources){object=Object(object);var index=-1,length=sources.length,guard=length>2?sources[2]:void 0;for(guard&&isIterateeCall(sources[0],sources[1],guard)&&(length=1);++index<length;)for(var source=sources[index],props=keysIn(source),propsIndex=-1,propsLength=props.length;++propsIndex<propsLength;){var key=props[propsIndex],value=object[key];(void 0===value||eq(value,objectProto$1[key])&&!hasOwnProperty$1.call(object,key))&&(object[key]=source[key])}return object});function last(array){var length=null==array?0:array.length;return length?array[length-1]:void 0}var nativeMax$1=Math.max;var findIndexFunc,find=(findIndexFunc=function(array,predicate,fromIndex){var length=null==array?0:array.length;if(!length)return-1;var result,remainder,index=null==fromIndex?0:(result=toFinite(fromIndex),remainder=result%1,result==result?remainder?result-remainder:result:0);return index<0&&(index=nativeMax$1(length+index,0)),baseFindIndex(array,baseIteratee(predicate),index)},function(collection,predicate,fromIndex){var iterable=Object(collection);if(!isArrayLike(collection)){var iteratee=baseIteratee(predicate);collection=keys(collection),predicate=function(key){return iteratee(iterable[key],key,iterable)}}var index=findIndexFunc(collection,predicate,fromIndex);return index>-1?iterable[iteratee?collection[index]:index]:void 0});function baseGt(value,other){return value>other}var hasOwnProperty=Object.prototype.hasOwnProperty;function baseHas(object,key){return null!=object&&hasOwnProperty.call(object,key)}function has(object,path){return null!=object&&hasPath(object,path,baseHas)}function mapValues(object,iteratee){var result={};return iteratee=baseIteratee(iteratee),baseForOwn(object,function(value,key,object2){baseAssignValue(result,key,iteratee(value,key,object2))}),result}function max(array){return array&&array.length?baseExtremum(array,identity,baseGt):void 0}function minBy(array,iteratee){return array&&array.length?baseExtremum(array,baseIteratee(iteratee),baseLt):void 0}function baseSet(object,path,value,customizer){if(!isObject(object))return object;for(var index=-1,length=(path=castPath(path,object)).length,lastIndex=length-1,nested=object;null!=nested&&++index<length;){var key=toKey(path[index]),newValue=value;if("__proto__"===key||"constructor"===key||"prototype"===key)return object;if(index!=lastIndex){var objValue=nested[key];void 0===(newValue=void 0)&&(newValue=isObject(objValue)?objValue:isIndex(path[index+1])?[]:{})}assignValue(nested,key,newValue),nested=nested[key]}return object}function compareAscending(value,other){if(value!==other){var valIsDefined=void 0!==value,valIsNull=null===value,valIsReflexive=value==value,valIsSymbol=isSymbol(value),othIsDefined=void 0!==other,othIsNull=null===other,othIsReflexive=other==other,othIsSymbol=isSymbol(other);if(!othIsNull&&!othIsSymbol&&!valIsSymbol&&value>other||valIsSymbol&&othIsDefined&&othIsReflexive&&!othIsNull&&!othIsSymbol||valIsNull&&othIsDefined&&othIsReflexive||!valIsDefined&&othIsReflexive||!valIsReflexive)return 1;if(!valIsNull&&!valIsSymbol&&!othIsSymbol&&value<other||othIsSymbol&&valIsDefined&&valIsReflexive&&!valIsNull&&!valIsSymbol||othIsNull&&valIsDefined&&valIsReflexive||!othIsDefined&&valIsReflexive||!othIsReflexive)return-1}return 0}function baseOrderBy(collection,iteratees,orders){iteratees=iteratees.length?arrayMap(iteratees,function(iteratee){return isArray(iteratee)?function(value){return baseGet(value,1===iteratee.length?iteratee[0]:iteratee)}:iteratee}):[identity];var index=-1;return iteratees=arrayMap(iteratees,baseUnary(baseIteratee)),function(array,comparer){var length=array.length;for(array.sort(comparer);length--;)array[length]=array[length].value;return array}(baseMap(collection,function(value,key,collection2){return{criteria:arrayMap(iteratees,function(iteratee){return iteratee(value)}),index:++index,value:value}}),function(object,other){return function(object,other,orders){for(var index=-1,objCriteria=object.criteria,othCriteria=other.criteria,length=objCriteria.length,ordersLength=orders.length;++index<length;){var result=compareAscending(objCriteria[index],othCriteria[index]);if(result)return index>=ordersLength?result:result*("desc"==orders[index]?-1:1)}return object.index-other.index}(object,other,orders)})}function basePick(object,paths){return function(object,paths,predicate){for(var index=-1,length=paths.length,result={};++index<length;){var path=paths[index],value=baseGet(object,path);predicate(value,path)&&baseSet(result,castPath(path,object),value)}return result}(object,paths,function(value,path){return hasIn(object,path)})}var func,pick=setToString(overRest(func=function(object,paths){return null==object?{}:basePick(object,paths)},void 0,flatten),func+""),nativeCeil=Math.ceil,nativeMax=Math.max;var range=function(start,end,step){return step&&"number"!=typeof step&&isIterateeCall(start,end,step)&&(end=step=void 0),start=toFinite(start),void 0===end?(end=start,start=0):end=toFinite(end),function(start,end,step){for(var index=-1,length=nativeMax(nativeCeil((end-start)/(step||1)),0),result=Array(length);length--;)result[++index]=start,start+=step;return result}(start,end,step=void 0===step?start<end?1:-1:toFinite(step))},sortBy=baseRest(function(collection,iteratees){if(null==collection)return[];var length=iteratees.length;return length>1&&isIterateeCall(collection,iteratees[0],iteratees[1])?iteratees=[]:length>2&&isIterateeCall(iteratees[0],iteratees[1],iteratees[2])&&(iteratees=[iteratees[0]]),baseOrderBy(collection,baseFlatten(iteratees),[])}),idCounter=0;function uniqueId(prefix){var id=++idCounter;return toString(prefix)+id}class List{constructor(){var sentinel={};sentinel._next=sentinel._prev=sentinel,this._sentinel=sentinel}dequeue(){var sentinel=this._sentinel,entry=sentinel._prev;if(entry!==sentinel)return unlink(entry),entry}enqueue(entry){var sentinel=this._sentinel;entry._prev&&entry._next&&unlink(entry),entry._next=sentinel._next,sentinel._next._prev=entry,sentinel._next=entry,entry._prev=sentinel}toString(){for(var strs=[],sentinel=this._sentinel,curr=sentinel._prev;curr!==sentinel;)strs.push(JSON.stringify(curr,filterOutLinks)),curr=curr._prev;return"["+strs.join(", ")+"]"}}function unlink(entry){entry._prev._next=entry._next,entry._next._prev=entry._prev,delete entry._next,delete entry._prev}function filterOutLinks(k,v){if("_next"!==k&&"_prev"!==k)return v}var DEFAULT_WEIGHT_FN=constant(1);function greedyFAS(g,weightFn){if(g.nodeCount()<=1)return[];var state=function(g,weightFn){var fasGraph=new Graph,maxIn=0,maxOut=0;forEach(g.nodes(),function(v){fasGraph.setNode(v,{v:v,in:0,out:0})}),forEach(g.edges(),function(e){var prevWeight=fasGraph.edge(e.v,e.w)||0,weight=weightFn(e),edgeWeight=prevWeight+weight;fasGraph.setEdge(e.v,e.w,edgeWeight),maxOut=Math.max(maxOut,fasGraph.node(e.v).out+=weight),maxIn=Math.max(maxIn,fasGraph.node(e.w).in+=weight)});var buckets=range(maxOut+maxIn+3).map(function(){return new List}),zeroIdx=maxIn+1;return forEach(fasGraph.nodes(),function(v){assignBucket(buckets,zeroIdx,fasGraph.node(v))}),{graph:fasGraph,buckets:buckets,zeroIdx:zeroIdx}}(g,weightFn||DEFAULT_WEIGHT_FN),results=function(g,buckets,zeroIdx){var entry,results=[],sources=buckets[buckets.length-1],sinks=buckets[0];for(;g.nodeCount();){for(;entry=sinks.dequeue();)removeNode(g,buckets,zeroIdx,entry);for(;entry=sources.dequeue();)removeNode(g,buckets,zeroIdx,entry);if(g.nodeCount())for(var i=buckets.length-2;i>0;--i)if(entry=buckets[i].dequeue()){results=results.concat(removeNode(g,buckets,zeroIdx,entry,!0));break}}return results}(state.graph,state.buckets,state.zeroIdx);return flatten(map(results,function(e){return g.outEdges(e.v,e.w)}))}function removeNode(g,buckets,zeroIdx,entry,collectPredecessors){var results=collectPredecessors?[]:void 0;return forEach(g.inEdges(entry.v),function(edge){var weight=g.edge(edge),uEntry=g.node(edge.v);collectPredecessors&&results.push({v:edge.v,w:edge.w}),uEntry.out-=weight,assignBucket(buckets,zeroIdx,uEntry)}),forEach(g.outEdges(entry.v),function(edge){var weight=g.edge(edge),w=edge.w,wEntry=g.node(w);wEntry.in-=weight,assignBucket(buckets,zeroIdx,wEntry)}),g.removeNode(entry.v),results}function assignBucket(buckets,zeroIdx,entry){entry.out?entry.in?buckets[entry.out-entry.in+zeroIdx].enqueue(entry):buckets[buckets.length-1].enqueue(entry):buckets[0].enqueue(entry)}function run$2(g){var g2,fas="greedy"===g.graph().acyclicer?greedyFAS(g,(g2=g,function(e){return g2.edge(e).weight})):function(g){var fas=[],stack={},visited={};function dfs2(v){Object.prototype.hasOwnProperty.call(visited,v)||(visited[v]=!0,stack[v]=!0,forEach(g.outEdges(v),function(e){Object.prototype.hasOwnProperty.call(stack,e.w)?fas.push(e):dfs2(e.w)}),delete stack[v])}return forEach(g.nodes(),dfs2),fas}(g);forEach(fas,function(e){var label=g.edge(e);g.removeEdge(e),label.forwardName=e.name,label.reversed=!0,g.setEdge(e.w,e.v,label,uniqueId("rev"))})}function addDummyNode(g,type,attrs,name){var v;do{v=uniqueId(name)}while(g.hasNode(v));return attrs.dummy=type,g.setNode(v,attrs),v}function asNonCompoundGraph(g){var simplified=new Graph({multigraph:g.isMultigraph()}).setGraph(g.graph());return forEach(g.nodes(),function(v){g.children(v).length||simplified.setNode(v,g.node(v))}),forEach(g.edges(),function(e){simplified.setEdge(e,g.edge(e))}),simplified}function intersectRect(rect,point){var sx,sy,x=rect.x,y=rect.y,dx=point.x-x,dy=point.y-y,w=rect.width/2,h=rect.height/2;if(!dx&&!dy)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(dy)*w>Math.abs(dx)*h?(dy<0&&(h=-h),sx=h*dx/dy,sy=h):(dx<0&&(w=-w),sx=w,sy=w*dy/dx),{x:x+sx,y:y+sy}}function buildLayerMatrix(g){var layering=map(range(maxRank(g)+1),function(){return[]});return forEach(g.nodes(),function(v){var node=g.node(v),rank2=node.rank;isUndefined(rank2)||(layering[rank2][node.order]=v)}),layering}function addBorderNode$1(g,prefix,rank2,order2){var node={width:0,height:0};return arguments.length>=4&&(node.rank=rank2,node.order=order2),addDummyNode(g,"border",node,prefix)}function maxRank(g){return max(map(g.nodes(),function(v){var rank2=g.node(v).rank;if(!isUndefined(rank2))return rank2}))}function notime(name,fn){return fn()}function addBorderNode(g,prop,prefix,sg,sgNode,rank2){var label={width:0,height:0,rank:rank2,borderType:prop},prev=sgNode[prop][rank2-1],curr=addDummyNode(g,"border",label,prefix);sgNode[prop][rank2]=curr,g.setParent(curr,sg),prev&&g.setEdge(prev,curr,{weight:1})}function undo$1(g){var rankDir=g.graph().rankdir.toLowerCase();"bt"!==rankDir&&"rl"!==rankDir||function(g){forEach(g.nodes(),function(v){reverseYOne(g.node(v))}),forEach(g.edges(),function(e){var edge=g.edge(e);forEach(edge.points,reverseYOne),Object.prototype.hasOwnProperty.call(edge,"y")&&reverseYOne(edge)})}(g),"lr"!==rankDir&&"rl"!==rankDir||(!function(g){forEach(g.nodes(),function(v){swapXYOne(g.node(v))}),forEach(g.edges(),function(e){var edge=g.edge(e);forEach(edge.points,swapXYOne),Object.prototype.hasOwnProperty.call(edge,"x")&&swapXYOne(edge)})}(g),swapWidthHeight(g))}function swapWidthHeight(g){forEach(g.nodes(),function(v){swapWidthHeightOne(g.node(v))}),forEach(g.edges(),function(e){swapWidthHeightOne(g.edge(e))})}function swapWidthHeightOne(attrs){var w=attrs.width;attrs.width=attrs.height,attrs.height=w}function reverseYOne(attrs){attrs.y=-attrs.y}function swapXYOne(attrs){var x=attrs.x;attrs.x=attrs.y,attrs.y=x}function run$1(g){g.graph().dummyChains=[],forEach(g.edges(),function(edge){!function(g,e){var v=e.v,vRank=g.node(v).rank,w=e.w,wRank=g.node(w).rank,name=e.name,edgeLabel=g.edge(e),labelRank=edgeLabel.labelRank;if(wRank===vRank+1)return;g.removeEdge(e);var dummy,i,attrs=void 0;for(i=0,++vRank;vRank<wRank;++i,++vRank)edgeLabel.points=[],dummy=addDummyNode(g,"edge",attrs={width:0,height:0,edgeLabel:edgeLabel,edgeObj:e,rank:vRank},"_d"),vRank===labelRank&&(attrs.width=edgeLabel.width,attrs.height=edgeLabel.height,attrs.dummy="edge-label",attrs.labelpos=edgeLabel.labelpos),g.setEdge(v,dummy,{weight:edgeLabel.weight},name),0===i&&g.graph().dummyChains.push(dummy),v=dummy;g.setEdge(v,w,{weight:edgeLabel.weight},name)}(g,edge)})}function longestPath(g){var visited={};forEach(g.sources(),function dfs2(v){var label=g.node(v);if(Object.prototype.hasOwnProperty.call(visited,v))return label.rank;visited[v]=!0;var rank2=min(map(g.outEdges(v),function(e){return dfs2(e.w)-g.edge(e).minlen}));return rank2!==Number.POSITIVE_INFINITY&&null!=rank2||(rank2=0),label.rank=rank2})}function slack(g,e){return g.node(e.w).rank-g.node(e.v).rank-g.edge(e).minlen}function feasibleTree(g){var edge,delta,t=new Graph({directed:!1}),start=g.nodes()[0],size=g.nodeCount();for(t.setNode(start,{});tightTree(t,g)<size;)edge=findMinSlackEdge(t,g),delta=t.hasNode(edge.v)?slack(g,edge):-slack(g,edge),shiftRanks(t,g,delta);return t}function tightTree(t,g){return forEach(t.nodes(),function dfs2(v){forEach(g.nodeEdges(v),function(e){var edgeV=e.v,w=v===edgeV?e.w:edgeV;t.hasNode(w)||slack(g,e)||(t.setNode(w,{}),t.setEdge(v,w,{}),dfs2(w))})}),t.nodeCount()}function findMinSlackEdge(t,g){return minBy(g.edges(),function(e){if(t.hasNode(e.v)!==t.hasNode(e.w))return slack(g,e)})}function shiftRanks(t,g,delta){forEach(t.nodes(),function(v){g.node(v).rank+=delta})}function dfs$1(g,vs,order2){isArray(vs)||(vs=[vs]);var navigation=(g.isDirected()?g.successors:g.neighbors).bind(g),acc=[],visited={};return forEach(vs,function(v){if(!g.hasNode(v))throw new Error("Graph does not have node: "+v);doDfs(g,v,"post"===order2,visited,navigation,acc)}),acc}function doDfs(g,v,postorder2,visited,navigation,acc){Object.prototype.hasOwnProperty.call(visited,v)||(visited[v]=!0,postorder2||acc.push(v),forEach(navigation(v),function(w){doDfs(g,w,postorder2,visited,navigation,acc)}),postorder2&&acc.push(v))}function networkSimplex(g){g=function(g){var simplified=(new Graph).setGraph(g.graph());return forEach(g.nodes(),function(v){simplified.setNode(v,g.node(v))}),forEach(g.edges(),function(e){var simpleLabel=simplified.edge(e.v,e.w)||{weight:0,minlen:1},label=g.edge(e);simplified.setEdge(e.v,e.w,{weight:simpleLabel.weight+label.weight,minlen:Math.max(simpleLabel.minlen,label.minlen)})}),simplified}(g),longestPath(g);var e,t=feasibleTree(g);for(initLowLimValues(t),initCutValues(t,g);e=leaveEdge(t);)exchangeEdges(t,g,e,enterEdge(t,g,e))}function initCutValues(t,g){var vs=function(g,vs){return dfs$1(g,vs,"post")}(t,t.nodes());vs=vs.slice(0,vs.length-1),forEach(vs,function(v){!function(t,g,child){var childLab=t.node(child),parent=childLab.parent;t.edge(child,parent).cutvalue=calcCutValue(t,g,child)}(t,g,v)})}function calcCutValue(t,g,child){var parent=t.node(child).parent,childIsTail=!0,graphEdge=g.edge(child,parent),cutValue=0;return graphEdge||(childIsTail=!1,graphEdge=g.edge(parent,child)),cutValue=graphEdge.weight,forEach(g.nodeEdges(child),function(e){var u,v,isOutEdge=e.v===child,other=isOutEdge?e.w:e.v;if(other!==parent){var pointsToHead=isOutEdge===childIsTail,otherWeight=g.edge(e).weight;if(cutValue+=pointsToHead?otherWeight:-otherWeight,u=child,v=other,t.hasEdge(u,v)){var otherCutValue=t.edge(child,other).cutvalue;cutValue+=pointsToHead?-otherCutValue:otherCutValue}}}),cutValue}function initLowLimValues(tree,root){arguments.length<2&&(root=tree.nodes()[0]),dfsAssignLowLim(tree,{},1,root)}function dfsAssignLowLim(tree,visited,nextLim,v,parent){var low=nextLim,label=tree.node(v);return visited[v]=!0,forEach(tree.neighbors(v),function(w){Object.prototype.hasOwnProperty.call(visited,w)||(nextLim=dfsAssignLowLim(tree,visited,nextLim,w,v))}),label.low=low,label.lim=nextLim++,parent?label.parent=parent:delete label.parent,nextLim}function leaveEdge(tree){return find(tree.edges(),function(e){return tree.edge(e).cutvalue<0})}function enterEdge(t,g,edge){var v=edge.v,w=edge.w;g.hasEdge(v,w)||(v=edge.w,w=edge.v);var vLabel=t.node(v),wLabel=t.node(w),tailLabel=vLabel,flip=!1;return vLabel.lim>wLabel.lim&&(tailLabel=wLabel,flip=!0),minBy(filter(g.edges(),function(edge2){return flip===isDescendant(t,t.node(edge2.v),tailLabel)&&flip!==isDescendant(t,t.node(edge2.w),tailLabel)}),function(edge2){return slack(g,edge2)})}function exchangeEdges(t,g,e,f){var v=e.v,w=e.w;t.removeEdge(v,w),t.setEdge(f.v,f.w,{}),initLowLimValues(t),initCutValues(t,g),function(t,g){var root=find(t.nodes(),function(v){return!g.node(v).parent}),vs=function(g,vs){return dfs$1(g,vs,"pre")}(t,root);vs=vs.slice(1),forEach(vs,function(v){var parent=t.node(v).parent,edge=g.edge(v,parent),flipped=!1;edge||(edge=g.edge(parent,v),flipped=!0),g.node(v).rank=g.node(parent).rank+(flipped?edge.minlen:-edge.minlen)})}(t,g)}function isDescendant(tree,vLabel,rootLabel){return rootLabel.low<=vLabel.lim&&vLabel.lim<=rootLabel.lim}function rank(g){switch(g.graph().ranker){case"network-simplex":default:networkSimplexRanker(g);break;case"tight-tree":!function(g){longestPath(g),feasibleTree(g)}(g);break;case"longest-path":longestPathRanker(g)}}new Error,networkSimplex.initLowLimValues=initLowLimValues,networkSimplex.initCutValues=initCutValues,networkSimplex.calcCutValue=calcCutValue,networkSimplex.leaveEdge=leaveEdge,networkSimplex.enterEdge=enterEdge,networkSimplex.exchangeEdges=exchangeEdges;var longestPathRanker=longestPath;function networkSimplexRanker(g){networkSimplex(g)}function run(g){var root=addDummyNode(g,"root",{},"_root"),depths=function(g){var depths={};function dfs2(v,depth){var children=g.children(v);children&&children.length&&forEach(children,function(child){dfs2(child,depth+1)}),depths[v]=depth}return forEach(g.children(),function(v){dfs2(v,1)}),depths}(g),height=max(values(depths))-1,nodeSep=2*height+1;g.graph().nestingRoot=root,forEach(g.edges(),function(e){g.edge(e).minlen*=nodeSep});var weight=function(g){return reduce(g.edges(),function(acc,e){return acc+g.edge(e).weight},0)}(g)+1;forEach(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)}),g.graph().nodeRankFactor=nodeSep}function dfs(g,root,nodeSep,weight,height,depths,v){var children=g.children(v);if(children.length){var top=addBorderNode$1(g,"_bt"),bottom=addBorderNode$1(g,"_bb"),label=g.node(v);g.setParent(top,v),label.borderTop=top,g.setParent(bottom,v),label.borderBottom=bottom,forEach(children,function(child){dfs(g,root,nodeSep,weight,height,depths,child);var childNode=g.node(child),childTop=childNode.borderTop?childNode.borderTop:child,childBottom=childNode.borderBottom?childNode.borderBottom:child,thisWeight=childNode.borderTop?weight:2*weight,minlen=childTop!==childBottom?1:height-depths[v]+1;g.setEdge(top,childTop,{weight:thisWeight,minlen:minlen,nestingEdge:!0}),g.setEdge(childBottom,bottom,{weight:thisWeight,minlen:minlen,nestingEdge:!0})}),g.parent(v)||g.setEdge(root,top,{weight:0,minlen:height+depths[v]})}else v!==root&&g.setEdge(root,v,{weight:0,minlen:nodeSep})}function buildLayerGraph(g,rank2,relationship){var root=function(g){var v;for(;g.hasNode(v=uniqueId("_root")););return v}(g),result=new Graph({compound:!0}).setGraph({root:root}).setDefaultNodeLabel(function(v){return g.node(v)});return forEach(g.nodes(),function(v){var node=g.node(v),parent=g.parent(v);(node.rank===rank2||node.minRank<=rank2&&rank2<=node.maxRank)&&(result.setNode(v),result.setParent(v,parent||root),forEach(g[relationship](v),function(e){var u=e.v===v?e.w:e.v,edge=result.edge(u,v),weight=isUndefined(edge)?0:edge.weight;result.setEdge(u,v,{weight:g.edge(e).weight+weight})}),Object.prototype.hasOwnProperty.call(node,"minRank")&&result.setNode(v,{borderLeft:node.borderLeft[rank2],borderRight:node.borderRight[rank2]}))}),result}function crossCount(g,layering){for(var cc=0,i=1;i<layering.length;++i)cc+=twoLayerCrossCount(g,layering[i-1],layering[i]);return cc}function twoLayerCrossCount(g,northLayer,southLayer){for(var props,values2,southPos=(props=southLayer,values2=map(southLayer,function(v,i){return i}),function(props,values2,assignFunc){for(var index=-1,length=props.length,valsLength=values2.length,result={};++index<length;){var value=index<valsLength?values2[index]:void 0;assignFunc(result,props[index],value)}return result}(props||[],values2||[],assignValue)),southEntries=flatten(map(northLayer,function(v){return sortBy(map(g.outEdges(v),function(e){return{pos:southPos[e.w],weight:g.edge(e).weight}}),"pos")})),firstIndex=1;firstIndex<southLayer.length;)firstIndex<<=1;var treeSize=2*firstIndex-1;firstIndex-=1;var tree=map(new Array(treeSize),function(){return 0}),cc=0;return forEach(southEntries.forEach(function(entry){var index=entry.pos+firstIndex;tree[index]+=entry.weight;for(var weightSum=0;index>0;)index%2&&(weightSum+=tree[index+1]),tree[index=index-1>>1]+=entry.weight;cc+=entry.weight*weightSum})),cc}function resolveConflicts(entries,cg){var mappedEntries={};return forEach(entries,function(entry,i){var tmp=mappedEntries[entry.v]={indegree:0,in:[],out:[],vs:[entry.v],i:i};isUndefined(entry.barycenter)||(tmp.barycenter=entry.barycenter,tmp.weight=entry.weight)}),forEach(cg.edges(),function(e){var entryV=mappedEntries[e.v],entryW=mappedEntries[e.w];isUndefined(entryV)||isUndefined(entryW)||(entryW.indegree++,entryV.out.push(mappedEntries[e.w]))}),function(sourceSet){var entries=[];function handleIn(vEntry){return function(uEntry){uEntry.merged||(isUndefined(uEntry.barycenter)||isUndefined(vEntry.barycenter)||uEntry.barycenter>=vEntry.barycenter)&&function(target,source){var sum=0,weight=0;target.weight&&(sum+=target.barycenter*target.weight,weight+=target.weight);source.weight&&(sum+=source.barycenter*source.weight,weight+=source.weight);target.vs=source.vs.concat(target.vs),target.barycenter=sum/weight,target.weight=weight,target.i=Math.min(source.i,target.i),source.merged=!0}(vEntry,uEntry)}}function handleOut(vEntry){return function(wEntry){wEntry.in.push(vEntry),0===--wEntry.indegree&&sourceSet.push(wEntry)}}for(;sourceSet.length;){var entry=sourceSet.pop();entries.push(entry),forEach(entry.in.reverse(),handleIn(entry)),forEach(entry.out,handleOut(entry))}return map(filter(entries,function(entry2){return!entry2.merged}),function(entry2){return pick(entry2,["vs","i","barycenter","weight"])})}(filter(mappedEntries,function(entry){return!entry.indegree}))}function sort(entries,biasRight){var bias,parts=function(collection,fn){var result={lhs:[],rhs:[]};return forEach(collection,function(value){fn(value)?result.lhs.push(value):result.rhs.push(value)}),result}(entries,function(entry){return Object.prototype.hasOwnProperty.call(entry,"barycenter")}),sortable=parts.lhs,unsortable=sortBy(parts.rhs,function(entry){return-entry.i}),vs=[],sum=0,weight=0,vsIndex=0;sortable.sort((bias=!!biasRight,function(entryV,entryW){return entryV.barycenter<entryW.barycenter?-1:entryV.barycenter>entryW.barycenter?1:bias?entryW.i-entryV.i:entryV.i-entryW.i})),vsIndex=consumeUnsortable(vs,unsortable,vsIndex),forEach(sortable,function(entry){vsIndex+=entry.vs.length,vs.push(entry.vs),sum+=entry.barycenter*entry.weight,weight+=entry.weight,vsIndex=consumeUnsortable(vs,unsortable,vsIndex)});var result={vs:flatten(vs)};return weight&&(result.barycenter=sum/weight,result.weight=weight),result}function consumeUnsortable(vs,unsortable,index){for(var last$1;unsortable.length&&(last$1=last(unsortable)).i<=index;)unsortable.pop(),vs.push(last$1.vs),index++;return index}function sortSubgraph(g,v,cg,biasRight){var movable=g.children(v),node=g.node(v),bl=node?node.borderLeft:void 0,br=node?node.borderRight:void 0,subgraphs={};bl&&(movable=filter(movable,function(w){return w!==bl&&w!==br}));var barycenters=function(g,movable){return map(movable,function(v){var inV=g.inEdges(v);if(inV.length){var result=reduce(inV,function(acc,e){var edge=g.edge(e),nodeU=g.node(e.v);return{sum:acc.sum+edge.weight*nodeU.order,weight:acc.weight+edge.weight}},{sum:0,weight:0});return{v:v,barycenter:result.sum/result.weight,weight:result.weight}}return{v:v}})}(g,movable);forEach(barycenters,function(entry){if(g.children(entry.v).length){var subgraphResult=sortSubgraph(g,entry.v,cg,biasRight);subgraphs[entry.v]=subgraphResult,Object.prototype.hasOwnProperty.call(subgraphResult,"barycenter")&&(other=subgraphResult,isUndefined((target=entry).barycenter)?(target.barycenter=other.barycenter,target.weight=other.weight):(target.barycenter=(target.barycenter*target.weight+other.barycenter*other.weight)/(target.weight+other.weight),target.weight+=other.weight))}var target,other});var entries=resolveConflicts(barycenters,cg);!function(entries,subgraphs){forEach(entries,function(entry){entry.vs=flatten(entry.vs.map(function(v){return subgraphs[v]?subgraphs[v].vs:v}))})}(entries,subgraphs);var result=sort(entries,biasRight);if(bl&&(result.vs=flatten([bl,result.vs,br]),g.predecessors(bl).length)){var blPred=g.node(g.predecessors(bl)[0]),brPred=g.node(g.predecessors(br)[0]);Object.prototype.hasOwnProperty.call(result,"barycenter")||(result.barycenter=0,result.weight=0),result.barycenter=(result.barycenter*result.weight+blPred.order+brPred.order)/(result.weight+2),result.weight+=2}return result}function order(g){var maxRank$1=maxRank(g),downLayerGraphs=buildLayerGraphs(g,range(1,maxRank$1+1),"inEdges"),upLayerGraphs=buildLayerGraphs(g,range(maxRank$1-1,-1,-1),"outEdges"),layering=function(g){var visited={},simpleNodes=filter(g.nodes(),function(v){return!g.children(v).length}),maxRank2=max(map(simpleNodes,function(v){return g.node(v).rank})),layers=map(range(maxRank2+1),function(){return[]}),orderedVs=sortBy(simpleNodes,function(v){return g.node(v).rank});return forEach(orderedVs,function dfs2(v){if(!has(visited,v)){visited[v]=!0;var node=g.node(v);layers[node.rank].push(v),forEach(g.successors(v),dfs2)}}),layers}(g);assignOrder(g,layering);for(var best,bestCC=Number.POSITIVE_INFINITY,i=0,lastBest=0;lastBest<4;++i,++lastBest){sweepLayerGraphs(i%2?downLayerGraphs:upLayerGraphs,i%4>=2);var cc=crossCount(g,layering=buildLayerMatrix(g));cc<bestCC&&(lastBest=0,best=cloneDeep(layering),bestCC=cc)}assignOrder(g,best)}function buildLayerGraphs(g,ranks,relationship){return map(ranks,function(rank2){return buildLayerGraph(g,rank2,relationship)})}function sweepLayerGraphs(layerGraphs,biasRight){var cg=new Graph;forEach(layerGraphs,function(lg){var root=lg.graph().root,sorted=sortSubgraph(lg,root,cg,biasRight);forEach(sorted.vs,function(v,i){lg.node(v).order=i}),function(g,cg,vs){var rootPrev,prev={};forEach(vs,function(v){for(var parent,prevChild,child=g.parent(v);child;){if((parent=g.parent(child))?(prevChild=prev[parent],prev[parent]=child):(prevChild=rootPrev,rootPrev=child),prevChild&&prevChild!==child)return void cg.setEdge(prevChild,child);child=parent}})}(lg,cg,sorted.vs)})}function assignOrder(g,layering){forEach(layering,function(layer){forEach(layer,function(v,i){g.node(v).order=i})})}function parentDummyChains(g){var postorderNums=function(g){var result={},lim=0;function dfs2(v){var low=lim;forEach(g.children(v),dfs2),result[v]={low:low,lim:lim++}}return forEach(g.children(),dfs2),result}(g);forEach(g.graph().dummyChains,function(v){for(var node=g.node(v),edgeObj=node.edgeObj,pathData=function(g,postorderNums,v,w){var parent,lca,vPath=[],wPath=[],low=Math.min(postorderNums[v].low,postorderNums[w].low),lim=Math.max(postorderNums[v].lim,postorderNums[w].lim);parent=v;do{parent=g.parent(parent),vPath.push(parent)}while(parent&&(postorderNums[parent].low>low||lim>postorderNums[parent].lim));lca=parent,parent=w;for(;(parent=g.parent(parent))!==lca;)wPath.push(parent);return{path:vPath.concat(wPath.reverse()),lca:lca}}(g,postorderNums,edgeObj.v,edgeObj.w),path=pathData.path,lca=pathData.lca,pathIdx=0,pathV=path[pathIdx],ascending=!0;v!==edgeObj.w;){if(node=g.node(v),ascending){for(;(pathV=path[pathIdx])!==lca&&g.node(pathV).maxRank<node.rank;)pathIdx++;pathV===lca&&(ascending=!1)}if(!ascending){for(;pathIdx<path.length-1&&g.node(pathV=path[pathIdx+1]).minRank<=node.rank;)pathIdx++;pathV=path[pathIdx]}g.setParent(v,pathV),v=g.successors(v)[0]}})}function findType1Conflicts(g,layering){var conflicts={};return reduce(layering,function(prevLayer,layer){var k0=0,scanPos=0,prevLayerLength=prevLayer.length,lastNode=last(layer);return forEach(layer,function(v,i){var w=function(g,v){if(g.node(v).dummy)return find(g.predecessors(v),function(u){return g.node(u).dummy})}(g,v),k1=w?g.node(w).order:prevLayerLength;(w||v===lastNode)&&(forEach(layer.slice(scanPos,i+1),function(scanNode){forEach(g.predecessors(scanNode),function(u){var uLabel=g.node(u),uPos=uLabel.order;!(uPos<k0||k1<uPos)||uLabel.dummy&&g.node(scanNode).dummy||addConflict(conflicts,u,scanNode)})}),scanPos=i+1,k0=k1)}),layer}),conflicts}function addConflict(conflicts,v,w){if(v>w){var tmp=v;v=w,w=tmp}Object.prototype.hasOwnProperty.call(conflicts,v)||Object.defineProperty(conflicts,v,{enumerable:!0,configurable:!0,value:{},writable:!0});var conflictsV=conflicts[v];Object.defineProperty(conflictsV,w,{enumerable:!0,configurable:!0,value:!0,writable:!0})}function hasConflict(conflicts,v,w){if(v>w){var tmp=v;v=w,w=tmp}return!!conflicts[v]&&Object.prototype.hasOwnProperty.call(conflicts[v],w)}function horizontalCompaction(g,layering,root,align,reverseSep){var xs={},blockG=function(g,layering,root,reverseSep){var blockGraph=new Graph,graphLabel=g.graph(),sepFn=function(nodeSep,edgeSep,reverseSep){return function(g,v,w){var delta,vLabel=g.node(v),wLabel=g.node(w),sum=0;if(sum+=vLabel.width/2,Object.prototype.hasOwnProperty.call(vLabel,"labelpos"))switch(vLabel.labelpos.toLowerCase()){case"l":delta=-vLabel.width/2;break;case"r":delta=vLabel.width/2}if(delta&&(sum+=reverseSep?delta:-delta),delta=0,sum+=(vLabel.dummy?edgeSep:nodeSep)/2,sum+=(wLabel.dummy?edgeSep:nodeSep)/2,sum+=wLabel.width/2,Object.prototype.hasOwnProperty.call(wLabel,"labelpos"))switch(wLabel.labelpos.toLowerCase()){case"l":delta=wLabel.width/2;break;case"r":delta=-wLabel.width/2}return delta&&(sum+=reverseSep?delta:-delta),delta=0,sum}}(graphLabel.nodesep,graphLabel.edgesep,reverseSep);return forEach(layering,function(layer){var u;forEach(layer,function(v){var vRoot=root[v];if(blockGraph.setNode(vRoot),u){var uRoot=root[u],prevMax=blockGraph.edge(uRoot,vRoot);blockGraph.setEdge(uRoot,vRoot,Math.max(sepFn(g,v,u),prevMax||0))}u=v})}),blockGraph}(g,layering,root,reverseSep),borderType=reverseSep?"borderLeft":"borderRight";function iterate(setXsFunc,nextNodesFunc){for(var stack=blockG.nodes(),elem=stack.pop(),visited={};elem;)visited[elem]?setXsFunc(elem):(visited[elem]=!0,stack.push(elem),stack=stack.concat(nextNodesFunc(elem))),elem=stack.pop()}return iterate(function(elem){xs[elem]=blockG.inEdges(elem).reduce(function(acc,e){return Math.max(acc,xs[e.v]+blockG.edge(e))},0)},blockG.predecessors.bind(blockG)),iterate(function(elem){var min2=blockG.outEdges(elem).reduce(function(acc,e){return Math.min(acc,xs[e.w]-blockG.edge(e))},Number.POSITIVE_INFINITY),node=g.node(elem);min2!==Number.POSITIVE_INFINITY&&node.borderType!==borderType&&(xs[elem]=Math.max(xs[elem],min2))},blockG.successors.bind(blockG)),forEach(align,function(v){xs[v]=xs[root[v]]}),xs}function findSmallestWidthAlignment(g,xss){return minBy(values(xss),function(xs){var object,iteratee,max2=Number.NEGATIVE_INFINITY,min2=Number.POSITIVE_INFINITY;return iteratee=function(x,v){var halfWidth=function(g,v){return g.node(v).width}(g,v)/2;max2=Math.max(x+halfWidth,max2),min2=Math.min(x-halfWidth,min2)},null==(object=xs)||baseFor(object,castFunction(iteratee),keysIn),max2-min2})}function positionX(g){var adjustedLayering,layering=buildLayerMatrix(g),conflicts=merge(findType1Conflicts(g,layering),function(g,layering){var conflicts={};function scan(south,southPos,southEnd,prevNorthBorder,nextNorthBorder){var v;forEach(range(southPos,southEnd),function(i){v=south[i],g.node(v).dummy&&forEach(g.predecessors(v),function(u){var uNode=g.node(u);uNode.dummy&&(uNode.order<prevNorthBorder||uNode.order>nextNorthBorder)&&addConflict(conflicts,u,v)})})}return reduce(layering,function(north,south){var nextNorthPos,prevNorthPos=-1,southPos=0;return forEach(south,function(v,southLookahead){if("border"===g.node(v).dummy){var predecessors=g.predecessors(v);predecessors.length&&(nextNorthPos=g.node(predecessors[0]).order,scan(south,southPos,southLookahead,prevNorthPos,nextNorthPos),southPos=southLookahead,prevNorthPos=nextNorthPos)}scan(south,southPos,south.length,nextNorthPos,north.length)}),south}),conflicts}(g,layering)),xss={};forEach(["u","d"],function(vert){adjustedLayering="u"===vert?layering:values(layering).reverse(),forEach(["l","r"],function(horiz){"r"===horiz&&(adjustedLayering=map(adjustedLayering,function(inner){return values(inner).reverse()}));var neighborFn=("u"===vert?g.predecessors:g.successors).bind(g),align=function(g,layering,conflicts,neighborFn){var root={},align={},pos={};return forEach(layering,function(layer){forEach(layer,function(v,order2){root[v]=v,align[v]=v,pos[v]=order2})}),forEach(layering,function(layer){var prevIdx=-1;forEach(layer,function(v){var ws=neighborFn(v);if(ws.length)for(var mp=((ws=sortBy(ws,function(w2){return pos[w2]})).length-1)/2,i=Math.floor(mp),il=Math.ceil(mp);i<=il;++i){var w=ws[i];align[v]===v&&prevIdx<pos[w]&&!hasConflict(conflicts,v,w)&&(align[w]=v,align[v]=root[v]=root[w],prevIdx=pos[w])}})}),{root:root,align:align}}(0,adjustedLayering,conflicts,neighborFn),xs=horizontalCompaction(g,adjustedLayering,align.root,align.align,"r"===horiz);"r"===horiz&&(xs=mapValues(xs,function(x){return-x})),xss[vert+horiz]=xs})});var smallestWidth=findSmallestWidthAlignment(g,xss);return function(xss,alignTo){var alignToVals=values(alignTo),alignToMin=min(alignToVals),alignToMax=max(alignToVals);forEach(["u","d"],function(vert){forEach(["l","r"],function(horiz){var delta,alignment=vert+horiz,xs=xss[alignment];if(xs!==alignTo){var xsVals=values(xs);(delta="l"===horiz?alignToMin-min(xsVals):alignToMax-max(xsVals))&&(xss[alignment]=mapValues(xs,function(x){return x+delta}))}})})}(xss,smallestWidth),function(xss,align){return mapValues(xss.ul,function(ignore,v){if(align)return xss[align.toLowerCase()][v];var xs=sortBy(map(xss,v));return(xs[1]+xs[2])/2})}(xss,g.graph().align)}function position(g){var object,iteratee;(function(g){var layering=buildLayerMatrix(g),rankSep=g.graph().ranksep,prevY=0;forEach(layering,function(layer){var maxHeight=max(map(layer,function(v){return g.node(v).height}));forEach(layer,function(v){g.node(v).y=prevY+maxHeight/2}),prevY+=maxHeight+rankSep})})(g=asNonCompoundGraph(g)),object=positionX(g),iteratee=function(x,v){g.node(v).x=x},object&&baseForOwn(object,castFunction(iteratee))}function layout(g,opts){var time=notime;time("layout",()=>{var layoutGraph=time(" buildLayoutGraph",()=>function(inputGraph){var g=new Graph({multigraph:!0,compound:!0}),graph=canonicalize(inputGraph.graph());return g.setGraph(merge({},graphDefaults,selectNumberAttrs(graph,graphNumAttrs),pick(graph,graphAttrs))),forEach(inputGraph.nodes(),function(v){var node=canonicalize(inputGraph.node(v));g.setNode(v,defaults(selectNumberAttrs(node,nodeNumAttrs),nodeDefaults)),g.setParent(v,inputGraph.parent(v))}),forEach(inputGraph.edges(),function(e){var edge=canonicalize(inputGraph.edge(e));g.setEdge(e,merge({},edgeDefaults,selectNumberAttrs(edge,edgeNumAttrs),pick(edge,edgeAttrs)))}),g}(g));time(" runLayout",()=>function(g,time){time(" makeSpaceForEdgeLabels",()=>function(g){var graph=g.graph();graph.ranksep/=2,forEach(g.edges(),function(e){var edge=g.edge(e);edge.minlen*=2,"c"!==edge.labelpos.toLowerCase()&&("TB"===graph.rankdir||"BT"===graph.rankdir?edge.width+=edge.labeloffset:edge.height+=edge.labeloffset)})}(g)),time(" removeSelfEdges",()=>function(g){forEach(g.edges(),function(e){if(e.v===e.w){var node=g.node(e.v);node.selfEdges||(node.selfEdges=[]),node.selfEdges.push({e:e,label:g.edge(e)}),g.removeEdge(e)}})}(g)),time(" acyclic",()=>run$2(g)),time(" nestingGraph.run",()=>run(g)),time(" rank",()=>rank(asNonCompoundGraph(g))),time(" injectEdgeLabelProxies",()=>function(g){forEach(g.edges(),function(e){var edge=g.edge(e);if(edge.width&&edge.height){var v=g.node(e.v),label={rank:(g.node(e.w).rank-v.rank)/2+v.rank,e:e};addDummyNode(g,"edge-proxy",label,"_ep")}})}(g)),time(" removeEmptyRanks",()=>function(g){var offset=min(map(g.nodes(),function(v){return g.node(v).rank})),layers=[];forEach(g.nodes(),function(v){var rank2=g.node(v).rank-offset;layers[rank2]||(layers[rank2]=[]),layers[rank2].push(v)});var delta=0,nodeRankFactor=g.graph().nodeRankFactor;forEach(layers,function(vs,i){isUndefined(vs)&&i%nodeRankFactor!==0?--delta:delta&&forEach(vs,function(v){g.node(v).rank+=delta})})}(g)),time(" nestingGraph.cleanup",()=>function(g){var graphLabel=g.graph();g.removeNode(graphLabel.nestingRoot),delete graphLabel.nestingRoot,forEach(g.edges(),function(e){g.edge(e).nestingEdge&&g.removeEdge(e)})}(g)),time(" normalizeRanks",()=>function(g){var min$1=min(map(g.nodes(),function(v){return g.node(v).rank}));forEach(g.nodes(),function(v){var node=g.node(v);has(node,"rank")&&(node.rank-=min$1)})}(g)),time(" assignRankMinMax",()=>function(g){var maxRank2=0;forEach(g.nodes(),function(v){var node=g.node(v);node.borderTop&&(node.minRank=g.node(node.borderTop).rank,node.maxRank=g.node(node.borderBottom).rank,maxRank2=max(maxRank2,node.maxRank))}),g.graph().maxRank=maxRank2}(g)),time(" removeEdgeLabelProxies",()=>function(g){forEach(g.nodes(),function(v){var node=g.node(v);"edge-proxy"===node.dummy&&(g.edge(node.e).labelRank=node.rank,g.removeNode(v))})}(g)),time(" normalize.run",()=>run$1(g)),time(" parentDummyChains",()=>parentDummyChains(g)),time(" addBorderSegments",()=>function(g){forEach(g.children(),function dfs2(v){var children=g.children(v),node=g.node(v);if(children.length&&forEach(children,dfs2),Object.prototype.hasOwnProperty.call(node,"minRank")){node.borderLeft=[],node.borderRight=[];for(var rank2=node.minRank,maxRank2=node.maxRank+1;rank2<maxRank2;++rank2)addBorderNode(g,"borderLeft","_bl",v,node,rank2),addBorderNode(g,"borderRight","_br",v,node,rank2)}})}(g)),time(" order",()=>order(g)),time(" insertSelfEdges",()=>function(g){var layers=buildLayerMatrix(g);forEach(layers,function(layer){var orderShift=0;forEach(layer,function(v,i){var node=g.node(v);node.order=i+orderShift,forEach(node.selfEdges,function(selfEdge){addDummyNode(g,"selfedge",{width:selfEdge.label.width,height:selfEdge.label.height,rank:node.rank,order:i+ ++orderShift,e:selfEdge.e,label:selfEdge.label},"_se")}),delete node.selfEdges})})}(g)),time(" adjustCoordinateSystem",()=>function(g){var rankDir=g.graph().rankdir.toLowerCase();"lr"!==rankDir&&"rl"!==rankDir||swapWidthHeight(g)}(g)),time(" position",()=>position(g)),time(" positionSelfEdges",()=>function(g){forEach(g.nodes(),function(v){var node=g.node(v);if("selfedge"===node.dummy){var selfNode=g.node(node.e.v),x=selfNode.x+selfNode.width/2,y=selfNode.y,dx=node.x-x,dy=selfNode.height/2;g.setEdge(node.e,node.label),g.removeNode(v),node.label.points=[{x:x+2*dx/3,y:y-dy},{x:x+5*dx/6,y:y-dy},{x:x+dx,y:y},{x:x+5*dx/6,y:y+dy},{x:x+2*dx/3,y:y+dy}],node.label.x=node.x,node.label.y=node.y}})}(g)),time(" removeBorderNodes",()=>function(g){forEach(g.nodes(),function(v){if(g.children(v).length){var node=g.node(v),t=g.node(node.borderTop),b=g.node(node.borderBottom),l=g.node(last(node.borderLeft)),r=g.node(last(node.borderRight));node.width=Math.abs(r.x-l.x),node.height=Math.abs(b.y-t.y),node.x=l.x+node.width/2,node.y=t.y+node.height/2}}),forEach(g.nodes(),function(v){"border"===g.node(v).dummy&&g.removeNode(v)})}(g)),time(" normalize.undo",()=>function(g){forEach(g.graph().dummyChains,function(v){var w,node=g.node(v),origLabel=node.edgeLabel;for(g.setEdge(node.edgeObj,origLabel);node.dummy;)w=g.successors(v)[0],g.removeNode(v),origLabel.points.push({x:node.x,y:node.y}),"edge-label"===node.dummy&&(origLabel.x=node.x,origLabel.y=node.y,origLabel.width=node.width,origLabel.height=node.height),v=w,node=g.node(v)})}(g)),time(" fixupEdgeLabelCoords",()=>function(g){forEach(g.edges(),function(e){var edge=g.edge(e);if(Object.prototype.hasOwnProperty.call(edge,"x"))switch("l"!==edge.labelpos&&"r"!==edge.labelpos||(edge.width-=edge.labeloffset),edge.labelpos){case"l":edge.x-=edge.width/2+edge.labeloffset;break;case"r":edge.x+=edge.width/2+edge.labeloffset}})}(g)),time(" undoCoordinateSystem",()=>undo$1(g)),time(" translateGraph",()=>function(g){var minX=Number.POSITIVE_INFINITY,maxX=0,minY=Number.POSITIVE_INFINITY,maxY=0,graphLabel=g.graph(),marginX=graphLabel.marginx||0,marginY=graphLabel.marginy||0;function getExtremes(attrs){var x=attrs.x,y=attrs.y,w=attrs.width,h=attrs.height;minX=Math.min(minX,x-w/2),maxX=Math.max(maxX,x+w/2),minY=Math.min(minY,y-h/2),maxY=Math.max(maxY,y+h/2)}forEach(g.nodes(),function(v){getExtremes(g.node(v))}),forEach(g.edges(),function(e){var edge=g.edge(e);Object.prototype.hasOwnProperty.call(edge,"x")&&getExtremes(edge)}),minX-=marginX,minY-=marginY,forEach(g.nodes(),function(v){var node=g.node(v);node.x-=minX,node.y-=minY}),forEach(g.edges(),function(e){var edge=g.edge(e);forEach(edge.points,function(p){p.x-=minX,p.y-=minY}),Object.prototype.hasOwnProperty.call(edge,"x")&&(edge.x-=minX),Object.prototype.hasOwnProperty.call(edge,"y")&&(edge.y-=minY)}),graphLabel.width=maxX-minX+marginX,graphLabel.height=maxY-minY+marginY}(g)),time(" assignNodeIntersects",()=>function(g){forEach(g.edges(),function(e){var p1,p2,edge=g.edge(e),nodeV=g.node(e.v),nodeW=g.node(e.w);edge.points?(p1=edge.points[0],p2=edge.points[edge.points.length-1]):(edge.points=[],p1=nodeW,p2=nodeV),edge.points.unshift(intersectRect(nodeV,p1)),edge.points.push(intersectRect(nodeW,p2))})}(g)),time(" reversePoints",()=>function(g){forEach(g.edges(),function(e){var edge=g.edge(e);edge.reversed&&edge.points.reverse()})}(g)),time(" acyclic.undo",()=>function(g){forEach(g.edges(),function(e){var label=g.edge(e);if(label.reversed){g.removeEdge(e);var forwardName=label.forwardName;delete label.reversed,delete label.forwardName,g.setEdge(e.w,e.v,label,forwardName)}})}(g))}(layoutGraph,time)),time(" updateInputGraph",()=>function(inputGraph,layoutGraph){forEach(inputGraph.nodes(),function(v){var inputLabel=inputGraph.node(v),layoutLabel=layoutGraph.node(v);inputLabel&&(inputLabel.x=layoutLabel.x,inputLabel.y=layoutLabel.y,layoutGraph.children(v).length&&(inputLabel.width=layoutLabel.width,inputLabel.height=layoutLabel.height))}),forEach(inputGraph.edges(),function(e){var inputLabel=inputGraph.edge(e),layoutLabel=layoutGraph.edge(e);inputLabel.points=layoutLabel.points,Object.prototype.hasOwnProperty.call(layoutLabel,"x")&&(inputLabel.x=layoutLabel.x,inputLabel.y=layoutLabel.y)}),inputGraph.graph().width=layoutGraph.graph().width,inputGraph.graph().height=layoutGraph.graph().height}(g,layoutGraph))})}var graphNumAttrs=["nodesep","edgesep","ranksep","marginx","marginy"],graphDefaults={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},graphAttrs=["acyclicer","ranker","rankdir","align"],nodeNumAttrs=["width","height"],nodeDefaults={width:0,height:0},edgeNumAttrs=["minlen","weight","width","height","labeloffset"],edgeDefaults={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},edgeAttrs=["labelpos"];function selectNumberAttrs(obj,attrs){return mapValues(pick(obj,attrs),Number)}function canonicalize(attrs){var newAttrs={};return forEach(attrs,function(v,k){newAttrs[k.toLowerCase()]=v}),newAttrs}export{layout as l};
1
+ import{b as baseClone,G as Graph,i as isUndefined,v as values}from"./graph-NObGxitU.js";import{i as isSymbol,c as baseIteratee,k as keys,o as baseFindIndex,p as castFunction,q as baseForOwn,t as hasPath,u as castPath,v as toKey,w as baseGet,d as arrayMap,x as hasIn,b as baseFlatten,y as toString,n as forEach,m as filter,r as reduce}from"./_baseUniq-DiLy7vi3.js";import{f as flatten,b as baseExtremum,a as baseLt,c as baseMap,m as map,d as min}from"./min-CowkZam8.js";import{a_ as isObject,bw as setToString,bx as overRest,b5 as baseRest,by as isIterateeCall,aR as keysIn,bp as eq,aF as isArrayLike,bu as baseFor,bz as baseAssignValue,aH as identity,bt as isIndex,b4 as assignValue,aG as isArray,aY as baseUnary,b7 as constant,bA as merge}from"./mermaid.core-YnqOkuoS.js";var reWhitespace=/\s/;var reTrimStart=/^\s+/;function baseTrim(string){return string?string.slice(0,function(string){for(var index=string.length;index--&&reWhitespace.test(string.charAt(index)););return index}(string)+1).replace(reTrimStart,""):string}var reIsBadHex=/^[-+]0x[0-9a-f]+$/i,reIsBinary=/^0b[01]+$/i,reIsOctal=/^0o[0-7]+$/i,freeParseInt=parseInt;function toFinite(value){return value?Infinity===(value=function(value){if("number"==typeof value)return value;if(isSymbol(value))return NaN;if(isObject(value)){var other="function"==typeof value.valueOf?value.valueOf():value;value=isObject(other)?other+"":other}if("string"!=typeof value)return 0===value?value:+value;value=baseTrim(value);var isBinary=reIsBinary.test(value);return isBinary||reIsOctal.test(value)?freeParseInt(value.slice(2),isBinary?2:8):reIsBadHex.test(value)?NaN:+value}(value))||-Infinity===value?17976931348623157e292*(value<0?-1:1):value==value?value:0:0===value?value:0}function cloneDeep(value){return baseClone(value,5)}var objectProto$1=Object.prototype,hasOwnProperty$1=objectProto$1.hasOwnProperty,defaults=baseRest(function(object,sources){object=Object(object);var index=-1,length=sources.length,guard=length>2?sources[2]:void 0;for(guard&&isIterateeCall(sources[0],sources[1],guard)&&(length=1);++index<length;)for(var source=sources[index],props=keysIn(source),propsIndex=-1,propsLength=props.length;++propsIndex<propsLength;){var key=props[propsIndex],value=object[key];(void 0===value||eq(value,objectProto$1[key])&&!hasOwnProperty$1.call(object,key))&&(object[key]=source[key])}return object});function last(array){var length=null==array?0:array.length;return length?array[length-1]:void 0}var nativeMax$1=Math.max;var findIndexFunc,find=(findIndexFunc=function(array,predicate,fromIndex){var length=null==array?0:array.length;if(!length)return-1;var result,remainder,index=null==fromIndex?0:(result=toFinite(fromIndex),remainder=result%1,result==result?remainder?result-remainder:result:0);return index<0&&(index=nativeMax$1(length+index,0)),baseFindIndex(array,baseIteratee(predicate),index)},function(collection,predicate,fromIndex){var iterable=Object(collection);if(!isArrayLike(collection)){var iteratee=baseIteratee(predicate);collection=keys(collection),predicate=function(key){return iteratee(iterable[key],key,iterable)}}var index=findIndexFunc(collection,predicate,fromIndex);return index>-1?iterable[iteratee?collection[index]:index]:void 0});function baseGt(value,other){return value>other}var hasOwnProperty=Object.prototype.hasOwnProperty;function baseHas(object,key){return null!=object&&hasOwnProperty.call(object,key)}function has(object,path){return null!=object&&hasPath(object,path,baseHas)}function mapValues(object,iteratee){var result={};return iteratee=baseIteratee(iteratee),baseForOwn(object,function(value,key,object2){baseAssignValue(result,key,iteratee(value,key,object2))}),result}function max(array){return array&&array.length?baseExtremum(array,identity,baseGt):void 0}function minBy(array,iteratee){return array&&array.length?baseExtremum(array,baseIteratee(iteratee),baseLt):void 0}function baseSet(object,path,value,customizer){if(!isObject(object))return object;for(var index=-1,length=(path=castPath(path,object)).length,lastIndex=length-1,nested=object;null!=nested&&++index<length;){var key=toKey(path[index]),newValue=value;if("__proto__"===key||"constructor"===key||"prototype"===key)return object;if(index!=lastIndex){var objValue=nested[key];void 0===(newValue=void 0)&&(newValue=isObject(objValue)?objValue:isIndex(path[index+1])?[]:{})}assignValue(nested,key,newValue),nested=nested[key]}return object}function compareAscending(value,other){if(value!==other){var valIsDefined=void 0!==value,valIsNull=null===value,valIsReflexive=value==value,valIsSymbol=isSymbol(value),othIsDefined=void 0!==other,othIsNull=null===other,othIsReflexive=other==other,othIsSymbol=isSymbol(other);if(!othIsNull&&!othIsSymbol&&!valIsSymbol&&value>other||valIsSymbol&&othIsDefined&&othIsReflexive&&!othIsNull&&!othIsSymbol||valIsNull&&othIsDefined&&othIsReflexive||!valIsDefined&&othIsReflexive||!valIsReflexive)return 1;if(!valIsNull&&!valIsSymbol&&!othIsSymbol&&value<other||othIsSymbol&&valIsDefined&&valIsReflexive&&!valIsNull&&!valIsSymbol||othIsNull&&valIsDefined&&valIsReflexive||!othIsDefined&&valIsReflexive||!othIsReflexive)return-1}return 0}function baseOrderBy(collection,iteratees,orders){iteratees=iteratees.length?arrayMap(iteratees,function(iteratee){return isArray(iteratee)?function(value){return baseGet(value,1===iteratee.length?iteratee[0]:iteratee)}:iteratee}):[identity];var index=-1;return iteratees=arrayMap(iteratees,baseUnary(baseIteratee)),function(array,comparer){var length=array.length;for(array.sort(comparer);length--;)array[length]=array[length].value;return array}(baseMap(collection,function(value,key,collection2){return{criteria:arrayMap(iteratees,function(iteratee){return iteratee(value)}),index:++index,value:value}}),function(object,other){return function(object,other,orders){for(var index=-1,objCriteria=object.criteria,othCriteria=other.criteria,length=objCriteria.length,ordersLength=orders.length;++index<length;){var result=compareAscending(objCriteria[index],othCriteria[index]);if(result)return index>=ordersLength?result:result*("desc"==orders[index]?-1:1)}return object.index-other.index}(object,other,orders)})}function basePick(object,paths){return function(object,paths,predicate){for(var index=-1,length=paths.length,result={};++index<length;){var path=paths[index],value=baseGet(object,path);predicate(value,path)&&baseSet(result,castPath(path,object),value)}return result}(object,paths,function(value,path){return hasIn(object,path)})}var func,pick=setToString(overRest(func=function(object,paths){return null==object?{}:basePick(object,paths)},void 0,flatten),func+""),nativeCeil=Math.ceil,nativeMax=Math.max;var range=function(start,end,step){return step&&"number"!=typeof step&&isIterateeCall(start,end,step)&&(end=step=void 0),start=toFinite(start),void 0===end?(end=start,start=0):end=toFinite(end),function(start,end,step){for(var index=-1,length=nativeMax(nativeCeil((end-start)/(step||1)),0),result=Array(length);length--;)result[++index]=start,start+=step;return result}(start,end,step=void 0===step?start<end?1:-1:toFinite(step))},sortBy=baseRest(function(collection,iteratees){if(null==collection)return[];var length=iteratees.length;return length>1&&isIterateeCall(collection,iteratees[0],iteratees[1])?iteratees=[]:length>2&&isIterateeCall(iteratees[0],iteratees[1],iteratees[2])&&(iteratees=[iteratees[0]]),baseOrderBy(collection,baseFlatten(iteratees),[])}),idCounter=0;function uniqueId(prefix){var id=++idCounter;return toString(prefix)+id}class List{constructor(){var sentinel={};sentinel._next=sentinel._prev=sentinel,this._sentinel=sentinel}dequeue(){var sentinel=this._sentinel,entry=sentinel._prev;if(entry!==sentinel)return unlink(entry),entry}enqueue(entry){var sentinel=this._sentinel;entry._prev&&entry._next&&unlink(entry),entry._next=sentinel._next,sentinel._next._prev=entry,sentinel._next=entry,entry._prev=sentinel}toString(){for(var strs=[],sentinel=this._sentinel,curr=sentinel._prev;curr!==sentinel;)strs.push(JSON.stringify(curr,filterOutLinks)),curr=curr._prev;return"["+strs.join(", ")+"]"}}function unlink(entry){entry._prev._next=entry._next,entry._next._prev=entry._prev,delete entry._next,delete entry._prev}function filterOutLinks(k,v){if("_next"!==k&&"_prev"!==k)return v}var DEFAULT_WEIGHT_FN=constant(1);function greedyFAS(g,weightFn){if(g.nodeCount()<=1)return[];var state=function(g,weightFn){var fasGraph=new Graph,maxIn=0,maxOut=0;forEach(g.nodes(),function(v){fasGraph.setNode(v,{v:v,in:0,out:0})}),forEach(g.edges(),function(e){var prevWeight=fasGraph.edge(e.v,e.w)||0,weight=weightFn(e),edgeWeight=prevWeight+weight;fasGraph.setEdge(e.v,e.w,edgeWeight),maxOut=Math.max(maxOut,fasGraph.node(e.v).out+=weight),maxIn=Math.max(maxIn,fasGraph.node(e.w).in+=weight)});var buckets=range(maxOut+maxIn+3).map(function(){return new List}),zeroIdx=maxIn+1;return forEach(fasGraph.nodes(),function(v){assignBucket(buckets,zeroIdx,fasGraph.node(v))}),{graph:fasGraph,buckets:buckets,zeroIdx:zeroIdx}}(g,weightFn||DEFAULT_WEIGHT_FN),results=function(g,buckets,zeroIdx){var entry,results=[],sources=buckets[buckets.length-1],sinks=buckets[0];for(;g.nodeCount();){for(;entry=sinks.dequeue();)removeNode(g,buckets,zeroIdx,entry);for(;entry=sources.dequeue();)removeNode(g,buckets,zeroIdx,entry);if(g.nodeCount())for(var i=buckets.length-2;i>0;--i)if(entry=buckets[i].dequeue()){results=results.concat(removeNode(g,buckets,zeroIdx,entry,!0));break}}return results}(state.graph,state.buckets,state.zeroIdx);return flatten(map(results,function(e){return g.outEdges(e.v,e.w)}))}function removeNode(g,buckets,zeroIdx,entry,collectPredecessors){var results=collectPredecessors?[]:void 0;return forEach(g.inEdges(entry.v),function(edge){var weight=g.edge(edge),uEntry=g.node(edge.v);collectPredecessors&&results.push({v:edge.v,w:edge.w}),uEntry.out-=weight,assignBucket(buckets,zeroIdx,uEntry)}),forEach(g.outEdges(entry.v),function(edge){var weight=g.edge(edge),w=edge.w,wEntry=g.node(w);wEntry.in-=weight,assignBucket(buckets,zeroIdx,wEntry)}),g.removeNode(entry.v),results}function assignBucket(buckets,zeroIdx,entry){entry.out?entry.in?buckets[entry.out-entry.in+zeroIdx].enqueue(entry):buckets[buckets.length-1].enqueue(entry):buckets[0].enqueue(entry)}function run$2(g){var g2,fas="greedy"===g.graph().acyclicer?greedyFAS(g,(g2=g,function(e){return g2.edge(e).weight})):function(g){var fas=[],stack={},visited={};function dfs2(v){Object.prototype.hasOwnProperty.call(visited,v)||(visited[v]=!0,stack[v]=!0,forEach(g.outEdges(v),function(e){Object.prototype.hasOwnProperty.call(stack,e.w)?fas.push(e):dfs2(e.w)}),delete stack[v])}return forEach(g.nodes(),dfs2),fas}(g);forEach(fas,function(e){var label=g.edge(e);g.removeEdge(e),label.forwardName=e.name,label.reversed=!0,g.setEdge(e.w,e.v,label,uniqueId("rev"))})}function addDummyNode(g,type,attrs,name){var v;do{v=uniqueId(name)}while(g.hasNode(v));return attrs.dummy=type,g.setNode(v,attrs),v}function asNonCompoundGraph(g){var simplified=new Graph({multigraph:g.isMultigraph()}).setGraph(g.graph());return forEach(g.nodes(),function(v){g.children(v).length||simplified.setNode(v,g.node(v))}),forEach(g.edges(),function(e){simplified.setEdge(e,g.edge(e))}),simplified}function intersectRect(rect,point){var sx,sy,x=rect.x,y=rect.y,dx=point.x-x,dy=point.y-y,w=rect.width/2,h=rect.height/2;if(!dx&&!dy)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(dy)*w>Math.abs(dx)*h?(dy<0&&(h=-h),sx=h*dx/dy,sy=h):(dx<0&&(w=-w),sx=w,sy=w*dy/dx),{x:x+sx,y:y+sy}}function buildLayerMatrix(g){var layering=map(range(maxRank(g)+1),function(){return[]});return forEach(g.nodes(),function(v){var node=g.node(v),rank2=node.rank;isUndefined(rank2)||(layering[rank2][node.order]=v)}),layering}function addBorderNode$1(g,prefix,rank2,order2){var node={width:0,height:0};return arguments.length>=4&&(node.rank=rank2,node.order=order2),addDummyNode(g,"border",node,prefix)}function maxRank(g){return max(map(g.nodes(),function(v){var rank2=g.node(v).rank;if(!isUndefined(rank2))return rank2}))}function notime(name,fn){return fn()}function addBorderNode(g,prop,prefix,sg,sgNode,rank2){var label={width:0,height:0,rank:rank2,borderType:prop},prev=sgNode[prop][rank2-1],curr=addDummyNode(g,"border",label,prefix);sgNode[prop][rank2]=curr,g.setParent(curr,sg),prev&&g.setEdge(prev,curr,{weight:1})}function undo$1(g){var rankDir=g.graph().rankdir.toLowerCase();"bt"!==rankDir&&"rl"!==rankDir||function(g){forEach(g.nodes(),function(v){reverseYOne(g.node(v))}),forEach(g.edges(),function(e){var edge=g.edge(e);forEach(edge.points,reverseYOne),Object.prototype.hasOwnProperty.call(edge,"y")&&reverseYOne(edge)})}(g),"lr"!==rankDir&&"rl"!==rankDir||(!function(g){forEach(g.nodes(),function(v){swapXYOne(g.node(v))}),forEach(g.edges(),function(e){var edge=g.edge(e);forEach(edge.points,swapXYOne),Object.prototype.hasOwnProperty.call(edge,"x")&&swapXYOne(edge)})}(g),swapWidthHeight(g))}function swapWidthHeight(g){forEach(g.nodes(),function(v){swapWidthHeightOne(g.node(v))}),forEach(g.edges(),function(e){swapWidthHeightOne(g.edge(e))})}function swapWidthHeightOne(attrs){var w=attrs.width;attrs.width=attrs.height,attrs.height=w}function reverseYOne(attrs){attrs.y=-attrs.y}function swapXYOne(attrs){var x=attrs.x;attrs.x=attrs.y,attrs.y=x}function run$1(g){g.graph().dummyChains=[],forEach(g.edges(),function(edge){!function(g,e){var v=e.v,vRank=g.node(v).rank,w=e.w,wRank=g.node(w).rank,name=e.name,edgeLabel=g.edge(e),labelRank=edgeLabel.labelRank;if(wRank===vRank+1)return;g.removeEdge(e);var dummy,i,attrs=void 0;for(i=0,++vRank;vRank<wRank;++i,++vRank)edgeLabel.points=[],dummy=addDummyNode(g,"edge",attrs={width:0,height:0,edgeLabel:edgeLabel,edgeObj:e,rank:vRank},"_d"),vRank===labelRank&&(attrs.width=edgeLabel.width,attrs.height=edgeLabel.height,attrs.dummy="edge-label",attrs.labelpos=edgeLabel.labelpos),g.setEdge(v,dummy,{weight:edgeLabel.weight},name),0===i&&g.graph().dummyChains.push(dummy),v=dummy;g.setEdge(v,w,{weight:edgeLabel.weight},name)}(g,edge)})}function longestPath(g){var visited={};forEach(g.sources(),function dfs2(v){var label=g.node(v);if(Object.prototype.hasOwnProperty.call(visited,v))return label.rank;visited[v]=!0;var rank2=min(map(g.outEdges(v),function(e){return dfs2(e.w)-g.edge(e).minlen}));return rank2!==Number.POSITIVE_INFINITY&&null!=rank2||(rank2=0),label.rank=rank2})}function slack(g,e){return g.node(e.w).rank-g.node(e.v).rank-g.edge(e).minlen}function feasibleTree(g){var edge,delta,t=new Graph({directed:!1}),start=g.nodes()[0],size=g.nodeCount();for(t.setNode(start,{});tightTree(t,g)<size;)edge=findMinSlackEdge(t,g),delta=t.hasNode(edge.v)?slack(g,edge):-slack(g,edge),shiftRanks(t,g,delta);return t}function tightTree(t,g){return forEach(t.nodes(),function dfs2(v){forEach(g.nodeEdges(v),function(e){var edgeV=e.v,w=v===edgeV?e.w:edgeV;t.hasNode(w)||slack(g,e)||(t.setNode(w,{}),t.setEdge(v,w,{}),dfs2(w))})}),t.nodeCount()}function findMinSlackEdge(t,g){return minBy(g.edges(),function(e){if(t.hasNode(e.v)!==t.hasNode(e.w))return slack(g,e)})}function shiftRanks(t,g,delta){forEach(t.nodes(),function(v){g.node(v).rank+=delta})}function dfs$1(g,vs,order2){isArray(vs)||(vs=[vs]);var navigation=(g.isDirected()?g.successors:g.neighbors).bind(g),acc=[],visited={};return forEach(vs,function(v){if(!g.hasNode(v))throw new Error("Graph does not have node: "+v);doDfs(g,v,"post"===order2,visited,navigation,acc)}),acc}function doDfs(g,v,postorder2,visited,navigation,acc){Object.prototype.hasOwnProperty.call(visited,v)||(visited[v]=!0,postorder2||acc.push(v),forEach(navigation(v),function(w){doDfs(g,w,postorder2,visited,navigation,acc)}),postorder2&&acc.push(v))}function networkSimplex(g){g=function(g){var simplified=(new Graph).setGraph(g.graph());return forEach(g.nodes(),function(v){simplified.setNode(v,g.node(v))}),forEach(g.edges(),function(e){var simpleLabel=simplified.edge(e.v,e.w)||{weight:0,minlen:1},label=g.edge(e);simplified.setEdge(e.v,e.w,{weight:simpleLabel.weight+label.weight,minlen:Math.max(simpleLabel.minlen,label.minlen)})}),simplified}(g),longestPath(g);var e,t=feasibleTree(g);for(initLowLimValues(t),initCutValues(t,g);e=leaveEdge(t);)exchangeEdges(t,g,e,enterEdge(t,g,e))}function initCutValues(t,g){var vs=function(g,vs){return dfs$1(g,vs,"post")}(t,t.nodes());vs=vs.slice(0,vs.length-1),forEach(vs,function(v){!function(t,g,child){var childLab=t.node(child),parent=childLab.parent;t.edge(child,parent).cutvalue=calcCutValue(t,g,child)}(t,g,v)})}function calcCutValue(t,g,child){var parent=t.node(child).parent,childIsTail=!0,graphEdge=g.edge(child,parent),cutValue=0;return graphEdge||(childIsTail=!1,graphEdge=g.edge(parent,child)),cutValue=graphEdge.weight,forEach(g.nodeEdges(child),function(e){var u,v,isOutEdge=e.v===child,other=isOutEdge?e.w:e.v;if(other!==parent){var pointsToHead=isOutEdge===childIsTail,otherWeight=g.edge(e).weight;if(cutValue+=pointsToHead?otherWeight:-otherWeight,u=child,v=other,t.hasEdge(u,v)){var otherCutValue=t.edge(child,other).cutvalue;cutValue+=pointsToHead?-otherCutValue:otherCutValue}}}),cutValue}function initLowLimValues(tree,root){arguments.length<2&&(root=tree.nodes()[0]),dfsAssignLowLim(tree,{},1,root)}function dfsAssignLowLim(tree,visited,nextLim,v,parent){var low=nextLim,label=tree.node(v);return visited[v]=!0,forEach(tree.neighbors(v),function(w){Object.prototype.hasOwnProperty.call(visited,w)||(nextLim=dfsAssignLowLim(tree,visited,nextLim,w,v))}),label.low=low,label.lim=nextLim++,parent?label.parent=parent:delete label.parent,nextLim}function leaveEdge(tree){return find(tree.edges(),function(e){return tree.edge(e).cutvalue<0})}function enterEdge(t,g,edge){var v=edge.v,w=edge.w;g.hasEdge(v,w)||(v=edge.w,w=edge.v);var vLabel=t.node(v),wLabel=t.node(w),tailLabel=vLabel,flip=!1;return vLabel.lim>wLabel.lim&&(tailLabel=wLabel,flip=!0),minBy(filter(g.edges(),function(edge2){return flip===isDescendant(t,t.node(edge2.v),tailLabel)&&flip!==isDescendant(t,t.node(edge2.w),tailLabel)}),function(edge2){return slack(g,edge2)})}function exchangeEdges(t,g,e,f){var v=e.v,w=e.w;t.removeEdge(v,w),t.setEdge(f.v,f.w,{}),initLowLimValues(t),initCutValues(t,g),function(t,g){var root=find(t.nodes(),function(v){return!g.node(v).parent}),vs=function(g,vs){return dfs$1(g,vs,"pre")}(t,root);vs=vs.slice(1),forEach(vs,function(v){var parent=t.node(v).parent,edge=g.edge(v,parent),flipped=!1;edge||(edge=g.edge(parent,v),flipped=!0),g.node(v).rank=g.node(parent).rank+(flipped?edge.minlen:-edge.minlen)})}(t,g)}function isDescendant(tree,vLabel,rootLabel){return rootLabel.low<=vLabel.lim&&vLabel.lim<=rootLabel.lim}function rank(g){switch(g.graph().ranker){case"network-simplex":default:networkSimplexRanker(g);break;case"tight-tree":!function(g){longestPath(g),feasibleTree(g)}(g);break;case"longest-path":longestPathRanker(g)}}new Error,networkSimplex.initLowLimValues=initLowLimValues,networkSimplex.initCutValues=initCutValues,networkSimplex.calcCutValue=calcCutValue,networkSimplex.leaveEdge=leaveEdge,networkSimplex.enterEdge=enterEdge,networkSimplex.exchangeEdges=exchangeEdges;var longestPathRanker=longestPath;function networkSimplexRanker(g){networkSimplex(g)}function run(g){var root=addDummyNode(g,"root",{},"_root"),depths=function(g){var depths={};function dfs2(v,depth){var children=g.children(v);children&&children.length&&forEach(children,function(child){dfs2(child,depth+1)}),depths[v]=depth}return forEach(g.children(),function(v){dfs2(v,1)}),depths}(g),height=max(values(depths))-1,nodeSep=2*height+1;g.graph().nestingRoot=root,forEach(g.edges(),function(e){g.edge(e).minlen*=nodeSep});var weight=function(g){return reduce(g.edges(),function(acc,e){return acc+g.edge(e).weight},0)}(g)+1;forEach(g.children(),function(child){dfs(g,root,nodeSep,weight,height,depths,child)}),g.graph().nodeRankFactor=nodeSep}function dfs(g,root,nodeSep,weight,height,depths,v){var children=g.children(v);if(children.length){var top=addBorderNode$1(g,"_bt"),bottom=addBorderNode$1(g,"_bb"),label=g.node(v);g.setParent(top,v),label.borderTop=top,g.setParent(bottom,v),label.borderBottom=bottom,forEach(children,function(child){dfs(g,root,nodeSep,weight,height,depths,child);var childNode=g.node(child),childTop=childNode.borderTop?childNode.borderTop:child,childBottom=childNode.borderBottom?childNode.borderBottom:child,thisWeight=childNode.borderTop?weight:2*weight,minlen=childTop!==childBottom?1:height-depths[v]+1;g.setEdge(top,childTop,{weight:thisWeight,minlen:minlen,nestingEdge:!0}),g.setEdge(childBottom,bottom,{weight:thisWeight,minlen:minlen,nestingEdge:!0})}),g.parent(v)||g.setEdge(root,top,{weight:0,minlen:height+depths[v]})}else v!==root&&g.setEdge(root,v,{weight:0,minlen:nodeSep})}function buildLayerGraph(g,rank2,relationship){var root=function(g){var v;for(;g.hasNode(v=uniqueId("_root")););return v}(g),result=new Graph({compound:!0}).setGraph({root:root}).setDefaultNodeLabel(function(v){return g.node(v)});return forEach(g.nodes(),function(v){var node=g.node(v),parent=g.parent(v);(node.rank===rank2||node.minRank<=rank2&&rank2<=node.maxRank)&&(result.setNode(v),result.setParent(v,parent||root),forEach(g[relationship](v),function(e){var u=e.v===v?e.w:e.v,edge=result.edge(u,v),weight=isUndefined(edge)?0:edge.weight;result.setEdge(u,v,{weight:g.edge(e).weight+weight})}),Object.prototype.hasOwnProperty.call(node,"minRank")&&result.setNode(v,{borderLeft:node.borderLeft[rank2],borderRight:node.borderRight[rank2]}))}),result}function crossCount(g,layering){for(var cc=0,i=1;i<layering.length;++i)cc+=twoLayerCrossCount(g,layering[i-1],layering[i]);return cc}function twoLayerCrossCount(g,northLayer,southLayer){for(var props,values2,southPos=(props=southLayer,values2=map(southLayer,function(v,i){return i}),function(props,values2,assignFunc){for(var index=-1,length=props.length,valsLength=values2.length,result={};++index<length;){var value=index<valsLength?values2[index]:void 0;assignFunc(result,props[index],value)}return result}(props||[],values2||[],assignValue)),southEntries=flatten(map(northLayer,function(v){return sortBy(map(g.outEdges(v),function(e){return{pos:southPos[e.w],weight:g.edge(e).weight}}),"pos")})),firstIndex=1;firstIndex<southLayer.length;)firstIndex<<=1;var treeSize=2*firstIndex-1;firstIndex-=1;var tree=map(new Array(treeSize),function(){return 0}),cc=0;return forEach(southEntries.forEach(function(entry){var index=entry.pos+firstIndex;tree[index]+=entry.weight;for(var weightSum=0;index>0;)index%2&&(weightSum+=tree[index+1]),tree[index=index-1>>1]+=entry.weight;cc+=entry.weight*weightSum})),cc}function resolveConflicts(entries,cg){var mappedEntries={};return forEach(entries,function(entry,i){var tmp=mappedEntries[entry.v]={indegree:0,in:[],out:[],vs:[entry.v],i:i};isUndefined(entry.barycenter)||(tmp.barycenter=entry.barycenter,tmp.weight=entry.weight)}),forEach(cg.edges(),function(e){var entryV=mappedEntries[e.v],entryW=mappedEntries[e.w];isUndefined(entryV)||isUndefined(entryW)||(entryW.indegree++,entryV.out.push(mappedEntries[e.w]))}),function(sourceSet){var entries=[];function handleIn(vEntry){return function(uEntry){uEntry.merged||(isUndefined(uEntry.barycenter)||isUndefined(vEntry.barycenter)||uEntry.barycenter>=vEntry.barycenter)&&function(target,source){var sum=0,weight=0;target.weight&&(sum+=target.barycenter*target.weight,weight+=target.weight);source.weight&&(sum+=source.barycenter*source.weight,weight+=source.weight);target.vs=source.vs.concat(target.vs),target.barycenter=sum/weight,target.weight=weight,target.i=Math.min(source.i,target.i),source.merged=!0}(vEntry,uEntry)}}function handleOut(vEntry){return function(wEntry){wEntry.in.push(vEntry),0===--wEntry.indegree&&sourceSet.push(wEntry)}}for(;sourceSet.length;){var entry=sourceSet.pop();entries.push(entry),forEach(entry.in.reverse(),handleIn(entry)),forEach(entry.out,handleOut(entry))}return map(filter(entries,function(entry2){return!entry2.merged}),function(entry2){return pick(entry2,["vs","i","barycenter","weight"])})}(filter(mappedEntries,function(entry){return!entry.indegree}))}function sort(entries,biasRight){var bias,parts=function(collection,fn){var result={lhs:[],rhs:[]};return forEach(collection,function(value){fn(value)?result.lhs.push(value):result.rhs.push(value)}),result}(entries,function(entry){return Object.prototype.hasOwnProperty.call(entry,"barycenter")}),sortable=parts.lhs,unsortable=sortBy(parts.rhs,function(entry){return-entry.i}),vs=[],sum=0,weight=0,vsIndex=0;sortable.sort((bias=!!biasRight,function(entryV,entryW){return entryV.barycenter<entryW.barycenter?-1:entryV.barycenter>entryW.barycenter?1:bias?entryW.i-entryV.i:entryV.i-entryW.i})),vsIndex=consumeUnsortable(vs,unsortable,vsIndex),forEach(sortable,function(entry){vsIndex+=entry.vs.length,vs.push(entry.vs),sum+=entry.barycenter*entry.weight,weight+=entry.weight,vsIndex=consumeUnsortable(vs,unsortable,vsIndex)});var result={vs:flatten(vs)};return weight&&(result.barycenter=sum/weight,result.weight=weight),result}function consumeUnsortable(vs,unsortable,index){for(var last$1;unsortable.length&&(last$1=last(unsortable)).i<=index;)unsortable.pop(),vs.push(last$1.vs),index++;return index}function sortSubgraph(g,v,cg,biasRight){var movable=g.children(v),node=g.node(v),bl=node?node.borderLeft:void 0,br=node?node.borderRight:void 0,subgraphs={};bl&&(movable=filter(movable,function(w){return w!==bl&&w!==br}));var barycenters=function(g,movable){return map(movable,function(v){var inV=g.inEdges(v);if(inV.length){var result=reduce(inV,function(acc,e){var edge=g.edge(e),nodeU=g.node(e.v);return{sum:acc.sum+edge.weight*nodeU.order,weight:acc.weight+edge.weight}},{sum:0,weight:0});return{v:v,barycenter:result.sum/result.weight,weight:result.weight}}return{v:v}})}(g,movable);forEach(barycenters,function(entry){if(g.children(entry.v).length){var subgraphResult=sortSubgraph(g,entry.v,cg,biasRight);subgraphs[entry.v]=subgraphResult,Object.prototype.hasOwnProperty.call(subgraphResult,"barycenter")&&(other=subgraphResult,isUndefined((target=entry).barycenter)?(target.barycenter=other.barycenter,target.weight=other.weight):(target.barycenter=(target.barycenter*target.weight+other.barycenter*other.weight)/(target.weight+other.weight),target.weight+=other.weight))}var target,other});var entries=resolveConflicts(barycenters,cg);!function(entries,subgraphs){forEach(entries,function(entry){entry.vs=flatten(entry.vs.map(function(v){return subgraphs[v]?subgraphs[v].vs:v}))})}(entries,subgraphs);var result=sort(entries,biasRight);if(bl&&(result.vs=flatten([bl,result.vs,br]),g.predecessors(bl).length)){var blPred=g.node(g.predecessors(bl)[0]),brPred=g.node(g.predecessors(br)[0]);Object.prototype.hasOwnProperty.call(result,"barycenter")||(result.barycenter=0,result.weight=0),result.barycenter=(result.barycenter*result.weight+blPred.order+brPred.order)/(result.weight+2),result.weight+=2}return result}function order(g){var maxRank$1=maxRank(g),downLayerGraphs=buildLayerGraphs(g,range(1,maxRank$1+1),"inEdges"),upLayerGraphs=buildLayerGraphs(g,range(maxRank$1-1,-1,-1),"outEdges"),layering=function(g){var visited={},simpleNodes=filter(g.nodes(),function(v){return!g.children(v).length}),maxRank2=max(map(simpleNodes,function(v){return g.node(v).rank})),layers=map(range(maxRank2+1),function(){return[]}),orderedVs=sortBy(simpleNodes,function(v){return g.node(v).rank});return forEach(orderedVs,function dfs2(v){if(!has(visited,v)){visited[v]=!0;var node=g.node(v);layers[node.rank].push(v),forEach(g.successors(v),dfs2)}}),layers}(g);assignOrder(g,layering);for(var best,bestCC=Number.POSITIVE_INFINITY,i=0,lastBest=0;lastBest<4;++i,++lastBest){sweepLayerGraphs(i%2?downLayerGraphs:upLayerGraphs,i%4>=2);var cc=crossCount(g,layering=buildLayerMatrix(g));cc<bestCC&&(lastBest=0,best=cloneDeep(layering),bestCC=cc)}assignOrder(g,best)}function buildLayerGraphs(g,ranks,relationship){return map(ranks,function(rank2){return buildLayerGraph(g,rank2,relationship)})}function sweepLayerGraphs(layerGraphs,biasRight){var cg=new Graph;forEach(layerGraphs,function(lg){var root=lg.graph().root,sorted=sortSubgraph(lg,root,cg,biasRight);forEach(sorted.vs,function(v,i){lg.node(v).order=i}),function(g,cg,vs){var rootPrev,prev={};forEach(vs,function(v){for(var parent,prevChild,child=g.parent(v);child;){if((parent=g.parent(child))?(prevChild=prev[parent],prev[parent]=child):(prevChild=rootPrev,rootPrev=child),prevChild&&prevChild!==child)return void cg.setEdge(prevChild,child);child=parent}})}(lg,cg,sorted.vs)})}function assignOrder(g,layering){forEach(layering,function(layer){forEach(layer,function(v,i){g.node(v).order=i})})}function parentDummyChains(g){var postorderNums=function(g){var result={},lim=0;function dfs2(v){var low=lim;forEach(g.children(v),dfs2),result[v]={low:low,lim:lim++}}return forEach(g.children(),dfs2),result}(g);forEach(g.graph().dummyChains,function(v){for(var node=g.node(v),edgeObj=node.edgeObj,pathData=function(g,postorderNums,v,w){var parent,lca,vPath=[],wPath=[],low=Math.min(postorderNums[v].low,postorderNums[w].low),lim=Math.max(postorderNums[v].lim,postorderNums[w].lim);parent=v;do{parent=g.parent(parent),vPath.push(parent)}while(parent&&(postorderNums[parent].low>low||lim>postorderNums[parent].lim));lca=parent,parent=w;for(;(parent=g.parent(parent))!==lca;)wPath.push(parent);return{path:vPath.concat(wPath.reverse()),lca:lca}}(g,postorderNums,edgeObj.v,edgeObj.w),path=pathData.path,lca=pathData.lca,pathIdx=0,pathV=path[pathIdx],ascending=!0;v!==edgeObj.w;){if(node=g.node(v),ascending){for(;(pathV=path[pathIdx])!==lca&&g.node(pathV).maxRank<node.rank;)pathIdx++;pathV===lca&&(ascending=!1)}if(!ascending){for(;pathIdx<path.length-1&&g.node(pathV=path[pathIdx+1]).minRank<=node.rank;)pathIdx++;pathV=path[pathIdx]}g.setParent(v,pathV),v=g.successors(v)[0]}})}function findType1Conflicts(g,layering){var conflicts={};return reduce(layering,function(prevLayer,layer){var k0=0,scanPos=0,prevLayerLength=prevLayer.length,lastNode=last(layer);return forEach(layer,function(v,i){var w=function(g,v){if(g.node(v).dummy)return find(g.predecessors(v),function(u){return g.node(u).dummy})}(g,v),k1=w?g.node(w).order:prevLayerLength;(w||v===lastNode)&&(forEach(layer.slice(scanPos,i+1),function(scanNode){forEach(g.predecessors(scanNode),function(u){var uLabel=g.node(u),uPos=uLabel.order;!(uPos<k0||k1<uPos)||uLabel.dummy&&g.node(scanNode).dummy||addConflict(conflicts,u,scanNode)})}),scanPos=i+1,k0=k1)}),layer}),conflicts}function addConflict(conflicts,v,w){if(v>w){var tmp=v;v=w,w=tmp}Object.prototype.hasOwnProperty.call(conflicts,v)||Object.defineProperty(conflicts,v,{enumerable:!0,configurable:!0,value:{},writable:!0});var conflictsV=conflicts[v];Object.defineProperty(conflictsV,w,{enumerable:!0,configurable:!0,value:!0,writable:!0})}function hasConflict(conflicts,v,w){if(v>w){var tmp=v;v=w,w=tmp}return!!conflicts[v]&&Object.prototype.hasOwnProperty.call(conflicts[v],w)}function horizontalCompaction(g,layering,root,align,reverseSep){var xs={},blockG=function(g,layering,root,reverseSep){var blockGraph=new Graph,graphLabel=g.graph(),sepFn=function(nodeSep,edgeSep,reverseSep){return function(g,v,w){var delta,vLabel=g.node(v),wLabel=g.node(w),sum=0;if(sum+=vLabel.width/2,Object.prototype.hasOwnProperty.call(vLabel,"labelpos"))switch(vLabel.labelpos.toLowerCase()){case"l":delta=-vLabel.width/2;break;case"r":delta=vLabel.width/2}if(delta&&(sum+=reverseSep?delta:-delta),delta=0,sum+=(vLabel.dummy?edgeSep:nodeSep)/2,sum+=(wLabel.dummy?edgeSep:nodeSep)/2,sum+=wLabel.width/2,Object.prototype.hasOwnProperty.call(wLabel,"labelpos"))switch(wLabel.labelpos.toLowerCase()){case"l":delta=wLabel.width/2;break;case"r":delta=-wLabel.width/2}return delta&&(sum+=reverseSep?delta:-delta),delta=0,sum}}(graphLabel.nodesep,graphLabel.edgesep,reverseSep);return forEach(layering,function(layer){var u;forEach(layer,function(v){var vRoot=root[v];if(blockGraph.setNode(vRoot),u){var uRoot=root[u],prevMax=blockGraph.edge(uRoot,vRoot);blockGraph.setEdge(uRoot,vRoot,Math.max(sepFn(g,v,u),prevMax||0))}u=v})}),blockGraph}(g,layering,root,reverseSep),borderType=reverseSep?"borderLeft":"borderRight";function iterate(setXsFunc,nextNodesFunc){for(var stack=blockG.nodes(),elem=stack.pop(),visited={};elem;)visited[elem]?setXsFunc(elem):(visited[elem]=!0,stack.push(elem),stack=stack.concat(nextNodesFunc(elem))),elem=stack.pop()}return iterate(function(elem){xs[elem]=blockG.inEdges(elem).reduce(function(acc,e){return Math.max(acc,xs[e.v]+blockG.edge(e))},0)},blockG.predecessors.bind(blockG)),iterate(function(elem){var min2=blockG.outEdges(elem).reduce(function(acc,e){return Math.min(acc,xs[e.w]-blockG.edge(e))},Number.POSITIVE_INFINITY),node=g.node(elem);min2!==Number.POSITIVE_INFINITY&&node.borderType!==borderType&&(xs[elem]=Math.max(xs[elem],min2))},blockG.successors.bind(blockG)),forEach(align,function(v){xs[v]=xs[root[v]]}),xs}function findSmallestWidthAlignment(g,xss){return minBy(values(xss),function(xs){var object,iteratee,max2=Number.NEGATIVE_INFINITY,min2=Number.POSITIVE_INFINITY;return iteratee=function(x,v){var halfWidth=function(g,v){return g.node(v).width}(g,v)/2;max2=Math.max(x+halfWidth,max2),min2=Math.min(x-halfWidth,min2)},null==(object=xs)||baseFor(object,castFunction(iteratee),keysIn),max2-min2})}function positionX(g){var adjustedLayering,layering=buildLayerMatrix(g),conflicts=merge(findType1Conflicts(g,layering),function(g,layering){var conflicts={};function scan(south,southPos,southEnd,prevNorthBorder,nextNorthBorder){var v;forEach(range(southPos,southEnd),function(i){v=south[i],g.node(v).dummy&&forEach(g.predecessors(v),function(u){var uNode=g.node(u);uNode.dummy&&(uNode.order<prevNorthBorder||uNode.order>nextNorthBorder)&&addConflict(conflicts,u,v)})})}return reduce(layering,function(north,south){var nextNorthPos,prevNorthPos=-1,southPos=0;return forEach(south,function(v,southLookahead){if("border"===g.node(v).dummy){var predecessors=g.predecessors(v);predecessors.length&&(nextNorthPos=g.node(predecessors[0]).order,scan(south,southPos,southLookahead,prevNorthPos,nextNorthPos),southPos=southLookahead,prevNorthPos=nextNorthPos)}scan(south,southPos,south.length,nextNorthPos,north.length)}),south}),conflicts}(g,layering)),xss={};forEach(["u","d"],function(vert){adjustedLayering="u"===vert?layering:values(layering).reverse(),forEach(["l","r"],function(horiz){"r"===horiz&&(adjustedLayering=map(adjustedLayering,function(inner){return values(inner).reverse()}));var neighborFn=("u"===vert?g.predecessors:g.successors).bind(g),align=function(g,layering,conflicts,neighborFn){var root={},align={},pos={};return forEach(layering,function(layer){forEach(layer,function(v,order2){root[v]=v,align[v]=v,pos[v]=order2})}),forEach(layering,function(layer){var prevIdx=-1;forEach(layer,function(v){var ws=neighborFn(v);if(ws.length)for(var mp=((ws=sortBy(ws,function(w2){return pos[w2]})).length-1)/2,i=Math.floor(mp),il=Math.ceil(mp);i<=il;++i){var w=ws[i];align[v]===v&&prevIdx<pos[w]&&!hasConflict(conflicts,v,w)&&(align[w]=v,align[v]=root[v]=root[w],prevIdx=pos[w])}})}),{root:root,align:align}}(0,adjustedLayering,conflicts,neighborFn),xs=horizontalCompaction(g,adjustedLayering,align.root,align.align,"r"===horiz);"r"===horiz&&(xs=mapValues(xs,function(x){return-x})),xss[vert+horiz]=xs})});var smallestWidth=findSmallestWidthAlignment(g,xss);return function(xss,alignTo){var alignToVals=values(alignTo),alignToMin=min(alignToVals),alignToMax=max(alignToVals);forEach(["u","d"],function(vert){forEach(["l","r"],function(horiz){var delta,alignment=vert+horiz,xs=xss[alignment];if(xs!==alignTo){var xsVals=values(xs);(delta="l"===horiz?alignToMin-min(xsVals):alignToMax-max(xsVals))&&(xss[alignment]=mapValues(xs,function(x){return x+delta}))}})})}(xss,smallestWidth),function(xss,align){return mapValues(xss.ul,function(ignore,v){if(align)return xss[align.toLowerCase()][v];var xs=sortBy(map(xss,v));return(xs[1]+xs[2])/2})}(xss,g.graph().align)}function position(g){var object,iteratee;(function(g){var layering=buildLayerMatrix(g),rankSep=g.graph().ranksep,prevY=0;forEach(layering,function(layer){var maxHeight=max(map(layer,function(v){return g.node(v).height}));forEach(layer,function(v){g.node(v).y=prevY+maxHeight/2}),prevY+=maxHeight+rankSep})})(g=asNonCompoundGraph(g)),object=positionX(g),iteratee=function(x,v){g.node(v).x=x},object&&baseForOwn(object,castFunction(iteratee))}function layout(g,opts){var time=notime;time("layout",()=>{var layoutGraph=time(" buildLayoutGraph",()=>function(inputGraph){var g=new Graph({multigraph:!0,compound:!0}),graph=canonicalize(inputGraph.graph());return g.setGraph(merge({},graphDefaults,selectNumberAttrs(graph,graphNumAttrs),pick(graph,graphAttrs))),forEach(inputGraph.nodes(),function(v){var node=canonicalize(inputGraph.node(v));g.setNode(v,defaults(selectNumberAttrs(node,nodeNumAttrs),nodeDefaults)),g.setParent(v,inputGraph.parent(v))}),forEach(inputGraph.edges(),function(e){var edge=canonicalize(inputGraph.edge(e));g.setEdge(e,merge({},edgeDefaults,selectNumberAttrs(edge,edgeNumAttrs),pick(edge,edgeAttrs)))}),g}(g));time(" runLayout",()=>function(g,time){time(" makeSpaceForEdgeLabels",()=>function(g){var graph=g.graph();graph.ranksep/=2,forEach(g.edges(),function(e){var edge=g.edge(e);edge.minlen*=2,"c"!==edge.labelpos.toLowerCase()&&("TB"===graph.rankdir||"BT"===graph.rankdir?edge.width+=edge.labeloffset:edge.height+=edge.labeloffset)})}(g)),time(" removeSelfEdges",()=>function(g){forEach(g.edges(),function(e){if(e.v===e.w){var node=g.node(e.v);node.selfEdges||(node.selfEdges=[]),node.selfEdges.push({e:e,label:g.edge(e)}),g.removeEdge(e)}})}(g)),time(" acyclic",()=>run$2(g)),time(" nestingGraph.run",()=>run(g)),time(" rank",()=>rank(asNonCompoundGraph(g))),time(" injectEdgeLabelProxies",()=>function(g){forEach(g.edges(),function(e){var edge=g.edge(e);if(edge.width&&edge.height){var v=g.node(e.v),label={rank:(g.node(e.w).rank-v.rank)/2+v.rank,e:e};addDummyNode(g,"edge-proxy",label,"_ep")}})}(g)),time(" removeEmptyRanks",()=>function(g){var offset=min(map(g.nodes(),function(v){return g.node(v).rank})),layers=[];forEach(g.nodes(),function(v){var rank2=g.node(v).rank-offset;layers[rank2]||(layers[rank2]=[]),layers[rank2].push(v)});var delta=0,nodeRankFactor=g.graph().nodeRankFactor;forEach(layers,function(vs,i){isUndefined(vs)&&i%nodeRankFactor!==0?--delta:delta&&forEach(vs,function(v){g.node(v).rank+=delta})})}(g)),time(" nestingGraph.cleanup",()=>function(g){var graphLabel=g.graph();g.removeNode(graphLabel.nestingRoot),delete graphLabel.nestingRoot,forEach(g.edges(),function(e){g.edge(e).nestingEdge&&g.removeEdge(e)})}(g)),time(" normalizeRanks",()=>function(g){var min$1=min(map(g.nodes(),function(v){return g.node(v).rank}));forEach(g.nodes(),function(v){var node=g.node(v);has(node,"rank")&&(node.rank-=min$1)})}(g)),time(" assignRankMinMax",()=>function(g){var maxRank2=0;forEach(g.nodes(),function(v){var node=g.node(v);node.borderTop&&(node.minRank=g.node(node.borderTop).rank,node.maxRank=g.node(node.borderBottom).rank,maxRank2=max(maxRank2,node.maxRank))}),g.graph().maxRank=maxRank2}(g)),time(" removeEdgeLabelProxies",()=>function(g){forEach(g.nodes(),function(v){var node=g.node(v);"edge-proxy"===node.dummy&&(g.edge(node.e).labelRank=node.rank,g.removeNode(v))})}(g)),time(" normalize.run",()=>run$1(g)),time(" parentDummyChains",()=>parentDummyChains(g)),time(" addBorderSegments",()=>function(g){forEach(g.children(),function dfs2(v){var children=g.children(v),node=g.node(v);if(children.length&&forEach(children,dfs2),Object.prototype.hasOwnProperty.call(node,"minRank")){node.borderLeft=[],node.borderRight=[];for(var rank2=node.minRank,maxRank2=node.maxRank+1;rank2<maxRank2;++rank2)addBorderNode(g,"borderLeft","_bl",v,node,rank2),addBorderNode(g,"borderRight","_br",v,node,rank2)}})}(g)),time(" order",()=>order(g)),time(" insertSelfEdges",()=>function(g){var layers=buildLayerMatrix(g);forEach(layers,function(layer){var orderShift=0;forEach(layer,function(v,i){var node=g.node(v);node.order=i+orderShift,forEach(node.selfEdges,function(selfEdge){addDummyNode(g,"selfedge",{width:selfEdge.label.width,height:selfEdge.label.height,rank:node.rank,order:i+ ++orderShift,e:selfEdge.e,label:selfEdge.label},"_se")}),delete node.selfEdges})})}(g)),time(" adjustCoordinateSystem",()=>function(g){var rankDir=g.graph().rankdir.toLowerCase();"lr"!==rankDir&&"rl"!==rankDir||swapWidthHeight(g)}(g)),time(" position",()=>position(g)),time(" positionSelfEdges",()=>function(g){forEach(g.nodes(),function(v){var node=g.node(v);if("selfedge"===node.dummy){var selfNode=g.node(node.e.v),x=selfNode.x+selfNode.width/2,y=selfNode.y,dx=node.x-x,dy=selfNode.height/2;g.setEdge(node.e,node.label),g.removeNode(v),node.label.points=[{x:x+2*dx/3,y:y-dy},{x:x+5*dx/6,y:y-dy},{x:x+dx,y:y},{x:x+5*dx/6,y:y+dy},{x:x+2*dx/3,y:y+dy}],node.label.x=node.x,node.label.y=node.y}})}(g)),time(" removeBorderNodes",()=>function(g){forEach(g.nodes(),function(v){if(g.children(v).length){var node=g.node(v),t=g.node(node.borderTop),b=g.node(node.borderBottom),l=g.node(last(node.borderLeft)),r=g.node(last(node.borderRight));node.width=Math.abs(r.x-l.x),node.height=Math.abs(b.y-t.y),node.x=l.x+node.width/2,node.y=t.y+node.height/2}}),forEach(g.nodes(),function(v){"border"===g.node(v).dummy&&g.removeNode(v)})}(g)),time(" normalize.undo",()=>function(g){forEach(g.graph().dummyChains,function(v){var w,node=g.node(v),origLabel=node.edgeLabel;for(g.setEdge(node.edgeObj,origLabel);node.dummy;)w=g.successors(v)[0],g.removeNode(v),origLabel.points.push({x:node.x,y:node.y}),"edge-label"===node.dummy&&(origLabel.x=node.x,origLabel.y=node.y,origLabel.width=node.width,origLabel.height=node.height),v=w,node=g.node(v)})}(g)),time(" fixupEdgeLabelCoords",()=>function(g){forEach(g.edges(),function(e){var edge=g.edge(e);if(Object.prototype.hasOwnProperty.call(edge,"x"))switch("l"!==edge.labelpos&&"r"!==edge.labelpos||(edge.width-=edge.labeloffset),edge.labelpos){case"l":edge.x-=edge.width/2+edge.labeloffset;break;case"r":edge.x+=edge.width/2+edge.labeloffset}})}(g)),time(" undoCoordinateSystem",()=>undo$1(g)),time(" translateGraph",()=>function(g){var minX=Number.POSITIVE_INFINITY,maxX=0,minY=Number.POSITIVE_INFINITY,maxY=0,graphLabel=g.graph(),marginX=graphLabel.marginx||0,marginY=graphLabel.marginy||0;function getExtremes(attrs){var x=attrs.x,y=attrs.y,w=attrs.width,h=attrs.height;minX=Math.min(minX,x-w/2),maxX=Math.max(maxX,x+w/2),minY=Math.min(minY,y-h/2),maxY=Math.max(maxY,y+h/2)}forEach(g.nodes(),function(v){getExtremes(g.node(v))}),forEach(g.edges(),function(e){var edge=g.edge(e);Object.prototype.hasOwnProperty.call(edge,"x")&&getExtremes(edge)}),minX-=marginX,minY-=marginY,forEach(g.nodes(),function(v){var node=g.node(v);node.x-=minX,node.y-=minY}),forEach(g.edges(),function(e){var edge=g.edge(e);forEach(edge.points,function(p){p.x-=minX,p.y-=minY}),Object.prototype.hasOwnProperty.call(edge,"x")&&(edge.x-=minX),Object.prototype.hasOwnProperty.call(edge,"y")&&(edge.y-=minY)}),graphLabel.width=maxX-minX+marginX,graphLabel.height=maxY-minY+marginY}(g)),time(" assignNodeIntersects",()=>function(g){forEach(g.edges(),function(e){var p1,p2,edge=g.edge(e),nodeV=g.node(e.v),nodeW=g.node(e.w);edge.points?(p1=edge.points[0],p2=edge.points[edge.points.length-1]):(edge.points=[],p1=nodeW,p2=nodeV),edge.points.unshift(intersectRect(nodeV,p1)),edge.points.push(intersectRect(nodeW,p2))})}(g)),time(" reversePoints",()=>function(g){forEach(g.edges(),function(e){var edge=g.edge(e);edge.reversed&&edge.points.reverse()})}(g)),time(" acyclic.undo",()=>function(g){forEach(g.edges(),function(e){var label=g.edge(e);if(label.reversed){g.removeEdge(e);var forwardName=label.forwardName;delete label.reversed,delete label.forwardName,g.setEdge(e.w,e.v,label,forwardName)}})}(g))}(layoutGraph,time)),time(" updateInputGraph",()=>function(inputGraph,layoutGraph){forEach(inputGraph.nodes(),function(v){var inputLabel=inputGraph.node(v),layoutLabel=layoutGraph.node(v);inputLabel&&(inputLabel.x=layoutLabel.x,inputLabel.y=layoutLabel.y,layoutGraph.children(v).length&&(inputLabel.width=layoutLabel.width,inputLabel.height=layoutLabel.height))}),forEach(inputGraph.edges(),function(e){var inputLabel=inputGraph.edge(e),layoutLabel=layoutGraph.edge(e);inputLabel.points=layoutLabel.points,Object.prototype.hasOwnProperty.call(layoutLabel,"x")&&(inputLabel.x=layoutLabel.x,inputLabel.y=layoutLabel.y)}),inputGraph.graph().width=layoutGraph.graph().width,inputGraph.graph().height=layoutGraph.graph().height}(g,layoutGraph))})}var graphNumAttrs=["nodesep","edgesep","ranksep","marginx","marginy"],graphDefaults={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},graphAttrs=["acyclicer","ranker","rankdir","align"],nodeNumAttrs=["width","height"],nodeDefaults={width:0,height:0},edgeNumAttrs=["minlen","weight","width","height","labeloffset"],edgeDefaults={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},edgeAttrs=["labelpos"];function selectNumberAttrs(obj,attrs){return mapValues(pick(obj,attrs),Number)}function canonicalize(attrs){var newAttrs={};return forEach(attrs,function(v,k){newAttrs[k.toLowerCase()]=v}),newAttrs}export{layout as l};
@@ -1 +1 @@
1
- import{aL as constant,aM as interpolateNumber,aN as color,aO as interpolateRgb,aP as interpolateString}from"./mermaid.core-f1mZHh7u.js";import{i as initRange}from"./init-DMZMl1PR.js";import{e as exponent,f as formatSpecifier,a as formatPrefix,b as format}from"./defaultLocale-DZ7E7S9R.js";function ascending(a,b){return null==a||null==b?NaN:a<b?-1:a>b?1:a>=b?0:NaN}function descending(a,b){return null==a||null==b?NaN:b<a?-1:b>a?1:b>=a?0:NaN}function bisector(f){let compare1,compare2,delta;function left(a,x,lo=0,hi=a.length){if(lo<hi){if(0!==compare1(x,x))return hi;do{const mid=lo+hi>>>1;compare2(a[mid],x)<0?lo=mid+1:hi=mid}while(lo<hi)}return lo}return 2!==f.length?(compare1=ascending,compare2=(d,x)=>ascending(f(d),x),delta=(d,x)=>f(d)-x):(compare1=f===ascending||f===descending?f:zero,compare2=f,delta=f),{left:left,center:function(a,x,lo=0,hi=a.length){const i=left(a,x,lo,hi-1);return i>lo&&delta(a[i-1],x)>-delta(a[i],x)?i-1:i},right:function(a,x,lo=0,hi=a.length){if(lo<hi){if(0!==compare1(x,x))return hi;do{const mid=lo+hi>>>1;compare2(a[mid],x)<=0?lo=mid+1:hi=mid}while(lo<hi)}return lo}}}function zero(){return 0}const bisectRight=bisector(ascending).right;bisector(function(x){return null===x?NaN:+x}).center;const e10=Math.sqrt(50),e5=Math.sqrt(10),e2=Math.sqrt(2);function tickSpec(start,stop,count){const step=(stop-start)/Math.max(0,count),power=Math.floor(Math.log10(step)),error=step/Math.pow(10,power),factor=error>=e10?10:error>=e5?5:error>=e2?2:1;let i1,i2,inc;return power<0?(inc=Math.pow(10,-power)/factor,i1=Math.round(start*inc),i2=Math.round(stop*inc),i1/inc<start&&++i1,i2/inc>stop&&--i2,inc=-inc):(inc=Math.pow(10,power)*factor,i1=Math.round(start/inc),i2=Math.round(stop/inc),i1*inc<start&&++i1,i2*inc>stop&&--i2),i2<i1&&.5<=count&&count<2?tickSpec(start,stop,2*count):[i1,i2,inc]}function tickIncrement(start,stop,count){return tickSpec(start=+start,stop=+stop,count=+count)[2]}function tickStep(start,stop,count){count=+count;const reverse=(stop=+stop)<(start=+start),inc=reverse?tickIncrement(stop,start,count):tickIncrement(start,stop,count);return(reverse?-1:1)*(inc<0?1/-inc:inc)}function numberArray(a,b){b||(b=[]);var i,n=a?Math.min(b.length,a.length):0,c=b.slice();return function(t){for(i=0;i<n;++i)c[i]=a[i]*(1-t)+b[i]*t;return c}}function genericArray(a,b){var i,nb=b?b.length:0,na=a?Math.min(nb,a.length):0,x=new Array(na),c=new Array(nb);for(i=0;i<na;++i)x[i]=interpolate(a[i],b[i]);for(;i<nb;++i)c[i]=b[i];return function(t){for(i=0;i<na;++i)c[i]=x[i](t);return c}}function date(a,b){var d=new Date;return a=+a,b=+b,function(t){return d.setTime(a*(1-t)+b*t),d}}function object(a,b){var k,i={},c={};for(k in null!==a&&"object"==typeof a||(a={}),null!==b&&"object"==typeof b||(b={}),b)k in a?i[k]=interpolate(a[k],b[k]):c[k]=b[k];return function(t){for(k in i)c[k]=i[k](t);return c}}function interpolate(a,b){var c,x,t=typeof b;return null==b||"boolean"===t?constant(b):("number"===t?interpolateNumber:"string"===t?(c=color(b))?(b=c,interpolateRgb):interpolateString:b instanceof color?interpolateRgb:b instanceof Date?date:(x=b,!ArrayBuffer.isView(x)||x instanceof DataView?Array.isArray(b)?genericArray:"function"!=typeof b.valueOf&&"function"!=typeof b.toString||isNaN(b)?object:interpolateNumber:numberArray))(a,b)}function interpolateRound(a,b){return a=+a,b=+b,function(t){return Math.round(a*(1-t)+b*t)}}function number(x){return+x}var unit=[0,1];function identity(x){return x}function normalize(a,b){return(b-=a=+a)?function(x){return(x-a)/b}:(x=isNaN(b)?NaN:.5,function(){return x});var x}function bimap(domain,range,interpolate2){var d0=domain[0],d1=domain[1],r0=range[0],r1=range[1];return d1<d0?(d0=normalize(d1,d0),r0=interpolate2(r1,r0)):(d0=normalize(d0,d1),r0=interpolate2(r0,r1)),function(x){return r0(d0(x))}}function polymap(domain,range,interpolate2){var j=Math.min(domain.length,range.length)-1,d=new Array(j),r=new Array(j),i=-1;for(domain[j]<domain[0]&&(domain=domain.slice().reverse(),range=range.slice().reverse());++i<j;)d[i]=normalize(domain[i],domain[i+1]),r[i]=interpolate2(range[i],range[i+1]);return function(x){var i2=bisectRight(domain,x,1,j)-1;return r[i2](d[i2](x))}}function copy(source,target){return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown())}function transformer(){var transform,untransform,unknown,piecewise,output,input,domain=unit,range=unit,interpolate$1=interpolate,clamp=identity;function rescale(){var a,b,t,n=Math.min(domain.length,range.length);return clamp!==identity&&(a=domain[0],b=domain[n-1],a>b&&(t=a,a=b,b=t),clamp=function(x){return Math.max(a,Math.min(b,x))}),piecewise=n>2?polymap:bimap,output=input=null,scale}function scale(x){return null==x||isNaN(x=+x)?unknown:(output||(output=piecewise(domain.map(transform),range,interpolate$1)))(transform(clamp(x)))}return scale.invert=function(y){return clamp(untransform((input||(input=piecewise(range,domain.map(transform),interpolateNumber)))(y)))},scale.domain=function(_){return arguments.length?(domain=Array.from(_,number),rescale()):domain.slice()},scale.range=function(_){return arguments.length?(range=Array.from(_),rescale()):range.slice()},scale.rangeRound=function(_){return range=Array.from(_),interpolate$1=interpolateRound,rescale()},scale.clamp=function(_){return arguments.length?(clamp=!!_||identity,rescale()):clamp!==identity},scale.interpolate=function(_){return arguments.length?(interpolate$1=_,rescale()):interpolate$1},scale.unknown=function(_){return arguments.length?(unknown=_,scale):unknown},function(t,u){return transform=t,untransform=u,rescale()}}function continuous(){return transformer()(identity,identity)}function tickFormat(start,stop,count,specifier){var precision,step=tickStep(start,stop,count);switch((specifier=formatSpecifier(null==specifier?",f":specifier)).type){case"s":var value=Math.max(Math.abs(start),Math.abs(stop));return null!=specifier.precision||isNaN(precision=function(step,value){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))-exponent(Math.abs(step)))}(step,value))||(specifier.precision=precision),formatPrefix(specifier,value);case"":case"e":case"g":case"p":case"r":null!=specifier.precision||isNaN(precision=function(step,max){return step=Math.abs(step),max=Math.abs(max)-step,Math.max(0,exponent(max)-exponent(step))+1}(step,Math.max(Math.abs(start),Math.abs(stop))))||(specifier.precision=precision-("e"===specifier.type));break;case"f":case"%":null!=specifier.precision||isNaN(precision=function(step){return Math.max(0,-exponent(Math.abs(step)))}(step))||(specifier.precision=precision-2*("%"===specifier.type))}return format(specifier)}function linearish(scale){var domain=scale.domain;return scale.ticks=function(count){var d=domain();return function(start,stop,count){if(!((count=+count)>0))return[];if((start=+start)===(stop=+stop))return[start];const reverse=stop<start,[i1,i2,inc]=reverse?tickSpec(stop,start,count):tickSpec(start,stop,count);if(!(i2>=i1))return[];const n=i2-i1+1,ticks2=new Array(n);if(reverse)if(inc<0)for(let i=0;i<n;++i)ticks2[i]=(i2-i)/-inc;else for(let i=0;i<n;++i)ticks2[i]=(i2-i)*inc;else if(inc<0)for(let i=0;i<n;++i)ticks2[i]=(i1+i)/-inc;else for(let i=0;i<n;++i)ticks2[i]=(i1+i)*inc;return ticks2}(d[0],d[d.length-1],null==count?10:count)},scale.tickFormat=function(count,specifier){var d=domain();return tickFormat(d[0],d[d.length-1],null==count?10:count,specifier)},scale.nice=function(count){null==count&&(count=10);var prestep,step,d=domain(),i0=0,i1=d.length-1,start=d[i0],stop=d[i1],maxIter=10;for(stop<start&&(step=start,start=stop,stop=step,step=i0,i0=i1,i1=step);maxIter-- >0;){if((step=tickIncrement(start,stop,count))===prestep)return d[i0]=start,d[i1]=stop,domain(d);if(step>0)start=Math.floor(start/step)*step,stop=Math.ceil(stop/step)*step;else{if(!(step<0))break;start=Math.ceil(start*step)/step,stop=Math.floor(stop*step)/step}prestep=step}return scale},scale}function linear(){var scale=continuous();return scale.copy=function(){return copy(scale,linear())},initRange.apply(scale,arguments),linearish(scale)}export{copy as a,bisector as b,continuous as c,linear as l,tickStep as t};
1
+ import{aL as constant,aM as interpolateNumber,aN as color,aO as interpolateRgb,aP as interpolateString}from"./mermaid.core-YnqOkuoS.js";import{i as initRange}from"./init-DMZMl1PR.js";import{e as exponent,f as formatSpecifier,a as formatPrefix,b as format}from"./defaultLocale-DZ7E7S9R.js";function ascending(a,b){return null==a||null==b?NaN:a<b?-1:a>b?1:a>=b?0:NaN}function descending(a,b){return null==a||null==b?NaN:b<a?-1:b>a?1:b>=a?0:NaN}function bisector(f){let compare1,compare2,delta;function left(a,x,lo=0,hi=a.length){if(lo<hi){if(0!==compare1(x,x))return hi;do{const mid=lo+hi>>>1;compare2(a[mid],x)<0?lo=mid+1:hi=mid}while(lo<hi)}return lo}return 2!==f.length?(compare1=ascending,compare2=(d,x)=>ascending(f(d),x),delta=(d,x)=>f(d)-x):(compare1=f===ascending||f===descending?f:zero,compare2=f,delta=f),{left:left,center:function(a,x,lo=0,hi=a.length){const i=left(a,x,lo,hi-1);return i>lo&&delta(a[i-1],x)>-delta(a[i],x)?i-1:i},right:function(a,x,lo=0,hi=a.length){if(lo<hi){if(0!==compare1(x,x))return hi;do{const mid=lo+hi>>>1;compare2(a[mid],x)<=0?lo=mid+1:hi=mid}while(lo<hi)}return lo}}}function zero(){return 0}const bisectRight=bisector(ascending).right;bisector(function(x){return null===x?NaN:+x}).center;const e10=Math.sqrt(50),e5=Math.sqrt(10),e2=Math.sqrt(2);function tickSpec(start,stop,count){const step=(stop-start)/Math.max(0,count),power=Math.floor(Math.log10(step)),error=step/Math.pow(10,power),factor=error>=e10?10:error>=e5?5:error>=e2?2:1;let i1,i2,inc;return power<0?(inc=Math.pow(10,-power)/factor,i1=Math.round(start*inc),i2=Math.round(stop*inc),i1/inc<start&&++i1,i2/inc>stop&&--i2,inc=-inc):(inc=Math.pow(10,power)*factor,i1=Math.round(start/inc),i2=Math.round(stop/inc),i1*inc<start&&++i1,i2*inc>stop&&--i2),i2<i1&&.5<=count&&count<2?tickSpec(start,stop,2*count):[i1,i2,inc]}function tickIncrement(start,stop,count){return tickSpec(start=+start,stop=+stop,count=+count)[2]}function tickStep(start,stop,count){count=+count;const reverse=(stop=+stop)<(start=+start),inc=reverse?tickIncrement(stop,start,count):tickIncrement(start,stop,count);return(reverse?-1:1)*(inc<0?1/-inc:inc)}function numberArray(a,b){b||(b=[]);var i,n=a?Math.min(b.length,a.length):0,c=b.slice();return function(t){for(i=0;i<n;++i)c[i]=a[i]*(1-t)+b[i]*t;return c}}function genericArray(a,b){var i,nb=b?b.length:0,na=a?Math.min(nb,a.length):0,x=new Array(na),c=new Array(nb);for(i=0;i<na;++i)x[i]=interpolate(a[i],b[i]);for(;i<nb;++i)c[i]=b[i];return function(t){for(i=0;i<na;++i)c[i]=x[i](t);return c}}function date(a,b){var d=new Date;return a=+a,b=+b,function(t){return d.setTime(a*(1-t)+b*t),d}}function object(a,b){var k,i={},c={};for(k in null!==a&&"object"==typeof a||(a={}),null!==b&&"object"==typeof b||(b={}),b)k in a?i[k]=interpolate(a[k],b[k]):c[k]=b[k];return function(t){for(k in i)c[k]=i[k](t);return c}}function interpolate(a,b){var c,x,t=typeof b;return null==b||"boolean"===t?constant(b):("number"===t?interpolateNumber:"string"===t?(c=color(b))?(b=c,interpolateRgb):interpolateString:b instanceof color?interpolateRgb:b instanceof Date?date:(x=b,!ArrayBuffer.isView(x)||x instanceof DataView?Array.isArray(b)?genericArray:"function"!=typeof b.valueOf&&"function"!=typeof b.toString||isNaN(b)?object:interpolateNumber:numberArray))(a,b)}function interpolateRound(a,b){return a=+a,b=+b,function(t){return Math.round(a*(1-t)+b*t)}}function number(x){return+x}var unit=[0,1];function identity(x){return x}function normalize(a,b){return(b-=a=+a)?function(x){return(x-a)/b}:(x=isNaN(b)?NaN:.5,function(){return x});var x}function bimap(domain,range,interpolate2){var d0=domain[0],d1=domain[1],r0=range[0],r1=range[1];return d1<d0?(d0=normalize(d1,d0),r0=interpolate2(r1,r0)):(d0=normalize(d0,d1),r0=interpolate2(r0,r1)),function(x){return r0(d0(x))}}function polymap(domain,range,interpolate2){var j=Math.min(domain.length,range.length)-1,d=new Array(j),r=new Array(j),i=-1;for(domain[j]<domain[0]&&(domain=domain.slice().reverse(),range=range.slice().reverse());++i<j;)d[i]=normalize(domain[i],domain[i+1]),r[i]=interpolate2(range[i],range[i+1]);return function(x){var i2=bisectRight(domain,x,1,j)-1;return r[i2](d[i2](x))}}function copy(source,target){return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown())}function transformer(){var transform,untransform,unknown,piecewise,output,input,domain=unit,range=unit,interpolate$1=interpolate,clamp=identity;function rescale(){var a,b,t,n=Math.min(domain.length,range.length);return clamp!==identity&&(a=domain[0],b=domain[n-1],a>b&&(t=a,a=b,b=t),clamp=function(x){return Math.max(a,Math.min(b,x))}),piecewise=n>2?polymap:bimap,output=input=null,scale}function scale(x){return null==x||isNaN(x=+x)?unknown:(output||(output=piecewise(domain.map(transform),range,interpolate$1)))(transform(clamp(x)))}return scale.invert=function(y){return clamp(untransform((input||(input=piecewise(range,domain.map(transform),interpolateNumber)))(y)))},scale.domain=function(_){return arguments.length?(domain=Array.from(_,number),rescale()):domain.slice()},scale.range=function(_){return arguments.length?(range=Array.from(_),rescale()):range.slice()},scale.rangeRound=function(_){return range=Array.from(_),interpolate$1=interpolateRound,rescale()},scale.clamp=function(_){return arguments.length?(clamp=!!_||identity,rescale()):clamp!==identity},scale.interpolate=function(_){return arguments.length?(interpolate$1=_,rescale()):interpolate$1},scale.unknown=function(_){return arguments.length?(unknown=_,scale):unknown},function(t,u){return transform=t,untransform=u,rescale()}}function continuous(){return transformer()(identity,identity)}function tickFormat(start,stop,count,specifier){var precision,step=tickStep(start,stop,count);switch((specifier=formatSpecifier(null==specifier?",f":specifier)).type){case"s":var value=Math.max(Math.abs(start),Math.abs(stop));return null!=specifier.precision||isNaN(precision=function(step,value){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(exponent(value)/3)))-exponent(Math.abs(step)))}(step,value))||(specifier.precision=precision),formatPrefix(specifier,value);case"":case"e":case"g":case"p":case"r":null!=specifier.precision||isNaN(precision=function(step,max){return step=Math.abs(step),max=Math.abs(max)-step,Math.max(0,exponent(max)-exponent(step))+1}(step,Math.max(Math.abs(start),Math.abs(stop))))||(specifier.precision=precision-("e"===specifier.type));break;case"f":case"%":null!=specifier.precision||isNaN(precision=function(step){return Math.max(0,-exponent(Math.abs(step)))}(step))||(specifier.precision=precision-2*("%"===specifier.type))}return format(specifier)}function linearish(scale){var domain=scale.domain;return scale.ticks=function(count){var d=domain();return function(start,stop,count){if(!((count=+count)>0))return[];if((start=+start)===(stop=+stop))return[start];const reverse=stop<start,[i1,i2,inc]=reverse?tickSpec(stop,start,count):tickSpec(start,stop,count);if(!(i2>=i1))return[];const n=i2-i1+1,ticks2=new Array(n);if(reverse)if(inc<0)for(let i=0;i<n;++i)ticks2[i]=(i2-i)/-inc;else for(let i=0;i<n;++i)ticks2[i]=(i2-i)*inc;else if(inc<0)for(let i=0;i<n;++i)ticks2[i]=(i1+i)/-inc;else for(let i=0;i<n;++i)ticks2[i]=(i1+i)*inc;return ticks2}(d[0],d[d.length-1],null==count?10:count)},scale.tickFormat=function(count,specifier){var d=domain();return tickFormat(d[0],d[d.length-1],null==count?10:count,specifier)},scale.nice=function(count){null==count&&(count=10);var prestep,step,d=domain(),i0=0,i1=d.length-1,start=d[i0],stop=d[i1],maxIter=10;for(stop<start&&(step=start,start=stop,stop=step,step=i0,i0=i1,i1=step);maxIter-- >0;){if((step=tickIncrement(start,stop,count))===prestep)return d[i0]=start,d[i1]=stop,domain(d);if(step>0)start=Math.floor(start/step)*step,stop=Math.ceil(stop/step)*step;else{if(!(step<0))break;start=Math.ceil(start*step)/step,stop=Math.floor(stop*step)/step}prestep=step}return scale},scale}function linear(){var scale=continuous();return scale.copy=function(){return copy(scale,linear())},initRange.apply(scale,arguments),linearish(scale)}export{copy as a,bisector as b,continuous as c,linear as l,tickStep as t};