agentic-mermaid 0.4.1 → 0.5.3
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.
- package/AGENT_NATIVE.md +94 -627
- package/CHANGELOG.md +651 -0
- package/Instructions_for_agents.md +44 -23
- package/LICENSES/Khroma-MIT.txt +21 -0
- package/LICENSES/Mermaid-MIT.txt +21 -0
- package/LICENSES/es-toolkit-MIT.txt +21 -0
- package/LICENSES/pele-MIT.txt +40 -0
- package/LICENSES/zenuml-core-MIT.txt +21 -0
- package/README.md +93 -50
- package/SECURITY.md +28 -12
- package/THIRD_PARTY_NOTICES.md +60 -0
- package/assets/hero.png +0 -0
- package/dist/agent-core.d.ts +478 -210
- package/dist/agent-core.js +1 -396
- package/dist/agent.d.ts +17 -8
- package/dist/agent.js +1 -408
- package/dist/agentic-mermaid-mcp.js +1 -11
- package/dist/am.js +1 -34562
- package/dist/browser-lazy/chunks/agentic-producer-core-CC6OOLDW.js +1 -0
- package/dist/browser-lazy/chunks/architecture-QUFVKYJR.js +13 -0
- package/dist/browser-lazy/chunks/block-6J3Q63BO.js +11 -0
- package/dist/browser-lazy/chunks/builtin-backends-7SOZZHPF.js +12 -0
- package/dist/browser-lazy/chunks/c4-SQVBZAKJ.js +10 -0
- package/dist/browser-lazy/chunks/chunk-2GPK4VFF.js +5 -0
- package/dist/browser-lazy/chunks/chunk-2I4UPL7Q.js +3 -0
- package/dist/browser-lazy/chunks/chunk-2SH76OTH.js +1 -0
- package/dist/browser-lazy/chunks/chunk-2UIA2IME.js +3 -0
- package/dist/browser-lazy/chunks/chunk-4LHYF3BS.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5B2Z7575.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5FQ534HP.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5UVGUSD6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-5X6MJX3H.js +1 -0
- package/dist/browser-lazy/chunks/chunk-AMJLVPUB.js +4 -0
- package/dist/browser-lazy/chunks/chunk-BU5LHXNJ.js +3 -0
- package/dist/browser-lazy/chunks/chunk-BY2CPG6B.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CN7WTBWB.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CQE4HQEW.js +1 -0
- package/dist/browser-lazy/chunks/chunk-CSFUKSU6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-DF6765YX.js +17 -0
- package/dist/browser-lazy/chunks/chunk-E2WMJZNM.js +1 -0
- package/dist/browser-lazy/chunks/chunk-FAIMVOX5.js +6 -0
- package/dist/browser-lazy/chunks/chunk-GVOEAY52.js +1 -0
- package/dist/browser-lazy/chunks/chunk-HLWUNUCM.js +1 -0
- package/dist/browser-lazy/chunks/chunk-ICC7HBJX.js +1 -0
- package/dist/browser-lazy/chunks/chunk-J35HAQQF.js +20 -0
- package/dist/browser-lazy/chunks/chunk-J7FFAFQF.js +1 -0
- package/dist/browser-lazy/chunks/chunk-LH7HUDKW.js +1 -0
- package/dist/browser-lazy/chunks/chunk-N5ELX7LR.js +2 -0
- package/dist/browser-lazy/chunks/chunk-NMQQMRIR.js +1 -0
- package/dist/browser-lazy/chunks/chunk-NO7ZIVRU.js +1 -0
- package/dist/browser-lazy/chunks/chunk-OZ443IVJ.js +16 -0
- package/dist/browser-lazy/chunks/chunk-PQGPS2YV.js +7 -0
- package/dist/browser-lazy/chunks/chunk-QA6GJQ4X.js +1 -0
- package/dist/browser-lazy/chunks/chunk-RIVTHZAQ.js +1 -0
- package/dist/browser-lazy/chunks/chunk-SZELX2EJ.js +1 -0
- package/dist/browser-lazy/chunks/chunk-TYZOZXUJ.js +22 -0
- package/dist/browser-lazy/chunks/chunk-UL6NDWLL.js +1 -0
- package/dist/browser-lazy/chunks/chunk-VQYYGAXP.js +1 -0
- package/dist/browser-lazy/chunks/chunk-VWVZGQE2.js +1 -0
- package/dist/browser-lazy/chunks/chunk-X2UYKWKM.js +4 -0
- package/dist/browser-lazy/chunks/chunk-YCEICNM6.js +1 -0
- package/dist/browser-lazy/chunks/chunk-Z3FDIVLN.js +20 -0
- package/dist/browser-lazy/chunks/class-5QA4SCTS.js +13 -0
- package/dist/browser-lazy/chunks/decode-63UIZGD2.js +1 -0
- package/dist/browser-lazy/chunks/elk.bundled-L4CADV5W.js +24 -0
- package/dist/browser-lazy/chunks/er-7ZSKGN7Y.js +11 -0
- package/dist/browser-lazy/chunks/eventmodeling-2BPLHWRN.js +19 -0
- package/dist/browser-lazy/chunks/flowchart-NEIMZTB5.js +4 -0
- package/dist/browser-lazy/chunks/forest-implementation-AEP24AIP.js +1 -0
- package/dist/browser-lazy/chunks/gantt-RDPIFYAF.js +11 -0
- package/dist/browser-lazy/chunks/gitgraph-N4Y5RYB7.js +9 -0
- package/dist/browser-lazy/chunks/ishikawa-LD3YBDJN.js +6 -0
- package/dist/browser-lazy/chunks/journey-6YQR5DJX.js +16 -0
- package/dist/browser-lazy/chunks/kanban-PLMJ7NBW.js +20 -0
- package/dist/browser-lazy/chunks/mermaid-yaml-runtime-QVYX4EWK.js +136 -0
- package/dist/browser-lazy/chunks/mindmap-K2UBFO3Y.js +12 -0
- package/dist/browser-lazy/chunks/packet-CUW4QY6Y.js +7 -0
- package/dist/browser-lazy/chunks/pie-7F7UUCG3.js +15 -0
- package/dist/browser-lazy/chunks/quadrant-TOONO2WC.js +10 -0
- package/dist/browser-lazy/chunks/radar-J6JVWVAX.js +16 -0
- package/dist/browser-lazy/chunks/render-core-BZOM3K7D.js +3 -0
- package/dist/browser-lazy/chunks/requirement-CMAKDJPO.js +19 -0
- package/dist/browser-lazy/chunks/sankey-AWXQEP3F.js +13 -0
- package/dist/browser-lazy/chunks/sequence-Q2RJRB4L.js +5 -0
- package/dist/browser-lazy/chunks/state-WRBFQEDX.js +4 -0
- package/dist/browser-lazy/chunks/timeline-D2KILFXM.js +6 -0
- package/dist/browser-lazy/chunks/treemap-N3VYX5D4.js +6 -0
- package/dist/browser-lazy/chunks/xychart-G73OGK66.js +16 -0
- package/dist/browser-lazy/chunks/zenuml-H4BXNYXR.js +16 -0
- package/dist/browser-lazy/index.d.ts +544 -275
- package/dist/browser-lazy/index.js +1 -1
- package/dist/browser.global.js +802 -565
- package/dist/chunk-3LGLPG33.js +2 -0
- package/dist/chunk-7CRDX2QR.js +2 -0
- package/dist/chunk-7PPW2BMO.js +2 -0
- package/dist/chunk-DQDKA5ND.js +2 -0
- package/dist/chunk-EHCMJUMD.js +52 -0
- package/dist/chunk-GVCHLSHH.js +4 -0
- package/dist/chunk-H3NCS2XZ.js +19 -0
- package/dist/chunk-JZOJ4YGS.js +201 -0
- package/dist/chunk-MKE7GNYU.js +146 -0
- package/dist/chunk-NKNFOREZ.js +2 -0
- package/dist/chunk-O7H2UX5K.js +2 -0
- package/dist/chunk-OMY6NRQD.js +58 -0
- package/dist/chunk-UA234O4M.js +4 -0
- package/dist/chunk-VUFVLGTH.js +2 -0
- package/dist/chunk-XU5LPD2D.js +2 -0
- package/dist/cli-YGGTJZH7.js +226 -0
- package/dist/elk-constructor.js +2 -0
- package/dist/elk-constructor.node.js +11 -0
- package/dist/index-EeXqJXr5.d.ts +1223 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -334
- package/dist/jsonl-RPJY6YWO.js +2 -0
- package/dist/mcp-cli-63DYXTVD.js +2 -0
- package/dist/{index-BGA_-6LV.d.ts → paint-certification-6rwQjIv_.d.ts} +5283 -6173
- package/dist/server-5NEOHOFS.js +524 -0
- package/dist/svg-styles-BdnoM7AT.d.ts +724 -0
- package/dist/svg-styles.d.ts +1 -0
- package/dist/svg-styles.js +2 -0
- package/dist/svg.d.ts +13 -0
- package/dist/svg.js +2 -0
- package/dist/types-BcS52Mjt.d.ts +1360 -0
- package/dist/zenuml/chunks/appearance-UOQ5KA6O.js +1 -0
- package/dist/zenuml/chunks/builtin-backends-KDKE7YHO.js +12 -0
- package/dist/zenuml/chunks/chunk-42DXZ5C6.js +4 -0
- package/dist/zenuml/chunks/chunk-7TVYPTDW.js +1 -0
- package/dist/zenuml/chunks/chunk-EVPSMEKN.js +1 -0
- package/dist/zenuml/chunks/chunk-OXQWRSBM.js +20 -0
- package/dist/zenuml/chunks/chunk-QWX77U7G.js +2 -0
- package/dist/zenuml/chunks/chunk-RLJEI7YN.js +29 -0
- package/dist/zenuml/chunks/chunk-RZ6XK5CD.js +29 -0
- package/dist/zenuml/chunks/decode-BWERFDGK.js +1 -0
- package/dist/zenuml/chunks/mermaid-yaml-runtime-KZVU74WU.js +136 -0
- package/dist/zenuml/chunks/render-core-V5RQ737O.js +3 -0
- package/dist/zenuml/chunks/zenuml-EA2ZFRUX.js +20 -0
- package/dist/zenuml-frame.global.js +3626 -0
- package/dist/zenuml.d.ts +83 -0
- package/dist/zenuml.js +1 -0
- package/docs/MCP-DIRECTORY-LISTINGS.md +5 -1
- package/docs/README.md +59 -103
- package/docs/agent-api-cookbook.md +26 -16
- package/docs/agent-mutation-policy.md +86 -15
- package/docs/agent-workflow-examples.md +1 -1
- package/docs/api-advanced.md +385 -0
- package/docs/api.md +320 -366
- package/docs/ascii.md +40 -4
- package/docs/browser.md +46 -7
- package/docs/choosing-a-diagram.md +148 -0
- package/docs/code-mode-impact.md +1 -0
- package/docs/comparison.md +244 -28
- package/docs/computational-aesthetics-prototype-plan.md +10 -10
- package/docs/config.md +60 -2
- package/docs/custom-fonts.md +78 -21
- package/docs/diagram-families.md +160 -10
- package/docs/eventmodeling-and-zenuml.md +165 -0
- package/docs/features.md +21 -19
- package/docs/fork-differences.md +105 -32
- package/docs/getting-started.md +56 -51
- package/docs/layout-certification.md +126 -0
- package/docs/mcp-code-mode-rationale.md +20 -12
- package/docs/mcp-http-transport.md +14 -8
- package/docs/quality.md +145 -15
- package/docs/react.md +76 -31
- package/docs/style-authoring.md +23 -11
- package/docs/svg-semantic-contract.md +104 -4
- package/docs/testing-strategy.md +684 -126
- package/docs/theming.md +27 -8
- package/examples/styles/readme-hero.md +25 -0
- package/examples/styles/readme-hero.mmd +13 -0
- package/examples/styles/readme-hero.style.json +7 -0
- package/package.json +114 -57
- package/server.json +2 -2
- package/skills/agentic-mermaid-diagram-workflow/SKILL.md +26 -8
- package/skills/agentic-mermaid-diagram-workflow/references/cli.md +13 -3
- package/skills/agentic-mermaid-diagram-workflow/references/code-mode.md +2 -1
- package/skills/agentic-mermaid-diagram-workflow/references/flowchart.md +9 -6
- package/skills/agentic-mermaid-diagram-workflow/references/hosted-mcp.md +1 -0
- package/skills/agentic-mermaid-diagram-workflow/references/sequence.md +4 -3
- package/skills/agentic-mermaid-diagram-workflow/references/timeline.md +7 -6
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/agentflow.md +574 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/architecture.md +10 -2
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/c4.md +18 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/classDiagram.md +123 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/cynefin.md +6 -1
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/entityRelationshipDiagram.md +129 -9
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/eventmodeling.md +22 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/flowchart.md +188 -60
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/gitgraph.md +13 -7
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/mindmap.md +110 -1
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/packet.md +38 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/requirementDiagram.md +115 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/sequenceDiagram.md +101 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/stateDiagram.md +87 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/swimlanes.md +105 -2
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/timeline.md +12 -6
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/usecase.md +953 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/venn.md +77 -0
- package/skills/agentic-mermaid-diagram-workflow/references/upstream/xyChart.md +1 -1
- package/dist/browser-lazy/chunks/architecture-KTHE2HX3.js +0 -31
- package/dist/browser-lazy/chunks/chunk-2XCPFAD5.js +0 -46
- package/dist/browser-lazy/chunks/chunk-3H4F7RBT.js +0 -1
- package/dist/browser-lazy/chunks/chunk-4EVLW2NJ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-5Q4S74UO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-6OAPWSDO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-A7L4WWVW.js +0 -143
- package/dist/browser-lazy/chunks/chunk-C7FJO2I3.js +0 -4
- package/dist/browser-lazy/chunks/chunk-D3XXDKIO.js +0 -1
- package/dist/browser-lazy/chunks/chunk-DXA5WL7H.js +0 -4
- package/dist/browser-lazy/chunks/chunk-EPFMQPXX.js +0 -1
- package/dist/browser-lazy/chunks/chunk-FFOHLPDA.js +0 -2
- package/dist/browser-lazy/chunks/chunk-FLD63DXE.js +0 -2
- package/dist/browser-lazy/chunks/chunk-G6OLSHRG.js +0 -7
- package/dist/browser-lazy/chunks/chunk-GRXCKTHX.js +0 -0
- package/dist/browser-lazy/chunks/chunk-I6VE56S7.js +0 -1
- package/dist/browser-lazy/chunks/chunk-KJVNXJ5Y.js +0 -1
- package/dist/browser-lazy/chunks/chunk-L227EPFP.js +0 -11
- package/dist/browser-lazy/chunks/chunk-LNIHDJSF.js +0 -1
- package/dist/browser-lazy/chunks/chunk-M6BT2HIP.js +0 -1
- package/dist/browser-lazy/chunks/chunk-NZRUMODH.js +0 -1
- package/dist/browser-lazy/chunks/chunk-OFRMKQA6.js +0 -1
- package/dist/browser-lazy/chunks/chunk-P7HMSKHJ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-PXKL3O6H.js +0 -1
- package/dist/browser-lazy/chunks/chunk-PZEWZT35.js +0 -1
- package/dist/browser-lazy/chunks/chunk-STQRDZ67.js +0 -1
- package/dist/browser-lazy/chunks/chunk-SUFMSWTX.js +0 -1
- package/dist/browser-lazy/chunks/chunk-T7IJ6V4B.js +0 -3
- package/dist/browser-lazy/chunks/chunk-UAEZO5VL.js +0 -1
- package/dist/browser-lazy/chunks/chunk-WEUWIFG3.js +0 -1
- package/dist/browser-lazy/chunks/chunk-X64T74C5.js +0 -24
- package/dist/browser-lazy/chunks/class-F7R6TJ73.js +0 -9
- package/dist/browser-lazy/chunks/er-BDK7CM5L.js +0 -9
- package/dist/browser-lazy/chunks/flowchart-KFU6XV7S.js +0 -4
- package/dist/browser-lazy/chunks/gantt-I64VVDSP.js +0 -28
- package/dist/browser-lazy/chunks/gitgraph-EDUVJ5IJ.js +0 -8
- package/dist/browser-lazy/chunks/journey-TLO2RNM3.js +0 -40
- package/dist/browser-lazy/chunks/mindmap-OJCNDYPM.js +0 -9
- package/dist/browser-lazy/chunks/pie-HVG6XO7K.js +0 -19
- package/dist/browser-lazy/chunks/quadrant-U6S2L4MJ.js +0 -24
- package/dist/browser-lazy/chunks/radar-ZDLOBTVG.js +0 -32
- package/dist/browser-lazy/chunks/render-core-Y2DFNMQG.js +0 -12
- package/dist/browser-lazy/chunks/sequence-Z4WFS3VB.js +0 -12
- package/dist/browser-lazy/chunks/state-2HV2YGN3.js +0 -4
- package/dist/browser-lazy/chunks/timeline-XM4UFPOC.js +0 -20
- package/dist/browser-lazy/chunks/xychart-7JDHWTQY.js +0 -36
- package/dist/chunk-GGXCNCNA.js +0 -4118
- package/dist/chunk-IVD4NXNE.js +0 -615
- package/dist/chunk-JDMRPUAG.js +0 -37
- package/dist/chunk-JWAAW3FH.js +0 -149
- package/dist/chunk-LCGBT32P.js +0 -62036
- package/dist/chunk-RWMZRUIC.js +0 -4715
- package/dist/mcp-cli-4MLKC3ZH.js +0 -17
- package/docs/mutation-testing.md +0 -285
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import{Dd as de,Fc as pe,Ia as Nt,Kd as ge,Md as me,Nd as ke,Od as Bt,Qb as gt,Ra as O,Td as ye,Vb as fe,Wa as he,Xb as G,j as ae,jd as jt,kd as Gt,l as oe,m as ce,sb as _t,ua as ue,z as le}from"./chunk-OMY6NRQD.js";function Rt(t,e,n){if(t&&t.length){const[s,r]=e;const i=Math.PI/180*n;const o=Math.cos(i);const a=Math.sin(i);for(const l of t){const[u,c]=l;l[0]=(u-s)*o-(c-r)*a+s;l[1]=(u-s)*a+(c-r)*o+r}}}function hn(t,e,n){const s=[];t.forEach(r=>s.push(...r));Rt(s,e,n)}function fn(t,e){return t[0]===e[0]&&t[1]===e[1]}function xe(t,e,n,s=1){const r=n;const i=Math.max(e,.1);const o=t[0]&&t[0][0]&&typeof t[0][0]==="number"?[t]:t;const a=[0,0];if(r){for(const u of o){Rt(u,a,r)}}const l=pn(o,i,s);if(r){for(const u of o){Rt(u,a,-r)}hn(l,a,-r)}return l}function pn(t,e,n){const s=[];for(const u of t){const c=[...u];if(!fn(c[0],c[c.length-1])){c.push([c[0][0],c[0][1]])}if(c.length>2){s.push(c)}}const r=[];e=Math.max(e,.1);const i=[];for(const u of s){for(let c=0;c<u.length-1;c++){const h=u[c];const f=u[c+1];if(h[1]!==f[1]){const p=Math.min(h[1],f[1]);i.push({ymin:p,ymax:Math.max(h[1],f[1]),x:p===h[1]?h[0]:f[0],islope:(f[0]-h[0])/(f[1]-h[1])})}}}i.sort((u,c)=>{if(u.ymin<c.ymin){return-1}if(u.ymin>c.ymin){return 1}if(u.x<c.x){return-1}if(u.x>c.x){return 1}if(u.ymax===c.ymax){return 0}return(u.ymax-c.ymax)/Math.abs(u.ymax-c.ymax)});if(!i.length){return r}let o=[];let a=i[0].ymin;let l=0;while(o.length||i.length){if(i.length){let u=-1;for(let h=0;h<i.length;h++){if(i[h].ymin>a){break}u=h}const c=i.splice(0,u+1);c.forEach(h=>{o.push({s:a,edge:h})})}o=o.filter(u=>{if(u.edge.ymax<=a){return false}return true});o.sort((u,c)=>{if(u.edge.x===c.edge.x){return 0}return(u.edge.x-c.edge.x)/Math.abs(u.edge.x-c.edge.x)});if(n!==1||l%e===0){if(o.length>1){for(let u=0;u<o.length;u=u+2){const c=u+1;if(c>=o.length){break}const h=o[u].edge;const f=o[c].edge;r.push([[Math.round(h.x),a],[Math.round(f.x),a]])}}}a+=n;o.forEach(u=>{u.edge.x=u.edge.x+n*u.edge.islope});l++}return r}function B(t,e){var n;const s=e.hachureAngle+90;let r=e.hachureGap;if(r<0){r=e.strokeWidth*4}r=Math.round(Math.max(r,.1));let i=1;if(e.roughness>=1){if((((n=e.randomizer)===null||n===void 0?void 0:n.next())||Math.random())>.7){i=r}}return xe(t,r,s,i||1)}var H=class{constructor(e){this.helper=e}fillPolygons(e,n){return this._fillPolygons(e,n)}_fillPolygons(e,n){const s=B(e,n);const r=this.renderLines(s,n);return{type:"fillSketch",ops:r}}renderLines(e,n){const s=[];for(const r of e){s.push(...this.helper.doubleLineOps(r[0][0],r[0][1],r[1][0],r[1][1],n))}return s}};function D(t){const e=t[0];const n=t[1];return Math.sqrt(Math.pow(e[0]-n[0],2)+Math.pow(e[1]-n[1],2))}var mt=class extends H{fillPolygons(e,n){let s=n.hachureGap;if(s<0){s=n.strokeWidth*4}s=Math.max(s,.1);const r=Object.assign({},n,{hachureGap:s});const i=B(e,r);const o=Math.PI/180*n.hachureAngle;const a=[];const l=s*.5*Math.cos(o);const u=s*.5*Math.sin(o);for(const[h,f]of i){if(D([h,f])){a.push([[h[0]-l,h[1]+u],[...f]],[[h[0]+l,h[1]-u],[...f]])}}const c=this.renderLines(a,n);return{type:"fillSketch",ops:c}}};var kt=class extends H{fillPolygons(e,n){const s=this._fillPolygons(e,n);const r=Object.assign({},n,{hachureAngle:n.hachureAngle+90});const i=this._fillPolygons(e,r);s.ops=s.ops.concat(i.ops);return s}};var yt=class{constructor(e){this.helper=e}fillPolygons(e,n){n=Object.assign({},n,{hachureAngle:0});const s=B(e,n);return this.dotsOnLines(s,n)}dotsOnLines(e,n){const s=[];let r=n.hachureGap;if(r<0){r=n.strokeWidth*4}r=Math.max(r,.1);let i=n.fillWeight;if(i<0){i=n.strokeWidth/2}const o=r/4;for(const a of e){const l=D(a);const u=l/r;const c=Math.ceil(u)-1;const h=l-c*r;const f=(a[0][0]+a[1][0])/2-r/4;const p=Math.min(a[0][1],a[1][1]);for(let d=0;d<c;d++){const g=p+h+d*r;const k=f-o+Math.random()*2*o;const y=g-o+Math.random()*2*o;const x=this.helper.ellipse(k,y,i,i,n);s.push(...x.ops)}}return{type:"fillSketch",ops:s}}};var xt=class{constructor(e){this.helper=e}fillPolygons(e,n){const s=B(e,n);return{type:"fillSketch",ops:this.dashedLine(s,n)}}dashedLine(e,n){const s=n.dashOffset<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashOffset;const r=n.dashGap<0?n.hachureGap<0?n.strokeWidth*4:n.hachureGap:n.dashGap;const i=[];e.forEach(o=>{const a=D(o);const l=Math.floor(a/(s+r));const u=(a+r-l*(s+r))/2;let c=o[0];let h=o[1];if(c[0]>h[0]){c=o[1];h=o[0]}const f=Math.atan((h[1]-c[1])/(h[0]-c[0]));for(let p=0;p<l;p++){const d=p*(s+r);const g=d+s;const k=[c[0]+d*Math.cos(f)+u*Math.cos(f),c[1]+d*Math.sin(f)+u*Math.sin(f)];const y=[c[0]+g*Math.cos(f)+u*Math.cos(f),c[1]+g*Math.sin(f)+u*Math.sin(f)];i.push(...this.helper.doubleLineOps(k[0],k[1],y[0],y[1],n))}});return i}};var bt=class{constructor(e){this.helper=e}fillPolygons(e,n){const s=n.hachureGap<0?n.strokeWidth*4:n.hachureGap;const r=n.zigzagOffset<0?s:n.zigzagOffset;n=Object.assign({},n,{hachureGap:s+r});const i=B(e,n);return{type:"fillSketch",ops:this.zigzagLines(i,r,n)}}zigzagLines(e,n,s){const r=[];e.forEach(i=>{const o=D(i);const a=Math.round(o/(2*n));let l=i[0];let u=i[1];if(l[0]>u[0]){l=i[1];u=i[0]}const c=Math.atan((u[1]-l[1])/(u[0]-l[0]));for(let h=0;h<a;h++){const f=h*2*n;const p=(h+1)*2*n;const d=Math.sqrt(2*Math.pow(n,2));const g=[l[0]+f*Math.cos(c),l[1]+f*Math.sin(c)];const k=[l[0]+p*Math.cos(c),l[1]+p*Math.sin(c)];const y=[g[0]+d*Math.cos(c+Math.PI/4),g[1]+d*Math.sin(c+Math.PI/4)];r.push(...this.helper.doubleLineOps(g[0],g[1],y[0],y[1],s),...this.helper.doubleLineOps(y[0],y[1],k[0],k[1],s))}});return r}};var L={};function be(t,e){let n=t.fillStyle||"hachure";if(!L[n]){switch(n){case"zigzag":if(!L[n]){L[n]=new mt(e)}break;case"cross-hatch":if(!L[n]){L[n]=new kt(e)}break;case"dots":if(!L[n]){L[n]=new yt(e)}break;case"dashed":if(!L[n]){L[n]=new xt(e)}break;case"zigzag-line":if(!L[n]){L[n]=new bt(e)}break;case"hachure":default:n="hachure";if(!L[n]){L[n]=new H(e)}break}}return L[n]}function Me(){return Math.floor(Math.random()*2**31)}var Mt=class{constructor(e){this.seed=e}next(){if(this.seed){return(2**31-1&(this.seed=Math.imul(48271,this.seed)))/2**31}else{return Math.random()}}};var dn=0;var Ft=1;var $e=2;var $t={A:7,a:7,C:6,c:6,H:1,h:1,L:2,l:2,M:2,m:2,Q:4,q:4,S:4,s:4,T:2,t:2,V:1,v:1,Z:0,z:0};function gn(t){const e=new Array;while(t!==""){if(t.match(/^([ \t\r\n,]+)/)){t=t.substr(RegExp.$1.length)}else if(t.match(/^([aAcChHlLmMqQsStTvVzZ])/)){e[e.length]={type:dn,text:RegExp.$1};t=t.substr(RegExp.$1.length)}else if(t.match(/^(([-+]?[0-9]+(\.[0-9]*)?|[-+]?\.[0-9]+)([eE][-+]?[0-9]+)?)/)){e[e.length]={type:Ft,text:`${parseFloat(RegExp.$1)}`};t=t.substr(RegExp.$1.length)}else{return[]}}e[e.length]={type:$e,text:""};return e}function Wt(t,e){return t.type===e}function nt(t){const e=[];const n=gn(t);let s="BOD";let r=0;let i=n[r];while(!Wt(i,$e)){let o=0;const a=[];if(s==="BOD"){if(i.text==="M"||i.text==="m"){r++;o=$t[i.text];s=i.text}else{return nt("M0,0"+t)}}else if(Wt(i,Ft)){o=$t[s]}else{r++;o=$t[i.text];s=i.text}if(r+o<n.length){for(let l=r;l<r+o;l++){const u=n[l];if(Wt(u,Ft)){a[a.length]=+u.text}else{throw new Error("Param not a number: "+s+","+u.text)}}if(typeof $t[s]==="number"){const l={key:s,data:a};e.push(l);r+=o;i=n[r];if(s==="M")s="L";if(s==="m")s="l"}else{throw new Error("Bad segment: "+s)}}else{throw new Error("Path data ended short")}}return e}function at(t){let e=0,n=0;let s=0,r=0;const i=[];for(const{key:o,data:a}of t){switch(o){case"M":i.push({key:"M",data:[...a]});[e,n]=a;[s,r]=a;break;case"m":e+=a[0];n+=a[1];i.push({key:"M",data:[e,n]});s=e;r=n;break;case"L":i.push({key:"L",data:[...a]});[e,n]=a;break;case"l":e+=a[0];n+=a[1];i.push({key:"L",data:[e,n]});break;case"C":i.push({key:"C",data:[...a]});e=a[4];n=a[5];break;case"c":{const l=a.map((u,c)=>c%2?u+n:u+e);i.push({key:"C",data:l});e=l[4];n=l[5];break}case"Q":i.push({key:"Q",data:[...a]});e=a[2];n=a[3];break;case"q":{const l=a.map((u,c)=>c%2?u+n:u+e);i.push({key:"Q",data:l});e=l[2];n=l[3];break}case"A":i.push({key:"A",data:[...a]});e=a[5];n=a[6];break;case"a":e+=a[5];n+=a[6];i.push({key:"A",data:[a[0],a[1],a[2],a[3],a[4],e,n]});break;case"H":i.push({key:"H",data:[...a]});e=a[0];break;case"h":e+=a[0];i.push({key:"H",data:[e]});break;case"V":i.push({key:"V",data:[...a]});n=a[0];break;case"v":n+=a[0];i.push({key:"V",data:[n]});break;case"S":i.push({key:"S",data:[...a]});e=a[2];n=a[3];break;case"s":{const l=a.map((u,c)=>c%2?u+n:u+e);i.push({key:"S",data:l});e=l[2];n=l[3];break}case"T":i.push({key:"T",data:[...a]});e=a[0];n=a[1];break;case"t":e+=a[0];n+=a[1];i.push({key:"T",data:[e,n]});break;case"Z":case"z":i.push({key:"Z",data:[]});e=s;n=r;break}}return i}function ct(t){const e=[];let n="";let s=0,r=0;let i=0,o=0;let a=0,l=0;for(const{key:u,data:c}of t){switch(u){case"M":e.push({key:"M",data:[...c]});[s,r]=c;[i,o]=c;break;case"C":e.push({key:"C",data:[...c]});s=c[4];r=c[5];a=c[2];l=c[3];break;case"L":e.push({key:"L",data:[...c]});[s,r]=c;break;case"H":s=c[0];e.push({key:"L",data:[s,r]});break;case"V":r=c[0];e.push({key:"L",data:[s,r]});break;case"S":{let h=0,f=0;if(n==="C"||n==="S"){h=s+(s-a);f=r+(r-l)}else{h=s;f=r}e.push({key:"C",data:[h,f,...c]});a=c[0];l=c[1];s=c[2];r=c[3];break}case"T":{const[h,f]=c;let p=0,d=0;if(n==="Q"||n==="T"){p=s+(s-a);d=r+(r-l)}else{p=s;d=r}const g=s+2*(p-s)/3;const k=r+2*(d-r)/3;const y=h+2*(p-h)/3;const x=f+2*(d-f)/3;e.push({key:"C",data:[g,k,y,x,h,f]});a=p;l=d;s=h;r=f;break}case"Q":{const[h,f,p,d]=c;const g=s+2*(h-s)/3;const k=r+2*(f-r)/3;const y=p+2*(h-p)/3;const x=d+2*(f-d)/3;e.push({key:"C",data:[g,k,y,x,p,d]});a=h;l=f;s=p;r=d;break}case"A":{const h=Math.abs(c[0]);const f=Math.abs(c[1]);const p=c[2];const d=c[3];const g=c[4];const k=c[5];const y=c[6];if(h===0||f===0){e.push({key:"C",data:[s,r,k,y,k,y]});s=k;r=y}else{if(s!==k||r!==y){const x=Se(s,r,k,y,h,f,p,d,g);x.forEach(function($){e.push({key:"C",data:$})});s=k;r=y}}break}case"Z":e.push({key:"Z",data:[]});s=i;r=o;break}n=u}return e}function mn(t){return Math.PI*t/180}function ot(t,e,n){const s=t*Math.cos(n)-e*Math.sin(n);const r=t*Math.sin(n)+e*Math.cos(n);return[s,r]}function Se(t,e,n,s,r,i,o,a,l,u){const c=mn(o);let h=[];let f=0,p=0,d=0,g=0;if(u){[f,p,d,g]=u}else{[t,e]=ot(t,e,-c);[n,s]=ot(n,s,-c);const w=(t-n)/2;const M=(e-s)/2;let v=w*w/(r*r)+M*M/(i*i);if(v>1){v=Math.sqrt(v);r=v*r;i=v*i}const q=a===l?-1:1;const z=r*r;const b=i*i;const rt=z*b-z*M*M-b*w*w;const j=z*M*M+b*w*w;const V=q*Math.sqrt(Math.abs(rt/j));d=V*r*M/i+(t+n)/2;g=V*-i*w/r+(e+s)/2;f=Math.asin(parseFloat(((e-g)/i).toFixed(9)));p=Math.asin(parseFloat(((s-g)/i).toFixed(9)));if(t<d){f=Math.PI-f}if(n<d){p=Math.PI-p}if(f<0){f=Math.PI*2+f}if(p<0){p=Math.PI*2+p}if(l&&f>p){f=f-Math.PI*2}if(!l&&p>f){p=p-Math.PI*2}}let k=p-f;if(Math.abs(k)>Math.PI*120/180){const w=p;const M=n;const v=s;if(l&&p>f){p=f+Math.PI*120/180*1}else{p=f+Math.PI*120/180*-1}n=d+r*Math.cos(p);s=g+i*Math.sin(p);h=Se(n,s,M,v,r,i,o,0,l,[p,w,d,g])}k=p-f;const y=Math.cos(f);const x=Math.sin(f);const $=Math.cos(p);const C=Math.sin(p);const P=Math.tan(k/4);const W=4/3*r*P;const F=4/3*i*P;const I=[t,e];const T=[t+W*x,e-F*y];const N=[n+W*C,s-F*$];const _=[n,s];T[0]=2*I[0]-T[0];T[1]=2*I[1]-T[1];if(u){return[T,N,_].concat(h)}else{h=[T,N,_].concat(h);const w=[];for(let M=0;M<h.length;M+=3){const v=ot(h[M][0],h[M][1],c);const q=ot(h[M+1][0],h[M+1][1],c);const z=ot(h[M+2][0],h[M+2][1],c);w.push([v[0],v[1],q[0],q[1],z[0],z[1]])}return w}}var kn={randOffset:bn,randOffsetWithRange:Mn,ellipse:xn,doubleLineOps:$n};function It(t,e,n,s,r){return{type:"path",ops:Z(t,e,n,s,r)}}function lt(t,e,n){const s=(t||[]).length;if(s>2){const r=[];for(let i=0;i<s-1;i++){r.push(...Z(t[i][0],t[i][1],t[i+1][0],t[i+1][1],n))}if(e){r.push(...Z(t[s-1][0],t[s-1][1],t[0][0],t[0][1],n))}return{type:"path",ops:r}}else if(s===2){return It(t[0][0],t[0][1],t[1][0],t[1][1],n)}return{type:"path",ops:[]}}function yn(t,e){return lt(t,true,e)}function ve(t,e,n,s,r){const i=[[t,e],[t+n,e],[t+n,e+s],[t,e+s]];return yn(i,r)}function qt(t,e){if(t.length){const n=t[0];const s=typeof n[0]==="number"?[t]:t;const r=St(s[0],1*(1+e.roughness*.2),e);const i=e.disableMultiStroke?[]:St(s[0],1.5*(1+e.roughness*.22),Pe(e));for(let o=1;o<s.length;o++){const a=s[o];if(a.length){const l=St(a,1*(1+e.roughness*.2),e);const u=e.disableMultiStroke?[]:St(a,1.5*(1+e.roughness*.22),Pe(e));for(const c of l){if(c.op!=="move"){r.push(c)}}for(const c of u){if(c.op!=="move"){i.push(c)}}}}return{type:"path",ops:r.concat(i)}}return{type:"path",ops:[]}}function xn(t,e,n,s,r){const i=Vt(n,s,r);return Ot(t,e,r,i).opset}function Vt(t,e,n){const s=Math.sqrt(Math.PI*2*Math.sqrt((Math.pow(t/2,2)+Math.pow(e/2,2))/2));const r=Math.ceil(Math.max(n.curveStepCount,n.curveStepCount/Math.sqrt(200)*s));const i=Math.PI*2/r;let o=Math.abs(t/2);let a=Math.abs(e/2);const l=1-n.curveFitting;o+=m(o*l,n);a+=m(a*l,n);return{increment:i,rx:o,ry:a}}function Ot(t,e,n,s){const[r,i]=we(s.increment,t,e,s.rx,s.ry,1,s.increment*Pt(.1,Pt(.4,1,n),n),n);let o=wt(r,null,n);if(!n.disableMultiStroke&&n.roughness!==0){const[a]=we(s.increment,t,e,s.rx,s.ry,1.5,0,n);const l=wt(a,null,n);o=o.concat(l)}return{estimatedPoints:i,opset:{type:"path",ops:o}}}function Ht(t,e,n,s,r,i,o,a,l){const u=t;const c=e;let h=Math.abs(n/2);let f=Math.abs(s/2);h+=m(h*.01,l);f+=m(f*.01,l);let p=r;let d=i;while(p<0){p+=Math.PI*2;d+=Math.PI*2}if(d-p>Math.PI*2){p=0;d=Math.PI*2}const g=Math.PI*2/l.curveStepCount;const k=Math.min(g/2,(d-p)/2);const y=Oe(k,u,c,h,f,p,d,1,l);if(!l.disableMultiStroke){const x=Oe(k,u,c,h,f,p,d,1.5,l);y.push(...x)}if(o){if(a){y.push(...Z(u,c,u+h*Math.cos(p),c+f*Math.sin(p),l),...Z(u,c,u+h*Math.cos(d),c+f*Math.sin(d),l))}else{y.push({op:"lineTo",data:[u,c]},{op:"lineTo",data:[u+h*Math.cos(p),c+f*Math.sin(p)]})}}return{type:"path",ops:y}}function Dt(t,e){const n=ct(at(nt(t)));const s=[];let r=[0,0];let i=[0,0];for(const{key:o,data:a}of n){switch(o){case"M":{i=[a[0],a[1]];r=[a[0],a[1]];break}case"L":s.push(...Z(i[0],i[1],a[0],a[1],e));i=[a[0],a[1]];break;case"C":{const[l,u,c,h,f,p]=a;s.push(...Sn(l,u,c,h,f,p,i,e));i=[f,p];break}case"Z":s.push(...Z(i[0],i[1],r[0],r[1],e));i=[r[0],r[1]];break}}return{type:"path",ops:s}}function vt(t,e){const n=[];for(const s of t){if(s.length){const r=e.maxRandomnessOffset||0;const i=s.length;if(i>2){n.push({op:"move",data:[s[0][0]+m(r,e),s[0][1]+m(r,e)]});for(let o=1;o<i;o++){n.push({op:"lineTo",data:[s[o][0]+m(r,e),s[o][1]+m(r,e)]})}}}}return{type:"fillPath",ops:n}}function tt(t,e){return be(e,kn).fillPolygons(t,e)}function Le(t,e,n,s,r,i,o){const a=t;const l=e;let u=Math.abs(n/2);let c=Math.abs(s/2);u+=m(u*.01,o);c+=m(c*.01,o);let h=r;let f=i;while(h<0){h+=Math.PI*2;f+=Math.PI*2}if(f-h>Math.PI*2){h=0;f=Math.PI*2}const p=(f-h)/o.curveStepCount;const d=[];for(let g=h;g<=f;g=g+p){d.push([a+u*Math.cos(g),l+c*Math.sin(g)])}d.push([a+u*Math.cos(f),l+c*Math.sin(f)]);d.push([a,l]);return tt([d],o)}function bn(t,e){return m(t,e)}function Mn(t,e,n){return Pt(t,e,n)}function $n(t,e,n,s,r){return Z(t,e,n,s,r,true)}function Pe(t){const e=Object.assign({},t);e.randomizer=void 0;if(t.seed){e.seed=t.seed+1}return e}function Ae(t){if(!t.randomizer){t.randomizer=new Mt(t.seed||0)}return t.randomizer.next()}function Pt(t,e,n,s=1){return n.roughness*s*(Ae(n)*(e-t)+t)}function m(t,e,n=1){return Pt(-t,t,e,n)}function Z(t,e,n,s,r,i=false){const o=i?r.disableMultiStrokeFill:r.disableMultiStroke;const a=Et(t,e,n,s,r,true,false);if(o){return a}const l=Et(t,e,n,s,r,true,true);return a.concat(l)}function Et(t,e,n,s,r,i,o){const a=Math.pow(t-n,2)+Math.pow(e-s,2);const l=Math.sqrt(a);let u=1;if(l<200){u=1}else if(l>500){u=.4}else{u=-.0016668*l+1.233334}let c=r.maxRandomnessOffset||0;if(c*c*100>a){c=l/10}const h=c/2;const f=.2+Ae(r)*.2;let p=r.bowing*r.maxRandomnessOffset*(s-e)/200;let d=r.bowing*r.maxRandomnessOffset*(t-n)/200;p=m(p,r,u);d=m(d,r,u);const g=[];const k=()=>m(h,r,u);const y=()=>m(c,r,u);const x=r.preserveVertices;if(i){if(o){g.push({op:"move",data:[t+(x?0:k()),e+(x?0:k())]})}else{g.push({op:"move",data:[t+(x?0:m(c,r,u)),e+(x?0:m(c,r,u))]})}}if(o){g.push({op:"bcurveTo",data:[p+t+(n-t)*f+k(),d+e+(s-e)*f+k(),p+t+2*(n-t)*f+k(),d+e+2*(s-e)*f+k(),n+(x?0:k()),s+(x?0:k())]})}else{g.push({op:"bcurveTo",data:[p+t+(n-t)*f+y(),d+e+(s-e)*f+y(),p+t+2*(n-t)*f+y(),d+e+2*(s-e)*f+y(),n+(x?0:y()),s+(x?0:y())]})}return g}function St(t,e,n){if(!t.length){return[]}const s=[];s.push([t[0][0]+m(e,n),t[0][1]+m(e,n)]);s.push([t[0][0]+m(e,n),t[0][1]+m(e,n)]);for(let r=1;r<t.length;r++){s.push([t[r][0]+m(e,n),t[r][1]+m(e,n)]);if(r===t.length-1){s.push([t[r][0]+m(e,n),t[r][1]+m(e,n)])}}return wt(s,null,n)}function wt(t,e,n){const s=t.length;const r=[];if(s>3){const i=[];const o=1-n.curveTightness;r.push({op:"move",data:[t[1][0],t[1][1]]});for(let a=1;a+2<s;a++){const l=t[a];i[0]=[l[0],l[1]];i[1]=[l[0]+(o*t[a+1][0]-o*t[a-1][0])/6,l[1]+(o*t[a+1][1]-o*t[a-1][1])/6];i[2]=[t[a+1][0]+(o*t[a][0]-o*t[a+2][0])/6,t[a+1][1]+(o*t[a][1]-o*t[a+2][1])/6];i[3]=[t[a+1][0],t[a+1][1]];r.push({op:"bcurveTo",data:[i[1][0],i[1][1],i[2][0],i[2][1],i[3][0],i[3][1]]})}if(e&&e.length===2){const a=n.maxRandomnessOffset;r.push({op:"lineTo",data:[e[0]+m(a,n),e[1]+m(a,n)]})}}else if(s===3){r.push({op:"move",data:[t[1][0],t[1][1]]});r.push({op:"bcurveTo",data:[t[1][0],t[1][1],t[2][0],t[2][1],t[2][0],t[2][1]]})}else if(s===2){r.push(...Et(t[0][0],t[0][1],t[1][0],t[1][1],n,true,true))}return r}function we(t,e,n,s,r,i,o,a){const l=a.roughness===0;const u=[];const c=[];if(l){t=t/4;c.push([e+s*Math.cos(-t),n+r*Math.sin(-t)]);for(let h=0;h<=Math.PI*2;h=h+t){const f=[e+s*Math.cos(h),n+r*Math.sin(h)];u.push(f);c.push(f)}c.push([e+s*Math.cos(0),n+r*Math.sin(0)]);c.push([e+s*Math.cos(t),n+r*Math.sin(t)])}else{const h=m(.5,a)-Math.PI/2;c.push([m(i,a)+e+.9*s*Math.cos(h-t),m(i,a)+n+.9*r*Math.sin(h-t)]);const f=Math.PI*2+h-.01;for(let p=h;p<f;p=p+t){const d=[m(i,a)+e+s*Math.cos(p),m(i,a)+n+r*Math.sin(p)];u.push(d);c.push(d)}c.push([m(i,a)+e+s*Math.cos(h+Math.PI*2+o*.5),m(i,a)+n+r*Math.sin(h+Math.PI*2+o*.5)]);c.push([m(i,a)+e+.98*s*Math.cos(h+o),m(i,a)+n+.98*r*Math.sin(h+o)]);c.push([m(i,a)+e+.9*s*Math.cos(h+o*.5),m(i,a)+n+.9*r*Math.sin(h+o*.5)])}return[c,u]}function Oe(t,e,n,s,r,i,o,a,l){const u=i+m(.1,l);const c=[];c.push([m(a,l)+e+.9*s*Math.cos(u-t),m(a,l)+n+.9*r*Math.sin(u-t)]);for(let h=u;h<=o;h=h+t){c.push([m(a,l)+e+s*Math.cos(h),m(a,l)+n+r*Math.sin(h)])}c.push([e+s*Math.cos(o),n+r*Math.sin(o)]);c.push([e+s*Math.cos(o),n+r*Math.sin(o)]);return wt(c,null,l)}function Sn(t,e,n,s,r,i,o,a){const l=[];const u=[a.maxRandomnessOffset||1,(a.maxRandomnessOffset||1)+.3];let c=[0,0];const h=a.disableMultiStroke?1:2;const f=a.preserveVertices;for(let p=0;p<h;p++){if(p===0){l.push({op:"move",data:[o[0],o[1]]})}else{l.push({op:"move",data:[o[0]+(f?0:m(u[0],a)),o[1]+(f?0:m(u[0],a))]})}c=f?[r,i]:[r+m(u[p],a),i+m(u[p],a)];l.push({op:"bcurveTo",data:[t+m(u[p],a),e+m(u[p],a),n+m(u[p],a),s+m(u[p],a),c[0],c[1]]})}return l}function ut(t){return[...t]}function Zt(t,e=0){const n=t.length;if(n<3){throw new Error("A curve must have at least three points.")}const s=[];if(n===3){s.push(ut(t[0]),ut(t[1]),ut(t[2]),ut(t[2]))}else{const r=[];r.push(t[0],t[0]);for(let a=1;a<t.length;a++){r.push(t[a]);if(a===t.length-1){r.push(t[a])}}const i=[];const o=1-e;s.push(ut(r[0]));for(let a=1;a+2<r.length;a++){const l=r[a];i[0]=[l[0],l[1]];i[1]=[l[0]+(o*r[a+1][0]-o*r[a-1][0])/6,l[1]+(o*r[a+1][1]-o*r[a-1][1])/6];i[2]=[r[a+1][0]+(o*r[a][0]-o*r[a+2][0])/6,r[a+1][1]+(o*r[a][1]-o*r[a+2][1])/6];i[3]=[r[a+1][0],r[a+1][1]];s.push(i[1],i[2],i[3])}}return s}function Pn(t,e){return Math.sqrt(Lt(t,e))}function Lt(t,e){return Math.pow(t[0]-e[0],2)+Math.pow(t[1]-e[1],2)}function wn(t,e,n){const s=Lt(e,n);if(s===0){return Lt(t,e)}let r=((t[0]-e[0])*(n[0]-e[0])+(t[1]-e[1])*(n[1]-e[1]))/s;r=Math.max(0,Math.min(1,r));return Lt(t,et(e,n,r))}function et(t,e,n){return[t[0]+(e[0]-t[0])*n,t[1]+(e[1]-t[1])*n]}function On(t,e){const n=t[e+0];const s=t[e+1];const r=t[e+2];const i=t[e+3];let o=3*s[0]-2*n[0]-i[0];o*=o;let a=3*s[1]-2*n[1]-i[1];a*=a;let l=3*r[0]-2*i[0]-n[0];l*=l;let u=3*r[1]-2*i[1]-n[1];u*=u;if(o<l){o=l}if(a<u){a=u}return o+a}function Qt(t,e,n,s){const r=s||[];if(On(t,e)<n){const i=t[e+0];if(r.length){const o=Pn(r[r.length-1],i);if(o>1){r.push(i)}}else{r.push(i)}r.push(t[e+3])}else{const i=.5;const o=t[e+0];const a=t[e+1];const l=t[e+2];const u=t[e+3];const c=et(o,a,i);const h=et(a,l,i);const f=et(l,u,i);const p=et(c,h,i);const d=et(h,f,i);const g=et(p,d,i);Qt([o,c,p,g],0,n,r);Qt([g,d,f,u],0,n,r)}return r}function Te(t,e){return At(t,0,t.length,e)}function At(t,e,n,s,r){const i=r||[];const o=t[e];const a=t[n-1];let l=0;let u=1;for(let c=e+1;c<n-1;++c){const h=wn(t[c],o,a);if(h>l){l=h;u=c}}if(Math.sqrt(l)>s){At(t,e,u+1,s,i);At(t,u,n,s,i)}else{if(!i.length){i.push(o)}i.push(a)}return i}function ht(t,e=.15,n){const s=[];const r=(t.length-1)/3;for(let i=0;i<r;i++){const o=i*3;Qt(t,o,e,s)}if(n&&n>0){return At(s,0,s.length,n)}return s}function ze(t,e,n){const s=nt(t);const r=ct(at(s));const i=[];let o=[];let a=[0,0];let l=[];const u=()=>{if(l.length>=4){o.push(...ht(l,e))}l=[]};const c=()=>{u();if(o.length){i.push(o);o=[]}};for(const{key:f,data:p}of r){switch(f){case"M":c();a=[p[0],p[1]];o.push(a);break;case"L":u();o.push([p[0],p[1]]);break;case"C":if(!l.length){const d=o.length?o[o.length-1]:a;l.push([d[0],d[1]])}l.push([p[0],p[1]]);l.push([p[2],p[3]]);l.push([p[4],p[5]]);break;case"Z":u();o.push([a[0],a[1]]);break}}c();if(!n){return i}const h=[];for(const f of i){const p=Te(f,n);if(p.length){h.push(p)}}return h}var A="none";var Tt=class{constructor(e){this.defaultOptions={maxRandomnessOffset:2,roughness:1,bowing:1,stroke:"#000",strokeWidth:1,curveTightness:0,curveFitting:.95,curveStepCount:9,fillStyle:"hachure",fillWeight:-1,hachureAngle:-41,hachureGap:-1,dashOffset:-1,dashGap:-1,zigzagOffset:-1,seed:0,disableMultiStroke:false,disableMultiStrokeFill:false,preserveVertices:false,fillShapeRoughnessGain:.8};this.config=e||{};if(this.config.options){this.defaultOptions=this._o(this.config.options)}}static newSeed(){return Me()}_o(e){return e?Object.assign({},this.defaultOptions,e):this.defaultOptions}_d(e,n,s){return{shape:e,sets:n||[],options:s||this.defaultOptions}}line(e,n,s,r,i){const o=this._o(i);return this._d("line",[It(e,n,s,r,o)],o)}rectangle(e,n,s,r,i){const o=this._o(i);const a=[];const l=ve(e,n,s,r,o);if(o.fill){const u=[[e,n],[e+s,n],[e+s,n+r],[e,n+r]];if(o.fillStyle==="solid"){a.push(vt([u],o))}else{a.push(tt([u],o))}}if(o.stroke!==A){a.push(l)}return this._d("rectangle",a,o)}ellipse(e,n,s,r,i){const o=this._o(i);const a=[];const l=Vt(s,r,o);const u=Ot(e,n,o,l);if(o.fill){if(o.fillStyle==="solid"){const c=Ot(e,n,o,l).opset;c.type="fillPath";a.push(c)}else{a.push(tt([u.estimatedPoints],o))}}if(o.stroke!==A){a.push(u.opset)}return this._d("ellipse",a,o)}circle(e,n,s,r){const i=this.ellipse(e,n,s,s,r);i.shape="circle";return i}linearPath(e,n){const s=this._o(n);return this._d("linearPath",[lt(e,false,s)],s)}arc(e,n,s,r,i,o,a=false,l){const u=this._o(l);const c=[];const h=Ht(e,n,s,r,i,o,a,true,u);if(a&&u.fill){if(u.fillStyle==="solid"){const f=Object.assign({},u);f.disableMultiStroke=true;const p=Ht(e,n,s,r,i,o,true,false,f);p.type="fillPath";c.push(p)}else{c.push(Le(e,n,s,r,i,o,u))}}if(u.stroke!==A){c.push(h)}return this._d("arc",c,u)}curve(e,n){const s=this._o(n);const r=[];const i=qt(e,s);if(s.fill&&s.fill!==A){if(s.fillStyle==="solid"){const o=qt(e,Object.assign(Object.assign({},s),{disableMultiStroke:true,roughness:s.roughness?s.roughness+s.fillShapeRoughnessGain:0}));r.push({type:"fillPath",ops:this._mergedShape(o.ops)})}else{const o=[];const a=e;if(a.length){const l=a[0];const u=typeof l[0]==="number"?[a]:a;for(const c of u){if(c.length<3){o.push(...c)}else if(c.length===3){o.push(...ht(Zt([c[0],c[0],c[1],c[2]]),10,(1+s.roughness)/2))}else{o.push(...ht(Zt(c),10,(1+s.roughness)/2))}}}if(o.length){r.push(tt([o],s))}}}if(s.stroke!==A){r.push(i)}return this._d("curve",r,s)}polygon(e,n){const s=this._o(n);const r=[];const i=lt(e,true,s);if(s.fill){if(s.fillStyle==="solid"){r.push(vt([e],s))}else{r.push(tt([e],s))}}if(s.stroke!==A){r.push(i)}return this._d("polygon",r,s)}path(e,n){const s=this._o(n);const r=[];if(!e){return this._d("path",r,s)}e=(e||"").replace(/\n/g," ").replace(/(-\s)/g,"-").replace("/(ss)/g"," ");const i=s.fill&&s.fill!=="transparent"&&s.fill!==A;const o=s.stroke!==A;const a=!!(s.simplification&&s.simplification<1);const l=a?4-4*(s.simplification||1):(1+s.roughness)/2;const u=ze(e,1,l);const c=Dt(e,s);if(i){if(s.fillStyle==="solid"){if(u.length===1){const h=Dt(e,Object.assign(Object.assign({},s),{disableMultiStroke:true,roughness:s.roughness?s.roughness+s.fillShapeRoughnessGain:0}));r.push({type:"fillPath",ops:this._mergedShape(h.ops)})}else{r.push(vt(u,s))}}else{r.push(tt(u,s))}}if(o){if(a){u.forEach(h=>{r.push(lt(h,false,s))})}else{r.push(c)}}return this._d("path",r,s)}opsToPath(e,n){let s="";for(const r of e.ops){const i=typeof n==="number"&&n>=0?r.data.map(o=>+o.toFixed(n)):r.data;switch(r.op){case"move":s+=`M${i[0]} ${i[1]} `;break;case"bcurveTo":s+=`C${i[0]} ${i[1]}, ${i[2]} ${i[3]}, ${i[4]} ${i[5]} `;break;case"lineTo":s+=`L${i[0]} ${i[1]} `;break}}return s.trim()}toPaths(e){const n=e.sets||[];const s=e.options||this.defaultOptions;const r=[];for(const i of n){let o=null;switch(i.type){case"path":o={d:this.opsToPath(i),stroke:s.stroke,strokeWidth:s.strokeWidth,fill:A};break;case"fillPath":o={d:this.opsToPath(i),stroke:A,strokeWidth:0,fill:s.fill||A};break;case"fillSketch":o=this.fillSketch(i,s);break}if(o){r.push(o)}}return r}fillSketch(e,n){let s=n.fillWeight;if(s<0){s=n.strokeWidth/2}return{d:this.opsToPath(e),stroke:n.fill||A,strokeWidth:s,fill:A}}_mergedShape(e){return e.filter((n,s)=>{if(s===0){return true}if(n.op==="move"){return false}return true})}};import{decodeXML as ur}from"entities";function Ce(t){const e=[];let n=0;let s;const r=/<\/([a-zA-Z][a-zA-Z0-9-]*)>/g;const i=[];for(const o of he(t)){const a=new Map(o.attributes.map(l=>[l.name,l.value]));i.push({index:o.start,kind:o.selfClosing?"self":"open",tag:o.name,attrs:a})}while((s=r.exec(t))!==null)i.push({index:s.index,kind:"close",tag:s[1]});i.sort((o,a)=>o.index-a.index);for(const o of i){if(o.kind==="self"){if(n===0)e.push({tag:o.tag,attrs:o.attrs})}else if(o.kind==="open"){if(n===0)e.push({tag:o.tag,attrs:o.attrs});n++}else{n--}}return e}var E=new Tt;function vn(t,e){const n=t.get("opacity")??e.opacity;const s=t.get("fill-opacity")??e.fillOpacity;const r=t.get("stroke-opacity")??e.strokeOpacity;if(n===void 0&&s===void 0&&r===void 0)return void 0;const i=o=>o===void 0?n:n===void 0?o:Number(n)*Number(o);return{fill:i(s),stroke:i(r)}}function Ne(t){return{roughness:t?.roughness??1,bowing:t?.bowing??1,passes:t?.passes??2,strokeWidth:t?.strokeWidth??1.6,fill:t?.fill??"none",hachureAngle:t?.hachureAngle??-41,hachureGap:t?.hachureGap??5,fillWeight:t?.fillWeight??.9}}function Ln(t,e,n,s,r){return{seed:e,roughness:t.roughness,bowing:t.bowing,stroke:n,strokeWidth:s,disableMultiStroke:t.passes<2,...r?{fill:r,fillStyle:t.fill==="solid"?"solid":"hachure",fillWeight:t.fillWeight,hachureGap:t.hachureGap,hachureAngle:t.hachureAngle}:{},preserveVertices:false}}function An(t={}){const e=[`stroke-linecap="${t.lineCap??"round"}"`,`stroke-linejoin="${t.lineJoin??"round"}"`,...t.miterLimit!==void 0?[`stroke-miterlimit="${O(String(t.miterLimit))}"`]:[],...t.dashArray!==void 0?[`stroke-dasharray="${O(t.dashArray)}"`]:[],...t.dashOffset!==void 0?[`stroke-dashoffset="${O(String(t.dashOffset))}"`]:[],...t.opacity!==void 0?[`stroke-opacity="${O(String(t.opacity))}"`]:[],...t.pathLength!==void 0?[`pathLength="${O(String(t.pathLength))}"`]:[],...t.paintOrder!==void 0?[`paint-order="${O(t.paintOrder)}"`]:[],...t.mixBlendMode!==void 0?[`style="mix-blend-mode:${t.mixBlendMode}"`]:[],...t.nonScaling?['vector-effect="non-scaling-stroke"']:[]];return e.join(" ")}function Q(t,e,n,s,r,i={},o){const a=[];const l=An(i);const u=l?` ${l}`:" ";const c=o?.stroke===void 0?"":` stroke-opacity="${O(String(o.stroke))}"`;const h=o?.fill===void 0?"":` stroke-opacity="${O(String(o.fill))}"`;for(const f of t){const p=E.opsToPath(f,2);if(!p)continue;if(f.type==="path"){a.push(`<path d="${p}" fill="none" stroke="${e}" stroke-width="${Nt(n)}"${u}${c} />`)}else if(f.type==="fillPath"){a.push(`<path d="${p}" fill="${s}" fill-opacity="${O(String(o?.fill??.92))}" stroke="none" />`)}else if(f.type==="fillSketch"){a.push(`<path d="${p}" fill="none" stroke="${s}" stroke-width="${Nt(r.fillWeight)}"${h} />`)}}return a.join("\n")}function Tn(t,e,n,s,r){const i=Math.min(r,n/2,s/2);return`M ${t+i} ${e} L ${t+n-i} ${e} Q ${t+n} ${e} ${t+n} ${e+i} L ${t+n} ${e+s-i} Q ${t+n} ${e+s} ${t+n-i} ${e+s} L ${t+i} ${e+s} Q ${t} ${e+s} ${t} ${e+s-i} L ${t} ${e+i} Q ${t} ${e} ${t+i} ${e} Z`}function je(t,e,n,s,r,i,o,a,l){return Ge(t,e,n,s,r,i,o,a,l)}function Ge(t,e,n,s,r,i,o,a,l){const u={...a,...o!==void 0?{dashArray:o}:{}};const c=Ln(i,e,n,s,r);try{switch(t.kind){case"rect":{if((t.rx??0)>.5){return Q(E.path(Tn(t.x,t.y,t.width,t.height,t.rx),c).sets,n,s,r,i,u,l)}return Q(E.rectangle(t.x,t.y,t.width,t.height,c).sets,n,s,r,i,u,l)}case"circle":return Q(E.circle(t.cx,t.cy,t.r*2,c).sets,n,s,r,i,u,l);case"ellipse":return Q(E.ellipse(t.cx,t.cy,t.rx*2,t.ry*2,c).sets,n,s,r,i,u,l);case"line":return Q(E.line(t.x1,t.y1,t.x2,t.y2,c).sets,n,s,void 0,i,u,l);case"polygon":return Q(E.polygon(t.points.map(h=>[h.x,h.y]),c).sets,n,s,r,i,u,l);case"polyline":return Q(E.linearPath(t.points.map(h=>[h.x,h.y]),c).sets,n,s,void 0,i,u,l);case"path":return Q(E.path(t.d,c).sets,n,s,r,i,u,l);case"compound":return""}}catch{return""}}function st(t,e,n,s,r,i,o,a,l){if(t.sketcher){const u=t.sketcher(e,{seed:n,stroke:s,width:r,fill:i,p:t.p,style:t.ctx.style,dash:o,strokeProjection:a,opacity:l});if(u!==null)return u}return Ge(e,n,s,r,i,t.p,o,a,l)}function Be(t,e,n){return t.replace(`<${e} `,`<${e} ${n} `)}function Re(t){if(t===void 0)return 1;const e=typeof t==="number"?t:parseFloat(t);if(Number.isNaN(e))return 1;return e}function zt(t,e){return t!==void 0?t:e}function zn(t,e){if(/style="/.test(t)){return t.replace(/style="([^"]*)"/,(n,s)=>{const r=s.trim().length===0||/;\s*$/.test(s)?"":";";return`style="${s}${r}stroke:none"`})}return Be(t,e,'style="stroke:none"')}function Xt(t,e){if(!e||t==="")return t;return`<g transform="${ue(e)}">${t}</g>`}function Cn(t,e){const n=e.p;const s=G(t);const r=Ce(s);const i=t.geometry.kind==="compound"?t.geometry.children:[t.geometry];if(r.length<i.length)return s;const o=s.split("\n");const a=c=>o.length===1&&c===0?s:o[c]??"";const l=[];for(let c=0;c<i.length;c++){const h=r[c];const f=zt(h.attrs.get("stroke"),t.paint.stroke);const p=zt(h.attrs.get("fill"),t.paint.fill);const d=Gt(e.ctx.seed,t.id,`outline:${c}`)||1;const g=Re(zt(h.attrs.get("stroke-width"),t.paint.strokeWidth));const k=zt(h.attrs.get("stroke-dasharray"),t.paint.strokeDasharray);const y=f!==void 0&&f!=="none"&&g>0;const x=p!==void 0&&p!=="none";const $=x&&n.fill!=="none"?p:void 0;const C=vn(h.attrs,t.paint)??{};if(n.fill==="wash"&&t.channels?.category!==void 0&&["pie-slice","actor","legend","point","bar"].includes(t.role))C.fill??="1";if(!y){if(t.surfaceFragment&&x&&n.fill==="none"&&_e(p))continue;if($){const F=st(e,i[c],d,"none",0,$,k,void 0,C);if(F){l.push(Xt(F,t.transform));continue}}l.push(a(c));continue}const P=Math.max(.6,Math.min(n.strokeWidth*g,n.strokeWidth*4));const W=st(e,i[c],d,f,P,$,k,void 0,C);if(!W){l.push(a(c));continue}if(x&&n.fill==="none"&&!_e(p)){l.push(zn(a(c),h.tag))}l.push(Xt(W,t.transform))}const u=l.filter(Boolean).join("\n");return t.identity&&!/\sdata-id=/.test(u)?fe(u,t.identity):u}function _e(t){return t.startsWith("var(--_node-fill")||t.startsWith("var(--_group")||t==="var(--bg)"||t==="var(--surface)"}function Nn(t,e){const n=G(t);if(t.lineStyle==="invisible"||n==="")return n;const s=t.stroke.color;const r=Re(t.stroke.width);if(r<=0)return n;const i=t.stroke.encodesValue?r:e.p.strokeWidth*r;const o=Gt(e.ctx.seed,t.id,"stroke")||1;const a=t.stroke.dash?typeof t.stroke.dash.array==="string"?t.stroke.dash.array:t.stroke.dash.array.join(" "):void 0;const l={...a!==void 0?{dashArray:a}:{},...t.stroke.dash?.offset!==void 0?{dashOffset:t.stroke.dash.offset}:{},lineCap:t.stroke.lineCap,lineJoin:t.stroke.lineJoin,miterLimit:t.stroke.miterLimit,...t.stroke.opacity!==void 0?{opacity:t.stroke.opacity}:{},...t.stroke.pathLength!==void 0?{pathLength:t.stroke.pathLength}:{},...t.stroke.paintOrder!==void 0?{paintOrder:t.stroke.paintOrder}:{},...t.stroke.mixBlendMode!==void 0?{mixBlendMode:t.stroke.mixBlendMode}:{},nonScaling:t.stroke.nonScaling};let u="";const c=t.route.geometry;if(c.kind==="polyline"){u=st(e,{kind:"polyline",points:c.points},o,s,i,void 0,a,l)}else if(c.kind==="line"){u=st(e,c,o,s,i,void 0,a,l)}else{const p=le(c,t.route.closed);if(p.length===1){u=st(e,{kind:"path",d:c.d},o,s,i,void 0,a,l)}if(!u&&c.points.length>1){const d=p.map((g,k)=>{const y=g.points[0];const x=g.points.at(-1);const $=g.closed&&y&&x&&(y.x!==x.x||y.y!==x.y)?[...g.points,y]:g.points;return st(e,{kind:"polyline",points:[...$]},o+k,s,i,void 0,a,l)});u=d.every(Boolean)?d.join("\n"):""}}if(!u)return n;const h=n.replace(/\sstroke-opacity=(?:"[^"]*"|'[^']*')/,' stroke-opacity="0"');const f=h===n?Be(n,t.route.geometry.kind,'stroke-opacity="0"'):h;return`${f}
|
|
2
|
+
${Xt(u,t.transform)}`}function _n(t,e){const n=t.pageFill!==void 0?We(G(t),t.pageFill):jn(G(t),t,e);return n.replace(/<text\b[^>]*>/g,s=>s.replace(/\s(?:paint-order|stroke|stroke-width|stroke-linejoin|stroke-linecap)="[^"]*"/g,"").replace(/^<text/,'<text paint-order="stroke" stroke="var(--bg)" stroke-width="3" stroke-linejoin="round" stroke-linecap="round"'))}function jn(t,e,n){const s=n.colors;const r=s===void 0?void 0:_t("var(--bg)",s);if(s===void 0||r===void 0)return t;const i=e.fontSize>=24?ce:oe;const o=l=>{const u=_t(l,s);return u!==void 0&&(ae(u,r)??i)<i};const a=e.paint.fill!==void 0&&o(e.paint.fill)?We(t,"var(--_text)"):t;return a.replace(/(<tspan\b[^>]*?\sfill=")([^"]*)(")/g,(l,u,c,h)=>o(c)?`${u}var(--_text)${h}`:l)}function We(t,e){return/<text\b[^>]*?\sfill="/.test(t)?t.replace(/(<text\b[^>]*?\sfill=")[^"]*(")/,`$1${O(e)}$2`):t.replace(/<text /,`<text fill="${O(e)}" `)}function Gn(t,e){const n=t?.backdrop??"plain";if(n==="paper-ruled"){const s=['<g data-backdrop="paper-ruled">'];for(let r=26;r<e.height;r+=26){s.push(` <line x1="0" y1="${r}" x2="${e.width}" y2="${r}" stroke="var(--_line)" stroke-width="0.5" opacity="0.14" />`)}s.push("</g>");return s.join("\n")}if(n==="grid"){const s=['<g data-backdrop="grid">'];for(let r=22;r<e.width;r+=22)s.push(` <line x1="${r}" y1="0" x2="${r}" y2="${e.height}" stroke="var(--_line)" stroke-width="0.5" opacity="0.10" />`);for(let r=22;r<e.height;r+=22)s.push(` <line x1="0" y1="${r}" x2="${e.width}" y2="${r}" stroke="var(--_line)" stroke-width="0.5" opacity="0.10" />`);s.push("</g>");return s.join("\n")}return""}function Jt(t,e){switch(t.kind){case"document":return G(t);case"shape":return gt(t.role).sketch==="shape"?Cn(t,e):G(t);case"connector":return gt(t.role).sketch==="connector"?Nn(t,e):G(t);case"text":return gt(t.role).textHalo?_n(t,e):G(t);case"group":return me(t.open,t.close,t.join,t.children.map(n=>({serialized:Jt(n.node,e),indent:n.indent})))}}function Yt(t,e){return{id:t,capabilities:pe(`backend:${t}`,"sketch",e?"hybrid":"rough"),drawNode(n,s){return Jt(n,{ctx:s,p:Ne(s.style),sketcher:e})},render(n,s){const r=de(n);const i={ctx:s,p:Ne(s.style),sketcher:e,colors:r.colors};const o=[];for(let a=0;a<r.parts.length;a++){const l=r.parts[a];o.push(ge(s,l,Jt(l,i)));if(a===0&&l.kind==="document"&&l.element==="open"){const u=ke(r,s);if(u)o.push(u);const c=Gn(s.style,r);if(c)o.push(c)}}return o.join("\n")}}}var Fe=Yt("rough");var{PI:Bn}=Math;var ft=Bn+1e-4;var Ee=.5;var Ie=[1,1];function qe(t,e,n,s=r=>r){return t*s(.5-e*(.5-n))}var{min:Kt}=Math;function Ke(t,e,n){let s=Kt(1,e/n);return Kt(1,t+(Kt(1,1-s)-t)*(s*.275))}function Rn(t){return[-t[0],-t[1]]}function R(t,e){return[t[0]+e[0],t[1]+e[1]]}function Ve(t,e,n){return t[0]=e[0]+n[0],t[1]=e[1]+n[1],t}function K(t,e){return[t[0]-e[0],t[1]-e[1]]}function ee(t,e,n){return t[0]=e[0]-n[0],t[1]=e[1]-n[1],t}function Y(t,e){return[t[0]*e,t[1]*e]}function Ut(t,e,n){return t[0]=e[0]*n,t[1]=e[1]*n,t}function Wn(t,e){return[t[0]/e,t[1]/e]}function Ue(t){return[t[1],-t[0]]}function te(t,e){let n=e[0];return t[0]=e[1],t[1]=-n,t}function He(t,e){return t[0]*e[0]+t[1]*e[1]}function Fn(t,e){return t[0]===e[0]&&t[1]===e[1]}function En(t){return Math.hypot(t[0],t[1])}function De(t,e){let n=t[0]-e[0],s=t[1]-e[1];return n*n+s*s}function tn(t){return Wn(t,En(t))}function In(t,e){return Math.hypot(t[1]-e[1],t[0]-e[0])}function ne(t,e,n){let s=Math.sin(n),r=Math.cos(n),i=t[0]-e[0],o=t[1]-e[1],a=i*r-o*s,l=i*s+o*r;return[a+e[0],l+e[1]]}function Ze(t,e,n,s){let r=Math.sin(s),i=Math.cos(s),o=e[0]-n[0],a=e[1]-n[1],l=o*i-a*r,u=o*r+a*i;return t[0]=l+n[0],t[1]=u+n[1],t}function Qe(t,e,n){return R(t,Y(K(e,t),n))}function qn(t,e,n,s){let r=n[0]-e[0],i=n[1]-e[1];return t[0]=e[0]+r*s,t[1]=e[1]+i*s,t}function en(t,e,n){return R(t,Y(e,n))}var S=[0,0];var X=[0,0];var J=[0,0];function Vn(t,e){let n=en(t,tn(Ue(K(t,R(t,[1,1])))),-e),s=[],r=1/13;for(let i=r;i<=1;i+=r)s.push(ne(n,t,ft*2*i));return s}function Hn(t,e,n){let s=[],r=1/n;for(let i=r;i<=1;i+=r)s.push(ne(e,t,ft*i));return s}function Dn(t,e,n){let s=K(e,n),r=Y(s,.5),i=Y(s,.51);return[K(t,r),K(t,i),R(t,i),R(t,r)]}function Zn(t,e,n,s){let r=[],i=en(t,e,n),o=1/s;for(let a=o;a<1;a+=o)r.push(ne(i,t,ft*3*a));return r}function Qn(t,e,n){return[R(t,Y(e,n)),R(t,Y(e,n*.99)),K(t,Y(e,n*.99)),K(t,Y(e,n))]}function Xe(t,e,n){return t===false||t===void 0?0:t===true?Math.max(e,n):t}function Xn(t,e,n){return t.slice(0,10).reduce((s,r)=>{let i=r.pressure;return e&&(i=Ke(s,r.distance,n)),(s+i)/2},t[0].pressure)}function Jn(t,e={}){let{size:n=16,smoothing:s=.5,thinning:r=.5,simulatePressure:i=true,easing:o=b=>b,start:a={},end:l={},last:u=false}=e,{cap:c=true,easing:h=b=>b*(2-b)}=a,{cap:f=true,easing:p=b=>--b*b*b+1}=l;if(t.length===0||n<=0)return[];let d=t[t.length-1].runningLength,g=Xe(a.taper,n,d),k=Xe(l.taper,n,d),y=(n*s)**2,x=[],$=[],C=Xn(t,i,n),P=qe(n,r,t[t.length-1].pressure,o),W,F=t[0].vector,I=t[0].point,T=I,N=I,_=T,w=false;for(let b=0;b<t.length;b++){let{pressure:rt}=t[b],{point:j,vector:V,distance:on,runningLength:it}=t[b],pt=b===t.length-1;if(!pt&&d-it<3)continue;r?(i&&(rt=Ke(C,on,n)),P=qe(n,r,rt,o)):P=n/2,W===void 0&&(W=P);let cn=it<g?h(it/g):1,ln=d-it<k?p((d-it)/k):1;P=Math.max(.01,P*Math.min(cn,ln));let re=(pt?t[b]:t[b+1]).vector,Ct=pt?1:He(V,re),un=He(V,F)<0&&!w,ie=Ct!==null&&Ct<0;if(un||ie){te(S,F),Ut(S,S,P);for(let dt=0;dt<=1;dt+=.07692307692307693)ee(X,j,S),Ze(X,X,j,ft*dt),N=[X[0],X[1]],x.push(N),Ve(J,j,S),Ze(J,J,j,ft*-dt),_=[J[0],J[1]],$.push(_);I=N,T=_,ie&&(w=true);continue}if(w=false,pt){te(S,V),Ut(S,S,P),x.push(K(j,S)),$.push(R(j,S));continue}qn(S,re,V,Ct),te(S,S),Ut(S,S,P),ee(X,j,S),N=[X[0],X[1]],(b<=1||De(I,N)>y)&&(x.push(N),I=N),Ve(J,j,S),_=[J[0],J[1]],(b<=1||De(T,_)>y)&&($.push(_),T=_),C=rt,F=V}let M=[t[0].point[0],t[0].point[1]],v=t.length>1?[t[t.length-1].point[0],t[t.length-1].point[1]]:R(t[0].point,[1,1]),q=[],z=[];if(t.length===1){if(!(g||k)||u)return Vn(M,W||P)}else{g||k&&t.length===1||(c?q.push(...Hn(M,$[0],13)):q.push(...Dn(M,x[0],$[0])));let b=Ue(Rn(t[t.length-1].vector));k||g&&t.length===1?z.push(v):f?z.push(...Zn(v,b,P,29)):z.push(...Qn(v,b,P))}return x.concat(z,$.reverse(),q)}var Je=[0,0];function Ye(t){return t!=null&&t>=0}function Yn(t,e={}){let{streamline:n=.5,size:s=16,last:r=false}=e;if(t.length===0)return[];let i=.15+(1-n)*.85,o=Array.isArray(t[0])?t:t.map(({x:f,y:p,pressure:d=Ee})=>[f,p,d]);if(o.length===2){let f=o[1];o=o.slice(0,-1);for(let p=1;p<5;p++)o.push(Qe(o[0],f,p/4))}o.length===1&&(o=[...o,[...R(o[0],Ie),...o[0].slice(2)]]);let a=[{point:[o[0][0],o[0][1]],pressure:Ye(o[0][2])?o[0][2]:.25,vector:[...Ie],distance:0,runningLength:0}],l=false,u=0,c=a[0],h=o.length-1;for(let f=1;f<o.length;f++){let p=r&&f===h?[o[f][0],o[f][1]]:Qe(c.point,o[f],i);if(Fn(c.point,p))continue;let d=In(p,c.point);if(u+=d,f<h&&!l){if(u<s)continue;l=true}ee(Je,c.point,p),c={point:p,pressure:Ye(o[f][2])?o[f][2]:Ee,vector:tn(Je),distance:d,runningLength:u},a.push(c)}return a[0].vector=a[1]?.vector||[0,0],a}function nn(t,e={}){return Jn(Yn(t,e),e)}var U=t=>Math.round(t*1e3)/1e3;var sn=(t,e,n)=>t+(e-t)*n;var Kn=t=>Math.max(0,Math.min(1,t));function rn(t){switch(t.kind){case"rect":return[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}];case"polygon":return t.points;case"circle":{const e=[];for(let n=0;n<24;n++){const s=n/24*Math.PI*2;e.push({x:t.cx+Math.cos(s)*t.r,y:t.cy+Math.sin(s)*t.r})}return e}case"ellipse":{const e=[];for(let n=0;n<28;n++){const s=n/28*Math.PI*2;e.push({x:t.cx+Math.cos(s)*t.rx,y:t.cy+Math.sin(s)*t.ry})}return e}default:return null}}function Un(t){if(t.length<2)return"";const e=[`M${U(t[0][0])},${U(t[0][1])}`];for(let n=1;n<t.length;n++){const[s,r]=t[n];const[i,o]=t[(n+1)%t.length];e.push(`Q${U(s)},${U(r)} ${U((s+i)/2)},${U((r+o)/2)}`)}e.push("Z");return e.join(" ")}function ts(t,e,n,s){const r=n?[...t,t[0]]:t;const i=[];for(let a=0;a<r.length-1;a++){const l=r[a],u=r[a+1];const c=Math.hypot(u.x-l.x,u.y-l.y)||1;const h=Math.max(1,Math.ceil(c/14));const f=-(u.y-l.y)/c,p=(u.x-l.x)/c;for(let d=0;d<h;d++){if(a>0&&d===0)continue;const g=d/h;const k=!n&&(a===0&&d===0||a===r.length-2&&d===h);const y=k?0:(e()-.5)*2*s;const x={x:sn(l.x,u.x,g)+f*y,y:sn(l.y,u.y,g)+p*y};const $=(a+g)/Math.max(1,r.length-1);const C=Kn(.52+Math.sin($*Math.PI*2)*.12+(e()-.5)*.16);i.push([x.x,x.y,C])}}const o=r[r.length-1];i.push([o.x,o.y,n?i[0]?.[2]??.55:.46]);return i}function se(t,e,n){if(t.length<2)return"";const s=ts(t,e,n.closed,1);const r=nn(s,{size:n.width,thinning:.58,smoothing:.62,streamline:.35,simulatePressure:false,start:{cap:true,taper:n.closed?0:10},end:{cap:true,taper:n.closed?0:14},last:true});return Un(r)}function es(t,e,n,s,r){const i=t.map(a=>({x:a.x+(e()-.5)*3,y:a.y+(e()-.5)*3}));const o=i.map((a,l)=>`${l?"L":"M"}${U(a.x)},${U(a.y)}`).join(" ")+" Z";return`<path d="${o}" fill="${n}" fill-opacity="${s}" stroke="none" />
|
|
3
|
+
<path d="${o}" fill="none" stroke="${n}" stroke-width="1.4" stroke-opacity="${r}" />`}var ns=(t,e)=>{const n=e.style?.stroke??"jittered";const s=e.style?.fill??"none";const r=s==="wash"&&e.fill!==void 0;const i=n==="freehand";const o=e.opacity?.fill===void 0?void 0:Number(e.opacity.fill);const a=e.opacity?.stroke===void 0?void 0:Number(e.opacity.stroke);if(!r&&!i)return null;const l=[];if(r){const c=jt((e.seed^2654435769)>>>0);const h=t.kind==="path"?null:rn(t);if(h){l.push(es(h,c,e.fill,o??e.style?.washOpacity??.3,e.style?.washEdge??.34))}else if(t.kind==="path"){l.push(`<path d="${t.d}" fill="${e.fill}" fill-opacity="${o??e.style?.washOpacity??.3}" stroke="${e.fill}" stroke-width="1.4" stroke-opacity="${e.style?.washEdge??.34}" />`)}}if(i&&!e.dash){const c=jt(e.seed||1);const h=Math.max(2.5,e.width*2.2);let f="";if(t.kind==="polyline"){f=se(t.points,c,{width:h,closed:false})}else if(t.kind==="line"){f=se([{x:t.x1,y:t.y1},{x:t.x2,y:t.y2}],c,{width:h,closed:false})}else{const p=rn(t);if(p)f=se(p,c,{width:h,closed:true})}if(f){const p=e.strokeProjection?[...e.strokeProjection.opacity!==void 0?[`opacity="${O(String(e.strokeProjection.opacity))}"`]:[],...e.strokeProjection.paintOrder!==void 0?[`paint-order="${O(e.strokeProjection.paintOrder)}"`]:[],...e.strokeProjection.mixBlendMode!==void 0?[`style="mix-blend-mode:${e.strokeProjection.mixBlendMode}"`]:[]].join(" "):"";const d=a===void 0?"":` fill-opacity="${O(String(a))}"`;l.push(`<path d="${f}" fill="${e.stroke}" stroke="none"${d}${p?` ${p}`:""} />`);return l.join("\n")}}const u=je(t,e.seed,e.stroke,e.width,r?void 0:e.fill,e.p,e.dash,e.strokeProjection,e.opacity);if(u)l.push(u);return l.length>0?l.join("\n"):null};var an=Yt("hybrid",ns);var ss=Object.freeze([Bt,Fe,an]);for(const t of ss){if(t!==Bt)ye(t)}
|
|
4
|
+
//# sourceMappingURL=chunk-UA234O4M.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var e="New diagrams: author Mermaid source directly, then parse \u2192 verify \u2192 render or return it.";var t="Existing structured diagrams: parse \u2192 narrow \u2192 mutate \u2192 verify \u2192 serialize.";var r="`buildMermaid(kind, ops)` / `createMermaid(kind)` build a diagram from typed ops when you are generating one programmatically (for example, from data).";var a="Narrowing selects a structured, typed family with an as* helper. It does not select one element or freeze layout coordinates.";var i=`${e} ${r}`;export{t as a,a as b,i as c};
|
|
2
|
+
//# sourceMappingURL=chunk-XU5LPD2D.js.map
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import{b as ce}from"./chunk-DQDKA5ND.js";import"./chunk-NKNFOREZ.js";import{b as qe}from"./chunk-GVCHLSHH.js";import{A as We,E as Be,F as Je,H as Ge,I as Ve,O as se,P as je,Q as ze,R as Ue,S as Ye,g as Me,h as Le,k as De,n as Fe,t as X,u as K,x as Pe,y as $e}from"./chunk-7CRDX2QR.js";import{i as Y,k as Se,l as Oe,o as te,oa as P,p as Ne,qa as ie,r as Ae,ra as O}from"./chunk-JZOJ4YGS.js";import{Fc as Re,Gc as _e,gc as q,uh as H}from"./chunk-EHCMJUMD.js";import"./chunk-UA234O4M.js";import{Xc as Ie,dd as re,ed as Ce,fd as ne,xb as xe}from"./chunk-OMY6NRQD.js";import{a as hr,b as gr,c as N,d as p,e as fr,f as He,g as yr,h as wr,i as br,j as de,k as At,l as m,m as l,n as Ke,o as W,p as Qe}from"./chunk-MKE7GNYU.js";import{a as Xe,b as Q,c as $}from"./chunk-XU5LPD2D.js";import{A as T,B as Ee,H as Te,K as F,L as oe,M as ae,N as M}from"./chunk-O7H2UX5K.js";import"./chunk-3LGLPG33.js";import"./chunk-VUFVLGTH.js";import{spawnSync as Mt}from"child_process";import{existsSync as B,mkdtempSync as Lt,readFileSync as R,statSync as Dt,watch as Ft,writeFileSync as Z}from"fs";import{tmpdir as Pt}from"os";import{basename as lt,dirname as $t,join as ut,resolve as J}from"path";var Ze={EMPTY_DIAGRAM:{summary:"Diagram contains no renderable elements",what:"the source parses to a diagram with no drawable content.",triggers:"A bare header like <code>flowchart TD</code> with no statements after it, a body containing only comments, or a mutation sequence that removed the last node, message, or task.",fix:"Add at least one element \u2014 <code>add_node</code>/<code>add_edge</code> for flowcharts, <code>add_participant</code>/<code>add_message</code> for sequence, <code>add_task</code> for gantt/journey \u2014 or check that the intended body was not lost before serializing.",example:"flowchart TD",origins:["source"]},EDGE_MISANCHORED:{summary:"Edge endpoint does not attach to a real node / participant",what:"an edge, message, or dependency references an endpoint that is not in the diagram.",triggers:"A gantt <code>after</code>/<code>until</code> dependency naming a missing task, a class <code>note for</code> a class that does not exist, or a diagram body assembled outside the parser whose edges, messages, or commit parents name missing endpoints. The typed <code>remove_node</code> and <code>remove_participant</code> mutations drop the attached edges and messages themselves.",fix:"Add the missing endpoint (<code>add_node</code>, <code>add_participant</code>, <code>add_task</code>) or retarget/remove the dangling edge (<code>remove_edge</code>, <code>remove_message</code>).",example:"gantt\n dateFormat YYYY-MM-DD\n section Build\n Design :design, 2026-01-01, 2d\n Ship :ship, after review, 3d",origins:["source"]},OFF_CANVAS:{summary:"Node or edge segment lies outside the canvas",what:"a positioned node or edge route extends past the computed canvas on the reported axis.",triggers:"Never in normal operation \u2014 the engine sizes the canvas around content, so this is a tripwire that fires only when a layout pass moves geometry after the canvas was sized. Layout is deterministic, so a firing input reproduces byte-identically.",fix:"Not fixable by editing the diagram content itself: simplify or remove the construct that provokes it, and report the source as a renderer bug so the layout defect gets fixed.",origins:["engine"]},GROUP_BREACH:{summary:"Member node lies outside its group's bounds",what:"a node that belongs to a subgraph or group is positioned outside its group rectangle.",triggers:"An engine-bug tripwire like <code>OFF_CANVAS</code>: deeply nested subgraphs combined with cross-group edges are historically where containment slipped. The warning names both the group and the escaping member.",fix:"Flatten the nesting or move the member out of the group (source edit, or <code>remove_node</code> then re-add outside the subgraph). A reproducible breach is a renderer bug worth reporting with the source.",origins:["engine"]},UNKNOWN_SHAPE:{summary:"Shape name unrecognized; default used",what:"a node carries a shape outside the renderer\u2019s known vocabulary and falls back to a plain rectangle, or an architecture service names an icon the renderer cannot resolve and gets a text glyph instead.",triggers:"Shape syntax the parser modeled but the renderer does not draw \u2014 typically newer Mermaid shape names reaching a structured flowchart or state graph \u2014 or an architecture icon that is neither built in nor in the bundled icon set.",fix:"Switch the node to a supported shape (rectangle, rounded, diamond, stadium, circle, hexagon, cylinder, \u2026) or the service to a supported icon with a source edit; the diagram still renders meanwhile, so this is a warning rather than an error.",origins:["source"]},LABEL_OVERFLOW:{summary:"A label's longest rendered line exceeds the character cap (default 40, `labelCharCap`): `<br>` and `\\n` split lines, XML entities count as one character, and formatting tags are stripped. Families that draw text literally (Pie, Timeline, Gantt, XYChart, GitGraph, Radar) count `<br>` and tags as characters, as drawn. Payload includes `charCount` and `limit`. Character-based, no font-table dependency.",guideNote:"a label's longest displayed line is over the char cap \u2014 `<br>`/`\\n` split lines, XML entities decode to one char, formatting tags strip (families that draw text literally count them); default cap 40, raise via `labelCharCap` / `am verify --label-cap N` when long labels are intentional instead of truncating the user's text",what:"a label\u2019s longest rendered line exceeds the character cap (default 40), which hurts layout and readability. The count measures what the renderer draws: <code><br></code> starts a new line, XML entities like <code>&#160;</code> count as one character, and formatting tags are stripped, except in the families that draw text literally (Pie, Timeline, Gantt, XYChart, GitGraph, Radar), where <code><br></code> and tags count as characters.",triggers:"Prose sentences pasted into node labels, edge labels, message text, or section/period titles \u2014 common when an agent copies requirement text verbatim into the diagram. Multi-line labels fire only when a single rendered line exceeds the cap.",fix:"Shorten the text with <code>set_label</code>, <code>set_message_text</code>, or the matching family mutation; raise <code>labelCharCap</code> in <code>VerifyOptions</code> only when long labels are genuinely intended.",example:"flowchart LR\n A[This label is far longer than the forty character cap] --> B[Done]",origins:["source"]},UNRESOLVABLE_SCHEDULE:{summary:"The diagram parses and round-trips but its semantics cannot resolve, so rendering will fail loudly. Emitted for structured gantt bodies whose scheduler raises a named `GANTT_*` error (unknown task reference, bad calendar date, dependency cycle, everything-excluded calendar); the payload's `reason` carries that error.",guideNote:"a gantt parses but its schedule cannot resolve, so render would fail; `reason` names the `GANTT_*` error",what:"a gantt schedule cannot be resolved to concrete dates, so bars cannot be positioned.",triggers:"A task whose <code>after</code>/<code>until</code> expression references a task id that does not exist, a start/end that cannot be parsed against the declared <code>dateFormat</code>, a dependency cycle, or <code>excludes</code> that leave no working day. The warning carries the engine reason string.",fix:"Point the reference at a real task id or give the task explicit dates with the <code>set_task_dates</code> mutation (or edit the offending source line named in the reason).",example:"gantt\n title Release\n dateFormat YYYY-MM-DD\n section Build\n Ship :ship, after review, 3d",origins:["source"]},RENDER_FAILED:{summary:"Any family: the parser, the strict render parser, layout, or theme colors reject the source or its configuration, so rendering would fail; `origin` says which (`source` or `config`). Generalizes `UNRESOLVABLE_SCHEDULE`'s seam-closing \u2014 a clean verify proves the diagram actually renders; the payload's `reason` carries the renderer error. A defect in Agentic Mermaid itself is `INTERNAL_ERROR` instead.",guideNote:"the parser, the strict render parser, layout, or theme colors reject the source or its configuration (any family; `origin` says which), so rendering would fail; `reason` carries the renderer error \u2014 a clean verify proves the diagram actually renders",what:"the source or its configuration makes parsing or rendering throw, so <code>am render</code> would fail instead of producing an artifact.",triggers:'With <code>origin: "source"</code>, source the parser or the render path rejects: malformed frontmatter or statements, an unrecognized diagram header, a construct the strict render parser cannot handle, an invalid authored style color, or a diagram over a host work limit. With <code>origin: "config"</code>, configuration the render path rejects: an invalid theme or family config color, malformed config, or an invalid render option. The warning\u2019s <code>reason</code> carries the renderer\u2019s message. A failure caused by a defect in Agentic Mermaid is reported as <code>INTERNAL_ERROR</code>, not as this code.',fix:"Return the structured error and the source rather than a fabricated artifact; fix what <code>reason</code> names, in the source or the configuration as <code>origin</code> says (for example the invalid color), or simplify, split, or drop the construct it points at. A reproducible failure on well-formed source is still a renderer bug worth reporting.",origins:["source","config"]},INTERNAL_ERROR:{summary:"Agentic Mermaid hit an internal defect while drawing this source; it is not caused by the source. `defaultRender` says whether an ordinary render still produces output: `succeeds-unchecked` \u2014 it does, but the extra consistency checks verify runs failed, so its layout evidence cannot be trusted; `fails` \u2014 rendering throws. The payload's `reason` carries the internal error. Do not rewrite the diagram to work around it; report it with the source.",guideNote:"Agentic Mermaid hit an internal defect, not caused by the source; `defaultRender` is `succeeds-unchecked` when an ordinary render still produces output that the failed consistency checks cannot vouch for, or `fails` when rendering throws \u2014 do not rewrite the diagram to work around it; report it with the source",what:"Agentic Mermaid hit an internal defect while drawing this source; the failure is not caused by the source.",triggers:"A failed internal consistency check \u2014 a lowered Scene that disagrees with its own derivation, a broken layout-pass contract, a layout that could not be certified \u2014 or a runtime error such as a <code>TypeError</code> inside the engine. <code>defaultRender</code> says whether an ordinary render still produces output: <code>succeeds-unchecked</code> when it does, but the extra consistency checks verify runs failed, so its layout evidence cannot be trusted; <code>fails</code> when rendering throws.",fix:"Do not rewrite the diagram to work around it. Report it with the source and the warning\u2019s <code>reason</code>; layout is deterministic, so the source reproduces it exactly. A typed edit to a diagram that already had this defect is still accepted.",origins:["engine"]},NODE_OVERLAP:{summary:"Two laid-out node bounding boxes intersect",what:"two nodes\u2019 boxes intersect in the final layout; the warning reports the pair and the overlap area in pixels.",triggers:"The deterministic layout separates nodes by construction, so no small flowchart source fires this \u2014 it appears only when a family adapter or post-pass produces colliding boxes on dense inputs. It is a tripwire, not an everyday lint.",fix:"Shorten the labels of the named pair or reduce local density; if the overlap persists on a stable input, treat it as a layout defect and report the source.",origins:["source","engine"]},CONTENT_OCCLUDED:{summary:"Final layout hides authored text or an interaction marker",what:"a measured label plate, card or header covers authored text or an interaction marker in the final drawing.",triggers:"Dense relationships competing for a label corridor, containment relationships with insufficient clearance, or authored label offsets that move text over protected content. The warning names the affected interaction.",fix:"Remove the conflicting label offset, increase available space or split the view. Persistent occlusion without authored offsets is a renderer defect. Verification fails because retained metadata alone does not make hidden content readable.",origins:["source","engine"]},LAYOUT_LIMIT_EXCEEDED:{summary:"Preserved content exceeds an explicitly requested layout budget",what:"the minimum measured geometry or explicit placement constraints exceed a requested layout budget.",triggers:"A compact C4 width budget smaller than a card, nested boundary, protected label corridor or authored placement constraint can accommodate. Content is retained at its legible size.",fix:"Increase the requested width, allow wrapping, remove explicit placement constraints or split the diagram. The warning reports a limitation rather than silently shrinking or dropping content.",origins:["source","config"]},ROUTE_SELF_CROSS:{summary:"An edge route crosses itself",what:"a single edge\u2019s routed polyline crosses over itself.",triggers:"A routing tripwire on the final geometry: the router avoids self-intersection, so a firing means dense cyclic routing degraded. The warning names the edge and the crossing count.",fix:"Remove or redirect the redundant edge (<code>remove_edge</code>, then <code>add_edge</code> along a simpler path); a persistent self-cross on unchanged source is an engine bug to report.",origins:["engine"]},ROUTE_HITCH:{summary:"An edge bends although a direct lane for it is provably clear (route-contract tripwire)",what:"an edge bends although a clear straight lane exists for it; the warning reports how far the route strays from that lane, in pixels.",triggers:"The layout certifies clear lanes when routes are frozen; a hitch means a later pass mutated geometry after certification. Agents cannot cause this from source alone.",fix:"Simplify the crossing edges near the named edge if a quick fix is needed, and report the reproducing source \u2014 the certificate/geometry mismatch is an engine defect.",origins:["engine"]},ROUTE_UNEXPLAINED_BEND:{summary:"An edge contains a diagonal segment under orthogonal routing (route-contract tripwire)",what:"an orthogonally-routed edge contains a diagonal segment, a bend its route certificate cannot explain.",triggers:"Flowchart and state routes are orthogonal and certified; a diagonal segment on a forward or feedback edge means post-certification geometry drift. Not reachable from well-formed source in normal operation.",fix:"No source-level fix is expected to be needed; if verify reports it, capture the source and report it as a renderer bug \u2014 determinism makes the reproduction exact.",origins:["engine"]},ROUTE_LABEL_ON_SHARED_TRUNK:{summary:"A label pill sits on a line segment another edge shares (route-contract tripwire)",what:"an edge label sits on a line segment shared with another edge, so it is ambiguous which edge it names.",triggers:"Fan-in/fan-out patterns where several labeled edges merge onto a shared trunk and a label pill lands on the shared piece rather than the edge\u2019s own segment.",fix:"Shorten the label with <code>set_label</code> so it fits the edge\u2019s exclusive segment, or restructure the fan so the labeled edge has its own approach.",origins:["source","engine"]},ROUTE_SELF_LOOP_OCCUPANCY:{summary:"A self-loop certificate has invalid side/boundary geometry or collides with another loop/label (route-contract tripwire)",what:"a self-loop cannot reserve a clear side, boundary span, route corridor, or label area without colliding with another loop or route.",triggers:"Several self-loops competing for the same node side, or a later route/label pass entering space already certified for a loop. The warning names the conflict kind and, when applicable, the other edge.",fix:"Move one relationship to a different endpoint or remove a redundant loop. If it persists on unchanged source, report it as a route-allocation defect.",origins:["source","engine"]},ROUTE_CONTAINER_MISANCHOR:{summary:"A container edge does not terminate on the container border (route-contract tripwire)",what:"an edge attached to a subgraph or group does not terminate on the container\u2019s border.",triggers:"Container-anchored edges must end exactly on the group rectangle; a miss means the border moved after routing. This is a tripwire over final geometry rather than a source mistake.",fix:"Re-anchor the edge to a member node instead of the container as a workaround, and report the source \u2014 the container anchor contract is the engine\u2019s to uphold.",origins:["engine"]},ROUTE_SHAPE_MISANCHOR:{summary:"An endpoint is off the rendered shape boundary (route-contract tripwire)",what:"an edge endpoint does not sit on the outline of the node shape it connects to (e.g. off a diamond\u2019s facet).",triggers:"Endpoint-on-shape is checked against the final node geometry; a miss usually accompanies a node that changed size or shape after routes were frozen.",fix:"Switching the node to a simpler shape (rectangle) is the mechanical workaround; the underlying anchor drift is an engine defect worth reporting with the source.",origins:["engine"]},ROUTE_STALE_AFTER_NODE_MOVE:{summary:"An endpoint detached from its node entirely, or another node sits on the edge's route (route-contract tripwire)",what:"an edge still follows a corridor computed before a node moved: an endpoint anchors where its node used to be, or another node now sits on the route.",triggers:"A compaction or alignment pass moved a node after edge routing without re-anchoring the affected edges. Not producible from source alone in normal operation.",fix:"No diagram edit reliably clears it; report the reproducing source. If it blocks a task, removing and re-adding the named edge forces a fresh route.",origins:["engine"]},DUPLICATE_EDGE:{summary:"Flowchart/state contains an exact repeated edge with the same endpoints, label, style, and markers. Usually accidental regeneration or duplicate mutation.",what:"two edges with identical endpoints, label, style, and arrowheads \u2014 the second adds ink but no information.",triggers:"An agent re-adding an edge that already exists, typically an <code>add_edge</code> issued without checking the current edge list, or copy-pasted source lines.",fix:"Remove one copy with <code>remove_edge</code> (or delete the duplicate source line); if two parallel edges are intentional, give them distinct labels so they stop being duplicates.",example:"flowchart LR\n A[Start] --> B[Finish]\n A --> B",origins:["source"]},UNREACHABLE_NODE:{summary:"Flowchart/state contains a node not reachable from any entry root when the graph has roots. Usually a stranded branch after an edit.",what:"a node cannot be reached from any root (a node with no incoming edges) by following edges.",triggers:"Disconnected clusters left behind after <code>remove_edge</code>/<code>remove_node</code> mutations, or a cycle with no entry edge from the main flow.",fix:"Connect the node into the flow with <code>add_edge</code> from a reachable node, or delete it with <code>remove_node</code> if it is leftover.",example:"flowchart LR\n A[Start] --> B[Done]\n C[Orphan] --> D[Cycle]\n D --> C",origins:["source"]},DECISION_BRANCH_UNLABELED:{summary:"A decision diamond has two or more exits and this branch carries no condition label. ISO 5807 (10.3.1.2) and ANSI X3.5 (4.10.2) require every exit of a multi-exit decision to be labeled with its condition value.",guideNote:"a multi-exit decision diamond has an unlabeled branch",what:"a decision diamond with two or more exits has at least one unlabeled exit, so the branch condition is ambiguous.",triggers:"Adding a second exit to a diamond without a condition label. ISO 5807 / ANSI X3.5 require each exit of a multi-exit decision to be labeled with its condition value.",fix:"Label every exit \u2014 <code>set_label</code> on the unlabeled edge (e.g. <code>yes</code>/<code>no</code>) or add <code>|condition|</code> to the source line.",example:"flowchart TD\n A{Ready?} -->|yes| B[Ship]\n A --> C[Wait]",origins:["source"]},FLOW_IMBALANCE:{summary:"A sankey intermediate node (one with both inflow and outflow) receives a different total than it emits. Conservation across stages is the domain's defining property \u2014 the ribbon widths are an account \u2014 and the layout silently renders `max(in, out)`, hiding the unaccounted quantity. Payload carries `node`, `inflow`, `outflow`, and a `message` naming the unaccounted amount. Balance the flows or add an explicit remainder link (e.g. a `Losses` sink).",guideNote:"a sankey intermediate node receives a different total than it emits \u2014 conservation across stages is the domain's defining property, so the warning names the node, its inflow, its outflow, and the unaccounted amount (which otherwise renders silently as node height); balance the flows or add an explicit remainder link",what:"a Sankey intermediate node receives a different total flow than it emits, leaving part of its height without a matching ribbon.",triggers:"A node appears as both a link target and source, but the sum of incoming values differs from the sum of outgoing values beyond floating-point tolerance.",fix:"Balance the incoming and outgoing values, or add an explicit remainder link so every unit of flow has a named destination.",example:"sankey-beta\n Supply,Hub,10\n Hub,Used,7",origins:["source"]},COMMENT_DROPPED:{summary:"A parsed payload carries a known comment-loss receipt, including payloads produced by older serializers. Current built-in serializers retain detected comments; Flowchart and State anchor them to statements, and other structured families append unassociated comments. The warning carries occurrence count and original line numbers.",guideNote:"a payload carries known comment loss; current serializers retain detected comments, but cannot recover text already omitted from an older payload",what:"a record of comments already lost from a parsed artifact.",triggers:"Parsed metadata records a missing comment occurrence. No current built-in source-only reproducer is known; legacy or externally assembled payloads can still carry this receipt.",fix:"Recover the named comment text from the original source before committing the edit. Do not treat an ok flag as a losslessness certificate.",origins:["source"]},UNSUPPORTED_SYNTAX:{summary:'The source uses Mermaid syntax that is preserved losslessly but not fully modeled by local structured mutation/render semantics (for example flowchart edge IDs, edge metadata, click/href directives, or markdown strings), or, with `syntax: "empty_layout"`, the source carries content but the local layout renders a 0x0 canvas with no nodes, edges, or groups. Payload includes `syntax`, optional `line`, and `message`.',guideNote:'either a Mermaid construct (for example flowchart edge IDs, edge metadata, click/href, or markdown strings) is preserved losslessly as source but is not fully modeled by local structured mutation/render semantics, or `syntax: "empty_layout"` means the source carries content but the local layout produced a 0x0 canvas with no nodes, edges, or groups. Inspect the warning message and `verify.layout` before accepting the artifact',what:"the source uses syntax or content the local structured model cannot faithfully express.",triggers:'Flowchart <code>click</code>/<code>href</code> directives, edge IDs and edge metadata, v11 <code>@{ shape: \u2026 }</code> node metadata, markdown strings, unclosed delimiters that would silently drop content, or <code>syntax: "empty_layout"</code> when content-bearing source lays out to a 0\xD70 canvas with no nodes, edges, or groups.',fix:"For preserved Mermaid syntax, remove the directive if local rendering fidelity matters, or keep it knowing the local renderer ignores it; edits touching those lines need source-level editing rather than typed mutations. For <code>empty_layout</code>, inspect the warning message and <code>verify.layout</code>, then repair the malformed or unsupported source before accepting the artifact.",example:"flowchart LR\n A[Start] --> B[Docs]\n click B callCallback",origins:["source"]},CONTENT_DROPPED_ON_ROUNDTRIP:{summary:'The structured `{nodes, edges, groups}` tally changed across a parse \u2192 serialize \u2192 re-parse cycle, so canonical serialization is silently dropping or duplicating content even though the bytes may re-parse (payload carries `before`/`after` counts). The faithfulness analogue of `COMMENT_DROPPED` \u2014 "100% parse success is not faithfulness". Runs on every verify, for every family; opaque bodies (byte-verbatim) are exempt.',guideNote:"the structured node/edge/group tally changed across a parse \u2192 serialize \u2192 re-parse cycle \u2014 canonical serialization is silently dropping or duplicating content even though the bytes may re-parse; treat it as a faithfulness bug to report",what:"a parse \u2192 serialize \u2192 re-parse cycle lost nodes, edges, or groups by count.",triggers:"A serializer defect on unusual syntax: the faithfulness tally before and after the round trip disagrees. This is a tripwire that guards every verify; it should not fire on supported syntax.",fix:"Do not serialize the typed tree for this diagram \u2014 fall back to source-level edits so nothing is lost, and report the source; the before/after counts on the warning pinpoint what vanished.",origins:["engine"]},EVENT_SOURCE_TYPE:{summary:"An explicit Event Modeling input connects frame types outside the domain source rules. The source and connection remain renderable; inspect node, source and message.",guideNote:"inspect the named Event Modeling source and target frame types; rendering preserves the authored connection",what:"an explicit source frame has the wrong domain type for its target.",triggers:"A command sourced from something other than UI/processor, an event from something other than a command, a read model from something other than an event, or UI/processor from something other than a read model.",fix:"Correct the source reference or the authored frame type. Keep the connection when it deliberately documents a domain violation; the diagnostic remains advisory.",example:"eventmodeling\ntf 01 rmo CartItems\ntf 02 evt CartChanged ->> 01",origins:["source"]},INEFFECTIVE_CONFIG:{summary:"A Mermaid config field has no effect on this family's geometry or paint: it is accepted for config-shape compatibility but not wired (e.g. Journey's sequence-era fields `boxMargin`, `rightAngles`, \u2026), unknown to the family's config section, or given an invalid value. Payload names the `field`. Accepting-and-ignoring silently misleads migrating users; this lint says so.",guideNote:"a Mermaid config field has no effect on this family's output \u2014 it was accepted for compatibility but is not wired, is unknown to the family, or has an invalid value (the warning names the field)",what:"a Mermaid config field has no effect on this family\u2019s geometry or paint: it was accepted for compatibility but is not wired, is unknown to the family, or has an invalid value.",triggers:"Copying configuration between diagram families, using a documented upstream option that this deterministic renderer has not wired, supplying an unknown field under a known family section, or giving a field a value of the wrong type or range. The warning names the exact field.",fix:"Remove the inert field, correct an invalid value, move the setting under the family that supports it, or use a wired render option. Do not rely on the accepted value until verify stops reporting it.",example:"---\nconfig:\n flowchart:\n madeUpKey: 1\n---\nflowchart LR\n A --> B",origins:["config"]},LOW_CONTRAST:{summary:"A concrete authored paint remains authoritative but misses a measurable contrast threshold against the final resolved opaque background. Payload names the `field`, `foreground`, `background`, measured `ratio`, and required `minimum`; verification diagnoses without repainting authored intent. Transparent output is not measured because its host backdrop is unknown.",guideNote:"a concrete authored paint remains authoritative but misses a measurable contrast threshold against the final resolved opaque background; the warning reports both colors, the measured ratio, and the minimum without repainting. Transparent output is not measured because its host backdrop is unknown",what:"a concrete authored paint remains in the output but misses a measurable contrast threshold against the final resolved page background.",triggers:"An authored color such as <code>themeVariables.radar.axisColor</code> resolves to less than 4.5:1 against an opaque page. Transparent output is not measured because its host backdrop is unknown.",fix:"Choose a foreground or page color that meets the warning\u2019s <code>minimum</code> ratio. The renderer preserves explicit authored paint, so re-run verify after changing the source rather than expecting an automatic repaint.",example:'---\nconfig:\n themeVariables:\n radar:\n axisColor: "#dddddd"\n---\nradar-beta\n axis speed, cost, safety\n curve current{4,3,5}\n max 5',origins:["config"]},LABELS_HIDDEN:{summary:'A chart\'s layout left out text the source asked for because it did not fit. XY chart: `target: "x-axis"` lists the authored category names the axis does not draw (tick labels thinned to avoid overlap, or the whole category axis dropped when its widest name does not fit); `target: "data-labels"` lists the bars (`category = value`) whose value label fits neither inside the bar nor in the plot beyond its end \u2014 shorten the names, flip with `set_orientation {horizontal: true}`, or widen the value range. Quadrant chart: `target: "point-labels"` lists the points whose label collides with labels placed first \u2014 spread the points, shorten the names, or enlarge the chart. The chart still renders; `describe` still lists every category and point, so this lint is the only signal that a reader cannot see them.',guideNote:'a chart left out text the source asked for because it did not fit: for an XY chart, `target: "x-axis"` lists the category names the axis does not draw (thinned or dropped) and `target: "data-labels"` lists the bars whose value label has no room (shorten the names, flip the chart with `set_orientation {horizontal: true}`, or widen the value range); for a quadrant chart, `target: "point-labels"` lists the points whose label collides with labels placed first (spread the points, shorten the names, or enlarge the chart)',what:"an XY or quadrant chart left out text the source asked for because it did not fit: category names on the x-axis, bar value labels, or quadrant point labels.",triggers:"Many or long category names under a vertical chart, where the axis thins its tick labels to avoid overlap or drops a category axis whose widest name does not fit; a bar whose value label fits neither inside the bar nor in the plot beyond its end; or a quadrant point whose label collides with labels placed before it. <code>target</code> says which, and <code>labels</code> lists exactly what is missing.",fix:"Shorten the category names, flip the chart with <code>set_orientation {horizontal: true}</code> so categories run down the side, or widen the value range so labels have room beyond the bars. For a quadrant chart, spread the points, shorten the names, or enlarge the chart.",example:'xychart-beta\n x-axis ["North region", "South region", "East region", "West region", "Central region", "Coastal region", "Mountain region", "Desert region", "Island region", "Border region"]\n bar [12, 18, 9, 22, 15, 11, 7, 5, 3, 8]',origins:["source","config"]},SCALE_RANGE_EXCLUDES_ZERO:{summary:"The radial scale excludes zero.",what:"Radar radii are measured from an authored non-zero minimum.",triggers:"A radar chart sets min above zero.",fix:"Use min 0 for proportional radii, or retain the deliberate truncation and disclose the scale.",example:"radar-beta\n axis a, b, c\n curve x{95, 96, 99}\n min 90\n max 100",origins:["source"]},BAR_RANGE_EXCLUDES_ZERO:{summary:"An XY chart with bar series has an authored y-axis range that excludes zero. Bars grow from zero clamped into the range, so they start at the reported `baseline` and their lengths stop being proportional to their values (a truncated axis). The authored range is kept. Include zero with `set_y_axis`, or draw the series as a line.",guideNote:"an XY chart with bar series has an authored y-axis range that excludes zero, so bars start at the reported `baseline` and their lengths are not proportional to their values; include zero with `set_y_axis`, or draw the series as a line",what:"an XY chart with bar series has an authored y-axis range that excludes zero, so bar lengths are not proportional to their values.",triggers:"A <code>y-axis min --> max</code> range entirely above or below zero. Bars grow from zero clamped into the range, so every bar starts at the reported <code>baseline</code> and small differences look large.",fix:"Include zero in the range with <code>set_y_axis</code>, or draw the series as a <code>line</code>, whose position (not length) carries the value.",example:"xychart-beta\n x-axis [Q1, Q2, Q3]\n y-axis 90 --> 100\n bar [92, 95, 97]",origins:["source"]},VALUES_OUTSIDE_RANGE:{summary:"An XY chart series has values outside the authored y-axis range. A bar stops at the edge of the range, so its length understates the value, and a line point is drawn past the plot. The warning names the `series`, the `values` outside the range, and the `range`; the range is kept. Widen it with `set_y_axis`, or remove it so the axis fits the data.",guideNote:"an XY chart series has values outside the authored y-axis range: a bar stops at the edge of the range, so its length understates the value, and a line point is drawn past the plot; the warning names the `series` and its `values` outside the `range`. Widen the range with `set_y_axis`, or remove it",what:"an XY chart has values outside its authored y-axis range, so the chart misstates them: a bar stops at the edge of the range and a line point is drawn past the plot.",triggers:"A <code>y-axis min --> max</code> range that does not reach every value of a series. The warning names the <code>series</code>, the <code>values</code> outside the range, and the <code>range</code> itself; a bar chart drawn with <code>bar [5, 20]</code> on <code>0 --> 10</code> shows the two bars at a 1:2 length ratio instead of 1:4.",fix:"Widen the range with <code>set_y_axis</code> so it reaches every value, or remove the range so the axis fits the data.",example:"xychart-beta\n x-axis [a, b]\n y-axis 0 --> 10\n bar [5, 20]",origins:["source"]},BRAND_CONSTRAINT_WARNING:{summary:"A caller-selected inspect-only `contrast`, `accent-area`, or `mono-role` Brand constraint failed or could not be measured. Payload reports the constraint, `measurement`, applicable role/mark, and concrete evidence without repainting or relayout.",what:"an explicitly requested inspect-only Brand constraint failed or could not be measured.",triggers:'A StyleSpec <code>contrast</code>, <code>accent-area</code>, or <code>mono-role</code> constraint with <code>action: "warn"</code> inspects final Scene paint. Transparent or unresolved compositing contexts report unmeasurable evidence without inventing a ratio.',fix:"Inspect the structured measurement payload and adjust the role/slot paint or the constraint threshold. The renderer deliberately preserves the authored artifact and never repaints or relayouts it.",origins:["source","config"]},BRAND_CONSTRAINT_ERROR:{summary:'The same inspect-only Brand constraint contract with `action: "error"`; it preserves authored output but flips `verify.ok` so a caller can enforce its declared brand policy.',what:"a caller-selected Brand constraint failed with error action and therefore blocks verification.",triggers:'The same final-Scene rules as <code>BRAND_CONSTRAINT_WARNING</code>, selected with <code>action: "error"</code> when a project wants its declared brand policy to flip <code>verify.ok</code>.',fix:'Correct the StyleSpec or diagram paint named by the payload, or deliberately change that constraint to <code>action: "warn"</code>. Suppression does not repair the visual issue.',origins:["source","config"]}};function et(e,t,n="HANDLER_ERROR"){const r=[];for(let o=0;o<e.length;o++){try{r.push({ok:true,value:t(e[o],o)})}catch(a){const s=a instanceof Error?a.message:String(a);r.push({ok:false,error:{code:n,message:s}})}}return r}import{existsSync as me,mkdirSync as Et,readFileSync as Rt,writeFileSync as ue}from"fs";import{dirname as _t,join as le}from"path";var nt="https://agentic-mermaid.dev";var ot=`${nt}/llms.txt`;var at=`${nt}/agent-instructions.md`;var it="<!-- agentic-mermaid:start -->";var It="<!-- agentic-mermaid:end -->";var st=Y.map(e=>`\`${e.narrower}\``).join(" / ");var tt=`${it}
|
|
2
|
+
## Editing Mermaid diagrams
|
|
3
|
+
|
|
4
|
+
Use **Agentic Mermaid** whenever you create or edit Mermaid diagrams. Do not
|
|
5
|
+
regenerate an existing diagram from scratch when a typed edit path exists.
|
|
6
|
+
|
|
7
|
+
${$}
|
|
8
|
+
${Q}
|
|
9
|
+
Existing structured diagrams: parse \u2192 narrow (${st}) \u2192 mutate
|
|
10
|
+
\u2192 verify \u2192 serialize. Run verify at every commit point and never serialize a
|
|
11
|
+
diagram whose verify result you have not inspected. For styled output pass
|
|
12
|
+
\`style\` (a name like \`hand-drawn\`, a JSON record, or a stack) and \`seed\`
|
|
13
|
+
to any render call \u2014 \`npx agentic-mermaid styles\` lists what is available.
|
|
14
|
+
|
|
15
|
+
Useful entrypoints:
|
|
16
|
+
|
|
17
|
+
- Hosted discovery digest: ${ot}
|
|
18
|
+
- Hosted agent guide: ${at}
|
|
19
|
+
- Local/package guide: \`npx agentic-mermaid --agent-instructions\`
|
|
20
|
+
- Capabilities: \`npx agentic-mermaid capabilities --json\`
|
|
21
|
+
- Repo skill: \`skills/agentic-mermaid-diagram-workflow/SKILL.md\`
|
|
22
|
+
${It}
|
|
23
|
+
`;var Ct=`---
|
|
24
|
+
name: agentic-mermaid-diagram-workflow
|
|
25
|
+
description: Agent-agnostic workflow for authoring and editing Mermaid diagrams with Agentic Mermaid's parse, narrow, mutate, verify, serialize, and render APIs. Use when creating or modifying Mermaid diagrams.
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
# Agentic Mermaid \u2014 diagram workflow
|
|
29
|
+
|
|
30
|
+
Use Agentic Mermaid for Mermaid diagram work. Prefer the narrowest safe channel:
|
|
31
|
+
|
|
32
|
+
- MCP connected: use \`agentic-mermaid-mcp\` Code Mode and the global \`mermaid.*\` SDK.
|
|
33
|
+
- JS/TS available: import from \`agentic-mermaid/agent\`.
|
|
34
|
+
- Shell only: use \`npx agentic-mermaid --agent-instructions\` and \`npx agentic-mermaid capabilities --json\`.
|
|
35
|
+
|
|
36
|
+
## Safe edit loop
|
|
37
|
+
|
|
38
|
+
${$}
|
|
39
|
+
Existing structured diagrams:
|
|
40
|
+
|
|
41
|
+
1. \`parseRegisteredMermaid(source)\`.
|
|
42
|
+
2. Narrow with ${st}.
|
|
43
|
+
3. Edit with \`mutate(d, op)\`; mutation ops use \`kind\`, not \`type\`.
|
|
44
|
+
4. Run \`verifyMermaid(d)\` and inspect \`ok\`, \`warnings\`, and layout evidence.
|
|
45
|
+
5. Serialize only after inspected verification passes.
|
|
46
|
+
|
|
47
|
+
Do not concatenate strings or regenerate a whole existing structured diagram when a typed op exists. Every built-in renderable family ships a typed path when the body narrows; only opaque fallback bodies are source-level-only. If you deliberately edit source for an opaque fallback, re-parse and verify before returning it.
|
|
48
|
+
|
|
49
|
+
## Output artifacts
|
|
50
|
+
|
|
51
|
+
Agentic Mermaid outputs SVG, PNG, ASCII, Unicode, and JSON layout:
|
|
52
|
+
|
|
53
|
+
\`\`\`bash
|
|
54
|
+
npx agentic-mermaid render diagram.mmd --format svg > diagram.svg
|
|
55
|
+
npx agentic-mermaid render diagram.mmd --format png --output diagram.png
|
|
56
|
+
npx agentic-mermaid render diagram.mmd --format ascii > diagram.txt
|
|
57
|
+
\`\`\`
|
|
58
|
+
|
|
59
|
+
Docs:
|
|
60
|
+
|
|
61
|
+
- ${ot}
|
|
62
|
+
- ${at}
|
|
63
|
+
`;var Tt=JSON.stringify({mcpServers:{"agentic-mermaid":{command:"npx",args:["-y","--package","agentic-mermaid","agentic-mermaid-mcp"]}}},null,2)+"\n";function dt(e){const t=_t(e);if(!me(t))Et(t,{recursive:true})}function rt(e,t,n,r){if(me(e)&&!r){n.skipped.push(e);return}dt(e);ue(e,t);n.written.push(e)}function ct(e){const{dir:t,force:n=false}=e;const r={written:[],appended:[],skipped:[]};const o=le(t,"AGENTS.md");if(!me(o)){dt(o);ue(o,tt);r.written.push(o)}else{const a=Rt(o,"utf8");if(a.includes(it)){r.skipped.push(o)}else{const s=a.endsWith("\n")?"\n":"\n\n";ue(o,a+s+tt);r.appended.push(o)}}rt(le(t,"skills","agentic-mermaid-diagram-workflow","SKILL.md"),Ct,r,n);rt(le(t,".mcp.json"),Tt,r,n);return r}var pe=["execute","describe_sdk","render_png","describe","mutate","build"];var he=["execute","describe_sdk","render_svg","render_ascii","render_png","verify","describe","mutate","build"];function ge(e){const t=e.map(n=>`\`${n}\``);return t.length<2?t.join(""):`${t.slice(0,-1).join(", ")}, and ${t.at(-1)}`}function L(e){const t=e[0];const n=t?`${t.code}: ${t.message}`:"parse error";return{ok:false,error:{code:"PARSE_FAILED",message:n,details:e}}}function gt(e){if(typeof e!=="object"||e===null)return false;const t=e;if(t.ok!==false||typeof t.error!=="object"||t.error===null)return false;const n=t.error;return typeof n.code==="string"&&typeof n.message==="string"}function _(e){if(gt(e))return e;return{ok:false,error:ce(e)}}function ye(e){const t=O(e);if(!t.ok)throw L(t.error);if(t.value.body.kind==="preserved"){throw new _e(Re(t.value.body))}return t.value}function v(e){if(!e||e==="-"){if(process.stdin.isTTY)throw new Error("needs a file argument or piped stdin");try{return R(0).toString("utf8")}catch{return""}}if(!B(e))throw new Error(`File not found: ${e}`);return R(e,"utf8")}function b(e,t){return t instanceof Map?Object.fromEntries(t):t}function cn(e){const t=Qe(e);return"exitCode"in t?t.exitCode:Wt(t)}function Wt({args:e,json:t}){Me(e.command);try{switch(e.command){case"render":return Bt(e,t);case"verify":return jt(e);case"parse":return zt(e);case"serialize":return Ut();case"mutate":return qt(e,t);case"preview":return Qt(e,t);case"format":return Zt(e);case"describe":return er(e,t);case"capabilities":return or();case"styles":return nr(t);case"llms-txt":return ir();case"init-agent":return sr(e,t);case"batch":return ur().catch(n=>mt(e,t,n));case"render-markdown":return cr(e);default:process.stderr.write(`Unknown command: ${e.command}
|
|
64
|
+
${de}`);return l}}catch(n){return mt(e,t,n)}}function mt(e,t,n){const r=n instanceof Error?n.message:String(n);const o=/^needs a file argument|^File not found:/.test(r);const a=o?void 0:e.command==="render"||e.command==="preview"||gt(n)?_(n):void 0;if(a){if(t)process.stdout.write(JSON.stringify(a)+"\n");else process.stderr.write(`Error: ${a.error.code}: ${a.error.message}
|
|
65
|
+
`);return l}if(t)process.stdout.write(JSON.stringify({ok:false,error:{code:o?"ARG":"INTERNAL",message:r}})+"\n");else process.stderr.write(`Error: ${r}
|
|
66
|
+
`);return o?l:W}function Bt(e,t){const n=u=>{const f=p(e,u);return f===void 0?void 0:Number(f)};const r=p(e,"format")??oe;const o=p(e,"security");const a=o==="strict"?"strict":void 0;const s=p(e,"gantt-today");const i=n("target-width");if(!ae(r)){process.stderr.write(`am render: unsupported --format ${r}; expected ${F.join(", ")}
|
|
67
|
+
`);return l}const d=M(r);if(o!==void 0&&o!=="strict"){process.stderr.write("am render --security accepts only strict\n");return l}let c={};const h=p(e,"options");if(h!==void 0){try{c=rr(h)}catch(u){process.stderr.write(`am render --options: ${u instanceof Error?u.message:String(u)}
|
|
68
|
+
`);return l}}const w=p(e,"graph-layout");const x=p(e,"graph-layout-fallback");if(w!==void 0||x!==void 0){const u={backend:w??c.graphLayout?.backend??"elk",...x!==void 0||c.graphLayout?.fallback!==void 0?{fallback:x??c.graphLayout?.fallback}:{}};const f=H({graphLayout:u});if(f.length){process.stderr.write(`am render: ${f.join("; ")}
|
|
69
|
+
`);return l}c={...c,graphLayout:u}}if(i!==void 0&&(!Number.isInteger(i)||i<=0)){process.stderr.write("am render --target-width expects a positive integer number of terminal cells\n");return l}if(i!==void 0&&d.id!=="ascii"&&d.id!=="unicode"){process.stderr.write("am render --target-width is valid only with --format ascii or unicode\n");return l}const g=He.filter(u=>e.flags[u]!==void 0);if(d.id!=="png"&&g.length>0){process.stderr.write(`am render: ${g.map(u=>`--${u}`).join(", ")} ${g.length>1?"are":"is"} valid only with --format png
|
|
70
|
+
`);return l}const A=N(e,"certificates");const S=N(e,"watch");if(A&&d.id!=="layout"){process.stderr.write("am render: --certificates is valid only with --format layout\n");return l}if(S&&e.positional.length>1){process.stderr.write("am render --watch accepts exactly one input file\n");return l}let G;const ve=p(e,"style");if(ve!==void 0){try{G=vt(ve);ne(G)}catch(u){process.stderr.write(`am render --style: ${u instanceof Error?u.message:String(u)}
|
|
71
|
+
`);return l}}const V=n("seed");if(V!==void 0&&!Number.isFinite(V)){process.stderr.write("am render --seed expects a finite number\n");return l}const j={...c,...a===void 0?{}:{security:a},...G===void 0?{}:{style:G},...V===void 0?{}:{seed:V},...s===void 0?{}:{ganttToday:s},certificates:A,targetWidth:i};if(e.positional.length>1&&d.id==="png"){process.stderr.write("am render --format png accepts exactly one input; run once per file with a distinct --output path\n");return l}if(e.positional.length>1){const u=e.positional.map((f,k)=>{try{const y=v(f);const C=K(y);fe(C,`am render ${f}`);const E=we(y,r,j);return{index:k,file:f,ok:true,output:E.output,receipt:E.receipt,warnings:C}}catch(y){const C=_(y);return{index:k,file:f,ok:false,error:C?.error??{code:"RENDER_FAILED",message:y instanceof Error?y.message:String(y)}}}});process.stdout.write(JSON.stringify({ok:true,files:u})+"\n");return m}if(S&&d.id==="png"){process.stderr.write("am render --format png does not support --watch; run non-watch PNG renders with --output <file.png>\n");return l}if(S&&typeof e.positional[0]==="string"&&e.positional[0]!=="-"){return Gt(e.positional[0],r,e,t,j)}const z=v(e.positional[0]);try{ye(z)}catch(u){const f=_(u);if(!f)throw u;process.stdout.write(JSON.stringify(f)+"\n");return l}const D=K(z);const U=p(e,"o")??p(e,"output")??"";if(d.id==="png"){if(!U){process.stderr.write("am render --format png requires --output <file.png> (PNG bytes corrupt terminals if piped to stdout)\n");return l}const u=n("scale")??Te;if(!Number.isFinite(u)||u<=0){process.stderr.write("am render --scale expects a positive finite number\n");return l}const f=p(e,"bg");const k=n("fit-width");const y=n("fit-height");if(k!==void 0&&y!==void 0){process.stderr.write("am render PNG fitting accepts --fit-width or --fit-height, not both\n");return l}if(k!==void 0&&(!Number.isSafeInteger(k)||k<=0)||y!==void 0&&(!Number.isSafeInteger(y)||y<=0)){process.stderr.write("am render --fit-width/--fit-height expects a positive integer pixel value\n");return l}const C=k!==void 0?{width:k}:y!==void 0?{height:y}:void 0;const E=n("min-label-px");if(E!==void 0&&(!Number.isFinite(E)||E<0)){process.stderr.write("am render --min-label-px expects a non-negative finite number\n");return l}const xt=p(e,"font-dirs")?.split(",").map(Nt=>Nt.trim()).filter(Boolean);const St=N(e,"system-fonts");const{certificates:mr,targetWidth:pr,...Ot}=j;return Vt(z,{...Ot,scale:u,background:f,fitTo:C,minLabelPx:E,fontDirs:xt,loadSystemFonts:St},U,t,D)}fe(D,"am render");const ee=ft(z,r,j);const I=ee.output;const ke=typeof I==="string"?t?JSON.stringify({[r]:I,receipt:ee.receipt,warnings:D})+"\n":I.endsWith("\n")?I:I+"\n":JSON.stringify({...I,receipt:ee.receipt,...D.length>0?{warnings:D}:{}})+"\n";if(U){Z(U,ke);return m}process.stdout.write(ke);return m}function we(e,t,n={}){ye(e);return ft(e,t,n)}function ft(e,t,n={}){const{certificates:r,targetWidth:o,...a}=n;const s=M(t);if(!s)throw new Error(`unsupported render format: ${t}`);if(s.id==="ascii"||s.id==="unicode"){const i=Ue(e,{...a,useAscii:s.id==="ascii",targetWidth:o});return{output:i.text,receipt:i.receipt}}if(s.id==="layout"){const i=Ye(e,{...a,...r===true?{debug:true}:{}});return{output:i.layout,receipt:i.receipt}}if(s.id==="svg"){const i=je(e,a);return{output:i.svg,receipt:i.receipt}}throw new Error(`unsupported render format: ${t}`)}function yt(e,t,n={}){return we(e,t,n).output}function ln(e,t,n={}){const r=R(e,"utf8");try{const o=yt(r,t,n);return typeof o==="string"?o:JSON.stringify(o)}catch(o){const a=_(o);if(a)return JSON.stringify(a);throw o}}function Jt(e,t,n=25,r=Ft){const o=J(e);const a=lt(o);const s=()=>{try{const g=Dt(o,{bigint:true});return`${g.dev}:${g.ino}:${g.size}:${g.mtimeNs}:${g.ctimeNs}`}catch{return"missing"}};let i=s();let d;let c=false;const h=()=>{if(c)return;const g=s();if(g===i)return;i=g;if(d!==void 0)clearTimeout(d);d=setTimeout(()=>{d=void 0;if(!c)t()},n)};const w=r($t(o),{persistent:true},(g,A)=>{const S=A===null?void 0:lt(String(A));if(S===void 0||S===a)h()});const x=setInterval(h,Math.max(25,Math.min(250,n*4)));return Object.freeze({close(){c=true;if(d!==void 0)clearTimeout(d);d=void 0;clearInterval(x);w.close()}})}function Gt(e,t,n,r,o={}){const a=p(n,"output")??"";if(a&&J(a)===J(e)){process.stderr.write("am render --watch output must differ from the input file\n");return l}const s=()=>{try{const i=R(e,"utf8");fe(K(i),"am render --watch");const d=yt(i,t,o);const c=typeof d==="string"?d:JSON.stringify(d);if(a){Z(a,c);process.stderr.write(`rendered \u2192 ${a}
|
|
72
|
+
`)}else process.stdout.write(c+(c.endsWith("\n")?"":"\n"))}catch(i){const d=_(i);if(r&&d)process.stderr.write(`${JSON.stringify(d)}
|
|
73
|
+
`);else{const c=d?.error;const h=c?.message??(i instanceof Error?i.message:String(i));process.stderr.write(`render error: ${c?`${c.code}: `:""}${h}
|
|
74
|
+
`)}}};s();process.stderr.write(`watching ${e} (Ctrl-C to stop)\u2026
|
|
75
|
+
`);Jt(e,s);return m}function fe(e,t){for(const n of e){process.stderr.write(`${t}: warning ${n.code}${"field"in n?` (${n.field})`:""}: ${"message"in n?n.message:"configuration has no effect"}
|
|
76
|
+
`)}}function Vt(e,t,n,r,o=[]){try{const a=[];const s=qe(e,{...t,onWarning:c=>a.push(c)});const i=s.png;const d=[...o,...a];Z(n,i);for(const c of d)process.stderr.write(`am render --format png: warning ${c.code}: ${"message"in c?c.message:"configuration has no effect"}
|
|
77
|
+
`);if(r)process.stdout.write(JSON.stringify({ok:true,path:n,bytes:i.length,receipt:s.receipt,runtime:s.runtime,warnings:d})+"\n");return m}catch(a){if(ce(a).code!=="RENDER_FAILED")throw a;const s=a instanceof Error?a.message:String(a);process.stderr.write(`am render --format png: ${s}
|
|
78
|
+
`);return W}}function jt(e){const t=v(e.positional[0]);const n=p(e,"suppress");let r;if(n!==void 0){const c=n.split(",").map(w=>w.trim()).filter(Boolean);const h=new Set(Object.keys(T));if(c.length===0||c.some(w=>!h.has(w))){process.stderr.write("am verify --suppress accepts only known warning codes\n");return l}r=c}const o=p(e,"label-cap");let a;if(o!==void 0){if(!/^[1-9]\d*$/.test(o.trim())){process.stderr.write("am verify --label-cap must be a positive safe integer\n");return l}a=Number(o);if(!Number.isSafeInteger(a)){process.stderr.write("am verify --label-cap must be a positive safe integer\n");return l}}let s;const i=p(e,"style");if(i!==void 0){try{s=vt(i);ne(s)}catch(c){process.stderr.write(`am verify --style: ${c instanceof Error?c.message:String(c)}
|
|
79
|
+
`);return l}}const d=X(t,{suppress:r,labelCharCap:a,...s?{renderOptions:{style:s}}:{}});process.stdout.write(JSON.stringify(d,b)+"\n");return d.ok?m:be(d.warnings)}function be(e){const t=e.filter(n=>T[n.code]==="error");return t.length>0&&t.every(n=>n.code==="INTERNAL_ERROR")?W:Ke}function zt(e){const t=O(v(e.positional[0]));if(!t.ok){process.stdout.write(JSON.stringify(L(t.error))+"\n");return l}process.stdout.write(JSON.stringify(kt(t.value),b)+"\n");return m}function Ut(){const e=v("-");let t;try{t=JSON.parse(e)}catch(r){process.stderr.write(`serialize: invalid JSON: ${r.message}
|
|
80
|
+
`);return l}const n=ie(t);if(!n.ok){process.stderr.write(`serialize: ${JSON.stringify(n.error)}
|
|
81
|
+
`);return l}process.stdout.write(P(n.value));return m}function Yt(e){const t=p(e,"op")??"";const n=p(e,"ops")??"";if(t&&n)return{ok:false,error:{code:"INVALID_OP",message:"mutate accepts either --op or --ops, not both"}};if(!t&&!n)return{ok:false,error:{code:"INVALID_OP",message:"mutate requires --op <JSON> or --ops <JSON array|file.json>"}};try{if(t)return{ok:true,value:[JSON.parse(t)]};const r=B(n)?R(n,"utf8"):n;const o=JSON.parse(r);if(!Array.isArray(o))return{ok:false,error:{code:"INVALID_OP",message:"--ops must be a JSON array of MutationOps"}};if(o.length===0)return{ok:false,error:{code:"INVALID_OP",message:"--ops must contain at least one MutationOp"}};return{ok:true,value:o}}catch(r){return{ok:false,error:{code:"INVALID_OP",message:`invalid mutation JSON: ${r.message}`}}}}function wt(e,t,n=false){if(n){const d=Pe({source:e,ops:t,mode:"source-preserving"});if(!d.ok)return{ok:false,error:{...d.error,...d.opIndex!==void 0?{details:{index:d.opIndex,op:t[d.opIndex]}}:{}}};return{ok:true,source:d.source,verify:d.verify,mode:"source-preserving"}}const r=O(e);if(!r.ok){const d=L(r.error);return{ok:false,error:{code:"PARSE_FAILED",message:d.error.message,details:d.error.details}}}if(r.value.body.kind==="opaque"||r.value.body.kind==="preserved"||r.value.body.kind==="extension"||!te(r.value.kind)?.mutate){return{ok:false,error:{code:"UNSUPPORTED_FAMILY",message:`No structured mutation contract for ${r.value.kind}`}}}const o=Fe(r.value,t);if(!o.ok){const{opIndex:d,...c}=o.error;return{ok:false,error:{...c,details:{index:d,op:t[d]}}}}const a=o.value;const{accepted:s,verification:i}=$e(a,r.value);if(!s){return{ok:false,error:{code:"VERIFY_FAILED",message:"mutated diagram failed verify; source was not emitted",details:i.warnings},verify:i}}return{ok:true,source:P(a),verify:i}}function qt(e,t){const n=v(e.positional[0]);const r=Yt(e);if(!r.ok){process.stderr.write(`mutate: ${r.error.message}
|
|
82
|
+
`);return l}return Ht(wt(n,r.value,e.flags["preserve-source"]===true),t)}function Ht(e,t){if(!e.ok){process.stdout.write(JSON.stringify({ok:false,error:e.error,verify:e.verify},b)+"\n");return e.error.code==="VERIFY_FAILED"?be(e.verify?.warnings??[]):l}process.stdout.write(t?JSON.stringify({ok:true,source:e.source,verify:e.verify,...e.mode?{mode:e.mode}:{}},b)+"\n":e.source);return m}function Xt(e,t={}){const n=O(e);if(!n.ok){const i=L(n.error);return{ok:false,error:i.error}}const r=se(e,{security:t.security??"strict"});const o=n.value.meta.frontmatter?.title??"Mermaid preview";const a=pt(String(o));const s=pt(e);return{ok:true,value:`<!doctype html>
|
|
83
|
+
<html lang="en">
|
|
84
|
+
<head>
|
|
85
|
+
<meta charset="utf-8" />
|
|
86
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
87
|
+
<title>${a}</title>
|
|
88
|
+
<style>
|
|
89
|
+
body { margin: 0; min-height: 100vh; display: grid; grid-template-rows: auto 1fr; background: #f8fafc; color: #0f172a; font-family: system-ui, sans-serif; }
|
|
90
|
+
header { padding: 12px 16px; border-bottom: 1px solid #e2e8f0; background: white; }
|
|
91
|
+
main { padding: 24px; overflow: auto; }
|
|
92
|
+
.canvas { width: max-content; max-width: 100%; margin: 0 auto; background: white; box-shadow: 0 18px 70px rgba(15,23,42,.12); }
|
|
93
|
+
svg { display: block; max-width: 100%; height: auto; }
|
|
94
|
+
details { margin-top: 16px; }
|
|
95
|
+
pre { white-space: pre-wrap; background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 8px; }
|
|
96
|
+
</style>
|
|
97
|
+
</head>
|
|
98
|
+
<body>
|
|
99
|
+
<header><strong>${a}</strong></header>
|
|
100
|
+
<main>
|
|
101
|
+
<div class="canvas">${r}</div>
|
|
102
|
+
<details><summary>Mermaid source</summary><pre>${s}</pre></details>
|
|
103
|
+
</main>
|
|
104
|
+
</body>
|
|
105
|
+
</html>`}}function pt(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function Kt(e){const t=process.env.AM_OPEN_COMMAND;const n=t||(process.platform==="darwin"?"open":process.platform==="win32"?"cmd":"xdg-open");const r=t?[e]:process.platform==="win32"?["/c","start","",e]:[e];const o=Mt(n,r,{stdio:"ignore"});if(o.error||o.status!==0)return{ok:false,error:`open command failed: ${n}`};return{ok:true}}function Qt(e,t){const n=v(e.positional[0]);const r="strict";const o=p(e,"security");if(o!==void 0&&o!=="strict"){process.stderr.write("am preview --security accepts only strict\n");return l}const a=Xt(n,{security:r});if(!a.ok){process.stdout.write(JSON.stringify({ok:false,error:a.error})+"\n");return l}const s=N(e,"open");let i=p(e,"output")??"";if(!i&&s)i=ut(Lt(ut(Pt(),"am-preview-")),"preview.html");if(i){const d=J(i);Z(d,a.value);let c=false;if(s){const h=Kt(d);if(!h.ok){process.stderr.write(`am preview --open: ${h.error}
|
|
106
|
+
`);return W}c=true}if(t)process.stdout.write(JSON.stringify({ok:true,path:d,opened:c,bytes:a.value.length})+"\n");else process.stdout.write(`${d}
|
|
107
|
+
`);return m}process.stdout.write(t?JSON.stringify({ok:true,html:a.value})+"\n":a.value);return m}function Zt(e){const t=O(v(e.positional[0]));if(!t.ok){process.stderr.write(`format: parse failed: ${JSON.stringify(t.error)}
|
|
108
|
+
`);return l}const n=N(e,"canonical-wrapper")?"canonical":"verbatim";process.stdout.write(P(t.value,{wrapper:n}));return m}function er(e,t){const n=v(e.positional[0]);const r=p(e,"format");const o=r===void 0?"text":Je(r)?r:void 0;if(!o){process.stderr.write(`am describe --format must be one of: ${Be.join(", ")}
|
|
109
|
+
`);return l}const a=O(n);if(!a.ok){const d=L(a.error);if(t||o==="json")process.stdout.write(JSON.stringify(d)+"\n");else process.stderr.write(`describe: parse failed: ${d.error.message}
|
|
110
|
+
`);return l}const s=X(a.value);if(!s.ok){const d={ok:false,family:a.value.kind,warnings:s.warnings};if(t||o==="json")process.stdout.write(JSON.stringify(d,b)+"\n");else process.stderr.write(`describe: verify failed: ${s.warnings.map(c=>c.code).join(", ")}
|
|
111
|
+
`);return be(s.warnings)}if(o==="json"){const d=Ve(a.value);process.stdout.write(JSON.stringify(t?{ok:true,tree:d}:d)+"\n");return m}if(o==="facts"){const d=We(a.value);process.stdout.write(t?JSON.stringify({ok:true,facts:d})+"\n":d.join("\n")+"\n");return m}const i=Ge(a.value);process.stdout.write(t?JSON.stringify({ok:true,text:i})+"\n":i+"\n");return m}function ht(e){return Object.fromEntries(Object.entries(e).filter(t=>typeof t[1]==="string"))}function tr(e){return{...e,capabilities:e.capabilities.map(({witnessId:t,...n})=>n)}}function bt(){const e=xe;const t=new Set(Object.keys(q));const n=Ae().map(o=>{const a=te(o);const s=o in q?[...q[o]]:[];const i=s.length>0?"structured-when-narrowed":"source-level-only";return{id:o,identity:{id:a.identity.id,version:a.identity.version,compatibility:ht(a.identity.compatibility),provenance:ht(a.identity.provenance)},conformance:tr(Ne(o)),hasMutate:t.has(o),hasExtractLabels:Boolean(a.extractLabels),mutationOps:s,opFields:Le(o)?De(o):void 0,editPolicy:i,narrower:Oe(o)?Se(o)?.narrower:void 0,headers:a.headers,example:a.example}});const r=Object.keys(T).map(o=>({code:o,tier:Ee[o],severity:T[o],origins:Ze[o].origins}));return{sdkVersion:e,families:n,warningCodes:r,outputFormats:[...F]}}function vt(e){return e.split(",").map(t=>t.trim()).filter(Boolean).map(t=>{if(t.endsWith(".json")||B(t)){if(!B(t))throw new Error(`style spec file not found: ${t}`);const n=JSON.parse(R(t,"utf8"));const r=Ie(n);if(r.length>0)throw new Error(`invalid style spec ${t}: ${r.join("; ")}`);return n}return t})}function rr(e){const t=B(e)?R(e,"utf8"):e;let n;try{n=JSON.parse(t)}catch(o){throw new Error(`expected JSON object or JSON file: ${o instanceof Error?o.message:String(o)}`)}const r=H(n);if(r.length>0)throw new Error(r.join("; "));return n}function nr(e){const t=re().map(r=>({name:r.inputName,canonicalId:r.identity.id,label:r.displayLabel,kind:r.kind,isDefault:r.isDefault,backend:Ce(r.spec),...r.spec.intent?{intent:r.spec.intent}:{},blurb:r.spec.blurb??""}));if(e){process.stdout.write(JSON.stringify(t)+"\n");return m}const n=Math.max(...t.map(r=>r.name.length));for(const r of t){process.stdout.write(`${r.name.padEnd(n)} ${r.kind.padEnd(7)} ${r.blurb}
|
|
112
|
+
`)}process.stdout.write(`
|
|
113
|
+
Stack styles with: am render <file> --style <name[,name|file.json...]> [--seed N]
|
|
114
|
+
Author your own: docs/style-authoring.md (JSON records; validate with validateStyleSpec).
|
|
115
|
+
`);return m}function or(){process.stdout.write(JSON.stringify(bt())+"\n");return m}function ar(){const e=bt();const t=e.families.map(i=>i.id).join(", ");const n=e.families.filter(i=>i.hasMutate).map(i=>i.id);const r=Y.map(i=>i.narrower).join(", ");const o=e.outputFormats.join(", ");const a=e.warningCodes.map(i=>`${i.code} (${i.tier}/${i.severity})`).join(", ");const s=re().filter(i=>i.kind==="look").map(i=>`'${i.inputName}'`).join(", ");return`# Agentic Mermaid
|
|
116
|
+
|
|
117
|
+
> Agent-native Mermaid runtime: parse, verify, mutate, and round-trip
|
|
118
|
+
> Mermaid diagrams with a typed IR. Deterministic render outputs. No
|
|
119
|
+
> browser required. CLI + MCP + library.
|
|
120
|
+
|
|
121
|
+
Version: ${e.sdkVersion}
|
|
122
|
+
|
|
123
|
+
## What it does
|
|
124
|
+
|
|
125
|
+
A typed editing surface over Mermaid for AI agents. Parse a diagram to a
|
|
126
|
+
ValidDiagram, mutate it with typed ops, verify source and renderability,
|
|
127
|
+
serialize back to canonical source. Layout is deterministic (verified
|
|
128
|
+
cross-process and same-machine cross-runtime on x86_64/ARM64).
|
|
129
|
+
|
|
130
|
+
## The agent loop
|
|
131
|
+
|
|
132
|
+
${$}
|
|
133
|
+
${Xe}
|
|
134
|
+
Run verify at every commit point. Never serialize a diagram whose verify result
|
|
135
|
+
you haven't inspected.
|
|
136
|
+
|
|
137
|
+
## CLI verbs (\`am <verb>\`)
|
|
138
|
+
|
|
139
|
+
- render --format ${F.join(", ")} [--security strict] \u2014 render a diagram; PNG requires --output and does not support multi-input/watch
|
|
140
|
+
- render --style <names|file.json> --seed N \u2014 styled graphical/terminal output; comma-separate to stack (--style hand-drawn,dracula)
|
|
141
|
+
- styles [--json] \u2014 list registered styles (default + full looks + palette-only themes)
|
|
142
|
+
- parse \u2014 diagram \u2192 ValidDiagram JSON
|
|
143
|
+
- serialize \u2014 ValidDiagram JSON on stdin \u2192 canonical source (the inverse of parse)
|
|
144
|
+
- verify \u2014 structural validation (exit 3 if invalid, 4 if only INTERNAL_ERROR)
|
|
145
|
+
- mutate --op '<json>' / --ops '<json array|file>' \u2014 apply typed mutation(s), verify, then emit source
|
|
146
|
+
- preview [--output file.html] [--open] \u2014 standalone strict-mode HTML preview for user inspection
|
|
147
|
+
- format \u2014 normalize / canonicalize source
|
|
148
|
+
- describe [--format text|json|facts] \u2014 natural-language, AX-tree, or semantic facts summary
|
|
149
|
+
- capabilities --json \u2014 machine-readable capability envelope incl. editPolicy + mutationOps
|
|
150
|
+
- batch --jsonl \u2014 bulk render/verify/parse/serialize/mutate ops, one JSON envelope per line
|
|
151
|
+
- render-markdown <file.md> [--ascii] \u2014 render fenced mermaid blocks, skip invalid ones
|
|
152
|
+
- llms-txt \u2014 this document
|
|
153
|
+
- init-agent [--dir .] [--force] \u2014 write AGENTS.md section, root skills/ bundle, and .mcp.json sample
|
|
154
|
+
|
|
155
|
+
Exit codes: 0 ok, 2 arg error, 3 verify-failed, 4 internal (including a verify whose errors are all INTERNAL_ERROR).
|
|
156
|
+
|
|
157
|
+
## MCP tools
|
|
158
|
+
|
|
159
|
+
Local MCP exposes ${pe.length} tools: ${ge(pe)}.
|
|
160
|
+
Hosted MCP exposes ${he.length} tools: ${ge(he)}.
|
|
161
|
+
\`render_png\` is offline on the local server. Hosted successful deterministic
|
|
162
|
+
results may be reused by a private server-side compute cache for up to 24 hours;
|
|
163
|
+
the HTTP response is always \`cache-control: no-store\` and reports compute reuse
|
|
164
|
+
through \`x-agentic-mermaid-compute-cache\`.
|
|
165
|
+
|
|
166
|
+
## Output formats
|
|
167
|
+
|
|
168
|
+
Agentic Mermaid outputs SVG, PNG, ASCII, Unicode, and JSON layout. Full capability list: ${o}. SVG strict mode (security: 'strict') emits zero external-fetch
|
|
169
|
+
references \u2014 safe for untrusted/agent-generated diagrams. See SECURITY.md.
|
|
170
|
+
|
|
171
|
+
## Diagram families
|
|
172
|
+
|
|
173
|
+
All families parse, verify, render, round-trip: ${t}.
|
|
174
|
+
Structured mutation (${e.families.find(i=>i.hasMutate)?.editPolicy}): ${n.join(", ")}.
|
|
175
|
+
Narrowers: ${r}.
|
|
176
|
+
${Q}
|
|
177
|
+
State diagrams own a dedicated body (BUILD-19): narrow with asState; state-shaped ops apply (asFlowchart returns null on them).
|
|
178
|
+
Source-level-only: ${e.families.filter(i=>!i.hasMutate).map(i=>i.id).join(", ")||"none \u2014 every renderable family ships structured mutation"}.
|
|
179
|
+
Opaque-fallback bodies (unmodeled syntax) round-trip losslessly via preserved source (never silently dropped) and stay source-level only.
|
|
180
|
+
|
|
181
|
+
## Warning codes
|
|
182
|
+
|
|
183
|
+
${a}
|
|
184
|
+
|
|
185
|
+
## Library
|
|
186
|
+
|
|
187
|
+
\`import { parseRegisteredMermaid, mutate, verifyMermaid, analyzeMermaid,
|
|
188
|
+
analyzeMermaidSource, serializeMermaid, renderMermaidASCII,
|
|
189
|
+
renderMermaidPNG, renderMermaidSVG, renderMermaidASCIIWithMeta,
|
|
190
|
+
describeMermaid, asciiToMermaid, verifyNoExternalRefs,
|
|
191
|
+
registerStyle, knownStyles, validateStyleSpec } from 'agentic-mermaid/agent'\`
|
|
192
|
+
|
|
193
|
+
## Styles
|
|
194
|
+
|
|
195
|
+
Every render call accepts style: a registered look name (${s}), any palette
|
|
196
|
+
name, an inline JSON spec, or a stack
|
|
197
|
+
merged left \u2192 right ({ style: ['hand-drawn', 'dracula'] }). seed re-rolls
|
|
198
|
+
ink wobble, never layout \u2014 (source, style, seed) reproduces an image
|
|
199
|
+
exactly. Custom styles are data: validateStyleSpec(json) checks untrusted
|
|
200
|
+
records, registerStyle({ name, \u2026 }) makes them addressable by name.
|
|
201
|
+
Authoring guide + quality rubric: docs/style-authoring.md.
|
|
202
|
+
|
|
203
|
+
## Docs
|
|
204
|
+
|
|
205
|
+
- docs/README.md \u2014 documentation index and structure
|
|
206
|
+
- Instructions_for_agents.md \u2014 canonical agent-use guide
|
|
207
|
+
- AGENT_NATIVE.md \u2014 architecture/spec rationale
|
|
208
|
+
- docs/features.md \u2014 current capability inventory
|
|
209
|
+
- docs/api.md \u2014 library/CLI/MCP API reference, including SVG/PNG/ASCII output
|
|
210
|
+
- docs/diagram-families.md \u2014 family examples and edit policy
|
|
211
|
+
- docs/theming.md \u2014 themes, CSS variables, and Shiki compatibility
|
|
212
|
+
- docs/style-authoring.md \u2014 styles: the composable Look + Palette system (stack names/specs; author custom styles as data records with the quality rubric)
|
|
213
|
+
- docs/quality.md \u2014 determinism + "good looking" rubric
|
|
214
|
+
- TODO.md \u2014 only active backlog
|
|
215
|
+
- SECURITY.md \u2014 threat model + strict-mode guarantee
|
|
216
|
+
- docs/agent-mutation-policy.md \u2014 structured-vs-source-level policy
|
|
217
|
+
- docs/agent-api-cookbook.md \u2014 copy-pasteable library/CLI/MCP recipes
|
|
218
|
+
- docs/mcp-code-mode-rationale.md \u2014 MCP surface rationale
|
|
219
|
+
- docs/agent-workflow-examples.md \u2014 runnable MCP/CLI + agent-improvement examples
|
|
220
|
+
- skills/ \u2014 agent-agnostic SKILL.md bundles for diagram workflow and live-editor development
|
|
221
|
+
- skill-evals/ \u2014 skill-eval-harness manifest, fixtures, and benchmark instructions
|
|
222
|
+
`}function ir(){process.stdout.write(ar());return m}function sr(e,t){const n=p(e,"dir");const r=n===void 0?process.cwd():J(n);const o=N(e,"force");const a=ct({dir:r,force:o});if(t){process.stdout.write(JSON.stringify({ok:true,...a})+"\n");return m}const s=i=>i.startsWith(r)?"."+i.slice(r.length):i;for(const i of a.written)process.stdout.write(` created ${s(i)}
|
|
223
|
+
`);for(const i of a.appended)process.stdout.write(` updated ${s(i)}
|
|
224
|
+
`);for(const i of a.skipped)process.stdout.write(` skipped ${s(i)} (exists; use --force if applicable)
|
|
225
|
+
`);process.stdout.write("\nNext: read AGENTS.md, connect the MCP server in .mcp.json, or run `am --agent-instructions`.\n");return m}function dr(e,t="svg"){const n=/```mermaid[ \t]*\r?\n([\s\S]*?)\r?\n```/g;const r=[];for(const o of e.matchAll(n))r.push(o[1]);return et(r,(o,a)=>{try{const s=t==="ascii"?ze(o,{useAscii:true}):se(o);return{index:a,ok:true,format:t,output:s}}catch(s){const i=_(s);return{index:a,ok:false,error:i?.error??{code:"RENDER_FAILED",message:s instanceof Error?s.message:String(s)}}}},"MARKDOWN_BLOCK_ERROR").map((o,a)=>o.ok?o.value:{index:a,ok:false,error:o.error})}function cr(e){const t=v(e.positional[0]);const n=N(e,"ascii")?"ascii":"svg";const r=dr(t,n);process.stdout.write(JSON.stringify({ok:true,blocks:r})+"\n");return m}function lr(e,t=0){let n;try{n=JSON.parse(e)}catch(o){return{ok:false,error:{code:"INVALID_JSON",message:o.message}}}if(!n||typeof n!=="object"||typeof n.op!=="string"){return{ok:false,error:{code:"INVALID_PAYLOAD",message:"missing op string"}}}const r=n.op;if(["render","verify","parse","serialize","mutate"].includes(r)&&typeof n.source!=="string"){return{ok:false,op:r,error:{code:"INVALID_PAYLOAD",message:"missing source string"}}}try{switch(r){case"render":{const o=n.options===void 0?{}:n.options;if(typeof o!=="object"||o===null||Array.isArray(o)){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:"batch render options must be a plain JSON object"}}}const{format:a,certificates:s,targetWidth:i,...d}=o;if(a!==void 0&&typeof a!=="string"){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch render option "format" must be a string'}}}const c=a??oe;if(!ae(c)||M(c)?.id==="png"){const A=F.filter(S=>M(S)?.id!=="png");return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:`batch render format must be one of ${A.join(", ")}`}}}const h=M(c);if(s!==void 0&&typeof s!=="boolean"){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch render option "certificates" must be a boolean'}}}if(s===true&&h.id!=="layout"){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch render option "certificates" is valid only with format "layout"'}}}if(i!==void 0&&(!Number.isInteger(i)||i<=0)){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch render option "targetWidth" must be a positive integer'}}}if(i!==void 0&&h.id!=="ascii"&&h.id!=="unicode"){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch render option "targetWidth" is valid only with format "ascii" or "unicode"'}}}const w=H(d);if(w.length>0){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:w.join("; ")}}}const x=d;ye(n.source);const g=we(n.source,c,{...x,...h.id==="svg"?{idPrefix:`d${t}-${x.idPrefix??""}`}:{},...s===void 0?{}:{certificates:s},...i===void 0?{}:{targetWidth:i}});return{ok:true,op:r,data:{[c]:g.output,receipt:g.receipt}}}case"verify":{const o=n.options===void 0?{}:n.options;if(typeof o!=="object"||o===null||Array.isArray(o)){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:"batch verify options must be a plain JSON object"}}}const a=Object.keys(o).filter(c=>c!=="suppress"&&c!=="labelCharCap");if(a.length>0){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:`unknown batch verify option: ${a.join(", ")}`}}}const s=o;const i=new Set(Object.keys(T));if(s.suppress!==void 0&&(!Array.isArray(s.suppress)||s.suppress.some(c=>typeof c!=="string"||!i.has(c)))){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch verify option "suppress" must be an array of known warning-code strings'}}}if(s.labelCharCap!==void 0&&(!Number.isSafeInteger(s.labelCharCap)||s.labelCharCap<=0)){return{ok:false,op:r,error:{code:"INVALID_OPTIONS",message:'batch verify option "labelCharCap" must be a positive safe integer'}}}const d=X(n.source,o);if(!d.ok){const c=JSON.parse(JSON.stringify(d,b));return{ok:false,op:r,error:{code:"VERIFY_FAILED",message:"diagram failed verify",details:c.warnings},verify:c}}return{ok:true,op:r,data:JSON.parse(JSON.stringify(d,b))}}case"parse":{const o=O(n.source);if(!o.ok){const a=L(o.error);return{ok:false,op:r,error:a.error}}return{ok:true,op:r,data:JSON.parse(JSON.stringify(kt(o.value),b))}}case"serialize":{let o;try{o=JSON.parse(n.source)}catch(s){return{ok:false,op:r,error:{code:"INVALID_JSON",message:s.message}}}const a=ie(o);if(!a.ok)return{ok:false,op:r,error:{code:"SYNTHESIZE_FAILED",message:JSON.stringify(a.error)}};return{ok:true,op:r,data:{source:P(a.value)}}}case"mutate":{const o=Object.hasOwn(n,"mutation");const a=Object.hasOwn(n,"mutations");if(o===a){return{ok:false,op:r,error:{code:"INVALID_OP",message:"mutate batch line requires exactly one of mutation or mutations[]"}}}if(a&&!Array.isArray(n.mutations)){return{ok:false,op:r,error:{code:"INVALID_OP",message:"mutate batch line mutations must be a non-empty array"}}}const s=a?n.mutations:[n.mutation];if(s.length===0)return{ok:false,op:r,error:{code:"INVALID_OP",message:"mutate batch line mutations must be a non-empty array"}};if(n.preserveSource!==void 0&&typeof n.preserveSource!=="boolean")return{ok:false,op:r,error:{code:"INVALID_OP",message:"preserveSource must be boolean"}};const i=wt(n.source,s,n.preserveSource===true);if(!i.ok)return{ok:false,op:r,error:{code:i.error.code,message:i.error.message,..."details"in i.error&&i.error.details!==void 0?{details:i.error.details}:{}},...i.verify?{verify:JSON.parse(JSON.stringify(i.verify,b))}:{}};return{ok:true,op:r,data:{source:i.source,verify:JSON.parse(JSON.stringify(i.verify,b)),...i.mode?{mode:i.mode}:{}}}}default:return{ok:false,op:r,error:{code:"UNKNOWN_OP",message:`unknown op: ${r}`}}}}catch(o){const a=_(o);if(a)return{ok:false,op:r,error:a.error};return{ok:false,op:r,error:{code:"RENDER_FAILED",message:o instanceof Error?o.message:String(o)}}}}async function ur(){if(process.stdin.isTTY)throw new Error("needs a file argument or piped stdin");const{streamJsonlBatch:e}=await import("./jsonl-RPJY6YWO.js");await e(process.stdin,process.stdout,lr);return m}function kt(e){if(e.body.kind==="flowchart"){const t=e.body.graph;return{kind:e.kind,meta:e.meta,body:{kind:"flowchart",graph:{direction:t.direction,nodes:Object.fromEntries(t.nodes),edges:t.edges,subgraphs:t.subgraphs,classDefs:Object.fromEntries(t.classDefs),classAssignments:Object.fromEntries(t.classAssignments),nodeStyles:Object.fromEntries(t.nodeStyles),linkStyles:Object.fromEntries([...t.linkStyles].map(([n,r])=>[String(n),r]))}},canonicalSource:e.canonicalSource}}return{kind:e.kind,meta:e.meta,body:e.body,canonicalSource:e.canonicalSource}}export{gr as BOOLEAN_FLAGS,yr as COMMAND_FLAGS,At as COMMAND_HELP,wr as COMMAND_POSITIONALS,hr as FLAG_SPECS,de as GLOBAL_USAGE,q as MUTATION_OPS_BY_FAMILY,fr as PNG_CLI_FLAG_BINDINGS,He as PNG_RENDER_FLAGS,bt as buildCapabilities,ar as buildLlmsTxt,Xt as buildPreviewHtml,N as flagEnabled,p as flagValue,wt as mutateSource,Kt as openPreviewFile,br as parseArgs,ln as renderFileOnce,dr as renderMarkdownBlocks,we as renderSourceToFormatWithReceipt,lr as runBatchLine,cn as runCli,Wt as runPreparedCli,Jt as watchPathForChanges};
|
|
226
|
+
//# sourceMappingURL=cli-YGGTJZH7.js.map
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Node twin of `elk-constructor.ts` (see there), shipped verbatim rather than
|
|
2
|
+
// bundled. A bundler that inlines it sees the literal require below and
|
|
3
|
+
// bundles elkjs; an unbundled ES module under Node has no `require`, so it
|
|
4
|
+
// loads elkjs through createRequire the first time a family lays out with it.
|
|
5
|
+
import { createRequire } from 'node:module'
|
|
6
|
+
|
|
7
|
+
export function elkConstructor() {
|
|
8
|
+
return typeof require === 'function'
|
|
9
|
+
? require('elkjs/lib/elk.bundled.js')
|
|
10
|
+
: createRequire(import.meta.url)('elkjs/lib/elk.bundled.js')
|
|
11
|
+
}
|