agentic-mermaid 0.5.3 → 0.5.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +34 -0
- package/dist/agent-core.d.ts +7 -7
- package/dist/agent-core.js +1 -1
- package/dist/agent.d.ts +7 -7
- package/dist/agent.js +1 -1
- package/dist/agentic-mermaid-mcp.js +1 -1
- package/dist/am.js +1 -1
- package/dist/browser-lazy/chunks/{agentic-producer-core-CC6OOLDW.js → agentic-producer-core-ECZ3CMZM.js} +1 -1
- package/dist/browser-lazy/chunks/{architecture-QUFVKYJR.js → architecture-H5LTMKQW.js} +6 -6
- package/dist/browser-lazy/chunks/{block-6J3Q63BO.js → block-566X6FNV.js} +5 -5
- package/dist/browser-lazy/chunks/{builtin-backends-7SOZZHPF.js → builtin-backends-VAFEZXKY.js} +6 -6
- package/dist/browser-lazy/chunks/{c4-SQVBZAKJ.js → c4-ZXFDLBFK.js} +5 -5
- package/dist/browser-lazy/chunks/{chunk-5X6MJX3H.js → chunk-2JQXRKBC.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-E2WMJZNM.js → chunk-37FZNMPR.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-TYZOZXUJ.js → chunk-3JTYTXA6.js} +6 -6
- package/dist/browser-lazy/chunks/{chunk-PQGPS2YV.js → chunk-4NILRBC7.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-AMJLVPUB.js → chunk-5LKPDHPC.js} +2 -2
- package/dist/browser-lazy/chunks/{chunk-BY2CPG6B.js → chunk-62MR3LWJ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-J7FFAFQF.js → chunk-64JFHCJC.js} +1 -1
- package/dist/browser-lazy/chunks/chunk-6GPDLZFQ.js +1 -0
- package/dist/browser-lazy/chunks/{chunk-VWVZGQE2.js → chunk-6UOOATQR.js} +1 -1
- package/dist/browser-lazy/chunks/chunk-7TTFBJYA.js +1 -0
- package/dist/browser-lazy/chunks/chunk-7UFOFWBA.js +20 -0
- package/dist/browser-lazy/chunks/{chunk-5B2Z7575.js → chunk-A7V5VDKN.js} +1 -1
- package/dist/browser-lazy/chunks/chunk-CPO5P4L2.js +1 -0
- package/dist/browser-lazy/chunks/chunk-EIYLJ4FI.js +20 -0
- package/dist/browser-lazy/chunks/{chunk-X2UYKWKM.js → chunk-G4JBA7HU.js} +3 -3
- package/dist/browser-lazy/chunks/{chunk-2UIA2IME.js → chunk-IUI4DYC3.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-QA6GJQ4X.js → chunk-J57YRC2M.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-BU5LHXNJ.js → chunk-LBXXKLIR.js} +3 -3
- package/dist/browser-lazy/chunks/chunk-NKW2ZNCD.js +1 -0
- package/dist/browser-lazy/chunks/{chunk-ICC7HBJX.js → chunk-O34YYEQV.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-UL6NDWLL.js → chunk-OBI5U5XU.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-YCEICNM6.js → chunk-OFOS57WQ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-OZ443IVJ.js → chunk-PSZEE64O.js} +7 -7
- package/dist/browser-lazy/chunks/{chunk-SZELX2EJ.js → chunk-PXTLV57R.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-HLWUNUCM.js → chunk-QVSZOF5M.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-2GPK4VFF.js → chunk-TT5GR5EJ.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-DF6765YX.js → chunk-V6I2VGNQ.js} +5 -5
- package/dist/browser-lazy/chunks/{chunk-CN7WTBWB.js → chunk-VRZKI33U.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-2SH76OTH.js → chunk-XHU3A432.js} +1 -1
- package/dist/browser-lazy/chunks/{chunk-NO7ZIVRU.js → chunk-YVNJDVQO.js} +1 -1
- package/dist/browser-lazy/chunks/chunk-Z7UHFVKN.js +6 -0
- package/dist/browser-lazy/chunks/{class-5QA4SCTS.js → class-XIFNVBFE.js} +8 -8
- package/dist/{zenuml/chunks/decode-BWERFDGK.js → browser-lazy/chunks/decode-5MFOG3AZ.js} +1 -1
- package/dist/browser-lazy/chunks/{elk.bundled-L4CADV5W.js → elk.bundled-RYWHIS5N.js} +8 -8
- package/dist/browser-lazy/chunks/er-VEUYJBGG.js +11 -0
- package/dist/browser-lazy/chunks/{eventmodeling-2BPLHWRN.js → eventmodeling-G7DITZX7.js} +10 -10
- package/dist/browser-lazy/chunks/{flowchart-NEIMZTB5.js → flowchart-SSFIU4EU.js} +1 -1
- package/dist/browser-lazy/chunks/{forest-implementation-AEP24AIP.js → forest-implementation-RWFF7XDV.js} +1 -1
- package/dist/browser-lazy/chunks/{gantt-RDPIFYAF.js → gantt-HQNVDX2B.js} +6 -6
- package/dist/browser-lazy/chunks/{gitgraph-N4Y5RYB7.js → gitgraph-Z5MN6M6L.js} +4 -4
- package/dist/browser-lazy/chunks/{ishikawa-LD3YBDJN.js → ishikawa-UEERNFQV.js} +2 -2
- package/dist/browser-lazy/chunks/{journey-6YQR5DJX.js → journey-3BEWWGB5.js} +6 -6
- package/dist/browser-lazy/chunks/{kanban-PLMJ7NBW.js → kanban-2WFNCWLB.js} +10 -10
- package/dist/browser-lazy/chunks/{mermaid-yaml-runtime-QVYX4EWK.js → mermaid-yaml-runtime-IK4ET4BT.js} +8 -8
- package/dist/browser-lazy/chunks/{mindmap-K2UBFO3Y.js → mindmap-R2C6SNYR.js} +4 -4
- package/dist/browser-lazy/chunks/{packet-CUW4QY6Y.js → packet-GMVCI5YZ.js} +3 -3
- package/dist/browser-lazy/chunks/{pie-7F7UUCG3.js → pie-WER45DKC.js} +7 -7
- package/dist/browser-lazy/chunks/{quadrant-TOONO2WC.js → quadrant-NCUPSFKN.js} +4 -4
- package/dist/browser-lazy/chunks/{radar-J6JVWVAX.js → radar-WLYS4YC5.js} +8 -8
- package/dist/browser-lazy/chunks/render-core-42UVWIPF.js +3 -0
- package/dist/browser-lazy/chunks/{requirement-CMAKDJPO.js → requirement-AK3NWMJ6.js} +7 -7
- package/dist/browser-lazy/chunks/{sankey-AWXQEP3F.js → sankey-C2DY6WVU.js} +4 -4
- package/dist/browser-lazy/chunks/{sequence-Q2RJRB4L.js → sequence-D4WJB44W.js} +1 -1
- package/dist/browser-lazy/chunks/{state-WRBFQEDX.js → state-YUQVESE7.js} +2 -2
- package/dist/browser-lazy/chunks/{timeline-D2KILFXM.js → timeline-BMBJJXWR.js} +4 -4
- package/dist/browser-lazy/chunks/{treemap-N3VYX5D4.js → treemap-B66XBZZ6.js} +3 -3
- package/dist/browser-lazy/chunks/{xychart-G73OGK66.js → xychart-HAVFROGT.js} +6 -6
- package/dist/browser-lazy/chunks/{zenuml-H4BXNYXR.js → zenuml-62RLYFWP.js} +7 -7
- package/dist/browser-lazy/index.js +1 -1
- package/dist/browser.global.js +507 -507
- package/dist/{chunk-DQDKA5ND.js → chunk-2DNGDTJD.js} +2 -2
- package/dist/{chunk-GVCHLSHH.js → chunk-4F2UGYTM.js} +2 -2
- package/dist/{chunk-H3NCS2XZ.js → chunk-7XYB2LNC.js} +2 -2
- package/dist/chunk-DOFB572I.js +58 -0
- package/dist/chunk-EHJI3QYE.js +52 -0
- package/dist/{chunk-UA234O4M.js → chunk-HINRNKPO.js} +2 -2
- package/dist/{chunk-JZOJ4YGS.js → chunk-KXMANAST.js} +33 -33
- package/dist/{chunk-7CRDX2QR.js → chunk-U4MT3RRE.js} +2 -2
- package/dist/{chunk-NKNFOREZ.js → chunk-WYIB6BUR.js} +2 -2
- package/dist/{cli-YGGTJZH7.js → cli-ZYIDBYNS.js} +2 -2
- package/dist/{index-EeXqJXr5.d.ts → index-Bvhprdxz.d.ts} +3 -3
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/{mcp-cli-63DYXTVD.js → mcp-cli-YVDCORWA.js} +2 -2
- package/dist/{paint-certification-6rwQjIv_.d.ts → paint-certification-BoLyr006.d.ts} +2 -2
- package/dist/{server-5NEOHOFS.js → server-4JGAVXR3.js} +2 -2
- package/dist/{svg-styles-BdnoM7AT.d.ts → svg-styles-BnCoXyYe.d.ts} +1 -1
- package/dist/svg-styles.d.ts +1 -1
- package/dist/svg-styles.js +1 -1
- package/dist/svg.d.ts +4 -4
- package/dist/svg.js +1 -1
- package/dist/{types-BcS52Mjt.d.ts → types-CLVJCaH2.d.ts} +1 -1
- package/dist/zenuml/chunks/{appearance-UOQ5KA6O.js → appearance-5RM5MVM2.js} +1 -1
- package/dist/zenuml/chunks/{builtin-backends-KDKE7YHO.js → builtin-backends-UTNWL4N3.js} +11 -11
- package/dist/zenuml/chunks/{chunk-QWX77U7G.js → chunk-3A6S6GNB.js} +2 -2
- package/dist/zenuml/chunks/{chunk-OXQWRSBM.js → chunk-55WS466K.js} +11 -11
- package/dist/zenuml/chunks/chunk-6J4BGPB2.js +29 -0
- package/dist/zenuml/chunks/chunk-CNLL4BGF.js +1 -0
- package/dist/zenuml/chunks/{chunk-RZ6XK5CD.js → chunk-IARQ24W3.js} +13 -13
- package/dist/zenuml/chunks/{chunk-42DXZ5C6.js → chunk-ZNZRIISS.js} +2 -2
- package/dist/{browser-lazy/chunks/decode-63UIZGD2.js → zenuml/chunks/decode-LDNNXEAO.js} +1 -1
- package/dist/zenuml/chunks/{mermaid-yaml-runtime-KZVU74WU.js → mermaid-yaml-runtime-A5CNJ3IE.js} +8 -8
- package/dist/zenuml/chunks/render-core-ECIWU5ZS.js +3 -0
- package/dist/zenuml/chunks/{zenuml-EA2ZFRUX.js → zenuml-N3LZMB2G.js} +8 -8
- package/dist/zenuml.d.ts +2 -2
- package/dist/zenuml.js +1 -1
- package/docs/MCP-DIRECTORY-LISTINGS.md +81 -12
- package/docs/api.md +1 -1
- package/package.json +1 -1
- package/server.json +2 -2
- package/dist/browser-lazy/chunks/chunk-4LHYF3BS.js +0 -1
- package/dist/browser-lazy/chunks/chunk-FAIMVOX5.js +0 -6
- package/dist/browser-lazy/chunks/chunk-GVOEAY52.js +0 -1
- package/dist/browser-lazy/chunks/chunk-J35HAQQF.js +0 -20
- package/dist/browser-lazy/chunks/chunk-RIVTHZAQ.js +0 -1
- package/dist/browser-lazy/chunks/chunk-Z3FDIVLN.js +0 -20
- package/dist/browser-lazy/chunks/er-7ZSKGN7Y.js +0 -11
- package/dist/browser-lazy/chunks/render-core-BZOM3K7D.js +0 -3
- package/dist/chunk-EHCMJUMD.js +0 -52
- package/dist/chunk-OMY6NRQD.js +0 -58
- package/dist/zenuml/chunks/chunk-7TVYPTDW.js +0 -1
- package/dist/zenuml/chunks/chunk-RLJEI7YN.js +0 -29
- package/dist/zenuml/chunks/render-core-V5RQ737O.js +0 -3
- /package/dist/browser-lazy/chunks/{chunk-5FQ534HP.js → chunk-BMZ24VPS.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-2I4UPL7Q.js → chunk-D6MQ7QSU.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-CQE4HQEW.js → chunk-HJVO5VC3.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-LH7HUDKW.js → chunk-L4UC3KGS.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-NMQQMRIR.js → chunk-MFTQWHUB.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-N5ELX7LR.js → chunk-PJJSDGLB.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-CSFUKSU6.js → chunk-QCU5G5PZ.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-VQYYGAXP.js → chunk-TLFX3U6S.js} +0 -0
- /package/dist/browser-lazy/chunks/{chunk-5UVGUSD6.js → chunk-YHMTSXIR.js} +0 -0
- /package/dist/zenuml/chunks/{chunk-EVPSMEKN.js → chunk-GC7IPQ5P.js} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
1
|
+
import{a as e}from"./chunk-LBXXKLIR.js";import"./chunk-37FZNMPR.js";import"./chunk-MFTQWHUB.js";import{D as t,E as i,N as n,Q as a,R as r,S as o,W as l,X as s,Y as d,Z as c,aa as h,g as g,xa as p}from"./chunk-NKW2ZNCD.js";import"./chunk-HJVO5VC3.js";import"./chunk-L4UC3KGS.js";import"./chunk-BMZ24VPS.js";import"./chunk-62MR3LWJ.js";import"./chunk-PXTLV57R.js";import{d as m}from"./chunk-J57YRC2M.js";import{a as u,e as f,l as y}from"./chunk-XHU3A432.js";import{d as x}from"./chunk-5LKPDHPC.js";import{s as b,u as _}from"./chunk-V6I2VGNQ.js";import{d as w}from"./chunk-7UFOFWBA.js";import{a as v,b as k}from"./chunk-VRZKI33U.js";import{C as F,D as S,a as $,b as M,c as C,d as W,e as R,g as L,h as I,i as z,j as q,o as E}from"./chunk-QVSZOF5M.js";import{M as B,U as T,ba as P,c as O,ca as A,j as j,na as N,oa as X,r as D,x as U}from"./chunk-G4JBA7HU.js";import{c as Y}from"./chunk-3JTYTXA6.js";import{d as H,h as Z,i as J,j as Q,k as V,n as G}from"./chunk-YVNJDVQO.js";import{Bb as K,G as ee,K as et,N as ei,Sb as en,_ as ea,a as er,o as eo,tb as el}from"./chunk-EIYLJ4FI.js";import{J as es,K as ed}from"./chunk-PJJSDGLB.js";import{a as ec}from"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";var eh=Object.freeze({id:"c4",upstreamId:"c4",maturity:"experimental",label:"C4",headers:["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"],aliases:[],config:{section:"c4",keys:["diagramMarginX","diagramMarginY","c4ShapeMargin","c4ShapePadding","width","height","boxMargin","nextLinePaddingX","c4ShapeInRow","c4BoundaryInRow","wrap","wrapPadding","maxWidth","compact","typeLegend","personFontSize","personFontWeight","person_bg_color","person_border_color","external_personFontSize","external_personFontWeight","external_person_bg_color","external_person_border_color","systemFontSize","systemFontWeight","system_bg_color","system_border_color","system_dbFontSize","system_dbFontWeight","system_db_bg_color","system_db_border_color","system_queueFontSize","system_queueFontWeight","system_queue_bg_color","system_queue_border_color","external_systemFontSize","external_systemFontWeight","external_system_bg_color","external_system_border_color","external_system_dbFontSize","external_system_dbFontWeight","external_system_db_bg_color","external_system_db_border_color","external_system_queueFontSize","external_system_queueFontWeight","external_system_queue_bg_color","external_system_queue_border_color","containerFontSize","containerFontWeight","container_bg_color","container_border_color","container_dbFontSize","container_dbFontWeight","container_db_bg_color","container_db_border_color","container_queueFontSize","container_queueFontWeight","container_queue_bg_color","container_queue_border_color","external_containerFontSize","external_containerFontWeight","external_container_bg_color","external_container_border_color","external_container_dbFontSize","external_container_dbFontWeight","external_container_db_bg_color","external_container_db_border_color","external_container_queueFontSize","external_container_queueFontWeight","external_container_queue_bg_color","external_container_queue_border_color","componentFontSize","componentFontWeight","component_bg_color","component_border_color","component_dbFontSize","component_dbFontWeight","component_db_bg_color","component_db_border_color","component_queueFontSize","component_queueFontWeight","component_queue_bg_color","component_queue_border_color","external_componentFontSize","external_componentFontWeight","external_component_bg_color","external_component_border_color","external_component_dbFontSize","external_component_dbFontWeight","external_component_db_bg_color","external_component_db_border_color","external_component_queueFontSize","external_component_queueFontWeight","external_component_queue_bg_color","external_component_queue_border_color","boundaryFontSize","boundaryFontWeight","boundary_bg_color","boundary_border_color","nodeFontSize","nodeFontWeight","node_bg_color","node_border_color","useMaxWidth","personFont","personFontFamily","external_personFont","external_personFontFamily","systemFont","systemFontFamily","system_dbFont","system_dbFontFamily","system_queueFont","system_queueFontFamily","external_systemFont","external_systemFontFamily","external_system_dbFont","external_system_dbFontFamily","external_system_queueFont","external_system_queueFontFamily","containerFont","containerFontFamily","container_dbFont","container_dbFontFamily","container_queueFont","container_queueFontFamily","external_containerFont","external_containerFontFamily","external_container_dbFont","external_container_dbFontFamily","external_container_queueFont","external_container_queueFontFamily","componentFont","componentFontFamily","component_dbFont","component_dbFontFamily","component_queueFont","component_queueFontFamily","external_componentFont","external_componentFontFamily","external_component_dbFont","external_component_dbFontFamily","external_component_queueFont","external_component_queueFontFamily","boundaryFont","boundaryFontFamily","nodeFont","nodeFontFamily","messageFont","messageFontFamily","messageFontSize","messageFontWeight"],noopKeys:["useMaxWidth","personFont","personFontFamily","external_personFont","external_personFontFamily","systemFont","systemFontFamily","system_dbFont","system_dbFontFamily","system_queueFont","system_queueFontFamily","external_systemFont","external_systemFontFamily","external_system_dbFont","external_system_dbFontFamily","external_system_queueFont","external_system_queueFontFamily","containerFont","containerFontFamily","container_dbFont","container_dbFontFamily","container_queueFont","container_queueFontFamily","external_containerFont","external_containerFontFamily","external_container_dbFont","external_container_dbFontFamily","external_container_queueFont","external_container_queueFontFamily","componentFont","componentFontFamily","component_dbFont","component_dbFontFamily","component_queueFont","component_queueFontFamily","external_componentFont","external_componentFontFamily","external_component_dbFont","external_component_dbFontFamily","external_component_queueFont","external_component_queueFontFamily","boundaryFont","boundaryFontFamily","nodeFont","nodeFontFamily","messageFont","messageFontFamily","messageFontSize","messageFontWeight"]},identity:{id:"family:c4",kind:"family",version:"1.0.0",compatibility:{core:"0.5.4"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["category","status"],semanticRoles:["prelude","title","defs","chrome","group","group-header","edge","edge-label","node","label","legend"],scenePrimitiveEvidence:[{role:"prelude",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"title",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"defs",primitive:"marker",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"document",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"chrome",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"group-header",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"edge-label",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"node",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"label",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"legend",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`C4Context
|
|
2
2
|
Person(user, "Customer")
|
|
3
3
|
System(api, "API", "Serves requests")
|
|
4
|
-
Rel(user, api, "Uses", "HTTPS")`,detect:es,detectLoose:ed}),eg=new Map([["person","person"],["box","rectangle"],["rectangle","rectangle"],["cylinder","database"],["database","database"],["db","database"],["queue","queue"],["pipe","queue"]]);function ep(e){return void 0===e?void 0:eg.get(e.trim().toLowerCase())}function em(e){return ep(e.style.shape)??e.shape}var eu=(e,t,i=0)=>{if(void 0===e)return t;if("number"!=typeof e||!Number.isFinite(e)||e<i||e>1e4)throw RangeError(`Invalid C4 numeric configuration ${JSON.stringify(e)}; expected a finite number from ${i} to 10000`);return e},ef=(e,t)=>{let i=eu(e,t,1);if(!Number.isSafeInteger(i))throw RangeError(`Invalid C4 row count ${JSON.stringify(e)}; expected a positive integer`);return i};function ey(e={},t={}){let i=!0===(e=Object.fromEntries(Object.entries(e).filter(([e,t])=>ev[e]?.valid(t)??!0))).compact;return{compact:i,typeLegend:!1!==e.typeLegend,...void 0===e.maxWidth?{}:{maxWidth:eu(e.maxWidth,1e4,1)},marginX:eu(e.diagramMarginX,i?16:24),marginY:eu(e.diagramMarginY,i?16:24),gap:eu(e.c4ShapeMargin,i?32:56),padding:eu(e.c4ShapePadding,i?10:16,4),minimumWidth:eu(e.width,i?120:150,24),minimumHeight:eu(e.height,i?60:76,24),boundaryPadding:eu(e.boxMargin,i?16:24,12),rowGap:eu(e.nextLinePaddingX,i?36:56),shapesPerRow:ef(e.c4ShapeInRow,3),boundariesPerRow:ef(e.c4BoundaryInRow,2),...!1===e.wrap?{}:{wrapWidth:eu(e.wrapPadding,i?220:260,40)},input:e,themeVariables:t}}function ex(e,t){let i="external"in e?`${e.external?"external_":""}${e.kind}${"database"===e.shape?"_db":"queue"===e.shape?"_queue":""}`:"deployment"===e.kind?"node":"boundary",{input:n,themeVariables:a}=t,r=(t,i)=>{if(void 0===t)return;let n=Y(t,"color"!==i);if(void 0===n)throw new P(`C4 ${e.id}`,i,String(t),`UpdateElementStyle(${e.id})`);return n},o=n[`${i}FontSize`],l=n[`${i}FontWeight`];return{fill:r(e.style.bgColor??n[`${i}_bg_color`]??a[`${i}_bg_color`],"fill"),stroke:r(e.style.borderColor??n[`${i}_border_color`]??a[`${i}_border_color`],"stroke"),text:r(e.style.fontColor??e.style.textColor,"color"),...void 0===o?{}:{fontSize:eu(o,13,1)},...void 0===l?{}:{fontWeight:eu("string"==typeof l&&/^\d+$/.test(l)?Number(l):l,500,1)},dashed:void 0===e.style.lineStyle?"external"in e&&e.external:"dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle}}var eb=["person","external_person",...["system","container","component"].flatMap(e=>["","external_"].flatMap(t=>["","_db","_queue"].map(i=>`${t}${e}${i}`))),"boundary","node"],e_=Object.freeze(["diagramMarginX","diagramMarginY","c4ShapeMargin","c4ShapePadding","width","height","boxMargin","nextLinePaddingX","c4ShapeInRow","c4BoundaryInRow","wrap","wrapPadding","maxWidth","compact","typeLegend",...eb.flatMap(e=>[`${e}FontSize`,`${e}FontWeight`,`${e}_bg_color`,`${e}_border_color`])]),ew=(Object.freeze(["useMaxWidth",...[...eb,"message"].flatMap(e=>[`${e}Font`,`${e}FontFamily`]),"messageFontSize","messageFontWeight"]),Object.freeze({maxWidth:1,diagramMarginX:0,diagramMarginY:0,c4ShapeMargin:0,c4ShapePadding:4,width:24,height:24,boxMargin:12,nextLinePaddingX:0,c4ShapeInRow:1,c4BoundaryInRow:1,wrapPadding:40})),ev=(()=>{let e=Object.assign(Object.create(null),{wrap:f,compact:f,typeLegend:f});for(let[t,i]of Object.entries(ew)){let n=y(i,1e4);e[t]="c4ShapeInRow"===t||"c4BoundaryInRow"===t?u("an integer from 1 through 10000",e=>Number.isSafeInteger(e)&&n.valid(e)):n}for(let t of e_)if(/FontSize$/.test(t)&&(e[t]=y(1,1e4)),/FontWeight$/.test(t)){let i=y(1,1e3);e[t]=u(i.expected,e=>i.valid("string"==typeof e&&/^\d+$/.test(e)?Number(e):e))}return Object.freeze(e)})();function ek(e){let t=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.id])),i=new Map(e.relationships.map(e=>[e.id,e.id]));return{nodes:t,relationships:i,generated:
|
|
4
|
+
Rel(user, api, "Uses", "HTTPS")`,detect:es,detectLoose:ed}),eg=new Map([["person","person"],["box","rectangle"],["rectangle","rectangle"],["cylinder","database"],["database","database"],["db","database"],["queue","queue"],["pipe","queue"]]);function ep(e){return void 0===e?void 0:eg.get(e.trim().toLowerCase())}function em(e){return ep(e.style.shape)??e.shape}var eu=(e,t,i=0)=>{if(void 0===e)return t;if("number"!=typeof e||!Number.isFinite(e)||e<i||e>1e4)throw RangeError(`Invalid C4 numeric configuration ${JSON.stringify(e)}; expected a finite number from ${i} to 10000`);return e},ef=(e,t)=>{let i=eu(e,t,1);if(!Number.isSafeInteger(i))throw RangeError(`Invalid C4 row count ${JSON.stringify(e)}; expected a positive integer`);return i};function ey(e={},t={}){let i=!0===(e=Object.fromEntries(Object.entries(e).filter(([e,t])=>ev[e]?.valid(t)??!0))).compact;return{compact:i,typeLegend:!1!==e.typeLegend,...void 0===e.maxWidth?{}:{maxWidth:eu(e.maxWidth,1e4,1)},marginX:eu(e.diagramMarginX,i?16:24),marginY:eu(e.diagramMarginY,i?16:24),gap:eu(e.c4ShapeMargin,i?32:56),padding:eu(e.c4ShapePadding,i?10:16,4),minimumWidth:eu(e.width,i?120:150,24),minimumHeight:eu(e.height,i?60:76,24),boundaryPadding:eu(e.boxMargin,i?16:24,12),rowGap:eu(e.nextLinePaddingX,i?36:56),shapesPerRow:ef(e.c4ShapeInRow,3),boundariesPerRow:ef(e.c4BoundaryInRow,2),...!1===e.wrap?{}:{wrapWidth:eu(e.wrapPadding,i?220:260,40)},input:e,themeVariables:t}}function ex(e,t){let i="external"in e?`${e.external?"external_":""}${e.kind}${"database"===e.shape?"_db":"queue"===e.shape?"_queue":""}`:"deployment"===e.kind?"node":"boundary",{input:n,themeVariables:a}=t,r=(t,i)=>{if(void 0===t)return;let n=Y(t,"color"!==i);if(void 0===n)throw new P(`C4 ${e.id}`,i,String(t),`UpdateElementStyle(${e.id})`);return n},o=n[`${i}FontSize`],l=n[`${i}FontWeight`];return{fill:r(e.style.bgColor??n[`${i}_bg_color`]??a[`${i}_bg_color`],"fill"),stroke:r(e.style.borderColor??n[`${i}_border_color`]??a[`${i}_border_color`],"stroke"),text:r(e.style.fontColor??e.style.textColor,"color"),...void 0===o?{}:{fontSize:eu(o,13,1)},...void 0===l?{}:{fontWeight:eu("string"==typeof l&&/^\d+$/.test(l)?Number(l):l,500,1)},dashed:void 0===e.style.lineStyle?"external"in e&&e.external:"dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle}}var eb=["person","external_person",...["system","container","component"].flatMap(e=>["","external_"].flatMap(t=>["","_db","_queue"].map(i=>`${t}${e}${i}`))),"boundary","node"],e_=Object.freeze(["diagramMarginX","diagramMarginY","c4ShapeMargin","c4ShapePadding","width","height","boxMargin","nextLinePaddingX","c4ShapeInRow","c4BoundaryInRow","wrap","wrapPadding","maxWidth","compact","typeLegend",...eb.flatMap(e=>[`${e}FontSize`,`${e}FontWeight`,`${e}_bg_color`,`${e}_border_color`])]),ew=(Object.freeze(["useMaxWidth",...[...eb,"message"].flatMap(e=>[`${e}Font`,`${e}FontFamily`]),"messageFontSize","messageFontWeight"]),Object.freeze({maxWidth:1,diagramMarginX:0,diagramMarginY:0,c4ShapeMargin:0,c4ShapePadding:4,width:24,height:24,boxMargin:12,nextLinePaddingX:0,c4ShapeInRow:1,c4BoundaryInRow:1,wrapPadding:40})),ev=(()=>{let e=Object.assign(Object.create(null),{wrap:f,compact:f,typeLegend:f});for(let[t,i]of Object.entries(ew)){let n=y(i,1e4);e[t]="c4ShapeInRow"===t||"c4BoundaryInRow"===t?u("an integer from 1 through 10000",e=>Number.isSafeInteger(e)&&n.valid(e)):n}for(let t of e_)if(/FontSize$/.test(t)&&(e[t]=y(1,1e4)),/FontWeight$/.test(t)){let i=y(1,1e3);e[t]=u(i.expected,e=>i.valid("string"==typeof e&&/^\d+$/.test(e)?Number(e):e))}return Object.freeze(e)})();function ek(e){let t=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.id])),i=new Map(e.relationships.map(e=>[e.id,e.id]));return{nodes:t,relationships:i,generated:en([...t.keys(),...i.keys(),...e.legend?.entries.map(e=>e.id)??[]])}}function eF(e){let t=`${e.external?"External ":""}${e.kind[0].toUpperCase()}${e.kind.slice(1)}${"database"===e.shape?": Database":"queue"===e.shape?": Queue":""}`,i=e.style.techn??e.technology;return[e.label,`[${t}${i?`: ${i}`:""}]`,e.description,e.tags.length?`[tags: ${e.tags.join(", ")}]`:void 0,e.sprite?`[sprite: ${e.sprite}]`:void 0].filter(e=>void 0!==e&&""!==e).join(`
|
|
5
5
|
`)}function eS(e){let t="deployment"===e.kind?"Deployment Node":`${"boundary"===e.kind?"":`${e.kind[0].toUpperCase()}${e.kind.slice(1)} `}Boundary`;return[e.label,`[${t}${e.type?`: ${e.type}`:""}]`,e.description,e.tags.length?`[tags: ${e.tags.join(", ")}]`:void 0,e.sprite?`[sprite: ${e.sprite}]`:void 0].filter(e=>void 0!==e&&""!==e).join(`
|
|
6
6
|
`)}function e$(e,t){let i=t.index??("C4Dynamic"===e.variant?String(t.order):void 0);return[`${void 0!==i?`${i}: `:""}${t.label}`,t.technology?`[${t.technology}]`:void 0,t.description,t.tags.length?`[tags: ${t.tags.join(", ")}]`:void 0,t.sprite?`[sprite: ${t.sprite}]`:void 0].filter(e=>void 0!==e&&""!==e).join(`
|
|
7
|
-
`)}function eM(e,t){return e.statements.find(e=>e.id===t)?.span.line}function eC(e,t){let i=ek(e),n=new Map;for(let a of e.elements){let e=`${a.external?"external-":""}${a.kind}:${a.shape}`,r=`${a.external?"External ":""}${a.kind[0].toUpperCase()}${a.kind.slice(1)}${"database"===a.shape?" / Database":"queue"===a.shape?" / Queue":""}`;if(!n.has(e)){let o=t?ex(a,t):void 0;n.set(e,{id:i.generated(`c4:legend:${e}`,["c4","legend",e]),label:r,kind:"element",shape:em(a),external:a.external,style:{...a.style,...o?.fill?{bgColor:o.fill}:{},...o?.stroke?{borderColor:o.stroke}:{}}})}}return[...t?.typeLegend!==!1&&n.size>1||e.legend?.visible?[...n.values()]:[],...e.legend?.visible?e.legend.entries:[]]}var eW=class extends RangeError{code="C4_ROUTE_WORK_LIMIT";constructor(){super("C4_ROUTE_WORK_LIMIT: physical corridor checks exceed 400000; split the diagram or reduce its relationships"),this.name="C4RouteWorkLimitError"}},eL={T:{x:0,y:-1},R:{x:1,y:0},B:{x:0,y:1},L:{x:-1,y:0}},eR=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height,ez=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function eI(e,t,i){if("T"===t||"B"===t){let n=e.cylinder?8*(1-Math.sqrt(Math.max(0,1-(2*i-1)**2))):0;return{x:e.x+e.width*i,y:e.y+("B"===t?e.height-n:n)}}let n=e.container?e.headerHeight??0:8*!!e.cylinder;return{x:e.x+("R"===t?e.width:0),y:e.y+n+(e.height-n-8*!!e.cylinder)*i}}function eE(e,t,i,n){return eI(e,t,(i+1)/(n+1))}var eq={T:"B",R:"L",B:"T",L:"R"};function eB(e){if(!e.label||!e.labelPosition||!e.labelBlock)return;let t=e.labelBlock.width+20,i=e.labelBlock.height+16;return{x:e.labelPosition.x-t/2,y:e.labelPosition.y-i/2,width:t,height:i}}var eT=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),eP=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),eO=e=>e.flatMap(e=>[e,...eO(e.children)]);function ej(e,t,i){let n=0,a=1;for(let r of["x","y"]){let o=t[r]-e[r],l=i[r]+.01,s=i[r]+("x"===r?i.width:i.height)-.01;if(.001>Math.abs(o)){if(e[r]<=l||e[r]>=s)return!1;continue}let d=(l-e[r])/o,c=(s-e[r])/o;if((n=Math.max(n,Math.min(d,c)))>=(a=Math.min(a,Math.max(d,c))))return!1}return n<a}function eA(e,t){let i=[],n=e.inlineStyle?.["stroke-width"]?1:t*("thick"===e.style?2:1),a=H.width*n,r=(e.inlineStyle?.["stroke-width"]?H.width:H.height)*n/2,o=.375*n;for(let t of[!0,!1]){if(!(t?e.hasArrowStart:e.hasArrowEnd))continue;let n=e.points.at(t?0:-1),l=(t?e.points.slice(1):e.points.slice(0,-1).reverse()).find(e=>n&&Math.hypot(e.x-n.x,e.y-n.y)>.01);if(!n||!l)continue;let s=Math.hypot(n.x-l.x,n.y-l.y),d=(n.x-l.x)/s,c=(n.y-l.y)/s,h=[n,{x:n.x-d*a-c*r,y:n.y-c*a+d*r},{x:n.x-d*a+c*r,y:n.y-c*a-d*r}],g=Math.min(...h.map(e=>e.x)),p=Math.min(...h.map(e=>e.y));i.push({...eP({x:g,y:p,width:Math.max(...h.map(e=>e.x))-g,height:Math.max(...h.map(e=>e.y))-p},o),endpoint:t?e.source:e.target,polygon:h,strokePadding:o})}return i}function eN(e,t){return[...e,...eO(t).flatMap(e=>[{x:e.x,y:e.y,width:e.width,height:e.headerHeight??0},{x:e.x,y:e.y,width:1,height:e.height},{x:e.x+e.width-1,y:e.y,width:1,height:e.height},{x:e.x,y:e.y+e.height-1,width:e.width,height:1}])]}var eX=["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"],eU=class extends U{},eD=/^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/,eY={Boundary:"boundary",Enterprise_Boundary:"enterprise",System_Boundary:"system",Container_Boundary:"container",Deployment_Node:"deployment",Node:"deployment",Node_L:"deployment",Node_R:"deployment"},eH=new Set(["Rel","BiRel","Rel_U","Rel_Up","Rel_D","Rel_Down","Rel_L","Rel_Left","Rel_R","Rel_Right","Rel_Back","RelIndex"]),eZ={U:"BT",Up:"BT",D:"TB",Down:"TB",L:"RL",Left:"RL",R:"LR",Right:"LR"},eJ=["elementName","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eQ=["from","to","textColor","lineColor","offsetX","offsetY"],eG=["tagStereo","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eK=["tagStereo","textColor","lineColor","lineStyle","sprite","techn","legendText","legendSprite"];function eV(e,t){if(!L("c4"))return;let{start:i,end:n,line:a,column:r}=e.span;R("c4",t,e.raw,{line:a,column:r,offset:i,endOffset:n,unit:"physical"})}function e0(e,t=!0){let i=e.trim();if(i.length>=2&&('"'===i[0]||"'"===i[0])&&i.at(-1)===i[0]){let e=i.slice(1,-1).trim();return t?m(e):e}return t?m(i):i}function e4(e,t,i){let n;for(let a=0;a<e.length;a++)(e[a].name??t[a])===i&&(n=e[a]);if(n)return m(ee(e0(n.name?n.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):n.raw,!1)))}function e1(e,t=[]){return e.length>0&&e.length>=t.length&&e.every((i,n)=>{if(i.name&&(t.includes(i.name)||n<t.length&&"label"!==t[n])||i.raw.includes("%%{"))return!1;let a=(i.name?i.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):i.raw).trim();return i.name?/^ *\$[A-Za-z_][A-Za-z_0-9]* *= *"[^"]+"$/.test(i.raw):a.startsWith('"')?/^ *"[^"]*"$/.test(i.raw):""===i.raw&&n<e.length-1||n<e.length-1&&a.length>0&&!/^[\$']|[(),\r\n]/.test(a)})}function e2(e,t,i){if(!e.name&&t<i.length-1&&!/^["'$)]/.test(e.raw.trim())&&!e.raw.includes(","))return!1;for(let t of(e.name?e.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):e.raw).matchAll(/"[^"]*"|'[^']*'|(\$[A-Za-z_][A-Za-z_0-9]*\s*(?:=|["']))/g))if(t[1])return!0;return!1}function e3(e,t){let i=Object.create(null);for(let n=0;n<e.length;n++){let a=e[n],r=a.name??t[n];void 0!==r&&(i[r]=a.value)}return i}function e6(e){return e.startsWith("Person")||e.startsWith("System")?["alias","label","descr","sprite","tags","link"]:["alias","label","techn","descr","sprite","tags","link"]}function e5(e){return"deployment"===eY[e]?["alias","label","type","descr","sprite","tags","link"]:"Boundary"===e?["alias","label","type","tags","link"]:["alias","label","tags","link"]}function e8(e){return"RelIndex"===e?["index","from","to","label","tags","link"]:["from","to","label","techn","descr","sprite","tags","link"]}function e9(e){return e?e.split("+").map(e=>e.trim()).filter(Boolean):[]}function e7(e){return""===e?void 0:e}function te(e,t,i){let n=e[t];if(void 0===n||"label"!==t&&!n.trim())throw Error(`C4: ${i} requires ${"label"===t?"a":"a non-empty"} ${t}`);return n}function tt(e,t,i,n){let a=e4(e,t,"label");return void 0!==a?a:e[t.indexOf("label")]?.name?"":te(i,"label",n)}function ti(e){let{args:t,style:i,effectiveLink:n,statementId:a,...r}=e;return"name"in e?JSON.stringify([e.name,e.args.map(e=>[e.name,e.value])]):JSON.stringify(r)}function tn(e,t,i,n,a="warning"){e.diagnostics.push({code:"UNSUPPORTED_SYNTAX",syntax:i,severity:a,statementId:t,message:n})}var ta=new Set(["UpdateElementStyle","UpdateRelStyle","UpdateLayoutConfig"]);function tr(e,t){return Object.fromEntries(Object.entries(e).filter(([e,i])=>!t.includes(e)&&""!==i))}var to=O(function(t,i){let n=i.positioned,{body:a,config:r,identities:o}=n,l=Z(i.resolved.renderOptions,void 0,i.resolved.styleFace),s=e=>e&&"strict"!==i.resolved.renderOptions.security&&w(e)?` data-href="${et(e)}" role="link" tabindex="0"`:"",d=(e,t)=>o.generated(`c4:${e}:${t}`,["c4",e,t]),c=(e,i,n,a,r=!1)=>t.shape({id:d(e,i),role:r?"group":"node",geometry:n,paint:a}),h=e=>[`data-id="${et(e.id)}"`,`data-c4-kind="${et(e.kind)}"`,`data-c4-macro="${et(e.macro)}"`,...e.parentId?[`data-parent-id="${et(e.parentId)}"`]:[],...e.tags.length?[`data-tags="${et(JSON.stringify(e.tags))}"`]:[],...s(e.effectiveLink??e.link)?[s(e.effectiveLink??e.link)]:[],...e.sprite?[`data-sprite="${et(e.sprite)}"`]:[],...void 0!==eM(a,e.statementId)?[`data-source-line="${eM(a,e.statementId)}"`]:[],..."external"in e?[`data-external="${e.external}"`,`data-c4-shape="${e.shape}"`,`data-effective-c4-shape="${em(e)}"`]:[`data-alignment="${e.alignment??"center"}"`]].join(" "),g=new Map(a.boundaries.map(e=>[e.id,e])),p=e=>{let n=g.get(e.id),a=ex(n,r),{x:o,y:s,width:m,height:u}=e,f=a.stroke??l.groupBorderColor??"var(--_node-stroke)",y=a.fill??l.groupFillColor??"var(--_group-fill)",x=a.fill??l.groupHeaderFillColor??"var(--_group-hdr)",b=a.text??N(a.fill?{fill:a.fill}:void 0,l.groupTextColor??X("var(--_text-sec)",x,i.colors)),_=e.headerHeight??36,w=[],v=e=>w.push({node:e,indent:2}),k="solid"===n.style.lineStyle?void 0:"dotted"===n.style.lineStyle?"1 3":"dashed"===n.style.lineStyle?"5 3":"deployment"===n.kind?void 0:"6 4";v(c(n.id,"boundary-frame",{kind:"rect",x:o,y:s,width:m,height:u,rx:l.groupCornerRadius,ry:l.groupCornerRadius},{fill:y,stroke:f,strokeWidth:String(l.groupLineWidth),...k?{strokeDasharray:k}:{}},!0));let F={kind:"path",d:eo(o,s,m,_,l.groupCornerRadius)},S={fill:x,stroke:f,strokeWidth:String(l.groupLineWidth)};v(t.shape({id:d(n.id,"boundary-band"),role:"group-header",geometry:F,paint:S}));let $=e.labelBlock,M="left"===n.alignment?"start":"right"===n.alignment?"end":"middle",C="left"===n.alignment?o+r.padding:"right"===n.alignment?o+m-r.padding:o+m/2,W=s+_/2;for(let i of(v(t.text({id:d(n.id,"boundary-text"),role:"group-header",text:$.text,block:$,x:C,y:W,fontSize:$.fontSize,fontWeight:$.fontWeight,letterSpacing:$.letterSpacing,anchor:M,paint:{fill:b}})),e.children))v(p(i));return t.group({id:d(n.id,"frame"),role:"group",open:`<g class="cluster c4-boundary" ${h(n)}>`,close:"</g>",children:w,channels:{category:n.kind}})},m=new Map(a.relationships.map(e=>[e.id,e])),u=e({...t,connector:e=>{let n=el(e),a=m.get(n.identity?.id??"");if(!a)return t.connector(e);let r="dotted"===a.style.lineStyle?{...n.stroke,dash:{array:"1 3"}}:n.stroke,o="strict"===i.resolved.renderOptions.security?void 0:a.effectiveLink??a.link,{markers:l}=n,s=n.labels[0],c={className:"edge",data:{style:n.lineStyle,"arrow-start":String(!!l.start),"arrow-end":String(!!l.end),...l.start?{"marker-start":l.start.shape}:{},...l.end?{"marker-end":l.end.shape}:{},...s?{label:ea(s.text)}:{},"c4-macro":a.macro,"authored-from":a.from,"authored-to":a.to,order:String(a.order),...void 0!==a.index?{index:a.index}:{},...a.tags.length?{tags:JSON.stringify(a.tags)}:{},...o&&w(o)?{href:o}:{}},...o&&w(o)?{tabIndex:0}:{}},h={id:d(a.id,"relationship"),role:"edge",identity:n.identity,geometry:n.route.geometry,paint:{stroke:r.color,strokeWidth:String(r.width)},lineStyle:n.lineStyle,endpoints:n.endpoints,relationship:{...n.relationship,kind:`c4-${a.macro}`},route:n.route,stroke:r,markers:n.markers,hit:n.hit,labels:n.labels.map(e=>({...e,visual:{kind:"companion",markId:d(a.id,"label-text")},...a.style.textColor?{paint:{...e.paint,fill:a.style.textColor}}:{}})),channels:{category:"relationship",...a.tags.length?{status:a.tags.join(",")}:{}},attributes:c};return t.connector(h)}},i,{surfaces:!1,edgeLabels:!1,beforeEdges:()=>n.groups.map(p)}),f=u.parts,y=n.edges.flatMap(e=>{if(!e.label||!e.labelBlock||!e.labelPosition)return[];let n=m.get(e.id),a=e.labelBlock,{x:r,y:o}=e.labelPosition,s=n.style.textColor??n.style.fontColor??l.edgeTextColor??"var(--_text-sec)",c={kind:"rect",...eB(e),rx:3,ry:3};return[t.group({id:d(n.id,"relationship-label"),role:"edge-label",open:`<g class="edge-label" data-id="${et(d(n.id,"label"))}" data-role="edge-label" data-edge-id="${et(n.id)}" data-from="${et(n.source)}" data-to="${et(n.target)}">`,close:"</g>",children:[{indent:2,node:t.shape({id:d(n.id,"label-halo"),role:"chrome",geometry:c,paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"1"}})},{indent:2,node:t.text({id:d(n.id,"label-text"),role:"label",text:a.text,block:a,x:r,y:o,fontSize:a.fontSize,fontWeight:a.fontWeight,letterSpacing:a.letterSpacing,anchor:"middle",paint:{fill:s},pageFill:n.style.textColor??n.style.fontColor??X("var(--_text-sec)","var(--bg)",i.colors)})}]})]});if(f.splice(f.length-1,0,...y,...n.nodes.map(e=>((e,n)=>{let{x:a,y:o,width:s,height:g}=n,p=ex(e,r),m=em(e),u=p.fill??l.nodeFillColor??"var(--_node-fill)",f=p.stroke??l.nodeBorderColor??"var(--_node-stroke)",y=p.text??N(p.fill?{fill:p.fill}:void 0,l.nodeTextColor??X("var(--_text)",u,i.colors)),x={fill:u,stroke:f,strokeWidth:String(l.nodeLineWidth),...p.dashed?{strokeDasharray:"5 3"}:{}},b=[],_=e=>b.push({node:e,indent:2});if("database"===m){let t=`M ${a} ${o+8} A ${s/2} 8 0 0 1 ${a+s} ${o+8} L ${a+s} ${o+g-8} A ${s/2} 8 0 0 1 ${a} ${o+g-8} Z`;_(c(e.id,"surface",{kind:"path",d:t},x)),_(c(e.id,"database-rim",{kind:"ellipse",cx:a+s/2,cy:o+8,rx:s/2,ry:8},{fill:"none",stroke:f,strokeWidth:"1"}))}else{if(_(c(e.id,"surface",{kind:"rect",x:a,y:o,width:s,height:g,rx:l.cornerRadius??0,ry:l.cornerRadius??0},x)),"queue"===m)for(let[t,i]of[a+8,a+s-8].entries())_(c(e.id,`queue-end:${t}`,{kind:"line",x1:i,y1:o,x2:i,y2:o+g},{stroke:f,strokeWidth:"1"}));if("person"===m){let t=a+s/2,i=o+g/2+19-n.labelBlock.height/2-31,r={fill:y,stroke:y,strokeWidth:"1"};_(c(e.id,"person-head",{kind:"circle",cx:t,cy:i,r:7},r));let l=`M ${t-16} ${i+26} Q ${t-16} ${i+11} ${t} ${i+11} Q ${t+16} ${i+11} ${t+16} ${i+26} Z`;_(c(e.id,"person-shoulders",{kind:"path",d:l},r))}}let w=n.labelBlock;return _(t.text({id:d(e.id,"text"),role:"label",text:w.text,block:w,x:a+s/2,y:o+g/2+("person"===m?19:4*("database"===m)),fontSize:w.fontSize,fontWeight:w.fontWeight,letterSpacing:w.letterSpacing,anchor:"middle",paint:{fill:y}})),t.group({id:d(e.id,"card"),role:"node",open:`<g class="node c4-${e.kind}" ${h(e)}>`,close:"</g>",children:b,channels:{category:`${e.external?"external-":""}${e.kind}`,...e.tags.length?{status:e.tags.join(",")}:{}}})})(a.elements.find(t=>t.id===e.id),e))),n.legend){let e=n.legend,a=[],r=er(i.resolved.styleFace,"legend",{},{includeFallback:!1}),o=r?.textColor??"var(--_text)",s=e.heading,c=e.x+12,h=e.y+8+s.height/2,g=t.text({id:d("legend","heading"),role:"legend",text:s.text,block:s,x:c,y:h,fontSize:s.fontSize,fontWeight:s.fontWeight,letterSpacing:s.letterSpacing,anchor:"start",paint:{fill:o}});a.push({node:g,indent:2});let p=e.y+20+s.height;for(let i of e.entries){let{block:n}=i,s=e.x+38,c=p+n.height/2,h=i.style.borderColor??i.style.lineColor??r?.strokeColor??r?.borderColor??l.nodeBorderColor??"var(--_line)",g=i.style.bgColor??r?.fillColor??l.nodeFillColor??"var(--_node-fill)",m=String(r?.lineWidth??1),u="dotted"===i.style.lineStyle?"1 3":"dashed"===i.style.lineStyle||i.external?"5 3":void 0,f={fill:g,stroke:h,strokeWidth:m,...u?{strokeDasharray:u}:{}},y=e.x+10,x=n.height,b=(e,n)=>a.push({indent:2,node:t.shape({id:d(i.id,e),role:"legend",geometry:n,paint:f})});if("relationship"===i.kind)b("legend-swatch",{kind:"line",x1:y,y1:c,x2:y+18,y2:c});else if("database"===i.shape){let e=Math.min(3,x/4);b("legend-swatch",{kind:"path",d:`M ${y} ${p+e} A 9 ${e} 0 0 1 ${y+18} ${p+e} L ${y+18} ${p+x-e} A 9 ${e} 0 0 1 ${y} ${p+x-e} Z`}),b("legend-rim",{kind:"ellipse",cx:y+9,cy:p+e,rx:9,ry:e})}else if("person"===i.shape){let e=Math.min(3,x/5),t=y+9;b("legend-head",{kind:"circle",cx:t,cy:p+e,r:e}),b("legend-swatch",{kind:"path",d:`M ${y+3} ${p+x} Q ${y+3} ${p+2.5*e} ${t} ${p+2.5*e} Q ${y+15} ${p+2.5*e} ${y+15} ${p+x} Z`})}else if(b("legend-swatch",{kind:"rect",x:y,y:p,width:18,height:x}),"queue"===i.shape)for(let[e,t]of[y+3,y+15].entries())b(`legend-end:${e}`,{kind:"line",x1:t,y1:p,x2:t,y2:p+x});a.push({indent:2,node:t.text({id:d(i.id,"legend-text"),role:"legend",text:n.text,block:n,x:s,y:c,fontSize:n.fontSize,fontWeight:n.fontWeight,letterSpacing:n.letterSpacing,anchor:"start",paint:{fill:o}})}),p+=n.height+10}f.splice(f.length-1,0,t.group({id:d("legend","container"),role:"legend",open:'<g class="c4-legend">',close:"</g>",children:a}))}return{...u,family:"c4",parts:f}}),tl=W(eh,{configDiagnostics:e=>x("c4",e,ev),normalizeRequest:e=>{let t=e.source.authoredWrapperLength??e.source.wrapperSource?.length??0,i=e.source.originalText.slice(0,t),n=function(e){let t=function(e,t){let i="string"==typeof e?e:e.join(`
|
|
8
|
-
`),n=function(e="C4Context"){return{kind:"c4",variant:e,elements:[],boundaries:[],relationships:[],directives:[],statements:[],diagnostics:[],layout:{hints:[]}}}();
|
|
7
|
+
`)}function eM(e,t){return e.statements.find(e=>e.id===t)?.span.line}function eC(e,t){let i=ek(e),n=new Map;for(let a of e.elements){let e=`${a.external?"external-":""}${a.kind}:${a.shape}`,r=`${a.external?"External ":""}${a.kind[0].toUpperCase()}${a.kind.slice(1)}${"database"===a.shape?" / Database":"queue"===a.shape?" / Queue":""}`;if(!n.has(e)){let o=t?ex(a,t):void 0;n.set(e,{id:i.generated(`c4:legend:${e}`,["c4","legend",e]),label:r,kind:"element",shape:em(a),external:a.external,style:{...a.style,...o?.fill?{bgColor:o.fill}:{},...o?.stroke?{borderColor:o.stroke}:{}}})}}return[...t?.typeLegend!==!1&&n.size>1||e.legend?.visible?[...n.values()]:[],...e.legend?.visible?e.legend.entries:[]]}var eW=class extends RangeError{code="C4_ROUTE_WORK_LIMIT";constructor(){super("C4_ROUTE_WORK_LIMIT: physical corridor checks exceed 400000; split the diagram or reduce its relationships"),this.name="C4RouteWorkLimitError"}},eR={T:{x:0,y:-1},R:{x:1,y:0},B:{x:0,y:1},L:{x:-1,y:0}},eL=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height,eI=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function ez(e,t,i){if("T"===t||"B"===t){let n=e.cylinder?8*(1-Math.sqrt(Math.max(0,1-(2*i-1)**2))):0;return{x:e.x+e.width*i,y:e.y+("B"===t?e.height-n:n)}}let n=e.container?e.headerHeight??0:8*!!e.cylinder;return{x:e.x+("R"===t?e.width:0),y:e.y+n+(e.height-n-8*!!e.cylinder)*i}}function eq(e,t,i,n){return ez(e,t,(i+1)/(n+1))}var eE={T:"B",R:"L",B:"T",L:"R"};function eB(e){if(!e.label||!e.labelPosition||!e.labelBlock)return;let t=e.labelBlock.width+20,i=e.labelBlock.height+16;return{x:e.labelPosition.x-t/2,y:e.labelPosition.y-i/2,width:t,height:i}}var eT=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y)),eP=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t}),eO=e=>e.flatMap(e=>[e,...eO(e.children)]);function eA(e,t,i){let n=0,a=1;for(let r of["x","y"]){let o=t[r]-e[r],l=i[r]+.01,s=i[r]+("x"===r?i.width:i.height)-.01;if(.001>Math.abs(o)){if(e[r]<=l||e[r]>=s)return!1;continue}let d=(l-e[r])/o,c=(s-e[r])/o;if((n=Math.max(n,Math.min(d,c)))>=(a=Math.min(a,Math.max(d,c))))return!1}return n<a}function ej(e,t){let i=[],n=e.inlineStyle?.["stroke-width"]?1:t*("thick"===e.style?2:1),a=H.width*n,r=(e.inlineStyle?.["stroke-width"]?H.width:H.height)*n/2,o=.375*n;for(let t of[!0,!1]){if(!(t?e.hasArrowStart:e.hasArrowEnd))continue;let n=e.points.at(t?0:-1),l=(t?e.points.slice(1):e.points.slice(0,-1).reverse()).find(e=>n&&Math.hypot(e.x-n.x,e.y-n.y)>.01);if(!n||!l)continue;let s=Math.hypot(n.x-l.x,n.y-l.y),d=(n.x-l.x)/s,c=(n.y-l.y)/s,h=[n,{x:n.x-d*a-c*r,y:n.y-c*a+d*r},{x:n.x-d*a+c*r,y:n.y-c*a-d*r}],g=Math.min(...h.map(e=>e.x)),p=Math.min(...h.map(e=>e.y));i.push({...eP({x:g,y:p,width:Math.max(...h.map(e=>e.x))-g,height:Math.max(...h.map(e=>e.y))-p},o),endpoint:t?e.source:e.target,polygon:h,strokePadding:o})}return i}function eN(e,t){return[...e,...eO(t).flatMap(e=>[{x:e.x,y:e.y,width:e.width,height:e.headerHeight??0},{x:e.x,y:e.y,width:1,height:e.height},{x:e.x+e.width-1,y:e.y,width:1,height:e.height},{x:e.x,y:e.y+e.height-1,width:e.width,height:1}])]}var eX=["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"],eD=class extends D{},eU=/^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/,eY={Boundary:"boundary",Enterprise_Boundary:"enterprise",System_Boundary:"system",Container_Boundary:"container",Deployment_Node:"deployment",Node:"deployment",Node_L:"deployment",Node_R:"deployment"},eH=new Set(["Rel","BiRel","Rel_U","Rel_Up","Rel_D","Rel_Down","Rel_L","Rel_Left","Rel_R","Rel_Right","Rel_Back","RelIndex"]),eZ={U:"BT",Up:"BT",D:"TB",Down:"TB",L:"RL",Left:"RL",R:"LR",Right:"LR"},eJ=["elementName","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eQ=["from","to","textColor","lineColor","offsetX","offsetY"],eV=["tagStereo","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"],eG=["tagStereo","textColor","lineColor","lineStyle","sprite","techn","legendText","legendSprite"];function eK(e,t){if(!R("c4"))return;let{start:i,end:n,line:a,column:r}=e.span;L("c4",t,e.raw,{line:a,column:r,offset:i,endOffset:n,unit:"physical"})}function e0(e,t=!0){let i=e.trim();if(i.length>=2&&('"'===i[0]||"'"===i[0])&&i.at(-1)===i[0]){let e=i.slice(1,-1).trim();return t?m(e):e}return t?m(i):i}function e4(e,t,i){let n;for(let a=0;a<e.length;a++)(e[a].name??t[a])===i&&(n=e[a]);if(n)return m(et(e0(n.name?n.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):n.raw,!1)))}function e1(e,t=[]){return e.length>0&&e.length>=t.length&&e.every((i,n)=>{if(i.name&&(t.includes(i.name)||n<t.length&&"label"!==t[n])||i.raw.includes("%%{"))return!1;let a=(i.name?i.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):i.raw).trim();return i.name?/^ *\$[A-Za-z_][A-Za-z_0-9]* *= *"[^"]+"$/.test(i.raw):a.startsWith('"')?/^ *"[^"]*"$/.test(i.raw):""===i.raw&&n<e.length-1||n<e.length-1&&a.length>0&&!/^[\$']|[(),\r\n]/.test(a)})}function e2(e,t,i){if(!e.name&&t<i.length-1&&!/^["'$)]/.test(e.raw.trim())&&!e.raw.includes(","))return!1;for(let t of(e.name?e.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):e.raw).matchAll(/"[^"]*"|'[^']*'|(\$[A-Za-z_][A-Za-z_0-9]*\s*(?:=|["']))/g))if(t[1])return!0;return!1}function e3(e,t){let i=Object.create(null);for(let n=0;n<e.length;n++){let a=e[n],r=a.name??t[n];void 0!==r&&(i[r]=a.value)}return i}function e6(e){return e.startsWith("Person")||e.startsWith("System")?["alias","label","descr","sprite","tags","link"]:["alias","label","techn","descr","sprite","tags","link"]}function e5(e){return"deployment"===eY[e]?["alias","label","type","descr","sprite","tags","link"]:"Boundary"===e?["alias","label","type","tags","link"]:["alias","label","tags","link"]}function e8(e){return"RelIndex"===e?["index","from","to","label","tags","link"]:["from","to","label","techn","descr","sprite","tags","link"]}function e9(e){return e?e.split("+").map(e=>e.trim()).filter(Boolean):[]}function e7(e){return""===e?void 0:e}function te(e,t,i){let n=e[t];if(void 0===n||"label"!==t&&!n.trim())throw Error(`C4: ${i} requires ${"label"===t?"a":"a non-empty"} ${t}`);return n}function tt(e,t,i,n){let a=e4(e,t,"label");return void 0!==a?a:e[t.indexOf("label")]?.name?"":te(i,"label",n)}function ti(e){let{args:t,style:i,effectiveLink:n,statementId:a,...r}=e;return"name"in e?JSON.stringify([e.name,e.args.map(e=>[e.name,e.value])]):JSON.stringify(r)}function tn(e,t,i,n,a="warning"){e.diagnostics.push({code:"UNSUPPORTED_SYNTAX",syntax:i,severity:a,statementId:t,message:n})}var ta=new Set(["UpdateElementStyle","UpdateRelStyle","UpdateLayoutConfig"]);function tr(e,t){return Object.fromEntries(Object.entries(e).filter(([e,i])=>!t.includes(e)&&""!==i))}var to=O(function(t,i){let n=i.positioned,{body:a,config:r,identities:o}=n,l=Z(i.resolved.renderOptions,void 0,i.resolved.styleFace),s=e=>e&&"strict"!==i.resolved.renderOptions.security&&w(e)?` data-href="${ei(e)}" role="link" tabindex="0"`:"",d=(e,t)=>o.generated(`c4:${e}:${t}`,["c4",e,t]),c=(e,i,n,a,r=!1)=>t.shape({id:d(e,i),role:r?"group":"node",geometry:n,paint:a}),h=e=>[`data-id="${ei(e.id)}"`,`data-c4-kind="${ei(e.kind)}"`,`data-c4-macro="${ei(e.macro)}"`,...e.parentId?[`data-parent-id="${ei(e.parentId)}"`]:[],...e.tags.length?[`data-tags="${ei(JSON.stringify(e.tags))}"`]:[],...s(e.effectiveLink??e.link)?[s(e.effectiveLink??e.link)]:[],...e.sprite?[`data-sprite="${ei(e.sprite)}"`]:[],...void 0!==eM(a,e.statementId)?[`data-source-line="${eM(a,e.statementId)}"`]:[],..."external"in e?[`data-external="${e.external}"`,`data-c4-shape="${e.shape}"`,`data-effective-c4-shape="${em(e)}"`]:[`data-alignment="${e.alignment??"center"}"`]].join(" "),g=new Map(a.boundaries.map(e=>[e.id,e])),p=e=>{let n=g.get(e.id),a=ex(n,r),{x:o,y:s,width:m,height:u}=e,f=a.stroke??l.groupBorderColor??"var(--_node-stroke)",y=a.fill??l.groupFillColor??"var(--_group-fill)",x=a.fill??l.groupHeaderFillColor??"var(--_group-hdr)",b=a.text??N(a.fill?{fill:a.fill}:void 0,l.groupTextColor??X("var(--_text-sec)",x,i.colors)),_=e.headerHeight??36,w=[],v=e=>w.push({node:e,indent:2}),k="solid"===n.style.lineStyle?void 0:"dotted"===n.style.lineStyle?"1 3":"dashed"===n.style.lineStyle?"5 3":"deployment"===n.kind?void 0:"6 4";v(c(n.id,"boundary-frame",{kind:"rect",x:o,y:s,width:m,height:u,rx:l.groupCornerRadius,ry:l.groupCornerRadius},{fill:y,stroke:f,strokeWidth:String(l.groupLineWidth),...k?{strokeDasharray:k}:{}},!0));let F={kind:"path",d:el(o,s,m,_,l.groupCornerRadius)},S={fill:x,stroke:f,strokeWidth:String(l.groupLineWidth)};v(t.shape({id:d(n.id,"boundary-band"),role:"group-header",geometry:F,paint:S}));let $=e.labelBlock,M="left"===n.alignment?"start":"right"===n.alignment?"end":"middle",C="left"===n.alignment?o+r.padding:"right"===n.alignment?o+m-r.padding:o+m/2,W=s+_/2;for(let i of(v(t.text({id:d(n.id,"boundary-text"),role:"group-header",text:$.text,block:$,x:C,y:W,fontSize:$.fontSize,fontWeight:$.fontWeight,letterSpacing:$.letterSpacing,anchor:M,paint:{fill:b}})),e.children))v(p(i));return t.group({id:d(n.id,"frame"),role:"group",open:`<g class="cluster c4-boundary" ${h(n)}>`,close:"</g>",children:w,channels:{category:n.kind}})},m=new Map(a.relationships.map(e=>[e.id,e])),u=e({...t,connector:e=>{let n=K(e),a=m.get(n.identity?.id??"");if(!a)return t.connector(e);let r="dotted"===a.style.lineStyle?{...n.stroke,dash:{array:"1 3"}}:n.stroke,o="strict"===i.resolved.renderOptions.security?void 0:a.effectiveLink??a.link,{markers:l}=n,s=n.labels[0],c={className:"edge",data:{style:n.lineStyle,"arrow-start":String(!!l.start),"arrow-end":String(!!l.end),...l.start?{"marker-start":l.start.shape}:{},...l.end?{"marker-end":l.end.shape}:{},...s?{label:er(s.text)}:{},"c4-macro":a.macro,"authored-from":a.from,"authored-to":a.to,order:String(a.order),...void 0!==a.index?{index:a.index}:{},...a.tags.length?{tags:JSON.stringify(a.tags)}:{},...o&&w(o)?{href:o}:{}},...o&&w(o)?{tabIndex:0}:{}},h={id:d(a.id,"relationship"),role:"edge",identity:n.identity,geometry:n.route.geometry,paint:{stroke:r.color,strokeWidth:String(r.width)},lineStyle:n.lineStyle,endpoints:n.endpoints,relationship:{...n.relationship,kind:`c4-${a.macro}`},route:n.route,stroke:r,markers:n.markers,hit:n.hit,labels:n.labels.map(e=>({...e,visual:{kind:"companion",markId:d(a.id,"label-text")},...a.style.textColor?{paint:{...e.paint,fill:a.style.textColor}}:{}})),channels:{category:"relationship",...a.tags.length?{status:a.tags.join(",")}:{}},attributes:c};return t.connector(h)}},i,{surfaces:!1,edgeLabels:!1,beforeEdges:()=>n.groups.map(p)}),f=u.parts,y=n.edges.flatMap(e=>{if(!e.label||!e.labelBlock||!e.labelPosition)return[];let n=m.get(e.id),a=e.labelBlock,{x:r,y:o}=e.labelPosition,s=n.style.textColor??n.style.fontColor??l.edgeTextColor??"var(--_text-sec)",c={kind:"rect",...eB(e),rx:3,ry:3};return[t.group({id:d(n.id,"relationship-label"),role:"edge-label",open:`<g class="edge-label" data-id="${ei(d(n.id,"label"))}" data-role="edge-label" data-edge-id="${ei(n.id)}" data-from="${ei(n.source)}" data-to="${ei(n.target)}">`,close:"</g>",children:[{indent:2,node:t.shape({id:d(n.id,"label-halo"),role:"chrome",geometry:c,paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"1"}})},{indent:2,node:t.text({id:d(n.id,"label-text"),role:"label",text:a.text,block:a,x:r,y:o,fontSize:a.fontSize,fontWeight:a.fontWeight,letterSpacing:a.letterSpacing,anchor:"middle",paint:{fill:s},pageFill:n.style.textColor??n.style.fontColor??X("var(--_text-sec)","var(--bg)",i.colors)})}]})]});if(f.splice(f.length-1,0,...y,...n.nodes.map(e=>((e,n)=>{let{x:a,y:o,width:s,height:g}=n,p=ex(e,r),m=em(e),u=p.fill??l.nodeFillColor??"var(--_node-fill)",f=p.stroke??l.nodeBorderColor??"var(--_node-stroke)",y=p.text??N(p.fill?{fill:p.fill}:void 0,l.nodeTextColor??X("var(--_text)",u,i.colors)),x={fill:u,stroke:f,strokeWidth:String(l.nodeLineWidth),...p.dashed?{strokeDasharray:"5 3"}:{}},b=[],_=e=>b.push({node:e,indent:2});if("database"===m){let t=`M ${a} ${o+8} A ${s/2} 8 0 0 1 ${a+s} ${o+8} L ${a+s} ${o+g-8} A ${s/2} 8 0 0 1 ${a} ${o+g-8} Z`;_(c(e.id,"surface",{kind:"path",d:t},x)),_(c(e.id,"database-rim",{kind:"ellipse",cx:a+s/2,cy:o+8,rx:s/2,ry:8},{fill:"none",stroke:f,strokeWidth:"1"}))}else{if(_(c(e.id,"surface",{kind:"rect",x:a,y:o,width:s,height:g,rx:l.cornerRadius??0,ry:l.cornerRadius??0},x)),"queue"===m)for(let[t,i]of[a+8,a+s-8].entries())_(c(e.id,`queue-end:${t}`,{kind:"line",x1:i,y1:o,x2:i,y2:o+g},{stroke:f,strokeWidth:"1"}));if("person"===m){let t=a+s/2,i=o+g/2+19-n.labelBlock.height/2-31,r={fill:y,stroke:y,strokeWidth:"1"};_(c(e.id,"person-head",{kind:"circle",cx:t,cy:i,r:7},r));let l=`M ${t-16} ${i+26} Q ${t-16} ${i+11} ${t} ${i+11} Q ${t+16} ${i+11} ${t+16} ${i+26} Z`;_(c(e.id,"person-shoulders",{kind:"path",d:l},r))}}let w=n.labelBlock;return _(t.text({id:d(e.id,"text"),role:"label",text:w.text,block:w,x:a+s/2,y:o+g/2+("person"===m?19:4*("database"===m)),fontSize:w.fontSize,fontWeight:w.fontWeight,letterSpacing:w.letterSpacing,anchor:"middle",paint:{fill:y}})),t.group({id:d(e.id,"card"),role:"node",open:`<g class="node c4-${e.kind}" ${h(e)}>`,close:"</g>",children:b,channels:{category:`${e.external?"external-":""}${e.kind}`,...e.tags.length?{status:e.tags.join(",")}:{}}})})(a.elements.find(t=>t.id===e.id),e))),n.legend){let e=n.legend,a=[],r=eo(i.resolved.styleFace,"legend",{},{includeFallback:!1}),o=r?.textColor??"var(--_text)",s=e.heading,c=e.x+12,h=e.y+8+s.height/2,g=t.text({id:d("legend","heading"),role:"legend",text:s.text,block:s,x:c,y:h,fontSize:s.fontSize,fontWeight:s.fontWeight,letterSpacing:s.letterSpacing,anchor:"start",paint:{fill:o}});a.push({node:g,indent:2});let p=e.y+20+s.height;for(let i of e.entries){let{block:n}=i,s=e.x+38,c=p+n.height/2,h=i.style.borderColor??i.style.lineColor??r?.strokeColor??r?.borderColor??l.nodeBorderColor??"var(--_line)",g=i.style.bgColor??r?.fillColor??l.nodeFillColor??"var(--_node-fill)",m=String(r?.lineWidth??1),u="dotted"===i.style.lineStyle?"1 3":"dashed"===i.style.lineStyle||i.external?"5 3":void 0,f={fill:g,stroke:h,strokeWidth:m,...u?{strokeDasharray:u}:{}},y=e.x+10,x=n.height,b=(e,n)=>a.push({indent:2,node:t.shape({id:d(i.id,e),role:"legend",geometry:n,paint:f})});if("relationship"===i.kind)b("legend-swatch",{kind:"line",x1:y,y1:c,x2:y+18,y2:c});else if("database"===i.shape){let e=Math.min(3,x/4);b("legend-swatch",{kind:"path",d:`M ${y} ${p+e} A 9 ${e} 0 0 1 ${y+18} ${p+e} L ${y+18} ${p+x-e} A 9 ${e} 0 0 1 ${y} ${p+x-e} Z`}),b("legend-rim",{kind:"ellipse",cx:y+9,cy:p+e,rx:9,ry:e})}else if("person"===i.shape){let e=Math.min(3,x/5),t=y+9;b("legend-head",{kind:"circle",cx:t,cy:p+e,r:e}),b("legend-swatch",{kind:"path",d:`M ${y+3} ${p+x} Q ${y+3} ${p+2.5*e} ${t} ${p+2.5*e} Q ${y+15} ${p+2.5*e} ${y+15} ${p+x} Z`})}else if(b("legend-swatch",{kind:"rect",x:y,y:p,width:18,height:x}),"queue"===i.shape)for(let[e,t]of[y+3,y+15].entries())b(`legend-end:${e}`,{kind:"line",x1:t,y1:p,x2:t,y2:p+x});a.push({indent:2,node:t.text({id:d(i.id,"legend-text"),role:"legend",text:n.text,block:n,x:s,y:c,fontSize:n.fontSize,fontWeight:n.fontWeight,letterSpacing:n.letterSpacing,anchor:"start",paint:{fill:o}})}),p+=n.height+10}f.splice(f.length-1,0,t.group({id:d("legend","container"),role:"legend",open:'<g class="c4-legend">',close:"</g>",children:a}))}return{...u,family:"c4",parts:f}}),tl=W(eh,{configDiagnostics:e=>x("c4",e,ev),normalizeRequest:e=>{let t=e.source.authoredWrapperLength??e.source.wrapperSource?.length??0,i=e.source.originalText.slice(0,t),n=function(e){let t=function(e,t){let i="string"==typeof e?e:e.join(`
|
|
8
|
+
`),n=function(e="C4Context"){return{kind:"c4",variant:e,elements:[],boundaries:[],relationships:[],directives:[],statements:[],diagnostics:[],layout:{hints:[]}}}();R("c4")&&z("c4","initialize",n),n.statements=function(e){let t=[],i=0,n=1,a=1,r=!0,o=(r,o="unknown")=>{let l=e.slice(i,r);t.push({id:`c4-statement-${t.length+1}`,kind:o,raw:l,span:{start:i,end:r,line:n,column:a}}),R("c4")&&I("c4",`chunk:${o}`,l,{line:n,column:a,offset:i,endOffset:r,unit:"physical"});let s=e[i-1];for(let e of l)"\r"===e||e===`
|
|
9
9
|
`&&"\r"!==s?(n++,a=1):e!==`
|
|
10
|
-
`&&a++,s=e;i=r};for(;i<e.length;){let t=i;if(/\s|;/.test(e[t])){let i=t+1;for(;i<e.length&&/\s|;/.test(e[i]);)i++;o(i,"trivia");continue}if(e.startsWith("%%",t)){let i=b(e,t),n=i<0?e.length:i,a=!r&&D([e.slice(t,n)],0)?.form==="native";o(n,a?"accessibility":"trivia");continue}if(r){r=!1;let i=b(e,t),n=i<0?e.length:i,a=n;for(let i=t;i<n;i++){if("&"===e[i]){let t=/^&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.exec(e.slice(i,n));if(t){i+=t[0].length-1;continue}}if(";"===e[i]){a=i;break}}let l=ec(e.slice(t,a)).trim();if(eX.some(e=>e.toLowerCase()===l.toLowerCase())){o(a,"header");continue}}if("}"===e[t]){o(t+1,"boundary-close");continue}let a=e.slice(t),l=/^[A-Za-z_][A-Za-z_0-9]*/.exec(a)?.[0],s=t+(l?.length??0);for(;s<e.length&&/[ \t\r\n]/.test(e[s]);)s++;if(l&&"("===e[s]){let t=0,i="";for(;s<e.length;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("("===n)t++;else if(")"===n&&0==--t){s++;break}}if(t||i)throw Error(`C4: unclosed ${l} argument list at line ${n}`);let a=s;for(;a<e.length&&/\s/.test(e[a]);)a++;if("{"===e[a]){if(eY[l]){o(a+1,"boundary-open");continue}let t=1;for(i="",s=a+1;s<e.length&&t;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("%"===n&&"%"===e[s+1]){let t=b(e,s+2);s=t<0?e.length:t}else"{"===n?t++:"}"===n&&t--}if(t)throw Error(`C4: unclosed ${l} block at line ${n}`)}o(s);continue}let d=b(e,t);if(/^accDescr[ \t]*:?[ \t]*\{/i.test(a)){let i=e.indexOf("}",t);if(i<0)throw Error(`C4: unclosed accessibility block at line ${n}`);o(i+1,"accessibility");continue}o(d<0?e.length:d)}return t}(i);let a=[],r=new Set,o=new Set,l=!1,s=!1,d=!1;for(let e of n.statements){let i=e.raw.trim();if("trivia"===e.kind){eV(e,"trivia"),!i.startsWith("%%")&&i.includes(";")?(tn(n,e.id,"c4_semicolon_separator","Semicolon statement separators are a reader extension; pinned Mermaid C4 requires line breaks"),s=d=!1):i.startsWith("%%")?d||=s:/[\r\n]/.test(e.raw)&&!d&&(s=!1);continue}if(s&&"boundary-close"!==e.kind&&tn(n,e.id,"c4_statements_on_one_line","Statements sharing a line are a reader extension; pinned Mermaid C4 requires a line break after each statement and after `{`, and a comment after a statement takes its line break"),s=!0,d=!1,!l){let t=ec(i),a=eX.find(e=>e.toLowerCase()===t.toLowerCase());if(!a)throw Error("C4: expected C4Context, C4Container, C4Component, C4Dynamic, or C4Deployment");eV(e,"header"),n.variant=a,L("c4")&&I("c4","set-variant",a),e.kind="header",e.signature=a,l=!0;continue}if("boundary-close"===e.kind){eV(e,"boundary-close");let t=a.pop();if(!t)throw Error(`C4: unmatched closing boundary at line ${e.span.line}`);L("c4")&&I("c4","close-boundary",{id:t}),e.entityId=t;continue}if(A(i)!==i&&tn(n,e.id,"c4_entity_prepass","The global Mermaid entity prepass changes this statement; the writer protects its text fields without changing their values"),/^title\s/i.test(i)){eV(e,"title"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),/[#;]/.test(A(i.replace(/^title\s+/i,"")))&&tn(n,e.id,"c4_title_token","The title contains literal token delimiters; serialization writes entity escapes for pinned Mermaid"),n.title=m(ee(i.replace(/^title\s+/i,""))),L("c4")&&I("c4","set-title",n.title),e.kind="title",e.signature=n.title;continue}let c=D(i.split(/\r\n?|\n/),0);if(c){eV(e,"accessibility"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),c.title||"native"===c.form||""!==c.value||tn(n,e.id,"c4_empty_accessibility_description","An empty accessibility description block is a reader extension; the writer preserves its value in a native metadata comment"),c.title?n.accessibilityTitle=c.value:n.accessibilityDescription=c.value,L("c4")&&I("c4",c.title?"set-accessibility-title":"set-accessibility-description",c.value),e.kind="accessibility",e.entityId=c.title?"title":"description",e.signature=c.value;continue}if(/^accDescription\s+/i.test(i)){eV(e,"accessibility"),n.accessibilityDescription=i.replace(/^accDescription\s+/i,""),L("c4")&&I("c4","set-accessibility-description",n.accessibilityDescription),e.kind="accessibility",e.entityId="description",e.signature=n.accessibilityDescription;continue}let h=/^direction\s+(LR|RL|TB|BT)\s*$/.exec(i);if(h){eV(e,"direction");let t={id:e.id,name:"direction",args:[{value:h[1],raw:h[1]}],category:"layout",statementId:e.id};n.directives.push(t),L("c4")&&I("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t);continue}let g=/^([A-Za-z_][A-Za-z_0-9]*)\s*\(([\s\S]*)\)\s*(\{)?$/.exec(i);if(!g){eV(e,"unknown"),tn(n,e.id,"c4_unknown_statement","C4 statement is preserved but has no native interpretation","error");continue}let p=g[1],u=function(e){if(!e.trim())return[];let t=[],i=0,n=0,a="";for(let r=0;r<e.length;r++){let o=e[r];a?o===a&&(a=""):'"'===o||"'"===o?a=o:"("===o?n++:")"===o?n--:","===o&&0===n&&(t.push(e.slice(i,r)),i=r+1)}return t.push(e.slice(i)),t.map(e=>{let t=/^\s*\$([A-Za-z_][A-Za-z_0-9]*)\s*=([\s\S]*)$/.exec(e);return{...t?{name:t[1]}:{},value:e0(t?t[2]:e),raw:e}})}(g[2]);if("UpdateLayoutConfig"===p&&(0===u.length||1===u.length&&!u[0].name&&""===u[0].value)&&!g[3]){a.length&&r.add(a.at(-1)),"("===i[p.length]&&e1(u)||tn(n,e.id,"c4_empty_layout_arguments","An empty layout call is a no-op; the writer supplies the attribute required by pinned Mermaid"),e.kind="trivia";continue}/[\r\n]/.test(g[2].replace(/"[^"]*"|'[^']*'/g,""))&&tn(n,e.id,"c4_multiline_arguments","Line breaks between C4 arguments are a reader extension; quoted multiline text remains supported"),u.some(e=>e.name&&""===e.value)&&tn(n,e.id,"c4_empty_named_argument","Empty named arguments are retained; pinned Mermaid requires a positional empty slot");let f=eD.exec(p),y=!!(f&&!("Person"===f[1]&&f[2]))||Object.hasOwn(eY,p)||eH.has(p)||ta.has(p);if(y&&a.length&&r.add(a.at(-1)),y&&u.some(e2))throw new eU(`C4 argument is ambiguous in ${i}: separate named arguments with commas and use $name="value", or quote the entire value when it is literal text`);if(y&&u.some((e,t)=>{let i=e.raw.trim();return e.name?!/^\$[A-Za-z_][A-Za-z_0-9]*\s*=\s*"/.test(i)&&""!==e.value:i.startsWith("$")||t===u.length-1&&""!==i&&!/^["']/.test(i)})&&tn(n,e.id,"c4_unquoted_argument","Unquoted C4 argument text is read literally here, but pinned Mermaid requires a quoted final argument and quoted named values; serialization writes those values in double quotes"),y&&"("!==i[p.length]&&tn(n,e.id,"c4_space_before_arguments",`Pinned Mermaid reads "(" only straight after ${p} and rejects whitespace between them; ours reads the call. Write ${p}( with no space`),f&&!("Person"===f[1]&&f[2])){if(eV(e,"element"),g[3])throw Error(`C4: ${p} cannot open a boundary`);let i=e3(u,e6(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:f[1].toLowerCase(),external:!!f[3],shape:"Person"===f[1]?"person":"Db"===f[2]?"database":"Queue"===f[2]?"queue":"rectangle",label:tt(u,e6(p),i,p),technology:e7(e4(u,e6(p),"techn")),description:e7(e4(u,e6(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id};t&&B("nodes",n.elements.length+n.boundaries.length+1),n.elements.push(l),L("c4")&&I("c4","add-element",l),e.kind="element",e.entityId=r,e.signature=ti(l)}else if(eY[p]){if(eV(e,"boundary-open"),!g[3])throw Error(`C4: ${p} requires a boundary block`);let i=e3(u,e5(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:eY[p],label:tt(u,e5(p),i,p),type:e7(e4(u,e5(p),"type")),description:e7(e4(u,e5(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,..."Node_L"===p?{alignment:"left"}:"Node_R"===p?{alignment:"right"}:{}};t&&(B("nodes",n.elements.length+n.boundaries.length+1),B("nesting",a.length+1)),n.boundaries.push(l),a.push(r),L("c4")&&I("c4","open-boundary",l),e.entityId=r,e.signature=ti(l)}else if(eH.has(p)){eV(e,"relationship");let i=e3(u,e8(p)),a=te(i,"from",p),r=te(i,"to",p),o="Rel_Back"===p,l={id:"",macro:p,from:a,to:r,source:o?r:a,target:o?a:r,label:tt(u,e8(p),i,p),technology:e7(e4(u,e8(p),"techn")),description:e7(e4(u,e8(p),"descr")),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,index:"RelIndex"===p?te(i,"index",p):void 0,order:n.relationships.length+1,bidirectional:"BiRel"===p,reversed:o,direction:eZ[p.slice(4)]};t&&B("edges",n.relationships.length+n.layout.hints.length+1),n.relationships.push(l),L("c4")&&I("c4","add-relationship",l),e.kind="relationship","RelIndex"===p&&u.slice(4).some(e=>!e.name)&&tn(n,e.id,"c4_relindex_positional_metadata","RelIndex positional metadata follows documented tags/link slots; pinned Mermaid instead treats them as technology/description. Named $tags/$link avoids this ambiguity")}else{eV(e,"directive");let t={id:e.id,name:p,args:u,category:"UpdateElementStyle"===p?"element-style":"UpdateRelStyle"===p?"relationship-style":"AddElementTag"===p?"element-tag":"AddRelTag"===p?"relationship-tag":"UpdateLayoutConfig"===p||p.startsWith("Lay_")||p.startsWith("LAYOUT_")?"layout":"ShowLegend"===p||"SHOW_LEGEND"===p||"SHOW_FLOATING_LEGEND"===p?"legend":"AddElementLink"===p||"AddRelLink"===p?"link":"unknown",statementId:e.id};n.directives.push(t),L("c4")&&I("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t),"unknown"===t.category?tn(n,e.id,"c4_unknown_macro",`${p} is preserved but has no native interpretation`,"error"):p.startsWith("Update")||tn(n,e.id,"c4_directive_extension",`${p} is a reader extension; pinned Mermaid does not accept this directive`)}let x=f?e6(p):eY[p]?e5(p):eH.has(p)?e8(p):("UpdateElementStyle"===p?eJ:"UpdateRelStyle"===p?eQ:"UpdateLayoutConfig"===p?["c4ShapeInRow","c4BoundaryInRow"]:void 0)??("AddElementTag"===p?eG:"AddRelTag"===p?eK:void 0);if(x){let t=new Set;for(let i=0;i<u.length;i++){let a=u[i],r=a.name??x[i];void 0!==r&&x.includes(r)?t.has(r)&&tn(n,e.id,"c4_duplicate_argument",`${p} assigns ${r} more than once; every argument is retained`,"error"):tn(n,e.id,"c4_unknown_argument",`${p} argument ${a.name??i+1} is retained but has no native interpretation`,"error"),r&&t.add(r)}}u.some(e=>/^\s*'/.test(e.raw)||/\\["']/.test(e.raw))?tn(n,e.id,"c4_quoted_string_extension","Quoted-string extension is preserved; typed edits write Mermaid entity escapes"):!y||e1(u)||n.diagnostics.some(t=>t.statementId===e.id&&["c4_multiline_arguments","c4_empty_named_argument"].includes(t.syntax))||tn(n,e.id,"c4_argument_spelling","Argument text is retained as its native value; the writer emits complete quoted argument tokens instead of ambiguous imported spelling")}if(!l)throw Error("C4: missing diagram header");if(a.length)throw Error(`C4: unclosed boundary ${JSON.stringify(a.at(-1))}`);t&&T(n);let c=ei(o),h=new Map(n.statements.map(e=>[e.id,e]));for(let e of n.relationships){if(e.id=c(`c4-rel-${e.order}`,["c4-relationship",e.order]),L("c4")&&I("c4","set-relationship-identity",{id:e.id,order:e.order}),!o.has(e.from)||!o.has(e.to))throw Error(`C4: relationship ${e.id} references an undeclared endpoint`);let t=h.get(e.statementId);t.entityId=e.id,t.signature=ti(e)}for(let e of(!function(e,t=!1){for(let t of[...e.elements,...e.boundaries,...e.relationships])t.style={},delete t.effectiveLink,L("c4")&&I("c4","reset-presentation",{id:t.id,style:t.style});e.layout={hints:[]},L("c4")&&I("c4","reset-layout",e.layout);let i=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e])),n=new Map,a=(e,t)=>JSON.stringify([e,t]);for(let t of e.relationships){let e=a(t.from,t.to),i=n.get(e)??[];i.push(t),n.set(e,i)}let r=(e,t)=>{let i=e3(e.args,t);for(let n of["techn","legendText"]){let a=e4(e.args,t,n);void 0!==a&&(i[n]=a)}return i},o=new Map,l=new Map;for(let t of e.directives){if("element-tag"!==t.category&&"relationship-tag"!==t.category)continue;let e=r(t,"element-tag"===t.category?eG:eK);("element-tag"===t.category?o:l).set(e.tagStereo??"",tr(e,["tagStereo"])),L("c4")&&I("c4","define-tag",{category:t.category,tag:e.tagStereo??"",style:("element-tag"===t.category?o:l).get(e.tagStereo??"")})}for(let t of[...e.elements,...e.boundaries])for(let e of t.tags)Object.assign(t.style,o.get(e)),L("c4")&&I("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let t of e.relationships)for(let e of t.tags)Object.assign(t.style,l.get(e)),L("c4")&&I("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let o of e.directives)if("element-style"===o.category){let e=r(o,eJ),t=i.get(e.elementName);if(!t)throw Error(`C4: UpdateElementStyle references undeclared alias ${JSON.stringify(e.elementName)}`);Object.assign(t.style,tr(e,["elementName"])),L("c4")&&I("c4","set-element-style",{id:t.id,style:t.style})}else if("relationship-style"===o.category){let e=e3(o.args,eQ),t=n.get(a(e.from,e.to));if(!t)throw Error("C4: UpdateRelStyle references an undeclared relationship pair");for(let t of["offsetX","offsetY"])if(void 0!==e[t]&&!Number.isFinite(Number(e[t])))throw Error(`C4: ${t} must be finite`);for(let i of t)Object.assign(i.style,tr(e,["from","to"])),L("c4")&&I("c4","set-relationship-style",{id:i.id,style:i.style})}else if("UpdateLayoutConfig"===o.name){let t=e3(o.args,["c4ShapeInRow","c4BoundaryInRow"]);for(let[i,n]of[["c4ShapeInRow","shapesPerRow"],["c4BoundaryInRow","boundariesPerRow"]]){if(void 0===t[i]||""===t[i])continue;let a=Number(t[i]);if(!Number.isSafeInteger(a)||a<1)throw Error(`C4: ${i} must be a positive integer`);e.layout[n]=a,L("c4")&&I("c4","set-layout-option",{name:n,value:a})}}else if(o.name.startsWith("Lay_")){let n=eZ[o.name.slice(4)],a=e3(o.args,["from","to"]);if(!n||!a.from||!a.to||!i.has(a.from)||!i.has(a.to))throw Error(`C4: ${o.name} requires two declared aliases`);n&&a.from&&a.to&&(t&&B("edges",e.relationships.length+e.layout.hints.length+1),e.layout.hints.push({from:a.from,to:a.to,direction:n,statementId:o.statementId}),L("c4")&&I("c4","add-layout-hint",e.layout.hints.at(-1)))}else if("direction"===o.name)e.layout.direction=o.args[0]?.value,L("c4")&&I("c4","set-direction",e.layout.direction);else if("LAYOUT_LEFT_RIGHT"===o.name||"LAYOUT_TOP_DOWN"===o.name)e.layout.direction="LAYOUT_LEFT_RIGHT"===o.name?"LR":"TB",L("c4")&&I("c4","set-direction",e.layout.direction);else if("AddElementLink"===o.name){let e=e3(o.args,["alias","link"]),t=i.get(e.alias);t&&(t.effectiveLink=e.link,L("c4")&&I("c4","set-effective-link",{id:t.id,link:t.effectiveLink}))}else if("AddRelLink"===o.name){let e=e3(o.args,["from","to","link"]);for(let t of n.get(a(e.from,e.to))??[])t.effectiveLink=e.link,L("c4")&&I("c4","set-effective-link",{id:t.id,link:t.effectiveLink})}let s=ei([...e.elements,...e.boundaries,...e.relationships].map(e=>e.id));e.legend={visible:e.directives.some(e=>"legend"===e.category),entries:[...[...o.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["element-tag",e]),label:t.legendText??e,kind:"element",style:{...t}})),...[...l.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["relationship-tag",e]),label:t.legendText??e,kind:"relationship",style:{...t}}))]},L("c4")&&I("c4","set-legend",e.legend)}(n,t),n.boundaries))r.has(e.id)||tn(n,e.statementId,"c4_empty_boundary","An empty boundary is retained; the writer supplies a no-op layout statement because pinned Mermaid requires a statement inside its block");if(n.directives.some(e=>"direction"===e.name)){let e=n.directives.find(e=>"direction"===e.name);tn(n,e.statementId,"c4_direction","A standalone direction directive is a reader extension to legacy C4")}for(let e of[...n.elements,...n.boundaries,...n.relationships])for(let t of(e.sprite&&tn(n,e.statementId,"c4_sprite","C4 sprite metadata is preserved; offline native output uses an explicit text fallback"),void 0===e.style.lineStyle||["solid","dashed","dotted"].includes(e.style.lineStyle)||tn(n,e.statementId,"c4_line_style",`C4 lineStyle ${JSON.stringify(e.style.lineStyle)} is preserved but has no native paint effect; the route uses solid strokes`),Object.keys(e.style)))"shape"===t&&"external"in e&&void 0!==ep(e.style.shape)||["bgColor","fontColor","borderColor","textColor","lineColor","lineStyle","offsetX","offsetY","legendText","techn"].includes(t)||tn(n,e.statementId,"c4_style_property",`C4 style ${t} is preserved as metadata but has no native paint effect`);return n}(e,!0),i=t.diagnostics.find(e=>"error"===e.severity);if(i){let e;throw Error(`C4 unsupported syntax: ${(e=t.statements.find(e=>e.id===i.statementId))?`${i.message} (in: ${e.raw.trim()})`:i.message}`)}return t}(e.source.originalText.slice(t)),a=i.split(/\r\n?|\n/).length-1;for(let e of n.statements)e.span.start+=i.length,e.span.end+=i.length,e.span.line+=a;let r=_(e.source.frontmatter);return void 0===n.title&&void 0!==r&&(n.title=r),void 0!==e.source.accessibility.title&&(n.accessibilityTitle=e.source.accessibility.title),void 0!==e.source.accessibility.descr&&(n.accessibilityDescription=e.source.accessibility.descr),{familyConfig:{model:n,c4:e.source.config.c4??{},themeVariables:e.source.config.themeVariables??{}}}},layout:e=>{let m=e.familyConfig;return C(function(e,m={},u,f={},y={}){var x;let b,_,w,v,k,F,S,$,M,C;T(e);let W=ey({...void 0===m.padding?{}:{diagramMarginX:m.padding,diagramMarginY:m.padding},...void 0===m.nodeSpacing?{}:{c4ShapeMargin:m.nodeSpacing},...void 0===m.layerSpacing?{}:{nextLinePaddingX:m.layerSpacing},...f},y),L=Z(m,void 0,u),R=function(e,t=ey()){for(let t of[...e.elements,...e.boundaries,...e.relationships,...e.legend?.entries??[]]){let e=t.style;j({...void 0===e.bgColor?{}:{fill:e.bgColor},...void 0===e.borderColor&&void 0===e.lineColor?{}:{stroke:e.borderColor??e.lineColor},...void 0===e.fontColor&&void 0===e.textColor?{}:{color:e.fontColor??e.textColor}},`C4 ${t.id}`)}let i=ek(e),n={direction:e.layout.direction??e.layout.hints[0]?.direction??e.relationships.find(e=>e.direction)?.direction??"LR",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},a=new Map;for(let t of e.boundaries)a.set(t.id,{id:i.nodes.get(t.id)??t.id,label:eS(t),nodeIds:[],children:[]});for(let t of e.boundaries){let e=a.get(t.id),i=t.parentId&&a.get(t.parentId);i?i.children.push(e):n.subgraphs.push(e)}for(let r of e.elements){let e=i.nodes.get(r.id)??r.id,o=ex(r,t),l=em(r);n.nodes.set(e,{id:e,label:eF(r),shape:"database"===l?"cylinder":"queue"===l?"subroutine":"rectangle",href:r.effectiveLink??r.link}),r.parentId&&a.get(r.parentId)?.nodeIds.push(e),n.nodeStyles.set(e,{...o.fill?{fill:o.fill}:{},...o.stroke?{stroke:o.stroke}:{},...o.text?{color:o.text}:{},...o.dashed?{"stroke-dasharray":"5 3"}:{}})}for(let t of e.relationships){let a=e$(e,t);n.edges.push({id:i.relationships.get(t.id)??t.id,source:t.source,target:t.target,label:a,labelContent:{value:a,prepared:V(a,"literal")},style:"dashed"===t.style.lineStyle||"dotted"===t.style.lineStyle?"dotted":"solid",hasArrowStart:t.bidirectional,hasArrowEnd:!0}),n.linkStyles.set(n.edges.length-1,j({...t.style.lineColor?{stroke:t.style.lineColor}:{},...t.style.textColor?{color:t.style.textColor}:{}},`UpdateRelStyle(${t.from}, ${t.to})`))}return n}(e,W),z=new Map,I=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.parentId])),E=e=>{let t=[];for(let i=I.get(e);i&&!t.includes(i);i=I.get(i))t.push(i);return t},B=e=>void 0!==W.input.c4ShapePadding?W.padding:W.compact&&u?.node?.["X"===e?"paddingX":"paddingY"]===void 0?Math.min(W.padding,L["X"===e?"nodePaddingX":"nodePaddingY"]):L["X"===e?"nodePaddingX":"nodePaddingY"],P=e=>{if(void 0===W.wrapWidth)return;if(void 0===W.maxWidth)return W.wrapWidth;let t=void 0===e?0:E(e).length;return Math.max(24,W.minimumWidth-2*B("X")-20,Math.min(W.wrapWidth,W.maxWidth-(W.marginX+40)*2-t*W.boundaryPadding*2-2*B("X")-20))},O=(e,t,i=!1)=>{let n=ex(e,W);return en(t,{display:"literal",fontSize:n.fontSize??(i?L.groupHeaderFontSize:L.nodeLabelFontSize),fontWeight:n.fontWeight??(i?L.groupHeaderFontWeight:L.nodeLabelFontWeight),transform:i?L.groupTextTransform:L.nodeTextTransform,maxWidth:P(e.id),letterSpacing:i?L.groupLetterSpacing:L.nodeLetterSpacing,fontFamily:n.fontFamily??(i?L.groupFont:void 0)})},A=e.elements.map(e=>{let t=eF(e),i=O(e,t),n=em(e),a=Math.max(W.minimumWidth,i.width+2*B("X")+20*("queue"===n)),r=Math.max(W.minimumHeight,i.height+2*B("Y")+("person"===n?38:16*("database"===n)));return z.set(e.id,{id:e.id,x:0,y:0,width:a,height:r,..."database"===n?{cylinder:!0}:{}}),{...R.nodes.get(e.id),x:0,y:0,width:a,height:r,labelBlock:i,inlineStyle:R.nodeStyles.get(e.id)}}),N=new Map;for(let t of e.boundaries){let e=eS(t),i=O(t,e,!0),n=i.height+2*W.padding,a={id:t.id,label:e,labelBlock:i,x:0,y:0,width:Math.max(W.minimumWidth,i.width+2*W.padding),height:n+2*W.boundaryPadding,headerHeight:n,children:[]};N.set(t.id,a),z.set(t.id,{...a,container:!0})}let X=R.edges.map((t,i)=>({...t,points:[],labelBlock:en(e$(e,e.relationships[i]),{display:"literal",fontSize:L.edgeLabelFontSize,fontWeight:L.edgeLabelFontWeight,letterSpacing:L.edgeLetterSpacing,transform:L.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:P()}}),inlineStyle:R.linkStyles.get(i),edgeIndex:i}));for(let t of e.boundaries){let e=X.filter(e=>e.source===t.id&&E(e.target).includes(t.id)||e.target===t.id&&E(e.source).includes(t.id));e.length&&(z.get(t.id).bottomPadding=Math.max(W.boundaryPadding,...e.map(e=>(e.labelBlock?.height??0)+48))*e.length)}let U="LR"===R.direction||"RL"===R.direction;for(let[e,t]of z){let i=X.filter(t=>t.source===e||t.target===e),n=Math.max(0,...i.map(e=>(e.labelBlock?.height??0)+28)),a=Math.max(0,...i.map(e=>(e.labelBlock?.width??0)+24)),r=new Map;for(let t of i){let i=t.source===e?t.target:t.source;r.set(i,(r.get(i)??0)+1)}let o=Math.max(0,...r.values());U?t.height=Math.max(t.height,(o+1)*n+(t.headerHeight??0),(i.length+1)*16+(t.headerHeight??0)):t.width=Math.max(t.width,(o+1)*a,(i.length+1)*16)}let D=m.diagramTitle??e.title,Y=void 0===D?void 0:en(D,{display:"literal",fontSize:J,fontWeight:Q,transform:L.groupTextTransform,letterSpacing:L.groupLetterSpacing,fontFamily:L.groupFont,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX)}}),H=Y?{text:Y.text,width:Y.width,height:Y.height+G,block:Y}:void 0,ee=Math.max(W.gap,...X.map(e=>(e.labelBlock?.width??0)*2+48)),et=Math.max(W.rowGap,...X.map(e=>(e.labelBlock?.height??0)*2+48)),ei=new Map;for(let e of X){let t=JSON.stringify([e.source,e.target].sort());ei.set(t,(ei.get(t)??0)+1)}let ea=Math.max(1,...ei.values()),er=ea>1?ea+1:1,eo=(x={gapX:ee*er,gapY:et*er,padding:W.boundaryPadding,marginX:W.marginX+40,marginY:W.marginY+40+(H?.height??0),shapesPerRow:e.layout.shapesPerRow??W.shapesPerRow,boundariesPerRow:e.layout.boundariesPerRow??W.boundariesPerRow,direction:"TD"===R.direction?"TB":R.direction,maxWidth:W.maxWidth},b=new Map([...z].map(([e,t])=>[e,{...t}])),_=[],w=new Map(e.statements.map((e,t)=>[e.id,t])),k=new Map((v=[...e.boundaries,...e.elements].sort((e,t)=>(w.get(e.statementId)??0)-(w.get(t.statementId)??0))).map(e=>[e.id,e.parentId])),F=[...e.layout.hints,...e.relationships.filter(e=>e.direction).map(e=>({from:e.from,to:e.to,direction:e.direction,statementId:e.statementId}))],S=(e,t)=>{let i=new Set;for(;k.get(e)!==t;){if(i.has(e))return;i.add(e);let t=k.get(e);if(!t)return;e=t}return e},M=($=(e,t,i)=>{let n=v.filter(t=>t.parentId===e&&b.has(t.id));for(let e of n)if(b.get(e.id).container&&!t.has(e.id)){let n=new Set(t);n.add(e.id);let a=$(e.id,n,void 0===i?void 0:Math.max(1,i-2*x.padding)),r=b.get(e.id);r.width=Math.max(r.width,a.width+2*x.padding),r.height=Math.max(r.height,a.height+(r.headerHeight??0)+x.padding+Math.max(x.padding,r.bottomPadding??0))}let a=n.some(e=>b.get(e.id).container)?x.boundariesPerRow:x.shapesPerRow,r=x.direction,o="LR"===r||"RL"===r;if(!o&&void 0!==i){let e=Math.max(1,...n.map(e=>b.get(e.id).width)),t=Math.max(1,Math.floor((i+x.gapX)/(e+x.gapX)));a=Math.max(a,Math.ceil(n.length/t))}let l=0,s=0,d=0,c=0,h=0;n.forEach(e=>{let t=b.get(e.id);h&&(h>=a||o&&void 0!==i&&l+t.width>i)&&(o?(l=0,s+=d+x.gapY,d=0):(s=0,l+=c+x.gapX,c=0),h=0),t.x=l,t.y=s,o?l+=t.width+x.gapX:s+=t.height+x.gapY,d=Math.max(d,t.height),c=Math.max(c,t.width),h++});let g=[];for(let t of F){let i=S(t.from,e),n=S(t.to,e);if(!i||!n||i===n||!b.has(i)||!b.has(n))continue;let a="LR"===t.direction||"RL"===t.direction?"x":"y",r="RL"===t.direction||"BT"===t.direction,o=r?n:i,l=r?i:n,s=(e,t,i=new Set)=>e===t||!i.has(e)&&(i.add(e),g.some(n=>n.axis===a&&n.before===e&&s(n.after,t,i)));if(s(l,o)){_.push({code:"C4_LAYOUT_CONFLICT",severity:"warning",statementId:t.statementId,message:`Conflicting C4 ${"x"===a?"horizontal":"vertical"} direction for ${t.from} and ${t.to}; the earlier constraint is retained.`});continue}g.push({before:o,after:l,axis:a,statementId:t.statementId})}if(g.length){for(let e of n){let t=b.get(e.id);g.some(t=>"x"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.x=0),g.some(t=>"y"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.y=0)}let e=()=>{for(let e=0;e<n.length;e++)for(let e of g){let t=b.get(e.before),i=b.get(e.after);i[e.axis]=Math.max(i[e.axis],t[e.axis]+("x"===e.axis?t.width+x.gapX:t.height+x.gapY))}};e();for(let t=0;t<n.length;t++){let t=!1;for(let e=0;e<n.length;e++)for(let i=e+1;i<n.length;i++){let a=b.get(n[e].id),r=b.get(n[i].id);a.x<r.x+r.width&&r.x<a.x+a.width&&a.y<r.y+r.height&&r.y<a.y+a.height&&(r.y=a.y+a.height+x.gapY,t=!0)}if(e(),!t)break}}else if("RL"===r||"BT"===r){let e=Math.max(0,...n.map(e=>{let t=b.get(e.id);return"RL"===r?t.x+t.width:t.y+t.height}));for(let t of n){let i=b.get(t.id);"RL"===r?i.x=e-i.x-i.width:i.y=e-i.y-i.height}}return{width:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.x+t.width})),height:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.y+t.height}))}})(void 0,new Set,void 0===x.maxWidth?void 0:Math.max(1,x.maxWidth-2*x.marginX)),(C=(e,t,i,n)=>{for(let a of v.filter(t=>t.parentId===e)){let e=b.get(a.id);!e||n.has(a.id)||(n.add(a.id),e.x+=t,e.y+=i,e.container&&C(a.id,e.x+x.padding,e.y+(e.headerHeight??0)+x.padding,n))}})(void 0,x.marginX,x.marginY,new Set),{boxes:b,width:M.width+2*x.marginX,height:M.height+2*x.marginY,diagnostics:_});for(let e of A)Object.assign(e,eo.boxes.get(e.id));let el=[];for(let t of e.boundaries){let e=N.get(t.id);Object.assign(e,eo.boxes.get(t.id));let i=t.parentId&&N.get(t.parentId);i?i.children.push(e):el.push(e)}(function(e,i,m,u,f){let{edges:y}=i,x=[...e.values()].filter(e=>e.container).map(e=>({...e,id:f.generated(`c4-header-obstacle:${e.id}`,["c4","header-obstacle",e.id]),height:e.headerHeight??1,shape:"rectangle",label:""})),b=[...i.nodes,...x],_=0,w=()=>{if(++_>4e5)throw new eW},v=(e,t,i)=>(w(),h(e,t,i)),k=(e,t,i,n,a)=>{let r={x:eL[t].x*i,y:eL[t].y*i},o=n;for(let t of b){if(w(),t.id===a||!(r.x?e.y>t.y&&e.y<t.y+t.height:e.x>t.x&&e.x<t.x+t.width))continue;let i=r.x>0?t.x-e.x:r.x<0?e.x-t.x-t.width:r.y>0?t.y-e.y:e.y-t.y-t.height;i>=0&&(o=Math.min(o,Math.max(0,i-2)))}return{x:e.x+r.x*o,y:e.y+r.y*o}},F=new Map,S=new Map,$=new Map,M=y.flatMap(t=>{let i=e.get(t.source),n=e.get(t.target);if(!i||!n)return[];let[a,r]=function(e,t){if(e.id===t.id)return["R","B"];if(e.container&&eR(e,t)||t.container&&eR(t,e))return["B","B"];let i=ez(e),n=ez(t);return Math.abs(i.x-n.x)>=Math.abs(i.y-n.y)?i.x<=n.x?["R","L"]:["L","R"]:i.y<=n.y?["B","T"]:["T","B"]}(i,n);for(let[e,t]of[[i.id,a],[n.id,r]]){let i=`${e}\0${t}`;S.set(i,(S.get(i)??0)+1)}return[{edge:t,source:i,target:n,startSide:a,endSide:r}]}),C=new Map;for(let e of M){let t=JSON.stringify([e.source.id,e.target.id].sort()),i=C.get(t)??[];i.push(e),C.set(t,i)}for(let[e,i]of M.entries()){let n,{edge:a,source:r,target:o,startSide:l,endSide:s}=i,d=(e,t)=>{let i=`${e.id}\0${t}`,n=$.get(i)??0;return $.set(i,n+1),{index:n,count:S.get(i)}},c=d(r,l),h=d(o,s),p=eE(r,l,c.index,c.count),m=r.id===o.id?eE(o,s,h.index,h.count):function(e,t,i,n,a,r){let o=eE(i,n,a,r);if(eq[t]!==n)return o;let l="L"===n||"R"===n?"y":"x",s=e[l]-o[l];if(0===s||Math.abs(s)>=8)return o;let d=eI(i,n,0),c=eI(i,n,1),h=(e[l]-d[l])/(c[l]-d[l]);if(!(h>0&&h<1))return o;let g=eI(i,n,h);for(let e=0;e<r;e++)if(e!==a&&8>Math.abs(eE(i,n,e,r)[l]-g[l]))return o;return g}(p,l,o,s,h.index,h.count),f=r.container&&r.id!==o.id&&eR(r,o)?-1:1,y=o.container&&r.id!==o.id&&eR(o,r)?-1:1,x=C.get(JSON.stringify([r.id,o.id].sort())),b="R"===l||"L"===l?Math.max(24,...x.map(e=>(e.edge.labelBlock?.width??0)+32)):Math.max(24,...x.map(e=>(e.edge.labelBlock?.height??0)+24)),_=(x.indexOf(i)-(x.length-1)/2)*b,w=14+e%5*4,v=g(a,u),M=k(p,l,f,Math.max(w,v.start?v.start+(u.edgeBendRadius??0):0),r.id),W=k(m,s,y,Math.max(w,v.end?v.end+(u.edgeBendRadius??0):0),o.id);if(F.set(a,{start:p,end:m,startExit:M,endExit:W}),r.id===o.id){let e=r.x+r.width+w+(a.labelBlock?.width??0)/2,t=r.y+r.height+w+(a.labelBlock?.height??0)/2;n=[M,{x:e,y:M.y},{x:e,y:t},{x:W.x,y:t},W]}else if("R"===l||"L"===l){let e=(M.x+W.x)/2+_;n=[M,{x:e,y:M.y},{x:e,y:W.y},W]}else{let e=(M.y+W.y)/2+_;n=[M,{x:M.x,y:e},{x:W.x,y:e},W]}a.points=t([p,...n,m]),F.get(a).seed=a.points,a.label&&(a.labelPosition=q(a.points))}for(let n of(r(i,m,new Set,u),l(i,m,u),s(i,m,u),c(i,m,u),y)){let a=F.get(n),r=e.get(n.source),o=e.get(n.target),l=Math.abs(ez(r).x-ez(o).x)>=Math.abs(ez(r).y-ez(o).y)?ez(r).x<=ez(o).x?"LR":"RL":ez(r).y<=ez(o).y?"TB":"BT",s={id:f.generated(`${n.id}:routing-source`,["c4",n.id,"routing-source"]),label:"",shape:"rectangle",...a.startExit,width:0,height:0},d={id:f.generated(`${n.id}:routing-target`,["c4",n.id,"routing-target"]),label:"",shape:"rectangle",...a.endExit,width:0,height:0},c={...n,source:s.id,target:d.id,points:t([a.startExit,...a.seed.slice(1,-1),a.endExit])},h=(n.labelBlock?.width??0)/2+10,g=(n.labelBlock?.height??0)/2+8;p([...[...i.nodes,...x].map(e=>e.id===n.source||e.id===n.target?e:{...e,x:e.x-h,y:e.y-g,width:e.width+2*h,height:e.height+2*g}),s,d],[c],{...m,direction:l}),c.points.slice(1).some((e,t)=>b.some(i=>v(c.points[t],e,i)))&&(c.points=function(e,i,n,a){let r=(t,a)=>{let r=[...new Set(n.flatMap(e=>[e[t]-10,e[t]+e[a]+10]))],o=[Math.min(e[t],i[t],...r),Math.max(e[t],i[t],...r)],l=n=>Math.min(Math.abs(n-e[t]),Math.abs(n-i[t]));return[...new Set([...o,...r.sort((e,t)=>l(e)-l(t)||e-t).slice(0,14)])]},o=r("x","width"),l=r("y","height"),s=[];for(let t of o)s.push([e,{x:t,y:e.y},{x:t,y:i.y},i]);for(let t of l)s.push([e,{x:e.x,y:t},{x:i.x,y:t},i]);for(let t of o)for(let n of l)s.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:i.y},i]),s.push([e,{x:t,y:e.y},{x:t,y:n},{x:i.x,y:n},i]);let d=e=>e.slice(1).reduce((t,i,n)=>t+Math.hypot(i.x-e[n].x,i.y-e[n].y),0),c=(e,t)=>n.every(i=>!a(e,t,i)),h=e=>e.map(t).sort((e,t)=>d(e)-d(t)||e.length-t.length).find(e=>e.slice(1).every((t,i)=>c(e[i],t))),g=h(s);if(g)return g;let p=l.filter(t=>c(e,{x:e.x,y:t})),m=l.filter(e=>c({x:i.x,y:e},i)),u=o.filter(t=>c(e,{x:t,y:e.y})),f=o.filter(e=>c({x:e,y:i.y},i)),y=[];for(let t of o)for(let n of p)for(let a of m)y.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:a},{x:i.x,y:a},i]);for(let t of l)for(let n of u)for(let a of f)y.push([e,{x:n,y:e.y},{x:n,y:t},{x:a,y:t},{x:a,y:i.y},i]);return h(y)}(a.startExit,a.endExit,b,v)??c.points),n.points=t([a.start,...c.points,a.end]),n.labelPosition=q(n.points)}d(i,m,u);let W=[...i.nodes,...x],L={...i,nodes:W},{ctx:R}=a(W,y,m.direction,u,i.groups);for(let e of(R.finalLabelClearance=!0,y))if(e.label)for(let{start:t,end:i}of e.points.slice(1).map((t,i)=>({start:e.points[i],end:t})).sort((e,t)=>Math.abs(t.end.x-t.start.x)+Math.abs(t.end.y-t.start.y)-(Math.abs(e.end.x-e.start.x)+Math.abs(e.end.y-e.start.y)))){let a=n(e,t,i,R);if(a){e.labelPosition=a;break}}for(let t of(s(L,m,u),y)){let i=e.get(t.source),n=e.get(t.target);o(t,t.routeCertificate,{...i,label:"",shape:"rectangle"},{...n,label:"",shape:"rectangle"})}})(eo.boxes,{nodes:A,groups:el,edges:X},R,L,ek(e)),function(e,t,i){let{edges:n}=e,a=eN(e.nodes,e.groups),r=n.flatMap(e=>eA(e,t)),o=[],l=new Map(i.relationships.map(e=>[e.id,e.style])),s=n.flatMap(e=>e.points.slice(1).map((t,i)=>({edge:e,start:e.points[i],end:t})));for(let{edge:e,rect:t}of n.map((e,t)=>({edge:e,index:t,rect:eB(e)})).filter(e=>e.rect).sort((e,t)=>t.rect.width*t.rect.height-e.rect.width*e.rect.height||e.index-t.index)){let i=l.get(e.id),n=e=>Number.isFinite(Number(e))?Number(e):0,d=n(i?.offsetX),c=n(i?.offsetY),h=e=>({x:e.x+d,y:e.y+c}),g=h(e.labelPosition),p=[g],m=t.width,u=t.height,f=t=>{let i={x:t.x-m/2,y:t.y-u/2,width:m,height:u},n=eP(i,3);return[r.reduce((e,t)=>e+eT(n,t),0),a.reduce((e,t)=>e+eT(n,t),0),o.reduce((e,t)=>e+eT(eP(i,4),t),0),s.reduce((t,n)=>t+(n.edge!==e&&ej(n.start,n.end,eP(i,2))?1:0),0)]},y=g,x=f(g);if(x.every(e=>0===e)){e.labelPosition=g,o.push(eB(e));continue}for(let{start:t,end:i}of s.filter(t=>t.edge===e).sort((e,t)=>Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y)-Math.hypot(e.end.x-e.start.x,e.end.y-e.start.y))){let e=Math.hypot(i.x-t.x,i.y-t.y);if(e<.01)continue;let n=-(i.y-t.y)/e,a=(i.x-t.x)/e,r=Math.abs(n)*m/2+Math.abs(a)*u/2;for(let e of[.5,.25,.75,.1,.9])for(let o of[0,r+6,-r-6,r+20,-r-20])p.push(h({x:t.x+(i.x-t.x)*e+n*o,y:t.y+(i.y-t.y)*e+a*o}))}for(let e of(p.sort((e,t)=>Math.hypot(e.x-g.x,e.y-g.y)-Math.hypot(t.x-g.x,t.y-g.y)),p)){let t=f(e),i=t.findIndex((e,t)=>e!==x[t]);if(i>=0&&t[i]<x[i]&&(y=e,x=t),t.every(e=>0===e))break}e.labelPosition=y,o.push(eB(e))}}({nodes:A,groups:el,edges:X},L.lineWidth,e);let es=X.flatMap(e=>{let t=eB(e);return t?[{...t,id:e.id,label:"",shape:"rectangle"}]:[]}),ed=X.flatMap(e=>eA(e,L.lineWidth).map(t=>({...t,id:e.id,label:"",shape:"rectangle"})));i([...A,...es,...ed],X,el,Math.max(W.marginX,W.marginY)+(H?.height??0));let ec=[...A,...N.values(),...es,...ed],eh=Math.max(eo.width,...ec.map(e=>e.x+e.width+W.marginX),...X.flatMap(e=>[...e.points.map(e=>e.x+W.marginX),(e.labelPosition?.x??0)+(e.labelBlock?.width??0)/2+W.marginX]),H?H.width+2*W.marginX:0),eg=Math.max(eo.height,...ec.map(e=>e.y+e.height+W.marginY),...X.flatMap(e=>[...e.points.map(e=>e.y+W.marginY),(e.labelPosition?.y??0)+(e.labelBlock?.height??0)/2+W.marginY])),ep=eC(e,W).map(e=>({...e,block:en(e.label,{display:"literal",fontSize:L.edgeLabelFontSize,fontWeight:L.edgeLabelFontWeight,letterSpacing:L.edgeLetterSpacing,transform:L.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-64)}})})),eu=en("Legend",{display:"literal",fontSize:u?.text?.fontSize??13,fontWeight:u?.text?.fontWeight??600,letterSpacing:u?.text?.letterSpacing??0,transform:u?.text?.textTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-24)}}),ef=ep.length?{x:W.marginX,y:eg+12,width:Math.max(eu.width+24,...ep.map(e=>e.block.width+64)),height:eu.height+20+ep.reduce((e,t)=>e+t.block.height+10,0),heading:eu,entries:ep}:void 0;ef&&(eh=Math.max(eh,ef.x+ef.width+W.marginX),eg=ef.y+ef.height+W.marginY);let eb=[...eo.diagnostics,...function(e,t,i,n){let a=[],{edges:r,nodes:o,groups:l}=t,s=eN(o,l),d=r.map(e=>({edge:e,box:eB(e)})).filter(e=>e.box),c=t=>e.relationships.find(e=>e.id===t.id)?.statementId;for(let{edge:e,box:t}of d)(s.some(e=>eT(t,e)>.01)||d.some(i=>i.edge!==e&&eT(t,i.box)>.01)||r.some(i=>i!==e&&i.points.slice(1).some((e,n)=>ej(i.points[n],e,t))))&&a.push({code:"C4_LABEL_COLLISION",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has a label halo overlapping another label, card, boundary header/frame or relationship route; all authored text is retained.`});let h=eO(l).map(e=>({...e,height:e.headerHeight??0})),g=r.flatMap(e=>eA(e,i).map(t=>({edge:e,head:t})));for(let e of r){let t=g.filter(t=>t.edge===e).map(e=>e.head);((e.hasArrowEnd||e.hasArrowStart)&&!t.length||t.some(e=>d.some(t=>eT(e,t.box)>.01)||[...o,...h].some(t=>t.id!==e.endpoint&&eT(e,t)>.01)||g.some(t=>t.head!==e&&function(e,t){if(.01>=eT(e,t))return!1;for(let i of[e.polygon,t.polygon])for(let[n,a]of i.entries()){let r=i[(n+1)%i.length],o=-(r.y-a.y),l=r.x-a.x,s=Math.hypot(o,l);if(s<.001)continue;let d=e=>e.polygon.map(e=>(e.x*o+e.y*l)/s),c=d(e),h=d(t);if(Math.max(...c)+e.strokePadding<=Math.min(...h)-t.strokePadding+.01||Math.max(...h)+t.strokePadding<=Math.min(...c)-e.strokePadding+.01)return!1}return!0}(e,t.head))||n&&(e.x<-.01||e.y<-.01||e.x+e.width>n.width+.01||e.y+e.height>n.height+.01)))&&a.push({code:"C4_ARROW_OCCLUDED",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has an arrowhead overlapping a label, card, boundary header or another arrowhead, exceeds the final canvas, or lacks a nonzero terminal segment.`})}return a}(e,{nodes:A,groups:el,edges:X},L.lineWidth,{width:eh,height:eg})];return void 0!==W.maxWidth&&eh>W.maxWidth+.01&&eb.push({code:"C4_WIDTH_EXCEEDED",severity:"warning",message:`The requested C4 width ${W.maxWidth}px cannot contain the ${Math.ceil(eh)}px artifact without shrinking or clipping content; minimum card widths, nesting, explicit direction constraints and authored offsets retain precedence.`}),{width:eh,height:eg,...ef?{legend:ef}:{},nodes:A,groups:el,edges:X,...H?{title:K(H,eh,W.marginY)}:{},body:e,config:W,diagnostics:eb,identities:ek(e),textContext:{node:L.nodeTextTransform,edge:L.edgeTextTransform,group:L.groupTextTransform,legendHeading:u?.text?.textTransform,title:D}}}(m.model,e.renderOptions,e.styleFace,m.c4,m.themeVariables))},projectPositioned:$(function({positioned:e,options:t}){let i=e.body,n=e.textContext,a=(e,t,i,n)=>{if(!i||i.prepared.source!==t||"literal"!==i.prepared.display||i.prepared.transform!==n)throw Error("C4 "+e+" changed its retained prepared text")},r=new Map(i.elements.map(e=>[e.id,e])),o=new Map(i.relationships.map(e=>[e.id,e])),l=new Map,s=new Map,d=(e,t)=>{for(let i of e){if(l.has(i.id))throw Error(`C4 boundary "${i.id}" has a repeated positioned frame`);l.set(i.id,i),s.set(i.id,t),d(i.children,i.id)}};d(e.groups);let c=new Set(e.nodes.map(e=>e.id));if(c.size!==e.nodes.length||c.size!==r.size||i.elements.some(e=>!c.has(e.id)))throw Error("C4 positioned cards do not match the authored identities");if(l.size!==i.boundaries.length)throw Error("C4 positioned frames do not match the authored boundaries");let h=new Set(e.edges.map(e=>e.id));if(h.size!==e.edges.length||h.size!==o.size)throw Error("C4 positioned relationships do not match the authored identities");for(let t of e.nodes){let e=eF(r.get(t.id));if(t.label!==e)throw Error("C4 card "+t.id+" changed its authored text");a(t.id,e,t.labelBlock,n.node)}for(let t of e.edges){let e=void 0===t.id?void 0:o.get(t.id);if(!e)throw Error("C4 positioned relationship has no authored interaction identity");let r=e$(i,e),l="dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle?"dotted":"solid";if(t.source!==e.source||t.target!==e.target||t.label!==r||t.style!==l||t.hasArrowStart!==e.bidirectional||!t.hasArrowEnd||(t.startMarker??"arrow")!=="arrow"||(t.endMarker??"arrow")!=="arrow")throw Error("C4 relationship "+t.id+" changed its authored endpoints, label, shaft or markers");a(t.id,r,t.labelBlock,n.edge)}let g=[];for(let t of i.boundaries){let i=l.get(t.id);if(!i||s.get(t.id)!==t.parentId)throw Error(`C4 boundary "${t.id}" changed its authored parent`);let r=eS(t);if(i.label!==r)throw Error("C4 boundary "+t.id+" changed its authored text");a(t.id,r,i.labelBlock,n.group);let o="left"===t.alignment?"start":"right"===t.alignment?"end":"middle",d="left"===t.alignment?i.x+e.config.padding:"right"===t.alignment?i.x+i.width-e.config.padding:i.x+i.width/2,c=i.headerHeight??36;g.push({id:`boundary-label:${t.id}`,text:i.labelBlock?.text??i.label,bounds:F(i.labelBlock,d,i.y+c/2,o),container:k({...i,height:c})})}if(void 0!==n.title!=(void 0!==e.title))throw Error("C4 positioned title does not match the authored title");if(e.title){let t=e.title;a("title",n.title,t.block,n.group),g.push({id:"title",text:t.text,bounds:F(t.block,t.x,t.y),container:k(v(e))})}let p=eC(i,e.config);if(p.length>0!=(void 0!==e.legend))throw Error("C4 positioned legend does not match the authored legend");if(e.legend){let t=e.legend;if(t.entries.length!==p.length||t.entries.some((e,t)=>e.id!==p[t].id))throw Error("C4 positioned legend entries do not match the authored legend");a("legend heading","Legend",t.heading,n.legendHeading);let i=k(t);g.push({id:"legend:heading",text:t.heading.text,bounds:F(t.heading,t.x+12,t.y+8+t.heading.height/2,"start"),container:i});let r=t.y+20+t.heading.height;for(let[e,o]of t.entries.entries())a(o.id,p[e].label,o.block,n.edge),g.push({id:`legend:entry:${o.id}`,text:o.block.text,bounds:F(o.block,t.x+38,r+o.block.height/2,"start"),container:i}),r+=o.block.height+10}return{version:1,nodes:e.nodes.map(e=>{let t=r.get(e.id),i=em(t),n=e.y+e.height/2+("person"===i?19:4*("database"===i));return{id:t.id,x:E(e.x),y:E(e.y),w:E(e.width),h:E(e.height),shape:i,label:t.label,role:"box",...S(e.labelBlock,e.x+e.width/2,n,e),...void 0!==t.parentId?{parentId:t.parentId}:{}}}),edges:e.edges.map(e=>{let i=void 0===e.id?void 0:o.get(e.id);if(!i)throw Error("C4 positioned relationship has no authored interaction identity");return{id:i.id,from:e.source,to:e.target,path:e.points.map(e=>[E(e.x),E(e.y)]),...void 0!==e.label&&e.labelPosition?{label:{x:E(e.labelPosition.x),y:E(e.labelPosition.y),text:e.label,bounds:F(e.labelBlock,e.labelPosition.x,e.labelPosition.y)}}:{},...t.debug&&e.routeCertificate?{route:e.routeCertificate}:{}}}),groups:i.boundaries.map(e=>{let t=l.get(e.id);if(!t)throw Error(`C4 boundary "${e.id}" has no positioned frame`);return{id:e.id,label:e.label,x:E(t.x),y:E(t.y),w:E(t.width),h:E(t.height),members:i.elements.filter(t=>t.parentId===e.id).map(e=>e.id),...void 0!==e.parentId?{parentId:e.parentId}:{}}}),bounds:{w:E(e.width),h:E(e.height)},labels:g}}),lowerScene:M(to)});export{tl as default};
|
|
10
|
+
`&&a++,s=e;i=r};for(;i<e.length;){let t=i;if(/\s|;/.test(e[t])){let i=t+1;for(;i<e.length&&/\s|;/.test(e[i]);)i++;o(i,"trivia");continue}if(e.startsWith("%%",t)){let i=b(e,t),n=i<0?e.length:i,a=!r&&U([e.slice(t,n)],0)?.form==="native";o(n,a?"accessibility":"trivia");continue}if(r){r=!1;let i=b(e,t),n=i<0?e.length:i,a=n;for(let i=t;i<n;i++){if("&"===e[i]){let t=/^&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.exec(e.slice(i,n));if(t){i+=t[0].length-1;continue}}if(";"===e[i]){a=i;break}}let l=ec(e.slice(t,a)).trim();if(eX.some(e=>e.toLowerCase()===l.toLowerCase())){o(a,"header");continue}}if("}"===e[t]){o(t+1,"boundary-close");continue}let a=e.slice(t),l=/^[A-Za-z_][A-Za-z_0-9]*/.exec(a)?.[0],s=t+(l?.length??0);for(;s<e.length&&/[ \t\r\n]/.test(e[s]);)s++;if(l&&"("===e[s]){let t=0,i="";for(;s<e.length;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("("===n)t++;else if(")"===n&&0==--t){s++;break}}if(t||i)throw Error(`C4: unclosed ${l} argument list at line ${n}`);let a=s;for(;a<e.length&&/\s/.test(e[a]);)a++;if("{"===e[a]){if(eY[l]){o(a+1,"boundary-open");continue}let t=1;for(i="",s=a+1;s<e.length&&t;s++){let n=e[s];if(i)n===i&&(i="");else if('"'===n||"'"===n)i=n;else if("%"===n&&"%"===e[s+1]){let t=b(e,s+2);s=t<0?e.length:t}else"{"===n?t++:"}"===n&&t--}if(t)throw Error(`C4: unclosed ${l} block at line ${n}`)}o(s);continue}let d=b(e,t);if(/^accDescr[ \t]*:?[ \t]*\{/i.test(a)){let i=e.indexOf("}",t);if(i<0)throw Error(`C4: unclosed accessibility block at line ${n}`);o(i+1,"accessibility");continue}o(d<0?e.length:d)}return t}(i);let a=[],r=new Set,o=new Set,l=!1,s=!1,d=!1;for(let e of n.statements){let i=e.raw.trim();if("trivia"===e.kind){eK(e,"trivia"),!i.startsWith("%%")&&i.includes(";")?(tn(n,e.id,"c4_semicolon_separator","Semicolon statement separators are a reader extension; pinned Mermaid C4 requires line breaks"),s=d=!1):i.startsWith("%%")?d||=s:/[\r\n]/.test(e.raw)&&!d&&(s=!1);continue}if(s&&"boundary-close"!==e.kind&&tn(n,e.id,"c4_statements_on_one_line","Statements sharing a line are a reader extension; pinned Mermaid C4 requires a line break after each statement and after `{`, and a comment after a statement takes its line break"),s=!0,d=!1,!l){let t=ec(i),a=eX.find(e=>e.toLowerCase()===t.toLowerCase());if(!a)throw Error("C4: expected C4Context, C4Container, C4Component, C4Dynamic, or C4Deployment");eK(e,"header"),n.variant=a,R("c4")&&z("c4","set-variant",a),e.kind="header",e.signature=a,l=!0;continue}if("boundary-close"===e.kind){eK(e,"boundary-close");let t=a.pop();if(!t)throw Error(`C4: unmatched closing boundary at line ${e.span.line}`);R("c4")&&z("c4","close-boundary",{id:t}),e.entityId=t;continue}if(j(i)!==i&&tn(n,e.id,"c4_entity_prepass","The global Mermaid entity prepass changes this statement; the writer protects its text fields without changing their values"),/^title\s/i.test(i)){eK(e,"title"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),/[#;]/.test(j(i.replace(/^title\s+/i,"")))&&tn(n,e.id,"c4_title_token","The title contains literal token delimiters; serialization writes entity escapes for pinned Mermaid"),n.title=m(et(i.replace(/^title\s+/i,""))),R("c4")&&z("c4","set-title",n.title),e.kind="title",e.signature=n.title;continue}let c=U(i.split(/\r\n?|\n/),0);if(c){eK(e,"accessibility"),a.length&&tn(n,e.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header"),c.title||"native"===c.form||""!==c.value||tn(n,e.id,"c4_empty_accessibility_description","An empty accessibility description block is a reader extension; the writer preserves its value in a native metadata comment"),c.title?n.accessibilityTitle=c.value:n.accessibilityDescription=c.value,R("c4")&&z("c4",c.title?"set-accessibility-title":"set-accessibility-description",c.value),e.kind="accessibility",e.entityId=c.title?"title":"description",e.signature=c.value;continue}if(/^accDescription\s+/i.test(i)){eK(e,"accessibility"),n.accessibilityDescription=i.replace(/^accDescription\s+/i,""),R("c4")&&z("c4","set-accessibility-description",n.accessibilityDescription),e.kind="accessibility",e.entityId="description",e.signature=n.accessibilityDescription;continue}let h=/^direction\s+(LR|RL|TB|BT)\s*$/.exec(i);if(h){eK(e,"direction");let t={id:e.id,name:"direction",args:[{value:h[1],raw:h[1]}],category:"layout",statementId:e.id};n.directives.push(t),R("c4")&&z("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t);continue}let g=/^([A-Za-z_][A-Za-z_0-9]*)\s*\(([\s\S]*)\)\s*(\{)?$/.exec(i);if(!g){eK(e,"unknown"),tn(n,e.id,"c4_unknown_statement","C4 statement is preserved but has no native interpretation","error");continue}let p=g[1],u=function(e){if(!e.trim())return[];let t=[],i=0,n=0,a="";for(let r=0;r<e.length;r++){let o=e[r];a?o===a&&(a=""):'"'===o||"'"===o?a=o:"("===o?n++:")"===o?n--:","===o&&0===n&&(t.push(e.slice(i,r)),i=r+1)}return t.push(e.slice(i)),t.map(e=>{let t=/^\s*\$([A-Za-z_][A-Za-z_0-9]*)\s*=([\s\S]*)$/.exec(e);return{...t?{name:t[1]}:{},value:e0(t?t[2]:e),raw:e}})}(g[2]);if("UpdateLayoutConfig"===p&&(0===u.length||1===u.length&&!u[0].name&&""===u[0].value)&&!g[3]){a.length&&r.add(a.at(-1)),"("===i[p.length]&&e1(u)||tn(n,e.id,"c4_empty_layout_arguments","An empty layout call is a no-op; the writer supplies the attribute required by pinned Mermaid"),e.kind="trivia";continue}/[\r\n]/.test(g[2].replace(/"[^"]*"|'[^']*'/g,""))&&tn(n,e.id,"c4_multiline_arguments","Line breaks between C4 arguments are a reader extension; quoted multiline text remains supported"),u.some(e=>e.name&&""===e.value)&&tn(n,e.id,"c4_empty_named_argument","Empty named arguments are retained; pinned Mermaid requires a positional empty slot");let f=eU.exec(p),y=!!(f&&!("Person"===f[1]&&f[2]))||Object.hasOwn(eY,p)||eH.has(p)||ta.has(p);if(y&&a.length&&r.add(a.at(-1)),y&&u.some(e2))throw new eD(`C4 argument is ambiguous in ${i}: separate named arguments with commas and use $name="value", or quote the entire value when it is literal text`);if(y&&u.some((e,t)=>{let i=e.raw.trim();return e.name?!/^\$[A-Za-z_][A-Za-z_0-9]*\s*=\s*"/.test(i)&&""!==e.value:i.startsWith("$")||t===u.length-1&&""!==i&&!/^["']/.test(i)})&&tn(n,e.id,"c4_unquoted_argument","Unquoted C4 argument text is read literally here, but pinned Mermaid requires a quoted final argument and quoted named values; serialization writes those values in double quotes"),y&&"("!==i[p.length]&&tn(n,e.id,"c4_space_before_arguments",`Pinned Mermaid reads "(" only straight after ${p} and rejects whitespace between them; ours reads the call. Write ${p}( with no space`),f&&!("Person"===f[1]&&f[2])){if(eK(e,"element"),g[3])throw Error(`C4: ${p} cannot open a boundary`);let i=e3(u,e6(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:f[1].toLowerCase(),external:!!f[3],shape:"Person"===f[1]?"person":"Db"===f[2]?"database":"Queue"===f[2]?"queue":"rectangle",label:tt(u,e6(p),i,p),technology:e7(e4(u,e6(p),"techn")),description:e7(e4(u,e6(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id};t&&B("nodes",n.elements.length+n.boundaries.length+1),n.elements.push(l),R("c4")&&z("c4","add-element",l),e.kind="element",e.entityId=r,e.signature=ti(l)}else if(eY[p]){if(eK(e,"boundary-open"),!g[3])throw Error(`C4: ${p} requires a boundary block`);let i=e3(u,e5(p)),r=te(i,"alias",p);if(o.has(r))throw Error(`C4: duplicate declaration alias ${JSON.stringify(r)}`);o.add(r);let l={id:r,macro:p,kind:eY[p],label:tt(u,e5(p),i,p),type:e7(e4(u,e5(p),"type")),description:e7(e4(u,e5(p),"descr")),parentId:a.at(-1),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,..."Node_L"===p?{alignment:"left"}:"Node_R"===p?{alignment:"right"}:{}};t&&(B("nodes",n.elements.length+n.boundaries.length+1),B("nesting",a.length+1)),n.boundaries.push(l),a.push(r),R("c4")&&z("c4","open-boundary",l),e.entityId=r,e.signature=ti(l)}else if(eH.has(p)){eK(e,"relationship");let i=e3(u,e8(p)),a=te(i,"from",p),r=te(i,"to",p),o="Rel_Back"===p,l={id:"",macro:p,from:a,to:r,source:o?r:a,target:o?a:r,label:tt(u,e8(p),i,p),technology:e7(e4(u,e8(p),"techn")),description:e7(e4(u,e8(p),"descr")),tags:e9(i.tags),link:e7(i.link),sprite:e7(i.sprite),style:{},args:u,statementId:e.id,index:"RelIndex"===p?te(i,"index",p):void 0,order:n.relationships.length+1,bidirectional:"BiRel"===p,reversed:o,direction:eZ[p.slice(4)]};t&&B("edges",n.relationships.length+n.layout.hints.length+1),n.relationships.push(l),R("c4")&&z("c4","add-relationship",l),e.kind="relationship","RelIndex"===p&&u.slice(4).some(e=>!e.name)&&tn(n,e.id,"c4_relindex_positional_metadata","RelIndex positional metadata follows documented tags/link slots; pinned Mermaid instead treats them as technology/description. Named $tags/$link avoids this ambiguity")}else{eK(e,"directive");let t={id:e.id,name:p,args:u,category:"UpdateElementStyle"===p?"element-style":"UpdateRelStyle"===p?"relationship-style":"AddElementTag"===p?"element-tag":"AddRelTag"===p?"relationship-tag":"UpdateLayoutConfig"===p||p.startsWith("Lay_")||p.startsWith("LAYOUT_")?"layout":"ShowLegend"===p||"SHOW_LEGEND"===p||"SHOW_FLOATING_LEGEND"===p?"legend":"AddElementLink"===p||"AddRelLink"===p?"link":"unknown",statementId:e.id};n.directives.push(t),R("c4")&&z("c4","add-directive",t),e.kind="directive",e.entityId=t.id,e.signature=ti(t),"unknown"===t.category?tn(n,e.id,"c4_unknown_macro",`${p} is preserved but has no native interpretation`,"error"):p.startsWith("Update")||tn(n,e.id,"c4_directive_extension",`${p} is a reader extension; pinned Mermaid does not accept this directive`)}let x=f?e6(p):eY[p]?e5(p):eH.has(p)?e8(p):("UpdateElementStyle"===p?eJ:"UpdateRelStyle"===p?eQ:"UpdateLayoutConfig"===p?["c4ShapeInRow","c4BoundaryInRow"]:void 0)??("AddElementTag"===p?eV:"AddRelTag"===p?eG:void 0);if(x){let t=new Set;for(let i=0;i<u.length;i++){let a=u[i],r=a.name??x[i];void 0!==r&&x.includes(r)?t.has(r)&&tn(n,e.id,"c4_duplicate_argument",`${p} assigns ${r} more than once; every argument is retained`,"error"):tn(n,e.id,"c4_unknown_argument",`${p} argument ${a.name??i+1} is retained but has no native interpretation`,"error"),r&&t.add(r)}}u.some(e=>/^\s*'/.test(e.raw)||/\\["']/.test(e.raw))?tn(n,e.id,"c4_quoted_string_extension","Quoted-string extension is preserved; typed edits write Mermaid entity escapes"):!y||e1(u)||n.diagnostics.some(t=>t.statementId===e.id&&["c4_multiline_arguments","c4_empty_named_argument"].includes(t.syntax))||tn(n,e.id,"c4_argument_spelling","Argument text is retained as its native value; the writer emits complete quoted argument tokens instead of ambiguous imported spelling")}if(!l)throw Error("C4: missing diagram header");if(a.length)throw Error(`C4: unclosed boundary ${JSON.stringify(a.at(-1))}`);t&&T(n);let c=en(o),h=new Map(n.statements.map(e=>[e.id,e]));for(let e of n.relationships){if(e.id=c(`c4-rel-${e.order}`,["c4-relationship",e.order]),R("c4")&&z("c4","set-relationship-identity",{id:e.id,order:e.order}),!o.has(e.from)||!o.has(e.to))throw Error(`C4: relationship ${e.id} references an undeclared endpoint`);let t=h.get(e.statementId);t.entityId=e.id,t.signature=ti(e)}for(let e of(!function(e,t=!1){for(let t of[...e.elements,...e.boundaries,...e.relationships])t.style={},delete t.effectiveLink,R("c4")&&z("c4","reset-presentation",{id:t.id,style:t.style});e.layout={hints:[]},R("c4")&&z("c4","reset-layout",e.layout);let i=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e])),n=new Map,a=(e,t)=>JSON.stringify([e,t]);for(let t of e.relationships){let e=a(t.from,t.to),i=n.get(e)??[];i.push(t),n.set(e,i)}let r=(e,t)=>{let i=e3(e.args,t);for(let n of["techn","legendText"]){let a=e4(e.args,t,n);void 0!==a&&(i[n]=a)}return i},o=new Map,l=new Map;for(let t of e.directives){if("element-tag"!==t.category&&"relationship-tag"!==t.category)continue;let e=r(t,"element-tag"===t.category?eV:eG);("element-tag"===t.category?o:l).set(e.tagStereo??"",tr(e,["tagStereo"])),R("c4")&&z("c4","define-tag",{category:t.category,tag:e.tagStereo??"",style:("element-tag"===t.category?o:l).get(e.tagStereo??"")})}for(let t of[...e.elements,...e.boundaries])for(let e of t.tags)Object.assign(t.style,o.get(e)),R("c4")&&z("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let t of e.relationships)for(let e of t.tags)Object.assign(t.style,l.get(e)),R("c4")&&z("c4","apply-tag",{id:t.id,tag:e,style:t.style});for(let o of e.directives)if("element-style"===o.category){let e=r(o,eJ),t=i.get(e.elementName);if(!t)throw Error(`C4: UpdateElementStyle references undeclared alias ${JSON.stringify(e.elementName)}`);Object.assign(t.style,tr(e,["elementName"])),R("c4")&&z("c4","set-element-style",{id:t.id,style:t.style})}else if("relationship-style"===o.category){let e=e3(o.args,eQ),t=n.get(a(e.from,e.to));if(!t)throw Error("C4: UpdateRelStyle references an undeclared relationship pair");for(let t of["offsetX","offsetY"])if(void 0!==e[t]&&!Number.isFinite(Number(e[t])))throw Error(`C4: ${t} must be finite`);for(let i of t)Object.assign(i.style,tr(e,["from","to"])),R("c4")&&z("c4","set-relationship-style",{id:i.id,style:i.style})}else if("UpdateLayoutConfig"===o.name){let t=e3(o.args,["c4ShapeInRow","c4BoundaryInRow"]);for(let[i,n]of[["c4ShapeInRow","shapesPerRow"],["c4BoundaryInRow","boundariesPerRow"]]){if(void 0===t[i]||""===t[i])continue;let a=Number(t[i]);if(!Number.isSafeInteger(a)||a<1)throw Error(`C4: ${i} must be a positive integer`);e.layout[n]=a,R("c4")&&z("c4","set-layout-option",{name:n,value:a})}}else if(o.name.startsWith("Lay_")){let n=eZ[o.name.slice(4)],a=e3(o.args,["from","to"]);if(!n||!a.from||!a.to||!i.has(a.from)||!i.has(a.to))throw Error(`C4: ${o.name} requires two declared aliases`);n&&a.from&&a.to&&(t&&B("edges",e.relationships.length+e.layout.hints.length+1),e.layout.hints.push({from:a.from,to:a.to,direction:n,statementId:o.statementId}),R("c4")&&z("c4","add-layout-hint",e.layout.hints.at(-1)))}else if("direction"===o.name)e.layout.direction=o.args[0]?.value,R("c4")&&z("c4","set-direction",e.layout.direction);else if("LAYOUT_LEFT_RIGHT"===o.name||"LAYOUT_TOP_DOWN"===o.name)e.layout.direction="LAYOUT_LEFT_RIGHT"===o.name?"LR":"TB",R("c4")&&z("c4","set-direction",e.layout.direction);else if("AddElementLink"===o.name){let e=e3(o.args,["alias","link"]),t=i.get(e.alias);t&&(t.effectiveLink=e.link,R("c4")&&z("c4","set-effective-link",{id:t.id,link:t.effectiveLink}))}else if("AddRelLink"===o.name){let e=e3(o.args,["from","to","link"]);for(let t of n.get(a(e.from,e.to))??[])t.effectiveLink=e.link,R("c4")&&z("c4","set-effective-link",{id:t.id,link:t.effectiveLink})}let s=en([...e.elements,...e.boundaries,...e.relationships].map(e=>e.id));e.legend={visible:e.directives.some(e=>"legend"===e.category),entries:[...[...o.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["element-tag",e]),label:t.legendText??e,kind:"element",style:{...t}})),...[...l.entries()].map(([e,t])=>({id:s(`c4-tag-${e}`,["relationship-tag",e]),label:t.legendText??e,kind:"relationship",style:{...t}}))]},R("c4")&&z("c4","set-legend",e.legend)}(n,t),n.boundaries))r.has(e.id)||tn(n,e.statementId,"c4_empty_boundary","An empty boundary is retained; the writer supplies a no-op layout statement because pinned Mermaid requires a statement inside its block");if(n.directives.some(e=>"direction"===e.name)){let e=n.directives.find(e=>"direction"===e.name);tn(n,e.statementId,"c4_direction","A standalone direction directive is a reader extension to legacy C4")}for(let e of[...n.elements,...n.boundaries,...n.relationships])for(let t of(e.sprite&&tn(n,e.statementId,"c4_sprite","C4 sprite metadata is preserved; offline native output uses an explicit text fallback"),void 0===e.style.lineStyle||["solid","dashed","dotted"].includes(e.style.lineStyle)||tn(n,e.statementId,"c4_line_style",`C4 lineStyle ${JSON.stringify(e.style.lineStyle)} is preserved but has no native paint effect; the route uses solid strokes`),Object.keys(e.style)))"shape"===t&&"external"in e&&void 0!==ep(e.style.shape)||["bgColor","fontColor","borderColor","textColor","lineColor","lineStyle","offsetX","offsetY","legendText","techn"].includes(t)||tn(n,e.statementId,"c4_style_property",`C4 style ${t} is preserved as metadata but has no native paint effect`);return n}(e,!0),i=t.diagnostics.find(e=>"error"===e.severity);if(i){let e;throw Error(`C4 unsupported syntax: ${(e=t.statements.find(e=>e.id===i.statementId))?`${i.message} (in: ${e.raw.trim()})`:i.message}`)}return t}(e.source.originalText.slice(t)),a=i.split(/\r\n?|\n/).length-1;for(let e of n.statements)e.span.start+=i.length,e.span.end+=i.length,e.span.line+=a;let r=_(e.source.frontmatter);return void 0===n.title&&void 0!==r&&(n.title=r),void 0!==e.source.accessibility.title&&(n.accessibilityTitle=e.source.accessibility.title),void 0!==e.source.accessibility.descr&&(n.accessibilityDescription=e.source.accessibility.descr),{familyConfig:{model:n,c4:e.source.config.c4??{},themeVariables:e.source.config.themeVariables??{}}}},layout:e=>{let m=e.familyConfig;return C(function(e,m={},u,f={},y={}){var x;let b,_,w,v,k,F,S,$,M,C;T(e);let W=ey({...void 0===m.padding?{}:{diagramMarginX:m.padding,diagramMarginY:m.padding},...void 0===m.nodeSpacing?{}:{c4ShapeMargin:m.nodeSpacing},...void 0===m.layerSpacing?{}:{nextLinePaddingX:m.layerSpacing},...f},y),R=Z(m,void 0,u),L=function(e,t=ey()){for(let t of[...e.elements,...e.boundaries,...e.relationships,...e.legend?.entries??[]]){let e=t.style;A({...void 0===e.bgColor?{}:{fill:e.bgColor},...void 0===e.borderColor&&void 0===e.lineColor?{}:{stroke:e.borderColor??e.lineColor},...void 0===e.fontColor&&void 0===e.textColor?{}:{color:e.fontColor??e.textColor}},`C4 ${t.id}`)}let i=ek(e),n={direction:e.layout.direction??e.layout.hints[0]?.direction??e.relationships.find(e=>e.direction)?.direction??"LR",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map},a=new Map;for(let t of e.boundaries)a.set(t.id,{id:i.nodes.get(t.id)??t.id,label:eS(t),nodeIds:[],children:[]});for(let t of e.boundaries){let e=a.get(t.id),i=t.parentId&&a.get(t.parentId);i?i.children.push(e):n.subgraphs.push(e)}for(let r of e.elements){let e=i.nodes.get(r.id)??r.id,o=ex(r,t),l=em(r);n.nodes.set(e,{id:e,label:eF(r),shape:"database"===l?"cylinder":"queue"===l?"subroutine":"rectangle",href:r.effectiveLink??r.link}),r.parentId&&a.get(r.parentId)?.nodeIds.push(e),n.nodeStyles.set(e,{...o.fill?{fill:o.fill}:{},...o.stroke?{stroke:o.stroke}:{},...o.text?{color:o.text}:{},...o.dashed?{"stroke-dasharray":"5 3"}:{}})}for(let t of e.relationships){let a=e$(e,t);n.edges.push({id:i.relationships.get(t.id)??t.id,source:t.source,target:t.target,label:a,labelContent:{value:a,prepared:ee(a,"literal")},style:"dashed"===t.style.lineStyle||"dotted"===t.style.lineStyle?"dotted":"solid",hasArrowStart:t.bidirectional,hasArrowEnd:!0}),n.linkStyles.set(n.edges.length-1,A({...t.style.lineColor?{stroke:t.style.lineColor}:{},...t.style.textColor?{color:t.style.textColor}:{}},`UpdateRelStyle(${t.from}, ${t.to})`))}return n}(e,W),I=new Map,z=new Map([...e.elements,...e.boundaries].map(e=>[e.id,e.parentId])),q=e=>{let t=[];for(let i=z.get(e);i&&!t.includes(i);i=z.get(i))t.push(i);return t},B=e=>void 0!==W.input.c4ShapePadding?W.padding:W.compact&&u?.node?.["X"===e?"paddingX":"paddingY"]===void 0?Math.min(W.padding,R["X"===e?"nodePaddingX":"nodePaddingY"]):R["X"===e?"nodePaddingX":"nodePaddingY"],P=e=>{if(void 0===W.wrapWidth)return;if(void 0===W.maxWidth)return W.wrapWidth;let t=void 0===e?0:q(e).length;return Math.max(24,W.minimumWidth-2*B("X")-20,Math.min(W.wrapWidth,W.maxWidth-(W.marginX+40)*2-t*W.boundaryPadding*2-2*B("X")-20))},O=(e,t,i=!1)=>{let n=ex(e,W);return ea(t,{display:"literal",fontSize:n.fontSize??(i?R.groupHeaderFontSize:R.nodeLabelFontSize),fontWeight:n.fontWeight??(i?R.groupHeaderFontWeight:R.nodeLabelFontWeight),transform:i?R.groupTextTransform:R.nodeTextTransform,maxWidth:P(e.id),letterSpacing:i?R.groupLetterSpacing:R.nodeLetterSpacing,fontFamily:n.fontFamily??(i?R.groupFont:void 0)})},j=e.elements.map(e=>{let t=eF(e),i=O(e,t),n=em(e),a=Math.max(W.minimumWidth,i.width+2*B("X")+20*("queue"===n)),r=Math.max(W.minimumHeight,i.height+2*B("Y")+("person"===n?38:16*("database"===n)));return I.set(e.id,{id:e.id,x:0,y:0,width:a,height:r,..."database"===n?{cylinder:!0}:{}}),{...L.nodes.get(e.id),x:0,y:0,width:a,height:r,labelBlock:i,inlineStyle:L.nodeStyles.get(e.id)}}),N=new Map;for(let t of e.boundaries){let e=eS(t),i=O(t,e,!0),n=i.height+2*W.padding,a={id:t.id,label:e,labelBlock:i,x:0,y:0,width:Math.max(W.minimumWidth,i.width+2*W.padding),height:n+2*W.boundaryPadding,headerHeight:n,children:[]};N.set(t.id,a),I.set(t.id,{...a,container:!0})}let X=L.edges.map((t,i)=>({...t,points:[],labelBlock:ea(e$(e,e.relationships[i]),{display:"literal",fontSize:R.edgeLabelFontSize,fontWeight:R.edgeLabelFontWeight,letterSpacing:R.edgeLetterSpacing,transform:R.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:P()}}),inlineStyle:L.linkStyles.get(i),edgeIndex:i}));for(let t of e.boundaries){let e=X.filter(e=>e.source===t.id&&q(e.target).includes(t.id)||e.target===t.id&&q(e.source).includes(t.id));e.length&&(I.get(t.id).bottomPadding=Math.max(W.boundaryPadding,...e.map(e=>(e.labelBlock?.height??0)+48))*e.length)}let D="LR"===L.direction||"RL"===L.direction;for(let[e,t]of I){let i=X.filter(t=>t.source===e||t.target===e),n=Math.max(0,...i.map(e=>(e.labelBlock?.height??0)+28)),a=Math.max(0,...i.map(e=>(e.labelBlock?.width??0)+24)),r=new Map;for(let t of i){let i=t.source===e?t.target:t.source;r.set(i,(r.get(i)??0)+1)}let o=Math.max(0,...r.values());D?t.height=Math.max(t.height,(o+1)*n+(t.headerHeight??0),(i.length+1)*16+(t.headerHeight??0)):t.width=Math.max(t.width,(o+1)*a,(i.length+1)*16)}let U=m.diagramTitle??e.title,Y=void 0===U?void 0:ea(U,{display:"literal",fontSize:J,fontWeight:Q,transform:R.groupTextTransform,letterSpacing:R.groupLetterSpacing,fontFamily:R.groupFont,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX)}}),H=Y?{text:Y.text,width:Y.width,height:Y.height+V,block:Y}:void 0,K=Math.max(W.gap,...X.map(e=>(e.labelBlock?.width??0)*2+48)),et=Math.max(W.rowGap,...X.map(e=>(e.labelBlock?.height??0)*2+48)),ei=new Map;for(let e of X){let t=JSON.stringify([e.source,e.target].sort());ei.set(t,(ei.get(t)??0)+1)}let en=Math.max(1,...ei.values()),er=en>1?en+1:1,eo=(x={gapX:K*er,gapY:et*er,padding:W.boundaryPadding,marginX:W.marginX+40,marginY:W.marginY+40+(H?.height??0),shapesPerRow:e.layout.shapesPerRow??W.shapesPerRow,boundariesPerRow:e.layout.boundariesPerRow??W.boundariesPerRow,direction:"TD"===L.direction?"TB":L.direction,maxWidth:W.maxWidth},b=new Map([...I].map(([e,t])=>[e,{...t}])),_=[],w=new Map(e.statements.map((e,t)=>[e.id,t])),k=new Map((v=[...e.boundaries,...e.elements].sort((e,t)=>(w.get(e.statementId)??0)-(w.get(t.statementId)??0))).map(e=>[e.id,e.parentId])),F=[...e.layout.hints,...e.relationships.filter(e=>e.direction).map(e=>({from:e.from,to:e.to,direction:e.direction,statementId:e.statementId}))],S=(e,t)=>{let i=new Set;for(;k.get(e)!==t;){if(i.has(e))return;i.add(e);let t=k.get(e);if(!t)return;e=t}return e},M=($=(e,t,i)=>{let n=v.filter(t=>t.parentId===e&&b.has(t.id));for(let e of n)if(b.get(e.id).container&&!t.has(e.id)){let n=new Set(t);n.add(e.id);let a=$(e.id,n,void 0===i?void 0:Math.max(1,i-2*x.padding)),r=b.get(e.id);r.width=Math.max(r.width,a.width+2*x.padding),r.height=Math.max(r.height,a.height+(r.headerHeight??0)+x.padding+Math.max(x.padding,r.bottomPadding??0))}let a=n.some(e=>b.get(e.id).container)?x.boundariesPerRow:x.shapesPerRow,r=x.direction,o="LR"===r||"RL"===r;if(!o&&void 0!==i){let e=Math.max(1,...n.map(e=>b.get(e.id).width)),t=Math.max(1,Math.floor((i+x.gapX)/(e+x.gapX)));a=Math.max(a,Math.ceil(n.length/t))}let l=0,s=0,d=0,c=0,h=0;n.forEach(e=>{let t=b.get(e.id);h&&(h>=a||o&&void 0!==i&&l+t.width>i)&&(o?(l=0,s+=d+x.gapY,d=0):(s=0,l+=c+x.gapX,c=0),h=0),t.x=l,t.y=s,o?l+=t.width+x.gapX:s+=t.height+x.gapY,d=Math.max(d,t.height),c=Math.max(c,t.width),h++});let g=[];for(let t of F){let i=S(t.from,e),n=S(t.to,e);if(!i||!n||i===n||!b.has(i)||!b.has(n))continue;let a="LR"===t.direction||"RL"===t.direction?"x":"y",r="RL"===t.direction||"BT"===t.direction,o=r?n:i,l=r?i:n,s=(e,t,i=new Set)=>e===t||!i.has(e)&&(i.add(e),g.some(n=>n.axis===a&&n.before===e&&s(n.after,t,i)));if(s(l,o)){_.push({code:"C4_LAYOUT_CONFLICT",severity:"warning",statementId:t.statementId,message:`Conflicting C4 ${"x"===a?"horizontal":"vertical"} direction for ${t.from} and ${t.to}; the earlier constraint is retained.`});continue}g.push({before:o,after:l,axis:a,statementId:t.statementId})}if(g.length){for(let e of n){let t=b.get(e.id);g.some(t=>"x"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.x=0),g.some(t=>"y"===t.axis&&(t.before===e.id||t.after===e.id))&&(t.y=0)}let e=()=>{for(let e=0;e<n.length;e++)for(let e of g){let t=b.get(e.before),i=b.get(e.after);i[e.axis]=Math.max(i[e.axis],t[e.axis]+("x"===e.axis?t.width+x.gapX:t.height+x.gapY))}};e();for(let t=0;t<n.length;t++){let t=!1;for(let e=0;e<n.length;e++)for(let i=e+1;i<n.length;i++){let a=b.get(n[e].id),r=b.get(n[i].id);a.x<r.x+r.width&&r.x<a.x+a.width&&a.y<r.y+r.height&&r.y<a.y+a.height&&(r.y=a.y+a.height+x.gapY,t=!0)}if(e(),!t)break}}else if("RL"===r||"BT"===r){let e=Math.max(0,...n.map(e=>{let t=b.get(e.id);return"RL"===r?t.x+t.width:t.y+t.height}));for(let t of n){let i=b.get(t.id);"RL"===r?i.x=e-i.x-i.width:i.y=e-i.y-i.height}}return{width:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.x+t.width})),height:Math.max(0,...n.map(e=>{let t=b.get(e.id);return t.y+t.height}))}})(void 0,new Set,void 0===x.maxWidth?void 0:Math.max(1,x.maxWidth-2*x.marginX)),(C=(e,t,i,n)=>{for(let a of v.filter(t=>t.parentId===e)){let e=b.get(a.id);!e||n.has(a.id)||(n.add(a.id),e.x+=t,e.y+=i,e.container&&C(a.id,e.x+x.padding,e.y+(e.headerHeight??0)+x.padding,n))}})(void 0,x.marginX,x.marginY,new Set),{boxes:b,width:M.width+2*x.marginX,height:M.height+2*x.marginY,diagnostics:_});for(let e of j)Object.assign(e,eo.boxes.get(e.id));let el=[];for(let t of e.boundaries){let e=N.get(t.id);Object.assign(e,eo.boxes.get(t.id));let i=t.parentId&&N.get(t.parentId);i?i.children.push(e):el.push(e)}(function(e,i,m,u,f){let{edges:y}=i,x=[...e.values()].filter(e=>e.container).map(e=>({...e,id:f.generated(`c4-header-obstacle:${e.id}`,["c4","header-obstacle",e.id]),height:e.headerHeight??1,shape:"rectangle",label:""})),b=[...i.nodes,...x],_=0,w=()=>{if(++_>4e5)throw new eW},v=(e,t,i)=>(w(),h(e,t,i)),k=(e,t,i,n,a)=>{let r={x:eR[t].x*i,y:eR[t].y*i},o=n;for(let t of b){if(w(),t.id===a||!(r.x?e.y>t.y&&e.y<t.y+t.height:e.x>t.x&&e.x<t.x+t.width))continue;let i=r.x>0?t.x-e.x:r.x<0?e.x-t.x-t.width:r.y>0?t.y-e.y:e.y-t.y-t.height;i>=0&&(o=Math.min(o,Math.max(0,i-2)))}return{x:e.x+r.x*o,y:e.y+r.y*o}},F=new Map,S=new Map,$=new Map,M=y.flatMap(t=>{let i=e.get(t.source),n=e.get(t.target);if(!i||!n)return[];let[a,r]=function(e,t){if(e.id===t.id)return["R","B"];if(e.container&&eL(e,t)||t.container&&eL(t,e))return["B","B"];let i=eI(e),n=eI(t);return Math.abs(i.x-n.x)>=Math.abs(i.y-n.y)?i.x<=n.x?["R","L"]:["L","R"]:i.y<=n.y?["B","T"]:["T","B"]}(i,n);for(let[e,t]of[[i.id,a],[n.id,r]]){let i=`${e}\0${t}`;S.set(i,(S.get(i)??0)+1)}return[{edge:t,source:i,target:n,startSide:a,endSide:r}]}),C=new Map;for(let e of M){let t=JSON.stringify([e.source.id,e.target.id].sort()),i=C.get(t)??[];i.push(e),C.set(t,i)}for(let[e,i]of M.entries()){let n,{edge:a,source:r,target:o,startSide:l,endSide:s}=i,d=(e,t)=>{let i=`${e.id}\0${t}`,n=$.get(i)??0;return $.set(i,n+1),{index:n,count:S.get(i)}},c=d(r,l),h=d(o,s),p=eq(r,l,c.index,c.count),m=r.id===o.id?eq(o,s,h.index,h.count):function(e,t,i,n,a,r){let o=eq(i,n,a,r);if(eE[t]!==n)return o;let l="L"===n||"R"===n?"y":"x",s=e[l]-o[l];if(0===s||Math.abs(s)>=8)return o;let d=ez(i,n,0),c=ez(i,n,1),h=(e[l]-d[l])/(c[l]-d[l]);if(!(h>0&&h<1))return o;let g=ez(i,n,h);for(let e=0;e<r;e++)if(e!==a&&8>Math.abs(eq(i,n,e,r)[l]-g[l]))return o;return g}(p,l,o,s,h.index,h.count),f=r.container&&r.id!==o.id&&eL(r,o)?-1:1,y=o.container&&r.id!==o.id&&eL(o,r)?-1:1,x=C.get(JSON.stringify([r.id,o.id].sort())),b="R"===l||"L"===l?Math.max(24,...x.map(e=>(e.edge.labelBlock?.width??0)+32)):Math.max(24,...x.map(e=>(e.edge.labelBlock?.height??0)+24)),_=(x.indexOf(i)-(x.length-1)/2)*b,w=14+e%5*4,v=g(a,u),M=k(p,l,f,Math.max(w,v.start?v.start+(u.edgeBendRadius??0):0),r.id),W=k(m,s,y,Math.max(w,v.end?v.end+(u.edgeBendRadius??0):0),o.id);if(F.set(a,{start:p,end:m,startExit:M,endExit:W}),r.id===o.id){let e=r.x+r.width+w+(a.labelBlock?.width??0)/2,t=r.y+r.height+w+(a.labelBlock?.height??0)/2;n=[M,{x:e,y:M.y},{x:e,y:t},{x:W.x,y:t},W]}else if("R"===l||"L"===l){let e=(M.x+W.x)/2+_;n=[M,{x:e,y:M.y},{x:e,y:W.y},W]}else{let e=(M.y+W.y)/2+_;n=[M,{x:M.x,y:e},{x:W.x,y:e},W]}a.points=t([p,...n,m]),F.get(a).seed=a.points,a.label&&(a.labelPosition=E(a.points))}for(let n of(r(i,m,new Set,u),l(i,m,u),s(i,m,u),c(i,m,u),y)){let a=F.get(n),r=e.get(n.source),o=e.get(n.target),l=Math.abs(eI(r).x-eI(o).x)>=Math.abs(eI(r).y-eI(o).y)?eI(r).x<=eI(o).x?"LR":"RL":eI(r).y<=eI(o).y?"TB":"BT",s={id:f.generated(`${n.id}:routing-source`,["c4",n.id,"routing-source"]),label:"",shape:"rectangle",...a.startExit,width:0,height:0},d={id:f.generated(`${n.id}:routing-target`,["c4",n.id,"routing-target"]),label:"",shape:"rectangle",...a.endExit,width:0,height:0},c={...n,source:s.id,target:d.id,points:t([a.startExit,...a.seed.slice(1,-1),a.endExit])},h=(n.labelBlock?.width??0)/2+10,g=(n.labelBlock?.height??0)/2+8;p([...[...i.nodes,...x].map(e=>e.id===n.source||e.id===n.target?e:{...e,x:e.x-h,y:e.y-g,width:e.width+2*h,height:e.height+2*g}),s,d],[c],{...m,direction:l}),c.points.slice(1).some((e,t)=>b.some(i=>v(c.points[t],e,i)))&&(c.points=function(e,i,n,a){let r=(t,a)=>{let r=[...new Set(n.flatMap(e=>[e[t]-10,e[t]+e[a]+10]))],o=[Math.min(e[t],i[t],...r),Math.max(e[t],i[t],...r)],l=n=>Math.min(Math.abs(n-e[t]),Math.abs(n-i[t]));return[...new Set([...o,...r.sort((e,t)=>l(e)-l(t)||e-t).slice(0,14)])]},o=r("x","width"),l=r("y","height"),s=[];for(let t of o)s.push([e,{x:t,y:e.y},{x:t,y:i.y},i]);for(let t of l)s.push([e,{x:e.x,y:t},{x:i.x,y:t},i]);for(let t of o)for(let n of l)s.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:i.y},i]),s.push([e,{x:t,y:e.y},{x:t,y:n},{x:i.x,y:n},i]);let d=e=>e.slice(1).reduce((t,i,n)=>t+Math.hypot(i.x-e[n].x,i.y-e[n].y),0),c=(e,t)=>n.every(i=>!a(e,t,i)),h=e=>e.map(t).sort((e,t)=>d(e)-d(t)||e.length-t.length).find(e=>e.slice(1).every((t,i)=>c(e[i],t))),g=h(s);if(g)return g;let p=l.filter(t=>c(e,{x:e.x,y:t})),m=l.filter(e=>c({x:i.x,y:e},i)),u=o.filter(t=>c(e,{x:t,y:e.y})),f=o.filter(e=>c({x:e,y:i.y},i)),y=[];for(let t of o)for(let n of p)for(let a of m)y.push([e,{x:e.x,y:n},{x:t,y:n},{x:t,y:a},{x:i.x,y:a},i]);for(let t of l)for(let n of u)for(let a of f)y.push([e,{x:n,y:e.y},{x:n,y:t},{x:a,y:t},{x:a,y:i.y},i]);return h(y)}(a.startExit,a.endExit,b,v)??c.points),n.points=t([a.start,...c.points,a.end]),n.labelPosition=E(n.points)}d(i,m,u);let W=[...i.nodes,...x],R={...i,nodes:W},{ctx:L}=a(W,y,m.direction,u,i.groups);for(let e of(L.finalLabelClearance=!0,y))if(e.label)for(let{start:t,end:i}of e.points.slice(1).map((t,i)=>({start:e.points[i],end:t})).sort((e,t)=>Math.abs(t.end.x-t.start.x)+Math.abs(t.end.y-t.start.y)-(Math.abs(e.end.x-e.start.x)+Math.abs(e.end.y-e.start.y)))){let a=n(e,t,i,L);if(a){e.labelPosition=a;break}}for(let t of(s(R,m,u),y)){let i=e.get(t.source),n=e.get(t.target);o(t,t.routeCertificate,{...i,label:"",shape:"rectangle"},{...n,label:"",shape:"rectangle"})}})(eo.boxes,{nodes:j,groups:el,edges:X},L,R,ek(e)),function(e,t,i){let{edges:n}=e,a=eN(e.nodes,e.groups),r=n.flatMap(e=>ej(e,t)),o=[],l=new Map(i.relationships.map(e=>[e.id,e.style])),s=n.flatMap(e=>e.points.slice(1).map((t,i)=>({edge:e,start:e.points[i],end:t})));for(let{edge:e,rect:t}of n.map((e,t)=>({edge:e,index:t,rect:eB(e)})).filter(e=>e.rect).sort((e,t)=>t.rect.width*t.rect.height-e.rect.width*e.rect.height||e.index-t.index)){let i=l.get(e.id),n=e=>Number.isFinite(Number(e))?Number(e):0,d=n(i?.offsetX),c=n(i?.offsetY),h=e=>({x:e.x+d,y:e.y+c}),g=h(e.labelPosition),p=[g],m=t.width,u=t.height,f=t=>{let i={x:t.x-m/2,y:t.y-u/2,width:m,height:u},n=eP(i,3);return[r.reduce((e,t)=>e+eT(n,t),0),a.reduce((e,t)=>e+eT(n,t),0),o.reduce((e,t)=>e+eT(eP(i,4),t),0),s.reduce((t,n)=>t+(n.edge!==e&&eA(n.start,n.end,eP(i,2))?1:0),0)]},y=g,x=f(g);if(x.every(e=>0===e)){e.labelPosition=g,o.push(eB(e));continue}for(let{start:t,end:i}of s.filter(t=>t.edge===e).sort((e,t)=>Math.hypot(t.end.x-t.start.x,t.end.y-t.start.y)-Math.hypot(e.end.x-e.start.x,e.end.y-e.start.y))){let e=Math.hypot(i.x-t.x,i.y-t.y);if(e<.01)continue;let n=-(i.y-t.y)/e,a=(i.x-t.x)/e,r=Math.abs(n)*m/2+Math.abs(a)*u/2;for(let e of[.5,.25,.75,.1,.9])for(let o of[0,r+6,-r-6,r+20,-r-20])p.push(h({x:t.x+(i.x-t.x)*e+n*o,y:t.y+(i.y-t.y)*e+a*o}))}for(let e of(p.sort((e,t)=>Math.hypot(e.x-g.x,e.y-g.y)-Math.hypot(t.x-g.x,t.y-g.y)),p)){let t=f(e),i=t.findIndex((e,t)=>e!==x[t]);if(i>=0&&t[i]<x[i]&&(y=e,x=t),t.every(e=>0===e))break}e.labelPosition=y,o.push(eB(e))}}({nodes:j,groups:el,edges:X},R.lineWidth,e);let es=X.flatMap(e=>{let t=eB(e);return t?[{...t,id:e.id,label:"",shape:"rectangle"}]:[]}),ed=X.flatMap(e=>ej(e,R.lineWidth).map(t=>({...t,id:e.id,label:"",shape:"rectangle"})));i([...j,...es,...ed],X,el,Math.max(W.marginX,W.marginY)+(H?.height??0));let ec=[...j,...N.values(),...es,...ed],eh=Math.max(eo.width,...ec.map(e=>e.x+e.width+W.marginX),...X.flatMap(e=>[...e.points.map(e=>e.x+W.marginX),(e.labelPosition?.x??0)+(e.labelBlock?.width??0)/2+W.marginX]),H?H.width+2*W.marginX:0),eg=Math.max(eo.height,...ec.map(e=>e.y+e.height+W.marginY),...X.flatMap(e=>[...e.points.map(e=>e.y+W.marginY),(e.labelPosition?.y??0)+(e.labelBlock?.height??0)/2+W.marginY])),ep=eC(e,W).map(e=>({...e,block:ea(e.label,{display:"literal",fontSize:R.edgeLabelFontSize,fontWeight:R.edgeLabelFontWeight,letterSpacing:R.edgeLetterSpacing,transform:R.edgeTextTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-64)}})})),eu=ea("Legend",{display:"literal",fontSize:u?.text?.fontSize??13,fontWeight:u?.text?.fontWeight??600,letterSpacing:u?.text?.letterSpacing??0,transform:u?.text?.textTransform,...void 0===W.maxWidth?{}:{maxWidth:Math.max(24,W.maxWidth-2*W.marginX-24)}}),ef=ep.length?{x:W.marginX,y:eg+12,width:Math.max(eu.width+24,...ep.map(e=>e.block.width+64)),height:eu.height+20+ep.reduce((e,t)=>e+t.block.height+10,0),heading:eu,entries:ep}:void 0;ef&&(eh=Math.max(eh,ef.x+ef.width+W.marginX),eg=ef.y+ef.height+W.marginY);let eb=[...eo.diagnostics,...function(e,t,i,n){let a=[],{edges:r,nodes:o,groups:l}=t,s=eN(o,l),d=r.map(e=>({edge:e,box:eB(e)})).filter(e=>e.box),c=t=>e.relationships.find(e=>e.id===t.id)?.statementId;for(let{edge:e,box:t}of d)(s.some(e=>eT(t,e)>.01)||d.some(i=>i.edge!==e&&eT(t,i.box)>.01)||r.some(i=>i!==e&&i.points.slice(1).some((e,n)=>eA(i.points[n],e,t))))&&a.push({code:"C4_LABEL_COLLISION",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has a label halo overlapping another label, card, boundary header/frame or relationship route; all authored text is retained.`});let h=eO(l).map(e=>({...e,height:e.headerHeight??0})),g=r.flatMap(e=>ej(e,i).map(t=>({edge:e,head:t})));for(let e of r){let t=g.filter(t=>t.edge===e).map(e=>e.head);((e.hasArrowEnd||e.hasArrowStart)&&!t.length||t.some(e=>d.some(t=>eT(e,t.box)>.01)||[...o,...h].some(t=>t.id!==e.endpoint&&eT(e,t)>.01)||g.some(t=>t.head!==e&&function(e,t){if(.01>=eT(e,t))return!1;for(let i of[e.polygon,t.polygon])for(let[n,a]of i.entries()){let r=i[(n+1)%i.length],o=-(r.y-a.y),l=r.x-a.x,s=Math.hypot(o,l);if(s<.001)continue;let d=e=>e.polygon.map(e=>(e.x*o+e.y*l)/s),c=d(e),h=d(t);if(Math.max(...c)+e.strokePadding<=Math.min(...h)-t.strokePadding+.01||Math.max(...h)+t.strokePadding<=Math.min(...c)-e.strokePadding+.01)return!1}return!0}(e,t.head))||n&&(e.x<-.01||e.y<-.01||e.x+e.width>n.width+.01||e.y+e.height>n.height+.01)))&&a.push({code:"C4_ARROW_OCCLUDED",severity:"warning",statementId:c(e),message:`Relationship ${e.id} has an arrowhead overlapping a label, card, boundary header or another arrowhead, exceeds the final canvas, or lacks a nonzero terminal segment.`})}return a}(e,{nodes:j,groups:el,edges:X},R.lineWidth,{width:eh,height:eg})];return void 0!==W.maxWidth&&eh>W.maxWidth+.01&&eb.push({code:"C4_WIDTH_EXCEEDED",severity:"warning",message:`The requested C4 width ${W.maxWidth}px cannot contain the ${Math.ceil(eh)}px artifact without shrinking or clipping content; minimum card widths, nesting, explicit direction constraints and authored offsets retain precedence.`}),{width:eh,height:eg,...ef?{legend:ef}:{},nodes:j,groups:el,edges:X,...H?{title:G(H,eh,W.marginY)}:{},body:e,config:W,diagnostics:eb,identities:ek(e),textContext:{node:R.nodeTextTransform,edge:R.edgeTextTransform,group:R.groupTextTransform,legendHeading:u?.text?.textTransform,title:U}}}(m.model,e.renderOptions,e.styleFace,m.c4,m.themeVariables))},projectPositioned:$(function({positioned:e,options:t}){let i=e.body,n=e.textContext,a=(e,t,i,n)=>{if(!i||i.prepared.source!==t||"literal"!==i.prepared.display||i.prepared.transform!==n)throw Error("C4 "+e+" changed its retained prepared text")},r=new Map(i.elements.map(e=>[e.id,e])),o=new Map(i.relationships.map(e=>[e.id,e])),l=new Map,s=new Map,d=(e,t)=>{for(let i of e){if(l.has(i.id))throw Error(`C4 boundary "${i.id}" has a repeated positioned frame`);l.set(i.id,i),s.set(i.id,t),d(i.children,i.id)}};d(e.groups);let c=new Set(e.nodes.map(e=>e.id));if(c.size!==e.nodes.length||c.size!==r.size||i.elements.some(e=>!c.has(e.id)))throw Error("C4 positioned cards do not match the authored identities");if(l.size!==i.boundaries.length)throw Error("C4 positioned frames do not match the authored boundaries");let h=new Set(e.edges.map(e=>e.id));if(h.size!==e.edges.length||h.size!==o.size)throw Error("C4 positioned relationships do not match the authored identities");for(let t of e.nodes){let e=eF(r.get(t.id));if(t.label!==e)throw Error("C4 card "+t.id+" changed its authored text");a(t.id,e,t.labelBlock,n.node)}for(let t of e.edges){let e=void 0===t.id?void 0:o.get(t.id);if(!e)throw Error("C4 positioned relationship has no authored interaction identity");let r=e$(i,e),l="dashed"===e.style.lineStyle||"dotted"===e.style.lineStyle?"dotted":"solid";if(t.source!==e.source||t.target!==e.target||t.label!==r||t.style!==l||t.hasArrowStart!==e.bidirectional||!t.hasArrowEnd||(t.startMarker??"arrow")!=="arrow"||(t.endMarker??"arrow")!=="arrow")throw Error("C4 relationship "+t.id+" changed its authored endpoints, label, shaft or markers");a(t.id,r,t.labelBlock,n.edge)}let g=[];for(let t of i.boundaries){let i=l.get(t.id);if(!i||s.get(t.id)!==t.parentId)throw Error(`C4 boundary "${t.id}" changed its authored parent`);let r=eS(t);if(i.label!==r)throw Error("C4 boundary "+t.id+" changed its authored text");a(t.id,r,i.labelBlock,n.group);let o="left"===t.alignment?"start":"right"===t.alignment?"end":"middle",d="left"===t.alignment?i.x+e.config.padding:"right"===t.alignment?i.x+i.width-e.config.padding:i.x+i.width/2,c=i.headerHeight??36;g.push({id:`boundary-label:${t.id}`,text:i.labelBlock?.text??i.label,bounds:F(i.labelBlock,d,i.y+c/2,o),container:k({...i,height:c})})}if(void 0!==n.title!=(void 0!==e.title))throw Error("C4 positioned title does not match the authored title");if(e.title){let t=e.title;a("title",n.title,t.block,n.group),g.push({id:"title",text:t.text,bounds:F(t.block,t.x,t.y),container:k(v(e))})}let p=eC(i,e.config);if(p.length>0!=(void 0!==e.legend))throw Error("C4 positioned legend does not match the authored legend");if(e.legend){let t=e.legend;if(t.entries.length!==p.length||t.entries.some((e,t)=>e.id!==p[t].id))throw Error("C4 positioned legend entries do not match the authored legend");a("legend heading","Legend",t.heading,n.legendHeading);let i=k(t);g.push({id:"legend:heading",text:t.heading.text,bounds:F(t.heading,t.x+12,t.y+8+t.heading.height/2,"start"),container:i});let r=t.y+20+t.heading.height;for(let[e,o]of t.entries.entries())a(o.id,p[e].label,o.block,n.edge),g.push({id:`legend:entry:${o.id}`,text:o.block.text,bounds:F(o.block,t.x+38,r+o.block.height/2,"start"),container:i}),r+=o.block.height+10}return{version:1,nodes:e.nodes.map(e=>{let t=r.get(e.id),i=em(t),n=e.y+e.height/2+("person"===i?19:4*("database"===i));return{id:t.id,x:q(e.x),y:q(e.y),w:q(e.width),h:q(e.height),shape:i,label:t.label,role:"box",...S(e.labelBlock,e.x+e.width/2,n,e),...void 0!==t.parentId?{parentId:t.parentId}:{}}}),edges:e.edges.map(e=>{let i=void 0===e.id?void 0:o.get(e.id);if(!i)throw Error("C4 positioned relationship has no authored interaction identity");return{id:i.id,from:e.source,to:e.target,path:e.points.map(e=>[q(e.x),q(e.y)]),...void 0!==e.label&&e.labelPosition?{label:{x:q(e.labelPosition.x),y:q(e.labelPosition.y),text:e.label,bounds:F(e.labelBlock,e.labelPosition.x,e.labelPosition.y)}}:{},...t.debug&&e.routeCertificate?{route:e.routeCertificate}:{}}}),groups:i.boundaries.map(e=>{let t=l.get(e.id);if(!t)throw Error(`C4 boundary "${e.id}" has no positioned frame`);return{id:e.id,label:e.label,x:q(t.x),y:q(t.y),w:q(t.width),h:q(t.height),members:i.elements.filter(t=>t.parentId===e.id).map(e=>e.id),...void 0!==e.parentId?{parentId:e.parentId}:{}}}),bounds:{w:q(e.width),h:q(e.height)},labels:g}}),lowerScene:M(to)});export{tl as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as t,d as e,h as n}from"./chunk-
|
|
1
|
+
import{a as t,d as e,h as n}from"./chunk-64JFHCJC.js";function r(t){if(Number.isInteger(t))return String(t);let e=Math.round(100*t)/100;return String(Number.isFinite(e)&&(0!==e||0===t)?e:t)}function a(r,i={}){let c=r<=6?{accent:i.accent&&e(i.accent)?i.accent:t,bg:i.bg&&e(i.bg)?i.bg:void 0}:i,u=n(r,c),s=i.overrides;return s&&0!==s.length?u.map((t,e)=>s[e%12]??t):u}export{r as a,a as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{P as e,R as t,fb as a,jb as n,mb as r}from"./chunk-
|
|
1
|
+
import{P as e,R as t,fb as a,jb as n,mb as r}from"./chunk-EIYLJ4FI.js";function s(a){return e.test(a)?n(a,({name:e,value:a})=>t(e,a)):a}function l(e){let t=/<((?:[A-Za-z_][\w.-]*:)?(?:style|text|title|desc|metadata))\b[\s\S]*?<\/\1>/gi,a=[],n=e=>e.replace(/>\s*\r?\n\s*</g,"><"),r=0,s;for(;null!==(s=t.exec(e));)s.index>r&&a.push(n(e.slice(r,s.index))),a.push(s[0]),r=s.index+s[0].length;return r<e.length&&a.push(n(e.slice(r))),a.join("")}function i(e,t){if(!/^[A-Za-z0-9_.:-]+$/.test(t))throw Error("idPrefix must be non-empty and contain only ASCII letters, digits, underscore, hyphen, dot, and colon");let s=new Set;for(let t of a(e))for(let e of t.attributes)"id"===e.name&&s.add(e.value);let l=e=>e.startsWith(t)?e:`${t}${e}`;return r(n(e,e=>{if("id"===e.name)return l(e.value);if("aria-labelledby"===e.name||"aria-describedby"===e.name)return e.value.split(/\s+/).map(e=>s.has(e)?l(e):e).join(" ");if(("href"===e.name||"xlink:href"===e.name)&&e.value.startsWith("#")){let t=e.value.slice(1);return s.has(t)?`#${l(t)}`:e.value}}),e=>e.replace(/url\(#([^)]+)\)/g,(e,t)=>s.has(t)?`url(#${l(t)})`:e))}export{s as a,l as b,i as c};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{Aa as e,B as r,N as t,Q as i,R as o,fb as n,ib as s,kb as a,la as l,mb as f,na as u,oa as c,ra as d,sa as g,ta as h,va as v,xa as p,za as $}from"./chunk-EIYLJ4FI.js";import{a as m}from"./chunk-YHMTSXIR.js";var w=/^(?:#[0-9a-f]{3,4}|#[0-9a-f]{6}|#[0-9a-f]{8}|[a-z][a-z0-9-]*)$/i,b=/^var\(--[a-z_][a-z0-9_-]*\)$/i,x=/^[a-z0-9_#(),.%+\-\s/]*$/i,y=new Set(["color","color-mix","device-cmyk","hsl","hsla","hwb","lab","lch","oklab","oklch","rgb","rgba"]);function k(e){let r=[],t=0,i=0;for(let o=0;o<e.length;o++){let n=e[o];if("("===n?t++:")"===n?t--:","===n&&0===t&&(r.push(e.slice(i,o)),i=o+1),t<0)return[e]}return 0!==t?[e]:(r.push(e.slice(i)),r)}function B(e){return _(e,!1)}function _(e,r){if("string"!=typeof e)return;let t=e.trim();if(0===t.length||t.length>256)return;if(w.test(t))return t;if(!x.test(t))return;let i=t.indexOf("(");if(i<=0||!t.endsWith(")"))return;let o=0;for(let e of t)if("("===e)o++;else if(")"===e&&--o<0)return;if(0!==o)return;for(let e of t.matchAll(/([a-z][a-z0-9-]*)\s*\(/gi)){let t=e[1].toLowerCase();if(!(r&&"var"===t)&&!y.has(t))return}let n=t.slice(0,i).trim().toLowerCase();return r&&"var"===n||y.has(n)?t:void 0}function z(r,t=!1){let i=j(r);if(void 0===i)return;let o=i.toLowerCase();return"currentcolor"===o||t&&"none"===o||b.test(i)||null!==e(i)?i:void 0}function S(e){return`a color name, #RGB, #RGBA, #RRGGBB, #RRGGBBAA, rgb(), rgba(), hsl(), hsla(), transparent, currentColor${e?", none":""}, or var(--name)`}function j(e){return"string"==typeof e&&e.length<=256&&b.test(e)?e:_(e,!0)}var M=/^[a-z0-9_,'(). \t-]+$/i;function F(e){if("string"!=typeof e)return;let r=function(e){if(!e.includes('"')&&!e.includes("'"))return e;let r="";for(let t=0;t<e.length;t++){let i=e[t];if('"'!==i&&"'"!==i){r+=i;continue}let o=e.indexOf(i,t+1);if(o<0)return;let n=e.slice(t+1,o);if(n.includes('"')||n.includes("'"))return;r+=`'${n}'`,t=o}return r}(e.trim());if(void 0===r||0===r.length||r.length>256||!M.test(r))return;let t=0;for(let e of r)if("("===e)t++;else if(")"===e&&--t<0)return;if(0===t){for(let e of r.matchAll(/([a-z][a-z0-9-]*)\s*\(/gi))if("var"!==e[1].toLowerCase())return;if(!/\b(?:url|expression|import)\b/i.test(r))return r}}function A(e){let r=F(e);if(void 0===r)throw Error("font family must be a safe non-fetching CSS family or var() fallback");return r}function E(e,r){let t=new WeakSet,i=0,o=e=>{if(!(i>r)){if("string"==typeof e){i+=4*e.length+16;return}if(null===e||"object"!=typeof e){i+=16;return}if(t.has(e)){i+=8;return}if(t.add(e),i+=64,e instanceof Map){for(let[t,n]of e)if(i+=32,o(t),o(n),i>r)break}else if(e instanceof Set){for(let t of e)if(i+=16,o(t),i>r)break}else if(e instanceof ArrayBuffer)i+=e.byteLength;else if(ArrayBuffer.isView(e))o(e.buffer);else for(let t of Object.keys(e))if(i+=2*t.length+16,o(e[t]),i>r)break}};return o(e),i}var C={bg:"#FFFFFF",fg:"#27272A"};function O(e){if(!e.shadow)return"";let r=function(e){if(e.replace("#","").length<6)return!1;let[r,t,i]=l(e);return $(r,t,i)/255<.4}(e.bg);return` <filter id="bm-shadow" x="-12%" y="-10%" width="128%" height="136%">
|
|
2
2
|
<feDropShadow dx="0" dy="1.5" stdDeviation="2.5" flood-color="${r?"#ffffff":"#000000"}" flood-opacity="${r?"0.12":"0.08"}" />
|
|
3
|
-
</filter>`}function
|
|
3
|
+
</filter>`}function R(e){return/^[A-Za-z0-9][A-Za-z0-9 _-]*$/.test(e)}function L(e,r,t,i=!1){e=A(e);let o=i?[...R(e)?[`@import url('https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}:wght@400;500;600;700&display=swap');`]:[],...r?["@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500&display=swap');"]:[]]:[],n=`
|
|
4
4
|
/* Derived from --bg and --fg (overridable via --line, --accent, etc.) */
|
|
5
5
|
--_text: var(--fg);
|
|
6
6
|
--_text-sec: var(--muted, color-mix(in srgb, var(--fg) 78%, var(--bg)));
|
|
@@ -14,9 +14,9 @@ import{B as e,N as r,Q as t,R as i,fb as o,ib as n,ka as s,kb as a,ma as l,mb as
|
|
|
14
14
|
--_group-hdr: color-mix(in srgb, var(--fg) 5%, var(--bg));
|
|
15
15
|
--_inner-stroke: color-mix(in srgb, var(--fg) 12%, var(--bg));
|
|
16
16
|
--_key-badge: color-mix(in srgb, var(--fg) 10%, var(--bg));`,s=t?`
|
|
17
|
-
.node, .class-node, .entity, .actor[data-type="participant"], .note, .block, .timeline-event, .journey-task, .sankey-node { filter: url(#bm-shadow); }`:"",a=` svg { font-family: var(--font, ${
|
|
17
|
+
.node, .class-node, .entity, .actor[data-type="participant"], .note, .block, .timeline-event, .journey-task, .sankey-node { filter: url(#bm-shadow); }`:"",a=` svg { font-family: var(--font, ${R(e)?`'${e}'`:e}), system-ui, sans-serif; }`;return["<style>",...o.length>0?[` ${o.join(`
|
|
18
18
|
`)}`,a]:[a],...r?[" .mono { font-family: 'JetBrains Mono', 'SF Mono', 'Fira Code', ui-monospace, monospace; }"]:[],` svg {${n}`,` }${s}`,"</style>"].join(`
|
|
19
|
-
`)}function
|
|
20
|
-
`),
|
|
19
|
+
`)}function W(e,r,t,n,s){let a=void 0===t.font?void 0:A(t.font);for(let e of["bg","fg","line","accent","muted","surface","border"]){let r=t[e];void 0!==r&&function(e,r){if(void 0===j(e))throw Error(`${r} must be a safe non-fetching CSS color or var() reference`)}(r,e)}let l=[`--bg:${t.bg}`,`--fg:${t.fg}`,t.line?`--line:${t.line}`:"",t.accent?`--accent:${t.accent}`:"",t.muted?`--muted:${t.muted}`:"",t.surface?`--surface:${t.surface}`:"",t.border?`--border:${t.border}`:"",a?`--font:${a}`:""].filter(Boolean).join(";"),f=s&&("width"in s||"height"in s||"style"in s||"attrs"in s)?s:void 0,u=f?.attrs??s??{},c=`${l}${n?"":";background:var(--bg)"}${f?.style?`;${f.style}`:""}`,d=Object.entries(u).filter(([,e])=>void 0!==e).map(([e,r])=>`${e}="${r}"`).join(" "),g=d?` ${d}`:"";return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 ${i(e)} ${i(r)}" width="${o("width",String(f?.width??e))}" height="${o("height",String(f?.height??r))}" style="${c}"${g}>`}var D=new r(64,262144);function I(r){let t=[r.bg,r.fg,r.line,r.accent,r.muted,r.surface,r.border].join(`
|
|
20
|
+
`),i=D.get(t);if(i)return i;let o=Object.freeze(function(r){let{bg:t,fg:i}=r,o=r.surface??c(i,t,3),n=c(i,t,5),s=c(i,t,10),a=H(r,[t,o,n,s]),{text:l,textSec:f,textMuted:h,textFaint:p}=a.legible?a:H(r,[t,n,s]);return{bg:t,fg:i,text:l,textSec:f,textMuted:h,textFaint:p,line:g(r.line??c(i,t,50),t,3,l),arrow:g(r.accent??c(i,t,85),t,3,l),nodeFill:o,nodeStroke:function(r,t,i){let o=e(r),n=e(t);if(!o||!n||1!==o[3]||1!==n[3])return r;let s=u(o[0],o[1],o[2]),a=u(n[0],n[1],n[2]);if((d(s,a)??1/0)>=v)return r;let l=e(i);return g(s,a,v,l?.[3]===1?u(l[0],l[1],l[2]):void 0)}(r.border??c(i,t,20),t,l),groupFill:t,groupHdr:n,innerStroke:c(i,t,12),keyBadge:s}}(G(r)??r)),n=2*t.length+E(o,262144);return D.set(t,o,n),o}function G(r){if(p(r.bg)&&p(r.fg))return r;let t=e(r.bg),i=e(r.fg);if(!(!t||!i||1!==t[3]||1!==i[3]))return{...r,bg:u(t[0],t[1],t[2]),fg:u(i[0],i[1],i[2])}}function H(e,r){let{bg:t,fg:i}=e,o=U(i,r),n=U(e.muted??c(i,t,78),r,o),s=U(e.muted??c(i,t,66),r,o),a=U(c(i,t,54),r,o,v),l=(e,t)=>r.every(r=>(d(e,r)??1/0)>=t),f=[o,n,s].every(e=>l(e,h))&&l(a,v);return{text:o,textSec:n,textMuted:s,textFaint:a,legible:f}}function U(e,r,t,i=h){let o=e;for(let e=0;e<2;e++)for(let e of r)o=g(o,e,i,t);return o}function P(e){if(!G(e))return;let r=I(e),t=new Map;return t.set("bg",r.bg),t.set("fg",r.fg),e.line&&p(e.line)&&t.set("line",e.line),e.accent&&p(e.accent)&&t.set("accent",e.accent),e.muted&&p(e.muted)&&t.set("muted",e.muted),e.surface&&p(e.surface)&&t.set("surface",e.surface),e.border&&p(e.border)&&t.set("border",e.border),t.set("_text",r.text),t.set("_text-sec",r.textSec),t.set("_text-muted",r.textMuted),t.set("_text-faint",r.textFaint),t.set("_line",r.line),t.set("_arrow",r.arrow),t.set("_node-fill",r.nodeFill),t.set("_node-stroke",r.nodeStroke),t.set("_group-fill",r.groupFill),t.set("_group-hdr",r.groupHdr),t.set("_inner-stroke",r.innerStroke),t.set("_key-badge",r.keyBadge),t}function J(e,r){if(p(e))return e;let t=e.match(/^var\(\s*--([\w-]+)\s*(?:,\s*(#[0-9a-fA-F]{3,8})\s*)?\)$/);if(t)return P(r)?.get(t[1])??t[2]}function K(r){let t=new Map;for(let i of r.styleContexts)for(let o of r.source.slice(i.start,i.end).matchAll(/--([\w-]+)\s*:\s*([^;{}]+)/g)){let r=o[2].trim();("none"===r||"currentcolor"===r.toLowerCase()||e(r)||r.startsWith("var(")&&j(r))&&t.set(o[1],r)}return t}function N(e,r){let t=Y(r,e);return t?Z(e,t):e}function T(e,r){return X(t(e),Y(r))}function V(){let e,r;return(i,o)=>{let n=t(i);if(o!==e){let t=Object.isFrozen(o)?Object.getOwnPropertyDescriptors(o):void 0;if(!(t&&Reflect.ownKeys(t).every(e=>"value"in t[e])&&["bg","fg","line","accent","muted","surface","border","font"].every(e=>{let r=t[e];return Object.hasOwn(t,e)&&(void 0===r.value||"string"==typeof r.value)})))return X(n,Y(o));r=Y(o),e=o}return X(n,r)}}function X(e,r){let t=r?r.resolveCss(e,r.vars,10):e;return r&&/[<"]/.test(t)?s(n(Z(`<rect fill="${e}"/>`,r))[0],"fill"):m(t)}function Y(e,r){let t=P(e);if(!t)return;let i=I(e),o=void 0===r?void 0:a(r),n=o?K(o):new Map;for(let[e,r]of t)(e.startsWith("_")||void 0!==r&&!n.has(e))&&n.set(e,r);n.set("bg",i.bg),n.set("fg",i.fg);let s=new Set(["font"]);for(let r of[e.font,e.line,e.accent,e.muted,e.surface,e.border])if(r)for(let e of r.matchAll(/var\(\s*--([\w-]+)/g))n.has(e[1])||s.add(e[1]);return{vars:n,SKIP_VARS:s,resolveCss:(e,r,t)=>{let o=e;for(let e=0;e<t;e++){let e=o;if((o=(o=(o=o.replace(/var\(--([\w-]+)\)/g,(e,t)=>s.has(t)?e:r.get(t)??e)).replace(/var\(--([\w-]+),\s*([^()]+)\)/g,(e,t,i)=>s.has(t)?e:r.get(t)??i.trim())).replace(/color-mix\(in srgb,\s*(#[0-9a-fA-F]{3,8})\s+(\d+(?:\.\d+)?)%,\s*(#[0-9a-fA-F]{3,8}|transparent)\)/g,(e,r,t,o)=>c(r,"transparent"===o?i.bg:o,parseFloat(t))))===e)break}return o},projection:o}}function Z(e,r){let{vars:t,SKIP_VARS:i,resolveCss:o}=r,n=r.projection??a(e),s=new Map,l=f(e,e=>{let r=s.get(e);if(void 0!==r)return r;let i=o(e,t,10);return s.set(e,i),i},n),u=l.includes("color-mix(");if(!u){for(let e of l.matchAll(/var\((?=\s*--([\w-]+))/g))if(!i.has(e[1])){u=!0;break}}if(!u)return l;let c=a(l),d=K(c);if(d.size>0)for(let e=0;e<5;e++){let e=f(l,e=>o(e,d,1),c);if(e===l)break;c=a(l=e)}return l}function q(e,r,t,i,o){let n={};return o?(n.role="img",n["aria-roledescription"]=o):(e||r)&&(n.role="img"),e&&(n["aria-labelledby"]=t),r&&(n["aria-describedby"]=i),n}function Q(e,r,t,i,o){if("start"!==t&&"end"!==t)throw TypeError("Arrow endpoint must be start or end");let{width:n,height:s}=r,a="start"===t?0:n,l="start"===t?n:0,f={id:e,shape:"arrow",size:{width:n,height:s},ref:{x:a,y:s/2},...o?{units:o}:{},orient:"auto",geometry:{kind:"polygon",points:[{x:l,y:0},{x:a,y:s/2},{x:l,y:s}]},paint:i};return et(f),f}function ee(e,r){if(!Number.isFinite(e))throw Error(`Marker ${r} must be finite`);return e}function er(e){return e.map(e=>`${ee(e.x,"point.x")} ${ee(e.y,"point.y")}`).join(", ")}function et(e){if("string"!=typeof e.id||""===e.id.trim())throw Error("Marker id must not be empty");if(!["arrow","open-arrow","circle","cross","triangle","diamond","diamond-open"].includes(String(e.shape)))throw Error(`Marker "${e.id}" has an unknown shape`);if(!e.geometry)throw Error(`Marker "${e.id}" must declare geometry`);if(!e.size)throw Error(`Marker "${e.id}" must declare marker size`);if(!e.ref)throw Error(`Marker "${e.id}" must declare a reference point`);if(!(e.size.width>0)||!(e.size.height>0))throw Error(`Marker "${e.id}" size must be positive`);if(ee(e.size.width,"size.width"),ee(e.size.height,"size.height"),ee(e.ref.x,"ref.x"),ee(e.ref.y,"ref.y"),void 0!==e.units&&"strokeWidth"!==e.units&&"userSpaceOnUse"!==e.units)throw Error(`Marker "${e.id}" units must be strokeWidth or userSpaceOnUse`);if("number"==typeof e.orient)ee(e.orient,"orient");else if(void 0!==e.orient&&"auto"!==e.orient&&"auto-start-reverse"!==e.orient)throw Error(`Marker "${e.id}" orient must be auto, auto-start-reverse, or a finite angle`);if(void 0!==e.overflow&&"hidden"!==e.overflow&&"visible"!==e.overflow)throw Error(`Marker "${e.id}" overflow must be hidden or visible`);if(e.viewBox&&(ee(e.viewBox.x,"viewBox.x"),ee(e.viewBox.y,"viewBox.y"),ee(e.viewBox.width,"viewBox.width"),ee(e.viewBox.height,"viewBox.height"),!(e.viewBox.width>0)||!(e.viewBox.height>0)))throw Error(`Marker "${e.id}" viewBox must be positive`)}function ei(e,r={}){et(e);let i=" ".repeat(r.indent??2),o=`${i} `,n=e.units,s=e.orient??"auto",a=[`id="${t(e.id)}"`,`markerWidth="${ee(e.size.width,"size.width")}"`,`markerHeight="${ee(e.size.height,"size.height")}"`,`refX="${ee(e.ref.x,"ref.x")}"`,`refY="${ee(e.ref.y,"ref.y")}"`,`orient="${t(String(s))}"`,...n?[`markerUnits="${t(n)}"`]:[],...e.viewBox?[`viewBox="${ee(e.viewBox.x,"viewBox.x")} ${ee(e.viewBox.y,"viewBox.y")} ${ee(e.viewBox.width,"viewBox.width")} ${ee(e.viewBox.height,"viewBox.height")}"`]:[],...e.overflow?[`overflow="${t(e.overflow)}"`]:[]];return[`${i}<marker ${a.join(" ")}>`,...function e(r,i,o){let n=function(e){if(!e)return"";let r=[];return void 0!==e.fill&&r.push(`fill="${t(e.fill)}"`),void 0!==e.stroke&&r.push(`stroke="${t(e.stroke)}"`),void 0!==e.strokeWidth&&r.push(`stroke-width="${t(e.strokeWidth)}"`),void 0!==e.strokeDasharray&&r.push(`stroke-dasharray="${t(e.strokeDasharray)}"`),void 0!==e.strokeDashoffset&&r.push(`stroke-dashoffset="${t(e.strokeDashoffset)}"`),void 0!==e.strokeLinecap&&r.push(`stroke-linecap="${t(e.strokeLinecap)}"`),void 0!==e.strokeLinejoin&&r.push(`stroke-linejoin="${t(e.strokeLinejoin)}"`),void 0!==e.strokeMiterlimit&&r.push(`stroke-miterlimit="${t(e.strokeMiterlimit)}"`),void 0!==e.vectorEffect&&r.push(`vector-effect="${t(e.vectorEffect)}"`),void 0!==e.paintOrder&&r.push(`paint-order="${t(e.paintOrder)}"`),void 0!==e.opacity&&r.push(`opacity="${t(e.opacity)}"`),r.length>0?` ${r.join(" ")}`:""}(i);switch(r.kind){case"rect":return[`${o}<rect x="${ee(r.x,"rect.x")}" y="${ee(r.y,"rect.y")}" width="${ee(r.width,"rect.width")}" height="${ee(r.height,"rect.height")}"${void 0!==r.rx?` rx="${ee(r.rx,"rect.rx")}"`:""}${void 0!==r.ry?` ry="${ee(r.ry,"rect.ry")}"`:""}${n} />`];case"circle":return[`${o}<circle cx="${ee(r.cx,"circle.cx")}" cy="${ee(r.cy,"circle.cy")}" r="${ee(r.r,"circle.r")}"${n} />`];case"ellipse":return[`${o}<ellipse cx="${ee(r.cx,"ellipse.cx")}" cy="${ee(r.cy,"ellipse.cy")}" rx="${ee(r.rx,"ellipse.rx")}" ry="${ee(r.ry,"ellipse.ry")}"${n} />`];case"line":return[`${o}<line x1="${ee(r.x1,"line.x1")}" y1="${ee(r.y1,"line.y1")}" x2="${ee(r.x2,"line.x2")}" y2="${ee(r.y2,"line.y2")}"${n} />`];case"polygon":return[`${o}<polygon points="${er(r.points)}"${n} />`];case"polyline":return[`${o}<polyline points="${er(r.points)}"${n} />`];case"path":return[`${o}<path d="${t(r.d)}"${n} />`];case"compound":return r.children.flatMap(r=>e(r,i,o))}}(e.geometry,e.paint,o),`${i}</marker>`].join(`
|
|
21
21
|
`)}function eo(e,r={}){let t=new Set;for(let r of e){if(t.has(r.id))throw Error(`Duplicate marker resource "${r.id}"`);t.add(r.id)}return e.map(e=>ei(e,r)).join(`
|
|
22
|
-
`)}export{k as a,B as b,z as c,S as d,j as e,F as f,E as g,C as h,O as i,
|
|
22
|
+
`)}export{k as a,B as b,z as c,S as d,j as e,F as f,E as g,C as h,O as i,L as j,W as k,I as l,J as m,N as n,T as o,V as p,q as q,Q as r,et as s,ei as t,eo as u};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{_ as t}from"./chunk-EIYLJ4FI.js";var e=t=>(Math.round(100*t)/100).toString();function i(i,r,o){let n=t(o.replace(/[\t\n\r ]+/g," ").trim(),{display:"literal",fontSize:15,fontWeight:500}),a=n.width+28,l=i-a/2,p=Math.max(4,r-12-32),s=p+32,c=`M${e(i-6)},${e(s)} L${e(i+6)},${e(s)} L${e(i)},${e(s+6)} Z`;return{text:o,block:n,bgW:a,bgX:l,bgY:p,textX:i,textY:p+16,ptrPath:c}}function r(t,e,i,r,o){if(!i)throw TypeError(`Missing retained tooltip layout for ${r}`);let{block:n,bgW:a,bgX:l,bgY:p,textX:s,textY:c,ptrPath:d}=i,g=t=>Number((Math.round(100*t)/100).toString());return t.group({id:r,role:"chrome",owner:o,visibility:"conditional",open:`<g class="${e}-tip">`,close:"</g>",join:"",children:[{indent:0,node:t.shape({id:`${r}:background`,role:"chrome",owner:o,geometry:{kind:"rect",x:g(l),y:g(p),width:g(a),height:32,rx:8},paint:{fill:"var(--_text)"},attributes:{className:`${e}-tip ${e}-tip-bg`}})},{indent:0,node:t.shape({id:`${r}:pointer`,role:"chrome",owner:o,geometry:{kind:"path",d:d},paint:{fill:"var(--_text)"},attributes:{className:`${e}-tip ${e}-tip-ptr`}})},{indent:0,node:t.text({id:`${r}:text`,role:"label",owner:o,text:n.text,block:n,x:g(s),y:g(c),fontSize:15,fontWeight:500,anchor:"middle",paint:{fill:"var(--bg)"},attributes:{className:`${e}-tip ${e}-tip-text`}})}]})}function o(t,e){let i=e.map(e=>`.${e}:hover .${t}-tip`).join(`,
|
|
2
2
|
`);return`
|
|
3
3
|
.${t}-tip { opacity: 0; pointer-events: none; }
|
|
4
4
|
.${t}-tip-bg { fill: var(--_text); }
|