@xiaobuyu/nodesign 0.0.2 → 0.0.4

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 (111) hide show
  1. package/README.en.md +184 -0
  2. package/README.md +19 -25
  3. package/package.json +2 -1
  4. package/server/api/assets/helpers.js +20 -0
  5. package/server/api/assets/notes.js +50 -0
  6. package/server/api/assets.js +6 -11
  7. package/server/api/board.js +78 -1
  8. package/server/engine/agent/events.js +1 -0
  9. package/server/engine/agent/hooks/user-prompt-submit.js +43 -0
  10. package/server/engine/agent/prompts/nodesign-prelude.md +53 -1
  11. package/server/engine/agent/session-loop.js +11 -0
  12. package/server/engine/mcp/index.js +12 -0
  13. package/server/engine/mcp/tools/arrange-on-board.js +4 -4
  14. package/server/engine/mcp/tools/create-on-board.js +9 -12
  15. package/server/engine/mcp/tools/edit-sketch.js +167 -0
  16. package/server/engine/mcp/tools/look-at-board.js +124 -0
  17. package/server/engine/mcp/tools/read-board.js +121 -34
  18. package/server/engine/mcp/tools/read-user-view.js +59 -0
  19. package/server/engine/mcp/tools/relate-on-board.js +5 -3
  20. package/server/engine/mcp/tools/sketch-on-board.js +337 -0
  21. package/server/engine/mcp/tools/write-on-board.js +130 -0
  22. package/server/engine/plugins/nodesign/skills/deskskill-engine-mini/SKILL.md +7 -0
  23. package/server/engine/plugins/nodesign/skills/docx-craft/SKILL.md +7 -0
  24. package/server/engine/plugins/nodesign/skills/rp-craft/SKILL.md +7 -0
  25. package/server/engine/plugins/nodesign/skills/site-craft/SKILL.md +7 -0
  26. package/server/engine/runs/board-tasklist.js +130 -0
  27. package/server/index.js +3 -0
  28. package/server/lib/binding-types.js +12 -0
  29. package/server/lib/board-graph-export.js +191 -0
  30. package/server/lib/board-groups.js +167 -0
  31. package/server/lib/board-hero.js +76 -0
  32. package/server/lib/board-kind-sizes.js +23 -0
  33. package/server/lib/board-relations.js +1 -1
  34. package/server/lib/chalk.js +121 -0
  35. package/server/lib/sketch-layout.js +277 -0
  36. package/server/projects/board-limits.js +12 -0
  37. package/server/projects/board-sanitize.js +252 -0
  38. package/server/projects/board-store.js +72 -205
  39. package/server/projects/ui-config.js +6 -0
  40. package/server/projects/viewpoint-store.js +78 -0
  41. package/server/ws/broker.js +3 -0
  42. package/web/dist/assets/{BrowserWindow-BYCgizHw.js → BrowserWindow-P_vIdh-G.js} +2 -2
  43. package/web/dist/assets/{DeckWindow-pNydEM4L.js → DeckWindow-BpLv5082.js} +3 -3
  44. package/web/dist/assets/{DocxWindow-PPgzh3Gq.js → DocxWindow-DSAU1-tD.js} +4 -4
  45. package/web/dist/assets/MermaidBlock-DR1GikCv.js +313 -0
  46. package/web/dist/assets/SiteWindow-92uBuRRR.js +18 -0
  47. package/web/dist/assets/abnfDiagram-VCTEODGH-uA8Esix4.js +1 -0
  48. package/web/dist/assets/arc-D_khH_xN.js +1 -0
  49. package/web/dist/assets/architectureDiagram-5GKGNRK7-DydJHqOt.js +36 -0
  50. package/web/dist/assets/blockDiagram-NRAW4CY4-B7wBbKiW.js +129 -0
  51. package/web/dist/assets/c4Diagram-UCG6FXSJ-6mrH0x7Y.js +38 -0
  52. package/web/dist/assets/channel-DGkccMO1.js +1 -0
  53. package/web/dist/assets/chunk-2Q5K7J3B-Cuikho5Q.js +1 -0
  54. package/web/dist/assets/chunk-5VM5RSS4-3-KZ5AUz.js +15 -0
  55. package/web/dist/assets/chunk-F27PBJKO-Bkwq2gGU.js +1 -0
  56. package/web/dist/assets/chunk-G27WJ6UU-BLyQzdGE.js +231 -0
  57. package/web/dist/assets/chunk-JWPE2WC7-B7HxxQds.js +1 -0
  58. package/web/dist/assets/chunk-LCL6LL3I-CtXrnUwF.js +206 -0
  59. package/web/dist/assets/chunk-POPQ4Y6H-dxddZlXt.js +1 -0
  60. package/web/dist/assets/chunk-SVP7TREG-DpkmrgHn.js +88 -0
  61. package/web/dist/assets/chunk-XXDRQBXY-BwZ7RbpQ.js +1 -0
  62. package/web/dist/assets/classDiagram-DTDB5LWJ-BGscw3OD.js +1 -0
  63. package/web/dist/assets/classDiagram-v2-JRS7N3AN-BGscw3OD.js +1 -0
  64. package/web/dist/assets/cose-bilkent-JH36ORCC-DGFOsMUt.js +1 -0
  65. package/web/dist/assets/cynefin-OW5HDTMX-DUwn3ehS.js +178 -0
  66. package/web/dist/assets/cynefinDiagram-5FMLGOSQ-DlLAOZ9x.js +62 -0
  67. package/web/dist/assets/cytoscape.esm-BjAbmLdb.js +331 -0
  68. package/web/dist/assets/dagre-3AP2YEHR-CyourLfz.js +4 -0
  69. package/web/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  70. package/web/dist/assets/diagram-S7CK7UJ4-BTMbx2np.js +30 -0
  71. package/web/dist/assets/diagram-UQ7AKVKN-UK94_1-P.js +41 -0
  72. package/web/dist/assets/diagram-VSXAHHWV-C7zS-v9v.js +3 -0
  73. package/web/dist/assets/diagram-VX7I27RA-DKJRa6CK.js +24 -0
  74. package/web/dist/assets/diagram-Z3DM3KII-kUbAfGAp.js +24 -0
  75. package/web/dist/assets/ebnfDiagram-PWID7BFC-CVW16_vb.js +1 -0
  76. package/web/dist/assets/erDiagram-SSCWMZ5O-BRQMFQ5y.js +99 -0
  77. package/web/dist/assets/flowDiagram-A5DVABFB-S34LpLtK.js +168 -0
  78. package/web/dist/assets/ganttDiagram-EL5Y4UJY-BFiqk1-G.js +292 -0
  79. package/web/dist/assets/gitGraphDiagram-WWUBYQGX-LZsrdyyv.js +106 -0
  80. package/web/dist/assets/index-GAamh1p4.js +2152 -0
  81. package/web/dist/assets/infoDiagram-RXCK75RN-0DvN6KIp.js +2 -0
  82. package/web/dist/assets/init-Gi6I4Gst.js +1 -0
  83. package/web/dist/assets/ishikawaDiagram-5VMMS53U-CaY3A-Bx.js +70 -0
  84. package/web/dist/assets/journeyDiagram-EYS64GPL-BBeiaCrj.js +139 -0
  85. package/web/dist/assets/kanban-definition-3QL26DDD-ux42DRXQ.js +89 -0
  86. package/web/dist/assets/layout-CnXiF_NB.js +1 -0
  87. package/web/dist/assets/linear-BMW0u6G6.js +1 -0
  88. package/web/dist/assets/mindmap-definition-FBJOCRG2-hUxSpdKn.js +96 -0
  89. package/web/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  90. package/web/dist/assets/pegDiagram-XKGWAZYB-aCaQPH0w.js +1 -0
  91. package/web/dist/assets/{pending-edit-apply-C0I13CbD.js → pending-edit-apply-AcdOQ9Ij.js} +6 -6
  92. package/web/dist/assets/pieDiagram-E7YTZNPT-CmOEZ8zg.js +39 -0
  93. package/web/dist/assets/quadrantDiagram-AXDQQJYC-VW6fAhsV.js +7 -0
  94. package/web/dist/assets/railroadDiagram-O6MQD6OU-CKJ7Ba5K.js +1 -0
  95. package/web/dist/assets/requirementDiagram-EFPCY7ZU-pNGkq9Vw.js +84 -0
  96. package/web/dist/assets/{rotate-cw-B1UQ8Hld.js → rotate-cw-KAfChbGV.js} +1 -1
  97. package/web/dist/assets/sankeyDiagram-P5KCCOFB-BIMmDTfZ.js +40 -0
  98. package/web/dist/assets/sequenceDiagram-WJ2MYXX4-BBW7wzKY.js +162 -0
  99. package/web/dist/assets/sizeCapture-X5ZJPWSS-DdkXmLYR.js +1 -0
  100. package/web/dist/assets/{square-dashed-mouse-pointer-8lrgqmfv.js → square-dashed-mouse-pointer-CDUlhUP7.js} +1 -1
  101. package/web/dist/assets/stateDiagram-HBIQ2CUA-W313Uz16.js +1 -0
  102. package/web/dist/assets/stateDiagram-v2-4QOOHH4V-DDhJBZzf.js +1 -0
  103. package/web/dist/assets/swimlanes-XN3QIQJK-C29TL26K.js +1 -0
  104. package/web/dist/assets/swimlanesDiagram-VK2B7HYN-BfN-Xdmu.js +8 -0
  105. package/web/dist/assets/timeline-definition-24CTP7MA-CF0JMObX.js +120 -0
  106. package/web/dist/assets/vennDiagram-4TSXK5OY-DrDFsaH3.js +34 -0
  107. package/web/dist/assets/wardleyDiagram-VM6X3IG4-CVrnRIS_.js +78 -0
  108. package/web/dist/assets/xychartDiagram-S5SC5T6Z-BvkN1zsT.js +7 -0
  109. package/web/dist/index.html +1 -1
  110. package/web/dist/assets/SiteWindow-DM0LQPCO.js +0 -18
  111. package/web/dist/assets/index-BHTBJlpY.js +0 -2125
@@ -0,0 +1,4 @@
1
+ import{_ as m,ao as D,c as A,Q as Y,l as p,ap as _,aq as z,ar as b,as as H,at as J,au as T,av as R,aw as F,ax as q,ay as C,ah as P,af as W,az as j,aA as Q}from"./MermaidBlock-DR1GikCv.js";import{l as U}from"./layout-CnXiF_NB.js";import"./index-GAamh1p4.js";var v=m((t,e,d)=>Math.max(e,Math.min(d,t)),"clamp"),B=m((t="TB")=>{switch(t){case"BT":return"bottom";case"LR":return"right";case"RL":return"left";case"TB":default:return"top"}},"getDefaultSelfLoopSide"),K=m(t=>t==="flowchart"||t==="flowchart-v2"||t==="stateDiagram"||t==="er"||t==="classDiagram","shouldMergeSelfLoopSegments"),V=["x","y","width","height","labelBBox","intersect","calcIntersect","diff","clusterNode"],Z=m((t,e,d,g,s)=>{const h=[],L=new Set;if(d.forEach(({start:l,end:r})=>{l!==g&&L.add(l),r!==g&&L.add(r)}),L.forEach(l=>{const r=t.node(l);typeof(r==null?void 0:r.x)=="number"&&typeof(r==null?void 0:r.y)=="number"&&h.push(r)}),h.length===0&&d.forEach(({edge:l})=>{(l.points??[]).forEach(r=>{typeof(r==null?void 0:r.x)=="number"&&typeof(r==null?void 0:r.y)=="number"&&h.push(r)})}),h.length===0)return B(s);const c=h.reduce((l,r)=>({x:l.x+r.x/h.length,y:l.y+r.y/h.length}),{x:0,y:0}),i=c.x-e.x,o=c.y-e.y;return Math.abs(i)>Math.abs(o)?i>0?"right":"left":Math.abs(o)>0?o>0?"bottom":"top":B(s)},"getSelfLoopSide"),$=m((t,e="top",d=0,g=0)=>{const s=t.x,h=t.y-d,L=t.width/2,c=t.height/2,i=Math.max(36,Math.min(100,t.width*.8)),o=v(Math.max(g,t.width*.35),36,i),l=v(Math.min(t.width,t.height)*.45,24,48);switch(e){case"bottom":{const r=h+c;return[{x:s-o/2,y:r},{x:s-o/2,y:r+l},{x:s+o/2,y:r+l},{x:s+o/2,y:r}]}case"right":{const r=s+L;return[{x:r,y:h-o/2},{x:r+l,y:h-o/2},{x:r+l,y:h+o/2},{x:r,y:h+o/2}]}case"left":{const r=s-L;return[{x:r,y:h-o/2},{x:r-l,y:h-o/2},{x:r-l,y:h+o/2},{x:r,y:h+o/2}]}case"top":default:{const r=h-c;return[{x:s-o/2,y:r},{x:s-o/2,y:r-l},{x:s+o/2,y:r-l},{x:s+o/2,y:r}]}}},"getSelfLoopPoints"),ee=m((t,e,d="top",g=0,s={})=>{const L=t.x,c=t.y-g,i=s.width??0,o=s.height??0;switch(d){case"bottom":return{x:L,y:Math.max(...e.map(l=>l.y))+o/2+4};case"right":return{x:Math.max(...e.map(l=>l.x))+i/2+4,y:c};case"left":return{x:Math.min(...e.map(l=>l.x))-i/2-4,y:c};case"top":default:return{x:L,y:Math.min(...e.map(l=>l.y))-o/2-4}}},"getSelfLoopLabelPosition"),M=m((t,e=0,{mergeSelfLoops:d=!0}={})=>{var L;const g=new Map,s=[],h=(L=t.graph())==null?void 0:L.rankdir;return t.edges().forEach(c=>{const i=t.edge(c);if(d&&i.selfLoop){const o=i.selfLoop.id;g.has(o)||g.set(o,[]),g.get(o).push({edge:i,start:c.v,end:c.w})}else s.push({edge:i,start:c.v,end:c.w})}),g.forEach(c=>{if(c.length!==3){c.forEach(E=>s.push(E));return}c.sort((E,x)=>E.edge.selfLoop.order-x.edge.selfLoop.order);const[i,o,l]=c,r=i.edge.originalEdge??o.edge.originalEdge??l.edge.originalEdge??o.edge,a=t.node(r.start);if(!a){c.forEach(E=>s.push(E));return}const w={width:o.edge.width,height:o.edge.height},y=Z(t,a,c,r.start,h),f=$(a,y,e,w.width??0),n=ee(a,f,y,e,w),u={...o.edge,...r,id:r.id,points:f,start:r.start,end:r.end,x:n.x,y:n.y,width:w.width,height:w.height,labelStyle:o.edge.labelStyle,fromCluster:i.edge.fromCluster??o.edge.fromCluster??l.edge.fromCluster,toCluster:i.edge.toCluster??o.edge.toCluster??l.edge.toCluster};delete u.selfLoop,delete u.originalEdge,s.push({edge:u,start:u.start,end:u.end})}),s},"getEdgesToRender"),G=m(async({element:t,graph:e,diagramType:d,id:g,parentCluster:s,siteConfig:h})=>{const L=e.graph().rankdir;p.trace("Dir in recursive render - dir:",L);const{clusters:c,edgePaths:i,edgeLabels:o,nodes:l,rootGroups:r}=H(t,{edgePathsClass:"edgePaths"});e.nodes()?p.info("Recursive render XXX",e.nodes()):p.info("No nodes found for",e),e.edges().length>0&&p.info("Recursive edges",e.edge(e.edges()[0]));const a=K(d);await Promise.all(e.nodes().map(async function(f){const n=e.node(f);if(s!==void 0){const u=JSON.parse(JSON.stringify(s.clusterData));p.trace(`Setting data for parent cluster XXX
2
+ Node.id = `,f,`
3
+ data=`,u.height,`
4
+ Parent cluster`,s.height),e.setNode(s.id,u),e.parent(f)||(p.trace("Setting parent",f,s.id),e.setParent(f,s.id,u))}if(p.info("(Insert) Node XXX"+f+": "+JSON.stringify(e.node(f))),n!=null&&n.clusterNode){p.info("Cluster identified XBX",f,n.width,e.node(f));const{ranksep:u,nodesep:E}=e.graph();n.graph.setGraph({...n.graph.graph(),ranksep:u+25,nodesep:E});const x=await ne({element:l,graph:n.graph,diagramType:d,id:g,parentCluster:e.node(f),siteConfig:h}),S=x.elem;J(n,S),n.diff=x.diff||0,p.info("New compound node after recursive render XAX",f,"width",n.width,"height",n.height),T(S,n)}else e.children(f).length>0?(p.trace("Cluster - the non recursive path XBX",f,n.id,n,n.width,"Graph:",e),p.trace(R(n.id,e)),b.set(n.id,{id:R(n.id,e),node:n})):(p.trace("Node - the non recursive path XAX",f,l,e.node(f),L),await F(l,e.node(f),{config:h,dir:L}))})),await m(async()=>{const f=e.edges().map(async function(n){var E,x,S,X;const u=e.edge(n.v,n.w,n.name);if(p.info("Edge "+n.v+" -> "+n.w+": "+JSON.stringify(n)),p.info("Edge "+n.v+" -> "+n.w+": ",n," ",JSON.stringify(e.edge(n))),p.info("Fix",b,"ids:",n.v,n.w,"Translating: ",b.get(n.v),b.get(n.w)),a&&u.selfLoop){if(u.selfLoop.order!==1)return;const N={...u.originalEdge,...u,id:u.selfLoop.id,startLabelLeft:((E=u.originalEdge)==null?void 0:E.startLabelLeft)??u.startLabelLeft,startLabelRight:((x=u.originalEdge)==null?void 0:x.startLabelRight)??u.startLabelRight,endLabelLeft:((S=u.originalEdge)==null?void 0:S.endLabelLeft)??u.endLabelLeft,endLabelRight:((X=u.originalEdge)==null?void 0:X.endLabelRight)??u.endLabelRight};await C(o,N),u.width=N.width,u.height=N.height,u.labelStyle=N.labelStyle;return}await C(o,u)});await Promise.all(f)},"processEdges")();const{subGraphTitleTotalMargin:y}=q(h);return{elem:r,graph:e,groups:{clusters:c,edgePaths:i,edgeLabels:o,nodes:l,rootGroups:r},diagramType:d,id:g,mergeSelfLoops:a,subGraphTitleTotalMargin:y}},"measureDagreGraph"),k=m(t=>{p.info("############################################# XXX"),p.info("### Layout ### XXX"),p.info("############################################# XXX"),U(t)},"runDagreGraphLayout"),te=m((t,e,d)=>{const g=t.node(e);if(!g)return;const s={...g};return g!=null&&g.clusterNode?s.y=(g.y??0)+d:t.children(e).length>0?s.height=(g.height??0)+d:s.y=(g.y??0)+d/2,s},"normalizeDagreNode"),I=m((t,e)=>{V.forEach(d=>{e[d]!==void 0&&(t[d]=e[d])})},"applyDagreNodeLayout"),re=m((t,e,d,g)=>({...t,start:t.start??e,end:t.end??d,points:(t.points??[]).map(s=>({...s,y:typeof s.y=="number"?s.y+g:s.y}))}),"normalizeDagreEdge"),ae=m((t,e)=>{const{graph:d,mergeSelfLoops:g,subGraphTitleTotalMargin:s=0}=e,h=new Map(t.nodes.map(c=>[c.id,c]));D(d).forEach(c=>{const i=te(d,c,s);if(!i)return;I(d.node(c),i);const o=h.get(c);o&&I(o,i)});const L=s/2;return t.edges=M(d,L,{mergeSelfLoops:g}).map(({edge:c,start:i,end:o})=>re(c,i,o,L)),t},"applyDagreLayoutResult"),oe=m(async({elem:t,graph:e,groups:{clusters:d,edgePaths:g},diagramType:s,id:h,mergeSelfLoops:L,subGraphTitleTotalMargin:c})=>{let i=0;await Promise.all(D(e).map(async function(r){var w;const a=e.node(r);if(p.info("Position XBX => "+r+": ("+a.x,","+a.y,") width: ",a.width," height: ",a.height),a!=null&&a.clusterNode)a.y+=c,p.info("A tainted cluster node XBX1",r,a.id,a.width,a.height,a.x,a.y,e.parent(r)),b.get(a.id).node=a,P(a);else if(e.children(r).length>0){p.info("A pure cluster node XBX1",r,a.id,a.x,a.y,a.width,a.height,e.parent(r)),a.height+=c,e.node(a.parentId);const y=(a==null?void 0:a.padding)/2||0,f=((w=a==null?void 0:a.labelBBox)==null?void 0:w.height)||0,n=f-y||0;p.debug("OffsetY",n,"labelHeight",f,"halfPadding",y),await W(d,a),b.get(a.id).node=a}else{const y=e.node(a.parentId);a.y+=c/2,p.info("A regular node XBX1 - using the padding",a.id,"parent",a.parentId,a.width,a.height,a.x,a.y,"offsetY",a.offsetY,"parent",y,y==null?void 0:y.offsetY,a),P(a)}}));const o=c/2;return M(e,o,{mergeSelfLoops:L}).forEach(function({edge:r,start:a,end:w}){p.info("Edge "+a+" -> "+w+": "+JSON.stringify(r),r),r.points.forEach(u=>u.y+=o);const y=e.node(a),f=e.node(w),n=j(g,r,b,s,y,f,h);Q(r,n)}),e.nodes().forEach(function(r){const a=e.node(r);p.info(r,a.type,a.diff),a.isGroup&&(i=a.diff)}),p.warn("Returning from recursive render XAX",t,i),{elem:t,diff:i}},"paintDagreLayoutCore"),ne=m(async t=>{const e=await G(t);return k(e.graph),await oe(e)},"renderDagreSubgraph"),O=m(t=>{var d,g,s,h,L,c;const e=new Y({multigraph:!0,compound:!0}).setGraph({rankdir:t.direction,nodesep:((d=t.config)==null?void 0:d.nodeSpacing)||t.nodeSpacing||((s=(g=t.config)==null?void 0:g.flowchart)==null?void 0:s.nodeSpacing),ranksep:((h=t.config)==null?void 0:h.rankSpacing)||t.rankSpacing||((c=(L=t.config)==null?void 0:L.flowchart)==null?void 0:c.rankSpacing),marginx:8,marginy:8}).setDefaultEdgeLabel(function(){return{}});return t.nodes.forEach(i=>{e.setNode(i.id,{...i}),i.parentId&&e.setParent(i.id,i.parentId)}),p.debug("Edges:",t.edges),t.edges.forEach(i=>{if(i.start===i.end){const o=i.start,l=o+"---"+o+"---1",r=o+"---"+o+"---2",a=e.node(o);e.setNode(l,{domId:l,id:l,parentId:a.parentId,labelStyle:"",label:"",padding:0,shape:"labelRect",style:"",width:10,height:10}),e.setParent(l,a.parentId),e.setNode(r,{domId:r,id:r,parentId:a.parentId,labelStyle:"",padding:0,shape:"labelRect",label:"",style:"",width:10,height:10}),e.setParent(r,a.parentId);const w=structuredClone(i),y=structuredClone(i),f=structuredClone(i),n=structuredClone(i);y.originalEdge=w,y.selfLoop={id:w.id,order:0},f.originalEdge=w,f.selfLoop={id:w.id,order:1},n.originalEdge=w,n.selfLoop={id:w.id,order:2},y.label="",y.arrowTypeEnd="none",y.endLabelLeft="",y.endLabelRight="",y.startLabelLeft="",y.id=o+"-cyclic-special-1",f.startLabelRight="",f.startLabelLeft="",f.endLabelLeft="",f.endLabelRight="",f.arrowTypeStart="none",f.arrowTypeEnd="none",f.id=o+"-cyclic-special-mid",n.label="",n.startLabelRight="",n.startLabelLeft="",n.arrowTypeStart="none",a.isGroup&&(y.fromCluster=o,n.toCluster=o),n.id=o+"-cyclic-special-2",n.arrowTypeStart="none",e.setEdge(o,l,y,o+"-cyclic-special-0"),e.setEdge(l,r,f,o+"-cyclic-special-1"),e.setEdge(r,o,n,o+"-cyclic-special-2")}else e.setEdge(i.start,i.end,{...i},i.id)}),_(e),{graph:e}},"prepareLayoutForDagre"),se=m(async(t,{element:e,preparedLayout:d})=>{const g=d??O(t),s=A(),h=await G({element:e,graph:g.graph,diagramType:t.type,id:t.diagramId,parentCluster:void 0,siteConfig:s});return g.measuredLayout=h,h},"measureDagreLayout"),ie=m((t,e)=>{var g;const d=(g=e.preparedLayout)==null?void 0:g.measuredLayout;if(!d)throw new Error("runDagreLayoutCore requires measureDagreLayout to run first");return k(d.graph),ae(t,d),d},"runDagreLayoutCore"),de=m((t,{measure:e})=>D(e.graph).map(d=>e.graph.node(d)).filter(Boolean),"getDagrePaintNodes"),le=m((t,e,{measure:d})=>t?d.graph.node(t):void 0,"getDagreEdgeNode"),he=z({prepareLayout:O,measureLayout:se,runLayoutCore:ie,paintOptions:{clusterDb:b,getNodes:de,getEdgeNode:le,skipNode:m((t,{measure:e})=>!e.graph.hasNode(t.id),"skipNode"),isCluster:m((t,{measure:e})=>e.graph.hasNode(t.id)&&(e.graph.children(t.id)??[]).length>0,"isCluster")}});export{ae as applyDagreLayoutResult,M as getEdgesToRender,se as measureDagreLayout,O as prepareLayoutForDagre,he as render,ie as runDagreLayoutCore};
@@ -0,0 +1 @@
1
+ function J(n){return Math.abs(n=Math.round(n))>=1e21?n.toLocaleString("en").replace(/,/g,""):n.toString(10)}function j(n,t){if(!isFinite(n)||n===0)return null;var e=(n=t?n.toExponential(t-1):n.toExponential()).indexOf("e"),i=n.slice(0,e);return[i.length>1?i[0]+i.slice(2):i,+n.slice(e+1)]}function K(n){return n=j(Math.abs(n)),n?n[1]:NaN}function Q(n,t){return function(e,i){for(var o=e.length,a=[],c=0,h=n[0],M=0;o>0&&h>0&&(M+h+1>i&&(h=Math.max(1,i-M)),a.push(e.substring(o-=h,o+h)),!((M+=h+1)>i));)h=n[c=(c+1)%n.length];return a.reverse().join(t)}}function V(n){return function(t){return t.replace(/[0-9]/g,function(e){return n[+e]})}}var W=/^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;function $(n){if(!(t=W.exec(n)))throw new Error("invalid format: "+n);var t;return new L({fill:t[1],align:t[2],sign:t[3],symbol:t[4],zero:t[5],width:t[6],comma:t[7],precision:t[8]&&t[8].slice(1),trim:t[9],type:t[10]})}$.prototype=L.prototype;function L(n){this.fill=n.fill===void 0?" ":n.fill+"",this.align=n.align===void 0?">":n.align+"",this.sign=n.sign===void 0?"-":n.sign+"",this.symbol=n.symbol===void 0?"":n.symbol+"",this.zero=!!n.zero,this.width=n.width===void 0?void 0:+n.width,this.comma=!!n.comma,this.precision=n.precision===void 0?void 0:+n.precision,this.trim=!!n.trim,this.type=n.type===void 0?"":n.type+""}L.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(this.width===void 0?"":Math.max(1,this.width|0))+(this.comma?",":"")+(this.precision===void 0?"":"."+Math.max(0,this.precision|0))+(this.trim?"~":"")+this.type};function _(n){n:for(var t=n.length,e=1,i=-1,o;e<t;++e)switch(n[e]){case".":i=o=e;break;case"0":i===0&&(i=e),o=e;break;default:if(!+n[e])break n;i>0&&(i=0);break}return i>0?n.slice(0,i)+n.slice(o+1):n}var N;function v(n,t){var e=j(n,t);if(!e)return N=void 0,n.toPrecision(t);var i=e[0],o=e[1],a=o-(N=Math.max(-8,Math.min(8,Math.floor(o/3)))*3)+1,c=i.length;return a===c?i:a>c?i+new Array(a-c+1).join("0"):a>0?i.slice(0,a)+"."+i.slice(a):"0."+new Array(1-a).join("0")+j(n,Math.max(0,t+a-1))[0]}function X(n,t){var e=j(n,t);if(!e)return n+"";var i=e[0],o=e[1];return o<0?"0."+new Array(-o).join("0")+i:i.length>o+1?i.slice(0,o+1)+"."+i.slice(o+1):i+new Array(o-i.length+2).join("0")}const O={"%":(n,t)=>(n*100).toFixed(t),b:n=>Math.round(n).toString(2),c:n=>n+"",d:J,e:(n,t)=>n.toExponential(t),f:(n,t)=>n.toFixed(t),g:(n,t)=>n.toPrecision(t),o:n=>Math.round(n).toString(8),p:(n,t)=>X(n*100,t),r:X,s:v,X:n=>Math.round(n).toString(16).toUpperCase(),x:n=>Math.round(n).toString(16)};function R(n){return n}var U=Array.prototype.map,Y=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"];function nn(n){var t=n.grouping===void 0||n.thousands===void 0?R:Q(U.call(n.grouping,Number),n.thousands+""),e=n.currency===void 0?"":n.currency[0]+"",i=n.currency===void 0?"":n.currency[1]+"",o=n.decimal===void 0?".":n.decimal+"",a=n.numerals===void 0?R:V(U.call(n.numerals,String)),c=n.percent===void 0?"%":n.percent+"",h=n.minus===void 0?"−":n.minus+"",M=n.nan===void 0?"NaN":n.nan+"";function T(f,g){f=$(f);var b=f.fill,p=f.align,m=f.sign,w=f.symbol,S=f.zero,E=f.width,F=f.comma,y=f.precision,C=f.trim,d=f.type;d==="n"?(F=!0,d="g"):O[d]||(y===void 0&&(y=12),C=!0,d="g"),(S||b==="0"&&p==="=")&&(S=!0,b="0",p="=");var q=(g&&g.prefix!==void 0?g.prefix:"")+(w==="$"?e:w==="#"&&/[boxX]/.test(d)?"0"+d.toLowerCase():""),B=(w==="$"?i:/[%p]/.test(d)?c:"")+(g&&g.suffix!==void 0?g.suffix:""),D=O[d],H=/[defgprs%]/.test(d);y=y===void 0?6:/[gprs]/.test(d)?Math.max(1,Math.min(21,y)):Math.max(0,Math.min(20,y));function G(r){var l=q,u=B,x,I,k;if(d==="c")u=D(r)+u,r="";else{r=+r;var P=r<0||1/r<0;if(r=isNaN(r)?M:D(Math.abs(r),y),C&&(r=_(r)),P&&+r==0&&m!=="+"&&(P=!1),l=(P?m==="("?m:h:m==="-"||m==="("?"":m)+l,u=(d==="s"&&!isNaN(r)&&N!==void 0?Y[8+N/3]:"")+u+(P&&m==="("?")":""),H){for(x=-1,I=r.length;++x<I;)if(k=r.charCodeAt(x),48>k||k>57){u=(k===46?o+r.slice(x+1):r.slice(x))+u,r=r.slice(0,x);break}}}F&&!S&&(r=t(r,1/0));var z=l.length+r.length+u.length,s=z<E?new Array(E-z+1).join(b):"";switch(F&&S&&(r=t(s+r,s.length?E-u.length:1/0),s=""),p){case"<":r=l+r+u+s;break;case"=":r=l+s+r+u;break;case"^":r=s.slice(0,z=s.length>>1)+l+r+u+s.slice(z);break;default:r=s+l+r+u;break}return a(r)}return G.toString=function(){return f+""},G}function Z(f,g){var b=Math.max(-8,Math.min(8,Math.floor(K(g)/3)))*3,p=Math.pow(10,-b),m=T((f=$(f),f.type="f",f),{suffix:Y[8+b/3]});return function(w){return m(p*w)}}return{format:T,formatPrefix:Z}}var A,tn,rn;en({thousands:",",grouping:[3],currency:["$",""]});function en(n){return A=nn(n),tn=A.format,rn=A.formatPrefix,A}export{rn as a,tn as b,K as e,$ as f};
@@ -0,0 +1,30 @@
1
+ import{I as X}from"./chunk-2Q5K7J3B-Cuikho5Q.js";import{p as z}from"./chunk-JWPE2WC7-B7HxxQds.js";import{n as O,b as G,s as Y,o as P,g as F,a as Z,_ as g,A,l as E,D as q,d as U,y as D,p as j,i as J,ak as K,B as Q,al as ee}from"./MermaidBlock-DR1GikCv.js";import{p as te}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import"./index-GAamh1p4.js";var L=/[─━│┃└┗├┣]/,_=/[└┗├┣]/,re=/[─━]/,T=/^[\s│┃]+$/,V=/^\s*(title[\t ]|accTitle[\t ]*:|accDescr[\t ]*[:{])/,$=/^\s*%%/,ne=" ";function S(r){return r.some(t=>L.test(t))}g(S,"isBoxDrawingFormat");function M(r){for(const t of r){const e=_.exec(t);if(e!=null&&e.index&&e.index>0)return e.index}return 4}g(M,"inferSegmentWidth");function R(r,t){return r.replace(/\bline\s+(\d+)\b/gi,(e,i)=>{const s=parseInt(i,10),o=t.get(s);return o?`line ${o}`:e})}g(R,"remapErrorLines");function H(r){const t=r.split(`
2
+ `),e=new Map;let i=-1;for(const[d,l]of t.entries())if(l.trim()==="treeView-beta"){i=d;break}if(i===-1)return{text:r,lineMap:e};const s=[];for(let d=i+1;d<t.length;d++){const l=t[d];l.trim()===""||$.test(l)||V.test(l)||T.test(l)||s.push(l.replace(/\t/g," "))}if(!S(s))return{text:r,lineMap:e};const o=M(s),n=[];let c=0;for(let d=0;d<=i;d++)n.push(t[d]),c++,e.set(c,d+1);for(let d=i+1;d<t.length;d++){const l=t[d],u=l.trim(),a=d+1;if(u===""){n.push(l),c++,e.set(c,a);continue}if($.test(l)){n.push(l),c++,e.set(c,a);continue}if(V.test(l)){n.push(l),c++,e.set(c,a);continue}if(T.test(l))continue;const p=l.replace(/\t/g," "),h=_.exec(p);if((h==null?void 0:h.index)!==void 0){const m=h.index,w=Math.round(m/o)+1;let f=m+1;for(;f<p.length&&re.test(p[f]);)f++;for(;f<p.length&&p[f]===" ";)f++;const v=p.slice(f).trimEnd();if(!v)throw new Error(`Line ${a}: Empty node — expected a filename or directory name after the box-drawing prefix`);const b=ne.repeat(w);n.push(b+v),c++,e.set(c,a)}else{if(/^[\s─━│┃└┗├┣]+$/.test(p))continue;if(L.test(p))n.push(l),c++,e.set(c,a);else{if(/^\s+/.test(p))throw new Error(`Line ${a}: Unexpected indentation without box-drawing characters. In box-drawing format, use ├── or └── prefixes for indented nodes.`);n.push(l),c++,e.set(c,a)}}}return{text:n.join(`
3
+ `),lineMap:e}}g(H,"preprocessBoxDrawing");var x=new X(()=>({cnt:1,stack:[{id:0,level:-1,name:"/",nodeType:"directory",children:[]}]})),ie=g(()=>{x.reset(),j()},"clear"),oe=g(()=>x.records.stack[0],"getRoot"),se=g(()=>x.records.cnt,"getCount"),ae=Q.treeView,ce=g(()=>A(ae,D().treeView),"getConfig"),le=g((r,t,e,i,s,o)=>{for(;r<=x.records.stack[x.records.stack.length-1].level;)x.records.stack.pop();const n={id:x.records.cnt++,level:r,name:t,nodeType:e,icon:s,cssClass:i,description:o,children:[]};x.records.stack[x.records.stack.length-1].children.push(n),x.records.stack.push(n)},"addNode"),de={clear:ie,addNode:le,getRoot:oe,getCount:se,getConfig:ce,getAccTitle:Z,getAccDescription:F,getDiagramTitle:P,setAccDescription:Y,setAccTitle:G,setDiagramTitle:O},I=de,he=g(r=>{z(r,I);for(const t of r.nodes){const e=typeof t.indent=="number"?t.indent:0;let i=t.name;const s=i.endsWith("/");s&&(i=i.slice(0,-1));const o=s?"directory":"file",n=t.classAnnotation||void 0,c=t.iconAnnotation,d=c!==void 0?c||"none":void 0,l=t.descAnnotation||void 0,u=l?J(l,D()):void 0;I.addNode(e,i,o,n,d,u)}},"populate"),pe={parse:g(async r=>{const{text:t,lineMap:e}=H(r);try{const i=await te("treeView",t);E.debug(i),he(i)}catch(i){throw e.size>0&&i instanceof Error&&(i.message=R(i.message,e)),i}},"parse")},C={prefix:"mermaid-treeview",height:24,width:24,icons:{folder:{body:'<path fill="currentColor" d="M10.59 4.59A2 2 0 0 0 9.17 4H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.17z"/>'},file:{body:'<path fill="currentColor" fill-rule="evenodd" d="M6 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8.83a2 2 0 0 0-.59-1.42l-4.82-4.82A2 2 0 0 0 13.17 2H6Zm7.5 1.9l4.6 4.6h-3.6a1 1 0 0 1-1-1V3.9Z" clip-rule="evenodd"/>'}}};function W(r,t){var s;const e=(s=t==null?void 0:t.filenameIcons)==null?void 0:s[r];if(e)return e;const i=r.lastIndexOf(".");if(i>0){const o=r.substring(i).toLowerCase(),n=t==null?void 0:t.extensionIcons;return(n==null?void 0:n[o])??(n==null?void 0:n[o.slice(1)])}}g(W,"detectIcon");function y(r,t){return r.includes(":")?r:r in C.icons||!t?`${C.prefix}:${r}`:`${t}:${r}`}g(y,"qualifyIcon");function k(r,t){if(r.icon!=="none"){if(r.icon)return y(r.icon,t.defaultIconPack);if(t.showIcons){if(r.nodeType==="file"){const e=W(r.name,t);if(e==="none")return;if(e)return y(e,t.defaultIconPack)}return`${C.prefix}:${r.nodeType==="directory"?"folder":"file"}`}}}g(k,"getNodeIcon");ee([{name:C.prefix,icons:C}]);var B=14,ge=4,fe=16,ue=g(async(r,t)=>{const e=[],i=g(o=>{const n=k(o,t);n&&e.push({icon:n,node:o}),o.children.forEach(i)},"collect");i(r);const s=await Promise.all(e.map(async({icon:o,node:n})=>({id:n.id,svg:await K(o,{height:B,width:B})})));return new Map(s.map(({id:o,svg:n})=>[o,n]))},"resolveNodeIcons"),we=g((r,t,e,i,s,o)=>{var b;const n=i.append("g");let c="treeView-node-label";e.nodeType==="directory"&&(c+=" treeView-node-dir"),e.cssClass&&(c+=` ${e.cssClass}`);const d=B+ge,l=k(e,s),u=l!==void 0;l&&n.append("g").attr("class","treeView-node-icon").attr("transform",`translate(${r+s.paddingX}, ${t+s.paddingY})`).html(o.get(e.id)??"");const a=n.append("text").text(e.name).attr("dominant-baseline","middle").attr("class",c),{height:p,width:h}=a.node().getBBox(),m=p+s.paddingY*2,w=r+s.paddingX+(u?d:0);a.attr("x",w),a.attr("y",t+m/2);const f=w+h,v=h+s.paddingX*2+(u?d:0);return e.BBox={x:r,y:t,width:v,height:m},(b=e.cssClass)!=null&&b.split(/\s+/).includes("highlight")&&n.insert("rect",":first-child").attr("x",r).attr("y",t+1).attr("width",0).attr("height",m-2).attr("rx",3).attr("class","treeView-highlight-bg"),{node:e,nodeGroup:n,labelRightEdge:f,centerY:t+m/2}},"positionLabel"),N=g((r,t,e,i,s,o)=>r.append("line").attr("x1",t).attr("y1",e).attr("x2",i).attr("y2",s).attr("stroke-width",o).attr("class","treeView-node-line"),"positionLine"),me=g((r,t,e,i)=>{var u;let s=0,o=0;const n=[],c=g((a,p,h,m)=>{const w=m*(h.rowIndent+h.paddingX),f=we(w,s,p,a,h,i);n.push(f);const{height:v,width:b}=p.BBox;N(a,w-h.rowIndent,s+v/2,w,s+v/2,h.lineThickness),o=Math.max(o,w+b),s+=v},"drawNode"),d=g((a,p=0)=>{c(r,a,e,p),a.children.forEach(f=>{d(f,p+1)});const{x:h,y:m,height:w}=a.BBox;if(a.children.length){const{y:f,height:v}=a.children[a.children.length-1].BBox;N(r,h+e.paddingX,m+w,h+e.paddingX,f+v/2+e.lineThickness/2,e.lineThickness)}},"processNode");d(t);const l=n.filter(a=>a.node.description);if(l.length>0){const p=Math.max(...n.map(h=>h.labelRightEdge))+fe;for(const h of l){const w=h.nodeGroup.append("text").text(h.node.description).attr("dominant-baseline","middle").attr("class","treeView-node-description").attr("x",p).attr("y",h.centerY).node().getBBox();o=Math.max(o,p+w.width+e.paddingX)}}for(const a of n)if((u=a.node.cssClass)!=null&&u.split(/\s+/).includes("highlight")){const p=a.nodeGroup.select(".treeView-highlight-bg");if(!p.empty()){const h=o-a.node.BBox.x+8;p.attr("width",h),o=Math.max(o,a.node.BBox.x+h+2)}}return{totalHeight:s,totalWidth:o}},"drawTree"),ve=g(async(r,t,e,i)=>{E.debug(`Rendering treeView diagram
4
+ `+r);const s=i.db,o=s.getRoot(),n=s.getConfig(),c=q(t),d=c.append("g");d.attr("class","tree-view");const l=await ue(o,n),{totalHeight:u,totalWidth:a}=me(d,o,n,l);c.attr("viewBox",`-${n.lineThickness/2} 0 ${a} ${u}`),U(c,u,a,n.useMaxWidth)},"draw"),xe={draw:ve},be=xe,Ce={labelFontSize:"16px",labelColor:"black",lineColor:"black",iconColor:"#546e7a",descriptionColor:"#6a9955",highlightBg:"rgba(255, 193, 7, 0.15)",highlightStroke:"#ffc107"},Ie=g(({treeView:r})=>{const{labelFontSize:t,labelColor:e,lineColor:i,iconColor:s,descriptionColor:o,highlightBg:n,highlightStroke:c}=A(Ce,r);return`
5
+ .treeView-node-label {
6
+ font-size: ${t};
7
+ fill: ${e};
8
+ white-space: pre;
9
+ }
10
+ .treeView-node-dir {
11
+ font-weight: bold;
12
+ }
13
+ .treeView-node-line {
14
+ stroke: ${i};
15
+ }
16
+ .treeView-node-icon {
17
+ color: ${s};
18
+ }
19
+ .treeView-node-description {
20
+ font-size: ${t};
21
+ fill: ${o};
22
+ font-style: italic;
23
+ white-space: pre;
24
+ }
25
+ .treeView-highlight-bg {
26
+ fill: ${n};
27
+ stroke: ${c};
28
+ stroke-width: 1;
29
+ }
30
+ `},"styles"),ye=Ie,Ne={db:I,renderer:be,parser:pe,styles:ye};export{Ne as diagram};
@@ -0,0 +1,41 @@
1
+ import{p as I}from"./chunk-JWPE2WC7-B7HxxQds.js";import{s as _,g as E,o as D,n as F,a as P,b as z,_ as c,D as G,p as B,A as w,y as C,B as W,l as b,E as V,d as H}from"./MermaidBlock-DR1GikCv.js";import{p as j}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import"./index-GAamh1p4.js";var x={showLegend:!0,ticks:5,max:null,min:0,graticule:"circle"},y=32,A={axes:[],curves:[],options:x},m=structuredClone(A),U=W.radar,X=c(()=>w({...U,...C().radar}),"getConfig"),M=c(()=>m.axes,"getAxes"),K=c(()=>m.curves,"getCurves"),N=c(()=>m.options,"getOptions"),Y=c(a=>{m.axes=a.map(t=>({name:t.name,label:t.label??t.name}))},"setAxes"),Z=c(a=>{m.curves=a.map(t=>({name:t.name,label:t.label??t.name,entries:q(t.entries)}))},"setCurves"),q=c(a=>{if(a[0].axis==null)return a.map(e=>e.value);const t=M();if(t.length===0)throw new Error("Axes must be populated before curves for reference entries");return t.map(e=>{const r=a.find(s=>{var n;return((n=s.axis)==null?void 0:n.$refText)===e.name});if(r===void 0)throw new Error("Missing entry for axis "+e.label);return r.value})},"computeCurveEntries"),J=c(a=>{var e,r,s,n,l;const t=a.reduce((o,i)=>(o[i.name]=i,o),{});m.options={showLegend:((e=t.showLegend)==null?void 0:e.value)??x.showLegend,ticks:((r=t.ticks)==null?void 0:r.value)??x.ticks,max:((s=t.max)==null?void 0:s.value)??x.max,min:((n=t.min)==null?void 0:n.value)??x.min,graticule:((l=t.graticule)==null?void 0:l.value)??x.graticule},m.options.ticks>y&&(b.warn(`Radar diagram ticks (${m.options.ticks}) exceeds maximum allowed (${y}). Using ${y} instead.`),m.options.ticks=y)},"setOptions"),Q=c(()=>{B(),m=structuredClone(A)},"clear"),$={getAxes:M,getCurves:K,getOptions:N,setAxes:Y,setCurves:Z,setOptions:J,getConfig:X,clear:Q,setAccTitle:z,getAccTitle:P,setDiagramTitle:F,getDiagramTitle:D,getAccDescription:E,setAccDescription:_},tt=c(a=>{I(a,$);const{axes:t,curves:e,options:r}=a;$.setAxes(t),$.setCurves(e),$.setOptions(r)},"populate"),et={parse:c(async a=>{const t=await j("radar",a);b.debug(t),tt(t)},"parse")},at=c((a,t,e,r)=>{const s=r.db,n=s.getAxes(),l=s.getCurves(),o=s.getOptions(),i=s.getConfig(),d=s.getDiagramTitle(),p=G(t),u=rt(p,i),g=o.max??Math.max(...l.map(f=>Math.max(...f.entries))),h=o.min,v=Math.min(i.width,i.height)/2;st(u,n,v,o.ticks,o.graticule),nt(u,n,v,i),L(u,n,l,h,g,o.graticule,i),k(u,l,o.showLegend,i),u.append("text").attr("class","radarTitle").text(d).attr("x",0).attr("y",-i.height/2-i.marginTop)},"draw"),rt=c((a,t)=>{const e=t.width+t.marginLeft+t.marginRight,r=t.height+t.marginTop+t.marginBottom,s={x:t.marginLeft+t.width/2,y:t.marginTop+t.height/2};return H(a,r,e,t.useMaxWidth??!0),a.attr("viewBox",`0 0 ${e} ${r}`).attr("overflow","visible"),a.append("g").attr("transform",`translate(${s.x}, ${s.y})`)},"drawFrame"),st=c((a,t,e,r,s)=>{if(s==="circle")for(let n=0;n<r;n++){const l=e*(n+1)/r;a.append("circle").attr("r",l).attr("class","radarGraticule")}else if(s==="polygon"){const n=t.length;for(let l=0;l<r;l++){const o=e*(l+1)/r,i=t.map((d,p)=>{const u=2*p*Math.PI/n-Math.PI/2,g=o*Math.cos(u),h=o*Math.sin(u);return`${g},${h}`}).join(" ");a.append("polygon").attr("points",i).attr("class","radarGraticule")}}},"drawGraticule"),nt=c((a,t,e,r)=>{const s=t.length;for(let n=0;n<s;n++){const l=t[n].label,o=2*n*Math.PI/s-Math.PI/2,i=Math.cos(o),d=Math.sin(o);a.append("line").attr("x1",0).attr("y1",0).attr("x2",e*r.axisScaleFactor*i).attr("y2",e*r.axisScaleFactor*d).attr("class","radarAxisLine");const p=i>.01?"start":i<-.01?"end":"middle",u=d>.01?"hanging":d<-.01?"auto":"central",g=4;a.append("text").text(l).attr("x",e*r.axisLabelFactor*i+g*i).attr("y",e*r.axisLabelFactor*d+g*d).attr("text-anchor",p).attr("dominant-baseline",u).attr("class","radarAxisLabel")}},"drawAxes");function L(a,t,e,r,s,n,l){const o=t.length,i=Math.min(l.width,l.height)/2;e.forEach((d,p)=>{if(d.entries.length!==o)return;const u=d.entries.map((g,h)=>{const v=2*Math.PI*h/o-Math.PI/2,f=T(g,r,s,i),O=f*Math.cos(v),R=f*Math.sin(v);return{x:O,y:R}});n==="circle"?a.append("path").attr("d",S(u,l.curveTension)).attr("class",`radarCurve-${p}`):n==="polygon"&&a.append("polygon").attr("points",u.map(g=>`${g.x},${g.y}`).join(" ")).attr("class",`radarCurve-${p}`)})}c(L,"drawCurves");function T(a,t,e,r){const s=Math.min(Math.max(a,t),e);return r*(s-t)/(e-t)}c(T,"relativeRadius");function S(a,t){const e=a.length;let r=`M${a[0].x},${a[0].y}`;for(let s=0;s<e;s++){const n=a[(s-1+e)%e],l=a[s],o=a[(s+1)%e],i=a[(s+2)%e],d={x:l.x+(o.x-n.x)*t,y:l.y+(o.y-n.y)*t},p={x:o.x-(i.x-l.x)*t,y:o.y-(i.y-l.y)*t};r+=` C${d.x},${d.y} ${p.x},${p.y} ${o.x},${o.y}`}return`${r} Z`}c(S,"closedRoundCurve");function k(a,t,e,r){if(!e)return;const s=(r.width/2+r.marginRight)*3/4,n=-(r.height/2+r.marginTop)*3/4,l=20;t.forEach((o,i)=>{const d=a.append("g").attr("transform",`translate(${s}, ${n+i*l})`);d.append("rect").attr("width",12).attr("height",12).attr("class",`radarLegendBox-${i}`),d.append("text").attr("x",16).attr("y",0).attr("class","radarLegendText").text(o.label)})}c(k,"drawLegend");var ot={draw:at},it=c((a,t)=>{let e="";for(let r=0;r<a.THEME_COLOR_LIMIT;r++){const s=a[`cScale${r}`];e+=`
2
+ .radarCurve-${r} {
3
+ color: ${s};
4
+ fill: ${s};
5
+ fill-opacity: ${t.curveOpacity};
6
+ stroke: ${s};
7
+ stroke-width: ${t.curveStrokeWidth};
8
+ }
9
+ .radarLegendBox-${r} {
10
+ fill: ${s};
11
+ fill-opacity: ${t.curveOpacity};
12
+ stroke: ${s};
13
+ }
14
+ `}return e},"genIndexStyles"),lt=c(a=>{const t=V(),e=C(),r=w(t,e.themeVariables),s=w(r.radar,a);return{themeVariables:r,radarOptions:s}},"buildRadarStyleOptions"),ct=c(({radar:a}={})=>{const{themeVariables:t,radarOptions:e}=lt(a);return`
15
+ .radarTitle {
16
+ font-size: ${t.fontSize};
17
+ color: ${t.titleColor};
18
+ dominant-baseline: hanging;
19
+ text-anchor: middle;
20
+ }
21
+ .radarAxisLine {
22
+ stroke: ${e.axisColor};
23
+ stroke-width: ${e.axisStrokeWidth};
24
+ }
25
+ .radarAxisLabel {
26
+ font-size: ${e.axisLabelFontSize}px;
27
+ color: ${e.axisColor};
28
+ }
29
+ .radarGraticule {
30
+ fill: ${e.graticuleColor};
31
+ fill-opacity: ${e.graticuleOpacity};
32
+ stroke: ${e.graticuleColor};
33
+ stroke-width: ${e.graticuleStrokeWidth};
34
+ }
35
+ .radarLegendText {
36
+ text-anchor: start;
37
+ font-size: ${e.legendFontSize}px;
38
+ dominant-baseline: hanging;
39
+ }
40
+ ${it(t,e)}
41
+ `},"styles"),mt={parser:et,db:$,renderer:ot,styles:ct};export{mt as diagram};
@@ -0,0 +1,3 @@
1
+ import{p as oe}from"./chunk-JWPE2WC7-B7HxxQds.js";import{o as se,n as de,s as le,g as ce,a as me,b as ue,_ as o,l as g,c as T,j as xe,z as fe,p as ge,A as he,y as E,B as pe,i as P,w as S,am as be}from"./MermaidBlock-DR1GikCv.js";import{p as ve,i as we}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import"./index-GAamh1p4.js";var D="position frame",N="frame positioned",M="position relation",C="relation positioned",ye=o(function(e){g.debug("options str",e)},"setOptions"),Pe=o(function(){return{}},"getOptions"),Se=o(function(){O(),ge()},"clear");function O(){A={}}o(O,"reset");var ke=pe.eventmodeling,Me=o(()=>he({...ke,...E().eventmodeling}),"getConfig"),A={};function W(){let e=Be;const{ast:n}=A,t=R();if(!n)throw new Error("No data for EventModel");return n.frames.forEach((i,a)=>{const r=X(i,n.dataEntities,t);e=w(e,{$kind:D,index:a,frame:i,textProps:r});let d;q(i)?(g.debug("source frame",i.sourceFrames),d=n.frames.filter(l=>i.sourceFrames.some(c=>c.$refText===l.name)),d.forEach(l=>{e=w(e,{$kind:M,index:a,frame:i,sourceFrame:l})})):e=w(e,{$kind:M,index:a,frame:i})}),e={...e,sortedSwimlanesArray:$(e.swimlanes)},e}o(W,"getState");function I(e){A.ast=e}o(I,"setAst");var s={swimlaneMinHeight:70,swimlanePadding:15,swimlaneGap:10,boxPadding:10,boxOverlap:90,boxDefaultY:0,boxMinWidth:80,boxMaxWidth:450,boxMinHeight:80,boxMaxHeight:750,contentStartX:250,textMaxWidth:430,boxTextFontWeight:"bold",boxTextPadding:10,swimlaneTextFontWeight:"bold",labelUiAutomation:"UI/Automation",labelUiAutomationPrefix:"UI/A: ",labelCommandReadModel:"Command/Read Model",labelCommandReadModelPrefix:"C/RM: ",labelEvents:"Events",labelEventsPrefix:"Stream: "};function R(){return s}o(R,"getDiagramProps");var Be={boxes:[],swimlanes:{},relations:[],maxR:0,sortedSwimlanesArray:[]};function H(e){const n=e.split(".");if(n.length===2)return n[0]}o(H,"extractNamespace");function U(e){const n=e.split(".");return n.length===2?n[1]:e}o(U,"extractName");function _(e,n){if(!(!n||n.length===0))return Object.values(e).find(t=>t.namespace===n)}o(_,"findSwimlaneByNamespace");function v(e,n,t){return Math.max(n,...Object.keys(e).filter(i=>{const a=Number.parseInt(i);return a>n&&a<t}).map(i=>Number.parseInt(i)))+1}o(v,"findNextAvailableIndex");function V(e,n){const t=H(e.entityIdentifier),i=_(n,t);switch(e.modelEntityType){case"ui":case"pcr":case"processor":return i?{index:i.index,label:i.namespace||s.labelUiAutomation}:t?{index:v(n,0,100),label:s.labelUiAutomationPrefix+t}:{index:0,label:s.labelUiAutomation};case"rmo":case"readmodel":case"cmd":case"command":return i?{index:i.index,label:i.namespace||s.labelCommandReadModel}:t?{index:v(n,100,200),label:s.labelCommandReadModelPrefix+t}:{index:100,label:s.labelCommandReadModel};case"evt":case"event":default:return i?{index:i.index,label:i.namespace||s.labelEvents}:t?{index:v(n,200,300),label:s.labelEventsPrefix+t}:{index:200,label:s.labelEvents}}}o(V,"calculateSwimlaneProps");function L(e){const{themeVariables:n}=E();switch(e.modelEntityType){case"ui":return{fill:n.emUiFill??"white",stroke:n.emUiStroke??"#dbdada"};case"pcr":case"processor":return{fill:n.emProcessorFill??"#edb3f6",stroke:n.emProcessorStroke??"#b88cbf"};case"rmo":case"readmodel":return{fill:n.emReadModelFill??"#d3f1a2",stroke:n.emReadModelStroke??"#a3b732"};case"cmd":case"command":return{fill:n.emCommandFill??"#bcd6fe",stroke:n.emCommandStroke??"#679ac3"};case"evt":case"event":return{fill:n.emEventFill??"#ffb778",stroke:n.emEventStroke??"#c19a0f"};default:return{fill:"red",stroke:"black"}}}o(L,"calculateEntityVisualProps");function X(e,n,t){const i=E(),a=P(U(e.entityIdentifier)??"",i);let r;const d={fontSize:16,fontWeight:700,fontFamily:'"trebuchet ms", verdana, arial, sans-serif',joinWith:"<br/>"};let c=`<b>${S(a,t.textMaxWidth,d)}</b>`;if(e.dataInlineValue&&(r=e.dataInlineValue,r=r.substring(r.indexOf("{")+1),r=r.substring(0,r.lastIndexOf("}")-1),r=P(r,i),r=S(r,t.textMaxWidth,d),r=r.replaceAll(" ","&nbsp;")),e.dataReference){const p=n.find(y=>{var b;return y.name===((b=e.dataReference)==null?void 0:b.$refText)});p&&(r=p.dataBlockValue,r=r.substring(r.indexOf(`{
2
+ `)+2),r=r.substring(0,r.lastIndexOf("}")-1),r=P(r,i),r=S(r,t.textMaxWidth,d),r=r.replaceAll(" ","&nbsp;"),r+="<br/>")}const m=r!==void 0;m&&(c+=`<br/><br/><code style="text-align: left; display: block;max-width:${t.textMaxWidth}px">${r}</code>`);const x={fontSize:d.fontSize,fontWeight:d.fontWeight,fontFamily:d.fontFamily},u=be(c,x),h=m?u.width/3:u.width,f={content:c,width:h,height:u.height};return g.debug(`[${e.name}] ${e.entityIdentifier} text`,f),f}o(X,"calculateTextProps");function j(e,n){const t=n,i=L(t.frame),a={width:t.textProps.width+2*s.boxTextPadding,height:t.textProps.height+2*s.boxTextPadding};return[{$kind:N,frame:t.frame,index:t.index,visual:i,dimension:a,textProps:t.textProps}]}o(j,"decidePositionFrame");function G(e,n,t){return n===void 0?s.contentStartX:n.index===e.index&&e.r?e.r+s.boxPadding:t===void 0?s.contentStartX:t.r-s.boxOverlap+s.boxPadding}o(G,"calculateX");function Y(e,n){const t=[...e.map(i=>i.r),n];return Math.max(...t)}o(Y,"calculateMaxRight");function $(e){return Object.values(e).sort((n,t)=>n.index-t.index)}o($,"sortedSwimlanesArray");function z(e,n){const t=n,i=V(t.frame,e.swimlanes);let a;i.index in e.swimlanes?a=e.swimlanes[i.index]:a={index:i.index,label:i.label,r:0,y:i.index*s.swimlaneMinHeight+s.swimlaneGap,height:s.swimlaneMinHeight,maxHeight:s.swimlaneMinHeight};const r=e.boxes.length>0?e.boxes[e.boxes.length-1]:void 0,d=e.previousSwimlaneNumber!==void 0?e.swimlanes[e.previousSwimlaneNumber]:void 0,l={width:Math.max(s.boxMinWidth,Math.min(s.boxMaxWidth,t.dimension.width))+2*s.boxPadding,height:Math.max(s.boxMinHeight,Math.min(s.boxMaxHeight,t.dimension.height))+2*s.boxPadding},c=G(a,d,r),m=c+l.width+s.boxPadding,x=Y(Object.values(e.swimlanes),m);a.r=c+l.width,a.maxHeight=Math.max(a.maxHeight,l.height),a.height=Math.max(s.swimlaneMinHeight,a.maxHeight)+2*s.swimlanePadding;const u={x:c,y:s.swimlanePadding+a.y,r:m,dimension:l,leftSibling:!1,swimlane:a,visual:t.visual,text:t.textProps.content,frame:t.frame,index:t.index},h={...e,boxes:[...e.boxes,u],swimlanes:{...e.swimlanes,[`${a.index}`]:a},previousSwimlaneNumber:i.index,previousFrame:t.frame,maxR:x},f=$(h.swimlanes);f.length>0&&(f[0].y=0);for(let p=1;p<f.length;p++){const y=f[p],b=f[p-1];y.y=b.y+b.height+s.swimlaneGap}return h}o(z,"evolveFramePositioned");function K(e,n){return e===0&&n.sourceFrames.length===0}o(K,"isFirstFrame");function q(e){return e.sourceFrames!==void 0&&e.sourceFrames!==null&&e.sourceFrames.length>0}o(q,"hasSourceFrame");function B(e,n){if(n!=null)return e.find(t=>t.frame.name===n.name)}o(B,"findBoxByFrame");function J(e,n,t){if(!(t<0))for(let i=t;i>=0;i--){const a=e[i];if(a.swimlane.index!==n)return a}}o(J,"findBoxByLineIndex");function Q(e,n){const t=n;if(we(t.frame)||K(t.index,t.frame))return[];const i=B(e.boxes,t.frame);if(i===void 0)throw new Error(`Target box not found for frame ${t.frame.name}`);let a;return t.sourceFrame?a=B(e.boxes,t.sourceFrame):a=J(e.boxes,i.swimlane.index,t.index-1),a===void 0?[]:[{$kind:C,frame:t.frame,index:t.index,sourceBox:a,targetBox:i}]}o(Q,"decidePositionRelation");function Z(e,n){const t=n,i={visual:{fill:"none",stroke:"#000"},source:{x:t.sourceBox.x,y:t.sourceBox.y},target:{x:t.targetBox.x,y:t.targetBox.y},sourceBox:t.sourceBox,targetBox:t.targetBox};return{...e,relations:[...e.relations,i]}}o(Z,"evolveRelationPositioned");var Fe={[D]:j,[M]:Q},Ee={[N]:z,[C]:Z};function ee(e,n){const t=Fe[n.$kind];if(t==null)return[];const i=t(e,n);return g.debug("decided events",i),i}o(ee,"decide");function te(e,n){const t=n.reduce((i,a)=>{const r=Ee[a.$kind];return r==null?i:r(i,a)},e);return g.debug("evolve events",{state:e,newState:t,events:n}),t}o(te,"evolve");function w(e,n){const t=ee(e,n);return te(e,t)}o(w,"dispatch");var F={getConfig:Me,setOptions:ye,getOptions:Pe,clear:Se,setAccTitle:ue,getAccTitle:me,getAccDescription:ce,setAccDescription:le,setDiagramTitle:de,getDiagramTitle:se,setAst:I,getDiagramProps:R,getState:W},Ae={parse:o(async e=>{const n=await ve("eventmodeling",e);g.debug(n),F.setAst(n),oe(n,F)},"parse")},k=T(),Re=k==null?void 0:k.eventmodeling;function ne(e,n){return t=>{const i=t.swimlane.y+n.swimlanePadding,a=e.append("g").attr("class","em-box");a.append("rect").attr("x",t.x).attr("y",i).attr("rx","3").attr("width",t.dimension.width).attr("height",t.dimension.height).attr("stroke",t.visual.stroke).attr("fill",t.visual.fill),a.append("foreignObject").attr("x",t.x+n.boxPadding).attr("y",i+10).attr("width",t.dimension.width-2*n.boxPadding).attr("height",t.dimension.height-2*n.boxPadding).append("xhtml:div").style("display","table").style("height","100%").style("width","100%").append("span").style("display","table-cell").style("text-align","center").style("vertical-align","middle").html(t.text)}}o(ne,"renderD3Box");function ie(e,n){return e>n}o(ie,"dirUpwards");function ae(e,n,t,i){return a=>{const r=a.sourceBox.swimlane.y+n.swimlanePadding,d=a.targetBox.swimlane.y+n.swimlanePadding,l=ie(r,d),c=a.sourceBox.x+a.sourceBox.dimension.width*2/3,m=a.targetBox.x+a.targetBox.dimension.width/3;let x,u;g.debug(`rendering relation up=${l} for `,{sourceBox:a.sourceBox,targetBox:a.targetBox}),l?(x=r,u=d+a.targetBox.dimension.height):(x=r+a.sourceBox.dimension.height,u=d);const h=i.emRelationStroke??a.visual.stroke;e.append("path").attr("class","em-relation").attr("fill",a.visual.fill).attr("stroke",h).attr("stroke-width","1").attr("marker-end",`url(#${t})`).attr("d",`M${c} ${x} L${m} ${u}`)}}o(ae,"renderD3Relation");function re(e,n,t,i){return a=>{const r=e.append("g").attr("class","em-swimlane"),d=i.emSwimlaneBackgroundOdd??"rgb(250,250,250)",l=i.emSwimlaneBackgroundStroke??"rgb(240,240,240)";r.append("rect").attr("x",0).attr("y",a.y).attr("rx","3").attr("width",n+t.swimlanePadding).attr("height",a.height).attr("fill",d).attr("stroke",l),r.append("text").attr("font-weight",t.swimlaneTextFontWeight).attr("x",30).attr("y",a.y+30).text(a.label)}}o(re,"renderD3Swimlane");var $e=o(function(e,n,t,i){if(g.debug("in eventmodeling renderer",e+`
3
+ `,"id:",n,t),!Re)throw new Error("EventModeling config not found");const a=i.db,{themeVariables:r,eventmodeling:d}=T(),l=xe(`[id="${n}"]`),c=a.getDiagramProps(),m=a.getState(),x=`em-arrowhead-${n}`,u=r.emArrowhead??"#000000";m.sortedSwimlanesArray.forEach(re(l,m.maxR,c,r)),m.boxes.forEach(ne(l,c)),m.relations.forEach(ae(l,c,x,r)),l.append("defs").append("marker").attr("id",x).attr("markerWidth","10").attr("markerHeight","7").attr("refX","10").attr("refY","3.5").attr("orient","auto").append("polygon").attr("points","0 0, 10 3.5, 0 7").attr("fill",u),fe(void 0,l,(d==null?void 0:d.padding)??30,d==null?void 0:d.useMaxWidth)},"draw"),Te={draw:$e},De=o(e=>"","getStyles"),Ne=De,He={parser:Ae,db:F,renderer:Te,styles:Ne};export{He as diagram};
@@ -0,0 +1,24 @@
1
+ import{p as ge}from"./chunk-JWPE2WC7-B7HxxQds.js";import{_ as w,E as ye,y as ae,A as ee,D as Se,d as ve,l as te,bd as B,j as U,b as xe,a as be,n as we,o as Ce,g as Te,s as Le,B as $e,be as Ae,p as Fe}from"./MermaidBlock-DR1GikCv.js";import{s as Ne}from"./chunk-POPQ4Y6H-dxddZlXt.js";import{p as Me}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import{b as O}from"./defaultLocale-DX6XiGOO.js";import{o as Q}from"./ordinal-Cboi1Yqb.js";import"./index-GAamh1p4.js";import"./init-Gi6I4Gst.js";function _e(t){var a=0,l=t.children,n=l&&l.length;if(!n)a=1;else for(;--n>=0;)a+=l[n].value;t.value=a}function ke(){return this.eachAfter(_e)}function ze(t,a){let l=-1;for(const n of this)t.call(a,n,++l,this);return this}function Ve(t,a){for(var l=this,n=[l],r,s,h=-1;l=n.pop();)if(t.call(a,l,++h,this),r=l.children)for(s=r.length-1;s>=0;--s)n.push(r[s]);return this}function De(t,a){for(var l=this,n=[l],r=[],s,h,d,g=-1;l=n.pop();)if(r.push(l),s=l.children)for(h=0,d=s.length;h<d;++h)n.push(s[h]);for(;l=r.pop();)t.call(a,l,++g,this);return this}function Pe(t,a){let l=-1;for(const n of this)if(t.call(a,n,++l,this))return n}function Be(t){return this.eachAfter(function(a){for(var l=+t(a.data)||0,n=a.children,r=n&&n.length;--r>=0;)l+=n[r].value;a.value=l})}function Ee(t){return this.eachBefore(function(a){a.children&&a.children.sort(t)})}function Re(t){for(var a=this,l=We(a,t),n=[a];a!==l;)a=a.parent,n.push(a);for(var r=n.length;t!==l;)n.splice(r,0,t),t=t.parent;return n}function We(t,a){if(t===a)return t;var l=t.ancestors(),n=a.ancestors(),r=null;for(t=l.pop(),a=n.pop();t===a;)r=t,t=l.pop(),a=n.pop();return r}function He(){for(var t=this,a=[t];t=t.parent;)a.push(t);return a}function Ie(){return Array.from(this)}function Oe(){var t=[];return this.eachBefore(function(a){a.children||t.push(a)}),t}function Ge(){var t=this,a=[];return t.each(function(l){l!==t&&a.push({source:l.parent,target:l})}),a}function*qe(){var t=this,a,l=[t],n,r,s;do for(a=l.reverse(),l=[];t=a.pop();)if(yield t,n=t.children)for(r=0,s=n.length;r<s;++r)l.push(n[r]);while(l.length)}function ne(t,a){t instanceof Map?(t=[void 0,t],a===void 0&&(a=Ye)):a===void 0&&(a=je);for(var l=new Z(t),n,r=[l],s,h,d,g;n=r.pop();)if((h=a(n.data))&&(g=(h=Array.from(h)).length))for(n.children=h,d=g-1;d>=0;--d)r.push(s=h[d]=new Z(h[d])),s.parent=n,s.depth=n.depth+1;return l.eachBefore(Ze)}function Xe(){return ne(this).eachBefore(Ue)}function je(t){return t.children}function Ye(t){return Array.isArray(t)?t[1]:null}function Ue(t){t.data.value!==void 0&&(t.value=t.data.value),t.data=t.data.data}function Ze(t){var a=0;do t.height=a;while((t=t.parent)&&t.height<++a)}function Z(t){this.data=t,this.depth=this.height=0,this.parent=null}Z.prototype=ne.prototype={constructor:Z,count:ke,each:ze,eachAfter:De,eachBefore:Ve,find:Pe,sum:Be,sort:Ee,path:Re,ancestors:He,descendants:Ie,leaves:Oe,links:Ge,copy:Xe,[Symbol.iterator]:qe};function Je(t){if(typeof t!="function")throw new Error;return t}function G(){return 0}function q(t){return function(){return t}}function Ke(t){t.x0=Math.round(t.x0),t.y0=Math.round(t.y0),t.x1=Math.round(t.x1),t.y1=Math.round(t.y1)}function Qe(t,a,l,n,r){for(var s=t.children,h,d=-1,g=s.length,c=t.value&&(n-a)/t.value;++d<g;)h=s[d],h.y0=l,h.y1=r,h.x0=a,h.x1=a+=h.value*c}function et(t,a,l,n,r){for(var s=t.children,h,d=-1,g=s.length,c=t.value&&(r-l)/t.value;++d<g;)h=s[d],h.x0=a,h.x1=n,h.y0=l,h.y1=l+=h.value*c}var tt=(1+Math.sqrt(5))/2;function at(t,a,l,n,r,s){for(var h=[],d=a.children,g,c,p=0,b=0,i=d.length,x,S,v=a.value,u,y,N,$,V,W,M;p<i;){x=r-l,S=s-n;do u=d[b++].value;while(!u&&b<i);for(y=N=u,W=Math.max(S/x,x/S)/(v*t),M=u*u*W,V=Math.max(N/M,M/y);b<i;++b){if(u+=c=d[b].value,c<y&&(y=c),c>N&&(N=c),M=u*u*W,$=Math.max(N/M,M/y),$>V){u-=c;break}V=$}h.push(g={value:u,dice:x<S,children:d.slice(p,b)}),g.dice?Qe(g,l,n,r,v?n+=S*u/v:s):et(g,l,n,v?l+=x*u/v:r,s),v-=u,p=b}return h}const nt=(function t(a){function l(n,r,s,h,d){at(a,n,r,s,h,d)}return l.ratio=function(n){return t((n=+n)>1?n:1)},l})(tt);function lt(){var t=nt,a=!1,l=1,n=1,r=[0],s=G,h=G,d=G,g=G,c=G;function p(i){return i.x0=i.y0=0,i.x1=l,i.y1=n,i.eachBefore(b),r=[0],a&&i.eachBefore(Ke),i}function b(i){var x=r[i.depth],S=i.x0+x,v=i.y0+x,u=i.x1-x,y=i.y1-x;u<S&&(S=u=(S+u)/2),y<v&&(v=y=(v+y)/2),i.x0=S,i.y0=v,i.x1=u,i.y1=y,i.children&&(x=r[i.depth+1]=s(i)/2,S+=c(i)-x,v+=h(i)-x,u-=d(i)-x,y-=g(i)-x,u<S&&(S=u=(S+u)/2),y<v&&(v=y=(v+y)/2),t(i,S,v,u,y))}return p.round=function(i){return arguments.length?(a=!!i,p):a},p.size=function(i){return arguments.length?(l=+i[0],n=+i[1],p):[l,n]},p.tile=function(i){return arguments.length?(t=Je(i),p):t},p.padding=function(i){return arguments.length?p.paddingInner(i).paddingOuter(i):p.paddingInner()},p.paddingInner=function(i){return arguments.length?(s=typeof i=="function"?i:q(+i),p):s},p.paddingOuter=function(i){return arguments.length?p.paddingTop(i).paddingRight(i).paddingBottom(i).paddingLeft(i):p.paddingTop()},p.paddingTop=function(i){return arguments.length?(h=typeof i=="function"?i:q(+i),p):h},p.paddingRight=function(i){return arguments.length?(d=typeof i=="function"?i:q(+i),p):d},p.paddingBottom=function(i){return arguments.length?(g=typeof i=="function"?i:q(+i),p):g},p.paddingLeft=function(i){return arguments.length?(c=typeof i=="function"?i:q(+i),p):c},p}var R,oe=(R=class{constructor(){this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.setAccTitle=xe,this.getAccTitle=be,this.setDiagramTitle=we,this.getDiagramTitle=Ce,this.getAccDescription=Te,this.setAccDescription=Le}getNodes(){return this.nodes}getConfig(){const a=$e,l=ae();return ee({...a.treemap,...l.treemap??{}})}addNode(a,l){this.nodes.push(a),this.levels.set(a,l),l===0&&(this.outerNodes.push(a),this.root??(this.root=a))}getRoot(){return{name:"",children:this.outerNodes}}addClass(a,l){const n=this.classes.get(a)??{id:a,styles:[],textStyles:[]},r=l.replace(/\\,/g,"§§§").replace(/,/g,";").replace(/§§§/g,",").split(";");r&&r.forEach(s=>{Ae(s)&&(n!=null&&n.textStyles?n.textStyles.push(s):n.textStyles=[s]),n!=null&&n.styles?n.styles.push(s):n.styles=[s]}),this.classes.set(a,n)}getClasses(){return this.classes}getStylesForClass(a){var l;return((l=this.classes.get(a))==null?void 0:l.styles)??[]}clear(){Fe(),this.nodes=[],this.levels=new Map,this.outerNodes=[],this.classes=new Map,this.root=void 0}},w(R,"TreeMapDB"),R);function ce(t){if(!t.length)return[];const a=[],l=[];return t.forEach(n=>{const r={name:n.name,children:n.type==="Leaf"?void 0:[]};for(r.classSelector=n==null?void 0:n.classSelector,n!=null&&n.cssCompiledStyles&&(r.cssCompiledStyles=n.cssCompiledStyles),n.type==="Leaf"&&n.value!==void 0&&(r.value=n.value);l.length>0&&l[l.length-1].level>=n.level;)l.pop();if(l.length===0)a.push(r);else{const s=l[l.length-1].node;s.children?s.children.push(r):s.children=[r]}n.type!=="Leaf"&&l.push({node:r,level:n.level})}),a}w(ce,"buildHierarchy");var rt=w((t,a)=>{ge(t,a);const l=[];for(const s of t.TreemapRows??[])s.$type==="ClassDefStatement"&&a.addClass(s.className??"",s.styleText??"");for(const s of t.TreemapRows??[]){const h=s.item;if(!h)continue;const d=s.indent?parseInt(s.indent):0,g=st(h),c=h.classSelector?a.getStylesForClass(h.classSelector):[],p=c.length>0?c:void 0,b={level:d,name:g,type:h.$type,value:h.value,classSelector:h.classSelector,cssCompiledStyles:p};l.push(b)}const n=ce(l),r=w((s,h)=>{for(const d of s)a.addNode(d,h),d.children&&d.children.length>0&&r(d.children,h+1)},"addNodesRecursively");r(n,0)},"populate"),st=w(t=>t.name?String(t.name):"","getItemName"),he={parser:{yy:void 0},parse:w(async t=>{var a;try{const n=await Me("treemap",t);te.debug("Treemap AST:",n);const r=(a=he.parser)==null?void 0:a.yy;if(!(r instanceof oe))throw new Error("parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");rt(n,r)}catch(l){throw te.error("Error parsing treemap:",l),l}},"parse")},it=10,E=10,X=25,ot=w((t,a,l,n)=>{const r=n.db,s=r.getConfig(),h=s.padding??it,d=r.getDiagramTitle(),g=r.getRoot(),{themeVariables:c}=ae();if(!g)return;const p=d?30:0,b=Se(a),i=s.nodeWidth?s.nodeWidth*E:960,x=s.nodeHeight?s.nodeHeight*E:500,S=i,v=x+p;b.attr("viewBox",`0 0 ${S} ${v}`),ve(b,v,S,s.useMaxWidth);let u;try{const e=s.valueFormat||",";if(e==="$0,0")u=w(o=>"$"+O(",")(o),"valueFormat");else if(e.startsWith("$")&&e.includes(",")){const o=/\.\d+/.exec(e),f=o?o[0]:"";u=w(C=>"$"+O(","+f)(C),"valueFormat")}else if(e.startsWith("$")){const o=e.substring(1);u=w(f=>"$"+O(o||"")(f),"valueFormat")}else u=O(e)}catch(e){te.error("Error creating format function:",e),u=O(",")}const y=Q().range(["transparent",c.cScale0,c.cScale1,c.cScale2,c.cScale3,c.cScale4,c.cScale5,c.cScale6,c.cScale7,c.cScale8,c.cScale9,c.cScale10,c.cScale11]),N=Q().range(["transparent",c.cScalePeer0,c.cScalePeer1,c.cScalePeer2,c.cScalePeer3,c.cScalePeer4,c.cScalePeer5,c.cScalePeer6,c.cScalePeer7,c.cScalePeer8,c.cScalePeer9,c.cScalePeer10,c.cScalePeer11]),$=Q().range([c.cScaleLabel0,c.cScaleLabel1,c.cScaleLabel2,c.cScaleLabel3,c.cScaleLabel4,c.cScaleLabel5,c.cScaleLabel6,c.cScaleLabel7,c.cScaleLabel8,c.cScaleLabel9,c.cScaleLabel10,c.cScaleLabel11]);d&&b.append("text").attr("x",S/2).attr("y",p/2).attr("class","treemapTitle").attr("text-anchor","middle").attr("dominant-baseline","middle").text(d);const V=b.append("g").attr("transform",`translate(0, ${p})`).attr("class","treemapContainer"),W=ne(g).sum(e=>e.value??0).sort((e,o)=>(o.value??0)-(e.value??0)),le=lt().size([i,x]).paddingTop(e=>e.children&&e.children.length>0?X+E:0).paddingInner(h).paddingLeft(e=>e.children&&e.children.length>0?E:0).paddingRight(e=>e.children&&e.children.length>0?E:0).paddingBottom(e=>e.children&&e.children.length>0?E:0).round(!0)(W),de=le.descendants().filter(e=>e.children&&e.children.length>0),H=V.selectAll(".treemapSection").data(de).enter().append("g").attr("class","treemapSection").attr("transform",e=>`translate(${e.x0},${e.y0})`);H.append("rect").attr("width",e=>e.x1-e.x0).attr("height",X).attr("class","treemapSectionHeader").attr("fill","none").attr("fill-opacity",.6).attr("stroke-width",.6).attr("style",e=>e.depth===0?"display: none;":""),H.append("clipPath").attr("id",(e,o)=>`clip-section-${a}-${o}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-12)).attr("height",X),H.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class",(e,o)=>`treemapSection section${o}`).attr("fill",e=>y(e.data.name)).attr("fill-opacity",.6).attr("stroke",e=>N(e.data.name)).attr("stroke-width",2).attr("stroke-opacity",.4).attr("style",e=>{if(e.depth===0)return"display: none;";const o=B({cssCompiledStyles:e.data.cssCompiledStyles});return o.nodeStyles+";"+o.borderStyles.join(";")}),H.append("text").attr("class","treemapSectionLabel").attr("x",6).attr("y",X/2).attr("dominant-baseline","middle").text(e=>e.depth===0?"":e.data.name).attr("font-weight","bold").attr("clip-path",(e,o)=>`url(#clip-section-${a}-${o})`).attr("style",e=>{if(e.depth===0)return"display: none;";const o="dominant-baseline: middle; font-size: 12px; fill:"+$(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=B({cssCompiledStyles:e.data.cssCompiledStyles});return o+f.labelStyles.replace("color:","fill:")}).each(function(e){if(e.depth===0)return;const o=U(this),f=e.data.name;o.text(f);const C=e.x1-e.x0,L=6;let T;s.showValues!==!1&&e.value?T=C-10-30-10-L:T=C-L-6;const m=Math.max(15,T),_=o.node();if(_.getComputedTextLength()>m){let z=f;for(;z.length>0;){if(z=f.substring(0,z.length-1),z.length===0){o.text("..."),_.getComputedTextLength()>m&&o.text("");break}if(o.text(z+"..."),_.getComputedTextLength()<=m)break}}}),s.showValues!==!1&&H.append("text").attr("class","treemapSectionValue").attr("x",e=>e.x1-e.x0-10).attr("y",X/2).attr("text-anchor","end").attr("dominant-baseline","middle").text(e=>e.value?u(e.value):"").attr("font-style","italic").attr("style",e=>{if(e.depth===0)return"display: none;";const o="text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:"+$(e.data.name)+"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;",f=B({cssCompiledStyles:e.data.cssCompiledStyles});return o+f.labelStyles.replace("color:","fill:")});const re=le.leaves(),A=re.length>20,pe=A?16:38,j=A?14:28,D=A?4:8,I=A?4:6,J=A?2:4,se=A?8:10,K=A?1:2,Y=V.selectAll(".treemapLeafGroup").data(re).enter().append("g").attr("class",(e,o)=>`treemapNode treemapLeafGroup leaf${o}${e.data.classSelector?` ${e.data.classSelector}`:""}x`).attr("transform",e=>`translate(${e.x0},${e.y0})`);Y.append("rect").attr("width",e=>e.x1-e.x0).attr("height",e=>e.y1-e.y0).attr("class","treemapLeaf").attr("fill",e=>e.parent?y(e.parent.data.name):y(e.data.name)).attr("style",e=>B({cssCompiledStyles:e.data.cssCompiledStyles}).nodeStyles).attr("fill-opacity",.3).attr("stroke",e=>e.parent?y(e.parent.data.name):y(e.data.name)).attr("stroke-width",3),Y.append("clipPath").attr("id",(e,o)=>`clip-${a}-${o}`).append("rect").attr("width",e=>Math.max(0,e.x1-e.x0-4)).attr("height",e=>Math.max(0,e.y1-e.y0-4)),Y.append("text").attr("class","treemapLabel").attr("x",e=>(e.x1-e.x0)/2).attr("y",e=>(e.y1-e.y0)/2).attr("style",e=>{const o=`text-anchor: middle; dominant-baseline: middle; font-size: ${pe}px;fill:`+$(e.data.name)+";",f=B({cssCompiledStyles:e.data.cssCompiledStyles});return o+f.labelStyles.replace("color:","fill:")}).attr("clip-path",(e,o)=>`url(#clip-${a}-${o})`).text(e=>e.data.name).each(function(e){const o=U(this),f=e.x1-e.x0,C=e.y1-e.y0,L=o.node(),T=f-2*J,P=C-2*J;if(T<se||P<se){o.style("display","none");return}let m=parseInt(o.style("font-size"),10);const _=.6;for(;L.getComputedTextLength()>T&&m>D;)m--,o.style("font-size",`${m}px`);let F=Math.max(I,Math.min(j,Math.round(m*_))),k=m+K+F;for(;k>P&&m>D&&(m--,F=Math.max(I,Math.min(j,Math.round(m*_))),!(F<I&&m===D));)o.style("font-size",`${m}px`),k=m+K+F;o.style("font-size",`${m}px`),A?(m<D||P<D)&&o.style("display","none"):(L.getComputedTextLength()>T||m<D||P<m)&&o.style("display","none")}),s.showValues!==!1&&Y.append("text").attr("class","treemapValue").attr("x",o=>(o.x1-o.x0)/2).attr("y",function(o){return(o.y1-o.y0)/2}).attr("style",o=>{const f=`text-anchor: middle; dominant-baseline: hanging; font-size: ${j}px;fill:`+$(o.data.name)+";",C=B({cssCompiledStyles:o.data.cssCompiledStyles});return f+C.labelStyles.replace("color:","fill:")}).attr("clip-path",(o,f)=>`url(#clip-${a}-${f})`).text(o=>o.value?u(o.value):"").each(function(o){const f=U(this),C=this.parentNode;if(!C){f.style("display","none");return}const L=U(C).select(".treemapLabel");if(L.empty()||L.style("display")==="none"){f.style("display","none");return}const T=parseFloat(L.style("font-size")),m=Math.max(I,Math.min(j,Math.round(T*.6)));f.style("font-size",`${m}px`);const F=(o.y1-o.y0)/2+T/2+K;f.attr("y",F);const k=o.x1-o.x0,ie=o.y1-o.y0-4,me=k-2*J;f.node().getComputedTextLength()>me||F+m>ie||m<I?f.style("display","none"):f.style("display",null)});const ue=s.diagramPadding??8;Ne(b,ue,"flowchart",(s==null?void 0:s.useMaxWidth)||!1)},"draw"),ct=w(function(t,a){return a.db.getClasses()},"getClasses"),ht={draw:ot,getClasses:ct},dt={sectionStrokeColor:"black",sectionStrokeWidth:"1",sectionFillColor:"#efefef",leafStrokeColor:"black",leafStrokeWidth:"1",leafFillColor:"#efefef",labelFontSize:"12px",valueFontSize:"10px",titleFontSize:"14px"},pt=w(({treemap:t}={})=>{const a=ye(),l=ae(),n=ee(a,l.themeVariables),r=ee(dt,t),s=r.titleColor??n.titleColor,h=r.labelColor??n.textColor,d=r.valueColor??n.textColor;return`
2
+ .treemapNode.section {
3
+ stroke: ${r.sectionStrokeColor};
4
+ stroke-width: ${r.sectionStrokeWidth};
5
+ fill: ${r.sectionFillColor};
6
+ }
7
+ .treemapNode.leaf {
8
+ stroke: ${r.leafStrokeColor};
9
+ stroke-width: ${r.leafStrokeWidth};
10
+ fill: ${r.leafFillColor};
11
+ }
12
+ .treemapLabel {
13
+ fill: ${h};
14
+ font-size: ${r.labelFontSize};
15
+ }
16
+ .treemapValue {
17
+ fill: ${d};
18
+ font-size: ${r.valueFontSize};
19
+ }
20
+ .treemapTitle {
21
+ fill: ${s};
22
+ font-size: ${r.titleFontSize};
23
+ }
24
+ `},"getStyles"),ut=pt,Ct={parser:he,get db(){return new oe},renderer:ht,styles:ut};export{Ct as diagram};
@@ -0,0 +1,24 @@
1
+ import{p as $}from"./chunk-JWPE2WC7-B7HxxQds.js";import{_ as b,A as m,D as C,d as S,l as w,b as D,a as T,n as P,o as z,g as A,s as E,y as F,B as W,p as _}from"./MermaidBlock-DR1GikCv.js";import{p as N}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import"./index-GAamh1p4.js";var L=W.packet,u,v=(u=class{constructor(){this.packet=[],this.setAccTitle=D,this.getAccTitle=T,this.setDiagramTitle=P,this.getDiagramTitle=z,this.getAccDescription=A,this.setAccDescription=E}getConfig(){const t=m({...L,...F().packet});return t.showBits&&(t.paddingY+=10),t}getPacket(){return this.packet}pushWord(t){t.length>0&&this.packet.push(t)}clear(){_(),this.packet=[]}},b(u,"PacketDB"),u),M=1e4,Y=b((e,t)=>{$(e,t);let s=-1,r=[],n=1;const{bitsPerRow:l}=t.getConfig();for(let{start:a,end:i,bits:d,label:c}of e.blocks){if(a!==void 0&&i!==void 0&&i<a)throw new Error(`Packet block ${a} - ${i} is invalid. End must be greater than start.`);if(a??(a=s+1),a!==s+1)throw new Error(`Packet block ${a} - ${i??a} is not contiguous. It should start from ${s+1}.`);if(d===0)throw new Error(`Packet block ${a} is invalid. Cannot have a zero bit field.`);for(i??(i=a+(d??1)-1),d??(d=i-a+1),s=i,w.debug(`Packet block ${a} - ${s} with label ${c}`);r.length<=l+1&&t.getPacket().length<M;){const[p,o]=I({start:a,end:i,bits:d,label:c},n,l);if(r.push(p),p.end+1===n*l&&(t.pushWord(r),r=[],n++),!o)break;({start:a,end:i,bits:d,label:c}=o)}}t.pushWord(r)},"populate"),I=b((e,t,s)=>{if(e.start===void 0)throw new Error("start should have been set during first phase");if(e.end===void 0)throw new Error("end should have been set during first phase");if(e.start>e.end)throw new Error(`Block start ${e.start} is greater than block end ${e.end}.`);if(e.end+1<=t*s)return[e,void 0];const r=t*s-1,n=t*s;return[{start:e.start,end:r,label:e.label,bits:r-e.start},{start:n,end:e.end,label:e.label,bits:e.end-n}]},"getNextFittingBlock"),x={parser:{yy:void 0},parse:b(async e=>{var r;const t=await N("packet",e),s=(r=x.parser)==null?void 0:r.yy;if(!(s instanceof v))throw new Error("parser.parser?.yy was not a PacketDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");w.debug(t),Y(t,s)},"parse")},O=b((e,t,s,r)=>{const n=r.db,l=n.getConfig(),{rowHeight:a,paddingY:i,bitWidth:d,bitsPerRow:c}=l,p=n.getPacket(),o=n.getDiagramTitle(),h=a+i,g=h*(p.length+1)-(o?0:a),k=d*c+2,f=C(t);f.attr("viewBox",`0 0 ${k} ${g}`),S(f,g,k,l.useMaxWidth);for(const[y,B]of p.entries())j(f,B,y,l);f.append("text").text(o).attr("x",k/2).attr("y",g-h/2).attr("dominant-baseline","middle").attr("text-anchor","middle").attr("class","packetTitle")},"draw"),j=b((e,t,s,{rowHeight:r,paddingX:n,paddingY:l,bitWidth:a,bitsPerRow:i,showBits:d})=>{const c=e.append("g"),p=s*(r+l)+l;for(const o of t){const h=o.start%i*a+1,g=(o.end-o.start+1)*a-n;if(c.append("rect").attr("x",h).attr("y",p).attr("width",g).attr("height",r).attr("class","packetBlock"),c.append("text").attr("x",h+g/2).attr("y",p+r/2).attr("class","packetLabel").attr("dominant-baseline","middle").attr("text-anchor","middle").text(o.label),!d)continue;const k=o.end===o.start,f=p-2;c.append("text").attr("x",h+(k?g/2:0)).attr("y",f).attr("class","packetByte start").attr("dominant-baseline","auto").attr("text-anchor",k?"middle":"start").text(o.start),k||c.append("text").attr("x",h+g).attr("y",f).attr("class","packetByte end").attr("dominant-baseline","auto").attr("text-anchor","end").text(o.end)}},"drawWord"),G={draw:O},H={byteFontSize:"10px",startByteColor:"black",endByteColor:"black",labelColor:"black",labelFontSize:"12px",titleColor:"black",titleFontSize:"14px",blockStrokeColor:"black",blockStrokeWidth:"1",blockFillColor:"#efefef"},K=b(({packet:e}={})=>{const t=m(H,e);return`
2
+ .packetByte {
3
+ font-size: ${t.byteFontSize};
4
+ }
5
+ .packetByte.start {
6
+ fill: ${t.startByteColor};
7
+ }
8
+ .packetByte.end {
9
+ fill: ${t.endByteColor};
10
+ }
11
+ .packetLabel {
12
+ fill: ${t.labelColor};
13
+ font-size: ${t.labelFontSize};
14
+ }
15
+ .packetTitle {
16
+ fill: ${t.titleColor};
17
+ font-size: ${t.titleFontSize};
18
+ }
19
+ .packetBlock {
20
+ stroke: ${t.blockStrokeColor};
21
+ stroke-width: ${t.blockStrokeWidth};
22
+ fill: ${t.blockFillColor};
23
+ }
24
+ `},"styles"),J={parser:x,get db(){return new v},renderer:G,styles:K};export{J as diagram};
@@ -0,0 +1 @@
1
+ import{g as l,r as m,d as n}from"./chunk-SVP7TREG-DpkmrgHn.js";import{p}from"./chunk-JWPE2WC7-B7HxxQds.js";import{_ as t,l as o}from"./MermaidBlock-DR1GikCv.js";import{M as u,a as f}from"./cynefin-OW5HDTMX-DUwn3ehS.js";import"./index-GAamh1p4.js";var c=f().RailroadEbnf.parser.LangiumParser,s=t(e=>{const r=e.alternatives.map(E);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformChoice"),E=t(e=>{const r=e.elements.map(d);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformSequence"),i=t(e=>{switch(e.$type){case"EbnfTerminal":return{type:"terminal",value:e.value};case"EbnfNonTerminal":return{type:"nonterminal",name:e.name};case"EbnfSpecial":return{type:"special",text:e.text};case"EbnfGroup":return s(e.element);case"EbnfOptional":return{type:"optional",element:s(e.element)};case"EbnfRepetition":return{type:"repetition",element:s(e.element),min:0,max:1/0};default:throw new Error(`Unsupported EBNF primary node: ${e.$type}`)}},"transformPrimary"),b=t((e,r)=>{switch(r.$type){case"EbnfOptionalPostfix":return{type:"optional",element:e};case"EbnfZeroOrMorePostfix":return{type:"repetition",element:e,min:0,max:1/0};case"EbnfOneOrMorePostfix":return{type:"repetition",element:e,min:1,max:1/0};case"EbnfExceptionPostfix":return{type:"sequence",elements:[e,{type:"terminal",value:"-"},i(r.except)]};default:throw new Error(`Unsupported EBNF postfix node: ${r.$type}`)}},"transformPostfix"),d=t(e=>e.postfixes.reduce((r,a)=>b(r,a),i(e.base)),"transformTerm"),y=t(e=>({name:e.name,definition:s(e.definition)}),"transformRule"),v=t(e=>{p(e,n),e.title&&n.setTitle(e.title),e.rules.map(r=>n.addRule(y(r)))},"populateDb"),g={parse:t(e=>{n.clear(),o.debug("[EBNF Parser] Starting Langium parse");const r=c.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new u(r);const a=r.value;o.debug("[EBNF Parser] Parsed rules:",a.rules.length),v(a),o.debug("[EBNF Parser] Parse complete")},"parse"),parser:{yy:n}},R={parser:g,db:n,renderer:m,styles:l};export{R as diagram};
@@ -0,0 +1,99 @@
1
+ import{g as Ut}from"./chunk-XXDRQBXY-BwZ7RbpQ.js";import{s as Kt}from"./chunk-POPQ4Y6H-dxddZlXt.js";import{_ as f,b as Zt,a as jt,s as qt,g as Wt,n as Ht,o as Qt,c as tt,l as F,k as Xt,p as Jt,q as $t,r as te,t as ee,u as se,v as ie,j as re,x as ne}from"./MermaidBlock-DR1GikCv.js";import{c as ae}from"./channel-DGkccMO1.js";import"./index-GAamh1p4.js";var Ot=(function(){var s=f(function(G,a,h,d){for(h=h||{},d=G.length;d--;h[G[d]]=a);return h},"o"),n=[6,9,21,23,25,27,34,37,38,39,40,41,43,46,47,51,53,54,55],c=[2,2],o=[1,7],r=[1,9],l=[1,10],y=[1,11],b=[1,12],k=[1,30],R=[1,23],p=[1,24],g=[1,25],C=[1,26],v=[1,27],x=[1,19],T=[1,28],I=[1,29],N=[1,20],D=[1,18],L=[1,21],w=[1,22],xt=[2,6],u=[6,9,21,23,25,27,33,34,37,38,39,40,41,43,46,47,51,53,54,55],pt=[1,36],ft=[1,37],bt=[1,38],gt=[1,39],yt=[1,40],Z=[6,9,12,14,16,19,20,21,23,25,27,33,34,37,38,39,40,41,43,46,47,50,51,53,54,55,69,70,71,72,73],V=[1,46],M=[1,47],j=[1,57],q=[43,51,53,54,55,74,75],W=[1,70],H=[1,68],B=[1,65],Q=[1,69],X=[1,71],et=[6,9,12,16,21,23,25,27,33,34,37,38,39,40,41,43,44,45,46,47,51,52,53,54,55,69,70,71,72,73],st=[1,78],it=[1,77],rt=[1,76],Nt=[69,70,71,72,73],Ct=[1,91],It=[6,9,45,50],z=[6,9,12,44,45,50,51,52],nt=[1,101],at=[1,100],ot=[1,99],J=[18,61],At=[1,110],Rt=[1,109],vt=[20,43,51,53,54,55],_t=[18,61,64,66],kt={trace:f(function(){},"trace"),yy:{},symbols_:{error:2,start:3,ER_DIAGRAM:4,document:5,EOF:6,line:7,statement:8,NEWLINE:9,entityName:10,relSpec:11,COLON:12,role:13,STYLE_SEPARATOR:14,idList:15,BLOCK_START:16,attributes:17,BLOCK_STOP:18,SQS:19,SQE:20,title:21,title_value:22,acc_title:23,acc_title_value:24,acc_descr:25,acc_descr_value:26,acc_descr_multiline_value:27,direction:28,classDefStatement:29,classStatement:30,styleStatement:31,subgraphHeader:32,END:33,SUBGRAPH:34,separator:35,subgraphTitle:36,direction_tb:37,direction_bt:38,direction_rl:39,direction_lr:40,CLASSDEF:41,stylesOpt:42,UNICODE_TEXT:43,STYLE_TEXT:44,COMMA:45,CLASS:46,STYLE:47,style:48,styleComponent:49,SEMI:50,NUM:51,BRKT:52,ENTITY_NAME:53,DECIMAL_NUM:54,ENTITY_ONE:55,attribute:56,attributeType:57,attributeName:58,attributeKeyTypeList:59,attributeComment:60,ATTRIBUTE_WORD:61,"?":62,attributeKeyType:63,",":64,ATTRIBUTE_KEY:65,COMMENT:66,cardinality:67,relType:68,ZERO_OR_ONE:69,ZERO_OR_MORE:70,ONE_OR_MORE:71,ONLY_ONE:72,MD_PARENT:73,NON_IDENTIFYING:74,IDENTIFYING:75,WORD:76,$accept:0,$end:1},terminals_:{2:"error",4:"ER_DIAGRAM",6:"EOF",9:"NEWLINE",12:"COLON",14:"STYLE_SEPARATOR",16:"BLOCK_START",18:"BLOCK_STOP",19:"SQS",20:"SQE",21:"title",22:"title_value",23:"acc_title",24:"acc_title_value",25:"acc_descr",26:"acc_descr_value",27:"acc_descr_multiline_value",33:"END",34:"SUBGRAPH",37:"direction_tb",38:"direction_bt",39:"direction_rl",40:"direction_lr",41:"CLASSDEF",43:"UNICODE_TEXT",44:"STYLE_TEXT",45:"COMMA",46:"CLASS",47:"STYLE",50:"SEMI",51:"NUM",52:"BRKT",53:"ENTITY_NAME",54:"DECIMAL_NUM",55:"ENTITY_ONE",61:"ATTRIBUTE_WORD",62:"?",64:",",65:"ATTRIBUTE_KEY",66:"COMMENT",69:"ZERO_OR_ONE",70:"ZERO_OR_MORE",71:"ONE_OR_MORE",72:"ONLY_ONE",73:"MD_PARENT",74:"NON_IDENTIFYING",75:"IDENTIFYING",76:"WORD"},productions_:[0,[3,3],[5,0],[5,2],[7,1],[7,1],[7,1],[8,5],[8,9],[8,7],[8,7],[8,4],[8,6],[8,3],[8,5],[8,1],[8,3],[8,7],[8,9],[8,6],[8,8],[8,4],[8,6],[8,2],[8,2],[8,2],[8,1],[8,1],[8,1],[8,1],[8,1],[8,3],[32,3],[32,6],[36,1],[36,2],[28,1],[28,1],[28,1],[28,1],[29,4],[15,1],[15,1],[15,3],[15,3],[30,3],[31,4],[42,1],[42,3],[48,1],[48,2],[35,1],[35,1],[35,1],[49,1],[49,1],[49,1],[49,1],[10,1],[10,1],[10,1],[10,1],[10,1],[17,1],[17,2],[56,2],[56,3],[56,3],[56,4],[57,1],[57,2],[58,1],[59,1],[59,3],[63,1],[60,1],[11,3],[67,1],[67,1],[67,1],[67,1],[67,1],[68,1],[68,1],[13,1],[13,1],[13,1]],performAction:f(function(a,h,d,i,_,t,$){var e=t.length-1;switch(_){case 1:break;case 2:this.$=[];break;case 3:this.$=t[e-1].concat(t[e]);break;case 4:this.$=t[e];break;case 5:case 6:this.$=[];break;case 7:i.addEntity(t[e-4]),i.addEntity(t[e-2]),i.addRelationship(t[e-4],t[e],t[e-2],t[e-3]),this.$=[t[e-4],t[e-2]];break;case 8:i.addEntity(t[e-8]),i.addEntity(t[e-4]),i.addRelationship(t[e-8],t[e],t[e-4],t[e-5]),i.setClass([t[e-8]],t[e-6]),i.setClass([t[e-4]],t[e-2]),this.$=[t[e-8],t[e-4]];break;case 9:i.addEntity(t[e-6]),i.addEntity(t[e-2]),i.addRelationship(t[e-6],t[e],t[e-2],t[e-3]),i.setClass([t[e-6]],t[e-4]),this.$=[t[e-6],t[e-2]];break;case 10:i.addEntity(t[e-6]),i.addEntity(t[e-4]),i.addRelationship(t[e-6],t[e],t[e-4],t[e-5]),i.setClass([t[e-4]],t[e-2]),this.$=[t[e-6],t[e-4]];break;case 11:i.addEntity(t[e-3]),i.addAttributes(t[e-3],t[e-1]),this.$=[t[e-3]];break;case 12:i.addEntity(t[e-5]),i.addAttributes(t[e-5],t[e-1]),i.setClass([t[e-5]],t[e-3]),this.$=[t[e-5]];break;case 13:i.addEntity(t[e-2]),this.$=[t[e-2]];break;case 14:i.addEntity(t[e-4]),i.setClass([t[e-4]],t[e-2]),this.$=[t[e-4]];break;case 15:i.addEntity(t[e]),this.$=[t[e]];break;case 16:i.addEntity(t[e-2]),i.setClass([t[e-2]],t[e]),this.$=[t[e-2]];break;case 17:i.addEntity(t[e-6],t[e-4]),i.addAttributes(t[e-6],t[e-1]),this.$=[t[e-6]];break;case 18:i.addEntity(t[e-8],t[e-6]),i.addAttributes(t[e-8],t[e-1]),i.setClass([t[e-8]],t[e-3]),this.$=[t[e-8]];break;case 19:i.addEntity(t[e-5],t[e-3]),this.$=[t[e-5]];break;case 20:i.addEntity(t[e-7],t[e-5]),i.setClass([t[e-7]],t[e-2]),this.$=[t[e-7]];break;case 21:i.addEntity(t[e-3],t[e-1]);break;case 22:i.addEntity(t[e-5],t[e-3]),i.setClass([t[e-5]],t[e]);break;case 23:case 24:this.$=t[e].trim(),i.setAccTitle(this.$);break;case 25:case 26:this.$=t[e].trim(),i.setAccDescription(this.$);break;case 27:i.subgraphDepth?this.$=t[e]:(i.setDirection(t[e].value),this.$=[]);break;case 31:i.subgraphDepth=(i.subgraphDepth||1)-1,this.$=i.addSubGraph({text:t[e-2].id},t[e-1],{text:t[e-2].text});break;case 32:i.subgraphDepth=(i.subgraphDepth||0)+1,this.$={id:t[e-1],text:t[e-1]};break;case 33:i.subgraphDepth=(i.subgraphDepth||0)+1,this.$={id:t[e-4],text:t[e-2]};break;case 34:case 59:case 60:case 61:case 62:case 86:this.$=t[e];break;case 35:this.$=t[e-1]+" "+t[e];break;case 36:this.$={stmt:"dir",value:"TB"};break;case 37:this.$={stmt:"dir",value:"BT"};break;case 38:this.$={stmt:"dir",value:"RL"};break;case 39:this.$={stmt:"dir",value:"LR"};break;case 40:this.$=t[e-3],i.addClass(t[e-2],t[e-1]);break;case 41:case 42:case 63:case 72:this.$=[t[e]];break;case 43:case 44:this.$=t[e-2].concat([t[e]]);break;case 45:this.$=t[e-2],i.setClass(t[e-1],t[e]);break;case 46:this.$=t[e-3],i.addCssStyles(t[e-2],t[e-1]);break;case 47:this.$=[t[e]];break;case 48:t[e-2].push(t[e]),this.$=t[e-2];break;case 50:this.$=t[e-1]+t[e];break;case 58:case 84:case 85:this.$=t[e].replace(/"/g,"");break;case 64:t[e].push(t[e-1]),this.$=t[e];break;case 65:this.$={type:t[e-1],name:t[e]};break;case 66:this.$={type:t[e-2],name:t[e-1],keys:t[e]};break;case 67:this.$={type:t[e-2],name:t[e-1],comment:t[e]};break;case 68:this.$={type:t[e-3],name:t[e-2],keys:t[e-1],comment:t[e]};break;case 69:case 71:case 74:this.$=t[e];break;case 70:this.$=t[e-1]+t[e];break;case 73:t[e-2].push(t[e]),this.$=t[e-2];break;case 75:this.$=t[e].replace(/"/g,"");break;case 76:this.$={cardA:t[e],relType:t[e-1],cardB:t[e-2]};break;case 77:this.$=i.Cardinality.ZERO_OR_ONE;break;case 78:this.$=i.Cardinality.ZERO_OR_MORE;break;case 79:this.$=i.Cardinality.ONE_OR_MORE;break;case 80:this.$=i.Cardinality.ONLY_ONE;break;case 81:this.$=i.Cardinality.MD_PARENT;break;case 82:this.$=i.Identification.NON_IDENTIFYING;break;case 83:this.$=i.Identification.IDENTIFYING;break}},"anonymous"),table:[{3:1,4:[1,2]},{1:[3]},s(n,c,{5:3}),{6:[1,4],7:5,8:6,9:o,10:8,21:r,23:l,25:y,27:b,28:13,29:14,30:15,31:16,32:17,34:k,37:R,38:p,39:g,40:C,41:v,43:x,46:T,47:I,51:N,53:D,54:L,55:w},s(n,xt,{1:[2,1]}),s(u,[2,3]),s(u,[2,4]),s(u,[2,5]),s(u,[2,15],{11:31,67:35,14:[1,32],16:[1,33],19:[1,34],69:pt,70:ft,71:bt,72:gt,73:yt}),{22:[1,41]},{24:[1,42]},{26:[1,43]},s(u,[2,26]),s(u,[2,27]),s(u,[2,28]),s(u,[2,29]),s(u,[2,30]),s(u,c,{5:44}),s(Z,[2,58]),s(Z,[2,59]),s(Z,[2,60]),s(Z,[2,61]),s(Z,[2,62]),s(u,[2,36]),s(u,[2,37]),s(u,[2,38]),s(u,[2,39]),{15:45,43:V,44:M},{15:48,43:V,44:M},{15:49,43:V,44:M},{10:50,43:x,51:N,53:D,54:L,55:w},{10:51,43:x,51:N,53:D,54:L,55:w},{15:52,43:V,44:M},{17:53,18:[1,54],56:55,57:56,61:j},{10:58,43:x,51:N,53:D,54:L,55:w},{68:59,74:[1,60],75:[1,61]},s(q,[2,77]),s(q,[2,78]),s(q,[2,79]),s(q,[2,80]),s(q,[2,81]),s(u,[2,23]),s(u,[2,24]),s(u,[2,25]),{6:[1,63],7:5,8:6,9:o,10:8,21:r,23:l,25:y,27:b,28:13,29:14,30:15,31:16,32:17,33:[1,62],34:k,37:R,38:p,39:g,40:C,41:v,43:x,46:T,47:I,51:N,53:D,54:L,55:w},{12:W,42:64,44:H,45:B,48:66,49:67,51:Q,52:X},s(et,[2,41]),s(et,[2,42]),{15:72,43:V,44:M,45:B},{12:W,42:73,44:H,45:B,48:66,49:67,51:Q,52:X},{6:st,9:it,19:[1,75],35:74,50:rt},{12:[1,79],14:[1,80]},s(u,[2,16],{67:35,11:81,16:[1,82],45:B,69:pt,70:ft,71:bt,72:gt,73:yt}),{18:[1,83]},s(u,[2,13]),{17:84,18:[2,63],56:55,57:56,61:j},{58:85,61:[1,86]},{61:[2,69],62:[1,87]},{20:[1,88]},{67:89,69:pt,70:ft,71:bt,72:gt,73:yt},s(Nt,[2,82]),s(Nt,[2,83]),s(u,[2,31]),s(u,xt),{6:st,9:it,35:90,45:Ct,50:rt},{43:[1,92],44:[1,93]},s(It,[2,47],{49:94,12:W,44:H,51:Q,52:X}),s(z,[2,49]),s(z,[2,54]),s(z,[2,55]),s(z,[2,56]),s(z,[2,57]),s(u,[2,45],{45:B}),{6:st,9:it,35:95,45:Ct,50:rt},s(u,[2,32]),{10:97,36:96,43:x,51:N,53:D,54:L,55:w},s(u,[2,51]),s(u,[2,52]),s(u,[2,53]),{13:98,43:nt,53:at,76:ot},{15:102,43:V,44:M},{10:103,43:x,51:N,53:D,54:L,55:w},{17:104,18:[1,105],56:55,57:56,61:j},s(u,[2,11]),{18:[2,64]},s(J,[2,65],{59:106,60:107,63:108,65:At,66:Rt}),s([18,61,65,66],[2,71]),{61:[2,70]},s(u,[2,21],{14:[1,112],16:[1,111]}),s([43,51,53,54,55],[2,76]),s(u,[2,40]),{12:W,44:H,48:113,49:67,51:Q,52:X},s(et,[2,43]),s(et,[2,44]),s(z,[2,50]),s(u,[2,46]),{10:115,20:[1,114],43:x,51:N,53:D,54:L,55:w},s(vt,[2,34]),s(u,[2,7]),s(u,[2,84]),s(u,[2,85]),s(u,[2,86]),{12:[1,116],45:B},{12:[1,118],14:[1,117]},{18:[1,119]},s(u,[2,14]),s(J,[2,66],{60:120,64:[1,121],66:Rt}),s(J,[2,67]),s(_t,[2,72]),s(J,[2,75]),s(_t,[2,74]),{17:122,18:[1,123],56:55,57:56,61:j},{15:124,43:V,44:M},s(It,[2,48],{49:94,12:W,44:H,51:Q,52:X}),{6:st,9:it,35:125,50:rt},s(vt,[2,35]),{13:126,43:nt,53:at,76:ot},{15:127,43:V,44:M},{13:128,43:nt,53:at,76:ot},s(u,[2,12]),s(J,[2,68]),{63:129,65:At},{18:[1,130]},s(u,[2,19]),s(u,[2,22],{16:[1,131],45:B}),s(u,[2,33]),s(u,[2,10]),{12:[1,132],45:B},s(u,[2,9]),s(_t,[2,73]),s(u,[2,17]),{17:133,18:[1,134],56:55,57:56,61:j},{13:135,43:nt,53:at,76:ot},{18:[1,136]},s(u,[2,20]),s(u,[2,8]),s(u,[2,18])],defaultActions:{84:[2,64],87:[2,70]},parseError:f(function(a,h){if(h.recoverable)this.trace(a);else{var d=new Error(a);throw d.hash=h,d}},"parseError"),parse:f(function(a){var h=this,d=[0],i=[],_=[null],t=[],$=this.table,e="",lt=0,Dt=0,Ft=2,Lt=1,Yt=t.slice.call(arguments,1),m=Object.create(this.lexer),Y={yy:{}};for(var mt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,mt)&&(Y.yy[mt]=this.yy[mt]);m.setInput(a,Y.yy),Y.yy.lexer=m,Y.yy.parser=this,typeof m.yylloc>"u"&&(m.yylloc={});var Et=m.yylloc;t.push(Et);var Pt=m.options&&m.options.ranges;typeof Y.yy.parseError=="function"?this.parseError=Y.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function zt(S){d.length=d.length-2*S,_.length=_.length-S,t.length=t.length-S}f(zt,"popStack");function wt(){var S;return S=i.pop()||m.lex()||Lt,typeof S!="number"&&(S instanceof Array&&(i=S,S=i.pop()),S=h.symbols_[S]||S),S}f(wt,"lex");for(var E,P,O,St,U={},ht,A,Vt,ut;;){if(P=d[d.length-1],this.defaultActions[P]?O=this.defaultActions[P]:((E===null||typeof E>"u")&&(E=wt()),O=$[P]&&$[P][E]),typeof O>"u"||!O.length||!O[0]){var Tt="";ut=[];for(ht in $[P])this.terminals_[ht]&&ht>Ft&&ut.push("'"+this.terminals_[ht]+"'");m.showPosition?Tt="Parse error on line "+(lt+1)+`:
2
+ `+m.showPosition()+`
3
+ Expecting `+ut.join(", ")+", got '"+(this.terminals_[E]||E)+"'":Tt="Parse error on line "+(lt+1)+": Unexpected "+(E==Lt?"end of input":"'"+(this.terminals_[E]||E)+"'"),this.parseError(Tt,{text:m.match,token:this.terminals_[E]||E,line:m.yylineno,loc:Et,expected:ut})}if(O[0]instanceof Array&&O.length>1)throw new Error("Parse Error: multiple actions possible at state: "+P+", token: "+E);switch(O[0]){case 1:d.push(E),_.push(m.yytext),t.push(m.yylloc),d.push(O[1]),E=null,Dt=m.yyleng,e=m.yytext,lt=m.yylineno,Et=m.yylloc;break;case 2:if(A=this.productions_[O[1]][1],U.$=_[_.length-A],U._$={first_line:t[t.length-(A||1)].first_line,last_line:t[t.length-1].last_line,first_column:t[t.length-(A||1)].first_column,last_column:t[t.length-1].last_column},Pt&&(U._$.range=[t[t.length-(A||1)].range[0],t[t.length-1].range[1]]),St=this.performAction.apply(U,[e,Dt,lt,Y.yy,O[1],_,t].concat(Yt)),typeof St<"u")return St;A&&(d=d.slice(0,-1*A*2),_=_.slice(0,-1*A),t=t.slice(0,-1*A)),d.push(this.productions_[O[1]][0]),_.push(U.$),t.push(U._$),Vt=$[d[d.length-2]][d[d.length-1]],d.push(Vt);break;case 3:return!0}}return!0},"parse")},Gt=(function(){var G={EOF:1,parseError:f(function(h,d){if(this.yy.parser)this.yy.parser.parseError(h,d);else throw new Error(h)},"parseError"),setInput:f(function(a,h){return this.yy=h||this.yy||{},this._input=a,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:f(function(){var a=this._input[0];this.yytext+=a,this.yyleng++,this.offset++,this.match+=a,this.matched+=a;var h=a.match(/(?:\r\n?|\n).*/g);return h?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),a},"input"),unput:f(function(a){var h=a.length,d=a.split(/(?:\r\n?|\n)/g);this._input=a+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-h),this.offset-=h;var i=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),d.length-1&&(this.yylineno-=d.length-1);var _=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:d?(d.length===i.length?this.yylloc.first_column:0)+i[i.length-d.length].length-d[0].length:this.yylloc.first_column-h},this.options.ranges&&(this.yylloc.range=[_[0],_[0]+this.yyleng-h]),this.yyleng=this.yytext.length,this},"unput"),more:f(function(){return this._more=!0,this},"more"),reject:f(function(){if(this.options.backtrack_lexer)this._backtrack=!0;else return 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).
4
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno});return this},"reject"),less:f(function(a){this.unput(this.match.slice(a))},"less"),pastInput:f(function(){var a=this.matched.substr(0,this.matched.length-this.match.length);return(a.length>20?"...":"")+a.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:f(function(){var a=this.match;return a.length<20&&(a+=this._input.substr(0,20-a.length)),(a.substr(0,20)+(a.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:f(function(){var a=this.pastInput(),h=new Array(a.length+1).join("-");return a+this.upcomingInput()+`
5
+ `+h+"^"},"showPosition"),test_match:f(function(a,h){var d,i,_;if(this.options.backtrack_lexer&&(_={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&&(_.yylloc.range=this.yylloc.range.slice(0))),i=a[0].match(/(?:\r\n?|\n).*/g),i&&(this.yylineno+=i.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:i?i[i.length-1].length-i[i.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+a[0].length},this.yytext+=a[0],this.match+=a[0],this.matches=a,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(a[0].length),this.matched+=a[0],d=this.performAction.call(this,this.yy,this,h,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),d)return d;if(this._backtrack){for(var t in _)this[t]=_[t];return!1}return!1},"test_match"),next:f(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var a,h,d,i;this._more||(this.yytext="",this.match="");for(var _=this._currentRules(),t=0;t<_.length;t++)if(d=this._input.match(this.rules[_[t]]),d&&(!h||d[0].length>h[0].length)){if(h=d,i=t,this.options.backtrack_lexer){if(a=this.test_match(d,_[t]),a!==!1)return a;if(this._backtrack){h=!1;continue}else return!1}else if(!this.options.flex)break}return h?(a=this.test_match(h,_[i]),a!==!1?a:!1):this._input===""?this.EOF:this.parseError("Lexical error on line "+(this.yylineno+1)+`. Unrecognized text.
6
+ `+this.showPosition(),{text:"",token:null,line:this.yylineno})},"next"),lex:f(function(){var h=this.next();return h||this.lex()},"lex"),begin:f(function(h){this.conditionStack.push(h)},"begin"),popState:f(function(){var h=this.conditionStack.length-1;return h>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:f(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:f(function(h){return h=this.conditionStack.length-1-Math.abs(h||0),h>=0?this.conditionStack[h]:"INITIAL"},"topState"),pushState:f(function(h){this.begin(h)},"pushState"),stateStackSize:f(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:f(function(h,d,i,_){switch(i){case 0:return this.begin("acc_title"),23;case 1:return this.popState(),"acc_title_value";case 2:return this.begin("acc_descr"),25;case 3:return this.popState(),"acc_descr_value";case 4:this.begin("acc_descr_multiline");break;case 5:this.popState();break;case 6:return"acc_descr_multiline_value";case 7:return 37;case 8:return 38;case 9:return 39;case 10:return 40;case 11:break;case 12:return 9;case 13:return 53;case 14:return 76;case 15:return 4;case 16:return this.begin("block"),16;case 17:return 52;case 18:return 52;case 19:return 45;case 20:return 14;case 21:return 12;case 22:break;case 23:return 65;case 24:return 61;case 25:return 61;case 26:this.begin("block_bq");break;case 27:return 61;case 28:this.popState();break;case 29:return 66;case 30:break;case 31:return this.popState(),18;case 32:return d.yytext[0];case 33:return 19;case 34:return 20;case 35:return this.begin("style"),47;case 36:return this.popState(),9;case 37:break;case 38:return 12;case 39:return 45;case 40:return 52;case 41:return this.begin("style"),41;case 42:return 46;case 43:return 34;case 44:return 33;case 45:return 69;case 46:return 71;case 47:return 71;case 48:return 71;case 49:return 69;case 50:return 69;case 51:return 70;case 52:return 70;case 53:return 70;case 54:return 70;case 55:return 70;case 56:return 71;case 57:return 70;case 58:return 71;case 59:return 72;case 60:return 72;case 61:return 54;case 62:return 72;case 63:return 72;case 64:return 72;case 65:return 55;case 66:return 51;case 67:return 72;case 68:return 69;case 69:return 70;case 70:return 71;case 71:return 73;case 72:return 74;case 73:return 75;case 74:return 75;case 75:return 74;case 76:return 74;case 77:return 74;case 78:return 44;case 79:return 50;case 80:return 43;case 81:return d.yytext[0];case 82:return 6}},"anonymous"),rules:[/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:[\}])/i,/^(?:[^\}]*)/i,/^(?:.*direction\s+TB[^\n]*)/i,/^(?:.*direction\s+BT[^\n]*)/i,/^(?:.*direction\s+RL[^\n]*)/i,/^(?:.*direction\s+LR[^\n]*)/i,/^(?:[ \t\r]+)/i,/^(?:[\n]+)/i,/^(?:"[^"%\r\n\v\b\\]+")/i,/^(?:"[^"]*")/i,/^(?:erDiagram\b)/i,/^(?:\{)/i,/^(?:#)/i,/^(?:#)/i,/^(?:,)/i,/^(?::::)/i,/^(?::)/i,/^(?:\s+)/i,/^(?:\b((?:PK)|(?:FK)|(?:UK))\b)/i,/^(?:([^\s]*)[~].*[~]([^\s]*))/i,/^(?:([\*A-Za-z_\u00C0-\uFFFF][A-Za-z0-9\-\_\[\]\(\)\.,\u00C0-\uFFFF\*]*))/i,/^(?:[`])/i,/^(?:[^`]+)/i,/^(?:[`])/i,/^(?:"[^"]*")/i,/^(?:[\n]+)/i,/^(?:\})/i,/^(?:.)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:style\b)/i,/^(?:[\n]+)/i,/^(?:\s+)/i,/^(?::)/i,/^(?:,)/i,/^(?:#)/i,/^(?:classDef\b)/i,/^(?:class\b)/i,/^(?:subgraph\b)/i,/^(?:end\b\s*)/i,/^(?:one or zero\b)/i,/^(?:one or more\b)/i,/^(?:one or many\b)/i,/^(?:1\+)/i,/^(?:\|o\b)/i,/^(?:zero or one\b)/i,/^(?:zero or more\b)/i,/^(?:zero or many\b)/i,/^(?:0\+)/i,/^(?:\}o\b)/i,/^(?:many\(0\))/i,/^(?:many\(1\))/i,/^(?:many\b)/i,/^(?:\}\|)/i,/^(?:one\b)/i,/^(?:only one\b)/i,/^(?:[0-9]+\.[0-9]+)/i,/^(?:1(?=\s+[A-Za-z_"']))/i,/^(?:1(?=\s+[0-9]))/i,/^(?:1(?=(--|\.\.|\.-|-\.)))/i,/^(?:1\b)/i,/^(?:[0-9]+)/i,/^(?:\|\|)/i,/^(?:o\|)/i,/^(?:o\{)/i,/^(?:\|\{)/i,/^(?:u(?=[\.\-\|]))/i,/^(?:\.\.)/i,/^(?:--)/i,/^(?:to\b)/i,/^(?:optionally to\b)/i,/^(?:\.-)/i,/^(?:-\.)/i,/^(?:([^\x00-\x7F]|\w|-|\*)+)/i,/^(?:;)/i,/^(?:([^\x00-\x7F]|\w|-|\*|\.)+)/i,/^(?:.)/i,/^(?:$)/i],conditions:{style:{rules:[36,37,38,39,40,78,79],inclusive:!1},acc_descr_multiline:{rules:[5,6],inclusive:!1},acc_descr:{rules:[3],inclusive:!1},acc_title:{rules:[1],inclusive:!1},block_bq:{rules:[27,28],inclusive:!1},block:{rules:[22,23,24,25,26,29,30,31,32],inclusive:!1},INITIAL:{rules:[0,2,4,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,33,34,35,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,80,81,82],inclusive:!0}}};return G})();kt.lexer=Gt;function ct(){this.yy={}}return f(ct,"Parser"),ct.prototype=kt,kt.Parser=ct,new ct})();Ot.parser=Ot;var oe=Ot,K,ce=(K=class{constructor(){this.entities=new Map,this.relationships=[],this.classes=new Map,this.subgraphDepth=0,this.subGraphs=[],this.subGraphLookup=new Map,this.subCount=0,this.direction="TB",this.Cardinality={ZERO_OR_ONE:"ZERO_OR_ONE",ZERO_OR_MORE:"ZERO_OR_MORE",ONE_OR_MORE:"ONE_OR_MORE",ONLY_ONE:"ONLY_ONE",MD_PARENT:"MD_PARENT"},this.Identification={NON_IDENTIFYING:"NON_IDENTIFYING",IDENTIFYING:"IDENTIFYING"},this.setAccTitle=Zt,this.getAccTitle=jt,this.setAccDescription=qt,this.getAccDescription=Wt,this.setDiagramTitle=Ht,this.getDiagramTitle=Qt,this.getConfig=f(()=>tt().er,"getConfig"),this.clear(),this.addEntity=this.addEntity.bind(this),this.addAttributes=this.addAttributes.bind(this),this.addRelationship=this.addRelationship.bind(this),this.setDirection=this.setDirection.bind(this),this.addCssStyles=this.addCssStyles.bind(this),this.addClass=this.addClass.bind(this),this.setClass=this.setClass.bind(this),this.setAccTitle=this.setAccTitle.bind(this),this.setAccDescription=this.setAccDescription.bind(this),this.addSubGraph=this.addSubGraph.bind(this)}addEntity(n,c=""){var o;return this.entities.has(n)?!((o=this.entities.get(n))!=null&&o.alias)&&c&&(this.entities.get(n).alias=c,F.info(`Add alias '${c}' to entity '${n}'`)):(this.entities.set(n,{id:`entity-${n}-${this.entities.size}`,label:n,attributes:[],alias:c,shape:"erBox",look:tt().look??"default",cssClasses:"default",cssStyles:[],labelType:"markdown"}),F.info("Added new entity :",n)),this.entities.get(n)}getEntity(n){return this.entities.get(n)}getEntities(){return this.entities}getClasses(){return this.classes}addAttributes(n,c){const o=this.addEntity(n);let r;for(r=c.length-1;r>=0;r--)c[r].keys||(c[r].keys=[]),c[r].comment||(c[r].comment=""),o.attributes.push(c[r]),F.debug("Added attribute ",c[r].name)}addRelationship(n,c,o,r){let l;if(this.subGraphLookup.has(n))l=n;else{const k=this.addEntity(n);if(!k)return;l=k.id}let y;if(this.subGraphLookup.has(o))y=o;else{const k=this.addEntity(o);if(!k)return;y=k.id}const b={entityA:l,roleA:c,entityB:y,relSpec:r};this.relationships.push(b),F.debug("Added new relationship :",b)}getRelationships(){return this.relationships}getDirection(){return this.direction}setDirection(n){this.direction=n}getCompiledStyles(n){let c=[];for(const o of n){const r=this.classes.get(o);r!=null&&r.styles&&(c=[...c,...r.styles??[]].map(l=>l.trim())),r!=null&&r.textStyles&&(c=[...c,...r.textStyles??[]].map(l=>l.trim()))}return c}addCssStyles(n,c){for(const o of n){const r=this.entities.get(o),l=this.subGraphLookup.get(o);if(c){if(r)for(const y of c)r.cssStyles.push(y);if(l){l.cssStyles||(l.cssStyles=[]);for(const y of c)l.cssStyles.push(y)}}}}addClass(n,c){n.forEach(o=>{let r=this.classes.get(o);r===void 0&&(r={id:o,styles:[],textStyles:[]},this.classes.set(o,r)),c&&c.forEach(function(l){if(/color/.exec(l)){const y=l.replace("fill","bgFill");r.textStyles.push(y)}r.styles.push(l)})})}addSubGraph(n,c,o){let r=n.text.trim(),l=o.text;const b=f(g=>{const C=new Set;let v;return{nodeList:g.filter(T=>{if(T!=null&&T.stmt)return T.stmt==="dir"&&(v=T.value),!1;if(typeof T!="string")return!1;const I=T.trim();return!I||C.has(I)?!1:(C.add(I),!0)}),dir:v}},"uniq")(c.flat()),k=b.nodeList,R=b.dir;r=r??"subGraph"+this.subCount,l=l||"",l=this.sanitizeText(l),this.subCount=this.subCount+1;const p={id:r,nodes:k,title:l.trim(),classes:[],cssStyles:[],dir:R,labelType:this.sanitizeNodeLabelType(o==null?void 0:o.type)};return F.info("Adding",p.id,p.nodes,p.dir),p.nodes=this.makeUniq(p,this.subGraphs).nodes,this.subGraphs.push(p),this.subGraphLookup.set(r,p),r}getSubGraphs(){return this.subGraphs}setClass(n,c){for(const o of n){const r=this.entities.get(o);if(r)for(const y of c)r.cssClasses+=" "+y;const l=this.subGraphLookup.get(o);if(l)for(const y of c)l.classes.push(y)}}subgraphNodeCache(n){const c=new Set;for(const o of n)for(const r of o.nodes)c.add(r);return c}makeUniq(n,c){const o=this.subgraphNodeCache(c),r=[];return n.nodes.forEach((l,y)=>{o.has(l)?F.warn(`Entity '${l}' already belongs to another subgraph and will be ignored`):r.push(n.nodes[y])}),{nodes:r}}sanitizeText(n){return Xt.sanitizeText(n,tt())}sanitizeNodeLabelType(n){switch(n){case"markdown":case"string":case"text":return n;default:return"markdown"}}clear(){this.entities=new Map,this.classes=new Map,this.relationships=[],this.subGraphs=[],this.subGraphLookup=new Map,this.subCount=0,this.subgraphDepth=0,Jt()}getData(){const n=[],c=[],o=tt(),r=this.getSubGraphs(),l=new Map,y=new Map;for(let p=r.length-1;p>=0;p--){const g=r[p];g.nodes.length>0&&y.set(g.id,!0);for(const C of g.nodes)l.set(C,g.id)}for(let p=r.length-1;p>=0;p--){const g=r[p];n.push({id:g.id,label:g.title,labelStyle:"",labelType:g.labelType,parentId:l.get(g.id),padding:8,cssCompiledStyles:this.getCompiledStyles(g.classes),cssStyles:g.cssStyles,cssClasses:g.classes.join(" "),shape:"rect",dir:g.dir,isGroup:!0,look:o.look})}const b=new Set(r.map(p=>p.id));let k=0;for(const p of this.entities.keys()){if(b.has(p))continue;const g=this.entities.get(p);g&&(g.cssCompiledStyles=this.getCompiledStyles(g.cssClasses.split(" ")),g.colorIndex=k++,n.push({...g,parentId:l.get(p),isGroup:!1}))}let R=0;for(const p of this.relationships){const g={id:$t(p.entityA,p.entityB,{prefix:"id",counter:R++}),type:"normal",curve:"basis",start:p.entityA,end:p.entityB,label:p.roleA,labelpos:"c",thickness:"normal",classes:"relationshipLine",arrowTypeStart:p.relSpec.cardB.toLowerCase(),arrowTypeEnd:p.relSpec.cardA.toLowerCase(),pattern:p.relSpec.relType=="IDENTIFYING"?"solid":"dashed",look:o.look,labelType:"markdown"};c.push(g)}return{nodes:n,edges:c,other:{},config:o,direction:this.direction}}},f(K,"ErDB"),K),Bt={};ee(Bt,{draw:()=>le});var le=f(async function(s,n,c,o){F.info("REF0:"),F.info("Drawing er diagram (unified)",n);const{securityLevel:r,er:l,layout:y}=tt(),b=o.db.getData(),k=Ut(n,r);b.type=o.type,b.layoutAlgorithm=se(y),b.config.flowchart.nodeSpacing=(l==null?void 0:l.nodeSpacing)||140,b.config.flowchart.rankSpacing=(l==null?void 0:l.rankSpacing)||80,b.direction=o.db.getDirection();const{config:R}=b,{look:p}=R;p==="neo"?b.markers=["only_one_neo","zero_or_one_neo","one_or_more_neo","zero_or_more_neo"]:b.markers=["only_one","zero_or_one","one_or_more","zero_or_more"],b.diagramId=n,await ie(b,k),b.layoutAlgorithm==="elk"&&k.select(".edges").lower();const g=k.selectAll('[id*="-background"]');Array.from(g).length>0&&g.each(function(){const v=re(this),T=v.attr("id").replace("-background",""),I=k.select(`#${CSS.escape(T)}`);if(!I.empty()){const N=I.attr("transform");v.attr("transform",N)}});const C=8;ne.insertTitle(k,"erDiagramTitleText",(l==null?void 0:l.titleTopMargin)??25,o.db.getDiagramTitle()),Kt(k,C,"erDiagram",(l==null?void 0:l.useMaxWidth)??!0)},"draw"),Mt=f((s,n)=>{const c=ae,o=c(s,"r"),r=c(s,"g"),l=c(s,"b");return te(o,r,l,n)},"fade"),dt=new Set(["redux-color","redux-dark-color"]),he=f(s=>{const{theme:n,look:c,bkgColorArray:o,borderColorArray:r}=s;if(!dt.has(n))return"";const l=(o==null?void 0:o.length)>0;let y="";for(let b=0;b<s.THEME_COLOR_LIMIT;b++)y+=`
7
+
8
+ [data-look="${c}"][data-color-id="color-${b}"].node path {
9
+ stroke: ${r[b]};
10
+ ${l?`fill: ${o[b]};`:""}
11
+ }
12
+
13
+ [data-look="${c}"][data-color-id="color-${b}"].node rect {
14
+ stroke: ${r[b]};
15
+ ${l?`fill: ${o[b]};`:""}
16
+ }
17
+ `;return y},"genColor"),ue=f(s=>{const{look:n,theme:c,erEdgeLabelBackground:o,strokeWidth:r}=s;return`
18
+ ${he(s)}
19
+ .entityBox {
20
+ fill: ${s.mainBkg};
21
+ stroke: ${s.nodeBorder};
22
+ }
23
+
24
+ .relationshipLabelBox {
25
+ fill: ${s.tertiaryColor};
26
+ opacity: 0.7;
27
+ background-color: ${s.tertiaryColor};
28
+ rect {
29
+ opacity: 0.5;
30
+ }
31
+ }
32
+
33
+ .labelBkg {
34
+ background-color: ${dt.has(c)&&o?o:Mt(s.tertiaryColor,.5)};
35
+ }
36
+
37
+ .edgeLabel {
38
+ background-color: ${dt.has(c)&&o?o:s.edgeLabelBackground};
39
+ }
40
+ .edgeLabel .label rect {
41
+ fill: ${dt.has(c)&&o?o:s.edgeLabelBackground};
42
+ }
43
+ .edgeLabel .label text {
44
+ fill: ${s.textColor};
45
+ }
46
+
47
+ .edgeLabel .label {
48
+ fill: ${s.nodeBorder};
49
+ font-size: 14px;
50
+ }
51
+
52
+ .label {
53
+ font-family: ${s.fontFamily};
54
+ color: ${s.nodeTextColor||s.textColor};
55
+ }
56
+
57
+ .edge-pattern-dashed {
58
+ stroke-dasharray: 8,8;
59
+ }
60
+
61
+ .node rect,
62
+ .node circle,
63
+ .node ellipse,
64
+ .node polygon
65
+ {
66
+ fill: ${s.mainBkg};
67
+ stroke: ${s.nodeBorder};
68
+ stroke-width: ${n==="neo"?r:"1px"};
69
+ }
70
+
71
+ .relationshipLine {
72
+ stroke: ${s.lineColor};
73
+ stroke-width: ${n==="neo"?r:"1px"};
74
+ fill: none;
75
+ }
76
+
77
+ .marker {
78
+ fill: none !important;
79
+ stroke: ${s.lineColor} !important;
80
+ stroke-width: 1;
81
+ }
82
+ [data-look=neo].labelBkg {
83
+ background-color: ${Mt(s.tertiaryColor,.5)};
84
+ }
85
+
86
+ .cluster rect {
87
+ fill: ${s.clusterBkg??s.mainBkg};
88
+ stroke: ${s.clusterBorder??s.nodeBorder};
89
+ stroke-width: 1px;
90
+ }
91
+
92
+ .cluster text {
93
+ fill: ${s.titleColor??s.textColor};
94
+ }
95
+
96
+ .cluster-label text {
97
+ fill: ${s.titleColor??s.textColor};
98
+ }
99
+ `},"getStyles"),de=ue,_e={parser:oe,get db(){return new ce},renderer:Bt,styles:de};export{_e as diagram};