@codragraph/cli 2.1.0 → 2.1.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 (156) hide show
  1. package/README.md +62 -21
  2. package/dist/_shared/cgdb/schema-constants.d.ts +2 -2
  3. package/dist/_shared/cgdb/schema-constants.d.ts.map +1 -1
  4. package/dist/_shared/cgdb/schema-constants.js +3 -0
  5. package/dist/_shared/cgdb/schema-constants.js.map +1 -1
  6. package/dist/_shared/feature-clusters.d.ts +99 -0
  7. package/dist/_shared/feature-clusters.d.ts.map +1 -0
  8. package/dist/_shared/feature-clusters.js +2 -0
  9. package/dist/_shared/feature-clusters.js.map +1 -0
  10. package/dist/_shared/graph/types.d.ts +16 -2
  11. package/dist/_shared/graph/types.d.ts.map +1 -1
  12. package/dist/_shared/index.d.ts +1 -0
  13. package/dist/_shared/index.d.ts.map +1 -1
  14. package/dist/_shared/index.js.map +1 -1
  15. package/dist/_shared/pipeline.d.ts +1 -1
  16. package/dist/_shared/pipeline.d.ts.map +1 -1
  17. package/dist/cli/ai-context.js +4 -0
  18. package/dist/cli/analyze.js +46 -26
  19. package/dist/cli/index.js +39 -1
  20. package/dist/cli/serve.d.ts +1 -0
  21. package/dist/cli/serve.js +3 -1
  22. package/dist/cli/setup.js +42 -21
  23. package/dist/cli/status.d.ts +13 -0
  24. package/dist/cli/status.js +99 -0
  25. package/dist/cli/tool.d.ts +25 -0
  26. package/dist/cli/tool.js +74 -0
  27. package/dist/config/ignore-service.js +2 -0
  28. package/dist/config/supported-languages.d.ts +3 -3
  29. package/dist/config/supported-languages.js +3 -3
  30. package/dist/core/cgdb/cgdb-adapter.js +19 -3
  31. package/dist/core/cgdb/csv-generator.js +33 -2
  32. package/dist/core/cgdb/schema.d.ts +2 -1
  33. package/dist/core/cgdb/schema.js +55 -0
  34. package/dist/core/embeddings/embedder.js +4 -2
  35. package/dist/core/graphstore/cgdb-row-source.js +3 -2
  36. package/dist/core/graphstore/index.d.ts +1 -1
  37. package/dist/core/graphstore/index.js +1 -1
  38. package/dist/core/group/bridge-db.js +42 -10
  39. package/dist/core/group/service.d.ts +16 -0
  40. package/dist/core/group/service.js +360 -0
  41. package/dist/core/ingestion/emit-references.d.ts +1 -1
  42. package/dist/core/ingestion/emit-references.js +1 -1
  43. package/dist/core/ingestion/feature-cluster-processor.d.ts +62 -0
  44. package/dist/core/ingestion/feature-cluster-processor.js +626 -0
  45. package/dist/core/ingestion/finalize-orchestrator.js +1 -1
  46. package/dist/core/ingestion/model/registration-table.js +1 -0
  47. package/dist/core/ingestion/model/resolve.d.ts +2 -2
  48. package/dist/core/ingestion/model/resolve.js +3 -3
  49. package/dist/core/ingestion/model/semantic-model.d.ts +1 -1
  50. package/dist/core/ingestion/model/semantic-model.js +1 -1
  51. package/dist/core/ingestion/model/symbol-table.d.ts +1 -1
  52. package/dist/core/ingestion/model/symbol-table.js +1 -1
  53. package/dist/core/ingestion/pipeline-phases/feature-clusters.d.ts +17 -0
  54. package/dist/core/ingestion/pipeline-phases/feature-clusters.js +88 -0
  55. package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
  56. package/dist/core/ingestion/pipeline-phases/index.js +1 -0
  57. package/dist/core/ingestion/pipeline.d.ts +4 -0
  58. package/dist/core/ingestion/pipeline.js +9 -5
  59. package/dist/core/run-analyze.d.ts +21 -0
  60. package/dist/core/run-analyze.js +213 -6
  61. package/dist/core/search/hybrid-search.js +11 -3
  62. package/dist/mcp/core/embedder.js +5 -2
  63. package/dist/mcp/local/local-backend.d.ts +12 -0
  64. package/dist/mcp/local/local-backend.js +381 -3
  65. package/dist/mcp/resources.js +139 -0
  66. package/dist/mcp/tools.js +174 -2
  67. package/dist/server/api.d.ts +14 -2
  68. package/dist/server/api.js +206 -7
  69. package/dist/server/mcp-http.d.ts +22 -0
  70. package/dist/server/mcp-http.js +21 -2
  71. package/dist/server/web-dashboard.d.ts +28 -0
  72. package/dist/server/web-dashboard.js +61 -0
  73. package/dist/storage/repo-manager.d.ts +6 -1
  74. package/dist/storage/repo-manager.js +5 -1
  75. package/dist/types/pipeline.d.ts +2 -0
  76. package/dist/web/assets/agent-D5lb0zXz.js +1089 -0
  77. package/dist/web/assets/architectureDiagram-EMZXCZ2Q-CZtc99v_.js +36 -0
  78. package/dist/web/assets/blockDiagram-IGV67L2C-BtoUp-6Y.js +132 -0
  79. package/dist/web/assets/c4Diagram-DFAF54RM-C4Hl3J2U.js +10 -0
  80. package/dist/web/assets/chunk-3GS5O3IE-DkUjU0WD.js +231 -0
  81. package/dist/web/assets/chunk-3YCYZ6SJ-CQkVgT_z.js +1 -0
  82. package/dist/web/assets/chunk-7RZVMHOQ-BitYcNVR.js +338 -0
  83. package/dist/web/assets/chunk-AEOMTBSW-BgTIXPsY.js +1 -0
  84. package/dist/web/assets/chunk-H3VCZNTA-Cx5XV_aC.js +13 -0
  85. package/dist/web/assets/chunk-HN6EAY2L-BBnyTNdB.js +1 -0
  86. package/dist/web/assets/chunk-KSICW3F5-BYzvDLNI.js +15 -0
  87. package/dist/web/assets/chunk-O5ABG6QK-dHwHzA6n.js +1 -0
  88. package/dist/web/assets/chunk-PK6DOVAG-CvsEnugt.js +206 -0
  89. package/dist/web/assets/chunk-RWUO3TPN-BgRTY0_k.js +1 -0
  90. package/dist/web/assets/chunk-TBF5ZNIQ-DL5stGM1.js +1 -0
  91. package/dist/web/assets/chunk-TU3PZOEN-RLyvLcv-.js +1 -0
  92. package/dist/web/assets/classDiagram-PPOCWD7C-DTr8QIOf.js +1 -0
  93. package/dist/web/assets/classDiagram-v2-23LJLIIU-DTr8QIOf.js +1 -0
  94. package/dist/web/assets/context-builder-22jU3V56.js +16 -0
  95. package/dist/web/assets/cose-bilkent-PNC4W37J-DVhePRYg.js +1 -0
  96. package/dist/web/assets/dagre-E77IOHMT-Dzx0A6ZU.js +4 -0
  97. package/dist/web/assets/diagram-H7BISOXX-CC9pRew1.js +43 -0
  98. package/dist/web/assets/diagram-JC5VWROH-Bau_i9tf.js +24 -0
  99. package/dist/web/assets/diagram-LXUTUG65-D9_FM2Gt.js +10 -0
  100. package/dist/web/assets/diagram-WEHSV5V5-BMlayouL.js +24 -0
  101. package/dist/web/assets/erDiagram-GCSMX5X6-C3dhDFA8.js +85 -0
  102. package/dist/web/assets/flowDiagram-OTCZ4VVT-CWSFWmhr.js +162 -0
  103. package/dist/web/assets/ganttDiagram-MUNLMDZQ-D3a67Yol.js +292 -0
  104. package/dist/web/assets/gitGraphDiagram-3HKGZ4G3-7jmry-vM.js +106 -0
  105. package/dist/web/assets/index-BgeqpYgd.js +1415 -0
  106. package/dist/web/assets/index-CT0GtFLZ.css +1 -0
  107. package/dist/web/assets/infoDiagram-MN7RKWGX-G7lhP0Ib.js +2 -0
  108. package/dist/web/assets/ishikawaDiagram-YMYX4NHK-DUoJvNP2.js +70 -0
  109. package/dist/web/assets/journeyDiagram-SO5T7YLQ-RMFPNNqz.js +139 -0
  110. package/dist/web/assets/kanban-definition-LJHFXRCJ-BzpDs1K9.js +89 -0
  111. package/dist/web/assets/katex-GD7MH7QM-DBQvrix-.js +261 -0
  112. package/dist/web/assets/mindmap-definition-2EUWGEK5-Bk0O4roa.js +96 -0
  113. package/dist/web/assets/pieDiagram-3IATQBI2-DKU7kpgS.js +30 -0
  114. package/dist/web/assets/quadrantDiagram-E256RVCF-BY0TGWCS.js +7 -0
  115. package/dist/web/assets/requirementDiagram-M5DCFWZL-DLHOVTSv.js +84 -0
  116. package/dist/web/assets/sankeyDiagram-L3NBLAOT-DVMj5rX2.js +10 -0
  117. package/dist/web/assets/sequenceDiagram-ZOUHS735-CJC73bV-.js +157 -0
  118. package/dist/web/assets/stateDiagram-MLPALWAM-BCFyESls.js +1 -0
  119. package/dist/web/assets/stateDiagram-v2-B5LQ5ZB2-DahzzIca.js +1 -0
  120. package/dist/web/assets/timeline-definition-5SPVSISX-TRSDRgPw.js +120 -0
  121. package/dist/web/assets/vennDiagram-IE5QUKF5-DNy7HRBM.js +34 -0
  122. package/dist/web/assets/wardley-RL74JXVD-BCRCBASE-B-eZEzf9.js +161 -0
  123. package/dist/web/assets/wardleyDiagram-XU3VSMPF-BP-r1xzR.js +20 -0
  124. package/dist/web/assets/xychartDiagram-ZHJ5623Y-Dr9r7a35.js +7 -0
  125. package/dist/web/codragraph-logo-512.png +0 -0
  126. package/dist/web/codragraph-logo.png +0 -0
  127. package/dist/web/favicon.png +0 -0
  128. package/dist/web/index.html +36 -0
  129. package/hooks/claude/codragraph-hook.cjs +24 -9
  130. package/hooks/claude/pre-tool-use.sh +6 -1
  131. package/package.json +15 -4
  132. package/scripts/build.js +75 -16
  133. package/scripts/patch-tree-sitter-swift.cjs +0 -1
  134. package/skills/codragraph-cli.md +17 -1
  135. package/skills/codragraph-guide.md +6 -2
  136. package/skills/codragraph-onboarding.md +2 -2
  137. package/vendor/leiden/index.cjs +272 -285
  138. package/vendor/leiden/utils.cjs +264 -274
  139. package/dist/_shared/lbug/schema-constants.d.ts +0 -16
  140. package/dist/_shared/lbug/schema-constants.d.ts.map +0 -1
  141. package/dist/_shared/lbug/schema-constants.js +0 -67
  142. package/dist/_shared/lbug/schema-constants.js.map +0 -1
  143. package/dist/core/graphstore/lbug-row-source.d.ts +0 -19
  144. package/dist/core/graphstore/lbug-row-source.js +0 -141
  145. package/dist/core/lbug/content-read.d.ts +0 -46
  146. package/dist/core/lbug/content-read.js +0 -64
  147. package/dist/core/lbug/csv-generator.d.ts +0 -29
  148. package/dist/core/lbug/csv-generator.js +0 -492
  149. package/dist/core/lbug/lbug-adapter.d.ts +0 -176
  150. package/dist/core/lbug/lbug-adapter.js +0 -1320
  151. package/dist/core/lbug/pool-adapter.d.ts +0 -93
  152. package/dist/core/lbug/pool-adapter.js +0 -550
  153. package/dist/core/lbug/schema.d.ts +0 -62
  154. package/dist/core/lbug/schema.js +0 -502
  155. package/dist/mcp/core/lbug-adapter.d.ts +0 -5
  156. package/dist/mcp/core/lbug-adapter.js +0 -5
@@ -0,0 +1,20 @@
1
+ import{c as Lt}from"./chunk-AEOMTBSW-BgTIXPsY.js";import{d as Nt}from"./wardley-RL74JXVD-BCRCBASE-B-eZEzf9.js";import{a as zt,l as At,n as Et,h as Tt,s as Bt,e as It,m as u,p as et,a7 as Rt,b as Xt,o as Ft,q as G,c as Yt}from"./index-BgeqpYgd.js";import"./chunk-H3VCZNTA-Cx5XV_aC.js";var j=u((e,r)=>{let a=e<=1?e*100:e;if(a<0||a>100)throw new Error(`${r} must be between 0-1 (decimal) or 0-100 (percentage). Received: ${e}`);return a},"toPercent"),B=u((e,r,a)=>({x:j(r,`${a} evolution`),y:j(e,`${a} visibility`)}),"toCoordinates"),tt=u(e=>{if(e){if(e==="+<>")return"bidirectional";if(e==="+<")return"backward";if(e==="+>")return"forward"}},"getFlowFromPort"),Ot=u(e=>{var a;if(!(e!=null&&e.startsWith("+")))return{};let r=(a=/^\+'([^']*)'/.exec(e))==null?void 0:a[1];return e.includes("<>")?{flow:"bidirectional",label:r}:e.includes("<")?{flow:"backward",label:r}:e.includes(">")?{flow:"forward",label:r}:{label:r}},"extractFlowFromArrow"),Dt=u((e,r)=>{if(Lt(e,r),e.size&&r.setSize(e.size.width,e.size.height),e.evolution){let a=e.evolution.stages.map(n=>n.secondName?`${n.name.trim()} / ${n.secondName.trim()}`:n.name.trim()),h=e.evolution.stages.filter(n=>n.boundary!==void 0).map(n=>n.boundary);r.updateAxes({stages:a,stageBoundaries:h})}if(e.anchors.forEach(a=>{let h=B(a.visibility,a.evolution,`Anchor "${a.name}"`);r.addNode(a.name,a.name,h.x,h.y,"anchor")}),e.components.forEach(a=>{var v;let h=B(a.visibility,a.evolution,`Component "${a.name}"`),n=a.label?(a.label.negX?-1:1)*a.label.offsetX:void 0,s=a.label?(a.label.negY?-1:1)*a.label.offsetY:void 0,m=(v=a.decorator)==null?void 0:v.strategy;r.addNode(a.name,a.name,h.x,h.y,"component",n,s,a.inertia,m)}),e.notes.forEach(a=>{let h=B(a.visibility,a.evolution,`Note "${a.text}"`);r.addNote(a.text,h.x,h.y)}),e.pipelines.forEach(a=>{let h=r.getNode(a.parent);if(!h||typeof h.y!="number")throw new Error(`Pipeline "${a.parent}" must reference an existing component with coordinates.`);let n=h.y;r.startPipeline(a.parent),a.components.forEach(s=>{let m=`${a.parent}_${s.name}`,v=s.label?(s.label.negX?-1:1)*s.label.offsetX:void 0,g=s.label?(s.label.negY?-1:1)*s.label.offsetY:void 0,z=j(s.evolution,`Pipeline component "${s.name}" evolution`);r.addNode(m,s.name,z,n,"pipeline-component",v,g),r.addPipelineComponent(a.parent,m)})}),e.links.forEach(a=>{let h=!!a.arrow&&(a.arrow.includes("-.->")||a.arrow.includes(".-.")),n=tt(a.fromPort)??tt(a.toPort),{flow:s,label:m}=Ot(a.arrow);!n&&s&&(n=s);let v=a.linkLabel,g=m??v;r.addLink(a.from,a.to,h,g,n)}),e.evolves.forEach(a=>{let h=r.getNode(a.component);if((h==null?void 0:h.y)!==void 0){let n=j(a.target,`Evolve target for "${a.component}"`);r.addTrend(a.component,n,h.y)}}),e.annotations.length>0){let a=e.annotations[0],h=B(a.x,a.y,"Annotations box");r.setAnnotationsBox(h.x,h.y)}e.annotation.forEach(a=>{let h=B(a.x,a.y,`Annotation ${a.number}`);r.addAnnotation(a.number,[{x:h.x,y:h.y}],a.text)}),e.accelerators.forEach(a=>{let h=B(a.x,a.y,`Accelerator "${a.name}"`);r.addAccelerator(a.name,h.x,h.y)}),e.deaccelerators.forEach(a=>{let h=B(a.x,a.y,`Deaccelerator "${a.name}"`);r.addDeaccelerator(a.name,h.x,h.y)})},"populateDb"),at={parser:{yy:void 0},parse:u(async e=>{var h;let r=await Nt("wardley",e);et.debug(r);let a=(h=at.parser)==null?void 0:h.yy;if(!a||typeof a.addNode!="function")throw new Error("parser.parser?.yy was not a WardleyDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.");Dt(r,a)},"parse")},X,qt=(X=class{constructor(){this.nodes=new Map,this.links=[],this.trends=new Map,this.pipelines=new Map,this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.axes={}}addNode(r){let a=this.nodes.get(r.id)??{id:r.id,label:r.label},h={...a,...r,className:r.className??a.className,labelOffsetX:r.labelOffsetX??a.labelOffsetX,labelOffsetY:r.labelOffsetY??a.labelOffsetY};this.nodes.set(r.id,h)}addLink(r){this.links.push(r)}addTrend(r){this.trends.set(r.nodeId,r)}startPipeline(r){this.pipelines.set(r,{nodeId:r,componentIds:[]});let a=this.nodes.get(r);a&&(a.isPipelineParent=!0)}addPipelineComponent(r,a){let h=this.pipelines.get(r);h&&h.componentIds.push(a);let n=this.nodes.get(a);n&&(n.inPipeline=!0)}addAnnotation(r){this.annotations.push(r)}addNote(r){this.notes.push(r)}addAccelerator(r){this.accelerators.push(r)}addDeaccelerator(r){this.deaccelerators.push(r)}setAnnotationsBox(r,a){this.annotationsBox={x:r,y:a}}setAxes(r){this.axes={...this.axes,...r}}setSize(r,a){this.size={width:r,height:a}}getNode(r){return this.nodes.get(r)}build(){let r=[];for(let a of this.nodes.values()){if(typeof a.x!="number"||typeof a.y!="number")throw new Error(`Node "${a.label}" is missing coordinates`);r.push(a)}return{nodes:r,links:[...this.links],trends:[...this.trends.values()],pipelines:[...this.pipelines.values()],annotations:[...this.annotations],notes:[...this.notes],accelerators:[...this.accelerators],deaccelerators:[...this.deaccelerators],annotationsBox:this.annotationsBox,axes:{...this.axes},size:this.size}}clear(){this.nodes.clear(),this.links=[],this.trends.clear(),this.pipelines.clear(),this.annotations=[],this.notes=[],this.accelerators=[],this.deaccelerators=[],this.annotationsBox=void 0,this.axes={},this.size=void 0}},u(X,"WardleyBuilder"),X),$=new qt;function C(e){let r=G();return Yt(e.trim(),r)}u(C,"textSanitizer");function rt(){return G()["wardley-beta"]}u(rt,"getConfig");function nt(e,r,a,h,n,s,m,v,g){$.addNode({id:e,label:C(r),x:a,y:h,className:n,labelOffsetX:s,labelOffsetY:m,inertia:v,sourceStrategy:g})}u(nt,"addNode");function ot(e,r,a=!1,h,n){$.addLink({source:e,target:r,dashed:a,label:h,flow:n})}u(ot,"addLink");function it(e,r,a){$.addTrend({nodeId:e,targetX:r,targetY:a})}u(it,"addTrend");function lt(e,r,a){$.addAnnotation({number:e,coordinates:r,text:a?C(a):void 0})}u(lt,"addAnnotation");function st(e,r,a){$.addNote({text:C(e),x:r,y:a})}u(st,"addNote");function dt(e,r,a){$.addAccelerator({name:C(e),x:r,y:a})}u(dt,"addAccelerator");function ct(e,r,a){$.addDeaccelerator({name:C(e),x:r,y:a})}u(ct,"addDeaccelerator");function pt(e,r){$.setAnnotationsBox(e,r)}u(pt,"setAnnotationsBox");function ht(e,r){$.setSize(e,r)}u(ht,"setSize");function xt(e){$.startPipeline(e)}u(xt,"startPipeline");function gt(e,r){$.addPipelineComponent(e,r)}u(gt,"addPipelineComponent");function yt(e){let r={};e.xLabel&&(r.xLabel=C(e.xLabel)),e.yLabel&&(r.yLabel=C(e.yLabel)),e.stages&&(r.stages=e.stages.map(a=>C(a))),e.stageBoundaries&&(r.stageBoundaries=e.stageBoundaries),$.setAxes(r)}u(yt,"updateAxes");function ft(e){return $.getNode(e)}u(ft,"getNode");function ut(){return $.build()}u(ut,"getWardleyData");function mt(){$.clear(),Ft()}u(mt,"clear");var Wt={getConfig:rt,addNode:nt,addLink:ot,addTrend:it,addAnnotation:lt,addNote:st,addAccelerator:dt,addDeaccelerator:ct,setAnnotationsBox:pt,setSize:ht,startPipeline:xt,addPipelineComponent:gt,updateAxes:yt,getNode:ft,getWardleyData:ut,clear:mt,setAccTitle:It,getAccTitle:Bt,setDiagramTitle:Tt,getDiagramTitle:Et,getAccDescription:At,setAccDescription:zt},jt=["Genesis","Custom Built","Product","Commodity"],Gt=u(()=>{var r,a,h,n,s,m,v,g,z,S,k,L;let{themeVariables:e}=G();return{backgroundColor:((r=e.wardley)==null?void 0:r.backgroundColor)??e.background??"#fff",axisColor:((a=e.wardley)==null?void 0:a.axisColor)??"#000",axisTextColor:((h=e.wardley)==null?void 0:h.axisTextColor)??e.primaryTextColor??"#222",gridColor:((n=e.wardley)==null?void 0:n.gridColor)??"rgba(100, 100, 100, 0.2)",componentFill:((s=e.wardley)==null?void 0:s.componentFill)??"#fff",componentStroke:((m=e.wardley)==null?void 0:m.componentStroke)??"#000",componentLabelColor:((v=e.wardley)==null?void 0:v.componentLabelColor)??e.primaryTextColor??"#222",linkStroke:((g=e.wardley)==null?void 0:g.linkStroke)??"#000",evolutionStroke:((z=e.wardley)==null?void 0:z.evolutionStroke)??"#dc3545",annotationStroke:((S=e.wardley)==null?void 0:S.annotationStroke)??"#000",annotationTextColor:((k=e.wardley)==null?void 0:k.annotationTextColor)??e.primaryTextColor??"#222",annotationFill:((L=e.wardley)==null?void 0:L.annotationFill)??e.background??"#fff"}},"getTheme"),Ht=u(()=>{let e=G()["wardley-beta"];return{width:(e==null?void 0:e.width)??900,height:(e==null?void 0:e.height)??600,padding:(e==null?void 0:e.padding)??48,nodeRadius:(e==null?void 0:e.nodeRadius)??6,nodeLabelOffset:(e==null?void 0:e.nodeLabelOffset)??8,axisFontSize:(e==null?void 0:e.axisFontSize)??12,labelFontSize:(e==null?void 0:e.labelFontSize)??10,showGrid:(e==null?void 0:e.showGrid)??!1,useMaxWidth:(e==null?void 0:e.useMaxWidth)??!0}},"getConfigValues"),Vt=u((e,r,a,h)=>{var Q,U;et.debug(`Rendering Wardley map
2
+ `+e);let n=Ht(),s=Gt(),m=n.nodeRadius*1.6,v=h.db,g=v.getWardleyData(),z=v.getDiagramTitle(),S=((Q=g.size)==null?void 0:Q.width)??n.width,k=((U=g.size)==null?void 0:U.height)??n.height,L=Rt(r);L.selectAll("*").remove(),Xt(L,k,S,n.useMaxWidth),L.attr("viewBox",`0 0 ${S} ${k}`);let M=L.append("g").attr("class","wardley-map"),H=L.append("defs");H.append("marker").attr("id",`arrow-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",6).attr("markerHeight",6).attr("orient","auto-start-reverse").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",s.evolutionStroke).attr("stroke","none"),H.append("marker").attr("id",`link-arrow-end-${r}`).attr("viewBox","0 0 10 10").attr("refX",9).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 0 0 L 10 5 L 0 10 z").attr("fill",s.linkStroke).attr("stroke","none"),H.append("marker").attr("id",`link-arrow-start-${r}`).attr("viewBox","0 0 10 10").attr("refX",1).attr("refY",5).attr("markerWidth",5).attr("markerHeight",5).attr("orient","auto").append("path").attr("d","M 10 0 L 0 5 L 10 10 z").attr("fill",s.linkStroke).attr("stroke","none"),M.append("rect").attr("class","wardley-background").attr("width",S).attr("height",k).attr("fill",s.backgroundColor);let F=S-n.padding*2,Y=k-n.padding*2;z&&M.append("text").attr("class","wardley-title").attr("x",S/2).attr("y",n.padding/2).attr("fill",s.axisTextColor).attr("font-size",n.axisFontSize*1.05).attr("font-weight","bold").attr("text-anchor","middle").attr("dominant-baseline","middle").text(z);let A=u(t=>n.padding+t/100*F,"projectX"),E=u(t=>k-n.padding-t/100*Y,"projectY"),D=M.append("g").attr("class","wardley-axes");D.append("line").attr("x1",n.padding).attr("x2",S-n.padding).attr("y1",k-n.padding).attr("y2",k-n.padding).attr("stroke",s.axisColor).attr("stroke-width",1),D.append("line").attr("x1",n.padding).attr("x2",n.padding).attr("y1",n.padding).attr("y2",k-n.padding).attr("stroke",s.axisColor).attr("stroke-width",1);let wt=g.axes.xLabel??"Evolution",kt=g.axes.yLabel??"Visibility";D.append("text").attr("class","wardley-axis-label wardley-axis-label-x").attr("x",n.padding+F/2).attr("y",k-n.padding/4).attr("fill",s.axisTextColor).attr("font-size",n.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").text(wt),D.append("text").attr("class","wardley-axis-label wardley-axis-label-y").attr("x",n.padding/3).attr("y",n.padding+Y/2).attr("fill",s.axisTextColor).attr("font-size",n.axisFontSize).attr("font-weight","bold").attr("text-anchor","middle").attr("transform",`rotate(-90 ${n.padding/3} ${n.padding+Y/2})`).text(kt);let O=g.axes.stages&&g.axes.stages.length>0?g.axes.stages:jt;if(O.length>0){let t=M.append("g").attr("class","wardley-stages"),i=g.axes.stageBoundaries,o=[];if(i&&i.length===O.length){let l=0;i.forEach(d=>{o.push({start:l,end:d}),l=d})}else{let l=1/O.length;O.forEach((d,c)=>{o.push({start:c*l,end:(c+1)*l})})}O.forEach((l,d)=>{let c=o[d],y=n.padding+c.start*F,x=n.padding+c.end*F,f=(y+x)/2;d>0&&t.append("line").attr("x1",y).attr("x2",y).attr("y1",n.padding).attr("y2",k-n.padding).attr("stroke","#000").attr("stroke-width",1).attr("stroke-dasharray","5 5").attr("opacity",.8),t.append("text").attr("class","wardley-stage-label").attr("x",f).attr("y",k-n.padding/1.5).attr("fill",s.axisTextColor).attr("font-size",n.axisFontSize-2).attr("text-anchor","middle").text(l)})}if(n.showGrid){let t=M.append("g").attr("class","wardley-grid");for(let i=1;i<4;i++){let o=i/4,l=n.padding+F*o;t.append("line").attr("x1",l).attr("x2",l).attr("y1",n.padding).attr("y2",k-n.padding).attr("stroke",s.gridColor).attr("stroke-dasharray","2 6"),t.append("line").attr("x1",n.padding).attr("x2",S-n.padding).attr("y1",k-n.padding-Y*o).attr("y2",k-n.padding-Y*o).attr("stroke",s.gridColor).attr("stroke-dasharray","2 6")}}let p=new Map;if(g.nodes.forEach(t=>{p.set(t.id,{x:A(t.x),y:E(t.y),node:t})}),g.pipelines.length>0){let t=M.append("g").attr("class","wardley-pipelines"),i=M.append("g").attr("class","wardley-pipeline-links");g.pipelines.forEach(o=>{if(o.componentIds.length===0)return;let l=o.componentIds.map(x=>({id:x,pos:p.get(x),node:g.nodes.find(f=>f.id===x)})).filter(x=>x.pos&&x.node).sort((x,f)=>x.node.x-f.node.x);for(let x=0;x<l.length-1;x++){let f=l[x],w=l[x+1];i.append("line").attr("class","wardley-pipeline-evolution-link").attr("x1",f.pos.x).attr("y1",f.pos.y).attr("x2",w.pos.x).attr("y2",w.pos.y).attr("stroke",s.linkStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4")}let d=1/0,c=-1/0,y=0;if(o.componentIds.forEach(x=>{let f=p.get(x);f&&(d=Math.min(d,f.x),c=Math.max(c,f.x),y=f.y)}),d!==1/0&&c!==-1/0){let x=n.nodeRadius*4,f=y-x/2,w=p.get(o.nodeId);if(w){let P=(d+c)/2;w.x=P,w.y=f-m/6}t.append("rect").attr("class","wardley-pipeline-box").attr("x",d-15).attr("y",f).attr("width",c-d+30).attr("height",x).attr("fill","none").attr("stroke",s.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}})}let _=M.append("g").attr("class","wardley-links"),J=new Map;g.pipelines.forEach(t=>{J.set(t.nodeId,new Set(t.componentIds))});let K=g.links.filter(t=>{var i;return!(!p.has(t.source)||!p.has(t.target)||(i=J.get(t.target))!=null&&i.has(t.source))});_.selectAll("line").data(K).enter().append("line").attr("class",t=>`wardley-link${t.dashed?" wardley-link--dashed":""}`).attr("x1",t=>{let i=p.get(t.source),o=p.get(t.target),l=g.nodes.find(x=>x.id===t.source).isPipelineParent?m/Math.sqrt(2):n.nodeRadius,d=o.x-i.x,c=o.y-i.y,y=Math.sqrt(d*d+c*c);return i.x+d/y*l}).attr("y1",t=>{let i=p.get(t.source),o=p.get(t.target),l=g.nodes.find(x=>x.id===t.source).isPipelineParent?m/Math.sqrt(2):n.nodeRadius,d=o.x-i.x,c=o.y-i.y,y=Math.sqrt(d*d+c*c);return i.y+c/y*l}).attr("x2",t=>{let i=p.get(t.source),o=p.get(t.target),l=g.nodes.find(x=>x.id===t.target).isPipelineParent?m/Math.sqrt(2):n.nodeRadius,d=i.x-o.x,c=i.y-o.y,y=Math.sqrt(d*d+c*c);return o.x+d/y*l}).attr("y2",t=>{let i=p.get(t.source),o=p.get(t.target),l=g.nodes.find(x=>x.id===t.target).isPipelineParent?m/Math.sqrt(2):n.nodeRadius,d=i.x-o.x,c=i.y-o.y,y=Math.sqrt(d*d+c*c);return o.y+c/y*l}).attr("stroke",s.linkStroke).attr("stroke-width",1).attr("stroke-dasharray",t=>t.dashed?"6 6":null).attr("marker-end",t=>t.flow==="forward"||t.flow==="bidirectional"?`url(#link-arrow-end-${r})`:null).attr("marker-start",t=>t.flow==="backward"||t.flow==="bidirectional"?`url(#link-arrow-start-${r})`:null),_.selectAll("text").data(K.filter(t=>t.label)).enter().append("text").attr("class","wardley-link-label").attr("x",t=>{let i=p.get(t.source),o=p.get(t.target),l=(i.x+o.x)/2,d=o.y-i.y,c=o.x-i.x,y=Math.sqrt(c*c+d*d),x=8,f=d/y;return l+f*x}).attr("y",t=>{let i=p.get(t.source),o=p.get(t.target),l=(i.y+o.y)/2,d=o.x-i.x,c=o.y-i.y,y=Math.sqrt(d*d+c*c),x=8,f=-d/y;return l+f*x}).attr("fill",s.axisTextColor).attr("font-size",n.labelFontSize).attr("text-anchor","middle").attr("dominant-baseline","middle").attr("transform",t=>{let i=p.get(t.source),o=p.get(t.target),l=(i.x+o.x)/2,d=(i.y+o.y)/2,c=o.x-i.x,y=o.y-i.y,x=Math.sqrt(c*c+y*y),f=8,w=y/x,P=-c/x,I=l+w*f,q=d+P*f,R=Math.atan2(y,c)*180/Math.PI;return(R>90||R<-90)&&(R+=180),`rotate(${R} ${I} ${q})`}).text(t=>t.label);let bt=M.append("g").attr("class","wardley-trends"),$t=g.trends.map(t=>{let i=p.get(t.nodeId);if(!i)return null;let o=A(t.targetX),l=E(t.targetY),d=o-i.x,c=l-i.y,y=Math.sqrt(d*d+c*c),x=n.nodeRadius+2,f=y>x?o-d/y*x:o,w=y>x?l-c/y*x:l;return{origin:i,targetX:o,targetY:l,adjustedX2:f,adjustedY2:w}}).filter(t=>t!==null);bt.selectAll("line").data($t).enter().append("line").attr("class","wardley-trend").attr("x1",t=>t.origin.x).attr("y1",t=>t.origin.y).attr("x2",t=>t.adjustedX2).attr("y2",t=>t.adjustedY2).attr("stroke",s.evolutionStroke).attr("stroke-width",1).attr("stroke-dasharray","4 4").attr("marker-end",`url(#arrow-${r})`);let N=M.append("g").attr("class","wardley-nodes").selectAll("g").data(g.nodes).enter().append("g").attr("class",t=>["wardley-node",t.className?`wardley-node--${t.className}`:""].filter(Boolean).join(" "));N.filter(t=>t.sourceStrategy==="outsource").append("circle").attr("class","wardley-outsource-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","#666").attr("stroke",s.componentStroke).attr("stroke-width",1),N.filter(t=>t.sourceStrategy==="buy").append("circle").attr("class","wardley-buy-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","#ccc").attr("stroke",s.componentStroke).attr("stroke-width",1),N.filter(t=>t.sourceStrategy==="build").append("circle").attr("class","wardley-build-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","#eee").attr("stroke","#000").attr("stroke-width",1);let T=N.filter(t=>t.sourceStrategy==="market");T.append("circle").attr("class","wardley-market-overlay").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius*2).attr("fill","white").attr("stroke",s.componentStroke).attr("stroke-width",1),N.filter(t=>!t.isPipelineParent&&t.sourceStrategy!=="market"&&t.className!=="anchor").append("circle").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y).attr("r",n.nodeRadius).attr("fill",s.componentFill).attr("stroke",s.componentStroke).attr("stroke-width",1);let V=n.nodeRadius*.7,b=n.nodeRadius*1.2;if(T.append("line").attr("class","wardley-market-line").attr("x1",t=>p.get(t.id).x).attr("y1",t=>p.get(t.id).y-b).attr("x2",t=>p.get(t.id).x-b*Math.cos(Math.PI/6)).attr("y2",t=>p.get(t.id).y+b*Math.sin(Math.PI/6)).attr("stroke",s.componentStroke).attr("stroke-width",1),T.append("line").attr("class","wardley-market-line").attr("x1",t=>p.get(t.id).x-b*Math.cos(Math.PI/6)).attr("y1",t=>p.get(t.id).y+b*Math.sin(Math.PI/6)).attr("x2",t=>p.get(t.id).x+b*Math.cos(Math.PI/6)).attr("y2",t=>p.get(t.id).y+b*Math.sin(Math.PI/6)).attr("stroke",s.componentStroke).attr("stroke-width",1),T.append("line").attr("class","wardley-market-line").attr("x1",t=>p.get(t.id).x+b*Math.cos(Math.PI/6)).attr("y1",t=>p.get(t.id).y+b*Math.sin(Math.PI/6)).attr("x2",t=>p.get(t.id).x).attr("y2",t=>p.get(t.id).y-b).attr("stroke",s.componentStroke).attr("stroke-width",1),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>p.get(t.id).x).attr("cy",t=>p.get(t.id).y-b).attr("r",V).attr("fill","white").attr("stroke",s.componentStroke).attr("stroke-width",2),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>p.get(t.id).x-b*Math.cos(Math.PI/6)).attr("cy",t=>p.get(t.id).y+b*Math.sin(Math.PI/6)).attr("r",V).attr("fill","white").attr("stroke",s.componentStroke).attr("stroke-width",2),T.append("circle").attr("class","wardley-market-dot").attr("cx",t=>p.get(t.id).x+b*Math.cos(Math.PI/6)).attr("cy",t=>p.get(t.id).y+b*Math.sin(Math.PI/6)).attr("r",V).attr("fill","white").attr("stroke",s.componentStroke).attr("stroke-width",2),N.filter(t=>t.isPipelineParent===!0).append("rect").attr("x",t=>p.get(t.id).x-m/2).attr("y",t=>p.get(t.id).y-m/2).attr("width",m).attr("height",m).attr("fill",s.componentFill).attr("stroke",s.componentStroke).attr("stroke-width",1),N.filter(t=>t.inertia===!0).append("line").attr("class","wardley-inertia").attr("x1",t=>{let i=p.get(t.id),o=t.isPipelineParent?m/2+15:n.nodeRadius+15;return t.sourceStrategy&&(o+=n.nodeRadius+10),i.x+o}).attr("y1",t=>{let i=p.get(t.id),o=t.isPipelineParent?m:n.nodeRadius*2;return i.y-o/2}).attr("x2",t=>{let i=p.get(t.id),o=t.isPipelineParent?m/2+15:n.nodeRadius+15;return t.sourceStrategy&&(o+=n.nodeRadius+10),i.x+o}).attr("y2",t=>{let i=p.get(t.id),o=t.isPipelineParent?m:n.nodeRadius*2;return i.y+o/2}).attr("stroke",s.componentStroke).attr("stroke-width",6),N.append("text").attr("x",t=>{let i=p.get(t.id);if(t.className==="anchor")return t.labelOffsetX!==void 0?i.x+t.labelOffsetX:i.x;let o=n.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetX===void 0&&(o+=10);let l=t.labelOffsetX??o;return i.x+l}).attr("y",t=>{let i=p.get(t.id);if(t.className==="anchor")return t.labelOffsetY!==void 0?i.y+t.labelOffsetY:i.y-3;let o=-n.nodeLabelOffset;t.sourceStrategy&&t.labelOffsetY===void 0&&(o-=10);let l=t.labelOffsetY??o;return i.y+l}).attr("class","wardley-node-label").attr("fill",t=>t.className==="evolved"?s.evolutionStroke:t.className==="anchor"?"#000":s.componentLabelColor).attr("font-size",n.labelFontSize).attr("font-weight",t=>t.className==="anchor"?"bold":"normal").attr("text-anchor",t=>t.className==="anchor"?"middle":"start").attr("dominant-baseline",t=>t.className==="anchor"?"middle":"auto").text(t=>t.label),g.annotations.length>0){let t=M.append("g").attr("class","wardley-annotations");if(g.annotations.forEach(i=>{let o=i.coordinates.map(l=>({x:A(l.x),y:E(l.y)}));if(o.length>1)for(let l=0;l<o.length-1;l++)t.append("line").attr("class","wardley-annotation-line").attr("x1",o[l].x).attr("y1",o[l].y).attr("x2",o[l+1].x).attr("y2",o[l+1].y).attr("stroke",s.axisColor).attr("stroke-width",1.5).attr("stroke-dasharray","4 4");o.forEach(l=>{let d=t.append("g").attr("class","wardley-annotation");d.append("circle").attr("cx",l.x).attr("cy",l.y).attr("r",10).attr("fill","white").attr("stroke",s.axisColor).attr("stroke-width",1.5),d.append("text").attr("x",l.x).attr("y",l.y).attr("text-anchor","middle").attr("dominant-baseline","central").attr("font-size",10).attr("fill",s.axisTextColor).attr("font-weight","bold").text(i.number)})}),g.annotationsBox){let i=A(g.annotationsBox.x),o=E(g.annotationsBox.y),l=10,d=16,c=11,y=t.append("g").attr("class","wardley-annotations-box"),x=[...g.annotations].filter(w=>w.text).sort((w,P)=>w.number-P.number),f=[];if(x.forEach((w,P)=>{let I=y.append("text").attr("x",i+l).attr("y",o+l+(P+1)*d).attr("font-size",c).attr("fill",s.axisTextColor).attr("text-anchor","start").attr("dominant-baseline","middle").text(`${w.number}. ${w.text}`);f.push(I)}),f.length>0){let w=0,P=0;f.forEach(Z=>{let W=Z.node(),Pt=W.getComputedTextLength();w=Math.max(w,Pt);let Ct=W.getBBox();P=Math.max(P,Ct.height)});let I=w+l*2+105,q=x.length*d+l*2+P/2,R=n.padding,vt=S-n.padding-I,Mt=n.padding,St=k-n.padding-q;i=Math.max(R,Math.min(i,vt)),o=Math.max(Mt,Math.min(o,St)),f.forEach((Z,W)=>{Z.attr("x",i+l).attr("y",o+l+(W+1)*d)}),y.insert("rect","text").attr("x",i).attr("y",o).attr("width",I).attr("height",q).attr("fill","white").attr("stroke",s.axisColor).attr("stroke-width",1.5).attr("rx",4).attr("ry",4)}}}if(g.notes.length>0){let t=M.append("g").attr("class","wardley-notes");g.notes.forEach(i=>{let o=A(i.x),l=E(i.y);t.append("text").attr("x",o).attr("y",l).attr("text-anchor","start").attr("font-size",11).attr("fill",s.axisTextColor).attr("font-weight","bold").text(i.text)})}if(g.accelerators.length>0){let t=M.append("g").attr("class","wardley-accelerators");g.accelerators.forEach(i=>{let o=A(i.x),l=E(i.y),d=60,c=30,y=20,x=`
3
+ M ${o} ${l-c/2}
4
+ L ${o+d-y} ${l-c/2}
5
+ L ${o+d-y} ${l-c/2-8}
6
+ L ${o+d} ${l}
7
+ L ${o+d-y} ${l+c/2+8}
8
+ L ${o+d-y} ${l+c/2}
9
+ L ${o} ${l+c/2}
10
+ Z
11
+ `;t.append("path").attr("d",x).attr("fill","white").attr("stroke",s.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+d/2).attr("y",l+c/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",s.axisTextColor).attr("font-weight","bold").text(i.name)})}if(g.deaccelerators.length>0){let t=M.append("g").attr("class","wardley-deaccelerators");g.deaccelerators.forEach(i=>{let o=A(i.x),l=E(i.y),d=60,c=30,y=20,x=`
12
+ M ${o+d} ${l-c/2}
13
+ L ${o+y} ${l-c/2}
14
+ L ${o+y} ${l-c/2-8}
15
+ L ${o} ${l}
16
+ L ${o+y} ${l+c/2+8}
17
+ L ${o+y} ${l+c/2}
18
+ L ${o+d} ${l+c/2}
19
+ Z
20
+ `;t.append("path").attr("d",x).attr("fill","white").attr("stroke",s.componentStroke).attr("stroke-width",1),t.append("text").attr("x",o+d/2).attr("y",l+c/2+15).attr("text-anchor","middle").attr("font-size",10).attr("fill",s.axisTextColor).attr("font-weight","bold").text(i.name)})}},"draw"),Zt={draw:Vt},Ut={parser:at,db:Wt,renderer:Zt,styles:u(()=>"","styles")};export{Ut as diagram};
@@ -0,0 +1,7 @@
1
+ import{a as gi,l as ui,n as Wt,h as xi,s as di,e as pi,m as n,p as Nt,a7 as fi,b as yi,o as mi,O as kt,c as bi,L as Vt,y as Ai,ac as wi,ad as Bt,Z as zt,ae as Ci,af as Ot}from"./index-BgeqpYgd.js";var bt=function(){var s=n(function(P,o,l,c){for(l=l||{},c=P.length;c--;l[P[c]]=o);return l},"o"),t=[1,10,12,14,16,18,19,21,23],i=[2,6],e=[1,3],a=[1,5],g=[1,6],u=[1,7],m=[1,5,10,12,14,16,18,19,21,23,34,35,36],b=[1,25],E=[1,26],B=[1,28],R=[1,29],$=[1,30],W=[1,31],N=[1,32],D=[1,33],z=[1,34],p=[1,35],C=[1,36],r=[1,37],I=[1,43],O=[1,42],U=[1,47],Y=[1,50],A=[1,10,12,14,16,18,19,21,23,34,35,36],x=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36],w=[1,10,12,14,16,18,19,21,23,24,26,27,28,34,35,36,41,42,43,44,45,46,47,48,49,50],L=[1,64],k={trace:n(function(){},"trace"),yy:{},symbols_:{error:2,start:3,eol:4,XYCHART:5,chartConfig:6,document:7,CHART_ORIENTATION:8,statement:9,title:10,text:11,X_AXIS:12,parseXAxis:13,Y_AXIS:14,parseYAxis:15,LINE:16,plotData:17,BAR:18,acc_title:19,acc_title_value:20,acc_descr:21,acc_descr_value:22,acc_descr_multiline_value:23,SQUARE_BRACES_START:24,commaSeparatedNumbers:25,SQUARE_BRACES_END:26,NUMBER_WITH_DECIMAL:27,COMMA:28,xAxisData:29,bandData:30,ARROW_DELIMITER:31,commaSeparatedTexts:32,yAxisData:33,NEWLINE:34,SEMI:35,EOF:36,alphaNum:37,STR:38,MD_STR:39,alphaNumToken:40,AMP:41,NUM:42,ALPHA:43,PLUS:44,EQUALS:45,MULT:46,DOT:47,BRKT:48,MINUS:49,UNDERSCORE:50,$accept:0,$end:1},terminals_:{2:"error",5:"XYCHART",8:"CHART_ORIENTATION",10:"title",12:"X_AXIS",14:"Y_AXIS",16:"LINE",18:"BAR",19:"acc_title",20:"acc_title_value",21:"acc_descr",22:"acc_descr_value",23:"acc_descr_multiline_value",24:"SQUARE_BRACES_START",26:"SQUARE_BRACES_END",27:"NUMBER_WITH_DECIMAL",28:"COMMA",31:"ARROW_DELIMITER",34:"NEWLINE",35:"SEMI",36:"EOF",38:"STR",39:"MD_STR",41:"AMP",42:"NUM",43:"ALPHA",44:"PLUS",45:"EQUALS",46:"MULT",47:"DOT",48:"BRKT",49:"MINUS",50:"UNDERSCORE"},productions_:[0,[3,2],[3,3],[3,2],[3,1],[6,1],[7,0],[7,2],[9,2],[9,2],[9,2],[9,2],[9,2],[9,3],[9,2],[9,3],[9,2],[9,2],[9,1],[17,3],[25,3],[25,1],[13,1],[13,2],[13,1],[29,1],[29,3],[30,3],[32,3],[32,1],[15,1],[15,2],[15,1],[33,3],[4,1],[4,1],[4,1],[11,1],[11,1],[11,1],[37,1],[37,2],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1],[40,1]],performAction:n(function(P,o,l,c,f,h,T){var d=h.length-1;switch(f){case 5:c.setOrientation(h[d]);break;case 9:c.setDiagramTitle(h[d].text.trim());break;case 12:c.setLineData({text:"",type:"text"},h[d]);break;case 13:c.setLineData(h[d-1],h[d]);break;case 14:c.setBarData({text:"",type:"text"},h[d]);break;case 15:c.setBarData(h[d-1],h[d]);break;case 16:this.$=h[d].trim(),c.setAccTitle(this.$);break;case 17:case 18:this.$=h[d].trim(),c.setAccDescription(this.$);break;case 19:this.$=h[d-1];break;case 20:this.$=[Number(h[d-2]),...h[d]];break;case 21:this.$=[Number(h[d])];break;case 22:c.setXAxisTitle(h[d]);break;case 23:c.setXAxisTitle(h[d-1]);break;case 24:c.setXAxisTitle({type:"text",text:""});break;case 25:c.setXAxisBand(h[d]);break;case 26:c.setXAxisRangeData(Number(h[d-2]),Number(h[d]));break;case 27:this.$=h[d-1];break;case 28:this.$=[h[d-2],...h[d]];break;case 29:this.$=[h[d]];break;case 30:c.setYAxisTitle(h[d]);break;case 31:c.setYAxisTitle(h[d-1]);break;case 32:c.setYAxisTitle({type:"text",text:""});break;case 33:c.setYAxisRangeData(Number(h[d-2]),Number(h[d]));break;case 37:this.$={text:h[d],type:"text"};break;case 38:this.$={text:h[d],type:"text"};break;case 39:this.$={text:h[d],type:"markdown"};break;case 40:this.$=h[d];break;case 41:this.$=h[d-1]+""+h[d];break}},"anonymous"),table:[s(t,i,{3:1,4:2,7:4,5:e,34:a,35:g,36:u}),{1:[3]},s(t,i,{4:2,7:4,3:8,5:e,34:a,35:g,36:u}),s(t,i,{4:2,7:4,6:9,3:10,5:e,8:[1,11],34:a,35:g,36:u}),{1:[2,4],9:12,10:[1,13],12:[1,14],14:[1,15],16:[1,16],18:[1,17],19:[1,18],21:[1,19],23:[1,20]},s(m,[2,34]),s(m,[2,35]),s(m,[2,36]),{1:[2,1]},s(t,i,{4:2,7:4,3:21,5:e,34:a,35:g,36:u}),{1:[2,3]},s(m,[2,5]),s(t,[2,7],{4:22,34:a,35:g,36:u}),{11:23,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},{11:39,13:38,24:I,27:O,29:40,30:41,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},{11:45,15:44,27:U,33:46,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},{11:49,17:48,24:Y,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},{11:52,17:51,24:Y,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},{20:[1,53]},{22:[1,54]},s(A,[2,18]),{1:[2,2]},s(A,[2,8]),s(A,[2,9]),s(x,[2,37],{40:55,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r}),s(x,[2,38]),s(x,[2,39]),s(w,[2,40]),s(w,[2,42]),s(w,[2,43]),s(w,[2,44]),s(w,[2,45]),s(w,[2,46]),s(w,[2,47]),s(w,[2,48]),s(w,[2,49]),s(w,[2,50]),s(w,[2,51]),s(A,[2,10]),s(A,[2,22],{30:41,29:56,24:I,27:O}),s(A,[2,24]),s(A,[2,25]),{31:[1,57]},{11:59,32:58,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},s(A,[2,11]),s(A,[2,30],{33:60,27:U}),s(A,[2,32]),{31:[1,61]},s(A,[2,12]),{17:62,24:Y},{25:63,27:L},s(A,[2,14]),{17:65,24:Y},s(A,[2,16]),s(A,[2,17]),s(w,[2,41]),s(A,[2,23]),{27:[1,66]},{26:[1,67]},{26:[2,29],28:[1,68]},s(A,[2,31]),{27:[1,69]},s(A,[2,13]),{26:[1,70]},{26:[2,21],28:[1,71]},s(A,[2,15]),s(A,[2,26]),s(A,[2,27]),{11:59,32:72,37:24,38:b,39:E,40:27,41:B,42:R,43:$,44:W,45:N,46:D,47:z,48:p,49:C,50:r},s(A,[2,33]),s(A,[2,19]),{25:73,27:L},{26:[2,28]},{26:[2,20]}],defaultActions:{8:[2,1],10:[2,3],21:[2,2],72:[2,28],73:[2,20]},parseError:n(function(P,o){if(o.recoverable)this.trace(P);else{var l=new Error(P);throw l.hash=o,l}},"parseError"),parse:n(function(P){var o=this,l=[0],c=[],f=[null],h=[],T=this.table,d="",rt=0,Et=0,hi=0,oi=2,$t=1,ri=h.slice.call(arguments,1),S=Object.create(this.lexer),X={yy:{}};for(var dt in this.yy)Object.prototype.hasOwnProperty.call(this.yy,dt)&&(X.yy[dt]=this.yy[dt]);S.setInput(P,X.yy),X.yy.lexer=S,X.yy.parser=this,typeof S.yylloc>"u"&&(S.yylloc={});var pt=S.yylloc;h.push(pt);var li=S.options&&S.options.ranges;typeof X.yy.parseError=="function"?this.parseError=X.yy.parseError:this.parseError=Object.getPrototypeOf(this).parseError;function ci(v){l.length=l.length-2*v,f.length=f.length-v,h.length=h.length-v}n(ci,"popStack");function It(){var v;return v=c.pop()||S.lex()||$t,typeof v!="number"&&(v instanceof Array&&(c=v,v=c.pop()),v=o.symbols_[v]||v),v}n(It,"lex");for(var _,ft,H,M,Bi,yt,G={},lt,V,Mt,ct;;){if(H=l[l.length-1],this.defaultActions[H]?M=this.defaultActions[H]:((_===null||typeof _>"u")&&(_=It()),M=T[H]&&T[H][_]),typeof M>"u"||!M.length||!M[0]){var mt="";ct=[];for(lt in T[H])this.terminals_[lt]&&lt>oi&&ct.push("'"+this.terminals_[lt]+"'");S.showPosition?mt="Parse error on line "+(rt+1)+`:
2
+ `+S.showPosition()+`
3
+ Expecting `+ct.join(", ")+", got '"+(this.terminals_[_]||_)+"'":mt="Parse error on line "+(rt+1)+": Unexpected "+(_==$t?"end of input":"'"+(this.terminals_[_]||_)+"'"),this.parseError(mt,{text:S.match,token:this.terminals_[_]||_,line:S.yylineno,loc:pt,expected:ct})}if(M[0]instanceof Array&&M.length>1)throw new Error("Parse Error: multiple actions possible at state: "+H+", token: "+_);switch(M[0]){case 1:l.push(_),f.push(S.yytext),h.push(S.yylloc),l.push(M[1]),_=null,ft?(_=ft,ft=null):(Et=S.yyleng,d=S.yytext,rt=S.yylineno,pt=S.yylloc,hi>0);break;case 2:if(V=this.productions_[M[1]][1],G.$=f[f.length-V],G._$={first_line:h[h.length-(V||1)].first_line,last_line:h[h.length-1].last_line,first_column:h[h.length-(V||1)].first_column,last_column:h[h.length-1].last_column},li&&(G._$.range=[h[h.length-(V||1)].range[0],h[h.length-1].range[1]]),yt=this.performAction.apply(G,[d,Et,rt,X.yy,M[1],f,h].concat(ri)),typeof yt<"u")return yt;V&&(l=l.slice(0,-1*V*2),f=f.slice(0,-1*V),h=h.slice(0,-1*V)),l.push(this.productions_[M[1]][0]),f.push(G.$),h.push(G._$),Mt=T[l[l.length-2]][l[l.length-1]],l.push(Mt);break;case 3:return!0}}return!0},"parse")},xt=function(){var P={EOF:1,parseError:n(function(o,l){if(this.yy.parser)this.yy.parser.parseError(o,l);else throw new Error(o)},"parseError"),setInput:n(function(o,l){return this.yy=l||this.yy||{},this._input=o,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:n(function(){var o=this._input[0];this.yytext+=o,this.yyleng++,this.offset++,this.match+=o,this.matched+=o;var l=o.match(/(?:\r\n?|\n).*/g);return l?(this.yylineno++,this.yylloc.last_line++):this.yylloc.last_column++,this.options.ranges&&this.yylloc.range[1]++,this._input=this._input.slice(1),o},"input"),unput:n(function(o){var l=o.length,c=o.split(/(?:\r\n?|\n)/g);this._input=o+this._input,this.yytext=this.yytext.substr(0,this.yytext.length-l),this.offset-=l;var f=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),c.length-1&&(this.yylineno-=c.length-1);var h=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:c?(c.length===f.length?this.yylloc.first_column:0)+f[f.length-c.length].length-c[0].length:this.yylloc.first_column-l},this.options.ranges&&(this.yylloc.range=[h[0],h[0]+this.yyleng-l]),this.yyleng=this.yytext.length,this},"unput"),more:n(function(){return this._more=!0,this},"more"),reject:n(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:n(function(o){this.unput(this.match.slice(o))},"less"),pastInput:n(function(){var o=this.matched.substr(0,this.matched.length-this.match.length);return(o.length>20?"...":"")+o.substr(-20).replace(/\n/g,"")},"pastInput"),upcomingInput:n(function(){var o=this.match;return o.length<20&&(o+=this._input.substr(0,20-o.length)),(o.substr(0,20)+(o.length>20?"...":"")).replace(/\n/g,"")},"upcomingInput"),showPosition:n(function(){var o=this.pastInput(),l=new Array(o.length+1).join("-");return o+this.upcomingInput()+`
5
+ `+l+"^"},"showPosition"),test_match:n(function(o,l){var c,f,h;if(this.options.backtrack_lexer&&(h={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&&(h.yylloc.range=this.yylloc.range.slice(0))),f=o[0].match(/(?:\r\n?|\n).*/g),f&&(this.yylineno+=f.length),this.yylloc={first_line:this.yylloc.last_line,last_line:this.yylineno+1,first_column:this.yylloc.last_column,last_column:f?f[f.length-1].length-f[f.length-1].match(/\r?\n?/)[0].length:this.yylloc.last_column+o[0].length},this.yytext+=o[0],this.match+=o[0],this.matches=o,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(o[0].length),this.matched+=o[0],c=this.performAction.call(this,this.yy,this,l,this.conditionStack[this.conditionStack.length-1]),this.done&&this._input&&(this.done=!1),c)return c;if(this._backtrack){for(var T in h)this[T]=h[T];return!1}return!1},"test_match"),next:n(function(){if(this.done)return this.EOF;this._input||(this.done=!0);var o,l,c,f;this._more||(this.yytext="",this.match="");for(var h=this._currentRules(),T=0;T<h.length;T++)if(c=this._input.match(this.rules[h[T]]),c&&(!l||c[0].length>l[0].length)){if(l=c,f=T,this.options.backtrack_lexer){if(o=this.test_match(c,h[T]),o!==!1)return o;if(this._backtrack){l=!1;continue}else return!1}else if(!this.options.flex)break}return l?(o=this.test_match(l,h[f]),o!==!1?o:!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:n(function(){var o=this.next();return o||this.lex()},"lex"),begin:n(function(o){this.conditionStack.push(o)},"begin"),popState:n(function(){var o=this.conditionStack.length-1;return o>0?this.conditionStack.pop():this.conditionStack[0]},"popState"),_currentRules:n(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:n(function(o){return o=this.conditionStack.length-1-Math.abs(o||0),o>=0?this.conditionStack[o]:"INITIAL"},"topState"),pushState:n(function(o){this.begin(o)},"pushState"),stateStackSize:n(function(){return this.conditionStack.length},"stateStackSize"),options:{"case-insensitive":!0},performAction:n(function(o,l,c,f){switch(c){case 0:break;case 1:break;case 2:return this.popState(),34;case 3:return this.popState(),34;case 4:return 34;case 5:break;case 6:return 10;case 7:return this.pushState("acc_title"),19;case 8:return this.popState(),"acc_title_value";case 9:return this.pushState("acc_descr"),21;case 10:return this.popState(),"acc_descr_value";case 11:this.pushState("acc_descr_multiline");break;case 12:this.popState();break;case 13:return"acc_descr_multiline_value";case 14:return 5;case 15:return 5;case 16:return 8;case 17:return this.pushState("axis_data"),"X_AXIS";case 18:return this.pushState("axis_data"),"Y_AXIS";case 19:return this.pushState("axis_band_data"),24;case 20:return 31;case 21:return this.pushState("data"),16;case 22:return this.pushState("data"),18;case 23:return this.pushState("data_inner"),24;case 24:return 27;case 25:return this.popState(),26;case 26:this.popState();break;case 27:this.pushState("string");break;case 28:this.popState();break;case 29:return"STR";case 30:return 24;case 31:return 26;case 32:return 43;case 33:return"COLON";case 34:return 44;case 35:return 28;case 36:return 45;case 37:return 46;case 38:return 48;case 39:return 50;case 40:return 47;case 41:return 41;case 42:return 49;case 43:return 42;case 44:break;case 45:return 35;case 46:return 36}},"anonymous"),rules:[/^(?:%%(?!\{)[^\n]*)/i,/^(?:[^\}]%%[^\n]*)/i,/^(?:(\r?\n))/i,/^(?:(\r?\n))/i,/^(?:[\n\r]+)/i,/^(?:%%[^\n]*)/i,/^(?:title\b)/i,/^(?:accTitle\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*:\s*)/i,/^(?:(?!\n||)*[^\n]*)/i,/^(?:accDescr\s*\{\s*)/i,/^(?:\})/i,/^(?:[^\}]*)/i,/^(?:xychart-beta\b)/i,/^(?:xychart\b)/i,/^(?:(?:vertical|horizontal))/i,/^(?:x-axis\b)/i,/^(?:y-axis\b)/i,/^(?:\[)/i,/^(?:-->)/i,/^(?:line\b)/i,/^(?:bar\b)/i,/^(?:\[)/i,/^(?:[+-]?(?:\d+(?:\.\d+)?|\.\d+))/i,/^(?:\])/i,/^(?:(?:`\) \{ this\.pushState\(md_string\); \}\n<md_string>\(\?:\(\?!`"\)\.\)\+ \{ return MD_STR; \}\n<md_string>\(\?:`))/i,/^(?:["])/i,/^(?:["])/i,/^(?:[^"]*)/i,/^(?:\[)/i,/^(?:\])/i,/^(?:[A-Za-z]+)/i,/^(?::)/i,/^(?:\+)/i,/^(?:,)/i,/^(?:=)/i,/^(?:\*)/i,/^(?:#)/i,/^(?:[\_])/i,/^(?:\.)/i,/^(?:&)/i,/^(?:-)/i,/^(?:[0-9]+)/i,/^(?:\s+)/i,/^(?:;)/i,/^(?:$)/i],conditions:{data_inner:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,24,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},data:{rules:[0,1,3,4,5,6,7,9,11,14,15,16,17,18,21,22,23,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_band_data:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,25,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},axis_data:{rules:[0,1,2,4,5,6,7,9,11,14,15,16,17,18,19,20,21,22,24,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0},acc_descr_multiline:{rules:[12,13],inclusive:!1},acc_descr:{rules:[10],inclusive:!1},acc_title:{rules:[8],inclusive:!1},title:{rules:[],inclusive:!1},md_string:{rules:[],inclusive:!1},string:{rules:[28,29],inclusive:!1},INITIAL:{rules:[0,1,4,5,6,7,9,11,14,15,16,17,18,21,22,26,27,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46],inclusive:!0}}};return P}();k.lexer=xt;function F(){this.yy={}}return n(F,"Parser"),F.prototype=k,k.Parser=F,new F}();bt.parser=bt;var ki=bt;function At(s){return s.type==="bar"}n(At,"isBarPlot");function St(s){return s.type==="band"}n(St,"isBandAxisData");function j(s){return s.type==="linear"}n(j,"isLinearAxisData");var Q,Yt=(Q=class{constructor(t){this.parentGroup=t}getMaxDimension(t,i){if(!this.parentGroup)return{width:t.reduce((g,u)=>Math.max(u.length,g),0)*i,height:i};let e={width:0,height:0},a=this.parentGroup.append("g").attr("visibility","hidden").attr("font-size",i);for(let g of t){let u=Ci(a,1,g),m=u?u.width:g.length*i,b=u?u.height:i;e.width=Math.max(e.width,m),e.height=Math.max(e.height,b)}return a.remove(),e}},n(Q,"TextDimensionCalculatorWithFont"),Q),Z,Ft=(Z=class{constructor(t,i,e,a){this.axisConfig=t,this.title=i,this.textDimensionCalculator=e,this.axisThemeConfig=a,this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left",this.showTitle=!1,this.showLabel=!1,this.showTick=!1,this.showAxisLine=!1,this.outerPadding=0,this.titleTextHeight=0,this.labelTextHeight=0,this.range=[0,10],this.boundingRect={x:0,y:0,width:0,height:0},this.axisPosition="left"}setRange(t){this.range=t,this.axisPosition==="left"||this.axisPosition==="right"?this.boundingRect.height=t[1]-t[0]:this.boundingRect.width=t[1]-t[0],this.recalculateScale()}getRange(){return[this.range[0]+this.outerPadding,this.range[1]-this.outerPadding]}setAxisPosition(t){this.axisPosition=t,this.setRange(this.range)}getTickDistance(){let t=this.getRange();return Math.abs(t[0]-t[1])/this.getTickValues().length}getAxisOuterPadding(){return this.outerPadding}getLabelDimension(){return this.textDimensionCalculator.getMaxDimension(this.getTickValues().map(t=>t.toString()),this.axisConfig.labelFontSize)}recalculateOuterPaddingToDrawBar(){.7*this.getTickDistance()>this.outerPadding*2&&(this.outerPadding=Math.floor(.7*this.getTickDistance()/2)),this.recalculateScale()}calculateSpaceIfDrawnHorizontally(t){let i=t.height;if(this.axisConfig.showAxisLine&&i>this.axisConfig.axisLineWidth&&(i-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){let e=this.getLabelDimension(),a=.2*t.width;this.outerPadding=Math.min(e.width/2,a);let g=e.height+this.axisConfig.labelPadding*2;this.labelTextHeight=e.height,g<=i&&(i-=g,this.showLabel=!0)}if(this.axisConfig.showTick&&i>=this.axisConfig.tickLength&&(this.showTick=!0,i-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){let e=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),a=e.height+this.axisConfig.titlePadding*2;this.titleTextHeight=e.height,a<=i&&(i-=a,this.showTitle=!0)}this.boundingRect.width=t.width,this.boundingRect.height=t.height-i}calculateSpaceIfDrawnVertical(t){let i=t.width;if(this.axisConfig.showAxisLine&&i>this.axisConfig.axisLineWidth&&(i-=this.axisConfig.axisLineWidth,this.showAxisLine=!0),this.axisConfig.showLabel){let e=this.getLabelDimension(),a=.2*t.height;this.outerPadding=Math.min(e.height/2,a);let g=e.width+this.axisConfig.labelPadding*2;g<=i&&(i-=g,this.showLabel=!0)}if(this.axisConfig.showTick&&i>=this.axisConfig.tickLength&&(this.showTick=!0,i-=this.axisConfig.tickLength),this.axisConfig.showTitle&&this.title){let e=this.textDimensionCalculator.getMaxDimension([this.title],this.axisConfig.titleFontSize),a=e.height+this.axisConfig.titlePadding*2;this.titleTextHeight=e.height,a<=i&&(i-=a,this.showTitle=!0)}this.boundingRect.width=t.width-i,this.boundingRect.height=t.height}calculateSpace(t){return this.axisPosition==="left"||this.axisPosition==="right"?this.calculateSpaceIfDrawnVertical(t):this.calculateSpaceIfDrawnHorizontally(t),this.recalculateScale(),{width:this.boundingRect.width,height:this.boundingRect.height}}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}getDrawableElementsForLeftAxis(){let t=[];if(this.showAxisLine){let i=this.boundingRect.x+this.boundingRect.width-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["left-axis","axisl-line"],data:[{path:`M ${i},${this.boundingRect.y} L ${i},${this.boundingRect.y+this.boundingRect.height} `,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["left-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.boundingRect.x+this.boundingRect.width-(this.showLabel?this.axisConfig.labelPadding:0)-(this.showTick?this.axisConfig.tickLength:0)-(this.showAxisLine?this.axisConfig.axisLineWidth:0),y:this.getScaleValue(i),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"middle",horizontalPos:"right"}))}),this.showTick){let i=this.boundingRect.x+this.boundingRect.width-(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["left-axis","ticks"],data:this.getTickValues().map(e=>({path:`M ${i},${this.getScaleValue(e)} L ${i-this.axisConfig.tickLength},${this.getScaleValue(e)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["left-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.axisConfig.titlePadding,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:270,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForBottomAxis(){let t=[];if(this.showAxisLine){let i=this.boundingRect.y+this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["bottom-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${i} L ${this.boundingRect.x+this.boundingRect.width},${i}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["bottom-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.getScaleValue(i),y:this.boundingRect.y+this.axisConfig.labelPadding+(this.showTick?this.axisConfig.tickLength:0)+(this.showAxisLine?this.axisConfig.axisLineWidth:0),fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){let i=this.boundingRect.y+(this.showAxisLine?this.axisConfig.axisLineWidth:0);t.push({type:"path",groupTexts:["bottom-axis","ticks"],data:this.getTickValues().map(e=>({path:`M ${this.getScaleValue(e)},${i} L ${this.getScaleValue(e)},${i+this.axisConfig.tickLength}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["bottom-axis","title"],data:[{text:this.title,x:this.range[0]+(this.range[1]-this.range[0])/2,y:this.boundingRect.y+this.boundingRect.height-this.axisConfig.titlePadding-this.titleTextHeight,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElementsForTopAxis(){let t=[];if(this.showAxisLine){let i=this.boundingRect.y+this.boundingRect.height-this.axisConfig.axisLineWidth/2;t.push({type:"path",groupTexts:["top-axis","axis-line"],data:[{path:`M ${this.boundingRect.x},${i} L ${this.boundingRect.x+this.boundingRect.width},${i}`,strokeFill:this.axisThemeConfig.axisLineColor,strokeWidth:this.axisConfig.axisLineWidth}]})}if(this.showLabel&&t.push({type:"text",groupTexts:["top-axis","label"],data:this.getTickValues().map(i=>({text:i.toString(),x:this.getScaleValue(i),y:this.boundingRect.y+(this.showTitle?this.titleTextHeight+this.axisConfig.titlePadding*2:0)+this.axisConfig.labelPadding,fill:this.axisThemeConfig.labelColor,fontSize:this.axisConfig.labelFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}))}),this.showTick){let i=this.boundingRect.y;t.push({type:"path",groupTexts:["top-axis","ticks"],data:this.getTickValues().map(e=>({path:`M ${this.getScaleValue(e)},${i+this.boundingRect.height-(this.showAxisLine?this.axisConfig.axisLineWidth:0)} L ${this.getScaleValue(e)},${i+this.boundingRect.height-this.axisConfig.tickLength-(this.showAxisLine?this.axisConfig.axisLineWidth:0)}`,strokeFill:this.axisThemeConfig.tickColor,strokeWidth:this.axisConfig.tickWidth}))})}return this.showTitle&&t.push({type:"text",groupTexts:["top-axis","title"],data:[{text:this.title,x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.axisConfig.titlePadding,fill:this.axisThemeConfig.titleColor,fontSize:this.axisConfig.titleFontSize,rotation:0,verticalPos:"top",horizontalPos:"center"}]}),t}getDrawableElements(){if(this.axisPosition==="left")return this.getDrawableElementsForLeftAxis();if(this.axisPosition==="right")throw Error("Drawing of right axis is not implemented");return this.axisPosition==="bottom"?this.getDrawableElementsForBottomAxis():this.axisPosition==="top"?this.getDrawableElementsForTopAxis():[]}},n(Z,"BaseAxis"),Z),K,Si=(K=class extends Ft{constructor(t,i,e,a,g){super(t,a,g,i),this.categories=e,this.scale=Bt().domain(this.categories).range(this.getRange())}setRange(t){super.setRange(t)}recalculateScale(){this.scale=Bt().domain(this.categories).range(this.getRange()).paddingInner(1).paddingOuter(0).align(.5),Nt.trace("BandAxis axis final categories, range: ",this.categories,this.getRange())}getTickValues(){return this.categories}getScaleValue(t){return this.scale(t)??this.getRange()[0]}},n(K,"BandAxis"),K),J,_i=(J=class extends Ft{constructor(t,i,e,a,g){super(t,a,g,i),this.domain=e,this.scale=zt().domain(this.domain).range(this.getRange())}getTickValues(){return this.scale.ticks()}recalculateScale(){let t=[...this.domain];this.axisPosition==="left"&&t.reverse(),this.scale=zt().domain(t).range(this.getRange())}getScaleValue(t){return this.scale(t)}},n(J,"LinearAxis"),J);function wt(s,t,i,e){let a=new Yt(e);return St(s)?new Si(t,i,s.categories,s.title,a):new _i(t,i,[s.min,s.max],s.title,a)}n(wt,"getAxis");var q,Ti=(q=class{constructor(t,i,e,a){this.textDimensionCalculator=t,this.chartConfig=i,this.chartData=e,this.chartThemeConfig=a,this.boundingRect={x:0,y:0,width:0,height:0},this.showChartTitle=!1}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){let i=this.textDimensionCalculator.getMaxDimension([this.chartData.title],this.chartConfig.titleFontSize),e=Math.max(i.width,t.width),a=i.height+2*this.chartConfig.titlePadding;return i.width<=e&&i.height<=a&&this.chartConfig.showTitle&&this.chartData.title&&(this.boundingRect.width=e,this.boundingRect.height=a,this.showChartTitle=!0),{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){let t=[];return this.showChartTitle&&t.push({groupTexts:["chart-title"],type:"text",data:[{fontSize:this.chartConfig.titleFontSize,text:this.chartData.title,verticalPos:"middle",horizontalPos:"center",x:this.boundingRect.x+this.boundingRect.width/2,y:this.boundingRect.y+this.boundingRect.height/2,fill:this.chartThemeConfig.titleColor,rotation:0}]}),t}},n(q,"ChartTitle"),q);function Xt(s,t,i,e){let a=new Yt(e);return new Ti(a,s,t,i)}n(Xt,"getChartTitleComponent");var tt,Ri=(tt=class{constructor(t,i,e,a,g){this.plotData=t,this.xAxis=i,this.yAxis=e,this.orientation=a,this.plotIndex=g}getDrawableElement(){let t=this.plotData.data.map(e=>[this.xAxis.getScaleValue(e[0]),this.yAxis.getScaleValue(e[1])]),i;return this.orientation==="horizontal"?i=Ot().y(e=>e[0]).x(e=>e[1])(t):i=Ot().x(e=>e[0]).y(e=>e[1])(t),i?[{groupTexts:["plot",`line-plot-${this.plotIndex}`],type:"path",data:[{path:i,strokeFill:this.plotData.strokeFill,strokeWidth:this.plotData.strokeWidth}]}]:[]}},n(tt,"LinePlot"),tt),it,Di=(it=class{constructor(t,i,e,a,g,u){this.barData=t,this.boundingRect=i,this.xAxis=e,this.yAxis=a,this.orientation=g,this.plotIndex=u}getDrawableElement(){let t=this.barData.data.map(a=>[this.xAxis.getScaleValue(a[0]),this.yAxis.getScaleValue(a[1])]),i=Math.min(this.xAxis.getAxisOuterPadding()*2,this.xAxis.getTickDistance())*(1-.05),e=i/2;return this.orientation==="horizontal"?[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(a=>({x:this.boundingRect.x,y:a[0]-e,height:i,width:a[1]-this.boundingRect.x,fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]:[{groupTexts:["plot",`bar-plot-${this.plotIndex}`],type:"rect",data:t.map(a=>({x:a[0]-e,y:a[1],width:i,height:this.boundingRect.y+this.boundingRect.height-a[1],fill:this.barData.fill,strokeWidth:0,strokeFill:this.barData.fill}))}]}},n(it,"BarPlot"),it),et,Li=(et=class{constructor(t,i,e){this.chartConfig=t,this.chartData=i,this.chartThemeConfig=e,this.boundingRect={x:0,y:0,width:0,height:0}}setAxes(t,i){this.xAxis=t,this.yAxis=i}setBoundingBoxXY(t){this.boundingRect.x=t.x,this.boundingRect.y=t.y}calculateSpace(t){return this.boundingRect.width=t.width,this.boundingRect.height=t.height,{width:this.boundingRect.width,height:this.boundingRect.height}}getDrawableElements(){if(!(this.xAxis&&this.yAxis))throw Error("Axes must be passed to render Plots");let t=[];for(let[i,e]of this.chartData.plots.entries())switch(e.type){case"line":{let a=new Ri(e,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);t.push(...a.getDrawableElement())}break;case"bar":{let a=new Di(e,this.boundingRect,this.xAxis,this.yAxis,this.chartConfig.chartOrientation,i);t.push(...a.getDrawableElement())}break}return t}},n(et,"BasePlot"),et);function Ht(s,t,i){return new Li(s,t,i)}n(Ht,"getPlotComponent");var st,Pi=(st=class{constructor(t,i,e,a){this.chartConfig=t,this.chartData=i,this.componentStore={title:Xt(t,i,e,a),plot:Ht(t,i,e),xAxis:wt(i.xAxis,t.xAxis,{titleColor:e.xAxisTitleColor,labelColor:e.xAxisLabelColor,tickColor:e.xAxisTickColor,axisLineColor:e.xAxisLineColor},a),yAxis:wt(i.yAxis,t.yAxis,{titleColor:e.yAxisTitleColor,labelColor:e.yAxisLabelColor,tickColor:e.yAxisTickColor,axisLineColor:e.yAxisLineColor},a)}}calculateVerticalSpace(){let t=this.chartConfig.width,i=this.chartConfig.height,e=0,a=0,g=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),u=Math.floor(i*this.chartConfig.plotReservedSpacePercent/100),m=this.componentStore.plot.calculateSpace({width:g,height:u});t-=m.width,i-=m.height,m=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:i}),a=m.height,i-=m.height,this.componentStore.xAxis.setAxisPosition("bottom"),m=this.componentStore.xAxis.calculateSpace({width:t,height:i}),i-=m.height,this.componentStore.yAxis.setAxisPosition("left"),m=this.componentStore.yAxis.calculateSpace({width:t,height:i}),e=m.width,t-=m.width,t>0&&(g+=t,t=0),i>0&&(u+=i,i=0),this.componentStore.plot.calculateSpace({width:g,height:u}),this.componentStore.plot.setBoundingBoxXY({x:e,y:a}),this.componentStore.xAxis.setRange([e,e+g]),this.componentStore.xAxis.setBoundingBoxXY({x:e,y:a+u}),this.componentStore.yAxis.setRange([a,a+u]),this.componentStore.yAxis.setBoundingBoxXY({x:0,y:a}),this.chartData.plots.some(b=>At(b))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateHorizontalSpace(){let t=this.chartConfig.width,i=this.chartConfig.height,e=0,a=0,g=0,u=Math.floor(t*this.chartConfig.plotReservedSpacePercent/100),m=Math.floor(i*this.chartConfig.plotReservedSpacePercent/100),b=this.componentStore.plot.calculateSpace({width:u,height:m});t-=b.width,i-=b.height,b=this.componentStore.title.calculateSpace({width:this.chartConfig.width,height:i}),e=b.height,i-=b.height,this.componentStore.xAxis.setAxisPosition("left"),b=this.componentStore.xAxis.calculateSpace({width:t,height:i}),t-=b.width,a=b.width,this.componentStore.yAxis.setAxisPosition("top"),b=this.componentStore.yAxis.calculateSpace({width:t,height:i}),i-=b.height,g=e+b.height,t>0&&(u+=t,t=0),i>0&&(m+=i,i=0),this.componentStore.plot.calculateSpace({width:u,height:m}),this.componentStore.plot.setBoundingBoxXY({x:a,y:g}),this.componentStore.yAxis.setRange([a,a+u]),this.componentStore.yAxis.setBoundingBoxXY({x:a,y:e}),this.componentStore.xAxis.setRange([g,g+m]),this.componentStore.xAxis.setBoundingBoxXY({x:0,y:g}),this.chartData.plots.some(E=>At(E))&&this.componentStore.xAxis.recalculateOuterPaddingToDrawBar()}calculateSpace(){this.chartConfig.chartOrientation==="horizontal"?this.calculateHorizontalSpace():this.calculateVerticalSpace()}getDrawableElement(){this.calculateSpace();let t=[];this.componentStore.plot.setAxes(this.componentStore.xAxis,this.componentStore.yAxis);for(let i of Object.values(this.componentStore))t.push(...i.getDrawableElements());return t}},n(st,"Orchestrator"),st),at,vi=(at=class{static build(t,i,e,a){return new Pi(t,i,e,a).getDrawableElement()}},n(at,"XYChartBuilder"),at),nt=0,Ut,ht=Rt(),ot=Tt(),y=Dt(),Ct=ot.plotColorPalette.split(",").map(s=>s.trim()),gt=!1,_t=!1;function Tt(){let s=wi(),t=kt();return Vt(s.xyChart,t.themeVariables.xyChart)}n(Tt,"getChartDefaultThemeConfig");function Rt(){let s=kt();return Vt(Ai.xyChart,s.xyChart)}n(Rt,"getChartDefaultConfig");function Dt(){return{yAxis:{type:"linear",title:"",min:1/0,max:-1/0},xAxis:{type:"band",title:"",categories:[]},title:"",plots:[]}}n(Dt,"getChartDefaultData");function ut(s){let t=kt();return bi(s.trim(),t)}n(ut,"textSanitizer");function Gt(s){Ut=s}n(Gt,"setTmpSVGG");function jt(s){s==="horizontal"?ht.chartOrientation="horizontal":ht.chartOrientation="vertical"}n(jt,"setOrientation");function Qt(s){y.xAxis.title=ut(s.text)}n(Qt,"setXAxisTitle");function Lt(s,t){y.xAxis={type:"linear",title:y.xAxis.title,min:s,max:t},gt=!0}n(Lt,"setXAxisRangeData");function Zt(s){y.xAxis={type:"band",title:y.xAxis.title,categories:s.map(t=>ut(t.text))},gt=!0}n(Zt,"setXAxisBand");function Kt(s){y.yAxis.title=ut(s.text)}n(Kt,"setYAxisTitle");function Jt(s,t){y.yAxis={type:"linear",title:y.yAxis.title,min:s,max:t},_t=!0}n(Jt,"setYAxisRangeData");function qt(s){let t=Math.min(...s),i=Math.max(...s),e=j(y.yAxis)?y.yAxis.min:1/0,a=j(y.yAxis)?y.yAxis.max:-1/0;y.yAxis={type:"linear",title:y.yAxis.title,min:Math.min(e,t),max:Math.max(a,i)}}n(qt,"setYAxisRangeFromPlotData");function Pt(s){let t=[];if(s.length===0)return t;if(!gt){let i=j(y.xAxis)?y.xAxis.min:1/0,e=j(y.xAxis)?y.xAxis.max:-1/0;Lt(Math.min(i,1),Math.max(e,s.length))}if(_t||qt(s),St(y.xAxis)&&(t=y.xAxis.categories.map((i,e)=>[i,s[e]])),j(y.xAxis)){let i=y.xAxis.min,e=y.xAxis.max,a=(e-i)/(s.length-1),g=[];for(let u=i;u<=e;u+=a)g.push(`${u}`);t=g.map((u,m)=>[u,s[m]])}return t}n(Pt,"transformDataWithoutCategory");function vt(s){return Ct[s===0?0:s%Ct.length]}n(vt,"getPlotColorFromPalette");function ti(s,t){let i=Pt(t);y.plots.push({type:"line",strokeFill:vt(nt),strokeWidth:2,data:i}),nt++}n(ti,"setLineData");function ii(s,t){let i=Pt(t);y.plots.push({type:"bar",fill:vt(nt),data:i}),nt++}n(ii,"setBarData");function ei(){if(y.plots.length===0)throw Error("No Plot to render, please provide a plot with some data");return y.title=Wt(),vi.build(ht,y,ot,Ut)}n(ei,"getDrawableElem");function si(){return ot}n(si,"getChartThemeConfig");function ai(){return ht}n(ai,"getChartConfig");function ni(){return y}n(ni,"getXYChartData");var Ei=n(function(){mi(),nt=0,ht=Rt(),y=Dt(),ot=Tt(),Ct=ot.plotColorPalette.split(",").map(s=>s.trim()),gt=!1,_t=!1},"clear"),$i={getDrawableElem:ei,clear:Ei,setAccTitle:pi,getAccTitle:di,setDiagramTitle:xi,getDiagramTitle:Wt,getAccDescription:ui,setAccDescription:gi,setOrientation:jt,setXAxisTitle:Qt,setXAxisRangeData:Lt,setXAxisBand:Zt,setYAxisTitle:Kt,setYAxisRangeData:Jt,setLineData:ti,setBarData:ii,setTmpSVGG:Gt,getChartThemeConfig:si,getChartConfig:ai,getXYChartData:ni},Ii=n((s,t,i,e)=>{let a=e.db,g=a.getChartThemeConfig(),u=a.getChartConfig(),m=a.getXYChartData().plots[0].data.map(p=>p[1]);function b(p){return p==="top"?"text-before-edge":"middle"}n(b,"getDominantBaseLine");function E(p){return p==="left"?"start":p==="right"?"end":"middle"}n(E,"getTextAnchor");function B(p){return`translate(${p.x}, ${p.y}) rotate(${p.rotation||0})`}n(B,"getTextTransformation"),Nt.debug(`Rendering xychart chart
7
+ `+s);let R=fi(t),$=R.append("g").attr("class","main"),W=$.append("rect").attr("width",u.width).attr("height",u.height).attr("class","background");yi(R,u.height,u.width,!0),R.attr("viewBox",`0 0 ${u.width} ${u.height}`),W.attr("fill",g.backgroundColor),a.setTmpSVGG(R.append("g").attr("class","mermaid-tmp-group"));let N=a.getDrawableElem(),D={};function z(p){let C=$,r="";for(let[I]of p.entries()){let O=$;I>0&&D[r]&&(O=D[r]),r+=p[I],C=D[r],C||(C=D[r]=O.append("g").attr("class",p[I]))}return C}n(z,"getGroup");for(let p of N){if(p.data.length===0)continue;let C=z(p.groupTexts);switch(p.type){case"rect":if(C.selectAll("rect").data(p.data).enter().append("rect").attr("x",r=>r.x).attr("y",r=>r.y).attr("width",r=>r.width).attr("height",r=>r.height).attr("fill",r=>r.fill).attr("stroke",r=>r.strokeFill).attr("stroke-width",r=>r.strokeWidth),u.showDataLabel){let r=u.showDataLabelOutsideBar;if(u.chartOrientation==="horizontal"){let I=function(x,w){let{data:L,label:k}=x;return w*k.length*.7<=L.width-10};n(I,"fitsHorizontally");let O=p.data.map((x,w)=>({data:x,label:m[w].toString()})).filter(x=>x.data.width>0&&x.data.height>0),U=O.map(x=>{let{data:w}=x,L=w.height*.7;for(;!I(x,L)&&L>0;)L-=1;return L}),Y=Math.floor(Math.min(...U)),A=n(x=>r?x.data.x+x.data.width+10:x.data.x+x.data.width-10,"determineLabelXPosition");C.selectAll("text").data(O).enter().append("text").attr("x",A).attr("y",x=>x.data.y+x.data.height/2).attr("text-anchor",r?"start":"end").attr("dominant-baseline","middle").attr("fill",g.dataLabelColor).attr("font-size",`${Y}px`).text(x=>x.label)}else{let I=function(x,w,L){let{data:k,label:xt}=x,F=w*xt.length*.7,P=k.x+k.width/2,o=P-F/2,l=P+F/2,c=o>=k.x&&l<=k.x+k.width,f=k.y+L+w<=k.y+k.height;return c&&f};n(I,"fitsInBar");let O=p.data.map((x,w)=>({data:x,label:m[w].toString()})).filter(x=>x.data.width>0&&x.data.height>0),U=O.map(x=>{let{data:w,label:L}=x,k=w.width/(L.length*.7);for(;!I(x,k,10)&&k>0;)k-=1;return k}),Y=Math.floor(Math.min(...U)),A=n(x=>r?x.data.y-10:x.data.y+10,"determineLabelYPosition");C.selectAll("text").data(O).enter().append("text").attr("x",x=>x.data.x+x.data.width/2).attr("y",A).attr("text-anchor","middle").attr("dominant-baseline",r?"auto":"hanging").attr("fill",g.dataLabelColor).attr("font-size",`${Y}px`).text(x=>x.label)}}break;case"text":C.selectAll("text").data(p.data).enter().append("text").attr("x",0).attr("y",0).attr("fill",r=>r.fill).attr("font-size",r=>r.fontSize).attr("dominant-baseline",r=>b(r.verticalPos)).attr("text-anchor",r=>E(r.horizontalPos)).attr("transform",r=>B(r)).text(r=>r.text);break;case"path":C.selectAll("path").data(p.data).enter().append("path").attr("d",r=>r.path).attr("fill",r=>r.fill?r.fill:"none").attr("stroke",r=>r.strokeFill).attr("stroke-width",r=>r.strokeWidth);break}}},"draw"),Mi={draw:Ii},Oi={parser:ki,db:$i,renderer:Mi};export{Oi as diagram};
Binary file
Binary file
Binary file
@@ -0,0 +1,36 @@
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>CodraGraph</title>
7
+ <link rel="icon" type="image/png" sizes="256x256" href="/favicon.png" />
8
+ <link rel="apple-touch-icon" href="/codragraph-logo-512.png" />
9
+ <meta name="theme-color" content="#06060a" />
10
+ <link rel="preconnect" href="https://fonts.googleapis.com" />
11
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
12
+ <link
13
+ href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap"
14
+ rel="stylesheet"
15
+ />
16
+ <!-- Theme bootstrap: applies the saved theme before React paints to
17
+ avoid a flash. Reads localStorage 'codragraph-theme' (light|dark);
18
+ defaults to dark to match the existing brand palette. -->
19
+ <script>
20
+ (function () {
21
+ try {
22
+ var saved = localStorage.getItem('codragraph-theme');
23
+ var theme = saved === 'light' || saved === 'dark' ? saved : 'dark';
24
+ if (theme === 'dark') document.documentElement.classList.add('dark');
25
+ } catch (e) {
26
+ document.documentElement.classList.add('dark');
27
+ }
28
+ })();
29
+ </script>
30
+ <script type="module" crossorigin src="/assets/index-BgeqpYgd.js"></script>
31
+ <link rel="stylesheet" crossorigin href="/assets/index-CT0GtFLZ.css">
32
+ </head>
33
+ <body>
34
+ <div id="root"></div>
35
+ </body>
36
+ </html>
@@ -124,7 +124,7 @@ function extractPattern(toolName, toolInput) {
124
124
  * Resolve the codragraph CLI path.
125
125
  * 1. Relative path (works when script is inside npm package)
126
126
  * 2. require.resolve (works when codragraph is globally installed)
127
- * 3. Fall back to npx (returns empty string)
127
+ * 3. Fall back to a package runner (returns empty string)
128
128
  */
129
129
  function resolveCliPath() {
130
130
  let cliPath = path.resolve(__dirname, '..', '..', 'dist', 'cli', 'index.js');
@@ -138,6 +138,18 @@ function resolveCliPath() {
138
138
  return cliPath;
139
139
  }
140
140
 
141
+ function isRunningUnderBun() {
142
+ const userAgent = (process.env.npm_config_user_agent || '').toLowerCase();
143
+ const execBase = path.basename(process.env.npm_execpath || '').toLowerCase();
144
+ return userAgent.startsWith('bun/') || execBase === 'bun' || execBase === 'bun.exe';
145
+ }
146
+
147
+ function getPackageRunnerArgs(args) {
148
+ const useBun = isRunningUnderBun();
149
+ if (useBun) return { bin: 'bunx', args: ['@codragraph/cli', ...args] };
150
+ return { bin: 'npx', args: ['-y', '@codragraph/cli', ...args] };
151
+ }
152
+
141
153
  /**
142
154
  * Spawn a codragraph CLI command synchronously.
143
155
  * Returns the stderr output (KuzuDB captures stdout at OS level).
@@ -152,18 +164,18 @@ function runCodraGraphCli(cliPath, args, cwd, timeout) {
152
164
  stdio: ['pipe', 'pipe', 'pipe'],
153
165
  });
154
166
  }
155
- // npx fallback: on Windows, Node 22's spawn refuses to launch `npx.cmd`
156
- // directly (returns EINVAL), so route through `cmd /c` and let PATHEXT
157
- // resolve the shim. POSIX direct-spawn is fine.
167
+ // Package-runner fallback: on Windows, Node 22's spawn refuses to launch
168
+ // `.cmd` shims directly, so route through `cmd /c`. POSIX direct-spawn is fine.
169
+ const runner = getPackageRunnerArgs(args);
158
170
  if (isWin) {
159
- return spawnSync('cmd', ['/c', 'npx', '-y', '@codragraph/cli', ...args], {
171
+ return spawnSync('cmd', ['/c', runner.bin, ...runner.args], {
160
172
  encoding: 'utf-8',
161
173
  timeout: timeout + 5000,
162
174
  cwd,
163
175
  stdio: ['pipe', 'pipe', 'pipe'],
164
176
  });
165
177
  }
166
- return spawnSync('npx', ['-y', '@codragraph/cli', ...args], {
178
+ return spawnSync(runner.bin, runner.args, {
167
179
  encoding: 'utf-8',
168
180
  timeout: timeout + 5000,
169
181
  cwd,
@@ -268,7 +280,8 @@ function handlePostToolUse(input) {
268
280
  // If HEAD matches last indexed commit, no reindex needed
269
281
  if (currentHead && currentHead === lastCommit) return;
270
282
 
271
- const analyzeCmd = `npx @codragraph/cli analyze${hadEmbeddings ? ' --embeddings' : ''}`;
283
+ const analyzeArgs = `analyze${hadEmbeddings ? ' --embeddings' : ''}`;
284
+ const analyzeCmd = `npx @codragraph/cli ${analyzeArgs} (or bunx @codragraph/cli ${analyzeArgs})`;
272
285
 
273
286
  // Opt-in background auto-reindex.
274
287
  // Default stays as notification-only because spawning analyze while an MCP
@@ -316,9 +329,11 @@ function handlePostToolUse(input) {
316
329
  if (cliPath) {
317
330
  child = spawn(process.execPath, [cliPath, ...reindexArgs], spawnOpts);
318
331
  } else if (process.platform === 'win32') {
319
- child = spawn('cmd', ['/c', 'npx', '-y', '@codragraph/cli', ...reindexArgs], spawnOpts);
332
+ const runner = getPackageRunnerArgs(reindexArgs);
333
+ child = spawn('cmd', ['/c', runner.bin, ...runner.args], spawnOpts);
320
334
  } else {
321
- child = spawn('npx', ['-y', '@codragraph/cli', ...reindexArgs], spawnOpts);
335
+ const runner = getPackageRunnerArgs(reindexArgs);
336
+ child = spawn(runner.bin, runner.args, spawnOpts);
322
337
  }
323
338
  child.unref();
324
339
  } catch {
@@ -64,9 +64,14 @@ fi
64
64
 
65
65
  # Run codragraph augment — must be fast (<500ms target)
66
66
  # augment writes to stderr (KuzuDB captures stdout at OS level), so capture stderr and discard stdout
67
- # Prefer the global bin if present; fall back to npx (npm package is @codragraph/cli, bin is `codragraph`)
67
+ # Prefer the global bin if present; fall back to bunx when the hook is running
68
+ # under Bun, otherwise npx (npm package is @codragraph/cli, bin is `codragraph`).
68
69
  if command -v codragraph >/dev/null 2>&1; then
69
70
  RESULT=$(cd "$CWD" && codragraph augment "$PATTERN" 2>&1 1>/dev/null)
71
+ elif [ "${npm_config_user_agent#bun/}" != "$npm_config_user_agent" ] && command -v bunx >/dev/null 2>&1; then
72
+ RESULT=$(cd "$CWD" && bunx @codragraph/cli augment "$PATTERN" 2>&1 1>/dev/null)
73
+ elif ! command -v npx >/dev/null 2>&1 && command -v bunx >/dev/null 2>&1; then
74
+ RESULT=$(cd "$CWD" && bunx @codragraph/cli augment "$PATTERN" 2>&1 1>/dev/null)
70
75
  else
71
76
  RESULT=$(cd "$CWD" && npx -y @codragraph/cli augment "$PATTERN" 2>&1 1>/dev/null)
72
77
  fi
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@codragraph/cli",
3
- "version": "2.1.0",
3
+ "version": "2.1.4",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": {
6
- "name": "Anit Chaudhary",
7
- "email": "getintouch.anit@gmail.com",
8
- "url": "https://anit.upfyn.com"
6
+ "name": "Thinqmesh Technologies",
7
+ "email": "hello@thinqmesh.com",
8
+ "url": "https://thinqmesh.com"
9
9
  },
10
10
  "license": "Apache-2.0",
11
11
  "keywords": [
@@ -68,6 +68,7 @@
68
68
  "glob": "^13.0.6",
69
69
  "graphology": "^0.26.0",
70
70
  "graphology-indices": "^0.17.0",
71
+ "graphology-types": "^0.24.8",
71
72
  "graphology-utils": "^2.3.0",
72
73
  "ignore": "^7.0.5",
73
74
  "js-yaml": "^4.1.1",
@@ -76,6 +77,7 @@
76
77
  "mnemonist": "^0.40.3",
77
78
  "onnxruntime-node": "^1.24.0",
78
79
  "pandemonium": "^2.4.0",
80
+ "path-scurry": "^2.0.2",
79
81
  "tree-sitter": "^0.21.1",
80
82
  "tree-sitter-c": "0.23.2",
81
83
  "tree-sitter-c-sharp": "0.23.1",
@@ -123,5 +125,14 @@
123
125
  "publishConfig": {
124
126
  "access": "public",
125
127
  "registry": "https://registry.npmjs.org/"
128
+ },
129
+ "homepage": "https://github.com/AnitChaudhry/CodraGraph#readme",
130
+ "repository": {
131
+ "type": "git",
132
+ "url": "git+https://github.com/AnitChaudhry/CodraGraph.git",
133
+ "directory": "packages/core"
134
+ },
135
+ "bugs": {
136
+ "url": "https://github.com/AnitChaudhry/CodraGraph/issues"
126
137
  }
127
138
  }
package/scripts/build.js CHANGED
@@ -1,32 +1,73 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Build script that compiles codragraph and inlines codragraph-shared into the dist.
3
+ * Build script that compiles @codragraph/cli and inlines @codragraph/shared
4
+ * into the published dist.
4
5
  *
5
6
  * Steps:
6
- * 1. Build codragraph-shared (tsc)
7
- * 2. Build codragraph-graphstore (tsc) — codragraph imports it; without
7
+ * 1. Build @codragraph/shared (tsc)
8
+ * 2. Build @codragraph/graphstore (tsc) — @codragraph/cli imports it; without
8
9
  * a populated dist/ here, step 3 fails to resolve types.
9
- * 3. Build codragraph (tsc)
10
- * 4. Copy codragraph-shared/dist → dist/_shared
10
+ * 3. Build @codragraph/cli (tsc)
11
+ * 4. Copy packages/shared/dist → dist/_shared
11
12
  * 5. Rewrite bare '@codragraph/shared' specifiers → relative paths
12
13
  */
13
- import { execSync } from 'node:child_process';
14
+ import { execFileSync } from 'node:child_process';
14
15
  import fs from 'node:fs';
15
16
  import path from 'node:path';
17
+ import { createRequire } from 'node:module';
16
18
  import { fileURLToPath } from 'node:url';
17
19
 
18
20
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
21
+ const require = createRequire(import.meta.url);
19
22
  const ROOT = path.resolve(__dirname, '..');
23
+ const MONOREPO_ROOT = path.resolve(ROOT, '..', '..');
20
24
  // Workspace directory names — packages live under `packages/<short>` on disk
21
25
  // and publish as `@codragraph/<short>` on npm.
22
26
  const SHARED_ROOT = path.resolve(ROOT, '..', 'shared');
23
27
  const GRAPHSTORE_ROOT = path.resolve(ROOT, '..', 'graphstore');
28
+ const WEB_ROOT = path.resolve(MONOREPO_ROOT, 'apps', 'web');
24
29
  const DIST = path.join(ROOT, 'dist');
25
30
  const SHARED_DEST = path.join(DIST, '_shared');
31
+ const WEB_DEST = path.join(DIST, 'web');
32
+ const TSC_BIN = require.resolve('typescript/bin/tsc');
33
+
34
+ function runTsc(cwd) {
35
+ execFileSync(process.execPath, [TSC_BIN], { cwd, stdio: 'inherit' });
36
+ }
37
+
38
+ function isRunningUnderBun() {
39
+ const userAgent = (process.env.npm_config_user_agent || '').toLowerCase();
40
+ const execBase = path.basename(process.env.npm_execpath || '').toLowerCase();
41
+ return userAgent.startsWith('bun/') || execBase === 'bun' || execBase === 'bun.exe';
42
+ }
43
+
44
+ function runPackageScript(cwd, script) {
45
+ const useBun = isRunningUnderBun();
46
+ const command = useBun ? 'bun' : process.platform === 'win32' ? 'cmd' : 'npm';
47
+ const args = useBun
48
+ ? ['run', script]
49
+ : process.platform === 'win32'
50
+ ? ['/c', 'npm', 'run', script]
51
+ : ['run', script];
52
+ execFileSync(command, args, { cwd, stdio: 'inherit' });
53
+ }
54
+
55
+ function getWebBuildSkipReason() {
56
+ if (process.env.CODRAGRAPH_SKIP_WEB_BUILD === '1') {
57
+ return 'CODRAGRAPH_SKIP_WEB_BUILD=1';
58
+ }
59
+ if (
60
+ process.env.npm_lifecycle_event === 'prepare' &&
61
+ fs.existsSync(path.join(WEB_DEST, 'index.html'))
62
+ ) {
63
+ return 'dist/web already exists from the preceding pack build';
64
+ }
65
+ return null;
66
+ }
26
67
 
27
68
  // ── 1. Build @codragraph/shared ──────────────────────────────────────
28
69
  console.log('[build] compiling @codragraph/shared…');
29
- execSync('npx tsc', { cwd: SHARED_ROOT, stdio: 'inherit' });
70
+ runTsc(SHARED_ROOT);
30
71
 
31
72
  // ── 2. Build @codragraph/graphstore ──────────────────────────────────
32
73
  // core depends on this for snapshot/branch/diff types. On a
@@ -35,20 +76,20 @@ execSync('npx tsc', { cwd: SHARED_ROOT, stdio: 'inherit' });
35
76
  // `@codragraph/graphstore` imports. Skip gracefully if the workspace
36
77
  // is not present (e.g. someone pinned an older monorepo layout).
37
78
  if (fs.existsSync(GRAPHSTORE_ROOT)) {
38
- console.log('[build] compiling codragraph-graphstore…');
39
- execSync('npx tsc', { cwd: GRAPHSTORE_ROOT, stdio: 'inherit' });
79
+ console.log('[build] compiling @codragraph/graphstore…');
80
+ runTsc(GRAPHSTORE_ROOT);
40
81
  }
41
82
 
42
- // ── 3. Build codragraph ──────────────────────────────────────────────
43
- console.log('[build] compiling codragraph…');
44
- execSync('npx tsc', { cwd: ROOT, stdio: 'inherit' });
83
+ // ── 3. Build @codragraph/cli ─────────────────────────────────────────
84
+ console.log('[build] compiling @codragraph/cli…');
85
+ runTsc(ROOT);
45
86
 
46
- // ── 3. Copy shared dist ────────────────────────────────────────────
87
+ // ── 4. Copy shared dist ────────────────────────────────────────────
47
88
  console.log('[build] copying shared module into dist/_shared…');
48
89
  fs.cpSync(path.join(SHARED_ROOT, 'dist'), SHARED_DEST, { recursive: true });
49
90
 
50
- // ── 4. Rewrite imports ─────────────────────────────────────────────
51
- console.log('[build] rewriting codragraph-shared imports…');
91
+ // ── 5. Rewrite imports ─────────────────────────────────────────────
92
+ console.log('[build] rewriting @codragraph/shared imports…');
52
93
  let rewritten = 0;
53
94
 
54
95
  function rewriteFile(filePath) {
@@ -82,8 +123,26 @@ function walk(dir, extensions, cb) {
82
123
 
83
124
  walk(DIST, ['.js', '.d.ts'], rewriteFile);
84
125
 
85
- // ── 5. Make CLI entry executable ────────────────────────────────────
126
+ // ── 6. Make CLI entry executable ────────────────────────────────────
86
127
  const cliEntry = path.join(DIST, 'cli', 'index.js');
87
128
  if (fs.existsSync(cliEntry)) fs.chmodSync(cliEntry, 0o755);
88
129
 
130
+ // ── 7. Bundle the web dashboard ─────────────────────────────────────
131
+ // The npm package ships static web assets under dist/web. It never includes
132
+ // apps/web/node_modules; npm only packs files included by packages/core/files.
133
+ const webPackageJson = path.join(WEB_ROOT, 'package.json');
134
+ if (fs.existsSync(webPackageJson)) {
135
+ const skipReason = getWebBuildSkipReason();
136
+ if (skipReason) {
137
+ console.log(`[build] skipping bundled web dashboard (${skipReason}).`);
138
+ } else {
139
+ console.log('[build] compiling bundled web dashboard…');
140
+ runPackageScript(WEB_ROOT, 'build');
141
+ fs.rmSync(WEB_DEST, { recursive: true, force: true });
142
+ fs.cpSync(path.join(WEB_ROOT, 'dist'), WEB_DEST, { recursive: true });
143
+ }
144
+ } else {
145
+ console.log('[build] apps/web not found — skipping bundled web dashboard.');
146
+ }
147
+
89
148
  console.log(`[build] done — rewrote ${rewritten} files.`);
@@ -49,7 +49,6 @@ if (!swiftDir) {
49
49
  const bindingPath = path.join(swiftDir, 'binding.gyp');
50
50
 
51
51
  try {
52
-
53
52
  const content = fs.readFileSync(bindingPath, 'utf8');
54
53
  let needsRebuild = false;
55
54
 
@@ -5,7 +5,7 @@ description: "Use when the user needs to run CodraGraph CLI commands like analyz
5
5
 
6
6
  # CodraGraph CLI Commands
7
7
 
8
- All commands work via `npx` — no global install required.
8
+ All commands work via `npx` or `bunx` — no global install required. The examples are safe in Windows PowerShell, macOS bash/zsh, and Linux shells; prefer `npm --prefix <package> <script>` or `bun run --filter <workspace> <script>` from the repo root when running package-local checks.
9
9
 
10
10
  ## Commands
11
11
 
@@ -32,6 +32,22 @@ npx @codragraph/cli status
32
32
 
33
33
  Shows whether the current repo has a CodraGraph index, when it was last updated, and symbol/relationship counts. Use this to check if re-indexing is needed.
34
34
 
35
+ ### feature-clusters — List product/domain areas
36
+
37
+ ```bash
38
+ npx @codragraph/cli feature-clusters
39
+ ```
40
+
41
+ Shows the human-facing feature clusters CodraGraph detected: areas like Settings, Auth, AI, Billing, or Admin, with member counts and confidence. Use this before asking an agent to work on a product area.
42
+
43
+ ### feature-context — Load one focused context pack
44
+
45
+ ```bash
46
+ npx @codragraph/cli feature-context Settings
47
+ ```
48
+
49
+ Returns the members, file paths, line ranges, dependencies, and flows for one feature cluster so an agent can edit the right files without re-exploring the whole repo.
50
+
35
51
  ### clean — Delete the index
36
52
 
37
53
  ```bash
@@ -37,6 +37,8 @@ For any task involving code understanding, debugging, impact analysis, or refact
37
37
  | `impact` | Symbol blast radius — what breaks at depth 1/2/3 with confidence |
38
38
  | `detect_changes` | Git-diff impact — what do your current changes affect |
39
39
  | `rename` | Multi-file coordinated rename with confidence-tagged edits |
40
+ | `feature_clusters` | Product/domain feature map for targeted context |
41
+ | `feature_context` | Members, line ranges, dependencies, and flows for one feature |
40
42
  | `cypher` | Raw graph queries (read `codragraph://repo/{name}/schema` first) |
41
43
  | `list_repos` | Discover indexed repos |
42
44
 
@@ -48,6 +50,8 @@ Lightweight reads (~100-500 tokens) for navigation:
48
50
  | ---------------------------------------------- | ----------------------------------------- |
49
51
  | `codragraph://repo/{name}/context` | Stats, staleness check |
50
52
  | `codragraph://repo/{name}/clusters` | All functional areas with cohesion scores |
53
+ | `codragraph://repo/{name}/feature-clusters` | Product/domain feature areas |
54
+ | `codragraph://repo/{name}/feature/{featureName}` | Focused files, line ranges, flows, deps |
51
55
  | `codragraph://repo/{name}/cluster/{clusterName}` | Area members |
52
56
  | `codragraph://repo/{name}/processes` | All execution flows |
53
57
  | `codragraph://repo/{name}/process/{processName}` | Step-by-step trace |
@@ -55,8 +59,8 @@ Lightweight reads (~100-500 tokens) for navigation:
55
59
 
56
60
  ## Graph Schema
57
61
 
58
- **Nodes:** File, Function, Class, Interface, Method, Community, Process
59
- **Edges (via CodeRelation.type):** CALLS, IMPORTS, EXTENDS, IMPLEMENTS, DEFINES, MEMBER_OF, STEP_IN_PROCESS
62
+ **Nodes:** File, Function, Class, Interface, Method, Community, Process, FeatureCluster
63
+ **Edges (via CodeRelation.type):** CALLS, IMPORTS, EXTENDS, IMPLEMENTS, DEFINES, MEMBER_OF, STEP_IN_PROCESS, FEATURE_MEMBER_OF, FEATURE_DEPENDS_ON
60
64
 
61
65
  ```cypher
62
66
  MATCH (caller)-[:CodeRelation {type: 'CALLS'}]->(f:Function {name: "myFunc"})
@@ -89,7 +89,7 @@ running through it."
89
89
 
90
90
  3. READ .claude/skills/generated/ingestion/SKILL.md
91
91
  → Entry points: runFullAnalysis, IngestionPipeline.run
92
- → Key files: codragraph/src/core/ingestion/
92
+ → Key files: packages/core/src/core/ingestion/
93
93
 
94
94
  4. READ codragraph://repo/CodraGraph/processes
95
95
  → Top flows: AnalyzeFlow, McpQueryFlow, GraphstoreCommitFlow
@@ -101,7 +101,7 @@ running through it."
101
101
  → orchestrator that takes (repoPath, options, hooks) and runs the pipeline.
102
102
  → Called by: analyzeCommand (CLI), eval-server, augment hook
103
103
 
104
- Tour result: "Start at runFullAnalysis (codragraph/src/core/run-analyze.ts).
104
+ Tour result: "Start at runFullAnalysis (packages/core/src/core/run-analyze.ts).
105
105
  That's the orchestrator. The 12-stage pipeline lives under
106
106
  src/core/ingestion/. Phase 4 graphstore is in src/core/graphstore/."
107
107
  ```