cc-viewer 1.6.293 → 1.6.295

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 (110) hide show
  1. package/cli.js +7 -2
  2. package/dist/assets/App-Br-u2TKk.js +2 -0
  3. package/dist/assets/App-eFrjLzF_.css +1 -0
  4. package/dist/assets/{MdxEditorPanel-Cf01KF6Z.js → MdxEditorPanel-Cy4egsQx.js} +1 -1
  5. package/dist/assets/{Mobile-BJlGkvAP.js → Mobile-ZHF74GQs.js} +1 -1
  6. package/dist/assets/{_baseUniq-CPUnJ5bQ.js → _baseUniq-r3p3rodd.js} +1 -1
  7. package/dist/assets/{arc-WhuJ-oY5.js → arc-CjTV5gxc.js} +1 -1
  8. package/dist/assets/{architectureDiagram-Q4EWVU46-CWx77Yhd.js → architectureDiagram-Q4EWVU46-BqzjXpCq.js} +1 -1
  9. package/dist/assets/{blockDiagram-DXYQGD6D-D7AQLCoj.js → blockDiagram-DXYQGD6D-CLyFfeHh.js} +1 -1
  10. package/dist/assets/{c4Diagram-AHTNJAMY-BoPHNqCF.js → c4Diagram-AHTNJAMY-BaO-0tuc.js} +1 -1
  11. package/dist/assets/{channel-B9Ja6Xkc.js → channel-yOyhvOLV.js} +1 -1
  12. package/dist/assets/{chunk-4BX2VUAB-B-b0RYab.js → chunk-4BX2VUAB-CMTnvZkS.js} +1 -1
  13. package/dist/assets/{chunk-4TB4RGXK-BK_V34yf.js → chunk-4TB4RGXK-QI41m9WP.js} +1 -1
  14. package/dist/assets/{chunk-55IACEB6-D-kMbu-2.js → chunk-55IACEB6-C4ZO8bM3.js} +1 -1
  15. package/dist/assets/{chunk-EDXVE4YY-CEtSkZzd.js → chunk-EDXVE4YY-Bo8P4o65.js} +1 -1
  16. package/dist/assets/{chunk-FMBD7UC4-BXa_7Pn3.js → chunk-FMBD7UC4-CTHLGcHh.js} +1 -1
  17. package/dist/assets/{chunk-OYMX7WX6-tvM_OApS.js → chunk-OYMX7WX6-D0OHxKGd.js} +1 -1
  18. package/dist/assets/{chunk-QZHKN3VN-DrEmcVHf.js → chunk-QZHKN3VN-CoYnjUpS.js} +1 -1
  19. package/dist/assets/{chunk-YZCP3GAM-D2M9T_R5.js → chunk-YZCP3GAM-BY71mTXM.js} +1 -1
  20. package/dist/assets/classDiagram-6PBFFD2Q-C9o5ip5q.js +1 -0
  21. package/dist/assets/classDiagram-v2-HSJHXN6E-C9o5ip5q.js +1 -0
  22. package/dist/assets/clone-GDqN3kwT.js +1 -0
  23. package/dist/assets/{cose-bilkent-S5V4N54A-H7bkwu5F.js → cose-bilkent-S5V4N54A-DUNsA_MT.js} +1 -1
  24. package/dist/assets/{dagre-KV5264BT-DKXEGN18.js → dagre-KV5264BT-BzlT2Exr.js} +1 -1
  25. package/dist/assets/{diagram-5BDNPKRD-DZFhwpI3.js → diagram-5BDNPKRD-CiqQK3Ci.js} +1 -1
  26. package/dist/assets/{diagram-G4DWMVQ6-Crg9GlIk.js → diagram-G4DWMVQ6-BciK18tQ.js} +1 -1
  27. package/dist/assets/{diagram-MMDJMWI5-B8Qn1fKP.js → diagram-MMDJMWI5-C1WH1vfU.js} +1 -1
  28. package/dist/assets/{diagram-TYMM5635-BHE1LjtY.js → diagram-TYMM5635-CR5RzJ6u.js} +1 -1
  29. package/dist/assets/{erDiagram-SMLLAGMA-BaEqFWLd.js → erDiagram-SMLLAGMA-NJQKXu51.js} +1 -1
  30. package/dist/assets/{flowDiagram-DWJPFMVM-b2ukTawV.js → flowDiagram-DWJPFMVM-Cjx5t_1H.js} +1 -1
  31. package/dist/assets/{ganttDiagram-T4ZO3ILL-D5quyFgK.js → ganttDiagram-T4ZO3ILL-YFTDBBiU.js} +1 -1
  32. package/dist/assets/{gitGraphDiagram-UUTBAWPF-BE1H5_fN.js → gitGraphDiagram-UUTBAWPF-C2muKahz.js} +1 -1
  33. package/dist/assets/{graph-D_JLoOax.js → graph-I1olozIg.js} +1 -1
  34. package/dist/assets/{index-Cx8bk0Tp.js → index-7vxIrUNA.js} +1 -1
  35. package/dist/assets/{index-BDUs32pN.css → index-Be9T-kDq.css} +1 -1
  36. package/dist/assets/{index-CtrY6gFZ.js → index-C1RNAzAB.js} +1 -1
  37. package/dist/assets/{index-CQrdpZQb.js → index-Cf4FBg-V.js} +1 -1
  38. package/dist/assets/{index-B8UmlA4F.js → index-D-HPuqxB.js} +1 -1
  39. package/dist/assets/{index-k0AH8cvI.js → index-D2QUxu18.js} +1 -1
  40. package/dist/assets/index-DMuCrfTo.js +2 -0
  41. package/dist/assets/{index-DiZ9CErG.js → index-DhzoJ5wE.js} +1 -1
  42. package/dist/assets/{index-CWjqMDrs.js → index-fhI0i2p3.js} +1 -1
  43. package/dist/assets/{infoDiagram-42DDH7IO-DQKlrVkw.js → infoDiagram-42DDH7IO-C9bza97c.js} +1 -1
  44. package/dist/assets/{ishikawaDiagram-UXIWVN3A-BchFlpPc.js → ishikawaDiagram-UXIWVN3A-BtZGipfW.js} +1 -1
  45. package/dist/assets/{journeyDiagram-VCZTEJTY-Dg1mt4df.js → journeyDiagram-VCZTEJTY-CKTp590c.js} +1 -1
  46. package/dist/assets/{jszip.min-LIb2SFoK.js → jszip.min-DDU-_oA-.js} +1 -1
  47. package/dist/assets/{kanban-definition-6JOO6SKY-226va2PS.js → kanban-definition-6JOO6SKY-BHLNWfr5.js} +1 -1
  48. package/dist/assets/{layout-rSa8rcPi.js → layout-DBmqcl9N.js} +1 -1
  49. package/dist/assets/{linear-BeARi8nH.js → linear-Br9n7mCI.js} +1 -1
  50. package/dist/assets/{mermaid.core-CDgdx9l7.js → mermaid.core-BV3ugHFm.js} +2 -2
  51. package/dist/assets/{min-B9yebCuj.js → min-D-YA3MGY.js} +1 -1
  52. package/dist/assets/{mindmap-definition-QFDTVHPH-C3apVbdg.js → mindmap-definition-QFDTVHPH-CzrYj3cB.js} +1 -1
  53. package/dist/assets/{pieDiagram-DEJITSTG-xjOQoQeL.js → pieDiagram-DEJITSTG-BAvtfiT3.js} +1 -1
  54. package/dist/assets/{quadrantDiagram-34T5L4WZ-Dq8x_VN2.js → quadrantDiagram-34T5L4WZ-i4zhnBJq.js} +1 -1
  55. package/dist/assets/{requirementDiagram-MS252O5E-CLmO1Gai.js → requirementDiagram-MS252O5E-Cb2wX9Sk.js} +1 -1
  56. package/dist/assets/{sankeyDiagram-XADWPNL6-BuUP1Eqq.js → sankeyDiagram-XADWPNL6-CcpbP6z5.js} +1 -1
  57. package/dist/assets/seqResourceLoaders-C7X23dCJ.js +2 -0
  58. package/dist/assets/{seqResourceLoaders-DWKAvGtj.css → seqResourceLoaders-De_-fYhE.css} +2 -2
  59. package/dist/assets/{sequenceDiagram-FGHM5R23-B18koU20.js → sequenceDiagram-FGHM5R23-BcbUxMmI.js} +1 -1
  60. package/dist/assets/{stateDiagram-FHFEXIEX-Cj57OCcO.js → stateDiagram-FHFEXIEX-CpIa1qoO.js} +1 -1
  61. package/dist/assets/{stateDiagram-v2-QKLJ7IA2-C01a2p--.js → stateDiagram-v2-QKLJ7IA2-d3GoyW9S.js} +1 -1
  62. package/dist/assets/{timeline-definition-GMOUNBTQ-cOlsEN_F.js → timeline-definition-GMOUNBTQ-BfQPSOuT.js} +1 -1
  63. package/dist/assets/{vendor-antd-DqFS7Zj9.js → vendor-antd-Bur5ZxWE.js} +1 -1
  64. package/dist/assets/{vendor-codemirror-B_pF4DrA.js → vendor-codemirror-Si44UqBp.js} +1 -1
  65. package/dist/assets/{vendor-mdxeditor-B_IrHcWH.js → vendor-mdxeditor-Cco3AQJS.js} +2 -2
  66. package/dist/assets/{vendor-qrcode-C4PneAS5.js → vendor-qrcode-Dn3GYC4l.js} +1 -1
  67. package/dist/assets/{vendor-virtuoso-CEGeJyDP.js → vendor-virtuoso-CW9EqKMt.js} +1 -1
  68. package/dist/assets/{vennDiagram-DHZGUBPP-BCjdwiDk.js → vennDiagram-DHZGUBPP-hTgiYDQL.js} +1 -1
  69. package/dist/assets/{wardley-RL74JXVD-CRmLlBwn.js → wardley-RL74JXVD-ByDpAPp1.js} +1 -1
  70. package/dist/assets/{wardleyDiagram-NUSXRM2D-BJYVDJ4F.js → wardleyDiagram-NUSXRM2D-D7LJTuWq.js} +1 -1
  71. package/dist/assets/{xychartDiagram-5P7HB3ND-el5C4S1Z.js → xychartDiagram-5P7HB3ND-MW_KOomO.js} +1 -1
  72. package/dist/index.html +5 -5
  73. package/findcc.js +3 -3
  74. package/package.json +1 -1
  75. package/server/i18n.js +224 -8
  76. package/server/interceptor.js +21 -18
  77. package/server/lib/adapters/dingtalk-adapter.js +69 -0
  78. package/server/lib/adapters/discord-adapter.js +44 -1
  79. package/server/lib/adapters/feishu-adapter.js +56 -0
  80. package/server/lib/adapters/wecom-adapter.js +4 -0
  81. package/server/lib/ask-store.js +19 -90
  82. package/server/lib/async-file-lock.js +123 -0
  83. package/server/lib/async-write-queue.js +131 -0
  84. package/server/lib/git-diff.js +4 -1
  85. package/server/lib/im-bridge-core.js +178 -21
  86. package/server/lib/im-claude-md.js +37 -1
  87. package/server/lib/im-config.js +11 -6
  88. package/server/lib/im-process-manager.js +1 -1
  89. package/server/lib/im-senders.js +73 -0
  90. package/server/lib/jsonl-archive.js +0 -1
  91. package/server/lib/log-watcher.js +224 -177
  92. package/server/lib/plugin-manager.js +1 -1
  93. package/server/lib/updater.js +4 -2
  94. package/server/pty-manager.js +1 -1
  95. package/server/routes/ask-perm.js +2 -2
  96. package/server/routes/dingtalk.js +2 -0
  97. package/server/routes/files-fs.js +4 -4
  98. package/server/routes/im.js +117 -3
  99. package/server/routes/project-meta.js +18 -1
  100. package/server/routes/skills.js +180 -165
  101. package/server/routes/workspaces.js +7 -10
  102. package/server/server.js +23 -20
  103. package/server/workspace-registry.js +9 -53
  104. package/dist/assets/App-DRvRd96X.css +0 -1
  105. package/dist/assets/App-OM2oqZRW.js +0 -1
  106. package/dist/assets/classDiagram-6PBFFD2Q-CCwGJXEA.js +0 -1
  107. package/dist/assets/classDiagram-v2-HSJHXN6E-CCwGJXEA.js +0 -1
  108. package/dist/assets/clone-BuQbTPQO.js +0 -1
  109. package/dist/assets/index-CnWSVlWW.js +0 -2
  110. package/dist/assets/seqResourceLoaders-BZ6M3Jb-.js +0 -2
@@ -1 +1 @@
1
- import{_ as __name,l as log,c as getConfig2,H as selectSvgElement,ae as insertCluster,af as insertNode,ag as positionNode,X as setupGraphViewbox,F as defaultConfig_default,i as sanitizeText,t as load,J as JSON_SCHEMA,U as isDark,V as lighten,W as darken}from"./mermaid.core-CDgdx9l7.js";import{g as getIconStyles}from"./chunk-FMBD7UC4-BXa_7Pn3.js";import"./vendor-mdxeditor-B_IrHcWH.js";import"./vendor-antd-DqFS7Zj9.js";import"./vendor-codemirror-B_pF4DrA.js";import"./vendor-markdown-DOJHsAxX.js";var parser=function(){var o=__name(function(k,v,o2,l){for(o2=o2||{},l=k.length;l--;o2[k[l]]=v);return o2},"o"),$V0=[1,4],$V1=[1,13],$V2=[1,12],$V3=[1,15],$V4=[1,16],$V5=[1,20],$V6=[1,19],$V7=[6,7,8],$V8=[1,26],$V9=[1,24],$Va=[1,25],$Vb=[6,7,11],$Vc=[1,31],$Vd=[6,7,11,24],$Ve=[1,6,13,16,17,20,23],$Vf=[1,35],$Vg=[1,36],$Vh=[1,6,7,11,13,16,17,20,23],$Vi=[1,38],parser2={trace:__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"KANBAN",11:"EOF",13:"SPACELIST",16:"ICON",17:"CLASS",20:"NODE_DSTART",21:"NODE_DESCR",22:"NODE_DEND",23:"NODE_ID",24:"SHAPE_DATA"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:__name(function(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 6:case 7:return yy;case 8:yy.getLogger().trace("Stop NL ");break;case 9:yy.getLogger().trace("Stop EOF ");break;case 11:yy.getLogger().trace("Stop NL2 ");break;case 12:yy.getLogger().trace("Stop EOF2 ");break;case 15:yy.getLogger().info("Node: ",$$[$0-1].id),yy.addNode($$[$0-2].length,$$[$0-1].id,$$[$0-1].descr,$$[$0-1].type,$$[$0]);break;case 16:yy.getLogger().info("Node: ",$$[$0].id),yy.addNode($$[$0-1].length,$$[$0].id,$$[$0].descr,$$[$0].type);break;case 17:yy.getLogger().trace("Icon: ",$$[$0]),yy.decorateNode({icon:$$[$0]});break;case 18:case 23:yy.decorateNode({class:$$[$0]});break;case 19:yy.getLogger().trace("SPACELIST");break;case 20:yy.getLogger().trace("Node: ",$$[$0-1].id),yy.addNode(0,$$[$0-1].id,$$[$0-1].descr,$$[$0-1].type,$$[$0]);break;case 21:yy.getLogger().trace("Node: ",$$[$0].id),yy.addNode(0,$$[$0].id,$$[$0].descr,$$[$0].type);break;case 22:yy.decorateNode({icon:$$[$0]});break;case 27:yy.getLogger().trace("node found ..",$$[$0-2]),this.$={id:$$[$0-1],descr:$$[$0-1],type:yy.getType($$[$0-2],$$[$0])};break;case 28:this.$={id:$$[$0],descr:$$[$0],type:0};break;case 29:yy.getLogger().trace("node found ..",$$[$0-3]),this.$={id:$$[$0-3],descr:$$[$0-1],type:yy.getType($$[$0-2],$$[$0])};break;case 30:this.$=$$[$0-1]+$$[$0];break;case 31:this.$=$$[$0]}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:$V0},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:$V0},{6:$V1,7:[1,10],9:9,12:11,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},o($V7,[2,3]),{1:[2,2]},o($V7,[2,4]),o($V7,[2,5]),{1:[2,6],6:$V1,12:21,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},{6:$V1,9:22,12:11,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},{6:$V8,7:$V9,10:23,11:$Va},o($Vb,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:$V5,23:$V6}),o($Vb,[2,19]),o($Vb,[2,21],{15:30,24:$Vc}),o($Vb,[2,22]),o($Vb,[2,23]),o($Vd,[2,25]),o($Vd,[2,26]),o($Vd,[2,28],{20:[1,32]}),{21:[1,33]},{6:$V8,7:$V9,10:34,11:$Va},{1:[2,7],6:$V1,12:21,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},o($Ve,[2,14],{7:$Vf,11:$Vg}),o($Vh,[2,8]),o($Vh,[2,9]),o($Vh,[2,10]),o($Vb,[2,16],{15:37,24:$Vc}),o($Vb,[2,17]),o($Vb,[2,18]),o($Vb,[2,20],{24:$Vi}),o($Vd,[2,31]),{21:[1,39]},{22:[1,40]},o($Ve,[2,13],{7:$Vf,11:$Vg}),o($Vh,[2,11]),o($Vh,[2,12]),o($Vb,[2,15],{24:$Vi}),o($Vd,[2,30]),{22:[1,41]},o($Vd,[2,27]),o($Vd,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:__name(function(str,hash){if(!hash.recoverable){var error=new Error(str);throw error.hash=hash,error}this.trace(str)},"parseError"),parse:__name(function(input){var self=this,stack=[0],tstack=[],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,args=lstack.slice.call(arguments,1),lexer2=Object.create(this.lexer),sharedState={yy:{}};for(var k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(sharedState.yy[k]=this.yy[k]);lexer2.setInput(input,sharedState.yy),sharedState.yy.lexer=lexer2,sharedState.yy.parser=this,void 0===lexer2.yylloc&&(lexer2.yylloc={});var yyloc=lexer2.yylloc;lstack.push(yyloc);var ranges=lexer2.options&&lexer2.options.ranges;function lex(){var token;return"number"!=typeof(token=tstack.pop()||lexer2.lex()||1)&&(token instanceof Array&&(token=(tstack=token).pop()),token=self.symbols_[token]||token),token}"function"==typeof sharedState.yy.parseError?this.parseError=sharedState.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,__name(function(n){stack.length=stack.length-2*n,vstack.length=vstack.length-n,lstack.length=lstack.length-n},"popStack"),__name(lex,"lex");for(var symbol,state,action,r,p,len,newState,expected,yyval={};;){if(state=stack[stack.length-1],this.defaultActions[state]?action=this.defaultActions[state]:(null==symbol&&(symbol=lex()),action=table[state]&&table[state][symbol]),void 0===action||!action.length||!action[0]){var errStr="";for(p in expected=[],table[state])this.terminals_[p]&&p>2&&expected.push("'"+this.terminals_[p]+"'");errStr=lexer2.showPosition?"Parse error on line "+(yylineno+1)+":\n"+lexer2.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'":"Parse error on line "+(yylineno+1)+": Unexpected "+(1==symbol?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'"),this.parseError(errStr,{text:lexer2.match,token:this.terminals_[symbol]||symbol,line:lexer2.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1)throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol);switch(action[0]){case 1:stack.push(symbol),vstack.push(lexer2.yytext),lstack.push(lexer2.yylloc),stack.push(action[1]),symbol=null,yyleng=lexer2.yyleng,yytext=lexer2.yytext,yylineno=lexer2.yylineno,yyloc=lexer2.yylloc;break;case 2:if(len=this.productions_[action[1]][1],yyval.$=vstack[vstack.length-len],yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column},ranges&&(yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]),void 0!==(r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args))))return r;len&&(stack=stack.slice(0,-1*len*2),vstack=vstack.slice(0,-1*len),lstack=lstack.slice(0,-1*len)),stack.push(this.productions_[action[1]][0]),vstack.push(yyval.$),lstack.push(yyval._$),newState=table[stack[stack.length-2]][stack[stack.length-1]],stack.push(newState);break;case 3:return!0}}return!0},"parse")},lexer=function(){return{EOF:1,parseError:__name(function(str,hash){if(!this.yy.parser)throw new Error(str);this.yy.parser.parseError(str,hash)},"parseError"),setInput:__name(function(input,yy){return this.yy=yy||this.yy||{},this._input=input,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:__name(function(){var ch=this._input[0];return this.yytext+=ch,this.yyleng++,this.offset++,this.match+=ch,this.matched+=ch,ch.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),ch},"input"),unput:__name(function(ch){var len=ch.length,lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-len),this.offset-=len;var oldLines=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),lines.length-1&&(this.yylineno-=lines.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-len]),this.yyleng=this.yytext.length,this},"unput"),more:__name(function(){return this._more=!0,this},"more"),reject:__name(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:__name(function(n){this.unput(this.match.slice(n))},"less"),pastInput:__name(function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:__name(function(){var next=this.match;return next.length<20&&(next+=this._input.substr(0,20-next.length)),(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:__name(function(){var pre=this.pastInput(),c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},"showPosition"),test_match:__name(function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer&&(backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(backup.yylloc.range=this.yylloc.range.slice(0))),(lines=match[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=lines.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length},this.yytext+=match[0],this.match+=match[0],this.matches=match,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(match[0].length),this.matched+=match[0],token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),token)return token;if(this._backtrack){for(var k in backup)this[k]=backup[k];return!1}return!1},"test_match"),next:__name(function(){if(this.done)return this.EOF;var token,match,tempMatch,index;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var rules=this._currentRules(),i=0;i<rules.length;i++)if((tempMatch=this._input.match(this.rules[rules[i]]))&&(!match||tempMatch[0].length>match[0].length)){if(match=tempMatch,index=i,this.options.backtrack_lexer){if(!1!==(token=this.test_match(tempMatch,rules[i])))return token;if(this._backtrack){match=!1;continue}return!1}if(!this.options.flex)break}return match?!1!==(token=this.test_match(match,rules[index]))&&token:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:__name(function(){var r=this.next();return r||this.lex()},"lex"),begin:__name(function(condition){this.conditionStack.push(condition)},"begin"),popState:__name(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:__name(function(n){return(n=this.conditionStack.length-1-Math.abs(n||0))>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:__name(function(condition){this.begin(condition)},"pushState"),stateStackSize:__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:__name(function(yy,yy_,$avoiding_name_collisions,YY_START){switch($avoiding_name_collisions){case 0:return this.pushState("shapeData"),yy_.yytext="",24;case 1:return this.pushState("shapeDataStr"),24;case 2:return this.popState(),24;case 3:const re=/\n\s*/g;return yy_.yytext=yy_.yytext.replace(re,"<br/>"),24;case 4:return 24;case 5:case 10:case 29:case 32:this.popState();break;case 6:return yy.getLogger().trace("Found comment",yy_.yytext),6;case 7:return 8;case 8:this.begin("CLASS");break;case 9:return this.popState(),17;case 11:yy.getLogger().trace("Begin icon"),this.begin("ICON");break;case 12:return yy.getLogger().trace("SPACELINE"),6;case 13:return 7;case 14:return 16;case 15:yy.getLogger().trace("end icon"),this.popState();break;case 16:return yy.getLogger().trace("Exploding node"),this.begin("NODE"),20;case 17:return yy.getLogger().trace("Cloud"),this.begin("NODE"),20;case 18:return yy.getLogger().trace("Explosion Bang"),this.begin("NODE"),20;case 19:return yy.getLogger().trace("Cloud Bang"),this.begin("NODE"),20;case 20:case 21:case 22:case 23:return this.begin("NODE"),20;case 24:return 13;case 25:return 23;case 26:return 11;case 27:this.begin("NSTR2");break;case 28:return"NODE_DESCR";case 30:yy.getLogger().trace("Starting NSTR"),this.begin("NSTR");break;case 31:return yy.getLogger().trace("description:",yy_.yytext),"NODE_DESCR";case 33:return this.popState(),yy.getLogger().trace("node end ))"),"NODE_DEND";case 34:return this.popState(),yy.getLogger().trace("node end )"),"NODE_DEND";case 35:return this.popState(),yy.getLogger().trace("node end ...",yy_.yytext),"NODE_DEND";case 36:case 39:case 40:return this.popState(),yy.getLogger().trace("node end (("),"NODE_DEND";case 37:case 38:return this.popState(),yy.getLogger().trace("node end (-"),"NODE_DEND";case 41:case 42:return yy.getLogger().trace("Long description:",yy_.yytext),21}},"anonymous"),rules:[/^(?:@\{)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^\"]+)/i,/^(?:[^}^"]+)/i,/^(?:\})/i,/^(?:\s*%%.*)/i,/^(?:kanban\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}@]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{shapeDataEndBracket:{rules:[],inclusive:!1},shapeDataStr:{rules:[2,3],inclusive:!1},shapeData:{rules:[1,4,5],inclusive:!1},CLASS:{rules:[9,10],inclusive:!1},ICON:{rules:[14,15],inclusive:!1},NSTR2:{rules:[28,29],inclusive:!1},NSTR:{rules:[31,32],inclusive:!1},NODE:{rules:[27,30,33,34,35,36,37,38,39,40,41,42],inclusive:!1},INITIAL:{rules:[0,6,7,8,11,12,13,16,17,18,19,20,21,22,23,24,25,26],inclusive:!0}}}}();function Parser(){this.yy={}}return parser2.lexer=lexer,__name(Parser,"Parser"),Parser.prototype=parser2,parser2.Parser=Parser,new Parser}();parser.parser=parser;var kanban_default=parser,nodes=[],sections=[],cnt=0,elements={},clear=__name(()=>{nodes=[],sections=[],cnt=0,elements={}},"clear"),getSection=__name(level=>{if(0===nodes.length)return null;const sectionLevel=nodes[0].level;let lastSection=null;for(let i=nodes.length-1;i>=0;i--)if(nodes[i].level!==sectionLevel||lastSection||(lastSection=nodes[i]),nodes[i].level<sectionLevel)throw new Error('Items without section detected, found section ("'+nodes[i].label+'")');return level===(null==lastSection?void 0:lastSection.level)?null:lastSection},"getSection"),getSections=__name(function(){return sections},"getSections"),getData=__name(function(){const _nodes=[],sections2=getSections(),conf=getConfig2();for(const section of sections2){const node={id:section.id,label:sanitizeText(section.label??"",conf),labelType:"markdown",isGroup:!0,ticket:section.ticket,shape:"kanbanSection",level:section.level,look:conf.look};_nodes.push(node);const children=nodes.filter(n=>n.parentId===section.id);for(const item of children){const childNode={id:item.id,parentId:section.id,label:sanitizeText(item.label??"",conf),labelType:"markdown",isGroup:!1,ticket:null==item?void 0:item.ticket,priority:null==item?void 0:item.priority,assigned:null==item?void 0:item.assigned,icon:null==item?void 0:item.icon,shape:"kanbanItem",level:item.level,rx:5,ry:5,cssStyles:["text-align: left"]};_nodes.push(childNode)}}return{nodes:_nodes,edges:[],other:{},config:getConfig2()}},"getData"),addNode=__name((level,id,descr,type,shapeData)=>{var _a,_b;const conf=getConfig2();let padding=(null==(_a=conf.mindmap)?void 0:_a.padding)??defaultConfig_default.mindmap.padding;switch(type){case nodeType.ROUNDED_RECT:case nodeType.RECT:case nodeType.HEXAGON:padding*=2}const node={id:sanitizeText(id,conf)||"kbn"+cnt++,level:level,label:sanitizeText(descr,conf),width:(null==(_b=conf.mindmap)?void 0:_b.maxNodeWidth)??defaultConfig_default.mindmap.maxNodeWidth,padding:padding,isGroup:!1};if(void 0!==shapeData){let yamlData;yamlData=shapeData.includes("\n")?shapeData+"\n":"{\n"+shapeData+"\n}";const doc=load(yamlData,{schema:JSON_SCHEMA});if(doc.shape&&(doc.shape!==doc.shape.toLowerCase()||doc.shape.includes("_")))throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`);(null==doc?void 0:doc.shape)&&"kanbanItem"===doc.shape&&(node.shape=null==doc?void 0:doc.shape),(null==doc?void 0:doc.label)&&(node.label=null==doc?void 0:doc.label),(null==doc?void 0:doc.icon)&&(node.icon=null==doc?void 0:doc.icon.toString()),(null==doc?void 0:doc.assigned)&&(node.assigned=null==doc?void 0:doc.assigned.toString()),(null==doc?void 0:doc.ticket)&&(node.ticket=null==doc?void 0:doc.ticket.toString()),(null==doc?void 0:doc.priority)&&(node.priority=null==doc?void 0:doc.priority)}const section=getSection(level);section?node.parentId=section.id||"kbn"+cnt++:sections.push(node),nodes.push(node)},"addNode"),nodeType={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},kanbanDb_default={clear:clear,addNode:addNode,getSections:getSections,getData:getData,nodeType:nodeType,getType:__name((startStr,endStr)=>{switch(log.debug("In get type",startStr,endStr),startStr){case"[":return nodeType.RECT;case"(":return")"===endStr?nodeType.ROUNDED_RECT:nodeType.CLOUD;case"((":return nodeType.CIRCLE;case")":return nodeType.CLOUD;case"))":return nodeType.BANG;case"{{":return nodeType.HEXAGON;default:return nodeType.DEFAULT}},"getType"),setElementForId:__name((id,element)=>{elements[id]=element},"setElementForId"),decorateNode:__name(decoration=>{if(!decoration)return;const config=getConfig2(),node=nodes[nodes.length-1];decoration.icon&&(node.icon=sanitizeText(decoration.icon,config)),decoration.class&&(node.cssClasses=sanitizeText(decoration.class,config))},"decorateNode"),type2Str:__name(type=>{switch(type){case nodeType.DEFAULT:return"no-border";case nodeType.RECT:return"rect";case nodeType.ROUNDED_RECT:return"rounded-rect";case nodeType.CIRCLE:return"circle";case nodeType.CLOUD:return"cloud";case nodeType.BANG:return"bang";case nodeType.HEXAGON:return"hexgon";default:return"no-border"}},"type2Str"),getLogger:__name(()=>log,"getLogger"),getElementById:__name(id=>elements[id],"getElementById")},kanbanRenderer_default={draw:__name(async(text,id,_version,diagObj)=>{var _a,_b,_c,_d,_e;log.debug("Rendering kanban diagram\n"+text);const data4Layout=diagObj.db.getData(),conf=getConfig2();conf.htmlLabels=!1;const svg=selectSvgElement(id);for(const node of data4Layout.nodes)node.domId=`${id}-${node.id}`;const sectionsElem=svg.append("g");sectionsElem.attr("class","sections");const nodesElem=svg.append("g");nodesElem.attr("class","items");const sections2=data4Layout.nodes.filter(node=>node.isGroup);let cnt2=0;const sectionObjects=[];let maxLabelHeight=25;for(const section of sections2){const WIDTH=(null==(_a=null==conf?void 0:conf.kanban)?void 0:_a.sectionWidth)||200;cnt2+=1,section.x=WIDTH*cnt2+10*(cnt2-1)/2,section.width=WIDTH,section.y=0,section.height=3*WIDTH,section.rx=5,section.ry=5,section.cssClasses=section.cssClasses+" section-"+cnt2;const sectionObj=await insertCluster(sectionsElem,section);maxLabelHeight=Math.max(maxLabelHeight,null==(_b=null==sectionObj?void 0:sectionObj.labelBBox)?void 0:_b.height),sectionObjects.push(sectionObj)}let i=0;for(const section of sections2){const sectionObj=sectionObjects[i];i+=1;const WIDTH=(null==(_c=null==conf?void 0:conf.kanban)?void 0:_c.sectionWidth)||200,top=3*-WIDTH/2+maxLabelHeight;let y=top;const sectionItems=data4Layout.nodes.filter(node=>node.parentId===section.id);for(const item of sectionItems){if(item.isGroup)throw new Error("Groups within groups are not allowed in Kanban diagrams");item.x=section.x,item.width=WIDTH-15;const bbox=(await insertNode(nodesElem,item,{config:conf})).node().getBBox();item.y=y+bbox.height/2,await positionNode(item),y=item.y+bbox.height/2+5}const rect=sectionObj.cluster.select("rect"),height=Math.max(y-top+30,50)+(maxLabelHeight-25);rect.attr("height",height)}setupGraphViewbox(void 0,svg,(null==(_d=conf.mindmap)?void 0:_d.padding)??defaultConfig_default.kanban.padding,(null==(_e=conf.mindmap)?void 0:_e.useMaxWidth)??defaultConfig_default.kanban.useMaxWidth)},"draw")},genSections=__name(options=>{let sections2="";for(let i=0;i<options.THEME_COLOR_LIMIT;i++)options["lineColor"+i]=options["lineColor"+i]||options["cScaleInv"+i],isDark(options["lineColor"+i])?options["lineColor"+i]=lighten(options["lineColor"+i],20):options["lineColor"+i]=darken(options["lineColor"+i],20);const adjuster=__name((color,level)=>options.darkMode?darken(color,level):lighten(color,level),"adjuster");for(let i=0;i<options.THEME_COLOR_LIMIT;i++){const sw=""+(17-3*i);sections2+=`\n .section-${i-1} rect, .section-${i-1} path, .section-${i-1} circle, .section-${i-1} polygon, .section-${i-1} path {\n fill: ${adjuster(options["cScale"+i],10)};\n stroke: ${adjuster(options["cScale"+i],10)};\n\n }\n .section-${i-1} text {\n fill: ${options["cScaleLabel"+i]};\n }\n .node-icon-${i-1} {\n font-size: 40px;\n color: ${options["cScaleLabel"+i]};\n }\n .section-edge-${i-1}{\n stroke: ${options["cScale"+i]};\n }\n .edge-depth-${i-1}{\n stroke-width: ${sw};\n }\n .section-${i-1} line {\n stroke: ${options["cScaleInv"+i]} ;\n stroke-width: 3;\n }\n\n .disabled, .disabled circle, .disabled text {\n fill: lightgray;\n }\n .disabled text {\n fill: #efefef;\n }\n\n .node rect,\n .node circle,\n .node ellipse,\n .node polygon,\n .node path {\n fill: ${options.background};\n stroke: ${options.nodeBorder};\n stroke-width: 1px;\n }\n\n .kanban-ticket-link {\n fill: ${options.background};\n stroke: ${options.nodeBorder};\n text-decoration: underline;\n }\n `}return sections2},"genSections"),diagram={db:kanbanDb_default,renderer:kanbanRenderer_default,parser:kanban_default,styles:__name(options=>`\n .edge {\n stroke-width: 3;\n }\n ${genSections(options)}\n .section-root rect, .section-root path, .section-root circle, .section-root polygon {\n fill: ${options.git0};\n }\n .section-root text {\n fill: ${options.gitBranchLabel0};\n }\n .icon-container {\n height:100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .edge {\n fill: none;\n }\n .cluster-label, .label {\n color: ${options.textColor};\n fill: ${options.textColor};\n }\n .kanban-label {\n dy: 1em;\n alignment-baseline: middle;\n text-anchor: middle;\n dominant-baseline: middle;\n text-align: center;\n }\n ${getIconStyles()}\n`,"getStyles")};export{diagram};
1
+ import{_ as __name,l as log,c as getConfig2,H as selectSvgElement,ae as insertCluster,af as insertNode,ag as positionNode,X as setupGraphViewbox,F as defaultConfig_default,i as sanitizeText,t as load,J as JSON_SCHEMA,U as isDark,V as lighten,W as darken}from"./mermaid.core-BV3ugHFm.js";import{g as getIconStyles}from"./chunk-FMBD7UC4-CTHLGcHh.js";import"./vendor-mdxeditor-Cco3AQJS.js";import"./vendor-antd-Bur5ZxWE.js";import"./vendor-codemirror-Si44UqBp.js";import"./vendor-markdown-DOJHsAxX.js";var parser=function(){var o=__name(function(k,v,o2,l){for(o2=o2||{},l=k.length;l--;o2[k[l]]=v);return o2},"o"),$V0=[1,4],$V1=[1,13],$V2=[1,12],$V3=[1,15],$V4=[1,16],$V5=[1,20],$V6=[1,19],$V7=[6,7,8],$V8=[1,26],$V9=[1,24],$Va=[1,25],$Vb=[6,7,11],$Vc=[1,31],$Vd=[6,7,11,24],$Ve=[1,6,13,16,17,20,23],$Vf=[1,35],$Vg=[1,36],$Vh=[1,6,7,11,13,16,17,20,23],$Vi=[1,38],parser2={trace:__name(function(){},"trace"),yy:{},symbols_:{error:2,start:3,mindMap:4,spaceLines:5,SPACELINE:6,NL:7,KANBAN:8,document:9,stop:10,EOF:11,statement:12,SPACELIST:13,node:14,shapeData:15,ICON:16,CLASS:17,nodeWithId:18,nodeWithoutId:19,NODE_DSTART:20,NODE_DESCR:21,NODE_DEND:22,NODE_ID:23,SHAPE_DATA:24,$accept:0,$end:1},terminals_:{2:"error",6:"SPACELINE",7:"NL",8:"KANBAN",11:"EOF",13:"SPACELIST",16:"ICON",17:"CLASS",20:"NODE_DSTART",21:"NODE_DESCR",22:"NODE_DEND",23:"NODE_ID",24:"SHAPE_DATA"},productions_:[0,[3,1],[3,2],[5,1],[5,2],[5,2],[4,2],[4,3],[10,1],[10,1],[10,1],[10,2],[10,2],[9,3],[9,2],[12,3],[12,2],[12,2],[12,2],[12,1],[12,2],[12,1],[12,1],[12,1],[12,1],[14,1],[14,1],[19,3],[18,1],[18,4],[15,2],[15,1]],performAction:__name(function(yytext,yyleng,yylineno,yy,yystate,$$,_$){var $0=$$.length-1;switch(yystate){case 6:case 7:return yy;case 8:yy.getLogger().trace("Stop NL ");break;case 9:yy.getLogger().trace("Stop EOF ");break;case 11:yy.getLogger().trace("Stop NL2 ");break;case 12:yy.getLogger().trace("Stop EOF2 ");break;case 15:yy.getLogger().info("Node: ",$$[$0-1].id),yy.addNode($$[$0-2].length,$$[$0-1].id,$$[$0-1].descr,$$[$0-1].type,$$[$0]);break;case 16:yy.getLogger().info("Node: ",$$[$0].id),yy.addNode($$[$0-1].length,$$[$0].id,$$[$0].descr,$$[$0].type);break;case 17:yy.getLogger().trace("Icon: ",$$[$0]),yy.decorateNode({icon:$$[$0]});break;case 18:case 23:yy.decorateNode({class:$$[$0]});break;case 19:yy.getLogger().trace("SPACELIST");break;case 20:yy.getLogger().trace("Node: ",$$[$0-1].id),yy.addNode(0,$$[$0-1].id,$$[$0-1].descr,$$[$0-1].type,$$[$0]);break;case 21:yy.getLogger().trace("Node: ",$$[$0].id),yy.addNode(0,$$[$0].id,$$[$0].descr,$$[$0].type);break;case 22:yy.decorateNode({icon:$$[$0]});break;case 27:yy.getLogger().trace("node found ..",$$[$0-2]),this.$={id:$$[$0-1],descr:$$[$0-1],type:yy.getType($$[$0-2],$$[$0])};break;case 28:this.$={id:$$[$0],descr:$$[$0],type:0};break;case 29:yy.getLogger().trace("node found ..",$$[$0-3]),this.$={id:$$[$0-3],descr:$$[$0-1],type:yy.getType($$[$0-2],$$[$0])};break;case 30:this.$=$$[$0-1]+$$[$0];break;case 31:this.$=$$[$0]}},"anonymous"),table:[{3:1,4:2,5:3,6:[1,5],8:$V0},{1:[3]},{1:[2,1]},{4:6,6:[1,7],7:[1,8],8:$V0},{6:$V1,7:[1,10],9:9,12:11,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},o($V7,[2,3]),{1:[2,2]},o($V7,[2,4]),o($V7,[2,5]),{1:[2,6],6:$V1,12:21,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},{6:$V1,9:22,12:11,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},{6:$V8,7:$V9,10:23,11:$Va},o($Vb,[2,24],{18:17,19:18,14:27,16:[1,28],17:[1,29],20:$V5,23:$V6}),o($Vb,[2,19]),o($Vb,[2,21],{15:30,24:$Vc}),o($Vb,[2,22]),o($Vb,[2,23]),o($Vd,[2,25]),o($Vd,[2,26]),o($Vd,[2,28],{20:[1,32]}),{21:[1,33]},{6:$V8,7:$V9,10:34,11:$Va},{1:[2,7],6:$V1,12:21,13:$V2,14:14,16:$V3,17:$V4,18:17,19:18,20:$V5,23:$V6},o($Ve,[2,14],{7:$Vf,11:$Vg}),o($Vh,[2,8]),o($Vh,[2,9]),o($Vh,[2,10]),o($Vb,[2,16],{15:37,24:$Vc}),o($Vb,[2,17]),o($Vb,[2,18]),o($Vb,[2,20],{24:$Vi}),o($Vd,[2,31]),{21:[1,39]},{22:[1,40]},o($Ve,[2,13],{7:$Vf,11:$Vg}),o($Vh,[2,11]),o($Vh,[2,12]),o($Vb,[2,15],{24:$Vi}),o($Vd,[2,30]),{22:[1,41]},o($Vd,[2,27]),o($Vd,[2,29])],defaultActions:{2:[2,1],6:[2,2]},parseError:__name(function(str,hash){if(!hash.recoverable){var error=new Error(str);throw error.hash=hash,error}this.trace(str)},"parseError"),parse:__name(function(input){var self=this,stack=[0],tstack=[],vstack=[null],lstack=[],table=this.table,yytext="",yylineno=0,yyleng=0,args=lstack.slice.call(arguments,1),lexer2=Object.create(this.lexer),sharedState={yy:{}};for(var k in this.yy)Object.prototype.hasOwnProperty.call(this.yy,k)&&(sharedState.yy[k]=this.yy[k]);lexer2.setInput(input,sharedState.yy),sharedState.yy.lexer=lexer2,sharedState.yy.parser=this,void 0===lexer2.yylloc&&(lexer2.yylloc={});var yyloc=lexer2.yylloc;lstack.push(yyloc);var ranges=lexer2.options&&lexer2.options.ranges;function lex(){var token;return"number"!=typeof(token=tstack.pop()||lexer2.lex()||1)&&(token instanceof Array&&(token=(tstack=token).pop()),token=self.symbols_[token]||token),token}"function"==typeof sharedState.yy.parseError?this.parseError=sharedState.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError,__name(function(n){stack.length=stack.length-2*n,vstack.length=vstack.length-n,lstack.length=lstack.length-n},"popStack"),__name(lex,"lex");for(var symbol,state,action,r,p,len,newState,expected,yyval={};;){if(state=stack[stack.length-1],this.defaultActions[state]?action=this.defaultActions[state]:(null==symbol&&(symbol=lex()),action=table[state]&&table[state][symbol]),void 0===action||!action.length||!action[0]){var errStr="";for(p in expected=[],table[state])this.terminals_[p]&&p>2&&expected.push("'"+this.terminals_[p]+"'");errStr=lexer2.showPosition?"Parse error on line "+(yylineno+1)+":\n"+lexer2.showPosition()+"\nExpecting "+expected.join(", ")+", got '"+(this.terminals_[symbol]||symbol)+"'":"Parse error on line "+(yylineno+1)+": Unexpected "+(1==symbol?"end of input":"'"+(this.terminals_[symbol]||symbol)+"'"),this.parseError(errStr,{text:lexer2.match,token:this.terminals_[symbol]||symbol,line:lexer2.yylineno,loc:yyloc,expected:expected})}if(action[0]instanceof Array&&action.length>1)throw new Error("Parse Error: multiple actions possible at state: "+state+", token: "+symbol);switch(action[0]){case 1:stack.push(symbol),vstack.push(lexer2.yytext),lstack.push(lexer2.yylloc),stack.push(action[1]),symbol=null,yyleng=lexer2.yyleng,yytext=lexer2.yytext,yylineno=lexer2.yylineno,yyloc=lexer2.yylloc;break;case 2:if(len=this.productions_[action[1]][1],yyval.$=vstack[vstack.length-len],yyval._$={first_line:lstack[lstack.length-(len||1)].first_line,last_line:lstack[lstack.length-1].last_line,first_column:lstack[lstack.length-(len||1)].first_column,last_column:lstack[lstack.length-1].last_column},ranges&&(yyval._$.range=[lstack[lstack.length-(len||1)].range[0],lstack[lstack.length-1].range[1]]),void 0!==(r=this.performAction.apply(yyval,[yytext,yyleng,yylineno,sharedState.yy,action[1],vstack,lstack].concat(args))))return r;len&&(stack=stack.slice(0,-1*len*2),vstack=vstack.slice(0,-1*len),lstack=lstack.slice(0,-1*len)),stack.push(this.productions_[action[1]][0]),vstack.push(yyval.$),lstack.push(yyval._$),newState=table[stack[stack.length-2]][stack[stack.length-1]],stack.push(newState);break;case 3:return!0}}return!0},"parse")},lexer=function(){return{EOF:1,parseError:__name(function(str,hash){if(!this.yy.parser)throw new Error(str);this.yy.parser.parseError(str,hash)},"parseError"),setInput:__name(function(input,yy){return this.yy=yy||this.yy||{},this._input=input,this._more=this._backtrack=this.done=!1,this.yylineno=this.yyleng=0,this.yytext=this.matched=this.match="",this.conditionStack=["INITIAL"],this.yylloc={first_line:1,first_column:0,last_line:1,last_column:0},this.options.ranges&&(this.yylloc.range=[0,0]),this.offset=0,this},"setInput"),input:__name(function(){var ch=this._input[0];return this.yytext+=ch,this.yyleng++,this.offset++,this.match+=ch,this.matched+=ch,ch.match(/(?:\r\n?|\n).*/g)?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),ch},"input"),unput:__name(function(ch){var len=ch.length,lines=ch.split(/(?:\r\n?|\n)/g);this._input=ch+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-len),this.offset-=len;var oldLines=this.match.split(/(?:\r\n?|\n)/g);this.match=this.match.substr(0,this.match.length-1),this.matched=this.matched.substr(0,this.matched.length-1),lines.length-1&&(this.yylineno-=lines.length-1);var r=this.yylloc.range;return this.yylloc={first_line:this.yylloc.first_line,last_line:this.yylineno+1,first_column:this.yylloc.first_column,last_column:lines?(lines.length===oldLines.length?this.yylloc.first_column:0)+oldLines[oldLines.length-lines.length].length-lines[0].length:this.yylloc.first_column-len},this.options.ranges&&(this.yylloc.range=[r[0],r[0]+this.yyleng-len]),this.yyleng=this.yytext.length,this},"unput"),more:__name(function(){return this._more=!0,this},"more"),reject:__name(function(){return this.options.backtrack_lexer?(this._backtrack=!0,this):this.parseError("Lexical error on line "+(this.yylineno+1)+". You can only invoke reject() in the lexer when the lexer is of the backtracking persuasion (options.backtrack_lexer = true).\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"reject"),less:__name(function(n){this.unput(this.match.slice(n))},"less"),pastInput:__name(function(){var past=this.matched.substr(0,this.matched.length-this.match.length);return(past.length>20?"...":"")+past.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:__name(function(){var next=this.match;return next.length<20&&(next+=this._input.substr(0,20-next.length)),(next.substr(0,20)+(next.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:__name(function(){var pre=this.pastInput(),c=new Array(pre.length+1).join("-");return pre+this.upcomingInput()+"\n"+c+"^"},"showPosition"),test_match:__name(function(match,indexed_rule){var token,lines,backup;if(this.options.backtrack_lexer&&(backup={yylineno:this.yylineno,yylloc:{first_line:this.yylloc.first_line,last_line:this.last_line,first_column:this.yylloc.first_column,last_column:this.yylloc.last_column},yytext:this.yytext,match:this.match,matches:this.matches,matched:this.matched,yyleng:this.yyleng,offset:this.offset,_more:this._more,_input:this._input,yy:this.yy,conditionStack:this.conditionStack.slice(0),done:this.done},this.options.ranges&&(backup.yylloc.range=this.yylloc.range.slice(0))),(lines=match[0].match(/(?:\r\n?|\n).*/g))&&(this.yylineno+=lines.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:lines?lines[lines.length-1].length-lines[lines.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+match[0].length},this.yytext+=match[0],this.match+=match[0],this.matches=match,this.yyleng=this.yytext.length,this.options.ranges&&(this.yylloc.range=[this.offset,this.offset+=this.yyleng]),this._more=!1,this._backtrack=!1,this._input=this._input.slice(match[0].length),this.matched+=match[0],token=this.performAction.call(this,this.yy,this,indexed_rule,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),token)return token;if(this._backtrack){for(var k in backup)this[k]=backup[k];return!1}return!1},"test_match"),next:__name(function(){if(this.done)return this.EOF;var token,match,tempMatch,index;this._input||(this.done=!0),this._more||(this.yytext="",this.match="");for(var rules=this._currentRules(),i=0;i<rules.length;i++)if((tempMatch=this._input.match(this.rules[rules[i]]))&&(!match||tempMatch[0].length>match[0].length)){if(match=tempMatch,index=i,this.options.backtrack_lexer){if(!1!==(token=this.test_match(tempMatch,rules[i])))return token;if(this._backtrack){match=!1;continue}return!1}if(!this.options.flex)break}return match?!1!==(token=this.test_match(match,rules[index]))&&token:""===this._input?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+". Unrecognized text.\n"+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:__name(function(){var r=this.next();return r||this.lex()},"lex"),begin:__name(function(condition){this.conditionStack.push(condition)},"begin"),popState:__name(function(){return this.conditionStack.length-1>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:__name(function(){return this.conditionStack.length&&this.conditionStack[this.conditionStack.length-1]?this.conditions[this.conditionStack[this.conditionStack.length-1]].rules:this.conditions.INITIAL.rules},"_currentRules"),topState:__name(function(n){return(n=this.conditionStack.length-1-Math.abs(n||0))>=0?this.conditionStack[n]:"INITIAL"},"topState"),pushState:__name(function(condition){this.begin(condition)},"pushState"),stateStackSize:__name(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:__name(function(yy,yy_,$avoiding_name_collisions,YY_START){switch($avoiding_name_collisions){case 0:return this.pushState("shapeData"),yy_.yytext="",24;case 1:return this.pushState("shapeDataStr"),24;case 2:return this.popState(),24;case 3:const re=/\n\s*/g;return yy_.yytext=yy_.yytext.replace(re,"<br/>"),24;case 4:return 24;case 5:case 10:case 29:case 32:this.popState();break;case 6:return yy.getLogger().trace("Found comment",yy_.yytext),6;case 7:return 8;case 8:this.begin("CLASS");break;case 9:return this.popState(),17;case 11:yy.getLogger().trace("Begin icon"),this.begin("ICON");break;case 12:return yy.getLogger().trace("SPACELINE"),6;case 13:return 7;case 14:return 16;case 15:yy.getLogger().trace("end icon"),this.popState();break;case 16:return yy.getLogger().trace("Exploding node"),this.begin("NODE"),20;case 17:return yy.getLogger().trace("Cloud"),this.begin("NODE"),20;case 18:return yy.getLogger().trace("Explosion Bang"),this.begin("NODE"),20;case 19:return yy.getLogger().trace("Cloud Bang"),this.begin("NODE"),20;case 20:case 21:case 22:case 23:return this.begin("NODE"),20;case 24:return 13;case 25:return 23;case 26:return 11;case 27:this.begin("NSTR2");break;case 28:return"NODE_DESCR";case 30:yy.getLogger().trace("Starting NSTR"),this.begin("NSTR");break;case 31:return yy.getLogger().trace("description:",yy_.yytext),"NODE_DESCR";case 33:return this.popState(),yy.getLogger().trace("node end ))"),"NODE_DEND";case 34:return this.popState(),yy.getLogger().trace("node end )"),"NODE_DEND";case 35:return this.popState(),yy.getLogger().trace("node end ...",yy_.yytext),"NODE_DEND";case 36:case 39:case 40:return this.popState(),yy.getLogger().trace("node end (("),"NODE_DEND";case 37:case 38:return this.popState(),yy.getLogger().trace("node end (-"),"NODE_DEND";case 41:case 42:return yy.getLogger().trace("Long description:",yy_.yytext),21}},"anonymous"),rules:[/^(?:@\{)/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^\"]+)/i,/^(?:[^}^"]+)/i,/^(?:\})/i,/^(?:\s*%%.*)/i,/^(?:kanban\b)/i,/^(?::::)/i,/^(?:.+)/i,/^(?:\n)/i,/^(?:::icon\()/i,/^(?:[\s]+[\n])/i,/^(?:[\n]+)/i,/^(?:[^\)]+)/i,/^(?:\))/i,/^(?:-\))/i,/^(?:\(-)/i,/^(?:\)\))/i,/^(?:\))/i,/^(?:\(\()/i,/^(?:\{\{)/i,/^(?:\()/i,/^(?:\[)/i,/^(?:[\s]+)/i,/^(?:[^\(\[\n\)\{\}@]+)/i,/^(?:$)/i,/^(?:["][`])/i,/^(?:[^`"]+)/i,/^(?:[`]["])/i,/^(?:["])/i,/^(?:[^"]+)/i,/^(?:["])/i,/^(?:[\)]\))/i,/^(?:[\)])/i,/^(?:[\]])/i,/^(?:\}\})/i,/^(?:\(-)/i,/^(?:-\))/i,/^(?:\(\()/i,/^(?:\()/i,/^(?:[^\)\]\(\}]+)/i,/^(?:.+(?!\(\())/i],conditions:{shapeDataEndBracket:{rules:[],inclusive:!1},shapeDataStr:{rules:[2,3],inclusive:!1},shapeData:{rules:[1,4,5],inclusive:!1},CLASS:{rules:[9,10],inclusive:!1},ICON:{rules:[14,15],inclusive:!1},NSTR2:{rules:[28,29],inclusive:!1},NSTR:{rules:[31,32],inclusive:!1},NODE:{rules:[27,30,33,34,35,36,37,38,39,40,41,42],inclusive:!1},INITIAL:{rules:[0,6,7,8,11,12,13,16,17,18,19,20,21,22,23,24,25,26],inclusive:!0}}}}();function Parser(){this.yy={}}return parser2.lexer=lexer,__name(Parser,"Parser"),Parser.prototype=parser2,parser2.Parser=Parser,new Parser}();parser.parser=parser;var kanban_default=parser,nodes=[],sections=[],cnt=0,elements={},clear=__name(()=>{nodes=[],sections=[],cnt=0,elements={}},"clear"),getSection=__name(level=>{if(0===nodes.length)return null;const sectionLevel=nodes[0].level;let lastSection=null;for(let i=nodes.length-1;i>=0;i--)if(nodes[i].level!==sectionLevel||lastSection||(lastSection=nodes[i]),nodes[i].level<sectionLevel)throw new Error('Items without section detected, found section ("'+nodes[i].label+'")');return level===(null==lastSection?void 0:lastSection.level)?null:lastSection},"getSection"),getSections=__name(function(){return sections},"getSections"),getData=__name(function(){const _nodes=[],sections2=getSections(),conf=getConfig2();for(const section of sections2){const node={id:section.id,label:sanitizeText(section.label??"",conf),labelType:"markdown",isGroup:!0,ticket:section.ticket,shape:"kanbanSection",level:section.level,look:conf.look};_nodes.push(node);const children=nodes.filter(n=>n.parentId===section.id);for(const item of children){const childNode={id:item.id,parentId:section.id,label:sanitizeText(item.label??"",conf),labelType:"markdown",isGroup:!1,ticket:null==item?void 0:item.ticket,priority:null==item?void 0:item.priority,assigned:null==item?void 0:item.assigned,icon:null==item?void 0:item.icon,shape:"kanbanItem",level:item.level,rx:5,ry:5,cssStyles:["text-align: left"]};_nodes.push(childNode)}}return{nodes:_nodes,edges:[],other:{},config:getConfig2()}},"getData"),addNode=__name((level,id,descr,type,shapeData)=>{var _a,_b;const conf=getConfig2();let padding=(null==(_a=conf.mindmap)?void 0:_a.padding)??defaultConfig_default.mindmap.padding;switch(type){case nodeType.ROUNDED_RECT:case nodeType.RECT:case nodeType.HEXAGON:padding*=2}const node={id:sanitizeText(id,conf)||"kbn"+cnt++,level:level,label:sanitizeText(descr,conf),width:(null==(_b=conf.mindmap)?void 0:_b.maxNodeWidth)??defaultConfig_default.mindmap.maxNodeWidth,padding:padding,isGroup:!1};if(void 0!==shapeData){let yamlData;yamlData=shapeData.includes("\n")?shapeData+"\n":"{\n"+shapeData+"\n}";const doc=load(yamlData,{schema:JSON_SCHEMA});if(doc.shape&&(doc.shape!==doc.shape.toLowerCase()||doc.shape.includes("_")))throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`);(null==doc?void 0:doc.shape)&&"kanbanItem"===doc.shape&&(node.shape=null==doc?void 0:doc.shape),(null==doc?void 0:doc.label)&&(node.label=null==doc?void 0:doc.label),(null==doc?void 0:doc.icon)&&(node.icon=null==doc?void 0:doc.icon.toString()),(null==doc?void 0:doc.assigned)&&(node.assigned=null==doc?void 0:doc.assigned.toString()),(null==doc?void 0:doc.ticket)&&(node.ticket=null==doc?void 0:doc.ticket.toString()),(null==doc?void 0:doc.priority)&&(node.priority=null==doc?void 0:doc.priority)}const section=getSection(level);section?node.parentId=section.id||"kbn"+cnt++:sections.push(node),nodes.push(node)},"addNode"),nodeType={DEFAULT:0,NO_BORDER:0,ROUNDED_RECT:1,RECT:2,CIRCLE:3,CLOUD:4,BANG:5,HEXAGON:6},kanbanDb_default={clear:clear,addNode:addNode,getSections:getSections,getData:getData,nodeType:nodeType,getType:__name((startStr,endStr)=>{switch(log.debug("In get type",startStr,endStr),startStr){case"[":return nodeType.RECT;case"(":return")"===endStr?nodeType.ROUNDED_RECT:nodeType.CLOUD;case"((":return nodeType.CIRCLE;case")":return nodeType.CLOUD;case"))":return nodeType.BANG;case"{{":return nodeType.HEXAGON;default:return nodeType.DEFAULT}},"getType"),setElementForId:__name((id,element)=>{elements[id]=element},"setElementForId"),decorateNode:__name(decoration=>{if(!decoration)return;const config=getConfig2(),node=nodes[nodes.length-1];decoration.icon&&(node.icon=sanitizeText(decoration.icon,config)),decoration.class&&(node.cssClasses=sanitizeText(decoration.class,config))},"decorateNode"),type2Str:__name(type=>{switch(type){case nodeType.DEFAULT:return"no-border";case nodeType.RECT:return"rect";case nodeType.ROUNDED_RECT:return"rounded-rect";case nodeType.CIRCLE:return"circle";case nodeType.CLOUD:return"cloud";case nodeType.BANG:return"bang";case nodeType.HEXAGON:return"hexgon";default:return"no-border"}},"type2Str"),getLogger:__name(()=>log,"getLogger"),getElementById:__name(id=>elements[id],"getElementById")},kanbanRenderer_default={draw:__name(async(text,id,_version,diagObj)=>{var _a,_b,_c,_d,_e;log.debug("Rendering kanban diagram\n"+text);const data4Layout=diagObj.db.getData(),conf=getConfig2();conf.htmlLabels=!1;const svg=selectSvgElement(id);for(const node of data4Layout.nodes)node.domId=`${id}-${node.id}`;const sectionsElem=svg.append("g");sectionsElem.attr("class","sections");const nodesElem=svg.append("g");nodesElem.attr("class","items");const sections2=data4Layout.nodes.filter(node=>node.isGroup);let cnt2=0;const sectionObjects=[];let maxLabelHeight=25;for(const section of sections2){const WIDTH=(null==(_a=null==conf?void 0:conf.kanban)?void 0:_a.sectionWidth)||200;cnt2+=1,section.x=WIDTH*cnt2+10*(cnt2-1)/2,section.width=WIDTH,section.y=0,section.height=3*WIDTH,section.rx=5,section.ry=5,section.cssClasses=section.cssClasses+" section-"+cnt2;const sectionObj=await insertCluster(sectionsElem,section);maxLabelHeight=Math.max(maxLabelHeight,null==(_b=null==sectionObj?void 0:sectionObj.labelBBox)?void 0:_b.height),sectionObjects.push(sectionObj)}let i=0;for(const section of sections2){const sectionObj=sectionObjects[i];i+=1;const WIDTH=(null==(_c=null==conf?void 0:conf.kanban)?void 0:_c.sectionWidth)||200,top=3*-WIDTH/2+maxLabelHeight;let y=top;const sectionItems=data4Layout.nodes.filter(node=>node.parentId===section.id);for(const item of sectionItems){if(item.isGroup)throw new Error("Groups within groups are not allowed in Kanban diagrams");item.x=section.x,item.width=WIDTH-15;const bbox=(await insertNode(nodesElem,item,{config:conf})).node().getBBox();item.y=y+bbox.height/2,await positionNode(item),y=item.y+bbox.height/2+5}const rect=sectionObj.cluster.select("rect"),height=Math.max(y-top+30,50)+(maxLabelHeight-25);rect.attr("height",height)}setupGraphViewbox(void 0,svg,(null==(_d=conf.mindmap)?void 0:_d.padding)??defaultConfig_default.kanban.padding,(null==(_e=conf.mindmap)?void 0:_e.useMaxWidth)??defaultConfig_default.kanban.useMaxWidth)},"draw")},genSections=__name(options=>{let sections2="";for(let i=0;i<options.THEME_COLOR_LIMIT;i++)options["lineColor"+i]=options["lineColor"+i]||options["cScaleInv"+i],isDark(options["lineColor"+i])?options["lineColor"+i]=lighten(options["lineColor"+i],20):options["lineColor"+i]=darken(options["lineColor"+i],20);const adjuster=__name((color,level)=>options.darkMode?darken(color,level):lighten(color,level),"adjuster");for(let i=0;i<options.THEME_COLOR_LIMIT;i++){const sw=""+(17-3*i);sections2+=`\n .section-${i-1} rect, .section-${i-1} path, .section-${i-1} circle, .section-${i-1} polygon, .section-${i-1} path {\n fill: ${adjuster(options["cScale"+i],10)};\n stroke: ${adjuster(options["cScale"+i],10)};\n\n }\n .section-${i-1} text {\n fill: ${options["cScaleLabel"+i]};\n }\n .node-icon-${i-1} {\n font-size: 40px;\n color: ${options["cScaleLabel"+i]};\n }\n .section-edge-${i-1}{\n stroke: ${options["cScale"+i]};\n }\n .edge-depth-${i-1}{\n stroke-width: ${sw};\n }\n .section-${i-1} line {\n stroke: ${options["cScaleInv"+i]} ;\n stroke-width: 3;\n }\n\n .disabled, .disabled circle, .disabled text {\n fill: lightgray;\n }\n .disabled text {\n fill: #efefef;\n }\n\n .node rect,\n .node circle,\n .node ellipse,\n .node polygon,\n .node path {\n fill: ${options.background};\n stroke: ${options.nodeBorder};\n stroke-width: 1px;\n }\n\n .kanban-ticket-link {\n fill: ${options.background};\n stroke: ${options.nodeBorder};\n text-decoration: underline;\n }\n `}return sections2},"genSections"),diagram={db:kanbanDb_default,renderer:kanbanRenderer_default,parser:kanban_default,styles:__name(options=>`\n .edge {\n stroke-width: 3;\n }\n ${genSections(options)}\n .section-root rect, .section-root path, .section-root circle, .section-root polygon {\n fill: ${options.git0};\n }\n .section-root text {\n fill: ${options.gitBranchLabel0};\n }\n .icon-container {\n height:100%;\n display: flex;\n justify-content: center;\n align-items: center;\n }\n .edge {\n fill: none;\n }\n .cluster-label, .label {\n color: ${options.textColor};\n fill: ${options.textColor};\n }\n .kanban-label {\n dy: 1em;\n alignment-baseline: middle;\n text-anchor: middle;\n dominant-baseline: middle;\n text-align: center;\n }\n ${getIconStyles()}\n`,"getStyles")};export{diagram};
@@ -1 +1 @@
1
- import{b as baseClone,G as Graph,i as isUndefined,v as values}from"./graph-D_JLoOax.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-CPUnJ5bQ.js";import{f as flatten,b as baseExtremum,a as baseLt,c as baseMap,m as map,d as min}from"./min-B9yebCuj.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-CDgdx9l7.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-I1olozIg.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-r3p3rodd.js";import{f as flatten,b as baseExtremum,a as baseLt,c as baseMap,m as map,d as min}from"./min-D-YA3MGY.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-BV3ugHFm.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-CDgdx9l7.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-BV3ugHFm.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};