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
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import{a as e,b as t}from"./chunk-OFOS57WQ.js";import{c as i}from"./chunk-CPO5P4L2.js";import{a as n,b as a,d as r}from"./chunk-O34YYEQV.js";import{D as o,aa as l,xa as s}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 d}from"./chunk-J57YRC2M.js";import{a as h,b as p}from"./chunk-D6MQ7QSU.js";import{c as y,k as c}from"./chunk-XHU3A432.js";import{d as x}from"./chunk-5LKPDHPC.js";import{t as u,z as f}from"./chunk-V6I2VGNQ.js";import"./chunk-7UFOFWBA.js";import{c as g,d as m,e as b}from"./chunk-VRZKI33U.js";import{C as w,D as M,a as k,b as v,c as S,d as R,e as $,g as _,i as L,o as W}from"./chunk-QVSZOF5M.js";import{A as E,C as z,K as I,S as C,aa as T,c as F,ca as B,ea as P,pa as N,s as O,w as D,y as j}from"./chunk-G4JBA7HU.js";import{i as H,j as K,k as U,q as A}from"./chunk-3JTYTXA6.js";import{a as G,b as q,c as Y,h as Q,l as V,m as X,n as J,o as Z}from"./chunk-YVNJDVQO.js";import{$b as ee,C as et,D as ei,E as en,G as ea,H as er,K as eo,La as el,M as es,N as ed,Na as eh,O as ep,Ob as ey,Pb as ec,Sb as ex,Vb as eu,Wa as ef,_ as eg,_b as em,a as eb,ea as ew,o as eM,tb as ek}from"./chunk-EIYLJ4FI.js";import{q as ev,r as eS}from"./chunk-PJJSDGLB.js";import"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";var eR=Object.freeze({id:"er",upstreamId:"er",maturity:"stable",label:"ER",headers:["erDiagram"],aliases:[],config:{section:"er",keys:["layoutDirection","nodeSpacing","rankSpacing","titleTopMargin","diagramPadding","minEntityWidth","minEntityHeight","entityPadding","stroke","fill","fontSize","look","theme"],noopKeys:["diagramPadding","entityPadding","fill","fontSize","look","minEntityHeight","minEntityWidth","stroke","theme","titleTopMargin"]},identity:{id:"family:er",kind:"family",version:"1.0.0",compatibility:{core:"0.5.4"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:["category"],semanticRoles:["prelude","title","defs","chrome","group","group-header","entity","attribute","relationship","cardinality","label"],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:"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:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"entity",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"entity",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"attribute",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"attribute",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"relationship",primitive:"connector",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"cardinality",primitive:"shape",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"]}],example:`erDiagram
|
|
2
|
+
CUSTOMER ||--o{ ORDER : places
|
|
3
|
+
ORDER {
|
|
4
|
+
string id
|
|
5
|
+
}`,detect:ev,detectLoose:eS}),e$={layoutDirection:c("TB","TD","BT","LR","RL"),nodeSpacing:y,rankSpacing:y};function e_(e,t,i,n){let a=[],r=e.x-t.x,o=e.y-t.y,l=Math.sqrt(r*r+o*o);if(0===l)return[];let s=r/l,d=o/l,h=-d;if("parent"===i){let t=(t,i)=>({x:e.x-s*t+h*i,y:e.y-d*t+s*i});return[{geometry:{kind:"polygon",points:[t(0,0),t(6,4),t(12,0),t(6,-4)]},paint:{fill:"var(--bg)",...n}}]}let p=e.x-4*s,y=e.y-4*d,c=e.x-16*s,x=e.y-16*d,u="many"===i||"zero-many"===i,f=(e,t)=>{a.push({geometry:{kind:"line",x1:e+6*h,y1:t+6*s,x2:e-6*h,y2:t-6*s},paint:n})};if("one"===i?(f(p,y),f(p-4*s,y-4*d)):"zero-one"===i&&f(p,y),u){let t=p+7*h,r=y+7*s;a.push({geometry:{kind:"line",x1:t,y1:r,x2:c,y2:x},paint:n}),a.push({geometry:{kind:"line",x1:p,y1:y,x2:c,y2:x},paint:n});let o=p-7*h,l=y-7*s;a.push({geometry:{kind:"line",x1:o,y1:l,x2:c,y2:x},paint:n}),"many"===i&&f(e.x-20*s,e.y-20*d)}if("zero-one"===i||"zero-many"===i){let t=u?20:12,i=e.x-s*t,r=e.y-d*t;a.push({geometry:{kind:"circle",cx:i,cy:r,r:4},paint:{fill:"var(--bg)",...n}})}return a}function eL(e,t,i,n){let a=e_(e,t,i,{stroke:"#000",strokeWidth:String(n+.25)}),r=[];for(let e of a){let t=ef({kind:"shape",id:"cardinality",role:"cardinality",geometry:e.geometry,paint:e.paint});if(!t||!Object.values(t).every(Number.isFinite))return;r.push(t)}return r}function eW(e,t){return eL({x:0,y:0},{x:1,y:0},e,t)?.reduce((e,t)=>el(e,t),void 0)}function eE(e,t){let i=e.width+8,n=e.height+6;return{kind:"rect",x:t.x-i/2,y:t.y-n/2,width:i,height:n,rx:2,ry:2}}function ez(e,t){return ef({kind:"shape",id:"label-pill",role:"chrome",geometry:eE(e,t),paint:{fill:"#000",stroke:"#000",strokeWidth:"0.5"}})}var eI=class extends RangeError{code="ER_ROUTE_WORK_LIMIT";constructor(){super("ER_ROUTE_WORK_LIMIT: frame corridor checks exceed 400000; split the diagram or reduce its relationships"),this.name="ErRouteWorkLimitError"}},eC=class extends Error{code="ER_ROUTE_BLOCKED";constructor(e,t){super(`ER_ROUTE_BLOCKED: no clear frame corridor from ${e} to ${t}`),this.name="ErRouteGeometryError"}},eT=class extends RangeError{code="ER_LABEL_WORK_LIMIT";constructor(){super("ER_LABEL_WORK_LIMIT: label-slot search exceeds 400000 operations; split the diagram or reduce its relationships"),this.name="ErLabelWorkLimitError"}},eF={subject:"ER text entity",example:'A["I #9829; ER"]'};function eB(e){return e.replace(/\\(["\\])/g,"$1")}function eP(e,t,i){let n=e.slice(1,-1);return n.includes("\\")?i?.(`${t} ${e} contains a backslash, and \\" reads as "`,'write " as #quot; and \\ as #92;'):n.includes("%")?i?.(`${t} ${e} contains a % and is read as written`,"write % as #37;"):""===n&&i?.(`${t} ${e} is empty and is read as no text`,"give the name some text"),eB(n)}function eN(e){return d(e,eF)}function eO(e){return er(e).replace(/\*\*([\s\S]+?)\*\*/g,"<b>$1</b>").replace(/_([^_\n]+)_/g,"<i>$1</i>").replace(/(?<!\*)\*([^*\n]+)\*(?!\*)/g,"<i>$1</i>")}function eD(e,t,i=!1){if(/#\w+;/.test(e))return{value:t,prepared:en(ea(i?er(e):eO(e),i?"literal":"formatted"),/#\w+;/g,eN),authored:e}}function ej(e,t=!1){let i=t?eN(eO(e)):eN(e),n=eD(e,i);return{label:i,...n?{labelContent:n}:{}}}function eH(e,t){let i=et(e,t);return"string"!=typeof i?ei(i).replace(/\s+/g," ").trim():eo(e).replace(/\s+/g," ").trim()}function eK(e,t){return eM(t,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:!1})}function eU(e,t,i){let n=eK(e,i);return eg(et(e.label,e.labelContent),{transform:n?.textTransform??t.edgeTextTransform,fontSize:n?.fontSize??t.edgeLabelFontSize,fontWeight:n?.fontWeight??t.edgeLabelFontWeight,letterSpacing:n?.letterSpacing??t.edgeLetterSpacing})}function eA(e,t,i,n){let a=[],r=eY(e,t,i,n??{operations:0},!0,a);for(let t of e.relationships){let e=r.get(t);e?t.finalLabelPosition={...e}:delete t.finalLabelPosition}return a}function eG(e){let t=new Map;for(let i of e.relationships){if(!i.label||i.points.length<2)continue;let e=i.finalLabelPosition;if(!e||!Number.isFinite(e.x)||!Number.isFinite(e.y))return;t.set(i,e)}return t}function eq(e,t,i,n={operations:0}){return eY(e,t,i,n,"shaft-aware"===e.labelPlacement)}function eY(e,t,n,a,r,o){let l=new Map,s=(e=1)=>{if(a.operations+=e,a.operations>4e5)throw new eT};s(e.relationships.length);let d=e.relationships.filter(e=>e.label&&e.points.length>1).length;if(!d)return l;let h=(e,t)=>Math.min(e.x1,t.x1)-Math.max(e.x0,t.x0)>.5&&Math.min(e.y1,t.y1)-Math.max(e.y0,t.y0)>.5,p=[...e.entities.map(e=>{let i=Number.parseFloat(e.inlineStyle?.["stroke-width"]??""),n=(Number.isFinite(i)&&i>0?i:t.nodeLineWidth)/2;return{x0:e.x-n,y0:e.y-n,x1:e.x+e.width+n,y1:e.y+e.height+n}}),...e.groups.flatMap(e=>[{x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.headerHeight},{x0:e.x-.75,y0:e.y-.75,x1:e.x+.75,y1:e.y+e.height+.75},{x0:e.x+e.width-.75,y0:e.y-.75,x1:e.x+e.width+.75,y1:e.y+e.height+.75},{x0:e.x-.75,y0:e.y-.75,x1:e.x+e.width+.75,y1:e.y+.75},{x0:e.x-.75,y0:e.y+e.height-.75,x1:e.x+e.width+.75,y1:e.y+e.height+.75}])],y=e.relationships.flatMap(e=>{if(0===e.points.length)return[];let i=[e.points[0],e.points[e.points.length-1]],n=i.map(e=>({x0:e.x-18,y0:e.y-18,x1:e.x+18,y1:e.y+18}));if(e.points.length<2)return n;let a=[eL(i[0],e.points[1],e.cardinality1,t.lineWidth),eL(i[1],e.points.at(-2),e.cardinality2,t.lineWidth)];return s(2),[...n,...a.flatMap(e=>e??[])]}),c=[];s(p.length+y.length);let x=r?e.relationships.flatMap(e=>{if(e.points.length<2)return[];let i=eK(e,n),a=i?.bendRadius??t.edgeBendRadius,r=i?.lineWidth??t.lineWidth;if(r<=0)return[];let o=a>0&&e.points.length>2,l=Math.max(.5,r/2)+.5*!!o;if(o){s(e.points.length);let t=ew(e.points,a,{metric:"manhattan"}).geometry,i=[];if(!eh(t.d,t=>(s(),i.push({owner:e,box:{x0:t.bounds.x0-l,y0:t.bounds.y0-l,x1:t.bounds.x1+l,y1:t.bounds.y1+l}}),!0),()=>(s(),!0)))throw new eT;return i}return e.points.slice(1).map((t,i)=>{s();let n=e.points[i];return{owner:e,box:{x0:Math.min(n.x,t.x)-l,y0:Math.min(n.y,t.y)-l,x1:Math.max(n.x,t.x)+l,y1:Math.max(n.y,t.y)+l}}})}):[],u=i([...p.map(e=>({box:e,owner:void 0})),...y.map(e=>({box:e,owner:void 0})),...x],e=>e.box,s,2*d);for(let i of e.relationships){if(!i.label||i.points.length<2)continue;let a=i.labelBlock??eU(i,t,n),d=a.width+16,f=a.height+16,g=(e,t)=>({x0:e-d/2,y0:t-f/2,x1:e+d/2,y1:t+f/2}),m=t=>(s(),t.x0<0||t.y0<0||t.x1>e.width||t.y1>e.height||c.some(e=>(s(),h(t,e)))||u(t).some(e=>(s(),e.owner!==i&&h(t,e.box)))),b=i.points,w=[],M=0;for(let e=1;e<b.length;e++){s();let t=Math.hypot(b[e].x-b[e-1].x,b[e].y-b[e-1].y);w.push(t),M+=t}let k=e=>{let t=e;for(let e=0;e<w.length;e++){if(s(),t<=w[e]||e===w.length-1){let i=0===w[e]?0:Math.max(0,Math.min(1,t/w[e]));return{x:b[e].x+(b[e+1].x-b[e].x)*i,y:b[e].y+(b[e+1].y-b[e].y)*i}}t-=w[e]}return b[b.length-1]};s(2*b.length);let v=eQ(b),S={x:v.x,y:v.y},R=g(v.x,v.y),$=r?i.labelPosition:void 0;$&&Number.isFinite($.x)&&Number.isFinite($.y)&&b.slice(1).some((e,t)=>{s();let i=b[t],n=e.x-i.x,a=e.y-i.y,r=n*n+a*a,o=r?Math.max(0,Math.min(1,(($.x-i.x)*n+($.y-i.y)*a)/r)):0;return .001>=Math.hypot($.x-i.x-o*n,$.y-i.y-o*a)})&&!m(g($.x,$.y))&&(R=g((S={...$}).x,S.y));let _=m(R);if(_)for(let e of[.4,.6,.3,.7,.25,.75,.2,.8,.15,.85]){let t=k(M*e),i=g(t.x,t.y);if(!m(i)){S=t,R=i,_=!1;break}}if(_){let t=[];for(let e of x)s(),e.owner!==i&&t.push(e.box);s(p.length+y.length+c.length+t.length);let n=[...p,...y,...c,...t],a,r=0;for(let t=1;t<b.length;t++){s();let i=b[t-1],o=b[t],l=w[t-1],h=i.x===o.x,p=i.y===o.y;if(0===l||!h&&!p){r+=l;continue}let y=h?i.x:i.y,c=(h?d:f)/2,x=(h?f:d)/2,u=h?e.width:e.height,g=h?e.height:e.width;if(y-c<0||y+c>u){r+=l;continue}let m=Math.max(Math.min(h?i.y:i.x,h?o.y:o.x),x),k=Math.min(Math.max(h?i.y:i.x,h?o.y:o.x),g-x);if(m>=k){r+=l;continue}let v=[];for(let e of n){s();let t=h?e.x0:e.y0;Math.min(y+c,h?e.x1:e.y1)-Math.max(y-c,t)<=.5||v.push([(h?e.y0:e.x0)-x+.5,(h?e.y1:e.x1)+x-.5])}v.sort((e,t)=>(s(),e[0]-t[0]||e[1]-t[1]));let S=h?i.y:i.x,R=Math.sign((h?o.y:o.x)-S),$=S+R*(M/2-r),_=(e,t)=>{s();let i=Math.max(1e-6,Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t))*8);if(t-e<=2*i)return;let n=Math.max(e+i,Math.min(t-i,$)),o=Math.abs(r+Math.abs(n-S)-M/2);(!a||o<a.distance)&&(a={point:h?{x:y,y:n}:{x:n,y:y},distance:o})},L=m;for(let[e,t]of v)if(s(),!(t<=L)&&(e>k||(e>L&&_(L,Math.min(k,e)),(L=Math.max(L,t))>=k)))break;L<k&&_(L,k),r+=l}a&&!m(g(a.point.x,a.point.y))&&(R=g((S=a.point).x,S.y),_=!1)}_&&o&&(s(),o.push(i)),c.push(R),l.set(i,S)}return l}function eQ(e){if(0===e.length)return{x:0,y:0};if(1===e.length)return e[0];let t=0;for(let i=1;i<e.length;i++){let n=e[i].x-e[i-1].x,a=e[i].y-e[i-1].y;t+=Math.sqrt(n*n+a*a)}if(0===t)return e[0];let i=t/2,n=0;for(let t=1;t<e.length;t++){let a=e[t].x-e[t-1].x,r=e[t].y-e[t-1].y,o=Math.sqrt(a*a+r*r);if(n+o>=i){let l=o>0?(i-n)/o:0;return{x:e[t-1].x+a*l,y:e[t-1].y+r*l}}n+=o}return e[e.length-1]}var eV={nodeLabelFontSize:G.nodeLabel,edgeLabelFontSize:G.edgeLabel,groupHeaderFontSize:G.groupHeader,nodeLabelFontWeight:700,edgeLabelFontWeight:q.edgeLabel,groupHeaderFontWeight:q.groupHeader,nodePaddingX:14,nodePaddingY:8,nodeCornerRadius:0,nodeLineWidth:Y.outerBox,edgeLineWidth:Y.connector,groupCornerRadius:0,groupPaddingX:14,groupPaddingY:8,groupLineWidth:Y.outerBox};function eX(e,t){return eg(e,{transform:t.nodeTextTransform,fontSize:t.nodeLabelFontSize,fontWeight:t.nodeLabelFontWeight,letterSpacing:t.nodeLetterSpacing})}function eJ(e,t){return eg(e,{transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing})}function eZ(e){let t={display:"literal",fontSize:11,fontWeight:400,monospace:!0};return{type:eg(e.type,t),name:eg(e.name,t),keys:eg(e.keys.join(","),{display:"literal",fontSize:9,fontWeight:600}),...e.comment?{comment:eg(eH(e.comment,e.commentContent),{display:"literal",fontSize:11,fontWeight:400})}:{}}}function e0(){return eg("<i>(no attributes)</i>",{fontSize:11,fontWeight:400})}function e1(e,t,i){for(let i of e.entities)i.labelBlock=eX(et(i.label,i.labelContent),t),i.attributeBlocks=i.attributes.map(eZ),0===i.attributes.length&&(i.emptyAttributeBlock=e0());for(let i of e.groups)i.labelBlock??=eJ(et(i.label,i.labelContent),t);for(let n of e.relationships)n.labelBlock??=eU(n,t,i);return e}function e2(e,t){let i=new Map(e.groups.map(e=>[e.id,e.parentId])),n=new Map([...e.entities.map(e=>[e.id,e.groupId]),...i]),a=(e,t)=>{for(let a=n.get(t),r=0;void 0!==a&&i.has(a)&&r<I.nesting;a=i.get(a),r++)if(a===e)return!0;return!1},r=new Map,o=new Map,l=new Map;for(let[i,n]of e.relationships.entries()){let e=a(n.entity1,n.entity2)?n.entity1:a(n.entity2,n.entity1)?n.entity2:void 0;if(!e)continue;r.set(e,(r.get(e)??0)+t[i].height+56);let s=e===n.entity1?n.entity2:n.entity1;o.set(s,Math.max(o.get(s)??0,t[i].height+40));let d=l.get(e)??[];d.push(i),l.set(e,d)}let s=new Map;for(let e of l.values())e.forEach((t,i)=>s.set(t,(i+1)/(e.length+1)));return{padding:r,exits:o,lanes:s}}function e5(e,t,i){let n=Math.max(e.x,t.x)+(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*i;return[{x:n,y:e.y+e.height},{x:n,y:t.y+t.height}]}function e4(e,t){return e.flatMap((e,i)=>{if(!e.label||e.points.length<2)return[];let n=e.labelPosition??W(e.points),a=t[i];return[{x0:n.x-a.width/2-8,x1:n.x+a.width/2+8,y0:n.y-a.height/2-8,y1:n.y+a.height/2+8}]})}function e7(e,t=1){if(e.operations+=t,e.operations>4e5)throw new eI}function e6(e,t){for(let i=1;i<e.length;i++){let n=e[i-1],a=e[i],r=n.x===a.x;if(e7(t),![n.x,n.y,a.x,a.y].every(Number.isFinite)||n.x!==a.x&&n.y!==a.y||n.x===a.x&&n.y===a.y)return!1;for(let o=1;o<i;o++){e7(t);let l=e[o-1],s=e[o];if(r===(l.x===s.x)){let e=r?"x":"y",t=r?"y":"x";if(n[e]!==l[e])continue;let d=Math.max(Math.min(n[t],a[t]),Math.min(l[t],s[t])),h=Math.min(Math.max(n[t],a[t]),Math.max(l[t],s[t]));if(o===i-1?d<h:d<=h)return!1}else if(o!==i-1){let e=r?n.x:l.x,t=r?l.y:n.y;if(e>=Math.min(n.x,a.x)&&e<=Math.max(n.x,a.x)&&t>=Math.min(n.y,a.y)&&t<=Math.max(n.y,a.y)&&e>=Math.min(l.x,s.x)&&e<=Math.max(l.x,s.x)&&t>=Math.min(l.y,s.y)&&t<=Math.max(l.y,s.y))return!1}}}return!0}function e8(e,t,i,n){let a=new Map([...e,...t].map(e=>[e.id,e])),r=new Set(t.map(e=>e.id)),o=(e=1)=>e7(n,e),l=new Map([...e.map(e=>[e.id,e.groupId]),...t.map(e=>[e.id,e.parentId])]),s=(e,t)=>{for(let i=l.get(t),n=0;void 0!==i&&n<I.nesting;i=l.get(i),n++)if(o(),i===e)return!0;return!1};for(let e of i)for(let t of[!1,!0]){let i=t?e.entity2:e.entity1,n=t?e.entity1:e.entity2,l=a.get(i),d=t?e.points.at(-1):e.points[0];if(!l||!d)continue;let h=(t?[...e.points].reverse():e.points).find(e=>e.x!==d.x||e.y!==d.y);if(o(e.points.length),h)if(r.has(i)&&s(i,n)){if(h.x!==d.x)throw new eC(e.entity1,e.entity2);d.y=l.y+l.height}else{let e=h.y===d.y&&h.x!==d.x||(d.x===l.x||d.x===l.x+l.width)&&h.x!==d.x,t=h.x===d.x&&h.y!==d.y||(d.y===l.y||d.y===l.y+l.height)&&h.y!==d.y;e?(d.x=h.x>d.x?l.x+l.width:l.x,h.y=d.y):t&&(d.y=h.y>d.y?l.y+l.height:l.y,h.x=d.x)}}}function e3(e,t,i,n,a,r,d={operations:0},h){e8(e,t,i,d);let p=a.lineWidth,y=ex([...e.map(e=>e.id),...t.map(e=>e.id)]),c=new Set(t.map(e=>e.id)),x=new Map,u=new Map,f=[...e.map(e=>{let t=y(`er-entity:${e.id}`,["er","entity",e.id]);x.set(t,e.id);let i=Number.parseFloat(e.inlineStyle?.["stroke-width"]??""),n=(Number.isFinite(i)&&i>0?i:a.nodeLineWidth)/2;return{...e,id:t,x:e.x-n,y:e.y-n,width:e.width+2*n,height:e.height+2*n,shape:"rectangle"}}),...t.map(e=>{let t=y(`er-header:${e.id}`,["er","header",e.id]);return u.set(t,e.id),{...e,id:t,height:e.headerHeight,shape:"rectangle"}})],g=e=>e7(d,e);for(let[e,t]of i.entries()){if(h&&!h.indices.has(e)||t.points.length<2)continue;let[i,m]=[t.points[0],t.points.at(-1)],b=eK(t,r),w=(b?.bendRadius??a.edgeBendRadius)+2*(b?.lineWidth??a.lineWidth),M=f.filter(e=>{let i=x.get(e.id);return void 0===i||c.has(i)||i!==t.entity1&&i!==t.entity2}).map(e=>w&&u.get(e.id)!==t.entity1&&u.get(e.id)!==t.entity2?{...e,x:e.x-w,y:e.y-w,width:e.width+2*w,height:e.height+2*w}:e),k=e=>e.slice(1).some((t,i)=>M.some(n=>(g(1),l(e[i],t,n)))),v=(e,n,r)=>{let o=eL(e,n,r,p);if(g(2+(o?.length??0)),!o?.length)return!1;let l=e.y===n.y,s=Math.sign(l?n.x-e.x:n.y-e.y),d=Math.max(...o.map(t=>s>0?l?t.x1-e.x:t.y1-e.y:l?e.x-t.x0:e.y-t.y0)),h=Math.abs(l?n.x-e.x:n.y-e.y),y=b?.bendRadius??a.edgeBendRadius,c=e===i?t.points[2]:t.points.at(-3),x=c?Math.abs(c.x-n.x)+Math.abs(c.y-n.y):h;return h-(t.points.length>2?Math.min(y,h/2,x/2):0)>=d};if(!k(t.points)&&e6(t.points,d)&&v(i,t.points[1],t.cardinality1)&&v(m,t.points.at(-2),t.cardinality2)&&(!h||h.admit(e,t.points)))continue;delete t.labelPosition;let S=t.points.find(e=>e.x!==i.x||e.y!==i.y),R=[...t.points].reverse().find(e=>e.x!==m.x||e.y!==m.y),$=[],_=p+.25,L=(i,r,o,l)=>{let s={x:Math.sign(r.x-i.x),y:Math.sign(r.y-i.y)},d=eL(i,r,l,p);if(g(2+(d?.length??0)),!d?.length)throw new eC(t.entity1,t.entity2);let h=Math.max(0,...d.map(e=>s.x>0?e.x1-i.x:s.x<0?i.x-e.x0:s.y>0?e.y1-i.y:i.y-e.y0)),c=h+(b?.bendRadius??a.edgeBendRadius)+_,x=n[e],u=(s.x?x.width:x.height)/2+8,f=t.entity1===t.entity2&&t.label?h+u+1+_+a.nodeLineWidth/2:0,m=Math.max(c+1+_,f),w=Math.max(20,m);for(let e of M){if(g(1),!(s.x?i.y>e.y&&i.y<e.y+e.height:i.x>e.x&&i.x<e.x+e.width))continue;let t=s.x>0?e.x-i.x:s.x<0?i.x-e.x-e.width:s.y>0?e.y-i.y:i.y-e.y-e.height;t>=0&&(w=Math.min(w,t-1-_))}if(w<m)throw new eC(t.entity1,t.entity2);let k=Math.max(0,...d.map(e=>s.x?Math.max(i.y-e.y0,e.y1-i.y):Math.max(i.x-e.x0,e.x1-i.x))),v={x:i.x+s.x*c,y:i.y+s.y*c};return g(d.length+2),$.push({id:y(`er-terminal:${e}:${$.length}`,["er","terminal",e,$.length]),label:"",shape:"rectangle",x:s.x?Math.min(i.x,v.x):i.x-k,y:s.y?Math.min(i.y,v.y):i.y-k,width:s.x?c:2*k,height:s.y?c:2*k}),{id:o,label:"",shape:"rectangle",x:i.x+s.x*w,y:i.y+s.y*w,width:0,height:0}},W=L(i,S,t.entity1,t.cardinality1),E=L(m,R,t.entity2,t.cardinality2),z=e=>k(e)||e.slice(1).some((t,i)=>$.some(n=>(g(1),l(e[i],t,n)))),I=n[e],C=I.width/2+8,T=I.height/2+8,F=M.map(e=>({...e,x:e.x-C,y:e.y-T,width:e.width+2*C,height:e.height+2*T})),B=[F];g(M.length);let P={source:W.id,target:E.id,style:"solid",hasArrowStart:!1,hasArrowEnd:!1,points:[{x:W.x,y:W.y},...t.points.slice(1,-1),{x:E.x,y:E.y}]},N=Math.abs(m.x-i.x)>=Math.abs(m.y-i.y)?m.x>=i.x?"LR":"RL":m.y>=i.y?"TB":"BT";if(s([...F,...$,W,E],[P],{direction:N},g),z(P.points)){g(M.length);let e=M.map(e=>"TB"===N||"BT"===N?{...e,x:e.x-C,width:e.width+2*C}:{...e,y:e.y-T,height:e.height+2*T});B.push(e),s([...e,...$,W,E],[P],{direction:N},g)}if(z(P.points)){let e="LR"===N||"RL"===N?m.y>=i.y?"TB":"BT":m.x>=i.x?"LR":"RL";g(M.length);let t=M.map(t=>"TB"===e||"BT"===e?{...t,x:t.x-C,width:t.width+2*C}:{...t,y:t.y-T,height:t.height+2*T});B.push(t),s([...t,...$,W,E],[P],{direction:e},g)}let O=t=>{if(z(t))return!1;let n=o([i,...t,m]);return e6(n,d)&&(!h||h.admit(e,n))};if(!O(P.points)){let e;for(let t of[...B,M]){let i=[W.x,E.x],n=[W.y,E.y];for(let e of[...t,...$])g(4),i.push(e.x-_,e.x+e.width+_),n.push(e.y-_,e.y+e.height+_);for(let a of(i.sort((e,t)=>(g(1),Math.abs(e-(W.x+E.x)/2)-Math.abs(t-(W.x+E.x)/2)||e-t)),n.sort((e,t)=>(g(1),Math.abs(e-(W.y+E.y)/2)-Math.abs(t-(W.y+E.y)/2)||e-t)),g((i.length+n.length+2)*4),[[W,{x:E.x,y:W.y},E],[W,{x:W.x,y:E.y},E],...i.map(e=>[W,{x:e,y:W.y},{x:e,y:E.y},E]),...n.map(e=>[W,{x:W.x,y:e},{x:E.x,y:e},E])])){let i=o(a);if(!i.slice(1).some((e,n)=>t.some(t=>(g(1),l(i[n],e,t))))&&O(i)){e=i;break}}if(e)break}if(!e)throw new eC(t.entity1,t.entity2);P.points=e}if(t.points=o([i,...P.points,m]),k(t.points))throw new eC(t.entity1,t.entity2)}}function e9(e){let t=Math.max(0,...e.map(e=>e.comment?eZ(e).comment.width:0));return t>0?t+12:0}function te(e,t){let i={x:e.x+e.width/2,y:e.y+e.height/2},n=t.x-i.x,a=t.y-i.y;return Math.abs(n)*e.height>=Math.abs(a)*e.width?{point:{x:n>=0?e.x+e.width:e.x,y:i.y+a/(Math.abs(n)||1)*e.width/2},horizontal:!0}:{point:{x:i.x+n/(Math.abs(a)||1)*e.height/2,y:a>=0?e.y+e.height:e.y},horizontal:!1}}function tt(e,t){let i=te(e,{x:t.x+t.width/2,y:t.y+t.height/2}),n=te(t,{x:e.x+e.width/2,y:e.y+e.height/2});return function(e,t,i,n){let a=[e];if(e.x!==t.x&&e.y!==t.y)if(i!==n)a.push(i?{x:t.x,y:e.y}:{x:e.x,y:t.y});else if(i){let i=(e.x+t.x)/2;a.push({x:i,y:e.y},{x:i,y:t.y})}else{let i=(e.y+t.y)/2;a.push({x:e.x,y:i},{x:t.x,y:i})}return a.push(t),a}(i.point,n.point,i.horizontal,n.horizontal)}function ti(e,t,i,n){let a=new Map([...e.entities.map(e=>[e.id,e.groupId]),...e.groups.map(e=>[e.id,e.parentId])]),r=new Map;for(let o of(e7(n,a.size),e.relationships)){if(e7(n),o.label){let e=eU(o,t,i).width+16+t.nodeLineWidth+1.5+2*(t.lineWidth+.25);for(let[t,i]of[[o.entity1,o.entity2],[o.entity2,o.entity1]])for(let o=a.get(i),l=0;void 0!==o&&l<I.nesting;o=a.get(o),l++)if(e7(n),o===t){r.set(o,Math.max(r.get(o)??20,e));break}}let e=eK(o,i)?.bendRadius??t.edgeBendRadius;for(let[l,s]of[[o.entity1,o.cardinality1],[o.entity2,o.cardinality2]]){let d=a.get(l);if(!d)continue;let h=eW(s,t.lineWidth);if(e7(n),!h)throw new eC(o.entity1,o.entity2);let p=eK(o,i)?.lineWidth??t.lineWidth,y=h.x1+2*e+2*p+3*(t.lineWidth+.25)+2+.75;r.set(d,Math.max(r.get(d)??20,y))}}return r}function tn(e,t,i,n,a,r,o,l=20,s,d={operations:0},h=new Map){if(0===i.length)return!1;let p=new Map(i.map(e=>[e.id,e])),y=new Map(e.groups.map(e=>[e.id,e])),c=new Map,x=new Map;for(let e of i){let t=e.parentId&&p.has(e.parentId)?e.parentId:void 0,i=c.get(t)??[];i.push(e),c.set(t,i)}for(let e of t){let t=e.groupId&&p.has(e.groupId)?e.groupId:void 0,i=x.get(t)??[];i.push(e),x.set(t,i)}let u=new Map([...t,...i].map(e=>[e.id,e])),f=t=>{e7(d);let i=e.relationships[t],r=u.get(i.entity1),o=u.get(i.entity2),l=tt(r,o),s=eL(l[0],l[1],i.cardinality1,n.lineWidth),h=eL(l.at(-1),l.at(-2),i.cardinality2,n.lineWidth);if(!s?.length||!h?.length)return!0;let y=(e,t)=>(e7(d),e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0);if(s.some(e=>h.some(t=>y(e,t))))return!0;let c=(e,t)=>({x0:t.x,y0:t.y,x1:t.x+t.width,y1:t.y+(p.has(e)?t.headerHeight:t.height)});if(s.some(e=>y(e,c(i.entity2,o)))||h.some(e=>y(e,c(i.entity1,r))))return!0;if(i.label){let e=ez(a[t],W(l));if(!e||y(e,c(i.entity1,r))||y(e,c(i.entity2,o)))return!0}return!1},g=!1,m=(e,t,i)=>{for(let n of(e.x+=t,e.y+=i,x.get(e.id)??[]))n.x+=t,n.y+=i;for(let n of c.get(e.id)??[])m(n,t,i)},b=e=>new Set([e.id,...(x.get(e.id)??[]).map(e=>e.id),...(c.get(e.id)??[]).flatMap(e=>[...b(e)])]),w=(t,i)=>{let M=c.get(t)??[];for(let e of M)w(e.id,y.get(e.id)?.direction??i);let k=x.get(t)??[],v=new Map(k.map(e=>[e.id,e])),S=new Map(k.map(e=>[e.id,[]]));for(let t of e.relationships)v.has(t.entity1)&&v.has(t.entity2)&&(S.get(t.entity1).push(t.entity2),S.get(t.entity2).push(t.entity1));let R=new Set,$=[];for(let e of k){if(R.has(e.id))continue;let t=[],i=[e.id];for(;i.length;){let e=i.pop();R.has(e)||(R.add(e),t.push(v.get(e)),i.push(...S.get(e)))}let n=Math.min(...t.map(e=>e.x)),a=Math.min(...t.map(e=>e.y)),r={x:n,y:a,width:Math.max(...t.map(e=>e.x+e.width))-n,height:Math.max(...t.map(e=>e.y+e.height))-a};$.push({box:r,ids:new Set(t.map(e=>e.id)),move:(e,i)=>{for(let n of(r.x+=e,r.y+=i,t))n.x+=e,n.y+=i}})}let _=[...$,...M.map(e=>({box:e,ids:b(e),move:(t,i)=>m(e,t,i)}))];if(((t,i)=>{let r="LR"===i||"RL"===i,h=r?"y":"x",y=r?"height":"width",c=r?"x":"y",x=t=>{let i=[];for(let a of e.relationships){if(e7(d),!t.ids.has(a.entity1)&&!t.ids.has(a.entity2))continue;let e=u.get(a.entity1),r=u.get(a.entity2);if(!e||!r)continue;let o=tt(e,r),l=2*(eK(a,s)?.bendRadius??n.edgeBendRadius)+2*n.lineWidth+4*(n.lineWidth+.25)+2;for(let[e,r,s,h]of[[a.entity1,o[0],o[1],a.cardinality1],[a.entity2,o.at(-1),o.at(-2),a.cardinality2]]){if(!t.ids.has(e))continue;let o=eL(r,s,h,n.lineWidth);if(e7(d,2+(o?.length??0)),!o)throw new eC(a.entity1,a.entity2);i.push(...o.map(e=>({...e,overhead:l})))}}return i},m=e=>Math.max(0,...[...e.ids].map(e=>{if(e7(d),p.has(e))return .75;let t=u.get(e),i=Number.parseFloat(t?.inlineStyle?.["stroke-width"]??"");return(Number.isFinite(i)&&i>0?i:n.nodeLineWidth)/2})),b=new Map,w=new Map(t.map(e=>[e,Math.max(0,...[...e.ids].map(e=>o.get(e)??0))])),M=new Map;for(let e of t)for(let t of e.ids)b.set(t,e);for(let[t,i]of e.relationships.entries()){e7(d);let e=b.get(i.entity1),o=b.get(i.entity2);if(!e||!o||e===o)continue;let l=eW(i.cardinality1,n.lineWidth),h=eW(i.cardinality2,n.lineWidth);if(!l||!h)throw new eC(i.entity1,i.entity2);let p=eK(i,s)?.bendRadius??n.edgeBendRadius,y=e=>Math.max(0,e.x1,-e.x0,e.y1,-e.y0)+p,c=y(l)+y(h)+2*(n.lineWidth+.25),x=i.label?Math.max(a[t][r?"height":"width"]+56,a[t][r?"height":"width"]+20+c):c,u=c+(i.label?a[t][r?"width":"height"]+20:0);for(let[i,n]of[[e,o],[o,e]]){let e=M.get(i)??new Map,a=e.get(n);e.set(n,{cross:Math.max(a?.cross??0,x),main:Math.max(a?.main??0,u),indices:[...a?.indices??[],t]}),M.set(i,e)}}let k=new Map(t.map(e=>[e,new Set]));for(let t of e.relationships){e7(d);let e=b.get(t.entity1),i=b.get(t.entity2);e&&i&&e!==i&&k.get(e).add(i)}let v=(e,t)=>{let i=[e],n=new Set;for(;i.length;){e7(d);let e=i.pop();if(e===t)return!0;if(!n.has(e))for(let t of(n.add(e),k.get(e)))e7(d),i.push(t)}return!1},S=new Map(t.map(e=>[e,[]])),R=new Map(t.map(e=>[e,[]]));for(let[e,t]of k)for(let i of t)e7(d),v(i,e)||(S.get(i).push(e),R.get(e).push(i));let $=new Map(t.map(e=>[e,S.get(e).length])),_=t.filter(e=>0===$.get(e)),L="BT"===i||"RL"===i,W=r?"width":"height";for(let e=0;e<_.length;e++){let t=_[e],i=0;for(let e of S.get(t)){e7(d);let n=Math.max(l,M.get(t)?.get(e)?.main??0);i=L?Math.min(i,e.box[c]-n-t.box[c]-t.box[W]):Math.max(i,e.box[c]+e.box[W]+n-t.box[c])}for(let e of(0!==i&&(t.move(r?i:0,r?0:i),g=!0),R.get(t)))e7(d),$.set(e,$.get(e)-1),0===$.get(e)&&_.push(e)}t.sort((e,t)=>e.box[h]-t.box[h]||e.box[c]-t.box[c]);let E=[];for(let e of t){for(let t=0;t<E.length;t++){let t=0;for(let i of E){e7(d);let n=M.get(e)?.get(i),a=x(e),o=x(i),s=m(e),p=m(i),u=(e,t,i)=>(e7(d),e.x0<t.x+t.width+i&&e.x1>t.x-i&&e.y0<t.y+t.height+i&&e.y1>t.y-i),g=a.some(e=>u(e,i.box,p))||o.some(t=>u(t,e.box,s)),b=(e,t,i,n)=>Math.max(0,...e.map(e=>{e7(d);let a=i?(r?e.y1:e.x1)-t[h]-t[y]:t[h]-(r?e.y0:e.x0);return a>0?a+e.overhead+n:0})),k=g?b(o,i.box,!0,s)+b(a,e.box,!1,p):0,v=Math.max(n?.cross??0,w.get(e),w.get(i),k),S=r?"width":"height",R=Math.min(e.box[c]+e.box[S],i.box[c]+i.box[S])-Math.max(e.box[c],i.box[c]),$=Math.min(e.box[h]+e.box[y],i.box[h]+i.box[y])-Math.max(e.box[h],i.box[h]);(R>.5||g||n&&R>-n.main&&n.indices.some(f))&&$>-Math.max(v,l>20?l:0)+.5&&(t=Math.max(t,i.box[h]+i.box[y]+Math.max(l,v)-e.box[h]))}if(0===t)break;e.move(r?0:t,r?t:0),g=!0}E.push(e)}})(_,i),void 0===t||0===_.length)return;let L=p.get(t),W=h.get(L.id)??20,E=Math.min(..._.map(e=>e.box.x))-W,z=Math.min(..._.map(e=>e.box.y))-W-L.headerHeight,I=Math.max(E+(L.labelBlock?.width??eJ(L.label,n).width)+20,Math.max(..._.map(e=>e.box.x+e.box.width))+W)-E,C=Math.max(..._.map(e=>e.box.y+e.box.height))+Math.max(W,r.get(L.id)??0)-z;(L.x!==E||L.y!==z||L.width!==I||L.height!==C)&&(g=!0),Object.assign(L,{x:E,y:z,width:I,height:C})};return w(void 0,e.direction??"LR"),g}function ta(e,t,i){let n=V(t,i);if(!n)return e;if(0===e.width&&0===e.height)return{...e,...X(n,40)};let a=n.height;for(let t of e.entities)t.y+=a;for(let t of e.groups)t.y+=a;for(let t of e.relationships){for(let e of t.points)e.y+=a;t.labelPosition&&(t.labelPosition.y+=a)}let r=Math.max(e.width,n.width+80);return{...e,width:r,height:e.height+a,title:J(n,r,40)}}function tr(e,t,n,a){let r=e.relationships;if(!r.length)return e;let s=(e=1)=>e7(a,e),d=(e,t)=>(s(),e.x0<t.x1&&e.x1>t.x0&&e.y0<t.y1&&e.y1>t.y0),h=new Map([...e.entities,...e.groups].map(e=>[e.id,e])),p=new Set(e.groups.map(e=>e.id));e8(e.entities,e.groups,r,a);let y=[...e.entities.map(e=>{let i=Number.parseFloat(e.inlineStyle?.["stroke-width"]??""),n=(Number.isFinite(i)&&i>0?i:t.nodeLineWidth)/2;return{id:e.id,box:{x0:e.x-n,y0:e.y-n,x1:e.x+e.width+n,y1:e.y+e.height+n}}}),...e.groups.flatMap(e=>{let t=e.x,i=e.y,n=t+e.width,a=i+e.height;return[{id:e.id,group:!0,box:{x0:t,y0:i,x1:n,y1:i+e.headerHeight}},{id:e.id,group:!0,border:!0,box:{x0:t-.75,y0:i-.75,x1:t+.75,y1:a+.75}},{id:e.id,group:!0,border:!0,box:{x0:n-.75,y0:i-.75,x1:n+.75,y1:a+.75}},{id:e.id,group:!0,border:!0,box:{x0:t-.75,y0:i-.75,x1:n+.75,y1:i+.75}},{id:e.id,group:!0,border:!0,box:{x0:t-.75,y0:a-.75,x1:n+.75,y1:a+.75}}]})];s(y.length+h.size);let c=()=>r.flatMap((e,i)=>{if(s(),e.points.length<2)throw new eC(e.entity1,e.entity2);return[0,1].map(n=>{let a=n?e.points.at(-1):e.points[0],r=n?e.points.at(-2):e.points[1],o=eL(a,r,n?e.cardinality2:e.cardinality1,t.lineWidth);if(s(2+(o?.length??0)),!o?.length)throw new eC(e.entity1,e.entity2);return{index:i,end:n,rel:e,id:n?e.entity2:e.entity1,point:a,toward:r,pieces:o}})}),x=(e,t,i,n)=>Math.max(0,...e.map(e=>(s(),n>0?i?e.x1-t.x:e.y1-t.y:i?t.x-e.x0:t.y-e.y0))),u=()=>r.flatMap((e,i)=>{let a=eK(e,n),r=(a?.lineWidth??t.lineWidth)/2,o=a?.bendRadius??t.edgeBendRadius,l=(e,t,i,n)=>{s(),t.y===i.y?i.x>t.x===n?e.x0=n?t.x:i.x:e.x1=n?t.x:i.x:t.x===i.x&&(i.y>t.y===n?e.y0=n?t.y:i.y:e.y1=n?t.y:i.y)};if(o>0&&e.points.length>2){let t=ew(e.points,o,{metric:"manhattan"}).geometry,n=[],a;if("path"!==t.kind||!eh(t.d,e=>{s();let t={x0:e.bounds.x0-r,y0:e.bounds.y0-r,x1:e.bounds.x1+r,y1:e.bounds.y1+r};return!n.length&&e.line&&l(t,e.line[0],e.line[1],!0),a=e.line,n.push({index:i,box:t,first:!1,last:!1,...e.line?{line:e.line}:{}}),!0},()=>(s(),!0)))throw new eC(e.entity1,e.entity2);return n.length&&(n[0].first=!0,n.at(-1).last=!0,a&&l(n.at(-1).box,a[0],a[1],!1)),n}return e.points.slice(1).map((t,n)=>{s();let a=e.points[n];if(a.x!==t.x&&a.y!==t.y||![a.x,a.y,t.x,t.y,r].every(Number.isFinite))throw new eC(e.entity1,e.entity2);let o={x0:Math.min(a.x,t.x)-r,y0:Math.min(a.y,t.y)-r,x1:Math.max(a.x,t.x)+r,y1:Math.max(a.y,t.y)+r};return 0===n&&l(o,a,t,!0),n===e.points.length-2&&l(o,a,t,!1),{index:i,box:o,first:0===n,last:n===e.points.length-2,line:[a,t]}})}),f=eA(e,t,n,a),g=eG(e)??eq(e,t,n,a),m=i(y,e=>e.box,s,8*r.length),b=()=>{let e=c(),t=u(),n=new Map(e.map(e=>[e,(s(e.pieces.length),{x0:Math.min(...e.pieces.map(e=>e.x0)),y0:Math.min(...e.pieces.map(e=>e.y0)),x1:Math.max(...e.pieces.map(e=>e.x1)),y1:Math.max(...e.pieces.map(e=>e.y1))})]));return{currentGlyphs:e,glyphQuery:i(e,e=>n.get(e),s,e.length),shaftQuery:i(t,e=>e.box,s,e.length)}},w=b(),M=!1,k=new Map;for(let e of c()){s();let t=e.point.y===e.toward.y?e.toward.x>e.point.x?"E":"W":e.toward.y>e.point.y?"S":"N",i=k.get(e.id)??new Map,n=i.get(t)??[];n.push(e),i.set(t,n),k.set(e.id,i)}let v=[...k.values()].flatMap(e=>[...e.values()].flatMap(e=>e.sort((e,t)=>(s(),(e.point.y===e.toward.y?e.point.y-t.point.y:e.point.x-t.point.x)||2*e.index+e.end-2*t.index-t.end)))),S=new Map(v.map((e,t)=>[2*e.index+e.end,t]));for(let e of(s(2*v.length),v)){s();let i=h.get(e.id),r=e.end?e.rel.points.at(-1):e.rel.points[0],l=e.end?e.rel.points.at(-2):e.rel.points[1],y=l.y===r.y&&l.x!==r.x,c=l.x===r.x&&l.y!==r.y,u=Math.sign(y?l.x-r.x:l.y-r.y),f=y?r.x===(u>0?i.x+i.width:i.x):r.y===(u>0?i.y+i.height:i.y);if(!y&&!c||!f)continue;let g=y?r.y:r.x,v=p.has(e.id)?6:Math.min(t.cornerRadius??0,i.width/2,i.height/2),R=(y?i.y:i.x)+v,$=(y?i.y+i.height:i.x+i.width)-v,{currentGlyphs:_,glyphQuery:L,shaftQuery:W}=w,E=_.find(t=>t.index===e.index&&t.end===e.end),z=[...k.get(e.id).values()].flat().map(e=>_[2*e.index+e.end]).filter(t=>(s(),!(t.id!==e.id||S.get(2*t.index+t.end)<=S.get(2*e.index+e.end))&&(y?t.point.x===r.x&&t.toward.y===t.point.y&&Math.sign(t.toward.x-t.point.x)===u:t.point.y===r.y&&t.toward.x===t.point.x&&Math.sign(t.toward.y-t.point.y)===u))),I=new Set(z);s(z.length);let C=eK(e.rel,n),T=(C?.lineWidth??t.lineWidth)/2,F=x(E.pieces,r,y,u)+(C?.bendRadius??t.edgeBendRadius)+T+t.lineWidth+.25,B=Math.min(Math.abs(y?l.x-r.x:l.y-r.y),F),P=y?{x:r.x+u*B,y:r.y}:{x:r.x,y:r.y+u*B},N={x0:Math.min(r.x,P.x)-(y?0:T),x1:Math.max(r.x,P.x)+(y?0:T),y0:Math.min(r.y,P.y)-(y?T:0),y1:Math.max(r.y,P.y)+(y?T:0)},O=[...E.pieces,N];s(O.length);let D={x0:Math.min(...O.map(e=>e.x0)),x1:Math.max(...O.map(e=>e.x1)),y0:Math.min(...O.map(e=>e.y0)),y1:Math.max(...O.map(e=>e.y1))};y?(D.y0+=R-g,D.y1+=$-g):(D.x0+=R-g,D.x1+=$-g);let j=t.lineWidth+.25;y?(D.y0-=j,D.y1+=j):(D.x0-=j,D.x1+=j);let H=[...L(D).filter(t=>(s(),(t.index!==e.index||t.end!==e.end)&&!I.has(t))).flatMap(e=>e.pieces),...W(D).filter(t=>t.index!==e.index&&!z.some(e=>(s(),e.index===t.index&&(e.end?t.last:t.first)))).map(e=>e.box)],K=[...m(D).filter(t=>t.id!==e.id||!!t.group!==p.has(e.id)).map(e=>e.box),...H],U=new Set(_.filter(t=>t.index===e.index).flatMap(e=>e.pieces));s(U.size);let A=[...m(D).filter(t=>(t.id!==e.id||!!t.group!==p.has(e.id))&&!t.border).map(e=>e.box),...H.filter(e=>!U.has(e))],G=[...E.pieces.map(e=>({piece:e,occupied:K})),{piece:N,occupied:A}];if(s(K.length+A.length+G.length),g>=R&&g<=$&&!G.some(({piece:e,occupied:t})=>t.some(t=>d(e,t))))continue;let q=_.find(t=>t.index===e.index&&t.end!==e.end),Y=q.point.y===q.toward.y;if(y!==Y){let i=Math.sign(Y?q.toward.x-q.point.x:q.toward.y-q.point.y),a=eK(e.rel,n),r=x(q.pieces,q.point,Y,i)+(a?.lineWidth??t.lineWidth)/2+t.lineWidth+.25,o=r+Math.min(a?.bendRadius??t.edgeBendRadius,r),l=Y?q.point.x:q.point.y;i>0?R=Math.max(R,l+o):$=Math.min($,l-o)}let Q=Math.max(R,Math.min(g,$)),V=[];for(let{piece:e,occupied:i}of G)for(let n of i){s();let i=y?e.x0:e.y0,a=y?e.x1:e.y1,r=y?n.x0:n.y0;if(i>=(y?n.x1:n.y1)||a<=r)continue;let o=t.lineWidth+.25;V.push([(y?n.y0:n.x0)-((y?e.y1:e.x1)-g)-o,(y?n.y1:n.x1)-((y?e.y0:e.x0)-g)+o])}for(let[e,t]of(V.sort((e,t)=>(s(),e[0]-t[0]||e[1]-t[1])),V))s(),Q>e&&Q<t&&(Q=t);if(Q>$){Q=Math.max(R,Math.min(g,$));for(let e=V.length-1;e>=0;e--){s();let[t,i]=V[e];Q>t&&Q<i&&(Q=t)}if(Q<R)throw new eC(e.rel.entity1,e.rel.entity2)}if(Q===g)continue;if(Q>$)throw new eC(e.rel.entity1,e.rel.entity2);let X=e.rel.points.map(e=>({...e})),J=e.end?-1:1,Z=e.end?X.length-1:0,ee=y?"y":"x",et=r[ee],ei=Q-et,en=Z;for(let e=Z;e>=0&&e<X.length&&X[e][ee]===et;e+=J)s(),en=e;if(en===(e.end?0:X.length-1)){let i=X[0],a=X.at(-1);X[Z][ee]=Q;let r=_.find(t=>t.index===e.index&&0===t.end),l=_.find(t=>t.index===e.index&&1===t.end),s=eK(e.rel,n),d=e=>{let i=Math.sign(y?e.toward.x-e.point.x:e.toward.y-e.point.y),n=x(e.pieces,e.point,y,i)+(s?.lineWidth??t.lineWidth)/2+t.lineWidth+.25;return n+Math.min(s?.bendRadius??t.edgeBendRadius,n)},h=y?"x":"y",p=Math.sign(a[h]-i[h]),c=i[h]+p*d(r),u=a[h]-p*d(l);if((u-c)*p<0)throw new eC(e.rel.entity1,e.rel.entity2);let f=Math.max(Math.min(c,u),Math.min(Math.max(c,u),(i[h]+a[h])/2));e.rel.points=o(y?[i,{x:f,y:i.y},{x:f,y:a.y},a]:[i,{x:i.x,y:f},{x:a.x,y:f},a])}else{for(let e=Z;e!==en+J;e+=J)s(),X[e][ee]+=ei;e.rel.points=o(X)}if(!e6(e.rel.points,a))throw new eC(e.rel.entity1,e.rel.entity2);delete e.rel.finalLabelPosition,M=!0,w=b()}if(M&&(e3(e.entities,e.groups,r,r.map(e=>e.labelBlock??eU(e,t,n)),t,n,a),f=eA(e,t,n,a),g=eG(e)??eq(e,t,n,a)),f.length){s(r.length+f.length);let i=new Set(f),o=new Set(r.flatMap((e,t)=>i.has(e)?[t]:[]));e3(e.entities,e.groups,r,r.map(e=>e.labelBlock??eU(e,t,n)),t,n,a,{indices:o,admit:(i,r)=>(function(e,t,i,n,a,r){let o=e.relationships[t];if(!o.label)return!0;if(r.operations+=e.relationships.length+2*i.length+2,r.operations>4e5)throw new eT;let l={...o,points:i},s=Math.max(e.width,...i.map(e=>e.x+40)),d=Math.max(e.height,...i.map(e=>e.y+40)),h={...e,width:s,height:d,relationships:e.relationships.map((e,i)=>i===t?l:e)},p=[];return eY(h,n,a,r,!0,p),!p.includes(l)})(e,i,r,t,n,a)}),e.width=Math.max(e.width,...r.flatMap(e=>e.points.map(e=>e.x+40))),e.height=Math.max(e.height,...r.flatMap(e=>e.points.map(e=>e.y+40))),eA(e,t,n,a),g=eG(e)??eq(e,t,n,a)}let R=c(),$=u(),_=r.flatMap((e,i)=>{s();let a=g.get(e);if(!e.label||!a)return[];let r=ez(e.labelBlock??eU(e,t,n),a);if(!r)throw new eC(e.entity1,e.entity2);return[{index:i,box:r}]});for(let e of r)if(!e6(e.points,a))throw new eC(e.entity1,e.entity2);for(let t of r)for(let i=1;i<t.points.length;i++){for(let n of e.entities)if(s(),l(t.points[i-1],t.points[i],{...n,label:"",shape:"rectangle"}))throw new eC(t.entity1,t.entity2);for(let n of e.groups)if(s(),n.headerHeight>0&&l(t.points[i-1],t.points[i],{...n,height:n.headerHeight,label:"",shape:"rectangle"}))throw new eC(t.entity1,t.entity2)}let L=(e,t,i,n,a,o)=>{if(p.has(t)!==o)return!1;let l=r[e.index],d=e.first&&l.entity1===t?0:e.last&&l.entity2===t?1:void 0;if(void 0===d)return!1;let h=d?l.points.at(-1):l.points[0],y=d?l.points.at(-2):l.points[1],c=h.y>=i.y+a&&h.y<=i.y+i.height-a,x=h.x>=i.x+a&&h.x<=i.x+i.width-a;return s(),c&&y.y===h.y&&(h.x===i.x&&y.x<h.x&&e.box.x1<=i.x+n||h.x===i.x+i.width&&y.x>h.x&&e.box.x0>=i.x+i.width-n)||x&&y.x===h.x&&(h.y===i.y&&y.y<h.y&&e.box.y1<=i.y+n||h.y===i.y+i.height&&y.y>h.y&&e.box.y0>=i.y+i.height-n)};for(let i of $){let n=r[i.index];for(let a of e.entities){let e=Number.parseFloat(a.inlineStyle?.["stroke-width"]??""),r=(Number.isFinite(e)&&e>0?e:t.nodeLineWidth)/2,o={x0:a.x-r,y0:a.y-r,x1:a.x+a.width+r,y1:a.y+a.height+r};if(d(i.box,o)&&!L(i,a.id,a,r,Math.min(t.cornerRadius??0,a.width/2,a.height/2),!1))throw new eC(n.entity1,n.entity2)}for(let t of e.groups){let e={x0:t.x,y0:t.y,x1:t.x+t.width,y1:t.y+t.headerHeight};if(t.headerHeight>0&&d(i.box,e)&&!L(i,t.id,t,.75,6,!0))throw new eC(n.entity1,n.entity2)}}let W=new Map(R.map(e=>(s(4*e.pieces.length+1),[e,{x0:Math.min(...e.pieces.map(e=>e.x0)),y0:Math.min(...e.pieces.map(e=>e.y0)),x1:Math.max(...e.pieces.map(e=>e.x1)),y1:Math.max(...e.pieces.map(e=>e.y1))}]))),E=i(R,e=>W.get(e),s,R.length+_.length),z=i($,e=>e.box,s,4*R.length+_.length),I=i(_,e=>e.box,s,_.length);for(let e of R)for(let t of E(W.get(e)))if(s(),!(2*t.index+t.end<=2*e.index+e.end)){for(let i of e.pieces)if(t.pieces.some(e=>d(i,e)))throw new eC(e.rel.entity1,e.rel.entity2)}for(let e of R){let t=e.toward.x-e.point.x,i=e.toward.y-e.point.y,n=0===i&&0!==t,a=0===t&&0!==i,r=Math.sign(n?t:i),o=$.find(t=>(s(),t.index===e.index&&(e.end?t.last:t.first)))?.line,l=o&&(e.end?o[0]:o[1]),h=o&&(e.end?o[1]:o[0]);if(!n&&!a||!l||!h||(n?l.y!==h.y||Math.sign(l.x-h.x)!==r:l.x!==h.x||Math.sign(l.y-h.y)!==r)||r*((n?l.x:l.y)-(n?e.point.x:e.point.y))<x(e.pieces,e.point,n,r))throw new eC(e.rel.entity1,e.rel.entity2);for(let t of e.pieces){for(let i of m(t))if((i.id!==e.id||!!i.group!==p.has(e.id))&&d(t,i.box))throw new eC(e.rel.entity1,e.rel.entity2);for(let i of z(t))if((i.index!==e.index||!(e.end?i.last:i.first))&&d(t,i.box))throw new eC(e.rel.entity1,e.rel.entity2)}}for(let e of _){let t=r[e.index];for(let i of m(e.box))if(d(e.box,i.box))throw new eC(t.entity1,t.entity2);for(let i of E(e.box))if(d(e.box,W.get(i))&&i.pieces.some(t=>d(e.box,t)))throw new eC(t.entity1,t.entity2);for(let i of z(e.box))if(i.index!==e.index&&d(e.box,i.box))throw new eC(t.entity1,t.entity2);for(let i of I(e.box))if(i.index<e.index&&d(e.box,i.box))throw new eC(t.entity1,t.entity2)}return e}var to=String.raw`[A-Za-z0-9_][\w.-]*(?![\w.-])`,tl=String.raw`"(?:\\.|[^"\\])*"`,ts=RegExp(`^${tl}$`),td=`(?:${tl}|${to})`,th=RegExp(`^${to}$`),tp=String.raw`${td}(?:\[\s*(?:${tl}|[^\]"\r\n]+)\s*\])?(?::::[\w-]+(?:,[\w-]+)*)?`,ty=new RegExp(String.raw`^(${td})(?:\[\s*(?:(${tl})|([^\]"\r\n]+))\s*\])?(?::::([\w-]+(?:,[\w-]+)*))?$`),tc=String.raw`(?:one or zero|zero or one|one or more|one or many|zero or more|zero or many|only one|many\(0\)|many\(1\)|1\+|0\+|many|one|1|u(?=[.\-|])|[|o}{]+)`,tx=String.raw`(?:\|\||\|o|o\||\}o|o\{|\}\||\|\{|\bu(?=[.\-|]))`,tu=RegExp(`^(${tp})(?:[ \\t]+(${tc})|(${tx}))(?:([ \\t]*(?:--|\\.\\.|\\.-|-\\.)[ \\t]*)|([ \\t]+(?:optionally to|to)[ \\t]+))(?:(${tc})[ \\t]+|(${tx}))(${tp})(?:[ \\t]*:[ \\t]*(.*))?$`,"i");function tf(e,t){let i=e.trim().match(ty);if(!i)return null;let n=i[1].startsWith('"')?eP(i[1],"ER entity name",t):i[1],a=void 0!==i[2]?eP(i[2],"ER entity alias",t):i[3]?.trim();return{id:n,...void 0!==a?{alias:a}:{},...i[4]?{className:i[4].replaceAll(","," ")}:{},...i[1].startsWith('"')?{quoted:!0}:{}}}function tg(e,t,i){let n=e.get(t);if(n)for(let e of i)n.push(e);else e.set(t,[...i])}var tm=RegExp(String.raw`^subgraph\s+(${tl}|\S+?)(?:\s*\[([^\]]+)\])?$`,"i"),tb=/#(\d{2}|\d{5}|\d{7});/g;function tw(e){let t="ER_STYLE_ENTITY_";for(;e.includes(t);)t+="_";let i=[],n=e.replace(tb,(e,n)=>{let a=Number(n);return i.push(a<=1114111?String.fromCodePoint(a):"�"),`${t}${i.length-1}_`}),a=RegExp(`${t}(\\d+)_`,"g"),r=e=>e.replace(a,(e,t)=>i[Number(t)]);return Object.fromEntries(Object.entries(T(n)).map(([e,t])=>[r(e),r(t)]))}function tM(e,i,n){let a=t(e);if(a)return{kind:"direction",direction:a};let r=function(e,t){let i=e.match(tm);if(!i)return null;let n=i[1].startsWith('"')?eP(i[1],"ER subgraph id",t):i[1],a=i[2]?.trim();return a?{id:n,title:ts.test(a)?eP(a,"ER subgraph title",t):a}:{id:n}}(e,n);if(r)return{kind:"group-open",...r};if("end"===e&&i)return{kind:"end"};let o=e.match(/^classDef\s+([\w,-]+)\s+(.+)$/is);if(o)return{kind:"class-def",names:o[1].split(",").map(e=>e.trim()).filter(Boolean),props:tw(o[2])};let l=function(e,t){let i=/^class[ \t]+/i.exec(e);if(!i)return null;let n=e.slice(i[0].length).trimEnd(),a=n.length,r=[],o=e=>/[A-Za-z0-9_-]/.test(e);for(;a>0;){let e=a;for(;a>0&&o(n[a-1]);)a--;if(a===e)break;r.push(n.slice(a,e));let i=a;for(;a>0&&(" "===n[a-1]||" "===n[a-1]);)a--;if(","===n[a-1]){for(a--;a>0&&(" "===n[a-1]||" "===n[a-1]);)a--;continue}if(a===i||0===a)break;let l=n.slice(0,a).split(",").map(e=>tf(e.trim(),t));return 0===l.length||l.some(e=>null===e)?null:{ids:l.map(e=>e.id),classNames:r.reverse()}}return null}(e,n);if(l)return{kind:"class",...l};if(/^class(?:[ \t]|$)/i.test(e))throw Error(`Invalid ER class assignment: ${e}`);let s=e.match(/^style\s+(.+?)\s+(.+)$/is);if(s){let t=s[1].split(",").map(e=>tf(e.trim(),n));if(t.some(e=>null===e))throw Error(`Invalid ER style assignment: ${e}`);return{kind:"style",ids:t.map(e=>e.id),props:tw(s[2])}}let d=function(e,t){let i=e.match(tu);if(!i)return null;let n=i[2]??i[3];if("1"===n&&/^[ \t]/.test(i[4]??""))return null;let a=tf(i[1],t),r=tf(i[8],t);if(!a||!r)return null;let o=(i[4]??i[5]).trim().replace(/[ \t]+/g," ").toLowerCase();return{entity1:a,entity2:r,leftToken:n,rightToken:i[6]??i[7],identifying:"--"===o||"to"===o,label:function(e,t){let i=e.trim();if(!i.startsWith('"'))return i;if(/^"[^"]*"$/.test(i))return i.slice(1,-1);if(/^"(?:\\.|[^"\\])*"$/.test(i))return t?.(`ER relation label ${i} contains \\", which reads as "`,'write " as #quot;'),eB(i.slice(1,-1));throw O({what:`ER relation label ${i} is not one quoted string`,expectedForm:'one pair of quotes, with " written as #quot;',example:'A ||--o{ B : "says #quot;hi#quot;"'})}(i[9]??"",t),...!function(e){let t=e.replace(/#\w+;/g,"§");if(t.startsWith('"')||/direction\s+(?:TB|BT|LR|RL)/i.test(t))return!1;let i=/^(?:\P{ASCII}|[\w*.-])*/u.exec(t)[0],n=t.slice(i.length);return""===i||/^\d/.test(i)||tR.test(t)||tS.test(t)||/^[^\s"]/.test(n)||(n.match(/"/g)?.length??0)%2==1}(i[9]?.trim()??"")?/^[^"\s][^\s"]*(?:\s+\S|")/.test(i[9]?.trim()??"")?{unquotedWords:!0}:{}:{unreadLabel:!0}}}(e,n);if(d)return{kind:"relation",relation:d};let h=e.match(tk),p=h?tf(h[1],n):null;if(p)return{kind:"block-open",reference:p};let y=tf(e,n);return y?{kind:"entity",reference:y}:null}var tk=RegExp(`^(${tp})\\s*\\{`),tv=RegExp(`^${tp}`),tS=RegExp(String.raw`^(?:\|\||\|o|o\||\}o|o\{|\}\||\|\{|--|\.\.|\.-|-\.|u(?=[.|-])|1\+|0\+|1(?=\s+[\w"']|--|\.\.|\.-|-\.)|(?:one or zero|zero or one|one or more|one or many|zero or more|zero or many|only one|many\(0\)|many\(1\)|many|one|optionally to|to)(?!\w))`,"i"),tR=/^(?:(?:subgraph|end|style|classDef|class|erDiagram)(?!\w)|direction\s+(?:TB|BT|LR|RL))/i;function t$(e){let t=!1;for(let i=0;i<e.length;i++){let n=e[i];if(t)'"'===n&&(t=!1);else if('"'===n)t=!0;else if("`"===n&&(0===i||/\s/.test(e[i-1]))){let t=e.indexOf("`",i+1);t>i+1&&!/\s/.test(e.slice(i+1,t))&&(i=t)}else if("}"===n)return i}return -1}var t_=/[\w*\u00C0-\uFFFF]/,tL=/^[*A-Za-z_\u00C0-\uFFFF][\w\-[\]().,\u00C0-\uFFFF*]*$/,tW=/^`[^`]+`$/,tE=(e,t=e.text)=>"word"===e.kind&&((t.match(/~/g)?.length??0)>=2||tL.test(t)||tW.test(t))&&!/^(?:PK|FK|UK)\b/i.test(t),tz=e=>"word"===e.kind&&e.text.split(",").every(e=>!e||/^(?:PK|FK|UK)$/i.test(e));function tI(e,t,i,n){let a=e=>e.replace(/^`([^`]+)`(\?)?$/,(e,t,i)=>t+(i??"")),r=void 0===n?void 0:eN(er(n)),o=void 0===n?void 0:eD(n,r,!0);return{type:a(e),name:a(t),keys:i,comment:r,...o?{commentContent:o}:{}}}function tC(e,t,i){let n=(t,i)=>({syntax:t,start:i,end:"block-open"===t.kind?i+tk.exec(e.slice(i))[0].length:e.length}),a=tF(e,t,i);if(a)return a;let r=tM(e,t,i);if(r)return[n(r,0)];let o=[],l=[],s=[{syntax:{kind:"unknown"},start:0,end:e.length}];for(let i=0;i<e.length;){let a=e.slice(i);if(tS.test(a))return s;if(i>0){let e=[],r=tF(a,t,(t,i)=>e.push([t,i]));if(r){o.push(...r.map(e=>({...e,start:e.start+i,end:e.end+i}))),l.push(...e);break}let s=tM(a,t,(t,i)=>e.push([t,i]));if(s){o.push(n(s,i)),l.push(...e);break}}if(tR.test(a))return s;let r=tv.exec(a),d=r&&tf(r[0],(e,t)=>l.push([e,t]));if(!d)return s;o.push({syntax:{kind:"entity",reference:d},start:i,end:i+r[0].length}),i+=r[0].length,i+=e.slice(i).length-e.slice(i).trimStart().length}if(i)for(let[e,t]of l)i(e,t);return o}var tT=/^(?:[^":]|"[^"]*")*?:\s*"[^"]*"/;function tF(e,t,i){let n=tT.exec(e)?.[0].length??-1;if(n<0||!e.slice(n).trim())return null;let a=[],r=(e,t)=>{a.push([e,t])},o,l,s=e.length-e.slice(n).trimStart().length;try{if(o=tM(e.slice(0,n),t,r),o?.kind!=="relation")return null;l=tC(e.slice(s),t,r)}catch{return null}if(l.some(e=>"unknown"===e.syntax.kind))return null;if(i)for(let[e,t]of a)i(e,t);return[{syntax:o,start:0,end:n},...l.map(e=>({...e,syntax:e.syntax,start:e.start+s,end:e.end+s}))]}function tB(e,t){let i=e.get(t);return i||(i={id:t,label:t,attributes:[]},e.set(t,i),$("er")&&L("er","createEntity",i)),i}function tP(e){switch(e.toLowerCase()){case"u":return"parent";case"||":case"only one":case"1":case"one":return"one";case"|o":case"o|":case"one or zero":case"zero or one":return"zero-one";case"}|":case"|{":case"one or more":case"one or many":case"many(1)":case"1+":return"many";case"}o":case"o{":case"zero or more":case"zero or many":case"many(0)":case"0+":case"many":return"zero-many";default:return null}}function tN(e,t,i,n,a,r){let o={stroke:a.edgeStrokeColor??"var(--_line)",strokeWidth:String(a.lineWidth+.25)},l=e_(t,i,n,o);return e.shape({id:r,role:"cardinality",geometry:{kind:"compound",children:l.map(e=>e.geometry)},paint:o,...l.some(e=>e.paint!==o)?{childPaints:l.map(e=>e.paint)}:{},channels:{category:n}})}var tO=F(function(e,t){let{positioned:i,colors:n,resolved:a}=t,r=a.renderOptions,o=n.font??"Inter",l=r.transparent??!1,s=[],d=Q(r,eV,a.styleFace),h=`er-${eu(i.width,i.height,i.entities.length,i.relationships.length)}`,p=`${h}-title`,y=`${h}-desc`,c=A(i.accessibilityTitle,i.accessibilityDescription,p,y);s.push(e.documentOpen({id:"prelude",width:i.width,height:i.height,colors:n,transparent:l,font:o,hasMonoFont:!0},U(i.width,i.height,n,l,c)+`
|
|
6
|
+
`+K(o,!0,n.shadow,n.embedFontImport)));let x=[];x.push("<defs>");let u=H(n);for(let t of(u&&x.push(u),x.push("</defs>"),s.push(e.definitions({id:"defs"},x.join(`
|
|
7
|
+
`))),i.accessibilityTitle&&s.push(e.documentContent({id:"acc-title",role:"chrome",nonPaint:"accessibility"},`<title id="${p}">${es(i.accessibilityTitle)}</title>`)),i.accessibilityDescription&&s.push(e.documentContent({id:"acc-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${y}">${es(i.accessibilityDescription)}</desc>`)),i.title&&s.push(e.text(Z(i.title,d))),i.groups))s.push(function(e,t,i){let n=i.groupBorderColor??"var(--_node-stroke)",a=i.groupFillColor??"var(--_group-fill)",r=i.groupHeaderFillColor??"var(--_group-hdr)",o=i.groupTextColor??"var(--_text)",l=t.labelBlock??eJ(et(t.label,t.labelContent),i);return e.group({id:`er-group:${t.id}`,role:"group",open:`<g class="er-subgraph" data-id="${ed(t.id)}" data-label="${ep(t.label)}"${t.parentId?` data-parent-id="${ed(t.parentId)}"`:""}>`,close:"</g>",children:[{node:e.shape({id:`er-group:${t.id}:box`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:6,ry:6},paint:{fill:a,stroke:n,strokeWidth:"1.5"}}),indent:2},{node:e.shape({id:`er-group:${t.id}:header`,role:"group-header",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.headerHeight,rx:6,ry:6},paint:{fill:r,stroke:"none"}}),indent:2},{node:e.text({id:`er-group:${t.id}:label`,role:"label",text:l.text,block:l,x:t.x+10,y:t.y+t.headerHeight/2,fontSize:l.fontSize,anchor:"start",paint:{fill:o}}),indent:2}]})}(e,t,d));let f=new Map,g=new Set(i.groups.map(e=>e.id)),m=e=>({id:e,role:g.has(e)?"group":"entity"});for(let t of i.relationships){let i=`${t.entity1}-${t.entity2}`,n=f.get(i)??0;f.set(i,n+1),s.push(function(e,t,i,n,a,r){let o=t.identifying?"solid":"dashed",l={category:t.identifying?"identifying":"non-identifying"},s=eM(n,"relationship",l,{includeFallback:!1}),d=s?.bendRadius??i.edgeBendRadius,h={endpoints:{from:t.entity1,to:t.entity2,start:{owner:r(t.entity1)},end:{owner:r(t.entity2)}},relationship:{kind:t.identifying?"identifying":"non-identifying"},route:{ownership:"layout",bendRadius:d},labels:t.label?[{text:t.label,textContent:{value:t.label,prepared:ea(et(t.label,t.labelContent))}}]:[]};if(t.points.length<2)return e.connector({id:a,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:"invisible",paint:{},channels:l,...h});let p={className:"er-relationship",data:{cardinality1:t.cardinality1,cardinality2:t.cardinality2,identifying:String(t.identifying),...t.label?{label:eb(t.label)}:{}}},y={stroke:s?.strokeColor??i.edgeStrokeColor??"var(--_line)",strokeWidth:String(s?.lineWidth??i.lineWidth),...t.identifying?{}:{strokeDasharray:"6 4"}};if(d>0&&t.points.length>2){let i=ew(t.points,d,{metric:"manhattan"});return e.connector({id:a,role:"relationship",geometry:i.geometry,lineStyle:o,paint:y,channels:l,...h,route:{...h.route,contours:i.contours},attributes:p})}return e.connector({id:a,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:o,paint:y,channels:l,...h,attributes:p})}(e,t,d,a.styleFace,`rel:${i}#${n}`,m))}for(let t of i.entities)s.push(function(e,t,i,n){let{id:a,x:r,y:o,width:l,height:s,headerHeight:d,rowHeight:h,label:p,attributes:y}=t,c=[],x=t.className?` ${ed(t.className)}`:"",u=t.className?` data-class="${ed(t.className)}"`:"",f=`<g class="entity${x}" data-id="${ed(a)}" data-label="${ep(p)}"${u}>`,g=t.inlineStyle??{},m=void 0!==i.nodeTextColor,b=N(t.inlineStyle,n,m?void 0:i.groupHeaderFillColor??"var(--_group-hdr)"),w=N(t.inlineStyle,n,m?void 0:i.nodeFillColor??"var(--_node-fill)"),M=g.fill??i.nodeFillColor??"var(--_node-fill)",k=g.stroke??i.nodeBorderColor??"var(--_node-stroke)",v=Number.parseFloat(g["stroke-width"]??""),S=Number.isFinite(v)&&v>0?v:i.nodeLineWidth,R=g["stroke-dasharray"],$=void 0===R?{}:{strokeDasharray:R};c.push({indent:2,node:e.shape({id:`entity-rect:${a}`,role:"entity",geometry:{kind:"rect",x:r,y:o,width:l,height:s,rx:i.cornerRadius??0,ry:i.cornerRadius??0},paint:{fill:M,stroke:k,strokeWidth:String(S),...$}})});let _=g.fill??i.groupHeaderFillColor??"var(--_group-hdr)",L=ek(r,o,l,d,i.cornerRadius??0);c.push({indent:2,node:e.shape({id:`entity-header:${a}`,role:"group-header",geometry:{kind:"path",d:L},paint:{fill:_,stroke:k,strokeWidth:String(S),...$}})});let W=b(i.nodeTextColor??"var(--_text)"),E=t.labelBlock??eX(et(p,t.labelContent),i),z=E.text;c.push({indent:2,node:e.text({id:`entity-name:${a}`,role:"label",text:z,block:E,x:r+l/2,y:o+d/2,fontSize:i.nodeLabelFontSize,anchor:"middle",paint:{fill:W}})});let I=o+d,C=Math.min(i.nodeLineWidth,Y.innerBox);c.push({indent:2,node:e.shape({id:`entity-divider:${a}`,role:"chrome",geometry:{kind:"line",x1:r,y1:I,x2:r+l,y2:I},paint:{stroke:k,strokeWidth:String(C),...$}})});let T=e9(y);for(let n=0;n<y.length;n++)for(let o of function(e,t,i,n,a,r,o,l,s,d){let h=[],p=`attr:${i}:${t.name}`,y=d??eZ(t),c=o.nodeTextColor??"var(--_text-sec)",x=l(c),u=l(o.nodeTextColor??"var(--_text-muted)"),f=0;if(t.keys.length>0){let i=t.keys.join(",");f=y.keys.width+8;let r=n+Math.max(6,o.nodePaddingX/2);h.push(e.shape({id:`${p}:key-badge`,role:"chrome",geometry:{kind:"rect",x:r,y:a-7,width:f,height:14,rx:2,ry:2},paint:{fill:"var(--_key-badge)"}})),h.push(e.text({id:`${p}:key-text`,role:"attribute",text:i,block:y.keys,x:r+f/2,y:a,fontSize:9,anchor:"middle",paint:{fill:c}}))}let g=n+Math.max(8,o.nodePaddingX/2)+(f>0?f+6:0);h.push(e.text({id:`${p}:type`,role:"attribute",text:t.type,block:y.type,x:g,y:a,fontSize:11,anchor:"start",paint:{fill:u},attributes:{className:"mono"}}));let m=n+r-Math.max(8,o.nodePaddingX/2);if(h.push(e.text({id:p,role:"attribute",text:t.name,block:y.name,x:m-s,y:a,fontSize:11,anchor:"end",paint:{fill:x},attributes:{className:"mono"}})),t.comment){let i=eH(t.comment,t.commentContent);h.push(e.text({id:`${p}:comment`,role:"attribute",text:i,block:y.comment,x:m,y:a,fontSize:11,anchor:"end",paint:{fill:u}}))}if(t.comment&&t.comment.length>0){let i=eo(t.comment);return[e.group({id:`${p}:row`,role:"attribute",open:`<g><title>${es(i)}</title>`,close:"</g>",children:h.map(e=>({node:e,indent:0}))})]}return h}(e,y[n],a,r,I+n*h+h/2,l,i,w,T,t.attributeBlocks?.[n]))c.push({indent:2,node:o});if(0===y.length){let n=w(i.nodeTextColor??"var(--_text-muted)"),o=t.emptyAttributeBlock??e0();c.push({indent:2,node:e.text({id:`entity-empty:${a}`,role:"attribute",text:o.text,block:o,x:r+l/2,y:I+h/2,fontSize:11,anchor:"middle",paint:{fill:n}})})}return e.group({id:`entity:${a}`,role:"entity",open:f,close:"</g>",children:c})}(e,t,d,n));let b=new Map;for(let t of i.relationships){let i=`${t.entity1}-${t.entity2}`,n=b.get(i)??0;b.set(i,n+1),s.push(...function(e,t,i,n){if(t.points.length<2)return[e.shape({id:n,role:"cardinality",geometry:{kind:"compound",children:[]},paint:{}})];let a=t.points[0],r=t.points[1],o=t.points[t.points.length-1],l=t.points[t.points.length-2];return[tN(e,a,r,t.cardinality1,i,`${n}:1`),tN(e,o,l,t.cardinality2,i,`${n}:2`)]}(e,t,d,`card:${i}#${n}`))}let w=eG(i)??eq(i,d,a.styleFace),M=new Map;for(let t of i.relationships){let i=`${t.entity1}-${t.entity2}`,n=M.get(i)??0;M.set(i,n+1),s.push(...function(e,t,i,n,a,r){if(!t.label||t.points.length<2)return[];let o={category:t.identifying?"identifying":"non-identifying"},l=eM(n,"relationship",o,{includeFallback:!1}),s=l?.fontSize??i.edgeLabelFontSize,d=r??eQ(t.points),h=t.labelBlock??eU(t,i,n),p=h.text,y=e.shape({id:`${a}:bg`,role:"chrome",geometry:eE(h,d),paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"0.5"},channels:o}),c=l?.textColor??i.edgeTextColor??"var(--_text-muted)";return[y,e.text({id:a,role:"label",text:p,block:h,x:d.x,y:d.y,fontSize:s,anchor:"middle",paint:{fill:c},channels:o})]}(e,t,d,a.styleFace,`rel-label:${i}#${n}`,w.get(t)))}return s.push(e.documentClose()),{family:"er",width:i.width,height:i.height,colors:n,transparent:l,parts:s}}),tD=R(eR,{configDiagnostics:e=>x("er",e,e$),normalizeRequest:t=>({renderOptions:function(t,i){if(!t)return i;let n=e(t,"er","nodeSpacing"),a=e(t,"er","rankSpacing");return void 0===n&&void 0===a?i:{...i,nodeSpacing:i.nodeSpacing??n,layerSpacing:i.layerSpacing??a}}(t.source.frontmatter,t.renderOptions)}),layout:e=>{let t=u(function(e,t){if(!t)return e;let i=f(t,["er","layoutDirection"]),n="string"==typeof i&&/^(TB|TD|BT|LR|RL)$/i.test(i)?i.toUpperCase():void 0;return void 0===e.direction&&void 0!==n?{...e,direction:n}:e}(z(function(e){let t=j(e);E(t),e=t.familyLines;let i={entities:[],classDefs:new Map,relationships:[],groups:[],...void 0!==t.accessibility.title?{accessibilityTitle:er(t.accessibility.title)}:{},...void 0!==t.accessibility.descr?{accessibilityDescription:er(t.accessibility.descr)}:{}};$("er")&&(_("er","header",e[0]??"",{line:1,unit:"normalized"}),L("er","initialize",i));let n=function(e,t){let i,n,a,r,o,l,s,d,y,c,x=new Map,u=function(e,t,i){let n=[],a=0,r,o=e.findLastIndex(e=>e.includes('"')),l=t=>{let i=t.tokens[0],a=t.tokens.at(-1);n.push({syntax:"type"===t.last?{kind:"unknown"}:{kind:"attribute",attribute:function({tokens:e}){let t=+(e[1]?.text==="?"),i=e.slice(2+t).filter(e=>"word"===e.kind).flatMap(e=>e.text.split(",")).filter(Boolean).map(e=>e.toUpperCase()),n=e.find(e=>"comment"===e.kind);return tI(e[0].text+(t?"?":""),e[1+t].text,i,n?.text.slice(1,-1))}(t),text:function(e,{tokens:t}){return t.map((i,n)=>{let a=t[n-1];return a?((a.endLine??a.line)===i.line?e[i.line].slice(a.end,i.start):" ")+i.text:i.text}).join("")}(e,t),...!function({tokens:e}){let t=+(e[1]?.text==="?"),i=e.slice(2+t).filter(e=>"word"===e.kind).map(e=>e.text).join(" ");return""===i||/^(?:PK|FK|UK)(?:\s*,\s*(?:PK|FK|UK))*$/i.test(i)}(t)?{generous:!0}:{}},line:i.line,start:i.start,endLine:a.endLine??a.line,end:a.end})};for(let s=0;s<e.length;s++){let d=e[s],y=d.trim(),c=[],x=0,u=r?.comment;if(u&&y&&!y.startsWith("%%")){let e=d.indexOf('"');if(u.parts.push((e<0?d:d.slice(0,e)).trim()),i?.set(s,e<0?d.length:e+1),e<0)continue;c.push({kind:"comment",text:`"${u.parts.join(`
|
|
8
|
+
`)}"`,line:u.line,start:u.start,endLine:s,end:e+1}),r.comment=void 0,x=e+1}else if(!y||y.startsWith("%%")){n.push({syntax:{kind:y?"comment":"blank"},line:s,start:0,endLine:s,end:d.length});continue}let f=d.slice(x),g=x+f.length-f.trimStart().length+p(f.trim()).length,m=e=>{for(;e<g&&/\s/.test(d[e]);)e++;return e};for(let e=m(x);e<g||c.length>0;)if(r){let t=t$(d.slice(e,g)),i=t<0?g:e+t,a=[...c.splice(0),...function(e,t,i,n){let a=e.slice(i,n),r=new Map,o=[];for(let e=0,t=!1;e<a.length;e++)if('"'===a[e])t=!t;else{if("~"!==a[e]||t)continue;t_.test(a[e+1]??"")?o.push(e):o.length>0&&r.set(o.pop(),e)}let l=e=>{let t=e;for(;t<a.length&&!/[\s"]/.test(a[t]);)t++;return t},s=[],d=(e,n,r)=>{s.push({kind:e,text:a.slice(n,r),line:t,start:i+n,end:i+r})};for(let e=0;e<a.length;)if(/\s/.test(a[e]))e++;else if('"'===a[e]){let t=a.indexOf('"',e+1);d(t<0?"stray":"comment",e,t<0?e+1:t+1),e=t<0?e+1:t+1}else{let t=l(e),i=a.slice(e,t).indexOf("~"),n=i<0?void 0:r.get(e+i);void 0!==n&&n>=t&&(t=l(n+1)),d("word",e,t),e=t}return s}(d,s,e,i)],p=s<o?a.findIndex(e=>"stray"===e.kind):-1;p>=0&&(r.comment={line:s,start:a[p].start,parts:[d.slice(a[p].start+1,g).trimEnd()]},a=a.slice(0,p));let y=function(e,t){let i=[],n=e&&{tokens:[...e.tokens],last:e.last};for(let e of t)if(n?.last==="type")if("?"!==e.text||1!==n.tokens.length||n.tokens[0].text.endsWith("?"))if(!tE(e))return null;else n={tokens:[...n.tokens,e],last:"name"};else n.tokens.push(e);else if(n?.last==="name"&&tz(e))n.tokens.push(e);else if(n?.last==="name"&&"comment"===e.kind)n={tokens:[...n.tokens,e],last:"comment"};else{if(!tE(e,e.text.replace(/\?$/,"")))return null;n&&i.push(n),n={tokens:[e],last:"type"}}return{done:i,...n?{open:n}:{}}}(r.open,a);if(y){for(let e of y.done)l(e);r.open=y.open}else{r.open&&l(r.open),r.open=void 0,r.comment=void 0;let t=d.slice(e,i).trimEnd(),a=function(e){let t=e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!t||/^(?:"|(?:PK|FK|UK)\b)/i.test(t[1])||!t.slice(1,3).every(e=>/[^\W_]|[\u00C0-\uFFFF]/.test(e))||h(e)>=0||t$(e)>=0)return null;let i=t[1],n=t[2],a=t[3]?.trim()??"",r=a.match(/"([^"]*)"/),o=[];for(let e of a.replace(/"[^"]*"/,"").trim().split(/[\s,]+/)){let t=e.toUpperCase();if("PK"===t||"FK"===t||"UK"===t)o.push(t);else if(e)return null}return tI(i,n,o,r?.[1])}(t);n.push({syntax:a?{kind:"attribute",attribute:a,text:t,generous:!0}:{kind:"unknown"},line:s,start:e,endLine:s,end:e+t.length})}if(t<0)break;r.open&&l(r.open),n.push({syntax:{kind:"block-close"},line:s,start:i,endLine:s,end:i+1}),r=void 0,e=m(i+1)}else{let i=tC(d.slice(e,g),a>0,t?(e,i)=>t(e,i,s):void 0);for(let{syntax:t,start:o,end:l}of i)n.push({syntax:t,line:s,start:e+o,endLine:s,end:e+l}),"group-open"===t.kind?a++:"end"===t.kind?a--:"block-open"===t.kind&&(r={});e=m(e+i.at(-1).end)}}return n.sort((e,t)=>e.line-t.line||e.start-t.start)}(e,void 0,x),f=[],g=new Set;for(let e=u.length-1;e>=0;e--)f[e]=g.has(u[e].endLine),g.add(u[e].line);let m=new Map,b=[],w=(i=[],n=new Set,a=new Map,r=[],o=new Set,l=[],s=new Map,d=D(),y=e=>{n.has(e)||(n.add(e),i.push(e))},{open(e){if(o.has(e))throw Error(`Duplicate ER subgraph id '${e}'`);o.add(e),r.push(e),l.push({id:e,names:[]})},close(){let e=l.pop();if(!e)throw Error("ER `end` closes no subgraph");s.set(e.id,d.close(e.id,e.names)),l.at(-1)?.names.push(e.id)},get innermost(){return l.at(-1)?.id},declare:c=(e,t)=>{y(e),void 0===t||a.has(e)||a.set(e,t),l.at(-1)?.names.push(e)},relationEnd:(e,t)=>!o.has(e)&&(c(e,t),!0),style:y,created:e=>n.has(e),finish(){let e=l.at(-1);if(e)throw O({what:`ER subgraph '${e.id}' is never closed`,expectedForm:"each subgraph closed by an end line",example:`subgraph G
|
|
9
|
+
A
|
|
10
|
+
end`});let t=new Map;for(let e of[...i,...r]){let i=d.ownerOf(e);void 0!==i&&t.set(e,i)}return{order:i,alias:a,owner:t,groups:r.map(e=>({id:e,...t.has(e)?{parentId:t.get(e)}:{},entityIds:s.get(e).filter(e=>n.has(e))}))}}}),M;for(let[t,{syntax:i,line:n,endLine:a,end:r}]of u.entries()){let o=m.get(n)??0,l=f[t]?r:e[a].length;m.set(a,l);let s=n===a?e[n].slice(o,l):[e[n].slice(o),...e.slice(n+1,a),e[a].slice(0,l)].join(`
|
|
11
|
+
`),d={line:n,column:o,endLine:a,endColumn:l,...void 0!==w.innermost?{groupId:w.innermost}:{},...void 0!==M?{entityId:M}:{}},h={raw:s,...d,syntax:i};switch(b.push(h),$("er")&&_("er",i.kind,h.raw,{line:n+2,unit:"normalized"}),i.kind){case"group-open":w.open(i.id),$("er")&&L("er","openGroup",{id:i.id,enclosingGroupId:d.groupId},{line:n+2,unit:"normalized"});break;case"end":w.close(),$("er")&&L("er","closeGroup",{id:d.groupId,enclosingGroupId:w.innermost},{line:n+2,unit:"normalized"});break;case"block-open":M=i.reference.id,w.declare(M,i.reference.alias),$("er")&&L("er","declareEntity",{...i.reference,groupId:d.groupId},{line:n+2,unit:"normalized"});break;case"block-close":M=void 0;break;case"entity":w.declare(i.reference.id,i.reference.alias),$("er")&&L("er","declareEntity",{...i.reference,groupId:d.groupId},{line:n+2,unit:"normalized"});break;case"relation":h.relationEntityIds=[i.relation.entity1,i.relation.entity2].filter(e=>{let t=w.relationEnd(e.id,e.alias);return $("er")&&L("er","nameRelationshipEndpoint",{...e,isEntity:t,groupId:d.groupId},{line:n+2,unit:"normalized"}),t}).map(e=>e.id);break;case"style":for(let e of i.ids)w.style(e),$("er")&&L("er","ensureStyledEntity",{id:e},{line:n+2,unit:"normalized"})}}if(void 0!==M)throw Error(`ER_UNCLOSED_ENTITY: entity '${M}' needs a closing }`);let k=w.finish();return $("er")&&L("er","resolvePlacement",k),{statements:b,placement:k,continuedComments:x}}(e.slice(1)),a=new Map,r=new Map,o=(e,t)=>{let i=tB(a,e);return t&&(tg(r,e,t.split(" ")),$("er")&&L("er","appendEntityClasses",{id:e,classNames:r.get(e)})),i},l=e=>o(e.id,e.className),s=new Map;for(let e of n.statements){let t=e.syntax;switch(t.kind){case"unknown":throw Error(`ER_UNSUPPORTED_STATEMENT: line ${e.line+2}: ${e.raw.trim()}`);case"attribute":a.get(e.entityId).attributes.push(t.attribute),$("er")&&L("er","addAttribute",{entityId:e.entityId,attribute:t.attribute},{line:e.line+2,unit:"normalized"});break;case"direction":{let n=void 0!==e.groupId?s.get(e.groupId):void 0;n?n.direction=t.direction:i.direction=t.direction,$("er")&&L("er","setDirection",{direction:t.direction,groupId:n?.id},{line:e.line+2,unit:"normalized"});break}case"group-open":s.set(t.id,{id:t.id,...ej(t.title??t.id,!0)}),$("er")&&L("er","upsertGroup",s.get(t.id),{line:e.line+2,unit:"normalized"});break;case"end":break;case"class-def":for(let n of t.names)i.classDefs.set(n,{...t.props}),$("er")&&L("er","setClassDefinition",{name:n,props:i.classDefs.get(n)},{line:e.line+2,unit:"normalized"});break;case"class":for(let i of t.ids)a.has(i)&&(tg(r,i,t.classNames),$("er")&&L("er","appendEntityClasses",{id:i,classNames:r.get(i)},{line:e.line+2,unit:"normalized"}));break;case"style":for(let i of t.ids){let n=tB(a,i);n.inlineStyle={...n.inlineStyle,...t.props},$("er")&&L("er","setEntityStyle",{id:i,props:n.inlineStyle},{line:e.line+2,unit:"normalized"})}break;case"block-open":case"entity":l(t.reference);break;case"relation":for(let n of(i.relationships.push(function(e,t){let i=tP(e.leftToken),n=tP(e.rightToken);if(!i||!n)throw Error(`Invalid ER cardinality "${e.leftToken}${e.identifying?"--":".."}${e.rightToken}" in "${t}" (valid tokens include ||, |o, o|, }o, o{, }|, |{ and Mermaid's word/numeric aliases)`);return{entity1:e.entity1.id,entity2:e.entity2.id,cardinality1:i,cardinality2:n,...ej(e.label,!0),identifying:e.identifying}}(t.relation,e.raw)),$("er")&&L("er","addRelationship",i.relationships.at(-1),{line:e.line+2,unit:"normalized"}),[t.relation.entity1,t.relation.entity2]))e.relationEntityIds.includes(n.id)&&o(n.id,n.className)}}let d=n.placement;for(let[e,t]of r)a.get(e).className=t.join(" "),$("er")&&L("er","resolveEntityClasses",{id:e,className:a.get(e).className});return i.entities=d.order.map(e=>{var t;let i=a.get(e);Object.assign(i,void 0!==(t=d.alias.get(e))?ej(t,!0):th.test(e)?{label:e}:ej(e,!0));let n=d.owner.get(e);return $("er")&&L("er","resolveEntity",{...i,groupId:n}),void 0!==n?{...i,groupId:n}:i}),i.groups=d.groups.map(e=>{let t={...s.get(e.id),...void 0!==e.parentId?{parentId:e.parentId}:{},entityIds:e.entityIds};return $("er")&&L("er","resolveGroup",t),t}),C(i),i}(e.source.familyLines),e.source.accessibility),e.source.frontmatter),e.source.frontmatter);return P(t.classDefs,t.entities),S(function(e,t={},i){C(e);let o=Q(t,eV,i),l={operations:0},s=e=>{try{return e()}catch(i){if(t.graphLayout?.backend!=="agentic"||"elk"!==t.graphLayout.fallback||!(i instanceof eC||i instanceof eI||i instanceof eT))throw i;let e=new ec([{strategy:"er-final-geometry",violations:[i.message]}]);throw e.cause=i,e}};if(0===e.entities.length){let n=()=>e.groups.length?tr(ta(e1(function(e,t,i,n={operations:0}){let a=e.relationships.map(e=>eU(e,t,i)),r=e2(e,a),o=ti(e,t,i,n),l=(e.direction??"LR")==="LR"||(e.direction??"LR")==="RL",s="RL"===e.direction||"BT"===e.direction,d=e.groups.filter(e=>!e.parentId),h=s?[...d].reverse():d,p=[],y=(i,n,a)=>{let s=eJ(et(i.label,i.labelContent),t),d=t.groupHeaderFontSize+16+s.height-s.lineHeight,h={id:i.id,label:i.label,...i.labelContent?{labelContent:i.labelContent}:{},labelBlock:s,...i.parentId?{parentId:i.parentId}:{},x:n,y:a,width:Math.max(160,s.width+20),height:Math.max(100,d+20),headerHeight:d};p.push(h);let c=o.get(i.id)??20,x=n+c,u=a+d+c;for(let t of e.groups.filter(e=>e.parentId===i.id)){let e=y(t,x,u);h.width=Math.max(h.width,e.x+e.width-n+c),h.height=Math.max(h.height,e.y+e.height-a+Math.max(c,r.padding.get(i.id)??0)),l?x+=e.width+20:u+=e.height+Math.max(20,r.exits.get(t.id)??0)}return h},c=40,x=40;for(let e of h){let t=y(e,c,x);l?c+=t.width+40:x+=t.height+30}tn(e,[],p,t,a,r.padding,r.exits,20,i,n,o);let u=new Map(p.map(e=>[e.id,e])),f=e.relationships.map((e,t)=>{let i=u.get(e.entity1),n=u.get(e.entity2),a=[];return i&&n&&r.lanes.has(t)?a.push(...e5(i,n,r.lanes.get(t))):i&&n&&a.push(...tt(i,n)),{entity1:e.entity1,entity2:e.entity2,cardinality1:e.cardinality1,cardinality2:e.cardinality2,label:e.label,...e.labelContent?{labelContent:e.labelContent}:{},identifying:e.identifying,points:a}});e3([],p,f,a,t,i,n);let g=f.flatMap(e=>e.points),m=e4(f,a),b=Math.max(0,40-Math.min(...p.map(e=>e.x),...g.map(e=>e.x)),...m.map(e=>-e.x0)),w=Math.max(0,40-Math.min(...p.map(e=>e.y),...g.map(e=>e.y)),...m.map(e=>-e.y0));for(let e of p)e.x+=b,e.y+=w;for(let e of g)e.x+=b,e.y+=w;return{width:Math.max(...p.map(e=>e.x+e.width+40),...g.map(e=>e.x+40),...m.map(e=>e.x1+b),0),height:Math.max(...p.map(e=>e.y+e.height+40),...g.map(e=>e.y+40),...m.map(e=>e.y1+w),0),accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,entities:[],relationships:f,groups:p}}(e,o,i,l),o,i),e.title,o),o,i,l):ta({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,entities:[],relationships:[],groups:[]},e.title,o);return em(t,()=>s(n),()=>(e7(l,0),n()),!0)}let d=function(e,t){let i=new Map;for(let n of e.entities){let e=eX(et(n.label,n.labelContent),t),a=e.width,r=0===n.attributes.length?e0().width:0,o=e9(n.attributes);for(let e of n.attributes){let t=eZ(e),i=e.keys.length?t.keys.width+14:0,n=t.type.width+t.name.width+i+12+o;n>r&&(r=n)}let l=Math.max(140,a+2*t.nodePaddingX,r+2*Math.max(8,t.nodePaddingX)),s=Math.max(34,e.height+2*t.nodePaddingY),d=s+22*Math.max(n.attributes.length,1);i.set(n.id,{width:l,height:d,headerHeight:s})}return i}(e,o),h=t=>tr(ta(e1(function(e,t,i,n,a,r={operations:0}){let o=new Map;for(let e of t.entities)o.set(e.id,e);let l=[],s=B(t.classDefs.get("default"),"classDef default");for(let n of e.entities){let e=o.get(n.id);if(e){let a={...s};for(let i of e.className?.split(/[ \t]+/)??[])Object.assign(a,B(t.classDefs.get(i),`classDef ${i}`));l.push({id:e.id,label:e.label,...e.labelContent?{labelContent:e.labelContent}:{},attributes:e.attributes,x:n.x??0,y:n.y??0,width:n.width??i.get(e.id).width,height:n.height??i.get(e.id).height,headerHeight:i.get(e.id).headerHeight,rowHeight:22,...e.className?{className:e.className}:{},...Object.keys(a).length>0||e.inlineStyle?{inlineStyle:{...a,...B(e.inlineStyle,`style ${e.id}`)}}:{},...e.groupId?{groupId:e.groupId}:{}})}}let d=new Map(l.map(e=>[e.id,{x:e.x,y:e.y,width:e.width,height:e.height}])),h=t.relationships.map(e=>eU(e,n,a)),p=e2(t,h),y=ti(t,n,a,r);!function(e,t,i,n,a,r){let o=new Set;for(let l of e.groups){if(!l.direction)continue;let s=l.entityIds.map(e=>t.find(t=>t.id===e)).filter(e=>!!e);if(s.length<2)continue;for(let e of s)o.add(e.id);let d="LR"===l.direction||"RL"===l.direction,h="RL"===l.direction||"BT"===l.direction?[...s].reverse():s,p=new Set(s.map(e=>e.id)),y=Math.max(48,...e.relationships.flatMap((e,t)=>{if(e7(r),!p.has(e.entity1)||!p.has(e.entity2))return[];let o=eW(e.cardinality1,n.lineWidth),l=eW(e.cardinality2,n.lineWidth);if(e7(r,2),!o||!l)throw new eC(e.entity1,e.entity2);let s=eK(e,a)?.bendRadius??n.edgeBendRadius,h=Math.max(18,o.x1)+Math.max(18,l.x1)+2*s+2*(n.lineWidth+.25);return[Math.max(e.label?i[t][d?"width":"height"]+56:0,h+(e.label?i[t][d?"width":"height"]+20:0))]})),c=Math.min(...s.map(e=>e.x)),x=Math.min(...s.map(e=>e.y)),u=d?c:x;for(let e of h)d?(e.x=u,e.y=x,u+=e.width+y):(e.x=c,e.y=u,u+=e.height+y)}}(t,l,h,n,a,r);let c=function(e,t,i,n,a){let r=[];for(let o of[...e.groups].reverse()){let e=[...t.filter(e=>e.groupId===o.id),...r.filter(e=>e.parentId===o.id)],l=a.get(o.id)??20,s=eJ(et(o.label,o.labelContent),i),d=i.groupHeaderFontSize+16+s.height-s.lineHeight,h=e.length?Math.min(...e.map(e=>e.x))-l:40,p=e.length?Math.min(...e.map(e=>e.y))-l-d:40,y=Math.max(h+s.width+20,e.length?Math.max(...e.map(e=>e.x+e.width))+l:h+140),c=e.length?Math.max(...e.map(e=>e.y+e.height))+Math.max(l,n.get(o.id)??0):p+90;r.unshift({id:o.id,label:o.label,...o.labelContent?{labelContent:o.labelContent}:{},labelBlock:s,...o.parentId?{parentId:o.parentId}:{},x:h,y:p,width:y-h,height:c-p,headerHeight:d})}return r}(t,l,n,p.padding,y),x=e.preserveTerminalNormals?20+2*Math.max(n.edgeBendRadius,...t.relationships.map(e=>eK(e,a)?.bendRadius??n.edgeBendRadius)):20;tn(t,l,c,n,h,p.padding,p.exits,x,a,r,y);let u=new Map;l.forEach(e=>u.set(e.id,e)),c.forEach(e=>u.set(e.id,e));let f=e.routes,g=[];for(let i=0;i<t.relationships.length;i++){let n=t.relationships[i],a=u.get(n.entity1),r=u.get(n.entity2),o=d.get(n.entity1),l=d.get(n.entity2),s=a&&o?a.x-o.x:void 0,y=a&&o?a.y-o.y:void 0,c=void 0!==s&&void 0!==y&&r&&l&&.001>Math.abs(r.x-l.x-s)&&.001>Math.abs(r.y-l.y-y)&&a.width===o.width&&a.height===o.height&&r.width===l.width&&r.height===l.height?f.get(i):void 0,x=[],m;if(a&&r&&p.lanes.has(i))x.push(...e5(a,r,p.lanes.get(i)));else if(c?.length){x.push(...c.map(e=>({x:e.x+s,y:e.y+y})));let t=e.labelPositions?.get(i);t&&(m={x:t.x+s,y:t.y+y})}else a&&r&&x.push(...tt(a,r));g.push({entity1:n.entity1,entity2:n.entity2,cardinality1:n.cardinality1,cardinality2:n.cardinality2,label:n.label,...n.labelContent?{labelContent:n.labelContent}:{},labelBlock:h[i],identifying:n.identifying,points:x,...m?{labelPosition:m}:{}})}e3(l,c,g,h,n,a,r);let m=[...l.flatMap(e=>[e.x,e.x+e.width]),...c.flatMap(e=>[e.x,e.x+e.width]),...g.flatMap(e=>e.points.map(e=>e.x))],b=[...l.flatMap(e=>[e.y,e.y+e.height]),...c.flatMap(e=>[e.y,e.y+e.height]),...g.flatMap(e=>e.points.map(e=>e.y))],w=e4(g,h),M=Math.max(0,m.length?40-Math.min(...m):0,...w.map(e=>-e.x0)),k=Math.max(0,b.length?40-Math.min(...b):0,...w.map(e=>-e.y0));if(0!==M||0!==k){for(let e of l)e.x+=M,e.y+=k;for(let e of c)e.x+=M,e.y+=k;for(let e of g){for(let t of e.points)t.x+=M,t.y+=k;e.labelPosition&&(e.labelPosition.x+=M,e.labelPosition.y+=k)}}return{width:Math.max((e.width??600)+M,...l.map(e=>e.x+e.width+40),...c.map(e=>e.x+e.width+40),...g.flatMap(e=>e.points.map(e=>e.x+40)),...w.map(e=>e.x1+M)),height:Math.max((e.height??400)+k,...l.map(e=>e.y+e.height+40),...c.map(e=>e.y+e.height+40),...g.flatMap(e=>e.points.map(e=>e.y+40)),...w.map(e=>e.y1+k)),accessibilityTitle:t.accessibilityTitle,accessibilityDescription:t.accessibilityDescription,entities:l,relationships:g,groups:c,...e.labelPlacement?{labelPlacement:e.labelPlacement}:{}}}(t,e,d,o,i,l),o,i),e.title,o),o,i,l);return em(t,()=>s(()=>h((()=>{let n=new Map(e.entities.map((e,t)=>[e.id,t])),a=new Set(e.groups.map(e=>e.id)),s=new Set([...n.keys(),...a]),h=new Map,p=t.layerSpacing??90,y=0;for(let t of e.relationships){let e=eK(t,i);for(let[i,n]of[[t.entity1,t.cardinality1],[t.entity2,t.cardinality2]]){let r=eW(n,o.lineWidth);if(e7(l),!r)throw new eC(t.entity1,t.entity2);let s=r.x1+(e?.lineWidth??o.lineWidth)/2+o.lineWidth+.25,d=s+Math.min(e?.bendRadius??o.edgeBendRadius,s);y=Math.max(y,d),p=Math.max(p,4*d),a.has(i)||h.set(i,(h.get(i)??0)+r.y1-r.y0+o.lineWidth+.25)}}let c=new Map(e.entities.map(e=>{let t=d.get(e.id),i=(h.get(e.id)??0)+2*Math.max(8,o.cornerRadius??0);return[e.id,{...t,width:Math.max(t.width,i),height:Math.max(t.height,i)}]})),x=e.relationships.flatMap((e,t)=>{let r=a.has(e.entity1)?void 0:n.get(e.entity1),l=a.has(e.entity2)?void 0:n.get(e.entity2);if(!s.has(e.entity1)||!s.has(e.entity2))throw Error("ER relationship references an undeclared entity or frame");if(void 0===r||void 0===l)return[];let d=eU(e,o,i);return[{relationshipIndex:t,source:r,target:l,minSpan:1,...e.label?{label:{width:d.width+16,height:d.height+16}}:{}}]}),u=ey("agentic",()=>r({nodes:e.entities.map(e=>({id:e.id,...c.get(e.id)})),edges:x,direction:e.direction??"LR",padding:40,nodeSpacing:t.nodeSpacing??70,layerSpacing:p,...y>0?{minimumTerminalLead:y}:{},edgeSpacing:Math.max(6,o.lineWidth+4)}));return{width:u.width,height:u.height,preserveTerminalNormals:!0,labelPlacement:"shaft-aware",entities:u.nodes.map((t,i)=>({id:e.entities[i].id,...t,...c.get(e.entities[i].id)})),routes:new Map(u.edges.map((e,t)=>[x[t].relationshipIndex,e.points])),labelPositions:new Map(u.edges.flatMap((e,t)=>e.labelPosition?[[x[t].relationshipIndex,{...e.labelPosition}]]:[]))}})())),()=>h((()=>{e7(l,0);let{elkGraph:r}=function(e,t,i,n,a={operations:0}){let r=Q(t,eV,n),o=0,l=new Map;for(let t of e.relationships){let e=eK(t,n);for(let[n,s]of[[t.entity1,t.cardinality1],[t.entity2,t.cardinality2]]){e7(a,12);let d=eW(s,r.lineWidth);if(!d)throw new eC(t.entity1,t.entity2);o=Math.max(o,d.x1+(e?.bendRadius??r.edgeBendRadius)+(e?.lineWidth??r.lineWidth)/2),i.has(n)&&l.set(n,(l.get(n)??0)+d.y1-d.y0+r.lineWidth+.25)}}let s={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":ee(e.direction??"LR"),"elk.spacing.nodeNode":String(t.nodeSpacing??70),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing??90),"elk.padding":"[top=40,left=40,bottom=40,right=40]","elk.edgeRouting":"ORTHOGONAL",...o>10?{"elk.layered.spacing.edgeNodeBetweenLayers":String(o)}:{},"elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(let t of e.entities){let e=i.get(t.id),n=(l.get(t.id)??0)+2*Math.max(8,r.cornerRadius??0);e7(a),s.children.push({id:t.id,width:Math.max(e.width,n),height:Math.max(e.height,n)})}let d=new Set(e.entities.map(e=>e.id));for(let t=0;t<e.relationships.length;t++){let i=e.relationships[t];if(!d.has(i.entity1)||!d.has(i.entity2))continue;let a={id:`e${t}`,sources:[i.entity1],targets:[i.entity2]};if(i.label){let e=eU(i,r,n);a.labels=[{text:e.text,width:e.width+8,height:e.height+6}]}s.edges.push(a)}return{elkGraph:s,entitySizes:i}}(e,t,d,i,l),o=n(r);return{width:o.width,height:o.height,entities:o.children??[],routes:new Map((o.edges??[]).map(e=>{let t=e.sections?.[0];return[Number(e.id.slice(1)),t?a([t.startPoint,...t.bendPoints??[],t.endPoint]):[]]}))}})()),!0)}(t,e.renderOptions,e.styleFace))},projectPositioned:k(function({positioned:e,options:t}){let i=e.entities.map(e=>({id:e.id,x:g(e.x),y:g(e.y),w:m(e.x,e.width),h:m(e.y,e.height),shape:"rectangle",label:e.label,...M(e.labelBlock,e.x+e.width/2,e.y+e.headerHeight/2,{...e,height:e.headerHeight})})),n=new Map(e.entities.map(e=>[e.id,{x:e.x,y:e.y,width:e.width,height:e.height}])),a=eG(e);if("shaft-aware"===e.labelPlacement&&!a)throw Error("ER_LABEL_LAYOUT_MISSING: project the complete native family layout artifact");let r=a??eq(e,Q({},eV));return{version:1,nodes:i,edges:e.relationships.map((e,i)=>{let a=r.get(e);return{id:`rel#${i}:${e.entity1}->${e.entity2}`,from:e.entity1,to:e.entity2,path:e.points.map(e=>[g(e.x),g(e.y)]),label:e.label&&a?{x:g(a.x),y:g(a.y),text:e.label,bounds:w(e.labelBlock,a.x,a.y)}:void 0,route:t.debug?b("er",i,e.points,n.get(e.entity1),n.get(e.entity2)):void 0}}),groups:e.groups.map(t=>({id:t.id,x:g(t.x),y:g(t.y),w:m(t.x,t.width),h:m(t.y,t.height),members:[...e.entities.filter(e=>e.groupId===t.id).map(e=>e.id),...e.groups.filter(e=>e.parentId===t.id).map(e=>e.id)],label:t.label,parentId:t.parentId})),bounds:{w:g(e.width),h:g(e.height)}}}),lowerScene:v(tO)});export{tD as default};
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
1
|
+
import{a as e}from"./chunk-62MR3LWJ.js";import"./chunk-PXTLV57R.js";import{a as t}from"./chunk-IUI4DYC3.js";import{c as i}from"./chunk-VRZKI33U.js";import{D as n,a as r,b as o,c as a,d as l,e as s,g as d,i as c}from"./chunk-QVSZOF5M.js";import{B as f,H as p,M as h,c as m,o as g,q as u,qa as y,t as v,u as w,y as x}from"./chunk-G4JBA7HU.js";import{l as b,r as k,u as _}from"./chunk-3JTYTXA6.js";import{h as E,l as $,n as M,o as S}from"./chunk-YVNJDVQO.js";import{Ua as j,_ as W,ea as I}from"./chunk-EIYLJ4FI.js";import{S as z,a as O}from"./chunk-PJJSDGLB.js";import"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";var R=Object.freeze({id:"eventmodeling",upstreamId:"eventmodeling",maturity:"experimental",label:"Event Modeling",headers:["eventmodeling"],aliases:[],config:{section:"eventmodeling",keys:["padding","rowHeight","useWidth","useMaxWidth","theme","look","layout"],noopKeys:["useWidth","useMaxWidth","theme","look","layout"]},identity:{id:"family:eventmodeling",kind:"family",version:"1.0.0",compatibility:{core:"0.5.4"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:[],semanticRoles:["prelude","title","chrome","node","label","group","edge","defs"],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:"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:"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:"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:"edge",primitive:"connector",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"]}],example:`eventmodeling
|
|
2
2
|
tf 01 ui CartUI
|
|
3
3
|
tf 02 cmd AddItem
|
|
4
|
-
tf 03 evt ItemAdded`,detect:
|
|
4
|
+
tf 03 evt ItemAdded`,detect:z,detectLoose:z}),A={ui:"ui",pcr:"processor",processor:"processor",cmd:"command",command:"command",rmo:"readmodel",readmodel:"readmodel",evt:"event",event:"event"},C="[_a-zA-Z]\\w*(?:\\.[_a-zA-Z]\\w*)*",U=RegExp(`^(tf|timeframe|rf|resetframe)\\s+(\\d{1,3})\\s+(\\w+)\\s+(${C})`),F=new Set(["json","jsobj","figma","salt","uri","md","html","text"]);function D(e){let t=Object.hasOwn(A,e)?A[e]:void 0;if(!t)throw Error(`Unknown Event Modeling type: ${e}`);return t}function P(e,t){let i=e.match(/^(?:`(\w+)`\s*)?([\s\S]+)$/);if(!i||i[1]&&!F.has(i[1]))throw Error("Invalid Event Modeling data type");let n=i[2];if(t?!/^\{\s*\n[\s\S]*\n?\}$/.test(n):!/^(?:\{.*\}|".*"|'.*')$/.test(n))throw Error("Invalid Event Modeling data");return{...i[1]?{type:i[1]}:{},text:n.slice(1,-1).replace(t?/^\n|\n$/g:/$^/g,"")}}function T(e){let t=e.entity.split("."),i=t.length>1?t.slice(0,-1).join("."):"",n="event"===e.type?"Events":"command"===e.type||"readmodel"===e.type?"Command / Read Model":"UI / Automation";return i?`${i} \xb7 ${n}`:n}var L=new Set(["eventmodeling","rmo","readmodel","ui","cmd","command","evt","event","pcr","processor","json","jsobj","figma","salt","uri","md","html","text","tf","timeframe","rf","resetframe","entity","data","note","gwt","given","when","then","title"]);function B(e,t){let i=[],n="",r=t?[]:void 0,o=(e,t)=>{if(n+=e,r)for(let i=0;i<e.length;i++)r.push(t+i)},a=e.indexOf(`
|
|
5
5
|
`);a<0&&(a=e.length);let l=!0;for(let t=0;t<e.length;t++){let s=e[t],d=e[t+1];if(t>a){l=!n.slice(n.lastIndexOf(`
|
|
6
6
|
`)+1).trim();let i=e.indexOf(`
|
|
7
7
|
`,t);a=i<0?e.length:i}let c=l;if(l&&=/\s/.test(s),c&&("t"===s||"a"===s)&&/^(?:title(?:[ \t]|$)|accTitle[ \t]*:|accDescr[ \t]*:)/.test(e.slice(t,a))){let i=e.indexOf("%%",t);o(e.slice(t,i>=0&&i<a?i:a),t),t=a-1;continue}if("/"===s&&"*"===d){let n=e.indexOf("*/",t+2);if(n<0)throw Error("Unclosed Event Modeling comment");i.push([t,n+2]);let r=e.slice(t,n+2);o(r.replace(/[^\n]/g," "),t),l=c||r.includes(`
|
|
8
8
|
`),t=n+1;continue}if("%"===s&&"%"===d||"/"===s&&"/"===d){t=a-1;continue}if("{"===s){if(!e.slice(t+1,a).trim()&&a<e.length){let n=/^}[ \t]*(?=\n|$)/gm;n.lastIndex=a+1;let r=n.exec(e);if(!r)throw Error("Unclosed Event Modeling block");i.push([t,r.index+r[0].length]),o(e.slice(t,r.index+r[0].length),t),t=r.index+r[0].length-1;continue}let n=e.lastIndexOf("}",a-1);if(n<t)throw Error("Unclosed inline data");o(e.slice(t,n+1),t),t=n;continue}if('"'===s||"'"===s||"`"===s){let i="`"===s?e.indexOf(s,t+1):e.lastIndexOf(s,a-1);if(i<=t||i>=a)throw Error("Unclosed inline value");o(e.slice(t,i+1),t),t=i;continue}/\s/.test(e[t-1]??"")&&/[tredng]/.test(s)&&/^(?:tf|timeframe|rf|resetframe|entity|data|note|gwt)\s/.test(e.slice(t))&&n.slice(n.lastIndexOf(`
|
|
9
9
|
`)+1).trim()&&(n=n.trimEnd(),r&&(r.length=n.length),o(`
|
|
10
|
-
`,t)),o(s,t)}return{text:n,offsets:r,protectedSpans:i}}function
|
|
11
|
-
`);try{return
|
|
10
|
+
`,t)),o(s,t)}return{text:n,offsets:r,protectedSpans:i}}function H(e,t){let i=v(e),n=i.map((e,t)=>t);for(let[e,r]of t){let t=w(i,e).line-1,o=w(i,Math.max(e,r-1)).line-1;n[t]=Math.max(n[t],o)}return n}var Z=k("eventmodeling-arrow",{width:8,height:8},"end",{fill:"var(--_line)"},"userSpaceOnUse"),Y=e([Z]),X=m(function(e,{positioned:i,colors:n,resolved:r}){let o=i.style,a=y(n),l=o.edgeStrokeColor?{...Z,paint:{...Z.paint,fill:o.edgeStrokeColor}}:Z,s=[e.definitions({id:"defs",markerResources:[l]},`<defs>${_([l])}</defs>`)];for(let t of(i.title&&s.push(e.text(S(i.title,o))),i.lanes)){let n={id:t.id,role:"group"};s.push(e.group({id:t.id,role:"group",open:"<g>",close:"</g>",children:[{node:e.shape({id:`${t.id}:surface`,role:"group",identity:!1,owner:n,geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:o.groupCornerRadius},paint:{fill:o.groupFillColor??"var(--_group-fill)",stroke:o.groupBorderColor??"var(--_node-stroke)",strokeWidth:String(o.groupLineWidth)}}),indent:2},...o.groupHeaderFillColor?[{node:e.shape({id:`${t.id}:header`,role:"chrome",owner:n,geometry:{kind:"rect",x:t.x,y:t.y,width:i.laneWidth,height:t.height,rx:o.groupCornerRadius},paint:{fill:o.groupHeaderFillColor,stroke:"none"}}),indent:2}]:[],{node:e.text({id:`${t.id}:label`,role:"label",owner:n,text:t.block.text,block:t.block,x:t.x+o.groupLabelPaddingX,y:t.y+t.height/2,anchor:"start",fontSize:t.block.fontSize,fontWeight:t.block.fontWeight,letterSpacing:t.block.letterSpacing,paint:{fill:o.groupTextColor??a("var(--_text)",o.groupHeaderFillColor??o.groupFillColor??"var(--_group-fill)")}}),indent:2}]}))}for(let t of i.edges)s.push(e.connector({id:t.id,role:"edge",geometry:t.projection?.geometry??{kind:"polyline",points:t.points},route:{ownership:"layout",bendRadius:o.edgeBendRadius,...t.projection?{contours:t.projection.contours}:{}},lineStyle:"solid",paint:{stroke:o.edgeStrokeColor??"var(--_line)",strokeWidth:String(o.lineWidth)},endpoints:{from:t.from,to:t.to},relationship:{kind:t.explicit?"explicit":"inferred",direction:"forward"},markers:{end:l}}));for(let t of i.nodes){let i={id:t.id,role:"node"},n=o.nodeFillColor??"var(--_node-fill)";s.push(e.group({id:t.id,role:"node",open:`<g data-parent="${t.lane}">`,close:"</g>",children:[{node:e.shape({id:`${t.id}:surface`,role:"node",identity:!1,owner:i,geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:o.cornerRadius??5},paint:{fill:n,stroke:o.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(o.nodeLineWidth)}}),indent:2},{node:e.text({id:`${t.id}:label`,role:"label",owner:i,text:t.block.text,block:t.block,x:t.x+t.width/2,y:t.y+t.height/2,anchor:"middle",fontSize:t.block.fontSize,fontWeight:t.block.fontWeight,letterSpacing:t.block.letterSpacing,paint:{fill:o.nodeTextColor??a("var(--_text)",n)}}),indent:2}]}))}return t(e,"eventmodeling",i,n,r.renderOptions.transparent??!1,s)}),J=l(R,{normalizeRequest:e=>{let t=e.source.config.eventmodeling,i=t?.padding,n=t?.rowHeight;return{renderOptions:{...e.renderOptions,...void 0===e.renderOptions.padding&&"number"==typeof i&&Number.isFinite(i)&&i>=0?{padding:i}:{}},familyConfig:{rowHeight:"number"==typeof n&&Number.isFinite(n)&&n>=0?n:0},appearance:{family:{palette:e.colors}}}},statementEnds:function(e){let t=e.join(`
|
|
11
|
+
`);try{return H(t,B(t,!1).protectedSpans)}catch{return e.map((e,t)=>t)}},layout:e=>{let t=function(e,t){let i=(Array.isArray(e)?e.join(`
|
|
12
12
|
`):e).replace(/\r\n/g,`
|
|
13
|
-
`),n=
|
|
13
|
+
`),n=B(i,!1),r=n.text.split(`
|
|
14
14
|
`),o=x(i.split(`
|
|
15
|
-
`),
|
|
16
|
-
`).replace(/}\s*$/,"").trim();continue}let t=e.match(
|
|
17
|
-
`:"")+r[y].trim()}let t=[e];for(;!/^}\s*$/.test(r[++y]??"");){if(y>=r.length)throw Error("Unclosed Event Modeling data block");t.push(r[y])}t.push("}");let i=
|
|
18
|
-
`),!0);if(l[2]){if(Object.hasOwn(a.data,l[2]))throw Error(`Duplicate data: ${l[2]}`);a.data[l[2]]=i}else a.notes.push({frame:l[3],data:i});continue}let f=e.match(/^gwt\s+(\d{1,3})\s*(.*)$/);if(f&&(k="given",b={frame:f[1],given:[],when:[],then:[]},a.specifications.push(b),e=f[2]),b){let t=e.split(/\s+/).filter(Boolean);for(;t.length;){let e=t.shift();if("given"===e||"when"===e||"then"===e){["given","when","then"].indexOf(e),k=e;continue}let i=t.shift();if(!i||!/^[_a-zA-Z]\w*$/.test(i))throw Error("Invalid specification entity");b[k].push({type:D(e),entity:i})}continue}throw Error(`Unsupported Event Modeling statement: ${e}`)}return function(e,t=!1){if(t&&[...new Set([...e.frames.map(e=>e.entity),...e.entities,...Object.keys(e.data),...e.specifications.flatMap(e=>[...e.given,...e.when,...e.then].map(e=>e.entity))].filter(e=>e.split(".").some(e=>
|
|
19
|
-
`),{display:"literal",fontFamily:t.font,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,transform:o.nodeTextTransform,maxWidth:220})),g=Math.max(120,m.width+2*(o.nodePaddingX+l)),u=f.get(i.id),y=Math.max(u.incoming,u.outgoing),v=Math.max(6+l,o.nodePaddingY+l,Math.min(o.cornerRadius??5,g/2));return{id:i.id,frame:i,block:m,lane:d.get(
|
|
15
|
+
`),H(i,n.protectedSpans)),a={kind:"eventmodeling",frames:[],entities:[],data:Object.create(null),notes:[],specifications:[],...f(u(o.accessibility))},l=O(i);if(l){let e=p(l.yaml);if(!e.ok)throw Error(e.message);e.value&&"object"==typeof e.value&&"title"in e.value&&"string"==typeof e.value.title&&(a.title=e.value.title)}let m=new Set,y=r.findIndex(e=>"eventmodeling"===e.trim());if(y<0)throw Error("Expected eventmodeling header");let b,k="given";for(y++;y<r.length;y++){let e=r[y].trim();if(!e||e.startsWith("%%")||e.startsWith("//"))continue;if(d("eventmodeling","statement",e,{line:y+1,unit:"normalized"}),e.startsWith("title ")){a.title=g(e.slice(6));continue}if(e.startsWith("accTitle:")){a.accessibilityTitle=e.slice(9).trim();continue}if(e.startsWith("accDescr:")){a.accessibilityDescription=e.slice(9).trim();continue}if(e.startsWith("accDescr {")){let t=[e.slice(10)];for(;!t[t.length-1].includes("}")&&++y<r.length;)t.push(r[y]);if(!t[t.length-1].includes("}"))throw Error("Unclosed accessibility description");a.accessibilityDescription=t.join(`
|
|
16
|
+
`).replace(/}\s*$/,"").trim();continue}let t=e.match(U);if(t){if(m.has(t[2])){let o=n.offsets??B(i,!0).offsets,a=r.slice(0,y).reduce((e,t)=>e+t.length+1,0)+r[y].indexOf(e),l=w(v(i),o[a]??i.length);throw Error(`Duplicate event modeling frame ID "${t[2]}" on line ${l.line}`)}m.add(t[2]),b=void 0;let o=e.slice(t[0].length).trim(),l=[];for(;o.startsWith("->>");){let e=o.match(/^->>\s*(\d{1,3})(?=\s|$)/);if(!e)throw Error("Invalid frame reference");l.push(e[1]),o=o.slice(e[0].length).trim()}let d=o.match(/^\[\[(\w+)\]\]/);d&&(o=o.slice(d[0].length).trim()),a.frames.push({id:t[2],reset:"rf"===t[1]||"resetframe"===t[1],type:D(t[3]),entity:t[4],sources:l,...d?{dataReference:d[1]}:{},...o?{data:P(o,!1)}:{}}),s("eventmodeling")&&c("eventmodeling","append-frame",a.frames.at(-1)),h("nodes",a.frames.length);continue}let o=e.match(RegExp(`^entity\\s+(${C})$`));if(o){a.entities.push(o[1]),b=void 0;continue}let l=e.match(/^(data\s+([_a-zA-Z]\w*)|note\s+(\d{1,3}))(?:\s+([\s\S]+))?$/);if(l){b=void 0;let e=l[4]??"";for(;!e.includes("{");){if(++y>=r.length)throw Error("Unclosed Event Modeling data block");e+=(e?`
|
|
17
|
+
`:"")+r[y].trim()}let t=[e];for(;!/^}\s*$/.test(r[++y]??"");){if(y>=r.length)throw Error("Unclosed Event Modeling data block");t.push(r[y])}t.push("}");let i=P(t.join(`
|
|
18
|
+
`),!0);if(l[2]){if(Object.hasOwn(a.data,l[2]))throw Error(`Duplicate data: ${l[2]}`);a.data[l[2]]=i}else a.notes.push({frame:l[3],data:i});continue}let f=e.match(/^gwt\s+(\d{1,3})\s*(.*)$/);if(f&&(k="given",b={frame:f[1],given:[],when:[],then:[]},a.specifications.push(b),e=f[2]),b){let t=e.split(/\s+/).filter(Boolean);for(;t.length;){let e=t.shift();if("given"===e||"when"===e||"then"===e){["given","when","then"].indexOf(e),k=e;continue}let i=t.shift();if(!i||!/^[_a-zA-Z]\w*$/.test(i))throw Error("Invalid specification entity");b[k].push({type:D(e),entity:i})}continue}throw Error(`Unsupported Event Modeling statement: ${e}`)}return function(e,t=!1){if(t&&[...new Set([...e.frames.map(e=>e.entity),...e.entities,...Object.keys(e.data),...e.specifications.flatMap(e=>[...e.given,...e.when,...e.then].map(e=>e.entity))].filter(e=>e.split(".").some(e=>L.has(e))))].length)throw Error("Event Modeling identifiers cannot use reserved Mermaid grammar keywords");let i=new Set;for(let t of[e.title,e.accessibilityTitle,e.accessibilityDescription])if(void 0!==t&&"string"!=typeof t)throw Error("Metadata must be text");let n=(e,t)=>{if(!e||"object"!=typeof e||Array.isArray(e)||Object.keys(e).some(e=>!t.includes(e)))throw Error("Unknown or malformed Event Modeling record field")},r=e=>{if(n(e,["text","type"]),!e||"string"!=typeof e.text||void 0!==e.type&&!F.has(e.type))throw Error("Invalid data record")};for(let t of e.entities)if("string"!=typeof t||!RegExp(`^${C}$`).test(t))throw Error("Invalid entity declaration");if(new Set(e.entities).size!==e.entities.length)throw Error("Duplicate entity declaration");for(let[t,i]of Object.entries(e.data)){if(!/^[_a-zA-Z]\w*$/.test(t))throw Error("Invalid data identifier");r(i)}for(let t of e.notes)n(t,["frame","data"]),r(t.data);for(let t of e.frames){if(n(t,["id","reset","type","entity","sources","dataReference","data"]),"string"!=typeof t.id||!/^\d{1,3}$/.test(t.id)||i.has(t.id))throw Error(`Duplicate or invalid frame ID: ${t.id}`);if(i.add(t.id),"boolean"!=typeof t.reset||!Array.isArray(t.sources)||!t.sources.every(e=>"string"==typeof e))throw Error("Invalid frame record");if(t.data&&r(t.data),"string"!=typeof t.entity||!RegExp(`^${C}$`).test(t.entity)||!Object.values(A).includes(t.type))throw Error("Invalid frame entity or type")}for(let t of e.frames){for(let e of t.sources)if(!i.has(e)||e===t.id)throw Error(`Invalid source frame: ${e}`);if(new Set(t.sources).size!==t.sources.length)throw Error("Duplicate frame relation");if(void 0!==t.dataReference&&("string"!=typeof t.dataReference||!/^[_a-zA-Z]\w*$/.test(t.dataReference)))throw Error("Invalid data reference");if(t.dataReference&&!Object.hasOwn(e.data,t.dataReference))throw Error(`Unknown data: ${t.dataReference}`)}for(let t of e.notes)if(!i.has(t.frame))throw Error(`Unknown note frame: ${t.frame}`);for(let t of e.specifications){if(n(t,["frame","given","when","then"]),!Array.isArray(t.given)||!Array.isArray(t.when)||!Array.isArray(t.then))throw Error("Invalid specification statements");if(!i.has(t.frame)||!t.given.length||!t.then.length)throw Error("Invalid Given/When/Then specification");for(let e of[...t.given,...t.when,...t.then])if(n(e,["type","entity"]),!Object.values(A).includes(e.type)||"string"!=typeof e.entity||!/^[_a-zA-Z]\w*$/.test(e.entity))throw Error("Invalid specification type or entity")}}(a),a}(e.source.authoredFamilyBody??e.source.familyBody);return void 0===t.title&&"string"==typeof e.source.frontmatter.title&&(t.title=e.source.frontmatter.title),a(function(e,t={},i,n=0,r){let o=E(t,void 0,i),a=t.padding??24,l=j({stroke:o.nodeBorderColor??(r?b(r).nodeStroke:"var(--_node-stroke)"),strokeWidth:String(o.nodeLineWidth)},!1)??0,s=(function(e){let t=new Map;for(let i of e.frames){let e=T(i),n=t.get(e)??{id:`lane:${t.size}`,label:e,members:[]};n.members.push(i.id),t.set(e,n)}return[...t.values()]})(e).map(e=>({...e,block:W(e.label,{display:"literal",fontFamily:o.groupFont??t.font,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,transform:o.groupTextTransform,maxWidth:220}),x:a,y:0,width:0,height:0})),d=new Map(s.map(e=>[e.label,e])),c=function(e){let t=[],i,n;for(let r of e.frames){let e=void 0!==i&&T(i)===T(r),o=e?n:i,a=[...r.sources];for(let e of(r.reset||!o||a.length||a.unshift(o.id),a))t.push({id:`relation:${e}:${r.id}`,from:e,to:r.id,explicit:r.sources.includes(e)});e||(n=i),i=r}return h("edges",t.length),t}(e),f=new Map(e.frames.map(e=>[e.id,{incoming:0,outgoing:0}]));for(let e of c)f.get(e.from).outgoing++,f.get(e.to).incoming++;let p=Math.max(12,8+o.lineWidth),m=$(e.title,o),g=Math.max(140,...s.map(e=>o.groupLabelPaddingX+e.block.width+o.groupPaddingX))+l,u=e.frames.map((i,n)=>{let r,a,s,c,h,m=(a=(r="string"==typeof i?e.frames.find(e=>e.id===i):i).id,s=r.data??(r.dataReference?e.data[r.dataReference]:void 0),c=e.notes.filter(e=>e.frame===a).map(e=>`Note: ${e.data.text}`),h=e.specifications.filter(e=>e.frame===a).flatMap(e=>["given","when","then"].filter(t=>e[t].length).map(t=>`${t}: ${e[t].map(e=>`${e.type} ${e.entity}`).join(", ")}`)),W([`${r.id} \xb7 ${r.type}${r.reset?" · reset":""}`,r.entity,...s?[s.text]:[],...c,...h].join(`
|
|
19
|
+
`),{display:"literal",fontFamily:t.font,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,transform:o.nodeTextTransform,maxWidth:220})),g=Math.max(120,m.width+2*(o.nodePaddingX+l)),u=f.get(i.id),y=Math.max(u.incoming,u.outgoing),v=Math.max(6+l,o.nodePaddingY+l,Math.min(o.cornerRadius??5,g/2));return{id:i.id,frame:i,block:m,lane:d.get(T(i)).id,x:0,y:0,width:g,height:Math.max(64,m.height+2*(o.nodePaddingY+l),y>1?(y-1)*p+2*v:0),index:n}}),y=Math.max(160,...u.map(e=>e.width)),v=Math.max(48,t.nodeSpacing??48,2*l+16),w=Math.max(2*a+g+Math.max(1,u.length)*y+Math.max(0,u.length-1)*v+Math.max(o.groupPaddingX+l,v/2+o.lineWidth),(m?.width??0)+2*a),x=new Map;for(let e of u){let t=x.get(e.lane)??[];t.push(e),x.set(e.lane,t)}let k=a+(m?.height??0)+v/2+Math.max(4,o.lineWidth);for(let e of s){let t=x.get(e.id)??[];for(let i of(e.y=k,e.height=Math.max(n,e.block.height+2*o.groupPaddingY,...t.map(e=>e.height+2*(o.groupPaddingY+l))),e.width=w-2*a,t))i.x=a+g+i.index*(y+v),i.y=k+(e.height-i.height)/2;k+=e.height+v}let _=new Map(u.map(e=>[e.id,e])),S=new Map(s.map(e=>[e.id,e])),z=new Map,O=new Map,R=c.map((e,t)=>{let i=_.get(e.from),n=_.get(e.to),r=O.get(i.id)??0,a=z.get(n.id)??0;O.set(i.id,r+1),z.set(n.id,a+1);let s={x:i.x+i.width+l,y:i.y+i.height/2+(r-(f.get(i.id).outgoing-1)/2)*p},d={x:n.x-l,y:n.y+n.height/2+(a-(f.get(n.id).incoming-1)/2)*p},c=i.x+y+v/2,h=n.x-v/2,m=S.get(i.lane).y-v/2,g=i.lane===n.lane&&n.index===i.index+1&&s.y===d.y?[s,d]:n.index===i.index+1?[s,{x:c,y:s.y},{x:c,y:d.y},d]:[s,{x:c,y:s.y},{x:c,y:m},{x:h,y:m},{x:h,y:d.y},d],u=o.edgeBendRadius>0?I(g,o.edgeBendRadius,{precision:3,terminalClearance:{end:Y(Z.id,o.lineWidth,"end")}}):void 0;return{...e,points:u?.geometry.points??g,projection:u,index:t}});return{style:o,laneWidth:g,width:w,height:Math.max(k+a,2*a+40),lanes:s,nodes:u,edges:R,...m?{title:M(m,w,a)}:{}}}(t,e.renderOptions,e.styleFace,e.familyConfig?.rowHeight,e.familyAppearance?.palette))},projectPositioned:r(({positioned:e})=>({version:1,bounds:{w:i(e.width),h:i(e.height)},nodes:e.nodes.map(e=>({id:e.id,x:i(e.x),y:i(e.y),w:i(e.width),h:i(e.height),shape:"rectangle",label:e.frame.entity,parentId:e.lane,...n(e.block,e.x+e.width/2,e.y+e.height/2,e)})),edges:e.edges.map(e=>({id:e.id,from:e.from,to:e.to,path:e.points.map(e=>[i(e.x),i(e.y)])})),groups:e.lanes.map(t=>({id:t.id,label:t.label,x:i(t.x),y:i(t.y),w:i(t.width),h:i(t.height),members:e.nodes.filter(e=>e.lane===t.id).map(e=>e.id)})),labels:[]})),lowerScene:o(X)});export{J as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,b as i,d as t}from"./chunk-
|
|
1
|
+
import{a as e,b as i,d as t}from"./chunk-PSZEE64O.js";import{b as a}from"./chunk-LBXXKLIR.js";import"./chunk-37FZNMPR.js";import"./chunk-6UOOATQR.js";import{a as r}from"./chunk-6GPDLZFQ.js";import"./chunk-MFTQWHUB.js";import"./chunk-O34YYEQV.js";import"./chunk-NKW2ZNCD.js";import"./chunk-HJVO5VC3.js";import"./chunk-L4UC3KGS.js";import"./chunk-BMZ24VPS.js";import"./chunk-62MR3LWJ.js";import"./chunk-PXTLV57R.js";import"./chunk-TT5GR5EJ.js";import"./chunk-J57YRC2M.js";import{b as o}from"./chunk-XHU3A432.js";import{d as n}from"./chunk-5LKPDHPC.js";import{u as c,z as s}from"./chunk-V6I2VGNQ.js";import"./chunk-7UFOFWBA.js";import{a as l,b as p,c as m,d as d}from"./chunk-QVSZOF5M.js";import{da as f}from"./chunk-G4JBA7HU.js";import"./chunk-3JTYTXA6.js";import{h as h}from"./chunk-YVNJDVQO.js";import{C as _,_ as u}from"./chunk-EIYLJ4FI.js";import{h as v}from"./chunk-PJJSDGLB.js";import"./chunk-YHMTSXIR.js";import"./chunk-QCU5G5PZ.js";var b=Object.freeze({id:"flowchart",upstreamId:"flowchart-v2",maturity:"stable",label:"Flowchart",headers:["flowchart","graph"],aliases:["swimlane"],config:{section:"flowchart",keys:["nodeSpacing","rankSpacing","wrappingWidth","titleTopMargin","subGraphTitleMargin","arrowMarkerAbsolute","diagramPadding","htmlLabels","curve","padding","defaultRenderer","inheritDir","look","minNodeWidth","theme"],noopKeys:["arrowMarkerAbsolute","curve","defaultRenderer","diagramPadding","htmlLabels","inheritDir","look","minNodeWidth","padding","subGraphTitleMargin","theme","titleTopMargin"]},identity:{id:"family:flowchart",kind:"family",version:"1.0.0",compatibility:{core:"0.5.4"},provenance:{owner:"agentic-mermaid",source:"built-in"}},collisionPriority:100,semanticChannels:[],semanticRoles:["prelude","title","defs","chrome","group","group-header","edge","edge-label","node","label","icon"],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:"icon",primitive:"text",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"shape",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]},{role:"icon",primitive:"container",applicability:"applicable",realization:"native",evidence:["src/__tests__/section-a-family-descriptor-conformance.test.ts"]}],example:`flowchart TD
|
|
2
2
|
A[Start] --> B{Ship?}
|
|
3
3
|
B -->|yes| C[Deploy]
|
|
4
4
|
B -->|no| D[Fix]`,detect:v,detectLoose:v}),y={nodeSpacing:o,rankSpacing:o,wrappingWidth:o};function g(e,i){let t=s(e,["flowchart",i]);return"number"==typeof t&&Number.isFinite(t)&&t>0?t:void 0}var k=d(b,{configDiagnostics:e=>n("flowchart",e,y),statementEnds:i,normalizeRequest:e=>({renderOptions:function(e,i){if(!e)return i;let t=g(e,"nodeSpacing"),a=g(e,"rankSpacing"),r=g(e,"wrappingWidth");return void 0===t&&void 0===a&&void 0===r?i:{...i,nodeSpacing:i.nodeSpacing??t,layerSpacing:i.layerSpacing??a,wrappingWidth:i.wrappingWidth??r}}(e.source.frontmatter,e.renderOptions)}),layout:e=>{let i=t(e.source.authoredFamilyBody??e.source.familyBody,e.source.familyBody);f(i),function(e,i,t){let a=i.wrappingWidth,r=h(i,void 0,t);for(let i of e.nodes.values()){let e=a??(i.markdownLabel?200:void 0);if(void 0===e||!i.label){delete i.labelBlock;continue}i.labelBlock=u(_(i.label,i.labelContent),{maxWidth:e,transform:r.nodeTextTransform,fontSize:r.nodeLabelFontSize,fontWeight:r.nodeLabelFontWeight,letterSpacing:r.nodeLetterSpacing})}}(i,e.renderOptions,e.styleFace);let a=c(e.source.frontmatter);return m(r(i,{...e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{},...a?{diagramTitle:a}:{}}))},projectPositioned:l(e),lowerScene:p(a)});export{k as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-
|
|
1
|
+
import"./chunk-QCU5G5PZ.js";function e(e){let{nodes:t,edges:n,padding:i,nodeSpacing:r,layerSpacing:h}=e;if(t.length<2||n.length>=t.length||r<=0||h<=0||![i,r,h].every(e=>Number.isFinite(e)&&e>=0)||t.some(e=>!Number.isFinite(e.width)||!Number.isFinite(e.height)||e.width<=0||e.height<=0))return;let l=t.map(()=>[]),o=new Uint32Array(t.length);for(let e of n){if(void 0!==e.label||1!==e.minSpan||e.source===e.target||!Number.isInteger(e.source)||!Number.isInteger(e.target)||e.source<0||e.source>=t.length||e.target<0||e.target>=t.length||(o[e.target]=o[e.target]+1,o[e.target]>1))return;l[e.source].push(e.target)}let g=t.flatMap((e,t)=>0===o[t]?[t]:[]),a=[...g],s=new Uint32Array(t.length);for(let e=0;e<a.length;e++){let t=a[e];for(let e of l[t])s[e]=s[t]+1,a.push(e)}if(a.length!==t.length)return;let d="LR"===e.direction||"RL"===e.direction,u="RL"===e.direction||"BT"===e.direction,m=e=>d?t[e].width:t[e].height,c=e=>d?t[e].height:t[e].width;if(t.some((e,t)=>void 0!==e.minimumPortSpacing&&(l[t].length-1)*e.minimumPortSpacing>c(t)-2*(e.paintCornerRadius??0)))return;let p=new Float64Array(t.length),f=[];for(let e=a.length-1;e>=0;e--){let t=a[e],n=l[t],i=Math.max(0,n.length-1)*r;for(let e of n)i+=p[e];p[t]=Math.max(c(t),i),f[s[t]]=Math.max(f[s[t]]??0,m(t))}let y=[],x=0;for(let e=0;e<f.length;e++)y.push(x),x+=f[e]+(e+1<f.length?h:0);let w=new Float64Array(t.length),S=0;for(let e of g)w[e]=S,S+=p[e]+r;if(S-=r,!Number.isFinite(x+S+2*i))return;let b=t.map(()=>({x:0,y:0}));for(let e of a){let t=l[e],n=i+w[e]+(p[e]-c(e))/2,h=y[s[e]]+(f[s[e]]-m(e))/2;u&&(h=x-h-m(e)),h+=i,b[e]=d?{x:h,y:n}:{x:n,y:h};let o=Math.max(0,t.length-1)*r;for(let e of t)o+=p[e];let g=w[e]+(p[e]-o)/2;for(let e of t)w[e]=g,g+=p[e]+r}let M=new Float64Array(t.length),P=e.edgeSpacing??6;for(let n=0;n<t.length;n++){let i=t[n].minimumPortSpacing,r=l[n];if(!i||r.length<2)continue;let o=[],g=[],a=(d?b[n].y:b[n].x)+c(n)/2;for(let[e,t]of r.entries()){let n=a+(e-(r.length-1)/2)*i,h=(d?b[t].y:b[t].x)+c(t)/2;h<n?o.push(t):h>n&&g.push(t)}if((Math.max(o.length,g.length)-1)*P>h-2*Math.max(12,e.minimumTerminalLead??0))return;o.forEach((e,t)=>{M[e]=(t-(o.length-1)/2)*P}),g.forEach((e,t)=>{M[e]=((g.length-1)/2-t)*P})}let F=new Uint32Array(t.length);return{topology:"forest",width:2*i+(d?x:S),height:2*i+(d?S:x),nodes:b,edges:n.map(n=>{if(e.placementOnly&&!e.cycleOriented&&!e.loopPorts?.length)return{points:[]};let r=b[n.source],h=b[n.target],o=t[n.source],g=t[n.target],a=d?{x:r.x+(u?0:o.width),y:r.y+o.height/2}:{x:r.x+o.width/2,y:r.y+(u?0:o.height)},m=d?{x:h.x+(u?g.width:0),y:h.y+g.height/2}:{x:h.x+g.width/2,y:h.y+(u?g.height:0)},c=F[n.source],p=l[n.source].length;if(F[n.source]=c+1,o.minimumPortSpacing&&p>1){let e=(c-(p-1)/2)*o.minimumPortSpacing;d?a.y+=e:a.x+=e}let w=d?(a.x+m.x)/2:(a.y+m.y)/2,S=s[n.source],P=i+(u?x-(y[S]+f[S]):y[S]+f[S]),N=i+(u?x-y[S+1]:y[S+1]);return(w<=Math.min(P,N)||w>=Math.max(P,N))&&(w=P+(N-P)/2),o.minimumPortSpacing&&p>1&&(w=(P+N)/2+(u?-1:1)*M[n.target]),{points:d?[a,{x:w,y:a.y},{x:w,y:m.y},m]:[a,{x:a.x,y:w},{x:m.x,y:w},m]}})}}function t(t,n,i,r,h){let l=n.children;if(!l||l.length<2||t.subgraphs.length>0||t.stateNotes?.length||l.length!==t.nodes.size||t.edges.some(e=>void 0!==e.label||(e.length??1)!==1)||[...t.nodes.values()].some(e=>"rectangle"!==e.shape)||![i,r,h].every(e=>Number.isFinite(e)&&e>=0)||0===r||0===h)return;let o=new Map(l.map((e,t)=>[e.id,t])),g=t.edges.map(e=>({source:o.get(e.source)??-1,target:o.get(e.target)??-1,minSpan:1})),a=e({nodes:l.map(e=>({id:e.id,width:e.width,height:e.height})),edges:g,direction:t.direction,padding:i,nodeSpacing:r,layerSpacing:h});if(a)return{...n,width:a.width,height:a.height,children:l.map((e,t)=>({...e,...a.nodes[t]})),edges:t.edges.map((e,t)=>{let n=a.edges[t].points;return{id:`e${t}`,sources:[e.source],targets:[e.target],sections:[{id:`e${t}_s0`,startPoint:n[0],bendPoints:n.slice(1,-1),endPoint:n.at(-1)}]}})}}export{t as indexedForestLayout,e as layoutMeasuredForest};
|