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
package/dist/chunk-EHCMJUMD.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import{$ as em,$a as z1,$b as dr,A as P1,Aa as jr,Ad as oa,Ba as N1,Ca as Nc,Cc as Xx,Da as $1,Ea as $n,Ec as eC,Ed as xC,Fa as _1,Ga as Pi,H as Bx,Ha as Mu,I as E1,Ia as Ue,Ic as um,Ja as Xn,Jc as _o,Ka as ku,Kc as Ux,La as yt,Lc as iC,Ma as D1,Mc as rC,Na as O1,Nc as oC,Nd as bC,Oa as gs,Oc as sC,P as R1,Pa as B1,Pc as aC,Pd as SC,Qa as It,Qb as j1,Qc as lC,Qd as wC,Ra as Ye,Rb as st,Rc as cC,Rd as MC,S as v1,Sa as hn,Sb as sm,Sc as wl,T as ul,Ta as Ht,Tb as xn,U as Gr,Ua as pl,Ub as _c,Va as W1,Vd as kC,Wa as $c,Wb as Er,X as xu,Xa as Cu,Xb as Y1,Y as Wx,Ya as gl,Yb as q1,Yc as dC,Z as T1,Za as ys,Zb as X1,_ as fi,_a as Hx,_b as U1,a as Jh,aa as L1,ad as uC,b as w1,ba as Ic,bb as G1,bc as am,c as cl,ca as bu,cb as Pu,cc as hi,d as Yn,db as mo,dc as lm,e as Zi,ea as Hr,eb as im,ec as V1,ed as fC,f as Qh,fa as qe,fb as yl,fc as K1,fd as hC,ga as ia,gb as mn,gd as mC,ha as cr,hb as Eu,hc as ur,hd as pC,i as Zh,ia as A1,ib as Zn,ic as jx,id as mi,j as M1,ja as Su,jb as xl,jc as Sl,k as pu,ka as vt,kc as cm,l as Lc,la as tm,lc as J1,ma as _e,mb as Zt,mc as Yx,n as k1,na as zx,nc as xs,o as ms,oa as fl,ob as Dt,oc as dm,p as Nn,pa as wu,pb as Ot,pc as qx,q as C1,qa as hl,qb as bl,qd as gC,ra as ml,s as Vt,sa as nm,sb as _n,sc as bs,sd as Ml,t as gu,ta as I1,tb as H1,tc as Q1,td as fm,u as yu,ub as rm,ud as Yr,v as na,va as ra,vb as om,vc as Z1,vd as yC,w as dl,wa as Fc,wb as Bn,x as Ac,xa as ps,y as qn,ya as F1,za as Gx}from"./chunk-OMY6NRQD.js";import{I as hm,a as tC,b as nC,z as rt}from"./chunk-O7H2UX5K.js";var Vx=new WeakMap;var Kx=new WeakMap;function Ss(e){return Kx.get(e)??Vx.get(e)}var Jx=new WeakMap;var PC=new WeakSet;var sB=Object.freeze([1,0,0,1,0,0]);function sa(e){return Jx.get(e)}function EC(e){return PC.has(e)}function CC(e){return[e.x0,e.x1,e.y0,e.y1].every(Number.isFinite)&&e.x0<=e.x1&&e.y0<=e.y1}function mm(e){return e==="none"||e==="transparent"||!!e&&Vt(e)?.[3]===0}function Pn(e){if(e===void 0)return 1;const t=e.trim();if(!/^[+-]?(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?$/.test(t))return Number.NaN;const n=Number(t);return Number.isFinite(n)?Math.max(0,Math.min(1,n)):Number.NaN}function Qx(e,t){return e===0||t===0?0:e*t}function RC(e,t){return e&&Number(t.opacity??1)!==0&&(!mm(t.fill)||t.stroke!==void 0&&!mm(t.stroke)&&Number.parseFloat(t.strokeWidth??"1")!==0)}function aB(e){if(e.kind==="document")return e.element!=="content"||e.nonPaint!==void 0||Y1(e).trim()==="";if(e.kind==="text")return!RC(TC(e.block,e.text),e.paint);if(e.kind==="connector")return e.lineStyle==="invisible";if(e.kind==="shape"){if(e.conditionalPaint)return false;return[e.paint,...e.childPaints??[]].every(t=>t.opacity!==void 0&&Number(t.opacity)===0||mm(t.fill)&&(t.stroke===void 0||mm(t.stroke)))}return false}function vC(e){return cB(e)}function TC(e,t){return e?e.lineBlocks.some(n=>n.runs.some(i=>i.text.trim()!=="")):t.trim()!==""}var pm=new WeakSet;var Zx=Object.freeze([]);pm.add(Zx);function gm(e){return Object.freeze({id:e.id,role:e.role})}function LC(e,t){const n=gm(t);const i=e===void 0?Zx:pm.has(e)?e:Array.from(e,gm);const r=Object.freeze([...i,n]);pm.add(r);return r}function AC(e){const t=IC(e,void 0,true);return{leaf(n,i,r,o=Zx,s=false,a=1,l){if(!pm.has(o))throw new TypeError("Native paint ancestors must be owned snapshots");t.leaf(n,i,r,o,s,a,l)},finish:t.finish}}function lB(e){switch(e.kind){case"shape":return Object.freeze({kind:e.kind,geometry:e.geometry,paint:e.paint,...e.childPaints?{childPaints:e.childPaints}:{},...e.transform?{transform:e.transform}:{}});case"connector":return Object.freeze({kind:e.kind,lineStyle:e.lineStyle,endpoints:e.endpoints,route:e.route,stroke:e.stroke,markers:e.markers,...e.transform?{transform:e.transform}:{}});case"text":return Object.freeze({kind:e.kind,paint:e.paint});case"document":return Object.freeze({kind:e.kind})}}function IC(e,t,n=false){const i=[];const r={measured:0,unmeasured:0,nonPainting:0,preparedText:0,fallbackText:0};const o=(s,a,l,c,d,u,f,h=l===void 0)=>{const m=f??s.owner??c.at(-1)??s.identity??{id:s.id,role:s.role};const p=n?lB(s):void 0;const g=u===0||aB(s);const[y,b,S,x,k,w]=l??fl;const C=l||s.transform?{kind:"matrix",a:y,b,c:S,d:x,e:k,f:w}:void 0;const R=!l&&!s.transform?sB:Object.freeze(hl(l??fl,wu(s.transform)));const M=g?void 0:Pi(s,C);const P=!!M&&CC(M);const E=g?"non-painting":P?"measured":"unmeasured";const v=Object.freeze({key:a,id:s.id,kind:s.kind,role:s.role,owner:n&&c.includes(m)?m:gm(m),ancestors:c,order:i.length,coverage:E,...d||s.visibility==="conditional"||!Number.isFinite(u)?{visibility:"conditional"}:{},...u<1?{groupOpacity:u}:{},...P?{bounds:Object.freeze(M)}:{},...!g&&!P?{reason:s.kind==="document"?"opaque-visible-content":"missing-paint-geometry"}:{},...s.kind==="text"?{text:Object.freeze({measurement:s.measurement??"unavailable",...t?.(s.text,s.block,true)})}:{}});if(p)Kx.set(v,p);else Vx.set(v,s);Jx.set(v,R);if(h&&!s.transform)PC.add(v);i.push(v);if(g)r.nonPainting++;else if(P)r.measured++;else r.unmeasured++;if(s.kind==="text"&&!g){if(s.measurement==="prepared")r.preparedText++;else r.fallbackText++}if(s.kind==="connector")s.labels.forEach((L,T)=>{if(L.visual?.kind!=="inline")return;const A={...L.paint,...L.halo?{stroke:L.halo.color??"var(--bg)",strokeWidth:String(L.halo.width)}:{}};const $=u===0||!RC(TC(L.block,L.text),A);const _=$?void 0:N1(L);const[z,F,G,I,D,B]=R;const Y=_&&Nc(_,{kind:"matrix",a:z,b:F,c:G,d:I,e:D,f:B});const W=!!Y&&CC(Y);const O=Object.freeze({key:`${a}.label.${T}`,id:L.id??`${s.id}:label:${T}`,kind:"text",role:"label",owner:v.owner,ancestors:v.ancestors,order:i.length,coverage:$?"non-painting":W?"measured":"unmeasured",...v.visibility?{visibility:v.visibility}:{},...u<1?{groupOpacity:u}:{},...W?{bounds:Object.freeze(Y)}:!$?{reason:"missing-inline-label-geometry"}:{},text:Object.freeze({measurement:L.block?"prepared":"fallback",...t?.(L.text,L.block)})});if(p)Kx.set(O,p);else Vx.set(O,s);Jx.set(O,R);i.push(O);if($)r.nonPainting++;else{if(W)r.measured++;else r.unmeasured++;if(L.block)r.preparedText++;else r.fallbackText++}})};return{leaf:o,finish:()=>Object.freeze({version:1,family:e.family,bounds:Object.freeze({width:e.width,height:e.height}),primitives:Object.freeze(i),coverage:Object.freeze(r)})}}function cB(e,t){const n=IC(e,t);const i=(r,o,s,a,l=false,c=1,d=true)=>{r.forEach((u,f)=>{const h=`${o}.${f}`;if(u.kind==="group"){const m=u.identity??{id:u.id,role:u.role};i(u.children.map(p=>p.node),h,hl(s,wu(u.transform)),Object.freeze([...a,gm(m)]),l||u.visibility==="conditional",Qx(c,Pn(u.paint?.opacity)),d&&!u.transform)}else n.leaf(u,h,s,a,l,c,void 0,d)})};i(e.parts,"scene",fl,Object.freeze([]));return n.finish()}function Do(e,t,n,i,r,o){o?.();const s=e.geometry;if(!s)return[];const a=i==="start"&&e.orient==="auto-start-reverse"?-1:1,l=Math.hypot(n.x,n.y);if(!l)return[];const c=a*n.x/l,d=a*n.y/l,u=e.viewBox,f=(e.units==="userSpaceOnUse"?1:r)*Math.max(1,e.scale??1)*(u&&e.size?Math.min(e.size.width/u.width,e.size.height/u.height):1);if(!Number.isFinite(f))throw new TypeError("Nonfinite Class marker scale");if(f<=0)return[];const h=w=>{o?.();const C=(w.x-(e.ref?.x??0))*f,R=(w.y-(e.ref?.y??0))*f;return{x:t.x+c*C-d*R,y:t.y+d*C+c*R}};const m=e.paint??{},p=m.stroke&&m.stroke!=="none"&&m.stroke!=="transparent"?Number.parseFloat(m.strokeWidth??"1")/2:0,g=m.fill!==void 0&&m.fill!=="none"&&m.fill!=="transparent";if(s.kind==="circle"){const w=h({x:s.cx,y:s.cy});return[{kind:"circle",cx:w.x,cy:w.y,r:(s.r+p)*f}]}if(s.kind!=="polygon"&&s.kind!=="polyline")throw new TypeError("Unmeasured Class marker geometry");const y=s.points,b=[];if(g&&s.kind==="polygon"){for(let w=0;w<y.length;w++)o?.();b.push([...y])}const S=s.kind==="polygon"?y.length:y.length-1;const x=(w,C)=>{o?.();const R=Math.hypot(C.x-w.x,C.y-w.y);return{x:(C.x-w.x)/R,y:(C.y-w.y)/R}};if(p>0){for(let w=0;w<S;w++){o?.();const C=y[w],R=y[(w+1)%y.length],M=x(C,R),P={x:-M.y*p,y:M.x*p};b.push([{x:C.x+P.x,y:C.y+P.y},{x:R.x+P.x,y:R.y+P.y},{x:R.x-P.x,y:R.y-P.y},{x:C.x-P.x,y:C.y-P.y}])}for(let w=s.kind==="polygon"?0:1;w<(s.kind==="polygon"?y.length:y.length-1);w++){o?.();const C=y[w],R=y[(w-1+y.length)%y.length],M=y[(w+1)%y.length],P=x(R,C),E=x(C,M),v=P.x*E.y-P.y*E.x;if(!v)continue;const L=v>0?-1:1,T={x:C.x-L*P.y*p,y:C.y+L*P.x*p},A={x:C.x-L*E.y*p,y:C.y+L*E.x*p},$=((A.x-T.x)*E.y-(A.y-T.y)*E.x)/v,_={x:T.x+$*P.x,y:T.y+$*P.y};b.push(Math.hypot(_.x-C.x,_.y-C.y)<=Number(m.strokeMiterlimit??"4")*p?[C,T,_,A]:[C,T,A])}}const k=(w,C,R,M)=>{const P=[];for(let E=0;E<w.length;E++){o?.();const v=w[E],L=w[(E+1)%w.length],T=_=>M?_[C]>=R:_[C]<=R,A=T(v),$=T(L);if(A)P.push(v);if(A!==$){const _=(R-v[C])/(L[C]-v[C]);P.push({x:v.x+_*(L.x-v.x),y:v.y+_*(L.y-v.y)})}}return P};return b.flatMap(w=>{o?.();if(e.overflow==="hidden"&&u){for(const[M,P,E]of[["x",u.x,true],["x",u.x+u.width,false],["y",u.y,true],["y",u.y+u.height,false]]){o?.();w=k(w,M,P,E)}}const C=w[0];let R=0;if(C)for(let M=0;M<w.length;M++){o?.();const P=w[M],E=w[(M+1)%w.length];R+=(P.x-C.x)*(E.y-C.y)-(P.y-C.y)*(E.x-C.x)}return w.length>=3&&R!==0?[{kind:"polygon",points:w.map(h)}]:[]})}var ws=4e5;var FC=new WeakSet;function NC(e){return FC.has(e)}var $C=new WeakMap;function _C(e){return $C.get(e)}function DC(e){let t=0,n=false,i=false;const r=new Map;const o=[];const s=(f=1)=>{if(n)return false;if(!Number.isSafeInteger(f)||f<0||f>e-t){n=true;return false}t+=f;return true};const a=Symbol("unsupported-emission");const l=(f,h=0,m=new Set)=>{if(h>64)throw a;if(f===null||f===void 0||typeof f==="boolean")return f;if(typeof f==="number"||typeof f==="string")return f;if(typeof f!=="object"||!s()||m.has(f))throw a;const p=Object.getPrototypeOf(f);if(p!==Object.prototype&&p!==null&&p!==Array.prototype)throw a;const g=Object.getOwnPropertyNames(f);if(!s(g.length))throw a;m.add(f);const y=Array.isArray(f)?[]:{};let b;const S=V1(f);for(const x of g){if(!s())throw a;const k=Object.getOwnPropertyDescriptor(f,x);if(!k)continue;if(x==="length"&&Array.isArray(f)){b=k;continue}if(x==="terminalProjection"&&S)continue;if(!("value"in k))throw a;Object.defineProperty(y,x,{value:l(k.value,h+1,m),enumerable:k.enumerable,configurable:false,writable:false})}if(Array.isArray(f)){if(!b||!("value"in b))throw a;Object.defineProperty(y,"length",{value:b.value,writable:false})}if(S){if(!s(3)||!K1(f,y))throw a;const x=Object.getOwnPropertyDescriptor(y,"terminalProjection");Object.defineProperty(y,"terminalProjection",{...x,configurable:false})}tm(f,y);m.delete(f);return Object.preventExtensions(y)};const c=f=>{try{return l(f)}catch{return void 0}};const d=(f,h)=>{if(!s())return false;if(typeof f==="string"&&typeof h==="string")return s(f.length+h.length)&&f===h;if(f===h)return true;if(!f||!h||typeof f!=="object"||typeof h!=="object")return false;let m=0,p=0;if(!s(2))return false;const g=Object.getOwnPropertyNames(f),y=Object.getOwnPropertyNames(h);if(!s(g.length+y.length))return false;for(const b of g){if(!s(3))return false;const S=Object.getOwnPropertyDescriptor(f,b),x=Object.getOwnPropertyDescriptor(h,b);if(!S)continue;m++;if(!x||!("value"in S)||!("value"in x)||S.enumerable!==x.enumerable||!d(S.value,x.value))return false}for(const b of y){if(!s())return false;if(Object.hasOwn(h,b))p++}return m===p};const u=f=>{if(!s())return void 0;if(typeof f==="string")return f.length*6+2;if(typeof f==="number")return 32;if(!f||typeof f!=="object")return 8;let h=64;if(!s())return void 0;const m=Object.getOwnPropertyNames(f);if(!s(m.length))return void 0;for(const p of m){if(!s(3))return void 0;const g=Object.getOwnPropertyDescriptor(f,p);if(!g||!("value"in g))return void 0;const y=u(g.value);if(y===void 0)return void 0;h+=p.length+16+y;if(!Number.isSafeInteger(h)||h>e)return void 0}return h};return{snapshot:c,same:d,retainFragment(){return s()},parts(f,h){if(!s()){i=true;return f}if(!Array.isArray(f)){i=true;return f}const m=Object.getOwnPropertyDescriptor(f,"length")?.value;if(!Number.isSafeInteger(m)||m<0||m>h)throw new RangeError("Native drawing contains too many emitted nodes");if(!s(m*4)){i=true;return f}const p=[];for(let g=0;g<m;g++){const y=Object.getOwnPropertyDescriptor(f,String(g));if(!y||!("value"in y)){i=true;p.push(f[g])}else p.push(y.value)}return Object.freeze(p)},uncertain(){i=true},header(f,h){if(!s(h.length*8+128))return f;const m=$c(h).find(w=>w.name==="svg");if(!m){i=true;return f}const p=Ue(f.width),g=Ue(f.height);const y=ys(m,"viewBox");if(y!==void 0?y!==`0 0 ${p} ${g}`:ys(m,"width")!==p||ys(m,"height")!==g)i=true;for(const w of m.attributes){if(!s())return f;if(!["xmlns","width","height","viewBox","style","role","class","id"].includes(w.name)&&!w.name.startsWith("data-")&&!w.name.startsWith("aria-"))i=true}const b=Object.freeze({...f,width:Number(p),height:Number(g)});const S=f.colors;const x=ys(m,"style");if(x===void 0)return b;const k=new Set;for(const w of x.split(";")){if(!s(w.length+4))return b;if(!w.trim())continue;const C=w.indexOf(":");const R=w.slice(0,C).trim(),M=w.slice(C+1).trim();if(C<0||k.has(R)){i=true;continue}k.add(R);if(R==="background"&&M==="var(--bg)")continue;if(R==="--font"){if(!s(typeof S.font==="string"?S.font.length*4:1)||mo(S.font)!==M)i=true;continue}if(!["bg","fg","line","accent","muted","surface","border","font"].some(P=>`--${P}`===R)||S[R.slice(2)]!==M)i=true}return b},group(f){if(!s(f.open.length*8))return void 0;const h=$c(f.open)[0];if(!h||h.name!=="g"){i=true;return void 0}const m=ys(h,"opacity");if(m!==f.paint?.opacity||f.paint?.fill!==void 0||ys(h,"style")!==void 0)i=true;const p=ys(h,"transform");if(p===void 0)return void 0;const g=I1(p);if(!g)i=true;return g&&Object.freeze(g)},observe(f,h){if(!s(2*(1+(f.kind==="connector"?f.labels.length:0))))return false;if(f.kind==="connector"){const m=p=>{if(p&&s(2))o.push(p)};m(f.markers.start);for(const p of f.markers.mid){if(!s())break;m(p)}m(f.markers.end)}else if(f.kind==="document"&&f.element==="definitions"){if(!s(h.length*8))return false;for(const m of $c(h)){if(!s(m.attributes.length+1))break;if(m.name!=="marker")continue;const p=ys(m,"id");const g=h.indexOf("</marker>",m.end);if(!p||g<0||r.has(p)){i=true;continue}const y=h.slice(m.start,g+9).replace(/(^|\n)[ \t]+(?=<)/g,"$1");if(!s(2))break;r.set(p,y)}}return!n},leaf(f){const h=c(f);if(!h)return{node:f,conditional:true};X1(f,h);return{node:h,conditional:false}},finish(f,h){const m=new Map;for(const p of o){if(!s())break;try{if(!s(2))break;const g=m.get(p.id);if(g&&d(g,p))continue;const y=u(p);if(y===void 0||!s(y*2)){i=true;break}const b=am(p,{indent:0}).replace(/(^|\n)[ \t]+(?=<)/g,"$1");if(!s(b.length*3)||r.get(p.id)!==b)i=true;else if(s(2))m.set(p.id,p)}catch{i=true}}for(const p of f.primitives)if(p.visibility!=="conditional")FC.add(p);$C.set(f,Object.freeze({operations:t,exhausted:n,uncertain:i,header:h}))}}}var HC=new WeakMap;function f7(e,t){HC.set(e,t)}function h7(e){return e.paintCertification??HC.get(e)}var Oo=1e5;var dB=64;var uB=.5;var Dc=1e-6;var Oc=(e,t,n=0)=>e.x0<=t.x0+n&&e.y0<=t.y0+n&&e.x1>=t.x1-n&&e.y1>=t.y1-n;var po=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;var OC=e=>({x0:e.x,y0:e.y,x1:e.x+e.w,y1:e.y+e.h});var fB=e=>({x0:e.x,y0:e.y,x1:e.x+e.width,y1:e.y+e.height});function eb(e){if(!e.length)return void 0;const t={x0:Infinity,y0:Infinity,x1:-Infinity,y1:-Infinity};for(const r of e){t.x0=Math.min(t.x0,r.bounds.x0);t.y0=Math.min(t.y0,r.bounds.y0);t.x1=Math.max(t.x1,r.bounds.x1);t.y1=Math.max(t.y1,r.bounds.y1)}if(e.length<=8)return{bounds:t,leaves:e};const n=t.x1-t.x0>=t.y1-t.y0?"x0":"y0";e.sort((r,o)=>r.bounds[n]-o.bounds[n]||r.primitive.order-o.primitive.order);const i=Math.floor(e.length/2);return{bounds:t,left:eb(e.slice(0,i)),right:eb(e.slice(i))}}function hB(e,t,n,i,r,o,s){if(!s()||!o.every(Number.isFinite)||o[0]!==1||o[1]!==0||o[2]!==0||o[3]!==1||n.nonScaling||!["butt","round","square"].includes(n.lineCap??"butt")||!["miter","round","bevel"].includes(n.lineJoin??"miter")||!Number.isFinite(i)||i<=0||!Number.isFinite(r)||r<i/2)return false;const[a,l]=e;if(![a.x,a.y,l.x,l.y].every(Number.isFinite)||a.x!==l.x&&a.y!==l.y||a.x===l.x&&a.y===l.y)return false;const c=i/2;const d={x0:Math.min(a.x,l.x)-c,y0:Math.min(a.y,l.y)-c,x1:Math.max(a.x,l.x)+c,y1:Math.max(a.y,l.y)+c};if(!s()||!Object.values(d).every(Number.isFinite)||po(d,t))return false;for(const u of e){if(!s())return false;const f={x0:u.x-r,y0:u.y-r,x1:u.x+r,y1:u.y+r};if(!Object.values(f).every(Number.isFinite)||po(f,t))return false}return true}function BC(e,t){const n=Pn(t.opacity),i=Pn(t.fillOpacity);const r=t.fill?Vt(t.fill):null;return e.kind!=="line"&&t.fill!=="none"&&t.fill!=="transparent"&&!(n<1||i<1||r&&r[3]<1)}function WC(e,t){return Pn(t.opacity)!==0&&Pn(t.strokeOpacity)!==0&&$n(t,["polygon","polyline","path","compound"].includes(e.kind))!==0}function mB(e,t){const n=new Map;const i=l=>{if(n.has(l))return n.get(l);const c=rm(l,e.colors);const d=!!c&&Vt(c)?.[3]===1;n.set(l,d);return d};const r=l=>{if(l.vectorEffect==="non-scaling-stroke"||!l.stroke||!i(l.stroke)||Number(l.opacity??1)!==1||Number(l.strokeOpacity??1)!==1||l.strokeDasharray)return 0;const c=Number(l.strokeWidth?.replace(/px$/,"")??1);return Number.isFinite(c)&&c>0?c:0};const o=new Map;const s=(l,c)=>JSON.stringify([l.owner,c,sa(l)]);for(const l of t){const c=Ss(l);if(c?.kind!=="shape"||l.coverage!=="measured"||l.visibility==="conditional"||l.groupOpacity!==void 0)continue;const d=c.geometry.kind==="compound"?c.geometry.children:[c.geometry];for(let u=0;u<d.length;u++){const f=c.geometry.kind==="compound"?c.childPaints?.[u]??c.paint:c.paint;const h=r(f);if(h>0)o.set(s(l,d[u]),h)}}const a=[];for(const l of t){const c=Ss(l);if(!c||c.kind!=="shape"||l.visibility==="conditional"||l.coverage!=="measured")continue;if(l.groupOpacity!==void 0)continue;const{geometry:d,paint:u,childPaints:f}=c;const h=d.kind==="compound"?d.children:void 0;const m=h?void 0:d;const p=h?.map((z,F)=>f?.[F]??u);const g=h?void 0:u;const y=h?.map((z,F)=>BC(z,p[F]));const b=h?false:BC(m,g);const S=h?.map((z,F)=>WC(z,p[F]));const x=h?false:WC(m,g);if(!(y?y.some(Boolean):b)&&!(S?S.some(Boolean):x))continue;const k=sa(l);const[w,C,R,M,P,E]=k;const v={kind:"matrix",a:w,b:C,c:R,d:M,e:P,f:E};let L;const T=h?[]:void 0;for(let z=0,F=h?.length??1;z<F;z++){if(h&&!(z in h))continue;const G=h?h[z]:m,I=p?p[z]:g;if(!(y?y[z]:b)&&!(S?S[z]:x))continue;const D=Pi({kind:"shape",id:l.id,role:l.role,geometry:G,paint:I},v);const B=D??l.bounds;if(T)T[z]=B;L=ra(L,B)}if(!L)continue;const A={primitive:l,bounds:L,borderWidth:o.get(s(l,d)),...h?{partBorderWidths:h.map(z=>o.get(s(l,z))??0),partOwnBorderWidths:p.map(r),partFilled:y,partBounds:T}:{}};if(Math.abs(k[1])>1e-12||Math.abs(k[2])>1e-12){a.push(A);continue}const $=[],_=[];for(let z=0,F=h?.length??1;z<F;z++){if(h&&!(z in h))continue;const G=h?h[z]:m,I=p?p[z]:g;if(G.kind==="rect"&&k[0]===1&&k[3]===1&&k[1]===0&&k[2]===0&&I.vectorEffect!=="non-scaling-stroke"&&I.stroke&&i(I.stroke)&&Pn(I.opacity)===1&&Pn(I.strokeOpacity)===1&&!I.strokeDasharray&&$n(I,false)!==void 0){const O=Number.parseFloat(I.strokeWidth??"1")/2;const N=Math.max(0,Math.min(G.width/2,G.rx??G.ry??0)),H=Math.max(0,Math.min(G.height/2,G.ry??G.rx??0));if(O>0){for(const j of[{x0:G.x-O,y0:G.y+H,x1:G.x+O,y1:G.y+G.height-H},{x0:G.x+G.width-O,y0:G.y+H,x1:G.x+G.width+O,y1:G.y+G.height-H},{x0:G.x+N,y0:G.y-O,x1:G.x+G.width-N,y1:G.y+O},{x0:G.x+N,y0:G.y+G.height-O,x1:G.x+G.width-N,y1:G.y+G.height+O}])if(j.x0<j.x1&&j.y0<j.y1)_.push(Nc(j,v))}}if(!(y?y[z]:b)||G.kind!=="rect"||Pn(I.opacity)!==1||Pn(I.fillOpacity)!==1||!I.fill||!i(I.fill))continue;const D=Math.min(G.width/2,G.rx??G.ry??0),B=Math.min(G.height/2,G.ry??G.rx??0);const Y=ml({x:G.x+D,y:G.y+B},k);const W=ml({x:G.x+G.width-D,y:G.y+G.height-B},k);$.push({x0:Math.min(Y.x,W.x),y0:Math.min(Y.y,W.y),x1:Math.max(Y.x,W.x),y1:Math.max(Y.y,W.y)})}a.push({...A,interiors:$,strokeInteriors:_})}return a}function zC(e,t,n,i,r=0,o=()=>true,s,a,l=false){const c=Ss(e.primitive);if(c?.kind!=="shape")return false;const d=nm(sa(e.primitive));if(!d)return false;const{geometry:u,paint:f,childPaints:h}=c;const m=(i??[{x:t.x0,y:t.y0},{x:t.x0,y:t.y1},{x:t.x1,y:t.y0},{x:t.x1,y:t.y1}]).map(P=>ml(P,d));const[p,g,y,b]=d;const S=(Math.hypot(p+b,g-y)+Math.hypot(p-b,g+y))/2;const x=r*S;const k=a?ml(a,d):void 0;let w=false;let C;let R=[];const M=(P,E=e.borderWidth??0,v=f,L=true,T=e.bounds,A)=>{if(!o())return false;if(!A&&R.includes(P))return true;if(A&&(A.x<T.x0||A.x>T.x1||A.y<T.y0||A.y>T.y1))return true;const $=A?[ml(A,d)]:m;let _=A?0:x;const z=A?-1e-8:l?0:1e-8;const F=A?-1e-8:0;if(P.kind==="compound")return P===u&&P.children.length<=64&&P.children.every((O,N)=>O.kind!=="compound"&&M(O,e.partBorderWidths?.[N]??0,h?.[N]??f,e.partFilled?.[N]??true,e.partBounds?.[N]??e.bounds,A));if(!L){if(Pn(v.opacity)===0||Pn(v.strokeOpacity)===0||$n(v,P.kind!=="line")===0)return true}if(P.kind==="line"){if(!A&&C&&k&&["butt","round","square"].includes(v.strokeLinecap??"butt")){if(!o())return false;const H=P.x2-P.x1,j=P.y2-P.y1;const q=k.x===P.x1&&k.y===P.y1?1:k.x===P.x2&&k.y===P.y2?-1:0;if(q&&Number.isFinite(H)&&Number.isFinite(j)&&(H!==0||j!==0)&&m.every(X=>{if(!o())return false;const V=((X.x-k.x)*H+(X.y-k.y)*j)*q;return Number.isFinite(V)&&V<=0}))return M(P,E,v,L,T,C)}const O=$n(v,false);if(O===void 0)return false;if(O===0)return true;const N=O*(v.vectorEffect==="non-scaling-stroke"?S:1);return $.every(H=>o()&&H.x+_<=Math.min(P.x1,P.x2)-N+F)||$.every(H=>o()&&H.x-_>=Math.max(P.x1,P.x2)+N-F)||$.every(H=>o()&&H.y+_<=Math.min(P.y1,P.y2)-N+F)||$.every(H=>o()&&H.y-_>=Math.max(P.y1,P.y2)+N-F)}const G=$n(v,["polygon","polyline","path"].includes(P.kind));if(G===void 0)return false;if(A)_=G*(v.vectorEffect==="non-scaling-stroke"?S:1);else if(G>0&&Pn(v.opacity)!==0&&Pn(v.strokeOpacity)!==0&&!(n&&w&&E>0)&&po(T,t))return false;const I=!A&&n&&w?Math.max(0,E/2):0;if(P.kind==="rect"){const O=Math.min(P.width/2,P.rx??P.ry??0),N=Math.min(P.height/2,P.ry??P.rx??0);if(O>0&&N>0){const H=!c.transform&&EC(e.primitive)&&d.every((U,te)=>U===[1,0,0,1,0,0][te])&&Number(Ue(E))===E&&Number.parseFloat(Xn("stroke-width",v.strokeWidth??"1"))===Number.parseFloat(v.strokeWidth??"1");const j=H&&Number(Ue(P.x))===P.x&&Number(Ue(P.width))===P.width;const q=H&&Number(Ue(P.y))===P.y&&Number(Ue(P.height))===P.height;if(j&&($.every(U=>o()&&U.x+_<=P.x+I+z)||$.every(U=>o()&&U.x-_>=P.x+P.width-I-z))||q&&($.every(U=>o()&&U.y+_<=P.y+I+z)||$.every(U=>o()&&U.y-_>=P.y+P.height-I-z)))return true;const X=P.x+P.width/2,V=P.y+P.height/2;const ee=P.width/2-O,re=P.height/2-N;for(const U of $){if(!o())return false;const te=U.x-X,J=U.y-V;const ae=(te-Math.max(-ee,Math.min(ee,te)))/(O*O);const Q=(J-Math.max(-re,Math.min(re,J)))/(N*N);const K=Math.hypot(ae,Q);if(!K)continue;const Z=ae/K,se=Q/K;const oe=ee*Math.abs(Z)+re*Math.abs(se)+Math.hypot(O*Z,N*se)-I+_;if($.every(de=>o()&&(de.x-X)*Z+(de.y-V)*se>=oe-z))return true}return false}}if(P.kind==="ellipse"||P.kind==="circle"){const O=P.kind==="circle"?P.r:P.rx,N=P.kind==="circle"?P.r:P.ry;if(!(O>0&&N>0))return false;if(P.kind==="circle"){const H=Math.max(Math.min(...$.map(q=>q.x)),Math.min(P.cx,Math.max(...$.map(q=>q.x))));const j=Math.max(Math.min(...$.map(q=>q.y)),Math.min(P.cy,Math.max(...$.map(q=>q.y))));if(Math.hypot(H-P.cx,j-P.cy)>=O-I+_-z)return true}for(const H of $){if(!o())return false;const j=(H.x-P.cx)/(O*O),q=(H.y-P.cy)/(N*N),X=Math.hypot(j,q);if(!X)continue;const V=j/X,ee=q/X;const re=Math.hypot(O*V,N*ee)-I+_;if($.every(U=>o()&&(U.x-P.cx)*V+(U.y-P.cy)*ee>=re-z))return true}return false}const D=P.kind==="rect"?[{x:P.x,y:P.y},{x:P.x+P.width,y:P.y},{x:P.x+P.width,y:P.y+P.height},{x:P.x,y:P.y+P.height}]:P.kind==="polygon"?P.points:void 0;if(!D||D.length<3||D.length>64)return false;const B=(O,N,H)=>(N.x-O.x)*(H.y-O.y)-(N.y-O.y)*(H.x-O.x);const Y=D.reduce((O,N,H)=>{const j=D[(H+1)%D.length];return O+N.x*j.y-j.x*N.y},0);const W=Math.sign(Y);if(!W||!D.every((O,N)=>D.every(H=>o()&&W*B(O,D[(N+1)%D.length],H)>=-(A||l?0:1e-8))))return false;return D.some((O,N)=>{const H=D[(N+1)%D.length],j=Math.hypot(H.x-O.x,H.y-O.y);return j>0&&$.every(q=>o()&&W*B(O,H,q)<=(I-_+z)*j)})};if(n)C=s?.find(P=>o()&&M(u,e.borderWidth??0,f,true,e.bounds,P));w=C!==void 0;if(w&&k&&u.kind==="compound"&&d.every((P,E)=>P===[1,0,0,1,0,0][E])){const P=u.children[0];if(o()&&P?.kind==="rect"&&!P.rx&&!P.ry&&e.partFilled?.[0]&&$n(h?.[0]??f,false)===0){const E=k.x===P.x?1:k.x===P.x+P.width?2:0;const v=u.children[E],L=e.partOwnBorderWidths?.[E]??0;if(E&&v?.kind==="line"&&L>0&&v.x1===v.x2&&v.x1===k.x&&Math.min(v.y1,v.y2)===P.y&&Math.max(v.y1,v.y2)===P.y+P.height&&k.y>P.y&&k.y<P.y+P.height&&m.every(T=>o()&&(E===1?-1:1)*(T.x-v.x1)>=x-L/2))R=[P,v]}}return M(u)}function pB(e,t,n,i){const{position:r,anchor:o}=n;for(let M=0;M<18;M++)if(!i())return void 0;if(!t||r==="mid"||e.transform||e.route.closed||e.stroke.nonScaling||t.overflow==="visible"||(t.scale??1)!==1||t.paint?.vectorEffect==="non-scaling-stroke"||t.orient!==void 0&&t.orient!=="auto"&&t.orient!=="auto-start-reverse"||!t.size||!t.ref||!(t.size.width>0)||!(t.size.height>0)||!Number.isFinite(t.size.width+t.size.height+t.ref.x+t.ref.y)||t.ref.y<0||t.ref.y>t.size.height||t.ref.x!==0&&t.ref.x!==t.size.width||t.viewBox&&(t.viewBox.x!==0||t.viewBox.y!==0||t.viewBox.width!==t.size.width||t.viewBox.height!==t.size.height))return void 0;const s=e.route.geometry;let a,l;const c=(M,P)=>{if(!i()||!Number.isFinite(M)||!Number.isFinite(P))return false;if(!a)a={x:M,y:P};else if(M!==a.x||P!==a.y){l={x:M,y:P};return false}return true};if(s.kind==="line"){if(!c(r==="start"?s.x1:s.x2,r==="start"?s.y1:s.y2))return void 0;c(r==="start"?s.x2:s.x1,r==="start"?s.y2:s.y1)}else if(s.kind==="polyline"){for(let M=0;M<s.points.length;M++){const P=s.points[r==="start"?M:s.points.length-M-1];if(!c(P.x,P.y))break}}else return void 0;if(!a||!l||a.x!==o.x||a.y!==o.y||a.x!==l.x&&a.y!==l.y)return void 0;const d=M=>({x:Number(Ue(M.x)),y:Number(Ue(M.y))});const u=d(a),f=d(l);const h=a.y===l.y;if(![u.x,u.y,f.x,f.y].every(Number.isFinite)||h&&(u.x!==a.x||u.y!==f.y||Math.sign(f.x-u.x)!==Math.sign(l.x-a.x))||!h&&(u.y!==a.y||u.x!==f.x||Math.sign(f.y-u.y)!==Math.sign(l.y-a.y)))return void 0;let m=1;if(t.units!=="userSpaceOnUse"){const M=String(e.stroke.width);if(!/^\s*(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test(M))return void 0;m=Number.parseFloat(typeof e.stroke.width==="number"?Ue(e.stroke.width):Xn("stroke-width",e.stroke.width));if(!(m>0)||!Number.isFinite(m)||m!==Number.parseFloat(M))return void 0}const p=r==="start"?u:f,g=r==="start"?f:u;const y={x:g.x-p.x,y:g.y-p.y};const b=jr({route:{geometry:{kind:"line",x1:p.x,y1:p.y,x2:g.x,y2:g.y},closed:false,contours:[{start:p,end:g,closed:false,startTangent:y,endTangent:y}]},stroke:{width:m},markers:{mid:[],...r==="start"?{start:t}:{end:t}}})[0];if(!i()||!b?.bounds||!n.bounds)return void 0;const S=ra(n.bounds,b.bounds);const x=r==="end"?-1:t.orient==="auto-start-reverse"?-1:1;const k=t.ref.x===0?1:-1;const w=Math.sign(l.x-a.x)*x*k;const C=Math.sign(l.y-a.y)*x*k;if(!i())return void 0;const R={x0:w>0?Math.max(S.x0,b.anchor.x):S.x0,y0:C>0?Math.max(S.y0,b.anchor.y):S.y0,x1:w<0?Math.min(S.x1,b.anchor.x):S.x1,y1:C<0?Math.min(S.y1,b.anchor.y):S.y1};return R.x0<=R.x1&&R.y0<=R.y1?{region:{...b,bounds:S},clipped:R}:void 0}function gB(e,t,n,i){if(!e||!t||e.geometry?.kind!=="polygon"||(e.scale??1)>1||Pn(e.paint?.opacity)!==1||Pn(e.paint?.fillOpacity)!==1||!e.paint?.fill)return void 0;const r=n(e.paint.fill);if(!r||Vt(r)?.[3]!==1)return void 0;const o=e.geometry.points;if(o.length<3||o.length>64||o.length!==t.length)return void 0;const s=o.reduce((h,m,p)=>{const g=o[(p+1)%o.length];return h+m.x*g.y-g.x*m.y},0);const a=Math.sign(s);if(!a||!o.every((h,m)=>o.every(p=>i()&&a*((o[(m+1)%o.length].x-h.x)*(p.y-h.y)-(o[(m+1)%o.length].y-h.y)*(p.x-h.x))>=0)))return void 0;const l=h=>({x:h.reduce((m,p)=>m+p.x,0)/h.length,y:h.reduce((m,p)=>m+p.y,0)/h.length});const c=l(o),d=l(t);const u=e.viewBox??(e.size?{x:0,y:0,width:e.size.width,height:e.size.height}:void 0);const f=[];for(let h=-1,m=o.length;h<m;h++){if(!i())continue;const p=h<0?c:{x:(c.x+o[h].x)/2,y:(c.y+o[h].y)/2};if(e.overflow!=="visible"&&(!u||!(p.x>u.x&&p.x<u.x+u.width&&p.y>u.y&&p.y<u.y+u.height)))continue;f.push(h<0?d:{x:(d.x+t[h].x)/2,y:(d.y+t[h].y)/2})}return f}function yB(e,t,n,i){if(t?.length)return true;if(!e?.geometry||Pn(e.paint?.opacity)!==1)return false;const r=e.viewBox??(e.size?{x:0,y:0,width:e.size.width,height:e.size.height}:void 0);const o=c=>Number.isFinite(c.x)&&Number.isFinite(c.y)&&(e.overflow==="visible"||!!r&&c.x>r.x&&c.x<r.x+r.width&&c.y>r.y&&c.y<r.y+r.height);const s=c=>{if(!c||!i())return false;const d=n(c);return!!d&&Vt(d)?.[3]===1};const a=e.geometry;if(Pn(e.paint?.fillOpacity)===1&&s(e.paint?.fill)){if(a.kind==="circle"&&a.r>0&&o({x:a.cx,y:a.cy}))return true;if(a.kind==="ellipse"&&a.rx>0&&a.ry>0&&o({x:a.cx,y:a.cy}))return true;if(a.kind==="rect"&&a.width>0&&a.height>0&&o({x:a.x+a.width/2,y:a.y+a.height/2}))return true}if(Pn(e.paint?.strokeOpacity)!==1||!s(e.paint?.stroke)||e.paint?.strokeDasharray||!(Number.parseFloat(e.paint?.strokeWidth??"1")>0)||$n(e.paint??{},true)===void 0)return false;const l=(c,d)=>i()&&Math.hypot(d.x-c.x,d.y-c.y)>0&&o({x:(c.x+d.x)/2,y:(c.y+d.y)/2});if(a.kind==="line")return l({x:a.x1,y:a.y1},{x:a.x2,y:a.y2});if(a.kind==="polygon"||a.kind==="polyline")return a.points.length<=64&&a.points.some((c,d)=>d>0&&l(a.points[d-1],c));if(a.kind==="path"){let c=false;const d=ps(a.d,u=>{if(u.line&&l(u.line[0],u.line[1]))c=true;return i()},i);return d&&c}return false}function tb(e,t,n,i,r,o=void 0){const s=W=>{for(let O=0;O<W;O++)if(!r())return false;return true};if(!s(3)||!n||i==="mid"||n.geometry?.kind!=="polygon"&&n.geometry?.kind!=="polyline"||n.geometry.points.length<3||n.geometry.points.length>64||t.transform||n.geometry.kind==="polyline"&&n.paint?.strokeLinecap!==void 0&&!["butt","round"].includes(n.paint.strokeLinecap)||t.route.closed||t.stroke.nonScaling||t.stroke.mixBlendMode&&t.stroke.mixBlendMode!=="normal"||(n.scale??1)!==1||n.paint?.vectorEffect==="non-scaling-stroke"||n.paint?.strokeLinejoin&&!["miter","round","bevel"].includes(n.paint.strokeLinejoin)||!n.size||!n.ref||!(n.size.width>0)||!(n.size.height>0)||!Number.isFinite(n.size.width+n.size.height+n.ref.x+n.ref.y)||n.viewBox&&(!(n.viewBox.width>0)||!(n.viewBox.height>0)||!Number.isFinite(n.viewBox.x+n.viewBox.y+n.viewBox.width+n.viewBox.height)))return void 0;const a=String(t.stroke.width);if(!/^\s*(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test(a))return void 0;const l=W=>Number(Ue(W));const c=Number.parseFloat(typeof t.stroke.width==="number"?Ue(t.stroke.width):Xn("stroke-width",t.stroke.width));if(!(c>0)||!Number.isFinite(c)||!s(12+5*n.geometry.points.length))return void 0;const d=t.route.geometry;let u,f;const h=(W,O)=>{if(!r())return false;const N={x:l(W),y:l(O)};if(!Number.isFinite(N.x)||!Number.isFinite(N.y))return false;if(!u)u=N;else if(N.x!==u.x||N.y!==u.y){f=N;return false}return true};if(d.kind==="line"){h(i==="start"?d.x1:d.x2,i==="start"?d.y1:d.y2);h(i==="start"?d.x2:d.x1,i==="start"?d.y2:d.y1)}else if(d.kind==="polyline"){for(let W=0;W<d.points.length;W++){const O=d.points[i==="start"?W:d.points.length-W-1];if(!h(O.x,O.y))break}}else return void 0;if(!u||!f||!r()||u.x!==f.x&&u.y!==f.y)return void 0;const m=n.geometry.points;const p=n.geometry.kind==="polygon"?n:{...n,geometry:{kind:"polygon",points:m}};const g=i==="start"?{x:f.x-u.x,y:f.y-u.y}:{x:u.x-f.x,y:u.y-f.y};const y=i==="start"?u:f,b=i==="start"?f:u;const S={kind:"line",x1:y.x,y1:y.y,x2:b.x,y2:b.y};const x=jr({route:{...t.route,geometry:S,contours:[{start:y,end:b,closed:false,startTangent:g,endTangent:g}]},stroke:{...t.stroke,width:c},markers:{mid:[],...i==="start"?{start:p}:{end:p}}})[0];const k=x?.hull;if(!k||k.length!==m.length||!s(k.length))return void 0;let w=0;for(let W=0;W<k.length;W++){const O=k[W],N=k[(W+1)%k.length];for(const H of k){if(!r())return void 0;const j=(N.x-O.x)*(H.y-O.y)-(N.y-O.y)*(H.x-O.x);if(!Number.isFinite(j))return void 0;if(j){if(w&&Math.sign(j)!==w)return void 0;w||=Math.sign(j)}}}if(!w)return void 0;const C=p.viewBox??(p.size?{x:0,y:0,...p.size}:void 0);const R=W=>p.overflow==="visible"||!!C&&W.x>C.x&&W.x<C.x+C.width&&W.y>C.y&&W.y<C.y+C.height;const M=n.paint??{};const P=W=>{if(!W||!r())return void 0;const O=o?o(W):rm(W,e.colors);return O?Vt(O)??void 0:void 0};const E=P(M.fill),v=P(M.stroke);const L=Pn(M.opacity);const T=M.fill==="none"||L<1||!!E&&E[3]<1?"absent":E?.[3]===1&&L===1&&m.every(W=>r()&&R(W))?"opaque":"unknown";const A=M.stroke===void 0||M.stroke==="none"||L===0||v?.[3]===0;const $=M.strokeWidth??"1";const _=/^\s*(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test($)?Number.parseFloat($):void 0;const z=(p.units==="userSpaceOnUse"?1:c)*(p.viewBox&&p.size?Math.min(p.size.width/p.viewBox.width,p.size.height/p.viewBox.height):1);const F=A?0:_!==void 0&&Number.isFinite(_*z)?_*z/2:void 0;const G=A||_===0?"absent":_!==void 0&&_>0&&v?.[3]===1&&L===1&&!M.strokeDasharray?"visible":"unknown";const I=[];if(!A&&_!==void 0&&_>0&&v?.[3]===1&&L===1&&!M.strokeDasharray){for(let N=0;N<m.length-(n.geometry.kind==="polyline"?1:0);N++){const H=m[N],j=m[(N+1)%m.length];if(H.x===j.x&&H.y===j.y)continue;for(let q=1;q<4;q++){if(!s(3))return void 0;const X=q/4,V={x:H.x*(1-X)+j.x*X,y:H.y*(1-X)+j.y*X};if(R(V))I.push({x:k[N].x*(1-X)+k[(N+1)%k.length].x*X,y:k[N].y*(1-X)+k[(N+1)%k.length].y*X})}}const W=n.geometry.kind==="polygon"?0:1;const O=m.length-(n.geometry.kind==="polygon"?0:1);for(let N=W;N<O;N++){if(!s(2))return void 0;const H=m[(N+m.length-1)%m.length],j=m[N],q=m[(N+1)%m.length];if((H.x!==j.x||H.y!==j.y)&&(j.x!==q.x||j.y!==q.y)&&R(j))I.push(k[N])}}let D=false;if(n.overflow==="hidden"){if(!s(5))return void 0;D=n.viewBox?.x===0&&n.viewBox.y===0&&n.viewBox.width===n.size.width&&n.viewBox.height===n.size.height}let B;if((n.overflow==="visible"||D)&&(n.orient===void 0||n.orient==="auto"||n.orient==="auto-start-reverse")&&T!=="unknown"&&G!=="unknown"&&L===1&&(n.geometry.kind==="polygon"||M.fill==="none"||E?.[3]===0)&&!M.strokeDasharray&&(M.strokeLinecap===void 0||M.strokeLinecap==="butt")&&(M.strokeLinejoin===void 0||M.strokeLinejoin==="miter")&&(M.strokeMiterlimit===void 0||Number(M.strokeMiterlimit)===4)){if(D&&!s(16))return void 0;const W=D?{id:n.id,shape:n.shape,geometry:n.geometry,paint:n.paint,units:n.units,size:n.size,ref:n.ref,orient:n.orient,viewBox:n.viewBox,scale:n.scale,overflow:"visible"}:n;B={marker:W,anchor:u,tangent:g,position:i,width:c}}if(B&&!r())return void 0;if(!s(6))return void 0;const Y={resource:x.repaint,anchor:u,geometry:n.geometry.kind};return{repaint:Y,hull:k,fill:T,stroke:G,fillColor:E,strokeColor:v,innerStroke:F,strokeWitnesses:I,padding:x.padding,...B?{paintPieceSource:B}:{}}}function GC(e,t){const n=e.marker.geometry;if(n.kind!=="polygon"&&n.kind!=="polyline")return void 0;const i=n.points,r=n.kind==="polygon"?i.length:i.length-2;for(let a=0;a<r;a++){for(let S=0;S<8;S++)if(!t())return void 0;const l=n.kind==="polygon"?a:a+1;const c=i[(l+i.length-1)%i.length],d=i[l],u=i[(l+1)%i.length];const f=d.x-c.x,h=d.y-c.y,m=u.x-d.x,p=u.y-d.y;const g=Math.hypot(f,h),y=Math.hypot(m,p),b=f/g*(m/y)+h/g*(p/y);if(!(g>0)||!(y>0)||!Number.isFinite(b)||b<=-.875+128*Number.EPSILON)return void 0}const o={};let s;try{s=Do(e.marker,e.anchor,e.tangent,e.position,e.width,()=>{if(!t())throw o})}catch(a){if(a===o)return void 0;throw a}for(const a of s){if(!t()||a.kind!=="polygon"||a.points.length<3)return void 0;let l=0;for(let c=0;c<a.points.length;c++){if(!t())return void 0;const d=a.points[c],u=a.points[(c+1)%a.points.length];if(!Number.isFinite(d.x)||!Number.isFinite(d.y))return void 0;l+=(d.x-a.points[0].x)*(u.y-a.points[0].y)-(d.y-a.points[0].y)*(u.x-a.points[0].x)}if(!Number.isFinite(l)||l===0)return void 0}return s}function xB(e,t,n){for(const i of e)for(const r of t){if(!n()||i.kind!=="polygon"||r.kind!=="polygon")return false;let o=false;for(const s of[i.points,r.points]){for(let a=0;a<s.length;a++){if(!n())return false;const l=s[a],c=s[(a+1)%s.length],d=l.y-c.y,u=c.x-l.x,f=Math.hypot(d,u);if(!(f>0)||!Number.isFinite(f))continue;const h=d/f,m=u/f,p=i.points[0];let g=Infinity,y=-Infinity,b=Infinity,S=-Infinity,x=1;for(const w of i.points){if(!n())return false;const C=(w.x-p.x)*h+(w.y-p.y)*m;g=Math.min(g,C);y=Math.max(y,C);x=Math.max(x,Math.abs(w.x),Math.abs(w.y))}for(const w of r.points){if(!n())return false;const C=(w.x-p.x)*h+(w.y-p.y)*m;b=Math.min(b,C);S=Math.max(S,C);x=Math.max(x,Math.abs(w.x),Math.abs(w.y))}const k=1e-8+128*Number.EPSILON*x;if(Number.isFinite(g+y+b+S)&&(y+k<b||S+k<g)){o=true;break}}if(o)break}if(!o)return false}return true}function jC(e,t,n){if(!n())return"exhausted";const i=s=>s?.fill==="absent"&&s.stroke==="absent"&&(s.fillColor?.[3]===0||s.paintPieceSource?.marker.paint?.fill==="none");if(i(e)||i(t))return"clear";if(!e?.paintPieceSource||!t?.paintPieceSource)return"unknown";const r={};const o=()=>{if(!n())throw r;return true};try{const s=GC(e.paintPieceSource,o);if(s){const a=GC(t.paintPieceSource,o);if(a&&xB(s,a,o))return"clear"}}catch(s){if(s===r)return"exhausted";throw s}return"unknown"}function nb(e,t,n,i=0){if(!n()||!Number.isSafeInteger(i)||i<0)return"unknown";if(t?.fill==="absent"||e?.stroke==="absent"&&e.fill==="absent")return"clear";if(!e||!t)return"unknown";const r=t.hull;if(e.innerStroke!==void 0){let s=0;for(let a=0;a<e.hull.length;a++){if(!n())return"unknown";const l=e.hull[a],c=e.hull[(a+1)%e.hull.length],d=e.hull[(a+2)%e.hull.length];const u=(c.x-l.x)*(d.y-c.y)-(c.y-l.y)*(d.x-c.x);if(u){s=Math.sign(u);break}}if(s)for(let a=0;a<e.hull.length;a++){if(!n())return"unknown";const l=e.hull[a],c=e.hull[(a+1)%e.hull.length],d=c.x-l.x,u=c.y-l.y,f=Math.hypot(d,u);if(!f)continue;let h=true;for(const m of r){if(!n())return"unknown";const p=s*(d*(m.y-l.y)-u*(m.x-l.x))/f;const g=1e-8+64*Number.EPSILON*Math.max(1,Math.abs(m.x),Math.abs(m.y),Math.abs(l.x),Math.abs(l.y),Math.abs(c.x),Math.abs(c.y));if(!Number.isFinite(p)||p>=-e.innerStroke-g){h=false;break}}if(h)return"clear"}}if(e.padding!==void 0&&Number.isFinite(e.padding)){for(const s of[e.hull,r])for(let a=0;a<s.length;a++){if(!n())return"unknown";const l=s[a],c=s[(a+1)%s.length],d=c.y-l.y,u=l.x-c.x,f=Math.hypot(d,u);if(!f)continue;let h=Infinity,m=-Infinity,p=Infinity,g=-Infinity;for(const y of e.hull){if(!n())return"unknown";const b=(y.x-l.x)*d+(y.y-l.y)*u;h=Math.min(h,b);m=Math.max(m,b)}for(const y of r){if(!n())return"unknown";const b=(y.x-l.x)*d+(y.y-l.y)*u;p=Math.min(p,b);g=Math.max(g,b)}if(m+e.padding*f<p||g<h-e.padding*f)return"clear"}}if(e.paintPieceSource&&t.paintPieceSource){const s=jC(e,t,n);if(s==="clear")return"clear";if(s==="exhausted")return"unknown"}if(e.stroke!=="visible"||t.fill!=="opaque"||t.innerStroke===void 0)return"unknown";if(!e.strokeColor||!t.fillColor)return"unknown";let o=true;for(let s=0;s<3;s++){if(!n())return"unknown";if(e.strokeColor[s]!==t.fillColor[s])o=false}if(o)return"unknown";for(let s=i;s<e.strokeWitnesses.length;s++){if(!n())return"unknown";const a=e.strokeWitnesses[s];let l=0,c=true;for(let d=0;d<r.length;d++){if(!n())return"unknown";const u=r[d],f=r[(d+1)%r.length],h=f.x-u.x,m=f.y-u.y,p=Math.hypot(h,m);const g=h*(a.y-u.y)-m*(a.x-u.x);const y=1e-8+64*Number.EPSILON*Math.max(1,Math.abs(a.x),Math.abs(a.y),Math.abs(u.x),Math.abs(u.y),Math.abs(f.x),Math.abs(f.y));if(!Number.isFinite(g)||!p||Math.abs(g)/p<=t.innerStroke+y||l&&Math.sign(g)!==l){c=false;break}l||=Math.sign(g)}if(c&&l)return a}return"unknown"}function bB(e,t,n){if(!e||e.innerStroke===void 0)return false;const i=e.hull;let r=0;for(let o=0;o<i.length;o++){if(!n())return false;const s=i[o],a=i[(o+1)%i.length],l=i[(o+2)%i.length];const c=(a.x-s.x)*(l.y-a.y)-(a.y-s.y)*(l.x-a.x);if(c){r=Math.sign(c);break}}if(!r)return false;for(let o=0;o<i.length;o++){if(!n())return false;const s=i[o],a=i[(o+1)%i.length],l=a.x-s.x,c=a.y-s.y;const d=Math.hypot(l,c),u=r*(l*(t.y-s.y)-c*(t.x-s.x))/d;const f=1e-8+64*Number.EPSILON*Math.max(1,Math.abs(t.x),Math.abs(t.y),Math.abs(s.x),Math.abs(s.y),Math.abs(a.x),Math.abs(a.y));if(Number.isFinite(u)&&u<-e.innerStroke-f)return true}return false}function SB(e,t,n){if(!n()||!t)return true;if(t.geometry?.kind==="line"||t.paint?.fill==="none"||t.paint?.fill==="transparent"||Pn(t.paint?.opacity)<1)return false;const i=t.paint?.fill;if(!i||!n())return true;const r=e(i),o=r?Vt(r):null;return!o||o[3]===1}function wB(e,t,n){const i=e?.paint;if(!n()||!i||!Number.isFinite(Pn(i.opacity))||$n(i,true)===void 0||i.strokeDasharray!==void 0&&i.strokeDasharray!=="none"||i.strokeDashoffset!==void 0||i.paintOrder!==void 0&&i.paintOrder!=="normal")return void 0;if(!i.fill||!i.stroke||!n())return void 0;const r=t(i.fill);if(!r||r!=="none"&&!Vt(r)||!n())return void 0;const o=t(i.stroke);if(!o||o!=="none"&&!Vt(o))return void 0;return`${r}\0${o}`}function MB(e,t){const[n,i]=e;let r=0,o=1;for(const[s,a,l,c]of[[n.x,i.x-n.x,t.x0,t.x1],[n.y,i.y-n.y,t.y0,t.y1]]){if(Math.abs(a)<1e-12){if(s<=l+1e-8||s>=c-1e-8)return false}else{const d=(l-s)/a,u=(c-s)/a;r=Math.max(r,Math.min(d,u));o=Math.min(o,Math.max(d,u))}}return(o-r)*Math.hypot(i.x-n.x,i.y-n.y)>1e-8}var YC=new Set(["node","service","class-box","entity"]);var kB=new Set([...YC,"group","note","actor","junction"]);function qC(e,t,n={}){return ib(e,vC(e),t,n)}function ib(e,t,n,i={}){const r=[];let o=false,s=false;const a=(I,D=false)=>{if(r.length<dB)r.push(Object.freeze(I));if(D)o=true;else s=true};const l=(I,D,B)=>a({code:"POTENTIAL_OCCLUSION",id:I,by:D,message:B});const c=(I,D,B=false)=>a({code:"UNMEASURED_PAINT",id:I,message:D},B);const d=I=>a({code:"OUTPUT_SCOPE",message:I});const u=_C(t);if(u&&e!==u.header){d("Retained emission is paired with a different document header");e=u.header}let f=0,h=0,m=e.width,p=e.height,g=0;for(const I of t.primitives){if(!u&&NC(I))d("Native paint occurrences have no bound emission context");if(I.visibility==="conditional"){g++;continue}if(I.coverage==="unmeasured")c(I.id,I.reason??"Paint geometry is unavailable");if(I.text&&I.coverage!=="non-painting"&&I.text.measurement!=="prepared")a({code:"UNPREPARED_TEXT",id:I.id,message:"Text was not retained from layout preparation"});const D=I.bounds;if(D){f=Math.min(f,D.x0);h=Math.min(h,D.y0);m=Math.max(m,D.x1);p=Math.max(p,D.y1)}}if(g)a({code:"CONDITIONAL_PAINT",message:`${g} primitives depend on unresolved paint or interaction state`});if(i.outputSupported===false||e.family.startsWith("family:"))d("Selected backend, style or external family has no native final-paint proof");f=Math.min(0,f+Dc);h=Math.min(0,h+Dc);m=Math.max(e.width,m-Dc);p=Math.max(e.height,p-Dc);const y=f<0||h<0||m>e.width||p>e.height;const b={x:Math.floor(f),y:Math.floor(h),width:Math.ceil(m)-Math.floor(f),height:Math.ceil(p)-Math.floor(h)};if(y&&e.width>0&&e.height>0){const I=e.width/e.height;if(b.width/b.height>I)b.height=b.width/I;else b.width=b.height*I}const S=Object.freeze(y?b:{x:0,y:0,width:e.width,height:e.height});const x=fB(S);if(y&&t.primitives.some(I=>{const D=Ss(I);return D?.kind==="connector"?D.stroke.nonScaling:D?.kind==="shape"||D?.kind==="text"?D.paint.vectorEffect==="non-scaling-stroke":false}))d("Viewport expansion changes the user-unit extent of non-scaling strokes; final painted containment is unverified");let k=0;const w=(I,D,B)=>{k++;if(!D||!B){c(I,"Projected label has no retained occupied or available region");return}let Y=OC(B);if(Y.x0===0&&Y.y0===0&&Y.x1===e.width&&Y.y1===e.height)Y=x;if(!Oc(Y,OC(D),uB))a({code:"LABEL_CONTAINMENT",id:I,message:"Retained text extends beyond its declared available region"},true)};if(n){for(const I of n.nodes)if(I.label?.trim()&&I.labelVisibility!=="hidden"&&I.labelVisibility!=="semantic")w(String(I.id),I.labelBounds,I.labelContainer);for(const I of n.labels??[])if(I.text.trim()&&I.visibility!=="hidden"&&I.visibility!=="semantic")w(I.id,I.bounds,I.container)}const C=eb(mB(e,t.primitives));if(u?.uncertain)d("Emitted document context or marker resource differs from retained paint evidence");let R=0,M=u?.operations??0,P=u?.exhausted??false;const E=()=>{if(M>=ws){P=true;return false}M++;return true};const v=new Map;for(const I of t.primitives){if(P)break;for(const D of[I.owner,...I.ancestors]){if(!E())break;if(!kB.has(D.role))continue;const B=v.get(D.id)??new Set;B.add(D.role);v.set(D.id,B)}}const L=(I,D)=>{let B=false;for(const[Y,W]of[[I.endpoints.from,I.endpoints.start],[I.endpoints.to,I.endpoints.end]]){if(Y!==D.id)continue;if(W?.owner){if(W.owner.id!==Y){B=true;continue}if(W.owner.role===D.role)return"attached"}else if((v.get(Y)?.size??0)>1)B=true;else return"attached"}return B?"ambiguous":"unrelated"};const T=(I,D)=>{if(P||!E()||!I||!po(I.bounds,D.bounds))return;if(!I.leaves){T(I.left,D);T(I.right,D);return}for(const B of I.leaves){if(!E())return;if(++R>Oo){P=true;return}if(B.primitive.order<=D.order||!po(B.bounds,D.bounds))continue;if(B.interiors?.some(Y=>E()&&Oc(Y,D.bounds)))a({code:"TEXT_OCCLUDED",id:D.id,by:B.primitive.id,message:`Retained text is fully covered by later opaque artwork owned by ${B.primitive.owner.id}`},true);else l(D.id,B.primitive.id,"Later filled artwork overlaps the occupied text band; its exact ink intersection is unverified")}};for(const I of t.primitives)if(I.kind==="text"&&I.coverage==="measured"&&I.visibility!=="conditional")T(C,I);const A=new Map;for(const I of t.primitives){if(!E())break;const D=Ss(I);if(D?.kind!=="connector"||!["edge","relationship"].includes(I.role)||D.lineStyle==="invisible"||I.visibility==="conditional"||I.coverage!=="measured")continue;const B=Number.parseFloat(String(D.stroke.width)),Y=Number(D.stroke.opacity??1);if(B===0||Y===0||D.stroke.color==="none"||D.stroke.color==="transparent")continue;if(!A.has(D.stroke.color)){const ae=rm(D.stroke.color,e.colors);A.set(D.stroke.color,ae?Vt(ae)?.[3]:void 0)}const W=A.get(D.stroke.color);if(W===0)continue;const O=i.outputSupported!==false&&!e.family.startsWith("family:")&&!!D.endpoints?.from&&!!D.endpoints.to&&W!==void 0&&W>0&&B>0&&Y>0&&!D.stroke.dash;const N=sa(I);const[H,j,q,X,V,ee]=N;const re={kind:"matrix",a:H,b:j,c:q,d:X,e:V,f:ee};const U=$n({stroke:D.stroke.color,strokeWidth:String(D.stroke.width),strokeLinecap:D.stroke.lineCap,strokeLinejoin:D.stroke.lineJoin,strokeMiterlimit:String(D.stroke.miterLimit)},$1(D.route));if(U===void 0){c(I.id,"Final connector stroke has no bounded cap/join extent");continue}const te=ae=>{if(!E())return false;const Q=D.stroke.nonScaling?Fc(Nc(ae.bounds,re),U):Nc(Fc(ae.bounds,U),re);const K=ae.line?.map(se=>ml(se,N));const Z=se=>{if(P||!E()||!se||!po(se.bounds,Q))return;if(!se.leaves){Z(se.left);Z(se.right);return}for(const oe of se.leaves){if(!E())return;if(++R>Oo){P=true;return}const de=O&&oe.primitive.role==="note"&&!!oe.interiors?.length;if(!YC.has(oe.primitive.role)&&!de||oe.primitive.owner.id===I.owner.id&&oe.primitive.owner.role===I.owner.role||!po(oe.bounds,Q))continue;const xe=L(D,oe.primitive.owner);if(xe==="attached")continue;if(O&&K&&hB(K,oe.bounds,D.stroke,B,U,N,E))continue;if(O&&xe==="unrelated"&&K&&oe.interiors?.some(Me=>E()&&MB(K,Me)))a({code:"CONNECTOR_CARD_CROSSING",id:I.id,by:oe.primitive.id,message:`Final connector shaft crosses opaque artwork owned by unrelated ${de?"note":"card"} ${oe.primitive.owner.id}`},true);else l(I.id,oe.primitive.id,de?"Final connector envelope intersects unrelated filled note artwork; actual route/note crossing is unverified":"Final connector envelope intersects unrelated filled card artwork; actual route/card crossing is unverified")}};Z(C);return!P};const J=D.route.geometry;if(J.kind==="path"){if(!ps(J.d,te,E)&&!P)c(I.id,"Final connector segments could not be measured from typed path geometry")}else{const ae=J.kind==="line"?[{x:J.x1,y:J.y1},{x:J.x2,y:J.y2}]:J.points;for(let Q=1;Q<ae.length;Q++){const K=ae[Q-1],Z=ae[Q];if(!te({bounds:{x0:Math.min(K.x,Z.x),y0:Math.min(K.y,Z.y),x1:Math.max(K.x,Z.x),y1:Math.max(K.y,Z.y)},line:[K,Z]}))break}}}const $=new Map;let _;const z=I=>(_??=om())(I,e.colors);for(const I of t.primitives){const D=Ss(I);if(I.kind!=="connector"||D?.kind!=="connector"||D.lineStyle==="invisible"||I.coverage==="non-painting")continue;const B=nm(wu(D.transform));if(!B)continue;const[Y,W,O,N,H,j]=hl(sa(I),B);const q={kind:"matrix",a:Y,b:W,c:O,d:N,e:H,f:j};for(const X of jr(D,q)){if(!X.bounds){c(I.id,"Endpoint marker has no painted footprint");continue}const V=JSON.stringify([I.owner.id,I.owner.role,X.position,X.resource,X.anchor,X.repaint]);const ee=typeof D.stroke.width==="number"?Number.isFinite(D.stroke.width)&&D.stroke.width>0:/^\s*(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test(D.stroke.width)&&Number.parseFloat(D.stroke.width)>0;const re=X.position==="start"?D.markers.start:X.position==="end"?D.markers.end:D.markers.mid.length===1?D.markers.mid[0]:void 0;const U=I.coverage==="measured"&&!!nm(sa(I));const te=re?.units==="userSpaceOnUse"||ee;const J=$.get(V);const ae=i.outputSupported!==false&&!e.family.startsWith("family:")&&(["edge","relationship"].includes(I.role)&&!!D.endpoints?.from&&!!D.endpoints.to||J?.semantic===true);const Q=sa(I);const K=I.coverage==="measured"&&I.visibility!=="conditional"&&(I.groupOpacity??1)===1&&I.ancestors.length===0&&!!Q&&Q[0]===1&&Q[1]===0&&Q[2]===0&&Q[3]===1&&Q[4]===0&&Q[5]===0;const Z=ae&&K&&te?pB(D,re,X,E):void 0;const se=Z?.region??X;const oe=U&&te?gB(re,se.hull,z,E):void 0;const de=U&&te&&re?.paint?.vectorEffect!=="non-scaling-stroke"&&yB(re,oe,z,E);const xe=SB(z,re,E);const Me=ae&&(I.groupOpacity??1)===1&&I.ancestors.length===0&&(!D.stroke.mixBlendMode||D.stroke.mixBlendMode==="normal")?wB(re,z,E):void 0;const Ce=ae&&K?tb(e,D,re,X.position,E,z):void 0;$.set(V,{primitive:I,position:X.position,clipped:Z?.clipped,anchor:se.anchor,repaint:se.repaint,bounds:se.bounds,hull:se.hull,padding:se.padding,witnesses:oe,actualInk:de,strokeProof:Ce,paintIdentity:Me,semantic:ae,mayFill:xe})}}const F=(I,D)=>{if(D.primitive.visibility==="conditional")return;if(P||!E()||!I||!po(I.bounds,D.bounds))return;if(!I.leaves){F(I.left,D);F(I.right,D);return}for(const B of I.leaves){if(!E())return;if(++R>Oo){P=true;return}if(B.primitive.order<=D.primitive.order||!po(B.bounds,D.bounds))continue;if(D.actualInk&&(B.interiors?.some(O=>E()&&Oc(O,D.bounds))||B.strokeInteriors?.some(O=>E()&&Oc(O,D.bounds)))){a({code:"MARKER_OCCLUDED",id:D.primitive.id,by:B.primitive.id,message:"Endpoint marker is fully covered by later opaque artwork with no owned repaint"},true);continue}const Y=Ss(D.primitive);const W=Y?.kind==="connector"&&L(Y,B.primitive.owner)==="attached";if(zC(B,D.bounds,W,D.hull,D.padding,E,D.witnesses,D.anchor))continue;if(D.clipped&&zC(B,D.clipped,W,void 0,0,E,D.witnesses,D.anchor,true))continue;l(D.primitive.id,B.primitive.id,"Later filled artwork overlaps an endpoint marker; its exact ink intersection is unverified")}};const G=Array.from($.values());for(let I=0;I<G.length;I++)F(C,G[I]);for(let I=0;I<G.length;I++){const D=G[I];if(!E())break;if(!D.semantic||D.primitive.visibility==="conditional"||D.strokeProof?.fill==="absent"&&D.strokeProof.stroke==="absent")continue;const B=t.primitives;for(let Y=0;Y<B.length;Y++){const W=B[Y];if(!E())break;if(W.kind!=="text"||W.coverage!=="measured"||W.visibility==="conditional"||!W.bounds||!po(W.bounds,D.bounds))continue;if(++R>Oo){P=true;break}const O=D.primitive.order>W.order;l(O?W.id:D.primitive.id,O?D.primitive.id:W.id,O?"Later endpoint-marker ink overlaps occupied text; actual text visibility is unverified.":"Later occupied text or its halo overlaps an endpoint marker; actual marker ink visibility is unverified.")}}for(let I=0;I<G.length;I++){const D=G[I];if(P)break;if(!D.semantic||D.primitive.visibility==="conditional")continue;for(let B=0;B<G.length;B++){const Y=G[B];if(!E())break;const W=D.strokeProof?.repaint,O=Y.strokeProof?.repaint;const N=D.paintIdentity!==void 0&&D.paintIdentity===Y.paintIdentity;if(!Y.semantic||Y.primitive.visibility==="conditional"||Y.primitive.order<=D.primitive.order||N&&(D.anchor.x===Y.anchor.x&&D.anchor.y===Y.anchor.y&&D.repaint===Y.repaint||W&&O&&W.resource===O.resource&&W.geometry===O.geometry&&W.anchor.x===O.anchor.x&&W.anchor.y===O.anchor.y)||!po(D.bounds,Y.bounds))continue;if(++R>Oo){P=true;break}let H=0,j="unknown";while(!P){let q=Y.mayFill?nb(D.strokeProof,Y.strokeProof,E,H):jC(D.strokeProof,Y.strokeProof,E);if(q==="exhausted")q="unknown";if(typeof q==="string"){j=q;break}let X=false;const V=t.primitives;for(let U=0;U<V.length;U++){const te=V[U];if(!E())break;const J=te.bounds;if(te.order<=Y.primitive.order||te.coverage==="non-painting")continue;if(!J){X=true;break}if(J.x0>q.x||q.x>J.x1||J.y0>q.y||q.y>J.y1)continue;const ae=Ss(te);if(ae?.kind==="connector"&&Number(ae.stroke.opacity)===0){let Q=false;for(let K=0;K<G.length;K++){const Z=G[K];if(!E())break;if(Z.primitive.order!==te.order||Z.bounds.x0>q.x||q.x>Z.bounds.x1||Z.bounds.y0>q.y||q.y>Z.bounds.y1)continue;if(!bB(Z.strokeProof,q,E)){Q=true;break}}if(!Q&&!P)continue}X=true;break}if(!X&&!P){j="covered";break}const ee=D.strokeProof.strokeWitnesses;let re=false;for(;H<ee.length;H++){if(!E())break;if(ee[H]===q){H++;re=true;break}}if(!re)break}if(j==="covered"&&!P)a({code:"MARKER_OCCLUDED",id:D.primitive.id,by:Y.primitive.id,message:"Later opaque endpoint-marker fill covers actual stroke ink of a distinct marker."},true);else if(j==="unknown")l(D.primitive.id,Y.primitive.id,"Distinct endpoint-marker envelopes overlap; actual marker ink separation is unverified.")}}if(P)a({code:"CHECK_BUDGET",message:`Occlusion checking reached its ${Oo}-pair or ${ws}-operation limit`});for(const I of t.primitives)if(I.bounds&&I.visibility!=="conditional"&&!Oc(x,I.bounds,Dc))c(I.id,"Final viewport does not contain retained paint",true);for(const I of G)if(I.primitive.visibility!=="conditional"&&!Oc(x,I.bounds,Dc))c(I.primitive.id,"Final viewport does not contain serialized marker paint",true);return Object.freeze({version:1,unit:"px",scope:"native-scene",status:o?"failed":s?"unverified":"passed",viewport:S,attempts:y?2:1,repairs:Object.freeze(y?["expand-viewport"]:[]),coverage:Object.freeze({measured:t.coverage.measured,unmeasured:t.coverage.unmeasured,preparedText:t.coverage.preparedText,fallbackText:t.coverage.fallbackText,conditional:g}),checks:Object.freeze({primitives:t.primitives.length,labels:k,occlusionPairs:Math.min(R,Oo),maxOcclusionPairs:Oo,operations:M,maxOperations:ws,markers:$.size}),issues:Object.freeze(r),limitations:Object.freeze(["Prepared occupied text regions bound native geometry; exact glyph ink depends on the resolved font.","Declared transparency, intentional data-mark overlap and externally modified CSS are outside this proof."])})}var ym=class extends Error{constructor(n){super(`Final paint certification failed: ${n.issues.map(i=>`${i.id??"scene"}: ${i.message}`).join("; ")}`);this.certification=n;this.name="PaintLayoutCertificationError"}certification;code="PAINT_LAYOUT_CERTIFICATION_FAILED"};var Qe=class extends Error{constructor(n){super(`No certified layout after ${n.length} bounded attempts: ${n.map(i=>`${i.strategy}: ${i.violations.join("; ")}`).join(" | ")}`);this.attempts=n;this.name="LayoutCertificationError"}attempts;code="LAYOUT_CERTIFICATION_FAILED"};var Ei=class extends Error{constructor(n,i){super(`${n} has not loaded`);this.dependency=n;this.load=i}dependency;load};function g7(e){const t=new Set;while(e instanceof Error&&!t.has(e)){if(e instanceof Ei)return e;t.add(e);e=e.cause}return void 0}var XC={schemaVersion:2,provenance:{version:"12.2.0"},families:[{id:"flowchart",headers:[{value:"flowchart",agenticStatus:"native"},{value:"graph",agenticStatus:"native"},{value:"flowchart-elk",agenticStatus:"unsupported"}]},{id:"swimlane",headers:[{value:"swimlane-beta",agenticStatus:"unsupported"}]},{id:"sequence",headers:[{value:"sequenceDiagram",agenticStatus:"native"}]},{id:"class",headers:[{value:"classDiagram",agenticStatus:"native"},{value:"classDiagram-v2",agenticStatus:"native"}]},{id:"state",headers:[{value:"stateDiagram",agenticStatus:"native"},{value:"stateDiagram-v2",agenticStatus:"native"}]},{id:"er",headers:[{value:"erDiagram",agenticStatus:"native"}]},{id:"journey",headers:[{value:"journey",agenticStatus:"native"}]},{id:"gantt",headers:[{value:"gantt",agenticStatus:"native"}]},{id:"pie",headers:[{value:"pie",agenticStatus:"native"}]},{id:"quadrant",headers:[{value:"quadrantChart",agenticStatus:"native"}]},{id:"requirement",headers:[{value:"requirementDiagram",agenticStatus:"native"},{value:"requirement",agenticStatus:"native"}]},{id:"gitgraph",headers:[{value:"gitGraph",agenticStatus:"native"}]},{id:"c4",headers:[{value:"C4Context",agenticStatus:"native"},{value:"C4Container",agenticStatus:"native"},{value:"C4Component",agenticStatus:"native"},{value:"C4Dynamic",agenticStatus:"native"},{value:"C4Deployment",agenticStatus:"native"}]},{id:"mindmap",headers:[{value:"mindmap",agenticStatus:"native"}]},{id:"timeline",headers:[{value:"timeline",agenticStatus:"native"}]},{id:"zenuml",headers:[{value:"zenuml",agenticStatus:"native"}]},{id:"sankey",headers:[{value:"sankey",agenticStatus:"native"},{value:"sankey-beta",agenticStatus:"native"}]},{id:"xychart",headers:[{value:"xychart",agenticStatus:"native"},{value:"xychart-beta",agenticStatus:"native"}]},{id:"block",headers:[{value:"block",agenticStatus:"native"},{value:"block-beta",agenticStatus:"native"}]},{id:"packet",headers:[{value:"packet",agenticStatus:"native"},{value:"packet-beta",agenticStatus:"native"}]},{id:"kanban",headers:[{value:"kanban",agenticStatus:"native"}]},{id:"architecture",headers:[{value:"architecture",agenticStatus:"native"},{value:"architecture-beta",agenticStatus:"native"}]},{id:"radar",headers:[{value:"radar-beta",agenticStatus:"native"}]},{id:"eventmodeling",headers:[{value:"eventmodeling",agenticStatus:"native"}]},{id:"treemap",headers:[{value:"treemap",agenticStatus:"native"},{value:"treemap-beta",agenticStatus:"native"}]},{id:"venn",headers:[{value:"venn-beta",agenticStatus:"unsupported"}]},{id:"ishikawa",headers:[{value:"ishikawa",agenticStatus:"native"},{value:"ishikawa-beta",agenticStatus:"native"}]},{id:"wardley",headers:[{value:"wardley-beta",agenticStatus:"unsupported"}]},{id:"cynefin",headers:[{value:"cynefin-beta",agenticStatus:"unsupported"}]},{id:"treeview",headers:[{value:"treeView-beta",agenticStatus:"unsupported"}]},{id:"railroad",headers:[{value:"railroad-beta",agenticStatus:"unsupported"},{value:"railroad-ebnf-beta",agenticStatus:"unsupported"},{value:"railroad-abnf-beta",agenticStatus:"unsupported"},{value:"railroad-peg-beta",agenticStatus:"unsupported"}]},{id:"agentflow",headers:[{value:"agentflow-beta",agenticStatus:"unsupported"}]},{id:"usecase",headers:[{value:"usecase-beta",agenticStatus:"unsupported"}]}]};var rb=XC;function PB(e){return(e.split(";")[0]??"").trim().toLowerCase()}function EB(e,t){const n=t.trim().toLowerCase();if(e===n)return true;if(!e.startsWith(n))return false;const i=e[n.length];return i!==void 0&&/[\s:]/.test(i)}function UC(e,t=rb){const n=PB(e);const i=t.families.flatMap(r=>r.headers.map(o=>({family:r,header:o}))).sort((r,o)=>o.header.value.length-r.header.value.length||Bn(r.family.id,o.family.id));return i.find(r=>EB(n,r.header.value))??null}var Ms;function ie(e){return Ms?.family===e}function VC(e,t,n,i){const r=Ms;Ms={family:e,observer:t,mutations:i?.mutations?new Set(i.mutations):void 0};try{const o=n();if(o!==null&&typeof o==="object"&&"then"in o&&typeof o.then==="function"){void Promise.resolve(o).catch(()=>{});throw new TypeError("Parser observation scopes must be synchronous")}return o}finally{Ms=r}}function Bc(e,t=new Map,n="$"){if(e===null||e===void 0)return null;if(typeof e==="number")return Number.isFinite(e)?e:{$number:String(e)};if(typeof e==="string"||typeof e==="boolean")return e;if(typeof e!=="object")return String(e);const i=t.get(e);if(i!==void 0)return{$ref:i};t.set(e,n);let r;if(e instanceof Date)r=e.toISOString();else if(e instanceof Map)r=[...e].map(([o,s],a)=>[Bc(o,t,`${n}.${a}.0`),Bc(s,t,`${n}.${a}.1`)]);else if(e instanceof Set)r=[...e].map((o,s)=>Bc(o,t,`${n}.${s}`));else if(Array.isArray(e))r=e.map((o,s)=>Bc(o,t,`${n}.${s}`));else{const o=Object.create(null);for(const[s,a]of Object.entries(e)){if(typeof a!=="function"&&a!==void 0)o[s]=Bc(a,t,`${n}.${s}`)}r=o}t.delete(e);return r}function ob(e,t){const n=Ms;if(!n||n.family!==e)return;Ms=void 0;try{n.observer(t)}finally{Ms=n}}function Ge(e,t,n,i){if(!ie(e))return;ob(e,{family:e,unit:"statement",kind:t,text:n,...i?{source:{...i}}:{}})}function Bo(e,t,n,i){if(!ie(e))return;ob(e,{family:e,unit:"token",kind:t,text:n,...i?{source:{...i}}:{}})}function ue(e,t,n,i){if(!ie(e))return;if(Ms?.mutations&&!Ms.mutations.has(t))return;ob(e,{family:e,unit:"mutation",kind:t,value:Bc(n),...i?{source:{...i}}:{}})}var sb={"zenuml":["upsert_participant","remove_participant","rename_participant","insert_statement","remove_statement","set_statement","set_title","set_accessibility_title","set_accessibility_description"],"eventmodeling":["insert_frame","remove_frame","move_frame","set_frame","set_entities","set_notes","set_specifications","set_data","set_title","set_accessibility_title","set_accessibility_description"],"flowchart":["add_node","remove_node","rename_node","set_label","add_edge","remove_edge","set_shape","set_direction","add_subgraph","remove_subgraph","move_node","define_class","set_node_class","set_node_style"],"state":["add_state","remove_state","rename_state","set_state_label","add_transition","remove_transition","set_transition_label","make_composite","set_direction","move_state","dissolve_composite","add_note","remove_note","set_note_text","add_floating_note","remove_floating_note","set_floating_note_text","define_class","set_state_class","set_state_style","set_transition_style"],"sequence":["add_participant","remove_participant","add_message","remove_message","set_message_text","set_message_wrap","move_message","set_participant_label","add_fragment","remove_fragment","set_fragment_label","add_fragment_branch","set_fragment_branch_label","add_fragment_message","remove_fragment_message","set_fragment_message_text","set_fragment_message_wrap"],"timeline":["set_title","add_section","remove_section","set_section_label","add_period","remove_period","set_period_label","add_event","remove_event","set_event_text","move_period","move_event","move_section","set_accessibility_title","set_accessibility_description"],"class":["set_title","add_class","remove_class","rename_class","set_class_generic","add_member","remove_member","add_interface","add_relation","remove_relation","add_note","remove_note","set_class_namespace","define_class","set_css_class","set_class_style"],"er":["add_entity","remove_entity","rename_entity","set_entity_label","add_attribute","remove_attribute","add_relation","remove_relation","set_direction","define_class","set_entity_class","set_entity_style"],"journey":["set_title","add_section","remove_section","set_section_label","add_task","remove_task","set_task_text","set_task_score","set_task_actors","rename_actor","move_task","move_section","set_accessibility_title","set_accessibility_description"],"architecture":["set_title","set_accessibility_title","set_accessibility_description","add_service","remove_service","rename_service","set_service_label","set_service_icon","set_service_icon_text","move_service","add_junction","remove_junction","rename_junction","move_junction","add_group","set_group_label","remove_group","add_edge","update_edge","remove_edge"],"xychart":["set_title","set_x_axis","set_y_axis","add_series","remove_series","set_series_values","set_series_name","reorder_series","set_orientation","set_data_point"],"pie":["set_title","set_show_data","add_slice","remove_slice","rename_slice","set_slice_value","reorder_slice"],"quadrant":["set_title","set_axis_labels","set_quadrant_label","add_point","remove_point","move_point","rename_point"],"gantt":["set_title","add_section","rename_section","remove_section","add_task","remove_task","rename_task","set_task_status","set_task_dates","set_task_flags","set_task_id","move_task","move_section"],"mindmap":["add_node","remove_node","rename_node","set_label","move_node","set_shape","set_icon","set_node_class","set_accessibility_title","set_accessibility_description"],"gitgraph":["append_commit","create_branch","checkout_branch","merge_branch","cherry_pick","set_commit_message","set_commit_type","set_commit_tags","rename_branch","set_accessibility_title","set_accessibility_description"],"radar":["set_title","add_axis","remove_axis","rename_axis","set_axis_label","reorder_axis","add_curve","remove_curve","set_curve_values","set_curve_value","set_curve_label","rename_curve","reorder_curve","set_config"],"sankey":["add_link","remove_link","set_link_value","rename_node"],"c4":["add_element","update_element","rename_element","reparent_element","remove_element","add_boundary","update_boundary","rename_boundary","reparent_boundary","remove_boundary","add_relationship","update_relationship","remove_relationship","set_title","set_variant","add_directive","update_directive","remove_directive"],"packet":["set_title","set_accessibility_title","set_accessibility_description","add_field","remove_field","set_field_label","set_field_bits","move_field"],"kanban":["add_column","remove_column","set_column_label","move_column","add_task","remove_task","set_task_label","set_task_metadata","move_task","set_icon","set_class","set_accessibility_title","set_accessibility_description"],"requirement":["set_direction","add_requirement","update_requirement","add_element","update_element","rename_node","remove_node","add_relation","remove_relation","define_class","set_node_class","set_node_style"],"treemap":["set_title","add_node","remove_node","set_label","set_value","move_node","define_class","set_node_class","set_accessibility_title","set_accessibility_description"],"ishikawa":["set_effect","add_cause","remove_cause","set_label","move_cause","set_accessibility_title","set_accessibility_description"],"block":["set_columns","add_block","update_block","rename_block","remove_block","move_block","add_edge","remove_edge","define_class","set_node_class","set_node_style"]};function KC(e,t,n){if(Array.isArray(t)){return`Expected a single ${e} op, got an array of ${t.length}. Ops apply one at a time: call mutate() once per op, or pass the whole list to a batch entrypoint \u2014 applyOps({ source, family, ops }) to edit source, or buildMermaid(kind, ops) to author \u2014 valid ${e} ops: ${n}`}const i=t?.kind;const r=typeof i==="string"?`"${i}"`:JSON.stringify(t);return`Unknown ${e} op ${r} \u2014 valid ops: ${n}`}function RB(e){const t=sb[e];return t?t.join(", "):"(none \u2014 this family has no structured ops)"}function JC(e,t){return KC(e,t,RB(e))}function Rr(e){const t=[0];for(let n=0;n<e.length;n++){if(e.charCodeAt(n)===13){if(e.charCodeAt(n+1)===10)n++;t.push(n+1)}else if(e.charCodeAt(n)===10)t.push(n+1)}return t}function ks(e,t){let n=0;let i=e.length;while(n<i){const o=n+Math.floor((i-n)/2);if(e[o]<=t)n=o+1;else i=o}const r=Math.max(0,n-1);return Object.freeze({offset:t,line:r+1,col:t-e[r]+1})}function Cs(e,t,n){return Object.freeze({start:ks(e,t),end:ks(e,n)})}function Ru(e){const t=/%%\{\s*(\w+)/.exec(e)?.[1];return t!==void 0&&(t.match(/(?:init\b)|(?:initialize\b)/)!==null||t.match("wrap")!==null)}import{decodeXML as lP}from"entities";function ab(e){const t=(e.split(";")[0]??"").trim().toLowerCase();return/^(?:flowchart|graph|swimlane)(?:\s|$)/.test(t)}function lb(e){const t=(e.split(";")[0]??"").trim().toLowerCase();return/^statediagram(?:-v2)?\s*$/.test(t)}function cb(e){const t=(e.split(";")[0]??"").trim().toLowerCase();return/^statediagram(?:-v2)?(?:\s|$)/.test(t)}var A7=e=>/^sequencediagram\s*$/.test(e);var I7=e=>/^sequencediagram(?:\s|$)/.test(e);var F7=e=>/^timeline(?=$|[\s;#%])/.test(e);var N7=e=>/^timeline(?=$|[\s;#%])/.test(e);var $7=e=>/^classdiagram(?:-v2)?\s*$/.test(e);var _7=e=>/^classdiagram(?:-v2)?(?:\s|$)/.test(e);var D7=e=>/^erdiagram(?:\s+subgraph\b.*)?\s*$/.test(e);var O7=e=>/^erdiagram(?:\s|$)/.test(e);var B7=e=>/^journey\s*$/.test(e);var W7=e=>/^journey(?:\s|$)/.test(e);var z7=e=>/^architecture(?:-beta)?\s*$/.test(e);var G7=e=>/^architecture(?:-beta)?(?:\s|$)/.test(e);var H7=e=>/^xychart(?:-beta)?(?:\s|$)/.test(e);var j7=e=>/^pie(?:\s|$)/.test(e);var Y7=e=>/^quadrant(?:chart)?\s*$/.test(e);var q7=e=>/^quadrant(?:chart)?(?:\s|$)/.test(e);var X7=e=>/^gantt\s*$/.test(e);var U7=e=>/^gantt(?:\s|$)/.test(e);var V7=e=>/^mindmap\s*$/.test(e);var K7=e=>/^mindmap(?:\s|$)/.test(e);var J7=e=>/^gitgraph(?:\s+(?:lr|tb|bt))?\s*:?\s*$/.test(e);var Q7=e=>/^gitgraph(?:\s|:|$)/.test(e);var Z7=e=>/^radar-beta(?:\s|:|$)/.test(e);var eJ=e=>/^sankey(?:-beta)?\s*$/.test(e);var tJ=e=>/^sankey(?:-beta)?(?:\s|$)/.test(e);var nJ=e=>/^c4(?:context|container|component|dynamic|deployment)(?:\s|$)/.test(e);var iJ=e=>/^c4(?:context|container|component|dynamic|deployment)(?:\s|$)/.test(e);var rJ=e=>/^packet(?:-beta)?\s*$/.test(e);var oJ=e=>/^kanban\s*$/.test(e);var sJ=e=>/^requirement(?:diagram)?\s*$/.test(e);var aJ=e=>/^treemap(?:-beta)?\s*$/.test(e);var lJ=e=>/^ishikawa(?:-beta)?\s*$/.test(e);var cJ=e=>/^block(?:-beta)?\s*$/.test(e);var dJ=e=>/^zenuml\s*$/.test(e);var uJ=e=>/^eventmodeling\s*$/.test(e);function hr(e){const t=/^(?:[^\S\r\n]*(?:\r\n?|\n))*[^\S\r\n]*---[^\S\r\n]*(?:\r\n?|\n)/.exec(e)?.[0].length;if(!t)return void 0;let n=-1;let i="";const r=/([^\S\r\n]*)([^\r\n]*)(?:\r\n?|\n|$)/g;r.lastIndex=t;for(let o=r.exec(e);o?.[0];o=r.exec(e)){const s=o[1].length;const a=o[2].trimEnd();if(!a)continue;if(s<=n)n=-1;if(a==="---"&&n<0){return{source:e.slice(0,r.lastIndex),yaml:e.slice(t,o.index)}}if(n>=0||!i&&a[0]==="#")continue;const l=/^((?:-[ \t]+)*)(?:("(?:[^"\\]|\\.)*"|'(?:[^']|'')*'|[^"':](?:[^:]|:(?![ \t]))*):[ \t]+)?(?:[!&][^ \t]+[ \t]+)*/.exec(a);const c=i?i+a:a.slice(l[0].length);if(/^["'[{]/.test(c)){i="";let d=true,u="";for(let f=0;f<c.length;f++){const h=c[f];if(i){if(i==='"'&&h==="\\")f++;else if(h===i){if(i==="'"&&c[f+1]==="'")f++;else{i="";u=h}}}else if(h==="#"&&(f===0||/[ \t,]/.test(c[f-1])))break;else if(d&&h==="?"&&/[ \t]/.test(c[f+1]??""))continue;else if(d&&(h==="&"||h==="!")){const m=/^(?:!<[^>]*>|[!&][^ \t,[\]{}]*)/.exec(c.slice(f));f+=m[0].length-1}else if((h==='"'||h==="'")&&d){i=h;d=false}else if(!/[ \t]/.test(h)){d="[{,".includes(h)||h===":"&&(u==='"'||u==="'"||/[ \t]/.test(c[f+1]??""));u=h}}continue}if(/^[|>](?:[+-][1-9]?|[1-9][+-]?)?(?:[ \t]+#.*)?$/.test(c)){n=s+(l[2]?l[1].length:0)}}return void 0}var fr=/^[^\S\r\n]*%%\{\s*\w+\s*(?::\s*([\s\S]*?))?\}\s*%%[^\S\r\n]*(?:\r\n?|\n)?|%%\{\s*\w+\s*(?::\s*([\s\S]*?))?\}\s*%%/gm;var vB=/%%\{\s*\w+(?:(?!\}%%)[\s\S])*\}%%/g;function db(e,t){const n=t?e.replace(fr,(i,r,o)=>{t(r??o);return""}):e.replace(fr,"");return n.replace(vB,"")}function vu(e){return e.split(/\r\n?|\n/).map(t=>t.trim()).filter(t=>t&&!t.startsWith("%%"))}var TB=/^[^\S\r\n]*(?:sequenceDiagram|stateDiagram(?:-v2)?|mindmap|architecture(?:-beta)?|gitGraph(?:[^\S\r\n]+(?:LR|TB|BT))?(?:[^\S\r\n]*:)?|gantt(?=[^\S\r\n]+(?:(?:dateFormat|inclusiveEndDates|topAxis|axisFormat|tickInterval|includes|excludes|todayMarker|weekday|weekend|title|accTitle|accDescr|section|click)\b|[^\r\n]*:))|journey|quadrantChart|timeline(?:[^\S\r\n]+(?:LR|TD))?(?=[^\S\r\n]+(?:(?:title|section|accTitle|accDescr)\b|[^\r\n]*:))|pie(?:[^\S\r\n]+showData)?|xychart(?:-beta)?(?:[^\S\r\n]+(?:horizontal|vertical))?|radar-beta(?:[^\S\r\n]*:)?|erDiagram)/i;function kl(e){const t=e.split(/\r\n?|\n/);const n=t.findIndex(l=>l.trim()!==""&&!l.trim().startsWith("%%"));const i=n<0?null:TB.exec(t[n]);const r=i?t[n].slice(i[0].length):"";if(!i||!r.trim())return e;if(/^\s*(?:erDiagram|stateDiagram)/i.test(i[0])&&/direction\s+(?:TB|BT|LR|RL)/i.test(r))return e;if(/^\s*gitGraph\s+(?:LR|TB|BT)$/i.test(i[0]))return e;const o=/^\s*stateDiagram/i.test(i[0])&&/^[^\S\r\n]*;/.test(r);const s=/^\s*quadrantChart/i.test(i[0])&&/^[^\S\r\n]*;/.test(r);const a=i[0].endsWith(":")?/^[^\S\r\n]*(?!%%)\S/:/^[^\S\r\n]+(?!%%)\S/;if(!o&&!s&&!a.test(r))return e;t.splice(n,1,i[0],/^\s*mindmap/i.test(i[0])?r.trimEnd():s?r.replace(/^[^\S\r\n]*;/,"").trim():r.trim());return t.join("\n")}function Tu(e){return e.replace(/%%.*$/,"").split(";",1)[0].trim().toLowerCase()}function Wc(e){return vu(kl(db(e.slice(hr(e)?.source.length??0))))[0]?.toLowerCase()??""}var QC;var ZC;var ub=new Map;function eP(e,t="strict"){if(ab(e))return"flowchart";if(t==="loose"?cb(e):lb(e))return"state";return null}function yJ(e){QC=e}function xJ(e){ZC=e}function bJ(e){ub.set(e.id,e)}function fb(e){return ZC?.(e)??ub.get(e)}function zc(e,t="strict"){const n=QC?.(e,t);if(n)return n;const i=Tu(e);const r=[...ub.values()].sort((o,s)=>s.collisionPriority-o.collisionPriority||Bn(o.id,s.id));return r.find(o=>t==="loose"?(o.detectLoose??o.detect)(i):o.detect(i))??null}function Cl(e,t,n){if(!t.some(r=>/acc(?:Title|Descr)/i.test(r)))return void 0;const i=n===void 0?zc(e,"loose"):n;return i?.statementEnds?.(t)}var go=/[\u0000-\u001f\u007f-\u009f]/;var LB=/#\w+;/g;var Pl=/fl°°(\d+)¶ß|fl°(\w+)¶ß/g;var Lu=new Map([["amp","&"],["apos","'"],["gt",">"],["lt","<"],["quot",'"']]);function Un(e){return e.replace(/[^\r\n\u2028\u2029]+/g,t=>tP(tP(t,"style"),"classDef"))}function nP(e){const t=e("");if(Un(t)===t)return t;const n=e(":");if(Un(n)!==n)throw new Error("Mermaid statement cannot protect its text from the global entity prepass");return n}function tP(e,t){const n=e.lastIndexOf(";");if(n<0||!e.includes(t))return e;const i=new Uint8Array(e.length+1);let r=-1;let o=false;for(let s=e.length-1;s>=0;s--){const a=e[s];if(/\s/.test(a))r=-1;else if(a==="#")r=s;if(a===":"&&r>=0&&r<n)o=true;i[s]=o?1:0}for(let s=e.indexOf(t);s>=0;s=e.indexOf(t,s+t.length)){if(i[s+t.length]===1){return e.slice(0,n)+e.slice(n+1)}}return e}function Dn(e){return e.replace(LB,t=>{const n=t.slice(1,-1);return/^\+?\d+$/.test(n)?`\uFB02\xB0\xB0${n}\xB6\xDF`:`\uFB02\xB0${n}\xB6\xDF`})}function mb(e){return e.replace(Pl,(t,n,i)=>`#${n??i};`)}var AB={'"':"quot","&":"amp","<":"lt",">":"gt"};function hb(e){const t=AB[e];return t?`#${t};`:`#${e.codePointAt(0)};`}var IB=/\w/;function dn(e,t=""){const n=new Set(t);for(const a of n){const l=a.codePointAt(0);if(go.test(a)||l>=55296&&l<=57343){throw new RangeError(`encodeMermaidEntities cannot reserve U+${l.toString(16).toUpperCase().padStart(4,"0")}: no entity displays it`)}}const i=[...e];const r=a=>{const l=i[a];return l!==void 0&&!n.has(l)?l:void 0};const o=a=>{let l=a+1;while(r(l)!==void 0&&IB.test(r(l)))l++;return l>a+1&&r(l)===";"};let s="";for(let a=0;a<i.length;a++){const l=i[a];if(n.has(l))s+=hb(l);else if(l==="#"&&o(a))s+=hb("#");else if(l==="\uFB02"&&r(a+1)==="\xB0"||l==="\xB6"&&r(a+1)==="\xDF")s+=hb(l);else s+=l}return s}function mr(e,t=""){return e.split(/(#\w+;)/g).map((n,i)=>i%2?n:dn(n,t)).join("")}import{decodeXML as FB}from"entities";function Wo(e){return FB(mb(e))}var iP=new Set([...`#&:;,%{}"'\\\``,"\uFB02","\xB6"]);var NB={amp:"&",quot:'"',apos:"'"};function yo(e,t=""){const n=mb(e);return n.replace(/#(\w+);/g,(i,r,o)=>{if(o>0&&n[o-1]==="&")return i;const s=NB[r]??(/^\d+$/.test(r)&&Number(r)<=1114111?String.fromCodePoint(Number(r)):void 0);return s&&(iP.has(s)||t.includes(s)||o===0&&/^[A-Za-z]$/.test(s))?s:i})}function rP(e,t="",n,i=""){for(const o of t)if(!iP.has(o)&&!i.includes(o))throw new TypeError("Grammar text escapes must be formatting-neutral or owned by the family text reader");let r=dn(e,"#&:"+t);if(n?.test(r))r=`#${r.codePointAt(0)};${r.slice(1)}`;return r}function pb(e){return{...e.title!==void 0?{title:yo(e.title)}:{},...e.descr!==void 0?{descr:yo(e.descr)}:{}}}function zo(e){return pb({...e.title!==void 0?{title:Wo(e.title)}:{},...e.descr!==void 0?{descr:Wo(e.descr)}:{}})}function EJ(e){return{...e.accessibilityTitle!==void 0?{title:e.accessibilityTitle}:{},...e.accessibilityDescription!==void 0?{descr:e.accessibilityDescription}:{}}}var $B=/^\s*accTitle(?:\s*:\s*|\s+)([^\r\n]+)$/i;var _B=/^\s*accDescr(?=\s|:|\{|$)/i;function Tt(e,t){const n=e[t];if(n===void 0)return null;const i=n.match(/^\s*%% agentic-mermaid (accTitle|accDescr): ("[^\r\n]*")\s*$/);if(i){try{const s=JSON.parse(i[2]);if(typeof s==="string")return{title:i[1]==="accTitle",form:"native",value:s,endIndex:t}}catch{}}const r=n.match(_B);if(r){let s=n.slice(r[0].length).trimStart();if(s.startsWith(":"))s=s.slice(1).trimStart();if(!s.startsWith("{")){const l=s.trim();return l?{title:false,form:"inline",value:l,endIndex:t}:null}const a=[];for(let l=t;l<e.length;l++){const c=l===t?s.slice(1):e[l];const d=c.indexOf("}");if(d<0){if(c.trim())a.push(c.trim());continue}const u=c.slice(0,d).trim();if(u)a.push(u);const f=c.slice(d+1);const h=e[l].match(/^\s*/)?.[0]??"";return{title:false,form:"block",value:a.join("\n").trim(),endIndex:l,...f.trim()?{suffixLine:h+f.trimStart()}:{}}}return void 0}const o=n.match($B);if(o)return{title:true,form:"inline",value:o[1].trim(),endIndex:t};return null}function Wt(e,t,n){const i={};const r=[];const o=[];let s;for(let a=0;a<e.length;a++){const l=Tt(e,a);if(l===void 0){s=a;r.push(...e.slice(a));for(let d=a;d<e.length;d++)o.push(d);break}if(l===null){const d=Gc(t,a,e.length);r.push(...e.slice(a,d+1));for(let u=a;u<=d;u++)o.push(u);a=d;continue}const c=n?n(l):l.value;if(l.title)i.title=c;else i.descr=c;if(l.suffixLine){r.push(l.suffixLine);o.push(l.endIndex)}a=l.endIndex}return{accessibility:i,familyLines:r,familyOrigins:o,...s!==void 0?{unclosedIndex:s}:{}}}function Gc(e,t,n){const i=e?.[t]??t;return i>t?Math.min(i,n-1):t}function pr(e){if(e.unclosedIndex!==void 0)throw new Error("Unclosed accDescr block")}function vr(e){return{...e.title!==void 0?{accessibilityTitle:e.title}:{},...e.descr!==void 0?{accessibilityDescription:e.descr}:{}}}function qr(e,t){if(t.title===void 0&&t.descr===void 0){return e}return{...e,...vr(t)}}function xm(e,t){if(t.title===void 0&&t.descr===void 0){return e}return{...e,accessibility:{...e.accessibility,...t.title!==void 0?{title:t.title}:{},...t.descr!==void 0?{description:t.descr}:{}}}}function El(e,t){for(const[n,i]of[["accTitle",t.accessibilityTitle],["accDescr",t.accessibilityDescription]]){if(i===void 0)continue;const r=oP(rP(i,":;,%{}"));e.push(` %% agentic-mermaid ${n}: ${r}`)}}function oP(e){return JSON.stringify(e).replace(/[&<>#%\u2028\u2029]/g,t=>`\\u${t.charCodeAt(0).toString(16).padStart(4,"0")}`)}function sP(e,t){return gb(e,t).native.map(n=>{const i=e.slice(n.start,n.end);const r=n.start+i.indexOf('"');return{start:r,end:n.start+i.trimEnd().length,text:oP(n.directive.value)}}).filter(n=>n.text!==e.slice(n.start,n.end))}function gb(e,t){const{openers:n,closings:i}=aP(e);const r=[],o=[];const s=e.split(/\r\n?|\n/);let a=0,l=0,c=0,d=0,u=-1;const f=h=>{while(l<n.length&&n[l]<h){const m=n[l++];if(m<d)continue;while(c<i.length&&i[c].start<m)c++;if(c===i.length)continue;d=i[c].end;r.push({start:m,end:d})}};for(let h=0;h<s.length;h++){const m=s[h];f(a);if(d<=a&&h>u){const p=Tt(s,h);if(p?.form==="native"){const g=a+m.length;o.push({start:a,end:g,directive:p});while(l<n.length&&n[l]<g)l++}else u=p===void 0?s.length:Math.max(Gc(t,h,s.length),p?.endIndex??h)}a+=m.length;if(e[a]==="\r")a++;if(e[a]==="\n")a++}f(Infinity);return{native:o,directives:r}}function aP(e){const t=[...e.matchAll(/%%\{\s*\w+/g)].map(i=>i.index);const n=[...e.matchAll(/\}\s*%%/g)].map(i=>({start:i.index,end:i.index+i[0].length}));return{openers:t,closings:n}}function bm(e){const{openers:t,closings:n}=aP(e),i=e.split("");let r=0,o=0;for(const s of t){if(s<o)continue;while(r<n.length&&n[r].start<s)r++;if(r===n.length)break;o=n[r].end;for(let a=s;a<o;a++)if(i[a]!=="\r"&&i[a]!=="\n")i[a]=" "}return i.join("")}function yb(e,t="strict"){const n=Tu(e);const i=zc(n,t);if(i)return{kind:"registered",family:i};const r=UC(n);if(r)return{kind:"upstream",match:r};return{kind:"unknown",header:e}}function DB(e,t,n=0,i=Rr(e)){const r=[];const o=new RegExp(t.source,t.flags.includes("g")?t.flags:`${t.flags}g`);let s;while((s=o.exec(e))!==null){r.push(Cs(i,n+s.index,n+s.index+s[0].length));if(s[0].length===0)o.lastIndex++}return Object.freeze(r)}function dP(e,t,n=Rr(e),i=Wc(e),r){const o=[...e.slice(t).matchAll(/[^\r\n]*(?:\r\n?|\n|$)/g)];const s=o.map(p=>p[0]);const a=e.slice(t);const l=Cl(lP(i),bm(a).split(/\r\n?|\n/),r);const c=gb(a,l);const d=a.split("");for(const p of c.directives)for(let g=p.start;g<p.end;g++)if(d[g]!=="\r"&&d[g]!=="\n")d[g]=" ";const u=d.join("").split(/\r\n?|\n/);const f=o.map(p=>t+p.index);const h=[];const m=Cl(lP(i),u,r);for(let p=0;p<u.length;p++){const g=Tt(u,p);if(g===void 0)break;if(g===null){p=Gc(m,p,u.length);continue}const y=f[p];let b;if(g.form==="block"){b=f[g.endIndex]+u[g.endIndex].indexOf("}")+1}else{b=y+s[p].length}h.push(Cs(n,y,b));p=g.endIndex}return Object.freeze(h)}function OB(e,t,n,i=Rr(e),r){const o=hr(e);const s=o?.source.length??0;const a=dP(e,s,i,n,r);const l=e.split("");for(const d of a)if(/^\s*%% agentic-mermaid (?:accTitle|accDescr):/.test(e.slice(d.start.offset,d.end.offset))){for(let u=d.start.offset;u<d.end.offset;u++)if(l[u]!=="\r"&&l[u]!=="\n")l[u]=" "}const c=DB(l.join("").slice(s),new RegExp(fr.source,"gm"),s,i).filter(d=>Ru(e.slice(d.start.offset,d.end.offset)));return{...o?{frontmatter:Cs(i,0,s)}:{},...c.length>0?{initDirectives:c}:{},...a.length>0?{accessibilityDirectives:Object.freeze(a)}:{}}}function OJ(e,t){const n=e.split("");const i=Rr(e);for(const r of dP(e,hr(e)?.source.length??0,i,void 0,t)){for(let o=r.start.offset;o<r.end.offset;o++){if(n[o]!=="\n"&&n[o]!=="\r")n[o]=" "}}return n.join("")}function cP(e,t,n,i){const r=Rr(e);let o=-1;let s=-1;let a=e.length;const l=Math.max(0,Math.min(e.length,n??0));let c=l;while(c<=e.length){const d=/\r\n?|\n/g;d.lastIndex=c;const u=d.exec(e);const f=u?.index??-1;const h=f<0?e.length:f;const m=e.slice(c,h).replace(/\r$/,"");const p=m.trim();const g=p.startsWith(t)?p.slice(t.length):"";const y=/^\s*;/.test(g);if(p===t||y||/^\s/.test(g)&&kl(p)!==p){const b=m.indexOf(t);o=c+b;s=o+t.length;if(p===t){a=u?u.index+u[0].length:e.length}else{a=y?e.indexOf(";",s)+1:s;while(a<h&&/[ \t]/.test(e[a]))a++}break}if(f<0)break;c=u.index+u[0].length}if(o<0){const d=e.indexOf(t,l);o=d<0?l:d;s=Math.min(e.length,o+t.length);const u=e.indexOf("\n",s);a=u<0?e.length:u+1;c=o;while(c>0&&e.charCodeAt(c-1)!==10)c--}return Object.freeze({source:Cs(r,0,e.length),...(n??c)>0?{wrapper:Cs(r,0,n??c)}:{},...OB(e,a,t,r,i),header:Cs(r,o,s),body:Cs(r,a,e.length)})}function uP(e,t="strict"){const n=yb(e,t);return n.kind==="registered"?{kind:"registered",familyId:n.family.id}:n}function fP(e,t,n,i,r){const o=rb.provenance.version;if(e.kind==="unknown"){return{code:"UNKNOWN_HEADER",message:`Unrecognized Mermaid header: "${e.header}"`,line:1,preservation:{version:1,classification:"unknown",source:t,header:e.header,mermaidVersion:o,spans:cP(t,i??e.header,n,r)},help:"Check for a Mermaid upgrade or register a namespaced family descriptor; the source was preserved unchanged."}}const{family:s,header:a}=e.match;const l=a.agenticStatus==="inventory-only"?"inventory-only":"unsupported";const c=a.agenticStatus==="native";return{code:c?"FAMILY_DESCRIPTOR_MISMATCH":"UNSUPPORTED_FAMILY",message:c?`Mermaid ${o} header "${a.value}" is marked native but no installed family descriptor claimed it`:`Mermaid ${o} family "${s.id}" is ${l} in Agentic Mermaid`,line:1,preservation:{version:1,classification:l,source:t,header:a.value,upstreamFamilyId:s.id,mermaidVersion:o,spans:cP(t,i??a.value,n,r)},help:c?"Report a descriptor/manifest mismatch; the source was preserved unchanged.":`Install a family descriptor for "${a.value}" or use a currently native family; the source was preserved unchanged.`}}function BJ(e){return{code:e.diagnostic.code,message:e.diagnostic.message,line:1,preservation:e.preservation,help:e.diagnostic.help}}var Sm=class extends Error{name="MermaidFamilyDetectionError";code;line;preservation;help;constructor(t){super(t.message);this.code=t.code;this.line=t.line;this.preservation=t.preservation;this.help=t.help}toJSON(){return{code:this.code,message:this.message,line:this.line,preservation:this.preservation,help:this.help}}};var Hc=Object.freeze({nodes:5e3,edges:5e3,nesting:64,sourceCharacters:2e6});var Ps=class extends RangeError{code="DIAGRAM_WORK_LIMIT";resource;requested;constructor(t,n,i=false){const r=t==="sourceCharacters"?`authored plus normalized source of ${n} characters${i?", with its configuration,":""}`:`expanded graph ${t} ${n}`;super(`DIAGRAM_WORK_LIMIT: ${r} exceeds the host limit of ${Hc[t]}; split the diagram${t==="sourceCharacters"?"":` or reduce its ${t}`}`);this.name="DiagramWorkLimitError";this.resource=t;this.requested=n}};function Ve(e,t){if(t>Hc[e])throw new Ps(e,t)}function hP(e){Ve("nodes",e.requirements.length+e.elements.length);Ve("edges",e.relations.length)}function mP(e){Ve("edges",e.edges.length);Ve("nodes",e.root.children?.length??0);const t=(e.root.children??[]).map(r=>({node:r,depth:0}));const n=new Set([e.root]);let i=0;while(t.length){const{node:r,depth:o}=t.pop();if(n.has(r))throw new TypeError("Block children must form a tree without repeated objects");n.add(r);const s=o+(r.type==="composite"?1:0);Ve("nesting",s);Ve("nodes",++i+t.length+(r.children?.length??0));for(const a of r.children??[])t.push({node:a,depth:s})}}function wm(e){Ve("nodes",e.nodes.size);Ve("edges",e.edges.length);Ve("nodes",e.nodes.size+e.subgraphs.length);const t=e.subgraphs.map(r=>({group:r,depth:1}));const n=new Set;let i=e.nodes.size;while(t.length){const{group:r,depth:o}=t.pop();if(n.has(r))throw new TypeError("Graph groups must form a tree without repeated group objects");n.add(r);Ve("nesting",o);Ve("nodes",++i);Ve("nodes",i+t.length+r.children.length);for(const s of r.children)t.push({group:s,depth:o+1})}}function pP(e){Ve("nodes",e.children?.length??0);const t=(e.children??[]).map(o=>({node:o,depth:1}));const n=new Set([e]);let i=0;let r=e.edges?.length??0;Ve("edges",r);while(t.length){const{node:o,depth:s}=t.pop();if(n.has(o))throw new TypeError("Layout graph must form a tree without repeated node objects");n.add(o);Ve("nesting",o.children===void 0?s-1:s);Ve("nodes",++i);r+=o.edges?.length??0;Ve("edges",r);Ve("nodes",i+t.length+(o.children?.length??0));for(const a of o.children??[])t.push({node:a,depth:s+1})}}function Mm(e){let t=e.classes.length+e.notes.length;Ve("nodes",t+e.namespaces.length);Ve("edges",e.relationships.length);const n=e.namespaces.map(r=>({namespace:r,depth:1}));const i=new Set;while(n.length){const{namespace:r,depth:o}=n.pop();if(i.has(r))throw new TypeError("Class namespaces must form a tree without repeated namespace objects");i.add(r);Ve("nesting",o);Ve("nodes",++t+n.length+r.children.length);for(const s of r.children)n.push({namespace:s,depth:o+1})}}function km(e){xb(e.entities.length,e.relationships.length,e.groups,"ER")}function Cm(e){xb(e.services.length+e.junctions.length,e.edges.length,e.groups,"Architecture")}function Pm(e){xb(e.elements.length,e.relationships.length+e.layout.hints.length,e.boundaries,"C4");const t=new Set(e.boundaries.map(i=>i.id));const n=new Set(t);for(const i of e.elements){if(n.has(i.id))throw new TypeError(`C4 elements and boundaries must have distinct identities: ${i.id}`);n.add(i.id)}for(const i of[...e.elements,...e.boundaries]){if(i.parentId!==void 0&&!t.has(i.parentId))throw new TypeError(`C4 ${i.id} has no boundary parent ${i.parentId}`)}}function xb(e,t,n,i){Ve("nodes",e+n.length);Ve("edges",t);const r=new Map(n.map(s=>[s.id,s]));if(r.size!==n.length)throw new TypeError(`${i} groups must have distinct identities`);const o=new Map;for(const s of n){const a=[];const l=new Set;let c=s;while(c&&!o.has(c.id)){if(l.has(c.id))throw new TypeError(`${i} groups must form an acyclic hierarchy`);l.add(c.id);a.push(c.id);Ve("nesting",a.length);c=c.parentId===void 0?void 0:r.get(c.parentId)}let d=c?o.get(c.id):0;for(const u of a.reverse()){Ve("nesting",++d);o.set(u,d)}}}var Es=class extends Error{constructor(t){super(t);this.name="MermaidSyntaxError"}};function Je(e){const t=e.known&&e.known.length>0?` (known: ${e.known.join(", ")})`:"";return new Es(`${e.what} \u2014 expected ${e.expectedForm}, e.g. ${e.example}${t}`)}var yP=/[\s[({,:=]/;function jJ(e){return e.replace(/^(\s*%%)\{/,"$1 {").replace(/^(\s*%%) (?=agentic-mermaid (?:accTitle|accDescr):)/,"$1 ")}function Xr(e,t){let n=null;for(let i=0;i<e.length-1;i++){const r=e[i];if(n){if(r==="\\")i++;else if(r===n)n=null;continue}if((r==='"'||r==="'")&&(i===0||yP.test(e[i-1]))){n=r;continue}if(r==="%"&&e[i+1]==="%")return i;if(t&&(t.lastIndex=i,t.test(e))){const o=e.indexOf("}",t.lastIndex);if(o<0)return-1;i=o}}return-1}function Gt(e){const t=Xr(e);return t<0?e:e.slice(0,t).trimEnd()}function gP(e,t,n,i,r,o,s){for(let a=0;a<e.length;a++){const l=e[a];if(t==="{"){if(l==="}")t=null}else if(t){if(l==="\\"&&n)a++;else if(l===t)t=null}else if(l==="%"&&e[a+1]==="%"){break}else if(r&&(r.lastIndex=a,r.test(e))){break}else if(o&&(o.lastIndex=a,o.test(e))){t="{";a=o.lastIndex-1}else if((l==='"'||l==="'")&&(s?s(e,a):i.test(a===0?"\n":e[a-1]))){t=l}}return t}function Tr(e,t={}){const n=[...t.spanning??'"',...t.block?"{":""];const i=t.escapes??true;const r=t.opensAfter??yP;const o=new Array(e.length);let s=new Map(n.map(a=>[a,-1]));for(let a=e.length-1;a>=0;a--){const l=e[a];const c=t.wholeLine?.(l.trim())?null:gP(l,null,i,r,t.restOfLine,t.block,t.opensAt);const d=c?s.get(c)??-1:-1;o[a]=d<0?a:d;s=new Map(n.map(u=>{const f=gP(l,u,i,r,t.restOfLine,t.block,t.opensAt);return[u,f&&s.has(f)?s.get(f):a]}))}return o}function Rl(e,t,n){if(n===t)return e[t];return[e[t].trimEnd(),...e.slice(t+1,n+1).map(i=>i.trim())].join("\n")}function bb(e,t){const n=[...e];for(let i=0;i<e.length;i++){const r=t[i];if(r===i)continue;n[i]=Rl(e,i,r);n.fill("",i+1,r+1);i=r}return n}function aa(e,t={}){return bb(e,Tr(e,t))}var xP=/^align(?:\s|$)/;var BB=/^[\w-]+$/;function bP(e){const t=e.trim().split(/\s+/);const n=t[1];if(n!=="row"&&n!=="column"){return{ok:false,reason:`expected "align row" or "align column", got "${n??""}"`}}const i=t.slice(2);if(i.length<2){return{ok:false,reason:"an align directive needs at least two members"}}const r=new Set;for(const o of i){if(!BB.test(o)){return{ok:false,reason:`align member "${o}" must match [A-Za-z0-9_-]+`}}if(r.has(o)){return{ok:false,reason:`align member "${o}" is listed twice`}}r.add(o)}return{ok:true,alignment:{axis:n,members:i}}}function qJ(e){return`align ${e.axis} ${e.members.join(" ")}`}var WB="'JetBrains Mono'";var eQ=`${WB}, 'SF Mono', 'Fira Code', ui-monospace, monospace`;var er={nodeLabel:13,edgeLabel:11,groupHeader:12};var Lr={nodeLabel:500,edgeLabel:400,groupHeader:600};var Em={horizontal:20,vertical:10,diamondExtra:24};var et={outerBox:1,innerBox:.75,connector:1};var bn={width:8,height:5,strokeWidth:.75};var jc={dash:4,gap:4};var Oi={nodeLabelFontSize:er.nodeLabel,edgeLabelFontSize:er.edgeLabel,groupHeaderFontSize:er.groupHeader,nodeLabelFontWeight:Lr.nodeLabel,edgeLabelFontWeight:Lr.edgeLabel,groupHeaderFontWeight:Lr.groupHeader,nodePaddingX:Em.horizontal,nodePaddingY:Em.vertical,diamondExtraPadding:Em.diamondExtra,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:16,groupPaddingY:16,groupLabelPaddingX:12,groupLineWidth:et.outerBox};function ca(e){return typeof e==="number"&&Number.isFinite(e)?e:void 0}function Rs(e,...t){for(const n of t){const i=ca(n);if(i!=null&&i>0)return i}return e}function la(e,...t){for(const n of t){const i=ca(n);if(i!=null&&i>=0)return i}return e}function xo(...e){for(const t of e){if(typeof t==="string"&&t.trim().length>0)return t}return void 0}function Sb(...e){for(const t of e){const n=xo(t)?.toLowerCase();if(n==="uppercase"||n==="lowercase"||n==="capitalize"){return n}}return void 0}function pi(e,t){if(typeof e!=="string")return vt(e,e.display,t);if(!t)return e;const n=vt(e,"formatted",t);let i=0,r="";for(const o of n.lines)for(const s of o){r+=e.slice(i,s.sourceStart)+s.text;i=s.sourceEnd}return r+e.slice(i)}function Xe(e={},t=Oi,n){const i=n??e.styleFace;const r=i?.text;const o=i?.node;const s=i?.edge;const a=i?.group;const l=la(void 0,a?.paddingX);const c=t.nodeCornerRadius==null?la(void 0,o?.cornerRadius):la(t.nodeCornerRadius,o?.cornerRadius);return{nodeLabelFontSize:Rs(t.nodeLabelFontSize,o?.fontSize,r?.fontSize),edgeLabelFontSize:Rs(t.edgeLabelFontSize,s?.fontSize,r?.fontSize),groupHeaderFontSize:Rs(t.groupHeaderFontSize,a?.fontSize,r?.fontSize),nodeLabelFontWeight:Rs(t.nodeLabelFontWeight,o?.fontWeight,r?.fontWeight),edgeLabelFontWeight:Rs(t.edgeLabelFontWeight,s?.fontWeight,r?.fontWeight),groupHeaderFontWeight:Rs(t.groupHeaderFontWeight,a?.fontWeight,r?.fontWeight),nodeTextTransform:Sb(o?.textTransform,r?.textTransform,t.nodeTextTransform),edgeTextTransform:Sb(s?.textTransform,r?.textTransform,t.edgeTextTransform),nodeLetterSpacing:ca(o?.letterSpacing)??ca(r?.letterSpacing)??t.nodeLetterSpacing??0,edgeLetterSpacing:ca(s?.letterSpacing)??ca(r?.letterSpacing)??t.edgeLetterSpacing??0,groupLetterSpacing:ca(a?.letterSpacing)??ca(r?.letterSpacing)??t.groupLetterSpacing??0,nodePaddingX:la(t.nodePaddingX,o?.paddingX),nodePaddingY:la(t.nodePaddingY,o?.paddingY),diamondExtraPadding:t.diamondExtraPadding??Em.diamondExtra,cornerRadius:c,nodeLineWidth:Rs(t.nodeLineWidth??et.innerBox,o?.lineWidth),nodeFillColor:xo(o?.fillColor,t.nodeFillColor),nodeBorderColor:xo(o?.borderColor,t.nodeBorderColor),nodeTextColor:xo(o?.textColor,r?.textColor,t.nodeTextColor),lineWidth:Rs(t.edgeLineWidth,s?.lineWidth),edgeBendRadius:la(t.edgeBendRadius??0,s?.bendRadius),edgeStrokeColor:xo(s?.strokeColor,t.edgeStrokeColor),edgeTextColor:xo(s?.textColor,r?.textColor,t.edgeTextColor),groupFont:xo(a?.fontFamily,t.groupFont),groupTextTransform:Sb(a?.textTransform,r?.textTransform,t.groupTextTransform),groupCornerRadius:la(t.groupCornerRadius,a?.cornerRadius),groupBorderColor:xo(a?.borderColor,t.groupBorderColor),groupFillColor:xo(a?.fillColor,t.groupFillColor),groupHeaderFillColor:xo(a?.headerFillColor,t.groupHeaderFillColor),groupTextColor:xo(a?.textColor,r?.textColor,t.groupTextColor),groupPaddingX:l??t.groupPaddingX,groupPaddingY:la(t.groupPaddingY,a?.paddingY),groupLabelPaddingX:l??t.groupLabelPaddingX??t.groupPaddingX,groupLineWidth:Rs(t.groupLineWidth??et.outerBox,a?.lineWidth)}}var Rm=18;var vm=600;var vl=12;function tn(e,t){if(e===void 0)return void 0;const n=_e(e,{display:"formatted",transform:t.groupTextTransform,fontSize:Rm,fontWeight:vm,letterSpacing:t.groupLetterSpacing,fontFamily:t.groupFont});return{text:n.text,width:n.width,height:n.height+vl,block:n}}function da(e,t,n=t){const i=e.width+2*t;return{width:i,height:e.height-vl+2*n,title:rn(e,i,n)}}function rn(e,t,n){return{text:e.text,x:t/2,y:n+(e.height-vl)/2,...e.block?{block:e.block}:{}}}function En(e,t){const n=t.groupTextColor??"var(--_text)";return{id:"diagram-title",role:"title",text:e.text,block:e.block,x:e.x,y:e.y,fontSize:Rm,fontWeight:vm,letterSpacing:t.groupLetterSpacing,anchor:"middle",paint:{fill:n},attributes:{className:"diagram-title"}}}var Am=36;var wb=56;var zB=1.5;var Im=36;var un={groupHeaderHeight:28,groupFontSize:12,groupFontWeight:600,groupLetterSpacing:0,groupPaddingX:16,groupPaddingY:16,groupLabelPaddingX:12,groupCornerRadius:0,groupLineWidth:1,serviceFontSize:13,serviceFontWeight:500,serviceLetterSpacing:0,servicePaddingX:20,servicePaddingY:10,serviceCornerRadius:0,serviceLineWidth:1,edgeFontSize:11,edgeFontWeight:400,edgeLetterSpacing:0,edgeLineWidth:1,edgeBendRadius:0,iconSize:16,serviceIconSize:18,junctionOuterRadius:8,junctionInnerRadius:4.5};function wP(e,t,n={},i){const r=SP(e,"themeVariables");const o=SP(e,"architecture");const s=ua(Lm(o,"fontSize")??Lm(e,"fontSize")??Lm(r,"fontSize")??un.serviceFontSize,10,24);const a=ua(Lm(o,"iconSize")??un.serviceIconSize,12,40);const l=ua(Math.round(a*(un.iconSize/un.serviceIconSize)),10,36);const c=ua(Math.round(s*.92),10,22);const d=ua(Math.round(s*.85),10,20);const u=Math.max(un.groupHeaderHeight,Math.round(Math.max(c,l)+12));const f=ua(Math.round(a*.44),8,18);const h=Number((f*.56).toFixed(1));const m={nodeLabelFontSize:s,edgeLabelFontSize:d,groupHeaderFontSize:c,nodeLabelFontWeight:un.serviceFontWeight,edgeLabelFontWeight:un.edgeFontWeight,groupHeaderFontWeight:un.groupFontWeight,nodePaddingX:un.servicePaddingX,nodePaddingY:un.servicePaddingY,nodeCornerRadius:un.serviceCornerRadius,nodeLineWidth:un.serviceLineWidth,edgeLineWidth:un.edgeLineWidth,edgeBendRadius:un.edgeBendRadius,groupCornerRadius:un.groupCornerRadius,groupPaddingX:un.groupPaddingX,groupPaddingY:un.groupPaddingY,groupLabelPaddingX:un.groupLabelPaddingX,groupLineWidth:un.groupLineWidth};const p=Xe(n,m,i);const g={groupHeaderHeight:Math.max(u,p.groupHeaderFontSize+12),groupFontSize:p.groupHeaderFontSize,groupFontWeight:p.groupHeaderFontWeight,groupLetterSpacing:p.groupLetterSpacing,groupFont:p.groupFont,groupTextTransform:p.groupTextTransform,groupPaddingX:p.groupPaddingX,groupPaddingY:p.groupPaddingY,groupLabelPaddingX:p.groupLabelPaddingX,groupCornerRadius:p.groupCornerRadius,groupLineWidth:p.groupLineWidth,serviceFontSize:p.nodeLabelFontSize,serviceFontWeight:p.nodeLabelFontWeight,serviceLetterSpacing:p.nodeLetterSpacing,serviceTextTransform:p.nodeTextTransform,servicePaddingX:p.nodePaddingX,servicePaddingY:p.nodePaddingY,serviceCornerRadius:p.cornerRadius??0,serviceLineWidth:p.nodeLineWidth,edgeFontSize:p.edgeLabelFontSize,edgeFontWeight:p.edgeLabelFontWeight,edgeLetterSpacing:p.edgeLetterSpacing,edgeTextTransform:p.edgeTextTransform,edgeLineWidth:p.lineWidth,edgeBendRadius:p.edgeBendRadius,iconSize:l,serviceIconSize:a,junctionOuterRadius:f,junctionInnerRadius:h,groupSurface:p.groupFillColor??Tm(r,"clusterBkg")??t.surface,groupHeaderSurface:p.groupHeaderFillColor,groupBorder:p.groupBorderColor??Tm(r,"clusterBorder"),groupText:p.groupTextColor,serviceSurface:p.nodeFillColor??Tm(r,"mainBkg","secondaryColor")??t.surface,serviceBorder:p.nodeBorderColor??Tm(r,"primaryBorderColor"),serviceText:p.nodeTextColor,edgeStroke:p.edgeStrokeColor,edgeText:p.edgeTextColor};const y={...g,...n.architecture?.visual};if(y.junctionInnerRadius>y.junctionOuterRadius){throw new RangeError("architecture.visual.junctionInnerRadius must not exceed junctionOuterRadius")}return{visual:y,layout:Mb(y),padding:YB(o,"padding"),nodeSpacing:GB(o),layerSpacing:HB(o)}}function GB(e){const t=Fm(e,"nodeSeparation");if(t===void 0||!Number.isFinite(t)||t<0)return void 0;return ua(Math.round(t),0,512)}function HB(e){const t=Fm(e,"idealEdgeLengthMultiplier");if(t===void 0||!Number.isFinite(t)||t<=0)return void 0;return ua(Math.round(wb*t/zB),8,512)}function Mb(e){return{iconSize:e.iconSize,serviceIconSize:e.serviceIconSize,junctionOuterRadius:e.junctionOuterRadius,groupFontSize:e.groupFontSize,groupFontWeight:e.groupFontWeight,groupLetterSpacing:e.groupLetterSpacing,groupFont:e.groupFont,groupTextTransform:e.groupTextTransform,groupPaddingX:e.groupPaddingX,groupPaddingY:e.groupPaddingY,groupCornerRadius:e.groupCornerRadius,groupLineWidth:e.groupLineWidth,serviceFontSize:e.serviceFontSize,serviceFontWeight:e.serviceFontWeight,serviceLetterSpacing:e.serviceLetterSpacing,serviceTextTransform:e.serviceTextTransform,servicePaddingX:e.servicePaddingX,servicePaddingY:e.servicePaddingY,serviceCornerRadius:e.serviceCornerRadius,serviceLineWidth:e.serviceLineWidth,edgeFontSize:e.edgeFontSize,edgeFontWeight:e.edgeFontWeight,edgeLetterSpacing:e.edgeLetterSpacing,edgeTextTransform:e.edgeTextTransform,edgeLineWidth:e.edgeLineWidth,edgeBendRadius:e.edgeBendRadius}}function Tm(e,...t){for(const n of t){const i=jB(e,n);if(i)return i}return void 0}function jB(e,t){const n=e?.[t];return typeof n==="string"?n:void 0}function Fm(e,t){return qB(e?.[t])}function Lm(e,t){const n=Fm(e,t);return n!==void 0&&n>0?n:void 0}function YB(e,t){const n=Fm(e,t);return n!==void 0&&n>=0?n:void 0}function SP(e,t){const n=e?.[t];return XB(n)?n:void 0}function qB(e){if(typeof e==="number")return e;if(typeof e!=="string")return void 0;const t=e.trim();const n=t.match(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:px)?$/i);return n?Number.parseFloat(t):void 0}function ua(e,t,n){return Math.min(n,Math.max(t,e))}function XB(e){return Boolean(e)&&typeof e==="object"&&!Array.isArray(e)}var Go="[\\w-]+";var CP="\\((?<icon>[^)]+)\\)";var PP="\\[(?<content>.+)\\]";var UB=String.raw`(?<iconText>"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')`;var EP=new RegExp(`^group\\s+(?<id>${Go})(?:${CP})?(?:${PP})?(?:\\s+in\\s+(?<parentId>${Go}))?\\s*$`,"s");var RP=new RegExp(`^service\\s+(?<id>${Go})(?:\\s*(?:${CP}|${UB}))?\\s*(?:${PP})?(?:\\s+in\\s+(?<parentId>${Go}))?\\s*$`,"s");var vP=new RegExp(`^junction\\s+(${Go})(?:\\s+in\\s+(${Go}))?\\s*$`);var VB=new RegExp(`^(${Go})(\\{group\\})?:(L|R|T|B)$`);var KB=new RegExp(`^(L|R|T|B):(${Go})(\\{group\\})?$`);var TP=/^(<)?-\[(.*)\]-(>)?$/s;var LP=new RegExp(`^(${Go}(?:\\{group\\})?:[LRTB])\\s*(.+?)\\s*([LRTB]:${Go}(?:\\{group\\})?)$`,"s");var JB={spanning:`"'`,opensAt:(e,t)=>e[t-1]==="["||/^service\s+[\w-]+\s*$/.test(e.slice(0,t)),wholeLine:e=>/^title\s/i.test(e)};function Eb(e){return Tr(e,JB)}function AP(e){const t=e.familyBody.split(/\r?\n/);const n=t.findIndex(i=>i.trim()===e.familyLines[0]);return[t[n]?.trim()??e.familyLines[0]??"",...t.slice(n+1)]}var QB=/^\w(?:[\w-]*\w)?$/;var ZB=new Set(["architecture-beta","group","service","junction","in","align","row","column"]);var eW=/^(?:[LRTB]|title)/;var tW=/^[\w:-]+$/;var nW=/^[\w ]+$/;var iW=/^[^[\]\r\n]+$/;var IP=/^(?:"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*')$/;function rW(e){if(!QB.test(e))return Je({what:`Architecture id "${e}" must start and end with a letter, digit or _`,expectedForm:"letters, digits and _, with - only between them",example:e.replace(/^-+|-+$/g,"")||"api"});return ZB.has(e)||eW.test(e)?Je({what:`Architecture id "${e}" is read as a reserved token by Mermaid`,expectedForm:"an id other than an architecture keyword, not starting with L, R, T, B or title",example:`node_${e}`}):void 0}function oW(e){return tW.test(e)?void 0:Je({what:`Architecture icon (${e}) has a character an icon name cannot hold`,expectedForm:"letters, digits, _, - and : only",example:"(logos:aws-lambda)"})}function FP(e){if(IP.test(e))return e.slice(1,-1).replace(/\\"/g,'"').replace(/\\'/g,"'").trim();return e.trim()}function fQ(e){return nW.test(e)?e:`"${e.replace(/"/g,'\\"')}"`}function MP(e){const{id:t,icon:n,iconText:i,content:r,parentId:o}=e.groups;const s=n?.trim()||void 0;const a=r===void 0?t:FP(r);return{id:t,...s!==void 0?{icon:s}:{},...i!==void 0?{iconText:sW(i)}:{},title:a,...o!==void 0?{parentId:o}:{}}}function sW(e){const t={b:"\b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v",0:"\0"};return e.slice(1,-1).replace(/\\(.)/gs,(n,i)=>t[i]??i)}function hQ(e){const t={"\b":"\\b","\f":"\\f","\n":"\\n","\r":"\\r"," ":"\\t","\v":"\\v","\0":"\\0","\\":"\\\\",'"':'\\"'};return`"${e.replace(/[\b\f\n\r\t\v\0\\"]/g,n=>t[n])}"`}function mQ(e){const t=Gt(e.trim());const n=[];const i=l=>{if(l!==void 0&&rW(l))n.push({terminal:"id",what:`Architecture id "${l}" is not a portable Mermaid id and is read as written`})};const r=l=>{if(l!==void 0&&!iW.test(l)&&!IP.test(l)){n.push({terminal:"title",what:`Architecture title [${l}] has unquoted brackets or a line break, and is read as written`})}};const o=t.match(EP)??t.match(RP);if(o){const{id:l,icon:c,content:d,parentId:u}=o.groups;i(l);const f=c?.trim();if(f&&oW(f))n.push({terminal:"icon",what:`Architecture icon (${f}) has a character an icon name cannot hold, and is read as written`});r(d);i(u);return n}const s=t.match(vP);if(s){i(s[1]);i(s[2]);return n}const a=t.match(LP);if(a)r(a[2].trim().match(TP)?.[2]);return n}function NP(e){const t=[];const n=Eb(e);for(let i=0;i<e.length;i++){const r=i;const o=e[i];const s=(u,f=e.slice(r,i+1))=>{t.push({...u,raw:f,startLine:r+1,endLine:i+1})};const a=o.trim();if(!a||a.startsWith("%%")){s({kind:a?"comment":"blank"});continue}const l=Tt(e,i);if(l===void 0){const u=e.slice(i);i=e.length-1;s({kind:"invalid",error:new Error("Unclosed accDescr block")},u);break}if(l!==null){i=l.endIndex;const u=e.slice(r,i+1);if(l.suffixLine)u[u.length-1]=u.at(-1).slice(0,u.at(-1).indexOf("}")+1);s({kind:"accessibility",directive:l},u);if(l.suffixLine){const f=e[i];const h=f.slice(f.indexOf("}")+1);t.push(...NP([h]).map(m=>({...m,startLine:i+1,endLine:i+1})))}continue}i=n[i];const c=/^service\s+[\w-]+\s*["']/.test(a);const d=Gt((c?e.slice(r,i+1).join("\n"):Rl(e,r,i)).trim());try{const u=d.match(/^title\s+(.+)$/i);const f=d.match(EP);const h=d.match(RP);const m=d.match(vP);if(u)s({kind:"title",value:u[1].trim()});else if(f)s({kind:"group",declaration:MP(f)});else if(h)s({kind:"service",declaration:MP(h)});else if(m)s({kind:"junction",id:m[1],parentId:m[2]});else if(xP.test(d)){const p=bP(d);if(!p.ok)throw Je({what:`Invalid architecture align directive "${d}" \u2014 ${p.reason}`,expectedForm:"align row|column memberA memberB ..., listing at least two distinct services or junctions",example:"align row db1 db2 db3"});s({kind:"align",alignment:p.alignment})}else{const p=d.match(LP);if(!p)throw Je({what:`Invalid architecture edge: "${d}"`,expectedForm:"source:SIDE <op> SIDE:target, where SIDE is L, R, T, or B",example:"api:R --> L:db"});s({kind:"edge",edge:{source:lW(p[1]),target:cW(p[3]),...dW(p[2])}})}}catch(u){s({kind:"invalid",error:u instanceof Error?u:new Error(String(u))})}}return t}function $P(e){if(e.length===0){throw new Error("Empty mermaid diagram")}if(!/^architecture(?:-beta)?\s*$/i.test(Gt(e[0]))){throw new Error(`Invalid mermaid header: "${e[0]}". Expected "architecture" or "architecture-beta".`)}if(ie("architecture"))Ge("architecture","header",e[0],{line:1,unit:"normalized"});const t=new Map;const n=new Map;const i=new Map;const r=[];const o=[];const s=[];let a;let l;let c;for(const d of NP(e.slice(1))){const u=Gt(d.raw.join("\n").trim());if(ie("architecture"))Ge("architecture",d.kind,d.raw.join("\n"),{line:d.startLine+1,unit:"normalized"});if(d.kind==="invalid")throw d.error;if(d.kind==="blank"||d.kind==="comment")continue;if(d.kind==="accessibility"){if(d.directive.title)l=yt(d.directive.value);else c=yt(d.directive.value);if(ie("architecture"))ue("architecture",d.directive.title?"setAccessibilityTitle":"setAccessibilityDescription",d.directive.title?l:c,{line:d.startLine+1,unit:"normalized"});continue}if(d.kind==="title"){a=yt(d.value);if(ie("architecture"))ue("architecture","setTitle",a,{line:d.startLine+1,unit:"normalized"});continue}if(d.kind==="group"){const f=d.declaration;const{id:h,icon:m,parentId:p}=f;const g=yt(f.title);kb(h,t,n,i);const y={id:h,label:g,icon:m,parentId:p,children:[]};Cb(p,t,u);t.set(h,y);if(ie("architecture"))ue("architecture","addGroup",y,{line:d.startLine+1,unit:"normalized"});Pb({kind:"group",id:h},p,t,r);if(ie("architecture"))ue("architecture","attachChild",{kind:"group",id:h,parentId:p},{line:d.startLine+1,unit:"normalized"});continue}if(d.kind==="service"){const f=d.declaration;const{id:h,icon:m,iconText:p,parentId:g}=f;const y=yt(f.title);kb(h,t,n,i);const b={id:h,label:y,icon:m,...p!==void 0?{iconText:p}:{},parentId:g};Cb(g,t,u);n.set(h,b);if(ie("architecture"))ue("architecture","addService",b,{line:d.startLine+1,unit:"normalized"});Pb({kind:"service",id:h},g,t,r);if(ie("architecture"))ue("architecture","attachChild",{kind:"service",id:h,parentId:g},{line:d.startLine+1,unit:"normalized"});continue}if(d.kind==="junction"){const{id:f,parentId:h}=d;kb(f,t,n,i);const m={id:f,parentId:h};Cb(h,t,u);i.set(f,m);if(ie("architecture"))ue("architecture","addJunction",m,{line:d.startLine+1,unit:"normalized"});Pb({kind:"junction",id:f},h,t,r);if(ie("architecture"))ue("architecture","attachChild",{kind:"junction",id:f,parentId:h},{line:d.startLine+1,unit:"normalized"});continue}if(d.kind==="align"){s.push(aW(d.alignment,u,t,n,i));if(ie("architecture"))ue("architecture","addAlignment",s.at(-1),{line:d.startLine+1,unit:"normalized"});continue}if(d.kind==="edge"){kP(d.edge.source,n,i,u);kP(d.edge.target,n,i,u);o.push({...d.edge,label:d.edge.label===void 0?void 0:yt(d.edge.label)});if(ie("architecture"))ue("architecture","addEdge",o.at(-1),{line:d.startLine+1,unit:"normalized"})}}return{title:a,groups:[...t.values()],services:[...n.values()],junctions:[...i.values()],edges:o,alignments:s,rootChildren:r,accessibilityTitle:l,accessibilityDescription:c}}function aW(e,t,n,i,r){for(const o of e.members){if(i.has(o)||r.has(o))continue;if(n.has(o)){throw new Error(`Architecture align members must be services or junctions; "${o}" is a group in line "${t}"`)}throw Je({what:`Unknown architecture align member "${o}" in line "${t}"`,expectedForm:"a service or junction declared earlier",example:`service ${o}(server)[${o}]`,known:[...i.keys(),...r.keys()]})}return e}function kb(e,t,n,i){if(t.has(e)||n.has(e)||i.has(e)){throw Je({what:`Duplicate architecture identifier "${e}"`,expectedForm:"a unique id for each service, group, and junction",example:`${e}2`,known:[...t.keys(),...n.keys(),...i.keys()]})}}function Cb(e,t,n){if(e&&!t.has(e)){throw Je({what:`Unknown architecture group "${e}" in line "${n}"`,expectedForm:"a group declared earlier with group id(icon)[Label]",example:`group ${e}(cloud)[${e}]`,known:[...t.keys()]})}}function Pb(e,t,n,i){if(t){n.get(t).children.push(e)}else{i.push(e)}}function lW(e){const t=e.trim().match(VB);if(!t){throw new Error(`Invalid architecture edge source "${e}" \u2014 expected id then side, e.g. "api:R" in "api:R -- L:db"`)}return{id:t[1],boundary:t[2]?"group":"item",side:t[3]}}function cW(e){const t=e.trim().match(KB);if(!t){throw new Error(`Invalid architecture edge target "${e}" \u2014 expected side then id, e.g. "L:db" in "api:R -- L:db"`)}return{id:t[2],boundary:t[3]?"group":"item",side:t[1]}}function dW(e){const t=e.trim();if(t==="<-->")return{hasArrowStart:true,hasArrowEnd:true};if(t==="-->")return{hasArrowStart:false,hasArrowEnd:true};if(t==="<--")return{hasArrowStart:true,hasArrowEnd:false};if(t==="--")return{hasArrowStart:false,hasArrowEnd:false};const n=t.match(TP);if(!n){throw Je({what:`Invalid architecture edge operator "${e}"`,expectedForm:"one of --, -->, <--, <-->, or -[label]-",example:"api:R --> L:db"})}const i=FP(n[2]).trim()||void 0;return{label:i,hasArrowStart:Boolean(n[1]),hasArrowEnd:Boolean(n[3])}}function kP(e,t,n,i){const r=t.get(e.id);const o=n.get(e.id);if(!r&&!o){throw Je({what:`Unknown architecture item "${e.id}" in line "${i}"`,expectedForm:"a service or junction declared earlier",example:`service ${e.id}(server)[${e.id}]`,known:[...t.keys(),...n.keys()]})}if(e.boundary==="group"){if(!r){throw new Error(`Architecture group boundary modifier only applies to services: "${i}"`)}if(!r.parentId){throw new Error(`Service "${r.id}" is not inside a group, so "{group}" is invalid in line "${i}"`)}}}function _P(e){Cm(e);const t=new Map;for(const i of e.services){t.set(i.id,{id:i.id,label:i.label,shape:i.icon?"service":"rectangle"})}for(const i of e.junctions){t.set(i.id,{id:i.id,label:"",shape:"state-start"})}const n=fW(e.edges);return{direction:n,nodes:t,edges:e.edges.map(i=>({source:i.source.id,target:i.target.id,label:i.label,style:"solid",hasArrowStart:i.hasArrowStart,hasArrowEnd:i.hasArrowEnd})),subgraphs:uW(e.groups),classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map}}function uW(e){const t=new Map(e.map(r=>[r.id,r]));const n=new Set;function i(r,o){if(n.has(r))throw new TypeError("Architecture groups must form a tree without repeated groups");n.add(r);Ve("nesting",o);const s=[];const a=[];for(const l of r.children){if(l.kind==="group"){const c=t.get(l.id);if(c)a.push(i(c,o+1))}else{s.push(l.id)}}return{id:r.id,label:r.label,nodeIds:s,children:a,...r.icon?{titleOffset:Im}:{}}}return e.filter(r=>!r.parentId).map(r=>i(r,1))}function fW(e){let t=0;let n=0;for(const i of e){if(i.source.side==="L"||i.source.side==="R")t++;else n++;if(i.target.side==="L"||i.target.side==="R")t++;else n++}return t>=n?"LR":"TD"}var Nm=Object.freeze({maxIcons:32,maxNameBytes:128,maxPathBytes:4096});var $m=Object.freeze({account:"M12 4a4 4 0 0 1 4 4a4 4 0 0 1-4 4a4 4 0 0 1-4-4a4 4 0 0 1 4-4m0 10c4.42 0 8 1.79 8 4v2H4v-2c0-2.21 3.58-4 8-4",api:"M7 7H5a2 2 0 0 0-2 2v8h2v-4h2v4h2V9a2 2 0 0 0-2-2m0 4H5V9h2m7-2h-4v10h2v-4h2a2 2 0 0 0 2-2V9a2 2 0 0 0-2-2m0 4h-2V9h2m6 0v6h1v2h-4v-2h1V9h-1V7h4v2Z","application-brackets":"M21 2H3a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h18a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2M11 17.5L9.5 19L5 14.5L9.5 10l1.5 1.5l-3 3zm3.5 1.5L13 17.5l3-3l-3-3l1.5-1.5l4.5 4.5zM21 7H3V4h18z",archive:"M3 3h18v4H3zm1 5h16v13H4zm5.5 3a.5.5 0 0 0-.5.5V13h6v-1.5a.5.5 0 0 0-.5-.5z",cellphone:"M17 19H7V5h10m0-4H7c-1.11 0-2 .89-2 2v18a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V3a2 2 0 0 0-2-2",cloud:"M6.5 20q-2.28 0-3.89-1.57Q1 16.85 1 14.58q0-1.95 1.17-3.48q1.18-1.53 3.08-1.95q.63-2.3 2.5-3.72Q9.63 4 12 4q2.93 0 4.96 2.04Q19 8.07 19 11q1.73.2 2.86 1.5q1.14 1.28 1.14 3q0 1.88-1.31 3.19T18.5 20Z",cog:"M12 15.5A3.5 3.5 0 0 1 8.5 12A3.5 3.5 0 0 1 12 8.5a3.5 3.5 0 0 1 3.5 3.5a3.5 3.5 0 0 1-3.5 3.5m7.43-2.53c.04-.32.07-.64.07-.97s-.03-.66-.07-1l2.11-1.63c.19-.15.24-.42.12-.64l-2-3.46c-.12-.22-.39-.31-.61-.22l-2.49 1c-.52-.39-1.06-.73-1.69-.98l-.37-2.65A.506.506 0 0 0 14 2h-4c-.25 0-.46.18-.5.42l-.37 2.65c-.63.25-1.17.59-1.69.98l-2.49-1c-.22-.09-.49 0-.61.22l-2 3.46c-.13.22-.07.49.12.64L4.57 11c-.04.34-.07.67-.07 1s.03.65.07.97l-2.11 1.66c-.19.15-.25.42-.12.64l2 3.46c.12.22.39.3.61.22l2.49-1.01c.52.4 1.06.74 1.69.99l.37 2.65c.04.24.25.42.5.42h4c.25 0 .46-.18.5-.42l.37-2.65c.63-.26 1.17-.59 1.69-.99l2.49 1.01c.22.08.49 0 .61-.22l2-3.46c.12-.22.07-.49-.12-.64z",database:"M12 3C7.58 3 4 4.79 4 7s3.58 4 8 4s8-1.79 8-4s-3.58-4-8-4M4 9v3c0 2.21 3.58 4 8 4s8-1.79 8-4V9c0 2.21-3.58 4-8 4s-8-1.79-8-4m0 5v3c0 2.21 3.58 4 8 4s8-1.79 8-4v-3c0 2.21-3.58 4-8 4s-8-1.79-8-4",dns:"M7 9a2 2 0 0 1-2-2a2 2 0 0 1 2-2a2 2 0 0 1 2 2a2 2 0 0 1-2 2m13-6H4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1V4a1 1 0 0 0-1-1M7 19a2 2 0 0 1-2-2a2 2 0 0 1 2-2a2 2 0 0 1 2 2a2 2 0 0 1-2 2m13-6H4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h16a1 1 0 0 0 1-1v-6a1 1 0 0 0-1-1",email:"m20 8l-8 5l-8-5V6l8 5l8-5m0-2H4c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2","folder-network":"M3 15V5a2 2 0 0 1 2-2h6l2 2h6a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2h-6v2h1a1 1 0 0 1 1 1h7v2h-7a1 1 0 0 1-1 1h-4a1 1 0 0 1-1-1H2v-2h7a1 1 0 0 1 1-1h1v-2H5a2 2 0 0 1-2-2","function-variant":"M12.42 5.29c-1.1-.1-2.07.71-2.17 1.82L10 10h2.82v2h-3l-.44 5.07A4.001 4.001 0 0 1 2 18.83l1.5-1.5c.33 1.05 1.46 1.64 2.5 1.3c.78-.24 1.33-.93 1.4-1.74L7.82 12h-3v-2H8l.27-3.07a4.01 4.01 0 0 1 4.33-3.65c1.26.11 2.4.81 3.06 1.89l-1.5 1.5c-.25-.77-.93-1.31-1.74-1.38M22 13.65l-1.41-1.41l-2.83 2.83l-2.83-2.83l-1.43 1.41l2.85 2.85l-2.85 2.81l1.43 1.41l2.83-2.83l2.83 2.83L22 19.31l-2.83-2.81z","google-cloud":"M23 14.75C23 18.2 20.2 21 16.75 21h-9.5C3.8 21 1 18.2 1 14.75c0-2.14 1.08-4.03 2.71-5.15C4.58 5.82 7.96 3 12 3s7.42 2.82 8.29 6.6A6.22 6.22 0 0 1 23 14.75M16.63 17c1.31 0 2.37-1.06 2.37-2.37c0-1.28-1-2.33-2.28-2.38l.03-.5a4.754 4.754 0 0 0-8.32-3.14c1.5.29 2.8 1.11 3.71 2.25L9.5 13.5c-.42-.73-1.21-1.25-2.12-1.25c-1.32 0-2.38 1.06-2.38 2.38c0 1.27 1 2.3 2.25 2.37z",harddisk:"M6 2h12a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m6 2a6 6 0 0 0-6 6c0 3.31 2.69 6 6.1 6l-.88-2.23a1.01 1.01 0 0 1 .37-1.37l.86-.5a1.01 1.01 0 0 1 1.37.37l1.92 2.42A5.98 5.98 0 0 0 18 10a6 6 0 0 0-6-6m0 5a1 1 0 0 1 1 1a1 1 0 0 1-1 1a1 1 0 0 1-1-1a1 1 0 0 1 1-1m-5 9a1 1 0 0 0-1 1a1 1 0 0 0 1 1a1 1 0 0 0 1-1a1 1 0 0 0-1-1m5.09-4.73l2.49 6.31l2.59-1.5l-4.22-5.31z",lan:"M10 2c-1.11 0-2 .89-2 2v3c0 1.11.89 2 2 2h1v2H2v2h4v2H5c-1.11 0-2 .89-2 2v3c0 1.11.89 2 2 2h4c1.11 0 2-.89 2-2v-3c0-1.11-.89-2-2-2H8v-2h8v2h-1c-1.11 0-2 .89-2 2v3c0 1.11.89 2 2 2h4c1.11 0 2-.89 2-2v-3c0-1.11-.89-2-2-2h-1v-2h4v-2h-9V9h1c1.11 0 2-.89 2-2V4c0-1.11-.89-2-2-2zm0 2h4v3h-4zM5 17h4v3H5zm10 0h4v3h-4z",lock:"M12 17a2 2 0 0 0 2-2a2 2 0 0 0-2-2a2 2 0 0 0-2 2a2 2 0 0 0 2 2m6-9a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V10a2 2 0 0 1 2-2h1V6a5 5 0 0 1 5-5a5 5 0 0 1 5 5v2zm-6-5a3 3 0 0 0-3 3v2h6V6a3 3 0 0 0-3-3",memory:"M17 17H7V7h10m4 4V9h-2V7a2 2 0 0 0-2-2h-2V3h-2v2h-2V3H9v2H7c-1.11 0-2 .89-2 2v2H3v2h2v2H3v2h2v2a2 2 0 0 0 2 2h2v2h2v-2h2v2h2v-2h2a2 2 0 0 0 2-2v-2h2v-2h-2v-2m-6 2h-2v-2h2m2-2H9v6h6z","message-processing":"M17 11h-2V9h2m-4 2h-2V9h2m-4 2H7V9h2m11-7H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2","microsoft-azure":"M13.05 4.24L6.56 18.05L2 18l5.09-8.76zm.7 1.09L22 19.76H6.74l9.3-1.66l-4.87-5.79z",monitor:"M21 16H3V4h18m0-2H3c-1.11 0-2 .89-2 2v12a2 2 0 0 0 2 2h7v2H8v2h8v-2h-2v-2h7a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2","queue-first-in-last-out":"M6 6h12v2H6zm0 4.5h12v2H6zM6 15h12v2H6zm3 4h6l-3 3zM9 2h6l-3 3z","router-network":"M5 9c-1.1 0-2 .9-2 2v4a2 2 0 0 0 2 2h6v2h-1c-.55 0-1 .45-1 1H2v2h7c0 .55.45 1 1 1h4c.55 0 1-.45 1-1h7v-2h-7c0-.55-.45-1-1-1h-1v-2h6c1.11 0 2-.89 2-2v-4a2 2 0 0 0-2-2zm1 3h2v2H6zm3.5 0h2v2h-2zm3.5 0h2v2h-2z",server:"M4 1h16a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V2a1 1 0 0 1 1-1m0 8h16a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1m0 8h16a1 1 0 0 1 1 1v4a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1v-4a1 1 0 0 1 1-1M9 5h1V3H9zm0 8h1v-2H9zm0 8h1v-2H9zM5 3v2h2V3zm0 8v2h2v-2zm0 8v2h2v-2z","shield-lock":"M12 1L3 5v6c0 5.55 3.84 10.74 9 12c5.16-1.26 9-6.45 9-12V5zm0 6c1.4 0 2.8 1.1 2.8 2.5V11c.6 0 1.2.6 1.2 1.3v3.5c0 .6-.6 1.2-1.3 1.2H9.2c-.6 0-1.2-.6-1.2-1.3v-3.5c0-.6.6-1.2 1.2-1.2V9.5C9.2 8.1 10.6 7 12 7m0 1.2c-.8 0-1.5.5-1.5 1.3V11h3V9.5c0-.8-.7-1.3-1.5-1.3",web:"M16.36 14c.08-.66.14-1.32.14-2s-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2m-5.15 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95a8.03 8.03 0 0 1-4.33 3.56M14.34 14H9.66c-.1-.66-.16-1.32-.16-2s.06-1.35.16-2h4.68c.09.65.16 1.32.16 2s-.07 1.34-.16 2M12 19.96c-.83-1.2-1.5-2.53-1.91-3.96h3.82c-.41 1.43-1.08 2.76-1.91 3.96M8 8H5.08A7.92 7.92 0 0 1 9.4 4.44C8.8 5.55 8.35 6.75 8 8m-2.92 8H8c.35 1.25.8 2.45 1.4 3.56A8 8 0 0 1 5.08 16m-.82-2C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2s.06 1.34.14 2M12 4.03c.83 1.2 1.5 2.54 1.91 3.97h-3.82c.41-1.43 1.08-2.77 1.91-3.97M18.92 8h-2.95a15.7 15.7 0 0 0-1.38-3.56c1.84.63 3.37 1.9 4.33 3.56M12 2C6.47 2 2 6.5 2 12a10 10 0 0 0 10 10a10 10 0 0 0 10-10A10 10 0 0 0 12 2"});var hW=Object.freeze({"logos:aws":"cloud","logos:aws-lambda":"function-variant","logos:aws-aurora":"database","logos:aws-glacier":"archive","logos:aws-s3":"harddisk","logos:aws-ec2":"server","logos:microsoft-azure":"microsoft-azure","logos:google-cloud":"google-cloud"});var mW=/^[MmZzLlHhVvCcSsQqTtAa0-9eE+.,\s-]+$/;var DP=/^[a-z0-9][a-z0-9:_/-]*$/;function pW(){const e=Object.entries($m);if(e.length>Nm.maxIcons)throw new Error("Architecture icon registry exceeds maxIcons");for(const[t,n]of e){if(t.length>Nm.maxNameBytes||!DP.test(t)){throw new Error(`Unsafe Architecture icon name: ${t}`)}if(n.length>Nm.maxPathBytes||!mW.test(n)){throw new Error(`Unsafe or oversized Architecture icon path: ${t}`)}}}pW();function gW(e){const t=e.trim().toLowerCase();if(!t||t.length>Nm.maxNameBytes||!DP.test(t))return void 0;const n=hW[t];if(n)return n;const i=t.startsWith("mdi:")?t.slice(4):t.startsWith("mdi/")?t.slice(4):t;if(i.includes(":")||i.includes("/"))return void 0;return Object.prototype.hasOwnProperty.call($m,i)?i:void 0}function fa(e){const t=gW(e);if(!t)return null;return{canonicalName:`mdi:${t}`,viewBox:"0 0 24 24",path:$m[t],source:"@iconify-json/mdi@1.2.3",license:"Apache-2.0"}}function gQ(){return Object.keys($m).sort().map(e=>fa(`mdi:${e}`))}function gi(e){const t=new Set(e),n=new Map;return(i,r=i)=>{const o=typeof r==="string"?r:[...r];if(typeof o!=="string"&&o.some(d=>typeof d==="number"&&!Number.isFinite(d))){throw new TypeError("Generated identity key numeric components must be finite")}const s=JSON.stringify(o);const a=n.get(s);if(a!==void 0)return a;let l=i,c=1;while(t.has(l))l=`${i}#${c++}`;t.add(l);n.set(s,l);return l}}function ha(e){if(e.source==="merge"&&e.customId)return e.sourceId||e.id;return e.message||e.sourceId||e.id}var Rn=class extends Error{constructor(n,i){super(n);this.line=i;this.name="GitGraphParseError"}line};var Rb=class extends Rn{constructor(n,i){super(`Duplicate gitGraph commit id '${n}' on line ${i}; commit IDs must be unique.`,i);this.id=n}id;code="GITGRAPH_DUPLICATE_COMMIT_ID"};var zP={spanning:`"'`,wholeLine:e=>/^title(?:\s|$)/i.test(e)};function vb(e){return Tr(e,zP)}function GP(e,t={}){const n=e.replace(/^\uFEFF/,"").split(/\r?\n/);const i=Wt(n,vb(n));if(i.unclosedIndex!==void 0){throw new Rn("Unclosed accDescr block",i.unclosedIndex+1)}const r=aa(i.familyLines,zP).map(Gt);const o=r.findIndex(R=>/^\s*gitgraph\b/i.test(R));if(o<0)throw new Rn("gitGraph source must start with a gitGraph header");const s=r[o].trim().match(/^gitGraph(?:\s+(LR|TB|BT))?\s*:?[ \t]*$/i);if(!s)throw new Rn("Invalid gitGraph header; expected gitGraph, gitGraph LR:, gitGraph TB:, or gitGraph BT:",o+1);if(ie("gitgraph"))Ge("gitgraph","header",r[o],{line:o+1,unit:"normalized"});const a=s[1]?.toUpperCase()??"LR";const l=typeof t.mainBranchName==="string"&&t.mainBranchName.trim()?t.mainBranchName.trim():"main";const c=yW(t.mainBranchOrder,0);const d=typeof t.title==="string"&&t.title.trim()?t.title.trim():void 0;const u=[];const f=new Map([[l,{name:l,order:c,sequence:0}]]);const h=[];const m=new Map;const p=[];const g=new Map;for(let R=o+1;R<r.length;R++){const M=r[R].trim();const P=M.match(OP);const E=P?void 0:M.match(BP);if(!P&&!E)continue;const v=P?P[1]??"":E[2]??"";if(P&&/^(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')$/.test(v))continue;try{const L=_m(v,R+1,P?["id","tag","type","msg"]:["id","tag","type"]);g.set(R,L);if(L.id!==void 0)p.push(L.id)}catch{}}const y=gi(p);const b=new Map;let S=l;let x=0;const k=i.accessibility.title;const w=i.accessibility.descr;if(ie("gitgraph"))ue("gitgraph","initialize",{direction:a,mainBranchName:l,title:d,branch:f.get(l),currentBranch:S,accessibilityTitle:k,accessibilityDescription:w});const C=(R,M,P,E={},v)=>{const L=R.id!==void 0;const T=R.id??`c${x}`;if(M==="merge"&&L&&b.has(T))throw new Rb(T,P);const A=L&&!m.has(T)?T:y(T,["commit",x]);const $=M==="merge"?"MERGE":M==="cherry-pick"?"CHERRY_PICK":R.type??"NORMAL";const _=f.get(S);const z={id:A,...L&&A!==R.id?{sourceId:R.id}:{},...R.msg?{message:R.msg}:{},type:$,tags:R.tags,branch:S,parents:v??(_.head?[_.head]:[]),sequence:x++,source:M,customId:L,...E};u.push(z);if(ie("gitgraph"))ue("gitgraph","addCommit",z,{line:P,unit:"normalized"});m.set(A,z);b.set(R.id??A,z);_.head=A;if(ie("gitgraph"))ue("gitgraph","setBranchHead",{branch:S,head:A},{line:P,unit:"normalized"});return z};for(let R=o+1;R<r.length;R++){const M=r[R].trim();if(!M||M.startsWith("%%"))continue;const P=M.match(OP);if(P){if(ie("gitgraph"))Ge("gitgraph","commit",M,{line:R+1,unit:"normalized"});const A=P[1]??"";const $=/^(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')$/.test(A);const _=$?{tags:[],msg:Au(A)}:g.get(R)??_m(A,R+1,["id","tag","type","msg"]);const z=C(_,"commit",R+1);h.push({kind:"commit",ref:z.id});if(ie("gitgraph"))ue("gitgraph","appendStatement",h.at(-1),{line:R+1,unit:"normalized"});continue}const E=M.match(/^branch\s+("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)(?:\s+order\s*:\s*(-?\d+))?$/i);if(E){if(ie("gitgraph"))Ge("gitgraph","branch",M,{line:R+1,unit:"normalized"});const A=Au(E[1]);if(f.has(A))throw new Rn(`Trying to create existing branch '${A}'; use checkout ${Dm(A)} instead.`,R+1);const $=E[2]===void 0?void 0:Number(E[2]);if($!==void 0&&$<=0)throw new Rn("Branch order must be a positive integer.",R+1);const _=$??bW(f.size);f.set(A,{name:A,order:_,sequence:f.size,...f.get(S)?.head?{head:f.get(S).head}:{}});if(ie("gitgraph"))ue("gitgraph","addBranch",f.get(A),{line:R+1,unit:"normalized"});S=A;if(ie("gitgraph"))ue("gitgraph","setCurrentBranch",A,{line:R+1,unit:"normalized"});h.push({kind:"branch",name:A,...E[2]!==void 0?{order:_}:{}});if(ie("gitgraph"))ue("gitgraph","appendStatement",h.at(-1),{line:R+1,unit:"normalized"});continue}const v=M.match(/^(checkout|switch)\s+("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)$/i);if(v){if(ie("gitgraph"))Ge("gitgraph","checkout",M,{line:R+1,unit:"normalized"});const A=Au(v[2]);if(!f.has(A))throw new Rn(`Trying to checkout branch '${A}' before it is created.`,R+1);S=A;if(ie("gitgraph"))ue("gitgraph","setCurrentBranch",A,{line:R+1,unit:"normalized"});h.push({kind:"checkout",branch:A,keyword:v[1].toLowerCase()});if(ie("gitgraph"))ue("gitgraph","appendStatement",h.at(-1),{line:R+1,unit:"normalized"});continue}const L=M.match(BP);if(L){if(ie("gitgraph"))Ge("gitgraph","merge",M,{line:R+1,unit:"normalized"});const A=Au(L[1]);const $=g.get(R)??_m(L[2]??"",R+1,["id","tag","type"]);if(A===S)throw new Rn(`Cannot merge branch '${A}' into itself.`,R+1);const _=f.get(S);const z=f.get(A);if(!z)throw new Rn(`Branch to be merged ('${A}') does not exist.`,R+1);if(!_.head)throw new Rn(`Current branch '${S}' has no commits.`,R+1);if(!z.head)throw new Rn(`Branch to be merged ('${A}') has no commits.`,R+1);if(z.head===_.head)throw new Rn("Cannot merge branches with the same head commit.",R+1);const F=C($,"merge",R+1,{mergeBranch:A,message:`merged branch ${A} into ${S}`,...$.type?{customType:$.type}:{}},[_.head,z.head]);h.push({kind:"merge",ref:F.id,branch:A});if(ie("gitgraph"))ue("gitgraph","appendStatement",h.at(-1),{line:R+1,unit:"normalized"});continue}const T=M.match(/^cherry-pick\s+(.+)$/is);if(T){if(ie("gitgraph"))Ge("gitgraph","cherry-pick",M,{line:R+1,unit:"normalized"});const A=_m(T[1],R+1,["id","tag","parent"]);if(!A.id)throw new Rn('cherry-pick requires id:"existing commit".',R+1);const $=b.get(A.id);if(!$)throw new Rn(`Cherry-pick source commit '${A.id}' does not exist.`,R+1);const _=f.get(S);if(!_.head)throw new Rn(`Current branch '${S}' has no commits.`,R+1);if(xW(_.head,$.id,m))throw new Rn(`Cherry-pick source '${$.id}' is already reachable from current branch '${S}'.`,R+1);const z=A.parent?b.get(A.parent)?.id:void 0;if($.parents.length===2){if(!A.parent)throw new Rn(`Cherry-picking merge commit '${$.id}' requires parent:"immediate parent".`,R+1);if(!z||!$.parents.includes(z))throw new Rn(`Cherry-pick parent '${A.parent}' is not an immediate parent of '${$.id}'.`,R+1)}const F=A.tags.length===0?`cherry-pick:${$.sourceId??$.id}${A.parent?`|parent:${A.parent}`:""}`:void 0;const G={tags:F?[F]:A.tags};const I=C(G,"cherry-pick",R+1,{message:`cherry-picked ${ha($)} into ${S}`,cherrySource:$.id,...z?{cherryParent:z}:{},...F?{syntheticCherryTag:F}:{}},[_.head,$.id]);h.push({kind:"cherry-pick",ref:I.id,source:$.id,...z?{parent:z}:{}});if(ie("gitgraph"))ue("gitgraph","appendStatement",h.at(-1),{line:R+1,unit:"normalized"});continue}if(ie("gitgraph"))Ge("gitgraph","invalid",M,{line:R+1,unit:"normalized"});throw new Rn(`Unsupported gitGraph statement on line ${R+1}: ${M}`,R+1)}return{direction:a,mainBranchName:l,...d?{title:d}:{},commits:u,branches:[...f.values()],statements:h,...k?{accessibilityTitle:k}:{},...w?{accessibilityDescription:w}:{}}}var OP=/^commit(?:\s+(.*))?$/is;var BP=/^merge\s+("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)(?:\s+(.*))?$/is;function _m(e,t,n){const i={tags:[]};let r=0;const o=/([A-Za-z][\w-]*)\s*:\s*("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|\S+)/gy;while(r<e.length){while(/\s/.test(e[r]??""))r++;if(r>=e.length)break;o.lastIndex=r;const s=o.exec(e);if(!s)throw new Rn(`Invalid gitGraph attribute syntax near '${e.slice(r)}'.`,t);const a=s[1].toLowerCase();if(!n.includes(a))throw new Rn(`Attribute '${a}' is not valid for this gitGraph statement.`,t);const l=Au(s[2]);if(a==="id")i.id=l;else if(a==="msg")i.msg=l;else if(a==="tag")i.tags.push(l);else if(a==="parent")i.parent=l;else{const c=l.toUpperCase();if(!["NORMAL","REVERSE","HIGHLIGHT"].includes(c))throw new Rn(`Invalid commit type '${l}'.`,t);i.type=c}r=o.lastIndex}return i}function Au(e){if(!/^(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')$/.test(e))return e;const t={b:"\b",f:"\f",n:"\n",r:"\r",t:" ",v:"\v",0:"\0"};return e.slice(1,-1).replace(/\\(.)/g,(n,i)=>t[i]??i)}function Dm(e){return/^[A-Za-z_](?:[-./\w]*[-\w])?$/.test(e)&&!/^(?:title|(?:gitGraph|commit|branch|checkout|switch|merge|cherry-pick|LR|TB|BT|NORMAL|REVERSE|HIGHLIGHT)$)/i.test(e)?e:Tl(e)}function yW(e,t){return typeof e==="number"&&Number.isFinite(e)?e:t}function xW(e,t,n){const i=[e];const r=new Set;while(i.length>0){const o=i.pop();if(o===t)return true;if(r.has(o))continue;r.add(o);const s=n.get(o);if(s)i.push(...s.source==="cherry-pick"?s.parents.slice(0,1):s.parents)}return false}function PQ(e){const t=e.direction==="LR"?"gitGraph":`gitGraph ${e.direction}:`;const n=[t];if(e.accessibilityTitle)n.push(` accTitle: ${e.accessibilityTitle}`);if(e.accessibilityDescription?.includes("\n")){n.push(" accDescr {",...e.accessibilityDescription.split("\n").map(r=>` ${r}`)," }")}else if(e.accessibilityDescription)n.push(` accDescr: ${e.accessibilityDescription}`);const i=new Map(e.commits.map(r=>[r.id,r]));for(const r of e.statements){if(r.kind==="branch")n.push(` branch ${Dm(r.name)}${r.order!==void 0?` order: ${r.order}`:""}`);else if(r.kind==="checkout")n.push(` ${r.keyword} ${Dm(r.branch)}`);else{const o=i.get(r.ref);if(!o)continue;if(r.kind==="commit")n.push(` commit${WP(o)}`);else if(r.kind==="merge")n.push(` merge ${Dm(r.branch)}${WP(o,false)}`);else{const s=o.tags.filter(a=>a!==o.syntheticCherryTag);n.push(` cherry-pick id:${Tl(i.get(o.cherrySource??r.source)?.sourceId??o.cherrySource??r.source)}${r.parent?` parent:${Tl(i.get(r.parent)?.sourceId??r.parent)}`:""}${s.map(a=>` tag:${Tl(a)}`).join("")}`)}}}return n.join("\n")+"\n"}function WP(e,t=true){const n=[];if(e.customId)n.push(`id:${Tl(e.sourceId??e.id)}`);const i=e.type==="MERGE"?e.customType:e.type;if(i&&i!=="NORMAL"&&i!=="CHERRY_PICK")n.push(`type:${i}`);for(const r of e.tags)n.push(`tag:${Tl(r)}`);if(t&&e.message)n.push(`msg:${Tl(e.message)}`);return n.length?` ${n.join(" ")}`:""}function bW(e){return e<=9?e/10:1-1/(e+1)}function SW(e){const t={"\b":"b","\f":"f","\n":"n","\r":"r"," ":"t","\v":"v","\0":"0"};const n=e.replace(/[\\"%\b\f\n\r\t\v\0]/g,i=>`\\${t[i]??i}`).replace(/#\w+;/g,i=>`${i.slice(0,-1)}\\;`).replace(/style/g,"sty\\le").replace(/classDef/g,"class\\Def");return`"${n}"`}var Tl=SW;var tr=class extends Error{constructor(n,i){super(n);this.line=i;this.name="MindmapParseError"}line};var Tb=class extends tr{constructor(n,i){super(`Duplicate mindmap node identity '${n}' on line ${i}; every node identity must be unique.`,i);this.id=n}id;code="MINDMAP_DUPLICATE_ID"};function jP(e){const t=e.replace(/^\uFEFF/,"").split(/\r?\n/);const n=t.map(h=>Tt([h],0)?.form==="inline"?YP(h,false):h);const i=Wt(n,Om(n));if(i.unclosedIndex!==void 0){throw new tr("Unclosed accDescr block",i.unclosedIndex+1)}const r=zo(i.accessibility);const o=i.familyLines;const s=o.findIndex(h=>/^\s*mindmap\s*$/i.test(h));if(s<0)throw new tr("Mindmap source must start with the mindmap header");if(ie("mindmap"))Ge("mindmap","header",o[s],{line:s+1,unit:"normalized"});const a=[];const l=new Set;let c;let d;const u=r.title;const f=r.descr;if(ie("mindmap"))ue("mindmap","initialize",{accessibilityTitle:u,accessibilityDescription:f});for(const{raw:h,start:m,end:p}of Iu(o,s+1)){const g=m+1;const y=h.trim();if(!y||y.startsWith("%%"))continue;if(/^acc(?:Title|Descr)\b/i.test(y)){const k=/^accTitle\b/i.test(y)?"accTitle":"accDescr";throw new tr(`Mindmap ${k} must contain a non-empty value`,p+1)}if(/^::icon\b/i.test(y)){if(ie("mindmap"))Ge("mindmap","icon",y,{line:g,unit:"normalized"});const k=y.match(/^::icon\(([^)]*)\)$/i);const w=k?.[1]?.trim();if(!k||!w)throw new tr("Mindmap icon decoration must contain a non-empty value without closing parentheses",p+1);if(!d)throw new tr("Mindmap icon decoration requires a preceding node",p+1);d.icon=w;if(ie("mindmap"))ue("mindmap","setIcon",{id:d.id,icon:w},{line:g,unit:"normalized"});continue}if(y.startsWith(":::")){if(ie("mindmap"))Ge("mindmap","class",y,{line:g,unit:"normalized"});const k=y.match(/^:::\s*(.+)$/);if(!k)throw new tr("Mindmap class decoration must contain at least one class name",p+1);if(!d)throw new tr("Mindmap class decoration requires a preceding node",p+1);d.className=k[1].trim().replace(/\s+/g," ");if(ie("mindmap"))ue("mindmap","setClass",{id:d.id,className:d.className},{line:g,unit:"normalized"});continue}const b=qP(y);if(ie("mindmap"))Ge("mindmap",b?"node":"invalid",y,{line:g,unit:"normalized"});if(!b){throw new tr(`Invalid mindmap node syntax on line ${p+1}: ${y}`,p+1)}if(l.has(b.id))throw new Tb(b.id,p+1);l.add(b.id);const S={...b,children:[]};if(ie("mindmap"))ue("mindmap","createNode",S,{line:g,unit:"normalized"});const x=wW(h);while(a.length>0&&a[a.length-1].indent>=x)a.pop();if(a.length===0){if(c)throw new tr(`There can be only one mindmap root; '${S.label}' has no parent on line ${p+1}.`,p+1);c=S;if(ie("mindmap"))ue("mindmap","setRoot",{id:S.id},{line:g,unit:"normalized"})}else{a[a.length-1].node.children.push(S);if(ie("mindmap"))ue("mindmap","attachChild",{id:S.id,parentId:a[a.length-1].node.id},{line:g,unit:"normalized"})}a.push({indent:x,node:S});d=S}if(!c)throw new tr("Mindmap requires exactly one root node");return{root:c,...u?{accessibilityTitle:u}:{},...f?{accessibilityDescription:f}:{}}}function Om(e){const t=e.map((n,i)=>i);try{for(const{start:n,end:i}of Iu(e,0))t[n]=i}catch{}return t}function*Iu(e,t){let n;let i;for(let r=t;r<e.length;r++){const o=r;let s=e[r];if(s.includes('["`')&&!s.includes('`"]')){const a=[s];let l=false;while(++r<e.length){a.push(e[r]);if(e[r].includes('`"]')){l=true;break}}if(!l)throw new tr("Unclosed mindmap Markdown String",r+1);s=a.join("\n")}if(Lb(s.trimStart())==="open"){const a=d=>/^\s*%%/.test(d);n??=e.map(d=>a(d)?"":d).join("\n");i??=e.reduce((d,u,f)=>(d.push(f===0?0:d[f-1]+(a(e[f-1])?0:e[f-1].length)+1),d),[]);const l=i[r]+s.length-s.trimStart().length;const c=Lb(n.slice(l));if(c&&c!=="open"){const d=r+n.slice(l,l+c.end).split("\n").length-1;s=[e[r].trimEnd(),...e.slice(r+1,d+1).filter(u=>!a(u)).map(u=>u.trim())].join("\n");r=d}}yield{raw:YP(s),start:o,end:r}}}function IQ(e){const t=e.split(/\r?\n/);const n=t.findIndex(r=>/^\s*mindmap\s*$/i.test(r));if(n<0)return[];for(let r=n+1;r<t.length;r++){const o=Tt(t,r);if(o===void 0)break;if(o===null)continue;t.fill("",r,o.endIndex+1);r=o.endIndex}const i=[];for(const{raw:r,start:o}of Iu(t,n+1)){const s=r.trim();if(!s||s.startsWith("%%")||/^::icon\b/i.test(s)||s.startsWith(":::"))continue;if(Bm(s)?.nested)i.push(o+1)}return i}function Ib(e){const t=Lb(e);return t==="open"?null:t}function Lb(e){const t=e.match(/^([^()[{}]*?)(\(\(|\{\{|\[|\)\)|\)|\()/);if(!t)return null;const n=t[2];const i=t[0].length;let r=i;if(e.startsWith('"`',i)){const c=e.indexOf('`"',i+2);if(c<0)return"open";r=c+2}else if(e[i]==='"'){r=i+1;while(r<e.length){if(e[r]==="\\"){r+=2;continue}if(e[r++]==='"')break}if(e[r-1]!=='"'||r===i+1)return"open"}else{while(r<e.length&&!/[)\](}]/.test(e[r]))r++}const o=e.slice(i,r);const s=e[i]==='"';while(r<e.length&&(s?/[ \t]/:/\s/).test(e[r]))r++;if(r===e.length)return s?null:"open";const a=["))","}}","((","(-","-)",")","]","("].find(c=>e.startsWith(c,r));if(!a)return null;const l=n==="["?"rect":n==="{{"?"hexagon":n==="(("?"circle":n==="))"?"bang":n===")"||a!==")"?"cloud":"rounded";return{id:t[1].trim(),label:o,shape:l,end:r+a.length}}function YP(e,t=true){if(e.trimStart().startsWith(":::"))return e;const n=Tt([e],0)?.form==="inline";const i=e.trimStart();const r=t&&!i.startsWith("::")?Ib(i):null;if(r){const a=e.indexOf("%%",e.length-i.length+r.end);return a<0?e:e.slice(0,a)}let o=false;let s=false;for(let a=0;a<e.length-1;a++){const l=e[a];if(s){s=false;continue}if(l==="\\"){s=true;continue}if(l==='"'){o=!o;continue}if(o||l!=="%"||e[a+1]!=="%")continue;const c=e.slice(0,a).trim();if(!c||n||/^::icon\([^)]*\)$/.test(c))return e.slice(0,a);const d=qP(c);if(d&&d.shape!=="default")return e.slice(0,a)}return e}function wW(e){let t=0;for(const n of e){if(n===" ")t++;else if(n===" ")t+=4;else break}return t}var Fb=/^(?!mindmap\b)[^([\r\n){}]*$/i;function qP(e){return Bm(e)?.node??null}var MW=[{regex:/^(.*?)\(\((.*)\)\)$/,shape:"circle"},{regex:/^(.*?)\{\{(.*)\}\}$/,shape:"hexagon"},{regex:/^(.*?)\[([\s\S]*)\]$/,shape:"rect"},{regex:/^(.*?)\)\)(.*)\(\($/,shape:"bang"},{regex:/^(.*?)\)(.*)\($/,shape:"cloud"},{regex:/^(.*?)\((.*)\)$/,shape:"rounded"}];function Bm(e){const t=Ib(e);if(t&&!e.slice(t.end).trim()){const r=HP(t.id,t.label,t.shape);return r&&{node:r}}for(const{regex:r,shape:o}of MW){const s=e.match(r);if(!s)continue;const a=s[2];const l=!a.includes('"')&&kW(a)?HP(s[1].trim(),a,o):null;return l&&{node:l,nested:true}}if(!Fb.test(e))return null;const n=Nb(e);const i=Wm(n.label);return i?{node:{id:i,label:n.label,shape:"default",...n.markdown?{markdown:true}:{}}}:null}function HP(e,t,n){if(!Fb.test(e))return null;const i=Nb(t);const r=e||Wm(i.label);return r&&i.label?{id:r,label:i.label,shape:n,...i.markdown?{markdown:true}:{}}:null}function kW(e){const t=[];for(const n of e){const i=n==="("?")":n==="["?"]":n==="{"?"}":void 0;if(i)t.push(i);else if((n===")"||n==="]"||n==="}")&&t.pop()!==n)return false}return t.length===0}function Nb(e){let t=e.trim();const n=t.startsWith('"`')&&t.endsWith('`"');if(n)t=CW(Wo(t.slice(2,-2)));else{if(t.startsWith('"')&&t.endsWith('"'))t=t.slice(1,-1);t=Wo(t);t=t.replace(/\*\*([^*]+)\*\*/g,"$1").replace(/\*([^*]+)\*/g,"$1")}return{label:yo(yt(t),"*()[]").trim(),markdown:n}}function CW(e){return e.replace(/\*\*([\s\S]+?)\*\*/g,"<b>$1</b>").replace(/\*([\s\S]+?)\*/g,"<i>$1</i>")}function PW(e,t,n=""){const i=r=>{const o=(t==="bare"?"*()[{}":"#&*"+(t==="unquoted"?"":'"`'))+n+(r.includes("%%{")||t==="bare"&&/^%%/.test(e)?"%":"");let s=dn(t==="markdown"?r:r.replace(/\n/g,"<br/>"),o);if(t==="bare"&&/^mindmap\b/i.test(s))s=`#${s.codePointAt(0)};${s.slice(1)}`;return s};return t==="markdown"?e.split(/(<\/?[bi]>)/gi).map(r=>/^<\/?b>$/i.test(r)?"**":/^<\/?i>$/i.test(r)?"*":i(r)).join(""):i(e)}function Wm(e){return e.replace(/<\/?(?:b|i)>/gi,"").trim()}function Ab(e){const t=e.markdown;const n=t?"markdown":e.shape==="default"?"bare":/[()\]}]/.test(e.label)||e.label.startsWith('"')?"quoted":"unquoted";const i=e.id===Wm(e.label)&&(/[()[\]{}\r\n]/.test(e.id)||e.id.includes("%%{")||!Fb.test(e.id))?"":e.id;return nP(r=>{const o=PW(e.label,n,r);const s=t?`"\`${o}\`"`:n==="quoted"?`"${o}"`:o;return e.shape==="default"?s:e.shape==="rect"?`${i}[${s}]`:e.shape==="rounded"?`${i}(${s})`:e.shape==="circle"?`${i}((${s}))`:e.shape==="hexagon"?`${i}{{${s}}}`:e.shape==="cloud"?`${i})${s}(`:`${i}))${s}((`})}function XP(e,t){const n=a=>{if(a.shape==="default"&&(Ab(a)!==a.label.replace(/\n/g,"<br/>")||Nb(a.label).label!==a.label))return`Mindmap default node "${a.id}" needs text escapes that would change its identity; choose a bordered shape with an explicit identity before editing this text`;const l=a.shape!=="default"&&a.id===Wm(a.label);if(!l&&a.id.includes("%%{")||[a.icon,a.className].some(c=>c?.includes("%%{"))){return`Mindmap node "${a.id}" has an explicit identity or decoration containing a directive opener; rename that identity before editing its text`}for(const c of a.children){const d=n(c);if(d)return d}return void 0};const i=n(e.root);if(i||t===void 0)return i;const r=t.split(/\r?\n/);const o=r.findIndex(a=>/^\s*mindmap\s*$/i.test(a));const s=Wt(r,Om(r));for(const{raw:a}of Iu(s.familyLines,o+1)){const l=a.trim();if(!l||l.startsWith("%%")||l.startsWith("::"))continue;const c=Bm(l)?.node;if(!c||c.shape!=="default")continue;const d=h=>Dn(Un(h)).replace(/<br\s*\/?>/gi,"<br>");const u=d(l);const f=d(Ab({...c,children:[]}));if(f!==u)return`Mindmap default node "${c.id}" has an authored identity that cannot be reconstructed without changing its token; its source remains preserved`}return void 0}function FQ(e){const t=e.split(/\r?\n/);const n=t.findIndex(r=>/^\s*mindmap\s*$/i.test(r));const i=[];if(n<0)return i;for(const{raw:r,start:o}of Iu(t,n+1)){const s=r.trim();if(!s||s.startsWith("%%")||/^acc(?:Title|Descr)\b/i.test(s))continue;const a=Bm(s)?.node;const l=Ib(s)?.label;const c=s.includes("%%{")||l!==void 0&&/^"[\s\S]*"$/.test(l)&&/["`]/.test(l.slice(l.startsWith('"`')?2:1,l.endsWith('`"')?-2:-1));const d=c?"Mindmap label delimiters need grammar escapes for pinned Mermaid; the writer preserves their literal text":a?XP({root:{...a,children:[]}},`mindmap
|
|
2
|
-
${s}`):/^::/.test(s)&&s.includes("%%{")?"Mindmap decoration contains a directive opener with no portable spelling that preserves its text":void 0;if(d)i.push({line:o+1,message:d})}return i}function NQ(e){const t=XP(e);if(t)throw new tr(t);const n=["mindmap"];El(n,e);const i=(r,o)=>{const s=" ".repeat(o+1);const a=Ab(r);n.push(s+a);if(r.icon)n.push(`${s} ::icon(${r.icon})`);if(r.className)n.push(`${s} :::${r.className}`);for(const l of r.children)i(l,o+1)};i(e.root,0);return n.join("\n")+"\n"}function OQ(e,t){return e&&Object.hasOwn(e,t)?e[t]:void 0}function EW(e){const t=new Map;const n=[];for(let i=e.length-1;i>=0;i--){const[r,o]=e[i];let s=t.get(r);if(!s){s=new Set;t.set(r,s)}if(!s.has(o))n.push([r,o]);s.add(o)}return n.reverse()}function BQ(e){const t=EW(e);return new Set(t.map(([n])=>n)).size<t.length?t:void 0}function zm(e){const t=new Map;for(const[n,i]of e){t.delete(n);t.set(n,i)}return Object.fromEntries(t)}function Nu(...e){const t=new Map;for(const n of e)for(const[i,r]of Object.entries(n??{})){t.delete(i);t.set(i,r)}return Object.fromEntries(t)}function RW(e){const t=[];let n=0;let i=0;let r=false;let o="";for(let s=0;s<e.length;s++){const a=e[s];if(r){r=false;continue}if(a==="\\"){r=true;continue}if(o){if(a===o)o="";continue}if(a==='"'||a==="'"){o=a;continue}if(a==="(")n++;else if(a===")")n=Math.max(0,n-1);else if((a===","||a===";")&&n===0){t.push(e.slice(i,s));i=s+1}}t.push(e.slice(i));return t.map(s=>s.replace(/\\,/g,","))}function vn(e,t={}){return zm(vW(e,t))}function vW(e,t={}){const n=e.replace(/;\s*$/,"");const i=[];for(const r of RW(n)){const o=r.indexOf(":");if(o<=0)continue;const s=r.slice(0,o).trim();const a=t.caseInsensitive?s.toLowerCase():s;const l=r.slice(o+1).trim();if(a&&l)i.push([a,l])}return i}var TW=["fill","stroke","color"];function UP(e){for(const t of TW){const n=e[t];if(n!==void 0&&mn(n,t!=="color")===void 0)return{property:t,value:n}}return void 0}var Fu=class extends Error{code="INVALID_STYLE_COLOR";subject;property;value;constructor(t,n,i,r){super(Je({what:`${t}: ${n} ${JSON.stringify(i)} is not a CSS color`,expectedForm:Eu(n!=="color"),example:`${r?`${r} `:""}${n}:#f96`}).message);this.name="AuthoredStyleColorError";this.subject=t;this.property=n;this.value=i}};function LW(e,t,n){return new Fu(e,t.property,t.value,n)}function Lt(e,t){const n=e&&UP(e);if(n)throw LW(t,n,t);return e}function Gm(e){for(const[t,n]of e.classDefs)Lt(n,`classDef ${t}`);for(const[t,n]of e.nodeStyles)Lt(n,`style ${t}`);for(const[t,n]of e.linkStyles)Lt(n,`linkStyle ${t}`)}function Hm(e,t){for(const[n,i]of e)Lt(i,`classDef ${n}`);for(const n of t)Lt(n.inlineStyle,`style ${n.id}`)}function WQ(e){if(typeof e!=="string")return{ok:false,reason:"NOT_STRING"};if(/[\r\n]/.test(e))return{ok:false,reason:"MULTILINE"};const t=vn(e);if(Object.keys(t).length===0)return{ok:false,reason:"EMPTY"};const n=UP(t);return n?{ok:false,reason:"UNSAFE_PAINT",paint:n}:{ok:true,value:t}}function zQ(e){return Object.entries(e).map(([t,n])=>`${t}:${n}`).join(",")}function jm(e){return e?.split(/\s+/).filter(Boolean)??[]}function vs(e,t,n){const i=e.get(t);e.set(t,i?`${i} ${n}`:n)}var AW={default:{bg:xl.bg,fg:xl.fg},base:{bg:xl.bg,fg:xl.fg},neutral:{bg:"#ffffff",fg:"#1f2937",line:"#9ca3af",accent:"#6b7280",muted:"#6b7280"},dark:{bg:"#18181B",fg:"#FAFAFA"},forest:{bg:"#f0fdf4",fg:"#14532d",line:"#4d7c0f",accent:"#15803d",muted:"#65a30d",border:"#86efac"}};var Bi={bg:["background","mainBkg"],fg:["primaryTextColor","textColor","nodeTextColor"],line:["lineColor","defaultLinkColor"],accent:["arrowheadColor","primaryColor"],muted:["secondaryTextColor","tertiaryTextColor"],surface:["primaryColor","nodeBkg","mainBkg"],border:["primaryBorderColor","secondaryBorderColor"]};function Ym(e,t,n,i=false){const r=IW(t.theme);const o=t.themeVariables;const s=(...a)=>{const l=$b(o,...a);return i?l:Zn(l)};return{bg:e.bg??s(...Bi.bg)??r?.bg??xl.bg,fg:e.fg??s(...Bi.fg)??r?.fg??xl.fg,line:e.line??s(...Bi.line)??r?.line,accent:e.accent??s(...Bi.accent)??r?.accent,muted:e.muted??s(...Bi.muted)??r?.muted,surface:e.surface??s(...Bi.surface)??r?.surface,border:e.border??s(...Bi.border)??r?.border,shadow:e.shadow??r?.shadow,font:n,embedFontImport:e.embedFontImport}}function IW(e){if(typeof e!=="string"||!e)return void 0;return AW[e.toLowerCase()]}function $b(e,...t){if(!e)return void 0;for(const n of t){const i=e[n];if(typeof i==="string"&&i.length>0)return i}return void 0}function _b(e,t){let n;for(const r of jm(t.classAssignments.get(e))){const o=Lt(t.classDefs.get(r),`classDef ${r}`);if(o)n={...n,...o}}const i=Lt(t.nodeStyles.get(e),`style ${e}`);if(i)n=n?{...n,...i}:{...i};return n}function Db(e,t){let n;for(const i of jm(t.classAssignments.get(e))){const r=Lt(t.classDefs.get(i),`classDef ${i}`);if(r)n={...n,...r}}return n}function Yc(e,t){let n;const i=t.edges[e]?.id;for(const s of jm(i?t.classAssignments.get(i):void 0)){const a=Lt(t.classDefs.get(s),`classDef ${s}`);if(a)n={...n,...a}}const r=Lt(t.linkStyles.get("default"),"linkStyle default");if(r)n=n?{...n,...r}:{...r};const o=Lt(t.linkStyles.get(e),`linkStyle ${e}`);if(o)n=n?{...n,...o}:{...o};return n}function FW(e){const t=cl(e);return t?{r:t[0],g:t[1],b:t[2]}:null}function NW(e){const t=e.match(/^rgba?\(\s*(\d{1,3})(?:\s*,\s*|\s+)(\d{1,3})(?:\s*,\s*|\s+)(\d{1,3})/i);if(!t)return null;const n={r:Number.parseInt(t[1],10),g:Number.parseInt(t[2],10),b:Number.parseInt(t[3],10)};return Object.values(n).every(i=>i>=0&&i<=255)?n:null}function Ho(e){const t=FW(e)??NW(e);if(!t)return void 0;const n=Zh(`rgb(${t.r}, ${t.g}, ${t.b})`);return(n+.05)/.05>=1.05/(n+.05)?"#000000":"#FFFFFF"}function $u(e,t="var(--_text)"){if(e?.color)return e.color;if(e?.fill)return Ho(e.fill)??t;return t}var $W=new Set(["var(--_text)","var(--_text-sec)","var(--_text-muted)","var(--_text-faint)"]);function yi(e,t,n){if(!$W.has(e))return e;const i=_n(e,n);const r=_n(t,n);const o=i&&r?gu(r,_n("var(--bg)",n)??"#ffffff"):null;if(!o)return e;const s=e==="var(--_text-faint)"?k1:Lc;const a=ms(i,Yn(...o),s);return a===i?e:a}function Ts(e,t,n){const i=e?.color;if(i)return()=>i;if(!e?.fill)return n===void 0?s=>s:s=>yi(s,n,t);const r=gu(e.fill,_n("var(--bg)",t)??"#ffffff");if(!r)return s=>s;const o=Yn(...r);return s=>{const a=_n(s,t);return a?ms(a,o):Ho(o)??s}}function Ur(e){const t=new Map,n=new Map;return(i,r,o=false)=>{const s=o?n:t;let a=s.get(r);const l=a?.get(i);if(l!==void 0)return l;const c=o?Ts({fill:r},e,r)(i):yi(i,r,e);if(!a)s.set(r,a=new Map);a.set(i,c);return c}}var _u=new WeakMap;function Ob(e){return Object.freeze({...e,attempts:Object.freeze(e.attempts.map(t=>Object.freeze({...t})))})}function qm(e,t){const n=_u.get(e)??[];const i=Ob(t);if(n.some(r=>JSON.stringify(r)===JSON.stringify(i)))return;_u.set(e,Object.freeze([...n,i]))}function jo(e){return _u.get(e)??Object.freeze([])}function Du(e,t){const n=_u.get(e);if(n)_u.set(t,n)}var _W;var Bb;var Wb=0;function ei(e,t){const n=_W;if(!n)return t();const i=Bb,r=Wb;Bb=e;Wb++;const o=performance.now();try{return t()}finally{const s=performance.now()-o;Bb=i;Wb=r;n(Object.freeze({stage:e,ms:s,depth:r,...i?{parent:i}:{}}))}}var DW="agentic-layered@28";var bo=class extends Error{constructor(n){super(`Agentic graph layout does not support this input: ${n}`);this.reason=n;this.name="GraphLayoutUnsupportedError"}reason;code="GRAPH_LAYOUT_UNSUPPORTED"};var Xm;function VP(e,t){const n=Xm;Xm=e;try{return t()}finally{Xm=n}}function OW(e){Xm?.(Ob(e))}function Vr(e,t,n,i=false,r){const o=e.graphLayout;if(!o)return n();const s=[];let a,l=o.backend,c;if(o.backend==="agentic"){try{a=t()}catch(u){const f=u instanceof bo;if(!f&&!(i&&u instanceof Qe)||o.fallback!=="elk")throw u;c=f?u.reason:"candidate failed mandatory geometry certification";s.push({backend:"agentic",outcome:f?"unsupported":"candidate-rejected",reason:c});a=n();l="elk"}}else{a=n()}s.push({backend:l,outcome:"selected"});const d={requested:o.backend,fallback:o.fallback??"none",selected:l,attempts:s,implementation:l==="agentic"?DW:"elk-layered@1",...c?{reason:c}:{}};r?.(a,d);OW(d);return a}function ma(e){switch(e){case"LR":return"RIGHT";case"RL":return"LEFT";case"BT":return"UP";case"TD":case"TB":default:return"DOWN"}}function Ls(e){return ur(e)?e:void 0}function KP(e,t){const n=e.$ref;if(typeof n!=="string"||!n.startsWith("#/"))return void 0;let i=t;for(const r of n.slice(2).split("/")){if(!ur(i))return void 0;i=i[r.replaceAll("~1","/").replaceAll("~0","~")]}return Ls(i)}function zb(e,t,n){const i=KP(t,n);if(i)return zb(e,i,n);const r=Array.isArray(t.anyOf)?t.anyOf.map(Ls).filter(o=>o!==void 0):[];if(r.length>0)return r.some(o=>zb(e,o,n));switch(t.type){case"null":return e===null;case"string":return typeof e==="string";case"number":case"integer":return typeof e==="number";case"boolean":return typeof e==="boolean";case"array":return Array.isArray(e);case"object":return ur(e);default:return true}}function Gb(e,t,n=t,i=[],r={}){const o=r.diagnostics==="field";const s=(a,l,c,d,u)=>{const f=Ls(l.$defs)?l:c;const h=(S,x=true)=>[{path:d,message:S,generic:x}];if(l.$ref!==void 0){const S=KP(l,f);return S?s(a,S,f,d,u):h(o?"uses an unresolved schema reference":`uses unresolved schema reference ${String(l.$ref)}`,false)}const m=Array.isArray(l.anyOf)?l.anyOf.map(Ls).filter(S=>S!==void 0):[];if(m.length>0){const S=o?m.filter(w=>zb(a,w,f)):[];const x=S.length>0?S:m;const k=x.map(w=>s(a,w,f,d,new Set(u)));if(!k.some(w=>w.length===0)){const w=l["x-agentic-mermaid-validation-expectation"];if((!o||S.length===0)&&typeof w==="string")return h(`must be ${w}`);return k.sort((C,R)=>C.length-R.length)[0]??h("must match an allowed shape")}}const p=Array.isArray(l.oneOf)?l.oneOf.map(Ls).filter(S=>S!==void 0):[];if(p.length>0&&!o){const S=p.filter(x=>s(a,x,f,d,new Set(u)).length===0);if(S.length!==1)return h(`must match exactly one allowed shape (matched ${S.length})`)}const g=o?(S,x)=>S===x:Object.is;if(Object.prototype.hasOwnProperty.call(l,"const")&&!g(a,l.const))return h(`must equal ${String(l.const)}`);if(Array.isArray(l.enum)&&!(o?l.enum.includes(a):l.enum.some(S=>Object.is(S,a)))){return h(`must be one of ${l.enum.map(String).join(" | ")}`)}const y=l.type;const b=y===void 0||y==="null"&&a===null||y==="string"&&typeof a==="string"||y==="number"&&typeof a==="number"&&Number.isFinite(a)||y==="integer"&&typeof a==="number"&&Number.isFinite(a)&&Number.isInteger(a)||y==="boolean"&&typeof a==="boolean"||y==="array"&&Array.isArray(a)||y==="object"&&ur(a);if(!b){const S=y==="number"?"a finite number":y==="integer"?"a finite integer":y==="object"?"a plain JSON object":y==="array"?"an array":y==="null"?"null":`a ${String(y)}`;return h(`must be ${S}`)}if(typeof a==="number"){if(typeof l.minimum==="number"&&a<l.minimum)return h(`must be at least ${l.minimum}`);if(typeof l.exclusiveMinimum==="number"&&a<=l.exclusiveMinimum)return h(`must be greater than ${l.exclusiveMinimum}`);if(typeof l.maximum==="number"&&a>l.maximum)return h(`must be at most ${l.maximum}`)}if(typeof a==="string"){if(typeof l.minLength==="number"&&a.length<l.minLength)return h(`must contain at least ${l.minLength} character${l.minLength===1?"":"s"}`);if(typeof l.pattern==="string"){let S;try{S=new RegExp(l.pattern,o?void 0:"u").test(a)}catch{return h("uses an invalid schema pattern",false)}if(!S)return h(r.patternMismatch?.(l)??`must match ${l.pattern}`)}if(typeof l.maxLength==="number"&&a.length>l.maxLength)return h(`must contain at most ${l.maxLength} characters`)}if(Array.isArray(a)&&y==="array"){if(typeof l.minItems==="number"&&a.length<l.minItems)return h(`must contain at least ${l.minItems} item${l.minItems===1?"":"s"}`);if(typeof l.maxItems==="number"&&a.length>l.maxItems)return h(`must contain at most ${l.maxItems} items`);if(u.has(a))return h("must be acyclic",false);const S=Ls(l.items);if(S){u.add(a);try{const x=a.flatMap((k,w)=>s(k,S,f,[...d,w],u));if(x.length>0)return x}finally{u.delete(a)}}}if(ur(a)&&(y==="object"||l.properties!==void 0||l.required!==void 0||l.additionalProperties!==void 0)){if(u.has(a))return h("must be acyclic",false);u.add(a);try{const S=Ls(l.properties)??{};const x=Array.isArray(l.required)?l.required.filter(w=>typeof w==="string"):[];const k=[];for(const w of x){if(!Object.prototype.hasOwnProperty.call(a,w))k.push({path:[...d,w],message:"is required",generic:false})}for(const[w,C]of Object.entries(a)){if(cm(w)){k.push({path:[...d,w],message:"uses a forbidden prototype key",generic:false});continue}const R=Ls(S[w]);if(R){k.push(...s(C,R,f,[...d,w],u));continue}if(l.additionalProperties===false){k.push({path:[...d,w],message:"is not allowed",generic:false});continue}const M=Ls(l.additionalProperties);if(M)k.push(...s(C,M,f,[...d,w],u))}if(k.length>0)return k}finally{u.delete(a)}}return r.validateRuntime?.(a,l,d)??[]};return s(e,t,n,i,new Set)}import{decodeXML as Gu}from"entities";function JP(){let e=1e5;function t(){if(--e<0){const ne=new Error("Configuration validation exceeded 100000 loop steps");ne.name="MermaidConfigWorkLimitError";throw ne}}var n=(ne,we,{depth:Ee=2}={})=>{let ke={depth:Ee};if(Array.isArray(we)&&!Array.isArray(ne))return we.forEach(le=>n(ne,le,ke)),ne;else if(Array.isArray(we)&&Array.isArray(ne))return we.forEach(le=>{if(!ne.includes(le))ne.push(le)}),ne;if(ne===void 0||ne===null||Ee<=0)if(ne!==void 0&&ne!==null&&typeof ne==="object"&&typeof we==="object")return Object.assign(ne,we);else return we;if(we!==void 0&&we!==null&&typeof ne==="object"&&typeof we==="object"){let le=ne;Object.entries(we).forEach(([Se,Pe])=>{if(typeof Pe==="object"){if(Pe===null)return;if(!Object.hasOwn(ne,Se))Object.defineProperty(ne,Se,{value:void 0,writable:true,enumerable:true,configurable:true});if(le[Se]===void 0)le[Se]=Array.isArray(Pe)?[]:{};if(typeof le[Se]==="object")le[Se]=n(le[Se],Pe,{depth:Ee-1})}else if(typeof le[Se]!=="object")if(Object.hasOwn(ne,Se))le[Se]=Pe;else Object.defineProperty(ne,Se,{value:Pe,writable:true,enumerable:true,configurable:true})})}return ne},i=n;var r=new Set(["flowchart","useMaxWidth","theme","look","titleTopMargin","subGraphTitleMargin","top","bottom","diagramPadding","htmlLabels","nodeSpacing","rankSpacing","curve","padding","wrappingWidth","minNodeWidth","inheritDir","swimlane","layout","lineHops","ignoreCrossLaneEdges","optimizeRanksByCrossings","automaticLaneOrdering","agentflow","sequence","hideUnusedParticipants","activationWidth","diagramMarginX","diagramMarginY","actorMargin","width","height","boxMargin","boxTextMargin","noteMargin","messageMargin","messageAlign","mirrorActors","forceMenus","bottomMarginAdj","rightAngles","showSequenceNumbers","actorFontSize","actorFontFamily","actorFontWeight","noteFontSize","noteFontFamily","noteFontWeight","noteAlign","messageFontSize","messageFontFamily","messageFontWeight","wrap","wrapPadding","labelBoxWidth","labelBoxHeight","messageFont","noteFont","actorFont","gantt","barHeight","barGap","topPadding","rightPadding","leftPadding","gridLineStartPadding","fontSize","sectionFontSize","numberSectionStyles","axisFormat","topAxis","displayMode","weekday","tickInterval","useWidth","journey","leftMargin","maxLabelWidth","taskFontSize","taskFontFamily","taskMargin","textPlacement","titleColor","titleFontFamily","titleFontSize","class","hideEmptyMembersBox","hierarchicalNamespaces","state","dividerMargin","sizeUnit","textHeight","titleShift","forkWidth","forkHeight","miniPadding","fontSizeFactor","labelHeight","edgeLengthFactor","compositTitleSize","radius","er","layoutDirection","minEntityWidth","minEntityHeight","entityPadding","stroke","fill","pie","textPosition","donutHole","legendPosition","highlightSlice","quadrantChart","chartWidth","chartHeight","titlePadding","quadrantPadding","xAxisLabelPadding","yAxisLabelPadding","xAxisLabelFontSize","yAxisLabelFontSize","quadrantLabelFontSize","quadrantTextTopPadding","pointTextPadding","pointLabelFontSize","pointRadius","xAxisPosition","yAxisPosition","quadrantInternalBorderStrokeWidth","quadrantExternalBorderStrokeWidth","xyChart","showDataLabel","showDataLabelOutsideBar","showTitle","showLegend","legendFontSize","legendPadding","xAxis","$ref","showLabel","labelFontSize","labelPadding","showTick","tickLength","tickWidth","showAxisLine","axisLineWidth","labelRotation","yAxis","chartOrientation","plotReservedSpacePercent","requirement","rect_fill","text_color","rect_border_size","rect_border_color","rect_min_width","rect_min_height","rect_padding","line_height","mindmap","colorBy","maxNodeWidth","layoutAlgorithm","ishikawa","kanban","sectionWidth","ticketBaseUrl","timeline","disableMulticolor","gitGraph","nodeLabel","x","y","mainBranchName","mainBranchOrder","showCommitLabel","showBranches","rotateCommitLabel","parallelCommits","arrowMarkerAbsolute","c4","c4ShapeMargin","c4ShapePadding","c4ShapeInRow","nextLinePaddingX","c4BoundaryInRow","personFontSize","personFontFamily","personFontWeight","external_personFontSize","external_personFontFamily","external_personFontWeight","systemFontSize","systemFontFamily","systemFontWeight","external_systemFontSize","external_systemFontFamily","external_systemFontWeight","system_dbFontSize","system_dbFontFamily","system_dbFontWeight","external_system_dbFontSize","external_system_dbFontFamily","external_system_dbFontWeight","system_queueFontSize","system_queueFontFamily","system_queueFontWeight","external_system_queueFontSize","external_system_queueFontFamily","external_system_queueFontWeight","boundaryFontSize","boundaryFontFamily","boundaryFontWeight","containerFontSize","containerFontFamily","containerFontWeight","external_containerFontSize","external_containerFontFamily","external_containerFontWeight","container_dbFontSize","container_dbFontFamily","container_dbFontWeight","external_container_dbFontSize","external_container_dbFontFamily","external_container_dbFontWeight","container_queueFontSize","container_queueFontFamily","container_queueFontWeight","external_container_queueFontSize","external_container_queueFontFamily","external_container_queueFontWeight","componentFontSize","componentFontFamily","componentFontWeight","external_componentFontSize","external_componentFontFamily","external_componentFontWeight","component_dbFontSize","component_dbFontFamily","component_dbFontWeight","external_component_dbFontSize","external_component_dbFontFamily","external_component_dbFontWeight","component_queueFontSize","component_queueFontFamily","component_queueFontWeight","external_component_queueFontSize","external_component_queueFontFamily","external_component_queueFontWeight","person_bg_color","person_border_color","external_person_bg_color","external_person_border_color","system_bg_color","system_border_color","system_db_bg_color","system_db_border_color","system_queue_bg_color","system_queue_border_color","external_system_bg_color","external_system_border_color","external_system_db_bg_color","external_system_db_border_color","external_system_queue_bg_color","external_system_queue_border_color","container_bg_color","container_border_color","container_db_bg_color","container_db_border_color","container_queue_bg_color","container_queue_border_color","external_container_bg_color","external_container_border_color","external_container_db_bg_color","external_container_db_border_color","external_container_queue_bg_color","external_container_queue_border_color","component_bg_color","component_border_color","component_db_bg_color","component_db_border_color","component_queue_bg_color","component_queue_border_color","external_component_bg_color","external_component_border_color","external_component_db_bg_color","external_component_db_border_color","external_component_queue_bg_color","external_component_queue_border_color","personFont","external_personFont","systemFont","external_systemFont","system_dbFont","external_system_dbFont","system_queueFont","external_system_queueFont","containerFont","external_containerFont","container_dbFont","external_container_dbFont","container_queueFont","external_container_queueFont","componentFont","external_componentFont","component_dbFont","external_component_dbFont","component_queueFont","external_component_queueFont","boundaryFont","sankey","linkColor","nodeAlignment","showValues","prefix","suffix","nodeWidth","nodePadding","labelStyle","nodeColors","block","packet","rowHeight","bitWidth","bitsPerRow","showBits","bitOrder","paddingX","paddingY","treeView","rowIndent","lineThickness","showIcons","defaultIconPack","filenameIcons","extensionIcons","architecture","iconSize","randomize","nodeSeparation","idealEdgeLengthMultiplier","edgeElasticity","numIter","seed","eventmodeling","radar","marginTop","marginRight","marginBottom","marginLeft","axisScaleFactor","axisLabelFactor","curveTension","usecase","usecaseFontSize","usecaseFontFamily","usecaseFontWeight","colorScheme","venn","useDebugLayout","cynefin","showDomainDescriptions","boundaryAmplitude","handDrawnSeed","maxTextSize","maxEdges","darkMode","fontFamily","logLevel","securityLevel","startOnLoad","legacyMathML","forceLegacyMathML","deterministicIds","markdownAutoWrap","suppressErrorRendering","deterministicIDSeed","elk","mergeEdges","straightenEdges","preset","nodePlacementStrategy","layeringStrategy","cycleBreakingStrategy","layeringLayerBound","nodePlacementAlignment","forceNodeModelOrder","considerModelOrder","keepEntryNodeOnTop","orientFeedbackEdges","themeCSS","themeVariables","background","primaryColor","secondaryColor","tertiaryColor","primaryBorderColor","secondaryBorderColor","tertiaryBorderColor","primaryTextColor","secondaryTextColor","tertiaryTextColor","lineColor","textColor","mainBkg","secondBkg","border1","border2","arrowheadColor","labelBackground","THEME_COLOR_LIMIT","strokeWidth","nodeBkg","nodeBorder","clusterBkg","clusterBorder","defaultLinkColor","edgeLabelBackground","actorBorder","actorBkg","actorTextColor","actorLineColor","signalColor","signalTextColor","labelBoxBkgColor","labelBoxBorderColor","labelTextColor","loopTextColor","noteBorderColor","noteBkgColor","noteTextColor","activationBorderColor","activationBkgColor","sequenceNumberColor","sectionBkgColor","altSectionBkgColor","sectionBkgColor2","excludeBkgColor","taskBorderColor","taskBkgColor","taskTextLightColor","taskTextColor","taskTextDarkColor","taskTextOutsideColor","taskTextClickableColor","activeTaskBorderColor","activeTaskBkgColor","gridColor","doneTaskBkgColor","doneTaskBorderColor","critBorderColor","critBkgColor","todayLineColor","vertLineColor","fontWeight","personBorder","personBkg","archEdgeColor","archEdgeArrowColor","archEdgeWidth","archGroupBorderColor","archGroupBorderWidth","rowOdd","rowEven","labelColor","errorBkgColor","errorTextColor","useGradient","gradientStart","gradientStop","dropShadow","cScale0","cScale1","cScale2","cScale3","cScale4","cScale5","cScale6","cScale7","cScale8","cScale9","cScale10","cScale11","cScalePeer1","cScalePeer2","cScalePeer0","cScalePeer3","cScalePeer4","cScalePeer5","cScalePeer6","cScalePeer7","cScalePeer8","cScalePeer9","cScalePeer10","cScalePeer11","cScaleInv0","cScaleInv1","cScaleInv2","cScaleInv3","cScaleInv4","cScaleInv5","cScaleInv6","cScaleInv7","cScaleInv8","cScaleInv9","cScaleInv10","cScaleInv11","surface0","surfacePeer0","surface1","surfacePeer1","surface2","surfacePeer2","surface3","surfacePeer3","surface4","surfacePeer4","scaleLabelColor","flowContainerStroke","rectBkgColor","transitionColor","transitionLabelColor","stateLabelColor","stateBkg","labelBackgroundColor","compositeBackground","altBackground","compositeTitleBackground","compositeBorder","innerEndBackground","specialStateColor","classText","fillType0","fillType1","fillType2","fillType3","fillType4","fillType5","fillType6","fillType7","pie1","pie2","pie3","pie4","pie5","pie6","pie7","pie8","pie9","pie10","pie11","pie12","pieTitleTextSize","pieTitleTextColor","pieSectionTextSize","pieSectionTextColor","pieLegendTextSize","pieLegendTextColor","pieStrokeColor","pieStrokeWidth","pieOuterStrokeWidth","pieOuterStrokeColor","pieOpacity","venn1","venn2","venn3","venn4","venn5","venn6","venn7","venn8","vennTitleTextColor","vennSetTextColor","domainFontSize","itemFontSize","boundaryColor","boundaryWidth","cliffColor","cliffWidth","arrowColor","arrowWidth","complexBg","complicatedBg","chaoticBg","clearBg","confusionBg","quadrant1Fill","quadrant2Fill","quadrant3Fill","quadrant4Fill","quadrant1TextFill","quadrant2TextFill","quadrant3TextFill","quadrant4TextFill","quadrantPointFill","quadrantPointTextFill","quadrantXAxisTextFill","quadrantYAxisTextFill","quadrantInternalBorderStrokeFill","quadrantExternalBorderStrokeFill","quadrantTitleFill","axisColor","axisStrokeWidth","axisLabelFontSize","curveOpacity","curveStrokeWidth","graticuleColor","graticuleStrokeWidth","graticuleOpacity","legendBoxSize","wardleyEvolutionColor","wardley","backgroundColor","axisTextColor","componentFill","componentStroke","componentLabelColor","linkStroke","evolutionStroke","annotationStroke","annotationTextColor","annotationFill","dataLabelColor","legendTextColor","xAxisTitleColor","xAxisLabelColor","xAxisTickColor","xAxisLineColor","yAxisTitleColor","yAxisLabelColor","yAxisTickColor","yAxisLineColor","plotColorPalette","requirementBackground","requirementBorderColor","requirementBorderSize","requirementTextColor","relationColor","relationLabelBackground","relationLabelColor","git0","git1","git2","git3","git4","git5","git6","git7","gitInv0","gitInv1","gitInv2","gitInv3","gitInv4","gitInv5","gitInv6","gitInv7","gitBranchLabel0","gitBranchLabel1","gitBranchLabel2","gitBranchLabel3","gitBranchLabel4","gitBranchLabel5","gitBranchLabel6","gitBranchLabel7","tagLabelColor","tagLabelBackground","tagLabelBorder","tagLabelFontSize","commitLabelColor","commitLabelBackground","commitLabelFontSize","emUiFill","emUiStroke","emProcessorFill","emProcessorStroke","emReadModelFill","emReadModelStroke","emCommandFill","emCommandStroke","emEventFill","emEventStroke","emSwimlaneBackgroundOdd","emSwimlaneBackgroundStroke","emArrowhead","emRelationStroke","attributeBackgroundColorOdd","attributeBackgroundColorEven","cScaleLabel0","cScaleLabel3","cScaleLabel1","cScaleLabel2","cScaleLabel4","cScaleLabel5","cScaleLabel6","cScaleLabel7","cScaleLabel8","cScaleLabel9","cScaleLabel10","cScaleLabel11","railroad","terminalFill","terminalStroke","terminalTextColor","nonTerminalFill","nonTerminalStroke","nonTerminalTextColor","markerFill","commentFill","commentStroke","commentTextColor","specialFill","specialStroke","ruleNameColor","treemap","nodeHeight","borderWidth","valueFontSize","valueFormat"]);var o={trace(){},debug(){},info(){},warn(){},error(){},fatal(){}};var s={nodeColors:/^#[\da-f]{3,8}$|^rgb\([\d\s%,.]+\)$|^hsl\([\d\s%,.]+\)$|^[a-z]+$/i,filenameIcons:/^[\w-]+(?::[\w-]+)?$/,extensionIcons:/^[\w-]+(?::[\w-]+)?$/},a=(ne,we)=>{for(let Ee of Object.keys(ne)){t();let ke=ne[Ee];if(Ee.startsWith("__")||Ee.includes("proto")||Ee.includes("constr")||typeof ke!=="string"||!we.test(ke))o.debug("sanitize deleting dictionary entry:",Ee,ke),delete ne[Ee]}},l=ne=>{if(o.debug("sanitizeDirective called with",ne),typeof ne!=="object"||ne==null)return;if(Array.isArray(ne)){ne.forEach(we=>l(we));return}for(let we of Object.keys(ne)){t();if(o.debug("Checking key",we),we.startsWith("__")||we.includes("proto")||we.includes("constr")||!r.has(we)||ne[we]==null){o.debug("sanitize deleting key: ",we),delete ne[we];continue}if(typeof ne[we]==="object"){let ke=s[we];if(ke)a(ne[we],ke);else o.debug("sanitizing object",we),l(ne[we]);continue}let Ee=["themeCSS","fontFamily","altFontFamily"];for(let ke of Ee){t();if(we.includes(ke))o.debug("sanitizing css option",we),ne[we]=c(ne[we])}}if(ne.themeVariables)for(let we of Object.keys(ne.themeVariables)){t();let Ee=ne.themeVariables[we];if(Ee?.match&&!Ee.match(/^[\d "#%(),.;A-Za-z]+$/))ne.themeVariables[we]=""}o.debug("After sanitization",ne)},c=ne=>{let we=0,Ee=0;for(let ke of ne){t();if(we<Ee)return"{ /* ERROR: Unbalanced CSS */ }";if(ke==="{")we++;else if(ke==="}")Ee++}if(we!==Ee)return"{ /* ERROR: Unbalanced CSS */ }";return ne};function d(){}function u(ne){return ne==null||typeof ne!=="object"&&typeof ne!=="function"}function f(ne){return Object.getOwnPropertySymbols(ne).filter(we=>Object.prototype.propertyIsEnumerable.call(ne,we))}var h=typeof globalThis==="object"&&globalThis||typeof window==="object"&&window||typeof self==="object"&&self||typeof global==="object"&&global||(function(){return this})();function m(ne){return typeof h.Buffer<"u"&&h.Buffer.isBuffer(ne)}function p(ne){return ne==="__proto__"}function g(ne){if(typeof ne!=="object")return false;if(ne==null)return false;if(Object.getPrototypeOf(ne)===null)return true;if(Object.prototype.toString.call(ne)!=="[object Object]"){var we;let ke=ne[Symbol.toStringTag];if(ke==null)return false;if(!((we=Object.getOwnPropertyDescriptor(ne,Symbol.toStringTag))===null||we===void 0?void 0:we.writable))return false;return ne.toString()===`[object ${ke}]`}let Ee=ne;while(Object.getPrototypeOf(Ee)!==null){t();Ee=Object.getPrototypeOf(Ee)}return Object.getPrototypeOf(ne)===Ee}function y(ne){return ArrayBuffer.isView(ne)&&!(ne instanceof DataView)}function b(ne){return y(ne)}function S(ne){if(ne==null)return ne===void 0?"[object Undefined]":"[object Null]";return Object.prototype.toString.call(ne)}var x="[object RegExp]",k="[object String]",w="[object Number]",C="[object Boolean]",R="[object Arguments]",M="[object Symbol]",P="[object Date]",E="[object Map]",v="[object Set]",L="[object Array]";var T="[object ArrayBuffer]",A="[object Object]";var $="[object DataView]",_="[object Uint8Array]",z="[object Uint8ClampedArray]",F="[object Uint16Array]",G="[object Uint32Array]";var I="[object Int8Array]",D="[object Int16Array]",B="[object Int32Array]";var Y="[object Float32Array]",W="[object Float64Array]";var O=Object.prototype.hasOwnProperty;function N(ne,we){return O.call(ne,we)}function H(ne){return m(ne)}function j(ne,we){return q(ne,void 0,ne,new Map,we)}function q(ne,we,Ee,ke,le){if(le!=null){let Pe=le(ne,we,Ee,ke);if(Pe!==void 0)return Pe}if(u(ne))return ne;if(ke.has(ne))return ke.get(ne);if(Array.isArray(ne)){let Pe=Array(ne.length);ke.set(ne,Pe);for(let Ae=0;Ae<ne.length;Ae++){t();Pe[Ae]=q(ne[Ae],Ae,Ee,ke,le)}if(N(ne,"index"))Pe.index=ne.index;if(N(ne,"input"))Pe.input=ne.input;return Pe}if(ne instanceof Date)return new Date(ne.getTime());if(ne instanceof RegExp){let Pe=new RegExp(ne.source,ne.flags);return Pe.lastIndex=ne.lastIndex,Pe}if(ne instanceof Map){let Pe=new Map;return ke.set(ne,Pe),ne.forEach((Ae,Ne)=>{Pe.set(Ne,q(Ae,Ne,Ee,ke,le))}),Pe}if(ne instanceof Set){let Pe=new Set;return ke.set(ne,Pe),ne.forEach(Ae=>{Pe.add(q(Ae,void 0,Ee,ke,le))}),Pe}if(H(ne))return ne.subarray();if(b(ne)){let Pe=new(Object.getPrototypeOf(ne)).constructor(ne.length);ke.set(ne,Pe);for(let Ae=0;Ae<ne.length;Ae++){t();Pe[Ae]=q(ne[Ae],Ae,Ee,ke,le)}return Pe}if(ne instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&ne instanceof SharedArrayBuffer)return ne.slice(0);if(ne instanceof DataView){let Pe=new DataView(ne.buffer.slice(0),ne.byteOffset,ne.byteLength);return ke.set(ne,Pe),X(Pe,ne,Ee,ke,le),Pe}if(typeof File<"u"&&ne instanceof File){let Pe=new File([ne],ne.name,{type:ne.type});return ke.set(ne,Pe),X(Pe,ne,Ee,ke,le),Pe}if(typeof Blob<"u"&&ne instanceof Blob){let Pe=new Blob([ne],{type:ne.type});return ke.set(ne,Pe),X(Pe,ne,Ee,ke,le),Pe}let Se=S(ne);if(Se==="[object Error]"){if(ne===Ee)return{};return ne}switch(Se){case w:case k:case C:{let Pe=new ne.constructor(ne.valueOf());return ke.set(ne,Pe),X(Pe,ne,Ee,ke,le),Pe}case R:{let Pe={};return ke.set(ne,Pe),X(Pe,ne,Ee,ke,le),Pe.length=ne.length,Pe[Symbol.iterator]=ne[Symbol.iterator],Pe}}if(typeof ne==="object"&&V(Se)){let Pe=Se==="[object Object]"&&typeof ne.constructor!=="function"?{}:Object.create(Object.getPrototypeOf(ne));return ke.set(ne,Pe),X(Pe,ne,Ee,ke,le),Pe}return ne}function X(ne,we,Ee,ke,le){let Se=[...Object.keys(we),...f(we)];for(let Pe=0;Pe<Se.length;Pe++){t();let Ae=Se[Pe],Ne=Object.getOwnPropertyDescriptor(ne,Ae);if(Ne==null||Ne.writable)ne[Ae]=q(we[Ae],Ae,Ee,ke,le)}}function V(ne){switch(ne){case R:case L:case T:case $:case C:case P:case Y:case W:case I:case D:case B:case E:case w:case A:case x:case v:case k:case M:case _:case z:case F:case G:return true;default:return false}}function ee(ne){return j(ne)}function re(ne){return ne!==null&&typeof ne==="object"&&S(ne)==="[object Arguments]"}function U(ne){return typeof ne==="object"&&ne!==null}function te(ne){return Number.isSafeInteger(ne)&&ne>=0}function J(ne){return ne!=null&&typeof ne!=="function"&&te(ne.length)}function ae(ne){return U(ne)&&J(ne)}function Q(ne){if(u(ne))return ne;if(Array.isArray(ne)||y(ne)||ne instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&ne instanceof SharedArrayBuffer)return ne.slice(0);let we=Object.getPrototypeOf(ne);if(we==null)return Object.assign(Object.create(we),ne);let Ee=we.constructor;if(ne instanceof Date||ne instanceof Map||ne instanceof Set)return new Ee(ne);if(ne instanceof RegExp){let ke=new Ee(ne);return ke.lastIndex=ne.lastIndex,ke}if(ne instanceof DataView)return new Ee(ne.buffer.slice(0));if(ne instanceof Error){let ke;if(typeof AggregateError<"u"&&ne instanceof AggregateError)ke=new Ee(ne.errors,ne.message,{cause:ne.cause});else ke=new Ee(ne.message,{cause:ne.cause});return ke.stack=ne.stack,Object.assign(ke,ne),ke}if(typeof File<"u"&&ne instanceof File)return new Ee([ne],ne.name,{type:ne.type,lastModified:ne.lastModified});if(typeof ne==="object"){let ke=Object.create(we);return Object.assign(ke,ne)}return ne}function K(ne,...we){let Ee=we.slice(0,-1),ke=we[we.length-1],le=ne;for(let Se=0;Se<Ee.length;Se++){t();let Pe=Ee[Se];le=Z(le,Pe,ke,new Map)}return le}function Z(ne,we,Ee,ke){if(u(ne))ne=Object(ne);if(we==null||typeof we!=="object")return ne;if(ke.has(we))return Q(ke.get(we));if(ke.set(we,ne),Array.isArray(we)){we=we.slice();for(let Se=0;Se<we.length;Se++){t();if(!(Se in we))we[Se]=void 0}}let le=[...Object.keys(we),...f(we)];for(let Se=0;Se<le.length;Se++){t();let Pe=le[Se];if(p(Pe))continue;let Ae=we[Pe],Ne=ne[Pe];if(re(Ae))Ae=Object.assign({},Ae);if(re(Ne))Ne=Object.assign({},Ne);if(m(Ae))Ae=ee(Ae);if(Array.isArray(Ae))if(Array.isArray(Ne)){let We=[],ce=Reflect.ownKeys(Ne);for(let Le=0;Le<ce.length;Le++){t();let ve=ce[Le];We[ve]=Ne[ve]}Ne=We}else if(ae(Ne)){let We=[];for(let ce=0;ce<Ne.length;ce++){t();We[ce]=Ne[ce]}Ne=We}else Ne=[];let Oe=Ee(Ne,Ae,Pe,ne,we,ke);if(Oe!==void 0)ne[Pe]=Oe;else if(Array.isArray(Ae))ne[Pe]=Z(Ne,Ae,Ee,ke);else if(U(Ne)&&U(Ae)&&(g(Ne)||g(Ae)||b(Ne)||b(Ae)))ne[Pe]=Z(Ne,Ae,Ee,ke);else if(Ne==null&&g(Ae))ne[Pe]=Z({},Ae,Ee,ke);else if(Ne==null&&b(Ae))ne[Pe]=ee(Ae);else if(Ne===void 0||Ae!==void 0)ne[Pe]=Ae}return ne}function se(ne,...we){return K(ne,...we,d)}var oe={debug(){},error(){}},de="",xe=false,Me=()=>de;function Ce(ne,we){if(!ne||!we||typeof ne!=="object"||typeof we!=="object")return;for(let Ee of Object.keys(we)){t();if(typeof ne[Ee]==="string"&&typeof we[Ee]==="string")we[Ee]=ne[Ee];else Ce(ne[Ee],we[Ee])}}function pe(ne){let we=xe?structuredClone(ne):void 0;if(l(ne),we)Ce(we,ne)}var Te=/%{2}{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,Fe=/\s*(?:(\w+)(?=:):|(\w+))\s*(?:(\w+)|((?:(?!}%{2}).|\r?\n)*))?\s*(?:}%{2})?/gi,De=function(ne,we=null){try{let Ee=new RegExp(`[%]{2}(?![{]${Fe.source})(?=[}][%]{2}).*
|
|
3
|
-
`,"ig");ne=ne.trim().replace(Ee,"").replace(/'/gm,'"'),oe.debug(`Detecting diagram directive${we!==null?" type:"+we:""} based on the text:${ne}`);let ke,le=[];while((ke=Te.exec(ne))!==null){t();if(ke.index===Te.lastIndex)Te.lastIndex++;if(ke&&!we||we&&ke[1]?.match(we)||we&&ke[2]?.match(we)){let Se=ke[1]?ke[1]:ke[2],Pe=ke[3]?ke[3].trim():ke[4]?JSON.parse(ke[4].trim()):null;le.push({type:Se,args:Pe})}}if(le.length===0)return{type:ne,args:null};return le.length===1?le[0]:le}catch(Ee){return oe.error(`ERROR: ${Ee.message} - Unable to parse directive type: '${we}' based on the text: '${ne}'`),{type:void 0,args:null}}},Be=function(ne,we){let Ee=De(ne,/(?:init\b)|(?:initialize\b)/),ke={};if(Array.isArray(Ee)){let Pe=Ee.map(Ae=>Ae.args);pe(Pe),ke=i(ke,[...Pe])}else ke=Ee.args;if(!ke)return;let le=Me(ne,we),Se="config";if(ke[Se]!==void 0){if(le==="flowchart-v2")le="flowchart";ke[le]=ke[Se],delete ke[Se]}return ke},me=function(ne){return ne.replace(Te,"")},he={detectInit:Be,detectDirective:De},fe=ne=>{let we=he.detectInit(ne)??{},Ee=he.detectDirective(ne,"wrap");if(Array.isArray(Ee))we.wrap=Ee.some(({type:ke})=>ke==="wrap");else if(Ee?.type==="wrap")we.wrap=true;return{text:me(ne),directive:we}};function be(ne,we,Ee=true){if(!/^\w+$/.test(ne))throw Error("Invalid directive name");if(!Ee)return"%%{"+ne+"}%%";let ke=(Object.is(we,-0)?"-0":JSON.stringify(we)).replace(/[&<>#%'\u2028\u2029]/g,Ae=>"\\u"+Ae.charCodeAt(0).toString(16).padStart(4,"0")),le="%%{"+ne+": "+ke+"}%%";Te.lastIndex=0;let Se=Te.exec(le);Te.lastIndex=0;let Pe=De(le,ne);if(!Se||Se[0]!==le||!Object.is(typeof Pe.args,typeof we))throw Error("init argument has no complete pinned scalar token");return le}function ge(ne){return be("init",ne)}function Re(ne,we,Ee,ke=false){de=Ee,xe=ke;try{return se({},structuredClone(ne),fe(we).directive)}finally{xe=false}}function Ie(ne,we,Ee,ke=false,le=false){de=Ee,xe=le;try{let Se=we.map(ge).join(`
|
|
4
|
-
`)+(ke?`
|
|
5
|
-
%%{wrap}%%`:"");return Re(ne,Se,Ee,le)}finally{xe=false}}return{configDirective:be,initDirective:ge,mergeConfig:Ie,mergeConfigSource:Re}}function QP(...e){return JP().configDirective(...e)}function ZP(...e){return JP().mergeConfigSource(...e)}function eE(e){const t=e.split(/[;:\s]/,1)[0].replace(/-(?:v2|beta)$/i,"").toLowerCase();if(/^c4(?:context|container|component|dynamic|deployment)?$/.test(t))return"c4";return{graph:"flowchart-v2",flowchart:"flowchart-v2",class:"classDiagram",classdiagram:"classDiagram",state:"stateDiagram",statediagram:"stateDiagram",sequencediagram:"sequence",erdiagram:"er",requirementdiagram:"requirement",quadrant:"quadrantChart",quadrantchart:"quadrantChart",gitgraph:"gitGraph"}[t]??t}var Um=/^note\s+(left|right)\s+of\s+([\w\p{L}-]+)\s*$/iu;var Hb=/^note\s+(left|right)\s+of\s+([\w\p{L}-]+)\s+([^\s:].*)$/iu;var Ou=/^end\s+note$/i;function tE(e,t=false){for(let n=0;n<e.length;n++){const i=e[n];if(i==='"'){t=!t;continue}if(t)continue;if(i==="%"&&e[n+1]==="%")return{comment:n,quoted:t};if(i!==":"||e[n-1]===":"||e[n+1]===":")continue;const r=e.slice(0,n).trim();if(/^[\w\p{L}-]+$/u.test(r)||r.includes("-->")||/^note\s+(?:left|right)\s+of\s+[\w\p{L}-]+$/iu.test(r))return{comment:-1,quoted:false}}return{comment:-1,quoted:t}}function BW(e){return tE(e).comment}function nE(e){const t=BW(e);return(t<0?e:e.slice(0,t)).trim()}function pa(e){const t=[];const n=[];for(let o=e.length-1,s=false,a=false;o>=0;o--){t[o]=s;n[o]=a;s||=Ou.test(nE(e[o]));a||=e[o].includes('"')}let i=false;let r=false;return e.map((o,s)=>{const a=r;const l=tE(o,!i&&a);const c=(l.comment<0?o:o.slice(0,l.comment)).trim();const d=i&&!Ou.test(c);const u=d?o.trim():c;let f=false;if(i){if(!d)i=false}else if(!a&&(Um.test(u)||t[s]&&Hb.test(u))){i=f=true}r=!i&&l.quoted&&n[s]&&(a||/^(?:state|note)\s/i.test(u));const h=!d&&l.comment>0&&!/\s/.test(o[l.comment-1]);return{text:u,commentIndex:d?-1:l.comment,noteBody:d,noteOpen:f,openQuote:r,commentGlued:h}})}function ga(e,t,n,i){if(e[t]!=="{")throw new RangeError(`scanMetadataBlock: no "{" at ${t}`);if(n==="sequence"){const o=e.indexOf("}",t+1);if(o<0)return{kind:"unclosed"};if(o===t+1)return{kind:"invalid",message:"empty @{} participant metadata"};return{kind:"closed",body:e.slice(t+1,o).trim(),end:o}}let r="";for(let o=t+1;o<e.length;o++){const s=e[o];if(s==='"'){const a=e.indexOf('"',o+1);if(a<0)return{kind:"unclosed"};const l=o+1;r+=`"${e.slice(l,a).replace(/\n\s*/g,(c,d)=>{i?.(l+d,l+d+c.length,5);return"<br/>"})}"`;o=a}else if(s==="}"){return{kind:"closed",body:r,end:o}}else if(s==="^"){return{kind:"invalid",message:'unquoted "^" in @{} metadata'}}else{r+=s}}return{kind:"unclosed"}}function Bu(e){return/^(?:%(?!\{)|#(?![a-z\d]+;))/i.test(e.trimStart())}function jb(e){return rE(e,WW)}function Yb(e){return rE(e,zW)}function WW(e){return e}function zW(e,t,n){return{raw:e,line:t,column:n,endColumn:n+e.length}}function rE(e,t){const n=[];let i=false;for(const[r,o]of e.entries()){let s=0;const a=!o.trim();const l=(h,m)=>{if(!h.trim()&&!a)return;const p=s+m;n.push(t(h,r,p))};let c=o;if(i){const h=c.indexOf("}");if(h<0){l(c,0);continue}l(c.slice(0,h+1),0);c=c.slice(h+1);s=h+1;i=false}let d=0;let u=false;let f=-1;for(let h=0;h<c.length;h++){if(h===d){const p=c.slice(d).trimStart();const g=/^accDescr\s*:?\s*\{/i.exec(p);if(g){const b=c.indexOf("{",d);const S=c.indexOf("}",b+1);if(S<0){l(c.slice(d),d);i=true;u=true;break}l(c.slice(d,S+1),d);d=S+1;h=S;continue}const y=/^\s*end(?=[^\S\r\n]+\S)/i.exec(c.slice(d));if(y){l(c.slice(d,d+y[0].length),d);d+=y[0].length;h=d-1;continue}if(/^(?:rect|box)\s+#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8});/i.test(p)||Bu(p)||/^(?:accTitle|accDescr)(?:\s*:|\s+)/i.test(p)){l(c.slice(d),d);u=true;break}}const m=c[h];if(m==="@"&&c[h+1]==="{"&&/^(?:participant|actor)\b/i.test(c.slice(d,h).trimStart())){const p=ga(c,h+1,"sequence");h=p.kind==="closed"?p.end:p.kind==="unclosed"?c.length:h+1;continue}if(m==="#"&&f<0)f=h;if(m==="#"&&!oE(c,h)&&!(/^\s*(?:rect|box)\s*$/i.test(c.slice(d,h))&&/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})(?=\s|;|$)/i.test(c.slice(h)))){l(c.slice(d,h),d);l(c.slice(h),h);u=true;break}if(c[h]!==";"||GW(c,d,h,f))continue;l(c.slice(d,h),d);d=h+1;f=-1}if(!u)l(c.slice(d),d)}return n}function GW(e,t,n,i){let r=n-1;while(r>=t&&/[a-z\d]/i.test(e[r]))r--;if(e[r]!=="#"||r===n-1)return false;if(!oE(e,r))return false;if(i===r&&/^\s*(?:rect|box)\s+#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e.slice(t,n)))return false;return true}var iE=/#(?:\d+|[a-z][a-z\d]*);/iy;function oE(e,t){iE.lastIndex=t;return iE.test(e)}import{Document as HW,Scalar as aE,isMap as lE,isScalar as Ub,parse as jW,parseDocument as cE,visit as Vm}from"yaml";import{stringifyNumber as dE}from"yaml/util";var Vb=/^[-+]?(?:0b[01]+|0x[0-9a-fA-F]+|0o[0-7]+|[0-9]+)$/;var Kb=/^(?:[-+]?[0-9]+(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?|\.[0-9]+(?:[eE][-+]?[0-9]+)?|[-+]?\.(?:inf|Inf|INF)|\.(?:nan|NaN|NAN))$/;function YW(e,t){if(!Vb.test(e)){t(`cannot resolve ${JSON.stringify(e)} as an integer`);return Number.NaN}let n=e;const i=n[0]==="-"?-1:1;if(n[0]==="-"||n[0]==="+")n=n.slice(1);const r=n[1]==="b"?2:n[1]==="x"?16:n[1]==="o"?8:10;const o=i*Number.parseInt(r===10?n:n.slice(2),r);return Number.isFinite(o)?o:e}function qW(e,t){if(!Kb.test(e)){t(`cannot resolve ${JSON.stringify(e)} as a float`);return Number.NaN}let n=e.toLowerCase();const i=n[0]==="-"?-1:1;if(n[0]==="-"||n[0]==="+")n=n.slice(1);if(n===".inf")return i*Number.POSITIVE_INFINITY;if(n===".nan")return Number.NaN;const r=i*Number.parseFloat(n);return Number.isFinite(r)?r:e}var qb={identify:e=>typeof e==="number"&&Number.isInteger(e),default:true,tag:"tag:yaml.org,2002:int",test:Vb,resolve:YW,stringify:dE};var Xb={identify:e=>typeof e==="number",default:true,tag:"tag:yaml.org,2002:float",test:Kb,resolve:qW,stringify:dE};var uE={schema:"core",customTags:e=>[...e.filter(t=>typeof t==="string"||t.tag!==qb.tag&&t.tag!==Xb.tag),qb,Xb]};var XW="Comments must be separated from other tokens by white space characters";function UW(e,t){return e.code==="MISSING_CHAR"&&e.message.startsWith(XW)&&!/[|>][-+0-9]*$/.test(t.slice(0,e.pos[0]))}function VW(e,t){let n=false;Vm(e,{Pair(i,r,o){const s=o[o.length-1];const a=r.key;const l=Ub(a)&&a.source===""&&a.range?.[0]===a.range?.[1]?a.range[0]:-1;if(l>=0&&lE(s)&&!s.flow&&/^[ \t]*:/.test(t.slice(l))&&/^[ \t]*$/.test(t.slice(t.lastIndexOf("\n",l-1)+1,l))){n=true;return Vm.BREAK}return void 0}});return n}var KW=/(?:^|[[{,]|[:?-][ \t])[ \t]*$/;var JW=/(?:^|[:?-][ \t])[ \t]*[|>][-+0-9]*[ \t]*(?:#.*)?$/;function QW(e){const t=e.split("\n");const n=a=>a.match(/^[ \t]*/)[0];let i;let r="";let o;let s=false;for(let a=0;a<t.length;a++){const l=t[a];if(o!==void 0){if(l.trim()===""||n(l).length>o)continue;o=void 0}if(i){t[a]=r+l;s=true}let c=0;for(;c<l.length;c++){const d=l[c];if(i==='"'){if(d==="\\")c++;else if(d==='"')i=void 0}else if(i==="'"){if(d==="'"&&l[c+1]==="'")c++;else if(d==="'")i=void 0}else if(d==="#"&&(c===0||/[ \t]/.test(l[c-1]))){break}else if((d==='"'||d==="'")&&KW.test(l.slice(0,c))){i=d;r=`${n(l)} `}}if(!i&&JW.test(l))o=n(l).length}return s?t.join("\n"):void 0}function sE(e){const t=cE(e,{...uE,logLevel:"silent"});const n=t.errors.find(r=>!UW(r,e))??t.warnings[0];if(n)return{ok:false,message:n.message.split("\n")[0]};if(VW(t,e))return{ok:false,message:"a block mapping entry has no key"};let i;Vm(t,{Scalar(r,o){const s=o.tag===qb.tag?Vb:o.tag===Xb.tag?Kb:void 0;if(s&&(!s.test(o.source??"")||typeof o.value!=="number")){i=`cannot resolve ${JSON.stringify(o.source)} as ${o.tag}`}},Pair(r,o){if(Ub(o.key)&&o.key.value===null)o.key=new aE("null")}});if(i)return{ok:false,message:i};try{return{ok:true,value:t.toJS()}}catch(r){return{ok:false,message:r instanceof Error?r.message:String(r)}}}function As(e){const t=e.length>0&&!/[\n\r]$/.test(e)?`${e}
|
|
6
|
-
`:e;const n=sE(t);if(n.ok)return n;const i=QW(t);const r=i===void 0?void 0:sE(i);return r?.ok?r:n}function Jb(e){return jW(e)}function Qb(e){const t=cE(e,{keepSourceTokens:true});const n=[];if(!lE(t.contents))return n;for(const i of t.contents.items){if(!Ub(i.key)||!i.key.range||!i.value||!("range"in i.value)||!i.value.range)continue;const r=i.srcToken?.sep?.find(o=>o.type==="anchor"||o.type==="tag");n.push({name:String(i.key.value),keyStart:i.key.range[0],keyEnd:i.key.range[1],valueStart:r?.offset??i.value.range[0],valueEnd:i.value.range[1]})}return n}function ZW(e){const t=new HW(e,uE);Vm(t,{Scalar(n,i){if(typeof i.value==="string"&&/(?:^|\n)[ \t]+\r?(?:\n|$)/.test(i.value)){i.type=aE.QUOTE_DOUBLE}}});return t.toString()}import{decodeXML as ez}from"entities";function Ll(e,t){const n=/[\r\n]/g;n.lastIndex=t;return n.exec(e)?.index??-1}var Wu=Object.freeze([]);var tz=Object.freeze([]);var nz=Object.freeze([]);function fE(e){return Object.freeze({originalText:e,text:e,payloadText:e,authoredPayloadText:e,lineText:e,upstreamText:e,prepassedText:e,changes:tz,mappings:Wu,lineMappings:Wu,upstreamMappings:Wu,prepassedMappings:Wu})}function zu(e,t,n){if(t.length===0)return e;const i=[];const r=[];let o=0;let s=0;for(const l of t){i.push(e.text.slice(o,l.start),l.text);const c=l.start+s;r.push(Object.freeze({originalStart:l.start,originalEnd:l.end,cleanedStart:c,cleanedEnd:c+l.text.length}));s+=l.text.length-(l.end-l.start);o=l.end}i.push(e.text.slice(o));const a=e.mappings.length;return{text:i.join(""),mappings:[...e.mappings,Object.freeze({edits:Object.freeze(r)})],changes:[...e.changes,...r.map(l=>({reason:n,stage:a,edit:l}))]}}function mE(e,t,n){const i=[];for(const r of e.matchAll(t)){const o=n(r[0]);if(o!==r[0])i.push({start:r.index,end:r.index+r[0].length,text:o})}return i}function hE(e){return e.text.includes("\r")?zu(e,mE(e.text,/\r\n?/g,()=>"\n"),"line-ending"):e}function iz(e){const t=e.text.includes("<")?e.text.lastIndexOf(">"):-1;if(t<0)return e;const n=[];for(const i of e.text.slice(0,t+1).matchAll(/<(\w+)([^>]*)>/g)){const r=i.index+1+i[1].length;for(const o of i[2].matchAll(/="([^"]*)"/g)){const s=r+o.index+1;n.push({start:s,end:s+1,text:"'"},{start:s+o[0].length-2,end:s+o[0].length-1,text:"'"})}}return zu(e,n,"html-attribute-quotes")}function rz(e){if(!e.text.includes(";")||!e.text.includes("style")&&!e.text.includes("classDef"))return e;const t=[];for(const i of e.text.matchAll(/[^\r\n\u2028\u2029]+/g)){if(!i[0].includes(";")||!i[0].includes("style")&&!i[0].includes("classDef"))continue;const r=Un(i[0]);let o=i[0].length;const s=[];for(let a=i[0].length-r.length;a>0;a--){const l=i[0].lastIndexOf(";",o-1);s.push({start:i.index+l,end:i.index+l+1,text:""});o=l}t.push(...s.reverse())}const n=[];for(const i of t){const r=n.at(-1);if(r&&r.end===i.start)r.end=i.end;else n.push(i)}return zu(e,n,"style-semicolon")}function Km(e,t,n,i=false){const r=e.edits;let o=0;let s=r.length;while(o<s){const f=o+Math.floor((s-o)/2);const h=i?r[f].originalStart:r[f].cleanedStart;if(h<=t)o=f+1;else s=f}if(o===0)return t;const a=r[o-1];const l=i?a.originalStart:a.cleanedStart;const c=i?a.originalEnd:a.cleanedEnd;const d=i?a.cleanedStart:a.originalStart;const u=i?a.cleanedEnd:a.originalEnd;if(t>c)return t+u-c;if(t===l&&l!==c)return d;if(t===c&&l!==c)return u;return n==="start"?d:u}function eS(e,t,n,i=e.length){for(let r=i-1;r>=0;r--)t=Km(e[r],t,n);return t}function pE(e,t){return t==="text"||t==="payloadText"?e.mappings:t==="lineText"||t==="authoredPayloadText"?e.lineMappings:t==="upstreamText"?e.upstreamMappings:e.prepassedMappings}function qc(e,t,n="start",i="text"){if(!Number.isInteger(t)||t<0||t>e[i].length)throw new RangeError("Cleanup offset is outside the selected source view");return eS(pE(e,i),t,n)}function tS(e,t,n="start",i="text"){if(!Number.isInteger(t)||t<0||t>e.originalText.length)throw new RangeError("Cleanup offset is outside the original source");for(const r of pE(e,i))t=Km(r,t,n,true);return t}function oz(e,t,n,i="text"){if(n<t)throw new RangeError("Cleanup range ends before it starts");return{start:qc(e,t,"start",i),end:qc(e,n,"end",i)}}function gE(e,t,n,i="text"){const r=oz(e,t,n,i);return e.originalText.slice(r.start,r.end)}function Zb(e,t,n,i){const r=[];for(const{reason:o,stage:s,edit:a}of e.changes){if(i!==void 0&&o!==i)continue;const l=eS(e.mappings,a.originalStart,"start",s);const c=eS(e.mappings,a.originalEnd,"end",s);let d=a.cleanedStart;let u=a.cleanedEnd;for(let p=s+1;p<e.mappings.length;p++){d=Km(e.mappings[p],d,"start",true);u=Km(e.mappings[p],u,"end",true)}let f=0;let h=n.length;while(f<h){const p=f+Math.floor((h-f)/2);if(n[p]<=l)f=p+1;else h=p}const m=Math.max(1,f);r.push(Object.freeze({reason:o,view:t,originalStart:l,originalEnd:c,cleanedStart:d,cleanedEnd:u,line:m,col:l-n[m-1]+1}))}return r}function Jm(e,t=[]){const n=e.includes("\r");const i=e.includes("&");const r=e.includes("<")&&e.includes('="')&&e.includes(">");const o=e.includes(";")&&(e.includes("style")||e.includes("classDef"));if(!t.length&&!n&&!i&&!r&&!o)return fE(e);const s={text:e,mappings:Wu,changes:nz};const a=zu(s,t,"native-accessibility");const l=hE(a);const c=i?zu(a,mE(a.text,/&(?:#[xX][0-9a-fA-F]+|#[0-9]+|[A-Za-z][A-Za-z0-9]*);/g,ez),"xml-entity"):a;const d=c===a?l:hE(c);const u=o?rz(l):l;const f=r?iz(l):l;if(d===s&&u===s&&f===s)return fE(e);const h=[0];for(let p=0;p<e.length;p++){if(e[p]==="\r"){if(e[p+1]==="\n")p++;h.push(p+1)}else if(e[p]==="\n")h.push(p+1)}const m=[...Zb(d,"text",h),...Zb(u,"prepassedText",h,"style-semicolon"),...Zb(f,"upstreamText",h,"html-attribute-quotes")];return Object.freeze({originalText:e,text:d.text,payloadText:c.text.includes("\r")?c.text.replace(/\r\n/g,"\n"):c.text,authoredPayloadText:n?a.text.replace(/\r\n/g,"\n"):a.text,lineText:l.text,upstreamText:f.text,prepassedText:u.text,changes:Object.freeze(m),mappings:Object.freeze(d.mappings),lineMappings:Object.freeze(l.mappings),upstreamMappings:Object.freeze(f.mappings),prepassedMappings:Object.freeze(u.mappings)})}function Tn(e,t){const n=Ar(t);return e.title!==void 0||n===void 0?e:{...e,title:n}}function Ar(e){const t=e?.title;return typeof t==="string"&&t.trim()!==""?t:void 0}var Qm=/^\s*%%(?!\{)\s*(.*)\r?$/;function OZ(e){return xE(e)}function xE(e,t){return t?e.replace(fr,(n,i,r,o)=>{t(o,n.length);return""}):e.replace(fr,"")}function sz(e,t="render"){const n=e.cleanup??Jm(e.originalText);const i=e.wrapperSource?.length??0;const r=e.cleanup&&e.authoredWrapperLength!==void 0?qc(n,i,"end","text"):i;const o=e.cleanup&&t==="render"?"payloadText":"authoredPayloadText";const s=tS(n,r,"end",o);const a=n[o].slice(s);let l;let c=0;const d=xE(a,(u,f)=>{const h=u-c;const m=l?.at(-1);if(m?.at===h)m.after=u+f;else(l??=[]).push({at:h,before:u,after:u+f});c+=f});return{text:d,sourceOffset:(u,f="start")=>{if(!Number.isInteger(u)||u<0||u>d.length)throw new RangeError("Family source offset is outside the preserved payload");let h=0,m=l?.length??0;while(h<m){const y=h+Math.floor((m-h)/2);if(l[y].at<=u)h=y+1;else m=y}const p=l?.[h-1];const g=p?u===p.at?f==="start"?p.before:p.after:u+p.after-p.at:u;return qc(n,s+g,f,o)},familyOffset:(u,f="start")=>{const h=tS(n,u,f,o)-s;if(h<0||h>a.length)throw new RangeError("Authored offset is outside the preserved family");let m=0,p=l?.length??0;while(m<p){const y=m+Math.floor((p-m)/2);if(l[y].before<=h)m=y+1;else p=y}const g=l?.[m-1];return g?h<=g.after?g.at:h-g.after+g.at:h}}}function ya(e,t="render"){return sz(e,t).text}function bE(e){const t=[];const n=new RegExp(fr.source,"gm");let i;while((i=n.exec(e))!==null){if(!Ru(i[0]))continue;t.push({raw:i[0],parsed:az(i[0])??{}})}return t}function az(e){const t=new RegExp(fr.source,"m").exec(e);return t?t[1]!==void 0||t[2]!==void 0?vE(t[1]??t[2]):/%%\{\s*wrap\s*\}/.test(t[0])?{wrap:true}:{}:void 0}function lz(e){const t=new RegExp(fr.source,"m").exec(e);if(!t)return void 0;const n=t[1]??t[2];if(n===void 0)return null;if(!n.trim())return{};if(/^\w+$/.test(n.trim()))return n.trim();dm(n,"Mermaid init directive",{trackFlowDepth:true});try{const i=JSON.parse(n.replace(/'/g,'"'));xs(i,"Mermaid init directive");return sS(i)}catch(i){if(i instanceof Yx)throw i;return vE(n)}}function SE(e){const t=new RegExp(fr.source,"m").exec(e);const n=lz(e);if(!t||n===void 0)return void 0;return{kind:/%%\{\s*(\w+)/.exec(t[0])[1],hasArgs:t[1]!==void 0||t[2]!==void 0,payload:n}}function BZ(e){const t=hr(e);return t?RE(t.yaml):{}}function WZ(e){const t=SE(e.raw);return t?`${t.kind}:${t.hasArgs}:${nS(t.payload)}`:`raw:${e.raw.trim().replace(/\s+/g," ")}`}function nS(e){if(Array.isArray(e)){return`[${e.map(nS).join(",")}]`}if(e!==null&&typeof e==="object"){const t=Object.entries(e).filter(n=>n[1]!==void 0).sort(([n],[i])=>n<i?-1:n>i?1:0);return`{${t.map(([n,i])=>`${JSON.stringify(n)}:${nS(i)}`).join(",")}}`}return JSON.stringify(e)}function Hu(e,t={},n="authored",i){const r=iS(e,null);const o=Jm(e,r);const s=Wc(n==="render"?o.text:o.lineText);const a=i?i(s,"loose"):zc(n==="authored"?Gu(s):s,"loose");const l=iS(e,a);const c=r.length>0||l.length>0?Jm(e,l):o;return wE(e,t,n,c,a)}function iS(e,t){if(!e.includes("%% agentic-mermaid "))return[];const n=hr(e)?.source.length??0;const i=e.slice(n);return sP(i,Cl(Gu(Wc(e)),bm(i).split(/\r\n?|\n/),t)).map(r=>({...r,start:n+r.start,end:n+r.end}))}function wE(e,t,n,i,r){const o=n==="render"?i.text:i.lineText;const s=uz(o,PE(t),r);const a=s.body.split(/\r?\n/);const l=/^sequenceDiagram\b/i.test(s.lines[0]??"");const c=l&&/;\s*acc(?:Title|Descr)\b/i.test(s.body)?jb(a):a;const d=Wt(c,Cl(Gu(s.lines[0]??""),c,r),n==="render"?b=>(b.form==="native"?zo:pb)({title:b.value}).title:void 0);const u=dz(o,d.accessibility,r);const f=o===i.lineText;if(f&&o!==e){if(u.wrapperSource!==void 0){u.wrapperSource=e.slice(0,qc(i,u.wrapperSource.length,"end","lineText"))}const b=hr(o)?.source.length??(o.startsWith("\uFEFF")?1:0);const S=[...o.slice(b).matchAll(new RegExp(fr.source,"gm"))].filter(x=>Ru(x[0])).values();for(const x of u.initDirectives){const k=b+S.next().value.index;const w=k+x.raw.length;x.raw=gE(i,k,w,"lineText")}}const h=d.familyLines.join("\n");const m=/^stateDiagram(?:-v2)?(?=$|[\s;%])/i.test(s.lines[0]??"");const p=/^timeline(?=$|[\s;#%])/i.test(s.lines[0]??"");const g=m?pa(d.familyLines).filter(b=>b.noteBody||b.text.length>0).map(b=>b.text):p?d.familyLines.map(b=>b.trimStart()).filter(b=>b.trim().length>0&&!Qm.test(b)):vu(h);const y=f?void 0:wE(e,t,"authored",i,r);return{originalText:e,cleanup:i,...y?{authoredFamilyLines:y.familyLines,authoredFamilyBody:y.familyBody,authoredHeader:y.lines[0]??"",authoredWrapperLength:y.wrapperSource?.length??0}:{},text:s.lines.join("\n"),body:s.body,lines:s.lines,familyBody:h,familyText:g.join("\n"),familyLines:g,firstLine:s.lines[0]?.toLowerCase()??"",config:EE(s.frontmatter),frontmatter:s.frontmatter,...u.wrapperSource!==void 0?{wrapperSource:u.wrapperSource}:{},initDirectives:u.initDirectives,comments:u.comments,accessibility:u.accessibility}}function cz(e,t={},n="authored",i){const r=Hu(e,{},n,i);if(Object.keys(t).length===0)return r;const o=Xc(r.frontmatter,PE(t));return{...r,frontmatter:o,config:EE(o)}}function ME(e,t,n){return cz(e,t,"render",n)}function dz(e,t,n){const i=hr(e);const r=i?.source.length??(e.startsWith("\uFEFF")?1:0);const o=bE(e.slice(r));const s=S=>S.replace(/[^\r\n]/g," ");const a=(i?s(i.source)+e.slice(i.source.length):e).replace(new RegExp(fr.source,"gm"),s);const l=[];const c=a.split(/\r?\n/);const d=c.find(S=>S.trim().length>0&&!Qm.test(S))?.trim()??"";const u=/^stateDiagram(?:-v2)?(?=$|[\s;%])/i.test(d);const f=/^sequenceDiagram\b/i.test(d);const h=u?pa(c):void 0;const m=(S,x)=>{if(!f)return;const k=jb([S]).find(w=>w.trimStart().startsWith("%%"));if(k)l.push({text:k.trimStart().slice(2).trim(),line:x})};const p=Cl(Gu(d),c,n);let g=-1;for(let S=0;S<c.length;S++){const x=S>g?Tt(c,S):null;if(x===void 0)break;if(x!==null){if(x.suffixLine)m(x.suffixLine,x.endIndex+1);S=x.endIndex;continue}if(S>g)g=Gc(p,S,c.length);const k=c[S];const w=h?.[S];if(w){if(w.commentIndex>=0)l.push({text:k.slice(w.commentIndex+2).trim(),line:S+1});continue}const C=k.match(Qm);if(C)l.push({text:C[1],line:S+1});else if(f)m(k,S+1)}let y=r;const b=new RegExp(fr.source);for(;;){const S=e.slice(y);if(S.length===0)break;const x=S.match(b);if(x?.index===0&&x[0].length>0){y+=x[0].length;continue}const k=S.indexOf("\n");const w=k===-1?S:S.slice(0,k);if(Tt([w],0)?.form==="native")break;if(/^\s*$/.test(w)||Qm.test(w)){y+=k===-1?S.length:k+1;continue}break}return{...y>0?{wrapperSource:e.slice(0,y)}:{},initDirectives:o,comments:l,accessibility:t}}function uz(e,t={},n=zc(Gu(Wc(e)),"loose")){const i=iS(e,n);for(const d of i.toReversed())e=e.slice(0,d.start)+d.text+e.slice(d.end);const r=hr(e);const o=r?rS(RE(r.yaml)):{};const s=r?e.slice(r.source.length):e;const a=mz(s,Xc(rS(t),o),n);const l=kl(a.body);const c=a.frontmatter;return{body:l,lines:vu(l),frontmatter:c}}function Xc(e,t){return kE(e,t)}function kE(e,t){const n=Al(e);for(const[i,r]of Object.entries(t)){if(r===void 0)continue;const o=n[i];if(So(o)&&So(r)){n[i]=kE(o,r);continue}n[i]=aS(r)}return n}function Sn(e,t){let n=e;for(const i of t){if(!So(n))return void 0;n=n[i]}return So(n)?n:void 0}function kt(e,t){let n=e;for(const i of t){if(!So(n))return void 0;n=n[i]}return n!==void 0&&!Array.isArray(n)&&(typeof n!=="object"||n===null)?n:void 0}function CE(e,t){let n=e;for(const i of t){if(!So(n))return void 0;n=n[i]}return Array.isArray(n)?n:void 0}function PE(e){xs(e,"Mermaid runtime configuration");return rS(ep(e)??{})}function EE(e){const t=Al(e);if(So(t.themeVariables)){t.themeVariables=Al(t.themeVariables)}if(So(t.timeline)){t.timeline=fz(t.timeline)}if(So(t.journey)){t.journey=hz(t.journey)}return t}function fz(e){const t=Al(e);if(typeof t.disableMulticolor!=="boolean"){delete t.disableMulticolor}const n=Zm(t.sectionFills);if(n.length>0){t.sectionFills=n}else{delete t.sectionFills}const i=Zm(t.sectionColours);const r=Zm(t.sectionColors);if(i.length>0){t.sectionColours=i}else if(r.length>0){t.sectionColours=r}else{delete t.sectionColours}delete t.sectionColors;return t}function hz(e){const t=Al(e);for(const r of["diagramMarginX","diagramMarginY","leftMargin","maxLabelWidth","width","height","boxMargin","boxTextMargin","noteMargin","messageMargin","bottomMarginAdj","taskMargin","activationWidth"]){const o=t[r];if(typeof o!=="number"||!Number.isFinite(o)||o<0){delete t[r]}}if(typeof t.useMaxWidth!=="boolean")delete t.useMaxWidth;if(typeof t.rightAngles!=="boolean")delete t.rightAngles;if(t.messageAlign!=="left"&&t.messageAlign!=="center"&&t.messageAlign!=="right"){delete t.messageAlign}const n=yE(t.taskFontSize);if(n!==void 0)t.taskFontSize=n;else delete t.taskFontSize;for(const r of["taskFontFamily","textPlacement","titleColor","titleFontFamily"]){if(typeof t[r]!=="string"||t[r].trim().length===0)delete t[r]}const i=yE(t.titleFontSize);if(i!==void 0)t.titleFontSize=i;else delete t.titleFontSize;for(const r of["actorColours","sectionFills","sectionColours"]){const o=Zm(t[r]);if(o.length>0)t[r]=o;else delete t[r]}return t}function yE(e){if(typeof e==="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e==="string"&&e.trim().length>0)return e.trim();return void 0}function Zm(e){return Array.isArray(e)?e.filter(t=>typeof t==="string"):[]}function rS(e){xs(e,"Mermaid configuration");const t=Al(e);const n=So(t.config)?t.config:void 0;delete t.config;return n?Xc(n,t):t}var oS=class extends Error{};function RE(e){dm(e,"Mermaid frontmatter");const t=As(e);if(!t.ok){throw new oS(Je({what:`Mermaid frontmatter is not valid YAML: ${t.message}`,expectedForm:"a YAML mapping between the two `---` lines",example:'---\ntitle: "Order flow: v2"\n---'}).message)}xs(t.value,"Mermaid frontmatter");return ep(t.value)??{}}function mz(e,t,n){const i=bE(e).flatMap(c=>{const d=SE(c.raw);return d?[d]:[]});const r=db(e);const o=vu(r)[0]?.split(/\s/)[0]??"";const s=eE(n?.id??o);if(i.length===0&&Object.keys(t).length===0)return{body:r,frontmatter:t};const a=i.filter(c=>/(?:init\b)|(?:initialize\b)/.test(c.kind)).map(c=>c.payload);const l=i.some(c=>c.kind==="wrap");try{return{body:r,frontmatter:ZP(t,i.map(c=>QP(c.kind,c.payload,c.hasArgs)).join("\n"),s,true)}}catch{let c=Xc({},t);for(const d of a){if(!d||typeof d!=="object"||Array.isArray(d))continue;const u=Xc({},d);if(u.config!==void 0){if(a.length===1)u[s==="flowchart-v2"?"flowchart":s]=u.config;delete u.config}c=Xc(c,u)}if(l)c.wrap=true;return{body:r,frontmatter:c}}}function vE(e){return e===void 0?{wrap:true}:e.trim()===""?{}:pz(e.trim())}function pz(e){dm(e,"Mermaid init directive",{trackFlowDepth:true});try{const t=Jb(e);xs(t,"Mermaid init directive");return ep(t)}catch(t){if(t instanceof Yx||t instanceof Ei)throw t;const n=xz(e);if(n!==void 0)xs(n,"Mermaid init directive");return n}}function ep(e){if(!gz(e))return void 0;const t={};for(const[n,i]of Object.entries(e)){const r=sS(i);if(r!==void 0)t[n]=r}return t}function sS(e){if(e===null)return null;if(typeof e==="string"||typeof e==="number"||typeof e==="boolean")return e;if(Array.isArray(e)){const t=[];for(const n of e){const i=sS(n);if(i===void 0)return void 0;t.push(i)}return t}return ep(e)}function Al(e){const t={};for(const[n,i]of Object.entries(e)){t[n]=aS(i)}return t}function aS(e){if(e===void 0||e===null)return e;if(typeof e==="string"||typeof e==="number"||typeof e==="boolean")return e;if(Array.isArray(e))return e.map(t=>aS(t));return Al(e)}function So(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}function gz(e){return!!e&&typeof e==="object"&&!Array.isArray(e)}function yz(e){if(e.startsWith('"')&&e.endsWith('"')||e.startsWith("'")&&e.endsWith("'")){return LE(e)}if(e==="true")return true;if(e==="false")return false;if(e==="null")return null;if(/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(e))return Number(e);return e}function xz(e){const t=lS(e.trim());return So(t)?t:void 0}function lS(e){const t=e.trim();if(t.length===0)return void 0;if(t.startsWith("{")&&t.endsWith("}")){return bz(t.slice(1,-1))}if(t.startsWith("[")&&t.endsWith("]")){return Sz(t.slice(1,-1))}return yz(t)}function bz(e){const t={};for(const n of TE(e)){const i=Mz(n,":");if(i===-1)return void 0;const r=n.slice(0,i).trim();const o=n.slice(i+1).trim();const s=wz(r);if(!s)return void 0;const a=lS(o);if(a===void 0)return void 0;t[s]=a}return t}function Sz(e){const t=[];for(const n of TE(e)){const i=lS(n);if(i===void 0)return void 0;t.push(i)}return t}function wz(e){const t=e.trim();if(!t)return void 0;if(t.startsWith('"')&&t.endsWith('"')||t.startsWith("'")&&t.endsWith("'")){return LE(t)}return t}function TE(e){const t=[];let n="";let i=null;let r=0;let o=0;for(let a=0;a<e.length;a++){const l=e[a];if(i){n+=l;if(l===i&&e[a-1]!=="\\")i=null;continue}if(l==='"'||l==="'"){i=l;n+=l;continue}if(l==="{"){r++;n+=l;continue}if(l==="}"){r--;n+=l;continue}if(l==="["){o++;n+=l;continue}if(l==="]"){o--;n+=l;continue}if(l===","&&r===0&&o===0){const c=n.trim();if(c)t.push(c);n="";continue}n+=l}const s=n.trim();if(s)t.push(s);return t}function Mz(e,t){let n=null;let i=0;let r=0;for(let o=0;o<e.length;o++){const s=e[o];if(n){if(s===n&&e[o-1]!=="\\")n=null;continue}if(s==='"'||s==="'"){n=s;continue}if(s==="{"){i++;continue}if(s==="}"){i--;continue}if(s==="["){r++;continue}if(s==="]"){r--;continue}if(s===t&&i===0&&r===0)return o}return-1}function LE(e){try{if(e.startsWith("'")){return e.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\'/g,"'")}return JSON.parse(e)}catch{return e.slice(1,-1)}}var AE=new Set(Object.values(Bi).flat());var kz=new Set(["primaryTextColor","textColor","nodeTextColor","secondaryTextColor","tertiaryTextColor"]);var Cz=new Set([...Array.from({length:12},(e,t)=>`pie${t+1}`),"pieStrokeColor","pieOuterStrokeColor","pieSectionTextColor","pieTitleTextColor","pieLegendTextColor"]);var Pz=new Set(["pieSectionTextColor","pieTitleTextColor","pieLegendTextColor"]);var Ez=new Set([...Array.from({length:8},(e,t)=>[`git${t}`,`gitBranchLabel${t}`,`gitInv${t}`]).flat(),"commitLabelColor","commitLabelBackground"]);var Rz=new Set([...Array.from({length:8},(e,t)=>`gitBranchLabel${t}`),"commitLabelColor"]);var IE=new Set(Array.from({length:12},(e,t)=>[`cScale${t}`,`cScaleLabel${t}`,`cScaleInv${t}`]).flat());var FE=new Set([...Array.from({length:12},(e,t)=>`cScale${t}`),"titleColor"]);var vz=new Set(["clusterBkg","clusterBorder"]);var Tz=["backgroundColor","titleColor","xAxisLabelColor","xAxisTickColor","xAxisLineColor","xAxisTitleColor","yAxisLabelColor","yAxisTickColor","yAxisLineColor","yAxisTitleColor","legendTextColor","dataLabelColor"];var Lz=new Set(["xAxisTickColor","xAxisLineColor","yAxisTickColor","yAxisLineColor"]);var Az=[["bg",Bi.bg],["surface",Bi.surface],["line",Bi.line],["accent",Bi.accent]];function ba(e,t=false){const n=typeof e==="string"?e:JSON.stringify(e)??String(e);return t&&n.length>256?`${n.slice(0,256)}\u2026`:n}var xa=class extends Error{code="INVALID_THEME_COLOR";key;value;constructor(t,n,i){const r=ba(n,true);super(Je({what:`themeVariables.${t}: ${JSON.stringify(r)} is not a CSS color`,expectedForm:Eu(i),example:`themeVariables.${t}:#f96`}).message);this.name="ThemeVariableColorError";this.key=t;this.value=r}};var Yu=class extends Error{code="INVALID_RENDER_COLOR";field;value;constructor(t,n){const i=ba(n,true);super(Je({what:`render option "${t}": ${JSON.stringify(i)} is not a CSS color for Architecture derived paint`,expectedForm:"a drawable CSS color or var(--name)",example:`${t}:#f96`}).message);this.name="RenderOptionColorError";this.field=t;this.value=i}};function NE(e,t,n){if(t!=="architecture"||!e)return;const i=n?.edgeStroke;if(typeof i==="string"&&i.trim().toLowerCase()==="none"){throw new Yu("architecture.visual.edgeStroke",i)}for(const o of["bg","surface","line","accent"]){const s=e[o];if(typeof s!=="string"||s.trim().toLowerCase()!=="none")continue;if(o==="surface"&&n?.groupSurface?.trim().toLowerCase()!=="none")continue;if(o==="surface"&&n?.groupHeaderSurface)continue;if((o==="line"||o==="accent")&&i)continue;throw new Yu(o,s)}const r=n?.groupSurface;if(!n?.groupHeaderSurface&&typeof r==="string"&&r.trim().toLowerCase()==="none"){throw new Yu("architecture.visual.groupSurface",r)}}var Il=class extends Error{code="INVALID_CONFIG_COLOR";path;value;constructor(t,n,i,r){const o=ba(n,true);const s=ba(t,true);super(Je({what:`${s}: ${JSON.stringify(o)} is not ${r==="array"?"an array of CSS colors":r==="map"?"a map of CSS colors":"a CSS color"}`,expectedForm:r?r==="array"?"an array of drawable CSS colors":"an object mapping node labels to drawable CSS colors":Eu(i),example:`${s}${r==="array"?': ["#f96"]':r==="map"?': {"A":"#f96"}':": #f96"}`}).message);this.name="FamilyConfigColorError";this.path=s;this.value=o}};function tp(e){return e!==null&&typeof e==="object"&&!Array.isArray(e)?e:void 0}function Iz(e,t){return t.find(n=>{const i=e[n];return typeof i==="string"&&i.length>0})}function ju(e,t,n,i){const r=e[n];if(r===void 0)return;if(mn(r,i)===void 0){throw new Il(`${t}.${n}`,r,i)}}function Uc(e,t,n,i){const r=e[n];if(r===void 0)return;if(!Array.isArray(r))throw new Il(`${t}.${n}`,r,i,"array");for(let o=0;o<r.length;o++){const s=r[o];if(mn(s,i)===void 0){throw new Il(`${t}.${n}[${o}]`,s,i)}}}function $E(e,t){const n=tp(e[t]);if(!n)return;if(t==="timeline"){Uc(n,"timeline","sectionFills",false);Uc(n,"timeline","sectionColours",false);if(n.sectionColours===void 0||Array.isArray(n.sectionColours)&&n.sectionColours.length===0){Uc(n,"timeline","sectionColors",false)}}else if(t==="journey"){Uc(n,"journey","actorColours",true);Uc(n,"journey","sectionFills",false);Uc(n,"journey","sectionColours",false);ju(n,"journey","titleColor",false)}else if(t==="requirement"){ju(n,"requirement","rect_fill",true);ju(n,"requirement","rect_border_color",true);ju(n,"requirement","text_color",false)}else if(t==="sankey"){const i=n.linkColor;if(i!=="source"&&i!=="target"&&i!=="gradient"){ju(n,"sankey","linkColor",true)}if(n.nodeColors===void 0)return;const r=tp(n.nodeColors);if(!r)throw new Il("sankey.nodeColors",n.nodeColors,false,"map");const o=i!==void 0&&i!=="gradient";for(const[s,a]of Object.entries(r)){if(mn(a,o)===void 0){const l=/^[\w-]+$/.test(s)?`sankey.nodeColors.${s}`:`sankey.nodeColors[${JSON.stringify(s)}]`;throw new Il(l,a,o)}}}}function cS(e,t,n,i){if(!e)return;const r=t==="pie"?Cz:t==="gitgraph"?Ez:t==="timeline"?IE:t==="radar"?FE:t==="architecture"?vz:void 0;const o=r?new Set([...AE,...r]):AE;const s=t==="architecture"?new Set(Az.flatMap(([a,l])=>{if(n?.[a]!==void 0)return[];if(a==="surface"&&i&&(i?.groupHeaderSurface||i?.groupSurface?.trim().toLowerCase()!=="none"))return[];if((a==="line"||a==="accent")&&i?.edgeStroke)return[];return Iz(e,l)??[]})):void 0;for(const a of o){if(!Object.hasOwn(e,a))continue;const l=e[a];if(l===void 0)continue;const c=ba(l);const d=kz.has(a)||Pz.has(a)||Rz.has(a)||t==="timeline"&&IE.has(a)||t==="radar"&&FE.has(a)||t==="architecture"&&(a==="clusterBkg"&&(!i||!i.groupHeaderSurface&&i.groupSurface?.trim().toLowerCase()==="none")||s?.has(a));if(mn(l,!d)===void 0){throw new xa(a,c,!d)}}if(t==="radar"){const a=tp(e.radar);if(!a)return;for(const l of["axisColor","graticuleColor"]){const c=a[l];if(c===void 0)continue;const d=l==="graticuleColor";const u=ba(c);if(mn(c,d)===void 0){throw new xa(`radar.${l}`,u,d)}}}if(t==="xychart"){const a=tp(e.xyChart);if(!a)return;for(const c of Tz){if(c==="backgroundColor"&&n?.bg!==void 0)continue;const d=a[c];if(d===void 0)continue;const u=Lz.has(c);const f=ba(d);if(mn(d,u)===void 0){throw new xa(`xyChart.${c}`,f,u)}}const l=a.plotColorPalette;if(l!==void 0&&!(typeof l==="string"&&l.trim().length===0)){const c=typeof l==="string"?im(l):l;if(!Array.isArray(c)){throw new xa("xyChart.plotColorPalette",JSON.stringify(l)??String(l),false)}for(const[d,u]of c.entries()){const f=typeof u==="string"?u.trim():JSON.stringify(u)??String(u);if(mn(u)===void 0){throw new xa(`xyChart.plotColorPalette[${d}]`,f,false)}}}}if(t==="architecture"&&(typeof e.mainBkg!=="string"||e.mainBkg.length===0)){const a=e.secondaryColor;if(a!==void 0){const l=ba(a);if(mn(a,true)===void 0){throw new xa("secondaryColor",l,true)}}}}function Kr(e,t){if(!e||typeof e!=="object"||Array.isArray(e))return void 0;const n=e[t];return n&&typeof n==="object"&&!Array.isArray(n)?n:void 0}function dS(e,t,n){if(!n)return[];const i=t&&typeof t==="object"&&!Array.isArray(t)?t:void 0;const r=Kr(t,n.section);if(!r)return i&&n.section in i?[{code:"INEFFECTIVE_CONFIG",field:n.section,message:`${e} config section "${n.section}" must be an object; the invalid value has no effect.`}]:[];const o=new Set(n.keys);return Object.keys(r).filter(s=>!o.has(s)).sort().map(s=>({code:"INEFFECTIVE_CONFIG",field:`${n.section}.${s}`,message:`${e} config field "${s}" is unknown and has no effect; check the spelling or remove it.`}))}function bt(e,{root:t,config:n},i={}){const r=dS(e,t,n);const o=Kr(t,n.section);if(o){for(const[s,a]of Object.entries(i)){if(s in o&&!a.valid(o[s])){const l=`${n.section}.${s}`;r.push({code:"INEFFECTIVE_CONFIG",field:l,message:`${l} must be ${a.expected}; the invalid value has no effect.`})}}}return[...r,...Fz(e,t,n,i)]}function Fz(e,t,n,i={}){if(!n)return[];const r=Kr(t,n.section);if(!r)return[];const o=new Set(n.noopKeys??[]);return Object.keys(r).filter(s=>{if(!o.has(s))return false;const a=i[s];return!a||a.valid(r[s])}).sort().map(s=>({code:"INEFFECTIVE_CONFIG",field:`${n.section}.${s}`,message:`${e} config field "${s}" is accepted for ${e.includes(":")?"compatibility":"Mermaid compatibility"} but has no effect on this renderer.`}))}function Nz(e){const t=new Set;return e.sort((n,i)=>Bn(n.field,i.field)||Bn(n.message,i.message)).filter(n=>{const i=`${n.code}\0${n.field}\0${n.message}`;if(t.has(i))return false;t.add(i);return true})}function $z(e,t,n,i){if(!n)return[];const r=i??fb(e)?.configDiagnostics;return Nz(t.flatMap(o=>r?[...r({root:o,config:n})]:bt(e,{root:o,config:n})))}function _E(e,t,n,i){const r=fb(e);const o=n??r?.config;return $z(e,[t],o,i??r?.configDiagnostics)}var _z=["onConfigDiagnostic"];var np=(e,t)=>({type:"string",description:e,...t===void 0?{}:{default:t}});var Nl=(e,t,n={})=>({type:"number",description:e,...t===void 0?{}:{default:t},...n});var Wi=(e,t)=>Nl(e,t,{minimum:0});var Qr=(e,t)=>Nl(e,t,{exclusiveMinimum:0});var uS=e=>Nl(e,void 0,{minimum:1,maximum:1e3});var Is=(e,t)=>({type:"boolean",description:e,...t===void 0?{}:{default:t}});var zi=(e,t)=>({...np(e,t),"x-agentic-mermaid-runtime-validator":"safeCssPaint"});var qE=(e,t)=>({...np(e,t),"x-agentic-mermaid-runtime-validator":"safeCssFontFamily"});var wo=(e,t,n=[])=>({type:"object",description:t,additionalProperties:false,properties:e,...n.length===0?{}:{required:n}});var fS={type:"string",enum:["uppercase","lowercase","capitalize"]};var XE={groupHeaderHeight:Qr("Requested minimum Architecture group-header height; expands to fit measured title text."),groupFontSize:Qr("Architecture group-label font size."),groupFontWeight:uS("Architecture group-label font weight."),groupLetterSpacing:Nl("Architecture group-label letter spacing."),groupFont:qE("Architecture group-label font family."),groupTextTransform:{...fS,description:"Architecture group-label text transform."},groupPaddingX:Wi("Horizontal padding inside architecture groups."),groupPaddingY:Wi("Vertical padding inside architecture groups."),groupLabelPaddingX:Wi("Horizontal padding around architecture group labels."),groupCornerRadius:Wi("Architecture group corner radius."),groupLineWidth:Wi("Architecture group border width."),groupText:zi("Architecture group-label color."),serviceFontSize:Qr("Architecture service-label font size."),serviceFontWeight:uS("Architecture service-label font weight."),serviceLetterSpacing:Nl("Architecture service-label letter spacing."),serviceTextTransform:{...fS,description:"Architecture service-label text transform."},servicePaddingX:Wi("Horizontal padding inside architecture services."),servicePaddingY:Wi("Vertical padding inside architecture services."),serviceCornerRadius:Wi("Architecture service corner radius."),serviceLineWidth:Wi("Architecture service border width."),serviceText:zi("Architecture service-label color."),edgeFontSize:Qr("Architecture connector-label font size."),edgeFontWeight:uS("Architecture connector-label font weight."),edgeLetterSpacing:Nl("Architecture connector-label letter spacing."),edgeTextTransform:{...fS,description:"Architecture connector-label text transform."},edgeLineWidth:Wi("Architecture connector width."),edgeBendRadius:Wi("Architecture connector bend radius."),edgeStroke:zi("Architecture connector color."),edgeText:zi("Architecture connector-label color."),iconSize:Qr("Architecture group icon size."),serviceIconSize:Qr("Architecture service icon size."),junctionOuterRadius:Qr("Architecture junction outer radius."),junctionInnerRadius:Wi("Architecture junction inner radius."),groupSurface:zi("Architecture group surface color."),groupHeaderSurface:zi("Architecture group-header surface color."),groupBorder:zi("Architecture group border color."),serviceSurface:zi("Architecture service surface color."),serviceBorder:zi("Architecture service border color.")};var Dz={...wo(XE,"Sparse architecture visual overrides merged over resolved defaults."),"x-agentic-mermaid-runtime-validator":"architectureVisual"};var Oz=(()=>{const e=dC();const t=e.$defs;const n=a=>{if(Array.isArray(a))return a.map(n);if(a===null||typeof a!=="object")return a;const l=a;const c=l.$ref;if(typeof c==="string"&&c.startsWith("#/$defs/")){const d=t?.[c.slice("#/$defs/".length)];if(!d)throw new Error(`StyleSpec schema has unresolved local reference ${c}`);return n(d)}return Object.fromEntries(Object.entries(l).filter(([d])=>d!=="$defs").map(([d,u])=>[d,n(u)]))};const{$schema:i,$id:r,title:o,...s}=e;return n(s)})();var DE={anyOf:[{type:"string",description:"Registered Style or Palette name."},Oz],"x-agentic-mermaid-validation-expectation":"a registered Style name or StyleSpec"};var UE={anyOf:[DE,{type:"array",items:DE,description:"Style stack merged from left to right."}],description:"A registered name, inline StyleSpec, or left-to-right stack of either.","x-agentic-mermaid-runtime-validator":"styleInput"};var mS={anyOf:[{type:"null"},{type:"string"},{type:"number"},{type:"boolean"},{type:"array",items:{$ref:"#/$defs/jsonValue"}},{type:"object",additionalProperties:{$ref:"#/$defs/jsonValue"}}],description:"A finite, acyclic JSON value without prototype keys.","x-agentic-mermaid-validation-expectation":"a finite, acyclic JSON value without prototype keys"};var OE=["flowchart","state","class","er","architecture","c4"];var Bz=["flowchart","state","sequence","timeline","class","er","journey","xychart","pie","quadrant","gantt","mindmap","gitgraph","sankey"];var $l=jx({layoutHints:{typeScript:"{ ranks?: Record<string, number>; adjacent?: string[][]; shortEdges?: string[] }",description:"Relative ranks, sibling adjacency and short-edge preferences.",defaultLabel:"unset",validationExpectation:"contain integer ranks, node groups and edge IDs",schema:{type:"object",additionalProperties:false,properties:{ranks:{type:"object",additionalProperties:{type:"integer",minimum:0,maximum:1e4}},adjacent:{type:"array",items:{type:"array",minItems:2,items:{type:"string"}}},shortEdges:{type:"array",items:{type:"string"}}}},terminal:"not-applicable",terminalNote:"not used by terminals",applicableBuiltinFamilies:["flowchart","state"]},graphLayout:{typeScript:"{ backend: 'elk' | 'agentic'; fallback?: 'none' | 'elk' }",description:"Graph geometry producer and explicit Agentic fallback policy.",defaultLabel:"`elk`, no fallback",validationExpectation:"be a graph layout selection object",schema:{anyOf:[wo({backend:{type:"string",const:"elk"},fallback:{type:"string",enum:["none"]}},"ELK graph layout.",["backend"]),wo({backend:{type:"string",const:"agentic"},fallback:{type:"string",enum:["none","elk"]}},"Owned graph layout with optional ELK fallback.",["backend"])]},terminal:"projected",terminalNote:"selects pixel placement and optional graphical companion evidence, not terminal-cell placement",applicableBuiltinFamilies:["flowchart","state","architecture","class","er","requirement"]},layoutSafety:{typeScript:"'report' | 'strict'",description:"Report bounded layout evidence, or require a passed final certificate. Strict mode rejects missing or unverified evidence.",defaultLabel:"`report`",validationExpectation:"be report or strict",schema:{type:"string",enum:["report","strict"],default:"report",description:"Require a passed final native layout certificate."},terminal:"consumed"},bg:{typeScript:"string",description:"Background color or CSS variable.",defaultLabel:"`#FFFFFF`",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Background color or CSS variable.","#FFFFFF"),terminal:"consumed"},fg:{typeScript:"string",description:"Primary foreground and text color.",defaultLabel:"`#27272A`",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Primary foreground and text color.","#27272A"),terminal:"consumed"},line:{typeScript:"string",description:"Connector and secondary-line color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Connector and secondary-line color."),terminal:"consumed"},accent:{typeScript:"string",description:"Arrowhead, highlight, and data accent color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Arrowhead, highlight, and data accent color."),terminal:"consumed"},muted:{typeScript:"string",description:"Secondary text and label color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Secondary text and label color."),terminal:"projected",terminalNote:"terminal themes have no dedicated muted-text role"},surface:{typeScript:"string",description:"Node and group surface color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Node and group surface color."),terminal:"projected",terminalNote:"terminal cells do not paint graphical surfaces"},border:{typeScript:"string",description:"Node and group border color.",defaultLabel:"derived",validationExpectation:"be a safe non-fetching CSS paint",schema:zi("Node and group border color."),terminal:"consumed"},font:{typeScript:"string",description:"CSS font family or stack.",defaultLabel:"`Inter`",validationExpectation:"be a safe non-fetching CSS font family or stack",schema:qE("CSS font family or stack.","Inter"),terminal:"projected",terminalNote:"the host terminal owns the font face"},style:{typeScript:"StyleInput | StyleInput[]",description:"Registered Style/Palette name, inline StyleSpec, or left-to-right stack.",defaultLabel:"`crisp`",validationExpectation:"be a registered Style name or StyleSpec, or an array of them",schema:UE,terminal:"consumed"},padding:{typeScript:"number",description:"Canvas padding in SVG user units.",defaultLabel:"`40`",validationExpectation:"be a non-negative finite number",schema:Wi("Canvas padding in SVG user units.",40),terminal:"not-applicable",terminalNote:"terminal output uses paddingX, paddingY, and boxBorderPadding",applicableBuiltinFamilies:["flowchart","state","architecture","c4"]},nodeSpacing:{typeScript:"number",description:"Horizontal spacing between sibling nodes.",defaultLabel:"`24`",validationExpectation:"be a non-negative finite number",schema:Wi("Horizontal spacing between sibling nodes.",24),terminal:"not-applicable",terminalNote:"terminal layout has a cell-grid spacing contract",applicableBuiltinFamilies:OE},layerSpacing:{typeScript:"number",description:"Vertical spacing between graph layers.",defaultLabel:"`40`",validationExpectation:"be a non-negative finite number",schema:Wi("Vertical spacing between graph layers.",40),terminal:"not-applicable",terminalNote:"terminal layout has a cell-grid spacing contract",applicableBuiltinFamilies:OE},wrappingWidth:{typeScript:"number",description:"Flowchart measured-label wrapping budget in pixels.",defaultLabel:"unset",validationExpectation:"be a positive finite number",schema:Qr("Flowchart measured-label wrapping budget in pixels."),terminal:"not-applicable",terminalNote:"terminal output uses maxWidth or targetWidth",applicableBuiltinFamilies:["flowchart"]},componentSpacing:{typeScript:"number",description:"Spacing between disconnected graph components for compatible extension families; no built-in family currently consumes it.",defaultLabel:"extension-defined",validationExpectation:"be a non-negative finite number",schema:Wi("Spacing between disconnected graph components for compatible extension families; no built-in family currently consumes it."),terminal:"not-applicable",terminalNote:"terminal layout has a cell-grid spacing contract",applicableBuiltinFamilies:[]},transparent:{typeScript:"boolean",description:"Omit the painted SVG canvas background.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:Is("Omit the painted SVG canvas background.",false),terminal:"projected",terminalNote:"terminal output has no painted canvas background"},interactive:{typeScript:"boolean",description:"Enable hover tooltips for supported chart data points.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:Is("Enable hover tooltips for supported chart data points.",false),terminal:"projected",terminalNote:"terminal output is a static semantic projection",applicableBuiltinFamilies:["xychart","pie","quadrant"]},shadow:{typeScript:"boolean",description:"Paint explicit drop shadows on node shapes.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:Is("Paint explicit drop shadows on node shapes.",false),terminal:"projected",terminalNote:"elevation projects to borders and labels",applicableBuiltinFamilies:Bz},class:{typeScript:"{ hierarchicalNamespaces?: boolean }",description:"Class-diagram rendering controls.",defaultLabel:"`hierarchicalNamespaces: true`",validationExpectation:"be a class options object",schema:wo({hierarchicalNamespaces:Is("Nest namespace compounds.",true)},"Class-diagram rendering controls."),terminal:"not-applicable",terminalNote:"this option configures graphical class layout",applicableBuiltinFamilies:["class"]},kanban:{typeScript:"{ maxWidth?: number }",description:"Opt-in Kanban column wrapping with readable column widths.",defaultLabel:"`maxWidth`: unset",validationExpectation:"be a kanban options object",schema:wo({maxWidth:Qr("Best-effort width budget for wrapping whole Kanban columns into rows.")},"Kanban layout controls."),terminal:"not-applicable",terminalNote:"terminal layout uses its own targetWidth",applicableBuiltinFamilies:["kanban"]},pie:{typeScript:"{ maxWidth?: number }",description:"Opt-in Pie title and legend fitting without shrinking typography.",defaultLabel:"`maxWidth`: unset",validationExpectation:"be a pie options object",schema:wo({maxWidth:Qr("Best-effort graphical width budget; authored legend placement retains precedence.")},"Pie layout controls."),terminal:"not-applicable",terminalNote:"terminal layout uses its own targetWidth",applicableBuiltinFamilies:["pie"]},radar:{typeScript:"{ maxWidth?: number }",description:"Opt-in Radar plot and legend fitting without shrinking typography.",defaultLabel:"`maxWidth`: unset",validationExpectation:"be a radar options object",schema:wo({maxWidth:Qr("Best-effort graphical width budget; authored frames retain precedence.")},"Radar layout controls."),terminal:"not-applicable",terminalNote:"terminal layout uses its own targetWidth",applicableBuiltinFamilies:["radar"]},architecture:{typeScript:"{ visual?: ArchitectureVisualOverrides }",description:"Sparse architecture renderer visual metric and paint overrides.",defaultLabel:"built-in metrics",validationExpectation:"be an architecture options object",schema:wo({visual:Dz},"Architecture renderer visual metric and paint overrides."),terminal:"not-applicable",terminalNote:"this option configures graphical architecture rendering",applicableBuiltinFamilies:["architecture"]},timeline:{typeScript:"{ maxWidth?: number }",description:"Timeline layout controls.",defaultLabel:"`maxWidth`: unset",validationExpectation:"be a timeline options object",schema:wo({maxWidth:Qr("Best-effort width budget for horizontal timelines.")},"Timeline layout controls."),terminal:"not-applicable",terminalNote:"terminal output uses maxWidth or targetWidth",applicableBuiltinFamilies:["timeline"]},journey:{typeScript:"{ experienceCurve?: boolean }",description:"User-journey graphical controls.",defaultLabel:"`experienceCurve: true`",validationExpectation:"be a journey options object",schema:wo({experienceCurve:Is("Connect journey score markers with an experience curve.",true)},"User-journey graphical controls."),terminal:"not-applicable",terminalNote:"experience curves are graphical-only",applicableBuiltinFamilies:["journey"]},gantt:{typeScript:"{ dependencyArrows?: boolean; criticalPath?: boolean }",description:"Gantt dependency and critical-path overlays.",defaultLabel:"both `false`",validationExpectation:"be a Gantt options object",schema:wo({dependencyArrows:Is("Draw scheduled dependency connectors.",false),criticalPath:Is("Emphasize critical-path tasks and connectors.",false)},"Gantt dependency and critical-path overlays."),terminal:"not-applicable",terminalNote:"graphical Gantt connector emphasis is not represented in cells",applicableBuiltinFamilies:["gantt"]},mermaidConfig:{typeScript:"MermaidRuntimeConfig",description:"Mermaid-style recursive runtime configuration.",defaultLabel:"source config",validationExpectation:"be a plain JSON object",schema:{type:"object",description:"Mermaid-style recursive runtime configuration.",additionalProperties:{$ref:"#/$defs/jsonValue"}},terminal:"consumed"},embedFontImport:{typeScript:"boolean",description:"Embed the Google Fonts import in SVG styles; PNG forces this off for offline rasterization.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:Is("Embed the Google Fonts import in SVG styles; PNG forces this off for offline rasterization.",false),terminal:"not-applicable",terminalNote:"terminal output embeds no web-font import"},compact:{typeScript:"boolean",description:"Compact SVG serialization while preserving agent hooks.",defaultLabel:"`false`",validationExpectation:"be a boolean",schema:Is("Compact SVG serialization while preserving agent hooks.",false),terminal:"not-applicable",terminalNote:"compact controls SVG serialization"},idPrefix:{typeScript:"string",description:"Non-empty namespace for generated SVG definition IDs and local references.",defaultLabel:"unset",validationExpectation:"be non-empty and contain only ASCII letters, digits, underscore, hyphen, dot, and colon",schema:{...np("Non-empty namespace for generated SVG definition IDs and local references."),pattern:"^[A-Za-z0-9_.:-]+$"},terminal:"not-applicable",terminalNote:"terminal output has no SVG definition ids"},security:{typeScript:"'default' | 'strict'",description:"Active SVG content is rejected in every mode; strict additionally rejects every external reference. Raw Mermaid themeCSS is rejected in both modes.",defaultLabel:"`default`",validationExpectation:"be default or strict",schema:{type:"string",enum:["default","strict"],description:"Active SVG content is rejected in every mode; strict additionally rejects every external reference. Raw Mermaid themeCSS is rejected in both modes.",default:"default"},terminal:"not-applicable",terminalNote:"terminal text has its own control-character and HTML-color safety projection"},ganttToday:{typeScript:"string",description:"Explicit deterministic date for the Gantt today marker.",defaultLabel:"unset",validationExpectation:"be a string",schema:np("Explicit deterministic date for the Gantt today marker."),terminal:"consumed",applicableBuiltinFamilies:["gantt"]},seed:{typeScript:"number",description:"Deterministic re-roll seed for stochastic Styles.",defaultLabel:"`0`",validationExpectation:"be a finite number",schema:Nl("Deterministic re-roll seed for stochastic Styles.",0),terminal:"not-applicable",terminalNote:"terminal glyph geometry is deterministic and has no stochastic ink"}});var Jc=Object.freeze(Object.keys($l));var VE=Object.freeze(Jc.filter(e=>"applicableBuiltinFamilies"in $l[e]));function bee(e){const t=e.applicableRenderOptions;if(t===void 0)return;if(!Array.isArray(t)){throw new TypeError(`Family "${e.id}" applicableRenderOptions must be an array`)}const n=new Set;for(const i of t){if(typeof i!=="string"||!VE.includes(i)){throw new Error(`Family "${e.id}" applicableRenderOptions contains unknown family-scoped field "${String(i)}"`)}if(n.has(i)){throw new Error(`Family "${e.id}" applicableRenderOptions repeats "${i}"`)}n.add(i)}}function See(){const e=Jc.map(t=>` ${t}?: ${$l[t].typeScript}`);return`interface SharedRenderOptions {
|
|
7
|
-
${e.join("\n")}
|
|
8
|
-
}`}function Wz(e){if(Array.isArray(e.enum))return e.enum.map(t=>JSON.stringify(t)).join(" | ");if(e.type==="string")return"string";if(e.type==="number"||e.type==="integer")return"number";if(e.type==="boolean")return"boolean";return"unknown"}function wee(){const e=Object.entries(XE).map(([t,n])=>` ${t}?: ${Wz(n)}`);return`interface ArchitectureVisualOverrides {
|
|
9
|
-
${e.join("\n")}
|
|
10
|
-
}`}function pS(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(ur(n))return Object.fromEntries(Object.entries(n).map(([i,r])=>[i,t(r)]));return n};return t(e)}function KE(e){let t=String(e[0]??"");for(const n of e.slice(1))t+=typeof n==="number"?`[${n}]`:`.${n}`;return`render option "${t}"`}function JE(e){return qx(J1(e).map(t=>t.path.length>0?`${KE(t.path)} ${t.message}`:`render options ${t.message}`),"render options")}function QE(e,t,n){const i=t["x-agentic-mermaid-runtime-validator"];if(i==="safeCssColor"&&yl(e)===void 0){return[{path:n,message:"must be a safe, non-fetching CSS color",generic:false}]}if(i==="safeCssPaint"&&Zn(e)===void 0){return[{path:n,message:"must be a safe, non-fetching CSS paint",generic:false}]}if(i==="safeCssFontFamily"&&mo(e)===void 0){return[{path:n,message:"must be a safe, non-fetching CSS font family or stack",generic:false}]}if(i==="styleInput"){try{hC(e)}catch(r){return[{path:n,message:`is invalid: ${r instanceof Error?r.message:String(r)}`,generic:false}]}}if(i==="architectureVisual"&&ur(e)){const r=e.junctionOuterRadius;const o=e.junctionInnerRadius;if(typeof r==="number"&&typeof o==="number"&&o>r){return[{path:[...n,"junctionInnerRadius"],message:"must not exceed junctionOuterRadius",generic:false}]}}return[]}var zz;function ZE(e){if(!ur(e))return["render options must be a plain JSON object"];const t=JE(e);if(t.length>0)return t;const n=[];const i=zz??=jx(Gz());for(const[r,o]of Object.entries(e)){if(!Object.hasOwn($l,r)){n.push(`unknown render option "${r}"`);continue}if(o===null){n.push(`render option "${r}" must be omitted instead of null`);continue}const s=$l[r];const a=Gb(o,s.schema,i,[r],{diagnostics:"field",validateRuntime:QE});if(a.length>0&&a.every(l=>l.generic&&l.path.length===1)){n.push(`render option "${r}" must ${s.validationExpectation}`)}else{n.push(...a.map(l=>`${KE(l.path)} ${l.message}`))}}return qx(n,"render options")}function Gz(){const e={};for(const t of Jc){const n=$l[t];const i="terminalNote"in n?n.terminalNote:void 0;const r="applicableBuiltinFamilies"in n?n.applicableBuiltinFamilies:void 0;e[t]={...pS(n.schema),"x-agentic-mermaid-terminal":n.terminal,...i===void 0?{}:{"x-agentic-mermaid-terminal-note":i},...r===void 0?{}:{"x-agentic-mermaid-applicable-builtin-families":[...r]}}}return{$schema:"https://json-schema.org/draft/2020-12/schema",$id:"https://agentic-mermaid.dev/schemas/render-options.schema.json",type:"object",additionalProperties:false,properties:e,$defs:{jsonValue:pS(mS)}}}function Mee(e){return{...pS(UE),...e===void 0?{}:{description:e}}}var gS=class extends Error{constructor(n,i){super(`Parsed Mermaid family "${n}" serialized as family "${i}"`);this.expectedFamilyId=n;this.detectedFamilyId=i}expectedFamilyId;detectedFamilyId;name="ParsedDiagramFamilyMismatchError";code="PARSED_DIAGRAM_FAMILY_MISMATCH"};var Fl=class extends Error{name="RenderCapabilityError";code="UNSATISFIED_RENDER_CAPABILITIES";output;family;decision;constructor(t,n,i,r){super(t);this.output=n;this.family=Object.freeze({id:i.identity.id,version:i.identity.version});this.decision=r}toJSON(){return{name:this.name,code:this.code,message:this.message,output:this.output,family:this.family,decision:this.decision}}};var Ir=class extends TypeError{constructor(t){super(t);this.name="RenderConfigError"}};var qu=new WeakMap;function Gi(e){const t=qu.get(e);if(!t)throw new Error("Resolved render request has no internal execution plan");return t}function Hz(e,t){if(e.id.startsWith("family:")){const i=new Set(e.applicableRenderOptions??[]);return Object.freeze(t.flatMap(r=>{if(!VE.includes(r)||i.has(r))return[];return[Object.freeze({code:"RENDER_OPTION_NOT_APPLICABLE",feature:`render-option:${r}`,message:`Render option "${r}" does not apply to extension family "${e.id}". Its FamilyDescriptor does not list the field in applicableRenderOptions.`})]}))}const n=e.id;return Object.freeze(t.flatMap(i=>{const r=$l[i];if(!("applicableBuiltinFamilies"in r))return[];const o=r.applicableBuiltinFamilies;if(o.includes(n))return[];const s=o.length===0?"No built-in family currently consumes this option.":`Applicable built-in families: ${o.join(", ")}.`;return[Object.freeze({code:"RENDER_OPTION_NOT_APPLICABLE",feature:`render-option:${i}`,message:`Render option "${i}" does not apply to built-in Mermaid family "${n}". ${s}`})]}))}function jz(e,t){const n=new Set;return Object.freeze([...Object.hasOwn(e,"resolutionDiagnostics")?e.resolutionDiagnostics:[],...t,...jo(e).flatMap(i=>i.requested==="agentic"&&i.selected==="elk"?[{code:"GRAPH_LAYOUT_FALLBACK",feature:"graph-layout",message:`Agentic graph layout used the requested ELK fallback: ${i.reason??"candidate rejected"}`}]:[])].flatMap(i=>{const r=_l(i);if(n.has(r))return[];n.add(r);return[Object.freeze({...i})]}))}function eR(e,t=[]){const n=qu.get(e);const i=n?.executionDecision;const r=n&&Object.hasOwn(n,"textMeasurement")?n.textMeasurement:void 0;return Object.freeze({version:e.version,output:e.output,sharedRequestDigest:e.sharedRequestDigest,requestDigest:e.requestDigest,appearanceDigest:e.appearance.digest,capabilityDecision:e.capabilityDecision,diagnostics:jz(e,t),...i?{executionDecision:i}:{},...r?{textMeasurement:r.identity}:{},...jo(e).length?{layoutDecisions:jo(e)}:{}})}function Dl(e){const t=BE.get(e);if(t)return t;const n=qu.get(e)?.backend?.identity.id??(e.output==="layout"?`backend:${e.appearance.inferredBackend}`:void 0);const i=Object.freeze({renderOptions:e.renderOptions,...e.appearance.face?{styleFace:e.appearance.face}:{},...n?{paintBackendId:n}:{},...e.familyConfig?{familyConfig:e.familyConfig}:{},...e.appearance.family?{familyAppearance:e.appearance.family}:{}});if(qu.has(e))BE.set(e,i);return i}var BE=new WeakMap;function Yz(e,t,n){const i={...e};const r=s=>Bi[s].some(a=>n?.[a]!==void 0);const o=["bg","fg","line","accent","muted","surface","border"];for(const s of o){if(i[s]===void 0&&!r(s)&&t.colors?.[s]!==void 0){i[s]=t.colors[s]}}if(i.font===void 0&&t.font!==void 0)i.font=t.font;return i}function yS(e){const t={};for(const n of Jc){const i=e[n];if(i!==void 0)t[n]=i}return t}var qz=new Set(["padding","nodeSpacing","layerSpacing","wrappingWidth","class"]);function Xz(e){return Object.fromEntries(Object.entries(e).filter(([t,n])=>n!==void 0&&!_z.includes(t)))}function Uz(e,t){if(t.kind==="registered")return t.family;throw new Sm(fP(t.kind==="unknown"?{...t,header:e.lines[0]??e.firstLine}:t,e.originalText,e.authoredWrapperLength??e.wrapperSource?.length??0,e.authoredHeader??e.lines[0]??e.firstLine,null))}function Vz(e,t,n){if(n.onConfigDiagnostic!==void 0){throw new TypeError(`Family "${e.id}" request normalizer may not return executable option "onConfigDiagnostic"`)}const i=ZE(Xz(n));if(i.length>0){throw new Ir(`Family "${e.id}" returned invalid normalized RenderOptions: ${i.join("; ")}`)}const r=yS(t);const o=yS(n);for(const s of Jc){if(qz.has(s))continue;if(_l(r[s])!==_l(o[s])){throw new TypeError(`Family "${e.id}" request normalizer may not rewrite non-geometry option "${s}"`)}}}function Kz(e,t,n){const i=new Set(["bg","fg","line","accent","muted","surface","border","shadow","font","embedFontImport"]);const r=Object.keys(t).find(s=>!i.has(s));if(r)throw new TypeError(`Family "${e.id}" returned unknown appearance color field "${r}"`);const o={...n};for(const s of["bg","fg","line","accent","muted","surface","border"]){const a=t[s];if(a===void 0)continue;const l=Zn(a);if(l===void 0)throw new Ir(`Family "${e.id}" returned an unsafe ${s} paint`);o[s]=l}if(t.font!==void 0){const s=mo(t.font);if(s===void 0)throw new Ir(`Family "${e.id}" returned an unsafe font family`);if(s!==n.font){throw new TypeError(`Family "${e.id}" request normalizer may not rewrite appearance field "font"`)}}if(t.shadow!==void 0){if(typeof t.shadow!=="boolean")throw new TypeError(`Family "${e.id}" returned a non-boolean shadow value`);if(t.shadow!==n.shadow){throw new TypeError(`Family "${e.id}" request normalizer may not rewrite appearance field "shadow"`)}}if(t.embedFontImport!==void 0){if(typeof t.embedFontImport!=="boolean")throw new TypeError(`Family "${e.id}" returned a non-boolean embedFontImport value`);if(t.embedFontImport!==n.embedFontImport){throw new TypeError(`Family "${e.id}" request normalizer may not rewrite appearance field "embedFontImport"`)}}return o}var WE=64;var Vc=1e5;var Kc=2e6;function Xu(e,t="$",n=0,i=new Set,r={nodes:0,chars:0,opaque:false,admission:void 0}){const o=r.admission;if(o?.valid){if(++o.nodes>Sl.maxNodes||n>Sl.maxDepth)o.valid=false;switch(typeof e){case"number":if(e-e!==0)o.valid=false;break;case"undefined":case"bigint":case"symbol":case"function":o.valid=false}}if(typeof e==="string"){r.chars+=e.length;if(r.chars>Kc)throw new TypeError(`data exceeds the ${Kc}-character aggregate limit at ${t}`);return e}if(e===null||typeof e!=="object")return e;if(n>WE)throw new TypeError(`data exceeds maximum depth ${WE} at ${t}`);if(++r.nodes>Vc)throw new TypeError(`data exceeds the ${Vc}-node aggregate limit at ${t}`);if(i.has(e))throw new TypeError(`data must be acyclic at ${t}`);if(Array.isArray(e)){if(e.length>Vc)throw new TypeError(`data array exceeds the ${Vc}-entry limit at ${t}`);i.add(e);try{const s=[];const a=Object.create(null);a.enumerable=a.configurable=a.writable=true;for(let l=0;l<e.length;l++){if(l>=Vc)throw new TypeError(`data array exceeds the ${Vc}-entry limit at ${t}`);if(!Object.prototype.hasOwnProperty.call(e,l))throw new TypeError(`data must not contain a sparse array at ${t}[${l}]`);const c=Xu(e[l],`${t}[${l}]`,n+1,i,r);a.value=c;Object.defineProperty(s,l,a)}if(o&&s.length>Sl.maxItemsPerContainer)o.valid=false;return xS(s,!r.opaque)}finally{i.delete(e)}}if(!ur(e)){r.opaque=true;if(o)o.valid=false;return e}i.add(e);try{const s={};let a=0;for(const[l,c]of Object.entries(e)){r.chars+=l.length;if(r.chars>Kc)throw new TypeError(`data exceeds the ${Kc}-character aggregate limit at ${t}.${l}`);if(c!==void 0){if(o&&(++a>Sl.maxItemsPerContainer||cm(l)))o.valid=false;const d=Xu(c,`${t}.${l}`,n+1,i,r);if(l in s)Object.defineProperty(s,l,{value:d,enumerable:true});else s[l]=d}}return xS(s,!r.opaque)}finally{i.delete(e)}}function zE(e,t,n,i=false){if(t===void 0)return void 0;if(!ur(t)){throw new TypeError(`Family "${e.id}" returned ${n} data that is not a plain object`)}if(i)return t;let r;try{r=Xu(t)}catch(a){throw new TypeError(`Family "${e.id}" returned invalid ${n} data: ${a instanceof Error?a.message:String(a)}`)}const o={...mS,$defs:{jsonValue:mS}};const s=Gb(r,o,o,[`family${n==="config"?"Config":"Appearance"}`],{diagnostics:"field",validateRuntime:QE});if(s.length>0){const a=s.map(l=>`${l.path.join(".")} ${l.message}`).join("; ");throw new TypeError(`Family "${e.id}" returned invalid ${n} data: ${a}`)}return ti(r)}function Jz(e,t,n,i,r,o){if(!e.normalizeRequest)return{renderOptions:n,colors:i};const s=Object.freeze({source:ti(t),renderOptions:ti(n),colors:ti(i),...r?{style:ti(r)}:{},...o?{styleFace:ti(o)}:{}});const a=e.normalizeRequest(s);if(a===void 0)return{renderOptions:n,colors:i};let l;const c={nodes:0,valid:true};try{l=bS(a,`Family "${e.id}" request normalizer result`,c)}catch(y){throw new TypeError(`Family "${e.id}" request normalizer returned invalid data: ${y instanceof Error?y.message:String(y)}`)}if(!ur(l)){throw new TypeError(`Family "${e.id}" request normalizer must return a plain object`)}const d=Object.keys(l).find(y=>!["renderOptions","familyConfig","appearance"].includes(y));if(d){throw new TypeError(`Family "${e.id}" request normalizer returned unknown field "${d}"`)}const u=l;const f=u.appearance;if(f!==void 0){const y=f;if(!ur(y)){throw new TypeError(`Family "${e.id}" request normalizer returned a non-object appearance`)}const b=Object.keys(y).find(S=>!["colors","family"].includes(S));if(b){throw new TypeError(`Family "${e.id}" request normalizer returned unknown appearance field "${b}"`)}}const h=u.renderOptions??n;Vz(e,n,h);const m=f?.colors?Kz(e,f.colors,i):i;const p=zE(e,u.familyConfig,"config",c.valid);const g=zE(e,f?.family,"appearance",c.valid);return{renderOptions:h,colors:m,...p?{familyConfig:p}:{},...g?{familyAppearance:g}:{}}}function _l(e){if(e===null||typeof e!=="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(_l).join(",")}]`;const t=e;let n="{",i="";for(const r of Object.keys(t).sort()){const o=t[r];if(o===void 0)continue;n+=`${i}${JSON.stringify(r)}:${_l(o)}`;i=","}return`${n}}`}function GE(e,t){try{return Qz(e)}catch(n){if(n instanceof TypeError&&/aggregate limit/.test(n.message)){throw new Ps("sourceCharacters",t.originalText.length+t.text.length,true)}throw n}}function tR(e){return Qc(_l(nR(e)))}function Qz(e){let t=nR(e);let n;return()=>{if(n===void 0){n=Qc(_l(t));t=void 0}return n}}function nR(e){let t;const n={nodes:0,valid:Kc<=Sl.maxAggregateTextCharacters&&Kc*3<=Sl.maxAggregateTextBytes};try{t=bS(e,"render contract digest input",n)}catch(i){const r=(i instanceof Error?i.message:String(i)).replace("data exceeds maximum depth","data exceeds maximum nesting depth");throw new TypeError(r)}if(!n.valid)xs(t,"render contract digest input",{allowUndefinedObjectProperties:true});return t}function Qc(e){let t=3421674724|0;let n=2216829733|0;for(let i=0;i<e.length;i++){const r=n^e.charCodeAt(i);const o=(r>>>16)*435+((r&65535)*435>>>16)>>>16;n=Math.imul(r,435);t=Math.imul(t,435)+o+(r<<8)|0}return`fnv1a64:${(t>>>0).toString(16).padStart(8,"0")}${(n>>>0).toString(16).padStart(8,"0")}`}var iR=new WeakSet;function xS(e,t=true){Object.freeze(e);if(t)iR.add(e);return e}function ti(e,t="$",n,i){if(e===null||typeof e!=="object")return e;if(iR.has(e))return e;n??=new Set;i??=new WeakMap;if(n.has(e))throw new TypeError(`render request contains a cycle at ${t}`);const r=i.get(e);if(r)return r;const o=Object.getPrototypeOf(e);if(!Array.isArray(e)&&o!==Object.prototype&&o!==null){throw new TypeError(`render request contains a non-JSON object at ${t}`)}n.add(e);let s;if(Array.isArray(e)){const a=e.length;const l=new Array(a);for(let c=0;c<a;c++){if(c in e)l[c]=ti(e[c],`${t}[${c}]`,n,i)}s=l}else{const a={};for(const[l,c]of Object.entries(e)){const d=ti(c,`${t}.${l}`,n,i);if(l in a)Object.defineProperty(a,l,{value:d,enumerable:true});else a[l]=d}s=a}n.delete(e);i.set(e,s);return xS(s)}function bS(e,t,n){try{return ti(n?Xu(e,"$",0,new Set,{nodes:0,chars:0,opaque:false,admission:n}):Xu(e))}catch(i){throw new TypeError(`${t} could not be snapshotted: ${i instanceof Error?i.message:String(i)}`)}}var Zz=Object.freeze({serializable:ti({})});var eG=new WeakMap;var tG=new WeakMap;function nG(e){if(typeof e!=="object"&&typeof e!=="function"||e===null){throw new Ir("Invalid RenderOptions: render options must be an object")}const t=eG.get(e);if(t)return t;const n=[];let i;for(const[s,a]of Object.entries(e)){if(s==="onConfigDiagnostic"){i=a}else if(a!==void 0){n.push([s,a])}}if(i!==void 0&&typeof i!=="function"){throw new Ir("Invalid RenderOptions: onConfigDiagnostic must be a function")}if(n.length===0&&i===void 0)return Zz;const r=Object.fromEntries(n);let o;try{o=bS(r,"RenderOptions")}catch(s){const a=(s instanceof Error?s.message:String(s)).replace("data exceeds maximum depth","render option tree exceeds maximum nesting depth");throw new Ir(`Invalid RenderOptions: ${a}`)}return Object.freeze({serializable:o,...i===void 0?{}:{onConfigDiagnostic:i}})}function iG(e){const t=e===void 0?[]:Array.isArray(e)?e:[e];return ti(t.flatMap(n=>{if(typeof n!=="string"||n==="crisp")return[];const i=uC(n);if(!i)return[];return[{input:n,canonicalId:i.canonicalId}]}))}function rG(e){const t=new Set;for(const n of Object.values(Bi)){for(const i of n){const r=e.config.themeVariables?.[i];if(typeof r==="string"&&r.length>0&&yl(r)===void 0)t.add(i)}}return Object.freeze([...t].sort())}var SS="1.0.0";function Sa(e,t,n=SS){return t?[{id:e,version:n}]:[]}function Jr(e,t=`^${SS}`){return{id:e,range:t,level:"required"}}function HE(e){return`scene-primitive:${e.primitive}/${e.feature}/${e.operation}`}function oG(e){const t=new Set(e.scenePrimitiveEvidence.filter(n=>n.applicability==="applicable").map(n=>n.primitive));return Xx.filter(n=>t.has(n.primitive))}var jE=new WeakMap;function YE(e,t){let n=jE.get(e.backend);if(!n){n=new Set(Xx.filter(i=>e.backend.capabilities.some(r=>r.primitive===i.primitive&&r.feature===i.feature&&r.operation===i.operation&&r.realization!=="unsupported")));jE.set(e.backend,n)}return n.has(t)}function sG(e){return e.resolutions.filter(t=>t.level==="required"&&t.status!=="selected").map(t=>t.id).join(", ")}function aG(e,t,n,i,r,o){const s=sG(o);const a=s?` (unsatisfied capabilities: ${s})`:"";if(e==="layout"){return new Fl(`No public layout projection registered for Mermaid family "${t.id}"${a}`,e,t,o)}if(e==="ascii"||e==="unicode"||e==="html"){return new Fl(`No ASCII renderer registered for Mermaid family ${t.id}${a}`,e,t,o)}if(n.styled&&!t.lowerScene){return new Fl(`Family "${t.id}" does not support styled rendering (no SceneGraph lowering registered). Render without the style option, or register a lowerScene hook for the family.${a}`,e,t,o)}if(i==="scene"&&t.layout&&t.lowerScene&&!r){return new Fl(n.styled?`Style "${n.style?.name??"(inline)"}" requires an unavailable SceneGraph backend${a}`:`Default SceneGraph backend is not registered${a}`,e,t,o)}return new Fl(`No SVG renderer registered for Mermaid family ${t.id}${a}`,e,t,o)}var hS=new Map;function lG(e,t,n,i){const r=t.length+n.length;if(typeof e!=="string"||r>256)return void 0;let o=e.length+r*16;if(o>16384)return void 0;let s=`${e.length}:${e};${i};${t.length};${n.length};`;for(const a of t){if(typeof a.id!=="string"||typeof a.version!=="string")return void 0;o+=a.id.length+a.version.length;if(o>16384)return void 0;s+=`${a.id.length}:${a.id}${a.version.length}:${a.version}`}for(const a of n){if(typeof a.id!=="string"||typeof a.range!=="string"||typeof a.level!=="string")return void 0;o+=a.id.length+a.range.length+a.level.length;if(o>16384)return void 0;s+=`${a.id.length}:${a.id}${a.range.length}:${a.range}${a.level.length}:${a.level}`}return s.length<=8192?s:void 0}function cG(e,t,n,i){const r=lG(e,t,n,i);const o=r===void 0?void 0:hS.get(r);Ht("capability-decision",r===void 0?"bypass":o?"hit":"miss",r===void 0?"tuple-budget":void 0);if(o)return o;const s=R1(e,{offers:t,requirements:n,outputAvailable:i});if(r!==void 0){if(hS.size<32)hS.set(r,s);else Ht("capability-decision","store-skipped","capacity")}return s}function dG(e,t,n,i,r,o){let s;let a;let l;if(n==="svg"||n==="png"){s=t.styled||e.lowerScene?"scene":"family-svg";if(s==="scene"){l=t.styled?t.inferredBackend:"default";a=kC(l,i.backendPolicy)}}else if(n==="layout"){s="layout"}else{s="terminal"}const c=s==="scene"?oG(e):[];const d=a?c.flatMap(b=>Sa(HE(b),YE(a,b))):[];const u=[{id:e.identity.id,version:e.identity.version},...Sa("operation:layout",e.layout!==void 0),...Sa("operation:project-positioned",e.projectPositioned!==void 0),...Sa("operation:lower-scene",e.lowerScene!==void 0),...Sa("operation:render-svg",e.renderSvg!==void 0),...Sa("operation:render-terminal",e.renderAscii!==void 0),...Sa("core:scene",s==="scene"),...Sa("backend:scene-renderer",a!==void 0,a?.identity.version),...d];const f=[Jr("core:family-descriptor"),Jr(e.identity.id,e.identity.version)];let h;switch(s){case"scene":f.push(Jr("core:scene"),Jr("operation:layout"),Jr("operation:lower-scene"),Jr("backend:scene-renderer",a?.identity.version??SS),...c.map(b=>Jr(HE(b))));h=Boolean(e.layout&&e.lowerScene&&a&&c.every(b=>YE(a,b)));break;case"family-svg":f.push(Jr("operation:layout"),Jr("operation:render-svg"));h=Boolean(e.layout&&e.renderSvg);break;case"terminal":f.push(Jr("operation:render-terminal"));h=e.renderAscii!==void 0;break;case"layout":f.push(Jr("operation:layout"),Jr("operation:project-positioned"));h=Boolean(e.layout&&e.projectPositioned);break}const m=cG(n,u,f,h);if(!m.accepted){throw aG(n,e,t,s,a,m)}const p=s==="terminal"?void 0:v1(i.textMeasurement,t.font);let g;if(s==="scene"||s==="family-svg"){const b=s==="scene"?Object.freeze({mode:"scene",requestedId:l,selectedId:a.identity.id,version:a.identity.version,hostPolicy:i.backendPolicy!==void 0}):Object.freeze({mode:"family-svg"});const S={family:Object.freeze({id:e.identity.id,version:e.identity.version}),backend:b,...p?{textMeasurement:p.identity}:{}};g=Object.freeze({...S,digest:tR(S)})}const y=r===void 0?void 0:Object.freeze(_E(e.id,r,e.config,e.configDiagnostics).map(b=>Object.freeze({...b})));return Object.freeze({output:n,mode:s,family:e,...a?{backend:a}:{},...l?{requestedBackendId:l}:{},...y===void 0?{}:{configDiagnostics:y},...o?{onConfigDiagnostic:o}:{},capabilityDecision:m,...g?{executionDecision:g}:{},...p?{textMeasurement:p}:{}})}function uG(e){return!e.id.startsWith("output:")&&!e.id.startsWith("operation:")&&!e.id.startsWith("backend:")&&!e.id.startsWith("scene-primitive:")&&e.id!=="core:scene"}function fG(e){const{family:t,source:n,options:i,style:r,styleFace:o}=e;let s=i.security==="strict"?{...i,embedFontImport:false}:{...i};if(i.graphLayout)s.graphLayout={...i.graphLayout,fallback:i.graphLayout.fallback??"none"};const a=r!==void 0&&pC(r);if(a)s=Yz(s,r,n.config.themeVariables);const l=i.font??n.config.fontFamily??$b(n.config.themeVariables,"fontFamily")??s.font??"Inter";const c=mo(l)??l;const{style:d,...u}=s;const f={...u,...r?{style:r}:{},font:c,mermaidConfig:n.config};const h={...Ym(f,n.config,c)};const m=Jz(t,n,f,h,r,o);const p=ti(m.colors);const g=tG.get(i)??iG(i.style);const y=rG(n);const b={version:hm,colors:p,font:c,style:ti(r),face:ti(o),styled:a,inferredBackend:r?fC(r):"default",styleReferences:g,...y.length>0?{unsafeThemeColorKeys:y}:{},...m.familyAppearance?{family:m.familyAppearance}:{}};const S=ti({...b,digest:tR(b)});return ti({renderOptions:ti(m.renderOptions),appearance:S,...m.familyConfig?{familyConfig:m.familyConfig}:{}})}function kee(e,t={},n="svg",i){return wS(e,t,n,i)}function wS(e,t={},n="svg",i,r={}){const o=nG(t);const s=o.serializable;const a=s;const l=JE(a);if(l.length>0){throw new Ir(`Invalid RenderOptions: ${l.join("; ")}`)}const c=o.capturedStyle??mC(s.style);const d=c.style;const u=ti(c.face);const f=o.capturedStyle?[]:ZE(a);if(f.length>0){throw new Ir(`Invalid RenderOptions: ${f.join("; ")}`)}let h;const m=ME(e,s.mermaidConfig??{},F=>{if(r.familyDescriptor)return r.familyDescriptor;h=yb(F);return h.kind==="registered"?h.family:null});const p=ti(m);const g=r.familyDescriptor??Uz(p,h);const y=p;if(r.expectedFamilyId!==void 0&&g.id!==r.expectedFamilyId){throw new gS(r.expectedFamilyId,g.id)}Ve("sourceCharacters",y.originalText.length+y.text.length);const b=Q1(y.config.themeCSS,s.security??"default");if(b)throw new Ir(b);if(g.id!=="architecture")cS(y.config.themeVariables,g.id,s);$E(y.frontmatter,g.id);const S=Object.freeze(Jc.filter(F=>s[F]!==void 0));const x=Hz(g,S);const k=fG({family:g,source:y,options:s,...d?{style:d}:{},...u?{styleFace:u}:{}});const{appearance:w,renderOptions:C,familyConfig:R}=k;const M=w.family?.visual;if(g.id==="architecture"){cS(y.config.themeVariables,g.id,s,M)}NE(s,g.id,M);const P=dG(g,w,n,r,s.mermaidConfig,o.onConfigDiagnostic);const E=P.capabilityDecision;const v=Object.freeze(E.resolutions.filter(uG));const L=Object.freeze({version:E.version,accepted:v.every(F=>F.level!=="required"||F.status==="selected"),resolutions:v});const T={version:hm,authoredSource:y.originalText,source:y.text,options:yS(C),appearance:w.digest,...R?{familyConfig:R}:{},...P.textMeasurement?{textMeasurement:P.textMeasurement.identity}:{},capabilities:L};const A=GE(T,y);const $={...T,output:n,outputOptions:i,capabilities:E};const _=GE($,y);const z=Object.freeze({version:hm,output:n,source:ti(y),renderOptions:C,appearance:w,...R?{familyConfig:R}:{},capabilityDecision:E,explicitOptionFields:S,...x.length===0?{}:{resolutionDiagnostics:x},get sharedRequestDigest(){return A()},get requestDigest(){return _()}});qu.set(z,P);return z}var MS=128;function Ol(e,t,n,i){if(e.length<32||e.length>268435456)return null;let r=Infinity,o=-Infinity,s=0;i?.(2*e.length,"capacity");const a=new Float64Array(e.length),l=new Float64Array(e.length);for(let h=0;h<e.length;h++){i?.(1,"work");const m=e[h];const p=m[t]-n;const g=m[t]+(t==="x"?m.width:m.height)+n;const y=Math.floor(p/MS),b=Math.floor(g/MS);if(!Number.isSafeInteger(y)||!Number.isSafeInteger(b)||b<y)return null;s+=b-y+1;if(s>8*e.length)return null;a[h]=y;l[h]=b;r=Math.min(r,y);o=Math.max(o,b)}i?.(1,"work");const c=o-r+1;if(!Number.isSafeInteger(c)||c>8*e.length)return null;i?.(c+1,"capacity");const d=new Uint32Array(c+1);for(let h=0;h<e.length;h++){for(let m=a[h]-r;m<=l[h]-r;m++){i?.(1,"work");d[m+1]++}}for(let h=1;h<=c;h++){i?.(1,"work");d[h]+=d[h-1]}i?.(c+s,"capacity");const u=d.slice(0,c),f=new Uint32Array(s);for(let h=0;h<e.length;h++){for(let m=a[h]-r;m<=l[h]-r;m++){i?.(1,"work");f[u[m]++]=h}}return{firstCell:r,offsets:d,ordinals:f}}function ip(e,t){const n=Math.floor(t/MS);return Number.isSafeInteger(n)?n-e.firstCell:null}function rR(e,t,n,i){if(!e)return void 0;if(e[n]===void 0)e[n]=Ol(t,n,i);return e[n]}function hG(e){let t=Infinity,n=-Infinity,i=Infinity,r=-Infinity;for(const o of e){const s=o.x,a=o.y;if(!Number.isFinite(s)||!Number.isFinite(a))return null;t=Math.min(t,s);n=Math.max(n,s);i=Math.min(i,a);r=Math.max(r,a)}return{minX:t,maxX:n,minY:i,maxY:r}}function oR(e,t,n,i,r,o,s,a){if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(o))return true;if(t.points.length<2)return false;let l=e.get(t);if(l===void 0){l=hG(t.points);e.set(t,l)}if(!l)return true;const c=n==="x"?l.minX:l.minY;const d=n==="x"?l.maxX:l.maxY;if(i<c&&c-i>=s)return false;if(i>d&&i-d>=s)return false;const u=n==="x"?l.minY:l.minX;const f=n==="x"?l.maxY:l.maxX;return Math.min(o,f)-Math.max(r,u)>a}var sR=new WeakMap;var Zr=e=>({fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth});var op=e=>({stroke:e.stroke,strokeWidth:e.strokeWidth});var Hi=(e,t)=>({geometry:{kind:"polygon",points:e},paint:Zr(t),routing:{kind:"polygon",points:e}});var nr=(e,t,n,i={})=>({geometry:{kind:"path",d:t},paint:{...Zr(n),fill:i.fill==="none"?"none":n.fill},routing:{kind:"envelope",x:e.x,y:e.y,width:e.width,height:e.height,reason:i.reason??"closed curved path uses a conservative routing envelope"}});function Fr(e,t,n){const i=xG(e,t);if(i)return i;const{x:r,y:o,width:s,height:a}=e;const l=r+s/2,c=o+a/2;switch(e.shape){case"state-note":{const d=Math.min(12,s/6,a/4);return Hi([{x:r,y:o},{x:r+s-d,y:o},{x:r+s,y:o+d},{x:r+s,y:o+a},{x:r,y:o+a}],t)}case"diamond":case"state-choice":return Hi([{x:l,y:c-a/2},{x:l+s/2,y:c},{x:l,y:c+a/2},{x:l-s/2,y:c}],t);case"stadium":{const d=a/2;return{geometry:{kind:"rect",x:r,y:o,width:s,height:a,rx:d,ry:d},paint:Zr(t),routing:{kind:"stadium",cx:l,cy:c,halfWidth:s/2,radius:d}}}case"ellipse":return{geometry:{kind:"ellipse",cx:l,cy:c,rx:s/2,ry:a/2},paint:Zr(t),routing:{kind:"ellipse",cx:l,cy:c,rx:s/2,ry:a/2}};case"circle":case"state-history":return uR(l,c,Math.min(s,a)/2,t);case"doublecircle":return SG(l,c,Math.min(s,a)/2,t);case"hexagon":{const d=a/4;return Hi([{x:r+d,y:o},{x:r+s-d,y:o},{x:r+s,y:c},{x:r+s-d,y:o+a},{x:r+d,y:o+a},{x:r,y:c}],t)}case"cylinder":return MG(r,o,s,a,t);case"asymmetric":return Hi([{x:r+12,y:o},{x:r+s,y:o},{x:r+s,y:o+a},{x:r+12,y:o+a},{x:r,y:c}],t);case"trapezoid":{const d=s*.15;return Hi([{x:r+d,y:o},{x:r+s-d,y:o},{x:r+s,y:o+a},{x:r,y:o+a}],t)}case"trapezoid-alt":{const d=s*.15;return Hi([{x:r,y:o},{x:r+s,y:o},{x:r+s-d,y:o+a},{x:r+d,y:o+a}],t)}case"lean-r":{const d=s*.15;return Hi([{x:r+d,y:o},{x:r+s,y:o},{x:r+s-d,y:o+a},{x:r,y:o+a}],t)}case"lean-l":{const d=s*.15;return Hi([{x:r,y:o},{x:r+s-d,y:o},{x:r+s,y:o+a},{x:r+d,y:o+a}],t)}case"subroutine":return wG(r,o,s,a,t,n??0);case"state-start":return kG(l,c,Math.max(0,Math.min(s,a)/2-2));case"state-end":return CG(l,c,Math.max(0,Math.min(s,a)/2-2));case"state-fork":case"state-join":return PG(r,o,s,a);case"rounded":return aR(r,o,s,a,t,n??6);case"service":case"rectangle":default:return aR(r,o,s,a,t,n??0)}}function xi(e){const t=sR.get(e);if(t&&t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height&&t.shape===e.shape&&t.semanticShape===e.semanticShape){return t.profile}const n=Fr(e,{fill:"",stroke:"",strokeWidth:""}).routing;const i=yG(e);const r={};for(const s of["N","E","S","W"]){const a=mG(n,s)??i[s];if(n.kind==="none"){r[s]={kind:"none",preferred:a};continue}if(n.kind==="envelope"){const[c,d]=cR(n,s);r[s]={kind:"envelope",lo:c,hi:d,preferred:a};continue}const l=pG(e,n,s);r[s]=l?{kind:"dynamic",...l,preferred:a}:{kind:"port",point:a,preferred:a}}const o={boundary:n,sides:r};sR.set(e,{x:e.x,y:e.y,width:e.width,height:e.height,shape:e.shape,semanticShape:e.semanticShape,profile:o});return o}function Zc(e){const t=xi(e);return{N:{...t.sides.N.preferred},E:{...t.sides.E.preferred},S:{...t.sides.S.preferred},W:{...t.sides.W.preferred}}}function Fs(e,t,n){return dR(e,t==="E"||t==="W"?"x":"y",n,t==="E"||t==="S")}function lR(e,t,n){const i=e.sides[t];if(i.kind==="none")return null;if(i.kind==="port")return i.point;return Fs(e.boundary,t,n)}function mG(e,t){const n=CS(e);if(!n)return null;const i=t==="E"||t==="W"?"x":"y";const r=i==="x"?n.y+n.height/2:n.x+n.width/2;return dR(e,i,r,t==="E"||t==="S")}function cR(e,t){const n=CS(e);return t==="E"||t==="W"?[n.y,n.y+n.height]:[n.x,n.x+n.width]}function pG(e,t,n){const[i,r]=cR(t,n);if(t.kind==="rect")return Uu(i,r,4);if(t.kind==="stadium"&&(n==="N"||n==="S")){return Uu(t.cx-(t.halfWidth-t.radius),t.cx+(t.halfWidth-t.radius),2)}if(t.kind==="cylinder"&&(n==="E"||n==="W")){return Uu(t.y+t.capRadiusY,t.y+t.height-t.capRadiusY,2)}if(t.kind!=="polygon")return null;const o=CS(t);const s=n==="E"||n==="W"?"x":"y";const a=s==="x"?n==="E"?o.x+o.width:o.x:n==="S"?o.y+o.height:o.y;const l=[];for(let c=0;c<t.points.length;c++){const d=t.points[c];const u=t.points[(c+1)%t.points.length];if(Math.abs(d[s]-a)>1e-9||Math.abs(u[s]-a)>1e-9)continue;const f=s==="x"?d.y:d.x;const h=s==="x"?u.y:u.x;l.push([Math.min(f,h),Math.max(f,h)])}if(l.length>0){const c=l.sort((d,u)=>u[1]-u[0]-(d[1]-d[0]))[0];return Uu(c[0],c[1],2)}if(t.points.length===4&&gG(t.points,o)){const c=r-i;const d=c<=40?c/4:10;return Uu(i,r,d)}return null}function Uu(e,t,n){return t-e>n*2?{lo:e+n,hi:t-n}:null}function gG(e,t){const n=t.x+t.width/2;const i=t.y+t.height/2;const r=[{x:n,y:t.y},{x:t.x+t.width,y:i},{x:n,y:t.y+t.height},{x:t.x,y:i}];return e.every(o=>r.some(s=>Math.abs(o.x-s.x)<1e-8&&Math.abs(o.y-s.y)<1e-8))}function CS(e){switch(e.kind){case"rect":case"envelope":return{x:e.x,y:e.y,width:e.width,height:e.height};case"ellipse":return{x:e.cx-e.rx,y:e.cy-e.ry,width:e.rx*2,height:e.ry*2};case"stadium":return{x:e.cx-e.halfWidth,y:e.cy-e.radius,width:e.halfWidth*2,height:e.radius*2};case"cylinder":return{x:e.cx-e.width/2,y:e.y,width:e.width,height:e.height};case"polygon":{if(e.points.length===0)return null;const t=e.points.map(o=>o.x);const n=e.points.map(o=>o.y);const i=Math.min(...t),r=Math.min(...n);return{x:i,y:r,width:Math.max(...t)-i,height:Math.max(...n)-r}}case"none":return null}}function dR(e,t,n,i){const r=s=>s.length===0?null:i?Math.max(...s):Math.min(...s);const o=s=>t==="x"?{x:s,y:n}:{x:n,y:s};switch(e.kind){case"rect":case"envelope":{const s=t==="x"?e.y:e.x;const a=s+(t==="x"?e.height:e.width);if(n<s-1e-9||n>a+1e-9)return null;return o(t==="x"?i?e.x+e.width:e.x:i?e.y+e.height:e.y)}case"ellipse":{const s=t==="x"?e.cy:e.cx;const a=t==="x"?e.ry:e.rx;const l=t==="x"?e.cx:e.cy;const c=t==="x"?e.rx:e.ry;if(a<=0||c<=0)return null;const d=(n-s)/a;if(Math.abs(d)>1+1e-9)return null;return o(l+(i?1:-1)*c*Math.sqrt(Math.max(0,1-d*d)))}case"stadium":{if(t==="x"){const l=n-e.cy;if(Math.abs(l)>e.radius+1e-9)return null;const c=e.halfWidth-e.radius+Math.sqrt(Math.max(0,e.radius**2-l**2));return o(e.cx+(i?c:-c))}const s=Math.abs(n-e.cx);if(s>e.halfWidth+1e-9)return null;const a=Math.max(0,s-(e.halfWidth-e.radius));return o(e.cy+(i?1:-1)*Math.sqrt(Math.max(0,e.radius**2-a**2)))}case"cylinder":{const s=e.width/2;const a=e.y+e.capRadiusY;const l=e.y+e.height-e.capRadiusY;if(t==="x"){if(n<e.y-1e-9||n>e.y+e.height+1e-9)return null;const u=n<a?a:n>l?l:n;const f=u===n?0:(n-u)/e.capRadiusY;return o(e.cx+(i?1:-1)*s*Math.sqrt(Math.max(0,1-f*f)))}const c=(n-e.cx)/s;if(Math.abs(c)>1+1e-9)return null;const d=e.capRadiusY*Math.sqrt(Math.max(0,1-c*c));return o(i?l+d:a-d)}case"polygon":{const s=[];for(let l=0;l<e.points.length;l++){const c=e.points[l];const d=e.points[(l+1)%e.points.length];const u=t==="x"?c.y:c.x;const f=t==="x"?d.y:d.x;const h=c[t],m=d[t];const p=f-u;if(Math.abs(p)<1e-9){if(Math.abs(n-u)<1e-9)s.push(h,m);continue}const g=(n-u)/p;if(g>=-1e-9&&g<=1+1e-9)s.push(h+g*(m-h))}const a=r(s);return a===null?null:o(a)}case"none":return null}}function yG(e){const t=e.x+e.width/2;const n=e.y+e.height/2;return{N:{x:t,y:e.y},E:{x:e.x+e.width,y:n},S:{x:t,y:e.y+e.height},W:{x:e.x,y:n}}}function xG(e,t){const{x:n,y:i,width:r,height:o}=e;const s=n+r,a=i+o,l=n+r/2,c=i+o/2;switch(e.semanticShape){case"bang":return Hi(Array.from({length:16},(d,u)=>{const f=-Math.PI/2+u*Math.PI/8;const h=u%2===0?1:.62;return{x:l+Math.cos(f)*r/2*h,y:c+Math.sin(f)*o/2*h}}),t);case"notch-rect":return Hi([{x:n+10,y:i},{x:s,y:i},{x:s,y:a},{x:n,y:a},{x:n,y:i+10}],t);case"cloud":return nr(e,`M${n+r*.18} ${a}C${n-4} ${a} ${n-4} ${c} ${n+r*.12} ${c}C${n+r*.08} ${i+o*.15} ${n+r*.38} ${i-4} ${n+r*.48} ${i+o*.18}C${n+r*.65} ${i-5} ${s} ${i+o*.16} ${n+r*.88} ${c}C${s+5} ${c} ${s+5} ${a} ${n+r*.72} ${a}Z`,t);case"hourglass":return Hi([{x:n,y:i},{x:s,y:i},{x:n+r*.62,y:c},{x:s,y:a},{x:n,y:a},{x:n+r*.38,y:c}],t);case"bolt":return Hi([{x:n+r*.55,y:i},{x:n+r*.25,y:c},{x:n+r*.48,y:c},{x:n+r*.35,y:a},{x:n+r*.78,y:i+o*.4},{x:n+r*.55,y:i+o*.4}],t);case"brace":return rp(e,`M${s} ${i}C${n+r*.4} ${i} ${n+r*.7} ${c} ${n} ${c}C${n+r*.7} ${c} ${n+r*.4} ${a} ${s} ${a}`,t);case"brace-r":return rp(e,`M${n} ${i}C${n+r*.6} ${i} ${n+r*.3} ${c} ${s} ${c}C${n+r*.3} ${c} ${n+r*.6} ${a} ${n} ${a}`,t);case"braces":return rp(e,`M${n+r*.25} ${i}C${n} ${i} ${n+r*.15} ${c} ${n} ${c}C${n+r*.15} ${c} ${n} ${a} ${n+r*.25} ${a}M${n+r*.75} ${i}C${s} ${i} ${n+r*.85} ${c} ${s} ${c}C${n+r*.85} ${c} ${s} ${a} ${n+r*.75} ${a}`,t);case"datastore":return rp(e,`M${n+8} ${i}H${s}V${a}H${n+8}M${n+8} ${i}C${n-2} ${i+o*.2} ${n-2} ${a-o*.2} ${n+8} ${a}`,t);case"delay":return nr(e,`M${n} ${i}H${s-o/2}A${o/2} ${o/2} 0 0 1 ${s-o/2} ${a}H${n}Z`,t);case"h-cyl":return nr(e,`M${n+10} ${i}H${s-10}A10 ${o/2} 0 0 1 ${s-10} ${a}H${n+10}A10 ${o/2} 0 0 1 ${n+10} ${i}Z M${s-10} ${i}A10 ${o/2} 0 0 0 ${s-10} ${a}`,t);case"lin-cyl":return nr(e,`M${n} ${i+8}A${r/2} 8 0 0 1 ${s} ${i+8}V${a-8}A${r/2} 8 0 0 1 ${n} ${a-8}Z M${n} ${i+8}A${r/2} 8 0 0 0 ${s} ${i+8}M${n} ${a-16}A${r/2} 8 0 0 0 ${s} ${a-16}`,t);case"curv-trap":return nr(e,`M${n+12} ${i}Q${l} ${i+8} ${s-12} ${i}L${s} ${a}Q${l} ${a-8} ${n} ${a}Z`,t);case"div-rect":return kS(e,`M${n} ${i}H${s}V${a}H${n}ZM${n} ${c}H${s}`,t);case"doc":return nr(e,`M${n} ${i}H${s}V${a-8}Q${n+r*.75} ${a+2} ${l} ${a-8}Q${n+r*.25} ${a-18} ${n} ${a-8}Z`,t);case"tri":return Hi([{x:l,y:i},{x:s,y:a},{x:n,y:a}],t);case"fork":return EG(n,c-4,r,8,t.stroke,t.strokeWidth);case"win-pane":return kS(e,`M${n} ${i}H${s}V${a}H${n}ZM${n+r*.28} ${i}V${a}M${n} ${i+o*.32}H${s}`,t);case"f-circ":return bG(l,c,Math.min(r,o)/2,t.stroke,t.strokeWidth);case"lin-doc":return nr(e,`M${n} ${i}H${s}V${a-8}Q${n+r*.75} ${a+2} ${l} ${a-8}Q${n+r*.25} ${a-18} ${n} ${a-8}ZM${n+8} ${i+8}H${s-8}`,t);case"lin-rect":return kS(e,`M${n} ${i}H${s}V${a}H${n}ZM${n+6} ${i}V${a}M${s-6} ${i}V${a}`,t);case"notch-pent":return Hi([{x:n,y:i},{x:s-10,y:i},{x:s,y:c},{x:s-10,y:a},{x:n,y:a},{x:n+8,y:c}],t);case"flip-tri":return Hi([{x:n,y:i},{x:s,y:i},{x:l,y:a}],t);case"docs":return nr(e,`M${n+8} ${i}H${s}V${a-8}Q${n+r*.7} ${a} ${n+r*.45} ${a-8}Q${n+r*.22} ${a-16} ${n+8} ${a-8}ZM${n} ${i+8}H${n+8}M${n} ${i+8}V${a}`,t);case"st-rect":return nr(e,`M${n+8} ${i}H${s}V${a-8}H${n+8}ZM${n} ${i+8}H${s-8}V${a}H${n}Z`,t);case"flag":return nr(e,`M${n} ${i+6}Q${n+r*.25} ${i-4} ${l} ${i+6}Q${n+r*.75} ${i+16} ${s} ${i+6}V${a-6}Q${n+r*.75} ${a+4} ${l} ${a-6}Q${n+r*.25} ${a-16} ${n} ${a-6}Z`,t);case"sm-circ":return uR(l,c,Math.min(r,o)*.22,t);case"cross-circ":{const d=nr(e,`M${l} ${i}A${r/2} ${o/2} 0 1 1 ${l-.01} ${i}M${n+r*.28} ${i+o*.28}L${n+r*.72} ${i+o*.72}M${n+r*.72} ${i+o*.28}L${n+r*.28} ${i+o*.72}`,t);d.routing={kind:"ellipse",cx:l,cy:c,rx:r/2,ry:o/2};return d}case"bow-rect":return nr(e,`M${n} ${i}Q${n+12} ${c} ${n} ${a}H${s}Q${s-12} ${c} ${s} ${i}Z`,t);case"tag-doc":return nr(e,`M${n+10} ${i}H${s}V${a-8}Q${n+r*.7} ${a} ${l} ${a-8}Q${n+r*.25} ${a-16} ${n} ${a-8}V${i+10}ZM${n} ${i+10}L${n+10} ${i}`,t);case"tag-rect":return Hi([{x:n+10,y:i},{x:s,y:i},{x:s,y:a},{x:n,y:a},{x:n,y:i+10}],t);case"text":return{geometry:{kind:"path",d:`M${n} ${i}`},paint:{fill:"none",stroke:"none"},routing:{kind:"none",reason:"text blocks have no painted enclosure"}};default:return null}}function aR(e,t,n,i,r,o){return{geometry:{kind:"rect",x:e,y:t,width:n,height:i,rx:o,ry:o},paint:Zr(r),routing:{kind:"rect",x:e,y:t,width:n,height:i}}}function uR(e,t,n,i){return{geometry:{kind:"circle",cx:e,cy:t,r:n},paint:Zr(i),routing:{kind:"ellipse",cx:e,cy:t,rx:n,ry:n}}}function bG(e,t,n,i,r){return{geometry:{kind:"circle",cx:e,cy:t,r:n},paint:{fill:i,stroke:i,strokeWidth:r},routing:{kind:"ellipse",cx:e,cy:t,rx:n,ry:n}}}function SG(e,t,n,i){const r=Math.max(0,n-5);return{geometry:{kind:"compound",children:[{kind:"circle",cx:e,cy:t,r:n},{kind:"circle",cx:e,cy:t,r}]},paint:Zr(i),routing:{kind:"ellipse",cx:e,cy:t,rx:n,ry:n}}}function wG(e,t,n,i,r,o){const s=8;return{geometry:{kind:"compound",children:[{kind:"rect",x:e,y:t,width:n,height:i,rx:o,ry:o},{kind:"line",x1:e+s,y1:t,x2:e+s,y2:t+i},{kind:"line",x1:e+n-s,y1:t,x2:e+n-s,y2:t+i}]},paint:Zr(r),childPaints:[Zr(r),op(r),op(r)],routing:{kind:"rect",x:e,y:t,width:n,height:i}}}function MG(e,t,n,i,r){const o=7,s=e+n/2,a=t+o,l=i-2*o;return{geometry:{kind:"compound",children:[{kind:"rect",x:e,y:a,width:n,height:l},{kind:"line",x1:e,y1:a,x2:e,y2:a+l},{kind:"line",x1:e+n,y1:a,x2:e+n,y2:a+l},{kind:"ellipse",cx:s,cy:t+i-o,rx:n/2,ry:o},{kind:"ellipse",cx:s,cy:a,rx:n/2,ry:o}]},paint:Zr(r),childPaints:[{fill:r.fill,stroke:"none"},op(r),op(r),Zr(r),Zr(r)],routing:{kind:"cylinder",cx:s,y:t,width:n,height:i,capRadiusY:o}}}function kG(e,t,n){return{geometry:{kind:"circle",cx:e,cy:t,r:n},paint:{fill:"var(--_text)",stroke:"none"},routing:{kind:"ellipse",cx:e,cy:t,rx:n,ry:n}}}function CG(e,t,n){const i=Math.max(0,n-4);return{geometry:{kind:"compound",children:[{kind:"circle",cx:e,cy:t,r:n},{kind:"circle",cx:e,cy:t,r:i}]},paint:{fill:"var(--_text)",stroke:"var(--_text)"},childPaints:[{fill:"none",stroke:"var(--_text)",strokeWidth:String(et.innerBox*2)},{fill:"var(--_text)",stroke:"none"}],routing:{kind:"ellipse",cx:e,cy:t,rx:n,ry:n}}}function PG(e,t,n,i){const r=Math.min(n,i)/2;return{geometry:{kind:"rect",x:e,y:t,width:n,height:i,rx:r,ry:r},paint:{fill:"var(--_text)",stroke:"none"},routing:{kind:"rect",x:e,y:t,width:n,height:i}}}function EG(e,t,n,i,r,o){return{geometry:{kind:"rect",x:e,y:t,width:n,height:i},paint:{fill:r,stroke:r,strokeWidth:o},routing:{kind:"rect",x:e,y:t,width:n,height:i}}}var RG=new Set(["text","brace","brace-r","braces","datastore","fork","f-circ","state-start","state-end","state-fork","state-join"]);function fR(e){return!RG.has(e.semanticShape??e.shape)}function rp(e,t,n){const i=nr(e,t,n,{fill:"none",reason:"open symbol has no enclosing painted boundary"});i.routing={kind:"envelope",x:e.x,y:e.y,width:e.width,height:e.height,reason:"open symbol routes to its layout envelope"};return i}function kS(e,t,n){const i=nr(e,t,n);i.routing={kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height};return i}function Ns(e,t,n,i=1e-6){const r=xi(e).boundary;if(r.kind==="envelope"||r.kind==="none")return void 0;return PS(r,t,n,i)}function PS(e,t,n,i){const r=n.x-t.x,o=n.y-t.y;const s=Math.hypot(r,o);if(s<=1e-9||Math.abs(r)>i&&Math.abs(o)>i)return false;const a=Math.abs(r)>Math.abs(o)?r>0?"E":"W":o>0?"S":"N";const l=a==="E"||a==="W"?t.y:t.x;const c=Fs(e,a,l);if(!c||Math.hypot(c.x-t.x,c.y-t.y)>i)return false;let d=0,u=0;if(e.kind==="ellipse"){d=(t.x-e.cx)/e.rx/e.rx;u=(t.y-e.cy)/e.ry/e.ry}else if(e.kind==="stadium"){const h=e.halfWidth-e.radius;d=t.x-Math.max(e.cx-h,Math.min(e.cx+h,t.x));u=t.y-e.cy}else if(e.kind==="cylinder"){const h=e.y+e.capRadiusY,m=e.y+e.height-e.capRadiusY;if(t.y>=h&&t.y<=m)d=t.x-e.cx;else{d=(t.x-e.cx)/(e.width/2)/(e.width/2);u=(t.y-(t.y<h?h:m))/e.capRadiusY/e.capRadiusY}}else return true;const f=Math.hypot(d,u);return f>0&&Number.isFinite(f)&&(d*(r/s)+u*(o/s))/f>0}function sp(e,t){if(e.kind==="polygon"){let r=false;for(let o=0,s=e.points.length-1;o<e.points.length;s=o++){const a=e.points[o],l=e.points[s];const c=l.x-a.x,d=l.y-a.y;const u=(t.x-a.x)*d-(t.y-a.y)*c;if(Math.abs(u)<=1e-6*Math.hypot(c,d)&&(t.x-a.x)*(t.x-l.x)+(t.y-a.y)*(t.y-l.y)<=1e-6)return true;if(a.y>t.y!==l.y>t.y&&t.x<(l.x-a.x)*(t.y-a.y)/(l.y-a.y)+a.x)r=!r}return r}const n=Fs(e,"W",t.y),i=Fs(e,"E",t.y);return Boolean(n&&i&&t.x>=n.x-1e-6&&t.x<=i.x+1e-6)}function hR(e,t,n){if(!sp(e,t)||!sp(e,n))return true;if(e.kind!=="polygon")return false;const i=n.x-t.x,r=n.y-t.y;const o=Math.abs(i)<=1e-6;const s=o?r:i;if(Math.abs(s)<=1e-9)return false;const a=[0,1];for(let l=0;l<e.points.length;l++){const c=e.points[l],d=e.points[(l+1)%e.points.length];const u=o?yR(t.x,c,d):gR(t.y,c,d);if(u){const f=(o?u.y-t.y:u.x-t.x)/s;if(f>0&&f<1)a.push(f)}}a.sort((l,c)=>l-c);return a.some((l,c)=>{const d=a[c+1];if(d===void 0||d-l<=1e-9)return false;const u=(l+d)/2;return!sp(e,{x:t.x+i*u,y:t.y+r*u})})}function wa(e,t,n){if(e.length<2)return e;const i=xi(t).boundary;if(i.kind==="envelope"||i.kind==="none")return e;const r=n?e:[...e].reverse();const o=r[0];if(!sp(i,o))return e;const s=r.find(a=>Math.hypot(a.x-o.x,a.y-o.y)>1e-9);if(!s||PS(i,o,s,1e-6))return e;for(let a=0;a<r.length-1;a++){const l=r[a],c=r[a+1];const d=c.x-l.x,u=c.y-l.y,f=Math.hypot(d,u);if(f<=1e-9)continue;if(Math.abs(d)>1e-6&&Math.abs(u)>1e-6)return e;const h=Math.abs(d)>Math.abs(u)?d>0?"E":"W":u>0?"S":"N";const m=i.kind==="polygon"?pR(l,c,i.points):Fs(i,h,h==="E"||h==="W"?l.y:l.x);if(m){const p=((m.x-l.x)*d+(m.y-l.y)*u)/f**2;const g=r.slice(a+1);const y=g.find(b=>Math.hypot(b.x-m.x,b.y-m.y)>1e-9);if(p>=-1e-9&&p<=1+1e-9&&y&&PS(i,m,y,1e-6)){if(hR(i,l,m))return e;const b=Math.hypot(m.x-c.x,m.y-c.y)<=1e-9?g:[m,...g];return n?b:b.reverse()}}if(hR(i,l,c))return e}return e}function si(e,t,n){if(e.length<2)return e;const i=xi(t).boundary;if(i.kind==="rect"||i.kind==="envelope"||i.kind==="none")return e;const r=[...e];if(n)r[0]=mR(e[0],e[1],t,i);else{const o=e.length-1;r[o]=mR(e[o],e[o-1],t,i)}return r}function mR(e,t,n,i){const r=vG(e,t,i);if(r!==null)return r;const o=1e-6;if(e.x<n.x-o||e.x>n.x+n.width+o||e.y<n.y-o||e.y>n.y+n.height+o)return e;const s=[Math.abs(e.y-n.y)<=o?"N":void 0,Math.abs(e.y-n.y-n.height)<=o?"S":void 0,Math.abs(e.x-n.x)<=o?"W":void 0,Math.abs(e.x-n.x-n.width)<=o?"E":void 0].filter(l=>l!==void 0);const a=s.length===1?s[0]:void 0;if(!a)return e;return Fs(i,a,a==="N"||a==="S"?e.x:e.y)??e}function vG(e,t,n){switch(n.kind){case"ellipse":return TG(e,t,n);case"stadium":return LG(e,t,n);case"cylinder":return AG(e,t,n);case"polygon":return pR(e,t,n.points);case"rect":case"envelope":return e;case"none":return e}}function ap(e,t){const n=e.x-t.x;const i=e.y-t.y;const r=Math.abs(n)<Math.abs(i);return{vertical:r,dir:(r?i:n)>=0?1:-1}}function TG(e,t,n){const{cx:i,cy:r,rx:o,ry:s}=n;if(o<=0||s<=0)return null;const{vertical:a,dir:l}=ap(e,t);if(a){const d=(e.x-i)/o;if(Math.abs(d)>1)return null;return{x:e.x,y:r-l*s*Math.sqrt(Math.max(0,1-d*d))}}const c=(e.y-r)/s;if(Math.abs(c)>1)return null;return{x:i-l*o*Math.sqrt(Math.max(0,1-c*c)),y:e.y}}function LG(e,t,n){const{cx:i,cy:r,halfWidth:o,radius:s}=n;const{vertical:a,dir:l}=ap(e,t);if(a){const d=Math.abs(e.x-i);if(d<=o-s)return{x:e.x,y:r-l*s};const u=d-(o-s);if(u>s)return null;return{x:e.x,y:r-l*Math.sqrt(Math.max(0,s*s-u*u))}}const c=Math.abs(e.y-r);if(c>s)return null;return{x:i-l*(o-s+Math.sqrt(Math.max(0,s*s-c*c))),y:e.y}}function AG(e,t,n){const{cx:i,y:r,width:o,height:s,capRadiusY:a}=n;const l=o/2;const c=r+a;const d=r+s-a;const{vertical:u,dir:f}=ap(e,t);if(!u){if(e.y>=c&&e.y<=d)return{x:i-f*l,y:e.y};const p=e.y<c?c:d;const g=(e.y-p)/a;if(Math.abs(g)>1)return null;return{x:i-f*l*Math.sqrt(Math.max(0,1-g*g)),y:e.y}}const h=(e.x-i)/l;if(Math.abs(h)>1)return null;const m=a*Math.sqrt(Math.max(0,1-h*h));return f>0?{x:e.x,y:c-m}:{x:e.x,y:d+m}}function pR(e,t,n){const{vertical:i}=ap(e,t);let r=null;let o=Infinity;for(let s=0;s<n.length;s++){const a=n[s];const l=n[(s+1)%n.length];const c=l.x-a.x,d=l.y-a.y;const u=e.x-a.x,f=e.y-a.y;if(Math.abs(u*d-f*c)<1e-6&&u*(e.x-l.x)+f*(e.y-l.y)<=1e-6){const p=Math.hypot(t.x-e.x,t.y-e.y);const g=p>0?Math.min(1e-4/p,.5):0;const y={x:e.x+(t.x-e.x)*g,y:e.y+(t.y-e.y)*g};let b=false,S=false;for(let x=0,k=n.length-1;x<n.length;k=x++){const w=n[x],C=n[k];const R=t.x-e.x,M=t.y-e.y;const P=C.x-w.x,E=C.y-w.y,v=R*E-M*P;if(Math.abs(v)>1e-9){const L=w.x-e.x,T=w.y-e.y;const A=(L*E-T*P)/v,$=(L*M-T*R)/v;if(A*p>1e-6&&A<=1&&$>=0&&$<=1)S=true}if(w.y>y.y!==C.y>y.y&&y.x<(C.x-w.x)*(y.y-w.y)/(C.y-w.y)+w.x)b=!b}if(!b&&!S)return e}const h=i?yR(e.x,a,l):gR(e.y,a,l);if(!h)continue;const m=Math.hypot(h.x-t.x,h.y-t.y);if(m<o){r=h;o=m}}return r}function gR(e,t,n){const i=n.y-t.y;if(Math.abs(i)<1e-6)return null;const r=(e-t.y)/i;if(r<0||r>1)return null;return{x:t.x+r*(n.x-t.x),y:e}}function yR(e,t,n){const i=n.x-t.x;if(Math.abs(i)<1e-6)return null;const r=(e-t.x)/i;if(r<0||r>1)return null;return{x:e,y:t.y+r*(n.y-t.y)}}var IG=new Set(["cloud","brace","brace-r","braces","datastore","delay","h-cyl","lin-cyl","curv-trap","doc","lin-doc","docs","st-rect","flag","bow-rect","tag-doc"]);function ed(e,t,n=1.5){if(e.semanticShape==="text")return{policy:"none",onBoundary:false};if(e.semanticShape&&IG.has(e.semanticShape)){return{policy:"envelope",onBoundary:ES(t,e.x,e.y,e.width,e.height,n)}}const i=FG(e);if(i)return{policy:"exact",onBoundary:RS(t,i,n)};const r=e.x+e.width/2;const o=e.y+e.height/2;const s=Math.min(e.width,e.height)/2;if(e.semanticShape==="fork"){return{policy:"exact",onBoundary:ES(t,e.x,o-4,e.width,8,n)}}if(e.semanticShape==="sm-circ"){const a=Math.min(e.width,e.height)*.22;return{policy:"exact",onBoundary:Vu(t,r,o,a,a,n)}}if(e.semanticShape==="cross-circ"){return{policy:"exact",onBoundary:Vu(t,r,o,e.width/2,e.height/2,n)}}if(e.semanticShape==="f-circ"){return{policy:"exact",onBoundary:Vu(t,r,o,s,s,n)}}switch(e.shape){case"diamond":case"state-choice":return{policy:"exact",onBoundary:Math.abs(Math.abs(t.x-r)/(e.width/2)+Math.abs(t.y-o)/(e.height/2)-1)*Math.min(e.width,e.height)/2<n};case"circle":case"doublecircle":case"state-history":return{policy:"exact",onBoundary:Vu(t,r,o,s,s,n)};case"state-start":case"state-end":{const a=Math.max(0,s-2);return{policy:"exact",onBoundary:Vu(t,r,o,a,a,n)}}case"stadium":{const a=e.height/2;const l=e.width/2-a;const c=Math.abs(t.x-r);const d=c<=l?Math.abs(Math.abs(t.y-o)-a)<n:Math.abs(Math.hypot(c-l,t.y-o)-a)<n;return{policy:"exact",onBoundary:d}}case"hexagon":{const a=e.height/4;return{policy:"exact",onBoundary:RS(t,[{x:e.x+a,y:e.y},{x:e.x+e.width-a,y:e.y},{x:e.x+e.width,y:o},{x:e.x+e.width-a,y:e.y+e.height},{x:e.x+a,y:e.y+e.height},{x:e.x,y:o}],n)}}case"cylinder":return{policy:"exact",onBoundary:$G(e,t,n)};case"trapezoid":case"trapezoid-alt":case"lean-r":case"lean-l":case"asymmetric":return{policy:"exact",onBoundary:RS(t,NG(e),n)};default:return{policy:"exact",onBoundary:ES(t,e.x,e.y,e.width,e.height,n)}}}function FG(e){const{x:t,y:n,width:i,height:r}=e;const o=t+i,s=n+r,a=t+i/2,l=n+r/2;switch(e.semanticShape){case"bang":return Array.from({length:16},(c,d)=>{const u=-Math.PI/2+d*Math.PI/8;const f=d%2===0?1:.62;return{x:a+Math.cos(u)*i/2*f,y:l+Math.sin(u)*r/2*f}});case"notch-rect":return[{x:t+10,y:n},{x:o,y:n},{x:o,y:s},{x:t,y:s},{x:t,y:n+10}];case"hourglass":return[{x:t,y:n},{x:o,y:n},{x:t+i*.62,y:l},{x:o,y:s},{x:t,y:s},{x:t+i*.38,y:l}];case"bolt":return[{x:t+i*.55,y:n},{x:t+i*.25,y:l},{x:t+i*.48,y:l},{x:t+i*.35,y:s},{x:t+i*.78,y:n+r*.4},{x:t+i*.55,y:n+r*.4}];case"tri":return[{x:a,y:n},{x:o,y:s},{x:t,y:s}];case"notch-pent":return[{x:t,y:n},{x:o-10,y:n},{x:o,y:l},{x:o-10,y:s},{x:t,y:s},{x:t+8,y:l}];case"flip-tri":return[{x:t,y:n},{x:o,y:n},{x:a,y:s}];case"tag-rect":return[{x:t+10,y:n},{x:o,y:n},{x:o,y:s},{x:t,y:s},{x:t,y:n+10}];default:return null}}function NG(e){const{x:t,y:n,width:i,height:r}=e;const o=t+i,s=n+r,a=n+r/2;const l=i*.15;switch(e.shape){case"trapezoid":return[{x:t+l,y:n},{x:o-l,y:n},{x:o,y:s},{x:t,y:s}];case"trapezoid-alt":return[{x:t,y:n},{x:o,y:n},{x:o-l,y:s},{x:t+l,y:s}];case"lean-r":return[{x:t+l,y:n},{x:o,y:n},{x:o-l,y:s},{x:t,y:s}];case"lean-l":return[{x:t,y:n},{x:o-l,y:n},{x:o,y:s},{x:t+l,y:s}];default:return[{x:t+12,y:n},{x:o,y:n},{x:o,y:s},{x:t+12,y:s},{x:t,y:a}]}}function ES(e,t,n,i,r,o){const s=Math.abs(e.x-t)<o||Math.abs(e.x-(t+i))<o;const a=Math.abs(e.y-n)<o||Math.abs(e.y-(n+r))<o;return s&&e.y>=n-o&&e.y<=n+r+o||a&&e.x>=t-o&&e.x<=t+i+o}function Vu(e,t,n,i,r,o){if(i<=0||r<=0)return false;return Math.abs(Math.hypot((e.x-t)/i,(e.y-n)/r)-1)*Math.min(i,r)<o}function RS(e,t,n){let i=Infinity;for(let r=0;r<t.length;r++){i=Math.min(i,_G(e,t[r],t[(r+1)%t.length]))}return i<=n}function $G(e,t,n){const i=e.x+e.width/2;const r=e.y+e.height/2;const o=e.width/2;const s=7;if(t.y>=e.y+s-n&&t.y<=e.y+e.height-s+n&&Math.abs(Math.abs(t.x-i)-o)<n)return true;const a=t.y<r?e.y+s:e.y+e.height-s;return Math.abs(Math.hypot((t.x-i)/o,(t.y-a)/s)-1)*Math.min(o,s)<n*2}function _G(e,t,n){const i=n.x-t.x,r=n.y-t.y;const o=i*i+r*r;if(o===0)return Math.hypot(e.x-t.x,e.y-t.y);const s=Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/o));return Math.hypot(e.x-(t.x+s*i),e.y-(t.y+s*r))}function ji(e,t){return _e(e,{transform:t.edgeTextTransform,fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing})}function Wn(e,t,n){if(n==="group")return _e(e,{transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing,fontFamily:t.groupFont});if(n==="edge")return ji(e,t);if(n==="note")return _e(e,{transform:t.nodeTextTransform,fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing});return _e(e,{transform:t.nodeTextTransform,fontSize:t.nodeLabelFontSize,fontWeight:t.nodeLabelFontWeight,letterSpacing:t.nodeLetterSpacing})}var on=8;function Ri(e,t){return Math.max(4,t*(e.style==="thick"?2:1)*2)}function DG(e,t){return e.inlineStyle?.["stroke-width"]?bn.width:bn.width*t*(e.style==="thick"?2:1)}var td=4;function nd(e,t,n){const i=n==="start"?e.hasArrowStart:e.hasArrowEnd;return Ri(e,t)+(i?DG(e,t):0)+td}function Ma(e,t,n){const i=n.width+2*on;const r=n.height+2*on;return{x:e-i/2,y:t-r/2,w:i,h:r}}function Pt(e,t){if(!e.label||!e.labelPosition)return null;const n=e.labelBlock??ji(qe(e.label,e.labelContent),t);return Ma(e.labelPosition.x,e.labelPosition.y,n)}var Bl=.5;function Ku(e,t,n){const i=n.x+Bl,r=n.x+n.w-Bl;const o=n.y+Bl,s=n.y+n.h-Bl;const a=t.x-e.x,l=t.y-e.y;if(a===0)return l!==0&&e.x>i&&e.x<r&&Math.max(e.y,t.y)>o&&Math.min(e.y,t.y)<s;if(l===0)return e.y>o&&e.y<s&&Math.max(e.x,t.x)>i&&Math.min(e.x,t.x)<r;const c=(i-e.x)/a,d=(r-e.x)/a;const u=(o-e.y)/l,f=(s-e.y)/l;return Math.max(0,Math.min(c,d),Math.min(u,f))<Math.min(1,Math.max(c,d),Math.max(u,f))}function gr(e){const t=new Map(e.map(n=>[n.id,{start:Gx(n,"start"),end:Gx(n,"end"),fixed:n.units==="userSpaceOnUse"}]));return(n,i,r)=>{if(!n)return 0;const o=t.get(n);if(!o)throw new Error(`Missing terminal marker ${n}`);return o[r]*(o.fixed?1:i)+td}}function vS(e,t=false){const n=bn.width;const i=t?n:bn.height;const r=e??"var(--_arrow)";const o=`${e?`-${id(e)}`:""}${t?"-fixed":""}`;const s={fill:r,stroke:r,strokeWidth:String(bn.strokeWidth),strokeLinejoin:"round"};return[dr(`arrowhead${o}`,{width:n,height:i},"end",s,t?"userSpaceOnUse":void 0),dr(`arrowhead-start${o}`,{width:n,height:i},"start",s,t?"userSpaceOnUse":void 0)]}function TS(e,t=false){const n=bn.width;const i=`${e?`-${id(e)}`:""}${t?"-fixed":""}`;const r=e??"var(--_arrow)";const o=n/2-.75;const s={shape:"circle",size:{width:n,height:n},...t?{units:"userSpaceOnUse"}:{},orient:"auto",geometry:{kind:"circle",cx:n/2,cy:n/2,r:o},paint:{fill:"none",stroke:r,strokeWidth:"1"}};return[{...s,id:`circlehead${i}`,ref:{x:n-.5,y:n/2}},{...s,id:`circlehead-start${i}`,ref:{x:.5,y:n/2}}]}function LS(e,t=false){const n=bn.width;const i=`${e?`-${id(e)}`:""}${t?"-fixed":""}`;const r=e??"var(--_arrow)";const o=1.25;const s=1.25;const a=o;const l=n-o;const c={shape:"cross",size:{width:n,height:n},...t?{units:"userSpaceOnUse"}:{},orient:"auto",geometry:{kind:"compound",children:[{kind:"line",x1:a,y1:a,x2:l,y2:l},{kind:"line",x1:a,y1:l,x2:l,y2:a}]},paint:{stroke:r,strokeWidth:String(s),strokeLinecap:"round"}};return[{...c,id:`crosshead${i}`,ref:{x:l+s/2,y:n/2}},{...c,id:`crosshead-start${i}`,ref:{x:a-s/2,y:n/2}}]}function lp(e,t,n,i){const r=[...vS()];if(n)r.push(...TS());if(i)r.push(...LS());for(const o of e){r.push(...vS(o));if(n)r.push(...TS(o));if(i)r.push(...LS(o))}for(const o of t){r.push(...vS(o,true));if(n)r.push(...TS(o,true));if(i)r.push(...LS(o,true))}return r}function Wl(e){if(e==="circle")return"circlehead";if(e==="cross")return"crosshead";return"arrowhead"}function id(e){if(/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(e))return`23${e.slice(1)}`;if(/^[a-z]+$/i.test(e))return e;const t=`color-u-${Array.from(e,n=>n.codePointAt(0).toString(16)).join("-")}`;return t.length<=233?t:`color-h-${Qc(e).slice("fnv1a64:".length)}`}var OG=lp(new Set,new Set([void 0]),true,true);var xR=gr(OG);function $s(e,t){const n=e.inlineStyle?.["stroke-width"]?"-fixed":"";const i=(t.lineWidth??1)*(e.style==="thick"?2:1);return{start:e.hasArrowStart?xR(`${Wl(e.startMarker??"arrow")}-start${n}`,i,"start"):0,end:e.hasArrowEnd?xR(`${Wl(e.endMarker??"arrow")}${n}`,i,"end"):0}}function BG(e){const t=e[0];let n=`M ${t.x} ${t.y}`;const i=[];for(let r=1;r<e.length;r++){const o=e[r-1];const s=e[r];const a=(o.x+s.x)/2;n+=` C ${a} ${o.y}, ${a} ${s.y}, ${s.x} ${s.y}`;i.push({kind:"cubic",control1:{x:a,y:o.y},control2:{x:a,y:s.y},end:s})}return Ac(n,t,i)}function Ju(e,t){return e.curve?BG(e.points):(t.edgeBendRadius??0)>0?qn(e.points,t.edgeBendRadius,{terminalClearance:$s(e,t)}):void 0}function yr(e,t){if(e.style==="invisible"||e.points.length<2||!e.hasArrowStart&&!e.hasArrowEnd)return[];const n=e.inlineStyle?.stroke??t.edgeStrokeColor;const i=!!e.inlineStyle?.["stroke-width"];const r=lp(new Set(n?[n]:[]),new Set(i?[n]:[]),e.startMarker==="circle"||e.endMarker==="circle",e.startMarker==="cross"||e.endMarker==="cross");const o=`${n?`-${id(n)}`:""}${i?"-fixed":""}`;const s=e.hasArrowStart?r.find(d=>d.id===`${Wl(e.startMarker??"arrow")}-start${o}`):void 0;const a=e.hasArrowEnd?r.find(d=>d.id===`${Wl(e.endMarker??"arrow")}${o}`):void 0;const l=Ju(e,t);const c=l?.geometry??{kind:"polyline",points:e.points};return jr({route:{geometry:c,closed:false,contours:l?.contours??P1(c,false)},stroke:{width:e.inlineStyle?.["stroke-width"]??String((t.lineWidth??1)*(e.style==="thick"?2:1))},markers:{start:s,mid:[],end:a}})}var _s=64;var ka=128;function Ca(e){let t=e.nodes.size;const n=i=>{for(const r of i){t++;n(r.children)}};n(e.subgraphs);return t<=_s&&e.edges.length<=ka}var $e=.01;var en=4;var wR=8;var WG=12;function Yi(e,t,n="end"){const i=$s(t??{style:"solid",hasArrowStart:true,hasArrowEnd:true},e);return Math.max(WG,i[n]+(e.edgeBendRadius??0))}var AS=new Set(["rectangle","service","rounded","subroutine","state-fork","state-join"]);var gn=new Set([...AS,"diamond","circle","ellipse","doublecircle","stadium","hexagon","cylinder","state-start","state-end","state-choice","state-history","trapezoid","trapezoid-alt","asymmetric","lean-r","lean-l"]);var pn=.5;var Pa=12;var MR=8;function Ft(e){return Zc(e)}function Yo(e){const t=e.x+e.width/2;const n=e.y+e.height/2;const i=e.width/4;const r=e.height/4;return{NE:{x:t+i,y:n-r},SE:{x:t+i,y:n+r},SW:{x:t-i,y:n+r},NW:{x:t-i,y:n-r}}}function Vn(e,t){const n=xi(e);if(n.boundary.kind==="envelope"||n.boundary.kind==="none")return void 0;for(const i of["N","E","S","W"]){const r=n.sides[i].preferred;if(Math.abs(r.x-t.x)<=pn&&Math.abs(r.y-t.y)<=pn)return i}if(Nr(e)){const i=Yo(e);for(const r of["NE","SE","SW","NW"]){if(Math.abs(i[r].x-t.x)<=pn&&Math.abs(i[r].y-t.y)<=pn)return r}}return void 0}function bi(e,t,n){let i=0;for(const[r,o]of[[t,true],[n,false]]){if(!r)continue;const s=xi(r);if(s.boundary.kind==="envelope"||s.boundary.kind==="none")continue;const a=o?e.points:[...e.points].reverse();const l=a[0];const c=l&&a.find(f=>Math.hypot(f.x-l.x,f.y-l.y)>$e);if(!l||!c){i++;continue}const d=c.x-l.x,u=c.y-l.y;if(Math.abs(d)>$e&&Math.abs(u)>$e)continue;if(!Ns(r,l,c,pn))i++}return i}function Qu(e,t,n){for(const[i,r]of[[t,true],[n,false]]){if(!i)continue;const o=xi(i);if(o.boundary.kind==="envelope"||o.boundary.kind==="none")continue;while(e.points.length>2){const s=r?e.points:[...e.points].reverse();const[a,l]=s;const c={x:(a.x+l.x)/2,y:(a.y+l.y)/2};if(![a,l,c].every(u=>ed(i,u,$e).onBoundary))break;const d={...e,points:r?e.points.slice(1):e.points.slice(0,-1)};if(bi(d,r?i:void 0,r?void 0:i)!==0)break;e.points=d.points}}}function eo(e){const t=xi(e).boundary;return t.kind!=="envelope"&&t.kind!=="none"}function Nr(e){const t=xi(e);return t.boundary.kind==="polygon"&&["N","E","S","W"].every(n=>t.sides[n].kind==="dynamic")}function Ea(e){const t=new Set;const n=new Map;const i=(s,a)=>{for(const l of s){t.add(l.id);for(const c of l.nodeIds)n.set(c,l.id);i(l.children,l.id)}};i(e.subgraphs,"");const r=new Map;const o=(s,a)=>{const l=new Set;const c=[s];while(c.length>0){const d=c.pop();if(d===a)return true;if(l.has(d))continue;l.add(d);for(const u of r.get(d)??[])c.push(u)}return false};return e.edges.map(s=>{if(s.source===s.target)return"self-loop";if(t.has(s.source)||t.has(s.target))return"container";const a=o(s.target,s.source)?"feedback":(n.get(s.source)??"")!==(n.get(s.target)??"")?"cross-hierarchy":"primary-forward";if(a!=="feedback"){if(!r.has(s.source))r.set(s.source,new Set);r.get(s.source).add(s.target)}return a})}function rd(e){const t=e==="LR"||e==="RL";return{main:t?"x":"y",cross:t?"y":"x",sign:e==="RL"||e==="BT"?-1:1}}function bR(e,t,n){return e.x!==n.x&&e.y!==n.y&&(e.x===t.x&&t.y===n.y||e.y===t.y&&t.x===n.x)}function xt(e){let t=e;for(let n=0;n<8;n++){if(t.length<3)return t;const i=[t[0]];for(let o=1;o<t.length;o++){const s=t[o];const a=i[i.length-1];if(Math.abs(s.x-a.x)<$e&&Math.abs(s.y-a.y)<$e){const l=t[o+1];if(l?!bR(a,s,l):s.x===a.x&&s.y===a.y)continue}i.push(s)}const r=i.length<3?i:[i[0]];if(i.length>=3){for(let o=1;o<i.length-1;o++){const s=r[r.length-1],a=i[o],l=i[o+1];const c=(a.x-s.x)*(l.y-s.y)-(a.y-s.y)*(l.x-s.x);if(Math.abs(c)<$e&&!bR(s,a,l))continue;r.push(a)}r.push(i[i.length-1])}if(r.length===t.length)return r;t=r}return t}function IS(e){let t=false;for(let i=1;i<e.length;i++){const r=e[i-1],o=e[i];if(Math.abs(r.x-o.x)>$e&&Math.abs(r.y-o.y)>$e){t=true;break}}if(!t)return e;const n=[e[0]];for(let i=1;i<e.length;i++){const r=n[n.length-1],o=e[i];if(Math.abs(r.x-o.x)>$e&&Math.abs(r.y-o.y)>$e){const s=n.length>=2?n[n.length-2]:void 0;const a=s?Math.abs(s.y-r.y)<$e:true;n.push(a?{x:o.x,y:r.y}:{x:r.x,y:o.y})}n.push(o)}return n}function ai(e){return Math.max(0,xt(e).length-2)}function kR(e,t){let n=Infinity,i=-Infinity;for(const r of e){n=Math.min(n,r[t.cross]);i=Math.max(i,r[t.cross])}return i-n}function Zu(e,t){for(let n=1;n<e.length;n++){const i=e[n-1],r=e[n];const o=(r[t.main]-i[t.main])*t.sign;const s=Math.abs(r[t.cross]-i[t.cross]);if(o>$e&&s>$e)return false;if(o<-$e)return false}return true}function qo(e,t,n){const i=xi(e).sides[xr(t,n)];if(i.kind==="dynamic")return{lo:i.lo,hi:i.hi};if(i.kind==="port"){const r=i.point[t.cross];return{lo:r-pn,hi:r+pn}}return null}function to(e,t,n,i){const r=lR(xi(e),xr(n,i),t);return r?.[n.main]??null}function xr(e,t){const n=t*e.sign>0;return e.main==="x"?n?"E":"W":n?"S":"N"}function CR(e){switch(e){case"N":return"S";case"S":return"N";case"E":return"W";case"W":return"E"}}function zG(e,t){if(!e)return t;if(e==="N"||e==="E"||e==="S"||e==="W")return e;return e.includes(t)?t:e[0]}function PR(e,t,n){const i=e==="feedback"||e==="self-loop"||e==="container"||e==="cross-hierarchy"?e:"flow";const r=t==="source"!==(e==="feedback")?1:-1;return{role:`${i}-${t}`,side:xr(n,r)}}function SR(e,t,n){if(n)return e==="N"||e==="S"?n.x:n.y;return e==="N"||e==="S"?t.x+t.width/2:t.y+t.height/2}function cp(e,t,n=Ea(t)){return ER(e,t,n,true)}function FS(e,t,n,i,r,o=false){const s=rd(t.direction);const a=ER(e,t,i,false).sideUse;for(const l of e.edges){if(!r(l)||l.edgeIndex===void 0)continue;const c=i[l.edgeIndex];if(c!=="primary-forward"&&!(c==="feedback"&&!l.label))continue;for(const d of["source","target"]){const u=d==="source"?l.source:l.target;const{side:f}=PR(c,d,s);const h=`${u}:${f}`;const m=(a.get(h)??0)-1;if(m>0)a.set(h,m);else a.delete(h)}}return{axis:s,ctx:{nodes:e.nodes,edges:e.edges,groups:e.groups,axis:s,style:n,classes:i,sideUse:a,finalLabelClearance:o,nodeLaneIndexes:Gr()?void 0:{},routeChannelGeometry:Gr()?void 0:new WeakMap}}}function Ln(e,t,n){return e.main==="x"?{x:t,y:n}:{x:n,y:t}}function od(e,t,n){return{main:e.cross,cross:e.main,sign:t<n?1:-1}}function GG(e,t){e.routeChannelGeometry?.delete(t)}function Si(e,t,n){GG(e,t);t.points=n}function Ra(e){const t=new Map;e.forEach(n=>t.set(n.id,n));return t}function ER(e,t,n,i){const r=rd(t.direction);const o=Ra(e.nodes);const s=[];const a=new Map;const l=(f,h)=>{const m=`${f}:${h}`;a.set(m,(a.get(m)??0)+1)};for(const f of e.edges){if(f.edgeIndex===void 0)continue;const h=n[f.edgeIndex]??"primary-forward";for(const m of["source","target"]){const p=m==="source"?f.source:f.target;const g=o.get(p);if(!g)continue;const{role:y,side:b}=PR(h,m,r);const S=m==="source"?f.points[0]:f.points[f.points.length-1];const x=S?Vn(g,S):void 0;const k=zG(x,b);const w=h==="primary-forward"||h==="feedback"&&!f.label;if(w)l(p,b);if(!i){SR(k,g,S);continue}s.push({edge:f,endpoint:m,nodeId:p,side:k,role:y,coord:SR(k,g,S),edgeIndex:f.edgeIndex,port:x})}}if(!i)return{byEdge:new Map,sideUse:a};const c=new Map;for(const f of s){const h=`${f.nodeId}:${f.side}`;if(!c.has(h))c.set(h,[]);c.get(h).push(f)}const d=new Map;const u=f=>f==="source"?0:1;for(const f of c.values()){f.sort((m,p)=>m.coord-p.coord||m.edgeIndex-p.edgeIndex||u(m.endpoint)-u(p.endpoint));const h=f.length;f.forEach((m,p)=>{const g={side:m.side,slotIndex:p,slotCount:h,role:m.role,...m.port?{port:m.port}:{}};const y=d.get(m.edge)??{};y[m.endpoint]=g;d.set(m.edge,y)})}return{byEdge:d,sideUse:a}}function ef(e,t,n,i,r){let o=0;let s=0;const a=u=>{o=Math.min(o,u.x);s=Math.min(s,u.y);for(const f of u.children)a(f)};for(const u of e){o=Math.min(o,u.x);s=Math.min(s,u.y)}for(const u of n)a(u);for(const u of t){for(const h of u.points){o=Math.min(o,h.x);s=Math.min(s,h.y)}const f=r&&u.labelBlock?Pt(u,r):null;if(f){o=Math.min(o,f.x);s=Math.min(s,f.y)}else if(u.labelPosition){o=Math.min(o,u.labelPosition.x);s=Math.min(s,u.labelPosition.y)}}if(o>=0&&s>=0)return;const l=o<0?-o+i:0;const c=s<0?-s+i:0;const d=u=>{u.x+=l;u.y+=c;for(const f of u.children)d(f)};for(const u of e){u.x+=l;u.y+=c}for(const u of n)d(u);for(const u of t){for(const f of u.points){f.x+=l;f.y+=c}if(u.labelPosition){u.labelPosition.x+=l;u.labelPosition.y+=c}}}var qi=class extends Error{constructor(n,i,r){super(r);this.pass=n;this.contract=i;this.name="LayoutPassContractError"}pass;contract;code="LAYOUT_PASS_CONTRACT_VIOLATION"};var NS=class extends qi{constructor(n,i,r,o,s){super(n,"metric-budget",`Layout pass '${n}' worsened ${i} from ${r} to ${o} (allowance ${s})`);this.metric=i;this.before=r;this.after=o;this.allowance=s;this.name="LayoutMetricBudgetError"}metric;before;after;allowance;code="LAYOUT_METRIC_BUDGET_EXCEEDED"};var RR=e=>{const t=[...e.nodes];const n=i=>{for(const r of i){t.push(r);n(r.children??[])}};n(e.groups??[]);return t};function vR(e,t,n={}){const i=new Set;let r=e.frozen;for(const o of t){if(o.enabled&&!o.enabled(e)){i.add(o.id);continue}for(const b of o.after){if(!i.has(b)){throw new qi(o.id,"ordering",`LayoutPass ordering: '${o.id}' must run after '${b}', which has not run`)}}const s=Object.entries(o.mayChangeMetrics??{});const a=b=>b==="improve-only"||!b.whenImproves?[]:typeof b.whenImproves==="string"?[b.whenImproves]:b.whenImproves;const l=[];for(const[b,S]of s){if(!l.includes(b))l.push(b);for(const x of a(S)){if(!l.includes(x))l.push(x)}}const c=o.proposal?l.includes("hard")?[...l]:[...l,"hard"]:l;if((s.length||o.proposal)&&!n.measureMetrics)throw new qi(o.id,"measurement",`Layout pass '${o.id}' declares metric budgets but no geometry measurement was supplied`);const d=(b=l)=>{try{return n.measureMetrics(e,b)}catch(S){if(S instanceof qi)throw S;throw new qi(o.id,"measurement",`Layout pass '${o.id}' could not measure its declared geometry: ${S instanceof Error?S.message:String(S)}`)}};const u=s.length||o.proposal?d(c):void 0;const f=r?RR(e).map(({id:b,x:S,y:x,width:k,height:w})=>({id:b,x:S,y:x,width:k,height:w})):void 0;const h=r?(e.edges??[]).map(b=>({points:b.points?.map(S=>({...S})),labelPosition:b.labelPosition?{...b.labelPosition}:void 0,certificate:b.routeCertificate})):void 0;const m=(b=false)=>{let S;if(u){const x=d(b?c:l);const k=C=>{const R=u[C],M=x[C];if(R===void 0||M===void 0||!Number.isFinite(R)||!Number.isFinite(M)){throw new qi(o.id,"measurement",`Layout pass '${o.id}' has no finite measurement for ${C}`)}return(C==="straight"||C==="portRate"?-1:1)*(M-R)};const w=b&&o.proposal?[...s,["hard","improve-only"]]:s;for(const[C,R]of w){const M=Math.max(0,...a(R).map(E=>-k(E)));const P=R==="improve-only"||R.whenImproves&&M<=1e-6?0:R.worsenBy*(R.perImprovement?Math.floor(M+1e-6):1);if(k(C)>P+1e-6){const E=new NS(o.id,C,u[C],x[C],P);if(C==="hard")throw E;S??=E}}}return S};const p=()=>{if(f){const b=RR(e);const S=o.mutates.includes("translate");const x=S&&f[0]&&b[0]?b[0].x-f[0].x:0;const k=S&&f[0]&&b[0]?b[0].y-f[0].y:0;const w=(C,R)=>S?Math.abs(R.x-C.x-x)<=1e-6&&Math.abs(R.y-C.y-k)<=1e-6:C.x===R.x&&C.y===R.y;if(b.length!==f.length||!e.frozen)throw new qi(o.id,"freeze",`LayoutPass freeze: '${o.id}' changed frozen geometry membership or state`);for(let C=0;C<f.length;C++){const R=f[C],M=b[C];if(R.id!==M.id||R.width!==M.width||R.height!==M.height||!w(R,M)){throw new qi(o.id,"freeze",`LayoutPass freeze: '${o.id}' moved frozen geometry without a uniform translation`)}}if(h){if((e.edges?.length??0)!==h.length)throw new qi(o.id,"freeze",`LayoutPass freeze: '${o.id}' changed frozen edge membership`);for(let C=0;C<h.length;C++){const R=h[C],M=e.edges[C];const P=R.points?.length===M.points?.length&&(R.points??[]).every((E,v)=>M.points?.[v]&&w(E,M.points[v]));if(S){if(!P||Boolean(R.labelPosition)!==Boolean(M.labelPosition)||R.labelPosition&&!w(R.labelPosition,M.labelPosition)){throw new qi(o.id,"freeze",`LayoutPass freeze: '${o.id}' did not translate all frozen routes and labels uniformly`)}}else if(!P&&(!o.mutates.includes("edges")||M.routeCertificate===void 0||M.routeCertificate===R.certificate)){throw new qi(o.id,"certificate",`LayoutPass certificate: '${o.id}' rewrote edge geometry after the route-contract freeze without re-issuing routeCertificate`)}}}}};const g=o.run(e);if(g&&!o.proposal)throw new qi(o.id,"metric-budget",`Layout pass '${o.id}' returned a rollback without declaring a cosmetic proposal`);const y=m();p();if(y){if(!g)throw y;g();const b=m(true);if(b)throw b;p()}if(o.freezesNodes)e.frozen=true;r||=e.frozen;i.add(o.id);n.onAfterPass?.(o,e)}}function $S(e,t){return e.style==="invisible"?[]:e.points.slice(1).flatMap((n,i)=>{const r=e.points[i];const o=Math.abs(r.y-n.y)<=.01;if(!o&&Math.abs(r.x-n.x)>.01)return[];const s=o?r.x:r.y,a=o?n.x:n.y;if(Math.abs(a-s)<=.01)return[];const l=o?r.y:r.x;return[{edgeIndex:t,horizontal:o,cross:l,bucket:Math.floor(l/.01),lo:Math.min(s,a),hi:Math.max(s,a),sign:Math.sign(a-s)}]})}function Xo(e){const t=e.flatMap($S).sort((r,o)=>r.lo-o.lo||r.edgeIndex-o.edgeIndex);const n=new Map;const i=new Set;for(const r of t){for(let s=-1;s<=1;s++){const a=`${r.horizontal}:${r.bucket+s}`;const l=(n.get(a)??[]).filter(c=>c.hi-r.lo>.01);n.set(a,l);for(const c of l){if(c.edgeIndex===r.edgeIndex||c.sign===r.sign||Math.abs(c.cross-r.cross)>.01||Math.min(r.hi,c.hi)-r.lo<=.01)continue;i.add(`${Math.min(r.edgeIndex,c.edgeIndex)}:${Math.max(r.edgeIndex,c.edgeIndex)}`)}}const o=`${r.horizontal}:${r.bucket}`;n.get(o).push(r)}return i.size}function _S(e,t){const n=$S(e,0);const i=[];if(n.length===0)return i;const r=TR(e);for(const o of t){const s=TR(o);if(s.x0>r.x1+.01||s.x1<r.x0-.01||s.y0>r.y1+.01||s.y1<r.y0-.01)continue;if($S(o,1).some(a=>n.some(l=>l.horizontal===a.horizontal&&l.sign!==a.sign&&Math.abs(l.cross-a.cross)<=.01&&Math.min(l.hi,a.hi)-Math.max(l.lo,a.lo)>.01)))i.push(o)}return i}function TR(e){let t=Infinity,n=Infinity,i=-Infinity,r=-Infinity;for(const o of e.points){t=Math.min(t,o.x);i=Math.max(i,o.x);n=Math.min(n,o.y);r=Math.max(r,o.y)}return{x0:t,y0:n,x1:i,y1:r}}function tf(e,t){const n=t?e[0]:e.at(-1);if(!n)return 0;let i=0,r=0,o=0;for(let s=1;s<e.length;s++){const a=e[t?s:e.length-1-s];const l=a.x-n.x,c=a.y-n.y,d=Math.hypot(l,c);if(!d)continue;if(!o){i=l/d;r=c/d}const u=l*i+c*r;if(Math.abs(l*r-c*i)>1e-7||u<o)break;o=u}return o}function va(e,t){let n=e;for(const i of[true,false]){const r=i?t.start:t.end;if(tf(n,i)+1e-7>=r)continue;if(n.length<4)return void 0;const o=i?0:n.length-1,s=i?1:-1;const a=n[o],l=n[o+s],c=n[o+2*s];const d=Math.abs(l.x-a.x)>1e-7?Math.sign(l.x-a.x):0,u=Math.abs(l.y-a.y)>1e-7?Math.sign(l.y-a.y):0;if(Number(!d)+Number(!u)!==1||(d?Math.abs(l.x-c.x)>1e-7:Math.abs(l.y-c.y)>1e-7))return void 0;if(n===e)n=e.map(m=>({...m}));const f=d?"x":"y",h=a[f]+(d||u)*r;n[o+s][f]=h;n[o+2*s][f]=h}if(n===e)return e;for(const i of[true,false]){if(tf(n,i)+1e-7<(i?t.start:t.end))return void 0;const r=i?0:e.length-1,o=i?1:r-1;const s=e[r],a=e[o],l=n[o];if((a.x-s.x)*(l.x-s.x)+(a.y-s.y)*(l.y-s.y)<=0)return void 0}return n}function dp(e,t){const n=e.points.map(l=>({x:Number(Ue(l.x)),y:Number(Ue(l.y))}));const i=e.style==="thick"?2:1;const r=Number(Ue((t.lineWidth??1)*i))/i;const o={...t,lineWidth:r};const s=!e.curve&&!(t.edgeBendRadius&&t.edgeBendRadius>0);if(s)return{regions:yr({...e,points:n},o),points:n,directional:s};const a=yr(e,o).map(l=>{const c=l.position==="start"?n[0]:n.at(-1);const d=l.bounds;if(!d)return{...l,anchor:c};const u=Math.max(...[d.x0,d.x1].flatMap(f=>[d.y0,d.y1].map(h=>Math.hypot(f-l.anchor.x,h-l.anchor.y))));return{...l,anchor:c,bounds:{x0:c.x-u,y0:c.y-u,x1:c.x+u,y1:c.y+u}}});return{regions:a,points:n,directional:s}}function sd(e,t){if(e.style==="invisible"||!e.hasArrowStart&&!e.hasArrowEnd)return[];if(!DS(e,t))return void 0;const{regions:n}=dp(e,t);return n.length===Number(Boolean(e.hasArrowStart))+Number(Boolean(e.hasArrowEnd))&&n.every(nf)?n:void 0}function DS(e,t){if(!e.points.every(i=>Number.isFinite(i.x)&&Number.isFinite(i.y)))return false;if(t.edgeBendRadius!==void 0&&!(Number.isFinite(t.edgeBendRadius)&&t.edgeBendRadius>=0))return false;const n=(t.lineWidth??1)*(e.style==="thick"?2:1);return!!e.inlineStyle?.["stroke-width"]||Number.isFinite(n)&&n>0}function nf(e){const t=e.bounds;return!!t&&[t.x0,t.y0,t.x1,t.y1].every(Number.isFinite)&&t.x0<=t.x1&&t.y0<=t.y1}function LR(e,t,n){if(n==="mid")return false;const i=c=>n==="start"?c[0]:c.at(-1);const r=i(e),o=i(t);if(!r||!o||r.x!==o.x||r.y!==o.y)return false;const s=c=>{for(let d=1;d<c.length;d++){const u=c[n==="start"?d:c.length-d-1];if(u.x!==r.x||u.y!==r.y)return u}return void 0};const a=s(e),l=s(t);if(!a||!l)return false;if(a.x===l.x&&a.y===l.y)return true;if(r.x!==a.x&&r.y!==a.y||r.x!==l.x&&r.y!==l.y)return false;return Math.sign(a.x-r.x)===Math.sign(l.x-r.x)&&Math.sign(a.y-r.y)===Math.sign(l.y-r.y)}function HG(e,t,n){if(n==="mid"||e.length<2||t.length<2)return false;const i=l=>n==="start"?[l[0],l[1]]:[l.at(-1),l.at(-2)];const[r,o]=i(e),[s,a]=i(t);return r.x===s.x&&r.y===s.y&&o.x===a.x&&o.y===a.y}function AR(e,t){const n=e.bounds,i=t.bounds;if(!n||!i||!nf(e)||!nf(t))return false;const r=[n.x0,n.y0,n.x1,n.y1,i.x0,i.y0,i.x1,i.y1];if(!r.every(Number.isFinite))return false;const o=r.reduce((s,a)=>s+Math.abs(a),0)*1e-10+1e-9;return Number.isFinite(o)&&(n.x1+o<i.x0||i.x1+o<n.x0||n.y1+o<i.y0||i.y1+o<n.y0)}function Mo(e,t){if(e.label&&t.label)return false;if(e.style!==t.style||e.curve!==t.curve||e.animate!==t.animate||e.animation!==t.animation)return false;const n=e.inlineStyle??{},i=t.inlineStyle??{};for(const s in n)if(!(s in i)||i[s]!==n[s])return false;for(const s in i)if(!(s in n))return false;const r=e.classNames??[],o=t.classNames??[];if(r.length!==o.length)return false;for(let s=0;s<r.length;s++)if(r[s]!==o[s])return false;return true}function Ds(e,t,n,i,r=e){if(!e.hasArrowStart&&!e.hasArrowEnd||e.style==="invisible")return void 0;const o=(d,u,f)=>({kind:"port",id:`${f}:${d.id??`${d.source}->${d.target}[${d.edgeIndex??n.indexOf(d)}]`}:${u}`});if(!DS({...e,points:t},i))return o(r,"mapping","marker");const s=dp(e,i),a=dp({...e,points:t},i);const l=s.regions,c=a.regions;if(c.length!==Number(Boolean(e.hasArrowStart))+Number(Boolean(e.hasArrowEnd)))return o(r,"unmeasured","marker");for(const d of c){const u=l.find(f=>f.position===d.position);if(u&&u.resource===d.resource&&u.repaint===d.repaint&&u.anchor.x===d.anchor.x&&u.anchor.y===d.anchor.y&&(s.directional&&a.directional?LR(s.points,a.points,d.position):e.curve?e.points.length===t.length&&e.points.every((f,h)=>f.x===t[h].x&&f.y===t[h].y):HG(e.points,t,d.position)))continue;if(!nf(d))return o(r,d.position,"marker");for(const f of c)if(f!==d&&!AR(d,f))return o(r,f.position,"opposite-marker");for(const f of n){if(f===r||f.style==="invisible"||!f.hasArrowStart&&!f.hasArrowEnd)continue;if(!DS(f,i))return o(f,"mapping","peer-marker");const h=dp(f,i);for(const m of h.regions){const p=d.position==="start"?e.source:e.target;const g=m.position==="start"?f.source:f.target;if(a.directional&&h.directional&&nf(m)&&d.position===m.position&&p===g&&d.resource===m.resource&&d.repaint===m.repaint&&d.anchor.x===m.anchor.x&&d.anchor.y===m.anchor.y&&LR(a.points,h.points,d.position)&&Mo(e,f))continue;if(!AR(d,m))return o(f,m.position,"peer-marker")}}}return void 0}function $r(e,t,n,i,r=e){return Ds(e,t,n,i,r)===void 0}function ad(e){if(e.kind==="compound")return{...e,children:e.children.map(ad)};if(e.kind==="path")return{...e,d:Xn("d",e.d)};if(e.kind==="polygon"||e.kind==="polyline")return{...e,points:e.points.map(IR)};return Object.fromEntries(Object.entries(e).map(([t,n])=>[t,typeof n==="number"?Number(Ue(n)):n]))}var IR=e=>({x:Number(Ue(e.x)),y:Number(Ue(e.y))});var vi=e=>!!e&&Object.values(e).every(Number.isFinite)&&e.x0<=e.x1&&e.y0<=e.y1;var Xi=(e,t)=>{const n=(Math.abs(e.x0)+Math.abs(e.y0)+Math.abs(e.x1)+Math.abs(e.y1)+Math.abs(t.x0)+Math.abs(t.y0)+Math.abs(t.x1)+Math.abs(t.y1))*1e-10+1e-9;return!Number.isFinite(n)||e.x0<t.x1+n&&t.x0<e.x1+n&&e.y0<t.y1+n&&t.y0<e.y1+n};function up(e,t,n){if(e.style==="invisible")return{shafts:[],markers:[]};if(e.points.length>_s*ka)return void 0;if(t.edgeBendRadius!==void 0&&!(Number.isFinite(t.edgeBendRadius)&&t.edgeBendRadius>=0))return void 0;const i={stroke:e.inlineStyle?.stroke??t.edgeStrokeColor??"var(--_line)",strokeWidth:Xn("stroke-width",e.inlineStyle?.["stroke-width"]??String((t.lineWidth??1)*(e.style==="thick"?2:1)))};const r=$n(i,e.points.length>2||!!e.curve||(t.edgeBendRadius??0)>0);if(r===void 0||e.points.length<2)return void 0;if((e.hasArrowStart||e.hasArrowEnd)&&$n({...i,stroke:"black"},false)===void 0)return void 0;const o=[];const s=f=>{if(!n())return false;const h=Fc(f,r);if(!vi(h))return false;if(r>0)o.push(h);return true};const a=Ju(e,t);if(a){if(!ps(Xn("d",a.geometry.d),f=>s(f.bounds),n))return void 0}else{const f=e.points.map(IR);for(let h=1;h<f.length;h++){const m=f[h-1],p=f[h];if(!s({x0:Math.min(m.x,p.x),y0:Math.min(m.y,p.y),x1:Math.max(m.x,p.x),y1:Math.max(m.y,p.y)}))return void 0}}const l=sd(e,t);if(!l)return void 0;for(const f of l)if(!n()||!vi(f.bounds))return void 0;const c=Pt(e,t);const d=c?Ri(e,t.lineWidth??1):0;const u=c?{x0:c.x-d,y0:c.y-d,x1:c.x+c.w+d,y1:c.y+c.h+d}:void 0;if(u&&!vi(u))return void 0;return{shafts:o,markers:l,...u?{label:u}:{}}}function fp(e,t,n,i,r){if(!r(16))return void 0;const o=[],s=[];const a=new Map;const l=new Map;const c=h=>{if(!r(32))return false;if(h.kind==="compound")return r(h.children.length+1)&&h.children.every(c);if(h.kind==="path")return r(6*h.d.length+16);if(h.kind==="polygon"||h.kind==="polyline")return r(h.points.length*(2*384+4)+4);return r(8*384+32)};for(const h of e){const m=h.inlineStyle?.["stroke-width"]??String(i.nodeLineWidth??et.innerBox);if(!r(512+m.length*6+h.id.length))return void 0;const p=Fr(h,{fill:h.inlineStyle?.fill??i.nodeFillColor??"var(--_node-fill)",stroke:h.inlineStyle?.stroke??i.nodeBorderColor??"var(--_node-stroke)",strokeWidth:Xn("stroke-width",m)},i.cornerRadius);if(!c(p.geometry))return void 0;const g=Pi({kind:"shape",id:h.id,role:"node",geometry:ad(p.geometry),paint:p.paint,...p.childPaints?{childPaints:p.childPaints}:{}});if(!vi(g))return void 0;o.push(g)}const d=(h,m=0)=>{if(m>64||!r(h.length+1))return false;for(const p of h){const g=p.concurrencyRegion?0:p.headerHeight??p.height;const y=p.inlineStyle?.["stroke-width"]??String(i.groupLineWidth??et.innerBox);if(!r(8*384+y.length*6+88)||!Number.isFinite(g)||g<0||i.groupCornerRadius!==void 0&&!(Number.isFinite(i.groupCornerRadius)&&i.groupCornerRadius>=0))return false;if(g>0){const b=ad({kind:"rect",x:p.x,y:p.y,width:p.width,height:g});const S={fill:"black",stroke:p.inlineStyle?.stroke??"black",strokeWidth:Xn("stroke-width",y)};let x;if(i.groupCornerRadius===0)x=Pi({kind:"shape",id:p.id,role:"group-header",geometry:b,paint:S});else{const k=$n(S,true);const w=Pi({kind:"shape",id:p.id,role:"group-header",geometry:b,paint:{fill:"black",stroke:"none"}});if(k===void 0||!vi(w))return false;x=Fc(w,k)}if(!vi(x))return false;s.push(x)}if(!d(p.children,m+1))return false}return true};if(!d(n))return void 0;for(const h of t){if(h.label&&!h.labelPosition)return void 0;const m=h.inlineStyle?.["stroke-width"]??"";const p=h.curve||(i.edgeBendRadius??0)>0?18:4;const g=h.inlineStyle?.stroke??i.edgeStrokeColor??"";if(!r(2048+h.points.length*(p*384+32)+m.length*8+(h.label?.length??0)*12+(g.length+h.source.length+h.target.length+(h.id?.length??0))*8))return void 0;const y=up(h,i,()=>r(1));if(!y)return void 0;a.set(h,y)}const u=(h,m)=>{if(!r(4))return void 0;const p=l.get(h);if(p&&p.x===m.x&&p.y===m.y)return p.box;if(!r(64+(h.label?.length??0)*12))return void 0;const g=Pt({...h,labelPosition:m},i);if(!g)return void 0;const y=Ri(h,i.lineWidth??1);const b={x0:g.x-y,y0:g.y-y,x1:g.x+g.w+y,y1:g.y+g.h+y};if(!vi(b)||!r(6))return void 0;l.set(h,{x:m.x,y:m.y,box:b});return b};const f=(h,m,p,g,y)=>{const b=u(h,m);if(!b)return false;for(const x of o)if(!r(1)||Xi(b,x))return false;for(const x of s)if(!r(1)||Xi(b,x))return false;let S=true;for(const x of t){if(!r(1))return false;const k=a.get(x);for(const R of k.markers)if(!r(1)||!vi(R.bounds)||Xi(b,R.bounds))return false;if(x===h)continue;for(const R of k.shafts)if(!r(1)||Xi(b,R))return false;if(y instanceof Set?y.has(x):x===y)continue;const w=p.get(x)??x.labelPosition;if(!x.label||!w)continue;const C=u(x,w);if(!C)return false;if(Xi(b,C)){if(g&&!g.has(x)){if(!r(1))return false;g.add(x)}S=false}}return S};return{clear:f,label:u}}var hp=new WeakMap;function FR(e){const t=e.points[0];if(!t)return;const n=[];for(const i of e.points)n.push(i.x-t.x,i.y-t.y);hp.set(e,{source:e.source,target:e.target,edgeIndex:e.edgeIndex,coordinates:n})}function ko(e,t){const n=e[0];if(!n||e.length<2||!(e.every(i=>i.source===n.source)||e.every(i=>i.target===n.target)||e.every(i=>i.source===n.source&&i.target===n.target||i.source===n.target&&i.target===n.source))){throw new Error("Bundle construction requires related fan or parallel routes")}for(const i of e){FR(i);t.add(i)}}function Ta(e){const t=hp.get(e);if(!t||e.source!==t.source||e.target!==t.target||e.edgeIndex!==t.edgeIndex||e.points.length*2!==t.coordinates.length)return false;const n=e.points[0];if(!n)return false;for(let i=0;i<e.points.length;i++){const r=e.points[i];if(!(Math.abs(r.x-n.x-t.coordinates[i*2])<=1e-6)||!(Math.abs(r.y-n.y-t.coordinates[i*2+1])<=1e-6))return false}return true}function zl(e){return Ta(e)?hp.get(e):void 0}function La(e,t){if(t&&hp.get(e)===t&&e.source===t.source&&e.target===t.target&&e.edgeIndex===t.edgeIndex)FR(e)}var pp=.01;function mp(e,t){return 8*Number.EPSILON*Math.max(1,Math.abs(e.x),Math.abs(e.y),Math.abs(t.x),Math.abs(t.y))}function OS(e,t,n=0){const i=Math.max(n,mp(e,t));return Math.abs(e.x-t.x)<=i&&Math.abs(e.y-t.y)<=i}function ld(e,t){return e.x-t.x||e.y-t.y}function gp(e,t){const n=e.find(i=>i.x===t.x&&i.y===t.y);if(n)n.error=Math.max(n.error,t.error);else e.push(t)}function yp(e){e.sort(ld);const t=[];for(const n of e){if(!t.some(i=>OS(i,n,Math.max(i.error,n.error))))t.push(n)}return t.length}function NR(e,t,n){const i=n[e.edgeIndex].points;const r=c=>Math.hypot(c.x-t.x,c.y-t.y)<=pp+Math.max(t.error,mp(c,t));if(r(i[0])||r(i[i.length-1]))return void 0;const o=c=>OS(c,t,t.error);const s=o(e.a)?e.pointIndex:o(e.b)?e.pointIndex+1:-1;if(s<0)return[e.a,e.b];let a=s-1,l=s+1;while(a>=0&&o(i[a]))a--;while(l<i.length&&o(i[l]))l++;if(a<0||l>=i.length)return void 0;return[i[a],i[l]]}function cd(e,t,n){let i=e.a,r=e.b,o=t.a,s=t.b;if(ld(i,r)>0)[i,r]=[r,i];if(ld(o,s)>0)[o,s]=[s,o];if((ld(i,o)||ld(r,s))>0)[i,r,o,s]=[o,s,i,r];const a=r.x-i.x,l=r.y-i.y;const c=s.x-o.x,d=s.y-o.y;const u=a*d,f=l*c;const h=u-f;if(Math.abs(h)<=Number.EPSILON*(Math.abs(u)+Math.abs(f)))return void 0;const m=o.x-i.x,p=o.y-i.y;const g=m*d,y=p*c,b=m*l,S=p*a;const x=(g-y)/h,k=(b-S)/h;const w=Math.abs(u)+Math.abs(f);const C=(_,z,F)=>8*Number.EPSILON*(1+(Math.abs(z)+Math.abs(F)+Math.abs(_)*w)/Math.abs(h));const R=C(x,g,y),M=C(k,b,S);if(x<-R||x>1+R||k<-M||k>1+M)return void 0;const P=Math.abs(x)<=R?i:Math.abs(x-1)<=R?r:void 0;const E=Math.abs(k)<=M?o:Math.abs(k-1)<=M?s:void 0;const v=Math.max(mp(i,r),mp(o,s),R*(Math.abs(a)+Math.abs(l)),M*(Math.abs(c)+Math.abs(d)));const L={...P??E??{x:i.x+x*a,y:i.y+x*l},error:v};const T=NR(e,L,n),A=NR(t,L,n);if(!T||!A)return void 0;if(T[0]===e.a&&T[1]===e.b&&A[0]===t.a&&A[1]===t.b)return L;const $=[...T.map(_=>({angle:Math.atan2(_.y-L.y,_.x-L.x),edge:0})),...A.map(_=>({angle:Math.atan2(_.y-L.y,_.x-L.x),edge:1}))].sort((_,z)=>_.angle-z.angle);for(let _=0;_<$.length;_++){const z=$[_],F=$[(_+1)%$.length];const G=(F.angle-z.angle+2*Math.PI)%(2*Math.PI);if(z.edge===F.edge||G<1e-9)return void 0}return L}function _r(e,t){const n=[];e.forEach((s,a)=>{if(s.visible===false)return;for(let l=0;l+1<s.points.length;l++){const c=s.points[l],d=s.points[l+1];if(c.x===d.x&&c.y===d.y)continue;n.push({a:c,b:d,edgeIndex:a,pointIndex:l,minX:Math.min(c.x,d.x),maxX:Math.max(c.x,d.x),minY:Math.min(c.y,d.y),maxY:Math.max(c.y,d.y)})}});n.sort((s,a)=>s.minX-a.minX||s.minY-a.minY||s.edgeIndex-a.edgeIndex||s.pointIndex-a.pointIndex);const i=[];const r=new Map;for(const s of n){let a=0;for(let l=0;l<i.length;l++){const c=i[l];if(!(c.maxX>=s.minX))continue;i[a++]=c;if(c.edgeIndex===s.edgeIndex||t&&!t.has(c.edgeIndex)&&!t.has(s.edgeIndex)||c.maxY<s.minY||c.minY>s.maxY)continue;const d=cd(s,c,e);if(!d)continue;const u=`${Math.min(s.edgeIndex,c.edgeIndex)}:${Math.max(s.edgeIndex,c.edgeIndex)}`;const f=r.get(u);if(f){const h=f.find(m=>m.x===d.x&&m.y===d.y);if(h)h.error=Math.max(h.error,d.error);else f.push(d)}else r.set(u,[d])}i.length=a;i.push(s)}let o=0;for(const s of r.values()){s.sort(ld);const a=[];for(const l of s){if(!a.some(c=>OS(c,l,Math.max(c.error,l.error))))a.push(l)}o+=a.length}return o}function xp(e,t){let n;let i;for(let r=0;r+1<e.length;r++){const o=e[r],s=e[r+1];if(o.x===s.x&&o.y===s.y)continue;const a=Math.min(o.x,s.x),l=Math.max(o.x,s.x),c=Math.min(o.y,s.y),d=Math.max(o.y,s.y);for(let u=0;u+1<t.length;u++){const f=t[u],h=t[u+1];if(f.x===h.x&&f.y===h.y)continue;if(l<Math.min(f.x,h.x)||a>Math.max(f.x,h.x)||d<Math.min(f.y,h.y)||c>Math.max(f.y,h.y))continue;if(o.x===s.x&&f.x===h.x||o.y===s.y&&f.y===h.y)continue;n??=[{points:e},{points:t}];const m=cd({a:o,b:s,edgeIndex:0,pointIndex:r},{a:f,b:h,edgeIndex:1,pointIndex:u},n);if(!m)continue;if(!i)i=[m];else gp(i,m)}}return i?yp(i):0}function Gl(e){return Nr(e)?2:1}function $R(e,t){if(Nr(e)&&(t==="NE"||t==="SE"||t==="SW"||t==="NW")){return Yo(e)[t]}return Ft(e)[t]}function WS(e,t,n,i){const r=xi(t).boundary;if(r.kind!=="rect"||e.points.length<2)return;const o=n?0:e.points.length-1;const s=e.points[o];const a=r.x;const l=r.x+r.width;const c=r.y;const d=r.y+r.height;const u=(h,m)=>Math.abs(h-m)<=pn;const f=(h,m)=>{const p=[...e.points];p[o]=h;if(Math.abs(h.x-m.x)>$e||Math.abs(h.y-m.y)>$e){if(n){const g=p[1];if(!g||Math.abs(g.x-m.x)>$e||Math.abs(g.y-m.y)>$e)p.splice(1,0,m)}else{const g=p[p.length-2];if(!g||Math.abs(g.x-m.x)>$e||Math.abs(g.y-m.y)>$e)p.splice(p.length-1,0,m)}}if($r(e,p,i.edges,i.style))Si(i,e,p)};if(u(s.x,a)||u(s.x,l)){const h=u(s.x,a)?a:l;if(s.y<c-pn)f({x:h,y:c},{x:h,y:s.y});else if(s.y>d+pn)f({x:h,y:d},{x:h,y:s.y});return}if(u(s.y,c)||u(s.y,d)){const h=u(s.y,c)?c:d;if(s.x<a-pn)f({x:a,y:h},{x:s.x,y:h});else if(s.x>l+pn)f({x:l,y:h},{x:s.x,y:h})}}function jG(e,t){if(t!==2&&t!==3)return null;const n=xr(e,1);const i=n==="E"?"NE":n==="S"?"SW":"NW";const r=n==="W"?"SW":n==="N"?"NE":"SE";return t===2?[i,r]:[i,n,r]}function _R(e,t,n,i){if(!Nr(t)||e.edgeIndex===void 0||n.classes?.[e.edgeIndex]!=="primary-forward"){return null}const r=Ra(n.nodes);const o=n.edges.filter(d=>d.source===e.source&&d.edgeIndex!==void 0&&n.classes?.[d.edgeIndex]==="primary-forward"&&r.has(d.target)).sort((d,u)=>{const f=r.get(d.target);const h=r.get(u.target);const m=f[i.cross]+(i.cross==="y"?f.height:f.width)/2;const p=h[i.cross]+(i.cross==="y"?h.height:h.width)/2;return m-p||(d.edgeIndex??0)-(u.edgeIndex??0)});const s=jG(i,o.length);if(!s)return null;const a=o.indexOf(e);if(a<0)return null;const l=s[a];const c=o.map(d=>{const u=r.get(d.target);return u[i.main]+(i.main==="x"?u.width:u.height)/2});return{sourcePort:l,sourceLane:$R(t,l)[i.cross],targetsShareRank:Math.max(...c)-Math.min(...c)<=1}}function YG(e,t,n,i){return _R(e,t,n,i)?.sourceLane}function zS(e,t,n,i,r){const o=_R(e,t,i,r);if(!o||!o.targetsShareRank)return null;const s=xr(r,-1);const a=Ft(n)[s][r.cross];if(Math.abs(o.sourceLane-a)<=pn)return null;return{sourcePort:o.sourcePort,sourceLane:o.sourceLane,targetPort:s,targetLane:a}}function DR(e,t,n,i){if(e.points.length<=2)return false;const r=e.points[0];const o=e.points[e.points.length-1];const s=$R(t,i.sourcePort);const a=Ft(n)[i.targetPort];return Math.abs(r.x-s.x)<=pn&&Math.abs(r.y-s.y)<=pn&&Math.abs(o.x-a.x)<=pn&&Math.abs(o.y-a.y)<=pn}function OR(e,t,n){if(n.fixedLabels||n.finalLabelClearance)return false;if(!n.classes||e.edgeIndex===void 0||t.edgeIndex===void 0)return false;return n.classes[e.edgeIndex]==="primary-forward"&&n.classes[t.edgeIndex]==="feedback"&&t.source===e.target&&t.target===e.source}function Ti(e){return`${e.source}->${e.target}`}function bp(e,t,n,i,r,o=r.axis){return BR(e,t,n,i,r,o,false)}function Ui(e,t,n,i,r,o){return BR(e,t,n,i,r,o,true)}function BR(e,t,n,i,r,o,s){const a=s?void 0:[];const l=r.nodeLaneIndexes;const c=rR(l,r.nodes,o.cross,en);const d=c?ip(c,t):null;const u=c&&d!==null;const f=u?c.offsets[d]??0:0;const h=u?c.offsets[d+1]??0:r.nodes.length;for(let p=f;p<h;p++){const g=r.nodes[u?c.ordinals[p]:p];if(g.id===e.source||g.id===e.target)continue;const y=(o.cross==="x"?g.x:g.y)-en;const b=(o.cross==="x"?g.x:g.y)+(o.cross==="y"?g.height:g.width)+en;if(t>y&&t<b){const S=(o.main==="x"?g.x:g.y)-en;const x=(o.main==="x"?g.x:g.y)+(o.main==="x"?g.width:g.height)+en;if(Math.min(i,x)-Math.max(n,S)>$e){if(s)return true;a.push({kind:"node",id:g.id})}}}if(r.groups?.length&&e.style!=="invisible"){const p=g=>{const y=g.concurrencyRegion?0:g.headerHeight??g.height;const b=!Number.isFinite(y)||y<0;const S=o.cross==="x"?g.x:g.y;const x=S+(o.cross==="x"?g.width:y);const k=o.main==="x"?g.x:g.y;const w=k+(o.main==="x"?g.width:y);if(b||y>0&&g.width>0&&t>S&&t<x&&Math.min(i,w)>Math.max(n,k)){if(s)return true;a.push({kind:"group-header",id:g.id})}for(const C of g.children)if(p(C))return true;return false};for(const g of r.groups)if(p(g))return true}const m=r.routeChannelGeometry;for(let p=0;p<r.edges.length;p++){const g=r.edges[p];if(g===e||e.edgeIndex!==void 0&&g.edgeIndex===e.edgeIndex)continue;const y=!OR(e,g,r)&&g.label&&g.labelPosition?g.labelBlock??ji(qe(g.label,g.labelContent),r.style):void 0;if(y){const b=y.width+2*on,S=y.height+2*on;const x=g.labelPosition.x-b/2,k=g.labelPosition.y-S/2;const w=(o.main==="x"?x:k)-en;const C=w+(o.main==="x"?b:S)+2*en;const R=(o.cross==="y"?k:x)-en;const M=R+(o.cross==="y"?S:b)+2*en;if(t>R&&t<M&&Math.min(i,C)-Math.max(n,w)>$e){if(s)return true;a.push({kind:"label",id:Ti(g)})}}if(m&&!oR(m,g,o.cross,t,n,i,en,$e))continue;for(let b=1;b<g.points.length;b++){const S=g.points[b-1],x=g.points[b];if(Math.abs((o.cross==="x"?S.x:S.y)-(o.cross==="x"?x.x:x.y))>$e)continue;if(Math.abs((o.cross==="x"?S.x:S.y)-t)>=en)continue;const k=Math.min(o.main==="x"?S.x:S.y,o.main==="x"?x.x:x.y);const w=Math.max(o.main==="x"?S.x:S.y,o.main==="x"?x.x:x.y);if(Math.min(i,w)-Math.max(n,k)>$e){if(g.target===e.target&&g.source!==e.source&&Mo(e,g)&&Math.abs((o.cross==="x"?S.x:S.y)-t)<$e&&b===g.points.length-1){continue}if(s)return true;a.push({kind:"channel",id:Ti(g)});break}}}if(e.label){const p=e.labelBlock??ji(qe(e.label,e.labelContent),r.style);const g=(o.main==="x"?p.width:p.height)+2*on;if(i-n<g+wR){if(s)return true;a.push({kind:"label",id:Ti(e)})}}return s?false:Sp(a)}function ir(e,t,n,i){if(!e.label)return{x:(t.x+n.x)/2,y:(t.y+n.y)/2};const r=e.labelBlock??ji(qe(e.label,e.labelContent),i.style);const o=2;const s=(F,G,I,D,B,Y,W,O,N=o)=>F<B+W+N&&F+I+N>B&&G<Y+O+N&&G+D+N>Y;const a=i.style.lineWidth??1;const l=nd(e,a,"start"),c=nd(e,a,"end");const d=F=>Math.max(i.finalLabelClearance?8:o,F.id===e.source?l:0,F.id===e.target?c:0);const u=i.finalLabelClearance?16:o,f=i.finalLabelClearance?8:o;const h=i.edges.filter(F=>F!==e&&!(e.edgeIndex!==void 0&&F.edgeIndex===e.edgeIndex));const m=F=>!i.finalLabelClearance&&OR(e,F,i)?null:Pt(F,i.style);const p=Math.abs(t.x-n.x)<$e,g=p!==Math.abs(t.y-n.y)<$e;const y=p?"y":"x",b=p?"x":"y",S=p?"x1":"y1",x=p?"y1":"x1";const k=(p?r.height:r.width)/2+on,w=(p?r.width:r.height)/2+on;const C=Math.min(t[b],n[b])-w-1e-6,R=Math.max(t[b],n[b])+w+1e-6;const M=Math.min(t[y],n[y])-k-1e-6,P=Math.max(t[y],n[y])+k+1e-6;let E;const v=()=>{if(E)return E;const F=E=[];const G=(I,D,B,Y,W,O,N)=>{if(!g||(p?W:O)+N>=C&&(p?I:D)-N<=R&&(p?O:W)+N>=M&&(p?D:I)-N<=P)F.push({x:I,y:D,w:B,h:Y,x1:W,y1:O,gap:N})};for(const I of i.nodes)G(I.x,I.y,I.width,I.height,I.x+I.width,I.y+I.height,d(I));for(const I of h){const D=m(I);if(D)G(D.x,D.y,D.w,D.h,D.x+D.w,D.y+D.h,u);for(let B=1;B<I.points.length;B++){const Y=I.points[B-1],W=I.points[B];const O=Math.min(Y.x,W.x),N=Math.max(Y.x,W.x);const H=Math.min(Y.y,W.y),j=Math.max(Y.y,W.y);G(O,H,N-O,j-H,N,j,f)}}return F};const L=(F,G)=>{const I=Ma(F,G,r);return!v().some(D=>s(I.x,I.y,I.w,I.h,D.x,D.y,D.w,D.h,D.gap))};for(const F of[.5,1/3,2/3,.25,.75,1/6,5/6]){const G=t.x+(n.x-t.x)*F;const I=t.y+(n.y-t.y)*F;if(L(G,I))return{x:G,y:I}}if(!g)return null;const T=Math.min(t[y],n[y]),A=Math.max(t[y],n[y]),$=(T+A)/2;if(A-T<2*k-2*$e)return null;const _=[$];for(const F of v()){if(F[S]+F.gap<=t[b]-w||F[b]-F.gap>=t[b]+w)continue;_.push(F[y]-F.gap-k-$e,F[x]+F.gap+k+$e)}const z=_.filter(F=>F>=T+k-$e&&F<=A-k+$e).sort((F,G)=>Math.abs(F-$)-Math.abs(G-$)||F-G);for(const F of z.slice(0,16)){const G=y==="x"?{x:F,y:t.y}:{x:t.x,y:F};if(L(G.x,G.y))return G}return null}function br(e,t,n,i=Infinity){if(t.style==="invisible")return 0;let r=0;for(const o of n.edges){if(o===t||o.style==="invisible"||t.edgeIndex!==void 0&&o.edgeIndex===t.edgeIndex)continue;r+=xp(e,o.points);if(r>i)return r}return r}function Hl(e,t){for(const n of t.nodes){if(n.id===e.source||n.id===e.target)continue;if(ud(e.points,n))return true}return false}function Sp(e){const t=new Set;return e.filter(n=>{const i=`${n.kind}:${n.id}`;if(t.has(i))return false;t.add(i);return true})}function WR(e,t,n,i,r,o){const s=qo(t,r,1);const a=qo(n,r,-1);if(!s||!a)return null;const l=Math.max(s.lo,a.lo);const c=Math.min(s.hi,a.hi);const d=(C,R)=>{if(!Nr(C))return R;return{lo:C[r.cross]+2,hi:C[r.cross]+(r.cross==="y"?C.height:C.width)-2}};const u=Math.max(d(t,s).lo,d(n,a).lo);const f=Math.min(d(t,s).hi,d(n,a).hi);const h=C=>C[r.cross]+(r.cross==="y"?C.height:C.width)/2;const m=C=>Math.abs(C-h(n))<=pn||Math.abs(C-h(t))<=pn;if(u>f){return{overlapLo:l,overlapHi:c,relaxedLo:u,relaxedHi:f,candidates:[],isPortLane:m,emptyRelaxed:true}}const p=[];const g=C=>{if(p.every(R=>Math.abs(R-C)>.5))p.push(C)};const y=n[r.cross]+(r.cross==="y"?n.height:n.width)/2;const b=t[r.cross]+(r.cross==="y"?t.height:t.width)/2;const S=i.sideUse?.get(`${t.id}:${xr(r,1)}`)??1;const x=Nr(t)&&S===1&&Gl(t)>=Gl(n);const k=i.classes&&i.edges.some(C=>C!==e&&C.source===e.target&&C.target===e.source&&!C.label&&!e.label&&C.edgeIndex!==void 0&&e.edgeIndex!==void 0);const w=k&&Nr(t)&&Nr(n);if(o!==void 0){p.push(o)}else if(w){const C=i.classes[e.edgeIndex]==="feedback"?1:-1;const R=t[r.cross]+(r.cross==="y"?t.height:t.width)/2;const M=(r.cross==="y"?t.height:t.width)/4;g(R+C*M);g((l+c)/2+C*Pa/2);g(y);g(b)}else if(k){const C=(l+c)/2;const R=i.classes[e.edgeIndex]==="feedback"?1:-1;g(C+R*Pa/2);g(y);g(b)}else if(x){g(b);g(y)}else{const C=YG(e,t,i,r);if(C!==void 0)g(C);g(y);g(b)}if(o===void 0){if(e.points.length>0){g(e.points[e.points.length-1][r.cross]);g(e.points[0][r.cross]);const C=e.points.map(R=>R[r.cross]);g(Math.min(...C));g(Math.max(...C))}g((l+c)/2);g((l+(l+c)/2)/2);g(((l+c)/2+c)/2)}return{overlapLo:l,overlapHi:c,relaxedLo:u,relaxedHi:f,candidates:p,isPortLane:m,emptyRelaxed:false}}function BS(e,t,n,i,r,o,s){const a=s.isPortLane(i)?s.relaxedLo:s.overlapLo;const l=s.isPortLane(i)?s.relaxedHi:s.overlapHi;if(i<a-$e||i>l+$e)return{blockers:[{kind:"span",id:Ti(e)}]};const c=to(t,i,o,1);const d=to(n,i,o,-1);if(c===null||d===null)return{blockers:[{kind:"span",id:Ti(e)}]};if((d-c)*o.sign<=$e)return{blockers:[{kind:"span",id:Ti(e)}]};const u=Math.min(c,d);const f=Math.max(c,d);const h=bp(e,i,u,f,r,o);if(h.length>0)return{blockers:h};const m=Ln(o,c,i);const p=Ln(o,d,i);const g=r.nodeLaneIndexes&&!Gr()?s.priorCrossings??=br(e.points,e,r):br(e.points,e,r);const y=br([m,p],e,r,g);if(y>g){return{blockers:[{kind:"crossing",id:Ti(e)}]}}const b=ir(e,m,p,r);if(b===null)return{blockers:[{kind:"label",id:Ti(e)}]};return{start:m,end:p,slot:b}}function jl(e,t,n,i,r=i.axis,o,s=e){const a=WR(e,t,n,i,r,o);if(!a)return{applied:false,blockers:[]};if(a.emptyRelaxed)return{applied:false,blockers:[{kind:"span",id:Ti(e)}]};const l=[];for(let c=0;c<a.candidates.length;c++){const d=a.candidates[c];const u=BS(e,t,n,d,i,r,a);if("blockers"in u){l.push(...u.blockers);continue}const f=Ds(e,[u.start,u.end],i.edges,i.style,s);if(f){l.push(f);continue}const h=xt(e.points);if(h.length===2&&Math.abs(h[0][r.cross]-h[1][r.cross])<=$e){const m=Number(Boolean(Vn(t,h[0])))+Number(Boolean(Vn(n,h[1])));const p=Number(Boolean(Vn(t,u.start)))+Number(Boolean(Vn(n,u.end)));const g=p<m;const y=()=>{const b=i.edges.filter(S=>S!==e);return Xo([{...e,points:[u.start,u.end]},...b])<Xo([{...e,points:h},...b])};if(g&&br([u.start,u.end],e,i)>=br(h,e,i)&&!y()){const b=h[0][r.cross];const S=BS(e,t,n,b,i,r,{...a,overlapLo:Math.min(a.overlapLo,b),overlapHi:Math.max(a.overlapHi,b),relaxedLo:Math.min(a.relaxedLo,b),relaxedHi:Math.max(a.relaxedHi,b)});if(!("blockers"in S)&&Math.hypot(S.start.x-h[0].x,S.start.y-h[0].y)<=$e&&Math.hypot(S.end.x-h[1].x,S.end.y-h[1].y)<=$e){if(e.label)e.labelPosition=S.slot??void 0;return{applied:true,blockers:[]}}if("blockers"in S)l.push(...S.blockers);continue}}Si(i,e,[u.start,u.end]);if(e.label)e.labelPosition=u.slot??void 0;return{applied:true,blockers:[],usedCandidateIndex:c}}return{applied:false,blockers:Sp(l)}}function rf(e,t,n,i,r=i.axis){const o=WR(e,t,n,i,r);if(!o||o.emptyRelaxed)return null;if(!eo(t)||!eo(n))return null;if(!Zu(e.points,r))return null;for(const s of o.candidates){const a=BS(e,t,n,s,i,r,o);if(!("blockers"in a))return s}return null}function Uo(e,t,n,i,r){const o=rd(n);return{ctx:{nodes:e,edges:t,groups:r,axis:o,style:i},axis:o}}function Aa(e,t,n,i=e.labelPosition){if(!e.label||!i)return null;const r=e.labelBlock??ji(qe(e.label,e.labelContent),n);const o=Ma(i.x,i.y,r);for(const s of t){if(s===e||e.edgeIndex!==void 0&&s.edgeIndex===e.edgeIndex)continue;for(let a=1;a<s.points.length;a++){const l=s.points[a-1],c=s.points[a];const d=Math.abs(l.x-c.x)<$e;const u=Math.abs(l.y-c.y)<$e;if(!d&&!u)continue;const f=Math.min(l.x,c.x),h=Math.max(l.x,c.x);const m=Math.min(l.y,c.y),p=Math.max(l.y,c.y);const g=h>=o.x&&f<=o.x+o.w&&p>=o.y&&m<=o.y+o.h;if(!g)continue;for(let y=1;y<e.points.length;y++){const b=e.points[y-1],S=e.points[y];const x=d?Math.abs(b.x-S.x)<$e&&Math.abs(b.x-l.x)<en:Math.abs(b.y-S.y)<$e&&Math.abs(b.y-l.y)<en;if(!x)continue;const k=d?Math.min(b.y,S.y):Math.min(b.x,S.x);const w=d?Math.max(b.y,S.y):Math.max(b.x,S.x);const C=d?m:f;const R=d?p:h;if(Math.min(w,R)-Math.max(k,C)>$e)return s}}}return null}function dd(e,t,n){const i=br(t.points,t,n);return br(e,t,n,i)>i}function ud(e,t){const n=t.shape==="cylinder"?xi(t).boundary:void 0;const i=(t.shape==="rectangle"||t.shape==="subroutine")&&(t.semanticShape===void 0||t.semanticShape==="rect"||t.semanticShape==="fr-rect"||t.semanticShape==="lin-rect"||t.semanticShape==="div-rect"||t.semanticShape==="win-pane");const r=i?0:.5;for(let o=1;o<e.length;o++){const s=e[o-1],a=e[o];const l=Math.min(s.x,a.x),c=Math.max(s.x,a.x);const d=Math.min(s.y,a.y),u=Math.max(s.y,a.y);if(n?.kind==="cylinder"&&n.height>2*n.capRadiusY&&c>t.x&&l<t.x+t.width&&u>n.y+n.capRadiusY&&d<n.y+n.height-n.capRadiusY)return true;if(c>t.x+r&&l<t.x+t.width-r&&u>t.y+r&&d<t.y+t.height-r)return true}return false}function zR(e,t,n){const i=xt(e.points);if(i.length<4)return false;const r=t.axis;const o=v=>v[r.cross];const s=v=>v[r.main];let a=-1;let l=$e;for(let v=1;v<i.length;v++){if(Math.abs(o(i[v-1])-o(i[v]))>=$e)continue;const L=(s(i[v-1])-s(i[v]))*r.sign;if(L>l){l=L;a=v-1}}if(a<1)return false;const c=o(i[a]);const d=[i[a],i[a+1]];const u=Math.sign(s(d[1])-s(d[0]));const f=i[0];const h=t.nodes.find(v=>v.id===e.source);const m=v=>u>0?v>=s(d[0])-$e&&v<s(d[1])-$e:v<=s(d[0])+$e&&v>s(d[1])+$e;const p=(v,L)=>{if(Math.abs(L-c)<$e)return true;const T=r.main==="x"?{main:"y",cross:"x",sign:L<c?1:-1}:{main:"x",cross:"y",sign:L<c?1:-1};const A={...e,points:[],label:void 0};return bp(A,v,Math.min(L,c),Math.max(L,c),t,T).length===0};const g=(v,L,T)=>{const A=Ln(r,v,c);return Math.abs(L-c)<$e?[A,...i.slice(a+1)]:[T,A,...i.slice(a+1)]};let y=null;if(h&&eo(h)){const v=h[r.cross];const L=r.cross==="y"?c>v?"S":"N":c>v?"E":"W";const T=Ft(h)[L];const A=T[r.cross];const $=T[r.main];if(m($)&&p($,A)){y=g($,A,T)}}if(!y&&h){const v=u===r.sign?1:-1;const L=qo(h,r,v);const T=xi(h).sides[xr(r,v)];if(T.kind==="dynamic"&&L&&c>=L.lo-$e&&c<=L.hi+$e){const A=to(h,c,r,v);if(A!==null&&m(A)&&p(A,c)){const $=Ln(r,A,c);y=g(A,c,$)}}}if(!y&&m(s(f))&&p(s(f),o(f))){y=g(s(f),o(f),f)}if(!y&&a===2&&Math.abs(o(i[1])-o(f))<$e&&t.edges.some(v=>v.source===e.source&&v!==e&&Aa(v,t.edges,t.style))){const v=Math.sign(s(i[1])-s(f));const L=[s(f)+v*12];for(const T of t.edges){if(T===e)continue;for(const $ of T.points)L.push(s($)+v*12);const A=Pt(T,t.style);if(A)L.push((r.main==="x"?A.x+(v>0?A.w:0):A.y+(v>0?A.h:0))+v*(en+$e))}L.sort((T,A)=>(T-A)*v);for(const T of L){if((T-s(f))*v<12-$e||(s(i[1])-T)*v<=$e||!m(T))continue;if(!p(T,o(f)))continue;const A=r.main==="x"?{x:T,y:o(f)}:{x:o(f),y:T};const $=r.main==="x"?{x:T,y:c}:{x:c,y:T};const _=[f,A,$,...i.slice(a+1)];if(br(_,e,t)>br(i,e,t))continue;y=_;break}}const b=y??i;let S=false;{let v=-1;for(let T=1;T<b.length;T++){if(Math.abs(o(b[T-1])-c)<$e&&Math.abs(o(b[T])-c)<$e){v=T-1;break}}const L=t.nodes.find(T=>T.id===e.target);if(v>=0&&v+1<b.length-1&&L&&eo(L)){const T=L[r.cross];const A=r.cross==="y"?c>T?"S":"N":c>T?"E":"W";const $=Ft(L)[A];const _=$[r.cross];const z=$[r.main];const F=b[v],G=b[v+1];const I=Math.sign(s(G)-s(F));const D=I>0?z>s(F)+$e&&z<=s(G)+$e:z<s(F)-$e&&z>=s(G)-$e;if(D&&p(z,_)){const B=Ln(r,z,c);y=[...b.slice(0,v+1),B,$];S=true}}}if(!y)return false;const x=xt(y);const k=n.get(e.target);if(bi({...e,points:x},h,k)>0)return false;const w=e.inlineStyle?.["stroke-width"]??String((t.style.lineWidth??et.connector)*(e.style==="thick"?2:1));const C=$n({stroke:"black",strokeWidth:Xn("stroke-width",w)},true);if(!h||!k||C===void 0)return false;const R=v=>{const L=v.inlineStyle?.["stroke-width"]??String(t.style.nodeLineWidth??et.innerBox);const T=$n({stroke:"black",strokeWidth:Xn("stroke-width",L)},true);if(T===void 0)return void 0;const A=Math.max(en,T+C)+$e;const $=v.x-A,_=v.y-A;const z=v.width+2*A,F=v.height+2*A;if(![$,_,z,F].every(Number.isFinite))return void 0;return{...v,shape:"rectangle",semanticShape:void 0,x:$,y:_,width:z,height:F}};const M=R(h),P=R(k);if(!M||!P||ud(x.slice(1),M)||ud(x.slice(0,-1),P))return false;if(dd(x,e,t))return false;if(!$r(e,x,t.edges,t.style))return false;const E=e.points;Si(t,e,x);if(e.label&&e.labelPosition){const v=e.labelPosition;const L=e.points.some((T,A)=>{if(A===0)return false;const $=e.points[A-1],_=T;const z=Math.min($.x,_.x)-1,F=Math.max($.x,_.x)+1;const G=Math.min($.y,_.y)-1,I=Math.max($.y,_.y)+1;return v.x>=z&&v.x<=F&&v.y>=G&&v.y<=I});if(!L){let T=null;for(let A=1;A<e.points.length;A++){const $=e.points[A-1],_=e.points[A];if(Math.abs(o($)-c)<$e&&Math.abs(o(_)-c)<$e){T=ir(e,$,_,t);break}}if(T){e.labelPosition=T}else{Si(t,e,E);return false}}}return JSON.stringify(e.points)!==JSON.stringify(E)}function GS(e,t,n,i,r){if(t!=="feedback")return null;if(!n||!i)return"feedback-detour";const o=c=>r.cross==="y"?c.height:c.width;const s=Math.min(n[r.cross],i[r.cross])-2;const a=Math.max(n[r.cross]+o(n),i[r.cross]+o(i))+2;const l=e.points.some(c=>c[r.cross]<s||c[r.cross]>a);return l?"outer-feedback":"feedback-detour"}function GR(e,t,n,i){const r=n.style;const o=new Map;const s=[];const a=new Map;const l=(d,u)=>Math.min(d.x+d.w,u.x+u.w)>Math.max(d.x,u.x)&&Math.min(d.y+d.h,u.y+u.h)>Math.max(d.y,u.y);const c=d=>{const u=e.get(d.source);if(!u)return null;const f=u.x+u.width/2;const h=u.y+u.height/2;const m=d.points.slice(1,-1);const p=m.length>0?{x:m.reduce((D,B)=>D+B.x,0)/m.length,y:m.reduce((D,B)=>D+B.y,0)/m.length}:d.points[0]??{x:u.x,y:h};const g=(p.x-f)/Math.max(u.width/2,1);const y=(p.y-h)/Math.max(u.height/2,1);const b=Math.abs(g)>=Math.abs(y)?g<0?"W":"E":y<0?"N":"S";const S=[b,CR(b),...b==="W"||b==="E"?["N","S"]:["W","E"]];const x=d.label?d.labelBlock??ji(qe(d.label,d.labelContent),r):null;const k=D=>x?(D==="N"||D==="S"?x.height:x.width)+2*on:0;const w=(D,B)=>{const Y=D==="N"||D==="S";const W=Y?f:h;const O=W-B-6;const N=W+B+6;const H=D==="W"?u.x:D==="E"?u.x+u.width:D==="N"?u.y:u.y+u.height;const j=D==="W"||D==="N"?-1:1;let q=1e3;const X=(V,ee,re,U)=>{if(ee<O||V>N)return;const te=(re-H)*j;const J=U?2:6;if(te>0)q=Math.min(q,te-J)};for(const V of n.nodes){if(V.id===u.id)continue;X(Y?V.x:V.y,Y?V.x+V.width:V.y+V.height,Y?j<0?V.y+V.height:V.y:j<0?V.x+V.width:V.x,false)}for(const V of t.values()){const ee=f>V.x&&f<V.x+V.width&&h>V.y&&h<V.y+V.height;if(ee){const re=Y?j<0?V.y:V.y+V.height:j<0?V.x:V.x+V.width;const U=(re-H)*j;if(U>0)q=Math.min(q,U-4)}else{X(Y?V.x:V.y,Y?V.x+V.width:V.y+V.height,Y?j<0?V.y+V.height:V.y:j<0?V.x+V.width:V.x,false)}}for(const V of n.edges){if(V===d||V.source===V.target||!V.label)continue;const ee=Pt(V,r);if(!ee)continue;X(Y?ee.x:ee.y,Y?ee.x+ee.w:ee.y+ee.h,Y?j<0?ee.y+ee.h:ee.y:j<0?ee.x+ee.w:ee.x,false)}return q};const C=D=>D==="N"||D==="S"?u.width:u.height;const R=D=>`${u.id}:${D}`;const M=D=>o.get(R(D))??0;const P=D=>Math.min(Math.max(C(D)/4,6),10,Math.max(C(D)/2-2,3));const E=D=>P(D)+M(D)*6<=C(D)/2-2;const v=D=>{const B=M(D);const Y=P(D)+B*6;const W=24+B*Math.max(14,k(D)+8);return{d:Y,desired:W,clear:w(D,Y)}};const L=(D,B,Y)=>{if(!d.label||!x)return[];const W=D==="N"||D==="S";const O=D==="W"||D==="N"?-1:1;const N=D==="W"||D==="S"?-1:1;const H=D==="W"?u.x:D==="E"?u.x+u.width:D==="N"?u.y:u.y+u.height;const j=H+O*(B+k(D)/2+4);const q=(W?x.width:x.height)+2*on+2;const X=M(D);let V=W?{x:f,y:j}:{x:j,y:h};const ee=Z=>({x:Z.x-x.width/2-on,y:Z.y-x.height/2-on,w:x.width+2*on,h:x.height+2*on});const re=R(D);const U=a.get(re)??[];const te=[];const J=s.slice();if(X>0){for(const Z of U){const se=Z.edge.labelPosition;const oe=W?{x:f-N*q,y:se.y}:{x:se.x,y:h-N*q};te.push({edge:Z.edge,position:oe,rectIndex:Z.rectIndex});J[Z.rectIndex]=Pt({...Z.edge,labelPosition:oe},r)}V=W?{x:f+N*q*X,y:j}:{x:j,y:h+N*q*X}}if(J.some(Z=>l(ee(V),Z))){for(let Z=0;Z<8;Z++){const se=Z%2===0?N:-N;const oe=(1+Math.floor(Z/2))*q;const de=W?{x:f+se*oe,y:j}:{x:j,y:h+se*oe};if(!J.some(xe=>l(ee(de),xe))){V=de;break}}}te.push({edge:d,position:V});const ae=new Map(te.map(Z=>[Z.edge,Z.position]));const Q=(Z,se)=>{const oe=Pt({...Z,labelPosition:se},r);if(!oe)return null;const de=Ri(Z,r.lineWidth??1);return{x:oe.x-de,y:oe.y-de,w:oe.w+2*de,h:oe.h+2*de}};const K=r;for(const Z of te){const se=Q(Z.edge,Z.position);const oe=Pt({...Z.edge,labelPosition:Z.position},r);if(!se||!oe||!Object.values(se).every(Number.isFinite))return null;const de=Z.edge===d?Y:Z.edge.points;let xe=Infinity;for(let Ce=1;Ce<de.length;Ce++){const pe=de[Ce-1],Te=de[Ce];if(pe.x!==Te.x&&pe.y!==Te.y)return null;xe=Math.min(xe,Math.max(oe.x-Math.max(pe.x,Te.x),Math.min(pe.x,Te.x)-oe.x-oe.w,0)+Math.max(oe.y-Math.max(pe.y,Te.y),Math.min(pe.y,Te.y)-oe.y-oe.h,0))}if(!(xe<=oe.h/2+4))return null;const Me=(Ce,pe,Te,Fe)=>{const De=(Math.abs(Ce)+Math.abs(pe)+Math.abs(Te)+Math.abs(Fe)+Math.abs(se.x)+Math.abs(se.y)+se.w+se.h)*1e-10+1e-9;return!Number.isFinite(De)||l(se,{x:Ce-De,y:pe-De,w:Te+2*De,h:Fe+2*De})};for(const Ce of n.nodes){const pe=Fr(Ce,{fill:Ce.inlineStyle?.fill??K.nodeFillColor??"var(--_node-fill)",stroke:Ce.inlineStyle?.stroke??K.nodeBorderColor??"var(--_node-stroke)",strokeWidth:Ce.inlineStyle?.["stroke-width"]??String(K.nodeLineWidth??et.innerBox)},K.cornerRadius??0);const Te=Pi({kind:"shape",id:Ce.id,role:"node",geometry:pe.geometry,paint:pe.paint,...pe.childPaints?{childPaints:pe.childPaints}:{}});if(!Te||Me(Te.x0,Te.y0,Te.x1-Te.x0,Te.y1-Te.y0))return null}for(const Ce of t.values()){const pe=Ce.concurrencyRegion?0:Ce.headerHeight??Ce.height;if(!Number.isFinite(pe)||pe<0)return null;const Te=$n({stroke:Ce.inlineStyle?.stroke??"black",strokeWidth:Ce.inlineStyle?.["stroke-width"]??String(K.groupLineWidth??et.innerBox)},true);if(Te===void 0)return null;if(pe>0&&Me(Ce.x-Te,Ce.y-Te,Ce.width+2*Te,pe+2*Te))return null}for(const Ce of n.edges){const pe=Ce===d?{...Ce,points:Y}:Ce;const Te=sd(pe,r);if(!Te||Te.some(Be=>!Be.bounds||Me(Be.bounds.x0,Be.bounds.y0,Be.bounds.x1-Be.bounds.x0,Be.bounds.y1-Be.bounds.y0)))return null;if(Ce===Z.edge||!Ce.label)continue;const Fe=ae.get(Ce)??Ce.labelPosition;if(!Fe)continue;const De=Q(Ce,Fe);if(!De||Me(De.x,De.y,De.w,De.h))return null}}return te};const T=(D,B)=>{const Y=Math.max(Math.min(B.desired,B.clear),8);const W=B.d;const O=(()=>{switch(D){case"W":return[{x:u.x,y:h-W},{x:u.x-Y,y:h-W},{x:u.x-Y,y:h+W},{x:u.x,y:h+W}];case"E":return[{x:u.x+u.width,y:h-W},{x:u.x+u.width+Y,y:h-W},{x:u.x+u.width+Y,y:h+W},{x:u.x+u.width,y:h+W}];case"N":return[{x:f-W,y:u.y},{x:f-W,y:u.y-Y},{x:f+W,y:u.y-Y},{x:f+W,y:u.y}];default:return[{x:f-W,y:u.y+u.height},{x:f-W,y:u.y+u.height+Y},{x:f+W,y:u.y+u.height+Y},{x:f+W,y:u.y+u.height}]}})();const N=si(si(O,u,true),u,false);const H=Ds(d,N,n.edges,r);if(H){i?.push(H);return null}const j=L(D,Y,N);return j?{points:N,labels:j}:null};let A=null;let $=null;let _=null;let z=[];const F=S.map((D,B)=>({side:D,preference:B,rank:M(D)})).sort((D,B)=>D.rank-B.rank||D.preference-B.preference).map(D=>D.side);for(const D of F){if(!E(D))continue;const B=v(D);if(B.clear<Math.min(B.desired,14))continue;const Y=T(D,B);if(!Y)continue;A=D;$=B;_=Y.points;z=Y.labels;break}if(!A||!$||!_){const D=F.filter(E);if(D.length===0)return null;const B=D.reduce((O,N)=>v(N).clear>v(O).clear?N:O,D[0]);const Y=v(B);const W=T(B,Y);if(!W)return null;A=B;$=Y;_=W.points;z=W.labels}o.set(R(A),M(A)+1);Si(n,d,_);const G=R(A);const I=a.get(G)??[];for(const D of z){D.edge.labelPosition=D.position;const B=Pt(D.edge,r);if(D.rectIndex!==void 0)s[D.rectIndex]=B;else{const Y=s.push(B)-1;I.push({edge:D.edge,rectIndex:Y})}}if(z.length)a.set(G,I);return A};return c}function of(e){return e.routeCertificate?.invariant==="bundle"&&Ta(e)}function HR(e){return e.some((t,n)=>n>0&&Math.abs(t.x-e[n-1].x)>$e&&Math.abs(t.y-e[n-1].y)>$e)}function HS(e,t=false){e.invariant="straight";e.bendCount=0;e.directLaneClear=true;if(t)e.straightened=true;e.directLaneBlockedBy=void 0}function kp(e,t,n,i,r){const o=Ea(t);const{axis:s,ctx:a}=FS(e,t,i,o,M=>n.has(M)&&Ta(M),Boolean(r?.preserveLabels));a.fixedLabels=Boolean(r?.preserveLabels);const l=Ra(e.nodes);const c=YS(e.groups);const d=[];let u;const f=(M,P)=>{const E=P.routeClass==="feedback"?{...s,sign:s.sign===1?-1:1}:s;const v=l.get(M.source);const L=l.get(M.target);const T=v&&L&&eo(v)&&eo(L)&&(P.routeClass==="feedback"||Zu(IS(M.points),E));if(!T){P.invariant=GS(M,P.routeClass,v,L,a.axis)??"unverified-shape";return{applied:false,mutated:false}}if(r?.preserveStraightRoutes&&M.points.length===2){const I=M.points[0],D=M.points[1],B=s.main,Y=s.cross;if(I[Y]===D[Y]&&bi(M,v,L)===0&&!Ui(M,I[Y],Math.min(I[B],D[B]),Math.max(I[B],D[B]),a,E)){HS(P);return{applied:true,mutated:false}}}const A=a.sideUse?.get(`${v.id}:${xr(E,1)}`)??1;const $=P.routeClass==="primary-forward"&&Nr(v)&&A===1&&Gl(v)>=Gl(L);const _=JSON.stringify(M.points);if($){const I=v[E.cross]+(E.cross==="y"?v.height:v.width)/2;const D=jl(M,v,L,a,E,I);if(D.applied){const B=JSON.stringify(M.points)!==_;HS(P,B);return{applied:true,mutated:B}}if(b(M,v,L,a,E)||g(M,v,L,a,E,true)){P.invariant="explained-detour";P.directLaneClear=false;P.directLaneBlockedBy=Sp(D.blockers);P.bendCount=ai(M.points);return{applied:false,mutated:JSON.stringify(M.points)!==_}}}const z=zS(M,v,L,a,E);if(z&&g(M,v,L,a,E,false,{sourceLane:z.sourceLane,targetLane:z.targetLane,preferSourceJog:true})){P.invariant="explained-detour";P.directLaneClear=false;P.directLaneBlockedBy=[{kind:"port",id:Ti(M)}];P.bendCount=ai(M.points);return{applied:false,mutated:JSON.stringify(M.points)!==_}}const F=jl(M,v,L,a,E);if(F.applied){const I=JSON.stringify(M.points)!==_;HS(P,I);return{applied:true,mutated:I,upgradeable:(F.usedCandidateIndex??0)>0}}P.invariant=GS(M,P.routeClass,v,L,a.axis)??"explained-detour";P.directLaneClear=false;P.directLaneBlockedBy=F.blockers;let G=false;if(P.invariant==="outer-feedback"||P.invariant==="feedback-detour"){if(P.invariant==="outer-feedback"){G=zR(M,a,l);P.bendCount=ai(M.points)}if(Hl(M,a)&&g(M,v,L,a,E)){P.bendCount=ai(M.points);G=true}}else if(P.invariant==="explained-detour"&&(P.bendCount>2||HR(M.points)||Hl(M,a)||!Vn(v,M.points[0])||!Vn(L,M.points[M.points.length-1]))){const I=g(M,v,L,a,E)||y(M,v,L,a,E);if(p(M,L,a,E)||I){P.bendCount=ai(M.points);G=true}}return{applied:false,mutated:G}};const h=(M,P,E)=>a.edges.some(v=>v!==M&&v.target===M.target&&v.points.length>1&&Math.abs(v.points.at(-1)[E.cross]-P)<=pn&&!Mo(M,v));const m=(M,P,E)=>h(M,P,E)||a.edges.some(v=>{if(v===M||v.target!==M.target||v.source===M.target||Mo(M,v))return false;const L=l.get(v.source);return L!==void 0&&Math.abs(L[E.cross]+(E.cross==="y"?L.height:L.width)/2-P)<=pn});function p(M,P,E,v){if(M.points.length<3||!E.edges.some(W=>W!==M&&W.target===M.target))return false;const L=Ft(P);const T=L[xr(v,-1)];if(!m(M,T[v.cross],v))return false;const A=P[v.cross],$=A+(v.cross==="y"?P.height:P.width);let _=-1;for(let W=M.points.length-1;W>0&&_<0;W--){const O=M.points[W-1],N=M.points[W],H=N[v.cross];if(Math.abs(O[v.cross]-H)<=$e&&Math.abs(O[v.main]-N[v.main])>$e&&(H<=A-en||H>=$+en))_=W}if(_<1)return false;const z=M.points[_][v.cross];const F=v.cross==="y"?z<A?"N":"S":z<A?"W":"E";const G=L[F];const I=M.points[_-1];if((G[v.main]-I[v.main])*Math.sign(M.points[_][v.main]-I[v.main])<=$e)return false;const D={...M,points:[],label:void 0};if(Ui(D,z,Math.min(I[v.main],G[v.main]),Math.max(I[v.main],G[v.main]),E,v))return false;const B=od(v,z,G[v.cross]);if(Ui(D,G[v.main],Math.min(z,G[v.cross]),Math.max(z,G[v.cross]),E,B))return false;const Y=xt([...M.points.slice(0,_),Ln(v,G[v.main],z),G]);if(ai(Y)>ai(M.points)||dd(Y,M,E)||!$r(M,Y,E.edges,E.style))return false;if(M.label){let W;for(let N=1;N<Y.length;N++){const H=Math.abs(Y[N].x-Y[N-1].x)+Math.abs(Y[N].y-Y[N-1].y);if(!W||H>Math.abs(W[1].x-W[0].x)+Math.abs(W[1].y-W[0].y))W=[Y[N-1],Y[N]]}const O=W&&ir(M,W[0],W[1],E);if(!O)return false;M.labelPosition=O}Si(E,M,Y);return true}function g(M,P,E,v,L,T=false,A){if(M.points.length<2)return false;const $=qo(P,L,1);const _=qo(E,L,-1);if(!$||!_)return false;const z=M.points.map(Z=>Z[L.cross]);const F=[];const G=[];const I=(Z,se)=>{if(Z.every(oe=>Math.abs(oe-se)>.5))Z.push(se)};if(A?.sourceLane!==void 0){I(F,A.sourceLane)}else{I(F,P[L.cross]+(L.cross==="y"?P.height:P.width)/2);if(!T){I(F,M.points[0][L.cross]);for(const Z of z)I(F,Z)}}if(A?.targetLane!==void 0){I(G,A.targetLane)}else{const Z=E[L.cross]+(L.cross==="y"?E.height:E.width)/2;const se=v.edges.some(oe=>{if(oe===M||oe.target!==M.target||oe.source===M.target||Mo(M,oe))return false;const de=l.get(oe.source);return de!==void 0&&Math.abs(de[L.cross]+(L.cross==="y"?de.height:de.width)/2-Z)<=pn});if(se)I(G,M.points[M.points.length-1][L.cross]);I(G,Z);I(G,M.points[M.points.length-1][L.cross]);if(h(M,Z,L))for(const oe of[Pa,-Pa])I(G,Z+oe)}const D=Z=>{const se=Z[L.main];return[se,se+(L.main==="x"?Z.width:Z.height)]};const[B,Y]=D(P);const[W,O]=D(E);const N=Math.min(B,Y,W,O);const H=Math.max(B,Y,W,O);const j=(Z,se)=>{if(!se)return;for(const oe of v.nodes){if(oe.id===M.source||oe.id===M.target)continue;const[de,xe]=D(oe);if(xe<=N+$e||de>=H-$e)continue;const Me=oe[L.cross];const Ce=Me+(L.cross==="y"?oe.height:oe.width);for(const pe of[Me-en-$e,Ce+en+$e]){if(pe>=se.lo-$e&&pe<=se.hi+$e)I(Z,pe)}}};j(F,A?.sourceLane===void 0?$:null);j(G,A?.targetLane===void 0?_:null);const q=(Z,se)=>Nr(Z)?{lo:Z[L.cross]+2,hi:Z[L.cross]+(L.cross==="y"?Z.height:Z.width)-2}:se;const X=q(P,$);const V=q(E,_);const ee=!A?.requireFewerCrossings&&Hl(M,v);let re=null;const U={...M,points:[],label:void 0};let te;const J=!Gr();let ae;const Q=Yi(v.style,M,"start"),K=Yi(v.style,M,"end");for(const Z of G){if(Z<V.lo-$e||Z>V.hi+$e)continue;const se=to(E,Z,L,-1);if(se===null)continue;for(let oe=0;oe<F.length;oe++){const de=F[oe];if(de<X.lo-$e||de>X.hi+$e)continue;if(Math.abs(de-Z)<en)continue;const xe=to(P,de,L,1);if(xe===null)continue;if(A?.requireFewerCrossings&&(xe!==(L.sign===1?Y:B)||se!==(L.sign===1?W:O)))continue;if((se-xe)*L.sign<=$e)continue;const Me=A?.preferSourceJog?[xe+L.sign*Q,(xe+se)/2,se-L.sign*K]:[se-L.sign*K,(xe+se)/2,xe+L.sign*Q];for(let Ce=0;Ce<Me.length;Ce++){const pe=Me[Ce];if((pe-xe)*L.sign<=$e||(se-pe)*L.sign<=$e)continue;const Te=Math.abs(pe-xe)>=Math.abs(se-pe);const Fe=J?(oe*3+Ce)*2+Number(Te):0;const De=J?ae?.[Fe]:void 0;let Be;if(De&&Object.is(De.jog,pe))Be=De.blocked;else{Be=Ui(Te?M:U,de,Math.min(xe,pe),Math.max(xe,pe),v,L);if(J){if(De){De.jog=pe;De.blocked=Be}else(ae??=[])[Fe]={jog:pe,blocked:Be}}}if(Be)continue;const me=od(L,de,Z);if(Ui(U,pe,Math.min(de,Z),Math.max(de,Z),v,me))continue;if(Ui(Te?U:M,Z,Math.min(pe,se),Math.max(pe,se),v,L))continue;const he=[Ln(L,xe,de),Ln(L,pe,de),Ln(L,pe,Z),Ln(L,se,Z)];const fe=Te?[he[0],he[1]]:[he[2],he[3]];let be=null;if(M.label){be=ir(M,fe[0],fe[1],v);if(!be){const ne=Te?ir(M,he[2],he[3],v):ir(M,he[0],he[1],v);if(ne&&!Ui(M,Te?Z:de,Math.min(Te?pe:xe,Te?se:pe),Math.max(Te?pe:xe,Te?se:pe),v,L))be=ne}if(!be&&!(ee&&!re))continue}if(!$r(M,he,v.edges,v.style))continue;const ge=Number(Boolean(Vn(P,M.points[0])))+Number(Boolean(Vn(E,M.points.at(-1))));const Re=Number(Boolean(Vn(P,he[0])))+Number(Boolean(Vn(E,he.at(-1))));te??=ee?0:br(M.points,M,v);const Ie=ee?0:br(he,M,v,te);if(!ee&&Ie>te)continue;if(A?.requireFewerCrossings&&Ie>=te)continue;if(!ee&&Ie>=te&&bi({...M,points:he},P,E)>=bi(M,P,E)&&(ai(he)>ai(M.points)||ai(he)===ai(M.points)&&Re<ge))continue;if(M.label){if(!be){if(ee&&!re){re={route:he,labelMid:{x:(fe[0].x+fe[1].x)/2,y:(fe[0].y+fe[1].y)/2}}}continue}M.labelPosition=be}Si(v,M,he);return true}}}if(re){Si(v,M,re.route);if(M.label)M.labelPosition=re.labelMid;return true}return false}function y(M,P,E,v,L){if(!Hl(M,v))return false;const T=qo(P,L,1);const A=qo(E,L,-1);if(!T||!A)return false;const $={...M,points:[],label:void 0};const _=V=>L.cross==="y"?V.height:V.width;const z=V=>L.main==="x"?V.width:V.height;const F=P[L.cross]+_(P)/2;const G=to(P,F,L,1);const I=E[L.cross]+_(E)/2;const D=to(E,I,L,-1);if(G===null||D===null)return false;if(Math.abs(F-T.lo)>$e&&Math.abs(F-T.hi)>$e&&(F<T.lo-$e||F>T.hi+$e))return false;const B=[];for(const V of v.nodes){if(V.id===M.source||V.id===M.target)continue;const ee=V[L.main],re=ee+z(V);const U=(ee-G)*L.sign>$e||(re-G)*L.sign>$e;const te=(D-ee)*L.sign>$e||(D-re)*L.sign>$e;if(!U||!te)continue;const J=L.sign>0?ee:re;B.push({mainNear:J,crossLo:V[L.cross],crossHi:V[L.cross]+_(V)})}const Y=B.filter(V=>F>V.crossLo-en&&F<V.crossHi+en);if(Y.length===0)return false;const W=Y.reduce((V,ee)=>(ee.mainNear-G)*L.sign<(V-G)*L.sign?ee.mainNear:V,Y[0].mainNear);if((W-G)*L.sign<=en)return false;const O=G+(W-G)/2;const N=[I];if(h(M,I,L))N.push(I+Pa,I-Pa);const H=[];const j=V=>{if(H.every(ee=>Math.abs(ee-V)>.5))H.push(V)};for(const V of B){j(V.crossLo-en-$e);j(V.crossHi+en+$e)}const q=[...B].sort((V,ee)=>V.crossLo-ee.crossLo);for(let V=1;V<q.length;V++){const ee=q[V-1].crossHi,re=q[V].crossLo;if(re-ee>2*en)j((ee+re)/2)}H.sort((V,ee)=>Math.abs(V-F)-Math.abs(ee-F));let X=null;for(const V of N){if(V<A.lo-$e||V>A.hi+$e)continue;const ee=to(E,V,L,-1);if(ee===null)continue;const re=ee-L.sign*Yi(v.style,M,"end");if((re-O)*L.sign<=$e)continue;for(const U of H){if(Math.abs(U-F)<en)continue;if(Ui($,F,Math.min(G,O),Math.max(G,O),v,L))continue;if(Ui($,O,Math.min(F,U),Math.max(F,U),v,od(L,F,U)))continue;if(Ui($,U,Math.min(O,re),Math.max(O,re),v,L))continue;if(Ui($,re,Math.min(U,V),Math.max(U,V),v,od(L,U,V)))continue;if(Ui($,V,Math.min(re,ee),Math.max(re,ee),v,L))continue;const te=xt([Ln(L,G,F),Ln(L,O,F),Ln(L,O,U),Ln(L,re,U),Ln(L,re,V),Ln(L,ee,V)]);if(!$r(M,te,v.edges,v.style))continue;const J=[Ln(L,O,U),Ln(L,re,U)];if(M.label){const ae=ir(M,J[0],J[1],v);if(ae){M.labelPosition=ae;Si(v,M,te);return true}if(!X)X={route:te,labelMid:{x:(J[0].x+J[1].x)/2,y:(J[0].y+J[1].y)/2}};continue}Si(v,M,te);return true}}if(X){Si(v,M,X.route);if(M.label)M.labelPosition=X.labelMid;return true}return false}function b(M,P,E,v,L){if(M.points.length<2)return false;const T=P[L.cross]+(L.cross==="y"?P.height:P.width)/2;const A=E[L.cross];const $=A+(L.cross==="y"?E.height:E.width);let _;if(T<A-$e)_=L.cross==="y"?"N":"W";else if(T>$+$e)_=L.cross==="y"?"S":"E";else return false;const z=Ft(E)[_][L.cross];if(Math.abs(z-T)<MR)return false;const F=Ft(E)[xr(L,-1)];const G=v.edges.some(O=>O!==M&&O.target===M.target&&O.source!==M.source&&O.points.length>0&&Mo(M,O)&&Math.abs(O.points[O.points.length-1].x-F.x)<=pn&&Math.abs(O.points[O.points.length-1].y-F.y)<=pn);if(G)return false;const I=Ft(E)[_][L.main];const D=to(P,T,L,1);if(D===null)return false;if((I-D)*L.sign<=$e)return false;const B={...M,points:[],label:void 0};if(Ui(M,T,Math.min(D,I),Math.max(D,I),v,L))return false;const Y=od(L,T,z);if(Ui(B,I,Math.min(T,z),Math.max(T,z),v,Y))return false;const W=[Ln(L,D,T),Ln(L,I,T),Ln(L,I,z)];if(!$r(M,W,v.edges,v.style))return false;if(!Hl(M,v)&&dd(W,M,v))return false;if(M.label){const O=ir(M,W[0],W[1],v);if(!O)return false;M.labelPosition=O}Si(v,M,W);return true}const S=[];const x=GR(l,c,a,S);const k=[];for(const M of e.edges){const P=n.has(M)?zl(M):void 0;let E=xt(IS(M.points));const v=l.get(M.source),L=l.get(M.target);if(v)E=wa(E,v,true);if(L)E=wa(E,L,false);if($r(M,E,a.edges,a.style))Si(a,M,E);La(M,P);const T=M.edgeIndex??-1;const A=o[T]??"primary-forward";const $={edgeIndex:T,routeClass:A,bendCount:ai(M.points),invariant:"straight"};if(n.has(M)&&Ta(M)){$.invariant="bundle"}else if(A==="self-loop"){let _;if(r?.preserveSelfLoops){const F=l.get(M.source);const G=(W,O)=>{if(Math.abs(W.x-O.x)<=$e&&Math.abs(W.y-O.y)>$e)return O.y>W.y?"S":"N";if(Math.abs(W.y-O.y)<=$e&&Math.abs(W.x-O.x)>$e)return O.x>W.x?"E":"W";return void 0};const I=M.points[0],D=M.points.at(-1);const B=I&&M.points.find(W=>Math.hypot(W.x-I.x,W.y-I.y)>$e);const Y=D&&[...M.points].reverse().find(W=>Math.hypot(W.x-D.x,W.y-D.y)>$e);_=F&&I&&D&&B&&Y&&Math.hypot(I.x-D.x,I.y-D.y)>=8&&G(I,B)===G(D,Y)?G(I,B):void 0}S.length=0;const z=_??x(M);if(z){$.invariant="self-loop";$.loopSide=z;$.bendCount=ai(M.points)}else{$.invariant="explained-detour";if(S.length)$.directLaneBlockedBy=[...S]}}else if(A==="container"){$.invariant="container-attach";const _=qG(M,c,l);if(_){const z=jl(M,_.source,_.target,a,_.axis).applied;const F=!z&&(u??=Ca(t)&&!Gr()&&!e.edges.some(G=>G.label))&&br(M.points,M,a)>0&&g(M,_.source,_.target,a,_.axis,false,{requireFewerCrossings:true});if(z||F){$.bendCount=ai(M.points);if(z){$.directLaneClear=true;$.straightened=true}}}}else if(A==="primary-forward"||A==="feedback"){if($.bendCount>0){const _=f(M,$);if(!_.applied||_.upgradeable)k.push({edge:M,cert:$})}else{const _=l.get(M.source);const z=l.get(M.target);const F=!M.label&&M.edgeIndex!==void 0&&e.edges.some(D=>D!==M&&D.source===M.target&&D.target===M.source&&!D.label&&D.edgeIndex!==void 0);const[G,I]=[M.points[0],M.points[M.points.length-1]];if(_&&z&&(HR(M.points)||!Vn(_,G)||!Vn(z,I)||bi(M,_,z)>0||Hl(M,a)||F)){const D=f(M,$);if(!D.applied||D.upgradeable)k.push({edge:M,cert:$})}}}d.push({edge:M,cert:$})}for(let M=0;M<4&&k.length>0;M++){const P=[];let E=false;for(const v of k){if(v.cert.invariant==="unverified-shape")continue;const L=f(v.edge,v.cert);if(L.mutated)E=true;if(!L.applied||L.upgradeable)P.push(v)}if(!E)break;k.length=0;k.push(...P)}for(const M of e.edges){const P=n.has(M)?zl(M):void 0;const E=l.get(M.source);const v=l.get(M.target);if(E)WS(M,E,true,a);if(v)WS(M,v,false,a);let L=M.points;if(E)L=wa(L,E,true);if(v)L=wa(L,v,false);if($r(M,L,a.edges,a.style))Si(a,M,L);La(M,P)}const w=[];const C=cp(e,t,o);const R=(M,P)=>{const E=ai(M.points);const v=l.get(M.source);const L=l.get(M.target);const T=C.byEdge.get(M);const A={edgeIndex:P.edgeIndex,routeClass:P.routeClass,bendCount:E,directLaneClear:P.directLaneClear,directLaneBlockedBy:P.directLaneBlockedBy,sourcePort:v&&M.points.length>0?Vn(v,M.points[0]):void 0,targetPort:L&&M.points.length>0?Vn(L,M.points[M.points.length-1]):void 0,sourcePortAssignment:T?.source,targetPortAssignment:T?.target,...P.loopSide!==void 0?{loopSide:P.loopSide}:{}};if(P.invariant==="straight"&&E===0&&M.points.length===2){return{...A,invariant:"straight",...P.straightened?{straightened:true}:{}}}return{...A,invariant:P.invariant==="straight"?"explained-detour":P.invariant}};for(const{edge:M,cert:P}of d){const E=R(M,P);M.routeCertificate=E;w.push(E)}return w}function Os(e,t,n,i){if(!t){e.routeCertificate=void 0;return}const r={edgeIndex:t.edgeIndex,routeClass:t.routeClass,bendCount:ai(e.points),directLaneClear:t.directLaneClear,directLaneBlockedBy:t.directLaneBlockedBy,sourcePort:n&&e.points.length>0?Vn(n,e.points[0]):t.sourcePort,targetPort:i&&e.points.length>0?Vn(i,e.points[e.points.length-1]):t.targetPort,sourcePortAssignment:t.sourcePortAssignment,targetPortAssignment:t.targetPortAssignment,...t.loopSide!==void 0?{loopSide:t.loopSide}:{}};if(e.points.length===2&&ai(e.points)===0){e.routeCertificate={...r,invariant:"straight"};return}e.routeCertificate={...r,invariant:t.invariant==="straight"||t.invariant==="bundle"&&!Ta(e)?"explained-detour":t.invariant}}function jR(e,t,n=Xe({})){return YR(e,t,n,false)}function YR(e,t,n,i){const r=[];for(const u of e.edges){if(u.edgeIndex!==void 0&&u.routeCertificate)r[u.edgeIndex]=u.routeCertificate.routeClass}const{axis:o,ctx:s}=FS(e,t,n,r,of,true);const a=Ra(e.nodes);const l=s.sideUse;const c=[];const d=new Set;for(const u of e.edges){const f=u.routeCertificate;if(!f||of(u))continue;if(f.routeClass!=="primary-forward"&&f.routeClass!=="feedback")continue;const h=f.routeClass==="feedback"?{...o,sign:o.sign===1?-1:1}:o;const m=xt(u.points);if(m.length<=2)continue;const p=a.get(u.source);const g=a.get(u.target);if(!p||!g)continue;if(!eo(p))continue;if(!eo(g))continue;if(f.routeClass!=="feedback"&&!Zu(m,h))continue;const y=zS(u,p,g,s,h);if(y&&DR(u,p,g,y))continue;const b=l.get(`${u.source}:${xr(h,1)}`)??1;const S=f.routeClass==="primary-forward"&&Nr(p)&&b===1&&Gl(p)>=Gl(g);const x=S?p[h.cross]+(h.cross==="y"?p.height:p.width)/2:void 0;const k=i?u:{...u,points:m.map(C=>({...C}))};const w=jl(k,p,g,s,h,x,u);if(w.applied){c.push({edge:Ti(u),deviationPx:Math.round(kR(m,h)*10)/10});if(i)d.add(u)}}if(d.size>0){const u=cp(e,t,r);for(const f of d){const h=f.routeCertificate;if(!h||f.points.length!==2||ai(f.points)!==0)continue;const m=a.get(f.source);const p=a.get(f.target);const g=u.byEdge.get(f);f.routeCertificate={edgeIndex:h.edgeIndex,routeClass:h.routeClass,invariant:"straight",bendCount:0,directLaneClear:true,sourcePort:m?Vn(m,f.points[0]):void 0,targetPort:p?Vn(p,f.points[1]):void 0,sourcePortAssignment:g?.source,targetPortAssignment:g?.target,straightened:true}}}return c}function qG(e,t,n){const i=c=>{const d=t.get(c);if(d)return{id:c,label:"",shape:"rectangle",x:d.x,y:d.y,width:d.width,height:d.height};const u=n.get(c);if(u&&eo(u))return u;return null};const r=i(e.source);const o=i(e.target);if(!r||!o)return null;const s=xt(e.points);if(s.length===2&&jS(s[0],r.x,r.y,r.width,r.height,1)&&jS(s[1],o.x,o.y,o.width,o.height,1)){return null}const a=[{gap:o.y-(r.y+r.height),axis:{main:"y",cross:"x",sign:1}},{gap:r.y-(o.y+o.height),axis:{main:"y",cross:"x",sign:-1}},{gap:o.x-(r.x+r.width),axis:{main:"x",cross:"y",sign:1}},{gap:r.x-(o.x+o.width),axis:{main:"x",cross:"y",sign:-1}}];const l=a.filter(c=>c.gap>$e).sort((c,d)=>d.gap-c.gap)[0];if(!l)return null;return{source:r,target:o,axis:l.axis}}function jS(e,t,n,i,r,o){const s=(Math.abs(e.x-t)<=o||Math.abs(e.x-(t+i))<=o)&&e.y>=n-o&&e.y<=n+r+o;const a=(Math.abs(e.y-n)<=o||Math.abs(e.y-(n+r))<=o)&&e.x>=t-o&&e.x<=t+i+o;return s||a}function YS(e,t=new Map){for(const n of e){t.set(n.id,n);YS(n.children,t)}return t}var XG=Symbol("label-seat-sort-denied");function wp(e,t){if(t&&!t(1))return void 0;const n=[];for(let r=1;r<e.points.length;r++){if(t&&!t(2))return void 0;const o=e.points[r-1],s=e.points[r];const a=Math.abs(o.x-s.x)<$e;if(a||Math.abs(o.y-s.y)<$e){if(t&&!t(12))return void 0;n.push({a:o,b:s,vertical:a,len:Math.abs(o.x-s.x)+Math.abs(o.y-s.y),i:r})}}if(t&&!t(n.length*2+1))return void 0;const i=XG;try{n.sort((r,o)=>{if(t&&!t(4))throw i;return o.len-r.len||r.i-o.i})}catch(r){if(r===i)return void 0;throw r}return n}function fd(e,t){t?.();const n=[];const i=11;for(let r=0;r<i;r++){t?.();n.push(e+(1-2*e)*(r/(i-1)))}return n.sort((r,o)=>{t?.();return Math.abs(r-.5)-Math.abs(o-.5)})}function Mp(e,t){return Ri(e,t.lineWidth??1)}function Yl(e,t,n){n?.();let i;const r=(a,l)=>l.some(c=>{n?.();const d=c.concurrencyRegion?0:c.headerHeight??c.height;return d>0&&a.x<c.x+c.width&&a.x+a.w>c.x&&a.y<c.y+d&&a.y+a.h>c.y||r(a,c.children)});const o=a=>{const l=Gr()?e.edges.flatMap(c=>{n?.();return yr(c,t)}):i??=e.edges.flatMap(c=>{n?.();return yr(c,t)});for(const c of l){n?.();const d=c.bounds;if(d&&a.x<d.x1&&a.x+a.w>d.x0&&a.y<d.y1&&a.y+a.h>d.y0)return true}return false};const s=(a,l,c)=>{n?.();const d={x:a.x-l,y:a.y-l,w:a.w+2*l,h:a.h+2*l};const u=t.lineWidth??1;const f=nd(c,u,"start")-l,h=nd(c,u,"end")-l;if(e.nodes.some(m=>{n?.();const p=Math.max(0,m.id===c.source?f:0,m.id===c.target?h:0);return d.x<m.x+m.width+p&&d.x+d.w+p>m.x&&d.y<m.y+m.height+p&&d.y+d.h+p>m.y})||r(d,e.groups)||o(d))return void 0;return d};return{overlapsMarker:o,clearPaintRect:s}}function qR(e,t,n){let i;for(const r of e.edges){if(!r.label||!r.labelPosition||r.points.length<2)continue;if(!Aa(r,e.edges,n))continue;const o=i??=Yl(e,n);const s=Mp(r,n);const a=r.labelBlock??ji(qe(r.label,r.labelContent),n);const l=a.width+2*on,c=a.height+2*on;const d=wp(r);const u=r.labelPosition;let f=false;const h=Math.min(l,c)/2-1;for(const m of[0,h,-h]){if(f)break;for(const p of d){if(f)break;const g=(p.vertical?c:l)/2;if(p.len<=2*g)continue;const y=g/p.len;for(const b of[5,4,6,3,7,2,8,1,9,0,10]){const S=y+(1-2*y)*(b/10);const x=p.a.x+(p.b.x-p.a.x)*S+(p.vertical?m:0);const k=p.a.y+(p.b.y-p.a.y)*S+(p.vertical?0:m);r.labelPosition={x,y:k};if(o.clearPaintRect(Ma(x,k,a),s,r)&&!Aa(r,e.edges,n)){f=true;break}}}}if(!f)r.labelPosition=u}}function Cp(e,t,n){const i=(o,s,a)=>{const l=a.x-s.x,c=a.y-s.y,d=l*l+c*c;if(d===0)return Math.hypot(o.x-s.x,o.y-s.y);const u=Math.max(0,Math.min(1,((o.x-s.x)*l+(o.y-s.y)*c)/d));return Math.hypot(o.x-(s.x+u*l),o.y-(s.y+u*c))};let r;for(const o of e.edges){if(!o.label||!o.labelPosition||o.points.length<2)continue;if(o.source===o.target)continue;const s=o.labelBlock??ji(qe(o.label,o.labelContent),n);const a=s.width+2*on,l=s.height+2*on;const c=l/2+4;const d=g=>{let y=Infinity;for(let b=1;b<o.points.length;b++)y=Math.min(y,i(g,o.points[b-1],o.points[b]));return y};if(d(o.labelPosition)<=c)continue;const u=r??=Yl(e,n);const f=Mp(o,n);const h=(g,y)=>d({x:g,y})<=c&&!!u.clearPaintRect(Ma(g,y,s),f,o)&&!Aa(o,e.edges,n,{x:g,y});const m=wp(o);let p=false;for(const g of m){if(p)break;const y=(g.vertical?l:a)/2;if(g.len<=2*y)continue;const b=y/g.len;const S=fd(b);for(const x of S){const k=g.a.x+(g.b.x-g.a.x)*x;const w=g.a.y+(g.b.y-g.a.y)*x;if(h(k,w)){o.labelPosition={x:k,y:w};p=true;break}}}if(!p){let g=o.points[0],y=Infinity;for(const k of m.length?m:[]){const w=k.b.x-k.a.x,C=k.b.y-k.a.y,R=w*w+C*C||1;const M=Math.max(0,Math.min(1,((o.labelPosition.x-k.a.x)*w+(o.labelPosition.y-k.a.y)*C)/R));const P=k.a.x+M*w,E=k.a.y+M*C,v=Math.hypot(o.labelPosition.x-P,o.labelPosition.y-E);if(v<y){y=v;g={x:P,y:E}}}const b=y>$e?(o.labelPosition.x-g.x)/y:0;const S=y>$e?(o.labelPosition.y-g.y)/y:-1;const x=c-1;for(const k of[1,-1]){const w=g.x+b*x*k,C=g.y+S*x*k;if(h(w,C)){o.labelPosition={x:w,y:C};break}}}}}function XR(e,t,n){if(Math.abs(e.x-t.x)<=$e){return e.x>n.x+$e&&e.x<n.x+n.w-$e&&Math.min(Math.max(e.y,t.y),n.y+n.h)-Math.max(Math.min(e.y,t.y),n.y)>$e}if(Math.abs(e.y-t.y)<=$e){return e.y>n.y+$e&&e.y<n.y+n.h-$e&&Math.min(Math.max(e.x,t.x),n.x+n.w)-Math.max(Math.min(e.x,t.x),n.x)>$e}return false}function sf(e,t,n=Xe({}),i){let r=1e6;const o=e.edges.filter(m=>m.label&&m.labelPosition&&m.points.length>=2);if(o.length===0)return;const s=m=>{const p=Pt(m,n);const g=Mp(m,n);return p&&{x:p.x-g,y:p.y-g,w:p.w+2*g,h:p.h+2*g}};const a=(m,p)=>Math.min(m.x+m.w,p.x+p.w)-Math.max(m.x,p.x)>.5&&Math.min(m.y+m.h,p.y+p.h)-Math.max(m.y,p.y)>.5;const{overlapsMarker:l,clearPaintRect:c}=Yl(e,n);const d=function*(m,p,g=false,y,b=true){if(y&&!y.pay(16))return;const S=m.labelBlock??ji(qe(m.label,m.labelContent),n);const x=S.width+2*on,k=S.height+2*on;const w=Mp(m,n);const C=(E,v,L)=>{if(y)return y.pay(3)&&y.clear({x:E,y:v});if(i?.preserveRouteClearance&&r<=0)return false;const T=c(Ma(E,v,S),w,m);if(!T)return false;for(const A of p){const $=s(A);if($&&a(T,$))return false}if(Aa(m,e.edges,n,{x:E,y:v}))return false;if(i?.preserveRouteClearance||L)for(const A of e.edges){if(A===m||A.style==="invisible")continue;for(let $=1;$<A.points.length;$++){if(i?.preserveRouteClearance&&--r<0)return false;if(Ku(A.points[$-1],A.points[$],T))return false}}return true};const R=y?wp(m,y.pay):wp(m);if(!R)return;const M=k/2+4;const P=[M-1,-(M-1),(M-1)/2,-(M-1)/2];for(const[E,v]of[[0,false],...P.map(L=>[L,true]),...b?P.map(L=>[L,false]):[]]){for(const L of R){const T=(L.vertical?k:x)/2;if(!g&&L.len<=2*T)continue;const A=L.vertical?1:0,$=L.vertical?0:1;const _=g?0:T/L.len;if(y&&!y.pay(160))return;const z=fd(_);for(const F of z){const G=L.a.x+(L.b.x-L.a.x)*F+A*E;const I=L.a.y+(L.b.y-L.a.y)*F+$*E;if(i?.preserveRouteClearance&&r<=0)return;if(C(G,I,v))yield{x:G,y:I}}}}};const u=(m,p,g=true)=>{for(const y of d(m,p,false,void 0,g)){m.labelPosition=y;return true}return false};const f=(m,p)=>{const g=o.filter(y=>y!==m&&y!==p);for(const y of[false,true]){const b=k=>{const w=[];for(const C of d(k,g,y)){w.push(C);if(w.length===64)break}return w};const S=b(m),x=b(p);for(const k of S)for(const w of x){const C=s({...m,labelPosition:k}),R=s({...p,labelPosition:w});if(a(C,R))continue;m.labelPosition=k;p.labelPosition=w;return true}}return false};const h=()=>{if(Gr())return;const m=y=>{if(y>r){r=0;return false}r-=y;return true};if(!m(8))return;const p=(y,b)=>{for(const S of e.edges){if(!m(1))return false;if(S===y||S.style==="invisible")continue;for(let x=1;x<S.points.length;x++){if(!m(1))return false;if(Ku(S.points[x-1],S.points[x],b))return true}}return false};let g;for(const y of o){if(!m(64+(y.label?.length??0)*12+2*e.edges.length))return;const b=s(y);if(!b||!l(b)&&!p(y,b))continue;if(!m(y.points.length+2))return;if(y.curve||(n.edgeBendRadius??0)!==0||y.points.some((E,v)=>v>0&&E.x!==y.points[v-1].x&&E.y!==y.points[v-1].y))continue;g??=fp(e.nodes,e.edges,e.groups,n,m);if(!g||!m(8))return;const S=new Set,x=new Map;const k=g;const w=(E,v,L,T)=>{if(!m(8))return void 0;const A=[],$=new Map;const _=z=>{if(E.source===E.target){if(!m(E.points.length+8))return false;const F=Pt({...E,labelPosition:z},n);if(!F||E.points.some((G,I)=>I>0&&XR(E.points[I-1],G,F)))return false}return k.clear(E,z,$,T,L)};for(const z of d(E,[],v,{clear:_,pay:m})){if(!m(1))return void 0;A.push(z);if(A.length===64)break}return r>0?A:void 0};let C=false;const R=w(y,true,void 0,S);if(!R)return;for(const E of R){if(!m(3))return;x.set(y,E);if(g.clear(y,E,x)){y.labelPosition=E;C=true;break}}if(C)continue;const M=o.filter(E=>S.has(E)&&!E.curve&&!E.points.some((v,L)=>L>0&&v.x!==E.points[L-1].x&&v.y!==E.points[L-1].y));for(const E of o){if(!m(1))return;if(!M.includes(E))continue;if(!m(E.points.length+6))return;for(const v of[false,true]){const L=w(y,v,E),T=w(E,v,y);if(!L||!T)return;e:for(const A of L)for(const $ of T){if(!m(16))return;const _=new Map([[y,A],[E,$]]);if(!g.clear(y,A,_)||!g.clear(E,$,_))continue;y.labelPosition=A;E.labelPosition=$;C=true;break e}if(C)break}if(C)break}if(C||M.length<2)continue;const P=new Set(M);for(const E of[false,true]){const v=w(y,E,P);if(!v)return;e:for(const L of v){if(!m(8+4*M.length))return;const T=new Map([[y,L]]);for(const A of M){const $=w(A,E,y);if(!$)return;const _=$.find(z=>k.clear(A,z,new Map(T).set(A,z)));if(!_)continue e;T.set(A,_)}if(![...T].every(([A,$])=>k.clear(A,$,T)))continue;for(const[A,$]of T)A.labelPosition=$;C=true;break e}if(C)break}}};for(let m=0;m<3;m++){if(i?.preserveRouteClearance&&r<=0)return;let p=0;for(const g of o){const y=s(g);if(!y||!l(y))continue;p++;u(g,o.filter(b=>b!==g),false)}for(let g=0;g<o.length;g++){for(let y=g+1;y<o.length;y++){const b=o[g],S=o[y];const x=s(b),k=s(S);if(!x||!k||!a(x,k))continue;p++;if(!u(S,o.filter(w=>w!==S))&&!u(b,o.filter(w=>w!==b)))f(b,S)}}if(p===0){h();break}if(m===2)h()}}function UG(e,t,n){const i=Ra(e);for(const r of t){const o=r.routeCertificate;let s=false;let a=r.points;for(const l of[true,false]){const c=l?[...a].reverse():a;const[d,u,f]=c.slice(-3);const h=i.get(l?r.source:r.target);if(!h||h.shape!=="rectangle"||h.semanticShape!==void 0&&h.semanticShape!=="rect"||!d||!u||!f||Math.hypot(f.x-u.x,f.y-u.y)>=1)continue;const m=(Math.abs(u.x-h.x)<$e||Math.abs(u.x-h.x-h.width)<$e)&&Math.abs(f.x-u.x)<$e&&Math.abs(d.y-u.y)<$e&&u.y>h.y&&u.y<h.y+h.height&&f.y>h.y&&f.y<h.y+h.height&&(d.x-u.x)*(u.x-h.x-h.width/2)>0;const p=(Math.abs(u.y-h.y)<$e||Math.abs(u.y-h.y-h.height)<$e)&&Math.abs(f.y-u.y)<$e&&Math.abs(d.x-u.x)<$e&&u.x>h.x&&u.x<h.x+h.width&&f.x>h.x&&f.x<h.x+h.width&&(d.y-u.y)*(u.y-h.y-h.height/2)>0;if(!m&&!p)continue;a=l?a.slice(1):a.slice(0,-1);s=true}if(s&&$r(r,a,t,n)){r.points=a;Os(r,o,i.get(r.source),i.get(r.target))}}}function Pp(e,t,n){let i;for(const r of e.edges){if(r.style==="invisible"||r.points.length<3||!r.hasArrowStart&&!r.hasArrowEnd)continue;const o=$s(r,n);if(tf(r.points,true)+1e-7>=o.start&&tf(r.points,false)+1e-7>=o.end)continue;const s=va(r.points,o);if(!s)continue;i??=Uo(e.nodes,e.edges,t.direction,n,e.groups);const{ctx:a}=i;const l=a.nodes.find(f=>f.id===r.source),c=a.nodes.find(f=>f.id===r.target);const d={...r,points:s};if(bi(d,l,c)||dd(s,r,a)||!$r(r,s,e.edges,n))continue;let u=true;for(let f=1;f<s.length&&u;f++){const h=s[f-1],m=s[f],p=rd(h.x===m.x?"TB":"LR");u=!Ui(r,h[p.cross],Math.min(h[p.main],m[p.main]),Math.max(h[p.main],m[p.main]),a,p)}if(!u)continue;r.points=s;Os(r,r.routeCertificate,l,c)}}function Ep(e,t,n){for(let i=0;i<e.edges.length;i++){if(YR(e,t,n,true).length===0)break}UG(e.nodes,e.edges,n);return e.edges.flatMap(i=>i.routeCertificate?[i.routeCertificate]:[])}function Sne(e,t,n=Xe({})){const i=[];const r=Ra(e.nodes);const o=YS(e.groups);const s=1;for(const c of e.edges){if(c.points.length<2)continue;const d=c.routeCertificate;const u=Ti(c);if(d&&(d.routeClass==="primary-forward"||d.routeClass==="feedback")){for(let f=1;f<c.points.length;f++){const h=c.points[f-1],m=c.points[f];if(Math.abs(h.x-m.x)>$e&&Math.abs(h.y-m.y)>$e){i.push({code:"ROUTE_UNEXPLAINED_BEND",edge:u});break}}}if(d?.routeClass==="container"&&d.edgeIndex>=0){const f=t.edges[d.edgeIndex];if(f){for(const[h,m]of[[f.source,c.points[0]],[f.target,c.points[c.points.length-1]]]){const p=o.get(h);if(p&&!jS(m,p.x,p.y,p.width,p.height,s)){i.push({code:"ROUTE_CONTAINER_MISANCHOR",edge:u,container:h})}}}}if(d&&d.routeClass!=="container"){for(const[f,h]of[[c.source,c.points[0]],[c.target,c.points[c.points.length-1]]]){const m=r.get(f);if(!m)continue;const p=h.x>=m.x-2&&h.x<=m.x+m.width+2&&h.y>=m.y-2&&h.y<=m.y+m.height+2;if(!p){i.push({code:"ROUTE_STALE_AFTER_NODE_MOVE",edge:u,node:f});continue}const g=ed(m,h,s);if(g.policy!=="none"&&!g.onBoundary){i.push({code:"ROUTE_SHAPE_MISANCHOR",edge:u,node:f})}}}for(const f of e.nodes){if(f.id===c.source||f.id===c.target)continue;if(ud(c.points,f))i.push({code:"ROUTE_STALE_AFTER_NODE_MOVE",edge:u,node:f.id})}if(c.label&&c.labelPosition){const f=Aa(c,e.edges,n);if(f)i.push({code:"ROUTE_LABEL_ON_SHARED_TRUNK",edge:u,sharedWith:Ti(f)})}}const a=e.edges.filter(c=>c.source===c.target);const l=(c,d,u,f)=>{const h=Math.abs(c.x-d.x)<=$e;const m=Math.abs(u.x-f.x)<=$e;if(h===m){const S=h?Math.abs(c.x-u.x)<=$e:Math.abs(c.y-u.y)<=$e;if(!S)return false;const[x,k]=h?[Math.min(c.y,d.y),Math.max(c.y,d.y)]:[Math.min(c.x,d.x),Math.max(c.x,d.x)];const[w,C]=h?[Math.min(u.y,f.y),Math.max(u.y,f.y)]:[Math.min(u.x,f.x),Math.max(u.x,f.x)];return Math.min(k,C)-Math.max(x,w)>$e}const p=h?{a:c,b:d}:{a:u,b:f};const g=h?{a:u,b:f}:{a:c,b:d};const y=p.a.x;const b=g.a.y;return y>Math.min(g.a.x,g.b.x)+$e&&y<Math.max(g.a.x,g.b.x)-$e&&b>Math.min(p.a.y,p.b.y)+$e&&b<Math.max(p.a.y,p.b.y)-$e};for(let c=0;c<a.length;c++){const d=a[c];const u=d.routeCertificate;const f=Ti(d);const h=r.get(d.source);if(!u||u.invariant!=="self-loop"||!u.loopSide){i.push({code:"ROUTE_SELF_LOOP_OCCUPANCY",edge:f,kind:"allocation"});continue}if(h&&AS.has(h.shape)){const p=d.points[0];const g=d.points[d.points.length-1];const y=b=>u.loopSide==="N"?Math.abs(b.y-h.y)<=s:u.loopSide==="S"?Math.abs(b.y-(h.y+h.height))<=s:u.loopSide==="W"?Math.abs(b.x-h.x)<=s:Math.abs(b.x-(h.x+h.width))<=s;if(!y(p)||!y(g)||Math.hypot(p.x-g.x,p.y-g.y)<8){i.push({code:"ROUTE_SELF_LOOP_OCCUPANCY",edge:f,kind:"side"})}for(let b=1;b<d.points.length;b++){const S=d.points[b-1],x=d.points[b];const k=Math.abs(S.y-x.y)<=$e&&(Math.abs(S.y-h.y)<=s||Math.abs(S.y-(h.y+h.height))<=s)&&Math.min(Math.max(S.x,x.x),h.x+h.width)-Math.max(Math.min(S.x,x.x),h.x)>$e;const w=Math.abs(S.x-x.x)<=$e&&(Math.abs(S.x-h.x)<=s||Math.abs(S.x-(h.x+h.width))<=s)&&Math.min(Math.max(S.y,x.y),h.y+h.height)-Math.max(Math.min(S.y,x.y),h.y)>$e;if(k||w){i.push({code:"ROUTE_SELF_LOOP_OCCUPANCY",edge:f,kind:"boundary"});break}}}for(let p=c+1;p<a.length;p++){const g=a[p];let y=false;for(let x=1;x<d.points.length&&!y;x++){for(let k=1;k<g.points.length;k++){if(l(d.points[x-1],d.points[x],g.points[k-1],g.points[k])){y=true;break}}}if(y)i.push({code:"ROUTE_SELF_LOOP_OCCUPANCY",edge:f,conflictWith:Ti(g),kind:"route-route"});const b=Pt(d,n);const S=Pt(g,n);if(b&&S&&b.x<S.x+S.w&&b.x+b.w>S.x&&b.y<S.y+S.h&&b.y+b.h>S.y){i.push({code:"ROUTE_SELF_LOOP_OCCUPANCY",edge:f,conflictWith:Ti(g),kind:"label-label"})}}const m=Pt(d,n);if(m){const p=a.some(g=>g.points.some((y,b)=>b>0&&XR(g.points[b-1],y,m)));if(p)i.push({code:"ROUTE_SELF_LOOP_OCCUPANCY",edge:f,kind:"label-route"})}}return i}var qS=48;function Rp(e,t=qS){return t+(e-1)*(t+40)}var ni={font:"Inter",padding:40,nodeSpacing:28,layerSpacing:qS,mergeEdges:true,thoroughness:3};function Co(e){const t=new Map;const n=[];const i=a=>{let l=t.get(a);if(l===void 0){l=n.length;t.set(a,l);n.push([])}return l};for(const a of e)n[i(a.source)].push(i(a.target));const r=new Uint32Array(n.length);const o=[];let s=0;return(a,l)=>{if(a===l)return true;const c=t.get(a),d=t.get(l);if(c===void 0||d===void 0)return false;if(++s===4294967295){r.fill(0);s=1}o.length=0;o.push(c);r[c]=s;while(o.length){const u=n[o.pop()];for(const f of u){if(f===d)return true;if(r[f]!==s){r[f]=s;o.push(f)}}}return false}}function vp(e){const t=[];for(const n of e){t.push({x:n.x,y:n.y,right:n.x+n.width,bottom:n.y+n.height});t.push(...vp(n.children))}return t}function Tp(e){let t=0;for(let n=1;n<e.length;n++){const i=e[n].x-e[n-1].x;const r=e[n].y-e[n-1].y;t+=Math.sqrt(i*i+r*r)}return t}function VG(e,t){if(e.length===0)return{point:{x:0,y:0},segmentIndex:0,pathDistance:0};if(e.length===1)return{point:e[0],segmentIndex:0,pathDistance:0};const n=Math.max(0,Math.min(Tp(e),t));let i=n;let r=0;for(let o=1;o<e.length;o++){const s=e[o].x-e[o-1].x;const a=e[o].y-e[o-1].y;const l=Math.sqrt(s*s+a*a);if(l===0)continue;if(i<=l){const c=i/l;return{point:{x:e[o-1].x+c*s,y:e[o-1].y+c*a},segmentIndex:o,pathDistance:r+i}}i-=l;r+=l}return{point:e[e.length-1],segmentIndex:e.length-1,pathDistance:r}}function sn(e){return VG(e,Tp(e)/2).point}function _t(e){if(e==="LR")return{isHorizontal:true,main:"x",cross:"y",sign:1,sourceSide:"E",targetSide:"W"};if(e==="RL")return{isHorizontal:true,main:"x",cross:"y",sign:-1,sourceSide:"W",targetSide:"E"};if(e==="BT")return{isHorizontal:false,main:"y",cross:"x",sign:-1,sourceSide:"N",targetSide:"S"};return{isHorizontal:false,main:"y",cross:"x",sign:1,sourceSide:"S",targetSide:"N"}}function XS(e){return{x:e.x+e.width/2,y:e.y+e.height/2}}function Po(e,t){const n=_t(t);return e[n.main]}function rr(e,t){const n=_t(t);return e[n.cross]}function Eo(e,t){return _t(t).isHorizontal?e.height:e.width}function hd(e,t){return _t(t).isHorizontal?e.width:e.height}function Kn(e,t){return rr(e,t)+Eo(e,t)/2}function af(e,t){return Po(e,t)+hd(e,t)/2}function Li(e,t,n=0){return e.x<t.x+t.width+n&&e.x+e.width+n>t.x&&e.y<t.y+t.height+n&&e.y+e.height+n>t.y}function ql(e,t){for(const n of e){if(n.id===t)return n;const i=ql(n.children,t);if(i)return i}return void 0}function or(e){const t=globalThis.process?.env;const n=t?.[e];return n==="1"||n==="true"}function Ia(...e){if(or("APL_DEBUG"))console.error(...e)}function US(){return{total:0,labelLabel:0,labelNode:0,labelEdge:0}}function UR(e,t){return Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x)>Bl&&Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y)>Bl}function Fa(e,t,n){const i=e.edges.flatMap((r,o)=>{if(!r.label)return[];const s=Pt(r.labelPosition?r:{...r,labelPosition:sn(r.points)},t);return s?[{edgeIndex:o,rect:s}]:[]});if(i.length===0)return US();return VR(i,e.nodes.map(r=>({x:r.x,y:r.y,w:r.width,h:r.height})),e.edges.map(r=>({points:r.points,hidden:r.style==="invisible"})),n)}function Lne(e){if(e.edges.some(i=>i.label?.text&&!i.label.bounds))return void 0;const t=e.kind==="flowchart"||e.kind==="state"?on:0;const n=e.edges.flatMap((i,r)=>{const o=i.label?.bounds;return i.label?.text&&o?[{edgeIndex:r,rect:{x:o.x-t,y:o.y-t,w:o.w+2*t,h:o.h+2*t}}]:[]});if(n.length===0)return US();return VR(n,e.nodes,e.edges.map(i=>({points:i.path.map(([r,o])=>({x:r,y:o})),hidden:i.visibility==="hidden"})))}function VR(e,t,n,i){const r=US();const o=i?e.filter(a=>i.has(a.edgeIndex)):e;const s=i?[...i].filter(a=>n[a]!==void 0):[];for(let a=0;a<e.length;a++){const l=e[a];const c=!i||i.has(l.edgeIndex);const d=c?e:o;for(let u=c?a+1:0;u<d.length;u++){const f=d[u];if(!c&&f.edgeIndex<=l.edgeIndex)continue;if(UR(l.rect,f.rect))r.labelLabel++}if(c)for(const u of t){if(UR(l.rect,u))r.labelNode++}for(let u=0;u<(c?n.length:s.length);u++){const f=c?u:s[u];const h=n[f];if(f===l.edgeIndex||h.hidden)continue;for(let m=1;m<h.points.length;m++){if(Ku(h.points[m-1],h.points[m],l.rect)){r.labelEdge++;break}}}}r.total=r.labelLabel+r.labelNode+r.labelEdge;return r}var KG={edgeThroughNode:"primary",nodeOverlaps:"primary",diagonalSegments:"secondary",unexplainedBends:"secondary",hitches:"secondary",offOutlineEndpoints:"cosmetic",endpointApproaches:"primary",labelOffRoute:"cosmetic"};var KR={primary:0,secondary:1,cosmetic:2};function JG(e){return KG[e]??"secondary"}function ZR(e,t){const n=i=>Math.abs(i.x-t.x)<=.5&&Math.abs(i.y-t.y)<=.5;if(Object.values(Ft(e)).some(n))return true;if(e.shape==="diamond"&&Object.values(Yo(e)).some(n))return true;return false}function Ai(e,t,n=1.5){const i=ed(e,t,n);return i.policy==="none"||i.onBoundary}function QG(e){const{x:t,y:n,width:i,height:r}=e;const o=i*.15;switch(e.shape){case"trapezoid":return[{x:t+o,y:n},{x:t+i-o,y:n},{x:t+i,y:n+r},{x:t,y:n+r}];case"trapezoid-alt":return[{x:t,y:n},{x:t+i,y:n},{x:t+i-o,y:n+r},{x:t+o,y:n+r}];case"lean-r":return[{x:t+o,y:n},{x:t+i,y:n},{x:t+i-o,y:n+r},{x:t,y:n+r}];case"lean-l":return[{x:t,y:n},{x:t+i-o,y:n},{x:t+i,y:n+r},{x:t+o,y:n+r}];default:return[{x:t+12,y:n},{x:t+i,y:n},{x:t+i,y:n+r},{x:t+12,y:n+r},{x:t,y:n+r/2}]}}function Ii(e,t,n){const i=n.x+n.width/2;const r=n.y+n.height/2;const o=n.width/2;const s=n.height/2;const a=Math.min(e.x,t.x),l=Math.max(e.x,t.x);const c=Math.min(e.y,t.y),d=Math.max(e.y,t.y);if(n.shape==="cylinder"&&(n.semanticShape===void 0||n.semanticShape==="cyl")&&n.height>14&&l>n.x&&a<n.x+n.width&&d>n.y+7&&c<n.y+n.height-7)return true;const u=(n.shape==="rectangle"||n.shape==="subroutine")&&(n.semanticShape===void 0||n.semanticShape==="rect"||n.semanticShape==="fr-rect"||n.semanticShape==="lin-rect"||n.semanticShape==="div-rect"||n.semanticShape==="win-pane");const f=u?0:.5;const h=l>n.x+f&&a<n.x+n.width-f&&d>n.y+f&&c<n.y+n.height-f;if(!h)return false;const m=2.5;switch(n.shape){case"ellipse":case"circle":case"doublecircle":case"state-start":case"state-end":{const p={x:(e.x-i)/o,y:(e.y-r)/s};const g={x:(t.x-i)/o,y:(t.y-r)/s};return md({x:0,y:0},p,g)<1-m/Math.min(o,s)}case"stadium":{const p=s;const g={x:i-(o-p),y:r};const y={x:i+(o-p),y:r};return ev(e,t,g,y)<p-m}case"diamond":case"hexagon":case"trapezoid":case"trapezoid-alt":case"lean-r":case"lean-l":case"asymmetric":{const p=n.shape==="diamond"?[{x:i,y:n.y},{x:n.x+n.width,y:r},{x:i,y:n.y+n.height},{x:n.x,y:r}]:n.shape==="hexagon"?(()=>{const b=n.height/4;return[{x:n.x+b,y:n.y},{x:n.x+n.width-b,y:n.y},{x:n.x+n.width,y:r},{x:n.x+n.width-b,y:n.y+n.height},{x:n.x+b,y:n.y+n.height},{x:n.x,y:r}]})():QG(n);const g=Math.max(0,1-m/Math.min(o,s));const y=p.map(b=>({x:i+(b.x-i)*g,y:r+(b.y-r)*g}));return ZG(e,t,y)}default:return true}}function ZG(e,t,n){const i=o=>{for(let s=0;s<n.length;s++){const a=n[s],l=n[(s+1)%n.length];if((l.x-a.x)*(o.y-a.y)-(l.y-a.y)*(o.x-a.x)<-.5)return false}return true};const r={x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(i(e)||i(t)||i(r))return true;for(let o=0;o<n.length;o++){if(tv(e,t,n[o],n[(o+1)%n.length]))return true}return false}function ev(e,t,n,i){if(tv(e,t,n,i))return 0;return Math.min(md(e,n,i),md(t,n,i),md(n,e,t),md(i,e,t))}function tv(e,t,n,i){const r=(t.x-e.x)*(i.y-n.y)-(t.y-e.y)*(i.x-n.x);if(Math.abs(r)<1e-9)return false;const o=((n.x-e.x)*(i.y-n.y)-(n.y-e.y)*(i.x-n.x))/r;const s=((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/r;return o>.001&&o<.999&&s>.001&&s<.999}function Xl(e,t){return _r(e.map(n=>({points:n.points,visible:n.style!=="invisible"})),t)}function Na(e,t){const n=new Map;e.forEach((o,s)=>{if(o.style==="invisible"||o.source===o.target)return;const a=JSON.stringify([o.source,o.target]);const l=n.get(a)??[];l.push({edge:o,index:s});n.set(a,l)});const i=(o,s)=>{for(let a=1;a<o.points.length;a++)for(let l=1;l<s.points.length;l++){const c=o.points[a-1],d=o.points[a],u=s.points[l-1],f=s.points[l];if(Math.abs(c.x-d.x)<=.01&&Math.abs(u.x-f.x)<=.01&&Math.abs(c.x-u.x)<=.5&&Math.min(Math.max(c.y,d.y),Math.max(u.y,f.y))-Math.max(Math.min(c.y,d.y),Math.min(u.y,f.y))>1)return true;if(Math.abs(c.y-d.y)<=.01&&Math.abs(u.y-f.y)<=.01&&Math.abs(c.y-u.y)<=.5&&Math.min(Math.max(c.x,d.x),Math.max(u.x,f.x))-Math.max(Math.min(c.x,d.x),Math.min(u.x,f.x))>1)return true}return false};let r=0;for(const o of n.values())for(let s=0;s<o.length;s++)for(let a=s+1;a<o.length;a++){const l=o[s],c=o[a];if((!t||t.has(l.index)||t.has(c.index))&&i(l.edge,c.edge))r++}return r}function cf(e,t=false){const n=new Map(e.nodes.map(o=>[o.id,o]));let i=0,r=0;for(const o of e.edges){if(t&&o.style==="invisible")continue;for(const[s,a]of[[o.source,o.points[0]],[o.target,o.points.at(-1)]]){const l=n.get(s);if(!l)continue;i++;if(a&&ZR(l,a))r++}}return i===0?1:r/i}function md(e,t,n){const i=n.x-t.x;const r=n.y-t.y;const o=i*i+r*r;if(o===0)return Math.hypot(e.x-t.x,e.y-t.y);const s=Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/o));return Math.hypot(e.x-(t.x+s*i),e.y-(t.y+s*r))}function eH(e,t,n,i,r,o){const s=c=>c.x>=e-n&&c.x<=e+n&&c.y>=t-i&&c.y<=t+i;if(s(r)||s(o))return 0;const a=[{x:e-n,y:t-i},{x:e+n,y:t-i},{x:e+n,y:t+i},{x:e-n,y:t+i}];let l=Infinity;for(let c=0;c<4;c++)l=Math.min(l,ev(a[c],a[(c+1)%4],r,o));return l}function tH(e,t){let n=0;const i=[];for(let a=1;a<t.length;a++){const l=Math.hypot(t[a].x-t[a-1].x,t[a].y-t[a-1].y);i.push(l);n+=l}let r=Infinity,o=0,s=0;for(let a=1;a<t.length;a++){const l=t[a-1],c=t[a],d=c.x-l.x,u=c.y-l.y,f=d*d+u*u;let h=f?((e.x-l.x)*d+(e.y-l.y)*u)/f:0;h=Math.max(0,Math.min(1,h));const m=l.x+h*d,p=l.y+h*u,g=Math.hypot(e.x-m,e.y-p);if(g<r){r=g;o=s+h*i[a-1]}s+=i[a-1]}return n?o/n:.5}function nH(e){if(!e.label||!e.labelPosition||e.points.length<2)return 0;return Math.abs(tH(e.labelPosition,e.points)-.5)}function JR(e,t){return t==="LR"||t==="RL"?e.y+e.height/2:e.x+e.width/2}function lf(e,t){return t==="LR"||t==="RL"?e.x:e.y}function Lp(e,t){return t==="LR"||t==="RL"?e.x+e.width:e.y+e.height}function iH(e,t,n){if(n==="LR")return lf(t,n)>Lp(e,n);if(n==="RL")return Lp(t,n)<lf(e,n);if(n==="BT")return Lp(t,n)<lf(e,n);return lf(t,n)>Lp(e,n)}function rH(e,t,n=1){if(e.length<2)return false;const i=e.map(r=>lf(r,t));return Math.max(...i)-Math.min(...i)<=n}function QR(e,t){const n=i=>i.some(r=>e.x>=r.x-.5&&e.y>=r.y-.5&&e.x+e.width<=r.x+r.width+.5&&e.y+e.height<=r.y+r.height+.5||n(r.children));return n(t)}var oH=28;function nv(e,t){const n=Co(t.edges);const i=new Map(e.nodes.map(l=>[l.id,l]));const r=new Map;const o=new Map;for(const l of e.edges){const c=i.get(l.source);const d=i.get(l.target);if(!c||!d||!iH(c,d,t.direction))continue;if(!r.has(l.source))r.set(l.source,[]);r.get(l.source).push(d);if(!o.has(l.target))o.set(l.target,[]);o.get(l.target).push(c)}let s=0;const a=(l,c,d)=>{if(!l||c.length<2||c.length>6||!rH(c,t.direction,oH))return;if(!gn.has(l.shape)||QR(l,e.groups))return;const u=h=>d==="in"?gn.has(h.shape):h.shape==="rectangle";if(!c.every(h=>u(h)&&!QR(h,e.groups)))return;if(new Set(c.map(h=>h.id)).size!==c.length)return;for(let h=0;h<c.length;h++)for(let m=0;m<c.length;m++){if(h!==m&&n(c[h].id,c[m].id))return}const f=c.reduce((h,m)=>h+JR(m,t.direction),0)/c.length;s=Math.max(s,Math.abs(JR(l,t.direction)-f))};for(const[l,c]of r)a(i.get(l),c,"out");for(const[l,c]of o)a(i.get(l),c,"in");return s}function iv(e,t,n=Xe({})){return rv(e,t,n,true)}function rv(e,t,n,i){const r=[];const o=new Map(t.nodes.map(S=>[S.id,S]));let s=0;let a=0;let l=0;let c=0;let d=0;let u=0;let f=0;let h=0;let m=0;for(const S of t.edges){const x=`${S.source}->${S.target}`;const k=Math.max(0,S.points.length-2);if(S.style!=="invisible"){const P=bi(S,o.get(S.source),o.get(S.target));if(P){a+=P;r.push({metric:"endpointApproaches",detail:`${x}: ${P} inward or tangent exact endpoint shaft(s)`})}}const w=of(S);if(S.style!=="invisible"&&!w){u+=k;f=Math.max(f,k)}if(k>0&&S.routeCertificate?.invariant==="straight"){c+=k;r.push({metric:"unexplainedBends",detail:`${x} certified straight with ${k} bends`})}for(let P=1;P<S.points.length;P++){const E=S.points[P-1],v=S.points[P];if(Math.abs(E.x-v.x)>.01&&Math.abs(E.y-v.y)>.01){l++;r.push({metric:"diagonalSegments",detail:`${x} segment ${P}`})}}for(const[P,E,v]of[[S.source,S.points[0],"source"],[S.target,S.points[S.points.length-1],"target"]]){const L=o.get(P);if(!L)continue;if(!E||!Ai(L,E)){s++;r.push({metric:"offOutlineEndpoints",detail:E?`${x} ${v} on ${P}(${L.shape}) at (${E.x.toFixed(1)},${E.y.toFixed(1)})`:`${x} missing ${v} endpoint on ${P}`})}}const C=o.get(S.source);const R=o.get(S.target);const M=(P,E)=>P&&E?ZR(P,E):false;if(M(C,S.points[0])||M(R,S.points[S.points.length-1]))h++;if(S.label&&S.labelPosition&&S.points.length>=2){const P=S.labelBlock??Wn(S.label,n,"edge");const E=(P.height+16)/2+4;const v=S.source===S.target;let L=Infinity;for(let T=1;T<S.points.length;T++){L=Math.min(L,v?eH(S.labelPosition.x,S.labelPosition.y,(P.width+16)/2,(P.height+16)/2,S.points[T-1],S.points[T]):md(S.labelPosition,S.points[T-1],S.points[T]))}if(L>E){d++;r.push({metric:"labelOffRoute",detail:`${x} label ${L.toFixed(1)}px from its route (allowed ${E.toFixed(1)})`})}if(i)m=Math.max(m,nH(S))}}let p=0;for(const S of t.edges){for(const x of t.nodes){if(x.id===S.source||x.id===S.target)continue;for(let k=1;k<S.points.length;k++){if(Ii(S.points[k-1],S.points[k],x)){p++;r.push({metric:"edgeThroughNode",detail:`${S.source}->${S.target} segment ${k} through ${x.id}`});break}}}}const g=i?Xl(t.edges):0;let y=0;for(let S=0;S<t.nodes.length;S++){for(let x=S+1;x<t.nodes.length;x++){const k=t.nodes[S],w=t.nodes[x];const C=Math.min(k.x+k.width,w.x+w.width)-Math.max(k.x,w.x);const R=Math.min(k.y+k.height,w.y+w.height)-Math.max(k.y,w.y);if(C>.5&&R>.5){y++;r.push({metric:"nodeOverlaps",detail:`${k.id} overlaps ${w.id}`})}}}const b=jR(t,e,n);for(const S of b)r.push({metric:"hitches",detail:`${S.edge} deviates ${S.deviationPx}px with a clear lane`});return{metrics:{edges:t.edges.length,offOutlineEndpoints:s,endpointApproaches:a,diagonalSegments:l,unexplainedBends:c,hitches:b.length,nodeOverlaps:y,labelOffRoute:d,edgeThroughNode:p,labelConflicts:i?Fa(t,n).total:0,edgeCrossings:g,totalBends:u,maxBendsPerEdge:f,portEndpointRate:cf(t),portAnchoredEdgeRate:t.edges.length===0?1:h/t.edges.length,peerBarycenterDelta:i?nv(t,e):0,worstLabelOffset:m},violations:r.map(S=>({...S,severity:JG(S.metric)})).sort((S,x)=>KR[S.severity]-KR[x.severity])}}function ov(e,t,n,i,r=new Set){const o={};for(const s of n){switch(s){case"hard":o.hard=VS(rv(e,t,i,false)).length;break;case"crossings":o.crossings=Xl(t.edges);break;case"portRate":o.portRate=cf(t,true);break;case"symErr":o.symErr=nv(t,e);break;case"parallelOverlaps":o.parallelOverlaps=Na(t.edges);break;case"opposingOverlaps":o.opposingOverlaps=Xo(t.edges);break;case"endpointApproaches":{const a=new Map(t.nodes.map(l=>[l.id,l]));o.endpointApproaches=t.edges.reduce((l,c)=>l+(c.style==="invisible"?0:bi(c,a.get(c.source),a.get(c.target))),0);break}case"bends":o.bends=t.edges.reduce((a,l)=>a+(l.style==="invisible"||(l.routeCertificate?of(l):r.has(l)&&Ta(l))?0:Math.max(0,l.points.length-2)),0);break;case"straight":o.straight=t.edges.filter(a=>a.style!=="invisible"&&a.points.length===2).length;break}}return o}var sH=["offOutlineEndpoints","endpointApproaches","diagonalSegments","unexplainedBends","hitches","nodeOverlaps","labelOffRoute","edgeThroughNode"];function VS(e){const t=new Set(sH);return e.violations.filter(n=>t.has(n.metric))}var aH=4;var lH=["unreadableTitles","edgeCrossings","labelConflicts","totalBends","nonCanonicalEndpointRate","peerBarycenterDelta","area"];function cH(e,t,n){const i=[];const r=(m,p,g,y)=>{if(!g)return;const b=y==="node"?n.nodeTextTransform:y==="edge"?n.edgeTextTransform:n.groupTextTransform;const S=vt(p,"formatted",b),x=g.prepared;const k=x.lines.length===S.lines.length&&x.lines.every((w,C)=>w.length===S.lines[C].length&&w.every((R,M)=>{const P=S.lines[C][M];return R.text===P.text&&R.bold===P.bold&&R.italic===P.italic&&R.underline===P.underline&&R.strikethrough===P.strikethrough&&R.sourceStart===P.sourceStart&&R.sourceEnd===P.sourceEnd&&R.clusters?.length===P.clusters?.length&&(R.clusters?.every((E,v)=>{const L=P.clusters[v];return E.text===L.text&&E.sourceStart===L.sourceStart&&E.sourceEnd===L.sourceEnd})??true)}));if(x.source!==S.source||x.display!==S.display||x.transform!==S.transform||x.lineStarts.length!==S.lineStarts.length||x.lineStarts.some((w,C)=>w!==S.lineStarts[C])||!k){i.push(`${m}: changed retained prepared text`)}};const o=new Map,s=new Map;const a=new Map,l=new Map;const c=(m,p="")=>{for(const g of m){o.set(g.id,p);a.set(g.id,g);c(g.children,g.id)}};const d=(m,p="")=>{for(const g of m){if(s.has(g.id))i.push(`group ${g.id}: duplicate identity`);s.set(g.id,p);l.set(g.id,g);d(g.children,g.id)}};c(e.subgraphs);d(t.groups);for(const[m,p]of o)if(s.get(m)!==p)i.push(`group ${m}: missing or changed parent`);for(const m of s.keys())if(!o.has(m))i.push(`group ${m}: unexpected identity`);const u=new Set;const f=new Map(t.nodes.map(m=>[m.id,m]));for(const m of t.nodes){if(u.has(m.id))i.push(`node ${m.id}: duplicate identity`);u.add(m.id);if(!e.nodes.has(m.id))i.push(`node ${m.id}: unexpected identity`);else if(m.label!==e.nodes.get(m.id).label)i.push(`node ${m.id}: changed label`);else{const p=e.nodes.get(m.id);r(`node ${m.id}`,qe(p.label,p.labelContent),m.labelBlock,"node")}}for(const m of e.nodes.keys())if(!u.has(m)&&!s.has(m))i.push(`node ${m}: missing identity`);for(const[m,p]of a){const g=l.get(m);if(!g)continue;if(g.label!==p.label)i.push(`group ${m}: changed label`);r(`group ${m}`,qe(p.label,p.labelContent),g.labelBlock,"group");const y=l.get(o.get(m)??"");if(y&&(g.x<y.x-.5||g.y<y.y-.5||g.x+g.width>y.x+y.width+.5||g.y+g.height>y.y+y.height+.5)){i.push(`group ${m}: outside authored parent ${y.id}`)}for(const b of p.nodeIds){if(a.has(b))continue;const S=f.get(b);if(S&&(S.x<g.x-.5||S.y<g.y-.5||S.x+S.width>g.x+g.width+.5||S.y+S.height>g.y+g.height+.5)){i.push(`member ${b}: outside authored group ${m}`)}}}const h=new Set;for(const[m,p]of t.edges.entries()){const g=p.edgeIndex??m,y=e.edges[g];if(h.has(g))i.push(`edge ${g}: duplicate identity`);h.add(g);if(!y){i.push(`edge ${g}: unexpected identity`);continue}if(y.label!==void 0)r(`edge ${g}`,qe(y.label,y.labelContent),p.labelBlock,"edge");if(p.source!==y.source||p.target!==y.target||(p.id??"")!==(y.id??"")||(p.label??"")!==(y.label??"")||p.style!==y.style||p.hasArrowStart!==y.hasArrowStart||p.hasArrowEnd!==y.hasArrowEnd||(p.startMarker??"arrow")!==(y.startMarker??"arrow")||(p.endMarker??"arrow")!==(y.endMarker??"arrow")){i.push(`edge ${g}: changed endpoints, identity, label, shaft or markers`)}}e.edges.forEach((m,p)=>{if(!h.has(p))i.push(`edge ${p}: missing identity`)});return i}function KS(e,t){const n=new Map;const i=o=>{for(const s of o){n.set(s.id,s);i(s.children)}};i(e.subgraphs);const r=o=>{for(const s of o){s.nodeIds=n.get(s.id).nodeIds.filter(a=>e.nodes.has(a)&&!n.has(a));r(s.children)}};r(t.groups)}function dH(e,t){const n=[];const i=(o,s,a,l)=>{let c=0,d=1;for(const[u,f,h,m]of[[o.x,s.x-o.x,a.x,a.x+a.width],[o.y,s.y-o.y,a.y,a.y+l]]){if(f===0){if(u<=h||u>=m)return false;continue}const p=(h-u)/f,g=(m-u)/f;c=Math.max(c,Math.min(p,g));d=Math.min(d,Math.max(p,g));if(c>=d)return false}return c<d};const r=o=>{if(!o.concurrencyRegion){const s=o.labelBlock??Wn(qe(o.label,o.labelContent),t,"group");const a=o.headerHeight??t.groupHeaderFontSize+16+s.height-s.lineHeight;if(!Number.isFinite(a)||a<0)n.push(`group-header ${o.id}: invalid retained height`);else if(a>0&&o.width>0)for(const l of e.edges){if(l.style==="invisible")continue;for(let c=1;c<l.points.length;c++)if(i(l.points[c-1],l.points[c],o,a)){n.push(`group-header ${o.id}: edge ${l.source}->${l.target} segment ${c} enters reserved band`);break}}}o.children.forEach(r)};e.groups.forEach(r);return n}function sv(e,t){const n=[];const i=s=>s.every(Number.isFinite);if(!i([e.width,e.height])||e.width<0||e.height<0)return["non-finite or negative canvas"];const r=(s,a,l,c,d)=>{if(!i([a,l,c,d])||c<0||d<0)n.push(`${s}: non-finite or negative geometry`);else if(a<-.5||l<-.5||a+c>e.width+.5||l+d>e.height+.5)n.push(`${s}: outside canvas`)};for(const s of e.nodes)r(`node ${s.id}`,s.x,s.y,s.width,s.height);const o=s=>{r(`group ${s.id}`,s.x,s.y,s.width,s.height);s.children.forEach(o)};e.groups.forEach(o);for(const s of e.edges){if(s.style!=="invisible"&&s.points.length<2)n.push(`edge ${s.source}->${s.target}: missing route`);if(s.label&&(!s.labelPosition||!s.labelBlock))n.push(`label ${s.source}->${s.target}: missing retained geometry`);for(const a of s.points)r(`edge ${s.source}->${s.target}`,a.x,a.y,0,0);if(s.label!==void 0&&s.labelPosition&&s.labelBlock){const a=Pt(s,t);if(a)r(`label ${s.source}->${s.target}`,a.x,a.y,a.w,a.h)}}for(const s of e.notes??[])r(`note ${s.id}`,s.x,s.y,s.width,s.height);if(e.title?.block){const s=e.title,a=s.block;r("diagram title",s.x-a.width/2,s.y-a.height/2,a.width,a.height)}return n}function JS(e,t){const n=sv(e,t);return n.length?n:dH(e,t)}function uH(e,t,n){return{unreadableTitles:n?1:0,labelConflicts:t.labelConflicts,edgeCrossings:t.edgeCrossings,totalBends:t.totalBends,nonCanonicalEndpointRate:1-t.portEndpointRate,peerBarycenterDelta:Math.round(t.peerBarycenterDelta*1e3)/1e3,area:e.width*e.height}}function QS(e,t,n,i=false){return av(e,t,n,i)}function av(e,t,n,i=false,r="final"){try{const o=n.produce();const s=cH(e,o,t);if(i&&s.length)throw new TypeError(`Owned layout changed authored meaning: ${s.join("; ")}`);const a=[...s,...r==="placement"?sv(o,t):JS(o,t)];const l=a.length===0?iv(e,o,t):void 0;if(l)a.push(...VS(l).map(d=>`${d.metric}: ${d.detail}`));const c=a.length===0&&(n.preferNext?.(o)??false);return{attempt:{strategy:n.strategy,violations:a},...a.length===0&&l?{certified:{positioned:o,strategy:n.strategy,score:uH(o,l.metrics,c)}}:{}}}catch(o){if(i||o instanceof qi||o instanceof Ps||o instanceof Ei)throw o;return{attempt:{strategy:n.strategy,violations:[o instanceof Error?o.message:String(o)]}}}}function lv(e,t){for(const n of lH){if(t.score[n]<e.score[n])return{selected:t,reason:n};if(t.score[n]>e.score[n])return{selected:e,reason:n}}return{selected:e,reason:"candidate-order"}}function cv(e,t,n,i,r="final"){const o=[];const s=n.slice(0,aH);const a=i?[i,...s]:s;let l;let c;let d=false;const u=[];const f=(h,m)=>({selected:h,reason:m,compared:u,attempts:o.length});for(const[h,m]of a.entries()){if(l&&c==="routing"&&m.qualityAlternative===false)continue;if(d){pl("layout-candidate","candidate-rejected",o.length+1);d=false}const p=av(e,t,m,false,r);o.push(p.attempt);const g=p.certified;if(g){u.push({strategy:g.strategy,score:g.score});if(l){const b=lv(l,g);return f(b.selected,b.reason)}const y=a.slice(h+1);if(g.score.unreadableTitles&&y.length>0){l=g;c="readability";continue}if(g.score.edgeCrossings===0&&g.score.labelConflicts===0)return f(g,"first-certified");if(!Ca(e))return f(g,"work-budget");if(!y.some(b=>b.qualityAlternative!==false))return f(g,"no-alternative");l=g;c="routing";continue}if(l)return f(l,"alternative-invalid");d=true}if(l)return f(l,"no-alternative");throw new Qe(o)}function ZS(e,t){const{selected:n,reason:i,compared:r,attempts:o}=t;KS(e,n.positioned);n.positioned.certification={status:"passed",strategy:n.strategy,attempts:o,hardViolations:0,preference:{selectedScore:n.score,reason:i,compared:r}};return n.positioned}function dv(e,t,n,i){const{selected:r}=cv(e,t,n,i,"placement");KS(e,r.positioned);const{width:o,height:s,nodes:a,groups:l}=r.positioned;return{width:o,height:s,nodes:a,groups:l}}function uv(e,t,n,i,r){const o=cv(e,t,n,r);const s=ZS(e,o);const a=i(s,o.selected.score);if(!a)return s;const l={...o.selected,strategy:"bundled"};const c=QS(e,t,a);const d=[{strategy:l.strategy,score:l.score}];if(c.certified)d.push({strategy:c.certified.strategy,score:c.certified.score});const u=c.certified?lv(l,c.certified):{selected:l,reason:"alternative-invalid"};const f=u.selected.positioned;KS(e,f);f.certification={...s.certification,preference:{...s.certification.preference,selectedScore:u.selected.score,routing:{strategy:u.selected===l?"bundled":a.strategy,preference:{selectedScore:u.selected.score,reason:u.reason,compared:d}}}};return f}var fv=new WeakSet;function hv(e){if(fv.has(e))return;fv.add(e);const t=Gi(e);const n=t.configDiagnostics??[];if(n.length===0)return;const i=t.onConfigDiagnostic??(r=>console.warn(r.message));for(const r of n)i(r)}function mv(e){if(!Mu.test(e))return e;return Hx(e,({name:t,value:n})=>Xn(t,n))}function ew(e){const t=/<((?:[A-Za-z_][\w.-]*:)?(?:style|text|title|desc|metadata))\b[\s\S]*?<\/\1>/gi;const n=[];const i=s=>s.replace(/>\s*\r?\n\s*</g,"><");let r=0;let o;while((o=t.exec(e))!==null){if(o.index>r)n.push(i(e.slice(r,o.index)));n.push(o[0]);r=o.index+o[0].length}if(r<e.length)n.push(i(e.slice(r)));return n.join("")}function tw(e,t){if(!/^[A-Za-z0-9_.:-]+$/.test(t)){throw new Error("idPrefix must be non-empty and contain only ASCII letters, digits, underscore, hyphen, dot, and colon")}const n=new Set;for(const o of $c(e)){for(const s of o.attributes){if(s.name==="id")n.add(s.value)}}const i=o=>o.startsWith(t)?o:`${t}${o}`;const r=Hx(e,o=>{if(o.name==="id")return i(o.value);if(o.name==="aria-labelledby"||o.name==="aria-describedby"){return o.value.split(/\s+/).map(s=>n.has(s)?i(s):s).join(" ")}if((o.name==="href"||o.name==="xlink:href")&&o.value.startsWith("#")){const s=o.value.slice(1);return n.has(s)?`#${i(s)}`:o.value}return void 0});return G1(r,o=>o.replace(/url\(#([^)]+)\)/g,(s,a)=>n.has(a)?`url(#${i(a)})`:s))}import{decodeXML as fH}from"entities";function pv(e,t){return e.match(new RegExp(`\\b${t}\\s*=\\s*(["'])(.*?)\\1`,"i"))?.[2]}function pd(e,t){const n=pv(e,"style");const i=n?.match(new RegExp(`(?:^|;)\\s*${t}\\s*:\\s*([^;]+)`,"i"))?.[1]?.trim();return i??pv(e,t)}function gv(e,t,n){const i=Number.parseFloat(pd(e,t)??"");return Number.isFinite(i)?i:n}function yv(e,t){const n=pd(e,"font-weight")?.trim().toLowerCase();if(n===void 0)return t;if(n==="normal")return 400;if(n==="bold")return 700;if(n==="bolder"){if(t<350)return 400;if(t<550)return 700;return 900}if(n==="lighter"){if(t<550)return 100;if(t<750)return 400;return 700}const i=Number.parseFloat(n);return Number.isFinite(i)?i:t}function hH(e){return/\bclass\s*=\s*(["'])[^"']*\bmono\b/i.test(e)||/(?:^|[,\s])monospace(?:[,\s]|$)/i.test(pd(e,"font-family")??"")}function mH(e,t){let n="";for(let i=t+1;i<e.length;i++){const r=e[i];if(n){if(r===n)n="";continue}if(r==='"'||r==="'"){n=r;continue}if(r===">")return i}return-1}function pH(e){const t=[];const n=[];let i=0;while(i<e.length){const r=e.indexOf("<",i);if(r<0){if(n.length>0&&i<e.length)n[n.length-1].children.push({kind:"text-node",raw:e.slice(i)});i=e.length;break}if(n.length>0&&r>i)n[n.length-1].children.push({kind:"text-node",raw:e.slice(i,r)});if(e.startsWith("<!--",r)){const d=e.indexOf("-->",r+4);if(d<0)return null;i=d+3;continue}const o=mH(e,r);if(o<0)return null;const s=e.slice(r,o+1);if(/^<\?/.test(s)||/^<!/.test(s)){i=o+1;continue}const a=s.match(/^<\/\s*([\w:-]+)\s*>$/);if(a){const d=n.pop();if(!d||d.name!==a[1].toLowerCase())return null;d.closeStart=r;i=o+1;continue}const l=s.match(/^<\s*([\w:-]+)([\s\S]*?)(\/?)>$/);if(!l)return null;const c={kind:"element",name:l[1].toLowerCase(),attrs:l[2],openEnd:o+1,closeStart:o+1,children:[]};if(n.length>0)n[n.length-1].children.push(c);else t.push(c);if(l[3]!=="/")n.push(c);i=o+1}return n.length===0?t:null}function xv(e){return e.children.filter(t=>t.kind==="element")}function bv(e,t){const n=t.name==="b"||t.name==="strong";const i=e.mono||hH(t.attrs);return{size:gv(t.attrs,"font-size",e.size),weight:n?Math.max(700,yv(t.attrs,e.weight)):yv(t.attrs,e.weight),letterSpacing:gv(t.attrs,"letter-spacing",e.letterSpacing),mono:i,fontFamily:pd(t.attrs,"font-family")??(i&&!e.mono?void 0:e.fontFamily),fontStyle:t.name==="i"||t.name==="em"||pd(t.attrs,"font-style")==="italic"?"italic":pd(t.attrs,"font-style")==="normal"?"normal":e.fontStyle}}function df(e,t){return new RegExp(`\\b${t}\\s*=`,"i").test(e)}function nw(e){return e.name==="tspan"&&["x","y","dx","dy"].some(t=>df(e.attrs,t))}function Sv(e){return xv(e).some(t=>nw(t)||Sv(t))}function gH(e,t){const n=[];let i=false;const r=(o,s,a)=>{const l=bv(s,o);if(!a&&nw(o))return;if(!a&&df(o.attrs,"textLength")){i=true;return}for(const c of o.children){if(c.kind==="text-node"){const d=fH(c.raw);if(d.length>0)n.push({text:d,metrics:l})}else r(c,l,false)}};r(e,t,true);return{runs:n,blocked:i}}function yH(e,t=false){const n=e.filter(s=>s.text.length>0);if(n.length===0||n.every(s=>s.text.trim().length===0))return null;let i=0;let r=0;let o=0;for(const s of n){if(!(s.metrics.size>0))return null;const a=E1(s.text).length;if(r>0&&a>0)i+=o;i+=s.metrics.mono?Wx(s.text,s.metrics.size,s.metrics.letterSpacing,s.metrics.weight,s.metrics.fontStyle,s.metrics.fontFamily):t?xu(s.text,s.metrics.size,s.metrics.weight,s.metrics.fontStyle,s.metrics.fontFamily)+Math.max(0,a-1)*s.metrics.letterSpacing:T1(s.text,s.metrics.size,s.metrics.weight,s.metrics.letterSpacing,s.metrics.fontStyle,s.metrics.fontFamily);r=a;o=s.metrics.letterSpacing}return Math.round(i*1e3)/1e3}function wv(e,t){const n=pH(e);if(!n)return e;const i=[];const r={size:0,weight:400,letterSpacing:0,mono:false,fontStyle:"normal",fontFamily:t};const o=(a,l,c,d=false)=>{if(df(a.attrs,"data-prepared-text"))return;const u=bv(l,a);const f=d||df(a.attrs,"data-literal-text");const h=a.name==="text"&&!c;const m=h||c&&nw(a);const p=m&&df(a.attrs,"textLength");if(p)return;if(m&&!(h&&Sv(a))){const y=gH(a,l);const b=y.blocked?null:yH(y.runs,f);if(b!==null){i.push({offset:a.openEnd-1,text:` textLength="${b}" lengthAdjust="spacingAndGlyphs" data-font-metrics="deterministic-fit"`})}}const g=c||h;for(const y of xv(a))o(y,u,g,f)};for(const a of n)o(a,r,false);let s=e;for(const a of i.sort((l,c)=>c.offset-l.offset)){s=s.slice(0,a.offset)+a.text+s.slice(a.offset)}return s}var Mv=new WeakSet;function kv(e){Mv.add(e)}function Cv(e){return Mv.has(e)}var gd=new WeakMap;function gt(e){const t=n=>e(wl,n);gd.set(t,{original:e,current:e});return t}function Pv(e,t){const n=gd.get(e)?.current;if(n){const i=gd.get(t);if(i)i.current=n;else gd.set(t,{original:n,current:n})}return t}function Vo(e){return e&&gd.get(e)?.current}function yd(e){return e&&gd.get(e)?.original}var Ev=new WeakMap;var xH=0;var uf=new WeakMap;var Rv=0;var Ap=new WeakMap;var iw=16*1024*1024;var rw=8*1024*1024;var bH=128;var xd=new bu(128,rw);var ff=new bu(128,iw,e=>{xd.delete(e)});var ow=new WeakSet;function sw(e,t){let n=Ev.get(e);if(n===void 0){n=xH++;Ev.set(e,n)}return`${n}:${t}`}function Ip(e){const t=structuredClone(e);const n=new WeakSet;const i=(r,o)=>{if(r===null||typeof r!=="object"||o===null||typeof o!=="object"||n.has(r))return;n.add(r);tm(r,o);if(r instanceof Map&&o instanceof Map){const s=o.entries();for(const[a,l]of r){const[c,d]=s.next().value;i(a,c);i(l,d)}}else if(r instanceof Set&&o instanceof Set){const s=o.values();for(const a of r)i(a,s.next().value)}else for(const s of Object.keys(r))i(r[s],o[s])};i(e,t);return t}function vv(e){return ow.has(e)}function Tv(e,t,n=false){const i=ff.get(sw(e,t));if(!n)Ht("positioned-layout",i?"hit":"miss");if(!i)return void 0;const r=Ip(i.result);Du(i.result,r);return r}function Lv(e,t,n){const i=sw(e,t);const r=ff.get(i);Ht("positioned-layout",r?"hit":"miss");if(n&&r&&uf.has(r)){const o=Object.freeze({...r.result});Du(r.result,o);Ap.set(o,{key:i,snapshot:r,request:n});ow.add(o);return{...r,result:o}}return r}function Av(e,t,n,i){Fv(e,t,n,i,true)}function Iv(e,t,n,i){Fv(e,t,n,i,false)}function Fv(e,t,n,i,r){const o={result:n,...i?{projection:i}:{}};const s=t.length*2+ku([o,jo(n)],iw)+1024;if(s>iw){Ht("positioned-layout","store-skipped","weight-limit");return}let a=o;if(r){try{a=Ip(o)}catch(l){if(l instanceof Error&&l.name==="DataCloneError"){Ht("positioned-layout","store-skipped","uncloneable");return}throw l}Du(n,a.result)}if(!r)uf.set(a,{locallyRepeated:false});ff.set(sw(e,t),a,s);ow.add(a.result)}function Fp(e,t,n){const i=Ap.get(t);if(!n){Ap.delete(t);return void 0}if(!i||i.request!==e||ff.get(i.key)!==i.snapshot)return void 0;const r=++Rv;const o=uf.get(i.snapshot);o.locallyRepeated=o.lastUse===r-1;o.lastUse=r;const s=xd.get(i.key);return s?.owner===i.snapshot?s.drawing:void 0}function Nv(e,t,n){const i=Ap.get(t);if(!i||i.request!==e||ff.get(i.key)!==i.snapshot)return;const r=uf.get(i.snapshot);if(r.oversized){Ht("native-drawing","store-skipped","weight-limit");return}const o=r.drawingWeight??i.key.length*2+n.svg.length*4+1024;const s=xd.leastRecentlyUsed();const a=s&&uf.get(s.owner)?.lastUse;const l=a!==void 0&&Rv-a>=bH;if(!r.locallyRepeated&&!l&&!xd.canFit(i.key,o)){Ht("native-drawing","store-skipped","drawing-budget");return}const c={owner:i.snapshot,drawing:n};const d=i.key.length*2+ku(n,rw)+1024;r.drawingWeight=d;if(d>rw){r.oversized=true;Ht("native-drawing","store-skipped","weight-limit");return}if(!r.locallyRepeated&&!l&&!xd.canFit(i.key,d)){Ht("native-drawing","store-skipped","drawing-budget");return}xd.set(i.key,c,d)}var wi=.5;var SH=new Set(["rectangle","rounded","note","service","diamond","stadium","hexagon","cylinder"]);var wH={journey:"x",sequence:"none",xychart:"center",quadrant:"center"};function MH(e){return e.role?e.role==="box":SH.has(e.shape)}function Bs(e,t,n,i){return Number.isFinite(e)&&Number.isFinite(t)&&Number.isFinite(n)&&Number.isFinite(i)&&n>=0&&i>=0}function $v(e,t){const n=Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x);const i=Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y);return n>wi&&i>wi}function Np(e,t,n="both"){const i=n==="center"?t.x+t.w/2>=e.x-wi&&t.x+t.w/2<=e.x+e.w+wi:t.x>=e.x-wi&&t.x+t.w<=e.x+e.w+wi;const r=n==="x"||(n==="center"?t.y+t.h/2>=e.y-wi&&t.y+t.h/2<=e.y+e.h+wi:t.y>=e.y-wi&&t.y+t.h<=e.y+e.h+wi);return i&&r}function _v(e,t,n){let i=t;const r=new Set;while(i?.parentId&&!r.has(i.id)){r.add(i.id);if(i.parentId===e.id)return true;i=n.get(i.parentId)}return false}function Dv(e){return kH(e).violations}function kH(e){const t=[];if(!Bs(0,0,e.bounds.w,e.bounds.h)){t.push({metric:"nonFiniteGeometry",detail:`bounds ${e.bounds.w}\xD7${e.bounds.h}`})}const n=(s,a,l)=>{if(!l)return;if(!Bs(l.x,l.y,l.w,l.h)){t.push({metric:"nonFiniteGeometry",detail:`${s} ${a}`})}else if(l.x<-wi||l.y<-wi||l.x+l.w>e.bounds.w+wi||l.y+l.h>e.bounds.h+wi){t.push({metric:"offCanvas",detail:s==="node"?`node ${a} at (${l.x},${l.y}) ${l.w}\xD7${l.h}`:`${s} ${a}`})}};for(const s of e.nodes)n("node",s.id,s);for(const s of e.nodes){if(s.labelVisibility!=="hidden"&&s.labelVisibility!=="semantic")n("label",s.id,s.labelBounds)}for(const s of e.edges)n("label",s.id,s.label?.bounds);for(const s of e.labels??[]){if(s.visibility!=="hidden"&&s.visibility!=="semantic")n("label",s.id,s.bounds)}for(const s of e.edges){let a=false;for(const[l,c]of s.path){if(!Number.isFinite(l)||!Number.isFinite(c)){t.push({metric:"nonFiniteGeometry",detail:`edge ${s.id} path`});a=true;break}if(!a&&(l<-wi||c<-wi||l>e.bounds.w+wi||c>e.bounds.h+wi)){t.push({metric:"offCanvas",detail:`edge ${s.id} point (${l},${c})`});a=true}}}for(const s of e.groups)n("group",s.id,s);const i=e.nodes.filter(MH);for(let s=0;s<i.length;s++){for(let a=s+1;a<i.length;a++){const l=i[s],c=i[a];if(!Bs(l.x,l.y,l.w,l.h)||!Bs(c.x,c.y,c.w,c.h))continue;if(!$v(l,c))continue;t.push({metric:"nodeOverlaps",detail:`${l.id} overlaps ${c.id}`})}}const r=wH[e.kind]??"both";const o=new Map(e.groups.map(s=>[s.id,s]));if(r!=="none"){const s=new Map(e.nodes.map(a=>[a.id,a]));for(const a of e.groups){const l=a.parentId?o.get(a.parentId):void 0;if(l&&Bs(a.x,a.y,a.w,a.h)&&Bs(l.x,l.y,l.w,l.h)){if(!Np(l,a,r)){t.push({metric:"groupBreaches",detail:`${a.id} outside parent ${l.id}`})}}for(const c of a.members){const d=s.get(c);if(!d||!Bs(d.x,d.y,d.w,d.h))continue;if(!Np(a,d,r)){t.push({metric:"groupBreaches",detail:`${c} outside ${a.id}`})}}}}for(let s=0;s<e.groups.length;s++){for(let a=s+1;a<e.groups.length;a++){const l=e.groups[s],c=e.groups[a];if(!Bs(l.x,l.y,l.w,l.h)||!Bs(c.x,c.y,c.w,c.h))continue;if(!$v(l,c))continue;if(Np(l,c)||Np(c,l))continue;if(_v(l,c,o)||_v(c,l,o))continue;t.push({metric:"groupOverlaps",detail:`${l.id} partially overlaps ${c.id}`})}}return{violations:t,groupById:o}}var $p=new WeakMap;var Bv=new WeakMap;var Ov=new WeakSet;function aw(e,t,n){qm(e,{...t,role:n});if(t.requested!=="agentic"||t.selected!=="elk"||Ov.has(e))return;Ov.add(e);const i={code:"INEFFECTIVE_CONFIG",field:"graphLayout.backend",message:`Agentic graph layout declined this input; using the requested ELK fallback: ${t.reason??"candidate rejected"}`};const r=Gi(e).onConfigDiagnostic??(o=>console.warn(o.message));r(i)}function lw(e){return $p.get(e)}function CH(e){return"positioned"in e?e:{positioned:e}}function Lie(e,t,n=t.source,i={}){return Gv(e,t,n,i,false)}function Wv(e){const t=Gi(e);const n=Vo(t.family.lowerScene);const i=t.mode==="scene"&&wC(t.backend?.backend)&&Cv(t.family)&&!t.textMeasurement&&!!n&&n===yd(t.family.lowerScene)&&!oa(e);const r=Gv(t.family.id,e,e.source,{},i);if(i&&vv(r))Bv.set(r,n);return r}function zv(e,t){const n=Bv.get(e);return n&&n!==t?Ip(e.positioned):e.positioned}function Gv(e,t,n,i,r){const o=Gi(t);const s=o.family;if(s.id!==e){throw new Error(`Resolved request planned family ${s.id}, not ${e}`)}if(!s.layout)throw new Error(`No layout registered for Mermaid family ${e}`);const a=!e.startsWith("family:");const l=`${e}:final`;if(a&&!s.projectPositioned){throw new Qe([{strategy:l,violations:["missing final geometry projection"]}])}const c=Dl(t);const d=globalThis.process?.env;const u=Ic("position-cache")&&a&&e!=="gantt"&&!o.textMeasurement&&(d?.AGENTIC_MERMAID_ELK_CACHE??globalThis.AGENTIC_MERMAID_ELK_CACHE)!=="0";const f=u&&n===t.source?{...n,cleanup:void 0}:n;const h=u?JSON.stringify([f,t.renderOptions,t.appearance,t.familyConfig,i,e==="class"?c.paintBackendId??"backend:default":void 0,Object.entries(d??{}).filter(([p])=>p.startsWith("APL_")).sort(),L1.map(Ic)]):void 0;const m=h!==void 0&&h.length<=65536?h:void 0;if(m===void 0)Ht("positioned-layout","bypass",!Ic("position-cache")?"disabled":!a?"external-family":e==="gantt"?"time-dependent-family":o.textMeasurement?"custom-text-measurement":h===void 0?"elk-cache-disabled":"key-limit");return ul(o.textMeasurement,()=>{const p=t.output==="ascii"||t.output==="unicode"||t.output==="html"?"companion":"primary";if(r&&m!==void 0){const S=Lv(s,m,t.output==="svg"?t:void 0);if(S?.projection){for(const x of jo(S.result))aw(t,x,p);$p.set(S.result,S.projection);return S.result}}const g=m===void 0?void 0:Tv(s,m,r);const y=[];const b=g??CH(VP(S=>{y.push(S);aw(t,S,p)},()=>s.layout({source:n,renderOptions:c.renderOptions,...c.styleFace?{styleFace:c.styleFace}:{},...c.paintBackendId?{paintBackendId:c.paintBackendId}:{},...c.familyConfig?{familyConfig:c.familyConfig}:{},...c.familyAppearance?{familyAppearance:c.familyAppearance}:{}})));if(g)for(const S of jo(g))aw(t,S,p);else for(const S of y)qm(b,S);if(a){try{const S=s.projectPositioned({positioned:b.positioned,options:i});const x=Dv({...S,kind:e});if(x.length)throw new Qe([{strategy:l,violations:x.map(k=>`${k.metric}: ${k.detail}`)}]);$p.set(b,S)}catch(S){if(S instanceof Qe)throw S;throw new Qe([{strategy:l,violations:[S instanceof Error?S.message:String(S)]}])}}if(!g&&m!==void 0){const S=r&&t.output==="svg"&&(e==="sequence"||e==="flowchart"||e==="state")?Iv:Av;S(s,m,b,$p.get(b))}return b})}var PH="am-";function EH(e){let t=3735928559;let n=1103547991;for(let i=0;i<e.length;i++){const r=e.charCodeAt(i);t=Math.imul(t^r,2654435761);n=Math.imul(n^r,1597334677)}t=Math.imul(t^t>>>16,2246822507);t^=Math.imul(n^n>>>13,3266489909);n=Math.imul(n^n>>>16,2246822507);n^=Math.imul(t^t>>>13,3266489909);return`${(n>>>0).toString(36).padStart(7,"0")}${(t>>>0).toString(36).padStart(7,"0")}`}function RH(e,t){const n=e.match(/^\s*/)[0];const i=e.slice(n.length);if(i.length===0)return e;const r=/^svg(?![\w-])/.exec(i);if(r)return`${n}svg.${t}${i.slice(3)}`;return`${n}.${t} ${i}`}function vH(e){const t=[];let n=0;let i;let r=0;for(let o=0;o<e.length;o++){const s=e[o];if(i){if(s==="\\")o++;else if(s===i)i=void 0}else if(s==='"'||s==="'"){i=s}else if(s==="("||s==="["){n++}else if(s===")"||s==="]"){n--}else if(s===","&&n===0){t.push(e.slice(r,o));r=o+1}}t.push(e.slice(r));return t}var TH=new Set(["media","supports","container","layer","document"]);function Hv(e,t){let n="";let i=0;let r=0;let o;let s=0;while(i<e.length){const a=e[i];if(o){if(a==="\\")i++;else if(a===o)o=void 0;i++;continue}if(a==="/"&&e[i+1]==="*"){const l=e.indexOf("*/",i+2);i=l<0?e.length:l+2;continue}if(a==='"'||a==="'"){o=a}else if(a==="("){s++}else if(a===")"){s=Math.max(0,s-1)}else if(a===";"&&s===0){n+=e.slice(r,i+1);r=i+1}else if(a==="{"&&s===0){const l=AH(e,i);const c=e.slice(r,i);const d=e.slice(i+1,l);n+=LH(c,d,t);i=l+1;r=i;continue}i++}return n+e.slice(r)}function LH(e,t,n){const i=e.match(/^(?:\s*\/\*[\s\S]*?\*\/)*/)[0];const r=e.slice(i.length);const o=/^\s*@([\w-]+)/.exec(r);if(o){const a=o[1].toLowerCase();const l=TH.has(a)?Hv(t,n):t;return`${e}{${l}}`}const s=vH(r).map(a=>RH(a,n)).join(",");return`${i}${s}{${t}}`}function AH(e,t){let n=0;let i;for(let r=t;r<e.length;r++){const o=e[r];if(i){if(o==="\\")r++;else if(o===i)i=void 0}else if(o==="/"&&e[r+1]==="*"){const s=e.indexOf("*/",r+2);if(s<0)return e.length;r=s+1}else if(o==='"'||o==="'"){i=o}else if(o==="{"){n++}else if(o==="}"){n--;if(n===0)return r}}return e.length}function jv(e){const t=Cu(e);if(!t)return e;const n=z1(e);if(n.length===0)return e;const i=`${PH}${EH(e)}`;let r=e;for(let l=n.length-1;l>=0;l--){const c=n[l];r=`${r.slice(0,c.start)}${Hv(r.slice(c.start,c.end),i)}${r.slice(c.end)}`}const o=r.slice(t.start,t.end);const s=gl(t,"class");const a=s?`${o.slice(0,s.valueEnd-t.start)}${s.value?" ":""}${i}${o.slice(s.valueEnd-t.start)}`:`${o.slice(0,-1)} class="${i}">`;return Pu(r,t,a)}function IH(e,t,n){const i=AC(e);const r=[];function o(s,a,l){for(let c=0;c<s.length;c++){const d=s[c];const u=`${a}.${c}`;if(d.kind==="group"){r.push(d);let f;let h=1;let m;for(let y=r.length-1;y>=0;y--){const b=r[y];if(b.matrix!==void 0||f!==void 0){f=hl(b.matrix??fl,f??fl)}h=Qx(b.opacity,h);if(b.conditional)m=true}const p=LC(l?.ancestors,d.own);const g=d.owner?.id===d.own.id&&d.owner.role===d.own.role?p.at(-1):d.owner;o(d.children,u,{parentMatrix:f,ancestors:p,owner:g,conditional:m,groupOpacity:h});r.pop()}else if(l){const f=!d.conditional&&n(d.node,d.svg);i.leaf(d.node,u,l.parentMatrix,l.ancestors,l.conditional||!f,l.groupOpacity,d.node.owner??l.owner)}else{const f=!d.conditional&&n(d.node,d.svg);i.leaf(d.node,u,void 0,void 0,!f)}}}o(t,"scene");return i.finish()}function Yv(e,t,n,i){const r={family:n,width:t.positioned.width,height:t.positioned.height,colors:t.colors,transparent:t.resolved.renderOptions.transparent??false};const o=DC(ws);if(n.startsWith("family:"))o.uncertain();let s=o.snapshot(r);const a=yC(r);const l=new WeakSet;const c=R=>{if(o.retainFragment())l.add(R);return Object.freeze(R)};const d=R=>{const M=o.leaf(R);const P=a.node(M.node);return c({kind:"leaf",node:M.node,svg:P,conditional:M.conditional,nodeCount:1,depth:0,prepared:R.kind==="document"?!/<\s*text/i.test(P):R.kind!=="text"||R.measurement==="prepared"&&R.block!==void 0})};const u={shape:R=>d(um(R)),text:R=>d(Ux(R)),connector:R=>d(_o(R)),documentOpen:(R,M)=>{const P=o.snapshot(R);if(P){s=Object.freeze({family:n,width:P.width,height:P.height,colors:P.colors,transparent:P.transparent});s=o.header(s,M)}else o.uncertain();return d(lC(R,M))},documentContent:(R,M)=>d(iC(R,M)),documentText:R=>d(rC(R)),definitions:(R,M)=>d(oC(R,M)),documentClose:()=>d(sC()),group(R){const M=Object.getOwnPropertyDescriptor(R,"children");if(!M||!("value"in M))o.uncertain();const{children:P,...E}=R;const v=o.parts(P,Ml.maxNodes);const L=[];let T=1,A=0,$=1,_=true;const z=[];for(const W of v){const O=Object.getOwnPropertyDescriptor(W,"node"),N=Object.getOwnPropertyDescriptor(W,"indent");if(!O||!("value"in O)||!N||!("value"in N))o.uncertain();const H=Object.freeze({node:W.node,indent:W.indent});L.push(H);if(!l.has(H.node))o.uncertain();z.push(H.node);T+=H.node.nodeCount;A+=H.node.svg.length;$=Math.max($,1+H.node.depth);_=_&&H.node.prepared}if(T>Ml.maxNodes)throw new RangeError("Native drawing contains too many emitted nodes");if(A>Ml.maxSerializationBytesPerNode)throw new RangeError("Native group has an oversized SVG serialization");const F=aC({...E,children:[]});a.node(F);a.depth($);const G=o.snapshot(F);const I=G?o.group(G):void 0;const D=G?.identity??{id:F.id,role:F.role};for(const W of z){if(W.kind==="leaf"&&W.node.kind==="shape"&&!W.node.identity)a.enclosure(W.node.id,D)}const B=[F.open];for(const W of L)B.push(q1(W.node.svg,W.indent));B.push(F.close);const Y=B.join(F.join);a.serialization(Y);return c({kind:"group",svg:Y,children:Object.freeze(z),matrix:I,own:D,owner:G?.owner,conditional:!G||F.visibility==="conditional",opacity:Pn(G?.paint?.opacity),nodeCount:T,depth:$,prepared:!/<\s*text/i.test(F.open+F.close)&&_})},pathArtwork:R=>cC(u,R)};const f=lm(()=>e(u,t));for(const R of["parts","family","width","height","colors","transparent"]){const M=Object.getOwnPropertyDescriptor(f,R);if(!M||!("value"in M))o.uncertain()}const h=o.parts(f.parts,Ml.maxNodes);for(const R of h)if(!l.has(R))o.uncertain();const m=a.finish();if(!m.valid)throw new fm(m.diagnostics);let p=0,g=-1,y=true;for(const R of h){p+=R.nodeCount;g+=R.svg.length+1;y=y&&R.prepared}if(p>Ml.maxNodes)throw new RangeError("Native drawing contains too many emitted nodes");if(g>Ml.maxFinalSvgBytes)throw new RangeError("Native drawing exceeds the final SVG limit");const b=bC(f,{seed:0,...i?{style:i}:{}});const S=h.map((R,M)=>M===0&&b?`${R.svg}
|
|
11
|
-
${b}`:R.svg).join("\n");Yr(S,"native drawing output");const x=s??Object.freeze({...r,colors:Object.freeze({bg:"none",fg:"none"})});const k=o.snapshot({family:f.family,width:f.width,height:f.height,colors:f.colors,transparent:f.transparent});const w=Object.freeze({...x,family:k?.family??n});if(!k||!o.same({...k,width:Number(Ue(k.width)),height:Number(Ue(k.height))},w))o.uncertain();const C=IH(w,h,o.observe);o.finish(C,w);return Object.freeze({svg:S,header:w,preparedText:y,paint:C})}function qv(e,t,n="scene.parts"){e.forEach((i,r)=>{const o=`${n}[${r}]`;t(i,o);if(i.kind==="group")qv(i.children.map(s=>s.node),t,`${o}.children`)})}function cw(e,t,n=oa()){const i=e.id.startsWith("family:");const r=xC(t,i?"external":"internal",n);if(!i&&!n)return r;const o=[];if(i&&r.family!==e.id){o.push({code:"SCENE_DOCUMENT",path:"scene.family",message:`external family "${e.id}" emitted a document owned by "${r.family}"`})}const s=new Set(e.semanticRoles);const a=new Set(e.semanticChannels);const l=new Map(e.scenePrimitiveEvidence.map(c=>[`${c.role}\0${c.primitive}`,c]));qv(r.parts,(c,d)=>{if(!s.has(c.role)){o.push({code:"SCENE_PRIMITIVE_CLAIM",path:`${d}.role`,message:`emitted undeclared role "${c.role}"`});return}for(const u of Object.keys(c.channels??{})){if(!a.has(u)){o.push({code:"SCENE_CHANNEL_CLAIM",path:`${d}.channels.${u}`,message:`emitted undeclared semantic channel "${u}"`})}}for(const u of eC(c)){const f=l.get(`${c.role}\0${u}`);if(!f||f.applicability!=="applicable"||f.realization==="unsupported"){o.push({code:"SCENE_PRIMITIVE_CLAIM",path:d,message:`emitted undeclared ${c.role}/${u} primitive`})}}});if(o.length>0)throw new fm(Object.freeze(o));return r}var _p=new WeakMap;var dw=new WeakMap;function uw(e,t){let n=dw.get(t);if(!n){n=new WeakMap;dw.set(t,n)}const i=n.get(e);if(i){Ht("positioned-scene","hit");if(oa(e)&&!i.crossChecks){cw(Gi(e).family,i.scene,true);i.crossChecks=true}return i.scene}Ht("positioned-scene","miss");const r=Gi(e);if(!r.family.lowerScene)throw new Error(`Resolved ${e.output} family has no Scene lowering`);const o=e.output==="png"&&e.appearance.colors.embedFontImport!==false?{...e.appearance.colors,embedFontImport:false}:e.appearance.colors;const s=oa(e);const a=()=>r.family.lowerScene({positioned:t.positioned,colors:o,resolved:Dl(e)});const l=ul(r.textMeasurement,()=>cw(r.family,!s&&!r.family.id.startsWith("family:")?lm(a):a(),s));n.set(e,{scene:l,crossChecks:s});return l}function fw(e,t){const n=Gi(e);let i=oa(e)?"scene-assertions":n.family.id.startsWith("family:")?"external-family":n.backend&&!SC(n.backend.backend)?"alternate-backend":!(n.mode==="layout"?e.appearance.inferredBackend==="default":n.mode==="scene"&&n.backend?.inputName==="default")?"unsupported-mode":void 0;let r=i?void 0:Vo(n.family.lowerScene);if(!r)i??="no-native-producer";if(i){Ht("native-drawing","bypass",i);pl("native-drawing",i);return void 0}let o=_p.get(t);if(!o){o=new WeakMap;_p.set(t,o)}const s=o.get(e);if(s){Ht("native-drawing","hit");if(s.producer===Vo(n.family.lowerScene))return s.drawing;Ht("native-drawing","bypass","changed-producer");o.delete(e)}if(n.backend)MC(n.backend.conformance,n.backend.inputName);r=Vo(n.family.lowerScene);const a=Fp(e,t,r===yd(n.family.lowerScene));if(a){Ht("native-drawing","hit",void 0,"positioned-owner");const u=r;if(u&&u===Vo(n.family.lowerScene)&&u===yd(n.family.lowerScene)){o.set(e,{drawing:a,producer:u,certification:a.certification});return a}Ht("native-drawing","bypass","changed-producer");Fp(e,t,false);r=Vo(n.family.lowerScene)}Ht("native-drawing","miss");r=Vo(n.family.lowerScene);if(!r){Ht("native-drawing","bypass","no-native-producer");pl("native-drawing","no-native-producer");return void 0}const l=r;const c=e.output==="png"&&e.appearance.colors.embedFontImport!==false?{...e.appearance.colors,embedFontImport:false}:e.appearance.colors;const d=ul(n.textMeasurement,()=>Yv(l,{positioned:zv(t,l),colors:c,resolved:Dl(e)},n.family.id,e.appearance.styled?e.appearance.style:void 0));o.set(e,{drawing:d,producer:l,evidence:d});return d}function Xv(e,t){const n=_p.get(t)?.get(e);const i=n?.drawing??fw(e,t);if(i){const l=_p.get(t).get(e);Ht("paint-certification",l.certification?"hit":"miss",void 0,"native");if(l.certification)return l.certification;const c=l.evidence;const d=ib(c.header,c.paint,lw(t),{outputSupported:!e.appearance.colors.shadow});l.certification=d;const u=Object.freeze({svg:i.svg,preparedText:i.preparedText,certification:d});const f=Gi(e).family.lowerScene;if(l.producer===Vo(f)&&l.producer===yd(f))Nv(e,t,u);else{Ht("native-drawing","store-skipped","changed-producer");Fp(e,t,false)}return d}const r=uw(e,t);const o=dw.get(t).get(e);Ht("paint-certification",o.certification?"hit":"miss",void 0,"scene");if(o.certification)return o.certification;const s=Gi(e);const a=!e.appearance.colors.shadow&&(s.mode==="layout"?e.appearance.inferredBackend==="default":s.mode==="scene"&&s.backend?.inputName==="default");return o.certification=qC(r,lw(t),{outputSupported:a})}function FH(e){Yr(e,"graphical projection digest input");return Qc(JSON.stringify(e))}function NH(e,t){const n=e.appearance.colors;const i=e.output==="png"&&n.embedFontImport!==false?{...n,embedFontImport:false}:n;return{positioned:t.positioned,colors:i,resolved:Dl(e)}}function $H(e,t){const n=Gi(e);if(n.mode!=="scene")throw new Error(`Resolved ${e.output} request has no Scene execution plan`);return uw(e,t)}function hw(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function _H(e,t,n,i){const r=`${n}svg-title`;const o=`${n}svg-desc`;const s=[];const a=[];if(t.title){s.push(`aria-labelledby="${r}"`);a.push(`<title id="${r}">${hw(t.title)}</title>`)}if(t.descr){s.push(`aria-describedby="${o}"`);a.push(`<desc id="${o}">${hw(t.descr)}</desc>`)}if(a.length===0&&!i)return e;const l=Cu(e);if(!l)return e;if(gl(l,"aria-labelledby")||gl(l,"aria-describedby"))return e;if(i&&!t.title&&!gl(l,"aria-label"))s.push(`aria-label="${hw(i).replace(/"/g,""")}"`);const c=`${gl(l,"role")?"":' role="img"'} ${s.join(" ")}`;const d=e.slice(l.start,l.end);return Pu(e,l,`${d.slice(0,-1)}${c}>${a.join("")}`)}function DH(e,t){const n=Cu(e);if(!n)throw new Error("Cannot certify a graphical output with no SVG root");const i=e.slice(n.start,n.end);const r=i.replace(/\sviewBox="[^"]*"/g,"");const o=` viewBox="${t.x} ${t.y} ${t.width} ${t.height}"`;return Pu(e,n,r.slice(0,-1)+o+">")}function OH(e,t,n,i){return ul(Gi(e).textMeasurement,()=>BH(e,t,n,i))}function BH(e,t,n,i){const r=Gi(e);if(r.mode!=="scene"&&r.mode!=="family-svg"||!r.executionDecision){throw new Error(`Resolved ${e.output} request has no graphical execution plan`)}const o=e.renderOptions;const s=r.family;const a=NH(e,t);let l;let c=false;let d;if(r.mode==="scene"){const y=i?void 0:ei("drawing",()=>fw(e,t));const b=y?void 0:ei("scene",()=>$H(e,t));d=ei("paint-certification",()=>Xv(e,t));if(o.layoutSafety==="strict"&&d.status!=="passed"||d.status==="failed"&&r.backend?.inputName==="default")throw new ym(d);l=y?.svg??ei("backend",()=>{const S={seed:o.seed??0,...e.appearance.styled?{style:e.appearance.style}:{}};i?.begin(S,b);return r.backend.backend.render(b,S)});c=r.backend?.inputName==="default"&&!s.id.startsWith("family:")&&(y?.preparedText??U1(b))}else{if(o.layoutSafety==="strict")throw new Ir("Strict layout safety requires native Scene evidence");l=ei("backend",()=>s.renderSvg(a))}Yr(l,"backend/family SVG output");let u=H1(l,a.colors);if(d?.repairs.length&&r.backend?.inputName==="default")u=DH(u,d.viewport);Yr(u,"color-resolved SVG output");if(!c)u=wv(u,e.appearance.font);Yr(u,"font-geometry-fitted SVG output");const f=o.idPrefix??"";if(f){u=tw(u,f);Yr(u,"namespaced SVG output")}const h=e.source.accessibility;const m=s.id==="c4"?"C4 architecture diagram":void 0;if((t.injectAccessibility??true)&&(h.title||h.descr||m)){u=_H(u,h,f,m);Yr(u,"accessibility-projected SVG output")}if(i)u=i.finish(u);u=jv(mv(u));Yr(u,"style-scoped SVG output");if(o.compact){u=ew(u);Yr(u,"compacted SVG output")}const p=e.output==="png"?"strict":o.security;const g=ei("svg-security",()=>Z1(u,p));n.push(...g.diagnostics);u=g.svg;Yr(u,"final SVG output");return Object.freeze({svg:u,executionDecision:r.executionDecision,...d?{layoutCertification:d}:{}})}function WH(e,t){return OH(e,ei("layout",()=>Wv(e)),t)}function Pre(e,t,n,i,r={}){return W1(()=>zH(e,t,n,i,r))}function zH(e,t,n,i,r){const o=ei("request",()=>wS(e,t,n,i,r));return GH(o)}function GH(e){hv(e);const t=[];const n=WH(e,t);return HH(e,n,t)}function HH(e,t,n){const i=Object.hasOwn(t,"layoutCertification")?t.layoutCertification:void 0;return jH(t.svg,()=>{const r=FH(t.svg);return Object.freeze({...eR(e,n),graphicalProjectionDigest:r,executionDecision:t.executionDecision,...i?{layoutCertification:Object.freeze({...i,outputDigest:r})}:{}})})}function jH(e,t){let n=t;let i;return Object.freeze({svg:e,get receipt(){if(i===void 0){i=n();n=void 0}return i}})}var Tre=["padding","sectionWidth","ticketBaseUrl","useMaxWidth"];function hf(e={}){const t=Sn(e,["kanban"])??{};return{padding:typeof t.padding==="number"&&Number.isFinite(t.padding)&&t.padding>=0?t.padding:8,sectionWidth:typeof t.sectionWidth==="number"&&Number.isFinite(t.sectionWidth)&&t.sectionWidth>0?t.sectionWidth:240,ticketBaseUrl:typeof t.ticketBaseUrl==="string"?t.ticketBaseUrl:""}}function Dp(e,t){if(!e||!t)return void 0;const n=e.replaceAll("#TICKET#",encodeURIComponent(t));return/^(?:https?:|mailto:|\/|#)/i.test(n)&&bs(n)&&!/[\u0000-\u0020\u007f-\u009f]/.test(n)?n:void 0}var an=(e,t)=>({expected:e,valid:t});var Kt=an("a finite positive number",e=>typeof e==="number"&&Number.isFinite(e)&&e>0);var jt=an("a finite non-negative number",e=>typeof e==="number"&&Number.isFinite(e)&&e>=0);var Op=an("a finite number",e=>typeof e==="number"&&Number.isFinite(e));var ct=an("a boolean",e=>typeof e==="boolean");var Dr=an("a string",e=>typeof e==="string");var bd=an("a non-empty string",e=>typeof e==="string"&&e.trim().length>0);var Uv=an("a CSS font-family list without url(), @import or other functions besides var()",e=>mo(e)!==void 0);var mf=an("a non-empty array of strings",e=>Array.isArray(e)&&e.length>0&&e.every(t=>typeof t==="string"));var Ws=(...e)=>an(`one of: ${e.join(", ")}`,t=>typeof t==="string"&&e.includes(t));var Bp=(...e)=>an(`one of: ${e.join(", ")} (case-insensitive)`,t=>typeof t==="string"&&e.some(n=>n.toLowerCase()===t.toLowerCase()));var wn=(e,t,n=true)=>an(`a finite number ${n?"from":"greater than"} ${e} through ${t}`,i=>typeof i==="number"&&Number.isFinite(i)&&(n?i>=e:i>e)&&i<=t);var Ko=e=>an(`a finite positive number no greater than ${e}`,t=>typeof t==="number"&&Number.isFinite(t)&&t>0&&t<=e);var Ul=e=>an(`a finite non-negative number no greater than ${e}`,t=>typeof t==="number"&&Number.isFinite(t)&&t>=0&&t<=e);var Vv=an("a finite positive number or non-empty CSS size string",e=>typeof e==="number"&&Number.isFinite(e)&&e>0||typeof e==="string"&&e.trim().length>0);var $a=(e,t=false)=>an(`a numeric value${t?` greater than ${e}`:` of at least ${e}`}`,n=>{const i=typeof n==="number"?n:typeof n==="string"&&/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)(?:px)?$/i.test(n.trim())?Number.parseFloat(n):Number.NaN;return Number.isFinite(i)&&(t?i>e:i>=e)});var YH=new Map([["person","person"],["box","rectangle"],["rectangle","rectangle"],["cylinder","database"],["database","database"],["db","database"],["queue","queue"],["pipe","queue"]]);function mw(e){return e===void 0?void 0:YH.get(e.trim().toLowerCase())}function Ro(e){return mw(e.style.shape)??e.shape}var Or=(e,t,n=0)=>{if(e===void 0)return t;if(typeof e!=="number"||!Number.isFinite(e)||e<n||e>1e4)throw new RangeError(`Invalid C4 numeric configuration ${JSON.stringify(e)}; expected a finite number from ${n} to 10000`);return e};var Kv=(e,t)=>{const n=Or(e,t,1);if(!Number.isSafeInteger(n))throw new RangeError(`Invalid C4 row count ${JSON.stringify(e)}; expected a positive integer`);return n};function Wp(e={},t={}){e=Object.fromEntries(Object.entries(e).filter(([i,r])=>pw[i]?.valid(r)??true));const n=e.compact===true;return{compact:n,typeLegend:e.typeLegend!==false,...e.maxWidth===void 0?{}:{maxWidth:Or(e.maxWidth,1e4,1)},marginX:Or(e.diagramMarginX,n?16:24),marginY:Or(e.diagramMarginY,n?16:24),gap:Or(e.c4ShapeMargin,n?32:56),padding:Or(e.c4ShapePadding,n?10:16,4),minimumWidth:Or(e.width,n?120:150,24),minimumHeight:Or(e.height,n?60:76,24),boundaryPadding:Or(e.boxMargin,n?16:24,12),rowGap:Or(e.nextLinePaddingX,n?36:56),shapesPerRow:Kv(e.c4ShapeInRow,3),boundariesPerRow:Kv(e.c4BoundaryInRow,2),...e.wrap===false?{}:{wrapWidth:Or(e.wrapPadding,n?220:260,40)},input:e,themeVariables:t}}function qH(e){if(!("external"in e))return e.kind==="deployment"?"node":"boundary";return`${e.external?"external_":""}${e.kind}${e.shape==="database"?"_db":e.shape==="queue"?"_queue":""}`}function zs(e,t){const n=qH(e),{input:i,themeVariables:r}=t;const o=(l,c)=>{if(l===void 0)return void 0;const d=mn(l,c!=="color");if(d===void 0)throw new Fu(`C4 ${e.id}`,c,String(l),`UpdateElementStyle(${e.id})`);return d};const s=i[`${n}FontSize`],a=i[`${n}FontWeight`];return{fill:o(e.style.bgColor??i[`${n}_bg_color`]??r[`${n}_bg_color`],"fill"),stroke:o(e.style.borderColor??i[`${n}_border_color`]??r[`${n}_border_color`],"stroke"),text:o(e.style.fontColor??e.style.textColor,"color"),...s===void 0?{}:{fontSize:Or(s,13,1)},...a===void 0?{}:{fontWeight:Or(typeof a==="string"&&/^\d+$/.test(a)?Number(a):a,500,1)},dashed:e.style.lineStyle===void 0?"external"in e&&e.external:e.style.lineStyle==="dashed"||e.style.lineStyle==="dotted"}}var Jv=["person","external_person",...["system","container","component"].flatMap(e=>["","external_"].flatMap(t=>["","_db","_queue"].map(n=>`${t}${e}${n}`))),"boundary","node"];var XH=Object.freeze(["diagramMarginX","diagramMarginY","c4ShapeMargin","c4ShapePadding","width","height","boxMargin","nextLinePaddingX","c4ShapeInRow","c4BoundaryInRow","wrap","wrapPadding","maxWidth","compact","typeLegend",...Jv.flatMap(e=>[`${e}FontSize`,`${e}FontWeight`,`${e}_bg_color`,`${e}_border_color`])]);var _re=Object.freeze(["useMaxWidth",...[...Jv,"message"].flatMap(e=>[`${e}Font`,`${e}FontFamily`]),"messageFontSize","messageFontWeight"]);var UH=Object.freeze({maxWidth:1,diagramMarginX:0,diagramMarginY:0,c4ShapeMargin:0,c4ShapePadding:4,width:24,height:24,boxMargin:12,nextLinePaddingX:0,c4ShapeInRow:1,c4BoundaryInRow:1,wrapPadding:40});var pw=(()=>{const e=Object.assign(Object.create(null),{wrap:ct,compact:ct,typeLegend:ct});for(const[t,n]of Object.entries(UH)){const i=wn(n,1e4);e[t]=t==="c4ShapeInRow"||t==="c4BoundaryInRow"?an("an integer from 1 through 10000",r=>Number.isSafeInteger(r)&&i.valid(r)):i}for(const t of XH){if(/FontSize$/.test(t))e[t]=wn(1,1e4);if(/FontWeight$/.test(t)){const n=wn(1,1e3);e[t]=an(n.expected,i=>n.valid(typeof i==="string"&&/^\d+$/.test(i)?Number(i):i))}}return Object.freeze(e)})();function yw(e){if(!/#\w+;/.test(e))return{text:e,restore:f=>f,sourceOffset:f=>f};const t=new Map;const n=f=>{const h=f.codePointAt(0);if(h>=57344&&h<=63743)t.set(f,(t.get(f)??0)+1)};for(const f of e)n(f);for(const f of e.matchAll(/\\(?:u([\da-fA-F]{4})|U([\da-fA-F]{8}))/g)){const h=Number.parseInt(f[1]??f[2],16);if(h<=1114111)n(String.fromCodePoint(h))}let i="\uE000";let r=t.get(i)??0;for(let f=57345;r>0&&f<=63743;f++){const h=String.fromCodePoint(f),m=t.get(h)??0;if(m<r){i=h;r=m}}let o=e.length;const s=/#\w+;/g;while(s.test(e))o+=2*r;Ve("sourceCharacters",e.length+o);const a=i.repeat(r+1);const l=new RegExp(`${a}(\\w+)${a}`,"g");const c=[];let d=0;const u=e.replace(/#\w+;/g,(f,h)=>{const m=`${a}${f.slice(1,-1)}${a}`,p=h+d;c.push({start:p,end:p+m.length,sourceStart:h,sourceEnd:h+f.length});d+=m.length-f.length;return m});return{text:u,restore:f=>f.replace(l,(h,m)=>`#${m};`),sourceOffset:f=>{let h=0,m=c.length;while(h<m){const g=h+m>>>1;if(c[g].start<=f)h=g+1;else m=g}const p=c[h-1];return p?f<p.end?p.sourceStart:f-p.end+p.sourceEnd:f}}}function VH(e,t){const n=yw(e);const i=n.text;const r=As(i.includes("\n")?`${i}
|
|
12
|
-
`:`{
|
|
13
|
-
${i}
|
|
14
|
-
}`);if(!r.ok)return r;const o=r.value;if(t==="flowchart"&&(o===null||o===void 0)){return{ok:false,message:"empty @{} metadata document"}}const s=new Map;if(o&&typeof o==="object"&&!Array.isArray(o)){try{for(const[a,l]of Object.entries(gw(o,n.restore)))s.set(a,l)}catch(a){return{ok:false,message:a instanceof Error?a.message:String(a)}}}return{ok:true,entries:s}}function gw(e,t){if(typeof e==="string")return t(e);if(Array.isArray(e))return e.map(n=>gw(n,t));if(e&&typeof e==="object"){const n=new Set;return Object.fromEntries(Object.entries(e).map(([i,r])=>{const o=t(i);if(n.has(o))throw new Error(`duplicate metadata key ${JSON.stringify(o)}`);n.add(o);return[o,gw(r,t)]}))}return e}function Vl(e,t,n){const i=ga(e,t,n);if(i.kind==="unclosed")return{ok:false,unclosed:true,message:"unclosed @{ metadata block"};if(i.kind==="invalid")return{ok:false,unclosed:false,message:i.message};const r=VH(i.body,n);return r.ok?{ok:true,end:i.end,entries:r.entries}:{ok:false,unclosed:false,message:r.message}}function pf(e){return e?String(e):void 0}function zre(e){let t='"';const n=e.includes("%%{");for(const i of e){const r=i.codePointAt(0);if(i==="\\")t+="\\\\";else if(i==='"')t+="\\x22";else if(r<32||r>=127&&r<=159||n&&i==="%")t+=`\\x${r.toString(16).padStart(2,"0")}`;else if(r===8232||r===8233)t+=`\\u${r.toString(16)}`;else t+=i}return`${t}"`}import{decodeXML as Zv}from"entities";import{decodeHTML as KH,decodeHTMLStrict as JH}from"entities/decode";var Qv=class extends Error{loadHtmlEntityTable;constructor(t,n){super(`${t} needs the HTML entity table, which has not loaded`);this.loadHtmlEntityTable=n}};function zp(e){return KH(e)}function xw(e){const t=`&${e};`;return JH(t)!==t}var QH=/&(#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});|&(#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});/g;function bw(e){return e.startsWith("#")||Lu.has(e)||xw(e)}function ZH(e){if(!e.includes("&"))return e;return e.replace(QH,(t,n,i)=>{if(n!==void 0){if(!bw(n))return`&${n};`;return`#38;${n.replace("#","#35;")}#59;`}if(!i.startsWith("#")&&!Lu.has(i))return xw(i)?`#${i};`:t;const r=Zv(t);return r==="#"?"#35;":r===";"?"#59;":r})}function eT(e,t){const n=e.originalText;if(!n.includes("&"))return e;const i=ZH(n);return i===(t==="decoded"?Zv(n):n)?e:Hu(i)}var e4=new TextDecoder("windows-1252");var tT={subject:"Mermaid entity",example:"#35;"};function no(e,t=tT){return e.replace(Pl,(n,i,r)=>{let o;if(i!==void 0){const s=Number(i);o=s===0||s>1114111||s>=55296&&s<=57343?"\uFFFD":s>=128&&s<=159?e4.decode(Uint8Array.of(s)):String.fromCodePoint(s)}else{o=Lu.get(r)??zp(`&${r};`)}if(go.test(o)){throw Je({what:`${t.subject} projects a terminal control character`,expectedForm:"an entity that displays printable text",example:t.example})}return o})}function nn(e,t=tT){return no(Dn(e),t)}var Sw={subject:"Sequence text entity",example:"A->>B: #35;"};var t4=new RegExp(`#\\w+;|${Pl.source}`,"g");function Jo(e){const t=e.trim();const n=/^:?(wrap|nowrap):/.exec(t);return n?{text:t.slice(n[0].length).trim(),wrap:n[1]==="wrap"}:{text:t}}function ooe(e,t,n,i){const r=n===void 0?"":n?"wrap: ":"nowrap: ";let o=o4(e,t,i+r);if(!r&&/^:?(?:no)?wrap:/.test(o))o=`#${o.charCodeAt(0)};${o.slice(1)}`;return r+o}function n4(e){const t=nn(e,Sw);if(t===e)return{value:t};const n=cr(vt(yt(e)),t4,i=>nn(i,Sw));return{value:t,content:Object.freeze({value:t,authored:e,prepared:n})}}function _a(e){const t=n4(e);const n=nn(yt(e),Sw);return{label:n,...t.content?{labelContent:Object.freeze({...t.content,value:n})}:{}}}function i4(e){return e.replace(/\r\n|[\r\n]/g,"<br/>")}function r4(e){return dn(e,"#;")}function o4(e,t,n=""){let i;if(t?.value===e&&t.authored!==void 0){i=mr(t.authored,"#;")}else if(t?.value===e){i=A1(t.prepared,r=>dn(r,"#;*~_<").replace(/\\(?=n)/g,"#92;"),"<br/>")}else{i=r4(e)}i=i.replace(/&(?=#\d+;|#[xX][0-9a-fA-F]+;|([a-zA-Z][a-zA-Z\d]{0,31});)/g,(r,o)=>o===void 0||bw(o)?"#38;":r);i=i4(i).replace(/^ +| +$/g,r=>"#32;".repeat(r.length));i=i.replace(/%%/g,"%#37;");return Un(n+i)===n+i?i:i.replace(/:/g,"#58;")}var s4=/^(loop|alt|opt|par_over|par|critical|break|rect|box)\b\s*([\s\S]*)$/i;var a4=/^(else|and|option)\b\s*([\s\S]*)$/i;function nT(e){const t=s4.exec(e);if(!t)return null;const n=t[1].toLowerCase();const i=t[2]?.trim()??"";if(n==="box")return{type:n,label:i};const r=Jo(i);return{type:n,label:r.text,...r.wrap===void 0?{}:{wrap:r.wrap}}}function iT(e){const t=a4.exec(e);if(!t)return null;const n=Jo(t[2]??"");return{type:t[1].toLowerCase(),label:n.text,...n.wrap===void 0?{}:{wrap:n.wrap}}}function rT(e,t){return e==="else"&&t==="alt"||e==="and"&&(t==="par"||t==="par_over")||e==="option"&&t==="critical"}function ww(e){const t=e.toLowerCase();if(t==="transparent"||t in Jh)return true;if(!/^(?:#|(?:rgb|rgba|hsl|hsla)\()/i.test(e))return false;return Vt(e)!==null}function oT(e){const t=yl(e);if(!t)return void 0;const n=t.toLowerCase();if(n==="transparent"||Object.hasOwn(Jh,n))return t;const i=/^rgb\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/i.exec(t);if(i&&i.slice(1).every(o=>Number(o)<=255))return t;const r=/^rgba\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(0(?:\.\d+)?|\.\d+|1(?:\.0+)?)\s*\)$/i.exec(t);if(r&&r.slice(1,4).every(o=>Number(o)<=255))return t;return void 0}function Mw(e){const t=Jh[e.toLowerCase()];if(t)return t;const n=cl(e);if(n)return Yn(n[0],n[1],n[2]);const i=e.match(/^rgba?\(\s*(\d{1,3})\s*[, ]\s*(\d{1,3})\s*[, ]\s*(\d{1,3})/i);if(i)return Yn(Math.min(255,Number.parseInt(i[1],10)),Math.min(255,Number.parseInt(i[2],10)),Math.min(255,Number.parseInt(i[3],10)));return null}var Gp=class{constructor(t={}){this.options=t}options;records=new Map;order=[];boxes=[];currentBox;apply(t){if(t.kind==="links"){const n=this.records.get(t.id);if(n)n.links={...n.links,...t.links};return}this.addActor(t.id,t.kind==="declare"?t:void 0)}applyAll(t){for(const n of t)this.apply(n)}openBox(t){this.boxes.push(t);this.currentBox=this.boxes.length-1}closeBox(){this.currentBox=void 0}has(t){return this.records.has(t)}indexOf(t){return this.order.indexOf(t)}list(){return this.order.map(t=>this.records.get(t))}addActor(t,n){const i=this.records.get(t);let r=this.currentBox;if(i){if(r!==void 0&&i.box!==void 0&&r!==i.box){this.options.onBoxConflict?.(t)}r=i.box??r;if(r!==void 0)i.box=r;if(n?.label===void 0||n.create)return}const o={id:t,label:n?.label??t,...n?.wrap===void 0?{}:{wrap:n.wrap},type:n?.type??"participant",...n?{keyword:n.keyword}:{},...i?.links&&!this.options.upstreamLinks?{links:i.links}:{},...r!==void 0?{box:r}:{}};this.records.set(t,o);if(!i)this.order.push(t);if(this.currentBox!==void 0&&r===this.currentBox)this.boxes[this.currentBox].actorIds.push(t)}};var gf=new Map([["<<-->>",["filled","filled"]],["<<->>",["filled","filled"]],["-->>",["none","filled"]],["->>",["none","filled"]],["-->",["none","none"]],["->",["none","none"]],["--x",["none","cross"]],["-x",["none","cross"]],["--)",["none","open"]],["-)",["none","open"]],["--|\\",["none","half-top"]],["-|\\",["none","half-top"]],["--|/",["none","half-bottom"]],["-|/",["none","half-bottom"]],["--\\\\",["none","stick-top"]],["-\\\\",["none","stick-top"]],["--//",["none","stick-bottom"]],["-//",["none","stick-bottom"]],["/|--",["half-bottom","none"]],["/|-",["half-bottom","none"]],["\\|--",["half-top","none"]],["\\|-",["half-top","none"]],["//--",["stick-bottom","none"]],["//-",["stick-bottom","none"]],["\\\\--",["stick-top","none"]],["\\\\-",["stick-top","none"]],["--|",["none","stick-top"]],["-|",["none","stick-top"]],["--/",["none","stick-bottom"]],["-/",["none","stick-bottom"]],["--\\",["none","stick-top"]],["-\\",["none","stick-top"]],["|--",["stick-top","none"]],["|-",["stick-top","none"]],["/--",["stick-bottom","none"]],["/-",["stick-bottom","none"]],["\\--",["stick-top","none"]],["\\-",["stick-top","none"]]]);var kw=new Set(["--|","-|","--/","-/","--\\","-\\","|--","|-","/--","/-","\\--","\\-"]);var l4=new Map([...kw].map(e=>{const[t,n]=gf.get(e);const i=[...gf].find(([r,o])=>!kw.has(r)&&o[0]===t&&o[1]===n&&r.includes("--")===e.includes("--"))[0];return[e,i]}));var aT=[...gf.keys()].sort((e,t)=>t.length-e.length);var lT=aT.map(e=>e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|");var c4=new RegExp(String.raw`^(\S+?)(\(\))?\s*(${lT})`);var d4=new RegExp(String.raw`^(\S+?)\s+(\(\))\s*(${lT})`);var Hp=new Set(["participant","actor","note","alt","else","loop","rect","opt","par","and","end","activate","deactivate","autonumber","box","create","destroy","link","links","critical","break","option","title","over","off","properties","details","sequencediagram","par_over"]);var u4=new Set([...Hp,"acctitle","accdescr"]);var jp=/(?:#\w+;|[^\/\\\+\()\+<\->\->:\n,;])+((?!(\-x|\-\-x|\-\)|\-\-\)|\-\|\\|\-\\|\-\/|\-\/\/|\-\|\/|\/\|\-|\\\|\-|\/\/\-|\\\\\-|\/\|\-|\-\-\|\\|\-\-|\(\)))[\-]*(?:#\w+;|[^\+<\->\->:\n,;])+)*/iy;function Cw(e,t){jp.lastIndex=t;return jp.exec(e)?.[0].trim()??""}function f4(e){jp.lastIndex=0;const t=jp.exec(e);if(!t)return void 0;let n=t[0].length;const i=e.startsWith("()",n);const r=i&&/\s$/.test(t[0]);if(i)n+=2;while(n<e.length&&/\s/.test(e[n]))n++;const o=aT.find(s=>e.startsWith(s,n));if(!o)return void 0;n+=o.length;return{from:t[0].trim(),arrow:o,end:n,centralStart:i,spacedCentral:r}}function cT(e,t){if(!e||e.trim()!==e||/[\r\n]/.test(e))return false;const n=Dn(e);if(n.startsWith("#"))return false;if(t==="declaration")return vw(e)&&!/:/.test(n)&&!n.includes("%%{");if(n.startsWith("%")||n.includes("%%"))return false;const i=n.toLowerCase();const r=/^(\w+)\b/.exec(i)?.[1];if(r&&Hp.has(r)&&(!["title","link","links","properties","details"].includes(r)||/\s/.test(i.slice(r.length,r.length+1))))return false;if(/^(?:\d+(?:\.\d{1,2})?|\.\d{1,2})(?=\s)/.test(n))return false;if(Hp.has(i)&&!["title","link","links","properties","details"].includes(i))return false;if(t==="receiver"&&["acctitle","accdescr"].includes(i))return false;if(/^(?:left|right) of\b/.test(i))return false;return Cw(`${n}${t==="sender"?"->>Z:":":"}`,0)===n}var Ew=new WeakMap;var Rw=new WeakMap;function dT(e){return Rw.get(e)}function uT(e){return Ew.get(e)}function fT(e,t){Ew.set(e,t)}function hT(e,t){Rw.set(e,t)}function h4(e){let t=f4(e);if(!t){const b=e.match(c4);const S=b??e.match(d4);if(S)t={from:S[1],centralStart:Boolean(S[2]),arrow:S[3],end:S[0].length,spacedCentral:!b}}if(!t||!S4(t.arrow))return null;const{from:n,arrow:i,centralStart:r,spacedCentral:o}=t;if(o&&(/^(?:[0-9]+(?:\.[0-9]{1,2})?|\.[0-9]{1,2})$/.test(n)||Hp.has(n.toLowerCase())))return null;let s=e.slice(t.end).trimStart();const a=s.startsWith("()");if(a)s=s.slice(2).trimStart();const l=s[0]==="+"||s[0]==="-"?s[0]:void 0;if(o&&l)return null;if(l)s=s.slice(1).trimStart();const c=s.indexOf(":");if(c<1)return null;const d=s.slice(0,c).trimEnd();const{text:u,wrap:f}=Jo(s.slice(c+1));if(!d)return null;if(o&&(/[+<>]/.test(d)||d.includes("()")||u4.has(d.toLowerCase())))return null;const h=Dn(e);const m=Dn(n),p=Dn(d);const g=Dn(e.slice(0,e.length-s.length)).length;const y=Cw(h,0);if(y.length<=m.length&&(y!==m||Cw(h,g)!==p))return null;return{from:n,arrow:l4.get(i)??i,activationMark:l,to:d,label:u,centralStart:r,centralEnd:a,...f===void 0?{}:{wrap:f},...kw.has(i)?{localArrow:i}:{}}}function mT(e,t={}){const n=Yb(e);const i=Wt(n.map(S=>S.raw));const r=i.familyLines.flatMap((S,x)=>S.trim()?[{text:S.trim(),origin:n[i.familyOrigins[x]].line}]:[]);e=r.map(S=>S.text);const o=S=>{const x=r[S]?.origin??S;return t.authoredLine?.(x)??x+1};if(ie("sequence")&&e[0]!==void 0)Ge("sequence","header",e[0],{line:1,unit:"normalized"});const s={actors:[],messages:[],blocks:[],notes:[],activationEvents:[],boxes:[],...i.accessibility.title!==void 0?{accessibilityTitle:yt(i.accessibility.title)}:{},...i.accessibility.descr!==void 0?{accessibilityDescription:yt(i.accessibility.descr)}:{}};const a=new Gp;const l=new Map;const c=new Map;const d=m4(e.slice(1));const u=d.issues.find(S=>S.syntax==="sequence_block_boundary");if(u)throw new Error(`SEQUENCE_BLOCK_BOUNDARY: line ${o(u.line+1)}: ${u.message}`);const f=new Map;const h=[];const m=new Map;const p={visible:t.showSequenceNumbers===true,next:1,step:1};const g=[];const y=[];const b=S=>{const{from:x,to:k}=S;const w=w4(S.arrow);const C={from:x,to:k,..._a(S.label.trim()),...(S.wrap??t.wrap)===void 0?{}:{wrap:S.wrap??t.wrap},lineStyle:w.lineStyle,startHead:w.startHead,endHead:w.endHead,centralStart:S.centralStart,centralEnd:S.centralEnd};if(S.activationMark==="+")C.activate=true;if(S.activationMark==="-")C.deactivate=true;if(p.visible)C.number=p.next;p.next=Math.round((p.next+p.step)*100)/100;sT(g,R=>R===k,R=>{l.set(R,s.messages.length);if(ie("sequence"))ue("sequence","bind-create",{id:R,messageIndex:s.messages.length})});sT(y,R=>R===x||R===k,R=>{c.set(R,s.messages.length);if(ie("sequence"))ue("sequence","bind-destroy",{id:R,messageIndex:s.messages.length})});s.messages.push(C);if(ie("sequence"))ue("sequence","add-message",C)};for(const[S,x]of d.statements.entries()){const k=x.raw.trim();if(ie("sequence"))Ge("sequence",x.syntax?.kind??"unrecognized",x.raw,{line:x.line+2,column:x.column+1,unit:"normalized"});if(x.error)throw x.error;const w=x.syntax;if(!w){if(i.unclosedIndex!==void 0&&k===i.familyLines[i.unclosedIndex]?.trim())continue;if(k&&!Bu(k))throw new Error(`SEQUENCE_UNSUPPORTED_STATEMENT: line ${o(x.line+1)}: ${k}`);continue}for(const C of yT(w)){a.apply(C);if(ie("sequence"))ue("sequence","participant.apply",C)}switch(w.kind){case"declaration":case"create":{if(w.kind==="create")g.push(w.declaration.id);break}case"links":case"actor-data":break;case"title":{const C=_a(w.text);s.title=C.label;s.titleContent=C.labelContent;if(ie("sequence"))ue("sequence","set-title",s.title);break}case"autonumber":p.visible=w.numbering!==null;if(w.numbering?.next!==void 0){p.next=w.numbering.next;p.step=w.numbering.step??1}if(ie("sequence"))ue("sequence","set-autonumber",p);break;case"box":{const C=w.text;const R={actorIds:[]};const M=C.match(/^((?:rgb|rgba|hsl|hsla)\([^)]*\))\s*(.*)$/i);let P=C;if(M&&ww(M[1])){R.color=M[1];P=M[2]?.trim()??""}else{const E=C.split(/\s+/,1)[0]??"";if(E&&ww(E)){R.color=E;P=C.slice(E.length).trim()}}if(P){const E=Jo(P);Object.assign(R,_a(E.text));if((E.wrap??t.wrap)!==void 0)R.wrap=E.wrap??t.wrap}s.boxes.push(R);a.openBox(R);if(ie("sequence"))ue("sequence","open-box",{index:s.boxes.length-1,box:R});break}case"destroy":y.push(w.actorId);if(ie("sequence"))ue("sequence","pending-destroy",w.actorId);break;case"note":{const{note:C}=w;const R=_a(C.text);const M=s.notes.length;s.notes.push({actorIds:C.actorIds,text:R.label,...(C.wrap??t.wrap)===void 0?{}:{wrap:C.wrap??t.wrap},...R.labelContent?{textContent:R.labelContent}:{},position:C.position,afterIndex:s.messages.length-1});if(ie("sequence"))ue("sequence","add-note",{note:s.notes.at(-1),parent:x.parent});for(let P=x.parent;P!==void 0;P=f.get(P)?.parent){f.get(P)?.noteIndices.push(M)}break}case"block":{const{opener:C}=w;const R=C.type;const M=_a(C.type==="rect"?"":C.label);const P=C.type==="rect"&&C.label.startsWith("#")?"":C.label;const E=C.type==="rect"?oT(P):void 0;if(C.type==="rect"&&P&&!E){throw new Error("SEQUENCE_RECT_COLOR_UNSUPPORTED: rect requires a safe concrete CSS color")}f.set(S,{type:R,...M,...(C.wrap??t.wrap)===void 0?{}:{wrap:C.wrap??t.wrap},...E?{color:E}:{},startIndex:s.messages.length,dividers:[],dividerNoteIndices:[],parent:x.parent,parentSection:x.parent===void 0?0:f.get(x.parent)?.dividers.length??0,noteIndices:[],childBlockIndices:[],childSectionIndices:[]});h.push({kind:"open",blockId:S,messageIndex:s.messages.length,noteIndex:s.notes.length});if(ie("sequence"))ue("sequence","open-block",{id:S,block:f.get(S)});break}case"continuation":{const C=x.parent!==void 0?f.get(x.parent):void 0;if(C){h.push({kind:"divider",blockId:x.parent,messageIndex:s.messages.length,noteIndex:s.notes.length,dividerIndex:C.dividers.length});C.dividerNoteIndices.push(s.notes.length);C.dividers.push({index:s.messages.length,..._a(w.continuation.label),...(w.continuation.wrap??t.wrap)===void 0?{}:{wrap:w.continuation.wrap??t.wrap}});if(ie("sequence"))ue("sequence","divide-block",{parent:x.parent,divider:C.dividers.at(-1),type:w.continuation.type})}break}case"end":{const C=f.get(x.closes);if(C){const R=s.blocks.length;m.set(x.closes,R);h.push({kind:"close",blockId:x.closes,messageIndex:s.messages.length,noteIndex:s.notes.length});const M={type:C.type,label:C.label,...C.wrap===void 0?{}:{wrap:C.wrap},...C.labelContent?{labelContent:C.labelContent}:{},...C.color?{color:C.color}:{},startIndex:C.startIndex,endIndex:Math.max(s.messages.length-1,C.startIndex),dividers:C.dividers};Ew.set(M,{endMessageExclusive:s.messages.length,endNoteExclusive:s.notes.length,dividerNoteIndices:C.dividerNoteIndices,noteIndices:C.noteIndices,childBlockIndices:C.childBlockIndices,childSectionIndices:C.childSectionIndices});if(C.parent!==void 0){f.get(C.parent)?.childBlockIndices.push(R);f.get(C.parent)?.childSectionIndices.push(C.parentSection)}s.blocks.push(M);if(ie("sequence"))ue("sequence","close-block",{id:x.closes,parent:C.parent,parentSection:C.parentSection,block:M,notes:C.noteIndices,children:C.childBlockIndices})}else{a.closeBox();if(ie("sequence"))ue("sequence","close-box",null)}break}case"message":b(w.message);break;case"activation":s.activationEvents.push({actorId:w.actorId,kind:w.activate?"activate":"deactivate",messageIndex:s.messages.length});if(ie("sequence"))ue("sequence","activation",s.activationEvents.at(-1));break}}s.actors=a.list().map(({id:S,label:x,type:k,links:w,box:C,wrap:R})=>({id:S,..._a(x),type:k,...(R??t.wrap)===void 0?{}:{wrap:R??t.wrap},...w?{links:w}:{},...C!==void 0?{box:C}:{},...l.has(S)?{createMessageIndex:l.get(S)}:{},...c.has(S)?{destroyMessageIndex:c.get(S)}:{}}));Rw.set(s,h.map(({blockId:S,...x})=>({...x,blockIndex:m.get(S)})));return s}function pT(e){let t;return n=>{if(!t){const i=e.originalText.split(/\r?\n/);const r=e.wrapperSource?e.wrapperSource.split(/\r?\n/).length-1:0;const o=i.slice(r).flatMap((a,l)=>(l===0?kl(a).split("\n"):[a]).map(c=>({text:c.trim(),line:r+l+1})));let s=0;t=e.familyLines.map(a=>{const l=a.trim();for(let c=s;c<o.length;c++){const d=o[c].text;if(d!==l&&d.slice(d.indexOf("}")+1).trim()!==l)continue;s=c+1;return o[c].line}return void 0})}return t[n]}}function m4(e){const t=Yb(e).map(o=>{if(!o.raw.trim()||Bu(o.raw))return{...o,syntax:null};try{return{...o,syntax:gT(o.raw.trim())}}catch(s){if(s instanceof Ei)throw s;return{...o,syntax:null,error:s}}});const n=[];const i=[];const r=(o,s,a)=>{i.push({line:o.line,syntax:s,message:a})};for(const[o,s]of t.entries()){const{syntax:a}=s;if(n.length)s.parent=n.at(-1);if(!a){if(s.error instanceof Yp)r(s,"sequence_participant_id",s.error.message);else if(s.raw.trim()&&!Bu(s.raw))r(s,"sequence_statement",`Sequence statement is preserved in source but not drawn: ${s.raw.trim()}`);continue}if(a.kind==="block"||a.kind==="box"){n.push(o)}else if(a.kind==="end"){const l=n.pop();if(l===void 0)r(s,"sequence_block_boundary","Sequence end has no open block or box");else{s.closes=l;t[l].endIndex=o}}else if(a.kind==="continuation"){const l=s.parent!==void 0?t[s.parent].syntax:null;if(l?.kind!=="block"||!rT(a.continuation.type,l.opener.type)){r(s,"sequence_block_boundary",`Sequence ${a.continuation.type} does not belong to the enclosing block`)}}else if(a.kind==="declaration"&&a.declaration.unmodeledMetadata?.length){r(s,"sequence_participant_metadata",`Participant metadata fields ${a.declaration.unmodeledMetadata.join(", ")} are not modeled; the declaration is preserved as source`)}else if(a.kind==="message"&&a.message.localArrow){const{localArrow:l,arrow:c}=a.message;r(s,"sequence_local_arrow",`The arrow ${l} is a local spelling pinned Mermaid does not read, so it rejects this line. Ours draws it as Mermaid's ${c} and writes ${c}`)}else if(a.kind==="declaration"&&a.declaration.unspacedAlias){r(s,"sequence_unspaced_alias","Participant text immediately following as is read as its alias. Pinned Mermaid can reject this or read it as part of the ID; write as <label> with a separating space")}if(a.kind==="declaration"||a.kind==="create"){const l=xT(a.declaration.id);if(l)r(s,"sequence_participant_id_extension",l)}if(a.kind==="message"){for(const[l,c]of[["sender",a.message.from],["receiver",a.message.to]]){if(!cT(c,l))r(s,"sequence_message_id_extension",`Participant "${c}" is read as the ${l}, but pinned Mermaid reads another token there; rename it before typed editing`)}}}for(const o of n)r(t[o],"sequence_block_boundary","Sequence block or box is never closed by end");return{statements:t,issues:i}}function gT(e){const t=g4(e);if(t)return{kind:"declaration",declaration:t};const n=x4(e);if(n)return{kind:"links",...n};const i=e.match(/^(?:properties|details)\s+(\S+)\s*:/i);if(i)return{kind:"actor-data",actorId:i[1]};const r=e.match(/^title(?:\s*:\s*|\s+)(.+)$/i);if(r)return{kind:"title",text:r[1].trim()};const o=e.match(/^autonumber(?:\s+(.*))?$/i);if(o){const m=o[1]?.trim()??"";if(/^off$/i.test(m))return{kind:"autonumber",numbering:null};const p=m.match(/^((?:\d+(?:\.\d{1,2})?|\.\d{1,2}))(?:\s+((?:\d+(?:\.\d{1,2})?|\.\d{1,2})))?$/);if(m&&!p)return null;if(p&&(!Number.isFinite(Number(p[1]))||p[2]!==void 0&&!Number.isFinite(Number(p[2]))))return null;return{kind:"autonumber",numbering:p?{next:Number.parseFloat(p[1]),...p[2]===void 0?{}:{step:Number.parseFloat(p[2])}}:{}}}const s=e.match(/^box(?:\s+(.*))?$/i);if(s)return{kind:"box",text:s[1]?.trim()??""};const a=y4(e);if(a)return{kind:"create",declaration:a};const l=e.match(/^destroy\s+(\S+)$/i);if(l)return{kind:"destroy",actorId:l[1]};const c=b4(e);if(c)return{kind:"note",note:c};const d=nT(e);if(d&&d.type!=="box")return{kind:"block",opener:{type:d.type,label:d.label,...d.wrap===void 0?{}:{wrap:d.wrap}}};const u=iT(e);if(u)return{kind:"continuation",continuation:u};if(e==="end")return{kind:"end"};const f=h4(e);if(f)return{kind:"message",message:f};const h=e.match(/^(activate|deactivate)\s+(\S+)$/i);if(h)return{kind:"activation",actorId:h[2],activate:h[1].toLowerCase()==="activate"};return null}function yT(e){switch(e?.kind){case"declaration":{const{id:t,label:n,type:i,keyword:r,aliased:o,wrap:s}=e.declaration;return[{kind:"declare",id:t,keyword:r,type:i,...o?{label:n}:{},...s===void 0?{}:{wrap:s}}]}case"create":{const{id:t,label:n,type:i,wrap:r}=e.declaration;return[{kind:"declare",id:t,keyword:i==="actor"?"actor":"participant",type:i,label:n,...r===void 0?{}:{wrap:r},create:true}]}case"links":return[{kind:"mention",id:e.actorId},{kind:"links",id:e.actorId,links:e.links}];case"actor-data":return[{kind:"mention",id:e.actorId}];case"note":return e.note.actorIds.map(t=>({kind:"mention",id:t}));case"message":return[{kind:"mention",id:e.message.from},{kind:"mention",id:e.message.to}];default:return[]}}function voe(e){return yT(gT(e.trim()))}var p4=new Set(["participant","actor","boundary","control","entity","database","collections","queue"]);function vw(e){return typeof e==="string"&&e!==""&&e.trim()===e&&!/[<>,;@#\r\n]/.test(Dn(e))}function xT(e){const t=vw(e);if(t&&cT(e,"declaration"))return null;const n=t?"is read as authored, but pinned Mermaid rejects colons in declaration IDs":"has ambiguous declaration delimiters or whitespace";return`Sequence participant ID ${JSON.stringify(e)} ${n}. Typed editing and serialization require a portable ID; rename this ID and its references, and put display punctuation in an alias`}var Yp=class extends Es{};function Pw(e){if(!vw(e))throw new Yp(xT(e))}function g4(e){const t=e.match(/^(participant|actor)\s+([^\s@]+)\s*@\{/i);if(t){const l=t[1].toLowerCase();const c=t[2];Pw(c);const d=Vl(e,t[0].length-1,"sequence");const u=d.ok?e.slice(d.end+1):"";const f=u.match(/^\s+as(?:\s+(.*))?$/i);if(!d.ok||u.trim()!==""&&!f){throw Je({what:`Invalid participant metadata in "${e}": ${d.ok?`unexpected "${u.trim()}" after it`:d.message}`,expectedForm:'a YAML mapping in @{\u2026} with no "}" inside, then optionally `as <label>`',example:'participant DB@{ "type": "database", "alias": "Orders" }'})}const h=f?Jo(f[1]??""):void 0;const m=h?h.text||null:void 0;if(m===null)return null;const{entries:p}=d;const g=p.get("type");const y=typeof g==="string"?g.toLowerCase():l;if(!p4.has(y))throw new Error(`Unknown sequence actor type '${y}'`);const b=y;const S=pf(p.get("alias"));const x=S!==void 0&&(m===void 0||m===c)?S:m;const k=[...p.keys()].filter(w=>w!=="type"&&w!=="alias");return{id:c,label:x??c,type:b,keyword:l,aliased:x!==void 0,...h?.wrap===void 0?{}:{wrap:h.wrap},...k.length?{unmodeledMetadata:k}:{}}}if(e.includes("@{"))return null;const n=e.match(/^(participant|actor)\s+/i);if(!n)return null;const i=e.slice(n[0].length);const r=i.match(/^(\S+?)\s+as(\s*)(.+)$/i);if(!r&&(!i||/\s/.test(i)&&/[<>:\n,;@]/.test(Dn(i))))return null;const o=r?r[1]:i.trim();Pw(o);const s=n[1].toLowerCase();const a=r?.[3]===void 0?void 0:Jo(r[3]);return{id:o,label:a?.text??o,type:s,keyword:s,aliased:Boolean(r),...r?.[2]===""?{unspacedAlias:true}:{},...a?.wrap===void 0?{}:{wrap:a.wrap}}}function y4(e){const t=e.match(/^create\s+(participant|actor)\s+(\S+?)(?:\s+as\s+(.+))?$/i);if(!t)return null;const n=t[2];Pw(n);const i=t[3]===void 0?void 0:Jo(t[3]);return{id:n,label:i?.text??n,type:t[1].toLowerCase(),...i?.wrap===void 0?{}:{wrap:i.wrap}}}function x4(e){const t=e.match(/^link\s+(\S+)\s*:\s*(.+?)\s*@\s*(\S+)$/i);if(t){if(!/^(?:https?:|mailto:)/i.test(t[3]))return null;return{actorId:t[1],links:{[t[2].trim()]:t[3]}}}const n=e.match(/^links\s+(\S+)\s*:\s*(\{.*\})$/i);if(!n)return null;try{const i=JSON.parse(n[2]);const r={};for(const[o,s]of Object.entries(i))if(typeof s==="string"&&/^(?:https?:|mailto:)/i.test(s))r[o]=s;return Object.keys(r).length>0?{actorId:n[1],links:r}:null}catch{return null}}function b4(e){const t=e.match(/^Note\s+(left of|right of|over)\s+([^:]+):\s*(.*)$/i);if(!t)return null;const n=t[1].toLowerCase();return{actorIds:t[2].trim().split(",").map(i=>i.trim()),...Jo(t[3]),position:n==="left of"?"left":n==="right of"?"right":"over"}}function S4(e){return gf.has(e)}function w4(e){const t=e.includes("--")?"dashed":"solid";const[n,i]=gf.get(e)??["none","none"];return{lineStyle:t,startHead:n,endHead:i}}function sT(e,t,n){for(let i=e.length-1;i>=0;i--){const r=e[i];if(!t(r))continue;n(r);e.splice(i,1)}}function bT(e){return e.number!==void 0?`${e.number}. ${e.label}`:e.label}function ST(e){const t=qe(e.label,e.labelContent);return e.number!==void 0?Su([`${e.number}. `,typeof t==="string"?vt(t):t]):t}var Sd=class extends Error{};function Aoe(e,t){if(!e.includes("%%{"))return void 0;const n=e.split(/\r?\n/);const i=Wt(n,t?.(n)).accessibility;return[i.title,i.descr].some(r=>r?.includes("%%{"))?"Accessibility text contains an init-directive opener. Source is preserved for native reading; remove the literal opener before typed editing or portable export.":void 0}function Ioe(e){if(typeof e!=="string"||!e.trim())throw new Sd("Accessibility metadata must be non-empty text");return e.trim()}function qp(e){if(typeof e!=="string"||!e.trim()||/[\r\n]/.test(e))throw new Sd("Accessibility title must be non-empty single-line text");return e.trim()}function Xp(e){if(typeof e!=="string")throw new Sd("Accessibility description must be text");const t=e.replace(/\r\n?/g,"\n").split("\n").map(n=>n.trim()).join("\n").trim();if(!t)throw new Sd("Accessibility description must be non-empty text");return t}function Foe(e){if(e.kind==="mindmap"||e.kind==="ishikawa"||e.kind==="block")return e;const t=C4(e);if(!t)return e;const n=t.title===void 0?void 0:qp(t.title);const i=t.descr===void 0||t.descr===""?t.descr:Xp(t.descr);return n===t.title&&i===t.descr?e:{...e,...n!==void 0?{accessibilityTitle:n}:{},...i!==void 0?{accessibilityDescription:i}:{}}}function M4(e,t){if(t.accessibilityTitle!==void 0)e.push(` accTitle: ${qp(t.accessibilityTitle)}`);if(t.accessibilityDescription===void 0)return;const n=t.accessibilityDescription.trim()?Xp(t.accessibilityDescription):"";if(!n){El(e,{accessibilityDescription:""});return}if(n&&!n.includes("\n")){e.push(` accDescr: ${n}`);return}e.push(" accDescr {");for(const i of n.split("\n"))e.push(` ${i}`);e.push(" }")}function Noe(e,t){const n=e.split(/\r?\n/).find(u=>u.trim()&&!u.trimStart().startsWith("%%"))?.trim()??"";const i=/^(?:zenuml|eventmodeling|block(?:-beta)?|sankey(?:-beta)?|mindmap|ishikawa(?:-beta)?)(?:\s|$)/i.test(n);const r=new Set;const o=e.split(/\r?\n/);for(let u=0;u<o.length;u++){const f=Tt(o,u);if(f){r.add(f.title?"title":"descr");u=f.endIndex}}const s=[];const a=i?El:M4;if(t.title!==void 0&&!r.has("title")){a(s,{accessibilityTitle:t.title})}if(t.descr!==void 0&&!r.has("descr")){a(s,{accessibilityDescription:t.descr})}if(s.length===0)return e;const l=e.endsWith("\n");const c=e.replace(/\n$/,"").split(/\r?\n/);const d=c.findIndex(u=>u.trim().length>0);c.splice(d<0?0:d+1,0,...s);return c.join("\n")+(l?"\n":"")}function k4(e,t){const n=[];if(e.title!==void 0&&t.title!==void 0&&e.title!==t.title)n.push("accTitle");if(e.descr!==void 0&&t.descr!==void 0&&e.descr!==t.descr)n.push("accDescr");return n}function $oe(e,t){const n=e.accessibility;if(k4(t,n).length>0)return false;if(t.title!==void 0&&n.title===void 0||t.descr!==void 0&&n.descr===void 0){e.accessibility={...n,...t.title!==void 0?{title:t.title}:{},...t.descr!==void 0?{descr:t.descr}:{}}}return true}function C4(e){switch(e.kind){case"zenuml":case"timeline":case"journey":case"architecture":case"xychart":case"pie":case"quadrant":case"mindmap":case"gitgraph":case"c4":case"packet":case"kanban":case"requirement":case"treemap":case"ishikawa":case"block":return{...e.accessibilityTitle!==void 0?{title:e.accessibilityTitle}:{},...e.accessibilityDescription!==void 0?{descr:e.accessibilityDescription}:{}};default:return void 0}}function _oe(e,t){switch(e.kind){case"timeline":case"journey":case"architecture":case"xychart":case"pie":case"quadrant":case"mindmap":case"gitgraph":case"c4":case"packet":case"kanban":case"requirement":case"treemap":case"ishikawa":case"block":if(t.title!==void 0)e.accessibilityTitle=t.title;if(t.descr!==void 0)e.accessibilityDescription=t.descr;break}}var io=String.raw`(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|[\p{L}_$][\p{L}\p{N}_$-]*?)`;var P4=new RegExp(`^${io}$`,"u");var wT=new RegExp(`^(${io})(?![\\p{L}\\p{N}_$-])`,"u");var E4=new RegExp(`^(${io})\\s*(-->|->)\\s*(${io})\\s*:\\s*([\\s\\S]*)$`,"u");var R4=new RegExp(`^(${io})(?:\\s+as\\s+(${io}))?$`,"u");var v4=new RegExp(`^(?:(${io})\\s*->\\s*)?(${io})\\s*\\.\\s*([\\s\\S]+)$`,"u");function Fi(e){const t=e.trim();if(!P4.test(t))throw Error(`Invalid ZenUML identity: ${e}`);if(t.startsWith('"'))return JSON.parse(t);if(t.startsWith("'"))return t.slice(1,-1).replace(/\\'/g,"'").replace(/\\\\/g,"\\");return t}function On(e){if(!e||/[\r\n]/.test(e))throw Error("ZenUML identities must be non-empty single-line text");return/^[\p{L}_$][\p{L}\p{N}_$-]*$/u.test(e)&&!Tw.has(e)?e:JSON.stringify(e)}var Tw=new Set(["title","if","else","while","for","foreach","forEach","loop","par","opt","try","catch","finally","return","new","critical","group","ref","section","const","readonly","static","await","true","false","null","nil","as","in"]);function kT(e){const t=[];let n=0,i="",r=false,o=0,s=0,a=false,l=false,c=false;const d=u=>{const f=e.slice(n,u).trim();if(f)t.push({kind:"text",text:f,start:n+e.slice(n,u).indexOf(f),end:u-(e.slice(n,u).length-e.slice(n,u).trimEnd().length)})};for(let u=0;u<e.length;u++){const f=e[u];const h=!l&&/\S/.test(f);if(h){l=true;if(!o&&!s&&/^title(?:[ \t]|$)/.test(e.slice(u,u+6)))c="title"}if(i){if(r)r=false;else if(f==="\\")r=true;else if(f===i)i="";continue}if(!c&&(f==='"'||f==="'")){i=f;continue}if(!c&&e.startsWith("//",u)){d(u);const m=e.indexOf("\n",u);const p=m<0?e.length:m;t.push({kind:"comment",text:e.slice(u+2,p).replace(/^ /,""),start:u,end:p});u=p-1;n=p;l=false;a=false;continue}if(!c&&e.startsWith("%%",u)&&h){const m=e.indexOf("\n",u);u=m<0?e.length:m-1;n=u+1;l=false;a=false;continue}if(!c){if(f==="(")o++;if(f===")"){if(!o)throw Error("Unmatched ZenUML parenthesis");o--}if(f==="[")s++;if(f==="]"){if(!s)throw Error("Unmatched ZenUML bracket");s--}if(f===">"&&e[u-1]==="-"&&!o&&!s)a=true;if(f===":"&&!o&&!s&&a)c="event"}if(!o&&!s&&(!c&&(f==="{"||f==="}")||f==="\n"||f===";"&&c!=="title")){d(u);if(f==="{"||f==="}")t.push({kind:f==="{"?"open":"close",text:f,start:u,end:u+1});n=u+1;c=false;l=false;a=false}}if(i||o||s)throw Error("Unclosed ZenUML quote or parameter list");d(e.length);return t}function Lw(e){const t=e.join("\n"),n=e.map((i,r)=>r);try{let i=0,r=0;for(const o of kT(t)){while(r<o.start)if(t[r++]==="\n")i++;const s=i;while(r<o.end)if(t[r++]==="\n")i++;for(let a=s;a<i;a++)n[a]=i}}catch{}return n}function T4(e){const t=e.match(new RegExp(`^(?:(${io})\\s+)?(${io})\\s*=\\s*(?!=)([\\s\\S]+)$`,"u"));return t?{assignment:{name:Fi(t[2]),...t[1]?{type:Fi(t[1])}:{}},rest:t[3].trim()}:{rest:e}}function L4(e){const t=[];let n=e,i;while(/^@[\w]+\s+/.test(n)){const s=n.match(/^@([\w]+)\s+/);t.push(s[1]);n=n.slice(s[0].length)}if(n.startsWith("<<")){const s=n.indexOf(">>");if(s<0)return void 0;i=Fi(n.slice(2,s).trim());n=n.slice(s+2).trim()}const r=n.match(R4);if(!r||!n.startsWith('"')&&Tw.has(r[1]))return void 0;const o=Fi(r[1]);return{id:o,label:r[2]?Fi(r[2]):o,annotations:t,...i?{stereotype:i}:{}}}function Up(e,t){const n=Array.isArray(e)?e.join("\n"):e;let i=n.replace(/\r\n?/g,"\n");const r=Rr(n);let o=0;let s;const a=hr(i);if(a){const T=As(a.yaml);if(!T.ok)throw Error(T.message);if(T.value&&typeof T.value==="object"&&"title"in T.value&&typeof T.value.title==="string")s=T.value.title;i=i.slice(a.source.length);o=a.source.split("\n").length-1}const l=Wt(i.split("\n"),Lw(i.split("\n")));i=l.familyLines.join("\n");const c=i.match(/^(?:(?:[^\S\n]*(?:%%[^\n]*)?\n))*[^\S\n]*zenuml\b/);if(!c)throw Error("Expected zenuml header");const d=kT(i.slice(c[0].length));const u=Rr(i);const f=[];const h=T=>{const A=ks(u,T+c[0].length);const $=(l.familyOrigins[A.line-1]??A.line-1)+o;return(r[$]??n.length)+A.col-1};const m=(T,A,$)=>{if(t)f.push({kind:T,id:A,start:h($.start),end:h($.end)})};const p={kind:"zenuml",participants:[],statements:[],...vr(l.accessibility),...s===void 0?{}:{title:s}};let g=0,y=0,b=0,S=true;const x=()=>`statement:${++y}`;const k=T=>({offset:h(T.start),endOffset:h(T.end),unit:"physical"});const w=()=>{const T=d[g++];if(T&&ie("zenuml")){const A=k(T);Ge("zenuml",T.kind,n.slice(A.offset,A.endOffset),A)}return T};const C=(T,A,$)=>{T.push(A);if(ie("zenuml"))ue("zenuml","append-statement",A,k($))};const R=T=>{if(++b>128)throw Error("ZenUML nesting exceeds 128 scopes");const A=[];while(g<d.length){const $=w();if($.kind==="close"){if(!T)throw Error("Unmatched ZenUML closing brace");b--;return A}if($.kind==="open")throw Error("ZenUML scope has no owner");if($.kind==="comment"){const H={kind:"comment",id:x(),text:$.text};C(A,H,$);m("labels",H.id,$);continue}let _=$.text;if(!T&&(_==="title"||_.startsWith("title "))){p.title=_.slice(5).trim();if(ie("zenuml"))ue("zenuml","set-title",p.title,k($));m("labels","title",$);continue}const z=_.match(new RegExp(`^@Starter\\(\\s*(${io})\\s*\\)$`,"u"));if(!T&&z&&S){p.starter=Fi(z[1]);if(ie("zenuml"))ue("zenuml","set-starter",p.starter,k($));continue}if(!T&&S){const H=L4(_);if(H){if(p.participants.some(q=>q.id===H.id))throw Error(`Duplicate ZenUML participant: ${H.id}`);const j=[];while(A.at(-1)?.kind==="comment"){const q=A.pop();j.unshift(q.text);if(ie("zenuml"))ue("zenuml","claim-participant-comment",{participant:H.id,comment:q})}if(j.length)H.comments=j;if(H.annotations.length>1)p.unsupportedSource=n;m("nodes",H.id,$);p.participants.push(H);if(ie("zenuml"))ue("zenuml","append-participant",H,k($));continue}}S=false;const F=x();m("edges",F,$);let G=false;if(/^@(return|reply)(?:\s|$)/.test(_)){G=true;_=_.replace(/^@(return|reply)\s*/,"");if(!_){const H=w();if(!H||H.kind!=="text")throw Error("ZenUML reply annotation requires a message");_=H.text}}const I=_.match(E4);if(I){m("nodes",Fi(I[1]),$);m("nodes",Fi(I[3]),$);C(A,{kind:"message",id:F,from:Fi(I[1]),to:Fi(I[3]),label:I[4],reply:G||I[2]==="-->"},$);continue}if(G)throw Error("ZenUML reply annotation requires a directed message");const D=_.match(/^(if|while|for|forEach|foreach|loop|par|opt|try|critical)\b([\s\S]*)$/);if(D){if(t)f.pop();m("groups",F,$);const H=D[1];const j=MT(D[2]);if(d[g]?.kind!=="open")throw Error(`ZenUML ${H} requires a brace-delimited scope`);w();const q=[{kind:"body",statements:R(true)}];while(d[g]?.kind==="text"){const X=d[g].text.match(/^(else\s+if|else|catch|finally)\b([\s\S]*)$/);if(!X)break;const V=X[1]==="else if"?"else-if":X[1];if(H==="if"?!["else-if","else"].includes(V):H==="try"?!["catch","finally"].includes(V):true)break;w();const ee=MT(X[2]);if(w()?.kind!=="open")throw Error("ZenUML branch requires a brace-delimited scope");q.push({kind:V,...ee===void 0?{}:{condition:ee},statements:R(true)})}C(A,{kind:"fragment",id:F,type:H,...j===void 0?{}:{condition:j},branches:q},$);continue}if(/^return\b/.test(_)){C(A,{kind:"return",id:F,label:_.slice(6).trim()},$);continue}const B=T4(_);const Y=B.rest.match(new RegExp(`^new\\s+(${io})(?:\\s*\\(([\\s\\S]*)\\))?$`,"u"));const W=()=>{if(d[g]?.kind!=="open")return[];w();return R(true)};if(Y){m("nodes",B.assignment?`${B.assignment.name}:${Fi(Y[1])}`:Fi(Y[1]),$);C(A,{kind:"create",id:F,constructor:Fi(Y[1]),...Y[2]===void 0?{}:{arguments:Y[2]},...B.assignment?{assignment:B.assignment}:{},children:W()},$);continue}const O=B.rest.match(v4);const N=O?O[3]:B.rest;if(wT.test(N)&&A4(N)&&(O!==null||!Tw.has(wT.exec(N)[1]))){if(O?.[1])m("nodes",Fi(O[1]),$);if(O?.[2])m("nodes",Fi(O[2]),$);C(A,{kind:"call",id:F,...O?.[1]?{from:Fi(O[1])}:{},...O?.[2]?{to:Fi(O[2])}:{},label:N,...B.assignment?{assignment:B.assignment}:{},children:W()},$);continue}C(A,{kind:"opaque",id:F,source:_},$);p.unsupportedSource=n;if(d[g]?.kind==="open"){w();R(true)}}b--;if(T)throw Error("Unclosed ZenUML scope");return A};p.statements=R(false);const M=new Set(p.participants.map(T=>T.id));if(p.starter)M.add(p.starter);const P=[];const E=T=>{for(const A of T){P.push(A);if(A.kind==="call"||A.kind==="message"){if(A.from)M.add(A.from);if(A.to)M.add(A.to)}if(A.kind==="create")M.add(A.assignment?`${A.assignment.name}:${A.constructor}`:A.constructor);if(A.kind==="call"||A.kind==="create")E(A.children);if(A.kind==="fragment")for(const $ of A.branches)E($.statements)}};E(p.statements);const v=new Map;let L=0;for(const T of P){const A=T.id;do{T.id=`statement:${++L}`}while(M.has(T.id));v.set(A,T.id);if(A!==T.id&&ie("zenuml"))ue("zenuml","readdress-statement",{from:A,to:T.id})}for(const T of f){if(T.kind!=="nodes"&&T.id!=="title")T.id=v.get(T.id)??T.id;t?.(T)}Ve("nodes",M.size);Ve("edges",y);return p}function MT(e){const t=e.trim();if(!t)return void 0;if(!t.startsWith("(")||!t.endsWith(")"))throw Error("ZenUML condition requires parentheses");return t.slice(1,-1).trim()}function A4(e){let t=0,n="",i=false,r="";for(const o of e){if(n){if(i)i=false;else if(o==="\\")i=true;else if(o===n)n="";continue}if(o==='"'||o==="'"){if(!t)return false;n=o;continue}if(o==="("){t++;if(t===1)r+="()";continue}if(o===")"){t--;continue}if(!t)r+=o}return/^[\p{L}_$][\p{L}\p{N}_$-]*(?:\(\))?(?:\s*\.\s*[\p{L}_$][\p{L}\p{N}_$-]*(?:\(\))?)*$/u.test(r.trim())}function Gs(e,t){for(const n of e){t(n,e);if(n.kind==="call"||n.kind==="create")Gs(n.children,t);if(n.kind==="fragment")for(const i of n.branches)Gs(i.statements,t)}}function yf(e,t=false){if(!e||e.kind!=="zenuml"||!Array.isArray(e.participants)||!Array.isArray(e.statements))throw Error("Invalid ZenUML body");for(const l of[e.title,e.accessibilityTitle,e.accessibilityDescription])if(l!==void 0&&typeof l!=="string")throw Error("ZenUML metadata must be text");if(e.starter!==void 0)On(e.starter);const n=new Set;for(const l of e.participants){On(l.id);if(typeof l.label!=="string"||/[\r\n]/.test(l.label))throw Error("ZenUML aliases must be single-line text");if(n.has(l.id))throw Error(`Duplicate ZenUML participant: ${l.id}`);n.add(l.id);if(!Array.isArray(l.annotations)||l.annotations.some(c=>typeof c!=="string"||!/^\w+$/.test(c)))throw Error("Invalid ZenUML annotator");if(l.annotations.length>1&&(t||e.unsupportedSource===void 0))throw Error("ZenUML declarations accept one participant annotator");if(l.stereotype!==void 0&&(typeof l.stereotype!=="string"||!l.stereotype||/[<>\r\n]/.test(l.stereotype)))throw Error("Invalid ZenUML stereotype");if(l.comments!==void 0&&(!Array.isArray(l.comments)||l.comments.some(c=>typeof c!=="string")))throw Error("Invalid ZenUML participant comments")}const i=new Set,r=new Set;const o=l=>{if(typeof l!=="string")throw Error("ZenUML content must be text")};const s=l=>{if(l){On(l.name);if(l.type!==void 0)On(l.type)}};const a=(l,c)=>{if(!Array.isArray(l)||c>128)throw Error("Invalid or excessive ZenUML scope nesting");for(const d of l){if(!d||typeof d!=="object"||r.has(d))throw Error("Cyclic or shared ZenUML statement");r.add(d);if(typeof d.id!=="string"||!d.id||i.has(d.id))throw Error("ZenUML statement identities must be unique");i.add(d.id);switch(d.kind){case"call":if(d.from!==void 0)On(d.from);if(d.to!==void 0)On(d.to);if(d.from!==void 0&&d.to===void 0)throw Error("An explicit ZenUML caller requires a target");o(d.label);s(d.assignment);a(d.children,c+1);break;case"create":On(d.constructor);if(d.arguments!==void 0)o(d.arguments);s(d.assignment);a(d.children,c+1);break;case"message":On(d.from);On(d.to);o(d.label);if(typeof d.reply!=="boolean")throw Error("ZenUML message reply flag must be boolean");break;case"return":o(d.label);break;case"comment":o(d.text);break;case"fragment":{if(!["if","opt","while","for","forEach","foreach","loop","par","try","critical"].includes(d.type)||!Array.isArray(d.branches)||!d.branches.length||d.branches[0]?.kind!=="body")throw Error("Invalid ZenUML fragment");if(d.condition!==void 0)o(d.condition);let u=false;for(const[f,h]of d.branches.entries()){if(f&&(u||(d.type==="if"?!["else-if","else"].includes(h.kind):d.type==="try"?!["catch","finally"].includes(h.kind):true)))throw Error("Invalid ZenUML branch order");if(h.kind==="else"||h.kind==="finally")u=true;if(h.condition!==void 0)o(h.condition);a(h.statements,c+1)}break}case"opaque":o(d.source);if(t||e.unsupportedSource===void 0)throw Error("Unsupported ZenUML syntax is retained; typed editing and rendering require a fully modelled document");break;default:throw Error("Unknown ZenUML statement kind")}}};a(e.statements,0);if(t&&e.unsupportedSource!==void 0)throw Error("Unsupported ZenUML source cannot be rewritten through typed editing");Ve("nodes",ET(e).size);Ve("edges",i.size)}function CT(e){return e?`${e.type?`${On(e.type)} `:""}${On(e.name)} = `:""}function I4(e,t=true){yf(e);if(e.unsupportedSource!==void 0)return e.unsupportedSource;const n=["zenuml"];El(n,e);if(e.title!==void 0&&t){if(/[\r\n]/.test(e.title)){n.unshift(`---
|
|
15
|
-
title: ${JSON.stringify(e.title)}
|
|
16
|
-
---`)}else n.push(`title ${e.title}`)}for(const r of e.participants){for(const o of r.comments??[])for(const s of o.split("\n"))n.push(`//${s?` ${s}`:""}`);n.push(`${r.annotations.map(o=>`@${o} `).join("")}${r.stereotype?`<<${On(r.stereotype)}>> `:""}${On(r.id)}${r.label===r.id?"":` as ${r.label?On(r.label):'""'}`}`)}if(e.starter!==void 0)n.push(`@Starter(${On(e.starter)})`);const i=(r,o)=>{const s=" ".repeat(o);const a=(l,c)=>{if(!c.length){n.push(s+l);return}n.push(`${s}${l} {`);i(c,o+1);n.push(`${s}}`)};for(const l of r)switch(l.kind){case"comment":for(const c of l.text.split("\n"))n.push(`${s}//${c?` ${c}`:""}`);break;case"call":a(`${CT(l.assignment)}${l.to===void 0?"":`${l.from===void 0?"":`${On(l.from)}->`}${On(l.to)}.`}${l.label}`,l.children);break;case"create":a(`${CT(l.assignment)}new ${On(l.constructor)}${l.arguments===void 0?"":`(${l.arguments})`}`,l.children);break;case"return":n.push(`${s}return${l.label?` ${l.label}`:""}`);break;case"message":n.push(`${s}${On(l.from)}${l.reply?"-->":"->"}${On(l.to)}: ${l.label}`);break;case"fragment":for(const[c,d]of l.branches.entries()){const u=c===0?`${l.type}${l.condition===void 0?"":` (${l.condition})`}`:`${d.kind==="else-if"?"else if":d.kind}${d.condition===void 0?"":` (${d.condition})`}`;n.push(`${s}${c?"} ":""}${u} {`);i(d.statements,o+1)}n.push(`${s}}`);break;case"opaque":throw Error("Unsupported ZenUML source cannot be serialized partially")}};i(e.statements,0);return n.join("\n")+"\n"}function PT(e){const t=n=>{if(Array.isArray(n))return n.map(t);if(n&&typeof n==="object")return Object.fromEntries(Object.entries(n).filter(([i,r])=>r!==void 0&&!(i==="id"&&"kind"in n&&n.kind!=="zenuml")).sort(([i],[r])=>i<r?-1:i>r?1:0).map(([i,r])=>[i,t(r)]));return n};return JSON.stringify(t(e))}function Joe(e,t){try{yf(e,true);const n=structuredClone(e);const i=a=>{let l;Gs(n.statements,(c,d)=>{if(c.id===a)l={statement:c,siblings:d}});if(!l)throw Error(`Unknown ZenUML statement: ${a}`);return l};const r=(a,l)=>{const c=a??l;if(!Number.isSafeInteger(c)||c<0||c>l)throw Error("Invalid ZenUML insertion position");return c};const o=a=>{const l=n.participants.findIndex(c=>c.id===a);if(l<0)throw Error(`Unknown declared ZenUML participant: ${a}`);return l};switch(t.kind){case"upsert_participant":{const a=n.participants.findIndex(l=>l.id===t.participant.id);if(a<0)n.participants.splice(r(t.index,n.participants.length),0,structuredClone(t.participant));else n.participants[a]=structuredClone(t.participant);break}case"remove_participant":{if(F4(n,t.id))throw Error("Cannot remove a participant referenced by ZenUML interactions");const a=o(t.id);n.participants.splice(a,1);break}case"rename_participant":{const a=ET(n);if(!a.has(t.id))throw Error(`Unknown ZenUML participant: ${t.id}`);On(t.newId);const l=new Map([[t.id,t.newId]]);Gs(n.statements,d=>{if(d.kind!=="create")return;const u=d.assignment?`${d.assignment.name}:${d.constructor}`:d.constructor;if(u===t.id&&d.assignment){const f=`:${d.constructor}`;if(!t.newId.endsWith(f))throw Error("Renaming a created instance must retain its constructor suffix");d.assignment.name=t.newId.slice(0,-f.length);On(d.assignment.name)}else if(d.constructor===t.id){d.constructor=t.newId;l.set(u,d.assignment?`${d.assignment.name}:${d.constructor}`:d.constructor)}});const c=new Set;for(const[d,u]of l){if(c.has(u)||d!==u&&a.has(u)&&!l.has(u))throw Error("Renaming would merge distinct ZenUML participants");c.add(u)}for(const d of n.participants)if(l.has(d.id)){const u=d.id;d.id=l.get(u);if(d.label===u)d.label=d.id}if(n.starter!==void 0)n.starter=l.get(n.starter)??n.starter;Gs(n.statements,d=>{if(d.kind==="call"||d.kind==="message"){if(d.from!==void 0)d.from=l.get(d.from)??d.from;if(d.to!==void 0)d.to=l.get(d.to)??d.to}});break}case"insert_statement":{let a=n.statements;if(t.parentId!==void 0){const l=i(t.parentId).statement;if(l.kind==="call"||l.kind==="create"){if(t.branchIndex!==void 0)throw Error("Only fragments own branch indices");a=l.children}else if(l.kind==="fragment"){const c=l.branches[r(t.branchIndex??0,l.branches.length-1)];if(!c)throw Error("Unknown ZenUML branch");a=c.statements}else throw Error("Statement cannot own nested ZenUML interactions")}else if(t.branchIndex!==void 0)throw Error("A branch index requires a parent fragment");a.splice(r(t.index,a.length),0,structuredClone(t.statement));break}case"remove_statement":{const a=i(t.id);a.siblings.splice(a.siblings.indexOf(a.statement),1);break}case"set_statement":{const a=i(t.id);if(t.statement.id!==t.id)throw Error("Statement replacement must retain its editing identity");a.siblings[a.siblings.indexOf(a.statement)]=structuredClone(t.statement);break}case"set_title":n.title=t.title;break;case"set_accessibility_title":n.accessibilityTitle=t.title===void 0?void 0:qp(t.title);break;case"set_accessibility_description":n.accessibilityDescription=t.description===void 0?void 0:Xp(t.description);break;default:throw Error(JC("zenuml",t))}yf(n,true);const s=Up(I4(n));if(PT(n)!==PT(s))throw Error("ZenUML edit cannot be written without changing owned meaning");return tC(s)}catch(n){return nC({code:"INVALID_OP",message:n instanceof Error?n.message:String(n)})}}function F4(e,t){let n=e.starter===t;Gs(e.statements,i=>{if((i.kind==="call"||i.kind==="message")&&(i.from===t||i.to===t))n=true;if(i.kind==="create"&&(i.constructor===t||(i.assignment?`${i.assignment.name}:${i.constructor}`:i.constructor)===t))n=true});return n}function ET(e){const t=new Set(e.participants.map(n=>n.id));if(e.starter!==void 0)t.add(e.starter);Gs(e.statements,n=>{if(n.kind==="call"||n.kind==="message"){if(n.from!==void 0)t.add(n.from);if(n.to!==void 0)t.add(n.to)}if(n.kind==="create")t.add(n.assignment?`${n.assignment.name}:${n.constructor}`:n.constructor)});return t}var RT={actor:"actor",boundary:"boundary",control:"control",entity:"entity",database:"database",collections:"collections",queue:"queue",participant:"participant"};var wd=e=>({value:e,prepared:vt(e,"literal")});function TT(e,t){yf(e,true);const n={actors:[],messages:[],blocks:[],notes:[],activationEvents:[],boxes:[],...e.title===void 0?{}:{title:e.title,titleContent:wd(e.title)},...e.accessibilityTitle===void 0?{}:{accessibilityTitle:e.accessibilityTitle},...e.accessibilityDescription===void 0?{}:{accessibilityDescription:e.accessibilityDescription}};const i=new Map,r=new Set(e.participants.map(g=>g.id));if(e.starter)r.add(e.starter);Gs(e.statements,g=>{r.add(g.id);if(g.kind==="call"||g.kind==="message"){if(g.from)r.add(g.from);if(g.to)r.add(g.to)}if(g.kind==="create")r.add(vT(g))});let o="zenuml:outside";while(r.has(o))o+=":";const s=g=>{let y=g;while(r.has(y))y+=":";r.add(y);return y};const a=g=>{const y=g??o;if(!i.has(y)){const b={id:y,label:g===void 0?"":g,type:"participant",labelContent:wd(g??""),...g===void 0?{external:true}:{}};n.actors.push(b);i.set(y,b)}return y};for(const g of e.participants){a(g.id);const y=i.get(g.id);y.type=g.annotations.map(S=>RT[S.toLowerCase()]).find(Boolean)??"participant";const b=[...g.annotations.filter(S=>!RT[S.toLowerCase()]).map(S=>`@${S}`),...g.stereotype?[g.stereotype]:[]];y.label=[...b.map(S=>`\xAB${S}\xBB`),g.label].join("\n");y.labelContent=wd(y.label)}let l=e.starter;if(l===void 0)for(const g of e.statements){if(g.kind==="message"||g.kind==="call"&&g.from!==void 0){l=g.from;break}if(g.kind!=="comment")break}if(l!==void 0)a(l);const c=[],d=new Map,u=[];const f=(g,y,b,S,x,k,w=false,C=g)=>{const R=a(y),M=a(b);const P=k==="reply";const E={id:g,...x.parentId?{parentId:x.parentId}:{},from:R,to:M,label:S,labelContent:wd(S),lineStyle:P?"dashed":"solid",startHead:"none",endHead:P?"open":"filled",centralStart:false,centralEnd:false,...w?{activate:true}:{}};n.messages.push(E);t?.message?.({message:E,kind:k,sourceId:C,callAncestors:x.callAncestors,scopes:x.scopes})};const h=(g,y,b,S)=>{const x=D1(y);const k={id:g,...S.parentId?{parentId:S.parentId}:{},actorIds:[...new Set(b.length?b:[a(S.owner)])],text:x,textContent:{value:x,authored:y,prepared:vt(x,"formatted")},position:"over",afterIndex:n.messages.length-1};const w=n.notes.length;n.notes.push(k);t?.note?.({note:k,sourceId:g,callAncestors:S.callAncestors,scopes:S.scopes});for(const C of u)d.get(C).noteIndices.push(w)};const m=(g,y,b)=>g.some(S=>S.kind==="return"||S.kind==="message"&&S.reply&&S.from===y&&S.to===b||S.kind==="fragment"&&S.branches.some(x=>m(x.statements,y,b)));const p=(g,y)=>{let b=[];const S=x=>{for(const k of b)h(k.id,k.text,x,y);b=[]};for(const x of g){if(x.kind==="comment"){b.push(x);continue}switch(x.kind){case"call":{const k=x.from??y.owner,w=x.to??y.owner;const C=a(k),R=a(w);S([C,R]);const M=C===R;const P=x.assignment&&!M&&m(x.children,w,k);f(x.id,k,w,x.assignment&&(M||P)?`${Vp(x.assignment)} = ${x.label}`:x.label,y,"call",true);const E={...y,owner:w,returnTo:k,callAncestors:t?[...y.callAncestors,x.id]:y.callAncestors};p(x.children,E);if(x.assignment&&!M&&!P)f(s(`${x.id}:reply`),w,k,Vp(x.assignment),E,"reply",false,x.id);n.activationEvents.push({actorId:R,kind:"deactivate",messageIndex:n.messages.length});break}case"create":{const k=vT(x),w=a(y.owner);a(k);S([w,k]);const C=i.get(k);if(C.createMessageIndex!==void 0)throw Error(`Repeated creation of ZenUML object ${k} cannot share one sequence lifeline`);C.createMessageIndex=n.messages.length;const R=x.assignment&&m(x.children,k,y.owner);const M=`\xAB${x.arguments||"create"}\xBB`;f(x.id,y.owner,k,x.assignment&&R?`${Vp(x.assignment)} = ${M}`:M,y,"creation",true);const P={...y,owner:k,returnTo:y.owner,callAncestors:t?[...y.callAncestors,x.id]:y.callAncestors};p(x.children,P);if(x.assignment&&!R)f(s(`${x.id}:reply`),k,y.owner,Vp(x.assignment),P,"reply",false,x.id);n.activationEvents.push({actorId:k,kind:"deactivate",messageIndex:n.messages.length});break}case"message":S([a(x.from),a(x.to)]);f(x.id,x.from,x.to,x.label,y,x.reply?"reply":"async");n.messages.at(-1).endHead="open";break;case"return":S([a(y.owner),a(y.returnTo)]);f(x.id,y.owner,y.returnTo,x.label,y,"reply");break;case"fragment":{if(b.length)S([a(y.owner)]);const k=n.blocks.length;const w=x.type==="if"?"alt":x.type==="par"?"par":x.type==="opt"?"opt":x.type==="try"?"break":x.type==="critical"?"critical":"loop";const C=["if","opt","par","critical"].includes(x.type)?x.condition??"":`${x.type}${x.condition===void 0?"":` (${x.condition})`}`;const R={id:x.id,...y.parentId?{parentId:y.parentId}:{},type:w,label:C,labelContent:wd(C),startIndex:n.messages.length,endIndex:n.messages.length-1,dividers:[]};n.blocks.push(R);const M={endMessageExclusive:0,endNoteExclusive:0,dividerNoteIndices:[],noteIndices:[],childBlockIndices:[],childSectionIndices:[]};d.set(k,M);if(y.blockIndex!==void 0){const E=d.get(y.blockIndex);E.childBlockIndices.push(k);E.childSectionIndices.push(y.section)}c.push({kind:"open",blockIndex:k,messageIndex:n.messages.length,noteIndex:n.notes.length});u.push(k);const P=x.type==="par"?N4(x.branches[0].statements):x.branches;t?.fragment?.({fragment:x,branches:P,callAncestors:y.callAncestors,scopes:y.scopes});for(const[E,v]of P.entries()){if(E){const T=v.kind==="else-if"?`else if (${v.condition??""})`:v.kind==="body"?"":`${v.kind}${v.condition===void 0?"":` (${v.condition})`}`;const A=R.dividers.length;R.dividers.push({index:n.messages.length,label:T,labelContent:wd(T)});M.dividerNoteIndices.push(n.notes.length);c.push({kind:"divider",blockIndex:k,dividerIndex:A,messageIndex:n.messages.length,noteIndex:n.notes.length})}const L=E===0?x.condition:v.condition;p(v.statements,{...y,parentId:x.id,blockIndex:k,section:E,scopes:t?[...y.scopes,{fragmentId:x.id,fragmentIndex:k,type:x.type,branchIndex:E,branchKind:v.kind,...L===void 0?{}:{condition:L}}]:y.scopes})}u.pop();R.endIndex=n.messages.length-1;M.endMessageExclusive=n.messages.length;M.endNoteExclusive=n.notes.length;fT(R,M);c.push({kind:"close",blockIndex:k,messageIndex:n.messages.length,noteIndex:n.notes.length});break}case"opaque":throw Error("Unsupported ZenUML syntax cannot be projected partially")}}if(b.length)S([a(y.owner)])};p(e.statements,{owner:l,section:0,callAncestors:[],scopes:[]});if(!n.actors.length&&(n.blocks.length||n.notes.length))a(void 0);hT(n,c);return n}function Vp(e){return e.type===void 0?e.name:`${e.name}:${e.type}`}function vT(e){return e.assignment?`${e.assignment.name}:${e.constructor}`:e.constructor}function N4(e){const t=[];let n=[];for(const i of e){n.push(i);if(i.kind!=="comment"){t.push({kind:"body",statements:n});n=[]}}if(n.length||!t.length)t.push({kind:"body",statements:n});return t}import{decodeXML as $4}from"entities";var $T=String.raw`~{3,}|[xo]-?\.+-[xo]|-?\.+-[>xo]?|[xo]={2,}[xo]|={2,}[>xo]|={3,}|o-{2,}o|o-{2,}x|x-{2,}o|x-{2,}x|-{2,}[ox]|-{2,}>|-{3,}`;var _4=new RegExp(`(<)?(${$T})`,"y");var Qp=`<?(?:${$T})`;var _T=String.raw`(?!${Qp}|[xo]?(?:-{2,}|-\.|={2,}))[^\s"@[\](){}|<>;]+`;var DT=/([<xo])?(-{2,}|-\.+|={2,})/y;var LT={solid:"-{2,}[-ox>]",thick:"={2,}[=>xo]",dotted:"-?\\.+-[>xo]?"};var OT={...LT,mixed:Object.values(LT).join("|")};var D4=Object.fromEntries(Object.entries(OT).map(([e,t])=>[e,new RegExp(`(${t})`,"y")]));var O4=Object.fromEntries(Object.entries(OT).map(([e,t])=>[e,new RegExp(`\\s*(?:${t})`,"y")]));var B4={solid:/--/y,thick:/==/y,dotted:void 0};function Aw(e){return e.includes(".")?"dotted":e.startsWith("=")?"thick":"solid"}function Md(e,t,n){e.lastIndex=n;return e.exec(t)}var Iw=/[\p{L}\p{N}_!"#$%&'*+.`?\\/]/u;function Kl(e,t=0){let n=t;for(;n<e.length;n++){const i=e[n];if(i==="-"){const r=e[n+1];if(r==="-"||r===".")break;continue}if(n===t&&i==='"')break;if(i===":"){if(e.startsWith(":::",n))break;continue}if(!Iw.test(i))break}return n-t}var W4={text:/[[\](){}|"]/,trapezoid:/[[\](){}]/,"edge-text":/"/};function xf(e,t){let n=e;if(e.startsWith('"')){const i=e.startsWith('"`');const r=i?e.indexOf('`"',2):e.indexOf('"',1);if(r<0)return false;n=e.slice(r+(i?2:1))}return W4[t].test(n)}var z4=/^[\p{L}0-9\s!"#$%&'*+\-./:?\\^_`]*$/u;var G4=/(?:^|\s)(?:"|\.+-)|--|-\.|->|:::/;function Fw(e){let t=e;if(e.startsWith('"')){const n=e.startsWith('"`');const i=n?e.indexOf('`"',2):e.indexOf('"',1);if(i<0)return true;t=e.slice(i+(n?2:1))}return!z4.test(t)||G4.test(t)}function BT(e,t){const n=e[t-1];return e[t]===","&&n!==void 0&&(n==="-"||n===":"||Iw.test(n))}function Kp(e,t){return(e[t]==="."||e[t]==='"')&&t>0&&Iw.test(e[t-1])}function Zp(e,t){const n=Md(_4,e,t);return n?{hasArrowStart:Boolean(n[1]),op:n[2],end:t+n[0].length}:null}function H4(e,t,n){let i=t;while(i<e.length&&/\s/.test(e[i]))i++;if(e[i]!=='"')return void 0;for(let r=e.indexOf('"',i+1);r>=0;r=e.indexOf('"',r+1)){if(Md(O4[n],e,r+1))return{open:i,close:r}}return void 0}function Nw(e,t){const n=bf(e,t);return n&&"end"in n?n:null}function bf(e,t){const n=Md(DT,e,t);if(!n)return null;const i=AT(e,t,n,Aw(n[2]));return i&&"end"in i?i:AT(e,t,n,"mixed")}function j4(e){const t=bf(e,0);return t!==null&&"stray"in t}function AT(e,t,n,i){const r=t+n[0].length;const o=H4(e,r,i);const s=B4[Aw(n[2])];for(let a=o?o.close+1:r;a<e.length;a++){const l=Md(D4[i],e,a);if(!l){if(s&&Md(s,e,a))return{stray:a};continue}const c=e.slice(r,a);const d=c.trim();if(d.length===0)continue;const u=r+c.length-c.trimStart().length;return{hasArrowStart:Boolean(n[1]),...n[1]?{startMark:n[1]}:{},openOp:n[2],closeOp:l[1],labelStart:u,labelEnd:u+d.length,...o?{quote:o}:{},end:a+l[0].length,...i==="mixed"?{mixed:true}:{}}}return null}function Y4(e,t){let n=t+1;while(n<e.length&&/\s/.test(e[n]))n++;if(e[n]==='"'){for(let r=e.indexOf('"',n+1);r>=0;r=e.indexOf('"',r+1)){let o=r+1;while(o<e.length&&/\s/.test(e[o]))o++;if(e[o]==="|")return{close:o,quote:{open:n,close:r}}}}const i=e.indexOf("|",t+1);return i<0?void 0:{close:i}}function q4(e,t){let n=t+1;while(n<e.length&&/\s/.test(e[n]))n++;return e[n]==="{"?n:-1}var IT=new Set(["[","(","{"]);var X4=new Set(["]",")","}"]);function $w(e){return Jp(e,0,false,false)}function WT(e,t){const n=Jp(e,t,true,false).regions[0];return n?.start===t?n:void 0}function Jp(e,t,n,i,r=-1){const o=[];const s=n?[]:Array(e.length).fill(false);const a=[];const l=[];const c=[];const d=(f,h,m)=>{o.push({kind:f,start:h,end:e.length,contentStart:m,contentEnd:e.length,closed:false,parent:c.at(-1)??-1});c.push(o.length-1)};const u=(f,h)=>{const m=o[c.pop()];m.contentEnd=f;m.end=h;m.closed=true};for(let f=t;f<e.length;f++){if(n&&o.length>0&&c.length===0)break;const h=e[f];const m=c.length>0?o[c.at(-1)]:void 0;if(m?.kind==="string"){if(h==='"')u(f,f+1);continue}if(m?.kind==="markdown"){if(h==="`"&&e[f+1]==='"'){u(f,f+2);f++}else if(h==='"')d("string",f,f+1);continue}if(h==='"'&&f!==r&&!(i&&m?.kind==="shape"&&f!==m.contentStart)&&!(m===void 0&&Kp(e,f))){if(e[f+1]==="`"){d("markdown",f,f+2);f++}else d("string",f,f+1);continue}if(m?.kind==="shape"){if(IT.has(h))d("shape",f,f+1);else if(X4.has(h))u(f,f+1);continue}const p=h==="@"?q4(e,f):-1;if(p>=0){const g=ga(e,p,"flowchart");if(g.kind==="closed"){o.push({kind:"metadata",start:f,end:g.end+1,contentStart:p+1,contentEnd:g.end,closed:true,parent:-1});f=g.end;continue}if(g.kind==="unclosed"){d("metadata",f,p+1);break}}if(h==="|"){const g=Y4(e,f);if(!g){d("pipe",f,f+1);break}const y=o.length;o.push({kind:"pipe",start:f,end:g.close+1,contentStart:f+1,contentEnd:g.close,closed:true,parent:-1});if(g.quote){o.push({kind:"string",start:g.quote.open,end:g.quote.close+1,contentStart:g.quote.open+1,contentEnd:g.quote.close,closed:true,parent:y})}f=g.close;continue}if(IT.has(h)){d("shape",f,f+1);continue}if(h==="-"||h==="="||h==="<"||h==="~"||h==="."&&!Kp(e,f)){const g=Zp(e,f);if(g){l.push({start:f,end:g.end});s.fill(true,f,g.end);f=g.end-1;continue}const y=Md(DT,e,f);const b=y?bf(e,f):null;const S=b&&"end"in b?b:null;if(S){const x=o.length;o.push({kind:"edge-text",start:f,end:S.end,contentStart:S.labelStart,contentEnd:S.labelEnd,closed:true,parent:-1});if(S.quote){o.push({kind:"string",start:S.quote.open,end:S.quote.close+1,contentStart:S.quote.open+1,contentEnd:S.quote.close,closed:true,parent:x})}s.fill(true,f,S.labelStart);const k=S.end-S.closeOp.length;s.fill(true,k,S.end);if(!n)for(let w=S.labelEnd;w<k;w++)s[w]=true;l.push({start:f,end:f+y[0].length},{start:k,end:S.end});f=S.end-1;continue}if(y){l.push({start:f,end:f+y[0].length});s.fill(true,f,f+y[0].length);if(b){f+=y[0].length-1;continue}d("edge-text",f,f+y[0].length);break}}if(h===">"){d("shape",f,f+1);continue}if(!n)s[f]=true;if(h===";")a.push(f)}return{regions:o,topLevel:s,separators:a,links:l,openAtEnd:c.map(f=>o[f].kind)}}var U4=/^(?:style|classDef|linkStyle)\s/;function V4(e){return!!e.trim()&&!/[\r\n:;,]/.test(e)&&zT(`${e}:`)}function cse(e,t=false){const n=t?e.split(","):[e];return!!e.trim()&&!e.startsWith("::")&&!/[\r\n]/.test(e)&&n.every(i=>!!i.trim()&&zT(i))}function zT(e){if(/direction\s+(?:TB|BT|RL|LR|TD)|:::/.test(e))return false;let t=e;while(t){if(/^(?:acc(?:Title|Descr)\s*:|(?:call|href|click)\s|(?:classDef|class|linkStyle|default|end|graph|flowchart|subgraph|swimlane-beta|interpolate|_self|_blank|_parent|_top|v)\b|["&*]|[xo]?(?:--|-\.)|[xo]?-?\.+-)/.test(t))return false;const n=/^(?:style\b|[0-9]+|[:#]|[^\S\r\n]+)/.exec(t)??/^(?:[A-Za-z0-9!"#$%&'*+.`?\\_/]|-(?=[^>\-.]))+/.exec(t);if(!n)return false;t=t.slice(n[0].length)}return true}function eg(e){for(const t of Object.keys(e)){if(!V4(t))throw Je({what:`Invalid style property name ${JSON.stringify(t)}`,expectedForm:"property text that does not introduce Mermaid statements, links or shape delimiters",example:"style A background:#bbb,border:1px solid red"})}return e}var K4=new RegExp(String.raw`^[a-zA-Z][\w-]*\s*:(?!:)(?:(?!${Qp}|:::)[^&@"[\]{}|])*$`);function Sf(e,t=$w(e)){const n=[];let i=0;for(const r of[...t.separators,e.length]){const o=e.slice(i,r);const s=o.trim();const a=i+o.length-o.trimStart().length;const l=/^end\s+/.exec(s);const c=n.at(-1);if(l)n.push({text:"end",start:a},{text:s.slice(l[0].length),start:a+l[0].length});else if(s&&c&&U4.test(c.text)&&K4.test(s))c.text=e.slice(c.start,a+s.length);else if(s)n.push({text:s,start:a});i=r+1}return n}function J4(e,t){const n=e.joined??[];let i=0;let r=n.length;while(i<r){const s=i+Math.floor((r-i)/2);if(n[s].at<=t)i=s+1;else r=s}const o=i===0?{at:0,line:e.line,col:0}:n[i-1];return{line:o.line,col:o.col+t-o.at}}var Q4=5;var FT=/^(?:(?:end|subgraph|classDef|class|style|linkStyle|click|href|accTitle|accDescr)(?![\w-])|direction\s)/;function tg(e){const t=[];const n=p=>Jp(p,0,false,true);let i;let r="";let o=n(r);let s=false;let a=false;let l;const c=new Map;const d=(p,g)=>{let y=c.get(g);if(!y){const{delimiter:b,closer:S,after:x}=ej[g];y=new Uint8Array(e.length+1);for(let k=e.length-1;k>=0;k--){const w=e[k];const C=w.search(b);y[k]=C<0?y[k+1]:Number(w[C]===S&&x.test(w.slice(C+1)))}c.set(g,y)}return y[p]===1};let u;const f=p=>{if(!u){u=new Uint8Array(e.length+1);for(let g=e.length-1;g>=0;g--){const y=e[g];const b=y.indexOf('"');u[g]=b<0?u[g+1]:Number(/^\s*[\])}]/.test(y.slice(b+1)))}}return u[p]===1};let h=false;const m=p=>{const g=e[p];if(!/^\s*acc(?:Title|Descr)/i.test(g)||h&&/^\s*accDescr\s*:?\s*\{[^}]*$/i.test(g))return void 0;const y=Tt(e,p);if(y===void 0)h=true;return y?.endIndex};for(let p=0;p<e.length;p++){const g=e[p];const y=g.trim();const b=o.openAtEnd;const S=o.regions.some(v=>v.kind==="string"&&v.parent>=0&&v.start!==o.regions[v.parent].contentStart);const x=l!==void 0&&d(p,l);const k=i!==void 0&&b.length>0&&b.length<=Q4&&!S&&(b[0]==="metadata"||b.includes("markdown")||!s||x||a&&b.length===1&&b[0]==="string")&&!(b[0]==="edge-text"&&j4(`${NT(r,o).prefix}${y}`));if(!k&&(!y||y.startsWith("%%"))){t.push({text:g,line:p});continue}const w=k?void 0:m(p);if(w!==void 0){i={text:g,line:p,directive:true};t.push(i);for(let v=p+1;v<=w;v++){;(i.joined??=[]).push({at:i.text.length+1,line:v,col:0});i.text+=`
|
|
17
|
-
${e[v]}`}p=w;r="";o=n(r);s=true;a=false;l=void 0;continue}let C=y;let R;let M;if(k&&b[0]==="metadata"){C=`${r}
|
|
18
|
-
${g}`;M=n(C);R="\n"}else if(k){const v=NT(r,o);C=`${v.prefix}${y}`;M=n(C);const L=M.regions[b.length-1];const T=L.closed&&C.slice(v.prefix.length,L.contentEnd).trim()==="";R=v.blank||T?" ":"<br>"}else{M=n(C);const v=b.length===0&&o.links.at(-1)?.end===r.trimEnd().length;if(i&&!s&&(v&&!FT.test(y)||M.links[0]?.start===0))R=" "}const P=Z4(M);if(P!==void 0&&!f(p+1))M=Jp(C,0,false,true,P);if(R===void 0){i={text:g,line:p};t.push(i)}else{const v=R==="\n"?g:y;const L=R==="\n"?0:g.length-g.trimStart().length;(i.joined??=[]).push({at:i.text.length+R.length,line:p,col:L});i.text+=`${R}${v}`}const E=Sf(C,M).at(-1);if(R===void 0||E&&E.start>0){s=E!==void 0&&FT.test(E.text);a=E!==void 0&&/^(?:click|href)\s/.test(E.text);l=E!==void 0&&/^subgraph\s/.test(E.text)?tj(C,M,E):void 0}r=C;o=M}return t}function GT(e){const t=e.map((r,o)=>o);const n=[];const i=[];e.forEach((r,o)=>{const s=r.trim();if(s&&!s.startsWith("%%")){n.push(o);i.push(s)}});for(const r of tg(i)){const o=r.joined?.at(-1)?.line;if(o!==void 0)t[n[r.line]]=n[o]}return t}function Z4(e){const t=e.regions.filter(i=>!i.closed).at(-1);const n=t&&t.parent>=0?e.regions[t.parent]:void 0;return t?.kind==="string"&&n?.kind==="shape"&&t.start===n.contentStart?t.start:void 0}var ej={bracket:{delimiter:/[[\](){}]/,closer:"]",after:/^\s*(?:;|$)/},string:{delimiter:/"/,closer:'"',after:/^\s*(?:;|$)/},bracketString:{delimiter:/"/,closer:'"',after:/^\s*\]\s*(?:;|$)/}};function tj(e,t,n){const i=t.regions.filter(a=>!a.closed);const[r,o]=i;const s=n.start+/^subgraph\s+/.exec(n.text)[0].length;if(i.length===1&&r.kind==="string"&&r.start===s)return"string";if(r?.kind!=="shape"||e[r.start]!=="["||/[[\]"]/.test(e.slice(s,r.start)))return void 0;if(i.length===1)return"bracket";return i.length===2&&o.kind==="string"&&o.start===r.contentStart?"bracketString":void 0}function NT(e,t){const n=t.regions.filter(a=>!a.closed);const i=n.at(-1);const r=e.slice(i.contentStart).trimStart()[0];const o=r===void 0?"":i.kind==="pipe"||i.kind==="edge-text"?`${r} `:"_ ";const s=a=>a.kind==="edge-text"?nj[Aw(e.slice(a.start,a.contentStart).replace(/^</,""))]:e.slice(a.start,a.contentStart);return{prefix:`${n.map(s).join("")} ${o}`,blank:r===void 0}}var nj={solid:"--",thick:"==",dotted:"-."};var ij=/&(?:(quot|amp|lt|gt|apos)|#(\d+)|#[xX]([0-9a-fA-F]+));/g;function HT(e){if(!e.includes("&"))return e;const t=e.split("\n");const n=new Map;for(const i of tg(t)){if(i.directive||!i.text.includes("&"))continue;const r=$w(i.text);const o=Sf(i.text,r).filter(s=>/^(?:click|href)\s/i.test(s.text));for(const s of i.text.matchAll(ij)){const a=s.index;const l=o.some(m=>a>=m.start&&a<m.start+m.text.length);if(!l&&!r.regions.some(m=>a>=m.contentStart&&a+s[0].length<=m.contentEnd))continue;const c=s[1]===void 0?s[2]!==void 0?Number(s[2]):Number.parseInt(s[3],16):void 0;const d=!l&&(c===void 0||c>0&&c<=1114111&&(c<55296||c>57343)&&!go.test(String.fromCodePoint(c)));const{line:u,col:f}=J4(i,a);const h=n.get(u)??[];h.unshift({col:f,length:s[0].length,code:d?`#${s[1]??c};`:$4(s[0])});n.set(u,h)}}for(const[i,r]of n){let o=t[i];for(const{col:s,length:a,code:l}of r)o=o.slice(0,s)+l+o.slice(s+a);t[i]=o}return t.join("\n")}function dse(e,t=$w(e)){return t.regions.filter(n=>n.kind==="edge-text").map(n=>({start:n.contentStart,end:n.contentEnd}))}var ng={ui:"ui",pcr:"processor",processor:"processor",cmd:"command",command:"command",rmo:"readmodel",readmodel:"readmodel",evt:"event",event:"event"};var ig="[_a-zA-Z]\\w*(?:\\.[_a-zA-Z]\\w*)*";var rj=new RegExp(`^(tf|timeframe|rf|resetframe)\\s+(\\d{1,3})\\s+(\\w+)\\s+(${ig})`);var qT=new Set(["json","jsobj","figma","salt","uri","md","html","text"]);function jT(e){const t=Object.hasOwn(ng,e)?ng[e]:void 0;if(!t)throw Error(`Unknown Event Modeling type: ${e}`);return t}var oj={command:{allowed:["ui","processor"],target:"command",expected:"ui or processor"},event:{allowed:["command"],target:"event",expected:"command"},readmodel:{allowed:["event"],target:"read model",expected:"event"},processor:{allowed:["readmodel"],target:"processor",expected:"read model"},ui:{allowed:["readmodel"],target:"ui",expected:"read model"}};function Sse(e,t){const n=oj[e];return t.flatMap((i,r)=>i===void 0||n.allowed.includes(i)?[]:[{sourceIndex:r,message:`A ${n.target} can only receive input from a ${n.expected}, not from '${i}'.`}])}function YT(e,t){const n=e.match(/^(?:`(\w+)`\s*)?([\s\S]+)$/);if(!n||n[1]&&!qT.has(n[1]))throw Error("Invalid Event Modeling data type");const i=n[2];if(t?!/^\{\s*\n[\s\S]*\n?\}$/.test(i):!/^(?:\{.*\}|".*"|'.*')$/.test(i))throw Error("Invalid Event Modeling data");return{...n[1]?{type:n[1]}:{},text:i.slice(1,-1).replace(t?/^\n|\n$/g:/$^/g,"")}}function wf(e){const t=e.entity.split(".");const n=t.length>1?t.slice(0,-1).join("."):"";const i=e.type==="event"?"Events":e.type==="command"||e.type==="readmodel"?"Command / Read Model":"UI / Automation";return n?`${n} \xB7 ${i}`:i}function Dw(e){const t=[];let n,i;for(const r of e.frames){const o=n!==void 0&&wf(n)===wf(r);const s=o?i:n;const a=[...r.sources];if(!r.reset&&s&&!a.length)a.unshift(s.id);for(const l of a)t.push({id:`relation:${l}:${r.id}`,from:l,to:r.id,explicit:r.sources.includes(l)});if(!o)i=n;n=r}Ve("edges",t.length);return t}function XT(e,t){const n=(Array.isArray(e)?e.join("\n"):e).replace(/\r\n/g,"\n");const i=_w(n,t!==void 0);const r=i.text.split("\n");const o=[0];if(t){for(let x=0;x<i.text.length;x++)if(i.text[x]==="\n")o.push(x+1)}const s=x=>i.offsets?.[x]??n.length;const a=(x,k,w,C)=>t?.({kind:x,id:k,start:s(w),end:s(Math.max(w,C-1))+1});const l=t?new Map:void 0;const c=t?new Set:void 0;const d=Wt(n.split("\n"),VT(n,i.protectedSpans));const u={kind:"eventmodeling",frames:[],entities:[],data:Object.create(null),notes:[],specifications:[],...vr(zo(d.accessibility))};const f=hr(n);if(f){const x=As(f.yaml);if(!x.ok)throw Error(x.message);if(x.value&&typeof x.value==="object"&&"title"in x.value&&typeof x.value.title==="string")u.title=x.value.title}const h=new Set;let m=r.findIndex(x=>x.trim()==="eventmodeling");if(m<0)throw Error("Expected eventmodeling header");let p,g="given",y=0,b=-1,S=false;for(m++;m<r.length;m++){let x=r[m].trim();const k=t?o[m]+r[m].indexOf(x):0;if(!x||x.startsWith("%%")||x.startsWith("//"))continue;Ge("eventmodeling","statement",x,{line:m+1,unit:"normalized"});if(x.startsWith("title ")){if(t)a("labels","title",k,k+x.length);u.title=yo(x.slice(6));continue}if(x.startsWith("accTitle:")){u.accessibilityTitle=x.slice(9).trim();continue}if(x.startsWith("accDescr:")){u.accessibilityDescription=x.slice(9).trim();continue}if(x.startsWith("accDescr {")){const P=[x.slice(10)];while(!P[P.length-1].includes("}")&&++m<r.length)P.push(r[m]);if(!P[P.length-1].includes("}"))throw Error("Unclosed accessibility description");u.accessibilityDescription=P.join("\n").replace(/}\s*$/,"").trim();continue}const w=x.match(rj);if(w){if(h.has(w[2])){const L=i.offsets??_w(n,true).offsets;const T=r.slice(0,m).reduce(($,_)=>$+_.length+1,0)+r[m].indexOf(x);const A=ks(Rr(n),L[T]??n.length);throw Error(`Duplicate event modeling frame ID "${w[2]}" on line ${A.line}`)}h.add(w[2]);p=void 0;let P=x.slice(w[0].length).trim();const E=[];while(P.startsWith("->>")){const L=P.match(/^->>\s*(\d{1,3})(?=\s|$)/);if(!L)throw Error("Invalid frame reference");E.push(L[1]);if(t){const T=`relation:${L[1]}:${w[2]}`;const A=k+x.length-P.length;a("edges",T,A,A+L[0].length);c.add(T)}P=P.slice(L[0].length).trim()}const v=P.match(/^\[\[(\w+)\]\]/);if(v)P=P.slice(v[0].length).trim();if(t){const L=k+w[0].indexOf(w[2]);a("nodes",w[2],L,k+x.length);l.set(w[2],[L,k+x.length]);const T=k+w[0].lastIndexOf(w[4]);a("labels",`node:${w[2]}`,T,T+w[4].length)}u.frames.push({id:w[2],reset:w[1]==="rf"||w[1]==="resetframe",type:jT(w[3]),entity:w[4],sources:E,...v?{dataReference:v[1]}:{},...P?{data:YT(P,false)}:{}});if(ie("eventmodeling"))ue("eventmodeling","append-frame",u.frames.at(-1));Ve("nodes",u.frames.length);continue}const C=x.match(new RegExp(`^entity\\s+(${ig})$`));if(C){u.entities.push(C[1]);p=void 0;continue}const R=x.match(/^(data\s+([_a-zA-Z]\w*)|note\s+(\d{1,3}))(?:\s+([\s\S]+))?$/);if(R){p=void 0;let P=R[4]??"";while(!P.includes("{")){if(++m>=r.length)throw Error("Unclosed Event Modeling data block");P+=(P?"\n":"")+r[m].trim()}const E=[P];while(!/^}\s*$/.test(r[++m]??"")){if(m>=r.length)throw Error("Unclosed Event Modeling data block");E.push(r[m])}E.push("}");const v=YT(E.join("\n"),true);if(R[2]){if(Object.hasOwn(u.data,R[2]))throw Error(`Duplicate data: ${R[2]}`);u.data[R[2]]=v}else u.notes.push({frame:R[3],data:v});if(t)a("labels",R[2]?`data:${R[2]}`:`note:${R[3]}:${u.notes.length-1}`,k,o[m]+r[m].length);continue}const M=x.match(/^gwt\s+(\d{1,3})\s*(.*)$/);if(M){g="given";b=-1;S=false;y=k;p={frame:M[1],given:[],when:[],then:[]};u.specifications.push(p);if(t)a("labels",`gwt:${M[1]}:${u.specifications.length-1}`,k,k+x.length);x=M[2]}if(p){const P=x.split(/\s+/).filter(Boolean);while(P.length){const E=P.shift();if(E==="given"||E==="when"||E==="then"){const L=["given","when","then"].indexOf(E);if(t&&(L<=b||b<0&&L!==0||b>=0&&!S))a("labels","unsupported-gwt",y,k+x.length);b=L;S=false;g=E;continue}if(t&&b<0)a("labels","unsupported-gwt",y,k+x.length);const v=P.shift();if(!v||!/^[_a-zA-Z]\w*$/.test(v))throw Error("Invalid specification entity");p[g].push({type:jT(E),entity:v});S=true}if(t)a("labels",`gwt:${p.frame}:${u.specifications.length-1}`,y,k+x.length);continue}throw Error(`Unsupported Event Modeling statement: ${x}`)}lj(u);if(t)for(const x of Dw(u)){const k=l.get(x.to);if(!c.has(x.id))a("edges",x.id,k[0],k[1])}return u}var sj=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 aj(e){return[...new Set([...e.frames.map(t=>t.entity),...e.entities,...Object.keys(e.data),...e.specifications.flatMap(t=>[...t.given,...t.when,...t.then].map(n=>n.entity))].filter(t=>t.split(".").some(n=>sj.has(n))))]}function lj(e,t=false){if(t&&aj(e).length)throw Error("Event Modeling identifiers cannot use reserved Mermaid grammar keywords");const n=new Set;for(const o of[e.title,e.accessibilityTitle,e.accessibilityDescription])if(o!==void 0&&typeof o!=="string")throw Error("Metadata must be text");const i=(o,s)=>{if(!o||typeof o!=="object"||Array.isArray(o)||Object.keys(o).some(a=>!s.includes(a)))throw Error("Unknown or malformed Event Modeling record field")};const r=o=>{i(o,["text","type"]);if(!o||typeof o.text!=="string"||o.type!==void 0&&!qT.has(o.type))throw Error("Invalid data record")};for(const o of e.entities)if(typeof o!=="string"||!new RegExp(`^${ig}$`).test(o))throw Error("Invalid entity declaration");if(new Set(e.entities).size!==e.entities.length)throw Error("Duplicate entity declaration");for(const[o,s]of Object.entries(e.data)){if(!/^[_a-zA-Z]\w*$/.test(o))throw Error("Invalid data identifier");r(s)}for(const o of e.notes){i(o,["frame","data"]);r(o.data)}for(const o of e.frames){i(o,["id","reset","type","entity","sources","dataReference","data"]);if(typeof o.id!=="string"||!/^\d{1,3}$/.test(o.id)||n.has(o.id))throw Error(`Duplicate or invalid frame ID: ${o.id}`);n.add(o.id);if(typeof o.reset!=="boolean"||!Array.isArray(o.sources)||!o.sources.every(s=>typeof s==="string"))throw Error("Invalid frame record");if(o.data)r(o.data);if(typeof o.entity!=="string"||!new RegExp(`^${ig}$`).test(o.entity)||!Object.values(ng).includes(o.type))throw Error("Invalid frame entity or type")}for(const o of e.frames){for(const s of o.sources)if(!n.has(s)||s===o.id)throw Error(`Invalid source frame: ${s}`);if(new Set(o.sources).size!==o.sources.length)throw Error("Duplicate frame relation");if(o.dataReference!==void 0&&(typeof o.dataReference!=="string"||!/^[_a-zA-Z]\w*$/.test(o.dataReference)))throw Error("Invalid data reference");if(o.dataReference&&!Object.hasOwn(e.data,o.dataReference))throw Error(`Unknown data: ${o.dataReference}`)}for(const o of e.notes)if(!n.has(o.frame))throw Error(`Unknown note frame: ${o.frame}`);for(const o of e.specifications){i(o,["frame","given","when","then"]);if(!Array.isArray(o.given)||!Array.isArray(o.when)||!Array.isArray(o.then))throw Error("Invalid specification statements");if(!n.has(o.frame)||!o.given.length||!o.then.length)throw Error("Invalid Given/When/Then specification");for(const s of[...o.given,...o.when,...o.then]){i(s,["type","entity"]);if(!Object.values(ng).includes(s.type)||typeof s.entity!=="string"||!/^[_a-zA-Z]\w*$/.test(s.entity))throw Error("Invalid specification type or entity")}}}function _w(e,t){const n=[];let i="";const r=t?[]:void 0;const o=(l,c)=>{i+=l;if(r)for(let d=0;d<l.length;d++)r.push(c+d)};let s=e.indexOf("\n");if(s<0)s=e.length;let a=true;for(let l=0;l<e.length;l++){const c=e[l],d=e[l+1];if(l>s){a=!i.slice(i.lastIndexOf("\n")+1).trim();const f=e.indexOf("\n",l);s=f<0?e.length:f}const u=a;a&&=/\s/.test(c);if(u&&(c==="t"||c==="a")&&/^(?:title(?:[ \t]|$)|accTitle[ \t]*:|accDescr[ \t]*:)/.test(e.slice(l,s))){const f=e.indexOf("%%",l);o(e.slice(l,f>=0&&f<s?f:s),l);l=s-1;continue}if(c==="/"&&d==="*"){const f=e.indexOf("*/",l+2);if(f<0)throw Error("Unclosed Event Modeling comment");n.push([l,f+2]);const h=e.slice(l,f+2);o(h.replace(/[^\n]/g," "),l);a=u||h.includes("\n");l=f+1;continue}if(c==="%"&&d==="%"||c==="/"&&d==="/"){l=s-1;continue}if(c==="{"){if(!e.slice(l+1,s).trim()&&s<e.length){const h=/^}[ \t]*(?=\n|$)/gm;h.lastIndex=s+1;const m=h.exec(e);if(!m)throw Error("Unclosed Event Modeling block");n.push([l,m.index+m[0].length]);o(e.slice(l,m.index+m[0].length),l);l=m.index+m[0].length-1;continue}const f=e.lastIndexOf("}",s-1);if(f<l)throw Error("Unclosed inline data");o(e.slice(l,f+1),l);l=f;continue}if(c==='"'||c==="'"||c==="`"){const f=c==="`"?e.indexOf(c,l+1):e.lastIndexOf(c,s-1);if(f<=l||f>=s)throw Error("Unclosed inline value");o(e.slice(l,f+1),l);l=f;continue}if(/\s/.test(e[l-1]??"")&&/[tredng]/.test(c)&&/^(?:tf|timeframe|rf|resetframe|entity|data|note|gwt)\s/.test(e.slice(l))){const f=i.slice(i.lastIndexOf("\n")+1);if(f.trim()){i=i.trimEnd();if(r)r.length=i.length;o("\n",l)}}o(c,l)}return{text:i,offsets:r,protectedSpans:n}}function UT(e){const t=e.join("\n");try{return VT(t,_w(t,false).protectedSpans)}catch{return e.map((n,i)=>i)}}function VT(e,t){const n=Rr(e);const i=n.map((r,o)=>o);for(const[r,o]of t){const s=ks(n,r).line-1;const a=ks(n,Math.max(r,o-1)).line-1;i[s]=Math.max(i[s],a)}return i}function KT(e){const t=new Map;for(const n of e.frames){const i=wf(n);const r=t.get(i)??{id:`lane:${t.size}`,label:i,members:[]};r.members.push(n.id);t.set(i,r)}return[...t.values()]}var rg=["$end","INVALID","BLOCK_DIAGRAM_KEY","id-block","COLUMNS","MD_STR","STR","SPACE_BLOCK","DEFAULT","LINKSTYLE","INTERPOLATE","classDef","DEFAULT_CLASSDEF_ID","CLASSDEF_ID","CLASSDEF_STYLEOPTS","class","CLASSENTITY_IDS","STYLECLASS","style","STYLE_ENTITY_IDS","STYLE_DEFINITION_DATA","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","end","NODE_DSTART","NODE_DEND","BLOCK_ARROW_START","BLOCK_ARROW_END","DIR","NODE_ID","LINK","START_LINK","LINK_LABEL","SIZE","EOF"];function og(e){if(e<128)return e===32||e>=9&&e<=13;return e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function kd(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}var dj=["right","left","x","y","up","down"];var JT=new Uint8Array(128);for(const e of[9,10,11,12,13,32,40,41,45,58,60,61,62,91,123,125])JT[e]=1;function Ow(e,t){const n=e.length;const i=[];const r=[];const o=[];const s=[];let a=0;let l=0;const c=(P,E,v)=>{i.push(P);r.push(E);o.push(l);l=v;return true};const d=(P,E)=>c(P,e.slice(l,E),E);const u=P=>{s.push(a);a=P};const f=()=>{if(s.length>0)a=s.pop()};const h=P=>{while(P<n&&og(e.charCodeAt(P)))P++;return P};const m=P=>{while(P<n){const E=e.charCodeAt(P);if(E<48||E>57)break;P++}return P};const p=P=>{while(P<n&&kd(e.charCodeAt(P)))P++;return P};const g=P=>e.startsWith(P,l)&&!kd(e.charCodeAt(l+P.length));const y=()=>{if(e.charCodeAt(l+1)===96){u(2);l+=2}else{u(1);l++}return true};const b=P=>{if(e.charCodeAt(P)!==46)return-1;do P++;while(e.charCodeAt(P)===46);if(e.charCodeAt(P)!==45)return-1;const E=e.charCodeAt(P+1);return E===120||E===111||E===62?P+2:P+1};const S=P=>{const E=e.charCodeAt(P);if(E===120||E===111||E===60)P++;const v=e.charCodeAt(P);if(v===46)return b(P);if(v!==45&&v!==61)return-1;let L=P+1;while(e.charCodeAt(L)===v)L++;if(L-P===1)return v===45?b(L):-1;const T=e.charCodeAt(L);if(T===120||T===111||T===62)return L+1;return L-P>=3?L:-1};const x=()=>{const P=S(l);if(P>=0)return d(33,h(P));const E=e.charCodeAt(l)===60?l+1:l;const v=e.charCodeAt(E);const L=e.charCodeAt(E+1);if(v===45&&(L===45||L===46)||v===61&&L===61){u(6);return d(34,h(E+2))}return false};const k=P=>{let E=e.indexOf("\n",l);if(E===-1)E=n;f();return d(P,E)};const w=(P,E)=>{let v=p(l);if(v===l)return false;while(e.charCodeAt(v)===44){const L=h(v+1);const T=p(L);if(T===L)break;v=T}a=E;return d(P,v)};const C=P=>{if(P===37&&e.charCodeAt(l+1)===37){const v=e.indexOf("\n",l+2);t?.(l,v<0?n:v);l=v<0?n:v;return true}if(og(P)){l=h(l+1);return true}let E;switch(P){case 98:if(e.startsWith("block",l)){if(g("block-beta"))return d(2,l+10);if(e.charCodeAt(l+5)===58)return d(3,l+6);if(!kd(e.charCodeAt(l+5)))return d(2,l+5)}break;case 99:if(e.startsWith("columns",l)){E=h(l+7);if(E>l+7){if(e.startsWith("auto",E)&&!kd(e.charCodeAt(E+4)))return c(4,"-1",E+4);const v=m(E);if(v>E)return c(4,e.slice(E,v),v)}}else if(e.startsWith("class",l)){const v=e.startsWith("Def",l+5);const L=v?l+8:l+5;E=h(L);if(E>L){u(v?7:9);return d(v?11:15,E)}}break;case 34:return y();case 115:if(e.startsWith("space",l)){if(e.charCodeAt(l+5)===58){const v=m(l+6);if(v>l+6)return c(7,e.slice(l+6,v),v)}if(!kd(e.charCodeAt(l+5)))return c(7,"1",l+5)}else if(e.startsWith("style",l)){E=h(l+5);if(E>l+5){u(11);return d(18,E)}}break;case 100:if(g("default"))return d(8,l+7);break;case 108:if(g("linkStyle"))return d(9,l+9);break;case 105:if(g("interpolate"))return d(10,l+11);break;case 97:if(e.startsWith("accTitle",l)){E=h(l+8);if(e.charCodeAt(E)===58){u(13);return d(21,h(E+1))}}else if(e.startsWith("accDescr",l)){E=h(l+8);const v=e.charCodeAt(E);if(v===58){u(14);return d(23,h(E+1))}if(v===123){u(15);l=h(E+1);return true}}break;case 101:if(g("end"))return d(26,h(l+3));break;case 45:if(e.charCodeAt(l+1)===41){u(3);return d(27,l+2)}return x();case 61:return x();case 60:if(e.charCodeAt(l+1)===91){u(4);return d(29,l+2)}return x();case 40:{const v=e.charCodeAt(l+1);const L=v===45||v===91?2:v===40?e.charCodeAt(l+2)===40?3:2:1;u(3);return d(27,l+L)}case 41:case 123:u(3);return d(27,e.charCodeAt(l+1)===P?l+2:l+1);case 62:u(3);return d(27,l+1);case 91:{const v=e.charCodeAt(l+1);u(3);return d(27,v===91||v===124||v===40||v===92||v===47?l+2:l+1)}case 58:{const v=m(l+1);if(v>l+1)return c(36,e.slice(l+1,v),v);return false}}E=l;while(E<n){const v=e.charCodeAt(E);if(v<128?JT[v]===1:og(v))break;E++}return E>l&&d(32,E)};const R=P=>{const E=e.charCodeAt(l+1);let v=0;switch(P){case 34:return y();case 40:v=E===45?2:E===40?e.charCodeAt(l+2)===40?3:2:1;break;case 41:v=E===41?e.charCodeAt(l+2)===41?3:2:E===93?2:1;break;case 125:v=E===125?2:1;break;case 45:v=E===41?2:0;break;case 93:v=E===93||E===41||E===62?2:1;break;case 92:case 47:v=E===93?2:0;break}if(v===0)return false;f();return d(28,l+v)};const M=P=>{if(P===41){f();f();return c(30,"]>",h(l+1))}const E=h(P===44?l+1:l);for(const v of dj){if(e.startsWith(v,E)){const L=h(E+v.length);return c(31,e.slice(P===44?E:l,L),L)}}return false};while(true){if(l>=n){let v=-1;switch(a){case 0:v=37;break;case 1:v=6;break;case 8:v=14;break;case 10:v=17;break;case 12:v=20;break;case 13:v=22;break;case 14:v=24;break;case 15:v=25;break}l=n;if(v!==-1)c(v,"",n);break}const P=e.charCodeAt(l);let E=true;switch(a){case 0:E=C(P);break;case 1:if(P===34){f();l++}else{const v=e.indexOf('"',l);d(6,v===-1?n:v)}break;case 2:if(P===96){E=e.charCodeAt(l+1)===34;if(E){f();l+=2}}else if(P===34){E=false}else{let v=l+1;while(v<n){const L=e.charCodeAt(v);if(L===96||L===34)break;v++}d(5,v)}break;case 3:E=R(P);break;case 4:if(P===34){y()}else if(P===93&&e.charCodeAt(l+1)===62){const v=h(l+2);E=e.charCodeAt(v)===40;if(E){u(5);l=v+1}}else{E=false}break;case 5:E=M(P);break;case 6:if(P===34){if(e.charCodeAt(l+1)===96){y()}else{d(35,l+1);u(1)}}else{const v=S(h(l));E=v>=0;if(E){f();d(33,h(v))}}break;case 7:{let v=12;let L=e.startsWith("DEFAULT",l)?l+7:l;let T=h(L);if(L===l||T===L){v=13;L=p(l);T=h(L)}E=L>l&&T>L;if(E){a=8;d(v,T)}break}case 8:k(14);break;case 9:E=w(16,10);break;case 10:k(17);break;case 11:E=w(19,12);break;case 12:k(20);break;case 13:k(22);break;case 14:k(24);break;case 15:if(P===125){f();l++}else{const v=e.indexOf("}",l);d(25,v===-1?n:v)}break}if(!E){i.push(1);r.push("");o.push(l);return{types:i,texts:r,starts:o}}}i.push(0);r.push("");o.push(n);return{types:i,texts:r,starts:o}}var Cd=["$end","INVALID","title","acc_title","acc_title_value","acc_descr","acc_descr_value","acc_descr_multiline_value","direction_tb","direction_bt","direction_rl","direction_lr","NEWLINE","EOF","RD","STRUCT_START","STRUCT_STOP","STYLE_SEPARATOR","COLONSEP","ID","TEXT","RISK","VERIFYMTHD","REQUIREMENT","FUNCTIONAL_REQUIREMENT","INTERFACE_REQUIREMENT","PERFORMANCE_REQUIREMENT","PHYSICAL_REQUIREMENT","DESIGN_CONSTRAINT","LOW_RISK","MED_RISK","HIGH_RISK","VERIFY_ANALYSIS","VERIFY_DEMONSTRATION","VERIFY_INSPECTION","VERIFY_TEST","ELEMENT","CONTAINS","COPIES","DERIVES","SATISFIES","VERIFIES","REFINES","TRACES","TYPE","DOCREF","STYLE","CLASSDEF","CLASS","ALPHA","COLON","SEMICOLON","PERCENT","MINUS","BRKT","END_ARROW_L","END_ARROW_R","LINE","qString","unqString","COMMA"];var QT=new Map([["requirementdiagram",14],["id",19],["text",20],["risk",21],["verifymethod",22],["requirement",23],["functionalrequirement",24],["interfacerequirement",25],["performancerequirement",26],["physicalrequirement",27],["designconstraint",28],["low",29],["medium",30],["high",31],["analysis",32],["demonstration",33],["inspection",34],["test",35],["element",36],["contains",37],["copies",38],["derives",39],["satisfies",40],["verifies",41],["refines",42],["traces",43],["type",44],["docref",45],["style",46],["classdef",47],["class",48]]);function Mf(e){if(e<128)return e===32||e>=9&&e<=13;return e===160||e===5760||e>=8192&&e<=8202||e===8232||e===8233||e===8239||e===8287||e===12288||e===65279}function kf(e){return e===10||e===13||e===8232||e===8233}function Pd(e){return e>=48&&e<=57||e>=65&&e<=90||e>=97&&e<=122||e===95}function Ise(e){for(let t=0;t<e.length;t++){const n=e.charCodeAt(t);if(Pd(n))continue;switch(n){case 32:case 35:case 44:case 45:case 58:case 59:continue;default:return false}}return true}var fj=/accTitle\s*:\s*/iy;var hj=/accDescr\s*:\s*/iy;var mj=/accDescr\s*\{\s*/iy;var sg=/direction\s+(?:(TB)|(BT)|(RL)|LR)/gi;var Bw=/[\n\r\u2028\u2029]/g;var pj=22;var ZT=new Uint8Array(128);for(const e of":,\r\n{<>-=")ZT[e.charCodeAt(0)]=1;function Ww(e,t){const n=e.length;const i=[];const r=[];const o=[];const s=[];let a=0;let l=false;let c=0;const d=[[],[],[],[]];const u=[[],[],[],[]];const f=[0,0,0,0];let h=false;let m=-1;sg.lastIndex=0;for(let R=sg.exec(e);R!==null;R=sg.exec(e)){const M=R[1]!==void 0?0:R[2]!==void 0?1:R[3]!==void 0?2:3;d[M].push(R.index);u[M].push(sg.lastIndex);h=true}const p=(R,M,P)=>{i.push(R);r.push(e.slice(M,P));o.push(M);c=P};const g=R=>{s.push(a);a=R};const y=()=>{if(s.length>0)a=s.pop()};const b=(R,M)=>{R.lastIndex=M;return R.test(e)?R.lastIndex:-1};const S=R=>{const M=Ll(e,R);return M===-1?n:M};const x=()=>{if(m<c){Bw.lastIndex=c;m=Bw.test(e)?Bw.lastIndex-1:n;for(let R=0;R<4;R++){const M=d[R];let P=f[R];while(P<M.length&&M[P]<=m)P++;f[R]=P}}for(let R=0;R<4;R++){const M=f[R]-1;if(M>=0&&d[R][M]>=c){p(8+R,c,S(u[R][M]));return true}}return false};const k=R=>{const M=R|32;if(M===116&&e.slice(c+1,c+5).toLowerCase()==="itle"&&Mf(e.charCodeAt(c+5))){let P=c+6;while(P<n){const E=e.charCodeAt(P);if(E===35||E===10||E===13||E===59)break;P++}if(P>c+6){p(2,c,P);return true}}if(M===97&&(e.charCodeAt(c+1)|32)===99&&(e.charCodeAt(c+2)|32)===99){let P;if((P=b(fj,c))>=0){g(3);p(3,c,P);return true}if((P=b(hj,c))>=0){g(4);p(5,c,P);return true}if((P=b(mj,c))>=0){g(5);c=P;return true}}if(h&&!kf(R)&&x())return true;if(R===10||R===13){let P=c;while(P<n){const E=e.charCodeAt(P);if(E===10)P++;else if(E===13)P+=e.charCodeAt(P+1)===10?2:1;else break}p(12,c,P);return true}if(Mf(R)){c++;while(c<n&&Mf(e.charCodeAt(c))&&!kf(e.charCodeAt(c)))c++;return true}if(R===35||R===37){if(e.startsWith("%%",c))t?.(c,S(c));c=S(c);return true}if(Pd(R)){let P=c+1;while(P<n&&Pd(e.charCodeAt(P)))P++;if(P-c<=pj){const E=QT.get(e.slice(c,P).toLowerCase());if(E!==void 0){if(E===46||E===47||E===48){l=false;g(2)}p(E,c,P);return true}}while(P<n){const E=e.charCodeAt(P);if(E<128&&ZT[E]===1)break;P++}i.push(59);r.push(e.slice(c,P).trim());o.push(c);c=P;return true}switch(R){case 123:p(15,c,c+1);return true;case 125:p(16,c,c+1);return true;case 58:if(e.charCodeAt(c+1)===58&&e.charCodeAt(c+2)===58)p(17,c,c+3);else p(18,c,c+1);return true;case 60:if(e.charCodeAt(c+1)!==45)return false;p(55,c,c+2);return true;case 45:if(e.charCodeAt(c+1)===62)p(56,c,c+2);else p(57,c,c+1);return true;case 34:g(1);c++;return true;case 44:p(60,c,c+1);return true}return false};const w=R=>{if(Pd(R)){let M=c+1;while(M<n&&Pd(e.charCodeAt(M)))M++;let P=M;while(P<n&&Mf(e.charCodeAt(P))&&!kf(e.charCodeAt(P)))P++;if(l&&e.charCodeAt(P)===40){M=P;let E=0;while(M<n){const v=e.charCodeAt(M);if(kf(v)||E===0&&(v===44||v===59))break;if(v===40)E++;else if(v===41)E=Math.max(0,E-1);M++}}p(49,c,M);return true}switch(R){case 58:l=true;p(50,c,c+1);return true;case 59:l=false;p(51,c,c+1);return true;case 37:p(52,c,c+1);return true;case 45:p(53,c,c+1);return true;case 35:p(54,c,c+1);return true;case 32:c++;return true;case 34:g(1);c++;return true;case 10:y();c++;return true;case 13:y();c+=e.charCodeAt(c+1)===10?2:1;return true;case 44:l=false;p(60,c,c+1);return true}return false};while(c<n){const R=e.charCodeAt(c);let M=true;switch(a){case 0:M=k(R);break;case 2:M=w(R);break;case 1:if(R===34){y();c++}else{const P=e.indexOf('"',c);p(58,c,P===-1?n:P)}break;case 3:y();p(4,c,S(c));break;case 4:y();p(6,c,S(c));break;case 5:if(R===125){y();c++}else{const P=e.indexOf("}",c);p(7,c,P===-1?n:P)}break}if(!M){i.push(1);r.push("");o.push(c);return{types:i,texts:r,starts:o}}}const C=a===0?13:a===1?58:a===3?4:a===4?6:a===5?7:-1;if(C!==-1)p(C,n,n);p(0,n,n);return{types:i,texts:r,starts:o}}function eL(e){const t=e.map((r,o)=>o);if(!e.length)return t;const n=["requirementDiagram",...e.slice(1)].join("\n");const i=[0];for(let r=0;r<n.length;r++)if(n[r]==="\n")i.push(r+1);try{const r=Ww(n);let o=0;for(let s=0;s<r.types.length;s++){if(r.types[s]!==58)continue;const a=r.starts[s],l=a+r.texts[s].length;while(o+1<i.length&&i[o+1]<=a)o++;let c=o;while(c+1<i.length&&i[c+1]<=l)c++;t[o]=Math.max(t[o],c);o=c}}catch{}return t}var gj=/(\(\(|\{\{|\(-|-\)|\)\)|\[|\(|\))/;var yj={"[":"]","(":")","((":"))","{{":"}}",")":"(","))":"((","(-":"-)","-)":"(-"};function xj(e){return e?nn(mr(String(e))):void 0}function bj(e,t){let n,i=0;const r=ga(e,1,"flowchart",(u,f,h)=>{const m=u-2+i;(n??=[]).push({start:m,end:m+h,sourceStart:u-2,sourceEnd:f-2});i+=h-(f-u)});if(r.kind!=="closed")return[];const o=[];const s=yw(r.body);const a=s.text.includes("\n"),l=a?0:2;const c=a?`${s.text}
|
|
19
|
-
`:`{
|
|
20
|
-
${s.text}
|
|
21
|
-
}`;const d=u=>{const f=s.sourceOffset(Math.max(0,Math.min(s.text.length,u-l)));let h=0,m=n?.length??0;while(h<m){const g=h+m>>>1;if(n[g].start<=f)h=g+1;else m=g}const p=n?.[h-1];return t+2+(p?f<p.end?p.sourceStart:f-p.end+p.sourceEnd:f)};for(const u of Qb(c)){o.push({name:s.restore(u.name),keyStart:d(u.keyStart),keyEnd:d(u.keyEnd),valueStart:d(u.valueStart),valueEnd:d(u.valueEnd)})}return o}function zw(e,t={},n,i){const r=typeof e==="string"?e:e.join("\n");const o=n?/\r|\n/g:/\r\n?|\n/g;const s=r.split(o);const a=r.match(o)??[];let l=2,c=0;while(s.length&&(!s[0].trim()||s[0].trim().startsWith("%%"))){c+=s[0].length+(a[0]?.length??0);s.shift();a.shift();l++}const d=c,u=s.shift()??"";c+=u.length+(a[0]?.length??0);const f=(w,C,R)=>{if(!i)return;const M=Xr(w);if(M>=0)i(w.slice(M+2).trim(),C,{start:R+M+2,end:R+w.length})};f(u,l-1,d);a.shift();let h=c;const m=ie("kanban")||i?s.map((w,C)=>{const R=h;h+=w.length+(a[C]?.length??0);return R}):void 0;Ge("kanban","header",u,{line:l-1,unit:"normalized"});if(!/^kanban\s*$/i.test(Gt(u).trim()))throw Je({what:"Invalid Kanban header",expectedForm:"kanban",example:"kanban\nTodo\n task[Write documentation]"});const p={kind:"kanban",columns:[],accessibilityTitle:t.title,accessibilityDescription:t.descr};const g=new Set,y=new Map;let b,S,x;const k=(w,C)=>{if(!n)return`line ${l+w}, column ${C+1}`;const R=n.originalText.split(/\r\n?|\n/);let M=(n.wrapperSource?.match(/\r\n?|\n/g)?.length??0)+1;for(let P=0;P<=w;P++){const E=s[P].trim();while(M<R.length&&R[M].trim()!==E)M++;if(M>=R.length)break;if(P===w){const v=R[M].length-R[M].trimStart().length,L=s[P].length-s[P].trimStart().length;return`line ${M+1}, column ${C+v-L+1}`}M++}return`line ${l+w}, column ${C+1}`};for(let w=0;w<s.length;w++){let C=s[w],R=0,M=C.trim();if(!M||M.startsWith("%%"))continue;const P=Tt(s,w);if(P){if(P.title&&t.title===void 0)p.accessibilityTitle=P.value;else if(!P.title&&t.descr===void 0)p.accessibilityDescription=P.value;w=P.endIndex;if(!P.suffixLine)continue;C=P.suffixLine;R=s[w].length-C.length;M=C.trim()}const E=w;const v=C.length-C.trimStart().length;const L=(H,j,q,X=E)=>Je({what:`Kanban syntax at ${k(X,j)}: ${H}`,expectedForm:q,example:"task[Work]@{ assigned: Alice }"});if(M.startsWith(":::")||M.startsWith("::icon(")){if(!x)throw L("Kanban decoration has no preceding item",v,"a column or task before its decoration");if(M.startsWith(":::")){f(M.slice(3),w+l,(m?.[w]??0)+R+v+3);x.className=Gt(M.slice(3)).trim()}else{const H=/^::icon\(([^)]*)\)\s*(?:%%.*)?$/.exec(M);if(!H)throw L("Invalid Kanban icon decoration",v,"::icon(icon-name)");f(M.slice(M.indexOf(")")+1),w+l,(m?.[w]??0)+R+v+M.indexOf(")")+1);x.icon=H[1].trim()}Ge("kanban",M.startsWith(":::")?"class":"icon",C,{line:w+l,unit:"normalized"});if(ie("kanban"))ue("kanban",M.startsWith(":::")?"set-class":"set-icon",{id:x.id,sourceId:x.sourceId,value:M.startsWith(":::")?x.className:x.icon});continue}let T="",A="",$=false,_=v,z="";const F=M.indexOf("@{"),G=gj.exec(F<0?M:M.slice(0,F));if(G){T=M.slice(0,G.index).trim();$=!T;const H=G[0],j=yj[H];let q=M.slice(G.index+H.length),X;if(q.startsWith('"')){const V=q.startsWith('"`'),ee=V?'`"':'"';const re=V?2:1;_=v+G.index+H.length+re;while(q.indexOf(ee,re)<0&&w+1<s.length)q+=(a[w]==="\r"?"\r":"\n")+s[++w];const U=q.indexOf(ee,re);if(U<0)throw L("Unclosed Kanban quoted label",v+G.index+H.length,`closing ${ee}${j}`);A=q.slice(re,U);X=U+ee.length;if(!q.slice(X).startsWith(j))throw L("Unclosed Kanban label",v+G.index,`closing ${j}`);X+=j.length}else{_=v+G.index+H.length;while(!q.includes(j)&&w+1<s.length)q+=(a[w]==="\r"?"\r":"\n")+s[++w];const V=q.indexOf(j);if(V<0)throw L("Unclosed Kanban label",v+G.index,`closing ${j}`);A=q.slice(0,V);X=V+j.length}z=q.slice(X).trim();if($)T=A}else{const H=F<0?M:M.slice(0,F);f(H,w+l,(m?.[w]??0)+R+v);const j=Gt(H).trim();T=A=j;z=F<0?"":M.slice(F)}if(!T||!A)throw L("Empty Kanban item",v,"a column or card with a non-empty label");const I=A;let D={};let B;if(z.startsWith("@{")){const H=s.slice(E,w+1).join("\n"),j=H.lastIndexOf(z);let q=z,X=Vl(q,1,"flowchart");while(!X.ok&&X.unclosed&&w+1<s.length){q+="\n"+s[++w];X=Vl(q,1,"flowchart")}if(!X.ok){const V=H.slice(0,j),ee=V.split("\n").length-1,re=j-(V.lastIndexOf("\n")+1);throw L(`Invalid Kanban metadata (${X.message})`,re,"a closed @{ key: value } metadata mapping",E+ee)}D=Object.fromEntries(X.entries);if(ie("kanban"))B=bj(q,j);z=q.slice(X.end+1).trim();if(D.shape&&(typeof D.shape!=="string"||D.shape!==D.shape.toLowerCase()||D.shape.includes("_")))throw L("Invalid Kanban metadata shape",v,"a lowercase shape without underscores");if(D.label)A=String(D.label)}if(Gt(z).trim())throw L(`Unexpected Kanban suffix: ${z}`,v,"a node followed by optional @{ metadata }");const Y=i?s[w].length-s[w].trimEnd().length:0;f(z,w+l,(m?.[w]??0)+s[w].length-Y-z.length);if(ie("kanban"))Ge("kanban","node",s.slice(E,w+1).join("\n"),{line:E+l,offset:m[E],endOffset:m[w]+s[w].length,unit:"normalized"});T=nn(T);A=xj(D.label)??nn(A);const W=y.get(T)??0;y.set(T,W+1);let O=W?`${T}#${W+1}`:T;while(g.has(O))O+="#";g.add(O);const N={id:O,sourceId:T,...$?{implicitId:true}:{},label:A,metadata:D,...D.icon?{icon:String(D.icon)}:{}};b??=v;if(v<b)throw L(`Items without section detected, found section ("${A}")`,v,"columns at the first column indentation and cards indented beneath them");if(v===b){S={...N,tasks:[]};p.columns.push(S);x=S;if(ie("kanban"))ue("kanban","add-column",{...N,indent:v,declaredStart:R+v,declaredLabel:I,declaredLabelStart:R+_,...B?{metadataSpans:B}:{}})}else{if(!S)throw new Error("Kanban card has no column");S.tasks.push(N);x=N;if(ie("kanban"))ue("kanban","add-task",{...N,indent:v,declaredStart:R+v,declaredLabel:I,declaredLabelStart:R+_,parentId:S.sourceId,...B?{metadataSpans:B}:{}})}Ve("nodes",g.size)}return p}function tL(e){const t=e.map((n,i)=>i);try{VC("kanban",n=>{if(n.unit!=="statement"||n.kind!=="node"||!n.source?.line||n.text===void 0)return;const i=n.source.line-1;t[i]=Math.min(e.length-1,i+n.text.split("\n").length-1)},()=>zw(e),{mutations:[]})}catch(n){if(n instanceof Ei)throw n}return t}import{decodeXML as nL}from"entities";var iL=["C4Context","C4Container","C4Component","C4Dynamic","C4Deployment"];var qw=class extends Es{};var Sj=/^(Person|System|Container|Component)(Db|Queue)?(_Ext)?$/;var Rd={Boundary:"boundary",Enterprise_Boundary:"enterprise",System_Boundary:"system",Container_Boundary:"container",Deployment_Node:"deployment",Node:"deployment",Node_L:"deployment",Node_R:"deployment"};var Gw=new Set(["Rel","BiRel","Rel_U","Rel_Up","Rel_D","Rel_Down","Rel_L","Rel_Left","Rel_R","Rel_Right","Rel_Back","RelIndex"]);var rL={U:"BT",Up:"BT",D:"TB",Down:"TB",L:"RL",Left:"RL",R:"LR",Right:"LR"};var oL=["elementName","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"];var sL=["from","to","textColor","lineColor","offsetX","offsetY"];var aL=["tagStereo","bgColor","fontColor","borderColor","shadowing","shape","sprite","techn","legendText","legendSprite"];var lL=["tagStereo","textColor","lineColor","lineStyle","sprite","techn","legendText","legendSprite"];function wj(e="C4Context"){return{kind:"c4",variant:e,elements:[],boundaries:[],relationships:[],directives:[],statements:[],diagnostics:[],layout:{hints:[]}}}function ro(e,t){if(!ie("c4"))return;const{start:n,end:i,line:r,column:o}=e.span;Ge("c4",t,e.raw,{line:r,column:o,offset:n,endOffset:i,unit:"physical"})}function Mj(e){const t=[];let n=0,i=1,r=1,o=true;const s=(a,l="unknown")=>{const c=e.slice(n,a);t.push({id:`c4-statement-${t.length+1}`,kind:l,raw:c,span:{start:n,end:a,line:i,column:r}});if(ie("c4"))Bo("c4",`chunk:${l}`,c,{line:i,column:r,offset:n,endOffset:a,unit:"physical"});let d=e[n-1];for(const u of c){if(u==="\r"||u==="\n"&&d!=="\r"){i++;r=1}else if(u!=="\n")r++;d=u}n=a};while(n<e.length){const a=n;if(/\s|;/.test(e[a])){let f=a+1;while(f<e.length&&/\s|;/.test(e[f]))f++;s(f,"trivia");continue}if(e.startsWith("%%",a)){const f=Ll(e,a);const h=f<0?e.length:f;const m=!o&&Tt([e.slice(a,h)],0)?.form==="native";s(h,m?"accessibility":"trivia");continue}if(o){o=false;const f=Ll(e,a);const h=f<0?e.length:f;let m=h;for(let g=a;g<h;g++){if(e[g]==="&"){const y=/^&(?:#\d+|#x[0-9a-f]+|[a-z][a-z0-9]*);/i.exec(e.slice(g,h));if(y){g+=y[0].length-1;continue}}if(e[g]===";"){m=g;break}}const p=nL(e.slice(a,m)).trim();if(iL.some(g=>g.toLowerCase()===p.toLowerCase())){s(m,"header");continue}}if(e[a]==="}"){s(a+1,"boundary-close");continue}const l=e.slice(a);const c=/^[A-Za-z_][A-Za-z_0-9]*/.exec(l)?.[0];let d=a+(c?.length??0);while(d<e.length&&/[ \t\r\n]/.test(e[d]))d++;if(c&&e[d]==="("){let f=0,h="";for(;d<e.length;d++){const p=e[d];if(h){if(p===h)h=""}else if(p==='"'||p==="'")h=p;else if(p==="(")f++;else if(p===")"&&--f===0){d++;break}}if(f||h)throw new Error(`C4: unclosed ${c} argument list at line ${i}`);let m=d;while(m<e.length&&/\s/.test(e[m]))m++;if(e[m]==="{"){if(Rd[c]){s(m+1,"boundary-open");continue}let p=1;h="";d=m+1;for(;d<e.length&&p;d++){const g=e[d];if(h){if(g===h)h=""}else if(g==='"'||g==="'")h=g;else if(g==="%"&&e[d+1]==="%"){const y=Ll(e,d+2);d=y<0?e.length:y}else if(g==="{")p++;else if(g==="}")p--}if(p)throw new Error(`C4: unclosed ${c} block at line ${i}`)}s(d);continue}const u=Ll(e,a);if(/^accDescr[ \t]*:?[ \t]*\{/i.test(l)){const f=e.indexOf("}",a);if(f<0)throw new Error(`C4: unclosed accessibility block at line ${i}`);s(f+1,"accessibility");continue}s(u<0?e.length:u)}return t}function cL(e,t=true){const n=e.trim();if(n.length>=2&&(n[0]==='"'||n[0]==="'")&&n.at(-1)===n[0]){const i=n.slice(1,-1).trim();return t?nn(i):i}return t?nn(n):n}function Da(e,t,n){let i;for(let o=0;o<e.length;o++)if((e[o].name??t[o])===n)i=e[o];if(!i)return void 0;const r=i.name?i.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):i.raw;return nn(gs(cL(r,false)))}function kj(e){if(!e.trim())return[];const t=[];let n=0,i=0,r="";for(let o=0;o<e.length;o++){const s=e[o];if(r){if(s===r)r=""}else if(s==='"'||s==="'")r=s;else if(s==="(")i++;else if(s===")")i--;else if(s===","&&i===0){t.push(e.slice(n,o));n=o+1}}t.push(e.slice(n));return t.map(o=>{const s=/^\s*\$([A-Za-z_][A-Za-z_0-9]*)\s*=([\s\S]*)$/.exec(o);return{...s?{name:s[1]}:{},value:cL(s?s[2]:o),raw:o}})}function vf(e,t=[]){return e.length>0&&e.length>=t.length&&e.every((n,i)=>{if(n.name&&(t.includes(n.name)||i<t.length&&t[i]!=="label"))return false;if(n.raw.includes("%%{"))return false;const r=(n.name?n.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):n.raw).trim();if(n.name)return/^ *\$[A-Za-z_][A-Za-z_0-9]* *= *"[^"]+"$/.test(n.raw);if(r.startsWith('"'))return/^ *"[^"]*"$/.test(n.raw);if(n.raw===""&&i<e.length-1)return true;return i<e.length-1&&r.length>0&&!/^[\$']|[(),\r\n]/.test(r)})}function Cj(e,t,n){if(!e.name&&t<n.length-1&&!/^["'$)]/.test(e.raw.trim())&&!e.raw.includes(","))return false;const i=e.name?e.raw.replace(/^\s*\$[A-Za-z_][A-Za-z_0-9]*\s*=/,""):e.raw;for(const r of i.matchAll(/"[^"]*"|'[^']*'|(\$[A-Za-z_][A-Za-z_0-9]*\s*(?:=|["']))/g))if(r[1])return true;return false}function Hs(e,t){const n=Object.create(null);for(let i=0;i<e.length;i++){const r=e[i];const o=r.name??t[i];if(o!==void 0)n[o]=r.value}return n}function Cf(e){return e.startsWith("Person")||e.startsWith("System")?["alias","label","descr","sprite","tags","link"]:["alias","label","techn","descr","sprite","tags","link"]}function Pf(e){return Rd[e]==="deployment"?["alias","label","type","descr","sprite","tags","link"]:e==="Boundary"?["alias","label","type","tags","link"]:["alias","label","tags","link"]}function Ef(e){return e==="RelIndex"?["index","from","to","label","tags","link"]:["from","to","label","techn","descr","sprite","tags","link"]}function Hw(e){return e?e.split("+").map(t=>t.trim()).filter(Boolean):[]}function oo(e){return e===""?void 0:e}function Ed(e,t,n){const i=e[t];if(i===void 0||t!=="label"&&!i.trim())throw new Error(`C4: ${n} requires ${t==="label"?"a":"a non-empty"} ${t}`);return i}function jw(e,t,n,i){const r=Da(e,t,"label");if(r!==void 0)return r;if(e[t.indexOf("label")]?.name)return"";return Ed(n,"label",i)}function Rf(e){const{args:t,style:n,effectiveLink:i,statementId:r,...o}=e;if("name"in e)return JSON.stringify([e.name,e.args.map(s=>[s.name,s.value])]);return JSON.stringify(o)}function Mn(e,t,n,i,r="warning"){e.diagnostics.push({code:"UNSUPPORTED_SYNTAX",syntax:n,severity:r,statementId:t,message:i})}var Pj=new Set(["UpdateElementStyle","UpdateRelStyle","UpdateLayoutConfig"]);function dL(e){return e==="UpdateElementStyle"?oL:e==="UpdateRelStyle"?sL:e==="UpdateLayoutConfig"?["c4ShapeInRow","c4BoundaryInRow"]:void 0}function iae(e){const t=dL(e.name);if(!t)return vf(e.args);if(e.name==="UpdateLayoutConfig")return vf(e.args)&&e.args.every((i,r)=>!i.name||i.name===t[r]);const n=e.name==="UpdateElementStyle"?1:2;return vf(e.args,t.slice(0,n))}function Ej(e){if(e==="UpdateElementStyle")return"element-style";if(e==="UpdateRelStyle")return"relationship-style";if(e==="AddElementTag")return"element-tag";if(e==="AddRelTag")return"relationship-tag";if(e==="UpdateLayoutConfig"||e.startsWith("Lay_")||e.startsWith("LAYOUT_"))return"layout";if(e==="ShowLegend"||e==="SHOW_LEGEND"||e==="SHOW_FLOATING_LEGEND")return"legend";if(e==="AddElementLink"||e==="AddRelLink")return"link";return"unknown"}function Yw(e,t){return Object.fromEntries(Object.entries(e).filter(([n,i])=>!t.includes(n)&&i!==""))}function Rj(e,t=false){for(const c of[...e.elements,...e.boundaries,...e.relationships]){c.style={};delete c.effectiveLink;if(ie("c4"))ue("c4","reset-presentation",{id:c.id,style:c.style})}e.layout={hints:[]};if(ie("c4"))ue("c4","reset-layout",e.layout);const n=new Map([...e.elements,...e.boundaries].map(c=>[c.id,c]));const i=new Map;const r=(c,d)=>JSON.stringify([c,d]);for(const c of e.relationships){const d=r(c.from,c.to),u=i.get(d)??[];u.push(c);i.set(d,u)}const o=(c,d)=>{const u=Hs(c.args,d);for(const f of["techn","legendText"]){const h=Da(c.args,d,f);if(h!==void 0)u[f]=h}return u};const s=new Map,a=new Map;for(const c of e.directives){if(c.category!=="element-tag"&&c.category!=="relationship-tag")continue;const d=o(c,c.category==="element-tag"?aL:lL);(c.category==="element-tag"?s:a).set(d.tagStereo??"",Yw(d,["tagStereo"]));if(ie("c4"))ue("c4","define-tag",{category:c.category,tag:d.tagStereo??"",style:(c.category==="element-tag"?s:a).get(d.tagStereo??"")})}for(const c of[...e.elements,...e.boundaries])for(const d of c.tags){Object.assign(c.style,s.get(d));if(ie("c4"))ue("c4","apply-tag",{id:c.id,tag:d,style:c.style})}for(const c of e.relationships)for(const d of c.tags){Object.assign(c.style,a.get(d));if(ie("c4"))ue("c4","apply-tag",{id:c.id,tag:d,style:c.style})}for(const c of e.directives){if(c.category==="element-style"){const d=o(c,oL);const u=n.get(d.elementName);if(!u)throw new Error(`C4: UpdateElementStyle references undeclared alias ${JSON.stringify(d.elementName)}`);Object.assign(u.style,Yw(d,["elementName"]));if(ie("c4"))ue("c4","set-element-style",{id:u.id,style:u.style})}else if(c.category==="relationship-style"){const d=Hs(c.args,sL);const u=i.get(r(d.from,d.to));if(!u)throw new Error("C4: UpdateRelStyle references an undeclared relationship pair");for(const f of["offsetX","offsetY"])if(d[f]!==void 0&&!Number.isFinite(Number(d[f])))throw new Error(`C4: ${f} must be finite`);for(const f of u){Object.assign(f.style,Yw(d,["from","to"]));if(ie("c4"))ue("c4","set-relationship-style",{id:f.id,style:f.style})}}else if(c.name==="UpdateLayoutConfig"){const d=Hs(c.args,["c4ShapeInRow","c4BoundaryInRow"]);for(const[u,f]of[["c4ShapeInRow","shapesPerRow"],["c4BoundaryInRow","boundariesPerRow"]]){if(d[u]===void 0||d[u]==="")continue;const h=Number(d[u]);if(!Number.isSafeInteger(h)||h<1)throw new Error(`C4: ${u} must be a positive integer`);e.layout[f]=h;if(ie("c4"))ue("c4","set-layout-option",{name:f,value:h})}}else if(c.name.startsWith("Lay_")){const d=rL[c.name.slice(4)];const u=Hs(c.args,["from","to"]);if(!d||!u.from||!u.to||!n.has(u.from)||!n.has(u.to))throw new Error(`C4: ${c.name} requires two declared aliases`);if(d&&u.from&&u.to){if(t)Ve("edges",e.relationships.length+e.layout.hints.length+1);e.layout.hints.push({from:u.from,to:u.to,direction:d,statementId:c.statementId});if(ie("c4"))ue("c4","add-layout-hint",e.layout.hints.at(-1))}}else if(c.name==="direction"){e.layout.direction=c.args[0]?.value;if(ie("c4"))ue("c4","set-direction",e.layout.direction)}else if(c.name==="LAYOUT_LEFT_RIGHT"||c.name==="LAYOUT_TOP_DOWN"){e.layout.direction=c.name==="LAYOUT_LEFT_RIGHT"?"LR":"TB";if(ie("c4"))ue("c4","set-direction",e.layout.direction)}else if(c.name==="AddElementLink"){const d=Hs(c.args,["alias","link"]);const u=n.get(d.alias);if(u){u.effectiveLink=d.link;if(ie("c4"))ue("c4","set-effective-link",{id:u.id,link:u.effectiveLink})}}else if(c.name==="AddRelLink"){const d=Hs(c.args,["from","to","link"]);for(const u of i.get(r(d.from,d.to))??[]){u.effectiveLink=d.link;if(ie("c4"))ue("c4","set-effective-link",{id:u.id,link:u.effectiveLink})}}}const l=gi([...e.elements,...e.boundaries,...e.relationships].map(c=>c.id));e.legend={visible:e.directives.some(c=>c.category==="legend"),entries:[...[...s.entries()].map(([c,d])=>({id:l(`c4-tag-${c}`,["element-tag",c]),label:d.legendText??c,kind:"element",style:{...d}})),...[...a.entries()].map(([c,d])=>({id:l(`c4-tag-${c}`,["relationship-tag",c]),label:d.legendText??c,kind:"relationship",style:{...d}}))]};if(ie("c4"))ue("c4","set-legend",e.legend)}function rae(e){return uL(e,false)}function uL(e,t){const n=typeof e==="string"?e:e.join("\n");const i=wj();if(ie("c4"))ue("c4","initialize",i);i.statements=Mj(n);const r=[];const o=new Set;const s=new Set;let a=false;let l=false;let c=false;for(const f of i.statements){const h=f.raw.trim();if(f.kind==="trivia"){ro(f,"trivia");if(!h.startsWith("%%")&&h.includes(";")){Mn(i,f.id,"c4_semicolon_separator","Semicolon statement separators are a reader extension; pinned Mermaid C4 requires line breaks");l=c=false}else if(h.startsWith("%%"))c||=l;else if(/[\r\n]/.test(f.raw)&&!c)l=false;continue}if(l&&f.kind!=="boundary-close")Mn(i,f.id,"c4_statements_on_one_line","Statements sharing a line are a reader extension; pinned Mermaid C4 requires a line break after each statement and after `{`, and a comment after a statement takes its line break");l=true;c=false;if(!a){const w=nL(h);const C=iL.find(R=>R.toLowerCase()===w.toLowerCase());if(!C)throw new Error("C4: expected C4Context, C4Container, C4Component, C4Dynamic, or C4Deployment");ro(f,"header");i.variant=C;if(ie("c4"))ue("c4","set-variant",C);f.kind="header";f.signature=C;a=true;continue}if(f.kind==="boundary-close"){ro(f,"boundary-close");const w=r.pop();if(!w)throw new Error(`C4: unmatched closing boundary at line ${f.span.line}`);if(ie("c4"))ue("c4","close-boundary",{id:w});f.entityId=w;continue}if(Un(h)!==h)Mn(i,f.id,"c4_entity_prepass","The global Mermaid entity prepass changes this statement; the writer protects its text fields without changing their values");if(/^title\s/i.test(h)){ro(f,"title");if(r.length)Mn(i,f.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header");if(/[#;]/.test(Un(h.replace(/^title\s+/i,""))))Mn(i,f.id,"c4_title_token","The title contains literal token delimiters; serialization writes entity escapes for pinned Mermaid");i.title=nn(gs(h.replace(/^title\s+/i,"")));if(ie("c4"))ue("c4","set-title",i.title);f.kind="title";f.signature=i.title;continue}const m=Tt(h.split(/\r\n?|\n/),0);if(m){ro(f,"accessibility");if(r.length)Mn(i,f.id,"c4_nested_header_directive","Metadata inside a boundary is read as global. Pinned Mermaid requires it at document scope; the writer moves it after the header");if(!m.title&&m.form!=="native"&&m.value==="")Mn(i,f.id,"c4_empty_accessibility_description","An empty accessibility description block is a reader extension; the writer preserves its value in a native metadata comment");if(m.title)i.accessibilityTitle=m.value;else i.accessibilityDescription=m.value;if(ie("c4"))ue("c4",m.title?"set-accessibility-title":"set-accessibility-description",m.value);f.kind="accessibility";f.entityId=m.title?"title":"description";f.signature=m.value;continue}if(/^accDescription\s+/i.test(h)){ro(f,"accessibility");i.accessibilityDescription=h.replace(/^accDescription\s+/i,"");if(ie("c4"))ue("c4","set-accessibility-description",i.accessibilityDescription);f.kind="accessibility";f.entityId="description";f.signature=i.accessibilityDescription;continue}const p=/^direction\s+(LR|RL|TB|BT)\s*$/.exec(h);if(p){ro(f,"direction");const w={id:f.id,name:"direction",args:[{value:p[1],raw:p[1]}],category:"layout",statementId:f.id};i.directives.push(w);if(ie("c4"))ue("c4","add-directive",w);f.kind="directive";f.entityId=w.id;f.signature=Rf(w);continue}const g=/^([A-Za-z_][A-Za-z_0-9]*)\s*\(([\s\S]*)\)\s*(\{)?$/.exec(h);if(!g){ro(f,"unknown");Mn(i,f.id,"c4_unknown_statement","C4 statement is preserved but has no native interpretation","error");continue}const y=g[1],b=kj(g[2]);if(y==="UpdateLayoutConfig"&&(b.length===0||b.length===1&&!b[0].name&&b[0].value==="")&&!g[3]){if(r.length)o.add(r.at(-1));if(h[y.length]!=="("||!vf(b))Mn(i,f.id,"c4_empty_layout_arguments","An empty layout call is a no-op; the writer supplies the attribute required by pinned Mermaid");f.kind="trivia";continue}if(/[\r\n]/.test(g[2].replace(/"[^"]*"|'[^']*'/g,"")))Mn(i,f.id,"c4_multiline_arguments","Line breaks between C4 arguments are a reader extension; quoted multiline text remains supported");if(b.some(w=>w.name&&w.value===""))Mn(i,f.id,"c4_empty_named_argument","Empty named arguments are retained; pinned Mermaid requires a positional empty slot");const S=Sj.exec(y);const x=Boolean(S&&!(S[1]==="Person"&&S[2]))||Object.hasOwn(Rd,y)||Gw.has(y)||Pj.has(y);if(x&&r.length)o.add(r.at(-1));if(x&&b.some(Cj))throw new qw(`C4 argument is ambiguous in ${h}: separate named arguments with commas and use $name="value", or quote the entire value when it is literal text`);if(x&&b.some((w,C)=>{const R=w.raw.trim();if(w.name)return!/^\$[A-Za-z_][A-Za-z_0-9]*\s*=\s*"/.test(R)&&w.value!=="";return R.startsWith("$")||C===b.length-1&&R!==""&&!/^["']/.test(R)}))Mn(i,f.id,"c4_unquoted_argument","Unquoted C4 argument text is read literally here, but pinned Mermaid requires a quoted final argument and quoted named values; serialization writes those values in double quotes");if(x&&h[y.length]!=="(")Mn(i,f.id,"c4_space_before_arguments",`Pinned Mermaid reads "(" only straight after ${y} and rejects whitespace between them; ours reads the call. Write ${y}( with no space`);if(S&&!(S[1]==="Person"&&S[2])){ro(f,"element");if(g[3])throw new Error(`C4: ${y} cannot open a boundary`);const w=Hs(b,Cf(y));const C=Ed(w,"alias",y);if(s.has(C))throw new Error(`C4: duplicate declaration alias ${JSON.stringify(C)}`);s.add(C);const R={id:C,macro:y,kind:S[1].toLowerCase(),external:Boolean(S[3]),shape:S[1]==="Person"?"person":S[2]==="Db"?"database":S[2]==="Queue"?"queue":"rectangle",label:jw(b,Cf(y),w,y),technology:oo(Da(b,Cf(y),"techn")),description:oo(Da(b,Cf(y),"descr")),parentId:r.at(-1),tags:Hw(w.tags),link:oo(w.link),sprite:oo(w.sprite),style:{},args:b,statementId:f.id};if(t)Ve("nodes",i.elements.length+i.boundaries.length+1);i.elements.push(R);if(ie("c4"))ue("c4","add-element",R);f.kind="element";f.entityId=C;f.signature=Rf(R)}else if(Rd[y]){ro(f,"boundary-open");if(!g[3])throw new Error(`C4: ${y} requires a boundary block`);const w=Hs(b,Pf(y));const C=Ed(w,"alias",y);if(s.has(C))throw new Error(`C4: duplicate declaration alias ${JSON.stringify(C)}`);s.add(C);const R={id:C,macro:y,kind:Rd[y],label:jw(b,Pf(y),w,y),type:oo(Da(b,Pf(y),"type")),description:oo(Da(b,Pf(y),"descr")),parentId:r.at(-1),tags:Hw(w.tags),link:oo(w.link),sprite:oo(w.sprite),style:{},args:b,statementId:f.id,...y==="Node_L"?{alignment:"left"}:y==="Node_R"?{alignment:"right"}:{}};if(t){Ve("nodes",i.elements.length+i.boundaries.length+1);Ve("nesting",r.length+1)}i.boundaries.push(R);r.push(C);if(ie("c4"))ue("c4","open-boundary",R);f.entityId=C;f.signature=Rf(R)}else if(Gw.has(y)){ro(f,"relationship");const w=Hs(b,Ef(y));const C=Ed(w,"from",y),R=Ed(w,"to",y);const M=y==="Rel_Back";const P={id:"",macro:y,from:C,to:R,source:M?R:C,target:M?C:R,label:jw(b,Ef(y),w,y),technology:oo(Da(b,Ef(y),"techn")),description:oo(Da(b,Ef(y),"descr")),tags:Hw(w.tags),link:oo(w.link),sprite:oo(w.sprite),style:{},args:b,statementId:f.id,index:y==="RelIndex"?Ed(w,"index",y):void 0,order:i.relationships.length+1,bidirectional:y==="BiRel",reversed:M,direction:rL[y.slice(4)]};if(t)Ve("edges",i.relationships.length+i.layout.hints.length+1);i.relationships.push(P);if(ie("c4"))ue("c4","add-relationship",P);f.kind="relationship";if(y==="RelIndex"&&b.slice(4).some(E=>!E.name))Mn(i,f.id,"c4_relindex_positional_metadata","RelIndex positional metadata follows documented tags/link slots; pinned Mermaid instead treats them as technology/description. Named $tags/$link avoids this ambiguity")}else{ro(f,"directive");const w={id:f.id,name:y,args:b,category:Ej(y),statementId:f.id};i.directives.push(w);if(ie("c4"))ue("c4","add-directive",w);f.kind="directive";f.entityId=w.id;f.signature=Rf(w);if(w.category==="unknown")Mn(i,f.id,"c4_unknown_macro",`${y} is preserved but has no native interpretation`,"error");else if(!y.startsWith("Update"))Mn(i,f.id,"c4_directive_extension",`${y} is a reader extension; pinned Mermaid does not accept this directive`)}const k=S?Cf(y):Rd[y]?Pf(y):Gw.has(y)?Ef(y):dL(y)??(y==="AddElementTag"?aL:y==="AddRelTag"?lL:void 0);if(k){const w=new Set;for(let C=0;C<b.length;C++){const R=b[C],M=R.name??k[C];if(M===void 0||!k.includes(M)){Mn(i,f.id,"c4_unknown_argument",`${y} argument ${R.name??C+1} is retained but has no native interpretation`,"error")}else if(w.has(M)){Mn(i,f.id,"c4_duplicate_argument",`${y} assigns ${M} more than once; every argument is retained`,"error")}if(M)w.add(M)}}if(b.some(w=>/^\s*'/.test(w.raw)||/\\["']/.test(w.raw))){Mn(i,f.id,"c4_quoted_string_extension","Quoted-string extension is preserved; typed edits write Mermaid entity escapes")}else if(x&&!vf(b)&&!i.diagnostics.some(w=>w.statementId===f.id&&["c4_multiline_arguments","c4_empty_named_argument"].includes(w.syntax))){Mn(i,f.id,"c4_argument_spelling","Argument text is retained as its native value; the writer emits complete quoted argument tokens instead of ambiguous imported spelling")}}if(!a)throw new Error("C4: missing diagram header");if(r.length)throw new Error(`C4: unclosed boundary ${JSON.stringify(r.at(-1))}`);if(t)Pm(i);const d=gi(s);const u=new Map(i.statements.map(f=>[f.id,f]));for(const f of i.relationships){f.id=d(`c4-rel-${f.order}`,["c4-relationship",f.order]);if(ie("c4"))ue("c4","set-relationship-identity",{id:f.id,order:f.order});if(!s.has(f.from)||!s.has(f.to))throw new Error(`C4: relationship ${f.id} references an undeclared endpoint`);const h=u.get(f.statementId);h.entityId=f.id;h.signature=Rf(f)}Rj(i,t);for(const f of i.boundaries){if(!o.has(f.id))Mn(i,f.statementId,"c4_empty_boundary","An empty boundary is retained; the writer supplies a no-op layout statement because pinned Mermaid requires a statement inside its block")}if(i.directives.some(f=>f.name==="direction")){const f=i.directives.find(h=>h.name==="direction");Mn(i,f.statementId,"c4_direction","A standalone direction directive is a reader extension to legacy C4")}for(const f of[...i.elements,...i.boundaries,...i.relationships]){if(f.sprite)Mn(i,f.statementId,"c4_sprite","C4 sprite metadata is preserved; offline native output uses an explicit text fallback");if(f.style.lineStyle!==void 0&&!["solid","dashed","dotted"].includes(f.style.lineStyle)){Mn(i,f.statementId,"c4_line_style",`C4 lineStyle ${JSON.stringify(f.style.lineStyle)} is preserved but has no native paint effect; the route uses solid strokes`)}for(const h of Object.keys(f.style)){if(h==="shape"&&"external"in f&&mw(f.style.shape)!==void 0)continue;if(!["bgColor","fontColor","borderColor","textColor","lineColor","lineStyle","offsetX","offsetY","legendText","techn"].includes(h)){Mn(i,f.statementId,"c4_style_property",`C4 style ${h} is preserved as metadata but has no native paint effect`)}}}return i}function vj(e,t){const n=e.statements.find(i=>i.id===t.statementId);return n?`${t.message} (in: ${n.raw.trim()})`:t.message}function fL(e){const t=uL(e,true);const n=t.diagnostics.find(i=>i.severity==="error");if(n)throw new Error(`C4 unsupported syntax: ${vj(t,n)}`);return t}import{decodeXML as vo}from"entities";var Tj=/^direction\s+(TB|TD|BT|LR|RL)\s*$/i;function Tf(e){const t=e.match(Tj);return t?t[1].toUpperCase():void 0}var Lj=/^\s*(?:fill|stroke|color)\s*:\s*$/;function mL(e){const t=[];let n=0;let i=0;let r="";let o=false;for(let s=0;s<e.length;s++){const a=e[s];if(a==="#"){const l=/^#\w+;/.exec(e.slice(s))?.[0];if(l&&!(Lj.test(e.slice(n,s))&&Vt(l.slice(0,-1))!==null)){s+=l.length-1;o=false;continue}}if(o){o=false;continue}if(a==="\\"){o=true;continue}if(r){if(a===r)r="";continue}if(a==='"'||a==="'"){r=a;continue}if(a==="(")i++;else if(a===")")i=Math.max(0,i-1);else if((a===","||a===";")&&i===0){t.push(e.slice(n,s));n=s+1}}t.push(e.slice(n));return t}function uae(e){return mL(e).some(t=>t.slice(t.indexOf(":")+1).includes(","))}function vd(e){return zm(ag(e))}function ag(e){const t=[];const n=i=>no(Dn(i),{subject:"Style text entity",example:"font-family: Inter#44;serif"});for(const i of mL(e)){const r=i.indexOf(":");if(r<=0)continue;const o=n(i.slice(0,r).trim());const s=n(i.slice(r+1).trim().replace(/\\,/g,","));if(o&&s)t.push([o,s])}return t}function Aj(e,t){if(t!==void 0){if(!Array.isArray(t)||t.some(r=>!Array.isArray(r)||r.length!==2||r.some(o=>typeof o!=="string"||!o.trim())))return;const n=Object.entries(zm(t));const i=Object.entries(e);if(i.length!==n.length||i.some(([r,o],s)=>r!==n[s][0]||o!==n[s][1]))return}for(const[n,i]of t??Object.entries(e)){for(const r of[n,i]){if(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\ufffe\uffff\r\n]/.test(r))return;for(const o of r){const s=o.codePointAt(0);if(s>=55296&&s<=57343)return}}}return{...e}}function hL(e){const t=dn(e,`,:;<>&%"'\\\u2028\u2029`);return t.replace(/direction(?=\s+(?:TB|BT|RL|LR))/gi,n=>`#${n.codePointAt(0)};${n.slice(1)}`)}function Ij(e,t=false,n){if(!Aj(e,n))throw new Error("Style contains unrepresentable text or inconsistent ordered declarations");const i=(n??Object.entries(e)).map(([s,a])=>[s,a]);if(t)i.unshift(["style",""]);const r=i.map(([s,a])=>({name:s,value:a,key:hL(s),text:hL(a)}));const o=r.some(s=>s.key!==s.name||s.text!==s.value)?": ":":";return r.map(s=>`${s.key}${o}${s.text}`).join(",")}function fae(e,t,n=false,i){return e+Ij(t,n,i)}function Xw(e){if(e.markerAt==="from"&&(e.fromType??e.type)==="lollipop")return"from";if(e.markerAt==="to"&&(e.toType??e.type)==="lollipop")return"to";return void 0}function pL(e){const t=[...e];let n=false;while(t.length){const a=t.pop();if(a.value.kind==="relationship"&&Xw(a.value.relationship)){n=true;break}if(a.children)t.push(...a.children)}if(!n)return()=>{throw new Error("No lollipop interface occurrence was declared")};const i=new Set;const r=[...e];while(r.length){const a=r.pop(),l=a.value;if(a.children)r.push(...a.children);if(l.kind==="class")i.add(l.declaration.id);else if(l.kind==="annotation")i.add(l.annotation.id);else if(l.kind==="member"||l.kind==="note"){if(l.reference)i.add(l.reference.id)}else if(l.kind==="interaction")i.add(l.interaction.id);else if(l.kind==="relationship"){i.add(l.relationship.from);i.add(l.relationship.to)}else if(l.kind==="style"||l.kind==="assignment")for(const c of l.references)i.add(c.id)}const o=gi(i);let s=0;return()=>{const a=s++;return o(`interface${a}`,["interface",a])}}function lg(e){return{id:"cls-lollipop",shape:"circle",size:{width:14,height:14},viewBox:{x:0,y:0,width:14,height:14},ref:{x:12,y:7},orient:"auto-start-reverse",overflow:"hidden",geometry:{kind:"circle",cx:7,cy:7,r:5},paint:{fill:"var(--bg)",stroke:e,strokeWidth:"1.5"}}}var yL=/&#(?:\d+|[xX][0-9a-fA-F]+);|#\w+;/g;var xL=/direction(?=\s+(?:TB|BT|RL|LR))/;var Sae=e=>xL.test(e);var bL=e=>e.startsWith("&")?e:nn(e,{subject:"Class text entity",example:'class A["I #9829; UML"]'});function Oa(e){return e.replace(yL,bL)}function Ba(e,t=true,n=true){const i=t?yt(e):e;const r=Oa(i);if(!/#\w+;/.test(e))return{label:r};const o=cr(vt(n?yt(e):e),yL,bL);return{label:r,labelContent:{value:r,prepared:o,authored:e}}}function wae(e,t,n='"'){const i=t?.value===e?t.authored:void 0;return(i===void 0?dn(e,n):mr(i,n)).replace(/\r\n?|\n/g,"<br/>").replace(/%%\{/g,"%%#123;").replace(new RegExp(xL.source,"g"),r=>`#${r.codePointAt(0)};${r.slice(1)}`)}function Lf(e){if(!e.isMethod&&e.sourceText){const r=e.visibility&&e.sourceText.startsWith(e.visibility)?e.visibility:"";return Oa(r+Fj(e.sourceText.slice(r.length)))}const t=e.visibility?`${e.visibility} `:"";const n=e.isMethod?`${e.name}(${e.params||""})`:e.name;const i=e.type?`: ${e.type}`:"";return Oa(`${t}${n}${i}`)}function Fj(e){const t=e.split(/(,)/);const n=[];for(let i=0;i<t.length;i+=2){let r=t[i];let o=gL(r);while(o%2!==0&&i+2<t.length){const s=t[i+2];r+=`,${s}`;o+=gL(s);i+=2}n.push(Nj(r));if(i+1<t.length)n.push(",")}return n.join("")}function gL(e){let t=0;for(const n of e)if(n==="~")t++;return t}function Nj(e){const t=[...e];const n=[];for(let r=0;r<t.length;r++)if(t[r]==="~")n.push(r);if(n.length<=1)return e;const i=n.length%2!==0&&t[0]==="~"?1:0;for(let r=i,o=n.length-1;r<o;r++,o--){t[n[r]]="<";t[n[o]]=">"}return t.join("")}var CL=/^namespace\s+((?:`[^`\r\n]+`|[\w$]+)(?:\.(?:`[^`\r\n]+`|[\w$]+))*)(?:\s*\[\s*"?([^\]"]*)"?\s*\])?\s*\{/;function $j(e){const t=e.match(CL);if(!t||t[0].length!==e.length)return null;const n=[...t[1].matchAll(/`[^`]+`|[\w$]+/g)].map(i=>i[0].startsWith("`")?i[0].slice(1,-1):i[0]);return{path:n,label:t[2]||void 0}}function Af(e){return Jw(e).map(t=>t.text)}function Jw(e){const t=e.match(CL);if(!t)return[{text:e}];const n=t[0];const i=e.slice(n.length).trim();if(!i||i.startsWith("%%"))return[{text:e}];const r=[];let o=0;let s;let a=0;let l=false;let c=false;const d=u=>{u=u.trim();if(u)r.push({text:u,...l?{followsNamespaceCloseOnSameLine:true}:{}})};for(let u=0;u<i.length;u++){const f=i[u];if(s){if(f==="\\"&&s==='"'){u++;continue}if(f===s)s=void 0}else if(f==='"'||f==="`"||f==="~")s=f;else if(f==="{")a++;else if(f==="}"&&a>0)a--;else if(a===0&&(f===";"||f==="}")){const h=i.slice(o,u);if(fg(h)>=0)break;d(h);if(f===";"&&!l)c=true;if(f==="}")r.push({text:"}"});if(f==="}")l=true;o=u+1}}d(i.slice(o));return[{text:n,...c?{compactSemicolon:true}:{}},...r]}function _j(e){return e.replace(/&(?:#(?:[xX][0-9a-fA-F]+|[0-9]+)|[A-Za-z][A-Za-z0-9]+);/g,t=>{const n=vo(t);return/[\r\n]/.test(n)?n:t}).split(/\r\n|\r|\n/)}function Dj(e){const t=e.flatMap(_j).map(o=>o.trim()).filter(o=>{const s=vo(o).trim();return s.length>0&&!s.startsWith("%%")});const n=t.map(o=>vo(o));const i=[];const r=(o,s)=>{const a=Af(s);const l=o===void 0?[]:Af(o);if(l.length===a.length&&l.every((c,d)=>vo(c)===a[d])){i.push(...l)}else{i.push(...a.map(()=>void 0))}};for(let o=0;o<t.length;o++){const s=Tt(n,o);if(s===void 0){for(;o<t.length;o++)r(t[o],n[o]);break}if(s===null){r(t[o],n[o]);continue}if(s.suffixLine){const a=t[s.endIndex];const l=/}|&(?:#(?:[xX][0-9a-fA-F]+|[0-9]+)|[A-Za-z][A-Za-z0-9]+);/g;let c=-1;for(const u of a.matchAll(l)){if(vo(u[0])==="}"){c=u.index+u[0].length;break}}const d=c<0?void 0:a.slice(c).trim();r(d!==void 0&&vo(d).trim()===s.suffixLine.trim()?d:void 0,s.suffixLine.trim())}o=s.endIndex}return i}var PL="`[^`]+`|[\\w$\\p{L}\\p{N}\\p{M}]+(?:[.-][\\w$\\p{L}\\p{N}\\p{M}]+)*";var Oj=new RegExp(`^class\\s+(${PL})(?:\\s*~([^~]+)~)?(?:\\s*\\[\\s*"([^"]*)"\\s*\\])?(?:\\s+as\\s+"([^"]+)")?(?:\\s+~([^~]+)~)?(?:\\s*:::([\\w-]+))?\\s*(\\{\\s*\\}|\\{)?\\s*$`,"u");var Bj=new RegExp(`^(${PL})(?:~([^~]+)~)?$`,"u");function EL(e){const t=e.match(Oj);if(!t)return null;const n=t[1];return{id:n.startsWith("`")?n.slice(1,-1):n,generic:(t[2]??t[5])?.trim(),label:t[3]??t[4],...t[6]?{className:t[6]}:{},opensBody:t[7]==="{"}}function so(e){const t=e.trim().match(Bj);if(!t)return null;const n=t[1];return{id:n.startsWith("`")?n.slice(1,-1):n,generic:t[2]?.trim()||void 0}}function SL(e){const t=e.trim().match(/^<<[ \t]*(\w+)[ \t]*>>$/);return t?.[1]??null}function RL(e){const t=e.trim();return t.startsWith("<<")&&t.endsWith(">>")?t.slice(2,-2):null}function Wj(e){let t=false;let n=false;let i=false;let r=0;for(let o=0;o<e.length-1;o++){const s=e[o];if(t){if(s==="`")t=false;continue}if(n){if(s==='"')n=false;continue}if(i){if(s==="~")i=false;continue}if(s==="`"){t=true;continue}if(s==='"'){n=true;continue}if(s==="~"&&r===0){i=true;continue}if(s==="["){r++;continue}if(s==="]"){r=Math.max(0,r-1);continue}if(r===0&&s==="<"&&e[o+1]==="<")return o}return-1}function zj(e){const t=e.trim();if(t.startsWith("<<")){const u=t.indexOf(">>",2);if(u<0)return null;const f=SL(t.slice(0,u+2));const h=so(t.slice(u+2));return f&&h?{...h,annotation:f,placement:"separate"}:null}const n=t.match(/^class\s+/);if(!n)return null;const i=t.slice(n[0].length);const r=Wj(i);if(r<0)return null;let o=i.slice(0,r).trim();let s=i.slice(r).trim();const a=o.endsWith("{")&&s.endsWith("}");if(a){o=o.slice(0,-1).trim();s=s.slice(0,-1).trim()}const l=a?void 0:s.match(/\{\s*\}?$/)?.[0];if(l)s=s.slice(0,-l.length).trim();const c=EL(`class ${o}`);const d=a?RL(s):SL(s);return c&&!c.opensBody&&d!==null?{id:c.id,...c.generic?{generic:c.generic}:{},...c.label!==void 0?{label:c.label}:{},annotation:d,placement:a?"body-inline":"inline",...c.className!==void 0?{className:c.className}:{},...l==="{"?{opensBody:true}:{}}:null}function Uw(e,t){if(e.annotation!==void 0){throw Je({what:`Multiple annotations for class "${e.id}" are not modeled without losing identity`,expectedForm:"one annotation per class",example:`class ${e.id} <<${t}>>`})}e.annotation=Oa(t)}function $ae(e){return e.some(t=>{const n=t.trim();return n.length>0&&!n.startsWith("%%")})}var Vw=/(?:https?:\/\/|mailto:)\S*/iy;var Gj={'"':'"',"`":"`","~":"~","(":")"};function fg(e){const t=/^class\b/.test(e);for(let n=0;n<e.length-1;n++){const i=e[n];const r=Gj[i]??(t&&i==="{"?"}":void 0);if(r!==void 0){const o=e.indexOf(r,n+1);if(o<0)return-1;n=o;continue}if(i===":"){if(!e.startsWith(":::",n))return-1;n+=2;continue}if(n===0||/\s/.test(e[n-1])){Vw.lastIndex=n;if(Vw.test(e)){n=Vw.lastIndex-1;continue}}if(i==="%"&&e[n+1]==="%")return n}return-1}function cg(e){const t=e.indexOf("%%");return t<0?e:e.slice(0,t).trimEnd()}function vL(e){const t=fg(e);return t<0?e:e.slice(0,t).trimEnd()}function Qw(e,t){if(/^classDiagram(?:-v2)?\s*$/i.test(e))return{kind:"header"};if(!e||e.startsWith("%%"))return{kind:"trivia"};if(e==="}")return{kind:"close"};const n=t!==void 0?Kj(t):null;if(n)return{kind:"interaction",interaction:n};if(/^callback\s+(?:`[^`]+`|[\w$]+)(?:~[^~]+~)?\s+"[^"\r\n]+"(?:\s+"[^"\r\n]*")?\s*$/i.test(e)||/^click\s+(?:`[^`]+`|[\w$]+)(?:~[^~]+~)?\s+call\s+.+$/i.test(e)||/^(?:click|link)\s+(?:`[^`]+`|[\w$]+)(?:~[^~]+~)?\s+(?:href\s+)?"(?!(?:https?:\/\/|mailto:))[^"\r\n]*"(?:\s+"[^"\r\n]*")?\s*$/i.test(e)){return{kind:"source-only",reason:"Class callback or unsafe/relative link is retained as inert source-only action metadata"}}const i=vL((t??e).trim());const r=i.match(/^note(?:\s+for\s+(\S+))?\s+"([^"]*)"\s*$/i);const o=r??i.match(/^note(?:\s+for\s+(\S+))?\s+"((?:\\.|[^"\\])*)"\s*$/i);if(o){const S=o[1]?so(vo(o[1])):void 0;if(!o[1]||S)return{kind:"note",text:vo(r?o[2]:o[2].replace(/\\(["\\])/g,"$1")),...S?{reference:S}:{},...!r?{escapedQuotes:true}:{}}}const s=e.match(/^title\s+(.+)$/i);if(s)return{kind:"title",text:s[1].trim()};const a=Tf(e);if(a)return{kind:"direction",direction:a};const l=$j(e);if(l)return{kind:"namespace",...l};const c=S=>{const x=S.replace(/^"|"$/g,"").split(",").map(k=>so(k.trim()));return x.every(k=>k!==null)?x:null};const d=e.match(/^classDef\s+([\w,-]+)\s+(.+)$/);if(d){const S=vd(cg(d[2]));if(Object.keys(S).length>0)return{kind:"classDef",names:d[1].split(",").filter(Boolean),props:S,declarations:ag(cg(d[2]))}}const u=e.match(/^(class|cssClass)\s+(.+?)\s+([\w-]+)$/);if(u&&!e.includes("{")&&!e.includes("[")&&!e.includes(" as ")){const S=u[1]==="cssClass"&&/^"[^"]*"$/.test(u[2]);const x=S?u[2].slice(1,-1).split(",").map(k=>so(k.trim())??(k.trim()?{id:k.trim()}:null)):c(u[2]);if(x?.every(k=>k!==null)){return{kind:"assignment",references:x,name:u[3],form:u[1]==="class"?"class":S?"cssClass":"cssClassUnquoted"}}}const f=e.match(/^style\s+(.+?)\s+(.+)$/);if(f){const S=c(f[1]);const x=vd(cg(f[2]));if(S&&Object.keys(x).length>0)return{kind:"style",references:S,props:x,declarations:ag(cg(f[2]))}}const h=zj(e);if(h?.opensBody){const{id:S,generic:x,label:k,className:w}=h;return{kind:"class",declaration:{id:S,generic:x,label:k,...w!==void 0?{className:w}:{},annotation:h.annotation,opensBody:true}}}if(h)return{kind:"annotation",annotation:h};const m=EL(e);if(m&&!dg(m.id,/^class\s+`/.test(e),false)){return{kind:"unknown",reason:`Unrecognized class statement "${e}": Mermaid reads \`${m.id}\` there as a keyword, not a class name`}}if(m)return{kind:"class",declaration:m};const p=e.match(/^(.+?):::([\w-]+)$/);if(p){const S=so(p[1]);if(S)return{kind:"assignment",references:[S],name:p[2],form:"shorthand"}}const g=e.match(/^(\S+?)\s*:\s*(.+)$/);if(g){const S=so(g[1]);if(S&&(!dg(S.id,g[1].startsWith("`"),true)||/^call\s/.test(e))){return{kind:"unknown",reason:`Unrecognized class member statement "${e}": Mermaid reads \`${S.id}\` there as a keyword, not a class name`}}if(S)return{kind:"member",reference:S,text:g[2].trim()}}const y=Qj(e);if(y)return{kind:"relationship",relationship:y};const b=e.includes("<<")||e.includes(">>")?"annotation":iY(e)||rY(e)||oY(e)?"relationship":/^(?:click|link)\b/i.test(e)?"link":"";return{kind:"unknown",reason:`Unrecognized class${b?` ${b}`:""} statement "${e}"`}}var Hj=/^(?:note(?:\s+for\s+(?:`[^`]*`|\S+))?\s+|(?:class|namespace)\s[^"]*\[\s*)$/i;var jj=/^(?:class|namespace|note|click|link|callback|cssClass|style|classDef|title|direction)\b|^<</i;function Yj(e){return[false,true].every(t=>{let n;let i=-1;for(let o=0;o<e.length;o++){const s=e[o];if(n){if(t&&s==="\\"&&n==='"')o++;else if(s===n)n=void 0}else if(s==='"'||s==="`"){n=s;i=o}}if(n!=='"')return false;const r=e.slice(0,i);return Hj.test(r)||!jj.test(e)&&!r.includes(":")})}function qj(e){let t;for(let n=0;n<e.length;n++){const i=e[n];if(t){if(i===t)t=void 0}else if(i==='"'||i==="`"||i==="~")t=i;else if(i==="{")return n}return-1}function Xj(e){const t=[];let n=0;let i=0;for(let r=0;r<e.length;r++){const o=e[r];if(o==="(")i++;else if(o===")")i=Math.max(0,i-1);else if(o===";"&&i===0){let s=r;while(s>n&&/\w/.test(e[s-1]))s--;if(s<r&&(e[s-1]==="#"||e[s-1]==="&"))continue;t.push(e.slice(n,r));n=r+1}}t.push(e.slice(n));return t.map(r=>r.trim()).filter(Boolean)}function Uj(e,t){const n=/^class\s/.test(e)?qj(e):-1;const i=e.slice(0,n+1);const r=n<0?void 0:Qw(i,void 0);if(r?.kind==="class"&&r.declaration.opensBody){const a=e.slice(n+1);const l=a.indexOf("}");if(a.slice(0,l<0?void 0:l).includes("{"))return null;const c=l<0?"":a.slice(l);const d=/^[\s}]*/.exec(c)[0];const u=c.slice(d.length).trim();return[i,...Xj(l<0?a:a.slice(0,l)),...d.match(/\}/g)??[],...u?[u]:[]]}if(!t)return null;let o=e.length;while(o>0&&/[\s}]/.test(e[o-1]))o--;const s=e.slice(0,o);return o<e.length&&s&&Qw(s,void 0).kind!=="unknown"?[s,...e.slice(o).match(/\}/g)]:null}function Zw(e){const t=e.map((s,a)=>a);let n;try{n=hg(e)}catch{return t}const i=[];let r=0;for(const s of e){i.push(r);r+=s.length+1}const o=s=>{for(const a of s){const l=a.source.line-1;let c=l;while(c+1<e.length&&i[c+1]<=a.source.end)c++;if(c>t[l])t[l]=c;o(a.children??[])}};o(n.statements);return t}var wL=/%{2}\{\s*(?:(\w+)\s*:|(\w+))\s*(?:(\w+)|((?:(?!\}%{2}).|\r?\n)*))?\s*(?:\}%{2})?/gi;function _ae(e){const t=new Set;const n=[...hg(e,void 0,false).statements];while(n.length>0){const i=n.pop();if((i.value.kind==="style"||i.value.kind==="classDef")&&i.raw.trim()===e[i.source.line-1]?.trim())t.add(i.source.line);for(const r of i.children??[])n.push(r)}return t}function hg(e,t,n=true){const i={source:e.join("\n"),statements:[],diagnostics:[]};const r=[];let o=0;for(let s=0;s<e.length;s++){const a=e[s];const l={line:s+1,column:1,start:o,end:o+a.length};o+=a.length+1;let c=a.replace(wL,"");const d=t?t[s]?.replace(wL,""):c;const u=Jw(c.trim());const f=d===void 0?[]:Af(d.trim());let h=u.map((w,C)=>({...w,authored:f.length===u.length?f[C]:void 0}));const m=h.at(-1);let p=s;let g=m.text;for(let w=0;w<2&&r.at(-1)?.value.kind!=="class"&&Yj(g);w++){let C=p+1;while(C<e.length&&!e[C].includes('"'))C++;if(C===e.length)break;g=[g,...e.slice(p+1,C+1).map(R=>R.trim())].join("<br>");p=C}if(p>s){for(const w of e.slice(s+1,p+1))o+=w.length+1;l.end=o-1;s=p;c=g;h=[...h.slice(0,-1),...Jw(g).map(w=>({...m,...w,authored:void 0}))]}const y=h.reverse();const b=y.length===1;let S=false;let x;const k=(w,C)=>{for(let R=C.length-1;R>=0;R--)y.push({...w,text:C[R],authored:void 0});S=true};while(y.length>0){const w=y.pop();const C=w.text;const R=r[r.length-1];const M=R?.value.kind==="class";const P=M?C.indexOf("}"):C.startsWith("}")?0:-1;if(P>=0&&C!=="}"&&!C.startsWith("%%")){k(w,[C.slice(0,P).trim(),"}",C.slice(P+1).trim()].filter(Boolean));continue}const E=M&&!C.startsWith("}")?C:vL(C);let v;if(!C||C.startsWith("%%"))v={kind:"trivia"};else if(M&&E!=="}"){const $=RL(E);v=E.includes("{")?{kind:"unknown",reason:`Unrecognized class member "${E}": a class body cannot hold "{"`}:$===null?{kind:"member",text:E}:{kind:"body-annotation",text:$}}else v=Qw(E,w.authored);const L=v.kind==="unknown"&&!M?Uj(E,R?.value.kind==="namespace"):null;if(L){k(w,L);continue}const T={raw:b&&!S?c:C,text:E,source:l,value:v};if(n&&ie("class"))Ge("class",v.kind,E,{line:l.line,column:l.column,offset:l.start,endOffset:l.end,unit:"normalized"});if(w.followsNamespaceCloseOnSameLine||x==="namespace"&&v.kind!=="trivia"&&v.kind!=="close")T.followsNamespaceCloseOnSameLine=true;else if(x==="class"&&v.kind!=="trivia"&&v.kind!=="close")T.followsClassCloseOnSameLine=true;if(v.kind==="close"&&R)x=M?"class":"namespace";if(w.compactSemicolon)T.compactSemicolon=true;if(v.kind==="close"){if(R){R.closing=T;r.pop()}else{i.statements.push(T);i.diagnostics.push({reason:"Unexpected closing brace in class diagram",source:l})}continue}const A=R?R.children:i.statements;A.push(T);if(v.kind==="unknown")i.diagnostics.push({reason:v.reason,source:l});if(v.kind==="namespace"||v.kind==="class"&&v.declaration.opensBody){T.children=[];r.push(T)}}}for(const s of r)i.diagnostics.push({reason:`Unclosed ${s.value.kind==="namespace"?"namespace":"class"} block`,source:s.source});return i}function Dae(e){const t=[];for(let s=0;s<e.length;s++){const a=Tt(e,s);if(a===void 0)break;if(a!==null){t.push({text:"",index:s});s=a.endIndex;continue}for(const l of Af(e[s].trim())){if(l.length>0&&!l.startsWith("%%"))t.push({text:l,index:s})}}const n=[];const i=hg(t.map(s=>s.text));const r=(s,a,l)=>{const c=s.source.line-1;const{text:d,index:u}=t[c];if(d===""||l&&!d.startsWith("}"))return;const f=fg(d);if(f>=0&&(a>0||/^(?:class|namespace)\b/.test(d)||d.startsWith("}"))){n.push({index:u,what:"A %% comment after a class declaration, a namespace or a statement inside one, or a closing brace is read as a comment"})}else if(f>=0&&c<t.length-1&&s.value.kind!=="direction"){n.push({index:u,what:"A trailing %% comment on a statement that another statement follows is read as a comment"})}};const o=(s,a=0,l=false)=>{const c=[{nodes:s,namespaces:a,inClassBody:l,index:0}];while(c.length){const d=c.at(-1);if(d.index===d.nodes.length){if(d.closing)r(d.closing,d.namespaces,d.inClassBody);c.pop();continue}const u=d.nodes[d.index++];const{namespaces:f,inClassBody:h}=d;r(u,f,h);if(u.children){const m=f+(u.value.kind==="namespace"?1:0);const p=u.value.kind==="class";c.push({nodes:u.children,namespaces:m,inClassBody:p,index:0,closing:u.closing})}}};o(i.statements);return n}var ML=/(?:%|&#(?:0*37|x0*25);){2}/iy;function Kw(e,t=0){ML.lastIndex=t;return ML.test(e)}function Vj(e){const t=e.trimStart().match(/^(?:click|link)\s+(`[^`]+`(?:~[^~]+~)?|[\w$]+(?:~[^~]+~)?)\s+(?:href\s+)?(?:"((?:\\.|[^"\\])*)"|((?:https?:\/\/|mailto:)[^\s"\\]+))/i);if(!t)return null;const n=e.trimStart().slice(t[0].length).trimStart();let i;if(n.startsWith('"')){if(t[3]!==void 0)return null;let s=-1;let a=0;for(let c=1;c<n.length;c++){if(n[c]!=='"')continue;let d=c+1;while(d<n.length&&/\s/.test(n[d]))d++;if(a%2===0&&(d===n.length||Kw(n,d))){s=c;break}a++}if(s<0)return null;i=n.slice(1,s);if((i.match(/"/g)?.length??0)%2!==0)return null;const l=n.slice(s+1).trimStart();if(l&&!Kw(l))return null}else if(n&&!Kw(n))return null;const r=so(t[1]);const o=(t[2]??t[3]??"").replace(/\\(["\\])/g,"$1");return r&&/^(?:https?:|mailto:)/i.test(o)&&bs(o)&&!/[\u0000-\u0020\u007f-\u009f]/.test(o)&&(i===void 0||!/[\u0000-\u001f\u007f-\u009f]/.test(i))?{id:r.id,...r.generic?{generic:r.generic}:{},href:o,...i?{tooltip:i}:{}}:null}function Kj(e){const t=new Set;for(const u of vo(e)){const f=u.charCodeAt(0);if(f>=57344&&f<=63743)t.add(f)}let n=57344;while(t.has(n))n++;if(n>63743)return null;const i=String.fromCharCode(n);const r=vo(e.replace(/"|�*34;|�*22;/gi,u=>vo(u)==='"'?i:u));const o=u=>{const f=Vj(u);if(!f||f.tooltip?.includes('"'))return null;if(f.href.includes(i))return null;const h=f.href;const m=f.tooltip?.replaceAll(i,'"');if(!bs(h)||/[\u0000-\u0020\u007f-\u009f]/.test(h)||m!==void 0&&/[\u0000-\u001f\u007f-\u009f]/.test(m))return null;return{...f,href:h,...m!==void 0?{tooltip:m}:{}}};const s=o(r);if(s)return s;const a=u=>{const f=u.indexOf(i);const h=f<0?-1:u.indexOf(i,f+1);if(h<0)return null;return u.slice(0,f)+'"'+u.slice(f+1,h)+'"'+u.slice(h+1)};const l=a(r);if(!l)return null;const c=o(l);if(c)return c;if([...l].filter(u=>u===i).length!==2)return null;const d=a(l);return d===null?null:o(d)}function TL(e,t){const n=Wt(e,Zw(e));pr(n);const i=n.familyLines;const r=t?Dj(t):void 0;const o=i.flatMap(Af);const s=hg(o,r);if(s.diagnostics.length>0){const y=s.diagnostics[0];throw Je({what:`${y.reason} at line ${y.source.line}`,expectedForm:"supported class statements and balanced class/namespace blocks",example:"class A\nA --> B : linked"})}const a={classes:[],classDefs:new Map,relationships:[],notes:[],namespaces:[],...n.accessibility.title!==void 0?{accessibilityTitle:yt(n.accessibility.title)}:{},...n.accessibility.descr!==void 0?{accessibilityDescription:yt(n.accessibility.descr)}:{}};const l=new Map;const c=pL(s.statements);const d=new Map;const u=new Set;const f=[];const h=(y,b)=>{if(b&&!u.has(y)){d.get(b).classIds.push(y);u.add(y);if(ie("class"))ue("class","claim-member",{id:y,parent:b})}};const m=(y,b,S)=>{let x=y?d.get(y).children:a.namespaces;for(const k of b){y=y?`${y}.${k}`:k;let w=d.get(y);if(w&&w.name!==k){throw Je({what:`Class namespace path collision "${y}" between a quoted literal name and a dotted hierarchy`,expectedForm:"distinct namespace names that do not flatten to the same path",example:"namespace `Literal A.B` { class First }"})}if(!w){w={name:k,classIds:[],children:[]};x.push(w);d.set(y,w);if(ie("class"))ue("class","add-namespace",{id:y,parent:y.slice(0,-(k.length+1))||void 0,name:k})}x=w.children}if(S!==void 0){const k=d.get(y);delete k.labelContent;Object.assign(k,Ba(S));if(ie("class"))ue("class","set-namespace-label",{id:y,label:k.label})}return y};const p=(y,b)=>{const S=Jj(b);if(S){;(S.isMethod?y.methods:y.attributes).push(S.member);if(ie("class"))ue("class","add-member",{id:y.id,method:S.isMethod,member:S.member})}};const g=(y,b="",S)=>{const x=[{nodes:y,path:b,owner:S,index:0}];while(x.length){const k=x.at(-1);if(k.index===k.nodes.length){x.pop();continue}const w=k.nodes[k.index++];const{path:C,owner:R}=k;const M=w.value;switch(M.kind){case"header":case"trivia":case"close":case"source-only":break;case"namespace":x.push({nodes:w.children,path:m(C,M.path,M.label),owner:void 0,index:0});break;case"class":{const P=M.declaration;const E=js(l,P.id,P.generic);if(P.label!==void 0){delete E.labelContent;Object.assign(E,Ba(P.label))}if(P.className!==void 0)E.className=P.className;if(ie("class"))ue("class","declare-class",E,{line:w.source.line,unit:"normalized"});if(P.annotation!==void 0){Uw(E,P.annotation);if(ie("class"))ue("class","set-annotation",{id:E.id,annotation:E.annotation})}h(E.id,C);if(w.children)x.push({nodes:w.children,path:C,owner:E,index:0});break}case"member":{const P=M.reference?js(l,M.reference.id,M.reference.generic):R;p(P,M.text);break}case"body-annotation":Uw(R,M.text);if(ie("class"))ue("class","set-annotation",{id:R.id,annotation:R.annotation});break;case"annotation":{const P=M.annotation;if(P.placement==="separate"&&!l.has(P.id)){throw Je({what:`Annotation targets undeclared class "${P.id}"`,expectedForm:"declare the class before a separate annotation",example:`class ${P.id}
|
|
22
|
-
<<${P.annotation}>> ${P.id}`})}const E=js(l,P.id,P.generic);if(P.label!==void 0){delete E.labelContent;Object.assign(E,Ba(P.label))}if(P.className!==void 0)E.className=P.className;Uw(E,P.annotation);if(ie("class"))ue("class","set-annotation",{id:E.id,annotation:E.annotation,label:E.label});h(E.id,C);break}case"interaction":{const P=js(l,M.interaction.id,M.interaction.generic);P.href=M.interaction.href;if(M.interaction.tooltip!==void 0)P.tooltip=M.interaction.tooltip;if(ie("class"))ue("class","set-interaction",{id:P.id,href:P.href,tooltip:P.tooltip});h(P.id,C);break}case"note":if(M.reference)js(l,M.reference.id,M.reference.generic);{const{label:P,labelContent:E}=Ba(M.text);a.notes.push({text:P,...E?{textContent:E}:{},...M.reference?{for:M.reference.id}:{}})}if(ie("class"))ue("class","add-note",a.notes.at(-1));break;case"title":a.title=M.text;if(ie("class"))ue("class","set-title",a.title);break;case"direction":a.direction=M.direction;if(ie("class"))ue("class","set-direction",a.direction);break;case"relationship":{const{fromGeneric:P,toGeneric:E,...v}=M.relationship;const L=Xw(v);if(L){const T=L==="from"?P:E;const A=v[L]+(T?`~${T}~`:"");const $=c();const _=L==="from"?"to":"from";js(l,v[_],_==="from"?P:E);const z={id:$,label:A,...T?{generic:T}:{},isInterface:true,attributes:[],methods:[]};l.set($,z);if(ie("class"))ue("class","add-class",z);v[L]=$}else{js(l,v.from,P);js(l,v.to,E)}a.relationships.push(v);if(ie("class"))ue("class","add-relationship",v,{line:w.source.line,unit:"normalized"});break}case"classDef":for(const P of M.names){a.classDefs.set(P,Nu(a.classDefs.get(P),M.props));if(ie("class"))ue("class","define-class",{name:P,props:M.props})}break;case"assignment":case"style":for(const P of M.references){if(M.kind==="assignment"&&M.form.startsWith("cssClass")){const v=l.get(P.id);if(v)v.className=M.name;else f.push({id:P.id,name:M.name});continue}const E=js(l,P.id,P.generic);if(M.kind==="assignment")E.className=M.name;else E.inlineStyle=Nu(E.inlineStyle,M.props);if(ie("class"))ue("class",M.kind==="assignment"?"assign-class":"set-style",E);h(E.id,C)}break;case"unknown":break}}};g(s.statements);for(const{id:y,name:b}of f){const S=l.get(y);if(S&&S.className===void 0)S.className=b}a.classes=[...l.values()].filter(y=>!y.isInterface).concat([...l.values()].filter(y=>y.isInterface));Mm(a);return a}function js(e,t,n){let i=e.get(t);if(!i){i={id:t,label:n?`${t}<${n}>`:t,generic:n,attributes:[],methods:[]};e.set(t,i);if(ie("class"))ue("class","add-class",i)}else if(n&&!i.generic){i.generic=n;if(i.label===t)i.label=`${t}<${n}>`;if(ie("class"))ue("class","set-generic",i)}return i}function Jj(e){const t=e.trim();const n=/#\w+;$/.test(t)?t:t.replace(/;$/,"");if(!n)return null;let i="";let r=n;if(/^[+\-#~]/.test(r)&&!/^#\w+;/.test(r)){i=r[0];r=r.slice(1).trim()}const o=r.match(/^(.+?)\(([^)]*)\)(?:\s*(.+))?$/);if(o){const u=o[1].trim();const f=o[2]?.trim()||void 0;const h=o[3]?.trim();const m=u.endsWith("$")||r.includes("$");const p=u.endsWith("*")||r.includes("*");return{member:{visibility:i,name:u.replace(/[$*]$/,""),type:h||void 0,isStatic:m,isAbstract:p,isMethod:true,params:f},isMethod:true}}const s=r.split(/\s+/);let a;let l;if(s.length>=2){l=s[0];a=s.slice(1).join(" ")}else{a=s[0]??r}const c=a.endsWith("$");const d=a.endsWith("*");return{member:{visibility:i,name:a.replace(/[$*]$/,""),sourceText:n.replace(/[$*]$/,""),type:l||void 0,isStatic:c,isAbstract:d,isMethod:false},isMethod:false}}function Qj(e){const t=fg(e);if(t>=0)e=e.slice(0,t).trimEnd();return tY(e)??Zj(e)}function Zj(e){const t=If(e);if(t<0)return null;const n=e.slice(0,t);const i=e.slice(t+2);let r=n.match(/(<\||\(\)|[*o<>])$/)?.[1];let o=i.match(/^(\|>|\(\)|[*o<>])/)?.[1];if(r==="o"&&/[\w$]/.test(n[n.length-2]??""))r=void 0;if(o==="o"&&/[\w$]/.test(i[1]??""))o=void 0;if(!r&&!o)return null;const s=eY(n.slice(0,n.length-(r?.length??0)),i.slice(o?.length??0));if(!s)return null;const a=e[t]===".";const l=r?kL(r,a):void 0;const c=o?kL(o,a):void 0;const d=l??c;const u=l&&c?"both":l?"from":"to";const f=[l,c].some(h=>h==="dependency"||h==="realization");return{...s,type:d,markerAt:u,...u==="both"?{fromType:l,toType:c}:{},...a&&!f?{lineStyle:"dashed"}:{}}}function LL(e,t,n){const i=t===void 0?void 0:Ba(t);const r=n===void 0?void 0:Ba(n);return{...e?Ba(e):{},...i?{fromCardinality:i.label,...i.labelContent?{fromCardinalityContent:i.labelContent}:{}}:{},...r?{toCardinality:r.label,...r.labelContent?{toCardinalityContent:r.labelContent}:{}}:{}}}function eY(e,t){if(FL(e,t))return null;let n=e.trim();let i=t.trim();let r;if(n.endsWith('"')){const f=n.lastIndexOf('"',n.length-2);if(f>=0){r=n.slice(f+1,-1);n=n.slice(0,f).trimEnd()}}let o;let s=false;let a=false;let l=false;for(let f=0;f<i.length;f++){const h=i[f];if(s){if(h==="`")s=false;continue}if(a){if(h==='"')a=false;continue}if(l){if(h==="~")l=false;continue}if(h==="`"){s=true;continue}if(h==='"'){a=true;continue}if(h==="~"){l=true;continue}if(h===":"){const m=i.slice(f+1).trim();if(!m||/[:;]/.test(m.replace(/(?<!&)#\w+;/g,"")))return null;o=m;i=i.slice(0,f).trimEnd();break}}let c;if(i.startsWith('"')){const f=i.indexOf('"',1);if(f<0)return null;c=i.slice(1,f);i=i.slice(f+1).trimStart()}const d=so(n);const u=so(i);if(!d||!u||!ug(d.id,n)||!ug(u.id,i))return null;return{from:d.id,to:u.id,...LL(o,r,c),...d.generic?{fromGeneric:d.generic}:{},...u.generic?{toGeneric:u.generic}:{}}}function tY(e){const t=If(e);if(t<0||FL(e.slice(0,t),e.slice(t+2)))return null;const n=e.slice(0,t).trim();let i=e.slice(t+2).trim();let r=so(n);let o;if(!r&&n.endsWith('"')){const f=n.lastIndexOf('"',n.length-2);if(f>=0){r=so(n.slice(0,f).trimEnd());if(r)o=n.slice(f+1,-1)}}if(!r)return null;let s=false;let a=false;let l=false;let c;for(let f=0;f<i.length;f++){const h=i[f];if(s){if(h==="`")s=false;continue}if(a){if(h==='"')a=false;continue}if(l){if(h==="~")l=false;continue}if(h==="`"){s=true;continue}if(h==='"'){a=true;continue}if(h==="~"){l=true;continue}if(h===":"){const m=i.slice(f+1).trim();if(!m||/[:;]/.test(m.replace(/(?<!&)#\w+;/g,"")))return null;c=m;i=i.slice(0,f).trim();break}}let d;if(i.startsWith('"')){const f=i.indexOf('"',1);if(f<0)return null;d=i.slice(1,f);i=i.slice(f+1).trim()}const u=so(i);if(!u)return null;if(!ug(r.id,n)||!ug(u.id,i))return null;return{from:r.id,to:u.id,type:e[t]==="."?"link-dashed":"link-solid",markerAt:"none",...LL(c,o,d),...r.generic?{fromGeneric:r.generic}:{},...u.generic?{toGeneric:u.generic}:{}}}var AL=new Set(["note","click","link","cssClass","href","callback"]);var IL=new Set([...AL,"o","_self","_blank","_parent","_top"]);var nY=new Set([...IL,"class","classDiagram","namespace","style","classDef"]);function dg(e,t,n){return!(t?AL:n?nY:IL).has(e)}function FL(e,t){return/^\s*call\s/.test(e)||/^\s*(?:"[^"]*"\s*)?call(?:\s|$)/.test(t)}function ug(e,t){return t.startsWith("`")?dg(e,true,true)&&!e.includes("~"):!e.includes("$")&&dg(e,false,true)}function If(e){let t=false;let n=false;let i=false;for(let r=0;r<e.length-1;r++){const o=e[r];if(t){if(o==="`")t=false;continue}if(n){if(o==='"')n=false;continue}if(i){if(o==="~")i=false;continue}if(o==="`"){t=true;continue}if(o==='"'){n=true;continue}if(o==="~"){i=true;continue}if((o==="-"||o===".")&&e[r+1]===o)return r}return-1}function e0(e,t){const n=e.slice(0,t).trimEnd();const i=e.slice(t+2);if(e[t]==="."){return/(?:<\||<)$/.test(n)||/^(?:>|\|>)/.test(i)}const r=n.endsWith("o")&&/\s/.test(n[n.length-2]??"")&&n.slice(0,-2).trim().length>0;return/(?:<\||<|\*|\(\))$/.test(n)||r||/^(?:>|\|>|\*|o\s+(?![:%])\S|\(\))/.test(i)}function iY(e){const t=If(e);return t>=0&&!e0(e,t)}function rY(e){const t=If(e);return t>=0&&e0(e,t)}function oY(e){if(!e.includes("`"))return false;const t=If(e);if(t<0)return false;const n=e.slice(0,t).trimEnd();const i=e.slice(t+2);const r=e[t]==="."&&/(?:\*|o)$/.test(n)&&/^(?:\*|o|>|\|>|<)/.test(i);if(!e0(e,t)&&!r)return false;if(e.slice(0,t).trimStart().startsWith("`"))return true;let o=e.slice(t+2).trimStart();o=o.replace(/^(?:\|>|[>*o]|\(\))\s*/,"");o=o.replace(/^"[^"]*"\s*/,"");return o.startsWith("`")}function kL(e,t){if(e==="()")return"lollipop";if(e==="*")return"composition";if(e==="o")return"aggregation";if(e.includes("|"))return t?"realization":"inheritance";return t?"dependency":"association"}function Jl(e){return e.lineStyle??([e.type,e.fromType,e.toType].some(t=>t==="dependency"||t==="realization"||t==="link-dashed")?"dashed":"solid")}var sY=["stroke","stroke-width","opacity","stroke-dasharray"];var aY=/^[#\w][\w#(),.%\s/-]*$/;function mg(e){const t=[];const n=[];const i=vn(e,{caseInsensitive:true});Lt(i.stroke===void 0?{}:{stroke:i.stroke},"todayMarker");for(const[r,o]of Object.entries(i)){if(!sY.includes(r)||r!=="stroke"&&!aY.test(o)){n.push(r);continue}t.push([r,o])}return{applied:t,ignored:n}}var Ni=class extends Error{code;line;constructor(t,n,i){super(`${t}: ${n}`);this.name="GanttError";this.code=t;this.line=i}};var NL=/^(?:(?:gantt|inclusiveEndDates|topAxis|dateFormat|axisFormat|tickInterval|includes|excludes|todayMarker|weekday|weekend|click|accTitle|accDescr)\b|\d{4}-\d{2}-\d{2}\b|(?:title|section|call|accDescription)\s|href\s+")/i;var jae=/^(?:call|title|section|accDescription)$/i;function Yae(e){return NL.test(e)||e.includes("%%{")}function $L(e){return nn(e,{subject:"Gantt task text entity",example:"Task #35;1 : 1d"})}function qae(e){let t=dn(e,"#&:%");if(NL.test(t))t=`#${t.codePointAt(0)};${t.slice(1)}`;return t}var lY=["active","done","crit","milestone","vert"];var OL=["sunday","monday","tuesday","wednesday","thursday","friday","saturday"];var i0=/^(\d+(?:\.\d+)?)(ms|s|m|h|d|w|M|y)$/;var t0=/^([1-9][0-9]*)(millisecond|second|minute|hour|day|week|month)$/;function cY(e){const t=e.split(",").map(l=>l.trim());if(t.some(l=>l.length===0))return null;const n=[];let i=0;while(i<t.length&&lY.includes(t[i])){const l=t[i];if(n.includes(l))return null;n.push(l);i++}const r=t.slice(i);if(r.length===0||r.length>3)return null;const o=l=>{const c=l.match(/^after\s+(.+)$/);if(c)return{kind:"after",refs:c[1].split(/\s+/).filter(Boolean)};return{kind:"date",raw:l}};const s=l=>{const c=l.match(/^until\s+(.+)$/);if(c)return{kind:"until",refs:c[1].split(/\s+/).filter(Boolean)};if(i0.test(l))return{kind:"duration",raw:l};return{kind:"date",raw:l}};if(r.length===1)return{tags:n,end:s(r[0])};if(r.length===2)return{tags:n,start:o(r[0]),end:s(r[1])};const a=r[0];if(!/^[\w-]+$/.test(a))return null;return{tags:n,id:a,start:o(r[1]),end:s(r[2])}}function tle(e){const t=[...e.tags];if(e.id!==void 0)t.push(e.id);if(e.start)t.push(e.start.kind==="after"?`after ${e.start.refs.join(" ")}`:e.start.raw);t.push(e.end.kind==="until"?`until ${e.end.refs.join(" ")}`:e.end.raw);return t.join(", ")}function _L(e){return e.split(/[,\s]+/).filter(Boolean).map(t=>{const n=t.toLowerCase();if(n==="weekends")return{kind:"weekends"};if(OL.includes(n))return{kind:"weekday",day:n};return{kind:"date",raw:t}})}var dY={title:/^title\s+(.+)$/i,dateFormat:/^dateFormat\s+(.+)$/i,axisFormat:/^axisFormat\s+(.+)$/i,tickInterval:/^tickInterval\s+(.+)$/i,excludes:/^excludes\s+(.+)$/i,includes:/^includes\s+(.+)$/i,todayMarker:/^todayMarker\s+(.+)$/i,weekday:/^weekday\s+(.+)$/i,weekend:/^weekend\s+(.+)$/i,section:/^section\s+(.+)$/i,click:/^click\s+([\w-]+)\s+(href|call)\s+(.+)$/i};var uY=/^(?:dateFormat|axisFormat|tickInterval|excludes|includes)\s/i;var fY=/^(?:title|section|click|todayMarker|weekday|weekend|acc(?:Title|Descr))\b/i;function DL(e){if(uY.test(e))return e.indexOf(";");const t=e.indexOf(":");if(fY.test(e)||t<=0)return-1;const n=e.indexOf(";",t+1);const i=Xr(e.slice(t+1));return i>=0&&n>t+i?-1:n}var hY=/^click\s+[\w-]+$/i;var mY=/^(?:href|call)\s/i;function pY(e,t){if(!hY.test(e[t].trim()))return-1;let n=t+1;while(n<e.length&&(!e[n].trim()||e[n].trim().startsWith("%%")))n++;return n<e.length&&mY.test(e[n].trim())?n:-1}function n0(e){const t=[];for(let n=0;n<e.length;n++){const i=n;const r=e[n];let o=r.trim();const s=(f,h=e.slice(i,n+1))=>{const m=f.kind==="section"||f.kind==="title"?r.indexOf(f.value,r.search(/\S/)+f.kind.length)+1:f.kind==="task"?r.search(/\S/)+1:void 0;t.push({...f,raw:h,startLine:i+1,endLine:n+1,valueColumn:m})};if(!o||o.startsWith("%%")){s({kind:o?"comment":"blank"});continue}const a=Tt(e,n);if(a===void 0){const f=e.slice(n);n=e.length-1;s({kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:"Unclosed accDescr block",structural:true},f);break}if(a!==null){n=a.endIndex;const f=e.slice(i,n+1);if(a.suffixLine)f[f.length-1]=f.at(-1).slice(0,f.at(-1).indexOf("}")+1);s({kind:"accessibility",directive:a},f);if(a.suffixLine){const h=e[n];const m=h.indexOf("}")+1;const p=n0([h.slice(m)]);t.push(...p.map(g=>({...g,startLine:n+1,endLine:n+1,valueColumn:g.valueColumn===void 0?void 0:g.valueColumn+m})))}continue}if(DL(o)>=0){let f=r;let h=0;for(let m=0;;m++){const p=DL(f.trim());const g=p<0?f.length:f.length-f.trimStart().length+p;t.push(...n0([f.slice(0,g)]).map((y,b)=>({...y,startLine:n+1,endLine:n+1,valueColumn:y.valueColumn===void 0?void 0:y.valueColumn+h,...m>0&&b===0?{afterSemicolon:true}:{}})));if(p<0)break;h+=g+1;f=f.slice(g+1)}continue}const l=pY(e,n);if(l>n){n=l;o=`${o}
|
|
23
|
-
${e[n].trim()}`}let c=false;for(const[f,h]of Object.entries(dY)){const m=f==="weekday"||f==="weekend"?Gt(o):o;const p=m.match(h);if(!p)continue;c=true;const g=p[1].trim();if(f==="title"||f==="section")s({kind:f,value:g});else if(f==="click")s({kind:"click",taskId:g,action:p[2].toLowerCase(),rest:p[3].trim()});else if(f==="weekday"&&!OL.includes(g.toLowerCase())){s({kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:`Invalid weekday "${g}"`})}else if(f==="weekend"&&!["friday","saturday"].includes(g.toLowerCase())){s({kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:`Invalid weekend "${g}" (friday or saturday)`})}else s({kind:"directive",name:f,value:g});break}if(c)continue;const d=Gt(o);if(/^(inclusiveEndDates|topAxis)\s*$/i.test(d)){s({kind:"directive",name:/^topAxis/i.test(d)?"topAxis":"inclusiveEndDates",value:""});continue}const u=o.indexOf(":");if(!/^(dateFormat|axisFormat|tickInterval|inclusiveEndDates|topAxis|excludes|includes|todayMarker|weekday|weekend|click)\b/i.test(o)&&u>0&&u<o.length-1){const f=o.slice(0,u).trim();const h=r.indexOf(":");const m=Xr(r.slice(h+1));const p=m<0?-1:h+1+m;const g=Gt(o.slice(u+1)).trim();const y=cY(g);if(y){s({kind:"task",label:$L(f),labelSource:f,meta:y},[p<0?r:r.slice(0,p)]);if(p>=0)s({kind:"comment"},[r.slice(p)])}else s({kind:"invalid",code:"GANTT_BAD_TASK",message:`Invalid task metadata "${g}"`})}else s({kind:"invalid",code:"GANTT_BAD_DIRECTIVE",message:`Unrecognized gantt line "${o}"`})}return t}function BL(e){const t=Gt((e[0]??"").trim());if(!/^gantt\s*$/i.test(t)){throw new Ni("GANTT_BAD_DIRECTIVE",`Expected "gantt" header, got "${t}"`,1)}if(ie("gantt"))Ge("gantt","header",e[0]??"",{line:1,unit:"normalized"});const n={dateFormat:"YYYY-MM-DD",inclusiveEndDates:false,topAxis:false,excludes:[],includes:[],weekendStart:"saturday",weekStart:"sunday",sections:[{taskIndexes:[]}],tasks:[],clicks:[]};if(ie("gantt"))ue("gantt","initialize",n);const i=new Set;let r=0;for(const o of n0(e.slice(1))){const s=o.startLine+1;if(ie("gantt"))Ge("gantt",o.kind==="directive"?o.name:o.kind,o.raw.join("\n"),{line:s,unit:"normalized"});if(o.kind==="invalid")throw new Ni(o.code,o.message,s);if(o.kind==="accessibility"){if(o.directive.title)n.accTitle=o.directive.value;else n.accDescr=o.directive.value.replace(/\s*\n\s*/g," ");if(ie("gantt"))ue("gantt",o.directive.title?"setAccessibilityTitle":"setAccessibilityDescription",o.directive.title?n.accTitle:n.accDescr,{line:s,unit:"normalized"})}else if(o.kind==="title"){n.title=o.value;if(ie("gantt"))ue("gantt","setTitle",n.title,{line:s,unit:"normalized"})}else if(o.kind==="directive"){const a=o.value;switch(o.name){case"dateFormat":n.dateFormat=a;break;case"axisFormat":n.axisFormat=a;break;case"tickInterval":{const l=a.match(t0);if(l)n.tickInterval={count:Number(l[1]),unit:l[2]};break}case"inclusiveEndDates":n.inclusiveEndDates=true;break;case"topAxis":n.topAxis=true;break;case"excludes":{const l=_L(a);n.excludes.push(...l);if(ie("gantt"))ue("gantt","appendExcludes",l,{line:s,unit:"normalized"});break}case"includes":{const l=_L(a);n.includes.push(...l);if(ie("gantt"))ue("gantt","appendIncludes",l,{line:s,unit:"normalized"});break}case"todayMarker":n.todayMarker=a.toLowerCase()==="off"?{off:true}:{off:false,style:a};break;case"weekday":n.weekStart=a.toLowerCase();break;case"weekend":n.weekendStart=a.toLowerCase();break}if(ie("gantt")){const l=o.name==="weekday"?"weekStart":o.name==="weekend"?"weekendStart":o.name;if(o.name!=="excludes"&&o.name!=="includes"&&(o.name!=="tickInterval"||t0.test(a)))ue("gantt",`set:${l}`,n[l],{line:s,unit:"normalized"})}}else if(o.kind==="click"){n.clicks.push({taskId:o.taskId,action:o.action,rest:o.rest,line:s});if(ie("gantt"))ue("gantt","addClick",n.clicks.at(-1),{line:s,unit:"normalized"})}else if(o.kind==="section"){n.sections.push({label:o.value,taskIndexes:[],line:s});r=n.sections.length-1;if(ie("gantt"))ue("gantt","addSection",{index:r,...n.sections[r]},{line:s,unit:"normalized"})}else if(o.kind==="task"){const{label:a,meta:l}=o;if(l.id!==void 0){if(i.has(l.id))throw new Ni("GANTT_DUPLICATE_TASK_ID",`Duplicate task id "${l.id}"`,s);i.add(l.id)}const c={index:n.tasks.length,id:l.id,label:a,tags:l.tags,start:l.start,end:l.end,sectionIndex:r,line:s};n.tasks.push(c);if(ie("gantt"))ue("gantt","addTask",c,{line:s,unit:"normalized"});n.sections[r].taskIndexes.push(c.index);if(ie("gantt"))ue("gantt","attachTask",{sectionIndex:r,taskIndex:c.index,taskId:c.id},{line:s,unit:"normalized"})}}if(n.todayMarker?.style!==void 0)mg(n.todayMarker.style);return n}function nle(e,t){return r0(e,Ff(t))}function Ff(e){if(!e)return{};const t={};const n=kt(e,["title"]);if(typeof n==="string"&&n.trim()!=="")t.title=n;const i=kt(e,["displayMode"]);const r=Sn(e,["gantt"]);const o=r?kt(e,["gantt","displayMode"]):void 0;const s=o??i;if(typeof s==="string"&&s.toLowerCase()==="compact")t.displayMode="compact";const a=kt(e,["gantt","barHeight"]);if(typeof a==="number"&&Number.isFinite(a)&&a>0)t.barHeight=a;const l=kt(e,["gantt","topAxis"]);if(l===true)t.topAxis=true;const c=kt(e,["gantt","axisFormat"]);if(typeof c==="string")t.axisFormat=c;const d=kt(e,["gantt","tickInterval"]);if(typeof d==="string"){const u=d.match(t0);if(u)t.tickInterval={count:Number(u[1]),unit:u[2]}}return t}function r0(e,t){if(t.title!==void 0&&e.title===void 0)e.title=t.title;if(t.displayMode)e.displayMode=t.displayMode;if(t.barHeight!==void 0)e.barHeight=t.barHeight;if(t.topAxis)e.topAxis=true;if(t.axisFormat!==void 0&&e.axisFormat===void 0)e.axisFormat=t.axisFormat;if(t.tickInterval!==void 0&&e.tickInterval===void 0)e.tickInterval=t.tickInterval;return e}import{decodeXML as gY}from"entities";var yY=/&((?:amp;)*(?:#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});)|&(?:#\d+|#[xX][0-9a-fA-F]+|[a-zA-Z][a-zA-Z\d]{0,31});/g;function Nf(e){return e.replace(yY,(t,n)=>{const i=n===void 0?gY(t):`&${n}`;return dn(i,i)})}var HL=1;var jL=5;var a0=256;var xY=/^title\s+(.+)$/i;var bY=/^section\s+(.+)$/i;var SY=/^([^:]+):\s*([+-]?(?:[0-9]+(?:\.[0-9]*)?|\.[0-9]+)(?:[eE][+-]?[0-9]+)?)\s*(?::\s*(.*))?$/;var wY=/^([^:]+):\s*([^:]+)(?::\s*(.*))?$/;function MY(e){return e.replace(/<br\s*\/?>/gi,"\n").replace(/\\n/g,"\n").replace(/<\/?(?:sub|sup|small|mark)\s*>/gi,"").replace(/\*\*(.+?)\*\*/g,"<b>$1</b>").replace(/(?<!\*)\*([^\s*](?:[^*]*[^\s*])?)\*(?!\*)/g,"<i>$1</i>").replace(/~~(.+?)~~/g,"<s>$1</s>")}function bg(e){return MY(e).split(/\r?\n/).map(t=>t.trim()).join("\n")}function kY(e){return bg(e).split("\n").filter(Boolean).join(" / ")}function xg(e){return no(bg(e))}function pg(e,t=false){const n=t?kY(e):bg(e);const i=no(n);if(i===n)return{value:i};const r=cr(vt(n),Pl,o=>no(o));return JSON.stringify(o0(r))===JSON.stringify(o0(vt(i)))?{value:i}:{value:i,content:{value:i,prepared:r}}}function o0(e){return e.lines.map(t=>t.map(({text:n,bold:i,italic:r,underline:o,strikethrough:s})=>({text:n,bold:i,italic:r,underline:o,strikethrough:s})))}function Wa(e,t){return JSON.stringify([e,t?.value===e?o0(t.prepared):null])}function gg(e){return Dn(e)}function s0(e){return e.startsWith("%%")||e.startsWith("#")||e.startsWith("%")}function CY(e){return Number.isFinite(e)&&e>=HL&&e<=jL}function YL(e,t,n){for(let i=t;i<e.length;i++){const r=e[i].trim();if(s0(r)&&!/^#\w+;/.test(r))continue;const o=gg(Nf(e[i].trim()));if(!o)continue;if(s0(o))continue;const s=Tt(e,i);if(s===void 0){const a=n.issue?.({code:"unclosed_accdescr",lineIndex:i,statement:o,detail:'Journey accDescr block is missing a closing "}"'});if(a==="stop")return;return}if(s?.form==="block"){n.accDescr?.(xg(gg(Nf(s.value))),i);i=s.endIndex;const a=gg(Nf(s.suffixLine??""));const l=Tt([a],0);if(l?.form==="inline"){const c=xg(l.value);if(l.title)n.accTitle?.(c,i);else n.accDescr?.(c,i);continue}if(GL(a))n.statementDelimiter?.(i);if(n.entitySemicolon)yg(s.suffixLine??"",()=>n.entitySemicolon(i));for(const c of yg(a)){const d=WL(c,s.endIndex,n);if(d==="stop")return}continue}if(s?.form==="inline"){const a=xg(gg(Nf(s.value)));if(s.title)n.accTitle?.(a,i);else n.accDescr?.(a,i);continue}if(GL(o))n.statementDelimiter?.(i);if(n.entitySemicolon)yg(e[i].trim(),()=>n.entitySemicolon(i));for(const a of yg(o)){const l=WL(a,i,n);if(l==="stop")return}}}function WL(e,t,n){const i=(c,d)=>n.issue?.({code:c,lineIndex:t,statement:e,detail:d});const r=Tt([e],0);if(r){const c=xg(r.value);if(r.title)n.accTitle?.(c,t);else n.accDescr?.(c,t);return}const o=e.match(xY);if(o){const c=pg(o[1]);if(!c.value)return i("empty_title",`Journey title is empty: "${e}"`);n.title?.(c.value,t,c.content);return}const s=e.match(bY);if(s){const c=pg(s[1]);if(!c.value){return i("section_colon",`Journey section labels must not contain ':': "${e}"`)}n.section?.(c.value,t,c.content);return}const a=e.match(SY);if(a){const c=pg(a[1]);if(!c.value)return i("empty_task_text",`Journey task text is empty: "${e}"`);const d=a[2];const u=Number(d);if(!CY(u))return i("invalid_score",zL(c.value,d));const f=(a[3]??"").split(",").map(h=>pg(h,true)).filter(h=>h.value);n.task?.(c.value,u,f.map(h=>h.value),t,c.content,f.some(h=>h.content)?f.map(h=>h.content):void 0);return}const l=e.match(wY);if(l){const c=bg(l[1]);const d=l[2].trim();if(c&&d)return i("invalid_score",zL(c,d))}return i("unrecognized_line",`Invalid user journey line: "${e}". Expected title, section, accessibility metadata, or "Task name: 3: Actor"`)}function zL(e,t){return`Journey task "${e}" has invalid score ${t}. Expected a finite number from ${HL} through ${jL}`}var PY=/^&(?:[a-zA-Z][a-zA-Z0-9]{1,31}|#[0-9]{1,7}|#x[0-9a-fA-F]{1,6});$/;var EY=34;function qL(e,t,n,i=0){return t>=i&&n-t+1<=EY&&PY.test(e.slice(t,n+1))}function GL(e){let t=-1;for(let n=0;n<e.length;n++){if(e[n]==="&")t=n;if(e[n]!==";")continue;if(qL(e,t,n))continue;return true}return false}function yg(e,t){if(!e.trim())return[];if(!e.includes(";"))return[e.trim()];const n=[];let i=0;let r=-1;for(let o=0;o<e.length;o++){if(e[o]==="&")r=o;if(e[o]!==";")continue;if(qL(e,r,o,i)){t?.();continue}n.push(e.slice(i,o));i=o+1;r=-1}n.push(e.slice(i));return n.map(o=>o.trim()).filter(o=>o&&!s0(o))}import{decodeXML as Sg}from"entities";var wg={wholeLine:e=>/^(?:pie(?:\s+showData)?\s+)?title(?:\s|$)/i.test(e)};function XL(e){if(!e.authoredFamilyLines)return e.familyLines;const t=/^\s*"(?:[^"\\]|\\.)*"/;const n=aa(e.authoredFamilyLines,wg).map((i,r)=>{const o=RY(i,r===0?"header":"body");if(o)return o.decodedPrefix+o.authoredTitle;const s=t.exec(i)?.[0];return s===void 0?Sg(i):s+Sg(i.slice(s.length))}).join("\n");return Hu(n).familyLines}function RY(e,t){const n=Sg(e);const i=t==="header"?n.match(/^(\s*pie\b(?:\s+showData\b)?\s+title)(\s+)(.+)$/i):n.match(/^(\s*title)(\s+)(.+)$/i);if(!i)return null;const r=i[1].length;const o=r+i[2].length;let s=0;let a=0;const l=()=>{let d=e[a];let u=1;if(d==="&"){const f=e.slice(a).match(/^&(?:#(?:x[0-9a-f]+|\d+)|[a-z][a-z0-9]+);/i)?.[0];if(f){const h=Sg(f);if(h!==f){d=h;u=f.length}}}return{text:d,length:u,entity:u>1}};while(s<r&&a<e.length){const d=l();if(n.slice(s,s+d.text.length)!==d.text)return null;s+=d.text.length;a+=d.length}if(s!==r)return null;let c=false;while(s<o&&a<e.length){const d=l();if(d.entity&&c)break;if(!/^\s+$/u.test(d.text))return null;s+=d.text.length;a+=d.length;c=true}if(!c)return null;return{decodedPrefix:n.slice(0,s),authoredTitle:e.slice(a)}}var vY=128;var TY=256;var Mg=class extends Error{code="INVALID_STYLE_COLOR";subject;property;value;constructor(t,n,i){const r=t.slice(0,vY);const o=i.slice(0,TY);super(Je({what:`${r}: ${n} ${JSON.stringify(o)} is not a CSS color`,expectedForm:"a drawable color name, hex color, rgb()/rgba(), hsl()/hsla(), transparent, currentColor, none, or var(--name)",example:`${n}: #f96`}).message);this.name="QuadrantStyleColorError";this.subject=r;this.property=n;this.value=o}};var LY=/^[A-Za-z_][\w-]*$/;var AY=/^\d+(?:\.\d+)?$/;var IY=/^\d+(?:\.\d+)?(?:px)?$/;var FY=/^[#\w][\w#(),.%+\s/~-]*$/;function NY(e){const t=[];let n=0;let i=0;for(let r=0;r<e.length;r++){const o=e[r];if(o==="(")i++;else if(o===")"){i--;if(i<0)return null}else if(o===","&&i===0){t.push(e.slice(n,r));n=r+1}}if(i!==0)return null;t.push(e.slice(n));return t}function l0(e,t="quadrant point style"){const n=e.trim();if(n.length===0)return{ok:true,style:void 0};const i={};let r=false;const o=NY(n);if(!o)return{ok:false,error:"style functions have unbalanced parentheses"};for(const s of o){const a=s.trim();if(!a)continue;const l=a.match(/^([a-z][\w-]*)\s*:\s*(.+)$/i);if(!l)return{ok:false,error:`malformed style entry "${a}" (expected key: value)`};const c=l[1].toLowerCase();const d=l[2].trim();switch(c){case"radius":{if(!AY.test(d))return{ok:false,error:`radius must be a non-negative number, got "${d}"`};i.radius=Number.parseFloat(d);break}case"color":{if(mn(d,true)===void 0)throw new Mg(t,"color",d);i.color=d;break}case"stroke-color":{if(mn(d,true)===void 0)throw new Mg(t,"stroke-color",d);i.strokeColor=d;break}case"stroke-width":{if(!IY.test(d))return{ok:false,error:`stroke-width must be a number with optional px suffix, got "${d}"`};i.strokeWidth=d;break}default:{if(!FY.test(d))return{ok:false,error:`style property "${c}" has unsupported characters: "${d}"`};i.extra=i.extra??[];i.extra.push(`${c}: ${d}`);break}}r=true}return{ok:true,style:r?i:void 0}}function UL(e){const t=e.trim().match(/^([A-Za-z_][\w-]*)\s+(.+)$/);if(!t)return{ok:false,error:`expected "classDef <name> <styles>", got "classDef ${e.trim()}"`};const n=t[1];const i=l0(t[2],`quadrant classDef ${n}`);if(!i.ok)return{ok:false,error:`classDef ${n}: ${i.error}`};if(!i.style)return{ok:false,error:`classDef ${n} has no style entries`};return{ok:true,name:n,style:i.style}}function ble(e){return LY.test(e)}var $Y=/\s*:::\s*([A-Za-z_][\w-]*)\s*$/;function VL(e){const t=e.match($Y);if(!t)return{label:e};return{label:e.slice(0,t.index).trim(),className:t[1]}}function KL(e,t,n){const i=e.className&&t&&Object.hasOwn(t,e.className)?t[e.className]:void 0;const r={radius:e.style?.radius??i?.radius??n.radius};const o=e.style?.color??i?.color;const s=e.style?.strokeColor??i?.strokeColor;const a=e.style?.strokeWidth??i?.strokeWidth;if(o!==void 0)r.fill=o;if(s!==void 0)r.stroke=s;if(a!==void 0)r.strokeWidth=a;return r}function Sle(e){if(!e)return"";const t=[];if(e.radius!==void 0)t.push(`radius: ${e.radius}`);if(e.color!==void 0)t.push(`color: ${e.color}`);if(e.strokeColor!==void 0)t.push(`stroke-color: ${e.strokeColor}`);if(e.strokeWidth!==void 0)t.push(`stroke-width: ${e.strokeWidth}`);if(e.extra!==void 0)t.push(...e.extra);return t.join(", ")}var JL={subject:"Flowchart label entity",example:'A["#35;"]'};var QL=new RegExp(`(${Bx})`,"i");var ZL=/(&#(?:\d+|[xX][0-9a-fA-F]+);)/;function _Y(e){return e.split(QL).map((t,n)=>n%2===1?t:t.split(ZL).map((i,r)=>r%2===1?i:nn(i,JL)).join("")).join("")}function za(e,t=false){const n=t?e:kg(e);const i=t||n!==e;const r=i&&n.length>=2&&n.startsWith("`")&&n.endsWith("`");const o=r?`\`${n.slice(1,-1).trim()}\``:n.trim();const s=r?yt(n.slice(1,-1).trim(),false):O1(o);if(!s.includes("#")&&!s.includes("\uFB02\xB0"))return{text:s,markdown:r};const a=_Y(s);const l=cr(vt(s),/&#(?:\d+|[xX][0-9a-fA-F]+);|#\w+;/g,d=>d.startsWith("&")?d:nn(d,JL));const c=ia(l)===B1(a)?void 0:{value:a,prepared:l,authored:o};return{text:a,markdown:r,...c?{labelContent:c}:{}}}function kg(e){if(e.length<2||!e.startsWith('"'))return e;if(e.endsWith('"'))return e.slice(1,-1);const t=e.indexOf('"',1);return t>0&&!e.startsWith('"`')&&!e.includes('"',t+1)?e.slice(1,t)+e.slice(t+1):e}var e2='"<';function DY(e){return e.replace(/&+(?=#\d+;)/g,t=>"#amp;".repeat(t.length))}function OY(e){return e.split(ZL).map((t,n)=>n%2===1?t:DY(dn(t,e2).replace(/\\(?=n)/g,"#92;"))).join("")}function Rle(e,t){if(t?.value===e&&t.authored!==void 0){const l=new RegExp(`(${Bx}|<br\\s*\\/?>)`,"gi");return t.authored.split(l).map((c,d)=>d%2?c:mr(c,e2)).join("")}const n=e.split(/\r?\n/).map(l=>l.split(QL).map((c,d)=>d%2===1?c:OY(c)).join(""));const i=n.join("<br>");const r=i.length-i.trimStart().length;const o=i.trim()===""?0:i.length-i.trimEnd().length;if(r===0&&o===0)return i;const s=l=>[...l].map(c=>`#${c.codePointAt(0)};`).join("");const a=i.slice(r,i.length-o);return s(i.slice(0,r))+(o>0?a.replace(/&+$/,l=>"#amp;".repeat(l.length)):a)+s(i.slice(i.length-o))}var t2={"rect":{aliases:["proc","process","rectangle"],geometry:"rectangle",exact:true,description:"Process"},"rounded":{aliases:["event"],geometry:"rounded",exact:true,description:"Event"},"stadium":{aliases:["pill","terminal"],geometry:"stadium",exact:true,description:"Terminal point"},"cyl":{aliases:["cylinder","database","db"],geometry:"cylinder",exact:true,description:"Database"},"diam":{aliases:["decision","diamond","question"],geometry:"diamond",exact:true,description:"Decision"},"hex":{aliases:["hexagon","prepare"],geometry:"hexagon",exact:true,description:"Prepare conditional"},"lean-r":{aliases:["in-out","lean-right"],geometry:"lean-r",exact:true,description:"Data input/output"},"lean-l":{aliases:["lean-left","out-in"],geometry:"lean-l",exact:true,description:"Data output/input"},"trap-b":{aliases:["priority","trapezoid","trapezoid-bottom"],geometry:"trapezoid",exact:true,description:"Priority action"},"trap-t":{aliases:["inv-trapezoid","manual","trapezoid-top"],geometry:"trapezoid-alt",exact:true,description:"Manual operation"},"circle":{aliases:["circ"],geometry:"circle",exact:true,description:"Start"},"dbl-circ":{aliases:["double-circle"],geometry:"doublecircle",exact:true,description:"Stop"},"fr-rect":{aliases:["framed-rectangle","subproc","subprocess","subroutine"],geometry:"subroutine",exact:true,description:"Subprocess"},"odd":{aliases:[],geometry:"asymmetric",exact:true,description:"Odd"},"bang":{aliases:[],geometry:"circle",exact:true,description:"Bang"},"notch-rect":{aliases:["card","notched-rectangle"],geometry:"rectangle",exact:true,description:"Card"},"cloud":{aliases:[],geometry:"rounded",exact:true,description:"Cloud"},"hourglass":{aliases:["collate"],geometry:"diamond",exact:true,description:"Collate"},"bolt":{aliases:["com-link","lightning-bolt"],geometry:"rectangle",exact:true,description:"Com link"},"brace":{aliases:["brace-l","comment"],geometry:"rectangle",exact:true,description:"Comment"},"brace-r":{aliases:[],geometry:"rectangle",exact:true,description:"Comment right"},"braces":{aliases:[],geometry:"rectangle",exact:true,description:"Comment both"},"datastore":{aliases:["data-store"],geometry:"cylinder",exact:true,description:"Data store"},"delay":{aliases:["half-rounded-rectangle"],geometry:"rounded",exact:true,description:"Delay"},"h-cyl":{aliases:["das","horizontal-cylinder"],geometry:"cylinder",exact:true,description:"Direct access storage"},"lin-cyl":{aliases:["disk","lined-cylinder"],geometry:"cylinder",exact:true,description:"Disk storage"},"curv-trap":{aliases:["curved-trapezoid","display"],geometry:"rounded",exact:true,description:"Display"},"div-rect":{aliases:["div-proc","divided-process","divided-rectangle"],geometry:"rectangle",exact:true,description:"Divided process"},"doc":{aliases:["document"],geometry:"rectangle",exact:true,description:"Document"},"tri":{aliases:["extract","triangle"],geometry:"trapezoid",exact:true,description:"Extract"},"fork":{aliases:["join"],geometry:"rectangle",exact:true,description:"Fork/join"},"win-pane":{aliases:["internal-storage","window-pane"],geometry:"rectangle",exact:true,description:"Internal storage"},"f-circ":{aliases:["filled-circle","junction"],geometry:"circle",exact:true,description:"Junction"},"lin-doc":{aliases:["lined-document"],geometry:"rectangle",exact:true,description:"Lined document"},"lin-rect":{aliases:["lin-proc","lined-process","lined-rectangle","shaded-process"],geometry:"subroutine",exact:true,description:"Lined/shaded process"},"notch-pent":{aliases:["loop-limit","notched-pentagon"],geometry:"hexagon",exact:true,description:"Loop limit"},"flip-tri":{aliases:["flipped-triangle","manual-file"],geometry:"trapezoid-alt",exact:true,description:"Manual file"},"sl-rect":{aliases:["manual-input","sloped-rectangle"],geometry:"lean-r",exact:true,description:"Manual input"},"docs":{aliases:["documents","st-doc","stacked-document"],geometry:"rectangle",exact:true,description:"Multi-document"},"st-rect":{aliases:["processes","procs","stacked-rectangle"],geometry:"rectangle",exact:true,description:"Multi-process"},"flag":{aliases:["paper-tape"],geometry:"rectangle",exact:true,description:"Paper tape"},"sm-circ":{aliases:["small-circle","start"],geometry:"circle",exact:true,description:"Start (small)"},"fr-circ":{aliases:["framed-circle","stop"],geometry:"doublecircle",exact:true,description:"Stop (framed)"},"bow-rect":{aliases:["bow-tie-rectangle","stored-data"],geometry:"cylinder",exact:true,description:"Stored data"},"cross-circ":{aliases:["crossed-circle","summary"],geometry:"circle",exact:true,description:"Summary"},"tag-doc":{aliases:["tagged-document"],geometry:"rectangle",exact:true,description:"Tagged document"},"tag-rect":{aliases:["tag-proc","tagged-process","tagged-rectangle"],geometry:"rectangle",exact:true,description:"Tagged process"},"text":{aliases:[],geometry:"rectangle",exact:true,description:"Text block"}};var n2=(()=>{const e=new Map;for(const[t,n]of Object.entries(t2)){e.set(t,t);for(const i of n.aliases)e.set(i,t)}return e})();function i2(e){const t=n2.get(e.trim().toLowerCase());if(!t)return null;const n=t2[t];return{canonical:t,geometry:n.geometry,exact:n.exact,description:n.description}}function Tle(){return[...n2.keys()].sort()}var r2={subject:"State text entity",example:"A : I #9829; states"};var BY=/#\w+;/g;var WY=e=>nn(e,r2);function Cg(e){return s2(yt(e),e)}function o2(e){const t=e.map(n=>n.startsWith('"')&&n.endsWith('"')?n.slice(1,-1):n);return s2(e.map(n=>yt(n)).join("\n"),t.join("\n").replace(/\r\n?|\n/g,"<br/>"))}function s2(e,t){const n=nn(e,r2);if(!/#\w+;/.test(t))return{text:n};const i=cr(vt(e),BY,WY);return{text:n,content:Object.freeze({value:n,prepared:i,authored:t})}}function zY(e,t,n=""){const i=t?.value===e?t.authored:void 0;const r=i!==void 0?mr(i,n):dn(e,n).replace(/\\(?=n)/g,"#92;");return r.replace(/%%(?=\{)/g,"#37;%")}function $le(e,t,n){const i=zY(e,t,";").replace(/\r\n?|\n/g,"<br/>").replace(/:(?=:|$)/g,"#58;");return GY(i,n)}function GY(e,t=""){return Un(t+e)===t+e?e:e.replace(/:/g,"#58;")}var Pg=String.raw`[\p{L}\p{N}_-]+`;var Dle=new RegExp(`^${Pg}$`,"u");var HY=new RegExp(`^(${Pg})`,"u");var jY=/^[\w-]+/;function YY(e){const t=e.match(HY);return t?{id:t[1],length:t[1].length}:null}function c0(e){if(!e.startsWith(":::"))return null;const t=e.slice(3).match(jY);return t?{className:t[0],length:3+t[0].length}:null}function Eg(e){const t=YY(e);if(!t)return null;const n=c0(e.slice(t.length));if(!n||t.length+n.length!==e.length)return null;return{id:t.id,className:n.className}}var qY=/^note\s+(left|right)\s+of\s+([\w\p{L}-]+)\s*:\s*(.+)$/iu;var XY=/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}-]+)\s*<<\s*(fork|join|choice|history|deephistory|H\*|H)\s*>>$/iu;var UY=/^-{2,}$/;var d2=/^([\w\p{L}-]*)\[(H\*?)\]$/u;var VY=/^[\w\p{L}-]+$/u;function u2(e){return VY.test(e)}function Rg(e){const t=e.match(/^state\s+([\w\p{L}-]+)$/u);return t?.[1]??(u2(e)?e:null)}function f2(e){if(/^scale\s+\d+\s+width$/i.test(e))return"scale";if(/^hide empty description$/i.test(e))return"hide_empty_description";return null}function h2(e){const t=e.match(/^(?:class|cssClass)\s+(.+?)\s+([\w-]+)$/iu);if(!t)return null;const n=t[1].split(",").map(i=>i.trim());if(n.some(i=>!u2(i)))return null;return{ids:n,className:t[2]}}function KY(e){return Un(e).replace(/#\w+;/g,"#")}function vg(e){const t=e.match(qY);if(!t)return null;return{side:t[1].toLowerCase(),target:t[2],text:t[3].trim()}}function Tg(e){const t=e.match(Um);if(!t)return null;return{side:t[1].toLowerCase(),target:t[2]}}function m2(e){const t=/^note\s+"([^"]*)"\s+as\s+([\w\p{L}-]+)\s*$/iu.exec(e);return t?{id:t[2],text:t[1]}:null}function p2(e){return Ou.test(e)}function Lg(e){const t=e.match(XY);if(!t)return null;const n=t[3].toLowerCase();const i=n==="h"||n==="history"?"history":n==="h*"||n==="deephistory"?"deep-history":n;return{id:t[2],stereotype:i,...t[1]!==void 0?{label:t[1]}:{}}}function Ag(e){return UY.test(e)}function g2(e){const t=e.match(d2);if(!t)return null;return{base:t[1],deep:t[2]==="H*"}}function d0(e){return e?"H*":"H"}var a2=String.raw`\[\*\]|[\w\p{L}-]+\[H\*?\]|\[H\*?\]|[\w\p{L}-]+`;var JY=new RegExp(`^(${a2})(?::::([\\w-]+))?\\s*-->\\s*(${a2})(?::::([\\w-]+))?(?:\\s*:\\s*(.+))?$`,"u");function Ig(e){const t=e.match(JY);if(!t)return null;const n=t[5]?.trim();return{from:t[1],...t[2]?{fromClass:t[2]}:{},to:t[3],...t[4]?{toClass:t[4]}:{},...n?{label:n}:{}}}function y2(e){return d2.test(e)}function zle(e){return e==="deep-history"?"<<deephistory>>":`<<${e}>>`}var x2=/^direction\s+(TD|TB|LR|BT|RL)\s*$/i;var Fg=/^state\s+"([^"]+)"\s+as\s+([\w\p{L}-]+)\s*$/u;var $f=/^state\s+(?:"([^"]+)"\s+as\s+)?([\w\p{L}-]+)\s*\{$/u;var Ng=/^([\w\p{L}-]+)\s*:\s*(.+)$/u;var b2=/^classDef\s+([\w,-]+)\s+(.+)$/i;var S2=/^style\s+([\w\p{L},-]+)\s+(.+)$/iu;var w2=/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/;var QY=/\[\*\]|\[H\*?\]|[\w\p{L}](?:[\w\p{L}]|-(?!->))*(?:\[H\*?\])?/uy;var ZY=/(?:\w|-(?!->))+/y;var eq=/(?:(?:classDef|class|style|note|scale|click|direction)(?=[ \t]|$)|end(?=[ \t]+note(?:[ \t]|$))|hide(?=[ \t]+empty[ \t]+description(?:[ \t]|$)))/iy;var tq=/(?:cssClass|linkStyle)(?=[ \t]|$)/y;var nq=/state[ \t]+/iy;var iq=/[\w\p{L}-]+/uy;var rq=/[ \t]+as[ \t]+/iy;var oq=/[ \t]+as(?=[ \t]|$)/iy;var l2=/[ \t]*(?:<<[^>\n]*>>|\[\[(fork|join|choice)\]\])/iy;var sq=/[ \t]*\{/y;var c2=/:::[ \t]*([\w-]+)/y;var aq=/-{2,}(?=[ \t;}]|$)/y;function Qo(e,t,n){e.lastIndex=n;return e.exec(t)?.[0]??null}function Ys(e,t){while(e[t]===" "||e[t]===" ")t++;return t}function lq(e,t){return t>=e.length||" ;}:".includes(e[t])||e.startsWith("-->",t)}function M2(e,t){let n=t;while(e[n].openQuote&&n+1<e.length)n++;return n}function k2(e){const t=pa(e);return t.map((n,i)=>{if(!n.noteOpen)return M2(t,i);let r=i;while(r+1<t.length&&t[r+1].noteBody)r++;return Math.min(r+1,t.length-1)})}function C2(e){const t=[];for(let v=0;v<e.length;v++){const L=v;v=M2(e,L);const T=e.slice(L,v+1).map(A=>A.text).join("\n");if(T||e[L].noteBody)t.push({text:T,line:L,noteBody:e[L].noteBody,noteOpen:e[L].noteOpen,commentGlued:e[v].commentGlued})}const n=(v,L)=>{const T=t[v].text;let A=t[v].line;let $=0;for(let _=T.indexOf("\n");_>=0&&_<L;_=T.indexOf("\n",_+1)){A++;$=_+1}return{line:A,column:L-$}};const i=[];const r=new Set;const o=new Set;const s=new Set;const a=new Set;const l=new Set;const c=new Set;const d=new Set;const u=(v,L)=>{if(t[v].text[L]!=="}")return;s.add(t[v].line);d.add(`${v}:${L}`)};let f=t.length-1;while(f>0&&!t[f].noteBody&&t[f].text.startsWith("//"))f--;const h=(v,L,T)=>{let A=v.length;if(T!==f)return A;let $=0;for(let z=L+1;z<A;z++)$+=v[z]==="}"?1:v[z]==="{"?-1:0;const _=Ys(v,L+1);for(let z=0;z<m&&$>0;z++,$--){let F=A-1;while(v[F]===" "||v[F]===" ")F--;if(v[F]!=="}"||F<=_)break;A=F}return A};let m=0;let p=0;let g=0;let y=true;const b=(v,L,T)=>{if(!y)o.add(L);i.push({text:v,line:L});y=T};const S=v=>{const L=t[v+1];return L!==void 0&&!L.noteBody&&!L.noteOpen};const x=v=>{for(;;){const L=t[v.row].text;v.column=Ys(L,v.column);if(v.column<L.length||m===0||!S(v.row))return;v.row++;v.column=0}};const k=(v,L)=>{const T=Qo(QY,t[v.row].text,v.column);if(T===null)return null;let A=T;const $={row:v.row,column:v.column+T.length};const _=t[v.row].text.slice($.column,$.column+1);L.push(/^[ \t\n]/.test(_)||_===""&&!t[v.row].commentGlued);const z={...$};x(z);if(t[z.row].text.startsWith(":::",z.column)){z.column+=3;x(z);const F=Qo(ZY,t[z.row].text,z.column);if(F===null)return null;A+=`:::${F}`;$.row=z.row;$.column=z.column+F.length}if(!lq(t[$.row].text,$.column))return null;u($.row,$.column);v.row=$.row;v.column=$.column;return A};const w=()=>{const v={row:p,column:g};const L=[];const T=k(v,L);if(T===null)return null;let A=T;const $={...v};x($);const _=t[$.row].text.startsWith("-->",$.column);let z;if(_){$.column+=3;x($);z=n($.row,$.column).line;const D=k($,L);if(D===null)return null;A+=` --> ${D}`;v.row=$.row;v.column=$.column}const F=t[v.row].text;const G=Ys(F,v.column);const I={text:A,...z!==void 0?{toLine:z,nameBlanks:L}:{}};if(F[G]===":"){const D=h(F,G,v.row);if(D<F.length&&!/;|::/.test(KY(F.slice(G+1,D))))l.add(t[v.row].line);const B=F.slice(G,D).trimEnd();const Y={start:n(v.row,G),end:n(v.row,D)};const W=_?-1:T.indexOf(":::");if(W<0)Object.assign(I,{text:`${A} ${B}`,textSpan:Y});else Object.assign(I,{also:`${T.slice(0,W)} ${B}`,alsoSpan:Y});v.column=D}p=v.row;g=v.column;return I};const C=(v,L,T,A)=>{const $=t[p].line;const _=`state ${L}${T}`;const z=Ys(v,A);c2.lastIndex=z;const F=c2.exec(v);if(F!==null){const B=Ys(v,z+F[0].length);if(B<v.length&&v[B]!==";"&&v[B]!=="}")return null;u(p,B);c.add($);g=z+F[0].length;return{text:_,opens:false,also:`${T}:::${F[1]}`}}if(v.startsWith(":::",z)||v.includes("{",z))return null;const G=h(v,z,p);if(G<v.length)l.add($);const I=v.slice(z+1,G).trim();if(I.includes(":"))c.add($);const D={start:n(p,z),end:n(p,G)};g=G;return{text:_,opens:false,...I?{also:`${T} : ${I}`,alsoSpan:D}:{}}};const R=v=>{const L=t[p].text;let T=v;let A="";let $;if(L[T]==='"'){const B=L.indexOf('"',T+1);const Y=B<0?null:Qo(rq,L,B+1);if(Y===null)return null;A=`${L.slice(T,B+1)} as `;$={start:n(p,T),end:n(p,B+1)};T=B+1+Y.length}const _=Qo(iq,L,T);if(_===null)return null;T+=_.length;if(!A&&Qo(oq,L,T)!==null)return null;if(A&&L[Ys(L,T)]===":"){const B=C(L,A,_,T);return B&&{...B,textSpan:$}}l2.lastIndex=T;const z=l2.exec(L);if(z!==null)T+=z[0].length;const F=z===null?null:z[1]!==void 0?`<<${z[1]}>>`:z[0];const G=Qo(sq,L,T);let I=G!==null;const D=Ys(L,T);if(G!==null)T+=G.length;else if(T<L.length&&!" ;}".includes(L[T]))return null;else if(F===null&&D===L.length&&S(p)&&t[p+1].text.startsWith("{")){p++;T=1;I=true}else if(A&&F===null&&D<L.length){if(L[D]!==";"&&L[D]!=="}")return null;u(p,D)}g=T;return{text:`state ${A}${_}${F===null?"":` ${F.trim()}`}${I?" {":""}`,opens:I,...$?{textSpan:$}:{}}};let M={statements:0,depth:0,column:0};while(p<t.length){const v=t[p];if(g===0){y=true;M={statements:i.length,depth:m,column:0};if(v.noteBody){i.push({text:v.text,line:v.line,noteBody:true});p++;continue}const B=v.noteOpen?v.text.match(Hb):null;if(B){i.push({text:`note ${B[1]} of ${B[2]}`,line:v.line},{text:B[3],line:v.line,noteBody:true});p++;continue}}const L=v.text;g=Ys(L,g);if(g>=L.length){p++;g=0;continue}const T=v.line;const A=L[g];if(A===";"){r.add(T);g++;y=true;continue}if(A==="}"){if(m===0&&!d.has(`${p}:${g}`))a.add(T);i.push({text:"}",line:T});m=Math.max(0,m-1);g++;y=true;continue}const $=m>0?Qo(aq,L,g):null;if($!==null){i.push({text:$,line:T});g+=$.length;y=true;continue}if(Qo(eq,L,g)!==null||Qo(tq,L,g)!==null){const B=L.slice(g);b(B,T,false);p++;g=0;if(Um.test(B)&&t[p]?.noteBody===false){const Y=t.findIndex((W,O)=>O>=p&&Ou.test(W.text));for(;Y>0&&p<Y;p++)i.push({text:t[p].text,line:t[p].line,noteBody:true})}continue}const _=p;const z=g;const F=Qo(nq,L,g);let G=F===null?null:R(g+F.length);const I=F!==null&&!F.startsWith("state");if(I&&G!==null&&!G.opens){const B=Ys(t[p].text,g);if(t[p].text.startsWith("-->",B)||t[p].text[B]===":"){p=_;g=z;G=null}}const D=G??(F===null||I?w():null);if(D!==null){b(D.text,T,D.opens??false);const B=i.at(-1);if(D.textSpan)B.textSpan=D.textSpan;if(D.toLine!==void 0)B.toLine=D.toLine;if(D.nameBlanks)B.nameBlanks=D.nameBlanks;if(D.opens){B.opens=true;m++}if(D.also!==void 0)i.push({text:D.also,line:T,...D.alsoSpan?{textSpan:D.alsoSpan}:{},...G!==null?{afterAlias:true}:{}});if(p!==_)M={statements:i.length,depth:m,column:g};continue}i.length=M.statements;m=M.depth;o.delete(T);r.delete(T);s.delete(T);a.delete(T);l.delete(T);c.delete(T);i.push({text:L.slice(M.column).trim(),line:T});p++;g=0}const P=i.filter((v,L)=>{if(!v.noteBody||v.text)return true;const T=A=>{let $=L;while(i[$]?.noteBody&&!i[$].text)$+=A;return!i[$]?.noteBody};return!T(-1)&&!T(1)});const E=[];for(const v of P){if(v.opens)E.push(v.line);else if(v.text==="}"&&!v.noteBody)E.pop()}return{statements:P,semicolonLines:[...r],juxtaposedLines:[...o],braceNameLines:[...s],unopenedBraceLines:[...a],braceTextLines:[...l],aliasSuffixLines:[...c],unclosedLines:E}}function P2(e){const t=new Set;for(const m of e){const p=m.noteBody?null:m.text.match($f);if(p)t.add(p[2])}const n=new Set(t);const i=new Map;const r=new Map;const o=new Map;const s=[];let a;const l=(m,p)=>{n.add(m);if(p&&!i.has(m)&&!s.some(g=>g.parent===m))i.set(m,p)};for(const m of e){const p=s.at(-1);const g=p?{parent:p.parent,region:p.region}:void 0;r.set(m,g);if(m.noteBody)continue;const y=m.text;const b=y.match($f);if(b){const k=b[2];if(s.some(w=>w.parent===k)){a=`Duplicate State composite identity "${k}" cannot contain itself`;break}l(k,g);if(!i.has(k))i.set(k,g);Ve("nesting",s.length+1);s.push({parent:k,region:o.get(k)??0});continue}if(y==="}"){s.pop();continue}if(Ag(y)&&p){o.set(p.parent,++p.region);continue}const S=Ig(y);if(S){for(const k of[S.from,S.to])if(k!=="[*]"&&!y2(k))l(k,g);continue}const x=vg(y)?.target??Tg(y)?.target??Lg(y)?.id??Eg(y)?.id??y.match(Fg)?.[2]??y.match(Ng)?.[1]??Rg(y);if(x)l(x,g)}const c=m=>m?{parent:m.parent,...(o.get(m.parent)??0)>0?{region:m.region??0}:{}}:void 0;const d=gi(n);const u=(m,p)=>d(`${m}__r${p+1}`,["state-region",m,p]);const f=m=>m.region===void 0?m.parent:u(m.parent,m.region);const h=new Map;for(const m of t){if(a||h.has(m))continue;const p=[],g=new Set;let y=m;while(y!==void 0&&!h.has(y)){if(g.has(y)){a=`State containment cycle: ${[...p,y].join(" -> ")}`;break}g.add(y);p.push(y);y=i.get(y)?.parent}if(a)break;let b=y===void 0?0:h.get(y);for(const S of p.reverse()){b+=c(i.get(S))?.region!==void 0?2:1;Ve("nesting",b);h.set(S,b)}}for(const[m,p]of h)if((o.get(m)??0)>0)Ve("nesting",p+1);return{compositeIds:t,issue:a,ownerOf:m=>c(i.get(m)),scopeOf:m=>c(r.get(m)),authored:n,ownedIds:()=>i.keys(),regionId:u,scopeId:f,floatingNoteId:m=>d(`note:${m}`,["state-floating-note",m]),pseudostateId:(m,p)=>{const g=c(r.get(p));const y=g?f(g):"";return d(`${y}_${m}`,["state-pseudo",g?.parent??"",g?.region??-1,m])}}}function $g(){const e=new Map;return{close(t,n){const i=[];const r=new Set;for(const o of n){if(o.trim()===""||r.has(o)||e.has(o)&&e.get(o)!==t)continue;r.add(o);e.set(o,t);i.push(o)}return i},ownerOf:t=>e.get(t)}}function F2(e,t){if(e===t)return _f(t);try{return _f(HT(e))}catch(n){if(n instanceof Ei)throw n;return _f(t)}}function _f(e){const t=e.split("\n");const n=t.find(f=>f.trim().length>0&&!f.trim().startsWith("%%"))?.trim()??"";const i=/^stateDiagram(?:-v2)?(?=$|[\s;%])/i.test(n);const r=i?[]:uq(t);const o=cq(i?pa(t).filter((f,h,m)=>f.noteBody||f.text.length>0&&(!f.text.startsWith("//")||m[h-1]?.openQuote===true)).map(f=>f.text):r.map(f=>f.text));const s=o.length-r.length;const a=s>0?[...Array(s+1),...r.slice(1).map(f=>f.breaks)]:r.map(f=>f.breaks);if(o.length===0){throw new Error("Empty mermaid diagram")}const l=o[0];const c=uP(l,"strict");const d=c.kind==="registered"?c.familyId:eP(l);if(d==="state"){return Cq(o)}if(d==="flowchart")return yq(o,a);if(c.kind==="unknown")throw new Error(`Unknown Mermaid diagram header: ${l}`);const u=c.kind==="registered"?c.familyId:c.match.family.id;throw new Error(`Mermaid family "${u}" is not a graph family; use the family-neutral agent parser`)}function cq(e){const t=e.length>0?dq(e[0]):void 0;return t?[t.header,...t.statements,...e.slice(1)]:e}function dq(e){if(!e.includes(";"))return void 0;const t=e.match(/^(?:(?:graph|flowchart|swimlane)(?:[ \t]+(?:TD|TB|LR|BT|RL|[<>^v])(?![\w-]))?|stateDiagram(?:-v2)?)(?=$|[\s;])/i);if(!t)return void 0;const n=e.slice(t[0].length).trim();if(!n.startsWith(";"))return void 0;return{header:t[0],statements:/^stateDiagram/i.test(t[0])?[n]:$2(n)}}function uq(e){return tg(e).flatMap(t=>{const n=t.text.trim();if(!n||n.startsWith("%%"))return[];const i=t.text.length-t.text.trimStart().length;return[{text:n,...t.joined?{breaks:t.joined.map(r=>r.at-i)}:{}}]})}function N2(e){const t=e.indexOf("[");return t>0&&t<e.length-1&&e.endsWith("]")?{id:e.slice(0,t).trim(),title:e.slice(t+1,-1)}:void 0}function fq(e){const t=N2(e);if(t){const o=za(t.title);const s={label:o.text,...o.labelContent?{labelContent:o.labelContent}:{}};if(u0(t.id))return{id:t.id,...s,generated:false,identity:t.id,titled:true};if(Fw(t.id)){throw new Error(`Invalid flowchart subgraph identifier ${JSON.stringify(t.id)}`)}const a=kg(t.id).trim();if(u0(a))return{id:a,...s,generated:false,identity:a,titled:true};return{id:E2(a),...s,generated:true,identity:a,titled:true}}const n=za(e);const i=kg(e).trim();const r=i!==e&&/^`[\s\S]*`$/.test(i)?i.slice(1,-1).trim():i;if(u0(r)){return{id:r,label:n.text,...n.labelContent?{labelContent:n.labelContent}:{},generated:false,identity:r,titled:false}}return{id:E2(r),label:n.text,...n.labelContent?{labelContent:n.labelContent}:{},generated:true,identity:r,titled:false}}function E2(e){return e.replace(/<\/?[a-z][^<>]*>/gi," ").trim().replace(/\s+/g,"_").replace(/[^\p{L}\p{N}_-]/gu,"").replace(/-{2,}/g,"_")||"group"}function u0(e){return e.length>0&&Kl(e)===e.length}function $2(e){return Sf(e).map(t=>t.text)}function R2(e){return e&&e[1].split(",").every(t=>t===""||Kl(t)===t.length)?e:null}function hq(e){return/^(?:click|href)\s+/i.test(e.trim())}function mq(e,t){const n=t.trim().match(/^(?:click\s+)?(\S+)\s+(?:href\s+)?(?:"((?:\\.|[^"])*)"|(https?:\/\/\S+|mailto:\S+))/i);if(!n)return;const i=(n[2]??n[3]??"").replace(/\\(["\\])/g,"$1");if(!/^(?:https?:|mailto:)/i.test(i))return;const r=e.nodes.get(n[1]);if(r){r.href=i;if(ie("flowchart"))ue("flowchart","set-interaction",{id:r.id,href:i})}}var m0=String.raw`\s*@\s*\{`;function p0(e,t){const n=Vl(e,t,"flowchart");if(!n.ok){throw Je({what:`Invalid @{} metadata in "${e}": ${n.message}`,expectedForm:'a YAML mapping with "double-quoted" strings (a single-quoted one may not hold `"` or `}`)',example:'A@{ shape: rect, label: "Start: a}b" }'})}return n}function Ql(e,t){return pf(e.get(t))?.trim()||void 0}function pq(e,{id:t,entries:n}){const i=e.edges.find(a=>a.id===t);if(!i)return;const r=Ql(n,"curve");if(r&&/^[a-z][a-z0-9-]*$/i.test(r))i.curve=r;const o=Ql(n,"animate")?.toLowerCase();const s=Ql(n,"animation")?.toLowerCase();if(o==="true"||o==="fast"||o==="slow"||s==="fast"||s==="slow"){i.animate=true;const a=o==="fast"||o==="slow"?o:s;if(a==="fast"||a==="slow")i.animation=a}if(ie("flowchart"))ue("flowchart","set-edge-metadata",i)}function gq(e,t){const n=t.trim();const i=Kl(n);const r=i>0?n.slice(i).match(new RegExp(`^${m0}`)):null;if(!r)return null;const{end:o,entries:s}=p0(n,i+r[0].length-1);if(n.slice(o+1).trim()!=="")return null;const a=n.slice(0,i);return e.edges.some(l=>l.id===a)?{id:a,entries:s}:null}var Df=new WeakMap;function Of(e){Ve("nodes",e.nodes.size+(Df.get(e)??0)+1)}function yq(e,t=[]){const n=e[0].match(/^(?:(?:graph|swimlane)\s+(TD|TB|LR|BT|RL|[<>^v])|flowchart(?:\s+(TD|TB|LR|BT|RL|[<>^v]))?)\s*$/i);if(!n){throw new Error(`Invalid mermaid header: "${e[0]}". Expected "graph TD", "flowchart LR", "stateDiagram-v2", etc.`)}const i=kq(n[1]??n[2]??"TD");if(ie("flowchart")){Ge("flowchart","header",e[0],{line:1,unit:"normalized"});ue("flowchart","set-direction",i)}const r={direction:i,nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map};const o=[];const s=new Map;const a=new Set;const l=Mq(e.slice(1),t.slice(1));let c=0;const d=new Set([...l.values()].map(m=>m.id));const u=$g();const f=[];const h=()=>{const m=o.pop();if(!m)return;const p=s.get(m.id);const g=u.close(m.id,m.nodeIds);const y=g.filter(S=>d.has(S)&&S!==m.id);if(y.length)f.push({lister:m.id,ids:y});p.nodeIds=[...new Set([...p.nodeIds,...g.filter(S=>!d.has(S))])];for(const S of m.children)if(S!==p&&!p.children.some(x=>x.id===S.id))p.children.push(S);p.direction??=m.direction;const b=o.at(-1);if(!a.has(m.id)&&!o.some(S=>S.id===m.id)){if(b)b.children.push(p);else r.subgraphs.push(p);a.add(m.id);if(ie("flowchart"))ue("flowchart","attach-group",{id:m.id,parent:b?.id})}if(ie("flowchart"))ue("flowchart","close-group",{id:p.id,label:p.label,members:p.nodeIds,children:p.children.map(S=>S.id),direction:p.direction})};for(let m=1;m<e.length;m++){for(const p of $2(e[m])){if(ie("flowchart"))Ge("flowchart","statement",p,{line:m+1,unit:"normalized"});if(hq(p)){mq(r,p);continue}const g=gq(r,p);if(g){pq(r,g);continue}const y=p.match(/^classDef\s+([\w,-]+)\s+(.+)$/);if(y){const R=y[1].split(",").map(P=>P.trim()).filter(Boolean);const M=eg(vn(y[2]));if(Object.keys(M).length===0)continue;for(const P of R){r.classDefs.set(P,M);if(ie("flowchart"))ue("flowchart","define-class",{name:P,props:M})}continue}const b=R2(p.match(/^class\s+(\S+)\s+([\w-]+)\s*;?$/));if(b){const R=b[1].split(",").map(P=>P.trim());const M=b[2];for(const P of R){vs(r.classAssignments,P,M);if(ie("flowchart"))ue("flowchart","append-class",{id:P,name:M,classes:r.classAssignments.get(P)})}continue}const S=R2(p.match(/^style\s+(\S+)\s+(.+)$/));if(S){const R=S[1].split(",").map(P=>P.trim()).filter(Boolean);for(const P of R)z2(r,P,d);const M=eg(vn(S[2]));if(Object.keys(M).length===0)continue;for(const P of R){r.nodeStyles.set(P,{...r.nodeStyles.get(P),...M});if(ie("flowchart"))ue("flowchart","set-node-style",{id:P,props:r.nodeStyles.get(P)})}continue}const x=p.match(/^linkStyle\s+(default|[\d,\s]+)\s+(.+)$/);if(x){const R=x[1].trim();const M=R==="default"?[]:R.split(",").map(E=>parseInt(E.trim(),10)).filter(E=>!isNaN(E));const P=eg(vn(x[2]));if(Object.keys(P).length===0)continue;if(R==="default"){r.linkStyles.set("default",{...r.linkStyles.get("default"),...P});if(ie("flowchart"))ue("flowchart","set-link-style",{target:R,props:r.linkStyles.get("default")})}else{for(const E of M){r.linkStyles.set(E,{...r.linkStyles.get(E),...P});if(ie("flowchart"))ue("flowchart","set-link-style",{target:E,props:r.linkStyles.get(E)})}}continue}const k=p.match(/^direction\s+(TD|TB|LR|BT|RL)\s*$/i);if(k){const R=k[1].toUpperCase();if(o.length>0)o[o.length-1].direction=R;else r.direction=R;if(ie("flowchart"))ue("flowchart","set-direction",{parent:o.at(-1)?.id,direction:R});continue}if(p==="subgraph"){throw Je({what:`Invalid flowchart statement "${p}": a subgraph needs an id or a title (upstream fails on one with neither)`,expectedForm:'subgraph id, subgraph id[Title] or subgraph "Title"',example:'subgraph S["Stage one"]'})}const w=p.match(/^subgraph\s+(.+)$/);if(w){const{id:R,label:M,labelContent:P}=l[c++];const E={id:R,label:M,...P?{labelContent:P}:{},nodeIds:[],children:[]};if(!s.has(R)){Ve("nodes",r.nodes.size+s.size+1);s.set(R,{id:R,label:M,...P?{labelContent:P}:{},nodeIds:[],children:[]});Df.set(r,s.size)}Ve("nesting",o.length+1);o.push(E);if(ie("flowchart"))ue("flowchart","open-group",{id:R,label:M,scope:o.at(-2)?.id});continue}if(p==="end"){h();continue}const C=O2(p,r,o,d);if(!C.ok)throw wq(p,C)}}while(o.length>0)h();xq(r,f.map(({lister:m,ids:p})=>({lister:s.get(m),ids:p.map(g=>s.get(g))})));return r}function xq(e,t){const n=(i,r)=>i===r||i.children.some(o=>n(o,r));for(const{lister:i,ids:r}of t){for(const o of r){const s=o?e.subgraphs.indexOf(o):-1;if(s<0||n(o,i))continue;e.subgraphs.splice(s,1);i.children.push(o);if(ie("flowchart"))ue("flowchart","attach-group",{id:o.id,parent:i.id})}}}var bq=/^(?:end$|(?:direction|classDef|class|style|linkStyle|click|href)\s)/i;function Sq(){return{direction:"TD",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map}}function yce(e,t=Sq()){const n=new Set;const i=e.match(/^subgraph\s+(.+)$/);if(i){const r=i[1].trim();const o=N2(r);if(o?xf(o.title,"text"):Fw(r))n.add(o?"label-delimiter":"subgraph-title");if(Dg.test(o?o.title:r))n.add("empty-string");const s=o?r.length-o.title.length-2:-1;if([...r.matchAll(/(?:^|\s)[^\s"]+@(?![{"])/g)].some(a=>a.index<s))n.add("node-edge-id");return n}if(bq.test(e))return n;try{const r=O2(e,t,[],new Set,n);if(r.ok)return n;if(_2(e,r))return new Set(["comma-id"]);return new Set(D2(r)!==void 0?["link-markers"]:[])}catch(r){if(r instanceof Ei)throw r;return new Set}}function wq(e,t){const n=`Invalid flowchart statement "${e}"`;if(/^<?(?:-{2,}|-\.+|={2,})/.test(t.remaining)){const r=bf(t.remaining,0);if(r&&"stray"in r){const o=t.remaining.slice(r.stray,r.stray+2);return Je({what:`${n}: the link label in "${t.remaining}" holds a \`${o}\` before the link that closes it, which upstream's lexer rejects`,expectedForm:`a label without \`${o}\`, or a quoted one`,example:`A -- "x ${o} y" --> B`})}return Je({what:`${n}: "${t.remaining}" opens a link label that no link closes (\`--\` and \`-.\` always open a link, so a node id cannot hold them)`,expectedForm:"a label closed by a link of the same stroke, or an id without `--`",example:"A -- label --> B, A == label ==> B or A -. label .-> B"})}const i=D2(t);if(i!==void 0){return Je({what:`${n}: the link "${i}" starts with an \`${i[0]}\` marker and ends otherwise; upstream reads it as a link of no type, and ours reads an \`x\` or \`o\` start only before the same end`,expectedForm:"the same marker at both ends of a link label, or none",example:"A x-- label --x B or A -- label --> B"})}if(_2(e,t)){return Je({what:`${n}: upstream reads the "," before "${t.remaining.slice(1)}" as part of one node id (\`A,B\` is one node there), and ours reads no "," in a node id`,expectedForm:'a node id without ",", or `&` between nodes',example:"A & B --> C"})}return new Error(`${n}: could not fully consume ${t.reason}; remaining input: "${t.remaining}"`)}function _2(e,t){const n=e.trim().replace(/;\s*$/,"").trim();return t.remaining.startsWith(",")&&n.endsWith(t.remaining)&&(t.reason!=="expected edge operator"||BT(n,n.length-t.remaining.length))}function Mq(e,t=[]){const n=[];const i=new Set;const r=new Set;for(const[s,a]of e.entries()){for(const{text:l,start:c}of Sf(a)){const d=l.match(/^subgraph\s+(.+)$/);if(d){const u=d[1].trim();const f=fq(u);n.push(f);if(!f.generated)r.add(f.id);else if(!f.titled&&(/\s/.test(f.identity)||t[s]?.some(h=>h>c&&h<c+l.length)))i.add(f)}else{for(const u of l.matchAll(new RegExp(Pg,"gu")))r.add(u[0]);for(let u=0;u<l.length;){const f=Kl(l,u);if(f>0)r.add(l.slice(u,u+f));u=Zp(l,u)?.end??u+Math.max(f,1)}}}}const o=new Map;for(const s of n){if(!s.generated)continue;const a=i.has(s)?void 0:o.get(s.identity);if(a){s.id=a;continue}const l=s.id;let c=l;for(let d=2;r.has(c);d++)c=`${l}_${d}`;if(!i.has(s))o.set(s.identity,c);r.add(c);s.id=c}return n}function kq(e){const t=e.toUpperCase();if(t===">")return"LR";if(t==="<")return"RL";if(t==="^")return"BT";if(t==="V")return"TB";return t}function Cq(e){if(ie("state"))Ge("state","header",e[0],{line:1,unit:"normalized"});const t={direction:"TD",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map};const n=[];const i=C2(pa(e.slice(1))).statements;const r=P2(i);if(r.issue)throw new Error(r.issue);const o=r.compositeIds;const s=new Map;let a=0;const l=new Set;const c=new Map;const d=(w,C,R)=>{if(l.has(w)&&!R)return;const M=[...l.has(w)?c.get(w)??[]:[],C];c.set(w,M);l.add(w);const P=s.get(w);if(P)Object.assign(P,Td(P,M))};const u=new Map;const f=new Map;const h=new Map;const m=new Set;const p=()=>{const w=n.at(-1);return w?h.get(w)??n.length:0};const g=(w,C=p()+1)=>{Ve("nesting",C);h.set(w,C);n.push(w)};let y=null;const b=(w,C,R)=>{if(!t.stateNotes)t.stateNotes=[];const{text:M,content:P}=Cg(R);t.stateNotes.push({id:`note#${t.stateNotes.length}`,target:w,side:C,text:M,...P?{textContent:P}:{}});if(ie("state"))ue("state","add-note",t.stateNotes.at(-1));if(!o.has(w))f0(t,n,w)};const S=new Set;const x=(w,C,R)=>{if(w==="[*]"){const P=r.pseudostateId(C==="source"?"start":"end",R);Ld(t,n,{id:P,label:"",shape:C==="source"?"state-start":"state-end"});return P}const M=g2(w);if(M){const P=[...n].reverse().find(L=>!L.concurrencyRegion);const E=M.base!==""?M.base:P?.id??"";const v=`${E}[H${M.deep?"*":""}]`;Ld(t,n,{id:v,label:d0(M.deep),shape:"state-history"});return v}if(!o.has(w))f0(t,n,w);return w};for(const w of i){const C=w.text;const R={line:w.line+2,unit:"normalized"};if(ie("state"))Ge("state",y?"note-body":"statement",C,R);if(y){if(p2(C)){b(y.target,y.side,y.lines.join("\n"));y=null}else{y.lines.push(C)}continue}if(!C)continue;const M=m2(C);if(M){if(S.has(M.id))throw new Error(`Duplicate floating State note "${M.id}"`);S.add(M.id);const{text:O,content:N}=Cg(M.text);const H=r.scopeOf(w);const j=r.floatingNoteId(M.id);const q={id:M.id,text:O,...N?{textContent:N}:{},...H?{scope:H}:{},nodeId:j};if(!t.floatingStateNotes)t.floatingStateNotes=[];t.floatingStateNotes.push(q);Of(t);t.nodes.set(j,{id:j,label:O,...N?{labelContent:N}:{},shape:"state-note",floatingNoteId:M.id});if(ie("state")){ue("state","add-floating-note",q);ue("state","add-node",t.nodes.get(j))}continue}if(f2(C))continue;const P=vg(C);if(P){b(P.target,P.side,P.text);continue}const E=Tg(C);if(E){y={target:E.target,side:E.side,lines:[]};continue}const v=C.match(x2);if(v){const O=n.at(-1);if(O){if(!m.has(O))O.direction=v[1].toUpperCase()}else{t.direction=v[1].toUpperCase()}if(ie("state"))ue("state","set-direction",{parent:n.at(-1)?.id,direction:v[1].toUpperCase()});continue}const L=C.match(b2);if(L){const O=L[1].split(",").map(H=>H.trim()).filter(Boolean);const N=vd(L[2]);for(const H of O){t.classDefs.set(H,Nu(t.classDefs.get(H),N));if(ie("state"))ue("state","define-class",{name:H,props:N})}continue}const T=h2(C);if(T){for(const O of T.ids){vs(t.classAssignments,O,T.className);if(ie("state"))ue("state","assign-class",{id:O,name:T.className})}continue}const A=C.match(S2);if(A){const O=A[1].split(",").map(H=>H.trim()).filter(Boolean);const N=vd(A[2]);for(const H of O){t.nodeStyles.set(H,{...N});if(ie("state"))ue("state","set-node-style",{id:H,props:t.nodeStyles.get(H)})}continue}const $=C.match(w2);if($){const O=$[1].trim();const N=vn($[2]);if(Object.keys(N).length===0)continue;if(O==="default"){t.linkStyles.set("default",{...t.linkStyles.get("default"),...N});if(ie("state"))ue("state","set-link-style",{target:O,props:t.linkStyles.get("default")})}else{const H=O.split(",").map(j=>parseInt(j.trim(),10));for(const j of H){if(!isNaN(j)){t.linkStyles.set(j,{...t.linkStyles.get(j),...N});if(ie("state"))ue("state","set-link-style",{target:j,props:t.linkStyles.get(j)})}}}continue}const _=Lg(C);if(_){const O=_.stereotype==="fork"?"state-fork":_.stereotype==="join"?"state-join":_.stereotype==="choice"?"state-choice":"state-history";const N=O==="state-history"?d0(_.stereotype==="deep-history"):"";if(!t.nodes.has(_.id))Of(t);t.nodes.set(_.id,{id:_.id,label:N,shape:O});if(ie("state"))ue("state","upsert-node",t.nodes.get(_.id));g0(t,n,_.id);continue}if(Ag(C)&&n.length>0){const O=n[n.length-1];let N;if(O.concurrencyRegion){n.pop();N=n[n.length-1]}else{N=O;Ve("nodes",t.nodes.size+ ++a);Df.set(t,a);const j={id:r.regionId(N.id,v2(u,N.id)-1),label:"",nodeIds:N.nodeIds.splice(0),children:N.children.splice(0),concurrencyRegion:true};N.children.push(j);h.set(j,p()+1);if(ie("state"))ue("state","add-region",{id:j.id,parent:N.id,members:j.nodeIds,children:j.children.map(q=>q.id)})}Ve("nodes",t.nodes.size+ ++a);Df.set(t,a);const H={id:r.regionId(N.id,v2(u,N.id)-1),label:"",nodeIds:[],children:[],concurrencyRegion:true};N.children.push(H);g(H);if(ie("state"))ue("state","add-region",{id:H.id,parent:N.id,members:H.nodeIds});continue}const z=C.match($f);if(z){const O=z[2];const N=s.get(O);if(N&&!n.includes(N)){if(z[1]!==void 0)d(O,z[1],true);if(N.direction!==void 0)m.add(N);t.nodes.delete(O);g(N,h.get(N));const X=N.children.at(-1);if(X?.concurrencyRegion)g(X,h.get(X));if(ie("state"))ue("state","open-group",{id:O,label:N.label,parent:f.get(N)});continue}if(z[1]!==void 0){c.set(O,[z[1]]);l.add(O)}const H=l.has(O)?c.get(O):void 0;const j={id:O,label:O,nodeIds:[],children:[],stateComposite:true};if(H!==void 0)Object.assign(j,Td(j,H));const q=j.label;Ve("nodes",t.nodes.size-Number(t.nodes.has(O))+ ++a);Df.set(t,a);g(j);s.set(O,j);t.nodes.delete(O);if(ie("state"))ue("state","open-group",{id:O,label:q,parent:n.at(-2)?.id});continue}if(C==="}"){if(n.length>0&&n[n.length-1].concurrencyRegion){n.pop()}const O=n.pop();if(O){if(!f.has(O)){const N=n.at(-1);if(N)N.children.push(O);else t.subgraphs.push(O);f.set(O,N?.id)}if(ie("state"))ue("state","close-group",{id:O.id,label:O.label,members:O.nodeIds,children:O.children.map(N=>N.id),parent:f.get(O)})}continue}const F=C.match(Fg);if(F){const O=[F[1]];const N=F[2];if(o.has(N)){d(N,F[1],false);continue}const H=t.nodes.get(N);if(H?.shape==="rounded"&&!l.has(N)){c.set(N,O);t.nodes.set(N,Td(H,O));if(ie("state"))ue("state","set-label",{id:N,label:t.nodes.get(N).label})}if(!H)c.set(N,O);Ld(t,n,Td({id:N,label:N,shape:"rounded"},O));l.add(N);continue}const G=Ig(C);if(G){const O=x(G.from,"source",w);const N=x(G.to,"target",w);if(G.fromClass){vs(t.classAssignments,O,G.fromClass);if(ie("state"))ue("state","assign-class",{id:O,name:G.fromClass})}if(G.toClass){vs(t.classAssignments,N,G.toClass);if(ie("state"))ue("state","assign-class",{id:N,name:G.toClass})}const H=G.label?Cg(G.label):void 0;Ve("edges",t.edges.length+1);t.edges.push({source:O,target:N,label:H?.text,...H?.content?{labelContent:H.content}:{},style:"solid",hasArrowStart:false,hasArrowEnd:true});if(ie("state"))ue("state","add-edge",t.edges.at(-1),R);continue}const I=Eg(C);if(I){if(!o.has(I.id))f0(t,n,I.id);vs(t.classAssignments,I.id,I.className);if(ie("state"))ue("state","assign-class",{id:I.id,name:I.className});continue}const D=C.match(Ng);if(D){const O=D[1];const N=D[2].trim();if(o.has(O)){d(O,N,true);continue}const H=t.nodes.get(O);const j=[...l.has(O)?c.get(O)??[]:[],N];if(H&&H.shape==="rounded"){c.set(O,j);t.nodes.set(O,Td(H,j));if(ie("state"))ue("state","set-label",{id:O,label:t.nodes.get(O).label})}if(!H)c.set(O,j);Ld(t,n,Td({id:O,label:O,shape:"rounded"},j));l.add(O);continue}const B=Rg(C);if(B!==null){if(!o.has(B))Ld(t,n,{id:B,label:B,shape:"rounded"});continue}const Y=/^state\s+"[^"]*"\s+as\s+/.exec(C);const W=Y?C.slice(Y[0].length).replace(/\{$/,"").trimEnd():"";if(/\s/.test(W))throw Je({what:`Unsupported state syntax: "${C}"`,expectedForm:`one word after \`as\`; pinned Mermaid reads "${W}" as one name, which no transition can refer to`,example:'state "Long name" as LongName'});throw Je({what:`Unsupported state syntax: "${C}"`,expectedForm:"a state declaration, transition, composite, note, direction, or paint directive",example:"A --> B : continue"})}const k=n.find(w=>!w.concurrencyRegion);if(k){throw Je({what:`Composite state "${k.id}" is never closed`,expectedForm:"a `}` where the composite ends",example:"state X { A }"})}if(y)b(y.target,y.side,y.lines.join("\n"));Pq(t,s,r);return t}function Pq(e,t,n){const i=new Map(t);for(const o of t.values()){for(const s of o.children.filter(a=>a.concurrencyRegion))i.set(s.id,s)}for(const o of i.values()){o.nodeIds=o.nodeIds.filter(s=>!n.authored.has(s));o.children=o.children.filter(s=>!s.stateComposite);if(ie("state"))ue("state","reset-scope-membership",{id:o.id,members:o.nodeIds,children:o.children.map(s=>s.id)})}e.subgraphs=[];for(const o of t.values()){const s=n.ownerOf(o.id);const a=s?i.get(n.scopeId(s)):void 0;if(s&&!a)throw new Error(`Missing State scope for ${o.id}`);if(a)a.children.push(o);else e.subgraphs.push(o);if(ie("state"))ue("state","resolve-group-owner",{id:o.id,parent:a?.id})}for(const o of n.ownedIds()){if(!e.nodes.has(o))continue;const s=n.ownerOf(o);if(!s)continue;const a=i.get(n.scopeId(s));if(!a)throw new Error(`Missing State scope for ${o}`);a.nodeIds.push(o);if(ie("state"))ue("state","resolve-member-owner",{id:o,parent:a.id})}for(const o of e.floatingStateNotes??[]){if(!o.scope)continue;const s=i.get(n.scopeId(o.scope));if(!s)throw new Error(`Missing State scope for floating note ${o.id}`);s.nodeIds.push(o.nodeId);if(ie("state"))ue("state","resolve-member-owner",{id:o.nodeId,parent:s.id})}const r=e.subgraphs.map(o=>({group:o,depth:1}));while(r.length){const{group:o,depth:s}=r.pop();Ve("nesting",s);for(const a of o.children)r.push({group:a,depth:s+1})}}function v2(e,t){const n=(e.get(t)??0)+1;e.set(t,n);return n}function Td(e,t){const{text:n,content:i}=o2(t);const{labelContent:r,...o}=e;return{...o,label:n,...i?{labelContent:i}:{}}}var T2=new WeakMap;function g0(e,t,n){const i=t.at(-1);if(!i||i.nodeIds.includes(n))return;let r=T2.get(e);if(!r)T2.set(e,r=new Map);if(r.has(n))return;r.set(n,i);i.nodeIds.push(n);if(ie("state"))ue("state","add-member",{parent:i.id,id:n})}function Ld(e,t,n){const i=!e.nodes.has(n.id);if(i){Of(e);e.nodes.set(n.id,n);if(ie("state"))ue("state","add-node",n)}g0(e,t,n.id)}function f0(e,t,n){if(!e.nodes.has(n)){Ld(e,t,{id:n,label:n,shape:"rounded"})}else{g0(e,t,n)}}function Eq(e){const t=WT(e,0);if(t?.kind!=="pipe"||!t.closed)return null;return{rawLabel:e.slice(t.contentStart,t.contentEnd),consumed:t.end}}function Rq(e){const t=Nw(e,0);if(!t)return null;const n=t.startMark==="x"?"cross":t.startMark==="o"?"circle":t.startMark?"arrow":void 0;if((t.startMark==="x"||t.startMark==="o")&&n!==Og(t.closeOp))return null;return{startMarker:n,openOp:t.openOp,rawLabel:e.slice(t.labelStart,t.labelEnd),closeOp:t.closeOp,consumed:t.end}}var sr=e=>new RegExp(`^${e}`,"u");var vq=[{regex:sr(String.raw`\(\(\((.+?)\)\)\)`),shape:"doublecircle"},{regex:sr(String.raw`\(\[(.+?)\]\)`),shape:"stadium"},{regex:sr(String.raw`\(-(.+?)-\)`),shape:"ellipse"},{regex:sr(String.raw`\(\((.+?)\)\)`),shape:"circle"},{regex:sr(String.raw`\[\[(.+?)\]\]`),shape:"subroutine"},{regex:sr(String.raw`\[\((.+?)\)\]`),shape:"cylinder"},{regex:sr(String.raw`\[\/([^\]]+?)\\\]`),shape:"trapezoid"},{regex:sr(String.raw`\[\\([^\]]+?)\/\]`),shape:"trapezoid-alt"},{regex:sr(String.raw`\[\/([^\]]+?)\/\]`),shape:"lean-r"},{regex:sr(String.raw`\[\\([^\]]+?)\\\]`),shape:"lean-l"},{regex:sr(String.raw`>(.+?)\]`),shape:"asymmetric"},{regex:sr(String.raw`\{\{(.+?)\}\}`),shape:"hexagon"},{regex:sr(String.raw`\[(.+?)\]`),shape:"rectangle"},{regex:sr(String.raw`\((.+?)\)`),shape:"rounded"},{regex:sr(String.raw`\{(.+?)\}`),shape:"diamond"}];var Tq=new Set(["trapezoid","trapezoid-alt","lean-r","lean-l"]);function _g(e){const t=Kl(e);return t>0?{id:e.slice(0,t),length:t}:null}var Lq=new RegExp(String.raw`^(${_T})@\s*(?=${Qp}|(?:-{2,}|-\.+|={2,})\s+)`,"u");function D2(e){if(e.reason!=="expected edge operator")return void 0;const t=Nw(e.remaining,0);if(t?.startMark!=="x"&&t?.startMark!=="o")return void 0;return Og(t.closeOp)===(t.startMark==="x"?"cross":"circle")?void 0:e.remaining.slice(0,t.end)}function h0(e){const t=c0(e);if(!t)return null;const n=e.slice(3);const i=Math.min(t.className.length,Kl(n));if(i===0)return null;return{className:n.slice(0,i),length:3+i}}function O2(e,t,n,i=new Set,r){let o=e.trim().replace(/;\s*$/,"").trim();const s=r?Nq(o,r):void 0;const a=L2(o,t,n,i,s);if(!a||a.ids.length===0){return{ok:false,remaining:o,reason:"expected node"}}o=a.remaining.trim();if(o.length===0)return{ok:true};let l=a.ids;while(o.length>0){let c;let d;let u;let f;let h;let m;let p;let g;const y=o.match(Lq);const b=y?.[1];if(y){if(ie("flowchart"))Bo("flowchart","edge-id",y[0]);o=o.slice(y[0].length).trim()}const S=Zp(o,0);if(S){const C=S.op;let R=S.end;const M=/^\s*/.exec(o.slice(R))[0].length;const P=o.slice(R+M);if(P.startsWith("|")){const E=Eq(P);if(!E)return{ok:false,remaining:P,reason:"expected edge target"};if(xf(E.rawLabel,"text"))r?.add("label-delimiter");if(Dg.test(E.rawLabel))r?.add("empty-string");if(E.rawLabel==="")r?.add("empty-pipe-label");if($q.test(E.rawLabel))r?.add("node-edge-id");const v=za(E.rawLabel.trim());m=v.text||void 0;p=v.labelContent;R+=M+E.consumed}if(ie("flowchart"))Bo("flowchart","link",o.slice(0,R));o=o.slice(R).trim();d=_q(C);g=Dq(C);f=Bq(C,S.hasArrowStart);h=Og(C);c=f!==void 0;u=h!==void 0}else{const C=Rq(o);if(!C)return{ok:false,remaining:o,reason:"expected edge operator"};if(xf(C.rawLabel,"edge-text"))r?.add("label-delimiter");if(Dg.test(C.rawLabel))r?.add("empty-string");const R=za(C.rawLabel);m=R.text||void 0;p=R.labelContent;if(ie("flowchart"))Bo("flowchart","text-link",o.slice(0,C.consumed));o=o.slice(C.consumed).trim();d=H2(C.openOp,C.closeOp);g=Oq(C.openOp,C.closeOp);f=C.startMarker;c=f!==void 0;h=Og(C.closeOp);u=h!==void 0}const x=L2(o,t,n,i,s);if(!x||x.ids.length===0){return{ok:false,remaining:o,reason:"expected edge target"}}o=x.remaining.trim();Ve("edges",t.edges.length+l.length*x.ids.length);const k=b!==void 0&&t.edges.some(C=>C.id===b);if(k)r?.add("duplicate-edge-id");let w=k?void 0:b;for(const C of l){for(const R of x.ids){const M=C===l.at(-1)&&R===x.ids[0]?w:void 0;if(M!==void 0)w=void 0;t.edges.push({source:C,target:R,...M!==void 0?{id:M}:{},label:m,...p?{labelContent:p}:{},style:d,hasArrowStart:c,hasArrowEnd:u,startMarker:f,endMarker:h,...g!==void 0?{length:g}:{}});if(ie("flowchart"))ue("flowchart","add-edge",t.edges.at(-1))}}l=x.ids}return{ok:true}}function L2(e,t,n,i,r){const o=I2(e,t,n,i,r);if(!o)return null;const s=[o.id];let a=o.remaining.trim();while(a.startsWith("&")){if(ie("flowchart"))Bo("flowchart","parallel-separator","&");const l=I2(a.slice(1).trim(),t,n,i,r);if(!l)break;s.push(l.id);a=l.remaining.trim()}return{ids:s,remaining:a}}function Aq(e,t,n){const i=_g(e);const r=i&&e.slice(i.length).match(new RegExp(`^${m0}`));if(!i||!r)return null;const o=i.id;const{end:s,entries:a}=p0(e,i.length+r[0].length-1);B2(o,a,t,n);return{id:o,remaining:e.slice(s+1)}}function B2(e,t,n,i){const r=t.get("label");const o=r===""?"":pf(r);const s=o!==void 0?za(o,true):void 0;const a=Ql(t,"shape");const l=a!==void 0?i2(a):null;const c=Ql(t,"icon");const d=Ql(t,"img");const u=Ql(t,"form");const f=u==="circle"||u==="rounded"||u==="square"?u:void 0;const h=l?{shape:l.geometry,semanticShape:l.canonical,authoredShape:a}:c||d?{shape:f==="circle"?"circle":f==="rounded"?"rounded":"rectangle",semanticShape:c?"icon":"image"}:{};const m={...c?{icon:c}:{},...d?{image:d}:{},...f?{iconForm:f}:{}};const p=n.nodes.get(e);if(p){n.nodes.set(e,{...p,...s!==void 0?{label:s.text,labelContent:s.labelContent,...s.markdown?{markdownLabel:true}:{}}:{},...h,...m});if(ie("flowchart"))ue("flowchart","set-node-metadata",n.nodes.get(e));Bg(i,e)}else{G2(n,i,{id:e,label:s?.text??e,...s?.labelContent?{labelContent:s.labelContent}:{},shape:"rectangle",...s?.markdown?{markdownLabel:true}:{},...h,...m})}}function A2(e,t,n,i){const r=t.match(new RegExp(`^${m0}`));if(!r)return null;const{end:o,entries:s}=p0(t,r[0].length-1);B2(e,s,n,i);return t.slice(o+1)}var Iq=[{open:"(((",close:")))",shape:"doublecircle"},{open:"([",close:"])",shape:"stadium"},{open:"(-",close:"-)",shape:"ellipse"},{open:"((",close:"))",shape:"circle"},{open:"[[",close:"]]",shape:"subroutine"},{open:"[(",close:")]",shape:"cylinder"},{open:"[/",close:"\\]",shape:"trapezoid"},{open:"[\\",close:"/]",shape:"trapezoid-alt"},{open:"[/",close:"/]",shape:"lean-r"},{open:"[\\",close:"\\]",shape:"lean-l"},{open:">",close:"]",shape:"asymmetric"},{open:"{{",close:"}}",shape:"hexagon"},{open:"[",close:"]",shape:"rectangle"},{open:"(",close:")",shape:"rounded"},{open:"{",close:"}",shape:"diamond"}];var Dg=/^\s*""\s*$/;function Fq(e,t,n,i){const r=_g(e);if(!r)return null;const o=e.slice(r.length);for(const s of Iq){if(!o.startsWith(`${s.open}"`))continue;const a=s.open.length;const l=o.indexOf('"',a+1);if(l<0||!o.startsWith(s.close,l+1))continue;if(l===a+1)i?.add("empty-string");const c=za(o.slice(a+1,l),true);W2(t,n,{id:r.id,label:c.text,...c.labelContent?{labelContent:c.labelContent}:{},shape:s.shape,...c.markdown?{markdownLabel:true}:{}});const d=r.length+l+1+s.close.length;return{id:r.id,remaining:e.slice(d)}}return null}function I2(e,t,n,i,r){const o=Aq(e,t,n);if(o){let f=o.remaining;const h=h0(f);if(h){vs(t.classAssignments,o.id,h.className);if(ie("flowchart"))ue("flowchart","append-class",{id:o.id,name:h.className,classes:t.classAssignments.get(o.id)});f=f.slice(h.length)}if(ie("flowchart"))Bo("flowchart","metadata-node",e.slice(0,e.length-f.length));return{id:o.id,remaining:f}}const s=Fq(e,t,n,r);if(s){let f=A2(s.id,s.remaining,t,n)??s.remaining;const h=h0(f);if(h){vs(t.classAssignments,s.id,h.className);if(ie("flowchart"))ue("flowchart","append-class",{id:s.id,name:h.className,classes:t.classAssignments.get(s.id)});f=f.slice(h.length)}if(ie("flowchart"))Bo("flowchart","quoted-node",e.slice(0,e.length-f.length));return{id:s.id,remaining:f}}let a=null;let l=e;const c=_g(e);const d=c?e.slice(c.length):"";for(const{regex:f,shape:h}of c?vq:[]){const m=d.match(f);if(m){a=c.id;if(xf(m[1],Tq.has(h)?"trapezoid":"text"))r?.add("label-delimiter");if(Dg.test(m[1]))r?.add("empty-string");const{text:p,markdown:g,labelContent:y}=za(m[1]);W2(t,n,{id:a,label:p,shape:h,...g?{markdownLabel:true}:{},...y?{labelContent:y}:{}});l=d.slice(m[0].length);break}}if(a===null){const f=_g(e);if(f){a=f.id;z2(t,a,i);Bg(n,a);l=e.slice(f.length)}}if(a===null)return null;l=A2(a,l,t,n)??l;const u=h0(l);if(u){vs(t.classAssignments,a,u.className);if(ie("flowchart"))ue("flowchart","append-class",{id:a,name:u.className,classes:t.classAssignments.get(a)});l=l.slice(u.length)}if(Kp(e,e.length-l.length))return null;if(r?.nodeEdgeId(e))r.add("node-edge-id");if(ie("flowchart"))Bo("flowchart","node",e.slice(0,e.length-l.length));return{id:a,remaining:l}}function Nq(e,t){const n=new Uint8Array(e.length);let i=false;for(let r=e.length-1;r>=0;r--){const o=e[r];if(/[\s"]/.test(o))i=false;else{n[r]=i?1:0;if(o==="@"&&e[r+1]!=="{"&&e[r+1]!=='"')i=true}}return{add:r=>{t.add(r)},nodeEdgeId:r=>n[e.length-r.length]===1}}var $q=/^[^\s"]*@(?![{"])/;function W2(e,t,n){const i=e.nodes.get(n.id);if(!i){G2(e,t,n);return}const{markdownLabel:r,semanticShape:o,authoredShape:s,labelContent:a,...l}=i;e.nodes.set(n.id,{...l,label:n.label,shape:n.shape,...n.markdownLabel?{markdownLabel:true}:{},...n.labelContent?{labelContent:n.labelContent}:{}});if(ie("flowchart"))ue("flowchart","define-node",e.nodes.get(n.id));Bg(t,n.id)}function z2(e,t,n){if(e.nodes.has(t)||n.has(t))return false;Of(e);e.nodes.set(t,{id:t,label:t,shape:"rectangle"});if(ie("flowchart"))ue("flowchart","add-node",e.nodes.get(t));return true}function G2(e,t,n){const i=!e.nodes.has(n.id);if(i){Of(e);e.nodes.set(n.id,n);if(ie("flowchart"))ue("flowchart","add-node",n)}Bg(t,n.id)}function Bg(e,t){if(e.length>0){const n=e[e.length-1];if(!n.nodeIds.includes(t)){n.nodeIds.push(t);if(ie("flowchart"))ue("flowchart","add-member",{parent:n.id,id:t})}}}function _q(e){if(e[0]==="~")return"invisible";if(e.includes("."))return"dotted";if(e.includes("="))return"thick";return"solid"}function Dq(e){let t;if(e[0]==="~"){t=e.length-3}else if(e.includes(".")){t=(e.match(/\./g)?.length??1)-1}else if(e.includes("=")){const n=e.match(/=/g)?.length??2;t=/[>ox]$/.test(e)?n-2:n-3}else{const n=e.match(/-/g)?.length??2;const i=/[>ox]$/.test(e)||/^[ox]/.test(e);t=i?n-2:n-3}return t>0?t+1:void 0}function H2(e,t){if(e.includes(".")||t.includes("."))return"dotted";if(e.includes("=")||t.includes("="))return"thick";return"solid"}function Oq(e,t){const n=H2(e,t);const i=(a,l)=>(a.match(new RegExp(`\\${l}`,"g"))??[]).length;let r=0;let o=0;if(n==="dotted"){r=Math.max(0,i(e,".")-1);o=Math.max(0,i(t,".")-1)}else if(n==="thick"){r=Math.max(0,i(e,"=")-2);o=Math.max(0,i(t,"=")-(/[>ox]$/.test(t)?2:3))}else{r=Math.max(0,i(e,"-")-2);o=Math.max(0,i(t,"-")-(/[>ox]$/.test(t)?2:3))}const s=Math.max(r,o);return s>0?s+1:void 0}function Bq(e,t){if(t)return"arrow";if(e.startsWith("o"))return"circle";if(e.startsWith("x"))return"cross";return void 0}function Og(e){const t=e[e.length-1];if(t===">")return"arrow";if(t==="o")return"circle";if(t==="x")return"cross";return void 0}function y0(e){const t=new Map;return e.map(n=>{const i=`${n.source}->${n.target}`;const r=t.get(i)??0;t.set(i,r+1);return`${i}#${r}`})}function Ad(e){const t=new Map;y0(e).forEach((n,i)=>{t.set(n,i);if(n.endsWith("#0"))t.set(n.slice(0,-2),i)});for(let n=e.length-1;n>=0;n--){const i=e[n].id;if(i)t.set(i,n)}return t}var j2=/^"((?:[^"\\]|\\.)*)"\s*:\s*(.+)$/;var Wq=/^\+?(?:\d+(?:\.\d+)?|\.\d+)$/;var b0=/[\u0000-\u0008\u000b\u000c\u000e-\u001f]/;function S0(e){return Tr(e,wg)}function X2(e){e=aa(Wt(e,S0(e)).familyLines,wg).map(Gt);if(e.length===0){throw new Error("Pie chart is empty")}const t=e[0].trim();const n=t.match(/^pie\b(.*)$/i);if(!n){throw new Error(`Pie chart must start with "pie", got: "${t}"`)}if(ie("pie"))Ge("pie","header",t,{line:1,unit:"normalized"});let i=false;let r;let o;let s=n[1].trim();const a=s.match(/^showData\b\s*(.*)$/i);if(a){i=true;if(ie("pie"))ue("pie","setShowData",i,{line:1,unit:"normalized"});s=a[1].trim()}const l=s.match(/^title\s+(.+)$/i);if(l){const h=l[1].trim();r=h;if(ie("pie"))ue("pie","setTitle",r,{line:1,unit:"normalized"});o=q2(h);if(ie("pie"))ue("pie","resolveTitleDisplay",o,{line:1,unit:"normalized"})}else if(s.length>0){throw new Error(`Unexpected text after pie header: "${s}"`)}const c=[];const d=new Set;let u=false;let f=false;for(let h=1;h<e.length;h++){const m=e[h].trim();if(m.length===0||m.startsWith("%%"))continue;if(/^showData\s*$/i.test(m)){if(ie("pie"))Ge("pie","showData",m,{line:h+1,unit:"normalized"});i=true;if(ie("pie"))ue("pie","setShowData",i,{line:h+1,unit:"normalized"});continue}const p=m.match(/^title\s+(.+)$/i);if(p){if(ie("pie"))Ge("pie","title",m,{line:h+1,unit:"normalized"});const y=p[1].trim();r=y;if(ie("pie"))ue("pie","setTitle",r,{line:h+1,unit:"normalized"});o=q2(y);if(ie("pie"))ue("pie","resolveTitleDisplay",o,{line:h+1,unit:"normalized"});continue}const g=m.match(j2);if(g){if(ie("pie"))Ge("pie","entry",m,{line:h+1,unit:"normalized"});const y=x0(g[1]);if(/[\u0000-\u001f]/.test(x0(g[1].replace(/\n/g,"")))){f=true;if(ie("pie"))ue("pie","setHasEscapedControlLabels",true,{line:h+1,unit:"normalized"})}const b=y;const S=g[2].trim();if(!Wq.test(S)){throw new Error(`Pie slice "${b}" has invalid value "${S}". Values must be non-negative numbers.`)}const x=Number.parseFloat(S);if(!Number.isFinite(x)||x<0){throw new Error(`Pie slice "${b}" has invalid value "${S}". Values must be non-negative numbers.`)}if(b0.test(y)){throw Je({what:"Pie slice label contains an XML-disallowed control character",expectedForm:"a label without XML-disallowed control characters",example:'"Alpha" : 10'})}const k=Un(m);const w=j2.exec(k)?.[1]??g[1];const C=x0(Dn(w));const R=no(C,U2);if(ie("pie"))ue("pie","resolveEntryDisplay",{sourceKey:C,label:R},{line:h+1,unit:"normalized"});if(Gq(b,R)){throw Je({what:"Pie entity projection creates a terminal control character after escape decoding",expectedForm:"an entity that displays printable text",example:'"Alpha#" : 10'})}if(b0.test(R)){throw Je({what:"Pie slice display label contains an XML-disallowed control character",expectedForm:"a label without XML-disallowed control characters",example:'"Alpha" : 10'})}const M=zq(R);if(d.has(C)){u=true;if(ie("pie"))ue("pie","setHasDuplicateSourceLabels",true,{line:h+1,unit:"normalized"})}else{d.add(C);if(ie("pie"))ue("pie","addSourceLabel",C,{line:h+1,unit:"normalized"});c.push({label:b,value:x,...M===b&&!Y2(b)?{}:{displayLabel:M}});if(ie("pie"))ue("pie","appendEntry",c[c.length-1],{line:h+1,unit:"normalized"})}continue}if(m.includes(":")){if(ie("pie"))Ge("pie","invalidEntry",m,{line:h+1,unit:"normalized"});throw new Error(`Invalid pie entry: "${m}". Expected: "label" : positiveNumber`)}if(ie("pie"))Ge("pie","unrecognized",m,{line:h+1,unit:"normalized"});throw Je({what:`Unrecognized pie chart line: "${m}"`,expectedForm:'a title, showData, or a slice ("Label" : number)',example:'"Free" : 60'})}return{title:r,showData:i,entries:c,...o!==r||r!==void 0&&Y2(r)?{displayTitle:o}:{},...u?{hasDuplicateSourceLabels:true}:{},...f?{hasEscapedControlLabels:true}:{}}}function Y2(e){return/[<>*~]/.test(e)}function zq(e){if(!e.includes("\n"))return e;const t=[];for(const n of e.split("\n")){let i=0;let r=n.length;while(i<r&&(n[i]===" "||n[i]===" "))i++;while(r>i&&(n[r-1]===" "||n[r-1]===" "))r--;if(i<r)t.push(n.slice(i,r))}return t.join(" ")}function q2(e){const t=no(Dn(Un(e)),U2);if(b0.test(t)){throw Je({what:"Pie title display contains an XML-disallowed control character",expectedForm:"a title without XML-disallowed control characters",example:"title Safe chart"})}return t}var U2={subject:"Pie entity",example:'"Alpha#" : 10'};function Gq(e,t){if(!go.test(t))return false;const n=new Uint32Array(160);for(const i of e){const r=i.charCodeAt(0);if(r<160&&go.test(i)){n[r]=n[r]+1}}for(const i of t){const r=i.charCodeAt(0);if(r>=160||!go.test(i))continue;if(n[r]===0)return true;n[r]=n[r]-1}return false}function x0(e){const t={n:"\n",t:" ",r:"\r",b:"\b",f:"\f",v:"\v","0":"\0"};return e.replace(/\\(.)/g,(n,i)=>t[i]??i)}function Bf(e){const t=Math.max(0,...e.series.map(n=>n.data.length));if(e.xAxis.categories)return Math.max(1,e.xAxis.categories.length,t);return Math.max(1,t)}function w0(e,t=Bf(e)){if(e.xAxis.range){const{min:n,max:i}=e.xAxis.range;const r=t>1?(i-n)/(t-1):0;return Array.from({length:t},(o,s)=>n+r*s)}return Array.from({length:t},(n,i)=>i)}function Wg(e,t=Bf(e)){if(e.xAxis.categories)return Array.from({length:t},(n,i)=>e.xAxis.categories[i]??String(i+1));if(e.xAxis.range)return w0(e,t).map(n=>Wf(n));return Array.from({length:t},(n,i)=>String(i+1))}function V2(e,t,n){if(e.length<2)return n;let i=Number.POSITIVE_INFINITY;for(let r=1;r<e.length;r++){i=Math.min(i,Math.abs(t(e[r])-t(e[r-1])))}return Number.isFinite(i)&&i>0?i:n}function zg(e,t){const n=Math.min(e.min,e.max);const i=Math.max(e.min,e.max);return Math.min(i,Math.max(n,t))}function K2(e){return zg(e,0)}function Zl(e){if(Number.isInteger(e))return String(e);const t=e.toFixed(Math.abs(e)<10?1:0);return Number(t)===0&&e!==0?String(e):t}function Gg(e,t,n=10){if(!(n>0))return[];if(e===t)return[e];const i=t<e;const r=i?t:e;const o=i?e:t;const[s,a,l]=J2(r,o,n);if(!(a>=s))return[];const c=a-s+1;const d=new Array(c);if(i){if(l<0){for(let u=0;u<c;u++)d[u]=(a-u)/-l}else{for(let u=0;u<c;u++)d[u]=(a-u)*l}}else if(l<0){for(let u=0;u<c;u++)d[u]=(s+u)/-l}else{for(let u=0;u<c;u++)d[u]=(s+u)*l}return d.map(Hq)}function Wf(e){if(!Number.isFinite(e))return String(e);if(Number.isInteger(e))return String(e);return Number(e.toPrecision(12)).toString()}function J2(e,t,n){const i=(t-e)/Math.max(0,n);const r=Math.floor(Math.log10(i));const o=i/Math.pow(10,r);const s=o>=Math.sqrt(50)?10:o>=Math.sqrt(10)?5:o>=Math.sqrt(2)?2:1;let a;let l;let c;if(r<0){c=Math.pow(10,-r)/s;a=Math.round(e*c);l=Math.round(t*c);if(a/c<e)a++;if(l/c>t)l--;c=-c}else{c=Math.pow(10,r)*s;a=Math.round(e/c);l=Math.round(t/c);if(a*c<e)a++;if(l*c>t)l--}if(l<a&&.5<=n&&n<2){return J2(e,t,n*2)}return[a,l,c]}function Hq(e){return Math.round(e*1e12)/1e12}function Yt(e,t,n,i="middle"){if(!e)return void 0;return{x:rt(t-(i==="start"?0:i==="end"?e.width:e.width/2)),y:rt(n-e.height/2),w:rt(e.width),h:rt(e.height)}}function St(e,t,n,i,r="middle"){const o=Yt(e,t,n,r);return o?{labelBounds:o,labelContainer:{x:rt(i.x),y:rt(i.y),w:rt(i.width),h:rt(i.height)}}:{}}function jq(e){return{id:e.id,x:rt(e.x),y:rt(e.y),w:rt(e.width),h:rt(e.height),shape:e.shape,label:e.label,...St(e.labelBlock,e.x+e.width/2,e.y+e.height/2,e)}}function Yq(e,t,n){const i=e.label?e.labelPosition??sn(e.points):void 0;return{id:t,from:e.source,to:e.target,path:e.points.map(r=>[rt(r.x),rt(r.y)]),...e.style==="invisible"?{visibility:"hidden"}:{},label:e.label&&i?{x:rt(i.x),y:rt(i.y),text:e.label,bounds:Yt(e.labelBlock,i.x,i.y)}:void 0,...n&&e.routeCertificate?{route:e.routeCertificate}:{}}}function Q2(e,t={}){const n=e.edges.map((l,c)=>({value:l,index:c})).sort((l,c)=>(l.value.edgeIndex??l.index)-(c.value.edgeIndex??c.index)).map(l=>l.value);const i=y0(n);const r=Ad(n);const o=new Set(e.nodes.map(l=>l.id));const s=[...e.groups];for(const l of s){o.add(l.id);s.push(...l.children)}const a=new Map(n.map((l,c)=>{const d=l.id;const u=i[c];const f=u.replace(/#0$/,"");return[l,d&&!o.has(d)&&r.get(d)===c?d:r.get(f)===c?f:u]}));return{version:1,nodes:e.nodes.map(jq),edges:e.edges.map(l=>Yq(l,a.get(l),t.debug===true)),groups:qq(e.groups,e.nodes),bounds:{w:rt(e.width),h:rt(e.height)}}}function qq(e,t){const n=[];const i=(o,s)=>s.x>=o.x-.5&&s.y>=o.y-.5&&s.x+s.width<=o.x+o.width+.5&&s.y+s.height<=o.y+o.height+.5;const r=(o,s)=>{const a=o.nodeIds?new Set(o.nodeIds):void 0;const l=t.filter(c=>a?a.has(c.id):i(o,c)&&!o.children.some(d=>i(d,c))).map(c=>c.id);n.push({id:o.id,x:rt(o.x),y:rt(o.y),w:rt(o.width),h:rt(o.height),members:l,label:o.label,...s?{parentId:s}:{}});for(const c of o.children)r(c,o.id)};for(const o of e)r(o);return n}function Fce(e){return{version:1,kind:e,nodes:[],edges:[],groups:[],bounds:{w:rt(0),h:rt(0)}}}var Xt=e=>({x:0,y:0,width:e.width,height:e.height});var ln=e=>({x:rt(e.x),y:rt(e.y),w:rt(e.width),h:rt(e.height)});function ye(e){return rt(Math.round(e))}function zt(e,t){return rt(Math.round(e+t)-Math.round(e))}function Hg(e,t,n,i,r){const o=!!(i&&n[0]&&Z2(n[0].x,n[0].y,i,1));const s=!!(r&&n[n.length-1]&&Z2(n[n.length-1].x,n[n.length-1].y,r,1));const a=zf(n);return{family:e,edgeIndex:t,routeClass:"family-layout",invariant:o&&s&&a?"orthogonal-box":"unverified-family-route",bendCount:Gf(n),orthogonal:a,sourceBoundary:o,targetBoundary:s}}function zf(e){for(let t=1;t<e.length;t++){const n=e[t-1],i=e[t];if(Math.abs(n.x-i.x)>.5&&Math.abs(n.y-i.y)>.5)return false}return true}function Gf(e){if(e.length<3)return 0;let t=0;for(let n=1;n<e.length-1;n++){const i=e[n-1],r=e[n],o=e[n+1];const s=Math.abs(i.x-r.x)<=.5&&Math.abs(r.x-o.x)<=.5;const a=Math.abs(i.y-r.y)<=.5&&Math.abs(r.y-o.y)<=.5;if(!s&&!a)t++}return t}function Z2(e,t,n,i){const r=(Math.abs(e-n.x)<=i||Math.abs(e-(n.x+n.width))<=i)&&t>=n.y-i&&t<=n.y+n.height+i;const o=(Math.abs(t-n.y)<=i||Math.abs(t-(n.y+n.height))<=i)&&e>=n.x-i&&e<=n.x+n.width+i;return r||o}function Zo(e,t,n,i,r="bounds"){const o=new Map;for(const s of t.groups){for(const a of s.members)o.set(a,s)}return t.nodes.map(s=>{const a=Xq(s,t.bounds);const l=o.get(s.id)??i;const c=l?r==="center"?Vq(s,l):Uq(s,l):void 0;return{family:e,elementId:s.id,routeClass:"family-layout",invariant:a&&(c??true)?n:"unverified-family-layout",bounds:{x:s.x,y:s.y,w:s.w,h:s.h},center:{x:ye(s.x+s.w/2),y:ye(s.y+s.h/2)},containment:r,withinBounds:a,...l?{groupId:l.id,withinGroup:c}:{}}})}function Xq(e,t,n=.5){return e.x>=-n&&e.y>=-n&&e.x+e.w<=t.w+n&&e.y+e.h<=t.h+n}function Uq(e,t,n=.5){return e.x>=t.x-n&&e.y>=t.y-n&&e.x+e.w<=t.x+t.w+n&&e.y+e.h<=t.y+t.h+n}function Vq(e,t,n=.5){const i=e.x+e.w/2;const r=e.y+e.h/2;return i>=t.x-n&&r>=t.y-n&&i<=t.x+t.w+n&&r<=t.y+t.h+n}function jg({positioned:e,options:t}){const n=new Map(e.lifelines.map(s=>[s.actorId,s.x]));const i=new Map;for(const s of e.messages)for(const a of[s.from,s.to])if(!i.has(a))i.set(a,s.y);const r=new Map;for(const s of e.notes)if(s.parentId!==void 0&&s.id!==void 0){const a=r.get(s.parentId)??[];a.push(s.id);r.set(s.parentId,a)}const o=[...e.actors.map(s=>({id:s.id,x:ye(s.external?s.x:s.bounds.x),y:ye(s.external?i.get(s.id)??s.y:s.bounds.y),w:ye(s.external?0:s.bounds.width),h:ye(s.external?0:s.bounds.height),shape:s.external?"external-anchor":"rectangle",label:s.label,labelBounds:ln(s.labelPosition.bounds),labelContainer:ln(s.bounds),...s.external?{labelVisibility:"semantic"}:{},role:s.external?"mark":"box"})),...e.notes.map((s,a)=>({id:s.id??`note#${a}`,...s.parentId===void 0?{}:{parentId:s.parentId},x:ye(s.x),y:ye(s.y),w:ye(s.width),h:ye(s.height),shape:"note",label:s.text,...St(s.block,s.x+s.width/2,s.y+s.height/2,s),role:"box"}))];return{version:1,nodes:o,edges:e.messages.map((s,a)=>({id:s.id??`msg#${a}:${s.from}->${s.to}`,...s.parentId===void 0?{}:{parentId:s.parentId},from:s.from,to:s.to,path:s.points.map(l=>[ye(l.x),ye(l.y)]),label:s.label?{x:ye(s.labelPosition.x),y:ye(s.labelPosition.y),text:s.label,bounds:ln(s.labelPosition.bounds)}:void 0,route:t.debug?Kq(a,s,s.points,n):void 0})),groups:e.blocks.map((s,a)=>({id:s.id??`block#${a}:${s.type}`,...s.parentId===void 0?{}:{parentId:s.parentId},x:ye(s.bounds.x),y:ye(s.bounds.y),w:ye(s.bounds.width),h:ye(s.bounds.height),members:s.id===void 0?[]:r.get(s.id)??[],label:s.label})),bounds:{w:ye(e.width),h:ye(e.height)}}}function Kq(e,t,n,i){const r=i.get(t.from);const o=i.get(t.to);const s=n[0];const a=n[n.length-1];const l=r!==void 0&&s!==void 0&&Math.abs(s.x-r)<=1;const c=o!==void 0&&a!==void 0&&Math.abs(a.x-o)<=1;const d=!t.isSelf&&n.every(f=>Math.abs(f.y-t.y)<=1);const u=zf(n);return{family:"sequence",edgeIndex:e,routeClass:"family-layout",invariant:l&&c&&u?t.isSelf?"self-message":"lifeline-message":"unverified-family-route",bendCount:Gf(n),horizontal:d,sourceLifeline:l,targetLifeline:c,selfMessage:t.isSelf}}function ec(e){const t=new Map([...e.elements,...e.boundaries].map(i=>[i.id,i.id]));const n=new Map(e.relationships.map(i=>[i.id,i.id]));return{nodes:t,relationships:n,generated:gi([...t.keys(),...n.keys(),...e.legend?.entries.map(i=>i.id)??[]])}}function Hf(e){const t=`${e.external?"External ":""}${e.kind[0].toUpperCase()}${e.kind.slice(1)}${e.shape==="database"?": Database":e.shape==="queue"?": Queue":""}`;const n=e.style.techn??e.technology;return[e.label,`[${t}${n?`: ${n}`:""}]`,e.description,e.tags.length?`[tags: ${e.tags.join(", ")}]`:void 0,e.sprite?`[sprite: ${e.sprite}]`:void 0].filter(i=>i!==void 0&&i!=="").join("\n")}function jf(e){const t=e.kind==="deployment"?"Deployment Node":`${e.kind==="boundary"?"":`${e.kind[0].toUpperCase()}${e.kind.slice(1)} `}Boundary`;return[e.label,`[${t}${e.type?`: ${e.type}`:""}]`,e.description,e.tags.length?`[tags: ${e.tags.join(", ")}]`:void 0,e.sprite?`[sprite: ${e.sprite}]`:void 0].filter(n=>n!==void 0&&n!=="").join("\n")}function Yf(e,t){const n=t.index??(e.variant==="C4Dynamic"?String(t.order):void 0);return[`${n!==void 0?`${n}: `:""}${t.label}`,t.technology?`[${t.technology}]`:void 0,t.description,t.tags.length?`[tags: ${t.tags.join(", ")}]`:void 0,t.sprite?`[sprite: ${t.sprite}]`:void 0].filter(i=>i!==void 0&&i!=="").join("\n")}function M0(e,t){return e.statements.find(n=>n.id===t)?.span.line}function eA(e,t=Wp()){for(const o of[...e.elements,...e.boundaries,...e.relationships,...e.legend?.entries??[]]){const s=o.style;Lt({...s.bgColor===void 0?{}:{fill:s.bgColor},...s.borderColor===void 0&&s.lineColor===void 0?{}:{stroke:s.borderColor??s.lineColor},...s.fontColor===void 0&&s.textColor===void 0?{}:{color:s.fontColor??s.textColor}},`C4 ${o.id}`)}const n=ec(e);const i={direction:e.layout.direction??e.layout.hints[0]?.direction??e.relationships.find(o=>o.direction)?.direction??"LR",nodes:new Map,edges:[],subgraphs:[],classDefs:new Map,classAssignments:new Map,nodeStyles:new Map,linkStyles:new Map};const r=new Map;for(const o of e.boundaries)r.set(o.id,{id:n.nodes.get(o.id)??o.id,label:jf(o),nodeIds:[],children:[]});for(const o of e.boundaries){const s=r.get(o.id),a=o.parentId&&r.get(o.parentId);if(a)a.children.push(s);else i.subgraphs.push(s)}for(const o of e.elements){const s=n.nodes.get(o.id)??o.id,a=zs(o,t),l=Ro(o);i.nodes.set(s,{id:s,label:Hf(o),shape:l==="database"?"cylinder":l==="queue"?"subroutine":"rectangle",href:o.effectiveLink??o.link});if(o.parentId)r.get(o.parentId)?.nodeIds.push(s);i.nodeStyles.set(s,{...a.fill?{fill:a.fill}:{},...a.stroke?{stroke:a.stroke}:{},...a.text?{color:a.text}:{},...a.dashed?{"stroke-dasharray":"5 3"}:{}})}for(const o of e.relationships){const s=Yf(e,o);i.edges.push({id:n.relationships.get(o.id)??o.id,source:o.source,target:o.target,label:s,labelContent:{value:s,prepared:vt(s,"literal")},style:o.style.lineStyle==="dashed"||o.style.lineStyle==="dotted"?"dotted":"solid",hasArrowStart:o.bidirectional,hasArrowEnd:true});i.linkStyles.set(i.edges.length-1,Lt({...o.style.lineColor?{stroke:o.style.lineColor}:{},...o.style.textColor?{color:o.style.textColor}:{}},`UpdateRelStyle(${o.from}, ${o.to})`))}return i}var An=864e5;var Yg=1e4;function qf(e){return Math.floor(e/An)}function Xf(e){return qf(e)*An}function tc(e){return((qf(e)+4)%7+7)%7}var k0={sunday:0,monday:1,tuesday:2,wednesday:3,thursday:4,friday:5,saturday:6};function Jq(e,t,n,i=0,r=0,o=0,s=0){if(t<1||t>12||n<1||n>31)return null;if(i<0||i>23||r<0||r>59||o<0||o>59)return null;const a=Date.UTC(e,t-1,n,i,r,o,s);const l=new Date(a);if(l.getUTCFullYear()!==e||l.getUTCMonth()!==t-1||l.getUTCDate()!==n)return null;return a}var Qq=["YYYY","YY","MM","M","DD","D","HH","H","mm","m","ss","s","SSS","X","x"];var Zq=new Set(["HH","H","mm","m","ss","s","SSS","X","x"]);function nA(e){const t=[];let n=0;e:while(n<e.length){for(const i of Qq){if(e.startsWith(i,n)){t.push({kind:"field",field:i});n+=i.length;continue e}}t.push({kind:"literal",text:e[n]});n++}return t}function e3(e){return!nA(e).some(t=>t.kind==="field"&&Zq.has(t.field))}function Id(e,t){const n=nA(t);let i=0;const r={};const o=(s,a)=>{let l=0;while(l<a&&i+l<e.length&&e[i+l]>="0"&&e[i+l]<="9")l++;if(l<s)return null;const c=Number(e.slice(i,i+l));i+=l;return c};for(const s of n){if(s.kind==="literal"){if(e[i]!==s.text)return null;i++;continue}switch(s.field){case"YYYY":{const a=o(4,4);if(a===null)return null;r.year=a;break}case"YY":{const a=o(2,2);if(a===null)return null;r.year=2e3+a;break}case"MM":{const a=o(2,2);if(a===null)return null;r.month=a;break}case"M":{const a=o(1,2);if(a===null)return null;r.month=a;break}case"DD":{const a=o(2,2);if(a===null)return null;r.day=a;break}case"D":{const a=o(1,2);if(a===null)return null;r.day=a;break}case"HH":{const a=o(2,2);if(a===null)return null;r.hour=a;break}case"H":{const a=o(1,2);if(a===null)return null;r.hour=a;break}case"mm":{const a=o(2,2);if(a===null)return null;r.minute=a;break}case"m":{const a=o(1,2);if(a===null)return null;r.minute=a;break}case"ss":{const a=o(2,2);if(a===null)return null;r.second=a;break}case"s":{const a=o(1,2);if(a===null)return null;r.second=a;break}case"SSS":{const a=o(3,3);if(a===null)return null;r.msec=a;break}case"X":{const a=o(1,11);if(a===null)return null;r.unix=a;break}case"x":{const a=o(1,14);if(a===null)return null;r.unixMs=a;break}}}if(i!==e.length)return null;if(r.unixMs!==void 0)return r.unixMs;if(r.unix!==void 0)return r.unix*1e3;return Jq(r.year??1970,r.month??1,r.day??1,r.hour??0,r.minute??0,r.second??0,r.msec??0)}var t3={ms:1,s:1e3,m:6e4,h:36e5,d:An,w:7*An};function n3(e,t){const n=t.match(i0);if(!n)return null;const i=Number(n[1]);const r=n[2];if(!Number.isFinite(i))return null;if(r==="M"||r==="y"){const o=r==="y"?i*12:i;const s=Math.trunc(o);const a=o-s;const l=new Date(e);const c=l.getUTCMonth()+s;const d=new Date(Date.UTC(l.getUTCFullYear(),c,1,l.getUTCHours(),l.getUTCMinutes(),l.getUTCSeconds(),l.getUTCMilliseconds()));const u=new Date(Date.UTC(d.getUTCFullYear(),d.getUTCMonth()+1,0)).getUTCDate();d.setUTCDate(Math.min(l.getUTCDate(),u));let f=d.getTime();if(a>0)f+=Math.round(a*30*An);return f}return e+Math.round(i*t3[r])}function i3(e){return{dateFormat:e.dateFormat,inclusiveEndDates:e.inclusiveEndDates,excludes:e.excludes,includes:e.includes,weekendStart:e.weekendStart,weekStart:e.weekStart}}function tA(e,t){const n=new Set;const i=new Set;let r=false;for(const o of e){if(o.kind==="weekends"){r=true;continue}if(o.kind==="weekday"){i.add(k0[o.day]);continue}const s=Id(o.raw,t.dateFormat)??Id(o.raw,"YYYY-MM-DD");if(s===null){throw new Ni("GANTT_BAD_DATE",`Invalid calendar date "${o.raw}" for dateFormat "${t.dateFormat}"`)}n.add(qf(s))}return{days:n,weekdays:i,weekends:r}}var iA=new WeakMap;function r3(e){const t=tA(e.excludes,e);const n=tA(e.includes,e);const i=e.weekendStart==="friday"?[5,6]:[6,0];const r=o=>{const s=qf(o);const a=tc(o);const l=n.days.has(s)||n.weekdays.has(a)||n.weekends&&i.includes(a);if(l)return false;if(t.days.has(s))return true;if(t.weekdays.has(a))return true;if(t.weekends&&i.includes(a))return true;return false};if(e.excludes.length){let o;iA.set(r,()=>o??={weekdays:Array.from({length:7},(s,a)=>{if(n.weekdays.has(a)||n.weekends&&i.includes(a))return false;return t.weekdays.has(a)||t.weekends&&i.includes(a)}),exceptions:[...new Set([...t.days,...n.days])].sort((s,a)=>s-a)})}return r}function o3(e,t,n,i){let r=e+An;let o=t;let s=t;let a=false;let l=0;const c=t-e>=14*An&&Number.isSafeInteger(e)&&Number.isSafeInteger(t)&&Math.max(Math.abs(e),Math.abs(t))+Yg*An<Number.MAX_SAFE_INTEGER;const d=c?iA.get(n)?.():void 0;while(r<=o){if(d){const u=qf(r);let f=0,h=d.exceptions.length;while(f<h){const g=f+h>>>1;if(d.exceptions[g]<u)f=g+1;else h=g}const m=f<d.exceptions.length?d.exceptions[f]-u:Infinity;const p=Math.floor(Math.min(Math.floor((o-r)/An)+1,Yg-l,m)/7);if(p>0){const g=tc(r);let y=0,b,S;let x=a,k=d.weekdays[(g+6)%7];for(let C=0;C<7;C++){if(!x)b=y;if(!k)S=y;x=k=d.weekdays[(g+C)%7];if(x)y++}const w=p>1&&S!==void 0?(p-1)*y+S:b;if(w!==void 0)s=o+w*An;o+=p*y*An;r+=p*7*An;l+=p*7;a=x;continue}}if(++l>Yg){throw new Ni("GANTT_SCHEDULE_OVERFLOW",`Calendar exclusion walk exceeded ${Yg} days (is every day excluded?)`,i)}if(!a)s=o;a=n(r);if(a)o+=An;r+=An}return{end:o,renderEnd:s}}function s3(e,t,n){const i=[];if(e.start===void 0&&n)i.push(n.index);if(e.start?.kind==="after"){for(const r of e.start.refs){const o=t.get(r);if(!o)throw new Ni("GANTT_UNKNOWN_TASK_REF",`Task "${e.label}" starts after unknown id "${r}"`,e.line);i.push(o.index)}}if(e.end.kind==="until"){for(const r of e.end.refs){const o=t.get(r);if(!o)throw new Ni("GANTT_UNKNOWN_TASK_REF",`Task "${e.label}" runs until unknown id "${r}"`,e.line);i.push(o.index)}}return i}function a3(e,t,n){const i=new Array(e).fill(0);const r=[];const o=new Array(e).fill(0);const s=[];for(let a=0;a<e;a++){if(i[a]!==0)continue;i[a]=1;r.push(a);while(r.length){const l=r.at(-1);if(o[l]<t[l].length){const c=t[l][o[l]];o[l]=o[l]+1;if(i[c]===0){i[c]=1;r.push(c)}else if(i[c]===1){const d=r.indexOf(c);const u=r.slice(d).concat(c).map(n);throw new Ni("GANTT_DEPENDENCY_CYCLE",`Dependency cycle: ${u.join(" -> ")}`)}}else{r.pop();i[l]=2;s.push(l)}}}return s}function rA(e,t={}){const n=i3(e);const i=r3(n);const r=e3(e.dateFormat);const o=new Map;for(const m of e.tasks){if(m.id!==void 0)o.set(m.id,m)}const s=e.tasks.map((m,p)=>s3(m,o,e.tasks[p-1]));const a=a3(e.tasks.length,s,m=>e.tasks[m].id??e.tasks[m].label);const l=new Array(e.tasks.length);const c=m=>{if(l[m.index])return l[m.index];let p;if(m.start===void 0){const x=m.index>0?l[m.index-1]:void 0;if(!x){throw new Ni("GANTT_NO_START",`Task "${m.label}" has no start date and no previous task to follow`,m.line)}p=x.end}else if(m.start.kind==="after"){p=Math.max(...m.start.refs.map(x=>l[o.get(x).index].end))}else{const x=Id(m.start.raw,e.dateFormat);if(x===null){throw new Ni("GANTT_BAD_DATE",`Invalid start date "${m.start.raw}" for dateFormat "${e.dateFormat}"`,m.line)}p=x}let g;let y=false;if(m.end.kind==="until"){g=Math.min(...m.end.refs.map(x=>l[o.get(x).index].start));y=true}else if(m.end.kind==="duration"){const x=n3(p,m.end.raw);if(x===null){throw new Ni("GANTT_BAD_DURATION",`Invalid duration "${m.end.raw}"`,m.line)}g=x}else{const x=Id(m.end.raw,e.dateFormat);if(x===null){throw new Ni("GANTT_BAD_DATE",`Invalid end date "${m.end.raw}" for dateFormat "${e.dateFormat}"`,m.line)}g=n.inclusiveEndDates&&r?x+An:x;y=true}let b=g;if(!y&&n.excludes.length>0){const x=o3(p,g,i,m.line);g=x.end;b=x.renderEnd}if(g<p)g=p;if(b<p)b=p;if(b>g)b=g;const S={index:m.index,id:m.id,label:m.label,tags:m.tags,sectionIndex:m.sectionIndex,start:p,end:g,renderEnd:b,manualEnd:y,line:m.line};l[m.index]=S;return S};for(const m of a)c(e.tasks[m]);const d=l;if(d.length===0)return{tasks:d,timeMin:0,timeMax:0,dateOnly:r,isExcludedDay:i};let u=Infinity;let f=-Infinity;for(const m of d){u=Math.min(u,m.start);f=Math.max(f,m.renderEnd)}if(f===u)f=u+(r?An:36e5);let h;if(t.today!==void 0&&!e.todayMarker?.off){const m=Id(t.today,e.dateFormat)??Id(t.today,"YYYY-MM-DD");if(m===null){throw new Ni("GANTT_BAD_DATE",`Invalid clock value "${t.today}" for dateFormat "${e.dateFormat}"`)}h=m}return{tasks:d,timeMin:u,timeMax:f,dateOnly:r,today:h,analysis:l3(e,d,o,a),isExcludedDay:i}}function oA(e){const t=new Map;for(const o of e.tasks)if(o.id!==void 0)t.set(o.id,o);const n=[];const i=new Set;const r=(o,s,a)=>{const l=`${o}>${s}:${a}`;if(i.has(l))return;i.add(l);n.push({from:o,to:s,kind:a})};for(const o of e.tasks){if(o.start?.kind==="after"){for(const s of o.start.refs){const a=t.get(s);if(a)r(a.index,o.index,"after")}}if(o.end.kind==="until"){for(const s of o.end.refs){const a=t.get(s);if(a)r(o.index,a.index,"until")}}}return n}function l3(e,t,n,i){const r=[];const o=new Set;for(const g of e.tasks){if(g.start?.kind==="after"){for(const y of g.start.refs){const b=n.get(y);r.push({from:b.index,to:g.index});o.add(b.index)}}if(g.end.kind==="until")for(const y of g.end.refs)o.add(n.get(y).index)}if(r.length===0)return void 0;const s=Math.min(...t.map(g=>g.start));const a=Math.max(...t.map(g=>g.end));const l=t.map(()=>[]);for(const g of r)l[g.from].push(g.to);const c=new Array(t.length).fill(Number.NaN);for(let g=i.length-1;g>=0;g--){const y=i[g];const b=l[y];let S=a;for(const x of b){const k=t[x].end-t[x].start;S=Math.min(S,c[x]-k)}c[y]=S}const d={};const u=new Set;for(const g of r){u.add(g.from);u.add(g.to)}const f=[];for(const g of t){const y=c[g.index]-g.end;if(g.id!==void 0)d[g.id]=y;if(u.has(g.index)&&y===0&&g.id!==void 0)f.push(g.id)}const h=new Set(r.map(g=>g.to));const m=t.filter(g=>g.id!==void 0&&!h.has(g.index)).map(g=>g.id);const p=t.filter(g=>g.id!==void 0&&!o.has(g.index)).map(g=>g.id);return{criticalPathTaskIds:f,slackByTaskId:d,projectStart:s,projectEnd:a,entryTaskIds:m,sinkTaskIds:p}}var c3=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];var d3=["January","February","March","April","May","June","July","August","September","October","November","December"];var u3=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];var f3=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function C0(e,t){const n=new Date(e);const i=(a,l=2)=>String(a).padStart(l,"0");const r=()=>{const a=Date.UTC(n.getUTCFullYear(),0,1);return Math.floor((e-a)/An)+1};const o=a=>{const l=Date.UTC(n.getUTCFullYear(),0,1);const c=tc(l);const d=(7+c-a)%7;return Math.floor((r()-1+d)/7)};let s="";for(let a=0;a<t.length;a++){const l=t[a];if(l!=="%"){s+=l;continue}const c=t[++a];switch(c){case"Y":s+=String(n.getUTCFullYear());break;case"y":s+=i(n.getUTCFullYear()%100);break;case"m":s+=i(n.getUTCMonth()+1);break;case"d":s+=i(n.getUTCDate());break;case"e":s+=String(n.getUTCDate()).padStart(2," ");break;case"b":s+=c3[n.getUTCMonth()];break;case"B":s+=d3[n.getUTCMonth()];break;case"a":s+=u3[tc(e)];break;case"A":s+=f3[tc(e)];break;case"H":s+=i(n.getUTCHours());break;case"I":s+=i((n.getUTCHours()+11)%12+1);break;case"M":s+=i(n.getUTCMinutes());break;case"S":s+=i(n.getUTCSeconds());break;case"L":s+=i(n.getUTCMilliseconds(),3);break;case"p":s+=n.getUTCHours()<12?"AM":"PM";break;case"j":s+=i(r(),3);break;case"U":s+=i(o(0));break;case"W":s+=i(o(1));break;case"%":s+="%";break;default:s+=c===void 0?"%":`%${c}`}}return s}function aA({positioned:e,options:t}){const n=[...e.services.map(c=>({id:c.id,x:ye(c.x),y:ye(c.y),w:ye(c.width),h:ye(c.height),shape:"service",label:c.label,role:"box",...c.labelPosition?St(c.labelBlock,c.labelPosition.x,c.labelPosition.y,c,"start"):{}})),...e.junctions.map(c=>({id:c.id,x:ye(c.x),y:ye(c.y),w:ye(c.width),h:ye(c.height),shape:"circle",label:void 0,role:"mark"}))];const i=new Map;const r=[];const o=c=>{i.set(c.id,c);r.push({id:c.id,x:ye(c.x),y:ye(c.y),w:ye(c.width),h:ye(c.height),members:[...e.services.filter(d=>d.parentId===c.id).map(d=>d.id),...e.junctions.filter(d=>d.parentId===c.id).map(d=>d.id)],label:c.label,parentId:c.parentId});for(const d of c.children)o(d)};for(const c of e.groups)o(c);const s=new Map(e.services.map(c=>[c.id,c]));const a=new Map(e.junctions.map(c=>[c.id,c]));const l=e.edges.map((c,d)=>({id:`edge#${d}:${c.source.id}->${c.target.id}`,from:c.source.id,to:c.target.id,path:c.points.map(u=>[ye(u.x),ye(u.y)]),label:c.label&&c.labelPosition?{x:ye(c.labelPosition.x),y:ye(c.labelPosition.y),text:c.label,bounds:Yt(c.labelBlock,c.labelPosition.x,c.labelPosition.y)}:void 0,route:t.debug?h3(d,c,s,a,i):void 0}));return{version:1,nodes:n,edges:l,groups:r,bounds:{w:ye(e.width),h:ye(e.height)}}}function h3(e,t,n,i,r){const o=h=>{if(h.boundary==="group"){const m=n.get(h.id);return m?.parentId?r.get(m.parentId):void 0}return n.get(h.id)??i.get(h.id)};const s=o(t.source);const a=o(t.target);const l=t.points[0];const c=t.points[t.points.length-1];const d=!!(l&&s&&sA(l,s,t.source.side,1));const u=!!(c&&a&&sA(c,a,t.target.side,1));const f=zf(t.points);return{family:"architecture",edgeIndex:e,routeClass:"family-layout",invariant:d&&u&&f&&t.obstacleFree?"side-anchored":"unverified-family-route",bendCount:Gf(t.points),orthogonal:f,sourceSide:t.source.side,targetSide:t.target.side,sourceBoundary:t.source.boundary,targetBoundary:t.target.boundary,sourceAnchored:d,targetAnchored:u,placement:t.placement,sourceFacesTarget:t.sourceFacesTarget,targetFacesSource:t.targetFacesSource,obstacleFree:t.obstacleFree}}function sA(e,t,n,i){switch(n){case"L":return Math.abs(e.x-t.x)<=i&&e.y>=t.y-i&&e.y<=t.y+t.height+i;case"R":return Math.abs(e.x-(t.x+t.width))<=i&&e.y>=t.y-i&&e.y<=t.y+t.height+i;case"T":return Math.abs(e.y-t.y)<=i&&e.x>=t.x-i&&e.x<=t.x+t.width+i;case"B":return Math.abs(e.y-(t.y+t.height))<=i&&e.x>=t.x-i&&e.x<=t.x+t.width+i}}function lA({positioned:e,options:t}){const n=e.classes.map(s=>{const a=s.interfaceBox??s;return{id:s.id,x:ye(a.x),y:ye(a.y),w:zt(a.x,a.width),h:zt(a.y,a.height),shape:s.isInterface?"circle":"rectangle",label:s.label,...St(s.labelBlock,s.x+s.width/2,s.y+s.headerHeight/2+(s.annotation?6:0),{...s,height:s.headerHeight})}});const i=new Map(e.classes.map(s=>[s.id,s.interfaceBox??{x:s.x,y:s.y,width:s.width,height:s.height}]));const r=e.relationships.map((s,a)=>({id:`rel#${a}:${s.from}->${s.to}`,from:s.from,to:s.to,path:s.points.map(l=>[ye(l.x),ye(l.y)]),label:s.label&&s.labelPosition?{x:ye(s.labelPosition.x),y:ye(s.labelPosition.y-8),text:s.label,bounds:Yt(s.labelBlock,s.labelPosition.x,s.labelPosition.y-8)}:void 0,route:t.debug?Hg("class",a,s.points,i.get(s.from),i.get(s.to)):void 0}));const o=e.namespaces.map(s=>({id:s.id,x:ye(s.x),y:ye(s.y),w:zt(s.x,s.width),h:zt(s.y,s.height),members:[...s.classIds],label:s.label,parentId:s.parentId}));return{version:1,nodes:n,edges:r,groups:o,bounds:{w:ye(e.width),h:ye(e.height)}}}function P0(e,t,n,i){const r=[];const o=e.x-t.x;const s=e.y-t.y;const a=Math.sqrt(o*o+s*s);if(a===0)return[];const l=o/a;const c=s/a;const d=-c;const u=l;if(n==="parent"){const S=(x,k)=>({x:e.x-l*x+d*k,y:e.y-c*x+u*k});return[{geometry:{kind:"polygon",points:[S(0,0),S(6,4),S(12,0),S(6,-4)]},paint:{fill:"var(--bg)",...i}}]}const f=e.x-l*4;const h=e.y-c*4;const m=e.x-l*16;const p=e.y-c*16;const g=n==="many"||n==="zero-many";const y=n==="zero-one"||n==="zero-many";const b=(S,x)=>{const k=6;const w=S+d*k;const C=x+u*k;const R=S-d*k;const M=x-u*k;r.push({geometry:{kind:"line",x1:w,y1:C,x2:R,y2:M},paint:i})};if(n==="one"){b(f,h);b(f-l*4,h-c*4)}else if(n==="zero-one"){b(f,h)}if(g){const S=7;const x=f;const k=h;const w=x+d*S;const C=k+u*S;r.push({geometry:{kind:"line",x1:w,y1:C,x2:m,y2:p},paint:i});r.push({geometry:{kind:"line",x1:x,y1:k,x2:m,y2:p},paint:i});const R=x-d*S;const M=k-u*S;r.push({geometry:{kind:"line",x1:R,y1:M,x2:m,y2:p},paint:i});if(n==="many"){b(e.x-l*20,e.y-c*20)}}if(y){const S=g?20:12;const x=e.x-l*S;const k=e.y-c*S;r.push({geometry:{kind:"circle",cx:x,cy:k,r:4},paint:{fill:"var(--bg)",...i}})}return r}function To(e,t,n,i){const r={stroke:"#000",strokeWidth:String(i+.25)};const o=P0(e,t,n,r);const s=[];for(const a of o){const l=Pi({kind:"shape",id:"cardinality",role:"cardinality",geometry:a.geometry,paint:a.paint});if(!l||!Object.values(l).every(Number.isFinite))return void 0;s.push(l)}return s}function Ga(e,t){const n=To({x:0,y:0},{x:1,y:0},e,t);return n?.reduce((i,r)=>ra(i,r),void 0)}function E0(e,t){const n=e.width+8,i=e.height+6;return{kind:"rect",x:t.x-n/2,y:t.y-i/2,width:n,height:i,rx:2,ry:2}}function R0(e,t){return Pi({kind:"shape",id:"label-pill",role:"chrome",geometry:E0(e,t),paint:{fill:"#000",stroke:"#000",strokeWidth:"0.5"}})}var Fd=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"}};var Nt=class extends Error{code="ER_ROUTE_BLOCKED";constructor(t,n){super(`ER_ROUTE_BLOCKED: no clear frame corridor from ${t} to ${n}`);this.name="ErRouteGeometryError"}};var es=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"}};import{elkConstructor as m3}from"#elk-constructor";var v0=null;var Uf=null;function p3(){if(v0)return;const e=m3();const t=[];const n=globalThis.setTimeout;globalThis.setTimeout=(o,s)=>{if(s===0){t.push(o);return 0}return n(o,s)};const i=globalThis;const r=typeof i.document!=="undefined";if(!r)i.document={};v0=new e;if(!r)delete i.document;globalThis.setTimeout=n;t.forEach(o=>o());Uf=v0.worker.worker}function Ha(e){return ei("elk",()=>b3(e))}var cA=globalThis;var g3=(cA.process?.env?.AGENTIC_MERMAID_ELK_CACHE??cA.AGENTIC_MERMAID_ELK_CACHE)!=="0";var y3=64;var x3=1024*1024;var T0=8*1024*1024;var dA=new bu(y3,T0);function b3(e){pP(e);if(!g3){Ht("elk-layout","bypass","disabled");return uA(e)}const t=S3(e);const n=dA.get(t);if(n){Ht("elk-layout","hit");return structuredClone(n)}Ht("elk-layout","miss");const i=uA(e);if(t.length<=x3){const r=Math.max(t.length*8,t.length*2+ku(i,T0));if(r<=T0)dA.set(t,structuredClone(i),r);else Ht("elk-layout","store-skipped","weight-limit")}else Ht("elk-layout","store-skipped","key-limit");return i}function S3(e){return JSON.stringify(e,(t,n)=>{if(n===void 0)return"\0undefined";if(typeof n==="number"&&!Number.isFinite(n))return`\0${n}`;if(typeof n==="string"&&n.startsWith("\0"))return`\0${n}`;return n})}function uA(e){p3();let t;let n;const i=Uf.onmessage;Uf.onmessage=r=>{if(r.data.error){n=r.data.error}else{t=r.data.data}};Uf.dispatcher.saveDispatch({data:{id:0,cmd:"layout",graph:e}});Uf.onmessage=i;if(n)throw n;if(!t)throw new Error("ELK layout did not return synchronously");return t}function qs(e){let t;for(const n of["x","y"]){let i=e[0]?.[n];for(let r=1;r<e.length;r++){const o=e[r][n];if(o===i)continue;if(i!==void 0&&w3(o,i)){t??=e.map(s=>({...s}));t[r][n]=i}else i=o}}return t??e}function w3(e,t){return Math.abs(e-t)<=Math.min(1e-6,8*Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t)))}function Vf(e,t,n){for(let i=0;i<e.length;i++)for(let r=0;r<t.length;r++){n?.(1);const o=e[i],s=t[r];if(o.kind==="circle"){if(s.kind==="circle"){const a=o.cx-s.cx,l=o.cy-s.cy,c=o.r+s.r;if(o.r>0&&s.r>0&&a*a+l*l<c*c)return true}else if(fA(o.cx,o.cy,o.r,s.points,n))return true}else if(s.kind==="circle"){if(fA(s.cx,s.cy,s.r,o.points,n))return true}else if(M3(o.points,s.points,n))return true}return false}function M3(e,t,n){if(e.length<3||t.length<3)return false;const i=e[0];let r=0;for(let o=0;o<2;o++){const s=o===0?e:t;for(let a=0;a<s.length;a++){n?.(1);const l=s[a],c=s[(a+1)%s.length],d=l.y-c.y,u=c.x-l.x;if(d===0&&u===0)continue;r++;let f=Infinity,h=-Infinity,m=Infinity,p=-Infinity;for(let g=0;g<e.length;g++){n?.(1);const y=e[g],b=(y.x-i.x)*d+(y.y-i.y)*u;f=Math.min(f,b);h=Math.max(h,b)}for(let g=0;g<t.length;g++){n?.(1);const y=t[g],b=(y.x-i.x)*d+(y.y-i.y)*u;m=Math.min(m,b);p=Math.max(p,b)}if(Math.min(h,p)<=Math.max(f,m))return false}}return r>0}function fA(e,t,n,i,r){if(!(n>0)||i.length<3)return false;let o=0,s=true,a=0,l=Infinity;const c=i[0];for(let d=0;d<i.length;d++){r?.(1);const u=i[d],f=i[(d+1)%i.length],h=f.x-u.x,m=f.y-u.y,p=h*(t-u.y)-m*(e-u.x);a+=(u.x-c.x)*(f.y-c.y)-(u.y-c.y)*(f.x-c.x);if(p!==0){if(o!==0&&Math.sign(p)!==o)s=false;o||=Math.sign(p)}const g=h*h+m*m,y=g>0?Math.max(0,Math.min(1,((e-u.x)*h+(t-u.y)*m)/g)):0;l=Math.min(l,(u.x+y*h-e)**2+(u.y+y*m-t)**2)}return a!==0&&(s||l<n*n)}function li(e,t,n){return e.x===t.x?e.x>n.x&&e.x<n.x+n.width&&Math.max(e.y,t.y)>n.y&&Math.min(e.y,t.y)<n.y+n.height:e.y>n.y&&e.y<n.y+n.height&&Math.max(e.x,t.x)>n.x&&Math.min(e.x,t.x)<n.x+n.width}function Ki(e,t,n){return(t.x===n.x?Math.abs(e.x-t.x)<1e-7:Math.abs(e.y-t.y)<1e-7)&&e.x>=Math.min(t.x,n.x)&&e.x<=Math.max(t.x,n.x)&&e.y>=Math.min(t.y,n.y)&&e.y<=Math.max(t.y,n.y)}function Xg(e,t){return e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height}function k3(e,t,n,i){return e.x===t.x&&n.x===i.x&&Math.abs(e.x-n.x)<=.5&&Math.min(Math.max(e.y,t.y),Math.max(n.y,i.y))-Math.max(Math.min(e.y,t.y),Math.min(n.y,i.y))>.01||e.y===t.y&&n.y===i.y&&Math.abs(e.y-n.y)<=.5&&Math.min(Math.max(e.x,t.x),Math.max(n.x,i.x))-Math.max(Math.min(e.x,t.x),Math.min(n.x,i.x))>.01}function Nd(e,t,n,i,r){if(e){if(r?.(3)===false)return void 0;e.candidateSegment=t;e.peerIndex=n;e.peerSegment=i}return false}function Us(e,t="complete"){return t==="complete"&&e.maximumEdgeStrokeWidth!==void 0&&e.maximumEdgeBendRadius===0?1:3}function C3(e,t,n,i,r){if(e.x!==t.x&&e.y!==t.y||n.x!==i.x&&n.y!==i.y)return void 0;return yA(e,t,n,i,r)}function yA(e,t,n,i,r){const o=(Math.abs(e.x)+Math.abs(e.y)+Math.abs(t.x)+Math.abs(t.y)+Math.abs(n.x)+Math.abs(n.y)+Math.abs(i.x)+Math.abs(i.y)+r)*1e-10+1e-9,s=r+o,a=Math.min(e.x,t.x)-Math.max(n.x,i.x),l=Math.min(n.x,i.x)-Math.max(e.x,t.x),c=Math.min(e.y,t.y)-Math.max(n.y,i.y),d=Math.min(n.y,i.y)-Math.max(e.y,t.y);return Number.isFinite(s)&&Number.isFinite(a)&&Number.isFinite(l)&&Number.isFinite(c)&&Number.isFinite(d)&&(a>s||l>s||c>s||d>s)}function L0(e,t,n,i){if(n?.(1)===false)return void 0;const r=t.get(e);if(r)return r;if(n?.(128)===false||i?.(14)===false)return void 0;const o=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(e);const s={n:BigInt(o[1]+o[2]+(o[3]??"")),e:Number(o[4]??0)-(o[3]?.length??0)};if(i?.(2)===false||n?.(1)===false)return void 0;t.set(e,s);return s}function xA(e,t,n,i,r,o=false,s){if(i?.(8)===false)return void 0;const a=Number(e),l=Number(t),c=Number(n),d=Math.abs(a-l)*(o?2:1)-c;if(Math.abs(d)>8*Number.EPSILON*Math.max(1,Math.abs(a),Math.abs(l),c))return d<0?-1:1;let u,f,h;if(s){const b=L0(e,s,i,r);if(!b)return void 0;u=b;const S=L0(t,s,i,r);if(!S)return void 0;f=S;const x=L0(n,s,i,r);if(!x)return void 0;h=x}else{if(i?.(384)===false||r?.(42)===false)return void 0;const b=S=>{const x=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(S);return{n:BigInt(x[1]+x[2]+(x[3]??"")),e:Number(x[4]??0)-(x[3]?.length??0)}};u=b(e);f=b(t);h=b(n)}const m=Math.min(u.e,f.e,h.e);if(i?.(32+u.e-m+f.e-m+h.e-m)===false)return void 0;const p=u.n*10n**BigInt(u.e-m)-f.n*10n**BigInt(f.e-m),g=p<0n?-p:p;const y=g*(o?2n:1n)-h.n*10n**BigInt(h.e-m);return y<0n?-1:y>0n?1:0}function $d(e,t,n,i,r){const o=xA(e,t,n,i,r);return o===void 0?void 0:o<0}function P3(e,t,n,i,r,o,s,a){const l=e.x===t.x;if(n.x===i.x!==l||!l&&(e.y!==t.y||n.y!==i.y))return false;if(s?.(2)===false)return void 0;const c=l?e.x:e.y,d=l?n.x:n.y,u=Math.abs(c-d),f=(Math.abs(c)+Math.abs(d)+r)*1e-10+1e-9;if(u>r+f)return false;const h=l?e.y:e.x,m=l?t.y:t.x,p=l?n.y:n.x,g=l?i.y:i.x,y=Math.min(Math.max(h,m),Math.max(p,g))-Math.max(Math.min(h,m),Math.min(p,g)),b=(Math.abs(h)+Math.abs(m)+Math.abs(p)+Math.abs(g))*1e-10+1e-9;if(y<-b)return false;if(y===0){if(s?.(2)===false)return void 0;if(Math.abs(h-m)>2*b&&Math.abs(p-g)>2*b)return false}if(s?.(2)===false)return void 0;if(u<r-f&&y>b)return true;if(s?.(6)===false)return void 0;if(!Number.isFinite(c)||!Number.isFinite(d)||!Number.isFinite(h)||!Number.isFinite(m)||!Number.isFinite(p)||!Number.isFinite(g))return void 0;if(a?.(10)===false)return void 0;if(s?.(256)===false)return void 0;const S=$d(Ue(c),Ue(d),o,s,a);if(S!==true)return S;if(a?.(20)===false)return void 0;if(s?.(512)===false)return void 0;const x=Number(Ue(h)),k=Number(Ue(m)),w=Number(Ue(p)),C=Number(Ue(g)),R=Math.max(Math.min(x,k),Math.min(w,C)),M=Math.min(Math.max(x,k),Math.max(w,C));return R<M}function ja(e,t){return e.x===t.x&&e.y===t.y}function Xs(e,t,n,i,r,o,s,a){if(o?.(3)===false)return void 0;const l=i-t;if(!l)return e<n;if(e===n)return l>0;if(e>n?l<0:l>0)return e<n;if(o?.(6)===false)return void 0;const c=Number(r),d=2*(e-n)-l*c,u=32*Number.EPSILON*Math.max(1,Math.abs(e)+Math.abs(n)+Math.abs(l*c));if(Number.isFinite(d)&&Math.abs(d)>u)return d<0;let f,h;if(a){const p=hA(e,a,o,s);if(p===void 0)return void 0;f=p;const g=hA(n,a,o,s);if(g===void 0)return void 0;h=g}else{if(s?.(10)===false||o?.(64)===false)return void 0;f=String(e);h=String(n)}const m=xA(f,h,r,o,s,Math.abs(l)===1,a?.parts);return m===void 0?void 0:l>0?m<0:m>0}function Kf(e,t,n,i,r,o){if(o){if(o.width!==void 0){if(i?.(1)===false)return void 0;const h=o.width,m=h/2,p=(Math.abs(e.x0)+Math.abs(e.x1)+Math.abs(e.y0)+Math.abs(e.y1)+Math.abs(t.x0)+Math.abs(t.x1)+Math.abs(t.y0)+Math.abs(t.y1)+h)*1e-10+1e-9;if(e.x0-t.x1+(e.ox0-t.ox1)*m>p||t.x0-e.x1+(t.ox0-e.ox1)*m>p||e.y0-t.y1+(e.oy0-t.oy1)*m>p||t.y0-e.y1+(t.oy0-e.oy1)*m>p)return false}if(i?.(4)===false)return void 0;const c=e.ox0===t.ox1,d=t.ox0===e.ox1,u=e.oy0===t.oy1,f=t.oy0===e.oy1;if(c){if(i?.(1)===false)return void 0;if(!(e.x0<t.x1))return false}if(d){if(i?.(1)===false)return void 0;if(!(t.x0<e.x1))return false}if(u){if(i?.(1)===false)return void 0;if(!(e.y0<t.y1))return false}if(f){if(i?.(1)===false)return void 0;if(!(t.y0<e.y1))return false}if(!c){const h=Xs(e.x0,e.ox0,t.x1,t.ox1,n,i,r,o);if(h!==true)return h}if(!d){const h=Xs(t.x0,t.ox0,e.x1,e.ox1,n,i,r,o);if(h!==true)return h}if(!u){const h=Xs(e.y0,e.oy0,t.y1,t.oy1,n,i,r,o);if(h!==true)return h}if(!f)return Xs(t.y0,t.oy0,e.y1,e.oy1,n,i,r,o);return true}const s=Xs(e.x0,e.ox0,t.x1,t.ox1,n,i,r,o);if(s!==true)return s;const a=Xs(t.x0,t.ox0,e.x1,e.ox1,n,i,r,o);if(a!==true)return a;const l=Xs(e.y0,e.oy0,t.y1,t.oy1,n,i,r,o);if(l!==true)return l;return Xs(t.y0,t.oy0,e.y1,e.oy1,n,i,r,o)}function Vi(e,t,n){if(t?.(2)===false)return void 0;if(Number.isSafeInteger(e.x)&&Number.isSafeInteger(e.y))return e;if(t?.(66)===false||n?.(13)===false)return void 0;if(!Number.isFinite(e.x)||!Number.isFinite(e.y))return void 0;let i=String(e.x),r=String(e.y);if(i.length>=14&&Mu.test(i)){if(n?.(5)===false||t?.(128)===false)return void 0;i=Ue(e.x)}if(r.length>=14&&Mu.test(r)){if(n?.(5)===false||t?.(128)===false)return void 0;r=Ue(e.y)}return{x:Number(i),y:Number(r)}}function A0(e,t,n){if(n?.(9)===false)return void 0;if(e.x===t.x&&e.y===t.y)return void 0;if(e.x===t.x)return{x0:e.x,x1:e.x,y0:Math.min(e.y,t.y),y1:Math.max(e.y,t.y),ox0:-1,ox1:1,oy0:0,oy1:0};if(e.y===t.y)return{x0:Math.min(e.x,t.x),x1:Math.max(e.x,t.x),y0:e.y,y1:e.y,ox0:0,ox1:0,oy0:-1,oy1:1};return void 0}function I0(e,t,n,i,r){if(i?.(8)===false)return void 0;const o=Math.sign(t.x-e.x),s=Math.sign(t.y-e.y),a=Math.sign(n.x-t.x),l=Math.sign(n.y-t.y),c=o*l-s*a;if(!c)return o*a+s*l<0?void 0:false;if(e.x!==t.x&&e.y!==t.y||t.x!==n.x&&t.y!==n.y)return void 0;if(r?.(9)===false)return void 0;const d=c>0?-1:1,u=(-s-l)*d,f=(o+a)*d;return{x0:t.x,x1:t.x,y0:t.y,y1:t.y,ox0:Math.min(0,u),ox1:Math.max(0,u),oy0:Math.min(0,f),oy1:Math.max(0,f)}}function hA(e,t,n,i){if(n?.(1)===false)return void 0;const r=t.texts.get(e);if(r!==void 0)return r;if(i?.(5)===false||n?.(32)===false)return void 0;const o=String(e);if(i?.(2)===false||n?.(1)===false)return void 0;t.texts.set(e,o);return o}function E3(e,t,n){if(n?.(2)===false)return void 0;return t.rows[e]}function nc(e,t,n,i,r,o){if(r?.(3)===false)return void 0;return i.rows[t]?.[n]}function mA(e,t,n,i,r,o,s,a){if(s?.(2)===false)return void 0;let l=o.strips[t];if(!l){if(a?.(e.length+1)===false)return void 0;l=o.strips[t]=new Array(e.length)}const c=l[n];if(c)return c;const d=A0(i,r,a);if(!d)return void 0;if(s?.(1)===false)return void 0;l[n]=d;return d}function pA(e,t,n,i,r,o,s,a){if(s?.(2)===false)return void 0;let l=o.joins[t];if(!l){if(a?.(e.length+1)===false)return void 0;l=o.joins[t]=new Array(e.length)}const c=l[n];if(c!==void 0)return c;const d=nc(e,t,n+1,o,s,a);if(!d)return void 0;const u=I0(i,r,d,s,a);if(u===void 0)return void 0;if(s?.(1)===false)return void 0;l[n]=u;return u}function qg(e,t,n,i,r,o,s,a=-1){let l=t-1,c=t,d,u;while(l>=0){if(r?.(1)===false)return void 0;d=i?s?nc(e,a,l,s,r,o):Vi(e[l],r,o):e[l];if(!d)return void 0;if(d.x!==n.x||d.y!==n.y)break;l--}while(c<e.length){if(r?.(1)===false)return void 0;u=i?s?nc(e,a,c,s,r,o):Vi(e[c],r,o):e[c];if(!u)return void 0;if(u.x!==n.x||u.y!==n.y)break;c++}if(l<0||c>=e.length||!d||!u)return false;return d.x===n.x&&u.x===n.x&&Math.min(d.y,u.y)<n.y&&n.y<Math.max(d.y,u.y)||d.y===n.y&&u.y===n.y&&Math.min(d.x,u.x)<n.x&&n.x<Math.max(d.x,u.x)}function R3(e,t,n,i,r,o,s,a,l,c,d,u){const f=i.edges[t];let h,m;let p;if(d){const g=E3(t,d,a);if(!g)return void 0;p=g}else{if(l?.(e.length+2)===false)return void 0;p=new Array(e.length)}for(let g=0;g<s.length;g++){if(a?.(1)===false)return void 0;const y=s[g],b=n[y],S=i.edges[y];if(d&&a?.(1)===false)return void 0;let x=d?.rows[y];const k=u?.[y];let w=0;for(let C=1;u?!!k&&w<k.length:C<e.length;C++)for(let R=1;u?w<k.length:R<b.points.length;R++){const M=w;if(u){if(a?.(2)===false)return void 0;C=k[w];R=k[w+1];w+=3}if(a?.(1)===false)return void 0;const P=e[C-1],E=e[C],v=b.points[R-1],L=b.points[R],T=(Math.abs(P.x)+Math.abs(P.y)+Math.abs(E.x)+Math.abs(E.y)+Math.abs(v.x)+Math.abs(v.y)+Math.abs(L.x)+Math.abs(L.y)+r)*1e-10+1e-9,A=r+T;if(Math.min(P.x,E.x)-Math.max(v.x,L.x)>A||Math.min(v.x,L.x)-Math.max(P.x,E.x)>A||Math.min(P.y,E.y)-Math.max(v.y,L.y)>A||Math.min(v.y,L.y)-Math.max(P.y,E.y)>A)continue;const $=P.x===E.x,_=v.x===L.x;if($!==_&&(P.x===E.x||P.y===E.y)&&(v.x===L.x||v.y===L.y)){const H=$?P.x:v.x,j=$?v.y:P.y,q=$?v:P,X=$?L:E,V=$?P:v,ee=$?E:L;if(H>Math.min(q.x,X.x)+A&&H<Math.max(q.x,X.x)-A&&j>Math.min(V.y,ee.y)+A&&j<Math.max(V.y,ee.y)-A)continue}if(!x){if(d)return void 0;if(l?.(b.points.length+1)===false)return void 0;x=new Array(b.points.length)}if(a?.(4)===false)return void 0;const z=p[C-1]??(p[C-1]=d?nc(e,t,C-1,d,a,l):Vi(P,a,l));if(!z)return void 0;const F=p[C]??(p[C]=d?nc(e,t,C,d,a,l):Vi(E,a,l));if(!F)return void 0;const G=x[R-1]??(x[R-1]=d?nc(b.points,y,R-1,d,a,l):Vi(v,a,l));if(!G)return void 0;const I=x[R]??(x[R]=d?nc(b.points,y,R,d,a,l):Vi(L,a,l));if(!I)return void 0;const D=d?mA(e,t,C,z,F,d,a,l):A0(z,F,l);if(!D)return void 0;const B=d?mA(b.points,y,R,G,I,d,a,l):A0(G,I,l);if(!B)return void 0;const Y=z.x===F.x,W=G.x===I.x;if(d?.contactOnly&&Y===W){if(a?.(2)===false)return void 0;const H=Math.max(Y?Math.min(z.y,F.y):Math.min(z.x,F.x),Y?Math.min(G.y,I.y):Math.min(G.x,I.x)),j=Math.min(Y?Math.max(z.y,F.y):Math.max(z.x,F.x),Y?Math.max(G.y,I.y):Math.max(G.x,I.x));if(H<j){const q=Y?z.x:z.y,X=Y?G.x:G.y,V=Xs(Math.max(q,X),-2,Math.min(q,X),0,o,a,l,d);if(V!==false)return V===void 0?void 0:Nd(c,C,y,R,a)}}else if(Y===W&&(P.x!==E.x&&P.y!==E.y||v.x!==L.x&&v.y!==L.y)){const H=Kf(D,B,o,a,l,d);if(H!==false)return H===void 0?void 0:Nd(c,C,y,R,a)}if(Y!==W){const H=Kf(D,B,o,a,l,d);if(H===void 0)return void 0;if(H){if(l?.(6)===false)return void 0;const j={x:Y?P.x:v.x,y:Y?v.y:P.y},q={x:Y?z.x:G.x,y:Y?G.y:z.y};let X=false;if(d?.contactOnly&&d.numericSeed&&(P.x!==E.x&&P.y!==E.y||v.x!==L.x&&v.y!==L.y)){if(a?.(1)===false)return void 0;if(k?.[M+2]===1){if(!h){if(l?.(20)===false)return void 0;h=[{points:p},{points:x}];m=[{a:z,b:F,edgeIndex:0,pointIndex:C-1},{a:G,b:I,edgeIndex:1,pointIndex:R-1}]}if(a?.(7+p.length+x.length)===false||l?.(4)===false)return void 0;h[1].points=x;const J=m[0],ae=m[1];J.a=z;J.b=F;J.pointIndex=C-1;ae.a=G;ae.b=I;ae.pointIndex=R-1;X=!!cd(J,ae,h)}}else{const J=qg(e,C,j,false,a,l);if(J===void 0)return void 0;const ae=qg(b.points,R,j,false,a,l);if(ae===void 0)return void 0;if(J&&ae){const Q=qg(e,C,q,true,a,l,d,t);if(Q===void 0)return void 0;const K=qg(b.points,R,q,true,a,l,d,y);if(K===void 0)return void 0;X=Q&&K}}const V=e[0],ee=e.at(-1),re=b.points[0],U=b.points.at(-1);if(a?.(4)===false)return void 0;const te=C===1&&R===1&&f.source===S.source&&ja(j,V)&&ja(j,re)||C===1&&R===b.points.length-1&&f.source===S.target&&ja(j,V)&&ja(j,U)||C===e.length-1&&R===1&&f.target===S.source&&ja(j,ee)&&ja(j,re)||C===e.length-1&&R===b.points.length-1&&f.target===S.target&&ja(j,ee)&&ja(j,U);if(!X&&!te)return Nd(c,C,y,R,a)}}let O=false,N=false;if(C+1<e.length){if(d){const H=pA(e,t,C,z,F,d,a,l);if(H===void 0)return void 0;O=H}else{if(a?.(1)===false)return void 0;const H=p[C+1]??(p[C+1]=Vi(e[C+1],a,l));if(!H)return void 0;const j=I0(z,F,H,a,l);if(j===void 0)return void 0;O=j}}if(R+1<b.points.length){if(d){const H=pA(b.points,y,R,G,I,d,a,l);if(H===void 0)return void 0;N=H}else{if(a?.(1)===false)return void 0;const H=x[R+1]??(x[R+1]=Vi(b.points[R+1],a,l));if(!H)return void 0;const j=I0(G,I,H,a,l);if(j===void 0)return void 0;N=j}}if(O){const H=Kf(O,B,o,a,l,d);if(H!==false)return H===void 0?void 0:Nd(c,C,y,R,a)}if(N){const H=Kf(D,N,o,a,l,d);if(H!==false)return H===void 0?void 0:Nd(c,C,y,R,a)}if(O&&N){const H=Kf(O,N,o,a,l,d);if(H!==false)return H===void 0?void 0:Nd(c,C,y,R,a)}}}return true}function gA(e){for(let t=0;t<e.length;t++){const n=e[t];if(!Number.isFinite(n.x)||!Number.isFinite(n.y)||t&&n.x!==e[t-1].x&&n.y!==e[t-1].y)return false}return true}function ts(e,t,n,i,r,o,s,a=3,l=false){return F0(e,t,n,i,r,o,true,s,a,l)}function v3(e,t,n){let i=false;for(const u of e)for(let f=1;f<u.points.length;f++){if(t?.(1)===false)return void 0;const h=u.points[f-1],m=u.points[f];if(h.x!==m.x&&h.y!==m.y)i=true}if(!i)return false;if(n?.(e.length+18)===false)return void 0;const r=new Array(e.length),o=[],s=[],a=[],l=[];for(let u=0;u<e.length;u++){const f=e[u].points;if(t?.(1)===false||n?.(5*f.length+5)===false)return void 0;const h=new Array(f.length),m=new Array(f.length);for(let p=0;p<f.length;p++){if(t?.(3)===false)return void 0;const g=f[p],y=Vi(g,t,n);if(!y)return void 0;h[p]={x:g.x,y:g.y};if(y===g){if(n?.(3)===false)return void 0;m[p]={x:y.x,y:y.y}}else m[p]=y}r[u]={raw:h,points:m};for(let p=0;p+1<m.length;p++){if(t?.(4)===false)return void 0;const g=m[p],y=m[p+1];if(g.x===y.x===(g.y===y.y))return false;if(n?.(15)===false)return void 0;const b={owner:u,segment:p},S=g.x===y.x;(S?s:o).push({key:S?g.x:g.y,piece:b});(S?l:a).push({key:S?g.y:g.x,piece:b},{key:S?y.y:y.x,piece:b})}}const c={},d=(u,f)=>{if(t?.(1)===false)throw c;return u.key-f.key||u.piece.owner-f.piece.owner||u.piece.segment-f.piece.segment};try{for(const u of[o,s,a,l])u.sort(d)}catch(u){if(u===c)return void 0;throw u}return{routes:r,horizontal:o,vertical:s,horizontalEnds:a,verticalEnds:l}}function bA(e,t,n,i,r=false,o){if(!o&&t.maximumEdgeStrokeWidth!==void 0&&t.maximumEdgeBendRadius===0){const k=v3(e,n,i);if(k===void 0)return void 0;if(k)o=k}if(!o){if(r)for(const k of e){let w;for(const C of k.points){const R=Vi(C,n,i);if(!R)return void 0;if(n?.(2)===false)return void 0;if(w&&(R.x===w.x&&R.y===w.y||R.x!==w.x&&R.y!==w.y))return false;w=R}}if(i?.(1)===false)return void 0;return(k,w)=>{if(n?.(e.length)===false)return false;let C=0;for(let P=0;P<e.length;P++)if(P!==k&&e[P].style!=="invisible")C+=Math.max(0,e[P].points.length-1);const R=e[k].points,M=Us(t);if(n?.(M*Math.max(0,R.length-1)*C+R.length+C+e.length)===false)return false;return ts(R,k,e,t,n,i,w,M,true)!==void 0}}if(n?.(e.length+1)===false)return void 0;if(o.routes.length!==e.length)return false;let s=0;for(const k of e)s+=Math.max(0,k.points.length-1);if(i?.(4*e.length+28+2*s+4)===false)return void 0;const a=new Array(e.length),l=new Array(e.length),c=[],d=[];let u=0,f=0;for(let k=0;k<e.length;k++){if(n?.(3)===false)return void 0;const w=e[k].points,C=o.routes[k];l[k]=f;f+=Math.max(0,w.length-1);if(w.length!==C.raw.length||w.length!==C.points.length)return false;a[k]=C.points;let R;for(let M=0;M<w.length;M++){if(n?.(7)===false)return void 0;const P=w[M],E=C.raw[M],v=C.points[M];if(P.x!==E.x||P.y!==E.y||!Number.isFinite(P.x)||!Number.isFinite(P.y)||!Number.isFinite(v.x)||!Number.isFinite(v.y))return false;if(R&&(v.x===R.x&&v.y===R.y||v.x!==R.x&&v.y!==R.y))return false;R=v;u+=Math.abs(P.x)+Math.abs(P.y)}}const h=t.maximumEdgeStrokeWidth;let m,p;if(Number.isSafeInteger(h)&&h>0){if(i?.(4)===false||n?.(h<10?2:17)===false)return void 0;m=h;p=String(h)}else{if(i?.(5)===false||n?.(128)===false)return void 0;p=Ue(h);m=Number(p)}if(!Number.isFinite(m)||m<=0||t.maximumEdgeBendRadius!==0)return false;const g=Math.max(m,pp)+(u+m)*1e-10+1e-9,y=pp+(u+m)*1e-10+1e-9,b=u>Math.sqrt(Number.MAX_VALUE)/4,S=new Uint8Array(s);for(let k=0;k<2;k++)for(const w of k?o.horizontal:o.vertical){if(n?.(3)===false)return void 0;const C=e[w.piece.owner].points,R=o.routes[w.piece.owner].points,M=T3(C,R,w.piece.segment,y,b,n);if(M===void 0)return void 0;if(M){if(i?.(1)===false||n?.(1)===false)return void 0;S[l[w.piece.owner]+w.piece.segment]=1;(k?c:d).push(w)}}const x={rows:a,rangeStarts:new Map,parts:new Map,texts:new Map,strips:new Array(e.length),joins:new Array(e.length),numericSeed:o,width:m,widthText:p,margin:g,offsets:l,driftHorizontal:c,driftVertical:d,seen:new Uint32Array(s),fullCandidates:S,epoch:0,contactOnly:true};return(k,w)=>F0(e[k].points,k,e,t,n,i,true,w,1,false,x)!==void 0}function Jf(e,t,n,i,r,o){return F0(e,t,n,i,r,o,false)}function T3(e,t,n,i,r,o){if(o?.(4)===false)return void 0;const s=e[n],a=e[n+1],l=t[n],c=t[n+1];if(r||s.x!==a.x&&s.y!==a.y)return true;for(let d=0;d<2;d++){if(o?.(2)===false)return void 0;const u=d?e.length-1:0,f=e[u],h=t[u];if(f.x===s.x&&f.y===s.y&&h.x===l.x&&h.y===l.y||f.x===a.x&&f.y===a.y&&h.x===c.x&&h.y===c.y)continue;for(let m=0;m<2;m++){if(o?.(1)===false)return void 0;const p=m?l:s,g=m?c:a,y=m?h:f;if(y.x>=Math.min(p.x,g.x)-i&&y.x<=Math.max(p.x,g.x)+i&&y.y>=Math.min(p.y,g.y)-i&&y.y<=Math.max(p.y,g.y)+i)return true}}return false}function L3(e,t,n,i,r){if(i?.(2)===false)return void 0;let o=n.rangeStarts.get(e);const s=o?.get(t);if(s!==void 0)return s;let a=0,l=e.length;while(a<l){if(i?.(1)===false)return void 0;const c=a+l>>>1;if(e[c].key<t)a=c+1;else l=c}if(!o){if(r?.(3)===false||i?.(1)===false)return void 0;o=new Map;n.rangeStarts.set(e,o)}if(r?.(2)===false||i?.(1)===false)return void 0;o.set(t,a);return a}function A3(e,t,n,i,r,o){let s;const a=i.numericSeed,l=i.margin;for(let c=1;c<e.length;c++){if(r?.(4)===false)return void 0;const d=e[c-1],u=e[c];if(i.contactOnly&&r?.(1)===false)return void 0;const f=d.x===u.x,h=i.contactOnly&&!i.fullCandidates[i.offsets[t]+c-1];if(i.contactOnly){if(r?.(1)===false)return void 0;i.epoch++;if(i.epoch===4294967296){if(r?.(i.seen.length)===false)return void 0;i.seen.fill(0);i.epoch=1}}for(let m=0;m<(h?5:2);m++){if(r?.(4)===false)return void 0;let p,g,y;if(!h){p=m?a.horizontal:a.vertical;g=Math.min(m?d.y:d.x,m?u.y:u.x)-l;y=Math.max(m?d.y:d.x,m?u.y:u.x)+l}else if(m===0){p=f?a.vertical:a.horizontal;g=(f?d.x:d.y)-l;y=(f?d.x:d.y)+l}else if(m===1||m===2){p=f?a.horizontal:a.vertical;const S=m===1?d:u;g=(f?S.y:S.x)-l;y=(f?S.y:S.x)+l}else if(m===3){p=f?a.horizontalEnds:a.verticalEnds;g=(f?d.x:d.y)-l;y=(f?d.x:d.y)+l}else{p=f?i.driftHorizontal:i.driftVertical;g=Math.min(f?d.y:d.x,f?u.y:u.x)-l;y=Math.max(f?d.y:d.x,f?u.y:u.x)+l}const b=L3(p,g,i,r,o);if(b===void 0)return void 0;for(let S=b;S<p.length;S++){if(r?.(3)===false)return void 0;const x=p[S];if(x.key>y)break;const k=x.piece;if(k.owner===t||n[k.owner].style==="invisible")continue;if(i.contactOnly){if(r?.(2)===false)return void 0;const P=i.offsets[k.owner]+k.segment;if(i.seen[P]===i.epoch)continue;i.seen[P]=i.epoch}if(r?.(1)===false)return void 0;const w=n[k.owner].points,C=w[k.segment],R=w[k.segment+1];if(yA(d,u,C,R,i.width))continue;if(!s){if(o?.(n.length+1)===false)return void 0;s=new Array(n.length)}let M=s[k.owner];if(!M){if(o?.(1)===false)return void 0;M=s[k.owner]=[]}if(o?.(3)===false||r?.(1)===false)return void 0;M.push(c,k.segment+1,0)}}}return s??null}function F0(e,t,n,i,r,o,s,a,l=3,c=false,d){let u=0;let f,h;if(d){if(r?.(2)===false)return void 0;f=d.width;h=d.widthText}else if(i.maximumEdgeStrokeWidth!==void 0){if(o?.(4)===false)return void 0;const k=i.maximumEdgeStrokeWidth;if(Number.isSafeInteger(k)&&k>0){if(r?.(k<10?2:17)===false)return void 0;f=k;h=String(k)}else{if(r?.(128)===false)return void 0;h=Ue(k);f=Number(h)}if(!Number.isFinite(f)||f<=0)throw new TypeError("Measured stroke width must be finite and positive")}let m;let p=false;if(d){if(r?.(2)===false)return void 0;p=d.contactOnly&&f!==void 0&&i.maximumEdgeBendRadius===0}if(s&&f!==void 0&&i.maximumEdgeBendRadius===0){if(o?.(1)===false)return void 0;m=[]}let g=false;if(d){g=A3(e,t,n,d,r,o);if(g===void 0)return void 0;if(g===null)return 0}let y;let b;const S=i.edges[t],x=[{points:e},{points:[]}];if(d&&r?.(n.length)===false)return void 0;for(let k=0;k<n.length;k++){const w=n[k];if(k===t||w.style==="invisible")continue;let C=!c;if(g){if(r?.(1)===false)return void 0;if(!g[k]?.length)continue}if(m){if(o?.(1)===false||r?.(1)===false)return void 0;if(C)m.push(k)}const R=i.edges[k];let M;let P;if(d){if(r?.(1)===false)return void 0;x[1].points=w.points}let E=0;const v=g?g[k]:void 0;for(let T=1;g?E<v.length:T<e.length;T++)for(let A=1;g?E<v.length:A<w.points.length;A++){const $=E;if(g){if(r?.(2)===false)return void 0;T=v[E];A=v[E+1];E+=3}if(d&&!g&&r?.(l)===false)return void 0;const _=e[T-1],z=e[T],F=w.points[A-1],G=w.points[A];if(!g&&s&&f!==void 0&&i.maximumEdgeBendRadius===0){const U=C3(_,z,F,G,f);if(U===void 0){const te=Vi(_,r,o);if(!te)return void 0;const J=Vi(z,r,o);if(!J)return void 0;const ae=Vi(F,r,o);if(!ae)return void 0;const Q=Vi(G,r,o);if(!Q)return void 0;if(r?.(4)===false)return void 0;if(te.x!==J.x&&te.y!==J.y||ae.x!==Q.x&&ae.y!==Q.y)return void 0}if(U===true)continue;C=true}if((g||l===1)&&r?.(p?1:2)===false)return void 0;if(!p){if(f===void 0){if(k3(_,z,F,G))return void 0}else{const U=P3(_,z,F,G,f,h,r,o);if(U!==false)return void 0}}if(d){if(r?.(1)===false)return void 0;if((_.x!==z.x||_.y!==z.y)&&(F.x!==G.x||F.y!==G.y)&&Math.min(_.x,z.x)<=Math.max(F.x,G.x)&&Math.min(F.x,G.x)<=Math.max(_.x,z.x)&&Math.min(_.y,z.y)<=Math.max(F.y,G.y)&&Math.min(F.y,G.y)<=Math.max(_.y,z.y)){if(!y){if(o?.(13)===false)return void 0;y=[{a:_,b:z,edgeIndex:0,pointIndex:T-1},{a:F,b:G,edgeIndex:1,pointIndex:A-1}]}if(r?.(7+e.length+w.points.length)===false||o?.(4)===false)return void 0;const U=y[0],te=y[1];U.a=_;U.b=z;U.pointIndex=T-1;te.a=F;te.b=G;te.pointIndex=A-1;const J=cd(U,te,x);if(J){if(!P){if(o?.(1)===false)return void 0;P=[]}if(r?.(P.length)===false||o?.(2)===false)return void 0;gp(P,J);if(p&&(_.x!==z.x&&_.y!==z.y||F.x!==G.x&&F.y!==G.y)){if(r?.(1)===false)return void 0;v[$+2]=1}}}}const I=_.x===z.x,D=F.x===G.x;let B=0,Y=0,W=false;if(I!==D){B=I?_.x:F.x;Y=I?F.y:_.y;W=B>=Math.min(_.x,z.x)&&B<=Math.max(_.x,z.x)&&Y>=Math.min(_.y,z.y)&&Y<=Math.max(_.y,z.y)&&B>=Math.min(F.x,G.x)&&B<=Math.max(F.x,G.x)&&Y>=Math.min(F.y,G.y)&&Y<=Math.max(F.y,G.y)}else if(I?_.x===F.x:_.y===F.y){const U=Math.max(I?Math.min(_.y,z.y):Math.min(_.x,z.x),I?Math.min(F.y,G.y):Math.min(F.x,G.x));const te=Math.min(I?Math.max(_.y,z.y):Math.max(_.x,z.x),I?Math.max(F.y,G.y):Math.max(F.x,G.x));if(te>=U){B=I?_.x:U;Y=I?U:_.y;W=true}}if(!W)continue;const O=e[0],N=e.at(-1),H=w.points[0],j=w.points.at(-1);const q=O.x===B&&O.y===Y,X=N.x===B&&N.y===Y;const V=H.x===B&&H.y===Y,ee=j.x===B&&j.y===Y;const re=S.source===R.source&&q&&V||S.source===R.target&&q&&ee||S.target===R.source&&X&&V||S.target===R.target&&X&ⅇif(!re)(M??=new Set).add(`${B},${Y}`)}if(m&&c&&C)m.push(k);let L;if(d){if(P){const T=P.length;if(r?.(2*T*T+T)===false||o?.(2*T+1)===false)return void 0;L=yp(P)}else L=0}else{if(!M&&(b??=gA(e))&&gA(w.points))continue;x[1].points=w.points;L=_r(x)}if(L<(M?.size??0))return void 0;u+=L}if(s&&f!==void 0&&i.maximumEdgeBendRadius===0&&m.length&&R3(e,t,n,i,f,h,m,r,o,a,d,g||void 0)!==true)return void 0;return u}function SA(e){if(!e||typeof e!=="object")throw new TypeError("Invalid measured marker paint");for(const t of[e.start,e.end]){if(t===void 0)continue;if(!Array.isArray(t)||t.length>64)throw new TypeError("Invalid measured marker pieces");for(const n of t){if(n.kind==="circle"){if(![n.cx,n.cy,n.r].every(i=>Number.isFinite(i*i*16))||!(n.r>0))throw new TypeError("Invalid measured marker circle")}else if(n.kind==="polygon"){if(!Array.isArray(n.points)||n.points.length<3||n.points.length>32)throw new TypeError("Invalid measured marker polygon");for(const r of n.points)if(!Number.isFinite(r.x*r.x*16)||!Number.isFinite(r.y*r.y*16))throw new TypeError("Invalid measured marker coordinate");let i=0;for(let r=0;r<n.points.length;r++){const o=n.points[r],s=n.points[(r+1)%n.points.length],a=n.points[(r+2)%n.points.length];const l=(s.x-o.x)*(a.y-s.y)-(s.y-o.y)*(a.x-s.x);if(!Number.isFinite(l)||l&&i&&Math.sign(l)!==i)throw new TypeError("Nonconvex measured marker polygon");if(l)i=Math.sign(l)}if(!i)throw new TypeError("Empty measured marker polygon")}else throw new TypeError("Invalid measured marker kind")}}}function I3(e,t,n,i,r,o,s,a){s();const l=e.x===t.x;if(n.x===i.x!==l)return false;s(2);const c=l?e.x:e.y,d=l?n.x:n.y,u=(Math.abs(c)+Math.abs(d)+Math.abs(r))*1e-10+1e-9;if(Math.abs(c-d)>r+u)return false;s(2);const f=Math.min(l?e.y:e.x,l?t.y:t.x),h=Math.max(l?e.y:e.x,l?t.y:t.x),m=Math.min(l?n.y:n.x,l?i.y:i.x),p=Math.max(l?n.y:n.x,l?i.y:i.x),g=(Math.abs(f)+Math.abs(h)+Math.abs(m)+Math.abs(p))*1e-10+1e-9;if(Math.min(h,p)<Math.max(f,m)-g)return false;a(42);s(384);const y=$d(Ue(c),Ue(d),Ue(o),s);if(y!==true)return y===void 0;a(20);s(512);const b=Number(Ue(l?e.y:e.x)),S=Number(Ue(l?t.y:t.x)),x=Number(Ue(l?n.y:n.x)),k=Number(Ue(l?i.y:i.x));return Math.min(Math.max(b,S),Math.max(x,k))>Math.max(Math.min(b,S),Math.min(x,k))}function wA(e,t,n,i,r,o,s,a,l,c,d=0,u,f){i.arcs-=18;if(i.arcs<0)o("agentic marker seating capacity limit");const h=(N=1)=>{i.pairs-=N;if(i.pairs<0)o("agentic marker seating work limit")};const m=N=>{i.arcs-=N;if(i.arcs<0)o("agentic marker seating capacity limit")};const p=[];let g=0;for(const N of e){h();if(N.visible!==false)g+=Number(!!N.markerPaint?.start?.length)+Number(!!N.markerPaint?.end?.length)}let y=0,b=0;if(c!==void 0){if(!Number.isFinite(c)||c<=0||!Number.isFinite(d)||d<0)throw new TypeError("Invalid measured marker carrier width");for(let N=0;N<t.length;N++){h();if(e[N].visible===false)continue;const H=t[N].points;h(2);if(H.length===2)b++;y+=Math.max(0,H.length-1);for(let j=1;j+1<H.length;j++){h(4);const q=H[j-1],X=H[j],V=H[j+1];if(q.x===X.x!==(X.x===V.x))y++}}}const S=4*(g+y+4*b+(u?.obstacles.length??0))+8;m(S);h(S);const x=new Float64Array(S);m(2*y+2*t.length+9);r(4);const k=[],w=[],C=[{kind:"polygon",points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}]}];const R=(c??0)/2;const M=(N,H,j)=>{h(13);if(!Number.isFinite(H.x)||!Number.isFinite(H.y)||!Number.isFinite(j.x)||!Number.isFinite(j.y)||H.x!==j.x&&H.y!==j.y)o("Unsupported measured marker carrier");N.a=H;N.b=j;const q=R+(N.join?d:0);N.minX=Math.min(H.x,j.x)-q;N.maxX=Math.max(H.x,j.x)+q;N.minY=Math.min(H.y,j.y)-q;N.maxY=Math.max(H.y,j.y)+q};const P=N=>{const H=w[N],j=t[N].points;H.minX=H.minY=Infinity;H.maxX=H.maxY=-Infinity;h(4);for(let q=H.begin;q<H.end;q++){const X=k[q];M(X,j[X.point],X.join?j[X.point]:j[X.point+1]);h(4);H.minX=Math.min(H.minX,X.minX);H.maxX=Math.max(H.maxX,X.maxX);H.minY=Math.min(H.minY,X.minY);H.maxY=Math.max(H.maxY,X.maxY)}};for(let N=0;N<t.length;N++){h();const H=k.length;if(c!==void 0&&e[N].visible!==false)for(let j=1;j<t[N].points.length;j++){h();k.push({current:true,a:t[N].points[j-1],b:t[N].points[j],point:j-1,join:false,minX:0,maxX:0,minY:0,maxY:0})}if(c!==void 0&&e[N].visible!==false)for(let j=1;j+1<t[N].points.length;j++){h(4);const q=t[N].points[j-1],X=t[N].points[j],V=t[N].points[j+1];if(q.x===X.x!==(X.x===V.x))k.push({current:true,a:X,b:X,point:j,join:true,minX:0,maxX:0,minY:0,maxY:0})}w.push({begin:H,end:k.length,minX:Infinity,maxX:-Infinity,minY:Infinity,maxY:-Infinity});P(N)}m(1);const E=(N,H)=>{const j=w[N],q=k.length;m(10);for(let X=0;X<3;X++){h();k.push({current:true,a:H[X],b:H[X+1],point:X,join:false,minX:0,maxX:0,minY:0,maxY:0})}for(let X=1;X<3;X++){h();k.push({current:true,a:H[X],b:H[X],point:X,join:true,minX:0,maxX:0,minY:0,maxY:0})}for(let X=j.begin;X<j.end;X++){h();k[X].current=false}j.begin=q;j.end=k.length};const v=(N,H)=>{h(5);return N.maxX>H.minX&&N.minX<H.maxX&&N.maxY>H.minY&&N.minY<H.maxY};const L=(N,H)=>{if(!v(N,H))return false;const j=H.a,q=H.b,X=C[0].points;h(8);if(H.join){X[0].x=H.minX;X[0].y=H.minY;X[1].x=H.maxX;X[1].y=H.minY;X[2].x=H.maxX;X[2].y=H.maxY;X[3].x=H.minX;X[3].y=H.maxY}else if(j.x===q.x){X[0].x=H.minX;X[0].y=Math.min(j.y,q.y);X[1].x=H.maxX;X[1].y=X[0].y;X[2].x=H.maxX;X[2].y=Math.max(j.y,q.y);X[3].x=H.minX;X[3].y=X[2].y}else{X[0].x=Math.min(j.x,q.x);X[0].y=H.minY;X[1].x=Math.max(j.x,q.x);X[1].y=H.minY;X[2].x=X[1].x;X[2].y=H.maxY;X[3].x=X[0].x;X[3].y=H.maxY}return Vf(N.pieces,C,h)};let T=1;for(const N of w){h(4);if(N.begin<N.end)T=Math.max(T,Math.abs(N.minX),Math.abs(N.maxX),Math.abs(N.minY),Math.abs(N.maxY))}for(const N of n){h(4);T=Math.max(T,Math.abs(N.x),Math.abs(N.y),Math.abs(N.x+N.width),Math.abs(N.y+N.height))}if(u){h(4);T=Math.max(T,Math.abs(u.bounds.x),Math.abs(u.bounds.y),Math.abs(u.bounds.x+u.bounds.width),Math.abs(u.bounds.y+u.bounds.height))}const A=(T+Math.abs(c??0))*1e-10+1e-9;const $=N=>{m(5);h(128);return Number(Ue(N))};const _=c===void 0?0:$(c);const z=(N,H)=>{if(c===void 0||H.join)return true;const j=H.a,q=H.b,X=j.x===q.x,V=X?j.x:j.y,ee=Math.min(X?j.y:j.x,X?q.y:q.x),re=Math.max(X?j.y:j.x,X?q.y:q.x);for(let U=0;U<w.length;U++){h();if(U===N)continue;const te=w[U];h(5);if(H.maxX<te.minX-A||H.minX>te.maxX+A||H.maxY<te.minY-A||H.minY>te.maxY+A)continue;for(let J=te.begin;J<te.end;J++){h();const ae=k[J];if(ae.join)continue;if(I3(j,q,ae.a,ae.b,c,_,h,m))return false}}return true};const F={current:true,a:void 0,b:void 0,point:0,join:false,minX:0,maxX:0,minY:0,maxY:0};const G=(N,H,j,q,X)=>{h(10);if(!Number.isFinite(H.x)||!Number.isFinite(H.y)||!Number.isFinite(j.x)||!Number.isFinite(j.y))o("Nonfinite measured marker normal");const V=Math.sign(j.x-H.x),ee=Math.sign(j.y-H.y);if(Number(!V)+Number(!ee)!==1)o("Nonorthogonal measured marker normal");let re=0;for(const te of N){h();if(te.kind==="polygon")re+=te.points.length}m(2+2*N.length+re);r(re);const U={owner:q,source:X,pieces:[],minX:Infinity,maxX:-Infinity,minY:Infinity,maxY:-Infinity};for(const te of N){h();if(te.kind==="circle"){const J=H.x+V*te.cx-ee*te.cy,ae=H.y+ee*te.cx+V*te.cy;U.pieces.push({kind:"circle",cx:J,cy:ae,r:te.r});U.minX=Math.min(U.minX,J-te.r);U.maxX=Math.max(U.maxX,J+te.r);U.minY=Math.min(U.minY,ae-te.r);U.maxY=Math.max(U.maxY,ae+te.r)}else{const J={kind:"polygon",points:[]};for(const ae of te.points){h();const Q=H.x+V*ae.x-ee*ae.y,K=H.y+ee*ae.x+V*ae.y;J.points.push({x:Q,y:K});U.minX=Math.min(U.minX,Q);U.maxX=Math.max(U.maxX,Q);U.minY=Math.min(U.minY,K);U.maxY=Math.max(U.maxY,K)}U.pieces.push(J)}}return U};m(g+1);const I=[];for(let N=0;N<e.length;N++){h();if(e[N].visible===false)continue;for(let H=0;H<2;H++){h();const j=H===0?e[N].markerPaint?.start:e[N].markerPaint?.end;if(!j?.length)continue;const q=t[N].points,X=H===0;I.push(G(j,X?q[0]:q.at(-1),X?q[1]:q.at(-2),N,X))}}const D=(N,H,j)=>{if(l&&!l(H,j,N.pieces,N))return false;if(c!==void 0)for(let q=0;q<w.length;q++){h();const X=w[q];if(!v(N,X))continue;for(let V=X.begin;V<X.end;V++){h();const ee=k[V];if(q===H&&(ee.join?ee.point===(j?1:t[H].points.length-2):j?ee.point<=1:ee.point>=t[H].points.length-3))continue;if(L(N,ee))return false}}for(const q of p){h(5);if(N.maxX<=q.minX||N.minX>=q.maxX||N.maxY<=q.minY||N.minY>=q.maxY)continue;if(Vf(N.pieces,q.pieces,h))return false}return true};let B=0;m(3*e.length+2);h(3*e.length);const Y=new Uint8Array(3*e.length);const W=(N,H,j,q,X,V,ee=-1,re,U=-1)=>{let te=false;for(let J=0;J<w.length&&!te&&B<8;J++){h();if(re?J!==U:X===0&&J===N)continue;const ae=w[J],Q=t[J].points;for(let K=ae.begin;K<ae.end&&!te&&B<8;K++){h(8);const Z=k[K],se=Z.point;if(Z.join||se<1||se+2>=Q.length)continue;const oe=Q[se],de=Q[se+1],xe=Q[se-1],Me=Q[se+2],Ce=oe.y===de.y;let pe=false;if(re){h(5);const le=J===ee?re.candidateSegment:re.peerSegment;pe=le>=se&&le<=se+2}else{if(Ce!==q)continue;h(4);const le=J===N,Se=le&&(H?se<=1:se>=Q.length-3);pe=!Se&&L(j,Z);if(X===0&&!pe)continue;for(let Pe=0;Pe<2&&!pe;Pe++){h(8);const Ae=k[ae.begin+se+(Pe===0?-1:1)];if(le&&(H?Ae.point<=1:Ae.point>=Q.length-3))continue;if(L(j,Ae))pe=true}if(!pe){h(3);let Pe=ae.begin+Q.length-1,Ae=ae.end;while(Pe<Ae){h(3);const Ne=Pe+Math.floor((Ae-Pe)/2);if(k[Ne].point<se)Pe=Ne+1;else Ae=Ne}for(let Ne=Pe;Ne<ae.end&&!pe;Ne++){h(8);const Oe=k[Ne];if(Oe.point>se+1)break;if(le&&Oe.point===(H?1:Q.length-2))continue;if(L(j,Oe))pe=true}}}if(!pe)continue;const Te=Ce?Math.min(oe.x,de.x):Math.min(oe.y,de.y),Fe=Ce?Math.max(oe.x,de.x):Math.max(oe.y,de.y);if(Ce?xe.x!==oe.x||Me.x!==de.x:xe.y!==oe.y||Me.y!==de.y)continue;const De=e[J].label,Be=De?t[J].labelPosition:void 0;let me=false,he=false;if(Be&&X===0){let le=false;for(let Se=se-1;Se<=se+1;Se++){h(6);if(Ki(Be,Q[Se],Q[Se+1])){le=true;break}}if(le)continue}else if(Be){h(18);if(Ki(Be,oe,de))continue;me=Ki(Be,xe,oe);he=Ki(Be,de,Me)}const fe=Ce?oe.y:oe.x,be=Ce?xe.y:xe.x,ge=Ce?Me.y:Me.x;let Re=Ce?V.bounds.y:V.bounds.x,Ie=Re+(Ce?V.bounds.height:V.bounds.width);if(fe===be||fe===ge)continue;if(fe>be)Re=Math.max(Re,be);else Ie=Math.min(Ie,be);if(fe>ge)Re=Math.max(Re,ge);else Ie=Math.min(Ie,ge);if(Be&&De&&(me||he)){h();if(d!==0)continue;h(6);const le=Ce?Be.y:Be.x,Se=(Ce?De.height:De.width)/2+2+R,Pe=le-Se,Ae=le+Se;let Ne=false;for(let Oe=0;Oe<2;Oe++){h(12);if(Oe===0?!me:!he)continue;const We=Oe===0?be:ge;if(Pe<Math.min(We,fe)||Ae>Math.max(We,fe)){Ne=true;break}if(We<=Pe)Re=Math.max(Re,Ae);else if(We>=Ae)Ie=Math.min(Ie,Pe);else{Ne=true;break}}if(Ne)continue}if(!(Re<Ie))continue;let ne=2;x[0]=Re;x[1]=0;x[2]=Ie;x[3]=0;m(1);const we=(le,Se)=>{h(2);le=Math.max(Re,le);Se=Math.min(Ie,Se);if(le<Se){x[2*ne]=le;x[2*ne+1]=1;ne++;x[2*ne]=Se;x[2*ne+1]=-1;ne++}};if(re){h(12);const le=J===ee?re.peerIndex:ee,Se=J===ee?re.peerSegment:re.candidateSegment,Pe=k[w[le].begin+Se-1];we((Ce?Pe.minY:Pe.minX)-R-.01,(Ce?Pe.maxY:Pe.maxX)+R+.01)}for(const le of V.obstacles){h(5);if(Ce?le.x+le.width+R<Te||le.x-R>Fe:le.y+le.height+R<Te||le.y-R>Fe)continue;we((Ce?le.y:le.x)-R,(Ce?le.y+le.height:le.x+le.width)+R)}for(const le of I){h(5);if(Ce?le.maxX+R<Te||le.minX-R>Fe:le.maxY+R<Te||le.minY-R>Fe)continue;we((Ce?le.minY:le.minX)-R-.01,(Ce?le.maxY:le.maxX)+R+.01)}for(let le=0;le<k.length;le++){h(5);const Se=k[le];if(!Se.current||le===K||Se.join||Se.a.y===Se.b.y!==Ce)continue;if(Ce?Se.maxX<Te||Se.minX>Fe:Se.maxY<Te||Se.minY>Fe)continue;we((Ce?Se.minY:Se.minX)-R-.01,(Ce?Se.maxY:Se.maxX)+R+.01)}for(let le=1;le<ne;le++){const Se=x[2*le],Pe=x[2*le+1];let Ae=le;while(Ae>0){h();if(x[2*(Ae-1)]<=Se)break;x[2*Ae]=x[2*(Ae-1)];x[2*Ae+1]=x[2*(Ae-1)+1];Ae--}x[2*Ae]=Se;x[2*Ae+1]=Pe}let Ee=-1,ke=-1;for(let le=0;le<8&&B<8;le++){let Se=0,Pe=-1,Ae=Infinity,Ne=0;for(let ve=1;ve<ne;ve++){h(3);Se+=x[2*(ve-1)+1];const He=x[2*(ve-1)],je=x[2*ve],Ke=He+(je-He)/2,ze=Math.abs(Ke-fe);if(Se!==0||!(He<je)||Ke===fe||ze<Ee||ze===Ee&&ve<=ke)continue;if(ze<Ae){Pe=ve;Ae=ze;Ne=Ke}}if(Pe<0)break;Ee=Ae;ke=Pe;B++;m(Q.length+1);r(2);h(Q.length);const Oe=Q.slice(),We={x:oe.x,y:oe.y},ce={x:de.x,y:de.y};if(Ce){We.y=ce.y=Ne}else{We.x=ce.x=Ne}Oe[se]=We;Oe[se+1]=ce;let Le=true;for(let ve=se-1;ve<=se+1&&Le;ve++){M(F,Oe[ve],Oe[ve+1]);if(!z(J,F)){Le=false;break}for(const He of I){h(2);const je=ve!==se&&He.owner===J&&(He.source?ve<=1:ve>=Q.length-3);if(!je&&L(He,F)){Le=false;break}}if(!Le)break;if(ve!==se){h(6);const He=ve===se-1?xe:Me,je=ve===se-1?oe:de,Ke=ve===se-1?We:ce;const ze=Math.abs(je.x-He.x)+Math.abs(je.y-He.y),Ze=Math.abs(Ke.x-He.x)+Math.abs(Ke.y-He.y);if(Ze>ze){M(F,je,Ke);for(const tt of I){h(4);if(tt.owner===J&&(tt.source?ve===0:ve===Q.length-2))continue;if(tt.owner===J&&(tt.source?ve<=1:ve>=Q.length-3)&&L(tt,F)){Le=false;break}}}}}h(4);for(let ve=Math.max(1,se-1);ve<=Math.min(Oe.length-2,se+2)&&Le;ve++){h(4);const He=Oe[ve-1],je=Oe[ve],Ke=Oe[ve+1];if(He.x===je.x===(je.x===Ke.x))continue;F.join=true;M(F,je,je);for(const ze of I){h();const Ze=ze.owner===J&&ve!==se&&ve!==se+1&&ve===(ze.source?1:Q.length-2);if(!Ze&&L(ze,F)){Le=false;break}}F.join=false}if(!Le||!s(J,Oe))continue;t[J].points=Oe;P(J);a(J);te=true;break}}}return te};let O=0;for(let N=0;N<e.length;N++){h();const H=e[N];if(H.visible===false)continue;e:for(let j=0;j<2;j++){h();const q=j===0?H.markerPaint?.start:H.markerPaint?.end;if(!q?.length)continue;let X=t[N].points;const V=j===0;let ee=V?X[0]:X.at(-1),re=V?X[1]:X.at(-2);let U=I[O++];B=0;if(!D(U,N,V)){const te=n[V?H.source:H.target],J=re.x===ee.x;const ae=J?te.x:te.y,Q=ae+(J?te.width:te.height),K=J?ee.x:ee.y;const Z=(J?U.minX:U.minY)-K,se=(J?U.maxX:U.maxY)-K;for(let oe=0;oe<2;oe++){h();if(c!==void 0&&u){let Te=false;do{h(3);Te=false;Te=W(N,V,U,J,oe,u);if(!Te)break;h(4);X=t[N].points;ee=V?X[0]:X.at(-1);re=V?X[1]:X.at(-2);if(D(U,N,V)){m(1);p.push(U);h();Y[2*N+j]=B;continue e}}while(oe===1&&B<8)}let de=2;x[0]=ae;x[1]=0;x[2]=Q;x[3]=0;for(const Te of p){h(6);if(J?U.maxY<=Te.minY||U.minY>=Te.maxY:U.maxX<=Te.minX||U.minX>=Te.maxX)continue;const Fe=Math.max(ae,(J?Te.minX:Te.minY)-se-.01),De=Math.min(Q,(J?Te.maxX:Te.maxY)-Z+.01);if(Fe<De){x[2*de]=Fe;x[2*de+1]=1;de++;x[2*de]=De;x[2*de+1]=-1;de++}}if(c!==void 0)for(let Te=0;Te<w.length;Te++){h();if(Te===N)continue;const Fe=w[Te];if(J?U.maxY<=Fe.minY||U.minY>=Fe.maxY:U.maxX<=Fe.minX||U.minX>=Fe.maxX)continue;for(let De=Fe.begin;De<Fe.end;De++){h(6);const Be=k[De];if(J?U.maxY<=Be.minY||U.minY>=Be.maxY:U.maxX<=Be.minX||U.minX>=Be.maxX)continue;const me=Math.max(ae,(J?Be.minX:Be.minY)-se-.01),he=Math.min(Q,(J?Be.maxX:Be.maxY)-Z+.01);if(me<he){x[2*de]=me;x[2*de+1]=1;de++;x[2*de]=he;x[2*de+1]=-1;de++}}}for(let Te=1;Te<de;Te++){const Fe=x[2*Te],De=x[2*Te+1];let Be=Te;while(Be>0){h();if(x[2*(Be-1)]<=Fe)break;x[2*Be]=x[2*(Be-1)];x[2*Be+1]=x[2*(Be-1)+1];Be--}x[2*Be]=Fe;x[2*Be+1]=De}let xe=false,Me=Infinity,Ce=-1,pe=-1;for(let Te=0;Te<8&&B<8;Te++){let Fe=-1,De=0,Be=2,me=0;for(let Ne=1;Ne<de;Ne++){h(2);me+=x[2*(Ne-1)+1];const Oe=x[2*Ne]-x[2*(Ne-1)],We=me===0?0:1;const ce=We>pe||We===pe&&(Oe<Me||Oe===Me&&Ne>Ce);if(Oe>0&&ce&&(We<Be||We===Be&&Oe>De)){De=Oe;Fe=Ne;Be=We}}if(Fe<0)break;const he=x[2*(Fe-1)]+De/2;Me=De;Ce=Fe;pe=Be;B++;const fe=X.length===2;h(3);let be=0;if(fe){const Ne=J?ee.y:ee.x,Oe=J?re.y:re.x,We=Math.sign(Oe-Ne);let ce=We>0?(J?U.maxY:U.maxX)-Ne:Ne-(J?U.minY:U.minX),Le=0;for(const ze of I){h(5);if(ze.owner===N&&ze.source!==V)Le=Math.max(Le,We>0?Oe-(J?ze.minY:ze.minX):(J?ze.maxY:ze.maxX)-Oe)}h(10);const ve=R+d,He=Math.min(8,Math.abs(Oe-Ne)),je=Ne+We*Math.max(He,ce+ve);let Ke=Oe-We*Math.max(He,Le+ve);if(H.label){h(9);const ze=t[N].labelPosition;if(!ze||!Ki(ze,ee,re))continue;const Ze=J?ze.y:ze.x,tt=(J?H.label.height:H.label.width)/2+2+R;Ke=We>0?Math.min(Ke,Ze-tt):Math.max(Ke,Ze+tt)}if(!(We*(Ke-je)>0))continue;be=je+(Ke-je)/2}m((fe?4:X.length)+1);r(fe?4:3);h(X.length+6);const ge={x:ee.x,y:ee.y},Re={x:re.x,y:re.y};if(J){ge.x=he;Re.x=he;if(fe)Re.y=be;if(Math.abs(ge.y-te.y)<1e-7)ge.y=te.y;else if(Math.abs(ge.y-te.y-te.height)<1e-7)ge.y=te.y+te.height}else{ge.y=he;Re.y=he;if(fe)Re.x=be;if(Math.abs(ge.x-te.x)<1e-7)ge.x=te.x;else if(Math.abs(ge.x-te.x-te.width)<1e-7)ge.x=te.x+te.width}const Ie=fe?V?[ge,Re,J?{x:re.x,y:be}:{x:be,y:re.y},re]:[re,J?{x:re.x,y:be}:{x:be,y:re.y},Re,ge]:X.slice();Ie[V?0:Ie.length-1]=ge;Ie[V?1:Ie.length-2]=Re;const ne=V?Ie.length-1:0,we=V?Ie.length-2:1,Ee=Ie[ne],ke={x:Ee.x,y:Ee.y},le=n[V?H.target:H.source];if(Ie[we].x===ke.x){if(Math.abs(ke.y-le.y)<1e-7)ke.y=le.y;else if(Math.abs(ke.y-le.y-le.height)<1e-7)ke.y=le.y+le.height}else if(Ie[we].y===ke.y){if(Math.abs(ke.x-le.x)<1e-7)ke.x=le.x;else if(Math.abs(ke.x-le.x-le.width)<1e-7)ke.x=le.x+le.width}if(ke.x!==Ee.x||ke.y!==Ee.y){m(16);h(256);if(Ue(ke.x)!==Ue(Ee.x)||Ue(ke.y)!==Ue(Ee.y))continue}Ie[ne]=ke;const Se=G(q,ge,Re,N,V);if(!D(Se,N,V))continue;let Pe=true,Ae=false;if(c!==void 0)for(let Ne=1;Ne<Ie.length;Ne++){h();if(!fe&&!Ae&&(V?Ne>2&&Ne!==Ie.length-1:Ne<Ie.length-2&&Ne!==1))continue;M(F,Ie[Ne-1],Ie[Ne]);if(!z(N,F)){h(5);if(!Ae&&!fe&&Ne===2&&Ie.length===4&&!H.label&&d===0){const Oe=Ie[we],We=J?ge.y:ge.x,ce=J?Re.y:Re.x,Le=J?ke.y:ke.x,ve=Math.sign(ce-We);h(6);if((J?Oe.y===ce&&Oe.x===ke.x:Oe.x===ce&&Oe.y===ke.y)&&ve*(Le-ce)>0){h(10);const He=ve>0?(J?Se.maxY:Se.maxX)-We:We-(J?Se.minY:Se.minX),je=Math.min(8,Math.abs(ce-We)),Ke=Math.min(8,Math.abs(Le-ce));let ze=0;for(const $t of I){h(5);if($t.owner===N&&$t.source!==V)ze=Math.max(ze,ve>0?Le-(J?$t.minY:$t.minX):(J?$t.maxY:$t.maxX)-Le)}h(8);const Ze=We+ve*Math.max(je,He+R),tt=Le-ve*Math.max(Ke,ze+R),nt=ce-ve*c,it=ve>0?Math.min(tt,nt):Math.max(tt,nt);if(ve*(it-Ze)>0){h(4);const $t=Ze+(it-Ze)/2;m(2);r(1);const yn={x:Oe.x,y:Oe.y};if(J)Re.y=yn.y=$t;else Re.x=yn.x=$t;Ie[we]=yn;Ae=true;Ne=0;continue}}}Pe=false;break}for(const Oe of fe||Ae?I:p){h(Ae?4:3);const We=Ae&&Oe.owner===N&&Oe.source===V?Se:Oe;const ce=We.owner===N&&(fe||Ae?We.source?Ne===1:Ne===Ie.length-1:We.source?Ne<=2:Ne>=Ie.length-2);if(!ce&&L(We,F)){Pe=false;break}}if(!Pe)break}if(Pe&&c!==void 0)for(let Ne=1;Ne+1<Ie.length;Ne++){h();if(!fe&&!Ae&&(V?Ne>2&&Ne!==Ie.length-2:Ne<Ie.length-3&&Ne!==1))continue;const Oe=Ie[Ne-1],We=Ie[Ne],ce=Ie[Ne+1];h(4);if(Oe.x===We.x===(We.x===ce.x))continue;F.join=true;M(F,We,We);F.join=false;F.join=true;for(const Le of fe||Ae?I:p){h(Ae?4:3);const ve=Ae&&Le.owner===N&&Le.source===V?Se:Le;const He=!fe&&!Ae&&ve.owner===N&&(ve.source?Ne===1:Ne===Ie.length-2);if(!He&&L(ve,F)){Pe=false;break}}F.join=false;if(!Pe)break}if(!Pe||!s(N,Ie))continue;if(fe&&c!==void 0)E(N,Ie);t[N].points=Ie;if(c!==void 0)P(N);U=Se;I[O-1]=Se;a(N);xe=true;break}if(!xe){if(oe===0)continue;o("No physically clear measured marker seat at occurrence "+N+" role "+j)}break}}m(1);p.push(U);h();Y[2*N+j]=B}}if(f&&u&&c!==void 0&&d===0){m(1);const N={candidateSegment:-1,peerIndex:-1,peerSegment:-1};for(let H=0;H<t.length;H++){h();if(e[H].visible===false)continue;while(f(H,N)){let j=false;for(let q=0;q<2&&!j;q++){h(3);const X=q===0?H:N.peerIndex,V=e[X].markerPaint,ee=!!(V?.start?.length||V?.end?.length);for(let re=0;re<(ee?2:1)&&!j;re++){h(4);if(ee&&!(re===0?V?.start?.length:V?.end?.length))continue;const U=ee?2*X+re:2*e.length+X;B=Y[U];if(B>=8)continue;j=W(X,re===0,void 0,false,1,u,H,N,X);h();Y[U]=B}}if(!j)o("No physically clear measured sharp contact repair at occurrence "+H)}}}}var MA=new WeakMap;function kA(e,t){if(!e)return false;const n=MA.get(e);if(!n||n.boxes!==t)return false;return Object.getOwnPropertyDescriptor(e,"containsPoint")?.value===n.containsPoint&&Object.getOwnPropertyDescriptor(e,"entersSegment")?.value===n.entersSegment&&Object.getOwnPropertyDescriptor(e,"projectPoint")?.value===n.projectPoint}function CA(e,t,n,i){const r=(m=1)=>{t.pairs-=m;if(t.pairs<0)n("agentic local cross-hierarchy obstacle-work limit")};const o=(m,p)=>{if(p==="work")r(m);else{t.arcs-=m;if(t.arcs<0)n("agentic local cross-hierarchy visibility-arc limit")}};const s=i?i.x:Ol(e,"x",0,o),a=i?i.y:Ol(e,"y",0,o);const l=(m,p,g)=>{if(!m)return null;g?.();r();return ip(m,p)};const c=(m,p)=>p<0||p+1>=m.offsets.length;const d=(m,p,g)=>p>m.x&&p<m.x+m.width&&g>m.y&&g<m.y+m.height;const u=(m,p,g,y,b)=>p===y?p>m.x&&p<m.x+m.width&&Math.max(g,b)>m.y&&Math.min(g,b)<m.y+m.height:g>m.y&&g<m.y+m.height&&Math.max(p,y)>m.x&&Math.min(p,y)<m.x+m.width;const f=(m,p,g,y,b)=>{r(2);if(p){if(y>m.y&&y<m.y+m.height){if(m.x>=g)b.right=Math.min(b.right,m.x);if(m.x+m.width<=g)b.left=Math.max(b.left,m.x+m.width)}}else if(g>m.x&&g<m.x+m.width){if(m.y>=y)b.bottom=Math.min(b.bottom,m.y);if(m.y+m.height<=y)b.top=Math.max(b.top,m.y+m.height)}};const h={projectPoint(m,p,g,y){r(4);y.left=g.x;y.right=g.x+g.width;y.top=g.y;y.bottom=g.y+g.height;for(let b=0;b<2;b++){const S=b===0,x=S?a:s;const k=l(x,S?p:m);if(x&&k!==null){if(c(x,k))continue;for(let w=x.offsets[k];w<x.offsets[k+1];w++){f(e[x.ordinals[w]],S,m,p,y)}}else for(const w of e)f(w,S,m,p,y)}},containsPoint(m,p,g){const y=l(s,m,g),b=l(a,p,g);if(s&&y!==null&&c(s,y)||a&&b!==null&&c(a,b))return false;const S=s&&y!==null?s.offsets[y+1]-s.offsets[y]:Infinity;const x=a&&b!==null?a.offsets[b+1]-a.offsets[b]:Infinity;const k=S<=x?s:a,w=S<=x?y:b;if(k&&w!==null){for(let C=k.offsets[w];C<k.offsets[w+1];C++){g?.();r();if(d(e[k.ordinals[C]],m,p))return true}}else for(const C of e){g?.();r();if(d(C,m,p))return true}return false},entersSegment(m,p,g,y,b){const S=m===g?s:a,x=l(S,m===g?m:p,b);if(S&&x!==null){if(c(S,x))return false;for(let k=S.offsets[x];k<S.offsets[x+1];k++){b?.();r();if(u(e[S.ordinals[k]],m,p,g,y))return true}}else for(const k of e){b?.();r();if(u(k,m,p,g,y))return true}return false}};o(4,"capacity");MA.set(h,{boxes:e,containsPoint:h.containsPoint,entersSegment:h.entersSegment,projectPoint:h.projectPoint});return h}function PA(e,t,n){return CA(e,t,n)}function EA(e,t){e.arcs-=8;if(e.arcs<0)t("agentic local cross-hierarchy visibility-arc limit");const n=s=>{e.pairs-=s;if(e.pairs<0)t("agentic local cross-hierarchy obstacle-work limit")};const i=s=>{e.arcs-=s;if(e.arcs<0)t("agentic local cross-hierarchy visibility-arc limit")};let r;const o=(s,a)=>a==="capacity"?i(s):n(s);return s=>{i(7);const a=f=>{n(3);const h=r?.[f];if(h&&r.boxes.length===s.length){let m=true;for(let p=0;p<s.length;p++){n(3);const g=r.boxes[p],y=s[p];const b=g[f]-0,S=g[f]+(f==="x"?g.width:g.height)+0;const x=y[f]-0,k=y[f]+(f==="x"?y.width:y.height)+0;if(!Object.is(Math.floor(b/128),Math.floor(x/128))||!Object.is(Math.floor(S/128),Math.floor(k/128))){m=false;break}}if(m)return h}return Ol(s,f,0,o)};const l=a("x"),c=a("y");const d={x:l,y:c};const u=CA(s,e,t,d);n(1);r={boxes:s,x:l,y:c};return u}}function Ug(e,t,n,i,r,o,s,a,l,c,d,u,f=.5,h=false){s.arcs-=24+r.length+2;if(s.arcs<0)l("agentic local cross-hierarchy visibility-arc limit");const m=($=1)=>{s.pairs-=$;if(s.pairs<0)l("agentic local cross-hierarchy obstacle-work limit")};const p=$=>{s.arcs-=$;if(s.arcs<0)l("agentic local cross-hierarchy visibility-arc limit")};const g=new Float64Array(r.length+2);const y=($,_)=>{if(--s.swaps<0)l("agentic local cross-hierarchy coordinate-sort limit");return $===_?0:$-_};m(18);const b=n.stub.x-n.port.x,S=n.stub.y-n.port.y;if(b===0===(S===0))return;const x=S===0,k=Math.sign(x?b:S);const w=x?n.port.y:n.port.x,C=x?n.port.x:n.port.y;const R=u===void 0?x?n.stub.x:n.stub.y:C+k*u;const M=x?e.y:e.x,P=M+(x?e.height:e.width);const E=x?e.x:e.y,v=E+(x?e.width:e.height),L=k<0?E:v;if(!Number.isFinite(f)||f<.5||u!==void 0&&(!Number.isFinite(u)||u<0))return;if(!Number.isFinite(M+P+E+v+w+C+R)||P<=M||v<=E||w<M||w>P||C<E||C>v||R<E||R>v)return;const T=($,_,z,F,G)=>{m(g.length);g.fill(Infinity);let I=2;g[0]=$;g[1]=_;for(const[Y,W]of r){m(10);const O=x?Y.y:Y.x,N=x?Y.x:Y.y,H=x?W.y:W.x,j=x?W.x:W.y;const q=z?O:N;if((z?O!==H:N!==j)||Math.max(z?N:O,z?j:H)<F-f||Math.min(z?N:O,z?j:H)>G+f||q<=$||q>=_)continue;g[I++]=q}g.sort(y);let D=-Infinity,B;for(let Y=1;Y<I;Y++){m(5);const W=g[Y-1],O=g[Y],N=O-W,H=W+N/2;if(N>2*f&&N>D&&H>W&&H<O){D=N;B=H}}return B};let A=0;for(let $=0;$<2;$++){if(A>=8)return;let _=0;for(const z of i){m(6);const F=x?z.stub.y-z.port.y:z.stub.x-z.port.x;const G=x?z.stub.x-z.port.x:z.stub.y-z.port.y;m(4);const I=$===1;if(I?G!==0||F===0:F!==0||Math.sign(G)!==k)continue;if(++_>4)break;const D=x?z.port.y:z.port.x,B=x?z.port.x:z.port.y,Y=x?z.stub.x:z.stub.y,W=x?z.stub.y:z.stub.x;m(8);if(D<M||D>P||B<E||B>v||k*(B-C)<=0)continue;for(let O=0;O<2;O++){const N=O===0?-1:1,H=N<0?M:P;m();if(I&&N!==Math.sign(F))continue;const j=Math.min(H,w),q=Math.max(H,w);let X=R,V=false;for(let se=0;se<=t.length;se++){let oe=X;for(const de of t){m(12);const xe=x?de.y:de.x,Me=x?de.x:de.y,Ce=x?de.height:de.width,pe=x?de.width:de.height;if(!Number.isFinite(xe+Me+Ce+pe)||Ce<0||pe<0)return;if(xe>=q||xe+Ce<=j)continue;if(k>0&&Me<=X&&Me+pe>X)oe=Math.max(oe,Me+pe);if(k<0&&Me<X&&Me+pe>=X)oe=Math.min(oe,Me)}m(3);if(oe===X){V=true;break}X=oe;if(X<E||X>v)break}if(!V)continue;let ee=L;for(const se of t){m(10);const oe=x?se.y:se.x,de=x?se.x:se.y,xe=x?se.height:se.width,Me=x?se.width:se.height;if(oe>=q||oe+xe<=j)continue;if(k>0&&de>=X)ee=Math.min(ee,de);if(k<0&&de+Me<=X)ee=Math.max(ee,de+Me)}const re=T(Math.min(X,ee),Math.max(X,ee),false,j,q);m(4);if(re===void 0||k*(re-R)<=0||k*(B-re)<=0)continue;let U=N<0?P:M;const te=Math.min(re,I?B:L),J=Math.max(re,I?B:L);for(const se of t){m(10);const oe=x?se.y:se.x,de=x?se.x:se.y,xe=x?se.height:se.width,Me=x?se.width:se.height;if(de>=J||de+Me<=te||oe>P||oe+xe<M)continue;U=N<0?Math.min(U,Math.max(M,oe)):Math.max(U,Math.min(P,oe+xe))}m(2);if(N*(H-U)<=0)continue;const ae=T(Math.max(Math.min(H,U),j),Math.min(Math.max(H,U),q),true,te,J);if(ae===void 0||N*(ae-w)<0)continue;let Q;if(I){m(4);if(N*(ae-W)<0)continue;m(2);if(A>=8)return;A++;a(5);p(6);Q=x?[{x:C,y:w},{x:re,y:w},{x:re,y:ae},{x:B,y:ae},{x:B,y:D}]:[{x:w,y:C},{x:w,y:re},{x:ae,y:re},{x:ae,y:B},{x:D,y:B}]}else{const se=Math.min(ae,D),oe=Math.max(ae,D);let de=Y;for(const Me of t){m(10);const Ce=x?Me.y:Me.x,pe=x?Me.x:Me.y,Te=x?Me.height:Me.width,Fe=x?Me.width:Me.height;if(Ce>=oe||Ce+Te<=se||pe>v||pe+Fe<E)continue;de=k<0?Math.min(de,Math.max(E,pe)):Math.max(de,Math.min(v,pe+Fe))}m(2);if(k*(L-de)<=0)continue;const xe=T(Math.min(L,de),Math.max(L,de),false,se,oe);if(xe===void 0)continue;m(2);if(A>=8)return;A++;a(6);p(7);Q=x?[{x:C,y:w},{x:re,y:w},{x:re,y:ae},{x:xe,y:ae},{x:xe,y:D},{x:B,y:D}]:[{x:w,y:C},{x:w,y:re},{x:ae,y:re},{x:ae,y:xe},{x:D,y:xe},{x:D,y:B}]}m();if(h){m(2*Q.length);Q.reverse()}let K=true,Z=0;for(let se=0;se<Q.length;se++){const oe=Q[se];if(o.containsPoint(oe.x,oe.y)){K=false;break}if(se===0)continue;const de=Q[se-1],xe=de.x===oe.x?2:1;m(4);if(de.x===oe.x&&de.y===oe.y||de.x!==oe.x&&de.y!==oe.y||o.entersSegment(de.x,de.y,oe.x,oe.y)||!c(de,oe,Z||xe,xe)||(se===1||se===Q.length-1)&&!Vg(de,oe,r,f,s,l)){K=false;break}Z=xe}if(K){const se=d(Q);if(se)return se}}}}}function RA(e,t,n,i,r,o,s,a,l,c,d,u,f,h,m,p){c.arcs-=24+e.length+1;if(c.arcs<0)h("agentic local cross-hierarchy visibility-arc limit");const g=(F=1)=>{c.pairs-=F;if(c.pairs<0)h("agentic local cross-hierarchy obstacle-work limit")};const y=F=>{c.arcs-=F;if(c.arcs<0)h("agentic local cross-hierarchy visibility-arc limit")};g(12);if(e.length<2||!Ki(n,e.at(-2),e.at(-1)))return;const b=e.at(-2),S=e.at(-1),x=S.x-b.x,k=S.y-b.y;if(x===0===(k===0))return;const w=x>0?i.x+i.width:x<0?i.x:S.x;const C=k>0?i.y+i.height:k<0?i.y:S.y;g(8);if(w<Math.min(b.x,S.x)||w>Math.max(b.x,S.x)||C<Math.min(b.y,S.y)||C>Math.max(b.y,S.y))return;const R=e[0],M=e[1],P=M.x-R.x,E=M.y-R.y;if(P===0===(E===0))return;const v=P>0?t.x+t.width:P<0?t.x:R.x;const L=E>0?t.y+t.height:E<0?t.y:R.y;g(4);if(Math.abs(v-R.x)>1e-7||Math.abs(L-R.y)>1e-7)return;f(3);y(3);const T=e.slice(),A={x:v,y:L},$={x:w,y:C},_={x:w+Math.sign(x)*d,y:C+Math.sign(k)*d};T[0]=A;T[T.length-1]=$;const z={port:$,stub:_,penalty:0};for(let F=1;F<T.length;F++){const G=T[F-1],I=T[F];g(4);if(!Number.isFinite(G.x+G.y+I.x+I.y)||G.x!==I.x&&G.y!==I.y)return;if(!Vg(G,I,a,u,c,h))return;for(const D of o){g(4);if(D===i&&F===T.length-1)continue;const B=G.x===I.x?G.x>D.x&&G.x<D.x+D.width&&Math.max(G.y,I.y)>D.y&&Math.min(G.y,I.y)<D.y+D.height:G.y>D.y&&G.y<D.y+D.height&&Math.max(G.x,I.x)>D.x&&Math.min(G.x,I.x)<D.x+D.width;if(B)return}}return Ug(r,o,z,s,a,l,c,f,h,m,F=>{y(T.length+F.length);const G=new Array(T.length+F.length-1);for(let D=0;D<T.length;D++){g();G[D]=T[D]}for(let D=1;D<F.length;D++){g();G[T.length+D-1]=F[D]}let I=0;for(let D=1;D<G.length;D++){const B=G[D-1],Y=G[D],W=B.x===Y.x?2:1;g(4);if(!m(B,Y,I||W,W))return;I=W}return p(G)},0,u)}function Vg(e,t,n,i,r,o){const s=e.x===t.x;for(const[a,l]of n){r.pairs-=3;if(r.pairs<0)o("agentic local cross-hierarchy crossing-work limit");if(s!==(a.x===l.x))continue;r.pairs-=4;if(r.pairs<0)o("agentic local cross-hierarchy crossing-work limit");const c=Math.abs(s?e.x-a.x:e.y-a.y);if(c>i)continue;r.pairs-=12;if(r.pairs<0)o("agentic local cross-hierarchy crossing-work limit");const d=Math.min(s?Math.max(e.y,t.y):Math.max(e.x,t.x),s?Math.max(a.y,l.y):Math.max(a.x,l.x))-Math.max(s?Math.min(e.y,t.y):Math.min(e.x,t.x),s?Math.min(a.y,l.y):Math.min(a.x,l.x));if(d>=-i)return false}return true}function N0(e,t,n){let i=0;for(let r=0;r<e.length;r++){if(--t.pairs<0)n("agentic local cross-hierarchy self-check limit");const o=e[r];e[i++]=o;while(i>=3){t.pairs-=12;if(t.pairs<0)n("agentic local cross-hierarchy self-check limit");const s=e[i-3],a=e[i-2],l=e[i-1];if(!(s.x===a.x&&a.x===l.x&&a.y>=Math.min(s.y,l.y)&&a.y<=Math.max(s.y,l.y)||s.y===a.y&&a.y===l.y&&a.x>=Math.min(s.x,l.x)&&a.x<=Math.max(s.x,l.x)))break;e[i-2]=l;i--}}if(--t.pairs<0)n("agentic local cross-hierarchy self-check limit");e.length=i;return e}function vA(e,t,n,i,r,o,s,a,l,c,d,u=.5){s.arcs-=40+r.length+3;if(s.arcs<0)l("agentic local cross-hierarchy visibility-arc limit");const f=(S=1)=>{s.pairs-=S;if(s.pairs<0)l("agentic local cross-hierarchy obstacle-work limit")};const h=S=>{s.arcs-=S;if(s.arcs<0)l("agentic local cross-hierarchy visibility-arc limit")};const m=new Float64Array(r.length+2);const p=(S,x)=>{if(--s.swaps<0)l("agentic local cross-hierarchy coordinate-sort limit");return S===x?0:S-x};const g=(S,x,k,w,C,R)=>{f(m.length);m.fill(Infinity);let M=2;m[0]=S;m[1]=x;for(const[v,L]of r){f(10);const T=R?v.y:v.x,A=R?v.x:v.y,$=R?L.y:L.x,_=R?L.x:L.y,z=k?T:A;if((k?T!==$:A!==_)||Math.max(k?A:T,k?_:$)<w-u||Math.min(k?A:T,k?_:$)>C+u||z<=S||z>=x)continue;m[M++]=z}m.sort(p);let P=-Infinity,E;for(let v=1;v<M;v++){f(5);const L=m[v-1],T=m[v],A=T-L,$=L+A/2;if(A>2*u&&A>P&&$>L&&$<T){P=A;E=$}}return E};f(2);if(!Number.isFinite(u)||u<.5)return;f(8);const y=e.x+e.width,b=e.y+e.height;if(!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(y)||!Number.isFinite(b)||y<=e.x||b<=e.y)return;for(let S=0;S<8;S++){const x=S>=4,k=S%4;const w=k%2===0?-1:1,C=k<2?1:-1;const R=x?e.y:e.x,M=x?b:y;const P=x?e.x:e.y,E=x?y:b;const v=w<0?R:M,L=C<0?P:E;let T,A;for(const ee of n){f(6);const re=x?ee.stub.y-ee.port.y:ee.stub.x-ee.port.x;const U=x?ee.stub.x-ee.port.x:ee.stub.y-ee.port.y;if(U===0&&Math.sign(re)===w){T=ee;break}}for(const ee of i){f(6);const re=x?ee.stub.y-ee.port.y:ee.stub.x-ee.port.x;const U=x?ee.stub.x-ee.port.x:ee.stub.y-ee.port.y;if(re===0&&Math.sign(U)===C){A=ee;break}}if(!T||!A)continue;const $=x?T.port.y:T.port.x,_=x?T.port.x:T.port.y;const z=x?T.stub.y:T.stub.x;const F=x?A.port.y:A.port.x,G=x?A.port.x:A.port.y;const I=x?A.stub.x:A.stub.y;f(9);if(C*(G-_)<=0){h(2);const ee=Ug(e,t,T,[A],r,o,s,a,l,c,d,void 0,u);if(ee)return ee;continue}if($<R||$>M||_<P||_>E||F<R||F>M||G<P||G>E)continue;let D=w<0?M:R;const B=Math.min(_,L),Y=Math.max(_,L);for(const ee of t){f(12);const re=x?ee.y:ee.x,U=x?ee.x:ee.y;const te=x?ee.height:ee.width,J=x?ee.width:ee.height;if(!Number.isFinite(re)||!Number.isFinite(U)||!Number.isFinite(re+te)||!Number.isFinite(U+J)||te<0||J<0)return;if(U>=Y||U+J<=B||re>M||re+te<R)continue;D=w<0?Math.min(D,Math.max(R,re)):Math.max(D,Math.min(M,re+te))}f(2);if(w*(v-D)<=0)continue;const W=g(Math.min(v,D),Math.max(v,D),true,B,Y,x);f(3);if(W===void 0||w*(W-z)<0)continue;let O=I;const N=Math.min(W,F),H=Math.max(W,F);for(const ee of t){f(10);const re=x?ee.y:ee.x,U=x?ee.x:ee.y;const te=x?ee.height:ee.width,J=x?ee.width:ee.height;if(re>=H||re+te<=N||U>E||U+J<P)continue;O=C<0?Math.min(O,Math.max(P,U)):Math.max(O,Math.min(E,U+J))}f(2);if(C*(L-O)<=0)continue;const j=g(Math.min(L,O),Math.max(L,O),false,N,H,x);f(3);if(j===void 0||C*(j-I)<0)continue;a(5);h(6);const q=x?[{x:_,y:$},{x:_,y:W},{x:j,y:W},{x:j,y:F},{x:G,y:F}]:[{x:$,y:_},{x:W,y:_},{x:W,y:j},{x:F,y:j},{x:F,y:G}];let X=true,V=0;for(let ee=0;ee<q.length;ee++){const re=q[ee];if(o.containsPoint(re.x,re.y)){X=false;break}if(ee===0)continue;const U=q[ee-1],te=U.x===re.x?2:1;f(4);if(U.x===re.x&&U.y===re.y||U.x!==re.x&&U.y!==re.y||o.entersSegment(U.x,U.y,re.x,re.y)||!c(U,re,V||te,te)||(ee===1||ee===q.length-1)&&!Vg(U,re,r,u,s,l)){X=false;break}V=te}if(X){const ee=d(q);if(ee)return ee}}h(12);for(let S=0;S<4;S++){f(12);const x=S<2,k=S%2===0?-1:1;let w,C;for(const v of n){f(6);const L=v.stub.x-v.port.x,T=v.stub.y-v.port.y;if(x?L===0&&Math.sign(T)===k:T===0&&Math.sign(L)===k){w=v;break}}for(const v of i){f(6);const L=v.stub.x-v.port.x,T=v.stub.y-v.port.y;if(x?L===0&&Math.sign(T)===k:T===0&&Math.sign(L)===k){C=v;break}}if(!w||!C)continue;const R=x?w.port.y:w.port.x,M=x?C.port.y:C.port.x;f(4);if(R===M)continue;const P=k*(M-R)<0;h(2);const E=Ug(e,t,P?C:w,[P?w:C],r,o,s,a,l,c,d,void 0,u,P);if(E)return E}}var $0=class{constructor(t,n,i,r,o,s,a){this.canvasWidth=i;this.canvasHeight=r;this.work=o;this.reservePoints=s;this.fail=a;this.capacity(t.length+2);this.catalog=new Array(t.length);this.rails=[];this.capacity(1);this.onIndexCharge=(l,c)=>c==="capacity"?this.capacity(l):this.charge(l);this.capacity(2);this.x={cross:"x",enabled:false,seed:null,first:Infinity,last:-Infinity,memberships:0,safe:true,domainFirst:NaN,domainLast:NaN,heads:void 0};this.y={cross:"y",enabled:false,seed:null,first:Infinity,last:-Infinity,memberships:0,safe:true,domainFirst:NaN,domainLast:NaN,heads:void 0};for(let l=0;l<t.length;l++){this.charge();if(l!==n&&t[l].style!=="invisible")this.addGeometry(l,t[l].points)}this.seedAxis(this.x);this.seedAxis(this.y);this.updating=false}canvasWidth;canvasHeight;work;reservePoints;fail;catalog;rails;x;y;revision=0;active;geometrySafe=true;arcAllocated=1;pointAllocated=0;insertionVisits=0;flatMoves=0;flatSearches=0;seedBuilds=0;failed=false;updating=true;lastStart=0;lastCount=0;onIndexCharge;charge(t=1){this.work.pairs-=t;if(this.work.pairs<0){this.failed=true;this.fail("agentic local cross-hierarchy crossing-work limit")}}capacity(t){this.work.arcs-=t;if(this.work.arcs<0){this.failed=true;this.fail("agentic local cross-hierarchy visibility-arc limit")}this.arcAllocated+=t}point(){try{this.reservePoints(1);this.pointAllocated++}catch(t){this.failed=true;throw t}}axisEligible(t){this.charge(8);const n=this.rails.length,i=t.last-t.first+1;return this.geometrySafe&&n>=32&&n<=268435456&&t.safe&&Number.isSafeInteger(t.memberships)&&t.memberships<=8*n&&Number.isSafeInteger(i)&&i<=8*n}addTotals(t,n){this.charge(8);const i=t.cross==="x"?n.xLow:n.yLow;const r=t.cross==="x"?n.xHigh:n.yHigh;if(!Number.isSafeInteger(i)||!Number.isSafeInteger(r)||r<i){t.safe=false;return}t.memberships+=r-i+1;t.first=Math.min(t.first,i);t.last=Math.max(t.last,r);if(!Number.isSafeInteger(t.memberships))t.safe=false}addGeometry(t,n){this.charge(3);if(!Number.isInteger(t)||t<0||t>=this.catalog.length||this.catalog[t]!==void 0)throw new TypeError("Duplicate or invalid peer geometry publication");this.capacity(n.length+2);const i=new Array(n.length);let r=0;for(let l=0;l<n.length;l++){this.charge(4);const c=n[l],d=i[r-1];if(d?.x===c.x&&d.y===c.y)continue;this.point();i[r++]={x:c.x,y:c.y};while(r>2){this.charge(8);const u=i[r-3],f=i[r-2],h=i[r-1];if(!(u.x===f.x&&f.x===h.x&&f.y>=Math.min(u.y,h.y)&&f.y<=Math.max(u.y,h.y)||u.y===f.y&&f.y===h.y&&f.x>=Math.min(u.x,h.x)&&f.x<=Math.max(u.x,h.x)))break;i[r-2]=h;r--}}i.length=r;const o=Math.max(0,r-1);let s=0;while(s<this.rails.length){this.charge();this.flatSearches++;if(this.rails[s].route>t)break;s++}this.capacity(o);const a=this.rails.length;this.rails.length=a+o;for(let l=a-1;l>=s;l--){this.charge();this.flatMoves++;this.rails[l+o]=this.rails[l]}for(let l=0;l<o;l++){this.charge(12);const c=i[l],d=i[l+1];this.geometrySafe&&=Number.isFinite(c.x)&&Number.isFinite(c.y)&&Number.isFinite(d.x)&&Number.isFinite(d.y)&&(c.x===d.x||c.y===d.y)&&Number.isFinite(Math.abs(c.x-d.x))&&Number.isFinite(Math.abs(c.y-d.y));this.capacity(3);const u=[c,d];u.route=t;u.ordinal=l;u.x=Math.min(c.x,d.x)-.5;u.y=Math.min(c.y,d.y)-.5;u.width=Math.abs(c.x-d.x)+1;u.height=Math.abs(c.y-d.y)+1;u.xLow=Math.floor(u.x/128);u.xHigh=Math.floor((u.x+u.width)/128);u.yLow=Math.floor(u.y/128);u.yHigh=Math.floor((u.y+u.height)/128);this.rails[s+l]=u;this.addTotals(this.x,u);this.addTotals(this.y,u)}this.catalog[t]={points:i,segments:o};this.lastStart=s;this.lastCount=o}seedAxis(t){this.charge(12);const n=t.cross==="x"?this.canvasWidth:this.canvasHeight;const i=Math.min(t.first,Math.floor(-.5/128));const r=Math.max(t.last,Math.floor((n+.5)/128)),o=r-i+1;t.domainFirst=i;t.domainLast=r;if(!this.axisEligible(t)||!Number.isFinite(n)||n<0||!Number.isSafeInteger(i)||!Number.isSafeInteger(r)||!Number.isSafeInteger(o)||o>8*this.rails.length)return;this.seedBuilds++;t.seed=Ol(this.rails,t.cross,0,this.onIndexCharge);if(!t.seed)return;this.capacity(o+1);this.charge(o);t.heads=new Array(o).fill(void 0);t.enabled=true;for(let s=0;s+1<t.seed.offsets.length;s++){this.charge();const a=t.seed.firstCell+s-t.domainFirst;for(let l=t.seed.offsets[s+1]-1;l>=t.seed.offsets[s];l--){this.charge();this.capacity(1);t.heads[a]={peer:this.rails[t.seed.ordinals[l]],next:t.heads[a]}}}}insert(t,n){const i=t.cross==="x"?n.xLow:n.yLow,r=t.cross==="x"?n.xHigh:n.yHigh;for(let o=i;o<=r;o++){this.charge(2);const s=o-t.domainFirst;let a,l=t.heads[s];while(l){this.charge(2);this.insertionVisits++;if(l.peer.route>n.route||l.peer.route===n.route&&l.peer.ordinal>=n.ordinal)break;a=l;l=l.next}this.capacity(1);const c={peer:n,next:l};if(a)a.next=c;else t.heads[s]=c}}assertLease(t){if(this.failed||this.updating||t.released||this.active!==t||t.revision!==this.revision)throw new TypeError("Stale peer geometry revision")}acquire(t){this.charge(4);if(this.failed||this.updating||this.active||!Number.isInteger(t)||t<0||t>=this.catalog.length||this.catalog[t]!==void 0)throw new TypeError("Peer geometry lease is already active or owns its current route");this.capacity(3);const n={index:t,revision:this.revision,released:false,queries:0,guardCalls:0,guard:void 0,release:void 0};n.guard=(i,r,o,s)=>this.canTraverse(n,i,r,o,s);n.release=()=>this.release(n);this.charge();this.active=n;return n}enterQuery(t){this.charge();this.assertLease(t);this.charge();t.queries++}leaveQuery(t){if(t.released||this.active!==t||t.revision!==this.revision||t.queries<=0){this.charge();throw new TypeError("Peer query lease was not entered or is stale")}t.queries--}release(t){if(t.released||this.active!==t||t.revision!==this.revision||t.queries||t.guardCalls){this.charge();throw new TypeError("Cannot release stale peer geometry or an active query")}t.released=true;this.active=void 0}publish(t,n,i){this.charge(4);if(this.failed||this.updating||this.active)throw new TypeError("Cannot publish peer geometry while a revision is leased or failed");if(!Number.isInteger(t)||t<0||t>=this.catalog.length||this.catalog[t]!==void 0)throw new TypeError("Duplicate or invalid peer geometry publication");this.updating=true;if(!i){this.catalog[t]=null;this.revision++;this.updating=false;return}this.addGeometry(t,n);const r=this.lastStart,o=this.lastCount;for(let s=0;s<2;s++){const a=s===0?this.x:this.y;let l=true;for(let c=r;c<r+o;c++){this.charge(4);const d=this.rails[c],u=s===0?d.xLow:d.yLow,f=s===0?d.xHigh:d.yHigh;if(!Number.isSafeInteger(u)||!Number.isSafeInteger(f)||u<a.domainFirst||f>a.domainLast)l=false}if(!this.axisEligible(a)||!l)a.enabled=false;if(a.enabled)for(let c=r;c<r+o;c++)this.insert(a,this.rails[c])}this.revision++;this.updating=false}blocked(t,n,i,r,o){const s=i[0],a=i[1];this.charge();if(r!==o&&Ki(t,s,a))return true;const l=t.x===n.x,c=s.x===a.x;if(l===c){const d=Math.abs(l?t.x-s.x:t.y-s.y);const u=Math.min(l?Math.max(t.y,n.y):Math.max(t.x,n.x),l?Math.max(s.y,a.y):Math.max(s.x,a.x))-Math.max(l?Math.min(t.y,n.y):Math.min(t.x,n.x),l?Math.min(s.y,a.y):Math.min(s.x,a.x));if(d<=.5&&u>.01||d===0&&u>=0)return true}else{const d=l?t.x:s.x,u=l?s.y:t.y;if((t.x===n.x?Math.abs(d-t.x)<1e-7:Math.abs(u-t.y)<1e-7)&&d>=Math.min(t.x,n.x)&&d<=Math.max(t.x,n.x)&&u>=Math.min(t.y,n.y)&&u<=Math.max(t.y,n.y)&&(s.x===a.x?Math.abs(d-s.x)<1e-7:Math.abs(u-s.y)<1e-7)&&d>=Math.min(s.x,a.x)&&d<=Math.max(s.x,a.x)&&u>=Math.min(s.y,a.y)&&u<=Math.max(s.y,a.y)&&(d===s.x&&u===s.y||d===a.x&&u===a.y))return true}return false}canTraverse(t,n,i,r,o){this.charge(2);this.assertLease(t);t.guardCalls++;try{const s=n.x===i.x?this.x:this.y;const a=n.x===i.x?n.x:n.y,l=Math.floor(a/128);if(!Number.isFinite(n.x)||!Number.isFinite(n.y)||!Number.isFinite(i.x)||!Number.isFinite(i.y)||n.x!==i.x&&n.y!==i.y||!s.enabled||!Number.isSafeInteger(l)){for(let d=0;d<this.rails.length;d++)if(this.blocked(n,i,this.rails[d],r,o))return false;return true}if(l<s.domainFirst||l>s.domainLast)return true;let c=s.heads[l-s.domainFirst];while(c){if(this.blocked(n,i,c.peer,r,o))return false;c=c.next}return true}finally{t.guardCalls--}}};function TA(e,t,n,i,r,o,s){r.arcs--;if(r.arcs<0)s("agentic local cross-hierarchy visibility-arc limit");const a=new $0(e,t,n,i,r,o,s);return a}function ii(e){const t=[];for(const n of e){if(t.at(-1)?.x===n.x&&t.at(-1)?.y===n.y)continue;t.push({...n});while(t.length>2){const i=t.at(-3),r=t.at(-2),o=t.at(-1);if(!(i.x===r.x&&r.x===o.x&&r.y>=Math.min(i.y,o.y)&&r.y<=Math.max(i.y,o.y)||i.y===r.y&&r.y===o.y&&r.x>=Math.min(i.x,o.x)&&r.x<=Math.max(i.x,o.x)))break;t.splice(t.length-2,1)}}return t}function LA(e,t){const n=[];let i=0;return{get arcs(){return i},acquire(r,o){const s=r*4;if(!Number.isSafeInteger(s)||s<4||s>2147483647)t("agentic local cross-hierarchy visibility-arc limit");let a;for(const l of n){o();if(!l.active&&l.capacity>=s&&(!a||l.capacity<a.capacity))a=l}if(!a){e(s);i+=s;a={active:false,capacity:s,nodes:new Int32Array(s),distances:new Float64Array(s)};n.push(a)}o(s);a.nodes.fill(-1,0,s);a.distances.fill(0,0,s);a.active=true;return a}}}function _0(e,t){const n=[];let i=0;const r=o=>{e(o);i+=o};return{get vertices(){return i},acquire(o,s){if(!Number.isSafeInteger(o)||o<1)throw new TypeError("Invalid sparse query capacity");let a;for(const l of n){s();if(!l.active&&l.capacity>=o&&(!a||l.capacity<a.capacity))a=l}if(!a){let l=Math.min(32,o);while(l<o)l*=2;if(!Number.isSafeInteger(l))t("agentic local cross-hierarchy visibility-expansion limit");r(l);a={active:false,capacity:l,distance:new Float64Array(l),parents:new Int32Array(l),roots:new Int32Array(l),slots:new Int32Array(l),heapPages:new Map,reserveHeap:r};n.push(a)}a.active=true;return a}}}function D0(e,t,n,i,r,o,s,a,l,c,d=false,u,f,h,m){s.pairs-=8;if(s.pairs<0)l("agentic local cross-hierarchy obstacle-work limit");const p=Math.max(e.x,Math.min(t.x-2*o,r.x-o));const g=Math.max(e.y,Math.min(t.y-2*o,r.y-o));const y=Math.min(e.x+e.width,Math.max(t.x+t.width+2*o,r.x+o));const b=Math.min(e.y+e.height,Math.max(t.y+t.height+2*o,r.y+o));if(y<=p||b<=g)l("cross-hierarchy route has no bounded clear corridor");return Qf({x:p,y:g,width:y-p,height:b-g},n,i,[r],o,s,a,l,c,d,u,f,h,m)}function Qf(e,t,n,i,r,o,s,a,l,c=false,d,u,f,h){const m=e.x+e.width,p=e.y+e.height;let g=0;const y=N=>{if(g+N>s)a("agentic local cross-hierarchy visibility-expansion limit");l?.(N);g+=N};const b=(N=1)=>{o.pairs-=N;if(o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit")};const S=N=>N.x>=e.x&&N.x<=m&&N.y>=e.y&&N.y<=p;const x=t.filter(N=>{b();return N.x<=m&&N.x+N.width>=e.x&&N.y<=p&&N.y+N.height>=e.y});b();let k=x.length>0;for(const N of x){b(8);const H=N.x+N.width,j=N.y+N.height;if(!Number.isFinite(N.x)||!Number.isFinite(N.y)||!Number.isFinite(H)||!Number.isFinite(j)||H<=N.x||j<=N.y){k=false;break}}const w=[],C=new Map;let R;const M=N=>`${N.x},${N.y}`;const P=N=>{if(d)return!(R??=d()).containsPoint(N.x,N.y);for(const H of x){b();if(N.x>H.x&&N.x<H.x+H.width&&N.y>H.y&&N.y<H.y+H.height)return false}return true};const E=N=>{b();if(!Number.isFinite(N.x+N.y))a("agentic local cross-hierarchy coordinate limit");if(!S(N)||C.has(M(N))||!P(N))return;y(1);C.set(M(N),w.length);w.push({...N})};const v=N=>{for(const H of[N.x,N.x+N.width])for(const j of[N.y,N.y+N.height])E({x:H,y:j})};v(e);for(const N of x)v(N);for(let N=0;N<x.length;N++)for(let H=N+1;H<x.length;H++){b();const j=x[N],q=x[H];if(j.x>q.x+q.width||q.x>j.x+j.width||j.y>q.y+q.height||q.y>j.y+j.height)continue;for(const[X,V]of[[j,q],[q,j]]){for(const ee of[X.x,X.x+X.width])for(const re of[V.y,V.y+V.height]){b();if(ee>=V.x&&ee<=V.x+V.width&&re>=X.y&&re<=X.y+X.height)E({x:ee,y:re})}}}for(const N of n){E(N.port);E(N.stub)}for(const N of i)E(N);const L=new Set;for(const N of n){b(2);L.add(M(N.port));L.add(M(N.stub))}for(const N of i){b();L.add(M(N))}if(c&&x.length){let N=m,H=e.x,j=p,q=e.y;for(const U of x){b(8);N=Math.min(N,Math.max(e.x,U.x));H=Math.max(H,Math.min(m,U.x+U.width));j=Math.min(j,Math.max(e.y,U.y));q=Math.max(q,Math.min(p,U.y+U.height))}b(4);const X=(U,te)=>U+(te-U)/2;const V=[...N>e.x?[X(e.x,N)]:[],...H<m?[X(H,m)]:[]];const ee=[...j>e.y?[X(e.y,j)]:[],...q<p?[X(q,p)]:[]];const re=(U,te,J,ae,Q)=>{if(!f)return U;let K;const Z=Q>U?1:-1;for(const[oe,de]of f){b();const xe=J?oe.x:oe.y;if((J?oe.x!==de.x:oe.y!==de.y)||te<Math.min(J?oe.y:oe.x,J?de.y:de.x)||te>Math.max(J?oe.y:oe.x,J?de.y:de.x)||Math.abs(xe-U)>.5||xe<=Math.min(ae,Q)||xe>=Math.max(ae,Q)||Z*(Q-xe)<=0)continue;if(K===void 0||Z*(xe-K)>0)K=xe}if(K===void 0)return U;let se=Q;for(const[oe,de]of f){b();const xe=J?oe.x:oe.y;if((J?oe.x!==de.x:oe.y!==de.y)||te<Math.min(J?oe.y:oe.x,J?de.y:de.x)||te>Math.max(J?oe.y:oe.x,J?de.y:de.x)||Z*(xe-K)<=0||Z*(se-xe)<=0)continue;se=xe}return X(K,se)};for(const U of V)for(const te of ee){const J={x:re(U,te,true,U<N?e.x:m,U<N?N:H),y:re(te,U,false,te<j?e.y:p,te<j?j:q)};E(J);b();L.add(M(J))}}const T=[],A=[],$=[],_=[];const z=(N,H,j)=>{b();if(N.x===H.x&&N.y===H.y)return;if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");const q=N.y===H.y;const X=q?{fixed:N.y,lower:Math.min(N.x,H.x),upper:Math.max(N.x,H.x)}:{fixed:N.x,lower:Math.min(N.y,H.y),upper:Math.max(N.y,H.y)};(q?T:A).push(X);if(j)(q?$:_).push(X)};const F=w.length;let G;if(d){if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");G={left:e.x,right:m,top:e.y,bottom:p}}for(let N=0;N<F;N++){const H=w[N];let j=e.x,q=m,X=e.y,V=p;if(G){const re=R??=d();re.projectPoint(H.x,H.y,e,G);j=G.left;q=G.right;X=G.top;V=G.bottom}else for(const re of x){b(4);if(H.y>re.y&&H.y<re.y+re.height){if(re.x>=H.x)q=Math.min(q,re.x);if(re.x+re.width<=H.x)j=Math.max(j,re.x+re.width)}if(H.x>re.x&&H.x<re.x+re.width){if(re.y>=H.y)V=Math.min(V,re.y);if(re.y+re.height<=H.y)X=Math.max(X,re.y+re.height)}}const ee=L.has(M(H));for(const re of[{x:j,y:H.y},{x:q,y:H.y},{x:H.x,y:X},{x:H.x,y:V}]){E(re);z(H,re,ee)}}const I=(N,H)=>{if(--o.swaps<0)a("agentic local cross-hierarchy coordinate-sort limit");return N-H};const D=N=>{const H=new Map;for(const j of N){b();const q=H.get(j.fixed)??[];q.push(j);H.set(j.fixed,q)}for(const[j,q]of H){q.sort((V,ee)=>I(V.lower,ee.lower)||I(V.upper,ee.upper));const X=[];for(const V of q){b();const ee=X.at(-1);if(ee&&V.lower<=ee.upper)ee.upper=Math.max(ee.upper,V.upper);else{if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");X.push({...V})}}H.set(j,X)}return{coordinates:[...H.keys()].sort(I),lines:H}};const B=(N,H,j)=>{const q=D(H),X=D(N);for(const V of X.lines.values())for(const ee of V){let re=0,U=q.coordinates.length;while(re<U){b();const te=Math.floor((re+U)/2);if(q.coordinates[te]<ee.lower)re=te+1;else U=te}for(let te=re;te<q.coordinates.length;te++){b();const J=q.coordinates[te];if(J>ee.upper)break;for(const ae of q.lines.get(J)){b();if(ae.lower>ee.fixed)break;if(ae.upper>=ee.fixed)E(j?{x:J,y:ee.fixed}:{x:ee.fixed,y:J})}}}return q};const Y=B($,A,true);const W=B(_,T,false);let O;try{O=h?.acquire(w.length,b);if(k&&d){b(10);k=kA(R,t)}const N=O?void 0:w.map(()=>[]);const H=(U,te)=>{if(d)return!(R??=d()).entersSegment(U.x,U.y,te.x,te.y);for(const J of x){b();if(li(U,te,J))return false}return true};for(const U of[1,2]){const te=new Map;w.forEach((J,ae)=>{b();const Q=U===1?J.y:J.x,K=te.get(Q)??[];K.push(ae);te.set(Q,K)});for(const J of te.values()){if(k)b();const ae=w[J[0]];const Q=k?(U===1?W:Y).lines.get(U===1?ae.y:ae.x):void 0;let K=0;J.sort((Z,se)=>{if(--o.swaps<0)a("agentic local cross-hierarchy coordinate-sort limit");return U===1?w[Z].x-w[se].x:w[Z].y-w[se].y});for(let Z=1;Z<J.length;Z++){if(O)b();else{o.arcs-=2;if(o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit")}const se=J[Z-1],oe=J[Z];const de=U===1?w[se].x:w[se].y,xe=U===1?w[oe].x:w[oe].y;let Me;while(k){b();if(!Q||K>=Q.length)break;const Te=Q[K];b();if(Te.upper>=de){Me=Te;break}b();K++}let Ce=false;if(Me){b();if(Me.lower<=de){b();Ce=xe<=Me.upper}}if(!Ce&&!H(w[se],w[oe]))continue;const pe=Math.abs(w[se].x-w[oe].x)+Math.abs(w[se].y-w[oe].y);if(O){const Te=se*4+(U===1?1:3),Fe=oe*4+(U===1?0:2);O.nodes[Te]=oe;O.distances[Te]=pe;O.nodes[Fe]=se;O.distances[Fe]=pe}else{N[se].push({node:oe,axis:U,distance:pe});N[oe].push({node:se,axis:U,distance:pe})}}}}const j=U=>C.get(M(U))??-1;const q=w.length*3,X=32;const V=u??_0(y,a);let ee=false,re=0;return{get vertices(){return g},retire(){if(ee)return;if(re)throw new TypeError("Cannot retire a sparse graph during an active query");ee=true;if(O)O.active=false},route(U,te,J=()=>true,ae=()=>true){if(ee)throw new TypeError("Cannot query a retired sparse graph");re++;try{const Q=j(te);if(Q<0)a("cross-hierarchy route has no clear anchor");b(q);const K=V.acquire(q,b);try{const{distance:Z,parents:se,roots:oe,slots:de,heapPages:xe}=K;Z.fill(Infinity,0,q);se.fill(-1,0,q);oe.fill(-1,0,q);de.fill(-1,0,q);let Me=0;const Ce=he=>xe.get(Math.floor(he/X))[he%X];const pe=(he,fe)=>{const be=Math.floor(he/X);let ge=xe.get(be);if(!ge){const Re=Math.min(X,K.capacity-be*X);K.reserveHeap(Re);ge=new Int32Array(Re);xe.set(be,ge)}ge[he%X]=fe};const Te=he=>{const fe=w[Math.floor(he/3)];return Z[he]+Math.abs(fe.x-te.x)+Math.abs(fe.y-te.y)};const Fe=(he,fe)=>{if(--o.swaps<0)a("agentic local cross-hierarchy heap-work limit");const be=Te(he),ge=Te(fe);return be<ge||be===ge&&he<fe};const De=(he,fe)=>{const be=Ce(he);pe(he,Ce(fe));pe(fe,be);de[Ce(he)]=he;de[Ce(fe)]=fe};const Be=he=>{let fe=de[he];if(fe===-2)return;if(fe<0){fe=Me;pe(Me++,he);de[he]=fe}while(fe>0){const be=Math.floor((fe-1)/2);if(!Fe(Ce(fe),Ce(be)))break;De(fe,be);fe=be}};const me=()=>{const he=Ce(0),fe=Ce(--Me);de[he]=-2;if(Me){pe(0,fe);de[fe]=0;let be=0;for(;;){let ge=be*2+1;if(ge>=Me)break;if(ge+1<Me&&Fe(Ce(ge+1),Ce(ge)))ge++;if(!Fe(Ce(ge),Ce(be)))break;De(be,ge);be=ge}}return he};for(let he=0;he<U.length;he++){b();const fe=U[he],be=j(fe.stub);if(be<0||!S(fe.port)||!P(fe.port)||!H(fe.port,fe.stub))continue;const ge=fe.port.x===fe.stub.x?2:fe.port.y===fe.stub.y?1:0;if(!ge)throw new TypeError("Measured terminal lead must be orthogonal");if(!ae(fe.port,fe.stub,ge,ge))continue;const Re=be*3+ge,Ie=Math.abs(fe.stub.x-fe.port.x)+Math.abs(fe.stub.y-fe.port.y)+fe.penalty;if(Ie<Z[Re]){Z[Re]=Ie;oe[Re]=he;Be(Re)}}while(Me){const he=me(),fe=Math.floor(he/3),be=he%3;if(fe===Q){const Re=[];let Ie=he;while(se[Ie]>=0){b();Re.push(w[Math.floor(Ie/3)]);Ie=se[Ie]}Re.push(w[Math.floor(Ie/3)],U[oe[Ie]].port);let ne=0,we;for(const ke of Re){b();if(!we||we.x!==ke.x||we.y!==ke.y)ne++;we=ke}y(ne);const Ee=ii(Re.reverse());if(J(Ee))return Ee}const ge=N?.[fe];for(let Re=0;Re<(O?4:ge.length);Re++){let Ie,ne,we;if(O){const le=fe*4+Re;Ie=O.nodes[le];if(Ie<0){b();continue}ne=Re<2?1:2;we=O.distances[le]}else{const le=ge[Re];Ie=le.node;ne=le.axis;we=le.distance}if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");if(se[he]===-1){b();const le=U[oe[he]],Se=w[fe],Pe=w[Ie];const Ae=le.stub.x-le.port.x,Ne=le.stub.y-le.port.y;if(Ae!==0&&ne===1&&Math.sign(Pe.x-Se.x)===-Math.sign(Ae)||Ne!==0&&ne===2&&Math.sign(Pe.y-Se.y)===-Math.sign(Ne))continue}const Ee=Ie*3+ne;const ke=Z[he]+we+(be===ne?0:r*2);if(de[Ee]!==-2&&ke<Z[Ee]&&ae(w[fe],w[Ie],be,ne)){Z[Ee]=ke;se[Ee]=he;oe[Ee]=oe[he];Be(Ee)}}}return a("cross-hierarchy route has no bounded clear corridor")}finally{K.active=false}}finally{re--}}}}catch(N){if(O)O.active=false;throw N}}var fn=32;function AA(e,t,n,i,r,o,s,a,l){let c=0;const d=_=>{if(c+_>s)a("agentic local cross-hierarchy visibility-expansion limit");l?.(_);c+=_};const u=e.x+e.width,f=e.y+e.height;const h=_=>_.x>=e.x&&_.x<=u&&_.y>=e.y&&_.y<=f;const m=t.filter(_=>{if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");return _.x<=u&&_.x+_.width>=e.x&&_.y<=f&&_.y+_.height>=e.y});const p=new Set([e.x,u]),g=new Set([e.y,f]);for(const _ of m){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");for(const z of[_.x,_.x+_.width])if(z>=e.x&&z<=u)p.add(z);for(const z of[_.y,_.y+_.height])if(z>=e.y&&z<=f)g.add(z)}const y=_=>{if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");if(!Number.isFinite(_.x+_.y))a("agentic local cross-hierarchy coordinate limit");if(h(_)){p.add(_.x);g.add(_.y)}};for(const _ of n){y(_.port);y(_.stub)}for(const _ of i)y(_);const b=(_,z)=>{if(--o.swaps<0)a("agentic local cross-hierarchy coordinate-sort limit");return _-z};const S=[...p].sort(b),x=[...g].sort(b),k=S.length,w=k*x.length;if(!Number.isSafeInteger(w*3)||w*3>2147483647)a("agentic local cross-hierarchy coordinate limit");const C=(_=false)=>{const z=new Map;return{get(F){return z.get(Math.floor(F/fn))?.[F%fn]??0},set(F,G){const I=Math.floor(F/fn);let D=z.get(I);if(!D){const B=Math.min(fn,w-I*fn);if(_){o.arcs-=B;if(o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit")}else d(B);D=new Int8Array(B);z.set(I,D)}D[F%fn]=G}}};const R=C(),M=C(true),P=C(true);let E;const v=()=>E??=PA(m,o,a);const L=_=>{const z=R.get(_);if(z)return z===1;const F=S[_%k],G=x[Math.floor(_/k)];if(v().containsPoint(F,G)){R.set(_,-1);return false}R.set(_,1);return true};const T=(_,z,F,G)=>{return!v().entersSegment(_,z,F,G)};const A=(_,z)=>T(S[_%k],x[Math.floor(_/k)],S[z%k],x[Math.floor(z/k)]);const $=_=>{const z=S.indexOf(_.x),F=x.indexOf(_.y);return z<0||F<0?-1:F*k+z};return{get vertices(){return c},virtualVertices:w*3,route(_,z){const F=$(z);if(F<0||!L(F))a("cross-hierarchy route has no clear anchor");const G=new Map,I=new Map;const D=J=>{const ae=Math.floor(J/fn);let Q=G.get(ae);if(!Q){const K=Math.min(fn,w*3-ae*fn);d(K);Q={distance:new Float64Array(K).fill(Infinity),parent:new Int32Array(K).fill(-1),slots:new Int32Array(K).fill(-1),roots:new Int32Array(K).fill(-1)};G.set(ae,Q)}return Q};const B=J=>G.get(Math.floor(J/fn));const Y=J=>B(J)?.distance[J%fn]??Infinity;const W=J=>B(J)?.parent[J%fn]??-1;const O=J=>B(J)?.slots[J%fn]??-1;const N=J=>B(J)?.roots[J%fn]??-1;let H=0;const j=J=>I.get(Math.floor(J/fn))[J%fn];const q=(J,ae)=>{const Q=Math.floor(J/fn);let K=I.get(Q);if(!K){const Z=Math.min(fn,w*3-Q*fn);d(Z);K=new Int32Array(Z);I.set(Q,K)}K[J%fn]=ae};const X=J=>{const ae=Math.floor(J/3);return Y(J)+Math.abs(S[ae%k]-z.x)+Math.abs(x[Math.floor(ae/k)]-z.y)};const V=(J,ae)=>{if(--o.swaps<0)a("agentic local cross-hierarchy heap-work limit");return X(J)<X(ae)||X(J)===X(ae)&&J<ae};const ee=(J,ae)=>{const Q=j(J);q(J,j(ae));q(ae,Q);D(j(J)).slots[j(J)%fn]=J;D(j(ae)).slots[j(ae)%fn]=ae};const re=J=>{let ae=O(J);if(ae===-2)return;if(ae<0){ae=H;q(H++,J);D(J).slots[J%fn]=ae}while(ae>0){const Q=Math.floor((ae-1)/2);if(!V(j(ae),j(Q)))break;ee(ae,Q);ae=Q}};const U=()=>{const J=j(0),ae=j(--H);D(J).slots[J%fn]=-2;if(H){q(0,ae);D(ae).slots[ae%fn]=0;let Q=0;while(2*Q+1<H){let K=2*Q+1;if(K+1<H&&V(j(K+1),j(K)))K++;if(!V(j(K),j(Q)))break;ee(Q,K);Q=K}}return J};for(let J=0;J<_.length;J++){const ae=_[J],Q=$(ae.stub);if(Q<0||!h(ae.port)||!L(Q))continue;if(!T(ae.port.x,ae.port.y,ae.stub.x,ae.stub.y))continue;const K=ae.port.x===ae.stub.x?2:1,Z=Q*3+K;const se=Math.abs(ae.stub.x-ae.port.x)+Math.abs(ae.stub.y-ae.port.y)+ae.penalty;if(se<Y(Z)){const oe=D(Z),de=Z%fn;oe.distance[de]=se;oe.roots[de]=J;re(Z)}}const te=J=>{d(1);return{x:S[J%k],y:x[Math.floor(J/k)]}};while(H){const J=U(),ae=Math.floor(J/3),Q=J%3;if(ae===F){const se=[];let oe=J;while(W(oe)>=0){se.push(te(Math.floor(oe/3)));oe=W(oe)}se.push(te(Math.floor(oe/3)));d(1);se.push({..._[N(oe)].port});const de=[];for(const xe of se.reverse()){if(de.at(-1)?.x===xe.x&&de.at(-1)?.y===xe.y)continue;de.push(xe);while(de.length>2){const Me=de.at(-3),Ce=de.at(-2),pe=de.at(-1);if(!(Me.x===Ce.x&&Ce.x===pe.x&&Ce.y>=Math.min(Me.y,pe.y)&&Ce.y<=Math.max(Me.y,pe.y)||Me.y===Ce.y&&Ce.y===pe.y&&Ce.x>=Math.min(Me.x,pe.x)&&Ce.x<=Math.max(Me.x,pe.x)))break;de.splice(de.length-2,1)}}return de}const K=ae%k,Z=Math.floor(ae/k);for(let se=0;se<4;se++){const oe=se===0?K>0?ae-1:-1:se===1?K+1<k?ae+1:-1:se===2?Z>0?ae-k:-1:Z+1<x.length?ae+k:-1;const de=se<2?1:2;if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");if(oe<0||!L(oe))continue;const xe=Math.min(ae,oe),Me=de===1?M:P;if(!Me.get(xe))Me.set(xe,A(ae,oe)?1:-1);if(Me.get(xe)!==1)continue;const Ce=oe*3+de;const pe=Y(J)+Math.abs(S[ae%k]-S[oe%k])+Math.abs(x[Math.floor(ae/k)]-x[Math.floor(oe/k)])+(Q===de?0:r*2);if(O(Ce)!==-2&&pe<Y(Ce)){const Te=D(Ce),Fe=Ce%fn;Te.distance[Fe]=pe;Te.parent[Fe]=J;Te.roots[Fe]=N(J);re(Ce)}}}return a("cross-hierarchy route has no bounded clear corridor")}}}var Kg=class extends Error{};function IA(e,t,n,i){const r=e.groups,o=e.nodes.length,s=Math.max(8,e.edgeSpacing??6,e.minimumTerminalLead??0);const a=new Map,l=new Map,c=new Map,d=new Map;const u=(f,h)=>{for(let m=t[h];m>=0;m=t[o+m]){if(--n.pairs<0)i("agentic local cross-hierarchy obstacle-work limit");if(m===f)return true}return false};for(const[f,h]of e.edges.entries()){if(--n.pairs<0)i("agentic local cross-hierarchy obstacle-work limit");const m=h.source>=o&&u(h.source-o,h.target);const p=h.target>=o&&u(h.target-o,h.source);if(!m&&!p)continue;let g=s;if(h.minSpan!==1){if(!Number.isSafeInteger(h.minSpan)||h.minSpan<1)throw new TypeError("Invalid measured compound edge dimensions");const C=Rp(h.minSpan);if(!Number.isSafeInteger(C)||C<0)i("agentic local coordinate-range limit");g=Math.max(s,C)}const y=(m?h.source:h.target)-o,b=r[y];const S=l.get(y)??0,x=Math.max(h.label?.height??0,h.boundaryMarker?.height??0);const k=x+2*s,w=Math.max(2*s,(h.boundaryMarker?.inset??0)+s);if(--n.arcs<0)i("agentic local cross-hierarchy visibility-arc limit");a.set(f,{edge:f,container:y,interior:m?h.target:h.source,containerEnd:m?"source":"target",rowOffset:b.padding.top+S+s+x/2,labelInset:w,minimumLead:g,...h.label?{label:{...h.label}}:{}});l.set(y,S+k);c.set(y,Math.max(c.get(y)??0,w+(h.label?.width??0)+2*s));d.set(y,Math.max(d.get(y)??0,g))}return{connections:a,clearance:s,groups:a.size?r.map((f,h)=>l.has(h)?{...f,headerHeight:f.headerHeight??f.padding.top,padding:{...f.padding,top:f.padding.top+l.get(h),left:Math.max(f.padding.left+c.get(h),d.get(h)+s)}}:f):r}}function FA(e,t,n,i){const r=e.connections.get(t),o=n[r.container],s=e.clearance;const a=o.y+r.rowOffset;i?.(r.label?3:2);const l=[{x:o.x,y:a},{x:o.x+e.groups[r.container].padding.left-s,y:a}];return{points:r.containerEnd==="source"?l:l.reverse(),...r.label?{labelPosition:{x:o.x+r.labelInset+r.label.width/2,y:a}}:{}}}function NA(e,t,n,i,r,o){const{work:s,fail:a}=o,l=i.connections.get(r),c=i.clearance;const d=e.nodes.length,u=t.groups,f=u[l.container];let h=0;const m=G=>{if(h+G>o.remainingVertices)a("agentic local cross-hierarchy visibility-expansion limit");o.reserveVertices(G);h+=G};const p=()=>{if(--s.pairs<0)a("agentic local cross-hierarchy obstacle-work limit")};const g=(G,I)=>{m(1);return{x:G,y:I}};const y=e.nodes.map((G,I)=>{p();return{...t.nodes[I],width:G.width,height:G.height}});const b=[...y,...u],S=b[l.interior];const x=new Set;for(let G=n[l.interior];G>=0;G=n[d+G]){p();x.add(G)}const k=(G,I)=>({x:G.x-I,y:G.y-I,width:G.width+2*I,height:G.height+2*I});const w=y.map((G,I)=>{p();return I===l.interior?G:k(G,c)});u.forEach((G,I)=>{p();if(!x.has(I))w.push(I+d===l.interior?G:k(G,c));else{const D=i.groups[I].headerHeight??i.groups[I].padding.top;if(D>0)w.push(k({...G,height:D},2))}});for(const[G,I]of e.edges.entries()){p();if(!I.label)continue;const D=i.connections.get(G),B=D&&u[D.container];const Y=D&&B?B.x+D.labelInset+I.label.width/2:t.edges[G]?.labelPosition?.x;const W=D&&B?B.y+D.rowOffset:t.edges[G]?.labelPosition?.y;if(I.label&&Y!==void 0&&W!==void 0)w.push(k({x:Y-I.label.width/2,y:W-I.label.height/2,width:I.label.width,height:I.label.height},2))}const C=i.groups[l.container].headerHeight??i.groups[l.container].padding.top;const R={x:f.x,y:f.y+C+2,width:f.width,height:f.height-C-2};const M=f.y+l.rowOffset;const P=g(f.x,M),E=g(f.x+i.groups[l.container].padding.left-c,M);let v=0,L=0;for(const[G,I]of e.edges.entries()){p();if(I.source===l.interior||I.target===l.interior){v++;if(G<r)L++}}const T=[...new Set([(L+1)/(v+1),.5,.25,.75])];const A=[];const $=l.interior>=d?i.groups[l.interior-d]:void 0;const _=S.y+($?($.headerHeight??$.padding.top)+2:0);for(const G of["L","R","B","T"])for(const I of T){p();if(G==="T"&&$&&($.headerHeight??$.padding.top)>0)continue;const D=G==="L"?S.x:G==="R"?S.x+S.width:S.x+I*S.width;const B=G==="T"?S.y:G==="B"?S.y+S.height:_+I*(S.y+S.height-_);const Y=g(D,B),W=g(D+(G==="L"?-c:G==="R"?c:0),B+(G==="T"?-c:G==="B"?c:0));if(--s.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");A.push({port:Y,stub:W,penalty:0})}const z=G=>{if(G==="cross-hierarchy route has no bounded clear corridor")throw new Kg(G);return a(G)};const F=Qf(R,w,A,[E],c,s,o.remainingVertices,z,m,false,void 0,o.queryWorkspaces);for(const G of A){let I;const D=(B,Y)=>{p();const{port:W,stub:O}=G;if(B.x===W.x&&B.y===W.y&&Y.x===O.x&&Y.y===O.y)return true;const N=W.y===O.y,H=N?B.y===Y.y:B.x===Y.x;if(H){if(N?B.y!==W.y:B.x!==W.x)return true;const V=Math.max(Math.min(N?B.x:B.y,N?Y.x:Y.y),Math.min(N?W.x:W.y,N?O.x:O.y));const ee=Math.min(Math.max(N?B.x:B.y,N?Y.x:Y.y),Math.max(N?W.x:W.y,N?O.x:O.y));return V>ee||V===ee&&V===(N?O.x:O.y)}const j=N?B.x:W.x,q=N?W.y:B.y;const X=j>=Math.min(B.x,Y.x)&&j<=Math.max(B.x,Y.x)&&q>=Math.min(B.y,Y.y)&&q<=Math.max(B.y,Y.y)&&j>=Math.min(W.x,O.x)&&j<=Math.max(W.x,O.x)&&q>=Math.min(W.y,O.y)&&q<=Math.max(W.y,O.y);return!X||j===O.x&&q===O.y};try{F.route([G],E,B=>{const Y=l.containerEnd==="source"?[P,...B.toReversed()]:[...B,P];let W=0,O;for(const U of Y){p();if(!O||O.x!==U.x||O.y!==U.y)W++;O=U}m(W);const N=ii(Y);const H=l.containerEnd==="source"?N[0]:N.at(-1);const j=l.containerEnd==="source"?N[1]:N.at(-2);if(H.x!==f.x||H.y!==M||j.y!==M||j.x-H.x<l.minimumLead)return false;const q=l.containerEnd==="source"?N.at(-1):N[0];const X=l.containerEnd==="source"?N.at(-2):N[1];const V=q.x>=S.x&&q.x<=S.x+S.width&&q.y>=S.y&&q.y<=S.y+S.height&&(q.x===S.x&&X.y===q.y&&X.x<q.x||q.x===S.x+S.width&&X.y===q.y&&X.x>q.x||q.y===S.y&&X.x===q.x&&X.y<q.y||q.y===S.y+S.height&&X.x===q.x&&X.y>q.y);if(!V||Math.abs(X.x-q.x)+Math.abs(X.y-q.y)<c)return false;const ee=l.label?g(f.x+l.labelInset+l.label.width/2,M):void 0;if(ee&&!N.some((U,te)=>te>0&&Ki(ee,N[te-1],U)))return false;for(const[U,te]of u.entries())if(x.has(U)){const J=i.groups[U].headerHeight??i.groups[U].padding.top;for(let ae=1;ae<N.length;ae++){p();if(J>0&&li(N[ae-1],N[ae],{...te,height:J}))return false}}const re={points:N,...ee?{labelPosition:ee}:{}};if(!o.accept(re))return false;I=re;return true},D)}catch(B){if(!(B instanceof Kg))throw B}if(I)return I}return a("cross-hierarchy route has no bounded clear corridor")}var Zf=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t});var ao=(e,t,n)=>(t.x===n.x?Math.abs(e.x-t.x)<1e-7:Math.abs(e.y-t.y)<1e-7)&&e.x>=Math.min(t.x,n.x)&&e.x<=Math.max(t.x,n.x)&&e.y>=Math.min(t.y,n.y)&&e.y<=Math.max(t.y,n.y);function ic(e,t,n,i,r=[.5,.25,.75]){const o=t==="LR"?"E":t==="RL"?"W":t==="BT"?"N":"S";const s={N:"S",E:"W",S:"N",W:"E"};const a=n?o:s[o];const l=[a,...["N","E","S","W"].filter(c=>c!==a)];return l.flatMap((c,d)=>r.map(u=>{const f=c==="N"||c==="S"?{x:e.x+u*e.width,y:c==="N"?e.y:e.y+e.height}:{x:c==="W"?e.x:e.x+e.width,y:e.y+u*e.height};const h={x:f.x+(c==="E"?i:c==="W"?-i:0),y:f.y+(c==="S"?i:c==="N"?-i:0)};return{port:f,stub:h,penalty:d*i*2+Math.abs(u-.5)*i}}))}function eh(e,t,n){for(let i=2;i<e.length;i++){if(--t.pairs<0)n("agentic local cross-hierarchy self-check limit");const r=e[i-2],o=e[i-1],s=e[i];if(r.x===o.x&&o.x===s.x&&Math.sign(o.y-r.y)!==Math.sign(s.y-o.y)||r.y===o.y&&o.y===s.y&&Math.sign(o.x-r.x)!==Math.sign(s.x-o.x))return true}for(let i=1;i<e.length;i++)for(let r=i+2;r<e.length;r++){if(--t.pairs<0)n("agentic local cross-hierarchy self-check limit");const o=e[i-1],s=e[i],a=e[r-1],l=e[r];if(o.x===s.x&&a.x===l.x){if(o.x===a.x&&Math.min(Math.max(o.y,s.y),Math.max(a.y,l.y))>=Math.max(Math.min(o.y,s.y),Math.min(a.y,l.y)))return true}else if(o.y===s.y&&a.y===l.y){if(o.y===a.y&&Math.min(Math.max(o.x,s.x),Math.max(a.x,l.x))>=Math.max(Math.min(o.x,s.x),Math.min(a.x,l.x)))return true}else{const c=o.x===s.x?o.x:a.x,d=o.x===s.x?a.y:o.y;if(ao({x:c,y:d},o,s)&&ao({x:c,y:d},a,l))return true}}return false}function F3(e,t,n){let i=ii(e);for(;;){let r;for(let o=2;o<i.length;o++){if(--t.pairs<0)n("agentic local cross-hierarchy self-check limit");const s=i[o-2],a=i[o-1],l=i[o];if(s.x===a.x&&a.x===l.x||s.y===a.y&&a.y===l.y){r=[...i.slice(0,o-1),...i.slice(o)];break}}for(let o=1;!r&&o<i.length;o++)for(let s=o+2;s<i.length;s++){if(--t.pairs<0)n("agentic local cross-hierarchy self-check limit");const a=i[o-1],l=i[o],c=i[s-1],d=i[s];let u;if(a.x===l.x&&c.x===d.x){const f=Math.max(Math.min(a.y,l.y),Math.min(c.y,d.y)),h=Math.min(Math.max(a.y,l.y),Math.max(c.y,d.y));if(a.x===c.x&&f<=h)u={x:a.x,y:Math.max(f,Math.min(h,a.y))}}else if(a.y===l.y&&c.y===d.y){const f=Math.max(Math.min(a.x,l.x),Math.min(c.x,d.x)),h=Math.min(Math.max(a.x,l.x),Math.max(c.x,d.x));if(a.y===c.y&&f<=h)u={x:Math.max(f,Math.min(h,a.x)),y:a.y}}else{const f={x:a.x===l.x?a.x:c.x,y:a.x===l.x?c.y:a.y};if(ao(f,a,l)&&ao(f,c,d))u=f}if(u){r=[...i.slice(0,o),u,...i.slice(s)];break}}if(!r)return i;i=ii(r)}}function rc(e,t,n,i,r,o,s,a,l,c=()=>true,d=false,u){const f=e.x+e.width,h=e.y+e.height;const m={};const p=()=>{if(a.pairs<=0)throw m;a.pairs--};const g=(y,b=true)=>{if(a.candidates<=0||a.pairs<=0)return;a.candidates--;const S=ii(y);for(const x of S)if(!Number.isFinite(x.x+x.y)||x.x<e.x||x.x>f||x.y<e.y||x.y>h)return;if(eh(S,s,l))return;for(let x=1;x<S.length;x++){if(--s.arcs<0)l("agentic local cross-hierarchy direct-arc limit");const k=S[x-1],w=S[x];if(u){try{if(u().entersSegment(k.x,k.y,w.x,w.y,p))return}catch(C){if(C===m)return;throw C}}else for(const C of t){if(a.pairs<=0)return;a.pairs--;if(--s.pairs<0)l("agentic local cross-hierarchy direct-pair limit");if(li(k,w,C))return}}return!b||c(S)?S:void 0};if(d){const y=[];for(let S=0;S<3;S++)for(let x=0;x<4;x++){const k=n[x*3+S];if(g([k.port,k.stub],false))y.push(k)}const b=S=>{if(a.pairs<=0||a.candidates<=0)return;for(const{port:x,stub:k}of y){const w=g([x,k,...S(k),i]);if(w)return w;if(a.pairs<=0||a.candidates<=0)return}};for(const S of[x=>[{x:i.x,y:x.y}],x=>[{x:x.x,y:i.y}]]){const x=b(S);if(x)return x}for(const S of r){const x=[S.x-o*2,S.x+S.width+o*2,S.x-o,S.x+S.width+o];const k=[S.y-o,S.y+S.height+o];for(const w of x){const C=b(R=>[{x:w,y:R.y},{x:w,y:i.y}]);if(C)return C}for(const w of k){const C=b(R=>[{x:R.x,y:w},{x:i.x,y:w}]);if(C)return C}for(const w of x)for(const C of k){const R=b(M=>[{x:w,y:M.y},{x:w,y:C},{x:i.x,y:C}]);if(R)return R}if(a.pairs<=0||a.candidates<=0)return}return}for(let y=0;y<3;y++)for(let b=0;b<4;b++){const{port:S,stub:x}=n[b*3+y];if(!g([S,x],false)){if(a.pairs<=0||a.candidates<=0)return;continue}for(const k of[{x:i.x,y:x.y},{x:x.x,y:i.y}]){const w=g([S,x,k,i]);if(w)return w;if(a.pairs<=0||a.candidates<=0)return}for(const k of r){const w=[k.x-o,k.x+k.width+o];const C=[k.y-o,k.y+k.height+o];for(const R of w){const M=g([S,x,{x:R,y:x.y},{x:R,y:i.y},i]);if(M)return M;if(a.pairs<=0||a.candidates<=0)return}for(const R of C){const M=g([S,x,{x:x.x,y:R},{x:i.x,y:R},i]);if(M)return M;if(a.pairs<=0||a.candidates<=0)return}for(const R of w)for(const M of C){const P=g([S,x,{x:R,y:x.y},{x:R,y:M},{x:i.x,y:M},i]);if(P)return P;if(a.pairs<=0||a.candidates<=0)return}}}return void 0}var _d=class{constructor(t){this.reason=t}reason};function Sr(e,t,n=1){e.arcs-=n;if(e.arcs<0)t("agentic local cross-hierarchy visibility-arc limit")}function O0(e,t,n){n();t.orthogonal=e.length>=2;t.minX=Infinity;t.maxX=-Infinity;t.minY=Infinity;t.maxY=-Infinity;for(let i=0;t.orthogonal&&i<e.length;i++){n(9);const r=e[i];if(!Number.isFinite(r.x)||!Number.isFinite(r.y)||i>0&&r.x!==e[i-1].x&&r.y!==e[i-1].y){t.orthogonal=false;return}t.minX=Math.min(t.minX,r.x);t.maxX=Math.max(t.maxX,r.x);t.minY=Math.min(t.minY,r.y);t.maxY=Math.max(t.maxY,r.y)}}function $A(e,t,n,i){if(!e?.orthogonal||!t?.orthogonal)return false;n(i===void 0?8:20);const r=e.minX-t.maxX,o=t.minX-e.maxX,s=e.minY-t.maxY,a=t.minY-e.maxY;const l=i===void 0?.5:Math.max(.5,i+(Math.abs(e.minX)+Math.abs(e.maxX)+Math.abs(e.minY)+Math.abs(e.maxY)+Math.abs(t.minX)+Math.abs(t.maxX)+Math.abs(t.minY)+Math.abs(t.maxY)+i)*1e-10+1e-9);return Number.isFinite(r)&&Number.isFinite(o)&&Number.isFinite(s)&&Number.isFinite(a)&&(r>l||o>l||s>l||a>l)}function N3(e,t,n,i,r){return $3(e,t,n,i,r,Jf)}function $3(e,t,n,i,r,o){const s=Us(e,o===Jf?"proposal":"complete");let a=0,l=0,c=0;for(let g=0;g<n.length;g++){if(--i.pairs<0)r("agentic local cross-hierarchy crossing-work limit");if(g!==t&&n[g].style!=="invisible"){a+=Math.max(0,n[g].points.length-1);l+=n[g].points.length;c++}}const d=(g=1)=>{i.pairs-=g;if(i.pairs<0)r("agentic local cross-hierarchy crossing-work limit")};if(e.maximumEdgeStrokeWidth!==void 0)Sr(i,r);const u=e.maximumEdgeStrokeWidth===void 0?void 0:g=>Sr(i,r,g);const f=g=>{i.pairs-=s*Math.max(0,g.length-1)*a+g.length+a;if(i.pairs<0)r("agentic local cross-hierarchy crossing-work limit");return o(g,t,n,e,d,u,void 0,s)!==void 0};if(a<32)return f;let h;let m;let p;return g=>{const y=Math.max(0,g.length-1);const b=1+9*g.length+(e.maximumEdgeStrokeWidth===void 0?8:20)*c+n.length;const S=h?0:9*l+c+3*n.length;const x=(s*y+1)*a;if(!Number.isSafeInteger(x)||x<=b+S)return f(g);if(!h){Sr(i,r,2*n.length);d(2*n.length);h=n.slice();m=new Array(n.length);for(let w=0;w<n.length;w++){d();const C=n[w];if(w===t||C.style==="invisible")continue;Sr(i,r);const R={points:C.points,style:C.style,originalStyle:C.style,orthogonal:false,minX:Infinity,maxX:-Infinity,minY:Infinity,maxY:-Infinity};O0(C.points,R,d);h[w]=R;m[w]=R}Sr(i,r);p={orthogonal:false,minX:Infinity,maxX:-Infinity,minY:Infinity,maxY:-Infinity}}O0(g,p,d);let k=0;for(let w=0;w<h.length;w++){d();const C=m[w];if(!C)continue;C.style=$A(p,C,d,e.maximumEdgeStrokeWidth)?"invisible":C.originalStyle;if(C.style!=="invisible")k+=Math.max(0,C.points.length-1)}d(s*y*k+g.length+k);return o(g,t,h,e,d,u,void 0,s)!==void 0}}function th(e,t,n,i,r,o){const s=(g=1)=>{i.pairs-=g;if(i.pairs<0)r("agentic local cross-hierarchy crossing-work limit")};if(e.maximumEdgeStrokeWidth!==void 0)Sr(i,r,2*t.edges.length+3);const a=e.maximumEdgeStrokeWidth===void 0?void 0:g=>Sr(i,r,g);const l=Us(e);let c=0,d=0,u=0;const f=t.edges.map((g,y)=>{s();let b=g.points.length>=2;for(let x=0;b&&x<g.points.length;x++){s();const k=g.points[x];if(!Number.isFinite(k.x)||!Number.isFinite(k.y)||x>0&&k.x!==g.points[x-1].x&&k.y!==g.points[x-1].y)b=false}const S=e.edges[y].visible!==false;if(S){c+=Math.max(0,g.points.length-1);d+=g.points.length;u++}return{...g,style:S?"solid":"invisible",orthogonal:b,covered:false}});let h;if(e.maximumEdgeStrokeWidth!==void 0&&e.maximumEdgeBendRadius===0){Sr(i,r,n.size+f.length+1);h=[];for(const g of n){s();h.push(g)}for(let g=0;g<f.length;g++){s();if(e.edges[g].visible!==false){s();if(!n.has(g))h.push(g)}}}const m=h??n;let p;if(c>=32){let g=0;for(const S of m){s();if(o){s();if(f[S].orthogonal&&e.edges[S].visible!==false&&o.has(S))continue}g=Math.max(g,f[S].points.length-1)}const y=(l*g+1)*c;const b=9*d+u+2*f.length+(e.maximumEdgeStrokeWidth===void 0?8:20)*u;if(Number.isSafeInteger(y)&&y>b){Sr(i,r,f.length);s(f.length);p=new Array(f.length);for(let S=0;S<f.length;S++){s();const x=f[S];if(x.style==="invisible"||!x.orthogonal)continue;Sr(i,r);const k={orthogonal:false,minX:Infinity,maxX:-Infinity,minY:Infinity,maxY:-Infinity};O0(x.points,k,s);p[S]=k}}}for(const g of m){const y=f[g],b=y.points;const S=y.orthogonal&&e.edges[g].visible!==false;if(o){s();if(S&&o.has(g))continue}let x=0;for(let k=0;k<f.length;k++){s();const w=f[k];if(o)s();w.style=e.edges[k].visible===false||S&&(w.covered||w.orthogonal&&o?.has(k))?"invisible":"solid";if(p&&k!==g&&w.style!=="invisible"&&$A(p[g],p[k],s,e.maximumEdgeStrokeWidth))w.style="invisible";if(k!==g&&w.style!=="invisible")x+=Math.max(0,w.points.length-1)}s(l*Math.max(0,b.length-1)*x+b.length+x+f.length);if(ts(b,g,f,e,s,a,void 0,l)===void 0)r("cross-hierarchy routes have an uncertified shared contact");if(S)y.covered=true}}function _3(e,t,n,i,r,o){for(let s=0;s<e.edges.length;s++)for(let a=0;a<2;a++){i.pairs-=10;if(i.pairs<0)o("agentic marker endpoint work limit");const l=t.edges[s].points,c=e.edges[s],d=a===0;if(l.length<2)continue;const u=d?0:l.length-1,f=l[u],h=d?l[1]:l.at(-2),m=n[d?c.source:c.target];let p,g;if(f.x===h.x&&f.y!==h.y){p="y";g=h.y>f.y?m.y+m.height:m.y}else if(f.y===h.y&&f.x!==h.x){p="x";g=h.x>f.x?m.x+m.width:m.x}else continue;if(f[p]===g)continue;i.arcs-=10;i.pairs-=256;if(i.arcs<0)o("agentic marker endpoint capacity limit");if(i.pairs<0)o("agentic marker endpoint work limit");if(Ue(f[p])!==Ue(g))continue;r(1);if(--i.arcs<0)o("agentic marker endpoint capacity limit");i.pairs-=3;if(i.pairs<0)o("agentic marker endpoint work limit");l[u]={x:f.x,y:f.y,[p]:g}}}function _A(e,t,n,i,r,o,s,a,l,c,d,u,f=false){if(f||e.maximumEdgeBendRadius===0)_3(e,t,r,s,a,l);s.arcs-=14;if(s.arcs<0)l("agentic marker full-proof capacity limit");const h=(w=1)=>{s.pairs-=w;if(s.pairs<0)l("agentic marker full-proof work limit")};const m=w=>Sr(s,l,w);const p=new Set;a(4);let g=0;for(let w=0;w<e.edges.length;w++){if(--s.pairs<0)l("agentic marker full-proof work limit");if(e.edges[w].label&&t.edges[w].labelPosition)g++}s.arcs-=2*(n.length+i.length+g)+3;if(s.arcs<0)l("agentic marker full-proof capacity limit");const y=[],b={x:0,y:0,width:t.width,height:t.height};for(let w=0;w<n.length;w++){if(--s.pairs<0)l("agentic marker full-proof work limit");const C=n[w],R=(e.nodes[w].paintStrokeWidth??0)/2;y.push({x:C.x-R,y:C.y-R,width:C.width+2*R,height:C.height+2*R})}for(let w=0;w<i.length;w++){if(--s.pairs<0)l("agentic marker full-proof work limit");const C=i[w],R=(e.groups[w].paintStrokeWidth??0)/2,M=o[w].headerHeight??o[w].padding.top;y.push({x:C.x-R,y:C.y-R,width:C.width+2*R,height:M+2*R})}for(let w=0;w<e.edges.length;w++){if(--s.pairs<0)l("agentic marker full-proof work limit");const C=e.edges[w].label,R=t.edges[w].labelPosition;if(C&&R)y.push({x:R.x-C.width/2-2,y:R.y-C.height/2-2,width:C.width+4,height:C.height+4})}const S={x:0,y:0,width:0,height:0};const x=[{kind:"polygon",points:[{x:0,y:0},{x:0,y:0},{x:0,y:0},{x:0,y:0}]}];const k=(w,C,R,M=false)=>{const P=e.edges[w],E=t.edges[w];h();if(M){if(C!==E.points||P.visible===false||C.length<2)return false;for(let A=0;A<C.length;A++){h(3);const $=C[A];if(!Number.isFinite($.x)||!Number.isFinite($.y)||A&&$.x!==C[A-1].x&&$.y!==C[A-1].y)return false}}else{if(eh(C,s,l))return false;for(let _=0;_<C.length;_++){h();const z=C[_];if(!Number.isFinite(z.x)||!Number.isFinite(z.y)||_&&z.x!==C[_-1].x&&z.y!==C[_-1].y)return false}for(let _=0;_<2;_++){h(8);const z=_===0,F=r[z?P.source:P.target];const G=z?C[0]:C.at(-1),I=z?C[1]:C.at(-2);const D=z?E.points[0]:E.points.at(-1),B=z?E.points[1]:E.points.at(-2);if(Math.sign(I.x-G.x)!==Math.sign(B.x-D.x)||Math.sign(I.y-G.y)!==Math.sign(B.y-D.y)||Math.abs(I.x-G.x)+Math.abs(I.y-G.y)<Math.min(d,Math.abs(B.x-D.x)+Math.abs(B.y-D.y)))return false;if(G.x<F.x||G.x>F.x+F.width||G.y<F.y||G.y>F.y+F.height)return false;if(!(Math.abs(G.x-F.x)<1e-7&&I.y===G.y&&I.x<G.x||Math.abs(G.x-F.x-F.width)<1e-7&&I.y===G.y&&I.x>G.x||Math.abs(G.y-F.y)<1e-7&&I.x===G.x&&I.y<G.y||Math.abs(G.y-F.y-F.height)<1e-7&&I.x===G.x&&I.y>G.y))return false}let A=false;if(P.label){if(!E.labelPosition)return false;for(let _=1;_<E.points.length;_++){h();if(ao(E.labelPosition,E.points[_-1],E.points[_])){A=true;break}}if(P.source!==P.target||A){let _=false;for(let z=1;z<C.length;z++){h();if(ao(E.labelPosition,C[z-1],C[z])){_=true;break}}if(!_)return false}}const $=(u??1)/2;for(let _=1;_<C.length;_++){const z=C[_-1],F=C[_];for(let G=0;G<n.length;G++){h(5);const I=n[G],D=G===P.source&&_===1||G===P.target&&_===C.length-1,B=D?0:$+(e.nodes[G].paintStrokeWidth??0)/2;S.x=I.x-B;S.y=I.y-B;S.width=I.width+2*B;S.height=I.height+2*B;if(li(z,F,S))return false}for(let G=0;G<i.length;G++){h(5);const I=i[G],D=o[G].headerHeight??o[G].padding.top;S.x=I.x-$;S.y=I.y-$;S.width=I.width+2*$;S.height=D+2*$;if(D>0&&li(z,F,S))return false}for(let G=0;G<e.edges.length;G++){h();const I=e.edges[G].label,D=t.edges[G].labelPosition;if(!I||!D)continue;if(G===w&&A&&ao(D,z,F))continue;h(4);S.x=D.x-I.width/2-2;S.y=D.y-I.height/2-2;S.width=I.width+4;S.height=I.height+4;if(li(z,F,S))return false}}}s.arcs-=2*t.edges.length+1;if(s.arcs<0)l("agentic marker full-proof capacity limit");h(3);const v=C===E.points&&P.visible!==false;let L=0;const T=t.edges.map((A,$)=>{h();let _=e.edges[$].visible!==false;if(v&&_&&$!==w){h(2);if(p.has($))_=false}if($!==w&&_)L+=Math.max(0,A.points.length-1);return{...A,style:_?"solid":"invisible"}});h(Us(e)*(C.length-1)*L+C.length+L);return ts(C,w,T,e,h,m,R,Us(e))!==void 0};m(1);wA(e.edges,t.edges,r,s,a,l,k,w=>{h(2);if(!p.has(w)){if(--s.arcs<0)l("agentic marker full-proof capacity limit");p.add(w)}if(!c.has(w)){s.arcs--;if(s.arcs<0)l("agentic marker full-proof capacity limit");c.add(w)}},(w,C,R,M)=>{s.arcs--;if(s.arcs<0)l("agentic marker full-proof capacity limit");const P=(v,L,T,A)=>{h(5);if(M.maxX<=v||M.minX>=v+T||M.maxY<=L||M.minY>=L+A)return true;h(8);const $=x[0].points;$[0].x=v;$[0].y=L;$[1].x=v+T;$[1].y=L;$[2].x=v+T;$[2].y=L+A;$[3].x=v;$[3].y=L+A;return!Vf(R,x,h)};const E=C?e.edges[w].source:e.edges[w].target;for(let v=0;v<n.length;v++){h();if(v===E)continue;const L=n[v],T=(e.nodes[v].paintStrokeWidth??0)/2;if(!P(L.x-T,L.y-T,L.width+2*T,L.height+2*T))return false}for(let v=0;v<i.length;v++){h();const L=i[v],T=o[v].headerHeight??o[v].padding.top,A=(e.groups[v].paintStrokeWidth??0)/2;if(T>0&&!P(L.x-A,L.y-A,L.width+2*A,T+2*A))return false}for(let v=0;v<e.edges.length;v++){h();const L=e.edges[v].label,T=t.edges[v].labelPosition;if(L&&T&&!P(T.x-L.width/2-2,T.y-L.height/2-2,L.width+4,L.height+4))return false}return true},u,e.maximumEdgeBendRadius??0,{bounds:b,obstacles:y},e.maximumEdgeBendRadius===0?(w,C)=>{h(5);C.candidateSegment=C.peerIndex=C.peerSegment=-1;if(p.has(w))return false;if(k(w,t.edges[w].points,C,!f)){m(1);p.add(w);return false}h(6);if(C.peerIndex<0||C.peerIndex>=t.edges.length||C.peerIndex===w||C.candidateSegment<1||C.candidateSegment>=t.edges[w].points.length||C.peerSegment<1||C.peerSegment>=t.edges[C.peerIndex].points.length)l("Measured final route violates its owned path or contact reservation");return true}:void 0);if(f)for(let w=0;w<t.edges.length;w++){h(2);if(p.has(w))continue;if(!k(w,t.edges[w].points))l("Measured final route violates its owned path or contact reservation");if(--s.arcs<0)l("agentic marker full-proof capacity limit");p.add(w)}return p}function DA(e,t,n,i,r){if(e.placementOnly||e.groups?.length||e.maximumEdgeStrokeWidth===void 0)return t;let o=false;for(const y of e.edges){if(--n.pairs<0)r("agentic marker metadata work limit");if(y.markerPaint?.start?.length||y.markerPaint?.end?.length){o=true;break}}if(!o){if(e.maximumEdgeBendRadius===0){Sr(n,r);if(--n.pairs<0)r("agentic marker full-proof work limit");th(e,t,new Set,n,r)}return t}const s=e.nodes.length,a=e.edges.length;n.arcs-=3*s+a+7;n.pairs-=2*s+a+4;if(n.arcs<0)r("agentic flat marker metadata capacity limit");if(n.pairs<0)r("agentic flat marker metadata work limit");let l=t.expandedVertices??0;const c=y=>{if(!Number.isSafeInteger(y)||y<0)throw new TypeError("Invalid measured marker point reservation");if(l+y>i)r("agentic local cross-hierarchy visibility-expansion limit");l+=y};const d=t.nodes.map((y,b)=>({...y,width:e.nodes[b].width,height:e.nodes[b].height})),u=[...d];const f=[],h=[],m=new Set;for(let y=0;y<a;y++)m.add(y);for(const y of t.edges){if(--n.pairs<0)r("agentic flat marker path work limit");N0(y.points,n,r)}const p=_A(e,t,d,f,u,h,n,c,r,m,Math.max(8,e.edgeSpacing??6),e.maximumEdgeStrokeWidth,true);th(e,t,m,n,r,p);n.arcs-=a+2;n.pairs-=a;if(n.arcs<0)r("agentic marker full-proof capacity limit");if(n.pairs<0)r("agentic marker full-proof work limit");const g=[];for(let y=0;y<a;y++)g.push(y);return{...t,expandedVertices:l,boundaryRoutes:g}}function OA(e,t,n,i,r,o,s,a,l){const c=e.nodes.length,d=t.groups,u=e.groups;const f=l?.groups??u;const h=u.length>16||i.size>16||e.edges.length>128;let m=t.edges.reduce((F,G)=>F+G.points.length,0);if(m>2048)a("agentic local cross-hierarchy route-point limit");let p=t.expandedVertices??0;let g=p;const y=F=>{if(!Number.isSafeInteger(F)||F<0)throw new TypeError("Invalid compound visibility reservation");if(p+F>s)a("agentic local cross-hierarchy visibility-expansion limit");p+=F};let b;const S=()=>b??=_0(y,a);let x;const k=()=>x??=LA(F=>{if(!Number.isSafeInteger(F)||F<0)throw new TypeError("Invalid compound adjacency reservation");o.arcs-=F;if(o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit")},a);const w=e.maximumEdgeStrokeWidth;if(w!==void 0){Sr(o,a,2);if(--o.pairs<0)a("agentic local cross-hierarchy crossing-work limit")}const C=w===void 0?void 0:F=>Sr(o,a,F);const R=w===void 0?void 0:F=>{o.pairs-=F;if(o.pairs<0)a("agentic local cross-hierarchy crossing-work limit")};let M=false;if(w!==void 0)for(const F of e.edges){if(--o.pairs<0)a("agentic marker metadata work limit");if(F.markerPaint?.start?.length||F.markerPaint?.end?.length){M=true;break}}const P=Math.max(8,e.edgeSpacing??6);const E=t.nodes.map((F,G)=>({...F,width:e.nodes[G].width,height:e.nodes[G].height}));const v=[...E,...d];const L=new Set;const T=new Set;let A;let $;let _;for(const[F,G]of i)for(let I=0;I<2;I++){let D;let B=false;let Y;const W=O=>{Y??=[];Y.push(O);return O};try{o.pairs-=E.length+d.length;if(o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const O=e.edges[F],N=t.edges[F];const H=ii(N.points);if(H.length<2||O.label&&!N.labelPosition)throw new TypeError("Compound quotient lost its route or label");const j=O.source!==G.source,q=O.target!==G.target;const X=(fe,be,ge=P)=>{const Re=Math.abs(fe.x-be.x)+Math.abs(fe.y-be.y),Ie=Math.min(ge,Re/2);return{x:fe.x+Math.sign(be.x-fe.x)*Ie,y:fe.y+Math.sign(be.y-fe.y)*Ie}};const V=j?X(H[0],H[1]):H[0];const ee=q?X(H.at(-1),H.at(-2)):H.at(-1);const re=[V,...H.slice(1,-1),ee];const U=new Set;for(const fe of[O.source,O.target])for(let be=n[fe];be>=0;be=n[c+be])U.add(be);const te=E.map((fe,be)=>be===O.source||be===O.target?fe:Zf(fe,P));for(let fe=0;fe<d.length;fe++){const be=d[fe];if(c+fe===O.source||c+fe===O.target)te.push(be);else if(!U.has(fe))te.push(Zf(be,P));else if(u[fe].padding.top>0)te.push(Zf({...be,height:l||c>64?f[fe].headerHeight??f[fe].padding.top:u[fe].padding.top},Math.max(2,(e.edgeSpacing??6)/2)))}const J=[...te];let ae;if(O.label&&--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");for(let fe=0;fe<t.edges.length;fe++){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const be=t.edges[fe],ge=e.edges[fe];if(ge.label&&be.labelPosition){const Re=Zf({x:be.labelPosition.x-ge.label.width/2,y:be.labelPosition.y-ge.label.height/2,width:ge.label.width,height:ge.label.height},2);te.push(Re);J.push(Re);if(fe===F)ae=Re}if(fe===F||ge.visible===false||l?.connections.has(fe))continue;for(let Re=1;Re<be.points.length;Re++){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const Ie=be.points[Re-1],ne=be.points[Re];te.push(Zf({x:Math.min(Ie.x,ne.x),y:Math.min(Ie.y,ne.y),width:Math.abs(Ie.x-ne.x),height:Math.abs(Ie.y-ne.y)},Math.max(2,(e.edgeSpacing??6)/2)))}}let Q;const K=()=>Q??=(A??=EA(o,a))(J);const Z=G.host,se=Z<0?void 0:d[Z],oe=Z<0?void 0:f[Z].padding;o.pairs-=8;if(o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const de=Z<0?void 0:u[Z].paintCornerRadius;const xe=w===void 0||de===void 0?Infinity:(w+(u[Z].paintStrokeWidth??0))/2+de+1;const Me=se&&oe?I===0?{x:se.x+oe.left,y:se.y+oe.top,width:se.width-oe.left-oe.right,height:se.height-oe.top-oe.bottom}:{x:se.x+xe,y:se.y+oe.top,width:se.width-2*xe,height:se.height-oe.top-xe}:{x:0,y:0,width:t.width,height:t.height};const Ce=j?ic(v[O.source],r[n[O.source]+1],true,P):[];const pe=q?ic(v[O.target],r[n[O.target]+1],false,P):[];const Te=fe=>{const be=[];for(let ge=n[fe];ge>=0;ge=n[c+ge]){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");be.push(d[ge])}return be};let Fe;let De;let Be="agentic local cross-hierarchy size limit";const me=fe=>{if(fe==="agentic local cross-hierarchy visibility-expansion limit"||fe==="cross-hierarchy route has no bounded clear corridor"||fe==="cross-hierarchy route needs an unsupported self-contact repair")throw new _d(fe);return a(fe)};if(!h)try{let fe=j?void 0:[V];let be=q?void 0:[ee];if(c>64){const ge={pairs:Math.min(16384,Math.floor(o.pairs/8)),candidates:64};if(!fe)fe=rc(Me,te,Ce,V,Te(O.source),P,o,ge,a);if(!be)be=rc(Me,te,pe,ee,Te(O.target),P,o,ge,a)?.reverse();if(!fe||!be)a("large cross-hierarchy route has no bounded direct corridor")}if(!fe||!be){const ge=s-p;const Re=AA(Me,te,[...Ce,...pe],[V,ee],P,o,ge,me,y);if(Re.virtualVertices>ge||Re.virtualVertices>s-g)me("agentic local cross-hierarchy visibility-expansion limit");g+=Re.virtualVertices;fe??=Re.route(Ce,V);be??=Re.route(pe,ee).reverse()}Fe=ii([...fe,...re.slice(1,-1),...be]);if(eh(Fe,o,a)){De=Fe;me("cross-hierarchy route needs an unsupported self-contact repair")}}catch(fe){if(!(fe instanceof _d))throw fe;Be=fe.reason;Fe=void 0}if(!Fe){const fe={pairs:Math.min(16384,Math.floor(o.pairs/8)),candidates:64};let be=j?X(H[0],H[1],P*2):V;let ge=q?X(H.at(-1),H.at(-2),P*2):ee;let Re=[be,...H.slice(1,-1),ge];if(O.label&&!Re.some((le,Se)=>Se>0&&ao(N.labelPosition,Re[Se-1],le))){be=V;ge=ee;Re=re}const Ie=t.edges.map((le,Se)=>({...le,style:e.edges[Se].visible===false||l?.connections.has(Se)||i.has(Se)&&!L.has(Se)?"invisible":"solid"}));const ne=N3(e,F,Ie,o,a);const we=le=>{const Se=eh(le,o,a)?F3(le,o,a):le;if(Se.length<2)return;for(const Pe of[true,false]){o.pairs-=4;if(o.pairs<0)a("agentic local cross-hierarchy self-check limit");const Ae=Pe?le[0]:le.at(-1),Ne=Pe?le[1]:le.at(-2);const Oe=Pe?Se[0]:Se.at(-1),We=Pe?Se[1]:Se.at(-2);const ce=v[Pe?O.source:O.target];const Le=Ne.x-Ae.x,ve=Ne.y-Ae.y;const He=Math.abs(Le)+Math.abs(ve),je=Math.min(P,He);const Ke={x:Ae.x+Math.sign(Le)*je,y:Ae.y+Math.sign(ve)*je};if(Oe.x!==Ae.x||Oe.y!==Ae.y||!ao(Ke,Oe,We))return;if(Oe.x<ce.x-1e-7||Oe.x>ce.x+ce.width+1e-7||Oe.y<ce.y-1e-7||Oe.y>ce.y+ce.height+1e-7)return;const ze=Math.abs(Oe.x-ce.x)<1e-7&&We.y===Oe.y&&We.x<Oe.x||Math.abs(Oe.x-ce.x-ce.width)<1e-7&&We.y===Oe.y&&We.x>Oe.x||Math.abs(Oe.y-ce.y)<1e-7&&We.x===Oe.x&&We.y<Oe.y||Math.abs(Oe.y-ce.y-ce.height)<1e-7&&We.x===Oe.x&&We.y>Oe.y;if(!ze)return}if(O.label&&!Se.some((Pe,Ae)=>Ae>0&&ao(N.labelPosition,Se[Ae-1],Pe)))return;return ne(Se)?Se:void 0};if(De)Fe=we(De);const Ee=le=>{if(!q){const Se=ii([...le,...Re.slice(1)]);const Pe=we(Se);if(Pe){Fe=Pe;return true}return false}return rc(Me,J,pe,ge,Te(O.target),P,o,fe,a,Se=>{const Pe=ii([...le,...Re.slice(1,-1),...Se.toReversed()]);const Ae=we(Pe);if(Ae){Fe=Ae;return true}return false},true,K)!==void 0};let ke;if(w!==void 0&&!Fe){o.arcs-=32;if(o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");ke=()=>{if(!Fe&&!O.label){const le=ic(v[O.source],r[n[O.source]+1],true,P);const Se=ic(v[O.target],r[n[O.target]+1],false,P);const Pe=[...Te(O.source),...Te(O.target)];for(let Ae=0;Ae<3&&!Fe&&fe.candidates>0;Ae++)for(let Ne=0;Ne<4&&!Fe&&fe.candidates>0;Ne++){const Oe=Se[Ne*3+Ae];let We=true;for(const ce of J){if(fe.pairs--<=0){We=false;break}if(--o.pairs<0)a("agentic local cross-hierarchy direct-pair limit");if(li(Oe.stub,Oe.port,ce)){We=false;break}}if(!We)continue;rc(Me,J,le,Oe.stub,Pe,P,o,fe,a,ce=>{const Le=ii([...ce,Oe.port]);const ve=we(Le);if(ve){Fe=ve;return true}return false},true,K)}}else if(!Fe&&j)rc(Me,J,Ce,be,Te(O.source),P,o,fe,a,Ee,true,K);else if(!Fe)Ee([be])}}else if(w===void 0){if(!Fe&&!O.label){const le=ic(v[O.source],r[n[O.source]+1],true,P);const Se=ic(v[O.target],r[n[O.target]+1],false,P);const Pe=[...Te(O.source),...Te(O.target)];for(let Ae=0;Ae<3&&!Fe&&fe.candidates>0;Ae++)for(let Ne=0;Ne<4&&!Fe&&fe.candidates>0;Ne++){const Oe=Se[Ne*3+Ae];let We=true;for(const ce of J){if(fe.pairs--<=0){We=false;break}if(--o.pairs<0)a("agentic local cross-hierarchy direct-pair limit");if(li(Oe.stub,Oe.port,ce)){We=false;break}}if(!We)continue;rc(Me,J,le,Oe.stub,Pe,P,o,fe,a,ce=>{const Le=ii([...ce,Oe.port]);const ve=we(Le);if(ve){Fe=ve;return true}return false},true,K)}}else if(!Fe&&j)rc(Me,J,Ce,be,Te(O.source),P,o,fe,a,Ee,true,K);else if(!Fe)Ee([be])}if(!Fe)try{const le=(ve,He)=>{let je=0,Ke=0,ze=0;const Ze=Ie.map((nt,it)=>{if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const $t=e.edges[it],yn=$t.source===ve||$t.target===ve;if(yn){je++;if(it<F)Ke++}const wt=yn?nt.style:"invisible";if(it!==F&&wt!=="invisible")ze+=Math.max(0,nt.points.length-1);return{...nt,style:wt}});const tt=[...new Set([(Ke+1)/(je+1),.5,.25,.75])];return ic(v[ve],r[n[ve]+1],He,P,tt).filter(nt=>{o.pairs-=4*ze+2;if(o.pairs<0)a("agentic local cross-hierarchy crossing-work limit");return Jf(He?[nt.port,nt.stub]:[nt.stub,nt.port],F,Ze,e,R,C)!==void 0})};const Se=(ve,He)=>{let je=0,Ke=0;for(let wt=0;wt<e.edges.length;wt++){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const ui=e.edges[wt];if(ui.source===ve||ui.target===ve){je++;if(wt<F)Ke++}}o.arcs-=8;if(o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");y(8);const ze=v[ve],Ze=r[n[ve]+1],tt=(Ke+.5)/(je+1);const nt=Ze==="LR"?"E":Ze==="RL"?"W":Ze==="BT"?"N":"S";const it=He?nt:nt==="N"?"S":nt==="S"?"N":nt==="E"?"W":"E";const $t=new Array(4);const yn=wt=>wt===0?it:it==="N"?wt===1?"E":wt===2?"S":"W":it==="E"?wt===1?"N":wt===2?"S":"W":it==="S"?wt===1?"N":wt===2?"E":"W":wt===1?"N":wt===2?"E":"S";for(let wt=0;wt<4;wt++){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const ui=yn(wt);const ll=ui==="N"||ui==="S"?{x:ze.x+tt*ze.width,y:ui==="N"?ze.y:ze.y+ze.height}:{x:ui==="W"?ze.x:ze.x+ze.width,y:ze.y+tt*ze.height};const _x={x:ll.x+(ui==="E"?P*2:ui==="W"?-P*2:0),y:ll.y+(ui==="S"?P*2:ui==="N"?-P*2:0)};$t[wt]={port:ll,stub:_x,penalty:wt*P*2+Math.abs(tt-.5)*P}}return $t};let Pe=we;if(w!==void 0){o.arcs-=4;if(o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");Pe=ve=>we(N0(ve,o,a))}const Ae=O.label&&!j?[]:le(O.source,true);const Ne=O.label&&!q?[]:le(O.target,false);$??=TA(Ie,F,t.width,t.height,o,y,a);D=$.acquire(F);const Oe=$.rails;const We=D.guard;const ce=ve=>{const He=je=>je.x>=Me.x&&je.x<=Me.x+Me.width&&je.y>=Me.y&&je.y<=Me.y+Me.height;for(const je of ve){o.pairs-=8;if(o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const{port:Ke,stub:ze}=je;if(!He(Ke)||!He(ze))continue;const Ze=K();if(Ze.containsPoint(Ke.x,Ke.y)||Ze.containsPoint(ze.x,ze.y)||Ze.entersSegment(Ke.x,Ke.y,ze.x,ze.y))continue;const tt=Ke.x===ze.x?2:Ke.y===ze.y?1:0;if(!tt)throw new TypeError("Measured terminal lead must be orthogonal");if(We(Ke,ze,tt,tt))return true}return false};const Le=ve=>{try{ve();return Fe!==void 0}catch(He){if(!(He instanceof _d))throw He;Be=He.reason;return false}};if(!O.label){if(w!==void 0){o.pairs-=2;if(o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");$.enterQuery(D);try{Fe=vA(Me,J,Ae,Ne,Oe,K(),o,y,a,We,Pe,Math.max(.5,w))}finally{$.leaveQuery(D)}}if(w!==void 0){o.pairs-=2;if(o.pairs<0)a("agentic local cross-hierarchy crossing-work limit")}if(!Fe&&ke)ke();const ve=He=>{const je=W(Qf(Me,J,[...Ae,...Ne],[be,ge],P,o,s-p,me,y,He,K,S(),Oe,k()));try{for(const Ke of Ne){if(Fe)break;if(!K().entersSegment(Ke.stub.x,Ke.stub.y,Ke.port.x,Ke.port.y))Le(()=>{$.enterQuery(D);try{je.route(Ae,Ke.stub,ze=>{const Ze=we(ii([...ze,Ke.port]));if(Ze){Fe=Ze;return true}return false},We)}finally{$.leaveQuery(D)}})}}finally{je.retire()}};if(!Fe)ve(false);if(!Fe&&Be==="cross-hierarchy route has no bounded clear corridor")ve(true)}else{if(w!==void 0&&!j&&q&&ae){o.pairs-=2;if(o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");$.enterQuery(D);try{Fe=RA(Re,v[O.source],N.labelPosition,ae,Me,J,Ne,Oe,K(),o,P,Math.max(.5,w),y,a,We,Pe)}finally{$.leaveQuery(D)}}if(w!==void 0){o.pairs-=2;if(o.pairs<0)a("agentic local cross-hierarchy crossing-work limit")}if(!Fe&&ke)ke();if(!Fe){const ve=nt=>n[nt]<0?v[nt]:d[n[nt]];const He={roots:Ne,interiorChannels:false,paths:[],complete:false};const je={roots:Ne,interiorChannels:true,paths:[],complete:false};const Ke=[];const ze=(nt,it=He)=>{if(!q){const wt=we(ii([...nt,...Re.slice(1)]));if(wt){Fe=wt;return true}return false}const $t=wt=>{const ui=we(ii([...nt,...Re.slice(1,-1),...wt.toReversed()]));if(ui){Fe=ui;return true}return false};for(const wt of it.paths)if($t(wt))return true;if(it.complete)return false;if(!it.graph&&!ce(it.roots)){it.complete=true;Be="cross-hierarchy route has no bounded clear corridor";return false}const yn=Le(()=>{it.graph??=W(D0(Me,ve(O.target),J,it.roots,ge,P,o,s-p,me,y,it.interiorChannels,K,S(),Oe,k()));$.enterQuery(D);try{it.graph.route(it.roots,ge,wt=>{if(it.late&&--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");it.paths.push(wt);return $t(wt)},We)}finally{$.leaveQuery(D)}});if(!yn&&Be==="cross-hierarchy route has no bounded clear corridor")it.complete=true;if(it.complete||yn)it.graph?.retire();return yn};const Ze=(nt,it,$t)=>{if(!ce(nt)){Be="cross-hierarchy route has no bounded clear corridor";return false}return Le(()=>{const yn=W(D0(Me,ve(O.source),J,nt,be,P,o,s-p,me,y,it,K,S(),Oe,k()));$.enterQuery(D);try{yn.route(nt,be,$t,We)}finally{try{$.leaveQuery(D)}finally{yn.retire()}}})};const tt=nt=>{Ke.push(nt);return ze(nt)};if(j)Ze(Ae,false,tt);else tt([be]);if(!Fe&&Be==="cross-hierarchy route has no bounded clear corridor"){if(q){for(const nt of Ke)if(ze(nt,je))break}if(!Fe&&j)Ze(Ae,true,nt=>{if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");Ke.push(nt);return ze(nt)||ze(nt,je)})}if(!Fe&&Be==="cross-hierarchy route has no bounded clear corridor"){let nt;if(q){const it=Se(O.target,false);if(--o.arcs<0)a("agentic local cross-hierarchy visibility-arc limit");nt={roots:it,interiorChannels:false,late:true,paths:[],complete:false}}if(nt){for(const it of Ke)if(ze(it,nt))break}if(!Fe&&j)Ze(Se(O.source,true),false,it=>ze(it)||q&&(ze(it,je)||ze(it,nt)))}}}}catch(le){if(!(le instanceof _d))throw le;Be=le.reason}if(!Fe){if(I===0&&se&&oe&&w!==void 0&&u[Z].paintStrokeWidth!==void 0&&xe<oe.left&&xe<oe.right&&xe<oe.bottom&&Be==="cross-hierarchy route has no bounded clear corridor")continue;a(Be)}T.add(F)}const he=Fe;if(O.label&&!he.some((fe,be)=>be>0&&ao(N.labelPosition,he[be-1],fe)))a("cross-hierarchy route lost its reserved label corridor");m+=he.length-N.points.length;if(m>2048)a("agentic local cross-hierarchy route-point limit");t.edges[F]={...N,points:he};L.add(F);B=true}finally{try{if(Y)for(const O of Y)O.retire()}finally{D?.release()}}if(B&&$)$.publish(F,t.edges[F].points,e.edges[F].visible!==false&&!l?.connections.has(F));break}if(l?.connections.size){const F=new Set;for(const[G,I]of l.connections){const D=e.edges[G],B=t.edges[G];const Y=t.edges.map((j,q)=>({...j,style:e.edges[q].visible===false||l.connections.has(q)&&!F.has(q)?"invisible":"solid"}));const W=Y.reduce((j,q,X)=>j+(X===G||q.style==="invisible"?0:Math.max(0,q.points.length-1)),0);const O=new Set;for(let j=n[I.interior];j>=0;j=n[c+j]){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");O.add(j)}const N=[...E];for(let j=0;j<d.length;j++){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");const q=f[j].headerHeight??f[j].padding.top;if(!O.has(j))N.push(d[j]);else if(q>0)N.push({...d[j],height:q})}const H=NA(e,t,n,l,G,{work:o,remainingVertices:s-p,reserveVertices:y,queryWorkspaces:S(),fail:a,accept(j){const q=j.points;if(q.length<2||q.some((K,Z)=>!Number.isFinite(K.x+K.y)||Z>0&&K.x!==q[Z-1].x&&K.y!==q[Z-1].y))throw new TypeError("Ancestor boundary producer returned invalid points");if(eh(q,o,a))return false;const X=I.containerEnd==="source",V=d[I.container];const ee=X?q[0]:q.at(-1),re=X?q[1]:q.at(-2);const U=f[I.container].headerHeight??f[I.container].padding.top;if(Math.abs(ee.x-V.x)>1e-7||ee.y<V.y+U||ee.y>V.y+V.height||re.y!==ee.y||re.x-ee.x<I.minimumLead)return false;const te=X?q.at(-1):q[0],J=X?q.at(-2):q[1],ae=v[I.interior];if(te.x<ae.x-1e-7||te.x>ae.x+ae.width+1e-7||te.y<ae.y-1e-7||te.y>ae.y+ae.height+1e-7)return false;const Q=Math.abs(te.x-ae.x)<1e-7&&J.y===te.y&&J.x<te.x||Math.abs(te.x-ae.x-ae.width)<1e-7&&J.y===te.y&&J.x>te.x||Math.abs(te.y-ae.y)<1e-7&&J.x===te.x&&J.y<te.y||Math.abs(te.y-ae.y-ae.height)<1e-7&&J.x===te.x&&J.y>te.y;if(!Q||Math.abs(J.x-te.x)+Math.abs(J.y-te.y)<l.clearance)return false;if(D.label&&(!j.labelPosition||!q.some((K,Z)=>Z>0&&ao(j.labelPosition,q[Z-1],K))))return false;for(let K=1;K<q.length;K++)for(const Z of N){if(--o.pairs<0)a("agentic local cross-hierarchy obstacle-work limit");if(li(q[K-1],q[K],Z))return false}o.pairs-=Us(e,"proposal")*Math.max(0,q.length-1)*W+q.length+W;if(o.pairs<0)a("agentic local cross-hierarchy crossing-work limit");return Jf(q,G,Y,e,R,C)!==void 0}});m+=H.points.length-B.points.length;if(m>2048)a("agentic local cross-hierarchy route-point limit");t.edges[G]={...B,...H};F.add(G);T.add(G)}}if(M)_=_A(e,t,E,d,v,f,o,y,a,T,P,w);if(T.size||w!==void 0&&e.maximumEdgeBendRadius===0)th(e,t,T,o,a,_);const z=[...i.keys()];if(l?.connections.size){for(const F of l.connections.keys())if(!i.has(F))z.push(F);z.sort((F,G)=>F-G)}if(M){let F=false;for(const G of T){o.pairs-=z.length+1;if(o.pairs<0)a("agentic marker full-proof work limit");if(z.includes(G))continue;if(--o.arcs<0)a("agentic marker full-proof capacity limit");z.push(G);F=true}if(F)z.sort((G,I)=>{if(--o.pairs<0)a("agentic marker full-proof work limit");return G-I})}if(M){o.arcs-=e.edges.length+1;o.pairs-=e.edges.length;if(o.arcs<0)a("agentic marker full-proof capacity limit");if(o.pairs<0)a("agentic marker full-proof work limit");const F=new Array(e.edges.length);for(let G=0;G<e.edges.length;G++)F[G]=G;return{...t,expandedVertices:p,boundaryRoutes:F}}return{...t,expandedVertices:p,boundaryRoutes:z}}function BA(e,t,n,i){const r=new Int32Array(t.length);for(const o of n){if((i.blockPairs??2e6)<=0)return;const s=o.slice(1,-1);if(s.length<2||s.some((x,k)=>t[x].incoming.length!==1||t[x].outgoing.length!==1||t[x].incoming[0]!==o[k]||t[x].outgoing[0]!==o[k+2]||t[x].rank!==t[o[k]].rank+1))continue;for(const x of e)for(let k=0;k<x.length;k++)r[x[k]]=k;const a=s.map(x=>e[t[x].rank].filter(k=>k!==x));const l=s.map(x=>r[x]);const c=[];for(let x=0;x<=s.length;x++){const k=o[x],w=o[x+1],C=[];for(const R of e[t[k].rank]){for(const M of t[R].outgoing){if(R===k&&M===w)continue;const P=r[R],E=r[M];C.push(P-Number(x>0&&P>r[k]),E-Number(x<s.length&&E>r[w]))}}c.push(Int32Array.from(C))}let d=false;const u=(x,k,w)=>{const C=c[x],R=1+C.length/2;if((i.blockPairs??2e6)<R){d=true;return Infinity}i.blockPairs=(i.blockPairs??2e6)-R;let M=0;for(let P=0;P<C.length;P+=2){const E=C[P],v=C[P+1];const L=E+Number(x>0&&E>=k),T=v+Number(x<s.length&&v>=w);if((k-L)*(w-T)<0)M++}return M};let f=0;for(let x=0;x<=s.length;x++)f+=u(x,x===0?r[o[0]]:l[x-1],x===s.length?r[o.at(-1)]:l[x]);if(d)return;if(f===0)continue;let h=Float64Array.from({length:a[0].length+1},(x,k)=>u(0,r[o[0]],k));let m=Float64Array.from(h,(x,k)=>Math.abs(k-l[0]));const p=[];for(let x=1;x<s.length&&!d;x++){const k=new Float64Array(a[x].length+1).fill(Infinity),w=new Int32Array(k.length);const C=new Float64Array(k.length).fill(Infinity);for(let R=0;R<k.length&&!d;R++)for(let M=0;M<h.length;M++){if(h[M]>=f)continue;const P=h[M]+u(x,M,R);const E=m[M]+Math.abs(R-l[x]);if(P<k[R]||P===k[R]&&E<C[R]){k[R]=P;w[R]=M;C[R]=E}if(d)break}h=k;m=C;p.push(w)}if(d)return;let g=Infinity,y=Infinity,b=0;for(let x=0;x<h.length;x++){const k=h[x]+u(s.length,x,r[o.at(-1)]);if(k<g||k===g&&m[x]<y){g=k;y=m[x];b=x}}if(d)return;if(g>=f)continue;const S=new Int32Array(s.length);S[s.length-1]=b;for(let x=s.length-2;x>=0;x--)S[x]=p[x][S[x+1]];for(let x=0;x<s.length;x++){const k=a[x];k.splice(S[x],0,s[x]);e[t[s[x]].rank]=k}}}var B0=4096;function lo(e,t=false){return(t&&!e.label?1:2)*e.minSpan}function WA(e,t,n=false){const i=e.nodes.length,r=e.edges;if(i===0)return new Float64Array(0);if(t.rankPairs<=0||i>64||r.length>128||r.reduce((c,d)=>c+d.minSpan,0)>128)return;const o=n?Int32Array.from(r,c=>c.short?100:1):new Int32Array(r.length).fill(1);const s=new Float64Array(i),a=new Int32Array(i),l=new Int32Array(i);for(let c=0;c<128;c++){s.fill(0);a.fill(-1);l.fill(0);let d=-1;for(let g=0;g<i;g++){d=-1;for(let y=0;y<r.length;y++){const b=r[y];t.rankPairs-=2;if(t.rankPairs<0)return;const S=lo(b,e.compactPrivateRanks);if(s[b.target]<s[b.source]+S){s[b.target]=s[b.source]+S;a[b.target]=b.source;l[b.target]=y+1;d=b.target}if(o[y]>0&&s[b.source]<s[b.target]-S){s[b.source]=s[b.target]-S;a[b.source]=b.target;l[b.source]=-y-1;d=b.source}}if(d<0){const y=n?r.reduce((S,x)=>S+(x.short?100:1)*(s[x.target]-s[x.source]),0):r.reduce((S,x)=>S+s[x.target]-s[x.source],0),b=r.reduce((S,x,k)=>S+o[k]*lo(x,e.compactPrivateRanks),0);if(y!==b)throw new Error(`dual rank mismatch ${y} ${b}`);return s}}let u=d;for(let g=0;g<i;g++)u=a[u];const f=u,h=[];let m=Infinity,p=0;do{const g=l[u],y=Math.abs(g)-1;if(y<0)throw new Error("missing residual predecessor");h.push(g);p+=Math.sign(g)*lo(r[y],e.compactPrivateRanks);if(g<0)m=Math.min(m,o[y]);u=a[u]}while(u!==f&&h.length<=i);if(u!==f||p<=0||!Number.isFinite(m)||m<=0)throw new Error(`invalid positive residual cycle ${p} ${m}`);for(const g of h)o[Math.abs(g)-1]=o[Math.abs(g)-1]+Math.sign(g)*m}}function zA(e,t,n){if(n.loopPairs<=0||e.groups?.length||e.nodes.length>256||e.edges.length>128||t.edges.reduce((w,C)=>w+C.points.length,0)>2048)return t;const i=w=>(n.loopPairs-=w)>=0;const r=e.direction==="LR"||e.direction==="RL",o=e.direction==="RL"||e.direction==="BT"?-1:1;const s=r?"x":"y",a=r?"y":"x";const l=(w,C)=>r?{x:w,y:C}:{x:C,y:w};const c=e.nodes.map((w,C)=>({...t.nodes[C],width:w.width,height:w.height}));const d=e.edges.map((w,C)=>{const R=t.edges[C].labelPosition;return w.label&&R?{x:R.x-w.label.width/2,y:R.y-w.label.height/2,width:w.label.width,height:w.label.height}:void 0});const u=t.edges.map((w,C)=>({points:w.points,style:e.edges[C].visible===false?"invisible":"solid"}));const f=()=>u.map(w=>({points:w.points,visible:w.style!=="invisible"}));const h=(w,C)=>Math.min(...C.slice(1).map((R,M)=>{const P=C[M];const E=Math.max(Math.min(P.x,R.x),Math.min(Math.max(P.x,R.x),w.x));const v=Math.max(Math.min(P.y,R.y),Math.min(Math.max(P.y,R.y),w.y));return Math.abs(w.x-E)+Math.abs(w.y-v)}));let m=false;for(const[w,C]of e.edges.entries()){const R=t.edges[w],M=R.points;if(C.source!==C.target||C.visible===false||M.length<=4)continue;const P=M[0],E=M.at(-1);if(Math.abs(P[s]-E[s])>1e-7||Math.abs(P[a]-E[a])<8-1e-7)continue;const v=[...c,...d.filter((_,z)=>Boolean(_)&&z!==w)];const L=[...new Set([...M.map(_=>_[s]),...v.flatMap(_=>r?[_.x-8,_.x+_.width+8]:[_.y-8,_.y+_.height+8]),P[s]+24*o])].filter(_=>(_-P[s])*o>=24);L.sort((_,z)=>(_-z)*o);const T=new Set([w]),A=u.reduce((_,z)=>_+z.points.length,0);n.loopPairs-=A*A;if(n.loopPairs<0)return t;const $=_r(f(),T);for(const _ of L.slice(0,32)){const z=[{...P},l(_,P[a]),l(_,E[a]),{...E}];if(z.some(B=>B.x<e.padding||B.y<e.padding||B.x>t.width-e.padding||B.y>t.height-e.padding))continue;n.loopPairs-=z.length*v.length+z.length*A;if(n.loopPairs<0)return t;if(z.slice(1).some((B,Y)=>v.some(W=>li(z[Y],B,W))))continue;let F=R.labelPosition,G=d[w];const I=B=>z.slice(1).some((Y,W)=>li(z[W],Y,B));if(F&&C.label&&(h(F,z)>h(F,M)+1e-7||G&&I(G))){const B=(r?C.label.width:C.label.height)/2,Y=(r?C.label.height:C.label.width)/2;const W=B+16,O=(_-P[s])*o-B-8;if(W>O)continue;const N=P[s]+o*Math.max(W,Math.min(O,(F[s]-P[s])*o));const H=[l(N,Math.min(P[a],E[a])-Y-4),l(N,Math.max(P[a],E[a])+Y+4)];H.sort((j,q)=>Math.abs(j.x-R.labelPosition.x)+Math.abs(j.y-R.labelPosition.y)-Math.abs(q.x-R.labelPosition.x)-Math.abs(q.y-R.labelPosition.y));F=void 0;for(const j of H){const q={x:j.x-C.label.width/2,y:j.y-C.label.height/2,width:C.label.width,height:C.label.height};n.loopPairs-=v.length+A;if(n.loopPairs<0)return t;if(q.x<e.padding||q.y<e.padding||q.x+q.width>t.width-e.padding||q.y+q.height>t.height-e.padding)continue;if(v.some(X=>Xg(q,X))||I(q)||u.some((X,V)=>V!==w&&X.style!=="invisible"&&X.points.slice(1).some((ee,re)=>li(X.points[re],ee,q))))continue;F=j;G=q;break}if(!F)continue}const D=ts(z,w,u,e,i,i);if(n.loopPairs<0)return t;if(D===void 0||D>$)continue;R.points=z;u[w].points=z;if(F)R.labelPosition={...F};d[w]=G;m=true;break}}if(!m)return t;let p=Infinity,g=Infinity,y=-Infinity,b=-Infinity;const S=(w,C,R=0,M=0)=>{p=Math.min(p,w);g=Math.min(g,C);y=Math.max(y,w+R);b=Math.max(b,C+M)};c.forEach(w=>S(w.x,w.y,w.width,w.height));t.edges.forEach((w,C)=>{w.points.forEach(P=>S(P.x,P.y));const R=w.labelPosition,M=e.edges[C].label;if(R&&M)S(R.x-M.width/2,R.y-M.height/2,M.width,M.height)});const x=e.padding-p,k=e.padding-g;t.nodes=t.nodes.map(w=>({x:w.x+x,y:w.y+k}));t.edges=t.edges.map(w=>({...w,points:w.points.map(C=>({x:C.x+x,y:C.y+k})),...w.labelPosition?{labelPosition:{x:w.labelPosition.x+x,y:w.labelPosition.y+k}}:{}}));t.width=y-p+2*e.padding;t.height=b-g+2*e.padding;return t}function GA(e,t,n,i){if(!e.shareCompleteFans||e.edges.some(P=>P.label||P.minSpan!==1))return void 0;const r=[],o=[];for(let P=0;P<e.nodes.length;P++){if(!t[P].length&&n[P].length)r.push(P);else if(!n[P].length&&t[P].length)o.push(P);else return void 0}if(!r.length||!o.length||r.length===1&&o.length===1||e.edges.length!==r.length*o.length)return void 0;const s=new Map(r.map((P,E)=>[P,E]));const a=new Map(o.map((P,E)=>[P,E]));const l=new Set;for(const P of e.edges){if(!s.has(P.source)||!a.has(P.target))return void 0;const E=P.source*e.nodes.length+P.target;if(l.has(E))return void 0;l.add(E)}const c=e.direction==="LR"||e.direction==="RL";const d=e.direction==="BT"||e.direction==="RL";const u=P=>c?e.nodes[P].height:e.nodes[P].width;const f=P=>c?e.nodes[P].width:e.nodes[P].height;const h=P=>P.reduce((E,v)=>E+u(v),0)+(P.length-1)*e.nodeSpacing;const m=h(r),p=h(o),g=Math.max(m,p);const y=Math.max(...r.map(f)),b=Math.max(...o.map(f));const S=Math.max(e.layerSpacing,2*Math.max(12,e.edgeSpacing??6)+(e.edgeSpacing??6));const x=y+S+b;if(!Number.isFinite(x+g+2*e.padding))i("agentic local coordinate-range limit");const k=new Float64Array(e.nodes.length),w=new Float64Array(e.nodes.length);for(const[P,E,v,L]of[[r,m,0,y],[o,p,y+S,b]]){let T=(g-E)/2;for(const A of P){k[A]=T+u(A)/2;w[A]=v+(L-f(A))/2;T+=u(A)+e.nodeSpacing}}const C=(P,E)=>c?{x:e.padding+(d?x-E:E),y:e.padding+P}:{x:e.padding+P,y:e.padding+(d?x-E:E)};const R=e.nodes.map((P,E)=>C(k[E]-u(E)/2,w[E]+(d?f(E):0)));const M=e.edges.map(P=>{if(e.placementOnly&&!e.cycleOriented&&!e.loopPorts?.length)return{points:[]};const E=[];const v=g/2,L=y+S/3,T=y+2*S/3;for(const[A,$]of[[k[P.source],w[P.source]+f(P.source)],[k[P.source],L],[v,L],[v,T],[k[P.target],T],[k[P.target],w[P.target]]]){const _=C(A,$);const z=E.at(-1),F=E.at(-2);if(z?.x===_.x&&z.y===_.y)continue;if(F&&z&&(F.x===z.x&&z.x===_.x&&(z.y-F.y)*(_.y-z.y)>=0||F.y===z.y&&z.y===_.y&&(z.x-F.x)*(_.x-z.x)>=0))E.pop();E.push(_)}return{points:E}});return{topology:"layered",width:2*e.padding+(c?x:g),height:2*e.padding+(c?g:x),nodes:R,edges:M,expandedVertices:R.length,sharedEdges:e.edges.map((P,E)=>E)}}function HA(e,t,n=2){const i=e.nodes.length,r=e.edges;if(!i||i>20||r.length>48||(t.blockPairs??2e6)<=0)return[];const o=new Uint16Array(i),s=new Uint16Array(i),a=new Uint16Array(i);const l=new Float64Array(i),c=new Int32Array(i);for(const k of r)o[k.target]=o[k.target]+1;let d=false;const u=k=>{const w=t.blockPairs??2e6;if(w<k){d=true;return false}t.blockPairs=w-k;return true};const f=(k,w,C=-1)=>{if(!u(i+4))return;s.set(o);l.fill(0);for(const P of[k,w,C])if(P>=0){const E=r[P];s[E.target]=s[E.target]-1;s[E.source]=s[E.source]+1}let R=0;for(let P=0;P<i;P++)if(!s[P])a[R++]=P;for(let P=0;P<R;P++){if(!u(r.length))return;const E=a[P];c[E]=P;for(let v=0;v<r.length;v++){const L=r[v],T=v===k||v===w||v===C;const A=T?L.target:L.source,$=T?L.source:L.target;if(A!==E)continue;l[$]=Math.max(l[$],l[E]+lo(L,e.compactPrivateRanks));s[$]=s[$]-1;if(!s[$])a[R++]=$}}if(R!==i)return;if(!u(r.length))return;let M=0;for(const P of r)M+=Math.abs(l[P.target]-l[P.source]);return{order:c.slice(),span:M}};const h=[];for(let k=0;k<r.length&&!d;k++){const w=f(k,-1);if(w)h.push(w)}if(h.length||d)return h;for(let k=0;k<r.length&&!d;k++){for(let w=k+1;w<r.length&&!d;w++){const C=f(k,w);if(C)h.push(C)}}if(h.length||d||n<3)return h;const m=new Uint8Array(r.length),p=new Uint8Array(i),g=new Int32Array(i);const y=[],b=new Set;const S=()=>{p.fill(0);g.fill(-1);const k=w=>{p[w]=1;for(let C=0;C<r.length;C++){if(!u(1))return;const R=r[C];if(m[C]||R.source!==w)continue;if(p[R.target]===1){const M=[C];for(let P=w;P!==R.target;){const E=g[P];M.push(E);P=r[E].source}return M}if(p[R.target]===0){g[R.target]=C;const M=k(R.target);if(M||d)return M}}p[w]=2;return};for(let w=0;w<i;w++)if(!p[w]){const C=k(w);if(C||d)return C}return};const x=()=>{if(d)return;const k=y.slice().sort((C,R)=>C-R).join(",");if(b.has(k))return;b.add(k);const w=S();if(d)return;if(!w){const C=f(y[0]??-1,y[1]??-1,y[2]??-1);if(C)h.push(C);return}if(y.length===3)return;for(const C of w){m[C]=1;y.push(C);x();y.pop();m[C]=0;if(d)return}};x();return h}function W0(e,t){const n=new Uint8Array(e.length),i=new Uint32Array(e.length);const r=new Int32Array(e.length),o=[];let s=e.length-1;for(let a=0;a<e.length;a++){if(n[a])continue;n[a]=1;o.push(a);while(o.length){const l=o.at(-1);if(i[l]<e[l].length){const c=t[e[l][i[l]]];i[l]=i[l]+1;if(!n[c.target]){n[c.target]=1;o.push(c.target)}}else{o.pop();n[l]=2;r[l]=s--}}}return r}function oc(e,t,n){const i=e.length,r=n.length;const o=new Int32Array(2*r+1).fill(-1);const s=new Int32Array(i).fill(-1),a=new Int32Array(i).fill(-1);const l=Uint32Array.from(e,k=>k.length),c=Uint32Array.from(t,k=>k.length);const d=new Uint8Array(i).fill(1),u=new Int32Array(i);const f=[],h=[];let m=0,p=0,g=i-1;const y=k=>r+c[k]-l[k];const b=k=>{const w=y(k),C=o[w];a[k]=-1;s[k]=C;if(C>=0)a[C]=k;o[w]=k;m=Math.max(m,w)};const S=k=>{const w=a[k],C=s[k];if(w>=0)s[w]=C;else o[y(k)]=C;if(C>=0)a[C]=w};const x=k=>{S(k);d[k]=0;for(const w of e[k]){const C=n[w].source;if(!d[C])continue;S(C);c[C]=c[C]-1;b(C);if(c[C]===0)h.push(C)}for(const w of t[k]){const C=n[w].target;if(!d[C])continue;S(C);l[C]=l[C]-1;b(C);if(l[C]===0)f.push(C)}};for(let k=i-1;k>=0;k--){b(k);if(!l[k])f.push(k);if(!c[k])h.push(k)}while(p<=g){while(h.length){const w=h.pop();if(d[w]){u[w]=g--;x(w)}}while(f.length){const w=f.pop();if(d[w]){u[w]=p++;x(w)}}if(p>g)break;while(m>=0&&o[m]===-1)m--;const k=o[m];if(k===void 0||k<0)throw new TypeError("Feedback ordering lost an active vertex");u[k]=p++;x(k)}return u}var Jg=class extends Error{};function jA(e,t,n,i,r,o,s){const{nodes:a,edges:l}=e;const c=oc(t,n,l),d=W0(n,l);const u=T=>l.reduce((A,$)=>A+Number(T[$.source]>T[$.target]),0);const f=(T,A,$,_=false,z=false)=>{const F=l.map(W=>T[W.source]>T[W.target]);const G=a.map((W,O)=>_?a.length-1-O:O);const I=new Uint32Array(a.length);G.forEach((W,O)=>{I[W]=O});const D=l.map((W,O)=>z?l.length-1-O:O);const B=new Uint32Array(l.length);D.forEach((W,O)=>{B[W]=O});const Y=i({...e,shareCompleteFans:false,cycleOriented:true,nodes:G.map(W=>a[W]),edges:D.map(W=>{const O=l[W],N=F[W]?O.target:O.source,H=F[W]?O.source:O.target;return{...O,source:I[N],target:I[H]}}),loopPorts:e.loopPorts?.map(([W,O])=>[B[W],B[O]])},A,$);return{...Y,nodes:a.map((W,O)=>Y.nodes[I[O]]),edges:l.map((W,O)=>{const N=Y.edges[B[O]];return F[O]?{...N,points:[...N.points].reverse()}:N})}};if(e.authoredCycleOrder)return f(Uint32Array.from(a,(T,A)=>A),r,o,false,true);const h=u(d)<=u(c)?d:c;let m=f(h,r,o);if(a.length>48||l.length>128||l.reduce((T,A)=>T+A.minSpan,0)>128||(m.expandedVertices??0)>1024||s.attempts<=0)return m;const p=T=>{const A=T.edges.reduce(($,_,z)=>$+(l[z].visible===false?0:_.points.length),0);if(A>2048||A*A>s.scorePairs)return void 0;s.scorePairs-=A*A;return _r(T.edges.map(($,_)=>({...$,visible:l[_].visible})))};let g=p(m);if(g===void 0||g===0)return m;const y=T=>T.edges.reduce((A,$,_)=>A+(l[_].visible===false?0:Math.max(0,$.points.length-2)),0);let b=y(m),S=m.width*m.height;const x=(T,A,$)=>l.map(_=>T[_.source]>T[_.target]?1:0).join("")+":"+A+":"+$;let k=e.compactPrivateRanks&&a.length>16?2:12;const w=new Set([x(h,false,false)]);const C=a.length<=12?a.map((T,A)=>A):a.length<=20?[0,Math.floor(a.length/4),Math.floor(a.length/2),Math.floor(3*a.length/4),a.length-1]:[];const R=C.flatMap(T=>{const A=I=>(I-T+a.length)%a.length;const $=l.map(I=>({...I,source:A(I.source),target:A(I.target)}));const _=n.slice(T).concat(n.slice(0,T)),z=t.slice(T).concat(t.slice(0,T));const F=W0(_,$),G=oc(z,_,$);return[Uint32Array.from(a,(I,D)=>F[A(D)]),Uint32Array.from(a,(I,D)=>G[A(D)])]});const M=e.compactPrivateRanks&&a.length>16;const P=M&&u(h)<=3?HA(e,s,3):[];P.sort((T,A)=>A.span-T.span);const E=P.length>1?[P[0].order,P.at(-1).order,...P.slice(1,-1).map(T=>T.order)]:P.map(T=>T.order);const v=[...E,c,d,...R,Uint32Array.from(a,(T,A)=>A)];const L=P.length?[[false,false],[true,true],[true,false],[false,true]]:[[true,true],[true,false],[false,true],[false,false]];for(let T=0;T<v.length*L.length;T++){const A=v[M?T%v.length:Math.floor(T/L.length)];const[$,_]=L[M?Math.floor(T/v.length):T%L.length];const z=x(A,$,_);if(w.has(z))continue;w.add(z);if(k--<=0||s.attempts--<=0||s.routing.pairs<0||s.routing.arcs<0||s.routing.swaps<0)return m;try{const F=f(A,B=>{throw new Jg(B)},s.routing,$,_);const G=p(F);if(G===void 0)return m;const I=y(F),D=F.width*F.height;if(G<g||G===g&&(I<b||I===b&&D<S)){m=F;g=G;b=I;S=D}if(g===0)return m}catch(F){if(!(F instanceof Jg))throw F}}return m}function YA(e,t,n,i,r){let o=e.groups;const s=e.nodes.length;const a=s+o.length;const l=new Int32Array(a).fill(-1);const c=Array.from({length:o.length+1},()=>[]);const d=Array.from({length:o.length+1},()=>[]);const u=new Map;let f;const h=new Set;for(let M=0;M<a;M++){const P=M<s?e.nodes[M]:o[M-s];if(h.has(P.id))throw new TypeError("Measured compound identities must be unique");h.add(P.id);if(P.modelOrder!==void 0&&(!Number.isSafeInteger(P.modelOrder)||P.modelOrder<0))throw new TypeError("Invalid measured model order");if(P.partition!==void 0&&(!Number.isSafeInteger(P.partition)||P.partition<0||P.partition>1e4))throw new TypeError("Invalid measured partition");const E=P.parent??-1;if(!Number.isInteger(E)||E<-1||E>=o.length||E>=0&&M===s+E)throw new TypeError("Invalid measured compound parent");if(M<s){const v=e.nodes[M];if(![v.width,v.height].every(L=>Number.isFinite(L)&&L>0))throw new TypeError("Invalid measured compound leaf dimensions")}l[M]=E;c[E+1].push(M)}for(let M=0;M<o.length;M++){const P=new Set;for(let v=M;v>=0;v=l[s+v]){if(P.has(v))throw new TypeError("Measured compound parents must be acyclic");P.add(v);if(P.size>64)n("agentic local compound-depth limit")}const E=o[M];if(E.direction!==void 0&&!["TD","TB","BT","LR","RL"].includes(E.direction))throw new TypeError("Invalid measured compound direction");if(![E.minWidth,...Object.values(E.padding)].every(v=>Number.isFinite(v)&&v>=0))throw new TypeError("Invalid measured compound dimensions");if(E.headerHeight!==void 0&&(!Number.isFinite(E.headerHeight)||E.headerHeight<0||E.headerHeight>E.padding.top))throw new TypeError("Invalid measured compound header")}for(let M=0;M<e.edges.length;M++){const P=e.edges[M];if(!Number.isInteger(P.source)||!Number.isInteger(P.target)||P.source<0||P.target<0||P.source>=a||P.target>=a)throw new TypeError("Invalid measured compound endpoint");if(!Number.isSafeInteger(P.minSpan)||P.minSpan<1||P.label&&![P.label.width,P.label.height].every(v=>Number.isFinite(v)&&v>=0))throw new TypeError("Invalid measured compound edge dimensions");if(P.short!==void 0&&P.short!==true)throw new TypeError("Invalid measured short-edge preference");if(P.boundaryMarker!==void 0&&![P.boundaryMarker.inset,P.boundaryMarker.height].every(v=>Number.isFinite(v)&&v>=0))throw new TypeError("Invalid measured ancestor marker dimensions");let E=l[P.source];if(E!==l[P.target]){const v=new Set([-1]);for(let $=E;$>=0;$=l[s+$])v.add($);E=l[P.target];while(!v.has(E))E=l[s+E];const L=$=>{while(l[$]!==E)$=s+l[$];return $};const T=L(P.source),A=L(P.target);if(T===A){(f??=[]).push(M);continue}u.set(M,{source:T,target:A,host:E})}d[E+1].push(M)}const m=f?IA(e,l,r,n):void 0;if(m){if(f.some(M=>!m.connections.has(M)))throw new TypeError("Ancestor planner lost an authored endpoint occurrence");o=m.groups}const p=new Array(o.length+1);let g=0;const y=(M,P)=>{const E=o[M-1];const v=E?.direction??P;const L=c[M],T=new Map(L.map((D,B)=>[D,B]));const A=L.map(D=>{if(D<s){const{id:Y,width:W,height:O,partition:N,modelOrder:H,minimumPortSpacing:j}=e.nodes[D];return{id:Y,width:W,height:O,partition:N,modelOrder:H,...j!==void 0?{minimumPortSpacing:j}:{}}}const B=y(D-s+1,v);return{id:o[D-s].id,width:B.width,height:B.height,partition:o[D-s].partition,modelOrder:o[D-s].modelOrder}});const $=d[M].map(D=>{const B=e.edges[D];const Y=u.get(D)??B;return{...B,source:T.get(Y.source),target:T.get(Y.target)}});const _={nodes:A,edges:$,padding:0,direction:v,nodeSpacing:e.nodeSpacing,layerSpacing:e.layerSpacing,edgeSpacing:e.edgeSpacing,...e.minimumTerminalLead!==void 0?{minimumTerminalLead:e.minimumTerminalLead}:{},...e.placementOnly?{placementOnly:true}:{}};if(u.size&&d[M].some(D=>u.has(D)))_.compactPrivateRanks=true;const z=t(_);g+=z.expandedVertices??A.length;if(g>i)n("agentic local compound-expansion limit");const F=E?.padding??{top:e.padding,right:e.padding,bottom:e.padding,left:e.padding};const G=Math.max(E?.minWidth??0,z.width+F.left+F.right,1);const I={direction:v,placed:z,width:G,height:Math.max(z.height+F.top+F.bottom,1),dx:F.left+(G-z.width-F.left-F.right)/2,dy:F.top};if(!Number.isFinite(I.width+I.height+I.dx+I.dy))n("agentic local coordinate-range limit");p[M]=I;return I};const b=y(0,e.direction);const S=new Array(s);const x=new Array(o.length);const k=new Array(e.edges.length);const w=(M,P,E)=>{const v=p[M],L=P+v.dx,T=E+v.dy;c[M].forEach((A,$)=>{const _=v.placed.nodes[$],z={x:_.x+L,y:_.y+T};if(A<s)S[A]=z;else{const F=A-s,G=p[F+1];x[F]={...z,width:G.width,height:G.height};w(F+1,z.x,z.y)}});d[M].forEach((A,$)=>{const _=v.placed.edges[$];k[A]={points:_.points.map(z=>({x:z.x+L,y:z.y+T})),..._.labelPosition?{labelPosition:{x:_.labelPosition.x+L,y:_.labelPosition.y+T}}:{}}})};w(0,0,0);if(m)for(const M of m.connections.keys())k[M]=FA(m,M,x,P=>{if(!Number.isSafeInteger(P)||P<0)throw new TypeError("Invalid ancestor placeholder reservation");if(g+P>i)n("agentic local compound-expansion limit");g+=P});const C={topology:"layered",width:b.width,height:b.height,nodes:S,groups:x,edges:k,expandedVertices:g};let R=false;if(e.maximumEdgeStrokeWidth!==void 0)for(const M of e.edges){if(--r.pairs<0)n("agentic marker metadata work limit");if(M.markerPaint?.start?.length||M.markerPaint?.end?.length){R=true;break}}if(e.placementOnly)return C;if(!u.size&&!m&&!R){if(e.maximumEdgeStrokeWidth!==void 0&&e.maximumEdgeBendRadius===0){if(--r.arcs<0)n("agentic local cross-hierarchy visibility-arc limit");if(--r.pairs<0)n("agentic local cross-hierarchy crossing-work limit");th(e,C,new Set,r,n)}return C}return OA(e,C,l,u,p.map(M=>M.direction),r,i,n,m)}function qA(e,t,n,i,r,o,s){const a=.01;const l=e.filter(E=>Math.abs(E.sourceCross-E.targetCross)>a);if(!l.length)return t;r.pairs-=l.length*e.length;if(r.pairs<0)o("agentic local channel-pair limit");const c=E=>Math.min(E.sourceCross,E.targetCross);const d=E=>Math.max(E.sourceCross,E.targetCross);const u=(E,v)=>Math.min(d(E),d(v))>=Math.max(c(E),c(v))-.5;const f=(E,v)=>E>=c(v)-a&&E<=d(v)+a;const h=l.map(()=>[]),m=l.map(()=>[]);const p=[];const g=(E,v)=>{if(--r.arcs<0)o("agentic local channel-constraint limit");const L=p.length;p.push({source:E,target:v,minSpan:1});m[E].push(L);h[v].push(L)};for(let E=0;E<l.length;E++)for(let v=E+1;v<l.length;v++){const L=l[E],T=l[v];if(!u(L,T))continue;if(f(T.sourceCross,L)&&Math.abs(T.sourceCross-L.sourceCross)>a)g(v,E);if(f(T.targetCross,L)&&Math.abs(T.targetCross-L.targetCross)>a)g(E,v);if(f(L.sourceCross,T)&&Math.abs(L.sourceCross-T.sourceCross)>a)g(E,v);if(f(L.targetCross,T)&&Math.abs(L.targetCross-T.targetCross)>a)g(v,E)}const y=oc(h,m,p);const b=l.map((E,v)=>v).sort((E,v)=>y[E]-y[v]||E-v);let S=0;for(let E=0;E<b.length;E++){const v=l[b[E]];for(let L=0;L<E;L++){const T=l[b[L]];if(u(v,T))v.track=Math.max(v.track,T.track+1)}S=Math.max(S,v.track)}let x=false;const k=Math.max(1,Math.min(2,n/2));const w=e.flatMap(E=>[E.sourceCross,E.targetCross]).sort((E,v)=>E-v);for(const E of l){if(!e.some($=>$!==E&&Math.abs($.sourceCross-E.targetCross)<=.5&&(Math.abs($.sourceCross-$.targetCross)<=a||$.track>=E.track)))continue;let v=E.targetCross-n,L=E.targetCross+n;for(let $=w.length-1;$>=0;$--){const _=w[$];if(Math.abs(_-v)<k)v=_-k}for(const $ of w)if(Math.abs($-L)<k)L=$+k;const T=v>=0?E.targetCross-v:Infinity;const A=L<=i?L-E.targetCross:Infinity;if(!Number.isFinite(Math.min(T,A)))o("agentic local channel-terminal clearance");E.targetEscape=A<T||A===T&&E.sourceCross>E.targetCross?L:v;x=true}const C=Math.max(12,n,s??0);const R=2*C+S*n+(x?n:0);const M=Math.max(t,R),P=(M-R)/2;for(const E of e){E.offset=C+P+E.track*n;if(E.targetEscape!==void 0)E.targetExit=M-C}return M}var z0=4096;var XA=16384;var Qg=32768;var D3=4;var O3=8;function wr(e,t){return Number.isFinite(e)&&(t?e>0:e>=0)}function sc(e,t,n,i={pairs:1e6,arcs:65536,swaps:1e6},r={attempts:128,scorePairs:8e6,loopPairs:2e6,rankPairs:2e5,blockPairs:2e6,routing:{pairs:5e5,arcs:32768,swaps:5e5}}){const{nodes:o,edges:s,padding:a,nodeSpacing:l,layerSpacing:c}=e;if(o.length>z0||s.length>XA)n("agentic local graph-size limit");if(![a,l,c].every(me=>wr(me,false))){throw new TypeError("Measured graph spacing must be finite and nonnegative")}if(e.edgeSpacing!==void 0&&!wr(e.edgeSpacing,true))throw new TypeError("Measured edge spacing must be finite and positive");if(e.minimumTerminalLead!==void 0&&!wr(e.minimumTerminalLead,true))throw new TypeError("Measured terminal lead must be finite and positive");if(e.maximumEdgeStrokeWidth!==void 0&&!wr(e.maximumEdgeStrokeWidth,true))throw new TypeError("Measured maximum edge stroke width must be finite and positive");if(e.maximumEdgeBendRadius!==void 0&&!wr(e.maximumEdgeBendRadius,false))throw new TypeError("Invalid measured edge bend radius");for(const me of e.nodes)if(me.paintStrokeWidth!==void 0&&!wr(me.paintStrokeWidth,true))throw new TypeError("Invalid measured node paint stroke");for(const me of e.nodes)if(me.paintCornerRadius!==void 0&&!wr(me.paintCornerRadius,false))throw new TypeError("Invalid measured node corner radius");for(const me of e.nodes)if(me.minimumPortSpacing!==void 0&&!wr(me.minimumPortSpacing,true))throw new TypeError("Invalid measured node port spacing");for(const me of e.groups??[])if(me.paintStrokeWidth!==void 0&&!wr(me.paintStrokeWidth,true))throw new TypeError("Invalid measured group paint stroke");for(const me of e.groups??[])if(me.paintCornerRadius!==void 0&&!wr(me.paintCornerRadius,false))throw new TypeError("Invalid measured group corner radius");for(const me of e.edges)if(me.markerPaint!==void 0)SA(me.markerPaint);if(!["TD","TB","BT","LR","RL"].includes(e.direction))throw new TypeError("Invalid measured graph direction");if(e.groups?.length){if(o.length+e.groups.length>z0)n("agentic local compound-size limit");return YA(e,me=>sc(me,t,n,i,r),n,Qg,i)}const d=e.direction==="LR"||e.direction==="RL";const u=e.direction==="BT"||e.direction==="RL";const f=new Set;let h=false;for(const me of o){if(me.parent!==void 0)throw new TypeError("Measured parent requires a compound scope");if(me.modelOrder!==void 0){if(!Number.isSafeInteger(me.modelOrder)||me.modelOrder<0)throw new TypeError("Invalid measured model order");h=true}if(me.partition!==void 0&&(!Number.isSafeInteger(me.partition)||me.partition<0||me.partition>1e4))throw new TypeError("Invalid measured partition");if(f.has(me.id))throw new TypeError("Measured graph node identities must be unique");f.add(me.id);if(!wr(me.width,true)||!wr(me.height,true))throw new TypeError("Measured node dimensions must be finite and positive")}const m=o.map(()=>[]);const p=o.map(()=>[]);const g=new Uint32Array(o.length);let y=false,b=false;for(let me=0;me<s.length;me++){const he=s[me];if(!Number.isInteger(he.source)||!Number.isInteger(he.target)||he.source<0||he.source>=o.length||he.target<0||he.target>=o.length){throw new TypeError("Measured edge endpoint is outside the node array")}if(!Number.isSafeInteger(he.minSpan)||he.minSpan<1)throw new TypeError("Measured edge minimum span must be a positive integer");if(he.short!==void 0&&he.short!==true)throw new TypeError("Invalid measured short-edge preference");if(he.boundaryMarker!==void 0&&![he.boundaryMarker.inset,he.boundaryMarker.height].every(fe=>Number.isFinite(fe)&&fe>=0))throw new TypeError("Invalid measured ancestor marker dimensions");b||=he.short===true;if(he.label&&(!wr(he.label.width,false)||!wr(he.label.height,false))){throw new TypeError("Measured edge label dimensions must be finite and nonnegative")}if(he.source===he.target){y=true;continue}p[he.source].push(me);m[he.target].push(me);g[he.target]=g[he.target]+1}const S=o.some(me=>(me.partition??0)!==(o[0]?.partition??0));if(S&&s.some(me=>(o[me.source].partition??0)>(o[me.target].partition??0))){const me=s.map(fe=>(o[fe.source].partition??0)>(o[fe.target].partition??0));const he=sc({...e,edges:s.map((fe,be)=>me[be]?{...fe,source:fe.target,target:fe.source}:fe)},t,n,i,r);return{...he,edges:he.edges.map((fe,be)=>me[be]?{...fe,points:[...fe.points].reverse()}:fe)}}if(y){const me=[...o],he=[...s];const fe=[...e.loopPorts??[]];const be=new Int32Array(s.length).fill(-1);let ge=0;for(let ne=0;ne<s.length;ne++){const we=s[ne];if(we.source!==we.target)continue;if(me.length===z0||he.length===XA)n("agentic local loop-expansion limit");let Ee;do{Ee=`\0agentic-loop:${ge++}`}while(f.has(Ee));f.add(Ee);const ke=me.length;me.push({id:Ee,width:d?1:40,height:d?40:1,...S?{partition:o[we.source].partition??0}:{}});he[ne]={...we,target:ke,...we.label?{label:d?{width:we.label.width,height:2*we.label.height+8}:{width:2*we.label.width+8,height:we.label.height}}:{}};be[ne]=he.length;fe.push([ne,he.length]);he.push({source:we.source,target:ke,minSpan:we.minSpan})}const Re=sc({...e,nodes:me,edges:he,loopPorts:fe},t,n,i,r);const Ie={...Re,topology:"layered",nodes:Re.nodes.slice(0,o.length),edges:Re.edges.slice(0,s.length).map((ne,we)=>{const Ee=be[we];if(Ee<0)return ne;const ke=Re.edges[Ee].points;let le=ne.labelPosition;if(le&&s[we].label){const Se=d?le.x:le.y,Pe=d?le.y:le.x;let Ae=-1;for(let Oe=1;Oe<ke.length;Oe++){const We=ke[Oe-1],ce=ke[Oe];const Le=d?We.x:We.y,ve=d?ce.x:ce.y;const He=d?We.y:We.x,je=d?ce.y:ce.x;if(He===je&&Se>=Math.min(Le,ve)&&Se<=Math.max(Le,ve)){Ae=Pe<He?-1:1;break}}const Ne=((d?s[we].label.height:s[we].label.width)/2+4)*Ae;le=d?{x:le.x,y:le.y+Ne}:{x:le.x+Ne,y:le.y}}return{...ne,...le?{labelPosition:le}:{},points:ne.points.concat([...ke].reverse())}})};return zA(e,Ie,r)}const x=!S&&!h&&!b&&GA(e,m,p,n);if(x)return x;const k=!S&&!h&&!b&&t(e);if(k)return{...k,expandedVertices:o.length};const w=new Uint32Array(o.length);const C=o.flatMap((me,he)=>g[he]===0?[he]:[]);let R=0;for(let me=0;me<C.length;me++){const he=C[me];for(const fe of p[he]){const be=s[fe];const ge=w[he]+lo(be,e.compactPrivateRanks);if(ge>=B0)n("agentic local rank-expansion limit");w[be.target]=Math.max(w[be.target],ge);R=Math.max(R,ge);g[be.target]=g[be.target]-1;if(g[be.target]===0)C.push(be.target)}}if(C.length!==o.length){if(S){const me=e.authoredCycleOrder?Uint32Array.from(o,(be,ge)=>ge):oc(m,p,s);const he=s.map(be=>(o[be.source].partition??0)===(o[be.target].partition??0)&&me[be.source]>me[be.target]);const fe=sc({...e,cycleOriented:true,edges:s.map((be,ge)=>he[ge]?{...be,source:be.target,target:be.source}:be)},t,n,i,r);return{...fe,edges:fe.edges.map((be,ge)=>he[ge]?{...be,points:[...be.points].reverse()}:be)}}return jA(e,m,p,(me,he,fe)=>sc(me,t,he,fe,r),n,i,r)}const M=b?new Uint32Array(o.length):void 0;const P=b?new Uint32Array(o.length):void 0;if(b)for(const me of s){const he=me.short?100:1;M[me.target]=M[me.target]+he;P[me.source]=P[me.source]+he}for(let me=0;!S&&me<4;me++){let he=false;for(const fe of[true,false]){for(let be=0;be<C.length;be++){const ge=C[fe?C.length-1-be:be];let Re=0,Ie=R;for(const Ee of m[ge]){const ke=s[Ee];Re=Math.max(Re,w[ke.source]+lo(ke,e.compactPrivateRanks))}for(const Ee of p[ge]){const ke=s[Ee];Ie=Math.min(Ie,w[ke.target]-lo(ke,e.compactPrivateRanks))}const ne=b?P[ge]>=M[ge]:p[ge].length>=m[ge].length;const we=p[ge].length&&ne?Ie:Re;if(we!==w[ge]){w[ge]=we;he=true}}}if(!he)break}if(S){const me=new Map;for(const fe of C){const be=o[fe].partition??0;const ge=me.get(be)??[];ge.push(fe);me.set(be,ge)}let he=0;for(const fe of[...me.keys()].sort((be,ge)=>be-ge)){let be=he;for(const ge of me.get(fe)){let Re=he;for(const Ie of m[ge]){const ne=s[Ie];Re=Math.max(Re,w[ne.source]+lo(ne,e.compactPrivateRanks))}if(Re>=B0)n("agentic local rank-expansion limit");w[ge]=Re;be=Math.max(be,Re)}he=be+1}}if(S&&b){const me=new Map;for(const[he,fe]of o.entries()){const be=fe.partition??0,ge=me.get(be);if(ge){ge.lower=Math.min(ge.lower,w[he]);ge.upper=Math.max(ge.upper,w[he])}else me.set(be,{lower:w[he],upper:w[he]})}for(let he=0;he<4;he++){let fe=false;for(const be of[true,false])for(let ge=0;ge<C.length;ge++){const Re=C[be?C.length-1-ge:ge],Ie=me.get(o[Re].partition??0);let ne=Ie.lower,we=Ie.upper;for(const ke of m[Re]){const le=s[ke];ne=Math.max(ne,w[le.source]+lo(le,e.compactPrivateRanks))}for(const ke of p[Re]){const le=s[ke];we=Math.min(we,w[le.target]-lo(le,e.compactPrivateRanks))}const Ee=p[Re].length&&P[Re]>=M[Re]?we:ne;if(Ee!==w[Re]){w[Re]=Ee;fe=true}}if(!fe)break}}const E=!S&&WA(e,r,b);if(E)w.set(E);R=w.reduce((me,he)=>Math.max(me,he),0);let v=o.length;for(const me of s){v+=w[me.target]-w[me.source]-1;if(v>Qg)n("agentic local expanded-graph limit")}if(o.length===0){if(!Number.isFinite(2*a))n("agentic local coordinate-range limit");return{topology:"layered",width:2*a,height:2*a,nodes:[],edges:[],expandedVertices:0}}const L=o.map((me,he)=>({rank:w[he],crossSize:d?me.height:me.width,mainSize:d?me.width:me.height,incoming:[],outgoing:[]}));const T=[];const A=[];for(let me=0;me<s.length;me++){const he=s[me];const fe=[he.source];const be=he.label?Math.floor((w[he.source]+w[he.target])/2):-1;for(let ge=w[he.source]+1;ge<w[he.target];ge++){const Re=ge===be;const Ie=L.length;L.push({rank:ge,crossSize:Re?(d?he.label.height:he.label.width)+2*O3:4,mainSize:Re?d?he.label.width:he.label.height:0,incoming:[],outgoing:[]});if(Re)A[me]=Ie;fe.push(Ie)}fe.push(he.target);for(let ge=1;ge<fe.length;ge++){const Re=fe[ge-1],Ie=fe[ge];L[Re].outgoing.push(Ie);L[Ie].incoming.push(Re)}T.push(fe)}const $=Array.from({length:R+1},()=>[]);const _=new Float64Array($.length);const z=new Float64Array($.length);for(let me=0;me<L.length;me++)$[L[me].rank].push(me);const F=h?me=>{const he=me.filter(be=>o[be]?.modelOrder!==void 0);he.sort((be,ge)=>o[be].modelOrder-o[ge].modelOrder);let fe=0;for(let be=0;be<me.length;be++)if(o[me[be]]?.modelOrder!==void 0)me[be]=he[fe++]}:void 0;if(F)for(const me of $)F(me);let G=0;for(let me=0;me<$.length;me++){const he=$[me];let fe=Math.max(0,he.length-1)*l;for(const be of he){const ge=L[be];fe+=ge.crossSize;z[me]=Math.max(z[me],ge.mainSize)}_[me]=fe;G=Math.max(G,fe)}const I=new Float64Array(L.length);const D=me=>{let he=(G-_[me])/2;const fe=$[me];for(let be=0;be<fe.length;be++){const ge=fe[be];const Re=L[ge].crossSize;I[ge]=he+Re/2;he+=Re+l}};for(let me=0;me<$.length;me++)D(me);const B=new Float64Array(L.length);const Y=(me,he)=>{const fe=$[me];let be=true;for(let ge=0;ge<fe.length;ge++){const Re=fe[ge];const Ie=he?L[Re].incoming:L[Re].outgoing;let ne=0;for(let Ee=0;Ee<Ie.length;Ee++)ne+=I[Ie[Ee]];const we=Ie.length?ne/Ie.length:I[Re];B[Re]=we;be&&=Number.isFinite(we)}if(fe.length<=16&&be){for(let ge=1;ge<fe.length;ge++){const Re=fe[ge],Ie=B[Re];let ne=ge;while(ne>0){const we=fe[ne-1];if((B[we]-Ie||we-Re)<=0)break;fe[ne--]=we}fe[ne]=Re}}else fe.sort((ge,Re)=>B[ge]-B[Re]||ge-Re);F?.(fe);D(me)};const W=new Uint32Array(L.length);const O=$.slice(1).map(me=>new Uint32Array(me.length+1));const N=()=>{for(let me=0;me<$.length;me++){const he=$[me];for(let fe=0;fe<he.length;fe++)W[he[fe]]=fe}};const H=()=>{N();let me=0;for(let he=0;he+1<$.length;he++){const fe=O[he];fe.fill(0);let be=0;const ge=$[he];for(let Re=0;Re<ge.length;Re++){const Ie=L[ge[Re]].outgoing;for(let ne=0;ne<Ie.length;ne++){const we=Ie[ne];let Ee=0;for(let ke=W[we]+1;ke>0;ke-=ke&-ke)Ee+=fe[ke];me+=be-Ee}for(let ne=0;ne<Ie.length;ne++){for(let we=W[Ie[ne]]+1;we<fe.length;we+=we&-we)fe[we]=fe[we]+1}be+=Ie.length}}return me};let j=H(),q=$.map(me=>[...me]);const X=()=>{const me=H();if(me<j){j=me;q=$.map(he=>[...he])}};for(let me=0;me<D3;me++){for(let he=1;he<$.length;he++)Y(he,true);X();for(let he=$.length-2;he>=0;he--)Y(he,false);X()}q.forEach((me,he)=>{$[he]=me;me.forEach((fe,be)=>{W[fe]=be})});const V=()=>{N();for(let me=0;me<4;me++){let he=false;for(let fe=0;fe<$.length;fe++){const be=$[fe];for(let ge=0;ge+1<be.length;ge++){if(h&&o[be[ge]]?.modelOrder!==void 0&&o[be[ge+1]]?.modelOrder!==void 0)continue;const Re=L[be[ge]],Ie=L[be[ge+1]];const ne=Re.incoming.length*Ie.incoming.length+Re.outgoing.length*Ie.outgoing.length;if(ne>i.swaps)continue;i.swaps-=ne;let we=0;for(let Ee=0;Ee<Re.incoming.length;Ee++)for(let ke=0;ke<Ie.incoming.length;ke++)we+=Math.sign(W[Re.incoming[Ee]]-W[Ie.incoming[ke]]);for(let Ee=0;Ee<Re.outgoing.length;Ee++)for(let ke=0;ke<Ie.outgoing.length;ke++)we+=Math.sign(W[Re.outgoing[Ee]]-W[Ie.outgoing[ke]]);if(we>0){const Ee=be[ge],ke=be[ge+1];be[ge]=ke;be[ge+1]=Ee;W[Ee]=ge+1;W[ke]=ge;he=true}}}if(!he)break}};V();if(e.compactPrivateRanks&&o.length<=20&&s.length<=64&&L.length<=256){let me=H(),he=128;const fe=T.map(be=>be.slice(1,-1)).filter(be=>be.length>1).sort((be,ge)=>ge.length-be.length);for(const be of fe){if(me===0)break;const ge=new Map(be.map(we=>[L[we].rank,[...$[L[we].rank]]]));let Re=me,Ie,ne=false;for(const we of[0,1,.25,.5,.75]){const Ee=$.length+L.length+16*(L.length-o.length+s.length);if(he--<=0||(r.blockPairs??2e6)<Ee){ne=true;break}r.blockPairs=(r.blockPairs??2e6)-Ee;for(const le of be){const Se=L[le].rank,Pe=$[Se],Ae=ge.get(Se);for(let We=0;We<Pe.length;We++)Pe[We]=Ae[We];const Ne=Pe.indexOf(le),Oe=Math.floor((Pe.length-1)*we);if(Ne<Oe)for(let We=Ne;We<Oe;We++)Pe[We]=Pe[We+1];else for(let We=Ne;We>Oe;We--)Pe[We]=Pe[We-1];Pe[Oe]=le}const ke=H();if(ke<Re){Re=ke;Ie=new Map([...ge].map(([le])=>[le,[...$[le]]]))}}for(const[we,Ee]of Ie??ge)$[we]=Ee;me=Re;if(ne)break}}if(e.compactPrivateRanks&&o.length>12&&o.length<=20&&s.length<=64&&L.length<=256){BA($,L,T,r)}if(e.compactPrivateRanks&&!e.cycleOriented)V();for(let me=0;me<$.length;me++)D(me);const ee=new Int32Array(L.length).fill(-1),re=new Int32Array(L.length).fill(-1);for(const me of $){let he=-1;for(const fe of me){ee[fe]=he;if(fe<o.length)he=fe}he=-1;for(let fe=me.length-1;fe>=0;fe--){const be=me[fe];re[be]=he;if(be<o.length)he=be}}let U=new Float64Array(0);const te=Math.min(4,l);for(let me=0;me<4;me++)for(const he of[true,false]){for(let fe=0;fe<$.length;fe++){const be=$[he?fe:$.length-1-fe];for(let ge=0;ge<be.length;ge++){const Re=he?ge:be.length-1-ge,Ie=be[Re],ne=L[Ie];const we=ne.incoming.length+ne.outgoing.length;if(!we)continue;let Ee;if(we<=2){const Ae=ne.incoming[0]??ne.outgoing[0];const Ne=we===1?Ae:ne.incoming.length===2?ne.incoming[1]:ne.outgoing[ne.incoming.length===1?0:1];const Oe=I[Ae],We=I[Ne];Ee=he?Math.min(Oe,We):Math.max(Oe,We)}else{if(U.length<we)U=new Float64Array(we);const Ae=U.subarray(0,we);let Ne=0,Oe=true;for(let ce=0;ce<ne.incoming.length;ce++){const Le=I[ne.incoming[ce]];Ae[Ne++]=Le;Oe&&=Number.isFinite(Le)&&!Object.is(Le,-0)}for(let ce=0;ce<ne.outgoing.length;ce++){const Le=I[ne.outgoing[ce]];Ae[Ne++]=Le;Oe&&=Number.isFinite(Le)&&!Object.is(Le,-0)}const We=Oe?Ae.sort():Array.from(Ae).sort((ce,Le)=>ce-Le);Ee=We[Math.floor((we-Number(he))/2)]}const ke=be[Re-1],le=be[Re+1];let Se=ke===void 0?ne.crossSize/2:I[ke]+(L[ke].crossSize+ne.crossSize)/2+te;let Pe=le===void 0?G-ne.crossSize/2:I[le]-(L[le].crossSize+ne.crossSize)/2-te;if(Ie<o.length){const Ae=ee[Ie],Ne=re[Ie];if(Ae>=0)Se=Math.max(Se,I[Ae]+(L[Ae].crossSize+ne.crossSize)/2+l);if(Ne>=0)Pe=Math.min(Pe,I[Ne]-(L[Ne].crossSize+ne.crossSize)/2-l)}if(Se<=Pe)I[Ie]=Math.max(Se,Math.min(Pe,Ee))}}}const J=new Uint32Array(L.length);for(const me of $)me.forEach((he,fe)=>{J[he]=fe});const ae=Math.min(4,l);for(const me of T){if(me.length<4)continue;let he=1;while(he<me.length-1){let fe=-Infinity,be=Infinity,ge=he;while(ge<me.length-1){const Re=me[ge],Ie=L[Re],ne=$[Ie.rank],we=J[Re];const Ee=ne[we-1],ke=ne[we+1];const le=Ee===void 0?Ie.crossSize/2:I[Ee]+(L[Ee].crossSize+Ie.crossSize)/2+ae;const Se=ke===void 0?G-Ie.crossSize/2:I[ke]-(L[ke].crossSize+Ie.crossSize)/2-ae;const Pe=Math.max(fe,le),Ae=Math.min(be,Se);if(Pe>Ae)break;fe=Pe;be=Ae;ge++}if(ge>he+1){const Re=(I[me[he-1]]+I[me[ge]])/2;const Ie=Math.max(fe,Math.min(be,Re));for(let ne=he;ne<ge;ne++)I[me[ne]]=Ie}he=Math.max(he+1,ge)}}const Q=new Float64Array(s.length),K=new Float64Array(s.length);const Z=new Map;for(const me of e.loopPorts??[]){const he=s[me[0]],fe=s[me[1]];if(!he||!fe||he.source!==fe.source)throw new TypeError("Invalid measured loop port pair");const be=Z.get(he.source)??[];be.push(me);Z.set(he.source,be)}for(let me=0;me<o.length;me++){const he=L[me].crossSize;const fe=(be,ge)=>{const Re=[...be].sort((Ee,ke)=>{const le=T[Ee],Se=T[ke];const Pe=ge?le[1]:le[le.length-2];const Ae=ge?Se[1]:Se[Se.length-2];return I[Pe]-I[Ae]||Ee-ke});const Ie=ge?Z.get(me):void 0;if(Ie?.length){const Ee=new Map(Re.map((le,Se)=>[le,Se]));const ke=Ie.map(([le,Se])=>[Math.min(Ee.get(le),Ee.get(Se)),Math.max(Ee.get(le),Ee.get(Se))]);if(ke.some(([le,Se])=>he*(Se-le)/(Re.length+1)<8)){const le=new Float64Array(Re.length);const Se=new Map;for(const[Ne,Oe]of ke){const We=Se.get(Oe)??[];We.push(Ne);Se.set(Oe,We)}for(let Ne=0;Ne<Re.length;Ne++){le[Ne]=Ne?le[Ne-1]+2:0;for(const Oe of Se.get(Ne)??[])le[Ne]=Math.max(le[Ne],le[Oe]+8)}const Pe=Math.min(8,he/6);const Ae=he-2*Pe-(le.at(-1)??0);if(Ae<0)n("agentic local loop-attachment capacity");Re.forEach((Ne,Oe)=>{Q[Ne]=I[me]-he/2+Pe+le[Oe]+Ae*(Oe+1)/(Re.length+1)});return}}if(o[me].minimumPortSpacing!==void 0){i.pairs-=3;if(i.pairs<0)n("agentic node port-spacing work limit")}const ne=Math.min(8,he/6),we=Math.max(8,o[me].minimumPortSpacing??8);if(!Ie?.length&&he-2*ne>=(Re.length-1)*we){const Ee=I[me]-he/2+ne,ke=I[me]+he/2-ne;const le=Re.map((Se,Pe)=>{const Ae=T[Se],Ne=ge?Ae[1]:Ae[Ae.length-2];return Math.max(Ee+Pe*we,Math.min(ke-(Re.length-1-Pe)*we,I[Ne]))});for(let Se=1;Se<le.length;Se++)le[Se]=Math.max(le[Se],le[Se-1]+we);Re.forEach((Se,Pe)=>{(ge?Q:K)[Se]=le[Pe]});return}for(let Ee=0;Ee<Re.length;Ee++){const ke=I[me]-he/2+he*(Ee+1)/(Re.length+1);(ge?Q:K)[Re[Ee]]=ke}};fe(p[me],true);fe(m[me],false)}const se=Math.max(4,c/2);const oe=Array.from({length:R},()=>[]);const de=T.map((me,he)=>me.slice(1).map((fe,be)=>{const ge=me[be];const Re={sourceCross:be===0?Q[he]:I[ge],targetCross:be===me.length-2?K[he]:I[fe],offset:se/2,track:0};oe[L[ge].rank].push(Re);return Re}));const xe=oe.map(me=>{if(e.minimumTerminalLead!==void 0){i.pairs-=3;if(i.pairs<0)n("agentic terminal-lead work limit")}return qA(me,se,e.edgeSpacing??6,G,i,n,e.minimumTerminalLead)});const Me=new Float64Array(L.length);let Ce=0;for(let me=0;me<$.length;me++){for(const he of $[me])Me[he]=Ce+z[me]/2;Ce+=z[me]+(xe[me]??0)}if(!Number.isFinite(Ce+G+2*a))n("agentic local coordinate-range limit");const pe=(me,he)=>{const fe=a+(u?Ce-he:he);return d?{x:fe,y:a+me}:{x:a+me,y:fe}};const Te=o.map((me,he)=>{const fe=pe(I[he],Me[he]);return{x:fe.x-me.width/2,y:fe.y-me.height/2}});const Fe=(me,he)=>{const fe=L[he].crossSize,be=Math.min(8,fe/6);const ge=d?Te[he].y:Te[he].x;if(me===I[he]-fe/2+be)return ge+be;if(me===I[he]+fe/2-be)return ge+fe-be;return a+me};const De=(me,he)=>{const fe=Te[me],be=o[me];return d?fe.x+(he!==u?be.width:0):fe.y+(he!==u?be.height:0)};const Be=e.placementOnly&&!e.cycleOriented&&!e.loopPorts?.length?s.map(()=>({points:[]})):s.map((me,he)=>{const fe=T[he];const be=[];const ge=(ne,we,Ee,ke)=>{const le=pe(ne,we);if(Ee!==void 0){if(d)le.y=Ee;else le.x=Ee}if(ke!==void 0){if(d)le.x=ke;else le.y=ke}const Se=be.at(-1);if(Se?.x===le.x&&Se.y===le.y)return;const Pe=be.at(-2);if(Pe&&Se&&(Pe.x===Se.x&&Se.x===le.x&&(Se.y-Pe.y)*(le.y-Se.y)>=0||Pe.y===Se.y&&Se.y===le.y&&(Se.x-Pe.x)*(le.x-Se.x)>=0))be.pop();be.push(le)};for(let ne=1;ne<fe.length;ne++){const we=fe[ne-1],Ee=fe[ne];const ke=de[he][ne-1];const le=ke.sourceCross,Se=ke.targetCross;const Pe=Me[we]+L[we].mainSize/2;const Ae=Me[Ee]-L[Ee].mainSize/2;const Ne=Me[we]+z[L[we].rank]/2;const Oe=Ne+ke.offset;const We=we<o.length?Fe(le,we):void 0;const ce=Ee<o.length?Fe(Se,Ee):void 0;ge(le,Pe,We,we<o.length?De(we,true):void 0);ge(le,Oe,We);ge(ke.targetEscape??Se,Oe,ke.targetEscape===void 0?ce:void 0);if(ke.targetEscape!==void 0){ge(ke.targetEscape,Ne+ke.targetExit);ge(Se,Ne+ke.targetExit,ce)}ge(Se,Ae,ce,Ee<o.length?De(Ee,false):void 0)}const Re=A[he];const Ie=Re===void 0?void 0:pe(I[Re],Me[Re]);return{points:be,...Ie?{labelPosition:Ie}:{}}});return{topology:"layered",expandedVertices:L.length,width:2*a+(d?Ce:G),height:2*a+(d?G:Ce),nodes:Te,edges:Be}}function B3(e){const t=[];for(const n of e){const i=t.at(-1),r=t.at(-2);if(i?.x===n.x&&i.y===n.y)continue;if(r&&i&&(r.x===i.x&&i.x===n.x&&(i.y-r.y)*(n.y-i.y)>=0||r.y===i.y&&i.y===n.y&&(i.x-r.x)*(n.x-i.x)>=0))t.pop();t.push(n)}return t}function UA(e,t){if(t.topology==="forest"||t.sharedEdges?.length||e.edges.length>128||t.edges.reduce((f,h)=>f+h.points.length,0)>2048)return t;const n=e.nodes.map((f,h)=>({...t.nodes[h],width:f.width,height:f.height}));const i=(t.groups??[]).map((f,h)=>({...f,height:e.groups[h].padding.top}));const r=e.edges.map((f,h)=>{const m=t.edges[h].labelPosition;return f.label&&m?{x:m.x-f.label.width/2-2,y:m.y-f.label.height/2-2,width:f.label.width+4,height:f.label.height+4}:void 0});const o=t.edges.map((f,h)=>({points:f.points,source:String(e.edges[h].source),target:String(e.edges[h].target),style:e.edges[h].visible===false?"invisible":"solid"}));const s=()=>o.map(f=>({points:f.points,visible:f.style!=="invisible"}));const a=f=>f.slice(1).reduce((h,m,p)=>h+Math.abs(m.x-f[p].x)+Math.abs(m.y-f[p].y),0);const l=(f,h)=>`${Math.sign(h.x-f.x)},${Math.sign(h.y-f.y)}`;let c=512,d=8e6;const u=f=>(d-=f)>=0;for(const[f,h]of e.edges.entries()){if(t.boundaryRoutes?.includes(f))continue;if(h.source===h.target||h.visible===false||o[f].points.length<5)continue;let m=24;const p=[...n,...i,...r.filter((b,S)=>Boolean(b)&&S!==f)];const g=new Set([f]);let y;for(let b=0;b<4;b++){const S=o[f].points,x=t.edges[f].labelPosition;const k=[...S];let w=-1;if(x){w=k.findIndex(M=>M.x===x.x&&M.y===x.y);if(w<0)for(let M=1;M<k.length;M++){if(Ki(x,k[M-1],k[M])){w=M;k.splice(M,0,{...x});break}}if(w<0)break}const C=[[0,k.length-1],...w>0&&w<k.length-1?[[0,w],[w,k.length-1]]:[]];let R=false;e:for(const[M,P]of C)for(let E=M;E+2<P;E++){for(let v=P;v>E+2;v--)for(const L of[false,true]){d-=k.length;if(d<0)return t;const T=k[E],A=k[v];const $=L?{x:A.x,y:T.y}:{x:T.x,y:A.y};const _=B3([...k.slice(0,E+1),$,...k.slice(v)]);if(_.length>=S.length||a(_)>a(S)+1e-7||l(_[0],_[1])!==l(S[0],S[1])||l(_.at(-2),_.at(-1))!==l(S.at(-2),S.at(-1)))continue;d-=_.length*p.length;if(d<0)return t;if(_.slice(1).some((D,B)=>p.some(Y=>li(_[B],D,Y))))continue;d-=_.length*o.reduce((D,B)=>D+B.points.length,0);if(d<0)return t;const z=o.reduce((D,B)=>D+B.points.length,0);if(m--<=0)break e;if(c--<=0)return t;d-=z*z;if(d<0)return t;const F=ts(_,f,o,e,u,u);if(d<0)return t;if(F===void 0)continue;let G=x,I=r[f];if(x&&h.label&&!_.slice(1).some((D,B)=>Ki(x,_[B],D))){const D=[];for(let B=1;B<_.length;B++){const Y=_[B-1],W=_[B],O=Y.y===W.y;const N=(O?h.label.width:h.label.height)/2+2;const H=Math.min(O?Y.x:Y.y,O?W.x:W.y)+N;const j=Math.max(O?Y.x:Y.y,O?W.x:W.y)-N;if(H>j)continue;const q=Math.max(H,Math.min(j,O?x.x:x.y));D.push(O?{x:q,y:Y.y}:{x:Y.x,y:q});D.push({x:(Y.x+W.x)/2,y:(Y.y+W.y)/2})}D.sort((B,Y)=>Math.abs(B.x-x.x)+Math.abs(B.y-x.y)-Math.abs(Y.x-x.x)-Math.abs(Y.y-x.y));G=void 0;for(const B of D){const Y={x:B.x-h.label.width/2-2,y:B.y-h.label.height/2-2,width:h.label.width+4,height:h.label.height+4};d-=p.length+o.reduce((W,O)=>W+O.points.length,0);if(d<0)return t;if(Y.x<0||Y.y<0||Y.x+Y.width>t.width||Y.y+Y.height>t.height||p.some(W=>Xg(Y,W)))continue;if(o.some((W,O)=>O!==f&&W.style!=="invisible"&&W.points.slice(1).some((N,H)=>li(W.points[H],N,Y))))continue;G=B;I=Y;break}if(!G)continue}y??=_r(s(),g);o[f].points=_;if(F>y){o[f].points=S;continue}t.edges[f].points=_;if(G)t.edges[f].labelPosition={...G};r[f]=I;y=F;R=true;break e}}if(!R)break}}return t}function Zg(e,t,n,i,r,o){if(t.length>16||t.length+e.junctions.length+e.groups.length>24||n.length>32||e.alignments.length||e.edges.some(a=>a.label!==void 0||a.source.boundary==="group"||a.target.boundary==="group"))return n;let s=8;if(_r(n)!==1||o(n))return n;for(let a=0;a<t.length&&s>0;a++){const l=t[a];for(let c=a+1;c<t.length&&s>0;c++){const d=t[c];if(l.parentId!==d.parentId||l.width!==d.width||l.height!==d.height)continue;for(const u of["x","y"]){if(s<=0||l[u]===d[u])continue;s--;const f=l[u];l[u]=d[u];d[u]=f;if(r()){const h=i();if(_r(h)===0&&!o(h)&&h.every((m,p)=>m.obstacleFree&&(!n[p].sourceFacesTarget||m.sourceFacesTarget)&&(!n[p].targetFacesSource||m.targetFacesSource))){return h}}d[u]=l[u];l[u]=f}}}return n}var ey=class{#e=new Map;#t=0;#n;constructor(t){this.#n=t}get(t){const n=this.#e.get(t);if(!n)return void 0;this.#e.delete(t);this.#e.set(t,n);return n.value}set(t,n,i){if(i>this.#n)return;const r=this.#e.get(t);if(r){this.#e.delete(t);this.#t-=r.weight}this.#e.set(t,{value:n,weight:i});this.#t+=i;while(this.#e.size>64||this.#t>this.#n){const o=this.#e.keys().next().value;this.#t-=this.#e.get(o).weight;this.#e.delete(o)}}};var ty=globalThis;var KA=(ty.process?.env?.AGENTIC_MERMAID_ELK_CACHE??ty.AGENTIC_MERMAID_ELK_CACHE)!=="0";function JA(e){return JSON.stringify(e,(t,n)=>{if(n===void 0)return"\0undefined";if(typeof n==="number"&&!Number.isFinite(n))return`\0${n}`;if(typeof n==="string"&&n.startsWith("\0"))return`\0${n}`;if(n instanceof Map)return{mapEntries:[...n]};if(n instanceof Set)return{setValues:[...n]};return n})}var VA=new WeakMap;var ny=new WeakMap;function QA(e){const t=new ey(8*1024*1024);return n=>{if(!KA)return e(n);const i=JA(n);if(i.length>1024*1024)return e(n);const r=t.get(i);if(r)return structuredClone(r);const o=e(n);const s=i.length*2+JSON.stringify(o).length*4+512;if(s<=8*1024*1024)t.set(i,structuredClone(o),s);return o}}function ZA(e,t,n,i){const r=i;const o=ny.get(e);try{if(o&&i&&i!==o){o.pairs-=24;const l=i.pairs,c=i.arcs,d=i.swaps;o.pairs=Math.min(o.pairs,l-(1e6-o.pairs));o.arcs=Math.min(o.arcs,c-(65536-o.arcs));o.swaps=Math.min(o.swaps,d-(1e6-o.swaps));if(!Number.isFinite(o.pairs)||!Number.isFinite(o.arcs)||!Number.isFinite(o.swaps)||o.pairs<0||o.arcs<0||o.swaps<0)n("agentic marker preparation work limit")}i=ny.get(e)??i??{pairs:1e6,arcs:65536,swaps:1e6};const s=sc(e,t,n,i);const a=e.placementOnly?s:DA(e,s,i,Qg,n);return e.placementOnly?a:UA(e,a)}finally{if(o&&r&&r!==o){r.pairs=o.pairs;r.arcs=o.arcs;r.swaps=o.swaps}}}function nh(e,t,n,i,r,o=false,s="primary"){const{edgeSelectorIndices:a,graphEdgeMarkerPaintRegions:l,DEFAULTS:c,LABEL_PILL_PADDING:d,measureRenderStage:u,graphTextBlock:f,resolveLabelContent:h,groupTitleWidth:m,groupHeaderHeight:p,estimateNodeSize:g,resolveNodeInlineStyle:y,resolveEdgeInlineStyle:b,resolveClassInlineStyle:S,containsNonFiniteNumber:x,finishGraphGeometry:k}=r;if(t.preserveSubgraphChildOrder)r.unsupported("family-specific graph geometry");const w={...c,...t};const C=[];const R={pairs:1e6,arcs:65536,swaps:1e6};R.arcs-=2;const M=(_,z=0)=>{R.pairs-=_;R.arcs-=z;if(R.pairs<0||R.arcs<0)r.unsupported("agentic marker preparation work limit")};const P=u("graph-preparation",()=>{const _=[];const z=new Map;const F=new Map;const G=(K,Z,se)=>{const oe=_.length,de=K.direction??se;const xe=p(K,n);const Me=K.concurrencyRegion?t.stateVisual?.dividerMargin??0:0;z.set(K.id,oe);C.push(K);_.push({id:K.id,parent:Z,direction:de,minWidth:m(K,n),headerHeight:xe,padding:{top:xe+n.groupPaddingY+Me,bottom:n.groupPaddingY+Me,left:n.groupPaddingX+Me,right:n.groupPaddingX+Me}});for(const Ce of K.nodeIds)F.set(Ce,{parent:oe,direction:de});K.children.forEach(Ce=>G(Ce,oe,de))};e.subgraphs.forEach(K=>G(K,void 0,e.direction));const I=[...e.nodes].map(([K,Z])=>{if(z.has(K))r.unsupported("overlapping node and frame identities");const se=F.get(K);return{id:K,...se?{parent:se.parent}:{},...t.nodeSizes?.get(K)??g(K,h(Z.label,Z.labelContent),Z.shape,n,se?.direction??e.direction,t.stateVisual,Z.labelBlock)}});const D=new Map(I.map((K,Z)=>[K.id,Z]));for(const[K,Z]of z)D.set(K,I.length+Z);const B=new Set;for(const[K,Z]of Object.entries(t.layoutHints?.ranks??{})){const se=D.get(K);if(se===void 0||!e.nodes.has(K))throw new Error(`LAYOUT_HINT_INVALID: unknown node "${K}"`);if(!Number.isSafeInteger(Z)||Z<0||Z>1e4)throw new Error(`LAYOUT_HINT_INVALID: rank for "${K}" must be an integer in [0,10000]`);const oe=I[se];oe.partition=Z;B.add(oe.parent??-1)}for(const K of I)if(B.has(K.parent??-1)&&K.partition===void 0)K.partition=0;for(const K of _)if(B.has(K.parent??-1))K.partition=0;if(t.layoutHints?.adjacent?.length){const K=new Map;const Z=[...I,..._];Z.forEach((xe,Me)=>{const Ce=xe.parent??-1,pe=K.get(Ce)??[];pe.push(Me);K.set(Ce,pe)});const se=new Map;for(const xe of K.values())xe.forEach((Me,Ce)=>se.set(Me,Ce));const oe=new Set,de=new Map;for(const xe of t.layoutHints.adjacent){if(xe.length<2)throw new Error("LAYOUT_HINT_INVALID: adjacent needs two or more nodes");const Me=xe.map(Te=>{const Fe=D.get(Te);if(Fe===void 0||!e.nodes.has(Te))throw new Error(`LAYOUT_HINT_INVALID: unknown node "${Te}"`);return Fe});const Ce=I[Me[0]].parent??-1;if(Me.some(Te=>(I[Te].parent??-1)!==Ce))throw new Error("LAYOUT_HINT_INVALID: adjacent nodes need the same container");for(const Te of Me){if(oe.has(Te))throw new Error("LAYOUT_HINT_INVALID: a node cannot repeat in adjacency groups");oe.add(Te)}const pe=de.get(Ce)??new Map;pe.set(Math.min(...Me.map(Te=>se.get(Te))),Me);de.set(Ce,pe)}for(const[xe,Me]of de){let Ce=0;K.get(xe).forEach((pe,Te)=>{const Fe=Me.get(Te);if(Fe)for(const De of Fe)Z[De].modelOrder=Ce++;else if(!oe.has(pe))Z[pe].modelOrder=Ce++})}}let Y;if(t.layoutHints?.shortEdges?.length){Y=new Set;const K=a(e.edges);for(const Z of t.layoutHints.shortEdges){const se=K.get(Z);if(se===void 0)throw new Error(`LAYOUT_HINT_INVALID: unknown edge "${Z}"`);Y.add(se)}}const W=_.length?(K,Z)=>{const se=(oe,de)=>{for(let xe=de<I.length?I[de].parent:_[de-I.length].parent;xe!==void 0;xe=_[xe].parent){if(xe===oe)return true}return false};if(K>=I.length&&se(K-I.length,Z))return"start";if(Z>=I.length&&se(Z-I.length,K))return"end";return void 0}:void 0;let O=0,N=0,H=0;M(0,3*I.length+5);const j=new Float64Array(I.length),q=new Uint32Array(I.length),X=new Uint32Array(I.length);const V=new Map;const ee=K=>{M(4+(typeof K==="string"?K.length:0),1);if(typeof K==="string"&&!/^\s*(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test(K))return void 0;const Z=typeof K==="number"?K:Number.parseFloat(K);return Number.isFinite(Z)&&Z>0?Z:void 0};const re=e.edges.map((K,Z)=>{const se=D.get(K.source),oe=D.get(K.target);if(se===void 0||oe===void 0)r.unsupported("unknown endpoint");const de=K.label?f(h(K.label,K.labelContent),n,"edge"):void 0;const xe=W?.(se,oe);let Me;const Ce=b(Z,e);const pe=!o&&K.style!=="invisible"&&(K.hasArrowStart||K.hasArrowEnd);const Te=ee(Ce?.["stroke-width"]??n.lineWidth*(K.style==="thick"?2:1));if(K.style!=="invisible"&&Te!==void 0)H=Math.max(H,Te);let Fe;if((pe||xe)&&Te!==void 0){M(12,15);const Be=(Ce?.stroke??n.edgeStrokeColor)==="none";const me=Boolean(Ce?.["stroke-width"]);const he=JSON.stringify([xe??null,K.style,K.hasArrowStart,K.hasArrowEnd,K.startMarker,K.endMarker,Be,me]);Fe=V.get(he);if(!Fe){M(Be?4096:2048,Be?2048:1024);const Re=xe==="end"?[{x:1,y:0},{x:0,y:0}]:[{x:0,y:0},{x:1,y:0}];const Ie=l({...K,id:"marker-room",source:"",target:"",points:Re,inlineStyle:me?{"stroke-width":"1"}:void 0},{lineWidth:n.lineWidth,...Be?{edgeStrokeColor:"none"}:{}});let ne=0,we=0,Ee=0,ke=0,le=0,Se=0;for(const Pe of Ie){M(18);const Ae=Pe.bounds;if(!Ae||!Number.isFinite(Ae.x0)||!Number.isFinite(Ae.x1)||!Number.isFinite(Ae.y0)||!Number.isFinite(Ae.y1)||Ae.x0>Ae.x1||Ae.y0>Ae.y1)r.unsupported("agentic marker paint bounds");const Ne=Pe.position==="start"?xe==="end"?1-Ae.x0:Ae.x1:xe==="end"?Ae.x1:1-Ae.x0;if(Pe.position==="start")ne=Math.max(ne,Ne);else if(Pe.position==="end")we=Math.max(we,Ne);Ee=Math.max(Ee,Ae.y1-Ae.y0);if(Pe.position===xe){Se++;ke=Math.max(ke,Ae.x1);le=Math.max(le,2*Math.max(Math.abs(Ae.y0),Math.abs(Ae.y1)))}}M(0,7);Fe={start:ne,end:we,span:Ee,boundaryInset:ke,boundaryHeight:le,boundaryCount:Se};V.set(he,Fe)}const{start:fe,end:be,span:ge}=Fe;if(pe){O=Math.max(O,fe+td+n.edgeBendRadius,be+td+n.edgeBendRadius,ge);N=Math.max(N,fe+be);if(K.hasArrowStart&&se<I.length)j[se]=Math.max(j[se],ge);if(K.hasArrowEnd&&oe<I.length)j[oe]=Math.max(j[oe],ge)}}if(K.style!=="invisible"){M(2);if(se<I.length)X[se]=X[se]+1;if(oe<I.length)q[oe]=q[oe]+1}if(xe){const Be=K.style!=="invisible"&&(xe==="start"?K.hasArrowStart:K.hasArrowEnd);if(Be&&(!Fe||!Fe.boundaryCount))r.unsupported("ancestor marker paint bounds");Me={inset:Be?Fe.boundaryInset:0,height:Be?Fe.boundaryHeight:0}}const De=xe&&de?Math.max(4,n.lineWidth*(K.style==="thick"?2:1)*2):0;return{source:se,target:oe,minSpan:K.length??1,...Y?.has(Z)?{short:true}:{},...Me?{boundaryMarker:Me}:{},...K.style==="invisible"?{visible:false}:{},...de?{label:{width:de.width+2*d+2*De,height:de.height+2*d+2*De}}:{}}});const U=!t.stateVisual&&!_.length&&[...e.nodes.values()].every(K=>K.shape==="rectangle"&&!K.semanticShape)&&e.edges.every((K,Z)=>{if(K.label||K.style!=="solid"||K.hasArrowStart||!K.hasArrowEnd||K.endMarker&&K.endMarker!=="arrow")return false;const se=b(Z,e);return!se||Object.keys(se).length===0});let te=Math.max(n.nodeLineWidth,n.groupLineWidth)/2;for(const[K]of e.nodes){const Z=ee(y(K,e)?.["stroke-width"]??n.nodeLineWidth);M(3);if(Z!==void 0)te=Math.max(te,Z/2)}for(const K of C)if(K.stateComposite){const Z=ee(S(K.id,e)?.["stroke-width"]??n.groupLineWidth);if(Z!==void 0)te=Math.max(te,Z/2)}const J=te+H/2;const ae=Math.max(6,n.lineWidth+4);const Q=O+J>Math.max(12,ae)?O+J:void 0;for(let K=0;K<I.length;K++){M(6);const Z=I[K],se=e.nodes.get(Z.id),oe=Math.max(q[K],X[K]);const de=j[K]+H;if(oe<2||j[K]<=8||se.shape!=="rectangle"||se.semanticShape||t.nodeSizes?.has(Z.id))continue;const xe=(F.get(Z.id)?.direction??e.direction)==="LR"||(F.get(Z.id)?.direction??e.direction)==="RL";const Me=(oe-1)*de,Ce=Me<=32?Me*1.5:Me+16;if(!Number.isFinite(Ce))r.unsupported("agentic marker spacing range");if(xe)Z.height=Math.max(Z.height,Ce);else Z.width=Math.max(Z.width,Ce);Z.minimumPortSpacing=de}if(!Number.isFinite(N+J)||!Number.isFinite(Q??0)||!Number.isFinite(2*(N+J)))r.unsupported("agentic marker spacing range");return{nodes:I,groups:_,edges:re,shareCompleteFans:U,direction:e.direction,padding:w.padding,nodeSpacing:w.nodeSpacing,layerSpacing:Math.max(w.layerSpacing,2*(N+J)),edgeSpacing:ae,...Q!==void 0?{minimumTerminalLead:Q}:{},...s==="authored"?{authoredCycleOrder:true}:s==="compact"?{compactPrivateRanks:true}:{},...o?{placementOnly:true}:{}}});M(0,2);ny.set(P,R);let E;try{E=u("agentic",()=>i(P))}finally{ny.delete(P)}if(E.nodes.length!==P.nodes.length||(E.groups?.length??0)!==P.groups.length||E.edges.length!==e.edges.length||x(E)||E.sharedEdges?.some(_=>!Number.isInteger(_)||_<0||_>=e.edges.length)||!o&&E.edges.some((_,z)=>_.points.length<2||P.edges[z].label&&!_.labelPosition)){throw new TypeError("Agentic graph producer returned malformed geometry")}const v=P.nodes.map((_,z)=>{const F=e.nodes.get(_.id);const G=e.classAssignments.get(_.id);return{...F,id:_.id,width:_.width,height:_.height,...E.nodes[z],inlineStyle:y(_.id,e),classNames:G?.split(/\s+/).filter(Boolean)}});const L=o?[]:e.edges.map((_,z)=>({..._,...E.edges[z],edgeIndex:z,inlineStyle:b(z,e),..._.id&&e.classAssignments.has(_.id)?{classNames:e.classAssignments.get(_.id).split(/\s+/).filter(Boolean)}:{}}));const T=C.map((_,z)=>{const F={id:_.id,label:_.label,..._.labelContent?{labelContent:_.labelContent}:{},...E.groups[z],children:[],..._.concurrencyRegion?{concurrencyRegion:true}:{},..._.headerMinHeight===void 0?{}:{headerMinHeight:_.headerMinHeight},..._.stateComposite?{inlineStyle:S(_.id,e)}:{}};if(o)F.headerHeight=P.groups[z].headerHeight;return F});const A=[];T.forEach((_,z)=>{const F=P.groups[z].parent;if(F===void 0)A.push(_);else T[F].children.push(_)});if(o)return{width:E.width,height:E.height,nodes:v,edges:[],groups:A};const $=k({width:E.width,height:E.height,nodes:v,edges:L,groups:A},e,E.topology==="forest",w.padding,n,t.stateVisual?.noteMargin??18,void 0,E.sharedEdges).positioned;if(x($))throw new TypeError("Agentic graph pipeline returned non-finite geometry");return $}function W3(e,t,n,i,r){const o=t.compareRoutePreferences!==false&&!t.stateVisual&&!e.subgraphs.length&&e.nodes.size<=20&&e.edges.length<=64;let s,a;if(o&&KA&&!r.customTextMeasurementActive()){const f=JA([e,t,n,Object.keys(ty.process?.env??{}).filter(h=>h.startsWith("APL_")).map(h=>[h,ty.process.env[h]]).sort()]);if(f.length<=65536){s=f;a=VA.get(r);if(!a){a=new ey(1024*1024);VA.set(r,a)}const h=a.get(s);if(h)return nh(e,t,n,i,r,false,h)}}const l=nh(e,t,n,i,r);if(!o)return l;const c=[{strategy:"agentic-authored-order",produce:()=>nh(e,t,n,i,r,false,"authored")}];if(e.edges.some(f=>!f.label))c.push({strategy:"agentic-compact-ranks",produce:()=>nh(e,t,n,i,r,false,"compact")});const d=z3(e,n,l,c,r);const u=d===l?"primary":d.certification?.strategy==="agentic-authored-order"?"authored":d.certification?.strategy==="agentic-compact-ranks"?"compact":void 0;if(s&&a&&u)a.set(s,u,s.length*2+128);return d}function z3(e,t,n,i,r){const{countEdgeCrossings:o,countOpposingRouteOverlaps:s,countParallelRouteOverlaps:a,measureLabelConflicts:l}=r;const c=m=>m.edges.reduce((p,g)=>p+g.points.length,0);if(e.subgraphs.length||e.nodes.size>20||e.edges.length>64||e.edges.reduce((m,p)=>m+(p.length??1),0)>128||c(n)>2048||o(n.edges)===0)return n;G0(e,t,{strategy:"agentic-layered",produce:()=>n},r);const d=m=>[l(m,t).total,s(m.edges),a(m.edges),o(m.edges),m.edges.reduce((p,g)=>p+(g.style==="invisible"?0:Math.max(0,g.points.length-2)),0),m.width*m.height];let u=n,f=d(n);const h=typeof i==="function"?[{strategy:"agentic-authored-order",produce:i}]:i;for(const m of h.slice(0,2)){let p;try{p=G0(e,t,m,r)}catch(y){if(!(y instanceof bo)&&!(y instanceof Qe))throw y;continue}if(c(p)>2048)continue;const g=d(p);for(let y=0;y<f.length;y++){if(g[y]<f[y]){u=p;f=g;break}if(g[y]>f[y])break}if(f[3]===0)break}return u}function G0(e,t,n,i){const r=i.certifyCandidate(e,t,n,true);if(!r.certified)throw new Qe([r.attempt]);return i.retainSelection(e,{selected:r.certified,reason:"first-certified",attempts:1,compared:[{strategy:r.certified.strategy,score:r.certified.score}]})}function eI(e,t,n,i,r){const o=W3(e,t,n,i,r);return G0(e,n,{strategy:"agentic-layered",produce:()=>o},r)}function tI(e,t,n,i,r){const o=nh(e,t,n,i,r,true);return{width:o.width,height:o.height,nodes:o.nodes,groups:o.groups}}function iy(e){const{nodes:t,edges:n,padding:i,nodeSpacing:r,layerSpacing:o}=e;if(t.length<2||n.length>=t.length||r<=0||o<=0||![i,r,o].every(M=>Number.isFinite(M)&&M>=0)||t.some(M=>!Number.isFinite(M.width)||!Number.isFinite(M.height)||M.width<=0||M.height<=0))return void 0;const s=t.map(()=>[]);const a=new Uint32Array(t.length);for(const M of n){if(M.label!==void 0||M.minSpan!==1||M.source===M.target||!Number.isInteger(M.source)||!Number.isInteger(M.target)||M.source<0||M.source>=t.length||M.target<0||M.target>=t.length)return void 0;a[M.target]=a[M.target]+1;if(a[M.target]>1)return void 0;s[M.source].push(M.target)}const l=t.flatMap((M,P)=>a[P]===0?[P]:[]);const c=[...l];const d=new Uint32Array(t.length);for(let M=0;M<c.length;M++){const P=c[M];for(const E of s[P]){d[E]=d[P]+1;c.push(E)}}if(c.length!==t.length)return void 0;const u=e.direction==="LR"||e.direction==="RL";const f=e.direction==="RL"||e.direction==="BT";const h=M=>u?t[M].width:t[M].height;const m=M=>u?t[M].height:t[M].width;if(t.some((M,P)=>M.minimumPortSpacing!==void 0&&(s[P].length-1)*M.minimumPortSpacing>m(P)-2*(M.paintCornerRadius??0)))return void 0;const p=new Float64Array(t.length),g=[];for(let M=c.length-1;M>=0;M--){const P=c[M],E=s[P];let v=Math.max(0,E.length-1)*r;for(const L of E)v+=p[L];p[P]=Math.max(m(P),v);g[d[P]]=Math.max(g[d[P]]??0,h(P))}const y=[];let b=0;for(let M=0;M<g.length;M++){y.push(b);b+=g[M]+(M+1<g.length?o:0)}const S=new Float64Array(t.length);let x=0;for(const M of l){S[M]=x;x+=p[M]+r}x-=r;if(!Number.isFinite(b+x+2*i))return void 0;const k=t.map(()=>({x:0,y:0}));for(const M of c){const P=s[M];const E=i+S[M]+(p[M]-m(M))/2;let v=y[d[M]]+(g[d[M]]-h(M))/2;if(f)v=b-v-h(M);v+=i;k[M]=u?{x:v,y:E}:{x:E,y:v};let L=Math.max(0,P.length-1)*r;for(const A of P)L+=p[A];let T=S[M]+(p[M]-L)/2;for(const A of P){S[A]=T;T+=p[A]+r}}const w=new Float64Array(t.length);const C=e.edgeSpacing??6;for(let M=0;M<t.length;M++){const P=t[M].minimumPortSpacing,E=s[M];if(!P||E.length<2)continue;const v=[],L=[];const T=(u?k[M].y:k[M].x)+m(M)/2;for(const[$,_]of E.entries()){const z=T+($-(E.length-1)/2)*P;const F=(u?k[_].y:k[_].x)+m(_)/2;if(F<z)v.push(_);else if(F>z)L.push(_)}const A=Math.max(v.length,L.length);if((A-1)*C>o-2*Math.max(12,e.minimumTerminalLead??0))return void 0;v.forEach(($,_)=>{w[$]=(_-(v.length-1)/2)*C});L.forEach(($,_)=>{w[$]=((L.length-1)/2-_)*C})}const R=new Uint32Array(t.length);return{topology:"forest",width:2*i+(u?b:x),height:2*i+(u?x:b),nodes:k,edges:n.map(M=>{if(e.placementOnly&&!e.cycleOriented&&!e.loopPorts?.length)return{points:[]};const P=k[M.source],E=k[M.target];const v=t[M.source],L=t[M.target];const T=u?{x:P.x+(f?0:v.width),y:P.y+v.height/2}:{x:P.x+v.width/2,y:P.y+(f?0:v.height)};const A=u?{x:E.x+(f?L.width:0),y:E.y+L.height/2}:{x:E.x+L.width/2,y:E.y+(f?L.height:0)};const $=R[M.source],_=s[M.source].length;R[M.source]=$+1;if(v.minimumPortSpacing&&_>1){const D=($-(_-1)/2)*v.minimumPortSpacing;if(u)T.y+=D;else T.x+=D}let z=u?(T.x+A.x)/2:(T.y+A.y)/2;const F=d[M.source];const G=i+(f?b-(y[F]+g[F]):y[F]+g[F]);const I=i+(f?b-y[F+1]:y[F+1]);if(z<=Math.min(G,I)||z>=Math.max(G,I))z=G+(I-G)/2;if(v.minimumPortSpacing&&_>1)z=(G+I)/2+(f?-1:1)*w[M.target];return{points:u?[T,{x:z,y:T.y},{x:z,y:A.y},A]:[T,{x:T.x,y:z},{x:A.x,y:z},A]}})}}function G3(e){throw new bo(e)}var Ya=QA(e=>ZA(e,iy,G3));function nI(e,t,n,i){return eI(e,t,n,Ya,i)}function iI(e,t,n,i){return tI(e,t,n,Ya,i)}function Dd(e,t,n){const i=kt(e,[t,n]);return typeof i==="number"&&Number.isFinite(i)&&i>=0?i:void 0}var H3={subject:"ER text entity",example:'A["I #9829; ER"]'};var j3='"%\\';function rI(e){return e.replace(/\\(["\\])/g,"$1")}function ih(e,t,n){const i=e.slice(1,-1);if(i.includes("\\"))n?.(`${t} ${e} contains a backslash, and \\" reads as "`,'write " as #quot; and \\ as #92;');else if(i.includes("%"))n?.(`${t} ${e} contains a % and is read as written`,"write % as #37;");else if(i==="")n?.(`${t} ${e} is empty and is read as no text`,"give the name some text");return rI(i)}function oI(e,t){const n=e.trim();if(!n.startsWith('"'))return n;if(/^"[^"]*"$/.test(n))return n.slice(1,-1);if(/^"(?:\\.|[^"\\])*"$/.test(n)){t?.(`ER relation label ${n} contains \\", which reads as "`,'write " as #quot;');return rI(n.slice(1,-1))}throw Je({what:`ER relation label ${n} is not one quoted string`,expectedForm:'one pair of quotes, with " written as #quot;',example:'A ||--o{ B : "says #quot;hi#quot;"'})}function rh(e){return nn(e,H3)}function sI(e){return yt(e).replace(/\*\*([\s\S]+?)\*\*/g,"<b>$1</b>").replace(/_([^_\n]+)_/g,"<i>$1</i>").replace(/(?<!\*)\*([^*\n]+)\*(?!\*)/g,"<i>$1</i>")}function Y3(e){return rh(sI(e))}function H0(e,t,n=false){if(!/#\w+;/.test(e))return void 0;const i=n?yt(e):sI(e);const r=cr(vt(i,n?"literal":"formatted"),/#\w+;/g,rh);return{value:t,prepared:r,authored:e}}function oh(e,t=false){const n=t?Y3(e):rh(e);const i=H0(e,n);return{label:n,...i?{labelContent:i}:{}}}function sh(e,t){const n=qe(e,t);if(typeof n!=="string")return ia(n).replace(/\s+/g," ").trim();return gs(e).replace(/\s+/g," ").trim()}function aI(e,t,n){return n?.value===e&&n.authored!==void 0?mr(n.authored,t):dn(e,t)}function q3(e,t){return`"${aI(e,j3,t)}"`}var X3=/^(?:(?:one|many|to|style|classDef|class|subgraph|end|erDiagram)(?!\w)|u-)/i;function lI(e){return/^[A-Za-z_][\w-]*$/.test(e)&&!X3.test(e)}function tfe(e,t){return lI(e)?e:`"${aI(e,'"',t)}"`}function nfe(e,t){return e.split(" ").every(lI)?e:q3(e,t)}function co(e,t,n){if(e.source===e.target)return false;const i=t.get(e.source);const r=t.get(e.target);if(!i||!r)return false;const o=_t(n);const s=XS(i);const a=XS(r);return(o.isHorizontal?a.x-s.x:a.y-s.y)*o.sign>8}function ac(e,t,n=18){if(e.length<2)return false;const i=e.map(r=>Po(r,t));return Math.max(...i)-Math.min(...i)<=n}function dI(e,t){const n=_t(t);const i=[];const r=18;const o=[...e].sort((a,l)=>Po(a,t)-Po(l,t)||rr(a,t)-rr(l,t));for(const a of o){const l=Po(a,t);let c=i.find(d=>Math.abs(Po(d[0],t)-l)<=r);if(!c){c=[];i.push(c)}c.push(a)}const s=24;for(const a of i){const l=[...a].sort((d,u)=>rr(d,t)-rr(u,t));let c=rr(l[0],t);for(const d of l){const u=rr(d,t);if(u<c){const f=c-u;if(n.isHorizontal)d.y+=f;else d.x+=f}c=rr(d,t)+Eo(d,t)+s}}}function zn(e,t){const n=i=>i.some(r=>e.x>=r.x-.5&&e.y>=r.y-.5&&e.x+e.width<=r.x+r.width+.5&&e.y+e.height<=r.y+r.height+.5||n(r.children));return n(t)}function Od(e,t=[]){for(const n of e){t.push(n);Od(n.children,t)}return t}function ry(e,t){return e.x>=t.x-.5&&e.y>=t.y-.5&&e.x+e.width<=t.x+t.width+.5&&e.y+e.height<=t.y+t.height+.5}function uI(e,t,n,i){if(i<=0)return;const r=_t(n);const o=new Set;for(const s of Od(e)){if(o.has(s)||!t.some(a=>ry(a,s)))continue;o.add(s);if(r.isHorizontal){if(r.sign>0)s.width+=i;else{s.x-=i;s.width+=i}}else if(r.sign>0)s.height+=i;else{s.y-=i;s.height+=i}}}function U3(e,t){if(e.shape==="diamond"&&(t==="NE"||t==="SE"||t==="SW"||t==="NW"))return Yo(e)[t];return Ft(e)[t]}function j0(e,t,n,i){if(e.shape==="diamond"){const s=i===2?{LR:["NE","SE"],RL:["NW","SW"],BT:["NW","NE"],TD:["SW","SE"],TB:["SW","SE"]}:i===3?{LR:["NE","E","SE"],RL:["NW","W","SW"],BT:["NW","N","NE"],TD:["SW","S","SE"],TB:["SW","S","SE"]}:{};const a=s[t]?.[n];if(a)return U3(e,a)}const r=_t(t);const o=(n+1)/(i+1);if(r.isHorizontal)return{x:r.sourceSide==="E"?e.x+e.width:e.x,y:e.y+e.height*o};return{x:e.x+e.width*o,y:r.sourceSide==="S"?e.y+e.height:e.y}}function fI(e,t){return Ft(e)[_t(t).targetSide]}function oy(e,t){return Array.from({length:e},(n,i)=>(i-(e-1)/2)*t)}function lc(e,t,n,i){const r=Math.abs(t-e);if(r/2>=i||r<n+i)return e+(t-e)/2;return t-Math.sign(t-e)*i}function Vs(e,t,n,i){const r=_t(n);return r.isHorizontal?xt([e,{x:i,y:e.y},{x:i,y:t.y},t]):xt([e,{x:e.x,y:i},{x:t.x,y:i},t])}function V3(e,t,n,i,r=1,o){const s=Math.min(e.x,t.x),a=Math.max(e.x,t.x);const l=Math.min(e.y,t.y),c=Math.max(e.y,t.y);for(const d of n){o?.(1);if(i.has(d.id))continue;const u=d.x-r,f=d.x+d.width+r;const h=d.y-r,m=d.y+d.height+r;if(Math.abs(e.x-t.x)<.01){if(e.x>=u&&e.x<=f&&l<m&&c>h)return false}else if(Math.abs(e.y-t.y)<.01){if(e.y>=h&&e.y<=m&&s<f&&a>u)return false}}return true}function ci(e,t,n,i){for(let r=1;r<e.length;r++){if(!V3(e[r-1],e[r],t,n,1,i))return false}return true}function cI(e,t,n,i){if(e.points.length===0)return;const r=_t(t);const o=n?e.points.length-1:0;const s=n?-1:1;const a=e.points[o][r.cross];let l=Infinity;let c=-Infinity;for(let d=o;d>=0&&d<e.points.length;d+=s){if(Math.abs(e.points[d][r.cross]-a)>.5)break;l=Math.min(l,e.points[d][r.main]);c=Math.max(c,e.points[d][r.main]);e.points[d][r.cross]+=i}if(e.labelPosition&&Math.abs(e.labelPosition[r.cross]-a)<=12&&e.labelPosition[r.main]>=l-.5&&e.labelPosition[r.main]<=c+.5){e.labelPosition[r.cross]+=i}}function ah(e,t,n,i,r){const o=_t(i);for(const s of t){if(!e.has(s.id))continue;s[o.cross]+=r}for(const s of n){const a=e.has(s.source);const l=e.has(s.target);if(a&&l){for(const c of s.points)c[o.cross]+=r;if(s.labelPosition)s.labelPosition[o.cross]+=r}else if(l){cI(s,i,true,r)}else if(a){cI(s,i,false,r)}}}function lh(e,t,n,i,r,o){const s=_t(i);const a=t.filter(c=>e.has(c.id));const l=new Map(a.map(c=>[c.id,{x:s.isHorizontal?c.x:c.x+r,y:s.isHorizontal?c.y+r:c.y,width:c.width,height:c.height}]));for(const c of l.values()){if(c.x<0||c.y<0)return false}for(let c=0;c<a.length;c++){const d=l.get(a[c].id);for(let u=c+1;u<a.length;u++){if(Li(d,l.get(a[u].id),8))return false}for(const u of t){if(e.has(u.id))continue;if(Li(d,u,8))return false}}for(const c of a){const d=l.get(c.id);for(const u of n){if(e.has(u.source)||e.has(u.target))continue;for(let h=1;h<u.points.length;h++){const m=u.points[h-1],p=u.points[h];if(Math.max(m.x,p.x)>d.x+.5&&Math.min(m.x,p.x)<d.x+d.width-.5&&Math.max(m.y,p.y)>d.y+.5&&Math.min(m.y,p.y)<d.y+d.height-.5)return false}const f=Pt(u,o);if(f&&Li(d,{x:f.x,y:f.y,width:f.w,height:f.h},8))return false}}return true}function cc(e,t,n,i={}){const r=new Map(e.map(s=>[s.id,s]));const o=_t(n.direction);for(const s of t){if(s.source===s.target||s.points.length<2)continue;const a=r.get(s.source),l=r.get(s.target);if(!a||!l)continue;const c=!Ai(a,s.points[0]);const d=!Ai(l,s.points[s.points.length-1]);if(!c&&!d)continue;const u=Ft(a)[o.sourceSide];const f=Ft(l)[o.targetSide];const h=lc(u[o.main],f[o.main],Yi(i,s,"start"),Yi(i,s,"end"));const m=Vs(u,f,n.direction,h);if(!ci(m,e,new Set([s.source,s.target])))continue;const p=s.routeCertificate;s.points=m;Os(s,p,a,l);if(s.label)s.labelPosition=sn(m)}}function Lo(e,t,n,i,r=[]){const o=_t(n.direction);i?.(e.length);const s=new Map(e.map(p=>[p.id,p]));const a=10;const l=(p,g)=>{for(const y of e){i?.(1);if(g.has(y.id))continue;for(let b=1;b<p.length;b++){i?.(1);if(Ii(p[b-1],p[b],y))return true}}return false};const c=p=>{const g=y=>{i?.(1);const b=y.concurrencyRegion?0:y.headerHeight;if(y.width!==0&&(b===void 0||!Number.isFinite(b)||b<0))return false;if(b!==void 0&&b>0&&y.width>0)for(let S=1;S<p.length;S++){i?.(1);const x=p[S-1],k=p[S];if(Math.max(x.x,k.x)>y.x&&Math.min(x.x,k.x)<y.x+y.width&&Math.max(x.y,k.y)>y.y&&Math.min(x.y,k.y)<y.y+b)return false}for(const S of y.children)if(!g(S))return false;return true};for(const y of r)if(!g(y))return false;return true};const d=(p,g)=>{for(let y=1;y<=p.length-3;y++){const b=p[y],S=p[y+1],x=p[y-1],k=p[y+2];const w=Math.abs(b.x-S.x)<.5,C=Math.abs(b.y-S.y)<.5;if(w===C)continue;if(!l([b,S],g))continue;const R=w?"x":"y";const M=w?"y":"x";if(Math.abs(x[M]-b[M])>.5||Math.abs(k[M]-S[M])>.5)continue;const P=b[R];const E=[];for(const v of e){i?.(1);if(g.has(v.id))continue;E.push(v[R]-a,v[R]+(R==="x"?v.width:v.height)+a)}E.sort((v,L)=>Math.abs(v-P)-Math.abs(L-P));for(const v of E){const L=p.map(T=>({...T}));L[y][R]=v;L[y+1][R]=v;if(!l(L,g)&&ci(L,e,g,i)&&c(L))return xt(L)}}return null};const u=(p,g)=>{const y=p[0],b=p[p.length-1];const S=Math.min(y[o.main],b[o.main]),x=Math.max(y[o.main],b[o.main]);let k=Infinity,w=-Infinity;const C=[];for(const A of e){i?.(1);if(g.has(A.id))continue;const $=A[o.main],_=A[o.main]+(o.main==="x"?A.width:A.height);if(_<=S||$>=x)continue;const z=rr(A,n.direction),F=z+Eo(A,n.direction);k=Math.min(k,z);w=Math.max(w,F);C.push(z-a,F+a)}if(!Number.isFinite(k))return null;C.push(k-a,w+a);const R=(A,$)=>o.main==="x"?{x:A,y:$}:{x:$,y:A};const M=Math.sign(b[o.main]-y[o.main])||1;const P=Math.min(12,Math.abs(b[o.main]-y[o.main])/3);const E=y[o.main]+M*P,v=b[o.main]-M*P;const L=(y[o.cross]+b[o.cross])/2;const T=[...new Set(C)].sort((A,$)=>Math.abs(A-L)-Math.abs($-L));for(const A of T){const $=xt([y,R(E,y[o.cross]),R(E,A),R(v,A),R(v,b[o.cross]),b]);if(!l($,g)&&ci($,e,g,i)&&c($))return $}return null};const f=p=>{for(let g=1;g<p.length;g++){i?.(1);const y=p[g-1],b=p[g];if(!Number.isFinite(y.x)||!Number.isFinite(y.y)||!Number.isFinite(b.x)||!Number.isFinite(b.y)||y.x!==b.x&&y.y!==b.y||y.x===b.x&&y.y===b.y)return false;const S=y.x===b.x;for(let x=1;x<g;x++){i?.(1);const k=p[x-1],w=p[x],C=k.x===w.x;if(S===C){const R=S?"y":"x",M=S?"x":"y";if(y[M]!==k[M])continue;const P=Math.max(Math.min(y[R],b[R]),Math.min(k[R],w[R]));const E=Math.min(Math.max(y[R],b[R]),Math.max(k[R],w[R]));if(x===g-1?P<E:P<=E)return false}else if(x!==g-1){const R=S?y.x:k.x,M=S?k.y:y.y;if(R>=Math.min(y.x,b.x)&&R<=Math.max(y.x,b.x)&&M>=Math.min(y.y,b.y)&&M<=Math.max(y.y,b.y)&&R>=Math.min(k.x,w.x)&&R<=Math.max(k.x,w.x)&&M>=Math.min(k.y,w.y)&&M<=Math.max(k.y,w.y))return false}}}return true};i?.(1);const h=new Set;const m=(p,g)=>{if(p.length<3)return null;const y=p.at(-1),b=p.at(-2),S=p.at(-3);const x=b.y===y.y&&b.x!==y.x?"x":b.x===y.x&&b.y!==y.y?"y":void 0;if(!x)return null;const k=x==="x"?"y":"x";if(S[x]!==b[x]||S[k]===b[k]||!l([b,y],g))return null;const w=[];for(const R of e){i?.(1);if(g.has(R.id)||!Ii(b,y,R))continue;i?.(2);w.push(R[k]-a,R[k]+(k==="x"?R.width:R.height)+a)}w.sort((R,M)=>{i?.(1);return Math.abs(R-b[k])-Math.abs(M-b[k])});const C=y[x]+Math.sign(b[x]-y[x])*Math.min(a,Math.abs(b[x]-y[x])/2);for(const R of w){i?.(2*p.length+12);const M={...b,[k]:R},P={...y,[x]:C,[k]:R},E={...y,[x]:C};const v=xt([...p.slice(0,-2),M,P,E,y]);const L=(T,A,$)=>A.x===T.x&&$.x===T.x&&Math.sign(A.y-T.y)===Math.sign($.y-T.y)||A.y===T.y&&$.y===T.y&&Math.sign(A.x-T.x)===Math.sign($.x-T.x);if(!L(p[0],p[1],v[1])||!L(y,b,v.at(-2)))continue;if(!l(v,h)&&ci(v,e,g,i)&&c(v)&&f(v))return v}return null};for(const p of t){i?.(1);if(p.source===p.target||p.points.length<2)continue;const g=s.get(p.source),y=s.get(p.target);if(!g||!y)continue;const b=new Set([p.source,p.target]);if(!l(p.points,b))continue;if(!Ai(g,p.points[0])||!Ai(y,p.points[p.points.length-1]))continue;let S=d(p.points,b)??u(p.points,b)??m(p.points,b);if(!S){i?.(p.points.length);S=m(p.points.toReversed(),b)?.reverse()??null}if(!S)continue;const x=p.routeCertificate;p.points=S;Os(p,x,g,y);if(p.label)p.labelPosition=sn(S)}}function Y0(e,t,n){const i=new Map(e.map(r=>[r.id,r]));for(const r of t){if(!n.has(r)||r.label||r.points.length!==4)continue;const o=zl(r);const[s,a,l,c]=r.points;if(!s||!a||!l||!c)continue;const d=i.get(r.target);if(!d||d.shape!=="rectangle")continue;const u=new Set([r.source,r.target]);if(Math.abs(s.y-a.y)<.01&&Math.abs(a.x-l.x)<.01&&Math.abs(l.y-c.y)<.01&&Math.abs(a.y-l.y)<=6){const f={x:c.x,y:s.y};const h=Math.abs(c.x-d.x)<.01||Math.abs(c.x-(d.x+d.width))<.01;if(h&&f.y>=d.y-.5&&f.y<=d.y+d.height+.5&&ci([s,f],e,u)){r.points=[s,f];r.routeCertificate=void 0;La(r,o)}continue}if(Math.abs(s.x-a.x)<.01&&Math.abs(a.y-l.y)<.01&&Math.abs(l.x-c.x)<.01&&Math.abs(a.x-l.x)<=6){const f={x:s.x,y:c.y};const h=Math.abs(c.y-d.y)<.01||Math.abs(c.y-(d.y+d.height))<.01;if(h&&f.x>=d.x-.5&&f.x<=d.x+d.width+.5&&ci([s,f],e,u)){r.points=[s,f];r.routeCertificate=void 0;La(r,o)}}}}function Mr(e,t,n){const i=st(n,"relationship",{category:e.identifying?"identifying":"non-identifying"},{includeFallback:false});return _e(qe(e.label,e.labelContent),{transform:i?.textTransform??t.edgeTextTransform,fontSize:i?.fontSize??t.edgeLabelFontSize,fontWeight:i?.fontWeight??t.edgeLabelFontWeight,letterSpacing:i?.letterSpacing??t.edgeLetterSpacing})}function sy(e,t,n,i){const r=[];const o=q0(e,t,n,i??{operations:0},true,r);for(const s of e.relationships){const a=o.get(s);if(a)s.finalLabelPosition={...a};else delete s.finalLabelPosition}return r}function hI(e,t,n,i,r,o){const s=e.relationships[t];if(!s.label)return true;o.operations+=e.relationships.length+n.length*2+2;if(o.operations>4e5)throw new es;const a={...s,points:n};const l=Math.max(e.width,...n.map(f=>f.x+40)),c=Math.max(e.height,...n.map(f=>f.y+40));const d={...e,width:l,height:c,relationships:e.relationships.map((f,h)=>h===t?a:f)};const u=[];q0(d,i,r,o,true,u);return!u.includes(a)}function qa(e){const t=new Map;for(const n of e.relationships){if(!n.label||n.points.length<2)continue;const i=n.finalLabelPosition;if(!i||!Number.isFinite(i.x)||!Number.isFinite(i.y))return void 0;t.set(n,i)}return t}function Ks(e,t,n,i={operations:0}){return q0(e,t,n,i,e.labelPlacement==="shaft-aware")}function q0(e,t,n,i,r,o){const s=new Map;const a=(h=1)=>{i.operations+=h;if(i.operations>4e5)throw new es};if(!e.relationships.some(h=>h.label&&h.points.length>1))return s;const l=(h,m)=>Math.min(h.x1,m.x1)-Math.max(h.x0,m.x0)>.5&&Math.min(h.y1,m.y1)-Math.max(h.y0,m.y0)>.5;const c=[...e.entities.map(h=>{const m=Number.parseFloat(h.inlineStyle?.["stroke-width"]??"");const p=(Number.isFinite(m)&&m>0?m:t.nodeLineWidth)/2;return{x0:h.x-p,y0:h.y-p,x1:h.x+h.width+p,y1:h.y+h.height+p}}),...e.groups.flatMap(h=>[{x0:h.x,y0:h.y,x1:h.x+h.width,y1:h.y+h.headerHeight},{x0:h.x-.75,y0:h.y-.75,x1:h.x+.75,y1:h.y+h.height+.75},{x0:h.x+h.width-.75,y0:h.y-.75,x1:h.x+h.width+.75,y1:h.y+h.height+.75},{x0:h.x-.75,y0:h.y-.75,x1:h.x+h.width+.75,y1:h.y+.75},{x0:h.x-.75,y0:h.y+h.height-.75,x1:h.x+h.width+.75,y1:h.y+h.height+.75}])];const d=e.relationships.flatMap(h=>{if(h.points.length===0)return[];const m=[h.points[0],h.points[h.points.length-1]];const p=m.map(y=>({x0:y.x-18,y0:y.y-18,x1:y.x+18,y1:y.y+18}));if(h.points.length<2)return p;const g=[To(m[0],h.points[1],h.cardinality1,t.lineWidth),To(m[1],h.points.at(-2),h.cardinality2,t.lineWidth)];a(2);return[...p,...g.flatMap(y=>y??[])]});const u=[];a(c.length+d.length);const f=r?e.relationships.flatMap(h=>{if(h.points.length<2)return[];const m=st(n,"relationship",{category:h.identifying?"identifying":"non-identifying"},{includeFallback:false});const p=m?.bendRadius??t.edgeBendRadius,g=m?.lineWidth??t.lineWidth;if(g<=0)return[];const y=p>0&&h.points.length>2;const b=Math.max(.5,g/2)+(y?.5:0);if(y){a(h.points.length);const S=qn(h.points,p,{metric:"manhattan"}).geometry;const x=[];if(!ps(S.d,k=>{a();x.push({owner:h,box:{x0:k.bounds.x0-b,y0:k.bounds.y0-b,x1:k.bounds.x1+b,y1:k.bounds.y1+b}});return true},()=>{a();return true}))throw new es;return x}return h.points.slice(1).map((S,x)=>{a();const k=h.points[x];return{owner:h,box:{x0:Math.min(k.x,S.x)-b,y0:Math.min(k.y,S.y)-b,x1:Math.max(k.x,S.x)+b,y1:Math.max(k.y,S.y)+b}}})}):[];for(const h of e.relationships){if(!h.label||h.points.length<2)continue;const m=h.labelBlock??Mr(h,t,n);const p=m.width+16,g=m.height+16;const y=(L,T)=>({x0:L-p/2,y0:T-g/2,x1:L+p/2,y1:T+g/2});const b=[];for(const L of f){a();if(L.owner!==h)b.push(L.box)}const S=L=>{a();return L.x0<0||L.y0<0||L.x1>e.width||L.y1>e.height||u.some(T=>{a();return l(L,T)})||c.some(T=>{a();return l(L,T)})||d.some(T=>{a();return l(L,T)})||b.some(T=>{a();return l(L,T)})};const x=h.points;const k=[];let w=0;for(let L=1;L<x.length;L++){a();const T=Math.hypot(x[L].x-x[L-1].x,x[L].y-x[L-1].y);k.push(T);w+=T}const C=L=>{let T=L;for(let A=0;A<k.length;A++){a();if(T<=k[A]||A===k.length-1){const $=k[A]===0?0:Math.max(0,Math.min(1,T/k[A]));return{x:x[A].x+(x[A+1].x-x[A].x)*$,y:x[A].y+(x[A+1].y-x[A].y)*$}}T-=k[A]}return x[x.length-1]};a(x.length*2);const R=X0(x);let M={x:R.x,y:R.y};let P=y(R.x,R.y);const E=r?h.labelPosition:void 0;if(E&&Number.isFinite(E.x)&&Number.isFinite(E.y)&&x.slice(1).some((L,T)=>{a();const A=x[T],$=L.x-A.x,_=L.y-A.y,z=$*$+_*_;const F=z?Math.max(0,Math.min(1,((E.x-A.x)*$+(E.y-A.y)*_)/z)):0;return Math.hypot(E.x-A.x-F*$,E.y-A.y-F*_)<=.001})&&!S(y(E.x,E.y))){M={...E};P=y(M.x,M.y)}let v=S(P);if(v){for(const L of[.4,.6,.3,.7,.25,.75,.2,.8,.15,.85]){const T=C(w*L);const A=y(T.x,T.y);if(!S(A)){M=T;P=A;v=false;break}}}if(v){a(c.length+d.length+u.length+b.length);const L=[...c,...d,...u,...b];let T,A=0;for(let $=1;$<x.length;$++){a();const _=x[$-1],z=x[$],F=k[$-1];const G=_.x===z.x,I=_.y===z.y;if(F===0||!G&&!I){A+=F;continue}const D=G?_.x:_.y,B=(G?p:g)/2,Y=(G?g:p)/2;const W=G?e.width:e.height,O=G?e.height:e.width;if(D-B<0||D+B>W){A+=F;continue}const N=Math.max(Math.min(G?_.y:_.x,G?z.y:z.x),Y);const H=Math.min(Math.max(G?_.y:_.x,G?z.y:z.x),O-Y);if(N>=H){A+=F;continue}const j=[];for(const U of L){a();const te=G?U.x0:U.y0,J=G?U.x1:U.y1;if(Math.min(D+B,J)-Math.max(D-B,te)<=.5)continue;j.push([(G?U.y0:U.x0)-Y+.5,(G?U.y1:U.x1)+Y-.5])}j.sort((U,te)=>{a();return U[0]-te[0]||U[1]-te[1]});const q=G?_.y:_.x,X=Math.sign((G?z.y:z.x)-q);const V=q+X*(w/2-A);const ee=(U,te)=>{a();const J=Math.max(1e-6,Number.EPSILON*Math.max(1,Math.abs(U),Math.abs(te))*8);if(te-U<=J*2)return;const ae=Math.max(U+J,Math.min(te-J,V));const Q=Math.abs(A+Math.abs(ae-q)-w/2);if(!T||Q<T.distance)T={point:G?{x:D,y:ae}:{x:ae,y:D},distance:Q}};let re=N;for(const[U,te]of j){a();if(te<=re)continue;if(U>H)break;if(U>re)ee(re,Math.min(H,U));re=Math.max(re,te);if(re>=H)break}if(re<H)ee(re,H);A+=F}if(T&&!S(y(T.point.x,T.point.y))){M=T.point;P=y(M.x,M.y);v=false}}if(v&&o){a();o.push(h)}u.push(P);s.set(h,M)}return s}function X0(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let r=1;r<e.length;r++){const o=e[r].x-e[r-1].x;const s=e[r].y-e[r-1].y;t+=Math.sqrt(o*o+s*s)}if(t===0)return e[0];const n=t/2;let i=0;for(let r=1;r<e.length;r++){const o=e[r].x-e[r-1].x;const s=e[r].y-e[r-1].y;const a=Math.sqrt(o*o+s*s);if(i+a>=n){const l=a>0?(n-i)/a:0;return{x:e[r-1].x+o*l,y:e[r-1].y+s*l}}i+=a}return e[e.length-1]}var Ct={padding:40,boxPadX:14,headerHeight:34,rowHeight:22,minWidth:140,attrFontSize:11,attrFontWeight:400,nodeSpacing:70,layerSpacing:90};var Bd={nodeLabelFontSize:er.nodeLabel,edgeLabelFontSize:er.edgeLabel,groupHeaderFontSize:er.groupHeader,nodeLabelFontWeight:700,edgeLabelFontWeight:Lr.edgeLabel,groupHeaderFontWeight:Lr.groupHeader,nodePaddingX:Ct.boxPadX,nodePaddingY:8,nodeCornerRadius:0,nodeLineWidth:et.outerBox,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:Ct.boxPadX,groupPaddingY:8,groupLineWidth:et.outerBox};function yI(e,t){if(!t)return e;const n=kt(t,["er","layoutDirection"]);const i=typeof n==="string"&&/^(TB|TD|BT|LR|RL)$/i.test(n)?n.toUpperCase():void 0;return e.direction===void 0&&i!==void 0?{...e,direction:i}:e}function xI(e,t){if(!e)return t;const n=Dd(e,"er","nodeSpacing");const i=Dd(e,"er","rankSpacing");return n===void 0&&i===void 0?t:{...t,nodeSpacing:t.nodeSpacing??n,layerSpacing:t.layerSpacing??i}}function dy(e,t){return _e(e,{transform:t.nodeTextTransform,fontSize:t.nodeLabelFontSize,fontWeight:t.nodeLabelFontWeight,letterSpacing:t.nodeLetterSpacing})}function Wd(e,t){return _e(e,{transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing})}function ch(e){const t={display:"literal",fontSize:Ct.attrFontSize,fontWeight:Ct.attrFontWeight,monospace:true};return{type:_e(e.type,t),name:_e(e.name,t),keys:_e(e.keys.join(","),{display:"literal",fontSize:9,fontWeight:600}),...e.comment?{comment:_e(sh(e.comment,e.commentContent),{display:"literal",fontSize:Ct.attrFontSize,fontWeight:400})}:{}}}function uy(){return _e("<i>(no attributes)</i>",{fontSize:Ct.attrFontSize,fontWeight:Ct.attrFontWeight})}function mI(e,t,n){for(const i of e.entities){i.labelBlock=dy(qe(i.label,i.labelContent),t);i.attributeBlocks=i.attributes.map(ch);if(i.attributes.length===0)i.emptyAttributeBlock=uy()}for(const i of e.groups)i.labelBlock??=Wd(qe(i.label,i.labelContent),t);for(const i of e.relationships)i.labelBlock??=Mr(i,t,n);return e}function bI(e,t){const n=new Map(e.groups.map(c=>[c.id,c.parentId]));const i=new Map([...e.entities.map(c=>[c.id,c.groupId]),...n]);const r=(c,d)=>{for(let u=i.get(d),f=0;u!==void 0&&n.has(u)&&f<Hc.nesting;u=n.get(u),f++)if(u===c)return true;return false};const o=new Map,s=new Map,a=new Map;for(const[c,d]of e.relationships.entries()){const u=r(d.entity1,d.entity2)?d.entity1:r(d.entity2,d.entity1)?d.entity2:void 0;if(!u)continue;o.set(u,(o.get(u)??0)+t[c].height+56);const f=u===d.entity1?d.entity2:d.entity1;s.set(f,Math.max(s.get(f)??0,t[c].height+40));const h=a.get(u)??[];h.push(c);a.set(u,h)}const l=new Map;for(const c of a.values())c.forEach((d,u)=>l.set(d,(u+1)/(c.length+1)));return{padding:o,exits:s,lanes:l}}function SI(e,t,n){const i=Math.max(e.x,t.x)+(Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*n;return[{x:i,y:e.y+e.height},{x:i,y:t.y+t.height}]}function wI(e,t){return e.flatMap((n,i)=>{if(!n.label||n.points.length<2)return[];const r=n.labelPosition??sn(n.points),o=t[i];return[{x0:r.x-o.width/2-8,x1:r.x+o.width/2+8,y0:r.y-o.height/2-8,y1:r.y+o.height/2+8}]})}function Jt(e,t=1){e.operations+=t;if(e.operations>4e5)throw new Fd}function ay(e,t){for(let n=1;n<e.length;n++){const i=e[n-1],r=e[n],o=i.x===r.x;Jt(t);if(![i.x,i.y,r.x,r.y].every(Number.isFinite)||i.x!==r.x&&i.y!==r.y||i.x===r.x&&i.y===r.y)return false;for(let s=1;s<n;s++){Jt(t);const a=e[s-1],l=e[s],c=a.x===l.x;if(o===c){const d=o?"x":"y",u=o?"y":"x";if(i[d]!==a[d])continue;const f=Math.max(Math.min(i[u],r[u]),Math.min(a[u],l[u]));const h=Math.min(Math.max(i[u],r[u]),Math.max(a[u],l[u]));if(s===n-1?f<h:f<=h)return false}else if(s!==n-1){const d=o?i.x:a.x,u=o?a.y:i.y;if(d>=Math.min(i.x,r.x)&&d<=Math.max(i.x,r.x)&&u>=Math.min(i.y,r.y)&&u<=Math.max(i.y,r.y)&&d>=Math.min(a.x,l.x)&&d<=Math.max(a.x,l.x)&&u>=Math.min(a.y,l.y)&&u<=Math.max(a.y,l.y))return false}}}return true}function MI(e,t,n,i){const r=new Map([...e,...t].map(c=>[c.id,c]));const o=new Set(t.map(c=>c.id));const s=(c=1)=>Jt(i,c);const a=new Map([...e.map(c=>[c.id,c.groupId]),...t.map(c=>[c.id,c.parentId])]);const l=(c,d)=>{for(let u=a.get(d),f=0;u!==void 0&&f<Hc.nesting;u=a.get(u),f++){s();if(u===c)return true}return false};for(const c of n)for(const d of[false,true]){const u=d?c.entity2:c.entity1,f=d?c.entity1:c.entity2,h=r.get(u);const m=d?c.points.at(-1):c.points[0];if(!h||!m)continue;const p=(d?[...c.points].reverse():c.points).find(g=>g.x!==m.x||g.y!==m.y);s(c.points.length);if(!p)continue;if(o.has(u)&&l(u,f)){if(p.x!==m.x)throw new Nt(c.entity1,c.entity2);m.y=h.y+h.height}else{const g=p.y===m.y&&p.x!==m.x||(m.x===h.x||m.x===h.x+h.width)&&p.x!==m.x;const y=p.x===m.x&&p.y!==m.y||(m.y===h.y||m.y===h.y+h.height)&&p.y!==m.y;if(g){m.x=p.x>m.x?h.x+h.width:h.x;p.y=m.y}else if(y){m.y=p.y>m.y?h.y+h.height:h.y;p.x=m.x}}}}function ly(e,t,n,i,r,o,s={operations:0},a){MI(e,t,n,s);const l=r.lineWidth;const c=gi([...e.map(p=>p.id),...t.map(p=>p.id)]);const d=new Set(t.map(p=>p.id)),u=new Map,f=new Map;const h=[...e.map(p=>{const g=c(`er-entity:${p.id}`,["er","entity",p.id]);u.set(g,p.id);const y=Number.parseFloat(p.inlineStyle?.["stroke-width"]??"");const b=(Number.isFinite(y)&&y>0?y:r.nodeLineWidth)/2;return{...p,id:g,x:p.x-b,y:p.y-b,width:p.width+2*b,height:p.height+2*b,shape:"rectangle"}}),...t.map(p=>{const g=c(`er-header:${p.id}`,["er","header",p.id]);f.set(g,p.id);return{...p,id:g,height:p.headerHeight,shape:"rectangle"}})];const m=p=>Jt(s,p);for(const[p,g]of n.entries()){if(a&&!a.indices.has(p))continue;if(g.points.length<2)continue;const[y,b]=[g.points[0],g.points.at(-1)];const S=st(o,"relationship",{category:g.identifying?"identifying":"non-identifying"},{includeFallback:false});const x=(S?.bendRadius??r.edgeBendRadius)+2*(S?.lineWidth??r.lineWidth);const k=h.filter(W=>{const O=u.get(W.id);return O===void 0||d.has(O)||O!==g.entity1&&O!==g.entity2}).map(W=>x&&f.get(W.id)!==g.entity1&&f.get(W.id)!==g.entity2?{...W,x:W.x-x,y:W.y-x,width:W.width+2*x,height:W.height+2*x}:W);const w=W=>W.slice(1).some((O,N)=>k.some(H=>{m(1);return Ii(W[N],O,H)}));const C=(W,O,N)=>{const H=To(W,O,N,l);m(2+(H?.length??0));if(!H?.length)return false;const j=W.y===O.y,q=Math.sign(j?O.x-W.x:O.y-W.y);const X=Math.max(...H.map(J=>q>0?j?J.x1-W.x:J.y1-W.y:j?W.x-J.x0:W.y-J.y0));const V=Math.abs(j?O.x-W.x:O.y-W.y),ee=S?.bendRadius??r.edgeBendRadius;const re=W===y?g.points[2]:g.points.at(-3);const U=re?Math.abs(re.x-O.x)+Math.abs(re.y-O.y):V;const te=V-(g.points.length>2?Math.min(ee,V/2,U/2):0);return te>=X};if(!w(g.points)&&ay(g.points,s)&&C(y,g.points[1],g.cardinality1)&&C(b,g.points.at(-2),g.cardinality2)&&(!a||a.admit(p,g.points)))continue;delete g.labelPosition;const R=g.points.find(W=>W.x!==y.x||W.y!==y.y),M=[...g.points].reverse().find(W=>W.x!==b.x||W.y!==b.y);const P=[];const E=1;const v=l+.25;const L=(W,O,N,H)=>{const j={x:Math.sign(O.x-W.x),y:Math.sign(O.y-W.y)};const q=To(W,O,H,l);m(2+(q?.length??0));if(!q?.length)throw new Nt(g.entity1,g.entity2);const X=Math.max(0,...q.map(K=>j.x>0?K.x1-W.x:j.x<0?W.x-K.x0:j.y>0?K.y1-W.y:W.y-K.y0));const V=X+(S?.bendRadius??r.edgeBendRadius)+v;const ee=i[p],re=(j.x?ee.width:ee.height)/2+8;const U=g.entity1===g.entity2&&g.label?X+re+E+v+r.nodeLineWidth/2:0;const te=Math.max(V+E+v,U);let J=Math.max(20,te);for(const K of k){m(1);if(!(j.x?W.y>K.y&&W.y<K.y+K.height:W.x>K.x&&W.x<K.x+K.width))continue;const Z=j.x>0?K.x-W.x:j.x<0?W.x-K.x-K.width:j.y>0?K.y-W.y:W.y-K.y-K.height;if(Z>=0)J=Math.min(J,Z-E-v)}if(J<te)throw new Nt(g.entity1,g.entity2);const ae=Math.max(0,...q.map(K=>j.x?Math.max(W.y-K.y0,K.y1-W.y):Math.max(W.x-K.x0,K.x1-W.x)));const Q={x:W.x+j.x*V,y:W.y+j.y*V};m(q.length+2);P.push({id:c(`er-terminal:${p}:${P.length}`,["er","terminal",p,P.length]),label:"",shape:"rectangle",x:j.x?Math.min(W.x,Q.x):W.x-ae,y:j.y?Math.min(W.y,Q.y):W.y-ae,width:j.x?V:ae*2,height:j.y?V:ae*2});return{id:N,label:"",shape:"rectangle",x:W.x+j.x*J,y:W.y+j.y*J,width:0,height:0}};const T=L(y,R,g.entity1,g.cardinality1),A=L(b,M,g.entity2,g.cardinality2);const $=W=>w(W)||W.slice(1).some((O,N)=>P.some(H=>{m(1);return Ii(W[N],O,H)}));const _=i[p],z=_.width/2+8,F=_.height/2+8;const G=k.map(W=>({...W,x:W.x-z,y:W.y-F,width:W.width+z*2,height:W.height+F*2}));const I=[G];m(k.length);const D={source:T.id,target:A.id,style:"solid",hasArrowStart:false,hasArrowEnd:false,points:[{x:T.x,y:T.y},...g.points.slice(1,-1),{x:A.x,y:A.y}]};const B=Math.abs(b.x-y.x)>=Math.abs(b.y-y.y)?b.x>=y.x?"LR":"RL":b.y>=y.y?"TB":"BT";Lo([...G,...P,T,A],[D],{direction:B},m);if($(D.points)){m(k.length);const W=k.map(O=>B==="TB"||B==="BT"?{...O,x:O.x-z,width:O.width+z*2}:{...O,y:O.y-F,height:O.height+F*2});I.push(W);Lo([...W,...P,T,A],[D],{direction:B},m)}if($(D.points)){const W=B==="LR"||B==="RL"?b.y>=y.y?"TB":"BT":b.x>=y.x?"LR":"RL";m(k.length);const O=k.map(N=>W==="TB"||W==="BT"?{...N,x:N.x-z,width:N.width+z*2}:{...N,y:N.y-F,height:N.height+F*2});I.push(O);Lo([...O,...P,T,A],[D],{direction:W},m)}const Y=W=>{if($(W))return false;const O=xt([y,...W,b]);return ay(O,s)&&(!a||a.admit(p,O))};if(!Y(D.points)){let W;for(const O of[...I,k]){const N=[T.x,A.x],H=[T.y,A.y];for(const q of[...O,...P]){m(4);N.push(q.x-v,q.x+q.width+v);H.push(q.y-v,q.y+q.height+v)}N.sort((q,X)=>{m(1);return Math.abs(q-(T.x+A.x)/2)-Math.abs(X-(T.x+A.x)/2)||q-X});H.sort((q,X)=>{m(1);return Math.abs(q-(T.y+A.y)/2)-Math.abs(X-(T.y+A.y)/2)||q-X});m((N.length+H.length+2)*4);const j=[[T,{x:A.x,y:T.y},A],[T,{x:T.x,y:A.y},A],...N.map(q=>[T,{x:q,y:T.y},{x:q,y:A.y},A]),...H.map(q=>[T,{x:T.x,y:q},{x:A.x,y:q},A])];for(const q of j){const X=xt(q);const V=X.slice(1).some((ee,re)=>O.some(U=>{m(1);return Ii(X[re],ee,U)}));if(!V&&Y(X)){W=X;break}}if(W)break}if(!W)throw new Nt(g.entity1,g.entity2);D.points=W}g.points=xt([y,...D.points,b]);if(w(g.points))throw new Nt(g.entity1,g.entity2)}}var kI=12;function V0(e){const t=e.map(i=>i.comment?ch(i).comment.width:0);const n=Math.max(0,...t);return n>0?n+kI:0}function K3(e,t){const n=new Map;for(const i of e.entities){const r=dy(qe(i.label,i.labelContent),t);const o=r.width;let s=i.attributes.length===0?uy().width:0;const a=V0(i.attributes);for(const u of i.attributes){const f=ch(u);const h=u.keys.length?f.keys.width+14:0;const m=f.type.width+f.name.width+h+kI+a;if(m>s)s=m}const l=Math.max(Ct.minWidth,o+t.nodePaddingX*2,s+Math.max(8,t.nodePaddingX)*2);const c=Math.max(Ct.headerHeight,r.height+t.nodePaddingY*2);const d=c+Math.max(i.attributes.length,1)*Ct.rowHeight;n.set(i.id,{width:l,height:d,headerHeight:c})}return n}function J3(e,t,n,i,r={operations:0}){const o=Xe(t,Bd,i);let s=0;const a=new Map;for(const d of e.relationships){const u=st(i,"relationship",{category:d.identifying?"identifying":"non-identifying"},{includeFallback:false});for(const[f,h]of[[d.entity1,d.cardinality1],[d.entity2,d.cardinality2]]){Jt(r,12);const m=Ga(h,o.lineWidth);if(!m)throw new Nt(d.entity1,d.entity2);s=Math.max(s,m.x1+(u?.bendRadius??o.edgeBendRadius)+(u?.lineWidth??o.lineWidth)/2);if(n.has(f))a.set(f,(a.get(f)??0)+m.y1-m.y0+o.lineWidth+.25)}}const l={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":ma(e.direction??"LR"),"elk.spacing.nodeNode":String(t.nodeSpacing??Ct.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing??Ct.layerSpacing),"elk.padding":`[top=${Ct.padding},left=${Ct.padding},bottom=${Ct.padding},right=${Ct.padding}]`,"elk.edgeRouting":"ORTHOGONAL",...s>10?{"elk.layered.spacing.edgeNodeBetweenLayers":String(s)}:{},"elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};for(const d of e.entities){const u=n.get(d.id),f=(a.get(d.id)??0)+2*Math.max(8,o.cornerRadius??0);Jt(r);l.children.push({id:d.id,width:Math.max(u.width,f),height:Math.max(u.height,f)})}const c=new Set(e.entities.map(d=>d.id));for(let d=0;d<e.relationships.length;d++){const u=e.relationships[d];if(!c.has(u.entity1)||!c.has(u.entity2))continue;const f={id:`e${d}`,sources:[u.entity1],targets:[u.entity2]};if(u.label){const h=Mr(u,o,i);const m=h.text;f.labels=[{text:m,width:h.width+8,height:h.height+6}]}l.edges.push(f)}return{elkGraph:l,entitySizes:n}}function Q3(e,t,n,i,r,o={operations:0}){const s=new Map;for(const M of t.entities)s.set(M.id,M);const a=[];const l=Lt(t.classDefs.get("default"),"classDef default");for(const M of e.entities){const P=s.get(M.id);if(P){const E={...l};for(const v of P.className?.split(/[ \t]+/)??[])Object.assign(E,Lt(t.classDefs.get(v),`classDef ${v}`));a.push({id:P.id,label:P.label,...P.labelContent?{labelContent:P.labelContent}:{},attributes:P.attributes,x:M.x??0,y:M.y??0,width:M.width??n.get(P.id).width,height:M.height??n.get(P.id).height,headerHeight:n.get(P.id).headerHeight,rowHeight:Ct.rowHeight,...P.className?{className:P.className}:{},...Object.keys(E).length>0||P.inlineStyle?{inlineStyle:{...E,...Lt(P.inlineStyle,`style ${P.id}`)}}:{},...P.groupId?{groupId:P.groupId}:{}})}}const c=new Map(a.map(M=>[M.id,{x:M.x,y:M.y,width:M.width,height:M.height}]));const d=t.relationships.map(M=>Mr(M,i,r));const u=bI(t,d);const f=CI(t,i,r,o);eX(t,a,d,i,r,o);const h=tX(t,a,i,u.padding,f);const m=e.preserveTerminalNormals?20+2*Math.max(i.edgeBendRadius,...t.relationships.map(M=>st(r,"relationship",{category:M.identifying?"identifying":"non-identifying"},{includeFallback:false})?.bendRadius??i.edgeBendRadius)):20;PI(t,a,h,i,d,u.padding,u.exits,m,r,o,f);const p=new Map;a.forEach(M=>p.set(M.id,M));h.forEach(M=>p.set(M.id,M));const g=e.routes;const y=[];for(let M=0;M<t.relationships.length;M++){const P=t.relationships[M];const E=p.get(P.entity1),v=p.get(P.entity2);const L=c.get(P.entity1),T=c.get(P.entity2);const A=E&&L?E.x-L.x:void 0;const $=E&&L?E.y-L.y:void 0;const _=A!==void 0&&$!==void 0&&v&&T&&Math.abs(v.x-T.x-A)<.001&&Math.abs(v.y-T.y-$)<.001&&E.width===L.width&&E.height===L.height&&v.width===T.width&&v.height===T.height?g.get(M):void 0;const z=[];let F;if(E&&v&&u.lanes.has(M)){z.push(...SI(E,v,u.lanes.get(M)))}else if(_?.length){z.push(..._.map(I=>({x:I.x+A,y:I.y+$})));const G=e.labelPositions?.get(M);if(G)F={x:G.x+A,y:G.y+$}}else{if(E&&v){z.push(...cy(E,v))}}y.push({entity1:P.entity1,entity2:P.entity2,cardinality1:P.cardinality1,cardinality2:P.cardinality2,label:P.label,...P.labelContent?{labelContent:P.labelContent}:{},labelBlock:d[M],identifying:P.identifying,points:z,...F?{labelPosition:F}:{}})}ly(a,h,y,d,i,r,o);const b=[...a.flatMap(M=>[M.x,M.x+M.width]),...h.flatMap(M=>[M.x,M.x+M.width]),...y.flatMap(M=>M.points.map(P=>P.x))];const S=[...a.flatMap(M=>[M.y,M.y+M.height]),...h.flatMap(M=>[M.y,M.y+M.height]),...y.flatMap(M=>M.points.map(P=>P.y))];const x=wI(y,d);const k=Math.max(0,b.length?Ct.padding-Math.min(...b):0,...x.map(M=>-M.x0));const w=Math.max(0,S.length?Ct.padding-Math.min(...S):0,...x.map(M=>-M.y0));if(k!==0||w!==0){for(const M of a){M.x+=k;M.y+=w}for(const M of h){M.x+=k;M.y+=w}for(const M of y){for(const P of M.points){P.x+=k;P.y+=w}if(M.labelPosition){M.labelPosition.x+=k;M.labelPosition.y+=w}}}const C=Math.max((e.width??600)+k,...a.map(M=>M.x+M.width+Ct.padding),...h.map(M=>M.x+M.width+Ct.padding),...y.flatMap(M=>M.points.map(P=>P.x+Ct.padding)),...x.map(M=>M.x1+k));const R=Math.max((e.height??400)+w,...a.map(M=>M.y+M.height+Ct.padding),...h.map(M=>M.y+M.height+Ct.padding),...y.flatMap(M=>M.points.map(P=>P.y+Ct.padding)),...x.map(M=>M.y1+w));return{width:C,height:R,accessibilityTitle:t.accessibilityTitle,accessibilityDescription:t.accessibilityDescription,entities:a,relationships:y,groups:h,...e.labelPlacement?{labelPlacement:e.labelPlacement}:{}}}function pI(e,t){const n={x:e.x+e.width/2,y:e.y+e.height/2};const i=t.x-n.x,r=t.y-n.y;if(Math.abs(i)*e.height>=Math.abs(r)*e.width){return{point:{x:i>=0?e.x+e.width:e.x,y:n.y+r/(Math.abs(i)||1)*e.width/2},horizontal:true}}return{point:{x:n.x+i/(Math.abs(r)||1)*e.height/2,y:r>=0?e.y+e.height:e.y},horizontal:false}}function cy(e,t){const n=pI(e,{x:t.x+t.width/2,y:t.y+t.height/2});const i=pI(t,{x:e.x+e.width/2,y:e.y+e.height/2});return Z3(n.point,i.point,n.horizontal,i.horizontal)}function Z3(e,t,n,i){const r=[e];if(e.x!==t.x&&e.y!==t.y){if(n!==i)r.push(n?{x:t.x,y:e.y}:{x:e.x,y:t.y});else if(n){const o=(e.x+t.x)/2;r.push({x:o,y:e.y},{x:o,y:t.y})}else{const o=(e.y+t.y)/2;r.push({x:e.x,y:o},{x:t.x,y:o})}}r.push(t);return r}function eX(e,t,n,i,r,o){const s=new Set;for(const a of e.groups){if(!a.direction)continue;const l=a.entityIds.map(g=>t.find(y=>y.id===g)).filter(g=>Boolean(g));if(l.length<2)continue;for(const g of l)s.add(g.id);const c=a.direction==="LR"||a.direction==="RL";const d=a.direction==="RL"||a.direction==="BT"?[...l].reverse():l;const u=new Set(l.map(g=>g.id));const f=Math.max(48,...e.relationships.flatMap((g,y)=>{Jt(o);if(!u.has(g.entity1)||!u.has(g.entity2))return[];const b=Ga(g.cardinality1,i.lineWidth),S=Ga(g.cardinality2,i.lineWidth);Jt(o,2);if(!b||!S)throw new Nt(g.entity1,g.entity2);const x=st(r,"relationship",{category:g.identifying?"identifying":"non-identifying"},{includeFallback:false})?.bendRadius??i.edgeBendRadius;const k=Math.max(18,b.x1)+Math.max(18,S.x1)+2*x+2*(i.lineWidth+.25);return[Math.max(g.label?n[y][c?"width":"height"]+56:0,k+(g.label?n[y][c?"width":"height"]+20:0))]}));const h=Math.min(...l.map(g=>g.x));const m=Math.min(...l.map(g=>g.y));let p=c?h:m;for(const g of d){if(c){g.x=p;g.y=m;p+=g.width+f}else{g.x=h;g.y=p;p+=g.height+f}}}return s}function CI(e,t,n,i){const r=new Map([...e.entities.map(s=>[s.id,s.groupId]),...e.groups.map(s=>[s.id,s.parentId])]);const o=new Map;Jt(i,r.size);for(const s of e.relationships){Jt(i);if(s.label){const l=Mr(s,t,n);const c=l.width+16+t.nodeLineWidth+1.5+2*(t.lineWidth+.25);for(const[d,u]of[[s.entity1,s.entity2],[s.entity2,s.entity1]]){for(let f=r.get(u),h=0;f!==void 0&&h<Hc.nesting;f=r.get(f),h++){Jt(i);if(f===d){o.set(f,Math.max(o.get(f)??20,c));break}}}}const a=st(n,"relationship",{category:s.identifying?"identifying":"non-identifying"},{includeFallback:false})?.bendRadius??t.edgeBendRadius;for(const[l,c]of[[s.entity1,s.cardinality1],[s.entity2,s.cardinality2]]){const d=r.get(l);if(!d)continue;const u=Ga(c,t.lineWidth);Jt(i);if(!u)throw new Nt(s.entity1,s.entity2);const f=st(n,"relationship",{category:s.identifying?"identifying":"non-identifying"},{includeFallback:false})?.lineWidth??t.lineWidth;const h=u.x1+2*a+2*f+3*(t.lineWidth+.25)+2+.75;o.set(d,Math.max(o.get(d)??20,h))}}return o}function tX(e,t,n,i,r){const o=[];for(const s of[...e.groups].reverse()){const a=[...t.filter(p=>p.groupId===s.id),...o.filter(p=>p.parentId===s.id)];const l=r.get(s.id)??20;const c=Wd(qe(s.label,s.labelContent),n);const d=n.groupHeaderFontSize+16+c.height-c.lineHeight;const u=a.length?Math.min(...a.map(p=>p.x))-l:Ct.padding;const f=a.length?Math.min(...a.map(p=>p.y))-l-d:Ct.padding;const h=Math.max(u+c.width+20,a.length?Math.max(...a.map(p=>p.x+p.width))+l:u+140);const m=a.length?Math.max(...a.map(p=>p.y+p.height))+Math.max(l,i.get(s.id)??0):f+90;o.unshift({id:s.id,label:s.label,...s.labelContent?{labelContent:s.labelContent}:{},labelBlock:c,...s.parentId?{parentId:s.parentId}:{},x:u,y:f,width:h-u,height:m-f,headerHeight:d})}return o}function PI(e,t,n,i,r,o,s,a=20,l,c={operations:0},d=new Map){if(n.length===0)return false;const u=new Map(n.map(w=>[w.id,w]));const f=new Map(e.groups.map(w=>[w.id,w]));const h=new Map;const m=new Map;for(const w of n){const C=w.parentId&&u.has(w.parentId)?w.parentId:void 0;const R=h.get(C)??[];R.push(w);h.set(C,R)}for(const w of t){const C=w.groupId&&u.has(w.groupId)?w.groupId:void 0;const R=m.get(C)??[];R.push(w);m.set(C,R)}const p=new Map([...t,...n].map(w=>[w.id,w]));const g=w=>{Jt(c);const C=e.relationships[w],R=p.get(C.entity1),M=p.get(C.entity2);const P=cy(R,M);const E=To(P[0],P[1],C.cardinality1,i.lineWidth);const v=To(P.at(-1),P.at(-2),C.cardinality2,i.lineWidth);if(!E?.length||!v?.length)return true;const L=(A,$)=>{Jt(c);return A.x0<$.x1&&A.x1>$.x0&&A.y0<$.y1&&A.y1>$.y0};if(E.some(A=>v.some($=>L(A,$))))return true;const T=(A,$)=>({x0:$.x,y0:$.y,x1:$.x+$.width,y1:$.y+(u.has(A)?$.headerHeight:$.height)});if(E.some(A=>L(A,T(C.entity2,M)))||v.some(A=>L(A,T(C.entity1,R))))return true;if(C.label){const A=R0(r[w],sn(P));if(!A||L(A,T(C.entity1,R))||L(A,T(C.entity2,M)))return true}return false};let y=false;const b=(w,C,R)=>{w.x+=C;w.y+=R;for(const M of m.get(w.id)??[]){M.x+=C;M.y+=R}for(const M of h.get(w.id)??[])b(M,C,R)};const S=w=>new Set([w.id,...(m.get(w.id)??[]).map(C=>C.id),...(h.get(w.id)??[]).flatMap(C=>[...S(C)])]);const x=(w,C)=>{const R=C==="LR"||C==="RL";const M=R?"y":"x";const P=R?"height":"width";const E=R?"x":"y";const v=O=>{const N=[];for(const H of e.relationships){Jt(c);if(!O.ids.has(H.entity1)&&!O.ids.has(H.entity2))continue;const j=p.get(H.entity1),q=p.get(H.entity2);if(!j||!q)continue;const X=cy(j,q);const V=st(l,"relationship",{category:H.identifying?"identifying":"non-identifying"},{includeFallback:false})?.bendRadius??i.edgeBendRadius;const ee=2*V+2*i.lineWidth+4*(i.lineWidth+.25)+2;for(const[re,U,te,J]of[[H.entity1,X[0],X[1],H.cardinality1],[H.entity2,X.at(-1),X.at(-2),H.cardinality2]]){if(!O.ids.has(re))continue;const ae=To(U,te,J,i.lineWidth);Jt(c,2+(ae?.length??0));if(!ae)throw new Nt(H.entity1,H.entity2);N.push(...ae.map(Q=>({...Q,overhead:ee})))}}return N};const L=O=>Math.max(0,...[...O.ids].map(N=>{Jt(c);if(u.has(N))return .75;const H=p.get(N);const j=Number.parseFloat(H?.inlineStyle?.["stroke-width"]??"");return(Number.isFinite(j)&&j>0?j:i.nodeLineWidth)/2}));const T=new Map;const A=new Map(w.map(O=>[O,Math.max(0,...[...O.ids].map(N=>s.get(N)??0))]));const $=new Map;for(const O of w)for(const N of O.ids)T.set(N,O);for(const[O,N]of e.relationships.entries()){Jt(c);const H=T.get(N.entity1),j=T.get(N.entity2);if(!H||!j||H===j)continue;const q=Ga(N.cardinality1,i.lineWidth),X=Ga(N.cardinality2,i.lineWidth);if(!q||!X)throw new Nt(N.entity1,N.entity2);const V=st(l,"relationship",{category:N.identifying?"identifying":"non-identifying"},{includeFallback:false})?.bendRadius??i.edgeBendRadius;const ee=J=>Math.max(0,J.x1,-J.x0,J.y1,-J.y0)+V;const re=ee(q)+ee(X)+2*(i.lineWidth+.25);const U=N.label?Math.max(r[O][R?"height":"width"]+56,r[O][R?"height":"width"]+20+re):re;const te=re+(N.label?r[O][R?"width":"height"]+20:0);for(const[J,ae]of[[H,j],[j,H]]){const Q=$.get(J)??new Map,K=Q.get(ae);Q.set(ae,{cross:Math.max(K?.cross??0,U),main:Math.max(K?.main??0,te),indices:[...K?.indices??[],O]});$.set(J,Q)}}const _=new Map(w.map(O=>[O,new Set]));for(const O of e.relationships){Jt(c);const N=T.get(O.entity1),H=T.get(O.entity2);if(N&&H&&N!==H)_.get(N).add(H)}const z=(O,N)=>{const H=[O],j=new Set;while(H.length){Jt(c);const q=H.pop();if(q===N)return true;if(j.has(q))continue;j.add(q);for(const X of _.get(q)){Jt(c);H.push(X)}}return false};const F=new Map(w.map(O=>[O,[]])),G=new Map(w.map(O=>[O,[]]));for(const[O,N]of _)for(const H of N){Jt(c);if(z(H,O))continue;F.get(H).push(O);G.get(O).push(H)}const I=new Map(w.map(O=>[O,F.get(O).length])),D=w.filter(O=>I.get(O)===0);const B=C==="BT"||C==="RL",Y=R?"width":"height";for(let O=0;O<D.length;O++){const N=D[O];let H=0;for(const j of F.get(N)){Jt(c);const q=Math.max(a,$.get(N)?.get(j)?.main??0);H=B?Math.min(H,j.box[E]-q-N.box[E]-N.box[Y]):Math.max(H,j.box[E]+j.box[Y]+q-N.box[E])}if(H!==0){N.move(R?H:0,R?0:H);y=true}for(const j of G.get(N)){Jt(c);I.set(j,I.get(j)-1);if(I.get(j)===0)D.push(j)}}w.sort((O,N)=>O.box[M]-N.box[M]||O.box[E]-N.box[E]);const W=[];for(const O of w){for(let N=0;N<W.length;N++){let H=0;for(const j of W){Jt(c);const q=$.get(O)?.get(j);const X=v(O),V=v(j);const ee=L(O),re=L(j);const U=(oe,de,xe)=>{Jt(c);return oe.x0<de.x+de.width+xe&&oe.x1>de.x-xe&&oe.y0<de.y+de.height+xe&&oe.y1>de.y-xe};const te=X.some(oe=>U(oe,j.box,re))||V.some(oe=>U(oe,O.box,ee));const J=(oe,de,xe,Me)=>Math.max(0,...oe.map(Ce=>{Jt(c);const pe=xe?(R?Ce.y1:Ce.x1)-de[M]-de[P]:de[M]-(R?Ce.y0:Ce.x0);return pe>0?pe+Ce.overhead+Me:0}));const ae=te?J(V,j.box,true,ee)+J(X,O.box,false,re):0;const Q=Math.max(q?.cross??0,A.get(O),A.get(j),ae);const K=R?"width":"height";const Z=Math.min(O.box[E]+O.box[K],j.box[E]+j.box[K])-Math.max(O.box[E],j.box[E]);const se=Math.min(O.box[M]+O.box[P],j.box[M]+j.box[P])-Math.max(O.box[M],j.box[M]);if((Z>.5||te||q&&Z>-q.main&&q.indices.some(g))&&se>-Math.max(Q,a>20?a:0)+.5){H=Math.max(H,j.box[M]+j.box[P]+Math.max(a,Q)-O.box[M])}}if(H===0)break;O.move(R?0:H,R?H:0);y=true}W.push(O)}};const k=(w,C)=>{const R=h.get(w)??[];for(const D of R)k(D.id,f.get(D.id)?.direction??C);const M=m.get(w)??[];const P=new Map(M.map(D=>[D.id,D]));const E=new Map(M.map(D=>[D.id,[]]));for(const D of e.relationships){if(!P.has(D.entity1)||!P.has(D.entity2))continue;E.get(D.entity1).push(D.entity2);E.get(D.entity2).push(D.entity1)}const v=new Set;const L=[];for(const D of M){if(v.has(D.id))continue;const B=[];const Y=[D.id];while(Y.length){const H=Y.pop();if(v.has(H))continue;v.add(H);B.push(P.get(H));Y.push(...E.get(H))}const W=Math.min(...B.map(H=>H.x)),O=Math.min(...B.map(H=>H.y));const N={x:W,y:O,width:Math.max(...B.map(H=>H.x+H.width))-W,height:Math.max(...B.map(H=>H.y+H.height))-O};L.push({box:N,ids:new Set(B.map(H=>H.id)),move:(H,j)=>{N.x+=H;N.y+=j;for(const q of B){q.x+=H;q.y+=j}}})}const T=[...L,...R.map(D=>({box:D,ids:S(D),move:(B,Y)=>b(D,B,Y)}))];x(T,C);if(w===void 0||T.length===0)return;const A=u.get(w);const $=d.get(A.id)??20;const _=Math.min(...T.map(D=>D.box.x))-$;const z=Math.min(...T.map(D=>D.box.y))-$-A.headerHeight;const F=Math.max(_+(A.labelBlock?.width??Wd(A.label,i).width)+20,Math.max(...T.map(D=>D.box.x+D.box.width))+$);const G=F-_;const I=Math.max(...T.map(D=>D.box.y+D.box.height))+Math.max($,o.get(A.id)??0)-z;if(A.x!==_||A.y!==z||A.width!==G||A.height!==I)y=true;Object.assign(A,{x:_,y:z,width:G,height:I})};k(void 0,e.direction??"LR");return y}function nX(e,t,n,i={operations:0}){const r=e.relationships.map(C=>Mr(C,t,n));const o=bI(e,r);const s=CI(e,t,n,i);const a=(e.direction??"LR")==="LR"||(e.direction??"LR")==="RL";const l=e.direction==="RL"||e.direction==="BT";const c=e.groups.filter(C=>!C.parentId);const d=l?[...c].reverse():c;const u=[];const f=(C,R,M)=>{const P=Wd(qe(C.label,C.labelContent),t);const E=t.groupHeaderFontSize+16+P.height-P.lineHeight;const v={id:C.id,label:C.label,...C.labelContent?{labelContent:C.labelContent}:{},labelBlock:P,...C.parentId?{parentId:C.parentId}:{},x:R,y:M,width:Math.max(160,P.width+20),height:Math.max(100,E+20),headerHeight:E};u.push(v);const L=s.get(C.id)??20;let T=R+L;let A=M+E+L;for(const $ of e.groups.filter(_=>_.parentId===C.id)){const _=f($,T,A);v.width=Math.max(v.width,_.x+_.width-R+L);v.height=Math.max(v.height,_.y+_.height-M+Math.max(L,o.padding.get(C.id)??0));if(a)T+=_.width+20;else A+=_.height+Math.max(20,o.exits.get($.id)??0)}return v};let h=Ct.padding;let m=Ct.padding;for(const C of d){const R=f(C,h,m);if(a)h+=R.width+40;else m+=R.height+30}PI(e,[],u,t,r,o.padding,o.exits,20,n,i,s);const p=new Map(u.map(C=>[C.id,C]));const g=e.relationships.map((C,R)=>{const M=p.get(C.entity1),P=p.get(C.entity2);const E=[];if(M&&P&&o.lanes.has(R)){E.push(...SI(M,P,o.lanes.get(R)))}else if(M&&P){E.push(...cy(M,P))}return{entity1:C.entity1,entity2:C.entity2,cardinality1:C.cardinality1,cardinality2:C.cardinality2,label:C.label,...C.labelContent?{labelContent:C.labelContent}:{},identifying:C.identifying,points:E}});ly([],u,g,r,t,n,i);const y=g.flatMap(C=>C.points);const b=wI(g,r);const S=Math.max(0,Ct.padding-Math.min(...u.map(C=>C.x),...y.map(C=>C.x)),...b.map(C=>-C.x0));const x=Math.max(0,Ct.padding-Math.min(...u.map(C=>C.y),...y.map(C=>C.y)),...b.map(C=>-C.y0));for(const C of u){C.x+=S;C.y+=x}for(const C of y){C.x+=S;C.y+=x}const k=Math.max(...u.map(C=>C.x+C.width+Ct.padding),...y.map(C=>C.x+Ct.padding),...b.map(C=>C.x1+S),0);const w=Math.max(...u.map(C=>C.y+C.height+Ct.padding),...y.map(C=>C.y+Ct.padding),...b.map(C=>C.y1+x),0);return{width:k,height:w,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,entities:[],relationships:g,groups:u}}function EI(e,t={},n){km(e);const i=Xe(t,Bd,n);const r={operations:0};const o=d=>{try{return d()}catch(u){if(t.graphLayout?.backend!=="agentic"||t.graphLayout.fallback!=="elk"||!(u instanceof Nt||u instanceof Fd||u instanceof es))throw u;const f=new Qe([{strategy:"er-final-geometry",violations:[u.message]}]);f.cause=u;throw f}};if(e.entities.length===0){const d=()=>U0({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,entities:[],relationships:[],groups:[]},e.title,i);const u=()=>e.groups.length?gI(U0(mI(nX(e,i,n,r),i,n),e.title,i),i,n,r):d();return Vr(t,()=>o(u),()=>{Jt(r,0);return u()},true)}const s=K3(e,i);const a=()=>{const d=new Map(e.entities.map((S,x)=>[S.id,x]));const u=new Set(e.groups.map(S=>S.id));const f=new Set([...d.keys(),...u]);const h=new Map;let m=t.layerSpacing??Ct.layerSpacing;let p=0;for(const S of e.relationships){const x=st(n,"relationship",{category:S.identifying?"identifying":"non-identifying"},{includeFallback:false});for(const[k,w]of[[S.entity1,S.cardinality1],[S.entity2,S.cardinality2]]){const C=Ga(w,i.lineWidth);Jt(r);if(!C)throw new Nt(S.entity1,S.entity2);const R=C.x1+(x?.lineWidth??i.lineWidth)/2+i.lineWidth+.25;const M=R+Math.min(x?.bendRadius??i.edgeBendRadius,R);p=Math.max(p,M);m=Math.max(m,4*M);if(!u.has(k))h.set(k,(h.get(k)??0)+C.y1-C.y0+i.lineWidth+.25)}}const g=new Map(e.entities.map(S=>{const x=s.get(S.id),k=(h.get(S.id)??0)+2*Math.max(8,i.cornerRadius??0);return[S.id,{...x,width:Math.max(x.width,k),height:Math.max(x.height,k)}]}));const y=e.relationships.flatMap((S,x)=>{const k=u.has(S.entity1)?void 0:d.get(S.entity1),w=u.has(S.entity2)?void 0:d.get(S.entity2);if(!f.has(S.entity1)||!f.has(S.entity2))throw new Error("ER relationship references an undeclared entity or frame");if(k===void 0||w===void 0)return[];const C=Mr(S,i,n);return[{relationshipIndex:x,source:k,target:w,minSpan:1,...S.label?{label:{width:C.width+16,height:C.height+16}}:{}}]});const b=ei("agentic",()=>Ya({nodes:e.entities.map(S=>({id:S.id,...g.get(S.id)})),edges:y,direction:e.direction??"LR",padding:Ct.padding,nodeSpacing:t.nodeSpacing??Ct.nodeSpacing,layerSpacing:m,...p>0?{minimumTerminalLead:p}:{},edgeSpacing:Math.max(6,i.lineWidth+4)}));return{width:b.width,height:b.height,preserveTerminalNormals:true,labelPlacement:"shaft-aware",entities:b.nodes.map((S,x)=>({id:e.entities[x].id,...S,...g.get(e.entities[x].id)})),routes:new Map(b.edges.map((S,x)=>[y[x].relationshipIndex,S.points])),labelPositions:new Map(b.edges.flatMap((S,x)=>S.labelPosition?[[y[x].relationshipIndex,{...S.labelPosition}]]:[]))}};const l=()=>{Jt(r,0);const{elkGraph:d}=J3(e,t,s,n,r);const u=Ha(d);return{width:u.width,height:u.height,entities:u.children??[],routes:new Map((u.edges??[]).map(f=>{const h=f.sections?.[0];return[Number(f.id.slice(1)),h?qs([h.startPoint,...h.bendPoints??[],h.endPoint]):[]]}))}};const c=d=>{const u=U0(mI(Q3(d,e,s,i,n,r),i,n),e.title,i);return gI(u,i,n,r)};return Vr(t,()=>o(()=>c(a())),()=>c(l()),true)}function U0(e,t,n){const i=tn(t,n);if(!i)return e;if(e.width===0&&e.height===0)return{...e,...da(i,Ct.padding)};const r=i.height;for(const s of e.entities)s.y+=r;for(const s of e.groups)s.y+=r;for(const s of e.relationships){for(const a of s.points)a.y+=r;if(s.labelPosition)s.labelPosition.y+=r}const o=Math.max(e.width,i.width+2*Ct.padding);return{...e,width:o,height:e.height+r,title:rn(i,o,Ct.padding)}}function gI(e,t,n,i){const r=e.relationships;if(!r.length)return e;const o=(M=1)=>Jt(i,M);const s=(M,P)=>{o();return M.x0<P.x1&&M.x1>P.x0&&M.y0<P.y1&&M.y1>P.y0};const a=new Map([...e.entities,...e.groups].map(M=>[M.id,M]));const l=new Set(e.groups.map(M=>M.id));MI(e.entities,e.groups,r,i);const c=[...e.entities.map(M=>{const P=Number.parseFloat(M.inlineStyle?.["stroke-width"]??"");const E=(Number.isFinite(P)&&P>0?P:t.nodeLineWidth)/2;return{id:M.id,box:{x0:M.x-E,y0:M.y-E,x1:M.x+M.width+E,y1:M.y+M.height+E}}}),...e.groups.flatMap(M=>{const P=M.x,E=M.y,v=P+M.width,L=E+M.height,T=.75;return[{id:M.id,group:true,box:{x0:P,y0:E,x1:v,y1:E+M.headerHeight}},{id:M.id,group:true,border:true,box:{x0:P-T,y0:E-T,x1:P+T,y1:L+T}},{id:M.id,group:true,border:true,box:{x0:v-T,y0:E-T,x1:v+T,y1:L+T}},{id:M.id,group:true,border:true,box:{x0:P-T,y0:E-T,x1:v+T,y1:E+T}},{id:M.id,group:true,border:true,box:{x0:P-T,y0:L-T,x1:v+T,y1:L+T}}]})];o(c.length+a.size);const d=()=>r.flatMap((M,P)=>{o();if(M.points.length<2)throw new Nt(M.entity1,M.entity2);return[0,1].map(E=>{const v=E?M.points.at(-1):M.points[0],L=E?M.points.at(-2):M.points[1];const T=To(v,L,E?M.cardinality2:M.cardinality1,t.lineWidth);o(2+(T?.length??0));if(!T?.length)throw new Nt(M.entity1,M.entity2);return{index:P,end:E,rel:M,id:E?M.entity2:M.entity1,point:v,toward:L,pieces:T}})});const u=(M,P,E,v)=>Math.max(0,...M.map(L=>{o();return v>0?E?L.x1-P.x:L.y1-P.y:E?P.x-L.x0:P.y-L.y0}));const f=()=>r.flatMap((M,P)=>{const E=st(n,"relationship",{category:M.identifying?"identifying":"non-identifying"},{includeFallback:false});const v=(E?.lineWidth??t.lineWidth)/2;const L=E?.bendRadius??t.edgeBendRadius;const T=(A,$,_,z)=>{o();if($.y===_.y){if(_.x>$.x===z)A.x0=z?$.x:_.x;else A.x1=z?$.x:_.x}else if($.x===_.x){if(_.y>$.y===z)A.y0=z?$.y:_.y;else A.y1=z?$.y:_.y}};if(L>0&&M.points.length>2){const A=qn(M.points,L,{metric:"manhattan"}).geometry;const $=[];let _;if(A.kind!=="path"||!ps(A.d,z=>{o();const F={x0:z.bounds.x0-v,y0:z.bounds.y0-v,x1:z.bounds.x1+v,y1:z.bounds.y1+v};if(!$.length&&z.line)T(F,z.line[0],z.line[1],true);_=z.line;$.push({index:P,box:F,first:false,last:false,...z.line?{line:z.line}:{}});return true},()=>{o();return true}))throw new Nt(M.entity1,M.entity2);if($.length){$[0].first=true;$.at(-1).last=true;if(_)T($.at(-1).box,_[0],_[1],false)}return $}return M.points.slice(1).map((A,$)=>{o();const _=M.points[$];if(_.x!==A.x&&_.y!==A.y||![_.x,_.y,A.x,A.y,v].every(Number.isFinite))throw new Nt(M.entity1,M.entity2);const z={x0:Math.min(_.x,A.x)-v,y0:Math.min(_.y,A.y)-v,x1:Math.max(_.x,A.x)+v,y1:Math.max(_.y,A.y)+v};if($===0)T(z,_,A,true);if($===M.points.length-2)T(z,_,A,false);return{index:P,box:z,first:$===0,last:$===M.points.length-2,line:[_,A]}})});let h=sy(e,t,n,i);let m=qa(e)??Ks(e,t,n,i);const p=M=>r.flatMap((P,E)=>{o();const v=m.get(P);if(!P.label||!v)return[];const L=P.labelBlock??Mr(P,t,n);const T=M?{x0:v.x-L.width/2-8,y0:v.y-L.height/2-8,x1:v.x+L.width/2+8,y1:v.y+L.height/2+8}:R0(L,v);if(!T)throw new Nt(P.entity1,P.entity2);return[{index:E,box:T}]});let g=false;const y=new Map;for(const M of d()){o();const P=M.point.y===M.toward.y;const E=P?M.toward.x>M.point.x?"E":"W":M.toward.y>M.point.y?"S":"N";const v=y.get(M.id)??new Map;const L=v.get(E)??[];L.push(M);v.set(E,L);y.set(M.id,v)}const b=[...y.values()].flatMap(M=>[...M.values()].flatMap(P=>P.sort((E,v)=>{o();const L=E.point.y===E.toward.y;return(L?E.point.y-v.point.y:E.point.x-v.point.x)||E.index*2+E.end-v.index*2-v.end})));const S=new Map(b.map((M,P)=>[M.index*2+M.end,P]));o(b.length*2);for(const M of b){o();const P=a.get(M.id),E=M.end?M.rel.points.at(-1):M.rel.points[0];const v=M.end?M.rel.points.at(-2):M.rel.points[1];const L=v.y===E.y&&v.x!==E.x,T=v.x===E.x&&v.y!==E.y;const A=L?Math.sign(v.x-E.x):Math.sign(v.y-E.y);const $=L?E.x===(A>0?P.x+P.width:P.x):E.y===(A>0?P.y+P.height:P.y);if(!L&&!T||!$)continue;const _=L?E.y:E.x;const z=l.has(M.id)?6:Math.min(t.cornerRadius??0,P.width/2,P.height/2);let F=(L?P.y:P.x)+z,G=(L?P.y+P.height:P.x+P.width)-z;const I=d(),D=I.find(pe=>pe.index===M.index&&pe.end===M.end);const B=I.filter(pe=>{o();if(pe.id!==M.id||S.get(pe.index*2+pe.end)<=S.get(M.index*2+M.end))return false;return L?pe.point.x===E.x&&pe.toward.y===pe.point.y&&Math.sign(pe.toward.x-pe.point.x)===A:pe.point.y===E.y&&pe.toward.x===pe.point.x&&Math.sign(pe.toward.y-pe.point.y)===A});const Y=new Set(B);o(B.length);const W=[...I.filter(pe=>{o();return(pe.index!==M.index||pe.end!==M.end)&&!Y.has(pe)}).flatMap(pe=>pe.pieces),...f().filter(pe=>pe.index!==M.index&&!B.some(Te=>{o();return Te.index===pe.index&&(Te.end?pe.last:pe.first)})).map(pe=>pe.box)];const O=[...c.filter(pe=>pe.id!==M.id||!!pe.group!==l.has(M.id)).map(pe=>pe.box),...W];const N=new Set(I.filter(pe=>pe.index===M.index).flatMap(pe=>pe.pieces));o(N.size);const H=[...c.filter(pe=>(pe.id!==M.id||!!pe.group!==l.has(M.id))&&!pe.border).map(pe=>pe.box),...W.filter(pe=>!N.has(pe))];const j=st(n,"relationship",{category:M.rel.identifying?"identifying":"non-identifying"},{includeFallback:false});const q=(j?.lineWidth??t.lineWidth)/2;const X=u(D.pieces,E,L,A);const V=X+(j?.bendRadius??t.edgeBendRadius)+q+t.lineWidth+.25;const ee=Math.min(Math.abs(L?v.x-E.x:v.y-E.y),V);const re=L?{x:E.x+A*ee,y:E.y}:{x:E.x,y:E.y+A*ee};const U={x0:Math.min(E.x,re.x)-(L?0:q),x1:Math.max(E.x,re.x)+(L?0:q),y0:Math.min(E.y,re.y)-(L?q:0),y1:Math.max(E.y,re.y)+(L?q:0)};const te=[...D.pieces.map(pe=>({piece:pe,occupied:O})),{piece:U,occupied:H}];o(O.length+H.length+te.length);if(_>=F&&_<=G&&!te.some(({piece:pe,occupied:Te})=>Te.some(Fe=>s(pe,Fe))))continue;const J=I.find(pe=>pe.index===M.index&&pe.end!==M.end);const ae=J.point.y===J.toward.y;if(L!==ae){const pe=Math.sign(ae?J.toward.x-J.point.x:J.toward.y-J.point.y);const Te=st(n,"relationship",{category:M.rel.identifying?"identifying":"non-identifying"},{includeFallback:false});const Fe=u(J.pieces,J.point,ae,pe)+(Te?.lineWidth??t.lineWidth)/2+t.lineWidth+.25;const De=Fe+Math.min(Te?.bendRadius??t.edgeBendRadius,Fe);const Be=ae?J.point.x:J.point.y;if(pe>0)F=Math.max(F,Be+De);else G=Math.min(G,Be-De)}let Q=Math.max(F,Math.min(_,G));const K=[];for(const{piece:pe,occupied:Te}of te)for(const Fe of Te){o();const De=L?pe.x0:pe.y0,Be=L?pe.x1:pe.y1;const me=L?Fe.x0:Fe.y0,he=L?Fe.x1:Fe.y1;if(De>=he||Be<=me)continue;const fe=t.lineWidth+.25;K.push([(L?Fe.y0:Fe.x0)-((L?pe.y1:pe.x1)-_)-fe,(L?Fe.y1:Fe.x1)-((L?pe.y0:pe.x0)-_)+fe])}K.sort((pe,Te)=>{o();return pe[0]-Te[0]||pe[1]-Te[1]});for(const[pe,Te]of K){o();if(Q>pe&&Q<Te)Q=Te}if(Q>G){Q=Math.max(F,Math.min(_,G));for(let pe=K.length-1;pe>=0;pe--){o();const[Te,Fe]=K[pe];if(Q>Te&&Q<Fe)Q=Te}if(Q<F)throw new Nt(M.rel.entity1,M.rel.entity2)}if(Q===_)continue;if(Q>G)throw new Nt(M.rel.entity1,M.rel.entity2);const Z=M.rel.points.map(pe=>({...pe})),se=M.end?-1:1,oe=M.end?Z.length-1:0;const de=L?"y":"x",xe=E[de],Me=Q-xe;let Ce=oe;for(let pe=oe;pe>=0&&pe<Z.length&&Z[pe][de]===xe;pe+=se){o();Ce=pe}if(Ce===(M.end?0:Z.length-1)){const pe=Z[0],Te=Z.at(-1);Z[oe][de]=Q;const Fe=I.find(Ie=>Ie.index===M.index&&Ie.end===0),De=I.find(Ie=>Ie.index===M.index&&Ie.end===1);const Be=st(n,"relationship",{category:M.rel.identifying?"identifying":"non-identifying"},{includeFallback:false});const me=Ie=>{const ne=Math.sign(L?Ie.toward.x-Ie.point.x:Ie.toward.y-Ie.point.y);const we=u(Ie.pieces,Ie.point,L,ne)+(Be?.lineWidth??t.lineWidth)/2+t.lineWidth+.25;return we+Math.min(Be?.bendRadius??t.edgeBendRadius,we)};const he=L?"x":"y",fe=Math.sign(Te[he]-pe[he]),be=pe[he]+fe*me(Fe),ge=Te[he]-fe*me(De);if((ge-be)*fe<0)throw new Nt(M.rel.entity1,M.rel.entity2);const Re=Math.max(Math.min(be,ge),Math.min(Math.max(be,ge),(pe[he]+Te[he])/2));M.rel.points=xt(L?[pe,{x:Re,y:pe.y},{x:Re,y:Te.y},Te]:[pe,{x:pe.x,y:Re},{x:Te.x,y:Re},Te])}else{for(let pe=oe;pe!==Ce+se;pe+=se){o();Z[pe][de]+=Me}M.rel.points=xt(Z)}if(!ay(M.rel.points,i))throw new Nt(M.rel.entity1,M.rel.entity2);delete M.rel.finalLabelPosition;g=true}if(g){ly(e.entities,e.groups,r,r.map(M=>M.labelBlock??Mr(M,t,n)),t,n,i);h=sy(e,t,n,i);m=qa(e)??Ks(e,t,n,i)}if(h.length){o(r.length+h.length);const M=new Set(h);const P=new Set(r.flatMap((E,v)=>M.has(E)?[v]:[]));ly(e.entities,e.groups,r,r.map(E=>E.labelBlock??Mr(E,t,n)),t,n,i,{indices:P,admit:(E,v)=>hI(e,E,v,t,n,i)});e.width=Math.max(e.width,...r.flatMap(E=>E.points.map(v=>v.x+Ct.padding)));e.height=Math.max(e.height,...r.flatMap(E=>E.points.map(v=>v.y+Ct.padding)));sy(e,t,n,i);m=qa(e)??Ks(e,t,n,i)}const x=d(),k=f(),w=p(false);for(const M of r)if(!ay(M.points,i))throw new Nt(M.entity1,M.entity2);for(const M of r)for(let P=1;P<M.points.length;P++){for(const E of e.entities){o();if(Ii(M.points[P-1],M.points[P],{...E,label:"",shape:"rectangle"}))throw new Nt(M.entity1,M.entity2)}for(const E of e.groups){o();if(E.headerHeight>0&&Ii(M.points[P-1],M.points[P],{...E,height:E.headerHeight,label:"",shape:"rectangle"}))throw new Nt(M.entity1,M.entity2)}}const C=(M,P,E,v,L,T)=>{if(l.has(P)!==T)return false;const A=r[M.index];const $=M.first&&A.entity1===P?0:M.last&&A.entity2===P?1:void 0;if($===void 0)return false;const _=$?A.points.at(-1):A.points[0],z=$?A.points.at(-2):A.points[1];const F=_.y>=E.y+L&&_.y<=E.y+E.height-L;const G=_.x>=E.x+L&&_.x<=E.x+E.width-L;o();return F&&z.y===_.y&&(_.x===E.x&&z.x<_.x&&M.box.x1<=E.x+v||_.x===E.x+E.width&&z.x>_.x&&M.box.x0>=E.x+E.width-v)||G&&z.x===_.x&&(_.y===E.y&&z.y<_.y&&M.box.y1<=E.y+v||_.y===E.y+E.height&&z.y>_.y&&M.box.y0>=E.y+E.height-v)};for(const M of k){const P=r[M.index];for(const E of e.entities){const v=Number.parseFloat(E.inlineStyle?.["stroke-width"]??"");const L=(Number.isFinite(v)&&v>0?v:t.nodeLineWidth)/2;const T={x0:E.x-L,y0:E.y-L,x1:E.x+E.width+L,y1:E.y+E.height+L};if(s(M.box,T)&&!C(M,E.id,E,L,Math.min(t.cornerRadius??0,E.width/2,E.height/2),false))throw new Nt(P.entity1,P.entity2)}for(const E of e.groups){const v={x0:E.x,y0:E.y,x1:E.x+E.width,y1:E.y+E.headerHeight};if(E.headerHeight>0&&s(M.box,v)&&!C(M,E.id,E,.75,6,true))throw new Nt(P.entity1,P.entity2)}}const R=new Map(x.map(M=>{o(M.pieces.length*4+1);return[M,{x0:Math.min(...M.pieces.map(P=>P.x0)),y0:Math.min(...M.pieces.map(P=>P.y0)),x1:Math.max(...M.pieces.map(P=>P.x1)),y1:Math.max(...M.pieces.map(P=>P.y1))}]}));for(const M of x)for(const P of x){o();if(P.index*2+P.end<=M.index*2+M.end||!s(R.get(M),R.get(P)))continue;for(const E of M.pieces)if(P.pieces.some(v=>s(E,v)))throw new Nt(M.rel.entity1,M.rel.entity2)}for(const M of x){const P=M.toward.x-M.point.x,E=M.toward.y-M.point.y;const v=E===0&&P!==0,L=P===0&&E!==0;const T=Math.sign(v?P:E);const A=k.find(F=>{o();return F.index===M.index&&(M.end?F.last:F.first)});const $=A?.line,_=$&&(M.end?$[0]:$[1]),z=$&&(M.end?$[1]:$[0]);if(!v&&!L||!_||!z||(v?_.y!==z.y||Math.sign(_.x-z.x)!==T:_.x!==z.x||Math.sign(_.y-z.y)!==T)||T*((v?_.x:_.y)-(v?M.point.x:M.point.y))<u(M.pieces,M.point,v,T))throw new Nt(M.rel.entity1,M.rel.entity2);for(const F of M.pieces){for(const G of c)if((G.id!==M.id||!!G.group!==l.has(M.id))&&s(F,G.box))throw new Nt(M.rel.entity1,M.rel.entity2);for(const G of k)if((G.index!==M.index||!(M.end?G.last:G.first))&&s(F,G.box))throw new Nt(M.rel.entity1,M.rel.entity2)}}for(const M of w){const P=r[M.index];for(const E of c)if(s(M.box,E.box))throw new Nt(P.entity1,P.entity2);for(const E of x)if(s(M.box,R.get(E))&&E.pieces.some(v=>s(M.box,v)))throw new Nt(P.entity1,P.entity2);for(const E of k)if(E.index!==M.index&&s(M.box,E.box))throw new Nt(P.entity1,P.entity2);for(const E of w)if(E.index<M.index&&s(M.box,E.box))throw new Nt(P.entity1,P.entity2)}return e}function RI({positioned:e,options:t}){const n=e.entities.map(l=>({id:l.id,x:ye(l.x),y:ye(l.y),w:zt(l.x,l.width),h:zt(l.y,l.height),shape:"rectangle",label:l.label,...St(l.labelBlock,l.x+l.width/2,l.y+l.headerHeight/2,{...l,height:l.headerHeight})}));const i=new Map(e.entities.map(l=>[l.id,{x:l.x,y:l.y,width:l.width,height:l.height}]));const r=qa(e);if(e.labelPlacement==="shaft-aware"&&!r)throw new Error("ER_LABEL_LAYOUT_MISSING: project the complete native family layout artifact");const o=r??Ks(e,Xe({},Bd));const s=e.relationships.map((l,c)=>{const d=o.get(l);return{id:`rel#${c}:${l.entity1}->${l.entity2}`,from:l.entity1,to:l.entity2,path:l.points.map(u=>[ye(u.x),ye(u.y)]),label:l.label&&d?{x:ye(d.x),y:ye(d.y),text:l.label,bounds:Yt(l.labelBlock,d.x,d.y)}:void 0,route:t.debug?Hg("er",c,l.points,i.get(l.entity1),i.get(l.entity2)):void 0}});const a=e.groups.map(l=>({id:l.id,x:ye(l.x),y:ye(l.y),w:zt(l.x,l.width),h:zt(l.y,l.height),members:[...e.entities.filter(c=>c.groupId===l.id).map(c=>c.id),...e.groups.filter(c=>c.parentId===l.id).map(c=>c.id)],label:l.label,parentId:l.parentId}));return{version:1,nodes:n,edges:s,groups:a,bounds:{w:ye(e.width),h:ye(e.height)}}}function fy({positioned:e,options:t}){return Q2(e,t)}function vI({positioned:e,options:t}){const n=e.plot.x+e.plot.w;const i=e.bars.map(s=>{const a=s.id??`task#${s.taskIndex}`;const l=s.labelPosition;const c=l&&!e.compact&&s.labelBlock?l.y+(s.labelBlock.height-s.labelBlock.lineHeight)/2:l?.y;const d=l&&c!==void 0?St(s.labelBlock,l.x,c,Xt(e),l.anchor):{};if(s.milestoneX!==void 0){const h=s.h/2;return{id:a,x:ye(s.milestoneX-h),y:ye(s.y),w:zt(s.milestoneX-h,s.h),h:zt(s.y,s.h),shape:"diamond",label:s.label,...d}}const u=Math.max(2,s.w);const f=Math.min(s.x,n-u);return{id:a,x:ye(f),y:ye(s.y),w:zt(f,u),h:zt(s.y,s.h),shape:"rectangle",label:s.label,...d}});const r=e.sections.map((s,a)=>({id:`section#${a}`,x:ye(e.plot.x),y:ye(s.y),w:zt(e.plot.x,e.plot.w),h:zt(s.y,s.h),members:e.bars.filter(l=>l.sectionIndex===a).map(l=>l.id??`task#${l.taskIndex}`),label:s.label}));const o={version:1,nodes:i,edges:[],groups:r,bounds:{w:ye(e.width),h:ye(e.height)}};if(t.debug)o.certificates=Zo("gantt",o,"section-contained");return o}var dh=12;function kr(e,t,n,i={}){return _e(e,{display:"literal",fontSize:t,fontWeight:n,...i})}function hy(e,t){return-6-e[t].fontSize-e.slice(0,t).reduce((n,i)=>n+i.height+5,0)-(e[t].height-e[t].lineHeight)/2}function Xa(e,t){const n=e.height-e.lineHeight;return t==="LR"?24+n:4+n/2}function LI(e,t={}){const n=rX(t.padding,44);const i=t.showBranches!==false;const r=t.showCommitLabel!==false;const o=t.rotateCommitLabel!==false;const s=oX(t.commitLabelFontSize,11);const a=Xe(t.renderOptions??{},{...Oi,nodeLabelFontSize:s,nodeLabelFontWeight:500,groupHeaderFontSize:12,groupHeaderFontWeight:600},t.styleFace);const l=Xe(t.renderOptions??{},{...Oi,nodeLabelFontSize:10,nodeLabelFontWeight:600},t.styleFace);const c=Xe(t.renderOptions??{},{...Oi,groupHeaderFontSize:16,groupHeaderFontWeight:600},t.styleFace);const d=I=>({...I,labelBlock:kr(ha(I),a.nodeLabelFontSize,a.nodeLabelFontWeight,{transform:a.nodeTextTransform,letterSpacing:a.nodeLetterSpacing}),tagBlocks:I.tags.map(D=>kr(D,l.nodeLabelFontSize,l.nodeLabelFontWeight,{transform:l.nodeTextTransform,letterSpacing:l.nodeLetterSpacing}))});const u=e.commits.map(d);const f=e.title?kr(e.title,c.groupHeaderFontSize,c.groupHeaderFontWeight,{transform:c.groupTextTransform,letterSpacing:c.groupLetterSpacing}):void 0;const h=f?40-16*fi+f.height:0;const m=e.branches.map(I=>({...I,labelBlock:kr(I.name,a.groupHeaderFontSize,a.groupHeaderFontWeight,{transform:a.groupTextTransform,letterSpacing:a.groupLetterSpacing})})).sort((I,D)=>I.order-D.order||I.sequence-D.sequence||Bn(I.name,D.name));const p=new Map(m.map((I,D)=>[I.name,D]));const g=new Map(u.map(I=>[I.id,I]));const y=new Map;for(const I of u){const D=I.parents.length===0?0:Math.max(...I.parents.map(B=>y.get(B)??0))+1;y.set(I.id,D)}const b=I=>t.parallelCommits?y.get(I.id):I.sequence;const S=Math.max(0,...u.map(b));const x=Math.max(82,...m.map(I=>I.labelBlock.height+20),...u.map(I=>{const D=TI(I,e.direction,o,s,r);return D.maxY-D.minY+20}));const k=Math.max(150,...m.map(I=>I.labelBlock.width+20));const w=94;const C=i?Math.max(80,...m.map(I=>I.labelBlock.width+24)):20;const R=new Map;for(const I of u){const D=b(I);const B=TI(I,e.direction,o,s,r);const Y=R.get(D);R.set(D,Y?{minX:Math.min(Y.minX,B.minX),minY:Math.min(Y.minY,B.minY),maxX:Math.max(Y.maxX,B.maxX),maxY:Math.max(Y.maxY,B.maxY)}:B)}const M=new Map;const P=Array.from({length:S+1},(I,D)=>e.direction==="BT"?S-D:D);for(const[I,D]of P.entries()){const B=R.get(D)??{minX:-10,minY:-10,maxX:10,maxY:10};const Y=e.direction==="LR"?B.minX:B.minY;if(I===0){M.set(D,e.direction==="LR"?Math.max(0,-Y):0);continue}const W=P[I-1];const O=R.get(W)??{minX:-10,minY:-10,maxX:10,maxY:10};const N=M.get(W);const H=e.direction==="LR"?O.maxX:O.maxY;M.set(D,Math.max(N+w,N+H-Y+18))}const E=n+C+20;const v=n+h+38;const L=u.map(I=>{const D=p.get(I.branch)??0;const B=b(I);if(e.direction==="LR"){return{...I,lane:D,x:E+M.get(B),y:n+h+D*x}}return{...I,lane:D,x:n+C+D*k,y:v+M.get(B)}});const T=new Map(L.map(I=>[I.id,I]));const A=[];const $=new Map;for(const I of L){const D=e.direction==="LR"?I.x:I.y;$.set(I.branch,Math.max($.get(I.branch)??-Infinity,D));for(const[B,Y]of[...new Set(I.parents)].entries()){const W=T.get(Y);if(!W)continue;const O=e.direction==="LR"?(W.x+I.x)/2:(W.y+I.y)/2;const N=e.direction==="LR"?[{x:W.x,y:W.y},{x:O,y:W.y},{x:O,y:I.y},{x:I.x,y:I.y}]:[{x:W.x,y:W.y},{x:W.x,y:O},{x:I.x,y:O},{x:I.x,y:I.y}];const H=B===0?"parent":I.source==="cherry-pick"?"cherry-pick":"merge";A.push({from:W.id,to:I.id,kind:H,points:N})}}const _=m.map((I,D)=>{const B=$.get(I.name)??-Infinity;if(e.direction==="LR"){const W=n+h+D*x;return{...I,lane:D,x1:E-14,y1:W,x2:Math.max(E,B),y2:W}}const Y=n+C+D*k;return{...I,lane:D,x1:Y,y1:n+h-14,x2:Y,y2:Math.max(v,B)}});let z;let F;if(e.direction==="LR"){z=Math.max(n*2+C+80,...L.map(I=>I.x+(r?Math.max(26,I.labelBlock.width*.75):18)))+n;F=n*2+h+Math.max(0,m.length-1)*x+82+(r?s*2+26:0)}else{z=n*2+C+Math.max(1,m.length)*k;F=Math.max(n*2+h+80,...L.map(I=>I.y+(r?38:18)))+n}if(e.title)z=Math.max(z,f.width+n*2);const G=[...L.flatMap(I=>[...r?[iX(I,e.direction,o,s)]:[],...I.tags.map((D,B)=>J0(I.tagBlocks[B],I.x+14,I.y+hy(I.tagBlocks,B),10,600,"start",0))]),...i?_.map(I=>J0(I.labelBlock,e.direction==="LR"?I.x1-10:I.x1,e.direction==="LR"?I.y1:I.y1-16,12,600,e.direction==="LR"?"end":"middle",0)):[]];if(G.length>0){const I=Math.min(...G.map(H=>H.minX));const D=Math.min(...G.map(H=>H.minY));const B=Math.max(...G.map(H=>H.maxX));const Y=Math.max(...G.map(H=>H.maxY));const W=I<n?n-I:0;const O=n+h;const N=D<O?O-D:0;if(W!==0||N!==0){for(const H of L){H.x+=W;H.y+=N}for(const H of _){H.x1+=W;H.x2+=W;H.y1+=N;H.y2+=N}for(const H of A)for(const j of H.points){j.x+=W;j.y+=N}}z=Math.max(z+W,B+W+n);F=Math.max(F+N,Y+N+n)}for(const I of L){I.x=ns(I.x);I.y=ns(I.y)}for(const I of _){I.x1=ns(I.x1);I.y1=ns(I.y1);I.x2=ns(I.x2);I.y2=ns(I.y2)}for(const I of A)for(const D of I.points){D.x=ns(D.x);D.y=ns(D.y)}return{width:ns(z),height:ns(F),direction:e.direction,...e.title?{title:e.title,titleBlock:f}:{},commits:L,branches:_,edges:A,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,showBranches:i,showCommitLabel:r,rotateCommitLabel:o}}function TI(e,t,n,i,r){const o=[{minX:-10,minY:-10,maxX:10,maxY:10}];if(r){const a=e.labelBlock??kr(ha(e),i,500);o.push(K0(a,t==="LR"?0:14,Xa(a,t),i,t==="LR"?"middle":"start",t==="LR"&&n?45:0))}const s=e.tagBlocks??e.tags.map(a=>kr(a,10,600));for(const[a,l]of e.tags.entries()){const c=J0(s[a],14,hy(s,a),10,600,"start",0);o.push({...c,minX:c.minX-4,maxX:c.maxX+6,minY:c.minY-2,maxY:c.maxY+2})}return{minX:Math.min(...o.map(a=>a.minX)),minY:Math.min(...o.map(a=>a.minY)),maxX:Math.max(...o.map(a=>a.maxX)),maxY:Math.max(...o.map(a=>a.maxY))}}function iX(e,t,n,i){const r=e.labelBlock??kr(ha(e),i,500);return t==="LR"?K0(r,e.x,e.y+Xa(r,t),i,"middle",n?45:0):K0(r,e.x+14,e.y+Xa(r,t),i,"start",0)}function K0(e,t,n,i,r,o){const s=typeof e==="string"?kr(e,i,500):e;i=s.fontSize;const a=s.height-s.lineHeight;const l=Math.max(18,s.width+dh*2);const c=r==="middle"?-l/2:-dh;const d=dl({x0:t+c,y0:n-i-a/2,x1:t+c+l,y1:n+6+a/2},{x:t,y:n},o);return{minX:d.x0,minY:d.y0,maxX:d.x1,maxY:d.y1}}function J0(e,t,n,i,r,o,s){const a=typeof e==="string"?kr(e,i,r):e;i=a.fontSize;const l=a.height-a.lineHeight;const c=a.width;const d=o==="middle"?-c/2:o==="end"?-c:0;const u=-i-l/2;const f=i*.28+l/2;const h=dl({x0:t+d,y0:n+u,x1:t+d+c,y1:n+f},{x:t,y:n},s);return{minX:h.x0,minY:h.y0,maxX:h.x1,maxY:h.y1}}function rX(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>=0?e:t}function oX(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:t}function ns(e){return Math.round(e*1e3)/1e3}function AI({positioned:e}){const t=e.commits.map(r=>{const o=r.customType??r.type;const s=r.labelBlock;let a=s&&e.showCommitLabel?Yt(s,e.direction==="LR"?r.x:r.x+14,r.y+Xa(s,e.direction)-s.fontSize*.35,e.direction==="LR"?"middle":"start"):void 0;if(a&&e.direction==="LR"&&e.rotateCommitLabel&&s){const l=dl({x0:a.x,y0:a.y,x1:a.x+a.w,y1:a.y+a.h},{x:r.x,y:r.y+Xa(s,e.direction)},45);a=ln({x:l.x0,y:l.y0,width:l.x1-l.x0,height:l.y1-l.y0})}return{id:r.id,x:ye(r.x-10),y:ye(r.y-10),w:ye(20),h:ye(20),shape:o==="CHERRY_PICK"?"diamond":o==="HIGHLIGHT"?"rectangle":"ellipse",label:r.message||r.id,labelVisibility:e.showCommitLabel?"visible":"hidden",labelBounds:a,labelContainer:ln(Xt(e))}});const n=e.edges.map((r,o)=>({id:`edge#${o}:${r.from}->${r.to}`,from:r.from,to:r.to,path:r.points.map(s=>[ye(s.x),ye(s.y)])}));const i=e.showBranches?e.branches.map(r=>{const o=e.commits.filter(d=>d.branch===r.name);const s=Math.min(r.x1,r.x2,...o.map(d=>d.x-10));const a=Math.min(r.y1,r.y2,...o.map(d=>d.y-10));const l=Math.max(r.x1,r.x2,...o.map(d=>d.x+10));const c=Math.max(r.y1,r.y2,...o.map(d=>d.y+10));return{id:`branch:${r.name}`,x:ye(s),y:ye(a),w:zt(s,Math.max(1,l-s)),h:zt(a,Math.max(1,c-a)),members:o.map(d=>d.id),label:r.name}}):[];return{version:1,nodes:t,edges:n,groups:i,bounds:{w:ye(e.width),h:ye(e.height)}}}function II({positioned:e}){const t=[];const n=[];for(const i of e.sections){const r=[];for(const s of i.tasks){t.push({id:s.id,x:ye(s.x),y:ye(s.y),w:ye(s.width),h:ye(s.height),shape:"rectangle",label:s.text,...St(s.block,s.textX,s.textY,s)});r.push(s.id)}const o=i.tasks.length>0?Math.max(i.y+i.height,...i.tasks.map(s=>s.y+s.height)):i.y+i.height;n.push({id:i.id,x:ye(i.x),y:ye(i.y),w:ye(i.width),h:ye(o-i.y),members:r,label:i.label})}return{version:1,nodes:t,edges:[],groups:n,bounds:{w:ye(e.width),h:ye(e.height)}}}function FI({positioned:e}){const t=e.nodes.map(i=>({id:i.id,x:ye(i.x),y:ye(i.y),w:ye(i.width),h:ye(i.height),shape:i.shape==="circle"?"ellipse":"rectangle",label:i.label,...St(i.labelBlock,i.x+i.width/2,i.y+i.height/2+(i.icon?5:0),i)}));const n=e.edges.map((i,r)=>({id:`edge#${r}:${i.from}->${i.to}`,from:i.from,to:i.to,path:i.points.map(o=>[ye(o.x),ye(o.y)])}));return{version:1,nodes:t,edges:n,groups:[],bounds:{w:ye(e.width),h:ye(e.height)}}}var $i={fontSize:15,fontWeight:500,height:32,padX:14,offsetY:12,rx:8,minY:4,pointerSize:6};var zd=e=>(Math.round(e*100)/100).toString();function Ua(e,t,n){const i=_e(n.replace(/[\t\n\r ]+/g," ").trim(),{display:"literal",fontSize:$i.fontSize,fontWeight:$i.fontWeight});const r=i.width+$i.padX*2;const o=e-r/2;const s=Math.max($i.minY,t-$i.offsetY-$i.height);const a=s+$i.height;const l=$i.pointerSize;const c=`M${zd(e-l)},${zd(a)} L${zd(e+l)},${zd(a)} L${zd(e)},${zd(a+l)} Z`;return{text:n,block:i,bgW:r,bgX:o,bgY:s,textX:e,textY:s+$i.height/2,ptrPath:c}}function Gd(e){if(Number.isInteger(e))return String(e);const t=Math.round(e*100)/100;return String(Number.isFinite(t)&&(t!==0||e===0)?t:e)}function NI(e){const t=e.reduce((n,i)=>n+i.value,0);if(!Number.isFinite(t))throw new Error("Pie total exceeds the finite numeric range; rescale the values");if(e.some(n=>n.value>0&&n.value/t===0))throw new Error("Pie slice share underflows the finite numeric range; rescale the values");return t}var Q0={textPosition:.75,donutHole:0,legendPosition:"right",paletteOverrides:[]};var sX=["top","bottom","left","right","center"];function uh(e){if(typeof e==="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e==="string"){const t=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(?:px)?$/.exec(e.trim());if(t){const n=Number.parseFloat(t[1]);if(Number.isFinite(n)&&n>0)return n}}return void 0}function Z0(e={}){const t=Sn(e,["pie"])??{};const n=Sn(e,["themeVariables"])??{};const i={...Q0,paletteOverrides:[]};const r=t.textPosition;if(typeof r==="number"&&Number.isFinite(r)&&r>=0&&r<=1){i.textPosition=r}const o=t.donutHole;if(typeof o==="number"&&Number.isFinite(o)&&o>0&&o<=.9){i.donutHole=o}const s=t.legendPosition;if(typeof s==="string"&&sX.includes(s)){i.legendPosition=s;i.legendPositionExplicit=true}if(typeof t.highlightSlice==="string"&&t.highlightSlice.trim()){i.highlightSlice=t.highlightSlice.trim()}for(let b=0;b<12;b++){const S=Zn(n[`pie${b+1}`]);if(S!==void 0)i.paletteOverrides[b]=S}i.paletteOverrides=Array.from(i.paletteOverrides,b=>b??null);const a=Zn(n.pieStrokeColor);if(a!==void 0)i.strokeColor=a;const l=uh(n.pieStrokeWidth);if(l!==void 0)i.strokeWidth=l;const c=uh(n.pieOuterStrokeWidth);if(c!==void 0)i.outerStrokeWidth=c;const d=Zn(n.pieOuterStrokeColor);if(d!==void 0)i.outerStrokeColor=d;const u=n.pieOpacity;if(typeof u==="number"&&Number.isFinite(u)&&u>=0&&u<=1){i.opacity=u}const f=uh(n.pieSectionTextSize);if(f!==void 0)i.sectionTextSize=f;const h=Zn(n.pieSectionTextColor);if(h!==void 0)i.sectionTextColor=h;const m=uh(n.pieTitleTextSize);if(m!==void 0)i.titleTextSize=m;const p=Zn(n.pieTitleTextColor);if(p!==void 0)i.titleTextColor=p;const g=uh(n.pieLegendTextSize);if(g!==void 0)i.legendTextSize=g;const y=Zn(n.pieLegendTextColor);if(y!==void 0)i.legendTextColor=y;return i}function Hd(e,t){let n=t.top??0,i=0,r=0;const o=e.map(l=>{const c=Math.max(t.minRowHeight??0,l.block.height);const d={item:l,top:n,height:c,textY:n+(t.align==="start"?l.block.height:c)/2};i=Math.max(i,l.block.width,l.reservedWidth??0);r+=c;n+=c+t.gap;return d});const s=Math.max(0,e.length-(t.trailingGap?0:1));const a=n-(e.length&&!t.trailingGap?t.gap:0);return{width:i,height:r+s*t.gap,bottom:a,rows:o}}function jd(e,t){const n=Hd(e,t);const i={width:t.leadingWidth+n.width,height:n.height,columns:1,rows:n.rows};if(t.maxWidth===void 0||e.length<4)return i;const r=[0,0];for(const[c,d]of e.entries()){if(d.block.lines.length!==1)return i;const u=c%2;r[u]=Math.max(r[u],t.leadingWidth+d.block.width,t.leadingWidth+(d.reservedWidth??0))}const o=r[0]+t.columnGap+r[1];if(o>t.maxWidth+.01)return i;const s=[];let a=t.top??0,l=0;for(let c=0;c<e.length;c+=2){const d=e.slice(c,c+2);const u=Math.max(t.minRowHeight??0,...d.map(f=>f.block.height));for(const[f,h]of d.entries())s.push({item:h,x:f?r[0]+t.columnGap:0,top:a,height:u,textY:a+u/2});l+=u;a+=u+t.gap}l+=(Math.ceil(e.length/2)-1)*t.gap;return l<n.height?{width:o,height:l,columns:2,rows:s}:i}function my(e,t,n){let i=e,r=e,o=1;if(e.width>t+.01){for(const s of[1,2]){const a=n(s,r);if(!a)break;o++;r=a;if(a.width<i.width)i=a;if(a.width<=t+.01){i=a;break}}}return Object.assign(i,{widthFit:{maxWidth:t,width:i.width,attempts:o,status:i.width<=t+.01?"fitted":"exceeded"}})}var dt={paddingX:24,paddingY:24,titleFontSize:18,titleFontWeight:600,titleGap:20,radius:95,circleToLegendGap:32,circleToLegendStackGap:24,legendFontSize:13,legendFontWeight:500,sliceStrokeWidth:1.5,legendLineHeight:13*1.3,legendSwatch:14,legendRowGap:8,legendColumnGap:16,legendSwatchToText:8,legendHighlightWidthScale:1.1,sliceLabelFontSize:12,sliceLabelFontWeight:500,sliceLabelFitPad:4};var _I=dt.sliceLabelFontWeight;var fh=700;var eM={nodeLabelFontSize:dt.legendFontSize,edgeLabelFontSize:dt.legendFontSize,groupHeaderFontSize:dt.titleFontSize,nodeLabelFontWeight:dt.legendFontWeight,edgeLabelFontWeight:dt.legendFontWeight,groupHeaderFontWeight:dt.titleFontWeight,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:dt.sliceStrokeWidth,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:et.outerBox};function gy(e){return Gd(e)}function dc(e){if(!(e>0))return"0.0%";const t=Math.max(.1,Math.round(e*1e3)/10);return`${t.toFixed(1)}%`}function aX(e){return`${(e*100).toFixed(0)}%`}function lX(e,t,n,i,r,o=0){const s=r-i;const a=o>0?Math.min(o,n):0;if(s>=Math.PI*2-1e-9){const h=ut(e);const m=ut(t-n);const p=ut(t+n);const g=`M ${h} ${m} A ${ut(n)} ${ut(n)} 0 1 1 ${h} ${p} A ${ut(n)} ${ut(n)} 0 1 1 ${h} ${m} Z`;if(a<=0)return g;const y=ut(t-a);const b=ut(t+a);const S=`M ${h} ${y} A ${ut(a)} ${ut(a)} 0 1 0 ${h} ${b} A ${ut(a)} ${ut(a)} 0 1 0 ${h} ${y} Z`;return`${g} ${S}`}const l=py(e,t,n,i);const c=py(e,t,n,r);const d=s>Math.PI?1:0;if(a<=0){return`M ${ut(e)} ${ut(t)} L ${ut(l.x)} ${ut(l.y)} A ${ut(n)} ${ut(n)} 0 ${d} 1 ${ut(c.x)} ${ut(c.y)} Z`}const u=py(e,t,a,i);const f=py(e,t,a,r);return`M ${ut(l.x)} ${ut(l.y)} A ${ut(n)} ${ut(n)} 0 ${d} 1 ${ut(c.x)} ${ut(c.y)} L ${ut(f.x)} ${ut(f.y)} A ${ut(a)} ${ut(a)} 0 ${d} 0 ${ut(u.x)} ${ut(u.y)} Z`}function py(e,t,n,i){return{x:e+n*Math.sin(i),y:t-n*Math.cos(i)}}function ut(e){return Math.round(e*100)/100}function DI(e,t={},n=Q0,i){const r=$I(e,t,n,i);const o=t.pie?.maxWidth;if(o===void 0)return r;return my(r,o,s=>{if(s!==1)return void 0;const a=n.legendPositionExplicit||n.legendPosition!=="right"?n.legendPosition:"bottom";return $I(e,t,{...n,legendPosition:a},i,o)})}function $I(e,t,n,i,r){const o=Xe(t,eM,i);const s=NI(e.entries);const a=dt.radius;const l=a*2;const c=n.donutHole>0?ut(n.donutHole*a):0;const d=r===void 0?void 0:Math.max(r,l+dt.paddingX*2);const u=dt.paddingX*2+dt.legendSwatch+dt.legendSwatchToText+(n.legendPosition==="left"||n.legendPosition==="right"?l+dt.circleToLegendGap:0);const f=d===void 0||d<=u?void 0:d-u;const h=n.titleTextSize??o.groupHeaderFontSize;const m=n.legendTextSize??o.nodeLabelFontSize;const p=m*1.3;let g=e.title?_e(e.displayTitle??e.title,{display:e.displayTitle===void 0?"formatted":"literal",transform:o.groupTextTransform,fontSize:h,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,safeFont:true,...d===void 0?{}:{maxWidth:d-dt.paddingX*2}}):void 0;if(g&&d!==void 0&&g.width>d-dt.paddingX*2+.01){g=_e(g.prepared,g)}const y=g?.text;const b=g?g.height:0;const S=g?b+dt.titleGap:0;const x=g?.width??0;const k=n.highlightSlice==="hover"?void 0:n.highlightSlice;const w=e.entries.map(B=>{const Y=s>0?B.value/s:0;const W=e.showData?` [${gy(B.value)}]`:"";const O=`${W} (${dc(Y)})`;const N=(B.displayLabel??B.label).split("\n");const H=k===B.label?fh:o.nodeLabelFontWeight;const j=N.map((te,J)=>J===N.length-1?`${te}${O}`:te).join("\n");const q=H===fh?dt.legendHighlightWidthScale:1;const X=n.legendPosition==="center"?void 0:f===void 0?void 0:f/q;let V=_e(j,{display:B.displayLabel===void 0?"formatted":"literal",transform:o.nodeTextTransform,fontSize:m,fontWeight:H,letterSpacing:o.nodeLetterSpacing,safeFont:true,...X===void 0?{}:{maxWidth:X}});if(X!==void 0&&V.width>X+.01)V=_e(V.prepared,V);const ee=V.lines;const re=V.width;const U=H===fh?re*dt.legendHighlightWidthScale:re;return{block:V,lines:ee,fraction:Y,textWidth:U,reservedWidth:U}});const C={gap:dt.legendRowGap,minRowHeight:dt.legendSwatch,leadingWidth:dt.legendSwatch+dt.legendSwatchToText,columnGap:dt.legendColumnGap,...d!==void 0&&(n.legendPosition==="top"||n.legendPosition==="bottom")?{maxWidth:d-dt.paddingX*2}:{}};const R=jd(w,C);const M=R.width;const P=R.height;const E=dt.paddingY+S;const v=n.legendPosition;let L;let T;let A;let $;let _;let z;if(v==="left"||v==="right"){const B=Math.max(l,P);T=E+B/2;$=E+(B-P)/2;if(v==="right"){L=dt.paddingX+a;A=dt.paddingX+l+dt.circleToLegendGap;_=A+M+dt.paddingX}else{A=dt.paddingX;L=dt.paddingX+M+dt.circleToLegendGap+a;_=L+a+dt.paddingX}_=Math.max(_,x+2*dt.paddingX);z=E+B+dt.paddingY}else{const B=Math.max(l,M);_=Math.max(dt.paddingX*2+B,x+2*dt.paddingX);const Y=(_-B)/2;L=Y+B/2;A=L-M/2;if(v==="top"){$=E;T=E+P+dt.circleToLegendStackGap+a;z=T+a+dt.paddingY}else if(v==="bottom"){T=E+a;$=E+l+dt.circleToLegendStackGap;z=$+P+dt.paddingY}else{const W=Math.max(l,P);T=E+W/2;$=T-P/2;z=E+W+dt.paddingY}}const F=[];let G=0;e.entries.forEach(B=>{const Y=s>0?B.value/s:0;const W=G;const O=s>0?G+Y*Math.PI*2:G;G=O;F.push({label:B.label,...B.displayLabel===void 0?{}:{displayLabel:B.displayLabel},value:B.value,fraction:Y,startAngle:W,endAngle:O,path:lX(L,T,a,W,O,c)})});for(const B of F){const Y=(B.startAngle+B.endAngle)/2;const W=a*n.textPosition;const O=`${(B.displayLabel??B.label).replace(/\n/g," ")}: ${gy(B.value)} (${dc(B.fraction)})`;B.tooltip=Ua(ut(ut(L)+W*Math.sin(Y)),ut(ut(T)-W*Math.cos(Y)),O)}cX(F,L,T,a,n);for(const B of F)if(B.pctLabel)B.pctLabel.block=_e(B.pctLabel.text,{display:"literal",fontSize:B.pctLabel.fontSize,fontWeight:dt.sliceLabelFontWeight});const I=jd(w,{...C,top:$});const D=I.rows.map(({item:B,x:Y=0,top:W,textY:O},N)=>{const H=e.entries[N];const j={label:H.label,...H.displayLabel===void 0?{}:{literalText:true},value:H.value,fraction:B.fraction,x:ut(A+Y),y:ut(W),swatchSize:dt.legendSwatch,textX:ut(A+Y+dt.legendSwatch+dt.legendSwatchToText),textY:ut(O),lines:B.lines,block:B.block,textWidth:ut(B.textWidth)};return j});return{width:ut(_),height:ut(z),title:e.title?{text:y,block:g,x:ut(_/2),y:dt.paddingY+b/2,...e.displayTitle===void 0?{}:{literalText:true}}:void 0,cx:ut(L),cy:ut(T),radius:a,innerRadius:c,slices:F,legend:D,showData:e.showData,total:s,visual:n}}function cX(e,t,n,i,r){const o=i*r.textPosition;const s=r.sectionTextSize??dt.sliceLabelFontSize;const a=s*1.1;const l=[];for(let d=0;d<e.length;d++){const u=e[d];if(u.fraction<.01)continue;const f=aX(u.fraction);if(f==="0%")continue;const h=u.endAngle-u.startAngle;if(!(h>0))continue;const m=xu(f,s,dt.sliceLabelFontWeight);const p=2*o*Math.sin(Math.min(h,Math.PI)/2);if(m+dt.sliceLabelFitPad>p)continue;const g=(u.startAngle+u.endAngle)/2;l.push({index:d,fraction:u.fraction,halfWidth:m/2,label:{text:f,x:ut(t+o*Math.sin(g)),y:ut(n-o*Math.cos(g)),fontSize:s}})}l.sort((d,u)=>u.fraction-d.fraction||d.index-u.index);const c=[];for(const d of l){const u={x0:d.label.x-d.halfWidth,y0:d.label.y-a/2,x1:d.label.x+d.halfWidth,y1:d.label.y+a/2};const f=c.some(h=>Math.min(u.x1,h.x1)-Math.max(u.x0,h.x0)>1&&Math.min(u.y1,h.y1)-Math.max(u.y0,h.y0)>1);if(f)continue;c.push(u);e[d.index].pctLabel=d.label}}function OI({positioned:e,options:t}){const n=e.legend.map((r,o)=>{const s=`${r.label} (${dc(r.fraction)})`;const a=Math.max(r.swatchSize,r.textX-r.x+r.textWidth);return{id:`slice#${o}:${r.label}`,x:ye(r.x),y:ye(r.y),w:ye(a),h:ye(r.swatchSize),shape:"rectangle",label:s,...St(r.block,r.textX,r.textY,Xt(e),"start")}});const i={version:1,nodes:n,edges:[],groups:[],bounds:{w:ye(e.width),h:ye(e.height)}};if(t.debug)i.certificates=Zo("pie",i,"legend-contained");return i}function BI({positioned:e,options:t}){const n=e.points.map((o,s)=>({id:`point#${s}:${o.label}`,x:ye(o.cx-o.radius),y:ye(o.cy-o.radius),w:ye(o.radius*2),h:ye(o.radius*2),shape:"circle",label:o.label,role:"labelled-mark",labelVisibility:o.labelHidden?"hidden":"visible",labelBounds:o.labelBox?{x:rt(o.labelBox.x0),y:rt(o.labelBox.y0),w:rt(o.labelBox.x1-o.labelBox.x0),h:rt(o.labelBox.y1-o.labelBox.y0)}:void 0,labelContainer:ln(Xt(e)),dataPosition:{x:rt(o.nx),y:rt(o.ny)}}));const i=e.regions.map(o=>({id:`quadrant#${o.number}`,x:ye(o.x),y:ye(o.y),w:ye(o.width),h:ye(o.height),members:e.points.map((s,a)=>({point:s,index:a})).filter(({point:s})=>o.number===(s.nx>=.5?s.ny>=.5?1:4:s.ny>=.5?2:3)).map(({point:s,index:a})=>`point#${a}:${s.label}`),label:o.label}));const r={version:1,nodes:n,edges:[],groups:i,bounds:{w:ye(e.width),h:ye(e.height)}};if(t.debug)r.certificates=Zo("quadrant",r,"plot-contained");return r}function WI({positioned:e}){const t=[];const n=e.rings.map((o,s)=>({id:`ring:${s}`,x:ye(e.cx-o.r),y:ye(e.cy-o.r),w:ye(o.r*2),h:ye(o.r*2),members:[]}));e.axes.forEach((o,s)=>{const a=Math.max(8,o.block?.width??o.labelWidth);const l=o.block?.height??0;const c=o.anchor==="start"?o.labelX:o.anchor==="end"?o.labelX-a:o.labelX-a/2;t.push({id:`axis#${s}:${o.id}`,x:ye(c),y:ye(o.labelY-l/2),w:ye(a),h:ye(l),shape:"rectangle",label:o.label,role:"labelled-mark",...St(o.block,o.labelX,o.labelY,Xt(e),o.anchor)})});e.tickLabels.forEach((o,s)=>{const a=o.block?.width??o.w;const l=o.block?.height??o.h;t.push({id:`tick:${s}`,x:ye(o.x-a/2),y:ye(o.y-l/2),w:ye(a),h:ye(l),shape:"rectangle",label:o.text,role:"labelled-mark",...St(o.block,o.x,o.y,Xt(e))})});const i=new Map;for(const o of e.curves)i.set(o.id,(i.get(o.id)??0)+1);const r=new Map;e.curves.forEach(o=>{const s=r.get(o.id)??0;r.set(o.id,s+1);const a=(i.get(o.id)??0)>1?`${o.id}#${s}`:o.id;o.vertices.forEach((l,c)=>{t.push({id:`dot:${a}:${c}`,x:ye(l.x-3),y:ye(l.y-3),w:ye(6),h:ye(6),shape:"circle",role:"mark"})})});for(const[o,s]of e.legend.entries()){t.push({id:`legend-swatch#${o}`,x:ye(s.x),y:ye(s.y),w:ye(s.swatchSize),h:ye(s.swatchSize),shape:"rectangle",role:"mark"});const a=Math.max(8,s.block?.width??0);const l=s.block?.height??0;t.push({id:`legend-label#${o}`,x:ye(s.textX),y:ye(s.textY-l/2),w:ye(a),h:ye(l),shape:"rectangle",label:s.lines.join(" "),role:"labelled-mark",...St(s.block,s.textX,s.textY,Xt(e),"start")})}if(e.title){const o=e.title.block?.width??0;const s=e.title.block?.height??0;t.push({id:"title",x:ye(e.title.x-o/2),y:ye(e.title.y-s/2),w:ye(o),h:ye(s),shape:"rectangle",label:e.title.text,role:"labelled-mark",...St(e.title.block,e.title.x,e.title.y,Xt(e))})}return{version:1,nodes:t,edges:[],groups:n,bounds:{w:ye(e.width),h:ye(e.height)}}}function zI({positioned:e}){const t=e.nodes.map(i=>({id:i.label,x:ye(i.x0),y:ye(i.y0),w:zt(i.x0,i.x1-i.x0),h:zt(i.y0,i.y1-i.y0),shape:"rectangle",label:i.label,role:"labelled-mark",...St(i.labelBlock,i.labelX,i.labelY,Xt(e),i.labelAnchor)}));const n=e.links.map(i=>({id:i.id,from:i.source,to:i.target,path:i.points.map(r=>[ye(r.x),ye(r.y)])}));if(e.title){const i=e.title.block?.width??0;const r=e.title.block?.height??0;t.push({id:e.title.id,x:ye(e.title.x-i/2),y:ye(e.title.y-r/2),w:ye(i),h:ye(r),shape:"rectangle",label:e.title.text,role:"labelled-mark",...St(e.title.block,e.title.x,e.title.y,Xt(e))})}return{version:1,nodes:t,edges:n,groups:[],bounds:{w:ye(e.width),h:ye(e.height)}}}function GI({positioned:e,options:t}){const n=[];const i=[];for(const o of e.sections){const s=[];for(const a of o.periods){const l=`${a.id}:period`;n.push({id:l,x:ye(a.pillX),y:ye(a.pillY),w:ye(a.pillWidth),h:ye(a.pillHeight),shape:"rounded",label:a.label,...St(a.block,a.centerX,a.pillY+a.pillHeight/2,{x:a.pillX,y:a.pillY,width:a.pillWidth,height:a.pillHeight})});s.push(l);for(const c of a.events){n.push({id:c.id,x:ye(c.x),y:ye(c.y),w:ye(c.width),h:ye(c.height),shape:"rectangle",label:c.text,...c.labelX===void 0?{}:St(c.block,c.labelX,c.y+c.height/2,c,"start")});s.push(c.id)}}if(o.framed){i.push({id:o.id,x:ye(o.x),y:ye(o.y),w:ye(o.width),h:ye(o.height),members:s,label:o.label})}}const r={version:1,nodes:n,edges:[],groups:i,bounds:{w:ye(e.width),h:ye(e.height)}};if(t.debug)r.certificates=Zo("timeline",r,"timeline-interval");return r}var Wr={showLabel:true,labelFontSize:14,labelPadding:5,showTitle:true,titleFontSize:16,titlePadding:5,showTick:true,tickLength:5,tickWidth:2,showAxisLine:true,axisLineWidth:2};var Br={width:700,height:500,useMaxWidth:true,useWidth:void 0,titleFontSize:20,titlePadding:10,chartOrientation:"vertical",plotReservedSpacePercent:50,showDataLabel:false,showDataLabelOutsideBar:false,showTitle:true,showLegend:true,legendFontSize:14,legendPadding:5,xAxis:{...Wr},yAxis:{...Wr}};function HI(e){return{showLabel:Js(e?.showLabel,Wr.showLabel),labelFontSize:Va(e?.labelFontSize,Wr.labelFontSize),labelPadding:hh(e?.labelPadding,Wr.labelPadding),showTitle:Js(e?.showTitle,Wr.showTitle),titleFontSize:Va(e?.titleFontSize,Wr.titleFontSize),titlePadding:hh(e?.titlePadding,Wr.titlePadding),showTick:Js(e?.showTick,Wr.showTick),tickLength:hh(e?.tickLength,Wr.tickLength),tickWidth:Va(e?.tickWidth,Wr.tickWidth),showAxisLine:Js(e?.showAxisLine,Wr.showAxisLine),axisLineWidth:Va(e?.axisLineWidth,Wr.axisLineWidth)}}function jI(e){return{width:Va(e.width,Br.width),height:Va(e.height,Br.height),useMaxWidth:Js(e.useMaxWidth,Br.useMaxWidth),useWidth:dX(e.useWidth),titleFontSize:Va(e.titleFontSize,Br.titleFontSize),titlePadding:hh(e.titlePadding,Br.titlePadding),chartOrientation:e.chartOrientation==="vertical"||e.chartOrientation==="horizontal"?e.chartOrientation:Br.chartOrientation,plotReservedSpacePercent:uX(e.plotReservedSpacePercent,Br.plotReservedSpacePercent,10,100),showDataLabel:Js(e.showDataLabel,Br.showDataLabel),showDataLabelOutsideBar:Js(e.showDataLabelOutsideBar,Br.showDataLabelOutsideBar),showTitle:Js(e.showTitle,Br.showTitle),showLegend:Js(e.showLegend,Br.showLegend),legendFontSize:Va(e.legendFontSize,Br.legendFontSize),legendPadding:hh(e.legendPadding,Br.legendPadding),xAxis:HI(e.xAxis),yAxis:HI(e.yAxis)}}function Va(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:t}function hh(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>=0?e:t}function dX(e){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:void 0}function uX(e,t,n,i){return typeof e==="number"&&Number.isFinite(e)&&e>0&&e<=i?Math.max(n,e):t}function Js(e,t){return typeof e==="boolean"?e:t}function fX(e){return e.length>1||e.some(t=>t.label!==void 0&&t.label.length>0)}function YI(e){if(!fX(e))return[];const t=[];let n=0;let i=0;for(let r=0;r<e.length;r++){const o=e[r];const s=o.type==="bar"?n++:i++;const a=o.type==="bar"?`Bar ${s+1}`:`Line ${s+1}`;t.push({label:o.label!==void 0&&o.label.length>0?o.label:a,type:o.type,seriesIndex:s,colorIndex:r})}return t}var hX=.05;var mX=.6;var by=4;var uo=12;var mh=6;var tM={nodeLabelFontSize:14,edgeLabelFontSize:16,groupHeaderFontSize:20,nodeLabelFontWeight:400,edgeLabelFontWeight:400,groupHeaderFontWeight:500,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:0,edgeLineWidth:3,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:et.outerBox};function pX(e){const t=new Map;const n=(i,r,o,s)=>{const a=JSON.stringify([i,r,o,s]);let l=t.get(a);if(!l){const c=i==="axisTitle";l=_e(r,{display:"literal",fontSize:o,fontWeight:c?e.edgeLabelFontWeight:e.nodeLabelFontWeight,letterSpacing:c?e.edgeLetterSpacing:e.nodeLetterSpacing,transform:i==="axisTitle"||i==="tick"?e.edgeTextTransform:e.nodeTextTransform,maxWidth:s});t.set(a,l)}return l};return{block:n,wrapTitle:(i,r,o)=>_e(i,{display:"literal",transform:e.groupTextTransform,fontSize:r,fontWeight:e.groupHeaderFontWeight,letterSpacing:e.groupLetterSpacing,maxWidth:o}),tick:(i,r)=>n("tick",i,r).width,legend:(i,r)=>n("legend",i,r).width}}function UI(e,t={},n){const i=Xe(t,tM,n);const r=jI(e.config);const o=n;if(o?.group?.fontSize!=null||o?.text?.fontSize!=null){r.titleFontSize=i.groupHeaderFontSize}if(o?.node?.fontSize!=null||o?.text?.fontSize!=null){r.xAxis.labelFontSize=i.nodeLabelFontSize;r.yAxis.labelFontSize=i.nodeLabelFontSize}if(o?.edge?.fontSize!=null||o?.text?.fontSize!=null){r.xAxis.titleFontSize=i.edgeLabelFontSize;r.yAxis.titleFontSize=i.edgeLabelFontSize}if(o?.edge?.lineWidth!=null){r.xAxis.axisLineWidth=i.lineWidth;r.yAxis.axisLineWidth=i.lineWidth;r.xAxis.tickWidth=i.lineWidth;r.yAxis.tickWidth=i.lineWidth}const s=pX(i);let a=0;const l=Math.max(0,...e.series.flatMap(d=>{if(d.type!=="line")return[];const u=st(n,"series",{category:`line-${a++}`},{includeFallback:false})?.lineWidth??i.lineWidth;const f=t.interactive||d.pointLabels?.some(h=>h!==void 0);return[Math.max(u/2,f?by+1:0)]}));const c=e.horizontal?xX(e,r,s,l):yX(e,r,s,l);for(const d of[c.xAxis,c.yAxis]){if(d.title){const u=d.title.block??=s.block("axisTitle",d.title.text,d.config.titleFontSize);const f=(u.lines.length-1)*u.lineHeight/2+(u.lineHeight-d.config.titleFontSize*fi)/2;if(d.title.rotate)d.title.x+=f;else d.title.y+=e.horizontal?f:-f}for(const u of d.ticks){const f=u.block=s.block("tick",u.label,d.config.labelFontSize);const h=u.textAnchor==="start"?0:u.textAnchor==="end"?f.width:f.width/2;u.labelX=Math.max(h,Math.min(c.width-f.width+h,u.labelX));u.labelY=Math.max(f.height/2,Math.min(c.height-f.height/2,u.labelY))}}for(const d of c.legend)d.block=s.block("legend",d.label,c.config.legendFontSize);for(const d of c.dataLabels)d.block=s.block("data",d.text,d.fontSize);for(const d of c.lines)for(const u of d.points){if(u.textLabel!==void 0){const f=u.textBlock=s.block("data",u.textLabel,12,Math.max(1,c.width-8));const h=(m,p,g)=>Math.max(p,Math.min(g,m));if(c.horizontal){const m=u.x+8+f.width<=c.width-4;const p=m?"start":"end";u.textPosition={x:m?h(u.x+8,4,c.width-4-f.width):h(u.x-8,f.width+4,c.width-4),y:h(u.y,f.height/2,c.height-f.height/2),anchor:p,placement:m?"right":"left"}}else{const m=u.y-8-f.height>=c.plotArea.y;u.textPosition={x:h(u.x,f.width/2,c.width-f.width/2),y:h(u.y+(m?-1:1)*(8+f.height/2),f.height/2,c.height-f.height/2),anchor:"middle",placement:m?"above":"below"}}}}{for(const d of c.bars)d.tooltip=Ua(c.horizontal?d.x+d.width:d.x+d.width/2,c.horizontal?d.y+d.height/2:d.y,Zl(d.value));for(const d of c.lines)for(const u of d.points)u.tooltip=Ua(u.x,u.y-by,Zl(u.value))}return c}var gX=1;function VI(e,t,n,i){const r=e.series.some(s=>s.type==="line")?t:0;const o=s=>s.showLabel&&s.showTick?s.tickWidth/2:0;return{value:Math.max(gX/2,o(n),r),position:i?Math.max(o(i),r):0}}function Sy(e){return e.showAxisLine?e.axisLineWidth/2:0}function yX(e,t,n,i){const r=t.width;const o=t.height;const s=Bf(e);const a=Wg(e,s);const l=w0(e,s);const c=e.yAxis.range;const d=Gg(c.min,c.max);const u=d.map(Wf);const f=e.xAxis.range?Gg(e.xAxis.range.min,e.xAxis.range.max):void 0;const h=f?.map(Wf)??a;let m=Math.max(0,o-Math.floor(o*t.plotReservedSpacePercent/100));let p=Math.max(0,r-Math.floor(r*t.plotReservedSpacePercent/100));const g=JI(e.title,t,m,n);const y=g.height;m=Math.max(0,m-y);const b=ZI(t.xAxis,e.xAxis.title,h,m,n);m=Math.max(0,m-b.size);const S=eF(t.yAxis,e.yAxis.title,u,p,n,o);p=Math.max(0,p-S.size);const x=S.config.showLabel&&u.length>0?t.yAxis.labelFontSize/2:0;const k=VI(e,i,S.config,e.xAxis.range?b.config:void 0);const w=Math.max(y,x,k.value);const C=Math.max(0,o-w-Math.max(b.size,x,k.value,Sy(b.config)));const R=KI(e,t,p,r,w,C,n);const M=Math.max(S.size,k.position,Sy(S.config));const P={x:M,y:w,width:Math.max(0,r-M-Math.max(R.size,k.position)),height:C};const E=e.xAxis.range&&e.series.some(D=>D.type==="bar")?P.width/Math.max(1,s)/2:0;const v=e.xAxis.range?D=>P.x+E+(D-e.xAxis.range.min)/(e.xAxis.range.max-e.xAxis.range.min||1)*(P.width-2*E):void 0;const L=D=>v?v(l[D]):P.x+(D+.5)*(P.width/s);const T=v?V2(l,v,P.width/Math.max(2,s)):P.width/Math.max(1,s);const A=D=>P.y+P.height-(D-c.min)/(c.max-c.min||1)*P.height;const $=!b.config.showLabel?[]:e.xAxis.range&&f&&v?qI(f,h,v,P,b.config,n,r):qI(a.map((D,B)=>B),a,L,P,b.config,n,r);const _=S.config.showLabel?tF(d,u,A,P,S.config):[];const z=d.map(D=>({x1:P.x,y1:A(D),x2:P.x+P.width,y2:A(D)}));const F=e.series.map((D,B)=>B);const G=sF(e,L,T,A,c,a,F,false);const I=aF(e,L,A,c,a,F,false);return{width:r,height:o,accessibility:e.accessibility,title:g.title,hiddenTitle:e.title&&t.showTitle&&!g.title?e.title:void 0,xAxis:{ticks:$,line:wX(P,b.config),title:kX(e.xAxis.title,P,o,b.config),config:b.config},yAxis:{ticks:_,line:nF(P,S.config),title:iF(e.yAxis.title,P,S.config,o,n),config:S.config},plotArea:P,bars:G,lines:I,gridLines:z,legend:R.items,hiddenLegendLabels:R.hiddenLabels,hiddenCategoryLabels:rF(e,t,b.config,$),...oF(G,false,P,t,n),config:t,theme:e.theme}}function xX(e,t,n,i){const r=t.width;const o=t.height;const s=Bf(e);const a=Wg(e,s);const l=e.yAxis.range;const c=Gg(l.min,l.max);const d=c.map(Wf);let u=Math.max(0,o-Math.floor(o*t.plotReservedSpacePercent/100));let f=Math.max(0,r-Math.floor(r*t.plotReservedSpacePercent/100));const h=JI(e.title,t,u,n);const m=h.height;u=Math.max(0,u-m);const p=bX(t.yAxis,e.yAxis.title,d,u,n);u=Math.max(0,u-p.size);const g=eF(t.xAxis,e.xAxis.title,a,f,n,o);f=Math.max(0,f-g.size);const y=VI(e,i,p.config);const b=Math.max(m+p.size,Sy(p.config));const S=Math.max(0,o-b);const x=Math.max(1,s);const k=g.config.showLabel?t.xAxis.labelFontSize*PX:0;const w=Math.min(S,Math.max(0,(k-S/(2*x))/(1-1/(2*x))));const C=Math.max(0,S-w);const R=KI(e,t,f,r,b,C,n);const M=p.config.showLabel&&d.length>0?Math.max(...[d[0],d[d.length-1]].map(D=>n.tick(D,t.yAxis.labelFontSize)/2)):0;const P=Math.max(0,Math.max(M,y.value,Sy(g.config))-g.size);const E=Math.max(0,M-R.size,y.value-R.size);const v={x:g.size+P,y:b,width:Math.max(0,r-g.size-P-R.size-E),height:C};const L=D=>v.x+(D-l.min)/(l.max-l.min||1)*v.width;const T=D=>v.y+(D+.5)*(v.height/s);const A=v.height/Math.max(1,s);const $=p.config.showLabel?SX(c,d,L,v,p.config):[];const _=g.config.showLabel?tF(a.map((D,B)=>B),a,T,v,g.config):[];const z=c.map(D=>({x1:L(D),y1:v.y,x2:L(D),y2:v.y+v.height}));const F=e.series.map((D,B)=>B);const G=sF(e,T,A,L,l,a,F,true);const I=aF(e,T,L,l,a,F,true);return{width:r,height:o,accessibility:e.accessibility,horizontal:true,title:h.title,hiddenTitle:e.title&&t.showTitle&&!h.title?e.title:void 0,xAxis:{ticks:_,line:nF(v,g.config),title:iF(e.xAxis.title,v,g.config,o,n),config:g.config},yAxis:{ticks:$,line:MX(v,p.config),title:CX(e.yAxis.title,v,m,p.config),config:p.config},plotArea:v,bars:G,lines:I,gridLines:z,legend:R.items,hiddenLegendLabels:R.hiddenLabels,hiddenCategoryLabels:rF(e,t,g.config,_),...oF(G,true,v,t,n),config:t,theme:e.theme}}function KI(e,t,n,i,r,o,s){if(!t.showLegend)return{items:[],size:0,hiddenLabels:[]};const a=YI(e.series);if(a.length===0)return{items:[],size:0,hiddenLabels:[]};const l=Math.ceil(Math.max(...a.map(m=>s.legend(m.label,t.legendFontSize))));const c=t.legendPadding*2+uo+mh+l;const d=Math.max(...a.map(m=>s.block("legend",m.label,t.legendFontSize).height),uo)+t.legendPadding;const u=t.legendPadding+a.length*d;if(c>n||u>o)return{items:[],size:0,hiddenLabels:a.map(m=>m.label)};const f=i-c+t.legendPadding;const h=a.map((m,p)=>({label:m.label,x:f,y:r+t.legendPadding+p*d,type:m.type,seriesIndex:m.seriesIndex,colorIndex:m.colorIndex}));return{items:h,size:c,hiddenLabels:[]}}function JI(e,t,n,i){if(!e||!t.showTitle)return{height:0};const r=i.wrapTitle(e,t.titleFontSize,Math.max(1,t.width-t.titlePadding*2));const o=r.height-r.lineHeight;const s=r.height+t.titlePadding*2;if(s>n)return{height:0};return{height:s,title:{text:r.text,block:r,x:t.width/2,y:t.titlePadding+r.height/2}}}function QI(e,t,n,i,r,o=e.titleFontSize){let s=i;const a={...e,showAxisLine:false,showLabel:false,showTick:false,showTitle:false};if(e.showAxisLine&&s>e.axisLineWidth){a.showAxisLine=true;s-=e.axisLineWidth}if(e.showLabel&&n.length>0){const l=r()+e.labelPadding*2;if(l<=s){a.showLabel=true;s-=l}}if(e.showTick&&s>=e.tickLength){a.showTick=true;s-=e.tickLength}if(e.showTitle&&t){const l=o+e.titlePadding*2;if(l<=s){a.showTitle=true;s-=l}}return{config:a,size:i-s}}function ZI(e,t,n,i,r){const o=t?r.block("axisTitle",t,e.titleFontSize).height-e.titleFontSize*(fi-1):e.titleFontSize;return QI(e,t,n,i,()=>Math.max(e.labelFontSize,...n.map(s=>r.block("tick",s,e.labelFontSize).height-e.labelFontSize*(fi-1))),o)}function bX(e,t,n,i,r){return ZI(e,t,n,i,r)}function eF(e,t,n,i,r,o){return QI(e,t,n,i,()=>Math.max(...n.map(s=>r.tick(s,e.labelFontSize))),t?r.block("axisTitle",t,e.titleFontSize,Math.max(1,o-4)).height-e.titleFontSize*(fi-1):e.titleFontSize)}function qI(e,t,n,i,r,o,s){const a=r.showAxisLine?r.axisLineWidth:0;const l=r.showTick?r.tickLength:0;const c=i.y+i.height+a+l+r.labelPadding+r.labelFontSize*(1-mX);const d=t.map(p=>o.tick(p,r.labelFontSize));const u=d.length?Math.max(...d):0;const f=e.map(p=>n(p));let h=Infinity;for(let p=1;p<f.length;p++)h=Math.min(h,Math.abs(f[p]-f[p-1]));const m=Number.isFinite(h)&&h>0?Math.max(1,Math.ceil((u+6)/h)):1;return e.map((p,g)=>{const y=g%m===0?t[g]:"";let b=n(p);if(s!==void 0&&y){const S=d[g]/2;b=Math.max(2+S,Math.min(s-2-S,b))}return{label:y,x:n(p),y:i.y+i.height+a,tx:n(p),ty:i.y+i.height+a+l,labelX:b,labelY:c,textAnchor:"middle"}})}function SX(e,t,n,i,r){const o=r.showAxisLine?r.axisLineWidth:0;const s=r.showTick?r.tickLength:0;const a=i.y-o-s-r.labelPadding;return e.map((l,c)=>({label:t[c],x:n(l),y:i.y-o,tx:n(l),ty:i.y-o-s,labelX:n(l),labelY:a,textAnchor:"middle"}))}function tF(e,t,n,i,r){const o=r.showAxisLine?r.axisLineWidth:0;const s=r.showTick?r.tickLength:0;const a=i.x-o-s-r.labelPadding;return e.map((l,c)=>({label:t[c],x:i.x-o,y:n(l),tx:i.x-o-s,ty:n(l),labelX:a,labelY:n(l),textAnchor:"end"}))}function wX(e,t){const n=e.y+e.height+(t.showAxisLine?t.axisLineWidth/2:0);return{x1:e.x,y1:n,x2:e.x+e.width,y2:n}}function MX(e,t){const n=e.y-(t.showAxisLine?t.axisLineWidth/2:0);return{x1:e.x,y1:n,x2:e.x+e.width,y2:n}}function nF(e,t){const n=e.x-(t.showAxisLine?t.axisLineWidth/2:0);return{x1:n,y1:e.y,x2:n,y2:e.y+e.height}}function kX(e,t,n,i){if(!e||!i.showTitle)return void 0;return{text:e,x:t.x+t.width/2,y:n-i.titlePadding-i.titleFontSize/2}}function CX(e,t,n,i){if(!e||!i.showTitle)return void 0;return{text:e,x:t.x+t.width/2,y:n+i.titlePadding+i.titleFontSize}}function iF(e,t,n,i,r){if(!e||!n.showTitle)return void 0;const o=r.block("axisTitle",e,n.titleFontSize,Math.max(1,i-4));const s=o.width/2;const a=t.y+t.height/2;return{text:e,block:o,x:n.titlePadding+n.titleFontSize*.8,y:2*s+4>=i?i/2:Math.min(i-2-s,Math.max(2+s,a)),rotate:-90}}function rF(e,t,n,i){const r=e.xAxis.categories;if(!r||e.xAxis.range||!t.xAxis.showLabel)return[];const o=(a,l)=>l<r.length&&a!=="";const s=Wg(e);if(!n.showLabel)return s.filter(o);return s.filter((a,l)=>o(a,l)&&i[l]?.label==="")}var PX=.6;var XI=8;var EX=16;var yy=8;var xy=4;function oF(e,t,n,i,r){if(!i.showDataLabel||e.length===0)return{dataLabels:[],unlabeledBars:[]};const o=e.map(c=>Zl(c.value));let s=EX;for(;s>=XI;s--){if(e.every((c,d)=>{const u=r.block("data",o[d],s);return t?u.height<=c.height-4:u.width<=c.width-yy}))break}if(s<XI)return{dataLabels:[],unlabeledBars:[...e]};const a=[];const l=[];e.forEach((c,d)=>{const u=o[d];const f=r.block("data",u,s);const h=f.width;const m=t?c.width-12>=h:c.height-10>=f.height;const p=x=>{const k=t?x?n.x+n.width-(c.x+c.width):c.x-n.x:x?c.y-n.y:n.y+n.height-(c.y+c.height);return k>=(t?h:f.height)+xy};const g=c.value>0||c.value===0&&(p(true)||!p(false));const y=p(g);const b=i.showDataLabelOutsideBar?y?"outside":m?"inside":void 0:m?"inside":y?"outside":void 0;if(!b){l.push(c);return}if(t){const x=b==="outside"===g;const k=g?c.x+c.width:c.x;const w=b==="outside"?xy:-yy;a.push({bar:c,text:u,fontSize:s,placement:b,x:k+(g?w:-w),y:c.y+c.height/2,anchor:x?"start":"end",dominantBaseline:"middle"});return}const S=b==="inside"?g:!g;a.push({bar:c,text:u,fontSize:s,placement:b,x:c.x+c.width/2,y:b==="inside"?g?c.y+yy:c.y+c.height-yy:g?c.y-xy:c.y+c.height+xy,anchor:"middle",...S?{dominantBaseline:"hanging"}:{}})});return{dataLabels:a,unlabeledBars:l}}function sF(e,t,n,i,r,o,s,a){const l=e.series.filter(g=>g.type==="bar");const c=l.length;if(c===0)return[];const d=n*(1-hX);const u=d/Math.max(1,c);const f=[];let h=0;let m=0;const p=i(K2(r));for(const g of e.series){if(g.type!=="bar"){m++;continue}for(let y=0;y<g.data.length;y++){const b=t(y)-d/2+h*u;const S=i(zg(r,g.data[y]));const x=Math.min(S,p);const k=Math.abs(p-S);f.push({x:a?x:b,y:a?b:x,width:a?k:u,height:a?u:k,value:g.data[y],label:o[y],seriesIndex:h,colorIndex:s[m]})}h++;m++}return f}function aF(e,t,n,i,r,o,s){const a=[];let l=0;let c=0;for(const d of e.series){if(d.type!=="line"){c++;continue}a.push({points:d.data.map((u,f)=>{const h=t(f);const m=n(zg(i,u));return{x:s?m:h,y:s?h:m,value:u,label:r[f],...d.pointLabels?.[f]!==void 0?{textLabel:d.pointLabels[f]}:{}}}),seriesIndex:l,colorIndex:o[c]});l++;c++}return a}function lF({positioned:e,options:t}){const n=[];const i=[];const r=ln(Xt(e));const o=(c,d,u,f,h,m="middle",p=0)=>{if(!d)return;let g=Yt(u,f,h,m);if(g&&p){const y=dl({x0:g.x,y0:g.y,x1:g.x+g.w,y1:g.y+g.h},{x:f,y:h},p);g=ln({x:y.x0,y:y.y0,width:y.x1-y.x0,height:y.y1-y.y0})}i.push({id:c,text:d,...g?{bounds:g}:{},container:r})};const s=new Map;e.bars.forEach(c=>{const d=s.get(c.seriesIndex)??0;s.set(c.seriesIndex,d+1);n.push({id:`bar#${c.seriesIndex}:pt#${d}`,x:ye(c.x),y:ye(c.y),w:zt(c.x,c.width),h:zt(c.y,c.height),shape:"rectangle",label:c.label,role:"labelled-mark",labelVisibility:"semantic"})});e.lines.forEach(c=>{c.points.forEach((d,u)=>{const f=e.plotArea;const h=Math.max(f.x,Math.min(f.x+f.width,d.x-3)),m=Math.max(f.y,Math.min(f.y+f.height,d.y-3));const p=Math.max(h,Math.min(f.x+f.width,d.x+3)),g=Math.max(m,Math.min(f.y+f.height,d.y+3));n.push({id:`line#${c.seriesIndex}:pt#${u}`,x:ye(h),y:ye(m),w:zt(h,p-h),h:zt(m,g-m),shape:"circle",label:d.label,role:d.label?"labelled-mark":"mark",labelVisibility:"semantic"});if(d.textLabel!==void 0){const y=d.textPosition;o(`point-label:${c.seriesIndex}:${u}`,d.textBlock?.text??d.textLabel,y?d.textBlock:void 0,y?.x??d.x,y?.y??d.y,y?.anchor??"middle")}})});if(e.title){const c=e.title;o("title",c.block?.text??c.text,c.block,c.x,c.y)}for(const[c,d]of[["x",e.xAxis],["y",e.yAxis]]){if(d.title){const u=d.title;o(`axis:${c}:title`,u.block?.text??u.text,u.block,u.x,u.y,"middle",u.rotate)}d.ticks.forEach((u,f)=>o(`axis:${c}:label:${f}`,u.block?.text??u.label,u.block,u.labelX,u.labelY,u.textAnchor))}for(const c of e.legend){o(`legend:label:${c.colorIndex}`,c.block?.text??c.label,c.block,c.x+uo+mh,c.y+Math.max(uo,c.block?.height??0)/2,"start")}e.dataLabels.forEach((c,d)=>{const u=c.dominantBaseline==="hanging"?c.y+(c.block?.height??0)/2:c.dominantBaseline==="middle"?c.y:c.y-c.fontSize*.35;o(`data-label:${d}`,c.block?.text??c.text,c.block,c.x,u,c.anchor)});const a=[{id:"plot",x:ye(e.plotArea.x),y:ye(e.plotArea.y),w:zt(e.plotArea.x,e.plotArea.width),h:zt(e.plotArea.y,e.plotArea.height),members:n.filter(c=>c.x+c.w/2>=e.plotArea.x&&c.x+c.w/2<=e.plotArea.x+e.plotArea.width&&c.y+c.h/2>=e.plotArea.y&&c.y+c.h/2<=e.plotArea.y+e.plotArea.height).map(c=>c.id)}];const l={version:1,nodes:n,edges:[],groups:a,bounds:{w:ye(e.width),h:ye(e.height)},labels:i};if(t.debug)l.certificates=Zo("xychart",l,"plot-contained",a[0],"center");return l}var pme=["bitsPerRow","bitOrder","showBits","rowHeight","bitWidth","paddingX","paddingY","useMaxWidth"];function ph(e={}){const t=Sn(e,["packet"])??{};const n=(r,o)=>typeof t[r]==="number"&&Number.isFinite(t[r])&&t[r]>0?t[r]:o;const i=r=>typeof t[r]==="number"&&Number.isFinite(t[r])&&t[r]>=0?t[r]:5;return{bitsPerRow:typeof t.bitsPerRow==="number"&&Number.isSafeInteger(t.bitsPerRow)&&t.bitsPerRow>0?t.bitsPerRow:32,bitOrder:t.bitOrder==="descending"?"descending":"ascending",showBits:t.showBits!==false,rowHeight:n("rowHeight",32),bitWidth:n("bitWidth",32),paddingX:i("paddingX"),paddingY:i("paddingY")}}var uc=dr("eventmodeling-arrow",{width:8,height:8},"end",{fill:"var(--_line)"},"userSpaceOnUse");var cF=gr([uc]);function RX(e,t){const n=typeof t==="string"?e.frames.find(a=>a.id===t):t;const i=n.id;const r=n.data??(n.dataReference?e.data[n.dataReference]:void 0);const o=e.notes.filter(a=>a.frame===i).map(a=>`Note: ${a.data.text}`);const s=e.specifications.filter(a=>a.frame===i).flatMap(a=>["given","when","then"].filter(l=>a[l].length).map(l=>`${l}: ${a[l].map(c=>`${c.type} ${c.entity}`).join(", ")}`));return[`${n.id} \xB7 ${n.type}${n.reset?" \xB7 reset":""}`,n.entity,...r?[r.text]:[],...o,...s].join("\n")}function dF(e,t={},n,i=0,r){const o=Xe(t,void 0,n),s=t.padding??24;const a=$n({stroke:o.nodeBorderColor??(r?bl(r).nodeStroke:"var(--_node-stroke)"),strokeWidth:String(o.nodeLineWidth)},false)??0;const l=v=>_e(v,{display:"literal",fontFamily:t.font,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,transform:o.nodeTextTransform,maxWidth:220});const c=v=>_e(v,{display:"literal",fontFamily:o.groupFont??t.font,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,transform:o.groupTextTransform,maxWidth:220});const d=KT(e).map(v=>({...v,block:c(v.label),x:s,y:0,width:0,height:0}));const u=new Map(d.map(v=>[v.label,v]));const f=Dw(e);const h=new Map(e.frames.map(v=>[v.id,{incoming:0,outgoing:0}]));for(const v of f){h.get(v.from).outgoing++;h.get(v.to).incoming++}const m=Math.max(12,8+o.lineWidth);const p=tn(e.title,o);const g=Math.max(140,...d.map(v=>o.groupLabelPaddingX+v.block.width+o.groupPaddingX))+a;const y=e.frames.map((v,L)=>{const T=l(RX(e,v));const A=Math.max(120,T.width+2*(o.nodePaddingX+a));const $=h.get(v.id);const _=Math.max($.incoming,$.outgoing);const z=Math.max(6+a,o.nodePaddingY+a,Math.min(o.cornerRadius??5,A/2));const F=_>1?(_-1)*m+2*z:0;return{id:v.id,frame:v,block:T,lane:u.get(wf(v)).id,x:0,y:0,width:A,height:Math.max(64,T.height+2*(o.nodePaddingY+a),F),index:L}});const b=Math.max(160,...y.map(v=>v.width));const S=Math.max(48,t.nodeSpacing??48,2*a+16);const x=Math.max(s*2+g+Math.max(1,y.length)*b+Math.max(0,y.length-1)*S+Math.max(o.groupPaddingX+a,S/2+o.lineWidth),(p?.width??0)+2*s);const k=new Map;for(const v of y){const L=k.get(v.lane)??[];L.push(v);k.set(v.lane,L)}let w=s+(p?.height??0)+S/2+Math.max(4,o.lineWidth);for(const v of d){const L=k.get(v.id)??[];v.y=w;v.height=Math.max(i,v.block.height+2*o.groupPaddingY,...L.map(T=>T.height+2*(o.groupPaddingY+a)));v.width=x-2*s;for(const T of L){T.x=s+g+T.index*(b+S);T.y=w+(v.height-T.height)/2}w+=v.height+S}const C=new Map(y.map(v=>[v.id,v]));const R=new Map(d.map(v=>[v.id,v]));const M=new Map,P=new Map;const E=f.map((v,L)=>{const T=C.get(v.from),A=C.get(v.to);const $=P.get(T.id)??0,_=M.get(A.id)??0;P.set(T.id,$+1);M.set(A.id,_+1);const z={x:T.x+T.width+a,y:T.y+T.height/2+($-(h.get(T.id).outgoing-1)/2)*m};const F={x:A.x-a,y:A.y+A.height/2+(_-(h.get(A.id).incoming-1)/2)*m};const G=T.x+b+S/2;const I=A.x-S/2;const D=R.get(T.lane).y-S/2;const B=T.lane===A.lane&&A.index===T.index+1&&z.y===F.y?[z,F]:A.index===T.index+1?[z,{x:G,y:z.y},{x:G,y:F.y},F]:[z,{x:G,y:z.y},{x:G,y:D},{x:I,y:D},{x:I,y:F.y},F];const Y=o.edgeBendRadius>0?qn(B,o.edgeBendRadius,{precision:3,terminalClearance:{end:cF(uc.id,o.lineWidth,"end")}}):void 0;return{...v,points:Y?.geometry.points??B,projection:Y,index:L}});return{style:o,laneWidth:g,width:x,height:Math.max(w+s,2*s+40),lanes:d,nodes:y,edges:E,...p?{title:rn(p,x,s)}:{}}}function wy(e){return e.replace(/#(?:quot|0*(?:34|37|96));/g,t=>t==="#quot;"?'"':String.fromCodePoint(Number(t.slice(1,-1))))}function Tme(e){return mr(e,'"%`')}var gh=class extends Error{constructor(t,n,i){super(t)}};function nM(e,t,n=0,i="",r=false){const o=t.slice(0,n),s=o.split("\n").length,a=n-o.lastIndexOf("\n");return new Error(`${e} ${r?"lexical":"parse"} error at line ${s}, column ${a}: ${i||"unrecognized input"}`)}function vX(e){switch(e){case"[]":return"square";case"()":return"round";case"(())":return"circle";case">]":return"rect_left_inv_arrow";case"{}":return"diamond";case"{{}}":return"hexagon";case"([])":return"stadium";case"[[]]":return"subroutine";case"[()]":return"cylinder";case"((()))":return"doublecircle";case"[//]":return"lean_right";case"[\\\\]":return"lean_left";case"[/\\]":return"trapezoid";case"[\\/]":return"inv_trapezoid";case"<[]>":return"block_arrow";default:return"na"}}function TX(e){switch(e.trim().slice(-1)){case"x":return"arrow_cross";case"o":return"arrow_circle";case">":return"arrow_point";default:return""}}function LX(e){switch(e.trim().charAt(0)){case"x":return"arrow_cross";case"o":return"arrow_circle";case"<":return"arrow_point";default:return"arrow_open"}}function AX(e){return e.includes("==")?"thick":"normal"}function IX(e){return e.includes(".-")?"dotted":"solid"}function uF(e,t){const n=e.flat();let i=-1;for(const r of n){if(r.type==="column-setting"){i=r.columns??-1;break}}return{list:n,at:0,parent:t,children:[],columns:i}}var My=class{type="block";title;root={id:"root",type:"composite",children:[],columns:-1};blocks=[];edges=[];classes=new Map;byId=new Map;typeStr2Type=vX;edgeStrToEdgeData=TX;edgeStrToEdgeStartData=LX;edgeStrToThickness=AX;edgeStrToPattern=IX;warn;pending=new Set;workIds=new Set;admitNode(t){if(this.workIds.has(t))return;Ve("nodes",this.workIds.size+1);this.workIds.add(t)}edgeCount=new Map;ids=0;colors=0;reservedIds=new Set;constructor(t={}){this.warn=t.warn}generateId(){let t;do t="block_generated_"+ ++this.ids;while(this.reservedIds.has(t)||this.byId.has(t));this.reservedIds.add(t);if(ie("block"))ue("block","generate-id",t);return t}addStyleClass(t,n=""){let i=this.classes.get(t);if(!i){i={id:t,styles:[],textStyles:[]};this.classes.set(t,i)}for(const r of n.split(",")){const o=r.indexOf(";");const s=(o===-1?r:r.slice(0,o)+r.slice(o+1)).trim();if(r.includes("color"))i.textStyles.push(s.replace("fill","bgFill").replace("color","fill"));i.styles.push(s);if(ie("block"))ue("block","define-class",{id:t,attribute:s})}}addStyle2Node(t,n=""){this.named(t).styles=n.replace(/;\s*$/,"").split(",");if(ie("block"))ue("block","set-node-style",{id:t,styles:this.named(t).styles})}setCssClass(t,n){for(const i of t.split(",")){;(this.named(i.trim()).classes??=[]).push(n);if(ie("block"))ue("block","add-node-class",{id:i.trim(),className:n})}}named(t){let n=this.byId.get(t);if(n===void 0){this.admitNode(t);n={id:t,type:"na",children:[]};this.byId.set(t,n);this.pending.add(t)}return n}unresolvedStyleTargets(){return[...this.pending]}setHierarchy(t){const n=[uF(t,this.root)];while(n.length>0){const i=n[n.length-1];if(i.at===i.list.length){i.parent.children=i.children;if(ie("block"))ue("block","set-children",{id:i.parent.id,children:i.children.map(l=>l.id)});n.pop();continue}const r=i.list[i.at++];if(i.columns>0&&r.type!=="column-setting"&&typeof r.widthInColumns==="number"&&r.widthInColumns>i.columns){this.warn?.(`Block ${r.id} width ${r.widthInColumns} exceeds configured column width ${i.columns}`)}switch(r.type){case"classDef":this.addStyleClass(r.id,r.css);continue;case"applyClass":this.setCssClass(r.id,r.styleClass??"");continue;case"applyStyles":if(r.stylesStr)this.addStyle2Node(r.id,r.stylesStr);continue;case"column-setting":i.parent.columns=r.columns??-1;if(ie("block"))ue("block","set-columns",{id:i.parent.id,columns:i.parent.columns});continue;case"edge":{Ve("edges",this.edges.length+1);const l=(this.edgeCount.get(r.id)??0)+1;this.edgeCount.set(r.id,l);r.id=l+"-"+r.id;this.edges.push(r);if(ie("block"))ue("block","add-edge",r);continue}}r.id??=this.generateId();if(r.type!=="space")this.admitNode(r.id);if(!r.label)r.label=r.type==="composite"?"":r.id;const o=this.byId.get(r.id);const s=o===void 0||this.pending.delete(r.id);if(!s){if(r.type!=="na")o.type=r.type;if(r.label!==r.id)o.label=r.label}else{if(o){r.classes=o.classes;r.styles=o.styles}if(r.type==="composite")r.colorIndex=this.colors++;this.byId.set(r.id,r)}if(ie("block"))ue("block","upsert-block",{parentId:i.parent.id,block:this.byId.get(r.id)});const a=r.children;r.children=[];if(r.type==="space"){const l=r.width??1;Ve("nodes",this.workIds.size+Math.max(l,0));for(let c=0;c<l;c++){const d={...r,id:r.id+"-"+c,width:1,children:[]};this.admitNode(d.id);this.byId.set(d.id,d);i.children.push(d);if(ie("block"))ue("block","attach-space",{parentId:i.parent.id,block:d})}}else if(s){i.children.push(r);if(ie("block"))ue("block","attach-child",{parentId:i.parent.id,block:r})}if(a&&a.length>0)n.push(uF(a,r))}this.blocks=this.root.children??[];if(ie("block"))ue("block","complete-hierarchy",{root:this.root,edges:this.edges,classes:this.classes})}};function hF(e){const t=Array.isArray(e)?e.join("\n"):e;const n=new My;const i=Ow(t);n.reservedIds=new Set(i.texts.filter((o,s)=>i.types[s]===32));FX(t.endsWith("\n")?t:t+"\n",n);if(n.unresolvedStyleTargets().length)throw new Error("Block style/class references undeclared targets: "+n.unresolvedStyleTargets().join(", "));for(const o of n.classes.values())Lt(vn(o.styles.join(",")),`classDef ${o.id}`);const r=[n.root];for(let o=0;o<r.length;o++){const s=r[o];Lt(vn((s.styles??[]).join(",")),`style ${s.id}`);r.push(...s.children??[])}return{kind:"block",root:n.root,edges:n.edges,classDefs:[...n.classes.values()],title:n.title}}var yh="'NODE_ID', 'COLUMNS', 'SPACE_BLOCK', 'BLOCK_DIAGRAM_KEY', 'id-block', 'classDef', 'class', 'style'";function fF(e){const t=e[e.length-1];if(!Array.isArray(t))return e;e.pop();return e.concat(t)}function FX(e,t){const{types:n,texts:i,starts:r}=Ow(e);let o=0;const s=f=>{const h=n[o];if(h===1)throw nM("block",e,r[o],"",true);throw nM("block",e,r[o],`Expecting ${f}, got '${rg[h]}'`)};const a=f=>{if(n[o]!==f)s(`'${rg[f]}'`);return i[o++]};const l=()=>{const f=a(32);if(n[o]===27){const h=i[o++];const m=wy(a(6));return{id:f,label:m,typeStr:h+a(28)}}if(n[o]===29){const h=i[o++];const m=wy(a(6));const p=[a(31)];while(n[o]===31)p.push(i[o++]);return{id:f,label:m,typeStr:h+a(30),directions:p}}return{id:f}};const c=()=>{const f=l();const h=n[o]===36?parseInt(i[o++],10):1;let m={id:f.id,label:f.label,type:t.typeStr2Type(f.typeStr),directions:f.directions,widthInColumns:h};let p;while(n[o]===33||n[o]===34){let g="";if(n[o++]===34){a(35);g=wy(a(6));a(33)}const y=i[o-1];const b=l();const S=t.edgeStrToEdgeData(y);const x=t.edgeStrToEdgeStartData(y);const k=t.edgeStrToThickness(y);const w=t.edgeStrToPattern(y);p??=[{id:m.id,label:m.label,type:m.type,directions:m.directions}];m={id:b.id,label:b.label,type:t.typeStr2Type(b.typeStr),directions:b.directions};p.push({id:p[p.length-1].id+"-"+b.id,start:p[p.length-1].id,end:b.id,label:g,type:"edge",thickness:k,pattern:w,directions:b.directions,arrowTypeEnd:S,arrowTypeStart:x},m)}return p??m};a(2);if(ie("block"))Ge("block","header",i[0],{offset:r[0],endOffset:r[0]+i[0].length,unit:"physical"});const d=[];let u=[];while(true){const f=o,h=n[o];if(h!==37&&ie("block"))Ge("block",rg[h],i[f],{offset:r[f],endOffset:r[f]+i[f].length,unit:"physical"});switch(n[o]){case 32:u.push(c());break;case 4:u.push({type:"column-setting",columns:parseInt(i[o++],10)});break;case 7:{const m=parseInt(i[o++],10);u.push({id:t.generateId(),type:"space",label:"",width:m,children:[]});break}case 2:o++;Ve("nesting",d.length+1);d.push({list:u,header:void 0});u=[];break;case 3:o++;Ve("nesting",d.length+1);if(n[o]!==32)s("'NODE_ID'");d.push({list:u,header:c()});u=[];break;case 26:{const m=d.pop();if(m===void 0||u.length===0)return s(yh);o++;const p=t.generateId();const g=fF(u);u=m.list;u.push(m.header===void 0?{id:p,type:"composite",label:"",children:g}:{...m.header,type:"composite",children:g});break}case 11:{o++;const m=a(13).trim();u.push({type:"classDef",id:m,css:a(14).trim()});break}case 15:{o++;const m=a(16).trim();u.push({type:"applyClass",id:m,styleClass:a(17).trim()});break}case 18:{o++;const m=a(19).trim();u.push({type:"applyStyles",id:m,stylesStr:a(20).trim()});break}case 37:if(d.length>0)s(yh+", 'end'");if(u.length===0)s(yh);t.setHierarchy(fF(u));return;default:s(u.length===0?yh:yh+(d.length>0?", 'end'":", 'EOF'"))}}}var NX=e=>/^ishikawa(?:-beta)?\s*(?:%%.*)?$/i.test(e.trim());function mF(e){const t=Wt(typeof e==="string"?e.split(/\r?\n/):e);pr(t);const n=t.familyLines;const i=n.findIndex(a=>a.trim()&&!a.trim().startsWith("%%"));if(!NX(n[i]??""))throw new Error("Ishikawa source must start with ishikawa");const r={kind:"ishikawa",nodes:[],...vr(zo(t.accessibility))};const o=[];let s;for(let a=i+1;a<n.length;a++){const l=n[a];const c=l.trim();if(!c||c.startsWith("%%"))continue;const d=yo(Wo(c));Ge("ishikawa","node",l,{line:a+1,unit:"normalized"});Ve("nodes",r.nodes.length+1);const u=l.match(/^[\t ]*/)?.[0].length??0;if(r.nodes.length===0){const m={id:"effect",label:d};r.nodes.push(m);ue("ishikawa","add-node",m);o.push({level:0,node:m});continue}s??=u;const f=Math.max(1,u-s+1);while(o.length>1&&o.at(-1).level>=f)o.pop();Ve("nesting",o.length);const h={id:`cause-${r.nodes.length}`,label:d,parentId:o.at(-1).node.id};r.nodes.push(h);o.push({level:f,node:h});ue("ishikawa","add-node",h)}return r}function Qs(e){const t=new Map;for(const n of e){const i=t.get(n.parentId)??[];i.push(n);t.set(n.parentId,i)}return t}function Kme(e,t){const n=Qs(e);const i=new Set;const r=[t];while(r.length){const o=r.pop();if(i.has(o))throw new Error("Hierarchy contains a cycle");i.add(o);for(const s of n.get(o)??[])r.push(s.id)}return i}function ky(e,t){Ve("nodes",e.length);const n=new Map(e.map(o=>[o.id,o]));if(n.size!==e.length)throw new Error("Hierarchy contains duplicate identities");const i=new Set(e.map(o=>o.parentId));const r=new Map;for(const o of e){const s=new Set;const a=t?.(o)??i.has(o.id);let l=o;while(l&&!r.has(l.id)){if(s.has(l.id))throw new Error("Hierarchy contains a cycle");s.add(l.id);Ve("nesting",s.size-(a?0:1));if(l.parentId&&!n.has(l.parentId))throw new Error(`Unknown parent ${l.parentId}`);l=l.parentId?n.get(l.parentId):void 0}let c=l?r.get(l.id):0;for(const d of[...s].reverse()){const u=n.get(d);c+=t?.(u)??i.has(d)?1:0;Ve("nesting",c);r.set(d,c)}}}var Cy=class extends Error{constructor(t,n,i){super(t)}};function iM(e,t,n=0,i="",r=false){const o=t.slice(0,n).split(/\r\n?|\n/),s=o.length,a=o.at(-1).length+1;return new Error(`${e} ${r?"lexical":"parse"} error at line ${s}, column ${a}: ${i||"unrecognized input"}`)}var fc={REQUIREMENT:"Requirement",FUNCTIONAL_REQUIREMENT:"Functional Requirement",INTERFACE_REQUIREMENT:"Interface Requirement",PERFORMANCE_REQUIREMENT:"Performance Requirement",PHYSICAL_REQUIREMENT:"Physical Requirement",DESIGN_CONSTRAINT:"Design Constraint"};var Ey={LOW_RISK:"Low",MED_RISK:"Medium",HIGH_RISK:"High"};var xh={VERIFY_ANALYSIS:"Analysis",VERIFY_DEMONSTRATION:"Demonstration",VERIFY_INSPECTION:"Inspection",VERIFY_TEST:"Test"};var Ka={CONTAINS:"contains",COPIES:"copies",DERIVES:"derives",SATISFIES:"satisfies",VERIFIES:"verifies",REFINES:"refines",TRACES:"traces"};var $X=1e6;var Py=class{type="requirement";direction="TB";requirements=new Map;elements=new Map;relations=[];classes=new Map;authoredStyles=new Map;title;accTitle;accDescr;newId="";newText="";newRisk="";newVerifyMethod="";newElementType="";newDocRef="";styleCopies=0;copy(t,n){this.styleCopies+=n.length;if(this.styleCopies>$X){throw new Cy("Requirement diagram applies too many style declarations.","limit",{type:"requirement"})}for(const i of n)t.push(i)}setDirection(t){this.direction=t;if(ie("requirement"))ue("requirement","setDirection",t)}addRequirement(t,n){let i=this.requirements.get(t);if(i===void 0){Ve("nodes",this.requirements.size+this.elements.size+1);i={name:t,type:n,requirementId:this.newId,text:this.newText,risk:this.newRisk,verifyMethod:this.newVerifyMethod,cssStyles:[],classes:["default"]};this.requirements.set(t,i);if(ie("requirement"))ue("requirement","addRequirement",i)}this.newId=this.newText=this.newRisk=this.newVerifyMethod="";return i}setNewReqId(t){this.newId=t;if(ie("requirement"))ue("requirement","setNewReqId",t)}setNewReqText(t){this.newText=t;if(ie("requirement"))ue("requirement","setNewReqText",t)}setNewReqRisk(t){this.newRisk=t;if(ie("requirement"))ue("requirement","setNewReqRisk",t)}setNewReqVerifyMethod(t){this.newVerifyMethod=t;if(ie("requirement"))ue("requirement","setNewReqVerifyMethod",t)}addElement(t){let n=this.elements.get(t);if(n===void 0){Ve("nodes",this.requirements.size+this.elements.size+1);n={name:t,type:this.newElementType,docRef:this.newDocRef,cssStyles:[],classes:["default"]};this.elements.set(t,n);if(ie("requirement"))ue("requirement","addElement",n)}this.newElementType=this.newDocRef="";return n}setNewElementType(t){this.newElementType=t;if(ie("requirement"))ue("requirement","setNewElementType",t)}setNewElementDocRef(t){this.newDocRef=t;if(ie("requirement"))ue("requirement","setNewElementDocRef",t)}addRelationship(t,n,i){Ve("edges",this.relations.length+1);this.relations.push({type:t,src:n,dst:i});if(ie("requirement"))ue("requirement","addRelationship",{type:t,src:n,dst:i})}node(t){return this.requirements.get(t)??this.elements.get(t)}setCssStyle(t,n){for(const i of t){const r=this.authoredStyles.get(i)??[];this.copy(r,n);this.authoredStyles.set(i,r)}for(const i of t){const r=this.node(i);if(!n||!r)return;(r.directStyles??=[]).push(...n.flatMap(o=>o.split(",")));for(const o of n){this.copy(r.cssStyles,o.includes(",")?o.split(","):[o]);if(ie("requirement"))ue("requirement","setCssStyle",{id:i,style:o,node:r})}}}setClass(t,n){for(const i of t){const r=this.node(i);if(!r)continue;for(const o of n){r.classes.push(o);if(ie("requirement"))ue("requirement","setClass",{id:i,className:o});const s=this.classes.get(o)?.styles;if(s)this.copy(r.cssStyles,s)}}}defineClass(t,n){for(const i of t){let r=this.classes.get(i);if(r===void 0){r={id:i,styles:[],textStyles:[]};this.classes.set(i,r)}for(const s of n){if(s.includes("color"))r.textStyles.push(s.replace("fill","bgFill"));r.styles.push(s)}if(ie("requirement"))ue("requirement","defineClass",r);const o=n.flatMap(s=>s.split(","));for(const s of this.requirements.values()){if(s.classes.includes(i))this.copy(s.cssStyles,o)}for(const s of this.elements.values()){if(s.classes.includes(i))this.copy(s.cssStyles,o)}}}setAccTitle(t){this.accTitle=t.replace(/^\s+/g,"");if(ie("requirement"))ue("requirement","setAccTitle",this.accTitle)}setAccDescription(t){this.accDescr=t.replace(/\n\s+/g,"\n");if(ie("requirement"))ue("requirement","setAccDescription",this.accDescr)}};var _X=[fc.REQUIREMENT,fc.FUNCTIONAL_REQUIREMENT,fc.INTERFACE_REQUIREMENT,fc.PERFORMANCE_REQUIREMENT,fc.PHYSICAL_REQUIREMENT,fc.DESIGN_CONSTRAINT,Ey.LOW_RISK,Ey.MED_RISK,Ey.HIGH_RISK,xh.VERIFY_ANALYSIS,xh.VERIFY_DEMONSTRATION,xh.VERIFY_INSPECTION,xh.VERIFY_TEST,"",Ka.CONTAINS,Ka.COPIES,Ka.DERIVES,Ka.SATISFIES,Ka.VERIFIES,Ka.REFINES,Ka.TRACES];function pF(e){return e===49||e===50||e===54||e===53||e===51}function gF(e,t,n){const i=Array.isArray(e)?e.join("\n"):e;const r=i.replace(/^[^\S\r\n]*requirement[^\S\r\n]*(?=\r\n?|\n|$)/i,"requirementDiagram");const o=r.length-i.length;const s=new Py;DX(r.endsWith("\n")?r:r+"\n",s,t,n?a=>n(a-o):void 0);for(const a of s.classes.values())Lt(vn(a.styles.join(",")),`classDef ${a.id}`);for(const[a,l]of s.authoredStyles){Lt(vn(l.join(",")),`style ${a}`)}for(const a of[...s.requirements.values(),...s.elements.values()]){Lt(vn((a.directStyles??[]).join(",")),`style ${a.name}`)}return{kind:"requirement",direction:s.direction,requirements:[...s.requirements.values()],elements:[...s.elements.values()],relations:s.relations.map((a,l)=>({...a,id:`relation-${l+1}`})),classDefs:[...s.classes.values()],title:s.title,accessibilityTitle:s.accTitle,accessibilityDescription:s.accDescr}}function DX(e,t,n,i){const{types:r,texts:o,starts:s}=Ww(e);let a=0;const l=[];const c=[];const d=(x,k=x,...w)=>{const C=r[a];if(C===1)throw iM("requirement",e,s[a],"",true);for(let M=k;M>=x;M--)w.unshift(M);const R=w.map(M=>`'${Cd[M]}'`).join(", ");throw iM("requirement",e,s[a],`Expecting ${R}, got '${Cd[C]}'`)};const u=x=>{if(r[a]!==x)d(x);if(x===12&&r[a-1]!==59)i?.(s[a]);return o[a++]};const f=(x,k)=>{const w=r[a];if(w<x||w>k)d(x,k);a++;return _X[w-23]};const h=()=>{const x=r[a];if(x!==59&&x!==58)d(58,59);return o[a++]};const m=()=>{const x=a;const k=r[a];if(k===3){a++;t.setAccTitle(u(4).trim())}else if(k===5){a++;t.setAccDescription(u(6).trim())}else if(k===7){t.setAccDescription(o[a++].trim())}else{return false}if(ie("requirement"))Ge("requirement",Cd[k],e.slice(s[x],s[a]??e.length),{offset:s[x],endOffset:s[a]??e.length,unit:"physical"});return true};const p=()=>{const x=[];while(true){const k=r[a];if(k!==49&&k!==59&&k!==58)d(58,59,49);x.push(o[a++]);if(r[a]!==60)return x;a++}};const g=()=>{const x=[];while(true){if(!pF(r[a]))d(49,51,53,54);let k=o[a++];while(pF(r[a])){const w=s[a-1]+o[a-1].length;if(k.includes(":")&&!k.endsWith(":")&&s[a]>w)k+=e.slice(w,s[a]);k+=o[a++]}x.push(k);if(r[a]!==60)return x;a++}};const y=()=>{let x;if(r[a]===17){a++;x=p();u(15)}else if(r[a]===15){a++}else{d(15,15,17)}u(12);return x};const b=x=>{l.length=0;c.length=0;while(true){const k=r[a];if(k===16){a++;break}if(k===12){a++;continue}if(x?k<19||k>22:k!==44&&k!==45){if(x)d(19,22,12,16);d(44,45,12,16)}const w=a;a++;u(18);c.push(k===21?f(29,31):k===22?f(32,35):h());l.push(k);u(12);if(ie("requirement"))Ge("requirement",Cd[k],e.slice(s[w],s[a]??e.length),{offset:s[w],endOffset:s[a]??e.length,unit:"physical"})}for(let k=l.length-1;k>=0;k--){const w=c[k];switch(l[k]){case 19:t.setNewReqId(w);break;case 20:t.setNewReqText(w);break;case 21:t.setNewReqRisk(w);break;case 22:t.setNewReqVerifyMethod(w);break;case 44:t.setNewElementType(w);break;default:t.setNewElementDocRef(w)}}};while(m()){if(r[a]===12)a++}if(r[a]!==14)d(14,14,3,5,7);const S=a++;u(12);if(ie("requirement"))Ge("requirement","header",e.slice(s[S],s[a]??e.length),{offset:s[S],endOffset:s[a]??e.length,unit:"physical"});while(true){const x=a;const k=r[a];if(k===13)return;if(k!==12&&k!==3&&k!==5&&k!==7&&ie("requirement"))Ge("requirement",Cd[k],o[x],{offset:s[x],endOffset:s[x]+o[x].length,unit:"physical"});if(k===12){a++}else if(m()){continue}else if(k>=8&&k<=11){a++;t.setDirection(k===8?"TB":k===9?"BT":k===10?"RL":"LR")}else if(k>=23&&k<=28){const w=f(23,28);const C=h();const R=y();b(true);t.addRequirement(C,w);if(R)t.setClass([C],R)}else if(k===36){a++;const w=h();const C=y();b(false);t.addElement(w);if(C)t.setClass([w],C)}else if(k===46){a++;const w=p();const C=e.slice(s[x],s[a]);const R=g();n?.({prefix:C,styles:R});t.setCssStyle(w,R)}else if(k===47){a++;const w=p();const C=e.slice(s[x],s[a]);const R=g();n?.({prefix:C,styles:R});t.defineClass(w,R)}else if(k===48){a++;const w=p();t.setClass(w,p())}else if(k===59||k===58){const w=o[a++];const C=r[a];if(C===17){a++;t.setClass([w],p())}else if(C===55||C===57){a++;const R=f(37,43);u(C===57?56:57);const M=h();if(C===57)t.addRelationship(R,w,M);else t.addRelationship(R,M,w)}else{d(17,17,55,57)}}else{d(12,13,3,5,7,8,9,10,11,23,24,25,26,27,28,36,47,48,46,59,58)}}}function yF(){const e=[];const t=new Set;const n=new Map;const i=[];const r=new Set;const o=[];const s=new Map;const a=$g();const l=d=>{if(!t.has(d)){t.add(d);e.push(d)}};const c=(d,u)=>{l(d);if(u!==void 0&&!n.has(d))n.set(d,u);o.at(-1)?.names.push(d)};return{open(d){if(r.has(d))throw new Error(`Duplicate ER subgraph id '${d}'`);r.add(d);i.push(d);o.push({id:d,names:[]})},close(){const d=o.pop();if(!d)throw new Error("ER `end` closes no subgraph");s.set(d.id,a.close(d.id,d.names));o.at(-1)?.names.push(d.id)},get innermost(){return o.at(-1)?.id},declare:c,relationEnd(d,u){if(r.has(d))return false;c(d,u);return true},style:l,created:d=>t.has(d),finish(){const d=o.at(-1);if(d){throw Je({what:`ER subgraph '${d.id}' is never closed`,expectedForm:"each subgraph closed by an end line",example:"subgraph G\n A\nend"})}const u=new Map;for(const f of[...e,...i]){const h=a.ownerOf(f);if(h!==void 0)u.set(f,h)}return{order:e,alias:n,owner:u,groups:i.map(f=>({id:f,...u.has(f)?{parentId:u.get(f)}:{},entityIds:s.get(f).filter(h=>t.has(h))}))}}}}var EF=String.raw`[A-Za-z0-9_][\w.-]*(?![\w.-])`;var bh=String.raw`"(?:\\.|[^"\\])*"`;var OX=new RegExp(`^${bh}$`);var RF=`(?:${bh}|${EF})`;var vF=new RegExp(`^${EF}$`);var Ry=String.raw`${RF}(?:\[\s*(?:${bh}|[^\]"\r\n]+)\s*\])?(?::::[\w-]+(?:,[\w-]+)*)?`;var BX=new RegExp(String.raw`^(${RF})(?:\[\s*(?:(${bh})|([^\]"\r\n]+))\s*\])?(?::::([\w-]+(?:,[\w-]+)*))?$`);var xF=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}{]+)`;var bF=String.raw`(?:\|\||\|o|o\||\}o|o\{|\}\||\|\{|\bu(?=[.\-|]))`;var WX=new RegExp(`^(${Ry})(?:[ \\t]+(${xF})|(${bF}))(?:([ \\t]*(?:--|\\.\\.|\\.-|-\\.)[ \\t]*)|([ \\t]+(?:optionally to|to)[ \\t]+))(?:(${xF})[ \\t]+|(${bF}))(${Ry})(?:[ \\t]*:[ \\t]*(.*))?$`,"i");function hc(e,t){const n=e.trim().match(BX);if(!n)return null;const i=n[1].startsWith('"')?ih(n[1],"ER entity name",t):n[1];const r=n[2]!==void 0?ih(n[2],"ER entity alias",t):n[3]?.trim();return{id:i,...r!==void 0?{alias:r}:{},...n[4]?{className:n[4].replaceAll(","," ")}:{},...n[1].startsWith('"')?{quoted:true}:{}}}function zX(e,t){if(t!==void 0)return oh(t,true);return vF.test(e)?{label:e}:oh(e,true)}function kpe(e){const t=e.trim();return vF.test(t)?t:null}function GX(e,t){const n=/^class[ \t]+/i.exec(e);if(!n)return null;const i=e.slice(n[0].length).trimEnd();let r=i.length;const o=[];const s=a=>/[A-Za-z0-9_-]/.test(a);while(r>0){const a=r;while(r>0&&s(i[r-1]))r--;if(r===a)return null;o.push(i.slice(r,a));const l=r;while(r>0&&(i[r-1]===" "||i[r-1]===" "))r--;if(i[r-1]===","){r--;while(r>0&&(i[r-1]===" "||i[r-1]===" "))r--;continue}if(r===l||r===0)return null;const c=i.slice(0,r).split(",").map(d=>hc(d.trim(),t));if(c.length===0||c.some(d=>d===null))return null;return{ids:c.map(d=>d.id),classNames:o.reverse()}}return null}function SF(e,t,n){const i=e.get(t);if(i)for(const r of n)i.push(r);else e.set(t,[...n])}var HX=new RegExp(String.raw`^subgraph\s+(${bh}|\S+?)(?:\s*\[([^\]]+)\])?$`,"i");function jX(e,t){const n=e.match(HX);if(!n)return null;const i=n[1].startsWith('"')?ih(n[1],"ER subgraph id",t):n[1];const r=n[2]?.trim();if(!r)return{id:i};return{id:i,title:OX.test(r)?ih(r,"ER subgraph title",t):r}}var YX=/[^\x80-\uFFFF\w\s*#:,;-]/;var qX=/#(\d{2}|\d{5}|\d{7});/g;function XX(e){const t=e.codePointAt(0);if(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f\ud800-\udfff\ufffe\uffff]/u.test(e))return void 0;return`#${String(t).padStart(t<=99?2:t<=99999?5:7,"0")};`}function wF(e){let t="ER_STYLE_ENTITY_";while(e.includes(t))t+="_";const n=[];const i=e.replace(qX,(s,a)=>{const l=Number(a);n.push(l<=1114111?String.fromCodePoint(l):"\uFFFD");return`${t}${n.length-1}_`});const r=new RegExp(`${t}(\\d+)_`,"g");const o=s=>s.replace(r,(a,l)=>n[Number(l)]);return Object.fromEntries(Object.entries(vn(i)).map(([s,a])=>[o(s),o(a)]))}function UX(e){const t=[];const n=i=>{let r="";for(const o of i){const s=XX(o);if(!s)return void 0;if(!YX.test(o)&&!",:;\uFB02\xB6".includes(o)&&!/\s/.test(o)){r+=o;continue}r+=s}return r};for(const[i,r]of Object.entries(e)){const o=n(i),s=n(r);if(o===void 0||s===void 0)return void 0;t.push(`${o}:${s}`)}return t.join(",")}function Cpe(e,t){const n=UX(t);if(n===void 0)return void 0;const i=`${e} ${n}`,r=`${i};;`;const o=r.length-Un(r).length;const s=i+";".repeat(o);if(Un(s)!==i)throw new Error("ER style statement did not preserve its fields through the entity prepass");return s}function VX(e){return Tf(Gt(e))}function Ppe(e){return Xr(e)>=0&&VX(e)===void 0}function rM(e,t,n){const i=Tf(e);if(i)return{kind:"direction",direction:i};const r=jX(e,n);if(r)return{kind:"group-open",...r};if(e==="end"&&t)return{kind:"end"};const o=e.match(/^classDef\s+([\w,-]+)\s+(.+)$/is);if(o){return{kind:"class-def",names:o[1].split(",").map(f=>f.trim()).filter(Boolean),props:wF(o[2])}}const s=GX(e,n);if(s)return{kind:"class",...s};if(/^class(?:[ \t]|$)/i.test(e))throw new Error(`Invalid ER class assignment: ${e}`);const a=e.match(/^style\s+(.+?)\s+(.+)$/is);if(a){const f=a[1].split(",").map(m=>hc(m.trim(),n));if(f.some(m=>m===null))throw new Error(`Invalid ER style assignment: ${e}`);const h=f.map(m=>m.id);return{kind:"style",ids:h,props:wF(a[2])}}const l=s5(e,n);if(l)return{kind:"relation",relation:l};const c=e.match(TF);const d=c?hc(c[1],n):null;if(d)return{kind:"block-open",reference:d};const u=hc(e,n);return u?{kind:"entity",reference:u}:null}var TF=new RegExp(`^(${Ry})\\s*\\{`);var KX=new RegExp(`^${Ry}`);var LF=new 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");var AF=/^(?:(?:subgraph|end|style|classDef|class|erDiagram)(?!\w)|direction\s+(?:TB|BT|LR|RL))/i;function IF(e){return AF.test(e)||LF.test(e)}function Epe(e){return e==="1"||IF(e)||/^\d/.test(e)&&!/^\d+(?:\.\d+)?$/.test(e)}function sM(e){let t=false;for(let n=0;n<e.length;n++){const i=e[n];if(t){if(i==='"')t=false}else if(i==='"')t=true;else if(i==="`"&&(n===0||/\s/.test(e[n-1]))){const r=e.indexOf("`",n+1);if(r>n+1&&!/\s/.test(e.slice(n+1,r)))n=r}else if(i==="}")return n}return-1}var JX=/[\w*\u00C0-\uFFFF]/;function FF(e,t,n,i){const r=e.slice(n,i);const o=new Map;const s=[];for(let d=0,u=false;d<r.length;d++){if(r[d]==='"')u=!u;else if(r[d]!=="~"||u)continue;else if(JX.test(r[d+1]??""))s.push(d);else if(s.length>0)o.set(s.pop(),d)}const a=d=>{let u=d;while(u<r.length&&!/[\s"]/.test(r[u]))u++;return u};const l=[];const c=(d,u,f)=>{l.push({kind:d,text:r.slice(u,f),line:t,start:n+u,end:n+f})};for(let d=0;d<r.length;){if(/\s/.test(r[d]))d++;else if(r[d]==='"'){const u=r.indexOf('"',d+1);c(u<0?"stray":"comment",d,u<0?d+1:u+1);d=u<0?d+1:u+1}else{let u=a(d);const f=r.slice(d,u).indexOf("~");const h=f<0?void 0:o.get(d+f);if(h!==void 0&&h>=u)u=a(h+1);c("word",d,u);d=u}}return l}var QX=/^[*A-Za-z_\u00C0-\uFFFF][\w\-[\]().,\u00C0-\uFFFF*]*$/;var ZX=/^`[^`]+`$/;var MF=(e,t=e.text)=>e.kind==="word"&&((t.match(/~/g)?.length??0)>=2||QX.test(t)||ZX.test(t))&&!/^(?:PK|FK|UK)\b/i.test(t);var e5=e=>e.kind==="word"&&e.text.split(",").every(t=>!t||/^(?:PK|FK|UK)$/i.test(t));function NF(e,t){const n=[];let i=e&&{tokens:[...e.tokens],last:e.last};for(const r of t){if(i?.last==="type"){if(r.text==="?"&&i.tokens.length===1&&!i.tokens[0].text.endsWith("?"))i.tokens.push(r);else if(MF(r))i={tokens:[...i.tokens,r],last:"name"};else return null}else if(i?.last==="name"&&e5(r))i.tokens.push(r);else if(i?.last==="name"&&r.kind==="comment")i={tokens:[...i.tokens,r],last:"comment"};else if(MF(r,r.text.replace(/\?$/,""))){if(i)n.push(i);i={tokens:[r],last:"type"}}else return null}return{done:n,...i?{open:i}:{}}}function $F(e,t,n,i){const r=a=>a.replace(/^`([^`]+)`(\?)?$/,(l,c,d)=>c+(d??""));const o=i===void 0?void 0:rh(yt(i));const s=i===void 0?void 0:H0(i,o,true);return{type:r(e),name:r(t),keys:n,comment:o,...s?{commentContent:s}:{}}}function _F({tokens:e}){const t=e[1]?.text==="?"?1:0;const n=e.slice(2+t).filter(i=>i.kind==="word").map(i=>i.text).join(" ");return n===""||/^(?:PK|FK|UK)(?:\s*,\s*(?:PK|FK|UK))*$/i.test(n)}function DF({tokens:e}){const t=e[1]?.text==="?"?1:0;const n=e.slice(2+t).filter(r=>r.kind==="word").flatMap(r=>r.text.split(",")).filter(Boolean).map(r=>r.toUpperCase());const i=e.find(r=>r.kind==="comment");return $F(e[0].text+(t?"?":""),e[1+t].text,n,i?.text.slice(1,-1))}function t5(e,{tokens:t}){return t.map((n,i)=>{const r=t[i-1];if(!r)return n.text;return((r.endLine??r.line)===n.line?e[n.line].slice(r.end,n.start):" ")+n.text}).join("")}function OF(e,t,n){const i=(c,d)=>({syntax:c,start:d,end:c.kind==="block-open"?d+TF.exec(e.slice(d))[0].length:e.length});const r=kF(e,t,n);if(r)return r;const o=rM(e,t,n);if(o)return[i(o,0)];const s=[];const a=[];const l=[{syntax:{kind:"unknown"},start:0,end:e.length}];for(let c=0;c<e.length;){const d=e.slice(c);if(LF.test(d))return l;if(c>0){const h=[];const m=kF(d,t,(g,y)=>h.push([g,y]));if(m){s.push(...m.map(g=>({...g,start:g.start+c,end:g.end+c})));a.push(...h);break}const p=rM(d,t,(g,y)=>h.push([g,y]));if(p){s.push(i(p,c));a.push(...h);break}}if(AF.test(d))return l;const u=KX.exec(d);const f=u&&hc(u[0],(h,m)=>a.push([h,m]));if(!f)return l;s.push({syntax:{kind:"entity",reference:f},start:c,end:c+u[0].length});c+=u[0].length;c+=e.slice(c).length-e.slice(c).trimStart().length}if(n)for(const[c,d]of a)n(c,d);return s}var n5=/^(?:[^":]|"[^"]*")*?:\s*"[^"]*"/;function kF(e,t,n){const i=n5.exec(e)?.[0].length??-1;if(i<0||!e.slice(i).trim())return null;const r=[];const o=(c,d)=>{r.push([c,d])};let s;let a;const l=e.length-e.slice(i).trimStart().length;try{s=rM(e.slice(0,i),t,o);if(s?.kind!=="relation")return null;a=OF(e.slice(l),t,o)}catch{return null}if(a.some(c=>c.syntax.kind==="unknown"))return null;if(n)for(const[c,d]of r)n(c,d);return[{syntax:s,start:0,end:i},...a.map(c=>({...c,syntax:c.syntax,start:c.start+l,end:c.end+l}))]}function BF(e,t,n){const i=[];let r=0;let o;const s=e.findLastIndex(l=>l.includes('"'));const a=l=>{const c=l.tokens[0];const d=l.tokens.at(-1);i.push({syntax:l.last==="type"?{kind:"unknown"}:{kind:"attribute",attribute:DF(l),text:t5(e,l),..._F(l)?{}:{generous:true}},line:c.line,start:c.start,endLine:d.endLine??d.line,end:d.end})};for(let l=0;l<e.length;l++){const c=e[l];const d=c.trim();const u=[];let f=0;const h=o?.comment;if(h&&d&&!d.startsWith("%%")){const y=c.indexOf('"');h.parts.push((y<0?c:c.slice(0,y)).trim());n?.set(l,y<0?c.length:y+1);if(y<0)continue;u.push({kind:"comment",text:`"${h.parts.join("\n")}"`,line:h.line,start:h.start,endLine:l,end:y+1});o.comment=void 0;f=y+1}else if(!d||d.startsWith("%%")){i.push({syntax:{kind:d?"comment":"blank"},line:l,start:0,endLine:l,end:c.length});continue}const m=c.slice(f);const p=f+m.length-m.trimStart().length+Gt(m.trim()).length;const g=y=>{while(y<p&&/\s/.test(c[y]))y++;return y};for(let y=g(f);y<p||u.length>0;){if(o){const b=sM(c.slice(y,p));const S=b<0?p:y+b;let x=[...u.splice(0),...FF(c,l,y,S)];const k=l<s?x.findIndex(C=>C.kind==="stray"):-1;if(k>=0){o.comment={line:l,start:x[k].start,parts:[c.slice(x[k].start+1,p).trimEnd()]};x=x.slice(0,k)}const w=NF(o.open,x);if(w){for(const C of w.done)a(C);o.open=w.open}else{if(o.open)a(o.open);o.open=void 0;o.comment=void 0;const C=c.slice(y,S).trimEnd();const R=zF(C);i.push({syntax:R?{kind:"attribute",attribute:R,text:C,generous:true}:{kind:"unknown"},line:l,start:y,endLine:l,end:y+C.length})}if(b<0)break;if(o.open)a(o.open);i.push({syntax:{kind:"block-close"},line:l,start:S,endLine:l,end:S+1});o=void 0;y=g(S+1)}else{const b=OF(c.slice(y,p),r>0,t?(S,x)=>t(S,x,l):void 0);for(const{syntax:S,start:x,end:k}of b){i.push({syntax:S,line:l,start:y+x,endLine:l,end:y+k});if(S.kind==="group-open")r++;else if(S.kind==="end")r--;else if(S.kind==="block-open")o={}}y=g(y+b.at(-1).end)}}}return i.sort((l,c)=>l.line-c.line||l.start-c.start)}function Rpe(e){const t=new Set;for(const n of BF(e)){if((n.syntax.kind==="style"||n.syntax.kind==="class-def")&&n.line===n.endLine&&e[n.line].slice(n.start,n.end).trim()===e[n.line].trim()){t.add(n.line+1)}}return t}function i5(e,t){const n=new Map;const i=BF(e,t,n);const r=[];const o=new Set;for(let u=i.length-1;u>=0;u--){r[u]=o.has(i[u].endLine);o.add(i[u].line)}const s=new Map;const a=[];const l=yF();let c;for(const[u,{syntax:f,line:h,endLine:m,end:p}]of i.entries()){const g=s.get(h)??0;const y=r[u]?p:e[m].length;s.set(m,y);const b=h===m?e[h].slice(g,y):[e[h].slice(g),...e.slice(h+1,m),e[m].slice(0,y)].join("\n");const S={line:h,column:g,endLine:m,endColumn:y,...l.innermost!==void 0?{groupId:l.innermost}:{},...c!==void 0?{entityId:c}:{}};const x={raw:b,...S,syntax:f};a.push(x);if(ie("er"))Ge("er",f.kind,x.raw,{line:h+2,unit:"normalized"});switch(f.kind){case"group-open":l.open(f.id);if(ie("er"))ue("er","openGroup",{id:f.id,enclosingGroupId:S.groupId},{line:h+2,unit:"normalized"});break;case"end":l.close();if(ie("er"))ue("er","closeGroup",{id:S.groupId,enclosingGroupId:l.innermost},{line:h+2,unit:"normalized"});break;case"block-open":c=f.reference.id;l.declare(c,f.reference.alias);if(ie("er"))ue("er","declareEntity",{...f.reference,groupId:S.groupId},{line:h+2,unit:"normalized"});break;case"block-close":c=void 0;break;case"entity":l.declare(f.reference.id,f.reference.alias);if(ie("er"))ue("er","declareEntity",{...f.reference,groupId:S.groupId},{line:h+2,unit:"normalized"});break;case"relation":x.relationEntityIds=[f.relation.entity1,f.relation.entity2].filter(k=>{const w=l.relationEnd(k.id,k.alias);if(ie("er"))ue("er","nameRelationshipEndpoint",{...k,isEntity:w,groupId:S.groupId},{line:h+2,unit:"normalized"});return w}).map(k=>k.id);break;case"style":for(const k of f.ids){l.style(k);if(ie("er"))ue("er","ensureStyledEntity",{id:k},{line:h+2,unit:"normalized"})}break}}if(c!==void 0)throw new Error(`ER_UNCLOSED_ENTITY: entity '${c}' needs a closing }`);const d=l.finish();if(ie("er"))ue("er","resolvePlacement",d);return{statements:a,placement:d,continuedComments:n}}function WF(e){const t=Wt(e);pr(t);e=t.familyLines;const n={entities:[],classDefs:new Map,relationships:[],groups:[],...t.accessibility.title!==void 0?{accessibilityTitle:yt(t.accessibility.title)}:{},...t.accessibility.descr!==void 0?{accessibilityDescription:yt(t.accessibility.descr)}:{}};if(ie("er")){Ge("er","header",e[0]??"",{line:1,unit:"normalized"});ue("er","initialize",n)}const i=i5(e.slice(1));const r=new Map;const o=new Map;const s=(d,u)=>{const f=CF(r,d);if(u){SF(o,d,u.split(" "));if(ie("er"))ue("er","appendEntityClasses",{id:d,classNames:o.get(d)})}return f};const a=d=>{return s(d.id,d.className)};const l=new Map;for(const d of i.statements){const u=d.syntax;switch(u.kind){case"unknown":throw new Error(`ER_UNSUPPORTED_STATEMENT: line ${d.line+2}: ${d.raw.trim()}`);case"attribute":r.get(d.entityId).attributes.push(u.attribute);if(ie("er"))ue("er","addAttribute",{entityId:d.entityId,attribute:u.attribute},{line:d.line+2,unit:"normalized"});break;case"direction":{const f=d.groupId!==void 0?l.get(d.groupId):void 0;if(f)f.direction=u.direction;else n.direction=u.direction;if(ie("er"))ue("er","setDirection",{direction:u.direction,groupId:f?.id},{line:d.line+2,unit:"normalized"});break}case"group-open":l.set(u.id,{id:u.id,...oh(u.title??u.id,true)});if(ie("er"))ue("er","upsertGroup",l.get(u.id),{line:d.line+2,unit:"normalized"});break;case"end":break;case"class-def":for(const f of u.names){n.classDefs.set(f,{...u.props});if(ie("er"))ue("er","setClassDefinition",{name:f,props:n.classDefs.get(f)},{line:d.line+2,unit:"normalized"})}break;case"class":for(const f of u.ids){if(r.has(f)){SF(o,f,u.classNames);if(ie("er"))ue("er","appendEntityClasses",{id:f,classNames:o.get(f)},{line:d.line+2,unit:"normalized"})}}break;case"style":for(const f of u.ids){const h=CF(r,f);h.inlineStyle={...h.inlineStyle,...u.props};if(ie("er"))ue("er","setEntityStyle",{id:f,props:h.inlineStyle},{line:d.line+2,unit:"normalized"})}break;case"block-open":a(u.reference);break;case"relation":{n.relationships.push(a5(u.relation,d.raw));if(ie("er"))ue("er","addRelationship",n.relationships.at(-1),{line:d.line+2,unit:"normalized"});for(const f of[u.relation.entity1,u.relation.entity2]){if(d.relationEntityIds.includes(f.id))s(f.id,f.className)}break}case"entity":a(u.reference);break}}const c=i.placement;for(const[d,u]of o){r.get(d).className=u.join(" ");if(ie("er"))ue("er","resolveEntityClasses",{id:d,className:r.get(d).className})}n.entities=c.order.map(d=>{const u=r.get(d);Object.assign(u,zX(d,c.alias.get(d)));const f=c.owner.get(d);if(ie("er"))ue("er","resolveEntity",{...u,groupId:f});return f!==void 0?{...u,groupId:f}:u});n.groups=c.groups.map(d=>{const u={...l.get(d.id),...d.parentId!==void 0?{parentId:d.parentId}:{},entityIds:d.entityIds};if(ie("er"))ue("er","resolveGroup",u);return u});km(n);return n}function CF(e,t){let n=e.get(t);if(!n){n={id:t,label:t,attributes:[]};e.set(t,n);if(ie("er"))ue("er","createEntity",n)}return n}function r5(e){if(Xr(e)>=0||sM(e)>=0)return null;return oM(e)??zF(e)}function oM(e){const t=NF(void 0,FF(e,0,0,e.length));return t?.done.length===0&&t.open&&t.open.last!=="type"&&_F(t.open)?DF(t.open):null}function vpe(e){if(oM(e))return e;const t=r5(e);if(!t)return e;const n=(e.match(/^\S+\s+\S+\s+(.+)$/)?.[1]??"").match(/"[^"]*"/)?.[0];const i=[t.type,t.name,t.keys.join(", "),n??""].filter(Boolean).join(" ");const r=oM(i);const o=r&&r.type===t.type&&r.name===t.name&&r.keys.join()===t.keys.join()&&r.comment===t.comment;return o?i:e}function zF(e){const t=e.match(/^(\S+)\s+(\S+)(?:\s+(.+))?$/);if(!t||/^(?:"|(?:PK|FK|UK)\b)/i.test(t[1])||!t.slice(1,3).every(a=>/[^\W_]|[\u00C0-\uFFFF]/.test(a)))return null;if(Xr(e)>=0||sM(e)>=0)return null;const n=t[1];const i=t[2];const r=t[3]?.trim()??"";const o=r.match(/"([^"]*)"/);const s=[];for(const a of r.replace(/"[^"]*"/,"").trim().split(/[\s,]+/)){const l=a.toUpperCase();if(l==="PK"||l==="FK"||l==="UK"){s.push(l)}else if(a)return null}return $F(n,i,s,o?.[1])}function o5(e){const t=e.replace(/#\w+;/g,"\xA7");if(t.startsWith('"')||/direction\s+(?:TB|BT|LR|RL)/i.test(t))return false;const n=/^(?:\P{ASCII}|[\w*.-])*/u.exec(t)[0];const i=t.slice(n.length);return n===""||/^\d/.test(n)||IF(t)||/^[^\s"]/.test(i)||(i.match(/"/g)?.length??0)%2===1}function s5(e,t){const n=e.match(WX);if(!n)return null;const i=n[2]??n[3];if(i==="1"&&/^[ \t]/.test(n[4]??""))return null;const r=hc(n[1],t);const o=hc(n[8],t);if(!r||!o)return null;const s=(n[4]??n[5]).trim().replace(/[ \t]+/g," ").toLowerCase();return{entity1:r,entity2:o,leftToken:i,rightToken:n[6]??n[7],identifying:s==="--"||s==="to",label:oI(n[9]??"",t),...o5(n[9]?.trim()??"")?{unreadLabel:true}:/^[^"\s][^\s"]*(?:\s+\S|")/.test(n[9]?.trim()??"")?{unquotedWords:true}:{}}}function a5(e,t){const n=PF(e.leftToken);const i=PF(e.rightToken);if(!n||!i){throw new 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:n,cardinality2:i,...oh(e.label,true),identifying:e.identifying}}function PF(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}}var Yd=/^title\s+(.+)$/i;var aM=/^([xy])-axis\s+(.+)$/is;var lM=/^quadrant-([1-4])\s+(.+)$/is;var cM=/^(.+?)\s*:\s*\[\s*([^,\]]+)\s*,\s*([^,\]]+)\s*\]\s*(.*)$/s;var dM=/^classDef\s+(.+)$/i;function GF(e){if(!e.includes(";")||Yd.test(e))return[e];const t=[];let n=0,i=false,r=0;for(let a=0;a<e.length;a++){const l=e[a];if(l==='"')i=!i;if(i)continue;if(l==="%"&&e[a+1]==="%")break;if(l==="(")r++;else if(l===")")r--;else if(l===";"&&r===0){t.push(e.slice(n,a));n=a+1;if(/^\s*title\s/i.test(e.slice(n)))break}}t.push(e.slice(n));const o=[];let s=[];for(let a=0;a<t.length;a++){const l=t[a];if(!l.trim()&&s.length===0)continue;s.push(l);const c=t[a+1]?.trim()??"";const d=cM.test(l.trim());const u=d||dM.test(l.trim())||/^quadrant(?:Chart)?$/i.test(l.trim());const f=aM.test(s[0].trim())||lM.test(s[0].trim());const h=cM.test(c)||dM.test(c)||Yd.test(c)||aM.test(c)||lM.test(c);if(u||f&&h||a===t.length-1){const m=s.join(";").trim();if(m)o.push(m);s=[]}}return o}var l5=/^[\d.,+\s-]*$/;var c5=/^[\d.,+\s-]*\]/;function vy(e){const t=Tr(e,{escapes:false,wholeLine:n=>Yd.test(n)});for(let n=0;n<e.length;n=t[n]+1){const i=t[n];const r=Gt(Rl(e,n,i).trim()).replace(/"[^"]*"/g,'""');const o=r.lastIndexOf("[");if(Yd.test(r)||o<0||r.includes("]",o)||!r.slice(0,o).trimEnd().endsWith(":"))continue;let s=i+1;while(s<e.length&&l5.test(e[s]))s++;if(s<e.length&&c5.test(e[s].trim()))t[n]=s}return t}var d5=/^"[^"]*"/;var u5=/[<>()[\]{}|@^~:;"\n\r\x00-\x08\x0e-\x1f\x7f]/;var f5=/(?<![A-Za-z])(?:[xy]-axis|quadrant-[1-4]|quadrantChart|(?:classDef|title)(?![A-Za-z0-9_]))/i;function jF(e,t=false){const n=t?e.replace(d5,""):e;return n.match(u5)?.[0]??n.match(f5)?.[0]??(e.startsWith("-")?"-":void 0)}function h5(e,t=false){const n=/(?:^|[^A-Za-z])(?:x-axis|y-axis|quadrant-[1-4]|quadrantChart|classDef|accTitle|accDescr|title)/i;return jF(e)!==void 0||t&&(e!==e.trim()||n.test(e))?`"${e}"`:e}function _pe(e){const t=h5(e,true).startsWith('"');return!e.startsWith("%%")&&!e.includes("%%{")&&!(t&&e.startsWith("`"))&&(!t||!e.includes('"'))}function Sh(e,t,n){const i=jF(e,true);if(i!==void 0)n?.(`Quadrant ${t} ${JSON.stringify(e)} has ${JSON.stringify(i)} outside a quoted string`);const r=/^"([^"]*)"/.exec(e);return yt(r?r[1]+e.slice(r[0].length):e)}function YF(e,t,n){const i=n?[0]:void 0;if(i)for(const g of e)i.push(i[i.length-1]+g.length+1);const r=Wt(e,vy(e));pr(r);const o=r.familyLines;e=bb(o,vy(o));if(e.length===0){throw new Error("Quadrant chart is empty")}const s=GF(e[0].trim());const a=Gt(s[0]??"");if(!/^quadrant(?:Chart)?\b\s*$/i.test(a)){throw new Error(`Quadrant chart must start with "quadrant" or "quadrantChart", got: "${a}"`)}if(ie("quadrant"))Ge("quadrant","header",a,{line:1,unit:"normalized"});let l;const c={...r.accessibility.title!==void 0?{title:yt(r.accessibility.title)}:{},...r.accessibility.descr!==void 0?{description:yt(r.accessibility.descr)}:{}};let d;let u;const f=[void 0,void 0,void 0,void 0];const h=[];const m=Object.create(null);const p=new Set;for(let g=0;g<e.length;g++){let y=g,b=0,S=n?e[g].indexOf("\n"):-1;let x=g===0?e[g].indexOf(s[0])+s[0].length:0;for(const k of g===0?s.slice(1):GF(e[g].trim())){const w=n?e[g].indexOf(k,x):0;if(n)x=w+k.length;const C=Yd.test(k)?k:Gt(k);if(C.length===0||C.startsWith("%%"))continue;let R;if(R=C.match(dM)){if(ie("quadrant"))Ge("quadrant","classDef",C,{line:g+1,unit:"normalized"});const M=UL(R[1]);if(!M.ok){throw new Error(`Invalid quadrant classDef: ${M.error}`)}m[M.name]=M.style;if(ie("quadrant"))ue("quadrant","setClassDef",{name:M.name,style:M.style},{line:g+1,unit:"normalized"});continue}if(R=C.match(Yd)){if(ie("quadrant"))Ge("quadrant","title",C,{line:g+1,unit:"normalized"});l=yt(R[1].trim());if(ie("quadrant"))ue("quadrant","setTitle",l,{line:g+1,unit:"normalized"});continue}if(R=C.match(aM)){if(ie("quadrant"))Ge("quadrant","axis",C,{line:g+1,unit:"normalized"});const M=m5(R[2].trim(),R[1].toLowerCase(),t);if(R[1].toLowerCase()==="x")d=M;else u=M;if(ie("quadrant"))ue("quadrant","setAxis",{axis:R[1].toLowerCase(),value:M},{line:g+1,unit:"normalized"});continue}if(R=C.match(lM)){if(ie("quadrant"))Ge("quadrant","quadrant",C,{line:g+1,unit:"normalized"});const M=Number.parseInt(R[1],10)-1;f[M]=Sh(R[2].trim(),`quadrant-${R[1]} label`,t);if(ie("quadrant"))ue("quadrant","setQuadrant",{quadrant:M+1,label:f[M]},{line:g+1,unit:"normalized"});continue}if(R=C.match(cM)){if(ie("quadrant"))Ge("quadrant","point",C,{line:g+1,unit:"normalized"});const{label:M,className:P}=VL(R[1].trim());const E=Sh(M,"point label",t);const v=R[4].trim();const L=l0(v,`quadrant point ${E}`);if(!L.ok){throw new Error(`Unsupported quadrant point style metadata: "${v}" \u2014 ${L.error}. Expected comma-separated radius/color/stroke-color/stroke-width entries.`)}const T=HF(E,R[2].trim());const A=HF(E,R[3].trim());if(p.has(E)){throw new Error(`Duplicate quadrant point label: "${E}"`)}p.add(E);if(ie("quadrant"))ue("quadrant","addPointLabel",E,{line:g+1,unit:"normalized"});const $={label:E,x:T,y:A};if(ie("quadrant"))ue("quadrant","createPoint",$,{line:g+1,unit:"normalized"});if(P!==void 0){$.className=P;if(ie("quadrant"))ue("quadrant","setPointClass",{label:E,className:P},{line:g+1,unit:"normalized"})}if(L.style!==void 0){$.style=L.style;if(ie("quadrant"))ue("quadrant","setPointStyle",{label:E,style:L.style},{line:g+1,unit:"normalized"})}h.push($);if(n){const _=F=>{while(S>=0&&S<F){y++;b=S+1;S=e[g].indexOf("\n",b)}const G=y===g?0:o[y].length-o[y].trimStart().length;return i[y]+G+F-b};const z=w+C.indexOf(M);n($,{start:_(z),end:_(z+M.length)})}if(ie("quadrant"))ue("quadrant","appendPoint",$,{line:g+1,unit:"normalized"});continue}if(C.includes(":")){if(ie("quadrant"))Ge("quadrant","invalidPoint",C,{line:g+1,unit:"normalized"});throw new Error(`Invalid quadrant point: "${C}". Expected: Label: [x, y] with x,y in [0,1]`)}if(ie("quadrant"))Ge("quadrant","unrecognized",C,{line:g+1,unit:"normalized"});throw Je({what:`Unrecognized quadrant chart line: "${C}"`,expectedForm:"a title, x-axis/y-axis, a quadrant-N label, a point (Label: [x, y]), or a classDef",example:"Quick win: [0.2, 0.8]"})}}return{title:l,...c.title||c.description?{accessibility:c}:{},xAxis:d,yAxis:u,quadrants:f,points:h,classDefs:m}}function m5(e,t,n){const i=t==="x"?"left":"bottom";let r=false,o=-1,s=0;for(let l=0;l<e.length;l++){if(e[l]==='"')r=!r;if(r||e[l]!=="-")continue;const c=/^--+>/.exec(e.slice(l));if(c){o=l;s=c[0].length;break}}if(o>=0){const l=Sh(e.slice(0,o).trim(),`${t}-axis text`,n);const c=e.slice(o+s).trim();if(!l)throw new Error(`Quadrant ${t}-axis is missing its ${i} label: "${e}"`);if(!c)return{near:l+" \u27F6 "};return{near:l,far:Sh(c,`${t}-axis text`,n)}}const a=Sh(e.trim(),`${t}-axis text`,n);if(!a)throw new Error(`Quadrant ${t}-axis is missing its ${i} label`);return{near:a}}function HF(e,t){if(!/^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(t)){throw new Error(`Quadrant point "${e}" has non-numeric coordinate "${t}". Coordinates must be numbers in [0, 1].`)}const n=Number.parseFloat(t);if(!Number.isFinite(n)||n<0||n>1){throw new Error(`Quadrant point "${e}" coordinate "${t}" is out of range. Coordinates must be in [0, 1].`)}return n}function qF(e){return e.map(t=>Dn(t.trimStart()))}function XF(e){return e.replace(/<br>/g,"\n")}function mc(e,t){const n=t==="title"||t==="accessibility"?e:XF(e);return no(n,{subject:"Timeline text entity",example:"2025 : #35;"})}function Wpe(e,t){if(e===""&&t==="section")return" ";if(!e.length)throw new Error(`Timeline ${t} text must be non-empty`);const n=t==="section"||t==="period"||t==="event";const i="#&"+(n?":<>":"")+(t==="accessibility"?"{}":"")+(e.includes("%%")||t==="period"&&e.startsWith("%")?"%":"");let r=n?e.split("\n").map(o=>dn(o,i)).join("<br>"):dn(e,i);if(t==="period"&&/^(?:timeline\b|title(?:\s|$)|section(?:\s|$)|acc(?:Title|Descr)(?:\s|$|[:{]))/i.test(r)){r=`#${r.codePointAt(0)};${r.slice(1)}`}return r}function UF(e){const t=e.trim().match(/^timeline(?=$|[\s;#%])(.*)$/i);if(!t)return null;const n=t[1];const i=n.search(/#|%(?!\{)/);const r=i>=0;const o=(i<0?n:n.slice(0,i)).trim();if(!o)return{kind:"supported",hasInlineComment:r};if(o.startsWith(";"))return{kind:"unsupported",suffix:o};if(/^(?:LR|TD)$/i.test(o))return{kind:"supported",direction:o.toUpperCase(),hasInlineComment:r};return{kind:"unsupported",suffix:o}}function VF(e){return Je({what:`Unsupported timeline header suffix "${e}"; only LR and TD are direction tokens`,expectedForm:"timeline [LR|TD]",example:"timeline TD"})}var KF=/^title\s+(.+)$/i;var JF=/^:\s+(.+)$/;function QF(e){const t=/^section\s([^:\n]+)/i.exec(e);return t?{label:t[1],eventSource:e.slice(t[0].length)}:null}function ZF(e){return/^(?:%(?!\{)|#)/.test(e.trimStart())}var eN=/^([^:#\n]+?)(\s*:\s+.+)$/;function Ty(e){const t=[];let n=0;while(n<e.length){while(n<e.length&&/\s/.test(e[n]))n++;if(n>=e.length)break;if(e[n]!==":"){throw Je({what:`Invalid timeline event list: "${e}"`,expectedForm:'events separated by " : "',example:"Launch : Beta"})}n++;if(n>=e.length||!/\s/.test(e[n])){throw new Error(`Timeline events must use ": " separators: "${e}"`)}while(n<e.length&&/\s/.test(e[n]))n++;const i=n;while(n<e.length){if(e[n]===":"&&/\s/.test(e[n+1]??""))break;n++}const r=e.slice(i,n).trim();if(!r||n>=e.length&&r.endsWith(":")){throw Je({what:`Invalid timeline event separator in "${e}"`,expectedForm:"a non-empty event after every separator, without a trailing colon",example:"2024 : Launch : Beta"})}t.push(r)}return t}var tN=64;var wh=256;var p5=/^radar-beta(?:[\t ]*:)?(?=$|\s)/i;var g5=/^title(?:[\t ]+(.*))?$/i;var y5=/^axis\s+([\s\S]+)$/i;var x5=/^curve\s+([\s\S]+)$/i;var nN=/^(showLegend|ticks|max|min|graticule)\b(.*)$/i;var b5=/^(?:0|[1-9]\d*|\d+\.\d+|0\.\d+)$/;var uM=String.raw`[\w](?:[\w-]*[\w])?`;var rN=String.raw`(?:"(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*')`;var S5=new RegExp(String.raw`^(${uM})\s*(?:\[\s*(${rN})\s*\])?$`);var w5=new RegExp(String.raw`^(${uM})\s*(?:\[\s*(${rN})\s*\])?\s*\{([\s\S]*)\}$`);var M5=new RegExp(String.raw`^(${uM})(?:\s*:\s*|\s+)(.+)$`);var oN={spanning:`"'`,wholeLine:e=>/^(?:title|accTitle|accDescr)(?=[\s:{]|$)/i.test(e)};function sN(e){return Tr(e,oN)}function Ly(e,t){const n=[];let i=0;let r=0;let o=null;let s=false;let a="";for(const l of e){if(s){a+=l;s=false;continue}if(o&&l==="\\"){a+=l;s=true;continue}if(l==='"'||l==="'"){if(o===l)o=null;else if(o===null)o=l;a+=l;continue}if(!o){if(l==="[")i++;else if(l==="]")i--;else if(l==="{")r++;else if(l==="}")r--}if(l===","&&!o&&i===0&&r===0){n.push(a.trim());a=""}else{a+=l}}n.push(a.trim());if(o||i!==0||r!==0){throw new Error(`Radar ${t} has unbalanced quotes or delimiters.`)}if(n.some(l=>l.length===0)){throw new Error(`Radar ${t} contains an empty comma-separated entry.`)}return n}function aN(e,t){const n=e[0];if(n!=='"'&&n!=="'"||e.at(-1)!==n){throw new Error(`Radar ${t} must use a quoted label.`)}let i="";for(let r=1;r<e.length-1;r++){const o=e[r];if(o!=="\\"){i+=o;continue}r++;if(r>=e.length-1)throw new Error(`Radar ${t} has an incomplete escape.`);const s=e[r];i+=s==="n"?"\n":s==="r"?"\r":s==="t"?" ":s==="b"?"\b":s==="f"?"\f":s}return i}var k5=["showLegend","graticule","accTitle","accDescr","title","ticks","curve","axis","max","min"];function iN(e,t){for(const n of k5){if(e.slice(t,t+n.length).toLowerCase()!==n.toLowerCase())continue;const i=e[t+n.length];if(i===void 0||/[\s:]/.test(i))return n}return void 0}function C5(e,t){const n=[];let i=0;while(i<e.length){while(i<e.length&&/\s/.test(e[i]))i++;if(i>=e.length)break;const r=i;const o=iN(e,i);if(o&&/^(?:title|accTitle)$/i.test(o)){while(i<e.length&&e[i]!=="\n"&&e[i]!=="\r")i++;const u=e.slice(r,i).trim();if(u){n.push(u);if(ie("radar"))Ge("radar",o,u,{offset:r+t,endOffset:i+t,unit:"normalized"})}continue}if(o?.toLowerCase()==="accdescr"){let u=i+o.length;while(u<e.length&&/[\t ]/.test(e[u]))u++;if(e[u]===":"){u++;while(u<e.length&&/[\t ]/.test(e[u]))u++}if(e[u]==="{"){const h=e.indexOf("}",u+1);if(h<0)throw new Error(`Radar statement is missing a closing "}": "${e.slice(r).trim()}"`);i=h+1;n.push(e.slice(r,i).trim());if(ie("radar"))Ge("radar",o,n[n.length-1],{offset:r+t,endOffset:i+t,unit:"normalized"});continue}while(i<e.length&&e[i]!=="\n"&&e[i]!=="\r")i++;const f=e.slice(r,i).trim();if(f){n.push(f);if(ie("radar"))Ge("radar",o,f,{offset:r+t,endOffset:i+t,unit:"normalized"})}continue}let s=0;let a=0;let l=null;let c=false;for(;i<e.length;i++){const u=e[i];if(c){c=false;continue}if(l&&u==="\\"){c=true;continue}if(u==='"'||u==="'"){if(l===u)l=null;else if(l===null)l=u;continue}if(l)continue;if(u==="[")s++;else if(u==="]")s--;else if(u==="{")a++;else if(u==="}")a--;if(s<0||a<0){throw new Error(`Radar statement has an unexpected closing delimiter: "${e.slice(r,i+1).trim()}"`)}if((u==="\n"||u==="\r")&&s===0&&a===0)break;if(/[\t ]/.test(u)&&s===0&&a===0){let f=i+1;while(f<e.length&&/[\t ]/.test(e[f]))f++;let h=i-1;while(h>=r&&/[\t ]/.test(e[h]))h--;if(e[h]!==","&&iN(e,f))break}}if(l||s!==0||a!==0){throw new Error(`Radar statement has unbalanced quotes or delimiters: "${e.slice(r,i).trim()}"`)}const d=e.slice(r,i).trim();if(d){n.push(d);if(ie("radar"))Ge("radar",o??"unrecognized",d,{offset:r+t,endOffset:i+t,unit:"normalized"})}}return n}function Mh(e,t){const n=e.trim();if(n.startsWith("-")||n.startsWith("+")){throw new Error(`Radar ${t} "${n}" has a sign \u2014 radar numbers must be non-negative (the grammar has no sign token).`)}if(!b5.test(n))throw new Error(`Radar ${t} "${n}" is not a valid number.`);const i=Number.parseFloat(n);if(!Number.isFinite(i))throw new Error(`Radar ${t} "${n}" is not finite.`);return i}function P5(e){const t=Mh(e,"ticks");if(!Number.isInteger(t)||t<1||t>tN){throw new Error(`Radar ticks must be an integer from 1 through ${tN}, got "${e.trim()}".`)}return t}function E5(e){const t=e.match(S5);if(!t){throw Je({what:`Invalid radar axis: "${e}"`,expectedForm:'an id (not ending in "-") with an optional quoted label',example:'axis speed["Top Speed"], range'})}const n=t[1];const i=t[2]!==void 0?yt(aN(t[2],`axis "${n}" label`)):n;return{id:n,label:i}}function R5(e,t){const n=e.match(w5);if(!n){throw Je({what:`Invalid radar curve: "${e}"`,expectedForm:'an id (not ending in "-") with an optional quoted label and a `{\u2026}` value block',example:'curve a["Alice"]{85, 90, 80}'})}const i=n[1];const r=n[2]!==void 0?yt(aN(n[2],`curve "${i}" label`)):i;const o=Ly(n[3],`curve "${i}" value block`);const s=o.map(u=>!/^[+-]?(?:\d|\.)/.test(u));const a=s.some(Boolean);const l=s.every(Boolean);if(a&&!l){throw new Error(`Radar curve "${i}" mixes positional and keyed entries \u2014 use one form.`)}if(!a)return{id:i,label:r,values:o.map(u=>Mh(u,`curve "${i}" value`))};if(t.length===0){throw new Error(`Radar curve "${i}" uses keyed entries (axis: value) but no axes are declared.`)}const c=new Map;for(const u of o){const f=u.match(M5);if(!f)throw new Error(`Radar curve "${i}" has an invalid keyed entry: "${u}".`);const h=f[1];const m=Mh(f[2],`curve "${i}" entry for "${h}"`);if(!c.has(h)){c.set(h,m);if(ie("radar"))ue("radar","setCurveAxisValue",{curve:i,axis:h,value:m})}}const d=t.map(u=>{const f=c.get(u.id);if(f===void 0)throw new Error(`Radar curve "${i}" is missing an entry for axis "${u.id}".`);if(ie("radar"))ue("radar","resolveCurveAxisValue",{curve:i,axis:u.id,value:f});return f});return{id:i,label:r,values:d}}function lN(e,t={}){const n=aa(e.join("\n").split(/\r?\n/),oN);const i=Wt(n.map(Gt));pr(i);const r=i.familyLines.join("\n").trimStart();if(!r)throw new Error("Radar chart is empty");const o=r.match(p5);if(!o)throw new Error(`Radar chart must start with "radar-beta", got: "${r.split(/\r?\n/,1)[0]}"`);if(ie("radar"))Ge("radar","header",o[0],{offset:0,endOffset:o[0].length,unit:"normalized"});const s=C5(r.slice(o[0].length),o[0].length);let a=t.title;if(a!==void 0&&ie("radar"))ue("radar","setFrontmatterTitle",a);const l={...i.accessibility.title!==void 0?{title:yt(i.accessibility.title)}:{},...i.accessibility.descr!==void 0?{description:yt(i.accessibility.descr)}:{}};const c=[];const d=[];let u=0;let f;let h=5;let m="circle";let p=true;const g={};for(let b=0;b<s.length;b++){const S=s[b];let x;const k=Tt(S.split("\n"),0);if(k===void 0)throw new Error('Radar accDescr block is missing a closing "}"');if(k!==null){const w=yt(k.value);if(k.title){g.title=k.value;if(i.accessibility.title===void 0)l.title=w}else{g.descr=k.value;if(i.accessibility.descr===void 0)l.description=w}if(ie("radar"))ue("radar",k.title?"setAccessibilityTitle":"setAccessibilityDescription",w);continue}if(x=S.match(g5)){a=yt((x[1]??"").trim());if(ie("radar"))ue("radar","setTitle",a);continue}if(x=S.match(y5)){for(const w of Ly(x[1],"axis list")){if(c.length>=wh){throw new Error(`Radar charts support at most ${wh} axes.`)}c.push(E5(w));if(ie("radar"))ue("radar","appendAxis",c[c.length-1])}continue}if(x=S.match(x5)){for(const w of Ly(x[1],"curve list")){d.push(w);if(ie("radar"))ue("radar","appendPendingCurve",w)}continue}if(nN.test(S)){for(const w of Ly(S,"option list")){const C=w.match(nN);if(!C)throw new Error(`Invalid radar option: "${w}"`);const R=C[1].toLowerCase();const M=C[2].trim();switch(R){case"showlegend":if(!/^(true|false)$/i.test(M))throw new Error(`Radar showLegend must be true or false, got "${M}".`);p=M.toLowerCase()==="true";if(ie("radar"))ue("radar","setShowLegend",p);break;case"ticks":h=P5(M);if(ie("radar"))ue("radar","setTicks",h);break;case"max":f=Mh(M,"max");if(ie("radar"))ue("radar","setMax",f);break;case"min":u=Mh(M,"min");if(ie("radar"))ue("radar","setMin",u);break;case"graticule":if(M!=="circle"&&M!=="polygon")throw new Error(`Radar graticule must be circle or polygon, got "${M}".`);m=M;if(ie("radar"))ue("radar","setGraticule",m);break}}continue}throw Je({what:`Unrecognized radar chart line: "${S}"`,expectedForm:"a title, accessibility directive, axis, curve, or option (min/max/ticks/graticule/showLegend)",example:"axis a, b, c"})}const y=d.map(b=>{const S=R5(b,c);if(ie("radar"))ue("radar","resolveCurve",S);return S});if(f!==void 0&&f<=u)throw new Error(`Radar max (${f}) must be greater than min (${u}).`);return{title:a,...l.title||l.description?{accessibility:l}:{},...Object.keys(g).length>0?{statementAccessibility:g}:{},axes:c,curves:y,min:u,max:f,ticks:h,graticule:m,showLegend:p}}function cN(e){if(!Number.isFinite(e.min)||e.min<0)throw new Error(`Radar min must be a finite non-negative number, got ${e.min}.`);if(e.max!==void 0&&(!Number.isFinite(e.max)||e.max<0)){throw new Error(`Radar max must be a finite non-negative number, got ${e.max}.`)}let t=false;let n=1;for(const r of e.curves){for(const o of r.values){if(!Number.isFinite(o)||o<0)throw new Error(`Radar curve "${r.id}" contains a non-finite or negative value.`);if(!t||o>n)n=o;t=true}}const i=e.max??(t?n:1);if(!(i>e.min)){throw new Error(`Radar scale is degenerate: max (${i}) must be greater than min (${e.min}). Set an explicit \`max\`, or ensure curve values span a range.`)}return{min:e.min,max:i}}function dN(e,t){const n=Math.min(Math.max(e,t.min),t.max);return(n-t.min)/(t.max-t.min)}var v5=/^\+?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/;var uN=e=>/^sankey(?:-beta)?\s*$/i.test(e.trim());function fN(e,t={}){const n=e.findIndex(d=>d.trim().length>0&&!d.trim().startsWith("%%"));if(n<0){throw new Error("Sankey diagram is empty")}const i=e[n].trim();if(!uN(i)){throw new Error(`Sankey diagram must start with "sankey" or "sankey-beta", got: "${i}"`)}if(ie("sankey"))Ge("sankey","header",i,{line:n+1,unit:"physical"});const r=[];const o=new Set;const s=[];const a=(d,u)=>{if(!o.has(d)){o.add(d);r.push(d);if(ie("sankey"))ue("sankey","appendNode",d,{line:u,unit:"physical"})}};for(let d=n+1;d<e.length;d++){let u=e[d].replace(/\r$/,"");const f=d+1;const h=u.trim();if(uN(h)){if(ie("sankey"))Ge("sankey","header",u,{line:f,unit:"physical"});continue}if(h.length===0||h.startsWith("%%"))continue;const m=Tt(e,d);if(m){if(ie("sankey"))Ge("sankey",m.title?"accTitle":"accDescr",e.slice(d,m.endIndex+1).join("\n"),{line:f,unit:"physical"});d=m.endIndex;continue}while(L5(u)&&d+1<e.length){d++;u+=`
|
|
24
|
-
${e[d].replace(/\r$/,"")}`}const p=u.trim();if(ie("sankey"))Ge("sankey","csvRecord",u,{line:f,unit:"physical"});const g=T5(u,f);if(g.length!==3){throw Je({what:`Sankey row ${f} has ${g.length} column${g.length===1?"":"s"}: "${p}"`,expectedForm:"exactly three CSV columns: source,target,value",example:"Electricity grid,Industry,342.165"})}const[y,b,S]=g;if(y.length===0||b.length===0){throw new Error(`Sankey row ${f} has an empty ${y.length===0?"source":"target"} label: "${p}"`)}if(!v5.test(S)){throw new Error(`Sankey flow "${y}" -> "${b}" has invalid value "${S}". Values must be non-negative numbers.`)}const x=Number(S);if(!Number.isFinite(x)||x<0){throw new Error(`Sankey flow "${y}" -> "${b}" has invalid value "${S}". Values must be non-negative numbers.`)}if(y===b){throw new Error(`Sankey flow "${y}" -> "${b}" is a self-loop. Sankey diagrams must be acyclic (upstream rejects circular links).`)}a(y,f);a(b,f);s.push({source:y,target:b,value:x});if(ie("sankey"))ue("sankey","appendLink",s[s.length-1],{line:f,unit:"physical"})}if(s.length===0){throw new Error("Sankey diagram must include at least one source,target,value row")}const l=A5(s);if(ie("sankey"))ue("sankey","resolveCycle",l);if(l){throw new Error(`Sankey diagram contains a cycle: ${l.map(d=>`"${d}"`).join(" -> ")}. Sankey diagrams must be acyclic (upstream rejects circular links).`)}const c={...t.title!==void 0?{title:t.title}:{},nodes:r,links:s};if(t.title!==void 0&&ie("sankey"))ue("sankey","setFrontmatterTitle",c.title);return c}function T5(e,t){const n=[];let i=0;while(true){let r=i;while(r<e.length&&(e[r]===" "||e[r]===" "))r++;if(e[r]==='"'){let o=r+1;let s="";let a=false;while(o<e.length){const c=e[o];if(c==='"'){if(e[o+1]==='"'){s+='"';o+=2;continue}a=true;o++;break}s+=c;o++}if(!a){throw new Error(`Sankey row ${t} has an unterminated quoted field: "${e.trim()}"`)}let l=o;while(l<e.length&&(e[l]===" "||e[l]===" "))l++;if(l<e.length&&e[l]!==","){throw new Error(`Sankey row ${t} has text after a closing quote: "${e.trim()}". Escape a literal quote by doubling it ("").`)}n.push(s.trim());i=l}else{let o=e.indexOf(",",r);if(o===-1)o=e.length;const s=e.slice(i,o).trim();if(s.includes('"')){throw new Error(`Sankey row ${t} has a quote inside the unquoted field "${s}": "${e.trim()}". Quote the whole field and double each quote inside it ("").`)}n.push(s);i=o}if(i>=e.length)break;i++;if(i>=e.length){n.push("");break}}return n}function L5(e){let t=false;for(let n=0;n<e.length;n++){if(e[n]!=='"')continue;if(t&&e[n+1]==='"'){n++;continue}t=!t}return t}function A5(e){const t=[];const n=new Set;const i=new Map;for(const o of e){for(const a of[o.source,o.target]){if(!n.has(a)){n.add(a);t.push(a)}}const s=i.get(o.source);if(s)s.push(o.target);else i.set(o.source,[o.target])}const r=new Map;for(const o of t){if(r.has(o))continue;const s=[{label:o,next:0}];r.set(o,"active");while(s.length>0){const a=s[s.length-1];const l=i.get(a.label)??[];if(a.next>=l.length){r.set(a.label,"done");s.pop();continue}const c=l[a.next];a.next++;const d=r.get(c);if(d==="active"){const u=s.findIndex(f=>f.label===c);return[...s.slice(u).map(f=>f.label),c]}if(d===void 0){r.set(c,"active");s.push({label:c,next:0})}}}return void 0}function hN(e,t={}){const n=Wt(qF(e));pr(n);e=n.familyLines;const i={sections:[],...vr(Object.fromEntries(Object.entries({...t,...n.accessibility}).map(([h,m])=>[h,mc(Dn(m),"accessibility")])))};const r=UF(e[0]??"");if(r?.kind==="unsupported")throw VF(r.suffix);if(r?.direction)i.direction=r.direction;if(ie("timeline")){Ge("timeline","header",e[0]??"",{line:1,unit:"normalized"});ue("timeline","initialize",i)}let o;let s;let a=0;let l=0;let c=0;let d=1;const u=()=>{if(o)return o;o={id:`section-${a++}`,periods:[]};i.sections.push(o);if(ie("timeline"))ue("timeline","addImplicitSection",o,{line:d,unit:"normalized"});return o};const f=(h,m)=>{for(const p of m){const g=mc(p.trim(),"event");if(!g)continue;const y={id:`event-${c++}`,text:g};h.events.push(y);if(ie("timeline"))ue("timeline","addEvent",{...y,periodId:h.id},{line:d,unit:"normalized"})}};for(let h=1;h<e.length;h++){const m=e[h];d=h+1;if(ZF(m))continue;const p=m.match(KF);if(p){if(ie("timeline"))Ge("timeline","title",m,{line:h+1,unit:"normalized"});i.title=mc(p[1].trim(),"title");if(ie("timeline"))ue("timeline","setTitle",i.title,{line:h+1,unit:"normalized"});continue}const g=QF(m);if(g){if(ie("timeline"))Ge("timeline","section",m,{line:h+1,unit:"normalized"});o={id:`section-${a++}`,label:mc(g.label.trim(),"section"),periods:[]};i.sections.push(o);if(ie("timeline"))ue("timeline","addSection",o,{line:h+1,unit:"normalized"});if(g.eventSource){if(!s)throw new Error("Timeline continuation found before any period was declared");f(s,Ty(g.eventSource))}continue}const y=m.match(JF);if(y){if(ie("timeline"))Ge("timeline","continuation",m,{line:h+1,unit:"normalized"});if(!s){throw new Error("Timeline continuation found before any period was declared")}f(s,Ty(`: ${y[1]}`));continue}const b=m.match(eN);if(b){if(ie("timeline"))Ge("timeline","period",m,{line:h+1,unit:"normalized"});const S=mc(b[1].trim(),"period");const x=Ty(b[2]);if(!S){throw Je({what:`Invalid timeline period: "${m}"`,expectedForm:"Period : Event[ : Event\u2026]",example:"2025 : Launch : Beta"})}const k={id:`period-${l++}`,label:S,events:[]};f(k,x);if(k.events.length===0){throw new Error(`Timeline period "${S}" must include at least one event`)}u().periods.push(k);if(ie("timeline"))ue("timeline","addPeriod",{...k,sectionId:o.id},{line:h+1,unit:"normalized"});s=k;continue}if(!m.includes(":")&&m.trim().length>0){if(ie("timeline"))Ge("timeline","bare-period",m,{line:h+1,unit:"normalized"});const S={id:`period-${l++}`,label:mc(m.trim(),"period"),events:[]};u().periods.push(S);if(ie("timeline"))ue("timeline","addPeriod",{...S,sectionId:o.id},{line:h+1,unit:"normalized"});s=S;continue}if(ie("timeline"))Ge("timeline","invalid",m,{line:h+1,unit:"normalized"});throw Je({what:`Unsupported timeline syntax: "${m}"`,expectedForm:"a title, a section, or a period (Period : Event\u2026)",example:"2025 : Launch"})}return i}function bN(e,t={}){const n=Ay(e,t.strict===true);const i=Wt(n);const r=i.accessibility;let o=i.familyLines;if(i.unclosedIndex!==void 0){if(t.strict)throw new Error('XYChart accDescr block is missing a closing "}"');const p=i.unclosedIndex;o=i.familyLines.slice(0,p-n.length);r.descr=n.slice(p).join("\n").replace(/^[^{]*\{/,"").trim()||void 0}const s={};const a={};const l=[];const c=Ay(o,t.strict===true);let d;let u=false;let f;const h=c[0];const m=h?.match(/^xychart(?:-beta)?(?:\s+(horizontal|vertical))?$/i);if(!m&&t.strict){throw new Error(`Invalid XYChart header: "${h??""}"`)}if(m&&ie("xychart"))Ge("xychart","header",h,{line:1,unit:"normalized"});if(m?.[1]){f=m[1].toLowerCase();if(ie("xychart"))ue("xychart","setHeaderOrientation",f,{line:1,unit:"normalized"});u=f==="horizontal";if(ie("xychart"))ue("xychart","setHorizontal",u,{line:1,unit:"normalized"})}for(let p=m?1:0;p<c.length;p++){const g=c[p];const y=g.match(/^title\s+([\s\S]+)$/i);if(y){if(ie("xychart"))Ge("xychart","title",g,{line:p+1,unit:"normalized"});const k=pc(y[1]);if(k===null){if(t.strict)throw new Error(`Invalid XYChart title directive: "${g}"`)}else{d=k;if(ie("xychart"))ue("xychart","setTitle",d,{line:p+1,unit:"normalized"})}continue}const b=g.match(/^x-axis\s+([\s\S]+)$/i);if(b){if(ie("xychart"))Ge("xychart","x-axis",g,{line:p+1,unit:"normalized"});if(!mM(s,b[1],"x",p+1)&&t.strict){throw new Error(`Invalid XYChart x-axis directive: "${g}"`)}continue}const S=g.match(/^y-axis\s+([\s\S]+)$/i);if(S){if(ie("xychart"))Ge("xychart","y-axis",g,{line:p+1,unit:"normalized"});if(!mM(a,S[1],"y",p+1)&&t.strict){throw new Error(`Invalid XYChart y-axis directive: "${g}"`)}continue}const x=kN(g);if(x?.type==="bar"){if(ie("xychart"))Ge("xychart","bar",g,{line:p+1,unit:"normalized"});const k=mN(x.points,t.strict===true,p+1);l.push({type:"bar",label:x.label,data:k.values,...k.labels.some(w=>w!==void 0)?{pointLabels:k.labels}:{}});if(ie("xychart"))ue("xychart","appendSeries",l[l.length-1],{line:p+1,unit:"normalized"});continue}if(x?.type==="line"){if(ie("xychart"))Ge("xychart","line",g,{line:p+1,unit:"normalized"});const k=mN(x.points,t.strict===true,p+1);l.push({type:"line",label:x.label,data:k.values,...k.labels.some(w=>w!==void 0)?{pointLabels:k.labels}:{}});if(ie("xychart"))ue("xychart","appendSeries",l[l.length-1],{line:p+1,unit:"normalized"});continue}if(ie("xychart"))Ge("xychart","unrecognized",g,{line:p+1,unit:"normalized"});throw new Error(`Unrecognized XYChart line: "${g}"`)}if(!a.range&&l.length>0){const p=l.flatMap(w=>w.data);const g=l.some(w=>w.type==="bar");let y=g?Math.min(0,...p):Math.min(...p);let b=g?Math.max(0,...p):Math.max(...p);const S=b-y||1;const x=g&&y===0;const k=g&&b===0&&y<0;if(!x)y=y-S*.1;if(!k)b=b+S*.1;if(y>0&&y<S*.5)y=0;a.range={min:y,max:b};if(ie("xychart"))ue("xychart","deriveYAxisRange",a.range)}if(!a.range){a.range={min:0,max:100};if(ie("xychart"))ue("xychart","setFallbackYAxisRange",a.range)}return{title:d,accessibility:r.title||r.descr?{...r.title!==void 0?{title:r.title}:{},...r.descr!==void 0?{description:r.descr}:{}}:void 0,horizontal:u,headerOrientation:f,xAxis:s,yAxis:a,series:l,config:Ph({}),theme:Eh({})}}function yge(e,t={}){const n=Ph(t);return yM(e,n,Eh(t))}function yM(e,t,n){const i={...e,horizontal:e.headerOrientation?e.horizontal:t.chartOrientation==="horizontal",config:t,theme:n};if(ie("xychart"))ue("xychart","applyConfig",{horizontal:i.horizontal,config:t,theme:n});return i}var SN=/^([+-]?(?:\d+(?:\.\d+)?|\.\d+))(?:\s+([\s\S]+))?$/;function mN(e,t=false,n){const i=[];const r=[];for(const o of Fy(e)){const s=o.trim().match(SN);if(!s)throw new Error(`Invalid XYChart point: "${o.trim()}"`);const a=Number(s[1]);if(!Number.isFinite(a))throw new Error(`XYChart point must be finite: "${o.trim()}"`);const l=s[2]?.trim();if(t&&l!==void 0&&!l.startsWith('"')){throw new Error(`XYChart point labels must be double-quoted: "${o.trim()}"`)}const c=l===void 0?void 0:pc(l);if(c===null)throw new Error(`Invalid XYChart point label: "${o.trim()}"`);i.push(a);if(ie("xychart"))ue("xychart","appendSeriesValue",{index:i.length-1,value:a},{line:n,unit:"normalized"});r.push(c);if(ie("xychart"))ue("xychart","appendSeriesPointLabel",{index:r.length-1,label:c},{line:n,unit:"normalized"})}if(i.length===0)throw new Error("XYChart series must contain at least one point");return{values:i,labels:r}}var pN=String.raw`[+-]?(?:\d+(?:\.\d+)?|\.\d+)`;var fM=new RegExp(`^(${pN})\\s*-->\\s*(${pN})$`);var I5=/[^A-Za-z0-9&+=*.#_\s-]/;var F5=/[^A-Za-z&+=*.#_\s-]/;var N5=/(?<![A-Za-z])(?:xychart-beta|xychart|vertical|horizontal|[xy]-axis|title|line|bar)(?![A-Za-z0-9_])/i;function kh(e,t,n,i,r){if(!r||e.startsWith('"'))return;const o=e.startsWith("'")?"'":(i==="xychart_unquoted_axis_title"?F5:I5).exec(t)?.[0];if(o!==void 0)return r(i,`${n} ${JSON.stringify(t)} has ${JSON.stringify(o)} outside a double-quoted string, which pinned Mermaid rejects`);const s=N5.exec(t)?.[0];if(s!==void 0)r(i,`${n} ${JSON.stringify(t)} has the keyword ${JSON.stringify(s)} outside a double-quoted string, where pinned Mermaid ends the text: it rejects the line or reads another statement there`)}function mM(e,t,n,i,r){const o=t.trim();if(o.length===0)return false;const s=Iy(o);if(s&&n==="x"){const l=s.prefix;const c=l.length>0?pc(l):void 0;if(c===null)return false;const d=D5(s.contents);if(d.length===0)return false;if(r)for(const u of Fy(s.contents))kh(u,u,"XY chart category","xychart_unquoted_text",r);if(c!==void 0){kh(l,c,`XY chart ${n}-axis title`,"xychart_unquoted_axis_title",r);e.title=c;if(ie("xychart"))ue("xychart","setAxisTitle",{axis:n,title:c},{line:i,unit:"normalized"})}e.categories=d;if(ie("xychart"))ue("xychart","setAxisCategories",{axis:n,categories:d},{line:i,unit:"normalized"});delete e.range;if(ie("xychart"))ue("xychart","deleteAxisRange",n,{line:i,unit:"normalized"});delete e.rangeAuthored;if(ie("xychart"))ue("xychart","deleteAxisRangeAuthored",n,{line:i,unit:"normalized"});e.authored=true;if(ie("xychart"))ue("xychart","setAxisAuthored",{axis:n,authored:true},{line:i,unit:"normalized"});return true}const a=wN(o);if(!a)return false;if(a.title!==void 0){kh(o,a.title,`XY chart ${n}-axis title`,"xychart_unquoted_axis_title",r);e.title=a.title;if(ie("xychart"))ue("xychart","setAxisTitle",{axis:n,title:e.title},{line:i,unit:"normalized"})}if(a.range){e.range=a.range;if(ie("xychart"))ue("xychart","setAxisRange",{axis:n,range:e.range},{line:i,unit:"normalized"});e.rangeAuthored=true;if(ie("xychart"))ue("xychart","setAxisRangeAuthored",{axis:n,authored:true},{line:i,unit:"normalized"});delete e.categories;if(ie("xychart"))ue("xychart","deleteAxisCategories",n,{line:i,unit:"normalized"})}e.authored=true;if(ie("xychart"))ue("xychart","setAxisAuthored",{axis:n,authored:true},{line:i,unit:"normalized"});return true}function wN(e){const t=l=>({min:parseFloat(l[1]),max:parseFloat(l[2])});const n=e.match(fM);if(n)return{range:t(n),words:false};const i=MN(e);if(!i)return null;const r=i.rest.match(fM);if(r)return{title:i.value,range:t(r),words:false};if(i.rest.length===0)return{title:i.value,words:false};if(/^["']/.test(e))return null;let o=e;let s;const a=e.lastIndexOf("-->");if(a>=0){const l=e.slice(0,a).trimEnd();let c=l.length;while(c>0&&!/\s/.test(l[c-1]))c--;const d=`${l.slice(c)} --> ${e.slice(a+3).trim()}`.match(fM);if(!d)return null;o=l.slice(0,c).trim();s=t(d)}return/^[^"[\]]+$/.test(o)&&!o.includes("-->")?{title:o,...s?{range:s}:{},words:true}:null}var $5={subject:"XYChart text entity",example:'title "Say #quot;hi#quot;"'};function MN(e){const t=e.trim();if(t.length===0)return void 0;if(t.startsWith('"')||t.startsWith("'")){const i=O5(t);if(!i)return void 0;return{value:nn(i.value,$5),rest:t.slice(i.endIndex+1).trim()}}const n=t.match(/^([^\s]+)(?:\s+(.*))?$/);if(!n)return void 0;return{value:n[1],rest:(n[2]??"").trim()}}function pc(e){const t=e.trim();if(!t)return null;if(!t.startsWith('"')&&!t.startsWith("'"))return t;const n=MN(t);return n&&n.rest.length===0?n.value:null}function _5(e){if(!e)return void 0;const t=e.trim();return t?pc(t):void 0}function kN(e){const t=e.match(/^(bar|line)\b/i);if(!t)return null;const n=e.slice(t[0].length).trim();const i=Iy(n);if(!i)return null;const r=i.prefix.length>0?_5(i.prefix):void 0;if(r===null)return null;return{type:t[1].toLowerCase(),label:r,points:i.contents}}function Iy(e){let t=null;let n=false;let i=-1;let r=0;let o=-1;for(let s=0;s<e.length;s++){const a=e[s];if(t){if(n){n=false;continue}if(a==="\\"){n=true;continue}if(a===t)t=null;continue}if(a==='"'||a==="'"){t=a;continue}if(a==="["){if(r===0)i=s;r++;continue}if(a==="]"){if(r===0)return null;r--;if(r===0)o=s}}if(t||r!==0||i<0||o<i||e.slice(o+1).trim())return null;return{prefix:e.slice(0,i).trim(),contents:e.slice(i+1,o)}}function D5(e){const t=Fy(e);const n=[];for(const i of t){const r=pc(i);if(r===null||r.length===0)throw Je({what:`Invalid XYChart category ${JSON.stringify(i)}`,expectedForm:"nonempty categories separated by commas",example:'x-axis ["A", "B"]'});n.push(r)}return n}function Fy(e){const t=[];let n="";let i=null;let r=false;for(let o=0;o<e.length;o++){const s=e[o];if(i){n+=s;if(r){r=false;continue}if(s==="\\"){r=true;continue}if(s===i)i=null;continue}if(s==='"'||s==="'"){i=s;n+=s;continue}if(s===","){gN(t,n);n="";continue}n+=s}if(i)throw new Error("Unclosed quoted XYChart value");gN(t,n);return t}function O5(e){const t=e[0];if(t!=='"'&&t!=="'")return null;let n="";let i=false;for(let r=1;r<e.length;r++){const o=e[r];if(i){if(o===t||o==="\\")n+=o;else n+=`\\${o}`;i=false;continue}if(o==="\\"){i=true;continue}if(o===t)return{value:n,endIndex:r};n+=o}return null}function xge(e,t){if(!e.length)throw new Error("Empty XYChart text has no portable quoted spelling");const n=`"${dn(e,e.includes("%%")?'"\\%':'"\\')}"`;if(t==="quoted")return n;const i=/^[A-Za-z_][A-Za-z0-9_]*$/.test(e)&&(t!=="token"||!/\d/.test(e))&&!/^(?:title|bar|line|xychart|horizontal|vertical|accTitle|accDescr)/i.test(e);return i&&e.length>0?e:n}function gN(e,t){e.push(t.trim())}function Ph(e){const t=Sn(e,["config"])??e;const n=Sn(e,["config","xyChart"])??Sn(e,["xyChart"])??{};const i=ar(n,["chartOrientation"]);const r={width:Ao(n,["width"]),height:Ao(n,["height"]),useMaxWidth:is(n,["useMaxWidth"])??is(t,["useMaxWidth"]),useWidth:Ao(n,["useWidth"])??Ao(t,["useWidth"]),titleFontSize:Ao(n,["titleFontSize"]),titlePadding:Ch(n,["titlePadding"]),chartOrientation:i==="horizontal"||i==="vertical"?i:void 0,plotReservedSpacePercent:Ao(n,["plotReservedSpacePercent"]),showDataLabel:is(n,["showDataLabel"]),showDataLabelOutsideBar:is(n,["showDataLabelOutsideBar"]),showTitle:is(n,["showTitle"]),showLegend:is(n,["showLegend"]),legendFontSize:Ao(n,["legendFontSize"]),legendPadding:Ch(n,["legendPadding"]),xAxis:yN(n,"xAxis"),yAxis:yN(n,"yAxis")};if(ie("xychart"))ue("xychart","resolveConfig",r);return r}function Eh(e){const t=Sn(e,["config"])??e;const n=Sn(e,["config","themeVariables","xyChart"])??Sn(e,["themeVariables","xyChart"])??{};const i={backgroundColor:ar(n,["backgroundColor"]),themeCss:ar(t,["themeCSS"]),titleColor:ar(n,["titleColor"]),xAxisLabelColor:ar(n,["xAxisLabelColor"]),xAxisTickColor:ar(n,["xAxisTickColor"]),xAxisLineColor:ar(n,["xAxisLineColor"]),xAxisTitleColor:ar(n,["xAxisTitleColor"]),yAxisLabelColor:ar(n,["yAxisLabelColor"]),yAxisTickColor:ar(n,["yAxisTickColor"]),yAxisLineColor:ar(n,["yAxisLineColor"]),yAxisTitleColor:ar(n,["yAxisTitleColor"]),legendTextColor:ar(n,["legendTextColor"]),dataLabelColor:ar(n,["dataLabelColor"]),plotColorPalette:W5(n,["plotColorPalette"])};if(ie("xychart"))ue("xychart","resolveTheme",i);return i}function yN(e,t){const n=Sn(e,[t]);if(!n)return void 0;const i=is(n,["showLabel"]);const r=Ao(n,["labelFontSize"]);const o=Ch(n,["labelPadding"]);const s=is(n,["showTitle"]);const a=Ao(n,["titleFontSize"]);const l=Ch(n,["titlePadding"]);const c=is(n,["showTick"]);const d=Ch(n,["tickLength"]);const u=Ao(n,["tickWidth"]);const f=is(n,["showAxisLine"]);const h=Ao(n,["axisLineWidth"]);if(i===void 0&&r===void 0&&o===void 0&&s===void 0&&a===void 0&&l===void 0&&c===void 0&&d===void 0&&u===void 0&&f===void 0&&h===void 0){return void 0}return{showLabel:i,labelFontSize:r,labelPadding:o,showTitle:s,titleFontSize:a,titlePadding:l,showTick:c,tickLength:d,tickWidth:u,showAxisLine:f,axisLineWidth:h}}function B5(e){if(!e)return void 0;const t=im(e).map(n=>n.trim()).filter(Boolean);return t.length>0?t:void 0}function W5(e,t){const n=CE(e,t);if(n&&n.length>0){const i=n.filter(r=>typeof r==="string").map(r=>r.trim()).filter(Boolean);if(i.length>0)return i}return B5(ar(e,t))}function is(e,t){const n=kt(e,t);return typeof n==="boolean"?n:void 0}function Ao(e,t){const n=kt(e,t);return typeof n==="number"&&Number.isFinite(n)&&n>0?n:void 0}function Ch(e,t){const n=kt(e,t);return typeof n==="number"&&Number.isFinite(n)&&n>=0?n:void 0}function ar(e,t){const n=kt(e,t);return typeof n==="string"&&n.trim().length>0?n.trim():void 0}function bge(e){const t=[];const n=(o,s)=>{const a=(f,h)=>t.push({index:s,syntax:f,what:h});const l=o.match(/^title\s+([\s\S]+)$/i);if(l)return kh(l[1].trim(),l[1].trim(),"XY chart title","xychart_unquoted_text",a);const c=o.match(/^(bar|line)\s+([\s\S]+)$/i);if(c){const f=Iy(c[2].trim())?.prefix;if(f)kh(f,f,`XY chart ${c[1].toLowerCase()} label`,"xychart_unquoted_text",a);return}const d=o.match(/^([xy])-axis\s+([\s\S]+)$/i);if(!d)return;const u=d[1].toLowerCase();try{mM({},d[2],u,s+1,a)}catch(f){if(!(f instanceof Es))throw f}};const i=[];const r=Ay([...e],false,i);for(let o=1;o<r.length;o++){const s=Tt(r,o);if(s===void 0)break;if(s===null){n(r[o],i[o]);continue}o=s.endIndex;if(s.suffixLine){for(const a of Ay([s.suffixLine],false))n(a,i[o])}}return t}function xM(e){return Tr(e,{escapes:false,restOfLine:/(?<!\w)acc(?:Title|Descr)\s*:/iy,block:CN})}function Ay(e,t,n){const i=[];let r=false;const o=xM(e);for(let s=0;s<e.length;s++){const a=s;let l=e[s].trim();if(!l)continue;if(l.startsWith("%%"))continue;if(r){i.push(l);n?.push(a);if(l.includes("}"))r=false;continue}const c=/^acc(?:Title|Descr)\b/i.test(l);if(!c){const u=o[s];if(u>s){l=Rl(e,s,u).trim();s=u}}const d=c?gM(l,t):z5(l,t);for(const u of d){i.push(u);n?.push(a);const f=u.match(/^accDescr\s*:?\s*\{(.*)$/i);if(f&&!f[1].includes("}"))r=true}}return i}function z5(e,t){const n=Xr(e,CN);if(n<0)return gM(e,t);const i=e.slice(0,n).trimEnd();const r=gM(i,t);const o=r.length-1;if(o>=0&&G5.test(r[o]))r[o]=e.slice(i.length-r[o].length).trim();return r}var G5=/^acc(?:Title|Descr)\s*:/i;var CN=/(?<!\w)accDescr\s*\{/iy;var xN=/(?:title|[xy]-axis|bar|line)(?!\w)|acc(?:Title\s*:|Descr\s*[:{])/iy;function hM(e,t,n){let i=0;if(n.length>0){let o=pM(t.slice(0,n[0]).trim());for(let s=0;s<n.length;s++){const a=pM(t.slice(n[s],n[s+1]).trim());if(o&&a&&(o!=="title"||a==="data")){const l=t.slice(i,n[s]).trim();if(l)e.push(l);i=n[s];o=a}else if(o!=="title"){o=a}}}const r=t.slice(i).trim();if(r)e.push(r)}function pM(e){const t=e.match(/^(title|x-axis|y-axis)\s+([\s\S]+)$/i);if(!t){const s=kN(e);return s&&Fy(s.points).every(a=>SN.test(a.trim()))?"data":void 0}const n=t[2].trim();const i=n.startsWith('"')||n.startsWith("'");if(/^title$/i.test(t[1]))return pc(n)===null?void 0:i?"data":"title";const r=/^x/i.test(t[1])?Iy(n):null;if(r)return r.prefix&&pc(r.prefix)===null?void 0:"data";const o=wN(n);return!o?void 0:o.range||i?"data":o.words?"title":"text"}function gM(e,t){const n=[];let i="";let r=null;let o=0;let s=0;let a=false;let l=[];let c=false;let d=true;for(let u=0;u<e.length;u++){const f=e[u];if(r){i+=f;if(a){a=false;continue}if(f==="\\"){a=true;continue}if(f===r)r=null;continue}if(f==='"'||f==="'"){r=f;i+=f;continue}if(f==="["){o++;i+=f;continue}if(f==="]"){o--;i+=f;continue}if(f==="{"){s++;i+=f;continue}if(f==="}"){s--;i+=f;continue}if(f===";"&&o===0&&s===0){hM(n,i,l);i="";l=[];c=false;d=true;continue}if(d&&o===0&&s===0&&/[abltxy]/i.test(f)&&!/\w/.test(e[u-1]??" ")){xN.lastIndex=u;const h=xN.exec(e);if(h&&/^acc/i.test(h[0])){const m=[];hM(m,i,l);if(m.length===0||pM(m[m.length-1])!==void 0){n.push(...m);i="";l=[];if(!h[0].endsWith("{")){n.push(e.slice(u).trim());return n}const p=e.indexOf("}",u+h[0].length);if(p>=0){i+=e.slice(u,p+1);u=p;c=true;d=false;continue}}d=false}else if(h&&c)l.push(i.length)}if(!c&&!/\s/.test(f))c=true;i+=f}if(t&&(r||o!==0||s!==0)){throw new Error(`Unclosed XYChart delimiter in line: "${e}"`)}hM(n,i,l);return n}function ft(e){return t=>e(t)}function ht(e){return Pv(e,t=>e(t))}function mt(e,t={}){return{positioned:e,...t}}function kge(e,t){const n=Object.freeze({...e,...t,contractVersion:2,capabilityEvidence:Object.freeze([])});kv(n);return n}var Rh={width:30,height:20,labelPadding:8};var yc=240;function gc(e,t,n,i,r,o,s=0,a=_e(e,{fontSize:r,fontWeight:o,letterSpacing:s})){const l=a;const c=i==="middle"?t-l.width/2:i==="start"?t:t-l.width;return{text:a.text,block:a,x:t,y:n,anchor:i,fontSize:r,fontWeight:o,letterSpacing:s,bounds:{x:c,y:n-l.height/2,width:l.width,height:l.height},metrics:l}}function bM(e,t){const n=Math.min(e.x,t.x);const i=Math.min(e.y,t.y);const r=Math.max(e.x+e.width,t.x+t.width);const o=Math.max(e.y+e.height,t.y+t.height);return{x:n,y:i,width:r-n,height:o-i}}function $y(e,t,n){return{x:e.x+t,y:e.y+n,width:e.width,height:e.height}}function Ny(e,t,n){return{...e,x:e.x+t,y:e.y+n,bounds:$y(e.bounds,t,n)}}function PN(e,t,n,i,r){const o=n?.textTransform??t.nodeTextTransform;const s=n?.fontSize??t.nodeLabelFontSize;const a=n?.fontWeight??t.nodeLabelFontWeight;const l=n?.letterSpacing??t.nodeLetterSpacing;const c=n?.paddingX??t.nodePaddingX;const d=n?.paddingY??t.nodePaddingY;const u=_e(qe(e.label,e.labelContent),{transform:o,fontSize:s,fontWeight:a,letterSpacing:l,...e.wrap?{maxWidth:yc}:{}});const f=u.text;const h=u;const m=Math.max(h.width+c*2,i);const p=e.type==="participant"?Math.max(r,Math.ceil(h.height+d*2)):r;return{fontSize:s,fontWeight:a,letterSpacing:l,paddingX:c,paddingY:d,displayLabel:f,block:u,...e.links?{menuBlock:_e("\u22EF",{display:"literal",fontSize:10,fontWeight:400})}:{},labelMetrics:h,width:m,height:p}}function SM(e,t,n,i){if(e.type==="participant"){const u=gc(t.displayLabel,n,i+t.height/2,"middle",t.fontSize,t.fontWeight,t.letterSpacing,t.block);const f={x:n-t.width/2,y:i,width:t.width,height:t.height};return{id:e.id,label:e.label,type:e.type,...e.links?{links:{...e.links}}:{},...t.menuBlock?{menuBlock:t.menuBlock}:{},x:n,y:i,width:t.width,height:t.height,bounds:f,labelPosition:u}}const r=e.type==="actor"?i+t.height:Math.max(i+t.height,i+26);const o=Math.max(14,t.labelMetrics.lineHeight/2+5.5);const s=r+o+(t.labelMetrics.lines.length-1)/2*t.labelMetrics.lineHeight;const a=gc(t.displayLabel,n,s,"middle",t.fontSize,t.fontWeight,t.letterSpacing,t.block);const l={x:n-t.width/2,y:i,width:t.width,height:r-i};const c=bM(l,a.bounds);const d={x:c.x,y:c.y,width:c.width,height:c.height+4};return{id:e.id,label:e.label,type:e.type,...e.links?{links:{...e.links}}:{},...t.menuBlock?{menuBlock:t.menuBlock}:{},x:n,y:i,width:t.width,height:t.height,bounds:d,labelPosition:a}}function H5(e,t,n){e.x+=t;e.y+=n;e.bounds=$y(e.bounds,t,n);e.labelPosition=Ny(e.labelPosition,t,n)}function EN(e,t,n){const i=bT(e);const r=Object.freeze({value:i,prepared:vt(ST(e))});const o=_e(r.prepared,{transform:t.edgeTextTransform,fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing,...e.wrap?{maxWidth:yc}:{}});const s=o.text;const a=t.edgeLabelFontSize*fi;const l=i?o:{width:0,height:0,lines:[],lineHeight:a};const c=Math.max(e.startHead!=="none"?bn.width:0,e.centralStart?5:0);const d=Math.max(e.endHead!=="none"?bn.width:0,e.centralEnd?5:0);const u=Math.max(t.lineWidth/2,e.startHead!=="none"||e.endHead!=="none"?bn.height/2:0,e.centralStart||e.centralEnd?4.75:0);const f=Math.max(16,c+d+8);const h=l.width+f;const m=Rh.width+(l.width>0?Rh.labelPadding+l.width:0);const p=m+Math.max(12,n/2+8);const g=e.from===e.to?0:Math.ceil(Math.max(0,l.height-a));return{label:i,labelContent:r,displayLabel:s,block:o,labelMetrics:l,startPad:c,endPad:d,markerHalfHeight:u,requiredSpanWidth:h,selfRightExtent:m,requiredSelfNeighborGap:p,extraAboveHeight:g}}function RN(e,t,n,i,r,o){const s=e.from===e.to;if(s){const S=Rh.width;const x=Rh.height;const k=[{x:i,y:o},{x:i+S,y:o},{x:i+S,y:o+x},{x:r,y:o+x}];const w=i+S+Rh.labelPadding;const C=o+Math.max(x,t.labelMetrics.height)/2;const R=gc(t.displayLabel,w,C,"start",n.edgeLabelFontSize,n.edgeLabelFontWeight,n.edgeLetterSpacing,t.block);const M={x:i-t.startPad,y:o-t.markerHalfHeight,width:S+t.startPad+n.lineWidth/2,height:x+t.markerHalfHeight*2};const P=t.label?bM(M,R.bounds):M;return{from:e.from,to:e.to,label:t.label,labelContent:t.labelContent,lineStyle:e.lineStyle,startHead:e.startHead,endHead:e.endHead,centralStart:e.centralStart??false,centralEnd:e.centralEnd??false,x1:i,x2:r,y:o,isSelf:s,points:k,labelPosition:R,bounds:P}}const a=[{x:i,y:o},{x:r,y:o}];const l=(i+r)/2;const c=Math.max(2.85,n.lineWidth/2+2);const d=Math.max(10,t.labelMetrics.height/2+c);const u=o-d;const f=gc(t.displayLabel,l,u,"middle",n.edgeLabelFontSize,n.edgeLabelFontWeight,n.edgeLetterSpacing,t.block);const h=i<=r?t.startPad:t.endPad;const m=i<=r?t.endPad:t.startPad;const p=Math.min(i,r)-h;const g=Math.max(i,r)+m;const y={x:p,y:o-t.markerHalfHeight,width:g-p,height:t.markerHalfHeight*2};const b=t.label?bM(y,f.bounds):y;return{from:e.from,to:e.to,label:t.label,labelContent:t.labelContent,lineStyle:e.lineStyle,startHead:e.startHead,endHead:e.endHead,centralStart:e.centralStart??false,centralEnd:e.centralEnd??false,x1:i,x2:r,y:o,isSelf:s,points:a,labelPosition:f,bounds:b}}function j5(e,t,n){e.x1+=t;e.x2+=t;e.y+=n;e.points=e.points.map(i=>({x:i.x+t,y:i.y+n}));e.labelPosition=Ny(e.labelPosition,t,n);e.bounds=$y(e.bounds,t,n)}function vN(e){return e.blocks.map((t,n)=>{const i=uT(t);if(i)return i;const r=[];for(let s=0;s<e.notes.length;s++){const a=e.notes[s];if(a.afterIndex>=t.startIndex&&a.afterIndex<=t.endIndex){r.push(s)}}const o=[];for(let s=0;s<n;s++){const a=e.blocks[s];if(a.startIndex>=t.startIndex&&a.endIndex<=t.endIndex){const l=e.blocks.some((c,d)=>d>s&&d<n&&a.startIndex>=c.startIndex&&a.endIndex<=c.endIndex&&c.startIndex>=t.startIndex&&c.endIndex<=t.endIndex);if(!l)o.push(s)}}return{endMessageExclusive:Math.min(t.endIndex+1,e.messages.length),dividerNoteIndices:t.dividers.map(()=>-1),endNoteExclusive:r.length>0?r.at(-1)+1:e.notes.filter(s=>s.afterIndex<=t.endIndex).length,noteIndices:r,childBlockIndices:o,childSectionIndices:o.map(s=>t.dividers.filter(a=>e.blocks[s].startIndex>=a.index).length)}})}function TN(e,t,n,i,r,o){const s=e.type==="rect"?"":e.label?Su([`${e.type} [`,vt(qe(e.label,e.labelContent)),"]"]):e.type;const a=_e(s,{transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing,fontFamily:t.groupFont,...e.wrap?{maxWidth:yc}:{}});const l=a.text;const c=t.groupHeaderFontSize*fi;const d=l?a:{width:0,height:0,lines:[],lineHeight:c};const u=Math.ceil(Math.max(0,(d.lines.length-1)*d.lineHeight));const f=Math.max(t.groupPaddingX*2,t.groupLabelPaddingX*2);const h=e.type==="rect"?0:d.width+f;const m=e.type==="rect"?0:Math.max(18,t.groupHeaderFontSize+t.groupPaddingY)+u;const p=n+u;const g=i+u;const y=e.type==="rect"?t.groupPaddingY:m+t.groupPaddingY;const b=e.dividers.map(S=>{const x=_e(S.label?Su(["[",vt(qe(S.label,S.labelContent)),"]"]):"",{transform:t.edgeTextTransform,fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing,...S.wrap?{maxWidth:yc}:{}});const k=x.text;const w=S.label?x:{width:0,height:0,lines:[],lineHeight:o};const C=Math.max(14,Math.ceil(w.lineHeight/2+6));const R=Math.max(0,C-14);const M=Math.ceil(Math.max(0,(w.lines.length-1)*w.lineHeight));return{index:S.index,label:S.label,displayLabel:k,block:x,metrics:w,firstLineOffset:C,extraFontOffset:R,extraLinesHeight:M,requiredExtraBefore:r+M+R,noteContentOffset:Math.ceil(Math.max(28+M+R,C+(w.lines.length-1)/2*w.lineHeight+w.height/2+t.groupPaddingY))}});return{headerText:l,block:a,headerMetrics:d,tabWidth:h,tabHeight:m,extraHeaderLinesHeight:u,blockPadTop:p,blockHeaderExtra:g,enclosingHeaderStep:y,contentTopPadding:e.type==="rect"?t.groupPaddingY:Math.max(p,m+t.groupPaddingY),dividers:b}}function _y(e,t,n,i){const r=t.dividerNoteIndices[i]??-1;const o=t.dividerNoteIndices[i+1]??t.endNoteExclusive;return r>=0&&r<o&&n.notes[r].afterIndex<e.dividers[i].index?r:void 0}function wM(e,t,n,i,r,o,s,a,l,c,d,u,f){const h=e.startIndex<n.endMessageExclusive?s[e.startIndex]:void 0;const m=e.startIndex<n.endMessageExclusive?s[n.endMessageExclusive-1]:void 0;const p=new Set;for(let M=e.startIndex;M<n.endMessageExclusive;M++){const P=i.messages[M];if(P){p.add(r.get(P.from)??0);p.add(r.get(P.to)??0)}}for(const M of n.noteIndices){const P=i.notes[M];if(P){for(const E of P.actorIds){const v=r.get(E);if(v!==void 0)p.add(v)}}}if(p.size===0){for(let M=0;M<i.actors.length;M++)p.add(M)}let g=Number.POSITIVE_INFINITY;let y=Number.NEGATIVE_INFINITY;for(const M of p){const P=o[M];if(!P)continue;const E=P.bounds;g=Math.min(g,E.x-c.groupPaddingX);y=Math.max(y,E.x+E.width+c.groupPaddingX)}for(let M=e.startIndex;M<n.endMessageExclusive;M++){const P=s[M];if(!P)continue;g=Math.min(g,P.bounds.x-c.groupPaddingX);y=Math.max(y,P.bounds.x+P.bounds.width+c.groupPaddingX)}for(const M of n.noteIndices){const P=a[M];if(!P)continue;g=Math.min(g,P.x-c.groupPaddingX);y=Math.max(y,P.x+P.width+c.groupPaddingX)}for(const M of n.childBlockIndices){const P=l[M];if(!P)continue;g=Math.min(g,P.x-c.groupPaddingX);y=Math.max(y,P.x+P.width+c.groupPaddingX)}if(e.type!=="rect"){y=Math.max(y,g+t.tabWidth+c.groupPaddingX)}for(const M of t.dividers){if(M.label){y=Math.max(y,g+8+M.metrics.width+c.groupPaddingX)}}const b=h&&!h.isSelf&&h.labelPosition.text.includes("\n")?Math.ceil(Math.max(0,h.labelPosition.y-h.labelPosition.bounds.y-c.edgeLabelFontSize*fi/2-1e-6)):0;const S=n.noteIndices.length>0?t.contentTopPadding:t.blockPadTop;let x=f?.top??(h?h.y-(t.blockPadTop+b):u-S);let k=(m?.y??u)+c.groupPaddingY+12;for(let M=e.startIndex;M<n.endMessageExclusive;M++){const P=s[M];if(!P)continue;x=Math.min(x,P.bounds.y-Math.max(t.tabHeight,c.groupPaddingY));const E=P.isSelf?c.groupPaddingY+4:c.groupPaddingY;k=Math.max(k,P.bounds.y+P.bounds.height+E)}for(const M of p){const P=i.actors[M];const E=o[M];if(!E||P?.createMessageIndex===void 0||!s[P.createMessageIndex])continue;if(P.createMessageIndex>=e.startIndex&&P.createMessageIndex<n.endMessageExclusive){const v=t.contentTopPadding;x=Math.min(x,E.bounds.y-v);k=Math.max(k,E.bounds.y+E.bounds.height+c.groupPaddingY)}}for(const M of n.noteIndices){const P=a[M];if(!P)continue;const E=t.contentTopPadding;x=Math.min(x,P.y-E);k=Math.max(k,P.y+P.height+c.groupPaddingY)}for(const M of n.childBlockIndices){const P=l[M];if(!P)continue;x=Math.min(x,P.y-t.enclosingHeaderStep);k=Math.max(k,P.y+P.height+c.groupPaddingY)}const w=t.dividers.map((M,P)=>{const E=_y(e,n,i,P);const v=E===void 0?void 0:a[E];const L=M.index<n.endMessageExclusive?s[M.index]:void 0;if(e.type==="par_over"){if(!M.label)return{y:x+t.tabHeight,label:""};let G=v??L?.bounds;for(const[Y,W]of n.childBlockIndices.entries()){const O=l[W];if(O&&n.childSectionIndices[Y]===P+1&&i.blocks[W].startIndex===M.index&&(!G||O.y<G.y))G=O}const I=G?.x??g+8;const D=G?G.y-M.metrics.height-8:x+t.tabHeight+8+P*(M.metrics.height+8);const B=gc(M.displayLabel,I,D+M.metrics.height/2,"start",c.edgeLabelFontSize,c.edgeLabelFontWeight,c.edgeLetterSpacing,M.block);y=Math.max(y,B.bounds.x+B.bounds.width+c.groupPaddingX);k=Math.max(k,B.bounds.y+B.bounds.height+c.groupPaddingY);return{y:D,label:M.label,labelPosition:B}}const T=L?.y??u;let A=28+M.extraLinesHeight+M.extraFontOffset;if(M.label&&L?.label){const G=g+8;const I=G+M.metrics.width;const D=L.labelPosition.bounds;const B=D.x;const Y=D.x+D.width;const W=8;if(I+W>B&&G-W<Y){const O=Math.max(0,Math.ceil(T-10-(D.y+D.height/2)));A=Math.max(36+M.extraLinesHeight+M.extraFontOffset+O,Math.ceil(24+d+M.extraLinesHeight+M.extraFontOffset+O))}}const $=f?.dividerY[P];let _=$??(v?v.y-M.noteContentOffset:T-A);for(const[G,I]of n.childBlockIndices.entries()){const D=l[I];const B=i.blocks[I];if($===void 0&&D&&B?.startIndex===M.index&&n.childSectionIndices[G]===P+1){const Y=M.noteContentOffset;_=Math.min(_,D.y-Y)}}if(!M.label){return{y:_,label:M.label}}const z=_+M.firstLineOffset+(M.metrics.lines.length-1)/2*M.metrics.lineHeight;const F=gc(M.displayLabel,g+8,z,"start",c.edgeLabelFontSize,c.edgeLabelFontWeight,c.edgeLetterSpacing,M.block);k=Math.max(k,F.bounds.y+F.bounds.height+c.groupPaddingY);return{y:_,label:M.label,labelPosition:{...F,text:M.displayLabel}}});const C=e.type==="rect"?void 0:(()=>{const M=x+t.tabHeight/2;const P=gc(t.headerText,g+c.groupLabelPaddingX,M,"start",c.groupHeaderFontSize,c.groupHeaderFontWeight,c.groupLetterSpacing,t.block);return{x:g,y:x,width:t.tabWidth,height:t.tabHeight,label:{...P,text:t.headerText}}})();const R={x:g,y:x,width:y-g,height:k-x};return{type:e.type,label:e.label,...e.color?{color:e.color}:{},x:R.x,y:R.y,width:R.width,height:R.height,dividers:w,...C?{header:C}:{},bounds:R}}function Y5(e,t,n){e.x+=t;e.y+=n;e.bounds=$y(e.bounds,t,n);if(e.header){e.header={...e.header,x:e.header.x+t,y:e.header.y+n,label:Ny(e.header.label,t,n)}}for(const i of e.dividers){i.y+=n;if(i.labelPosition){i.labelPosition=Ny(i.labelPosition,t,n)}}}function MM(e,t,n){for(const i of e.actors)H5(i,t,n);for(const i of e.messages)j5(i,t,n);for(const i of e.blocks)Y5(i,t,n);for(const i of e.notes){i.x+=t;i.y+=n}for(const i of e.boxes){i.x+=t;i.y+=n;if(i.labelY!==void 0)i.labelY+=n}for(const i of e.activations){i.x+=t;i.topY+=n;i.bottomY+=n}for(const i of e.lifelines){i.x+=t;i.topY+=n;i.bottomY+=n}for(const i of e.destructions){i.x+=t;i.y+=n}}var Gn={padding:30,actorGap:140,actorHeight:40,actorPadX:16,headerGap:26,messageRowHeight:40,selfMessageHeight:30,activationWidth:10,blockPadX:10,blockPadTop:40,blockPadBottom:8,blockHeaderExtra:28,dividerExtra:24,noteWidth:60,notePadX:12,notePadY:6,noteGap:10,boxPadX:8,boxTitleSpace:22,boxPadBottom:8};var xc={nodeLabelFontSize:er.nodeLabel,edgeLabelFontSize:er.edgeLabel,groupHeaderFontSize:er.edgeLabel,nodeLabelFontWeight:Lr.nodeLabel,edgeLabelFontWeight:Lr.edgeLabel,groupHeaderFontWeight:Lr.groupHeader,nodePaddingX:Gn.actorPadX,nodePaddingY:Gn.notePadY,nodeCornerRadius:4,nodeLineWidth:et.outerBox,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:Gn.blockPadX,groupPaddingY:8,groupLabelPaddingX:6,groupLineWidth:et.outerBox};function Dy(e,t={},n={},i){const r=Xe(t,xc,i);const o=n.diagramMarginX??Gn.padding;const s=n.diagramMarginY??Gn.padding;const a=n.width??80;const l=n.noteMargin??Gn.noteGap;const c=n.activationWidth??Gn.activationWidth;const d=e.actors.map(ce=>st(i,"actor",{category:ce.id},{includeFallback:false}));const u=Math.max(n.height??Gn.actorHeight,...d.map(ce=>em("Mg",ce?.fontSize??r.nodeLabelFontSize,ce?.fontWeight??r.nodeLabelFontWeight).height+(ce?.paddingY??r.nodePaddingY)*2));const f=em("Mg",xc.edgeLabelFontSize,xc.edgeLabelFontWeight).height;const h=em("Mg",r.edgeLabelFontSize,r.edgeLabelFontWeight).height;const m=n.messageMargin??Gn.messageRowHeight;const p=Math.max(m,m+h-f);const g=Math.max(Gn.selfMessageHeight,p-10);const y=Math.max(Gn.blockPadTop,Gn.blockPadTop+(r.groupHeaderFontSize-xc.groupHeaderFontSize)+(r.groupPaddingY-xc.groupPaddingY)*2);const b=Math.max(Gn.blockHeaderExtra,y+r.groupPaddingY+20-p);if(e.actors.length===0){return LN({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:[],lifelines:[],messages:[],activations:[],blocks:[],notes:[],boxes:[],destructions:[]},e.title===void 0?void 0:qe(e.title,e.titleContent),r,o,s)}const S=e.actors.map((ce,Le)=>PN(ce.wrap===void 0&&n.wrap!==void 0?{...ce,wrap:n.wrap}:ce,r,d[Le],a,u));const x=S.map(ce=>ce.width);const k=new Map;for(let ce=0;ce<e.actors.length;ce++)k.set(e.actors[ce].id,ce);const w=e.messages.map(ce=>EN(ce.wrap===void 0&&n.wrap!==void 0?{...ce,wrap:n.wrap}:ce,r,c));const C=Array.from({length:Math.max(0,e.actors.length-1)},()=>0);for(let ce=0;ce<e.messages.length;ce++){const Le=e.messages[ce];const ve=w[ce];const He=k.get(Le.from);const je=k.get(Le.to);if(He===void 0||je===void 0)continue;if(He===je){if(He<e.actors.length-1){C[He]=Math.max(C[He],ve.requiredSelfNeighborGap)}continue}const Ke=Math.min(He,je);const ze=Math.max(He,je);const Ze=ze-Ke;const tt=e.actors[je].createMessageIndex===ce&&e.actors[je].type==="participant"?x[je]/2:0;const nt=(ve.requiredSpanWidth+tt)/Ze;for(let it=Ke;it<ze;it++){C[it]=Math.max(C[it],nt)}}const R=[];let M=o+x[0]/2;for(let ce=0;ce<e.actors.length;ce++){if(ce>0){const Le=(x[ce-1]+x[ce])/2;const ve=n.actorMargin!==void 0?Le+n.actorMargin:Math.max(Gn.actorGap,Le+40);M+=Math.max(ve,C[ce-1]??0)}R.push(M)}const P=(e.boxes??[]).flatMap((ce,Le)=>{const ve=e.actors.flatMap((je,Ke)=>je.box===Le?[Ke]:[]);const He=ce.label?_e(qe(ce.label,ce.labelContent),{transform:r.groupTextTransform,fontSize:r.groupHeaderFontSize,fontWeight:r.groupHeaderFontWeight,letterSpacing:r.groupLetterSpacing,fontFamily:r.groupFont,...ce.wrap??n.wrap?{maxWidth:yc}:{}}):void 0;return ve.length>0?[{box:ce,memberIdxs:ve,block:He}]:[]});const E=Math.max(Gn.boxTitleSpace,...P.map(ce=>(ce.block?.height??0)+8));const v=s+(P.length>0?E+6:0);const L=e.actors.map((ce,Le)=>SM(ce,S[Le],R[Le],v));const T=e.actors.flatMap((ce,Le)=>{if(ce.createMessageIndex!==void 0&&ce.createMessageIndex<e.messages.length)return[];const ve=L[Le].bounds;return[ve.y+ve.height]});const A=T.length>0?Math.max(...T):v+u;let $=A+Gn.headerGap;const _=[];const z=vN(e);const F=e.blocks.map(ce=>TN({...ce,wrap:ce.wrap??n.wrap,dividers:ce.dividers.map(Le=>({...Le,wrap:Le.wrap??n.wrap}))},r,y,b,Gn.dividerExtra,h));const G=dT(e);const I=new Map;const D=new Map;const B=new Map;const Y=new Map;const W=new Map;for(let ce=0;ce<e.blocks.length;ce++){const Le=e.blocks[ce];const ve=D.get(Le.startIndex)??[];ve.push(ce);D.set(Le.startIndex,ve);const He=z[ce];const je=He.noteIndices[0];if(je!==void 0){const Ke=B.get(je)??[];Ke.push(ce);B.set(je,Ke)}for(const Ke of He.childBlockIndices)Y.set(Ke,ce)}const O=new Set;const N=new Set;if(G){const ce=new Map(G.filter(Le=>Le.kind==="open").map(Le=>[Le.blockIndex,Le.noteIndex]));for(let Le=0;Le<e.blocks.length;Le++){const ve=e.blocks[Le];const He=z[Le];const je=new Set(He.childSectionIndices);let Ke=ve.startIndex;let ze=ce.get(Le);for(let Ze=0;Ze<=ve.dividers.length;Ze++){const tt=ve.dividers[Ze]?.index??He.endMessageExclusive;const nt=He.dividerNoteIndices[Ze]??He.endNoteExclusive;if(Ke===tt&&ze===nt&&!je.has(Ze))N.add(Le);Ke=tt;ze=nt}if(He.childBlockIndices.some(Ze=>e.blocks[Ze].startIndex===z[Ze].endMessageExclusive&&z[Ze].noteIndices.length===0))N.add(Le)}for(let Le=0;Le<e.blocks.length;Le++){const ve=Y.get(Le);if(N.has(Le)&&ve!==void 0)N.add(ve)}}const H=ce=>(D.get(ce)??[]).filter(Le=>!O.has(Le)&&z[Le].endMessageExclusive>ce);const j=ce=>ce.length===0?0:F[ce[0]].blockHeaderExtra+ce.slice(1).reduce((Le,ve)=>Le+F[ve].enclosingHeaderStep,0);for(let ce=0;ce<e.blocks.length;ce++){if(N.has(ce)||e.blocks[ce].type==="par_over")continue;const Le=F[ce];const ve=z[ce];for(const[He,je]of Le.dividers.entries()){const Ke=_y(e.blocks[ce],ve,e,He);if(Ke!==void 0){W.set(Ke,Math.max(W.get(Ke)??0,je.noteContentOffset));continue}if(je.index>=ve.endMessageExclusive)continue;let ze=je.requiredExtraBefore;for(const tt of ve.childBlockIndices){if(e.blocks[tt]?.startIndex===je.index){ze+=F[tt].blockHeaderExtra}}const Ze=I.get(je.index)??0;I.set(je.index,Math.max(Ze,ze))}}const q=new Map;const X=new Map;const V=new Map;for(let ce=0;ce<e.actors.length;ce++){const Le=e.actors[ce];if(Le.createMessageIndex!==void 0&&Le.createMessageIndex<e.messages.length){const ve=q.get(Le.createMessageIndex)??[];ve.push(ce);q.set(Le.createMessageIndex,ve)}if(Le.destroyMessageIndex!==void 0&&Le.destroyMessageIndex<e.messages.length){const ve=X.get(Le.destroyMessageIndex)??[];ve.push(Le.id);X.set(Le.destroyMessageIndex,ve)}}const ee=new Map;for(let ce=0;ce<e.notes.length;ce++){const Le=e.notes[ce];const ve=ee.get(Le.afterIndex)??[];ve.push({note:Le,index:ce});ee.set(Le.afterIndex,ve)}const re=new Array(e.notes.length);const U=new Map;const te=[];const J=4;const ae=new Map;for(const ce of e.activationEvents??[]){const Le=ae.get(ce.messageIndex)??[];Le.push(ce);ae.set(ce.messageIndex,Le)}const Q=(ce,Le)=>{const ve=U.get(ce)??[];ve.push({startY:Le,depth:ve.length});U.set(ce,ve)};const K=(ce,Le)=>{const ve=U.get(ce);if(!ve||ve.length===0)return;const{startY:He,depth:je}=ve.pop();const Ke=k.get(ce);if(Ke===void 0||Le<=He)return;te.push({actorId:ce,x:R[Ke]-c/2+je*J,topY:He,bottomY:Le,width:c})};const Z=(ce,Le)=>{for(const ve of ae.get(ce)??[]){if(ve.kind==="activate")Q(ve.actorId,Le);else K(ve.actorId,Le)}};const se=(ce,Le)=>{const ve=_e(qe(ce.text,ce.textContent),{transform:r.nodeTextTransform,fontSize:r.nodeLabelFontSize,fontWeight:r.nodeLabelFontWeight,letterSpacing:r.nodeLetterSpacing,...ce.wrap??n.wrap?{maxWidth:yc}:{}});const He=ve;const je=Math.max(Gn.noteWidth,He.width+r.nodePaddingX*2);const Ke=He.height+r.nodePaddingY*2;const ze=k.get(ce.actorIds[0]??"")??0;let Ze;if(ce.position==="left"){Ze=R[ze]-x[ze]/2-je-l}else if(ce.position==="right"){Ze=R[ze]+x[ze]/2+l}else if(ce.actorIds.length>1){const tt=k.get(ce.actorIds[ce.actorIds.length-1]??"")??ze;Ze=(R[ze]+R[tt])/2-je/2}else{Ze=R[ze]-je/2}return{text:ce.text,block:ve,x:Ze,y:Le,width:je,height:Ke,position:ce.position,actors:ce.actorIds}};const oe=new Array(e.blocks.length);const de=[];let xe=Number.NEGATIVE_INFINITY;let Me=A;let Ce=Number.NEGATIVE_INFINITY;let pe=0;let Te=0;let Fe=0;let De=0;const Be=new Map;const me=(ce,Le,ve)=>{let He=0;const je=[];for(const[Ke,ze]of Be){const Ze=e.blocks[Ke];for(let tt=Ze.startIndex;tt<ze.messageEnd;tt++)if(_[tt])je.push(_[tt].bounds);for(const tt of z[Ke].noteIndices)if(tt<ze.noteEnd&&re[tt])je.push(re[tt]);for(const tt of ze.priorChildren)if(oe[tt])je.push(oe[tt]);for(const[tt,nt]of Ze.dividers.entries()){const it=F[Ke].dividers[tt];if(!nt.label)continue;const $t=_y(Ze,z[Ke],e,tt);const yn=$t!==void 0&&$t<ze.noteEnd?re[$t]:$t===void 0&&nt.index<ze.messageEnd?_[nt.index]?.bounds:void 0;if(yn)je.push({x:yn.x,y:yn.y-it.metrics.height-8,width:it.metrics.width,height:it.metrics.height});if($t===void 0&&Le===nt.index||$t!==void 0&&ve===$t){const wt=it.metrics.height+8;ce={x:ce.x,y:ce.y-wt,width:Math.max(ce.width,it.metrics.width),height:ce.height+wt}}}}for(let Ke=0;Ke<=je.length;Ke++){const ze=je.find(Ze=>ce.x<Ze.x+Ze.width+8&&ce.x+ce.width+8>Ze.x&&ce.y+He<Ze.y+Ze.height+8&&ce.y+ce.height+He+8>Ze.y);if(!ze)break;He=ze.y+ze.height+8-ce.y}return He};const he=ce=>{const Le=[];for(let ve=ce;ve!==void 0&&!O.has(ve);ve=Y.get(ve))Le.push(ve);for(let ve=Le.length-1;ve>=0;ve--){const He=Le[ve];const je=Math.max(Me,xe,Ce)+8;de[He]={top:je,dividerY:[]};O.add(He);Me=Ce=je+F[He].enclosingHeaderStep}};const fe=ce=>{const Le=e.blocks[ce];const ve=z[ce];const He=de[ce]?.top;const je=He!==void 0&&Le.startIndex===ve.endMessageExclusive&&ve.noteIndices.length===0?He+F[ce].blockPadTop:re[ve.noteIndices[0]??-1]?.y??$;O.add(ce);const Ke=wM(Le,F[ce],ve,e,k,L,_,re,oe,r,h,je,de[ce]);oe[ce]=Ke;xe=Math.max(xe,Ke.y+Ke.height);const ze=Be.get(ce);if(ze){Me=Math.max(Me,ze.bottom,xe);$=Math.max($,Me+p/2);Be.delete(ce)}};const be=()=>{if(G){while(Fe<G.length){const ce=G[Fe];if(ce.messageIndex>_.length||ce.noteIndex>pe)break;const Le=ce.blockIndex;if(ce.kind==="open"&&N.has(Le))he(Le);if(ce.kind==="open"&&e.blocks[Le].type==="par_over"){he(Le);const ve=Math.max(0,...F[Le].dividers.map(He=>He.noteContentOffset));Ce+=ve;Me=Ce;$=Math.max($,Ce+p/2);Be.set(Le,{messageY:$,contentBottom:Me,completedBottom:xe,reservedBottom:Ce,bottom:Me,messageEnd:e.blocks[Le].startIndex,noteEnd:ce.noteIndex,priorChildren:[]});De++}if(ce.kind==="divider"){const ve=Be.get(Le);if(ve){ve.bottom=Math.max(ve.bottom,Me,xe,Ce);ve.messageEnd=ce.messageIndex;ve.noteEnd=ce.noteIndex;ve.priorChildren=z[Le].childBlockIndices.filter(Ke=>oe[Ke]);({messageY:$,contentBottom:Me,completedBottom:xe,reservedBottom:Ce}=ve);De++;Fe++;continue}const He=F[Le].dividers[ce.dividerIndex];const je=Math.max(Me,xe,Ce)+8;if(N.has(Le)){de[Le].dividerY[ce.dividerIndex]=je;Me=Ce=je+He.noteContentOffset}else{Ce=je+He.noteContentOffset}}if(ce.kind==="close")fe(Le);Fe++}return}while(Te<e.blocks.length){const ce=Te;const Le=z[ce];if(Le.endMessageExclusive>_.length||Le.endNoteExclusive>pe)break;fe(ce);Te++}};const ge=(ce,Le)=>{let ve=Le;for(const{note:He,index:je}of ee.get(ce)??[]){const Ke=De;be();if(Ke!==De)ve=$;ve=Math.max(ve,xe+8,Ce);for(const it of B.get(je)??[]){const $t=de[it]?.top;if($t!==void 0)ve=Math.max(ve,$t+F[it].contentTopPadding)}const ze=(B.get(je)??[]).filter(it=>!O.has(it));const Ze=W.get(je)??0;if(ze.length>0||Ze>0){const it=Ze+(ze.length>0?F[ze[0]].contentTopPadding+ze.slice(1).reduce(($t,yn)=>$t+F[yn].enclosingHeaderStep,0):0);ve=Math.max(ve,Math.max(Me,xe)+8+it);for(const $t of ze)O.add($t)}let tt=se(He,ve);const nt=me(tt,void 0,je);if(nt>0){ve+=nt;tt=se(He,ve)}re[je]=tt;Me=Math.max(Me,tt.y+tt.height);pe=je+1;ve=tt.y+tt.height+4}if(ee.has(ce))$=Math.max($,ve+p/2)};ge(-1,$);for(let ce=0;ce<e.messages.length;ce++){const Le=e.messages[ce];const ve=w[ce];const He=k.get(Le.from)??0;const je=k.get(Le.to)??0;const Ke=Le.from===Le.to;be();const ze=H(ce);let Ze=Math.max(I.get(ce)??0,j(ze));for(const Fn of q.get(ce)??[]){const Qn=L[Fn].height/2;Ze=Ze>0?Ze+Math.max(0,Qn-12):Qn+8}$+=Ze+ve.extraAboveHeight;const tt=R[He];const nt=R[je];const it=e.actors[je].createMessageIndex===ce&&e.actors[je].type==="participant";const $t=it&&!Ke?nt-Math.sign(nt-tt)*x[je]/2:nt;const yn=()=>{const Fn=RN(Le,ve,r,tt,$t,$);_[ce]=Fn;for(const Qn of q.get(ce)??[]){L[Qn]=SM(e.actors[Qn],S[Qn],R[Qn],$-L[Qn].height/2)}return Fn};let wt=yn();let ui=wt.bounds.y;let ll=0;const _x=new Set(ze);const g1=(D.get(ce)??[]).filter(Fn=>_x.has(Fn)||de[Fn]?.top!==void 0&&!oe[Fn]);if(g1.length>0){const Fn=[];for(const Qn of g1){for(const Ox of z[Qn].childBlockIndices)if(oe[Ox])Fn[Ox]=oe[Ox];Fn[Qn]=wM(e.blocks[Qn],F[Qn],z[Qn],e,k,L,_,re,Fn,r,h,$,de[Qn]);const mu=de[Qn]?.top;if(mu!==void 0)ll=Math.max(ll,mu-Fn[Qn].y);else ui=Math.min(ui,Fn[Qn].y)}}const rB=ze.length>0?Math.max(Me,xe,Ce):Math.max(xe,Ce);const y1=Math.max(0,ll,rB+(ze.length>0?8:0)-ui);if(y1>0){$+=y1;wt=yn()}const x1=me(wt.bounds,ce);if(x1>0){$+=x1;wt=yn()}for(const Fn of ze)O.add(Fn);Me=Math.max(Me,wt.bounds.y+wt.bounds.height,...(q.get(ce)??[]).map(Fn=>L[Fn].bounds.y+L[Fn].bounds.height));Z(ce,$);const b1=X.get(ce);if(b1)for(const Fn of b1)V.set(Fn,$);if(Le.activate)Q(Le.to,$);if(Le.deactivate)K(Le.from,$);const S1=Ke?Math.max(g,Math.ceil(ve.labelMetrics.height)+10):0;$+=Ke?S1+p:p;const Dx=q.get(ce);if(Dx){const Fn=Math.max(...Dx.map(Qn=>{const mu=L[Qn];return mu.bounds.height-mu.height/2}));$+=Fn}const oB=Dx?Me+8:wt.y+S1+14;ge(ce,oB)}be();const Re=Math.max(_[_.length-1]?.y??$,$-p/2);Z(e.messages.length,Re);for(const[ce,Le]of U){while(Le.length>0)K(ce,Re)}for(const ce of L)if(e.actors[k.get(ce.id)]?.external)ce.external=true;for(const[ce,Le]of _.entries()){const ve=e.messages[ce];if(ve.id!==void 0)Le.id=ve.id;if(ve.parentId!==void 0)Le.parentId=ve.parentId}for(const[ce,Le]of oe.entries()){const ve=e.blocks[ce];if(ve.id!==void 0)Le.id=ve.id;if(ve.parentId!==void 0)Le.parentId=ve.parentId}for(const[ce,Le]of re.entries()){const ve=e.notes[ce];if(Le&&ve?.id!==void 0)Le.id=ve.id;if(Le&&ve?.parentId!==void 0)Le.parentId=ve.parentId}const Ie=re.filter(ce=>ce!==void 0);const ne=oe.reduce((ce,Le)=>Math.max(ce,Le.y+Le.height),0);if(ne>0){$=Math.max($,ne+8)}const we=$;const Ee=P.map(({box:ce,memberIdxs:Le,block:ve})=>{const He=Math.min(...Le.map(ze=>L[ze].bounds.x))-Gn.boxPadX;let je=Math.max(...Le.map(ze=>L[ze].bounds.x+L[ze].bounds.width))+Gn.boxPadX;if(ce.label){const ze=ve.width;je=Math.max(je,He+ze+Gn.boxPadX*2)}const Ke=s;return{label:ce.label,block:ve,labelY:s+E/2,color:ce.color,x:He,y:Ke,width:je-He,height:we+Gn.boxPadBottom-Ke}});const ke=$+s;let le=o;let Se=0;for(const ce of L){const Le=ce.bounds;le=Math.min(le,Le.x);Se=Math.max(Se,Le.x+Le.width)}for(const ce of oe){le=Math.min(le,ce.x);Se=Math.max(Se,ce.x+ce.width)}for(const ce of Ie){le=Math.min(le,ce.x);Se=Math.max(Se,ce.x+ce.width)}for(const ce of Ee){le=Math.min(le,ce.x);Se=Math.max(Se,ce.x+ce.width)}for(const ce of te){le=Math.min(le,ce.x);Se=Math.max(Se,ce.x+ce.width)}for(const ce of _){le=Math.min(le,ce.bounds.x);const Le=ce.isSelf&&ce.label?8:0;Se=Math.max(Se,ce.bounds.x+ce.bounds.width+Le)}const Pe=le<o?o-le:0;if(Pe>0){MM({actors:L,messages:_,blocks:oe,notes:Ie,boxes:Ee,activations:te,lifelines:[],destructions:[]},Pe,0);for(let ce=0;ce<R.length;ce++)R[ce]+=Pe}const Ae=e.actors.map((ce,Le)=>{const ve=L[Le];const He=ve.bounds.y+ve.bounds.height;return{actorId:ce.id,x:R[Le],topY:He,bottomY:V.get(ce.id)??ke-s}});const Ne=e.actors.filter(ce=>V.has(ce.id)).map(ce=>({actorId:ce.id,x:R[k.get(ce.id)],y:V.get(ce.id)}));const Oe=Se+Pe+o;const We=ke;return LN({width:Math.max(Oe,200),height:Math.max(We,100),accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:L,lifelines:Ae,messages:_,activations:te,blocks:oe,notes:Ie,boxes:Ee,destructions:Ne},e.title===void 0?void 0:qe(e.title,e.titleContent),r,o,s)}function LN(e,t,n,i,r){const o=tn(t,n);if(!o)return e;if(e.width===0&&e.height===0)return{...e,...da(o,i,r)};const s=o.height;MM(e,0,s);const a=Math.max(e.width,o.width+2*i);return{...e,width:a,height:e.height+s,title:rn(o,a,r)}}function Mi(e,t,n,i,r){const o={};if(r){o["role"]="img";o["aria-roledescription"]=r}else if(e||t){o["role"]="img"}if(e)o["aria-labelledby"]=n;if(t)o["aria-describedby"]=i;return o}function AN(e){const t=new Map;const n=[];for(const s of e){const a=`${s.from}->${s.to}`;const l=t.get(a)??0;t.set(a,l+1);if(!s.labelPosition.text.trim())continue;const c=s.labelPosition.bounds;n.push({key:`${a}#${l}`,x:c.x-2,y:c.y-2,width:c.width+4,height:c.height+4})}const i=s=>{const a=s==="x"?"width":"height";const l=[...n].sort((u,f)=>u[s]-f[s]);const c=(u,f)=>{if(u>=f)return void 0;const h=u+f>>>1;const m=l[h];const p=c(u,h);const g=c(h+1,f);return{area:m,left:p,right:g,end:Math.max(m[s]+m[a],p?.end??-Infinity,g?.end??-Infinity)}};const d=c(0,l.length);return u=>{const f=[];const h=m=>{if(!m||m.end<u[s])return;h(m.left);const p=m.area;if(p[s]>u[s]+u[a])return;if(p.x<=u.x+u.width&&p.x+p.width>=u.x&&p.y<=u.y+u.height&&p.y+p.height>=u.y)f.push(p);h(m.right)};h(d);return f}};const r=i("x");const o=i("y");return(s,a)=>{const l=(a==="x"?r:o)(s).sort((h,m)=>h.y-m.y);const c=[];const d=s.y+s.height;let u=s.y;let f;for(const h of l){const m=Math.max(s.y,h.y);if(m>u)c.push({top:u,bottom:m,after:f});const p=Math.min(d,h.y+h.height);if(p>u){u=p;f=h.key}}if(u<d)c.push({top:u,bottom:d,after:f});return c}}function CM(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=[];const c=Xe(o,xc,r.styleFace);const d=`seq-${mi(n.width,n.height,n.actors.length,n.messages.length)}`;const u=`${d}-title`;const f=`${d}-desc`;const h=Mi(n.accessibilityTitle,n.accessibilityDescription,u,f);l.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},Ot(n.width,n.height,i,a,h)+"\n"+Dt(s,false,i.shadow,i.embedFontImport)));const m=[];m.push("<defs>");const p=X5(c);m.push(hi(p));const g=Zt(i);if(g)m.push(g);m.push("</defs>");l.push(e.definitions({id:"defs",markerResources:p},m.join("\n")));if(n.accessibilityTitle){l.push(e.documentContent({id:"a11y-title",role:"chrome",nonPaint:"accessibility"},`<title id="${u}">${It(n.accessibilityTitle)}</title>`))}if(n.accessibilityDescription){l.push(e.documentContent({id:"a11y-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${f}">${It(n.accessibilityDescription)}</desc>`))}const y=n.blocks.some(T=>T.type==="rect");const b=y?[...n.blocks].reverse().sort((T,A)=>A.width*A.height-T.width*T.height):n.blocks;const S=q5(n.boxes,b,c,i);if(n.title)l.push(e.text(En(n.title,c)));const x=new Map;for(const T of n.boxes){const A=T.label??"";const $=x.get(A)??0;x.set(A,$+1);l.push(e6(e,T,c,`box:${A}#${$}`))}const k=new Map;const w=new Map;for(const T of n.blocks){const A=k.get(T.type)??0;k.set(T.type,A+1);w.set(T,T.id??`block:${T.type}#${A}`)}for(const T of b){l.push(kM(e,T,c,w.get(T),y?"background":"all"))}if(y){for(const T of b){if(T.type!=="rect")l.push(kM(e,T,c,w.get(T),"frame"))}for(const T of n.blocks){if(T.dividers.length>0)l.push(kM(e,T,c,w.get(T),"dividers"))}}const C=AN(n.messages);const R=new Set(n.actors.filter(T=>T.external).map(T=>T.id));for(const T of n.lifelines){if(R.has(T.actorId))continue;const A=Math.max(.75,c.lineWidth*.75);l.push(V5(e,T,c,C({x:T.x-A/2,y:T.topY,width:A,height:T.bottomY-T.topY},"x")))}const M=new Map;for(const T of n.activations){const A=M.get(T.actorId)??0;M.set(T.actorId,A+1);l.push(K5(e,T,c,`activation:${T.actorId}#${A}`,C({x:T.x-et.innerBox/2,y:T.topY,width:T.width+et.innerBox,height:T.bottomY-T.topY},"y")))}const P=new Map;for(const T of n.blocks){const A=P.get(T.type)??0;P.set(T.type,A+1);if(T.type!=="rect"&&T.header)l.push(Z5(e,T.header,c,w.get(T)))}const E=new Map;for(const T of n.blocks){const A=E.get(T.type)??0;E.set(T.type,A+1);if(T.dividers.some($=>$.label))l.push(Q5(e,T,c,w.get(T),S))}const v=new Map;for(const T of n.messages){const A=`${T.from}->${T.to}`;const $=v.get(A)??0;v.set(A,$+1);l.push(J5(e,T,c,T.id??`message:${A}#${$}`,S,p))}const L=new Map;for(const T of n.notes){const A=`${(T.actors??[]).join(",")}@${T.position??"over"}`;const $=L.get(A)??0;L.set(A,$+1);l.push(i6(e,T,c,i,T.id??`note:${A}#${$}`))}for(const T of n.destructions){l.push(n6(e,T,c))}for(const T of n.actors){if(T.external)continue;l.push(U5(e,T,c,i,r.styleFace,o.security!=="strict",S))}l.push(e.documentClose());return{family:"sequence",width:n.width,height:n.height,colors:i,transparent:a,parts:l}}function vh(e){return e.halo?{stroke:e.halo,strokeWidth:"3",strokeLinejoin:"round",paintOrder:"stroke"}:{}}function Oy(e){return{x:e.x+e.width/2,y:e.y+e.height/2,width:e.width,height:e.height}}function q5(e,t,n,i){const r=(c,d,u)=>d>=c.x&&d<=c.x+c.width&&u>=c.y&&u<=c.y+c.height;const o=e.flatMap(c=>{const d=c.color&&c.color.toLowerCase()!=="transparent"?Mw(c.color):void 0;return d?[{x:c.x,y:c.y,width:c.width,height:c.height,hex:d,authored:true}]:[]});const s=_n("var(--bg)",i)??"#ffffff";for(const c of t){const d=FN(c,n);const u=d===void 0?void 0:_n(d,i)??d;const f=u===void 0?null:Vt(u);if(!f||f[3]===0)continue;const h=c.x+c.width/2;const m=c.y+c.height/2;const p=o.findLast(y=>r(y,h,m))?.hex??s;const g=gu(u,p);if(!g)continue;o.push({x:c.x,y:c.y,width:c.width,height:c.height,hex:Yn(...g),authored:c.type==="rect"})}const a=(c,d)=>d.x-d.width/2<c.x+c.width&&d.x+d.width/2>c.x&&d.y-d.height/2<c.y+c.height&&d.y+d.height/2>c.y;const l=(c,d)=>r(c,d.x-d.width/2,d.y-d.height/2)&&r(c,d.x+d.width/2,d.y+d.height/2);return(c,d)=>{const u=o.findLastIndex(g=>r(g,c.x,c.y));const f=o[u];const h=f!==void 0&&!l(f,c)||o.some((g,y)=>y>u&&g.hex!==f?.hex&&a(g,c));if(!f)return h?{ink:d,halo:"var(--bg)"}:{ink:d};const m=_n(d,i);const p=m?ms(m,f.hex):Ho(f.hex)??d;return f.authored||h?{ink:p,halo:f.hex}:{ink:p}}}function X5(e){const t=bn.width;const n=bn.height;const i=e.edgeStrokeColor??"var(--_arrow)";const r={size:{width:t,height:n},orient:"auto-start-reverse"};const o=[{x:0,y:0},{x:t,y:n/2},{x:0,y:n}];return[{...r,id:"seq-arrow",shape:"arrow",ref:{x:t,y:n/2},geometry:{kind:"polygon",points:o},paint:{fill:i}},{...r,id:"seq-arrow-open",shape:"open-arrow",ref:{x:t,y:n/2},geometry:{kind:"polyline",points:o},paint:{fill:"none",stroke:i,strokeWidth:"1"}},{...r,id:"seq-arrow-cross",shape:"cross",ref:{x:t/2,y:n/2},orient:"auto",geometry:{kind:"path",d:`M1 1 L${t-1} ${n-1} M1 ${n-1} L${t-1} 1`},paint:{fill:"none",stroke:i,strokeWidth:"1.5"}},{...r,id:"seq-arrow-half-top",shape:"arrow",ref:{x:t,y:n/2},geometry:{kind:"polygon",points:[{x:0,y:0},{x:t,y:n/2},{x:0,y:n/2}]},paint:{fill:i}},{...r,id:"seq-arrow-half-bottom",shape:"arrow",ref:{x:t,y:n/2},geometry:{kind:"polygon",points:[{x:0,y:n/2},{x:t,y:n/2},{x:0,y:n}]},paint:{fill:i}},{...r,id:"seq-arrow-stick-top",shape:"open-arrow",ref:{x:t,y:n/2},geometry:{kind:"path",d:`M0 0 L${t} ${n/2}`},paint:{fill:"none",stroke:i,strokeWidth:"1.5"}},{...r,id:"seq-arrow-stick-bottom",shape:"open-arrow",ref:{x:t,y:n/2},geometry:{kind:"path",d:`M0 ${n} L${t} ${n/2}`},paint:{fill:"none",stroke:i,strokeWidth:"1.5"}}]}function IN(e,t){if(t==="none")return void 0;const n=t==="filled"?"seq-arrow":t==="cross"?"seq-arrow-cross":t==="half-top"?"seq-arrow-half-top":t==="half-bottom"?"seq-arrow-half-bottom":t==="stick-top"?"seq-arrow-stick-top":t==="stick-bottom"?"seq-arrow-stick-bottom":"seq-arrow-open";return e.find(i=>i.id===n)}function U5(e,t,n,i,r,o,s){const{id:a,x:l,y:c,width:d,height:u,label:f,type:h}=t;const m=[];const p=st(r,"actor",{category:a},{includeFallback:false});const g=p?.fontSize??n.nodeLabelFontSize;const y=p?.fontWeight??n.nodeLabelFontWeight;const b=p?.letterSpacing??n.nodeLetterSpacing;const S=p?.textTransform??n.nodeTextTransform;const x=p?.lineWidth??n.nodeLineWidth;const k=p?.fillColor??n.nodeFillColor??"var(--_node-fill)";const w=p?.borderColor??n.nodeBorderColor??"var(--_node-stroke)";const C=p?.textColor??n.nodeTextColor??"var(--_text)";const R=p?.textColor??n.nodeTextColor??yi("var(--_text)",k,i);const M=o&&t.links?` data-links="${Ye(JSON.stringify(t.links))}" role="link" tabindex="0"`:"";const P=`<g class="actor" data-id="${Ye(a)}" data-label="${hn(f)}" data-type="${h}"${M}>`;const{text:E,x:v,y:L,bounds:T}=t.labelPosition;const A=s(Oy(T),C);if(h==="actor"){const _=u/24*.9;const z=l-12*_;const F=c+(u-24*_)/2;const G=x/_;m.push({indent:2,node:e.pathArtwork({id:`actor:${a}:icon`,owner:{id:a,role:"actor"},channels:{category:a},open:`<g transform="translate(${z},${F}) scale(${_})">`,transform:{kind:"matrix",a:_,b:0,c:0,d:_,e:z,f:F},paint:{fill:"none",stroke:p?.borderColor??n.edgeStrokeColor??"var(--_line)",strokeWidth:String(G)},join:"\n",indent:2,paths:["M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z","M15 10C15 11.6569 13.6569 13 12 13C10.3431 13 9 11.6569 9 10C9 8.34315 10.3431 7 12 7C13.6569 7 15 8.34315 15 10Z","M5.62842 18.3563C7.08963 17.0398 9.39997 16 12 16C14.6 16 16.9104 17.0398 18.3716 18.3563"]})});m.push({indent:2,node:e.text({id:`actor:${a}:label`,role:"label",text:E,block:t.labelPosition.block,x:v,y:L,fontSize:g,fontWeight:y,letterSpacing:b,anchor:"middle",paint:{fill:A.ink,...vh(A)},channels:{category:a}})})}else if(h!=="participant"){const _=l-d/2;const z=c+2;const F=d;const G=Math.max(24,u-4);const I=[];const D={id:a,role:"actor"};const B={fill:k,stroke:p?.borderColor??n.edgeStrokeColor??"var(--_line)",strokeWidth:String(x)};const Y=j=>{I.push(e.shape({id:xn(`actor:${a}:icon`,"part",I.length),role:"icon",owner:D,geometry:j,paint:B}))};const W=j=>Y({kind:"path",d:j});const O=(j,q,X)=>Y({kind:"circle",cx:j,cy:q,r:X});const N=(j,q,X,V)=>Y({kind:"line",x1:j,y1:q,x2:X,y2:V});const H=(j,q,X,V,ee)=>Y({kind:"rect",x:j,y:q,width:X,height:V,...ee===void 0?{}:{rx:ee}});if(h==="database"){Y({kind:"ellipse",cx:l,cy:z+5,rx:F/2,ry:5});W(`M${_} ${z+5}V${z+G-5}A${F/2} 5 0 0 0 ${_+F} ${z+G-5}V${z+5}`);Y({kind:"ellipse",cx:l,cy:z+G-5,rx:F/2,ry:5})}else if(h==="collections"){H(_+6,z,F-6,G-6);H(_,z+6,F-6,G-6)}else if(h==="queue"){H(_,z,F,G,G/2);N(_+8,z+G/2,_+F-8,z+G/2)}else if(h==="entity"){O(l,z+G/2-3,Math.min(F,G)/2-3);N(_+5,z+G,_+F-5,z+G)}else if(h==="boundary"){O(l+3,z+G/2,Math.min(F,G)/2-3);N(_+3,z+2,_+3,z+G-2)}else if(h==="control"){O(l,z+G/2,Math.min(F,G)/2-3);W(`M${l-4} ${z+4}L${l+4} ${z}L${l+2} ${z+8}`)}else O(l,z+G/2,Math.min(F,G)/2-3);m.push({indent:2,node:e.group({id:`actor:${a}:icon`,role:"icon",owner:D,channels:{category:a},open:`<g class="sequence-actor-glyph sequence-actor-${h}">`,close:"</g>",join:"",children:I.map(j=>({node:j,indent:0}))})});m.push({indent:2,node:e.text({id:`actor:${a}:label`,role:"label",text:E,block:t.labelPosition.block,x:v,y:L,fontSize:g,fontWeight:y,letterSpacing:b,anchor:"middle",paint:{fill:A.ink,...vh(A)},channels:{category:a}})})}else{const _=l-d/2;const z=k;const F=w;const G=p?.cornerRadius??n.cornerRadius??4;m.push({indent:2,node:e.shape({id:`actor:${a}:box`,role:"actor",geometry:{kind:"rect",x:_,y:c,width:d,height:u,rx:G,ry:G},paint:{fill:z,stroke:F,strokeWidth:String(x)},channels:{category:a}})});m.push({indent:2,node:e.text({id:`actor:${a}:label`,role:"label",text:E,block:t.labelPosition.block,x:v,y:L,fontSize:g,fontWeight:y,letterSpacing:b,anchor:"middle",paint:{fill:R},channels:{category:a}})})}const $=h==="participant"?R:C;if(t.links)m.push({indent:2,node:e.text({id:`actor:${a}:menu`,role:"icon",text:"\u22EF",block:t.menuBlock,x:l+d/2-7,y:c+10,fontSize:10,anchor:"middle",paint:{fill:$},channels:{category:a},baselineShift:0,attributes:{className:"sequence-actor-menu"}})});return e.group({id:`actor:${a}`,role:"actor",open:P,close:"</g>",children:m,channels:{category:a}})}function V5(e,t,n,i){const r=n.edgeStrokeColor??"var(--_line)";const o=Math.max(.75,n.lineWidth*.75);const s=`lifeline:${t.actorId}`;if(i.length!==1||i[0].top!==t.topY||i[0].bottom!==t.bottomY){return e.group({id:s,role:"lifeline",open:`<g class="lifeline" data-actor="${Ye(t.actorId)}">`,close:"</g>",children:i.map(a=>{const l=(a.top-t.topY)%10;return{indent:2,node:e.connector({id:a.after?xn(s,"after",a.after):xn(s,"start"),role:"lifeline",geometry:{kind:"line",x1:t.x,y1:a.top,x2:t.x,y2:a.bottom},lineStyle:"dashed",paint:{stroke:r,strokeWidth:String(o),strokeDasharray:"6 4",strokeDashoffset:String(l)}})}})})}return e.connector({id:s,role:"lifeline",geometry:{kind:"line",x1:t.x,y1:t.topY,x2:t.x,y2:t.bottomY},lineStyle:"dashed",paint:{stroke:r,strokeWidth:String(o),strokeDasharray:"6 4"},attributes:{className:"lifeline",data:{actor:t.actorId}}})}function K5(e,t,n,i,r){const o=n.nodeFillColor??"var(--_node-fill)";const s=n.nodeBorderColor??"var(--_node-stroke)";if(r.length!==1||r[0].top!==t.topY||r[0].bottom!==t.bottomY){const a=[];const l=[];const c=[];for(const d of r){l.push(`M ${t.x} ${d.top} h ${t.width} V ${d.bottom} h ${-t.width} Z`);const u=[{x1:t.x,y1:d.top,x2:t.x,y2:d.bottom},{x1:t.x+t.width,y1:d.top,x2:t.x+t.width,y2:d.bottom},...d.top===t.topY?[{x1:t.x,y1:d.top,x2:t.x+t.width,y2:d.top}]:[],...d.bottom===t.bottomY?[{x1:t.x,y1:d.bottom,x2:t.x+t.width,y2:d.bottom}]:[]];for(const f of u){c.push(`M ${f.x1} ${f.y1} L ${f.x2} ${f.y2}`)}}if(l.length){const d=l.join(" ");const u=c.join(" ");a.push({indent:2,node:e.shape({id:xn(i,"fill"),role:"activation",surfaceFragment:true,geometry:{kind:"path",d},paint:{fill:o,stroke:"none"}})});a.push({indent:2,node:e.shape({id:xn(i,"border"),role:"activation",geometry:{kind:"path",d:u},paint:{fill:"none",stroke:s,strokeWidth:String(et.innerBox)}})})}return e.group({id:i,role:"activation",open:`<g class="activation" data-actor="${Ye(t.actorId)}">`,close:"</g>",children:a})}return e.shape({id:i,role:"activation",geometry:{kind:"rect",x:t.x,y:t.topY,width:t.width,height:t.bottomY-t.topY},paint:{fill:o,stroke:s,strokeWidth:String(et.innerBox)},attributes:{className:"activation",data:{actor:t.actorId}}})}function J5(e,t,n,i,r,o){const s=[];const a=IN(o,t.startHead);const l=IN(o,t.endHead);const c=n.edgeStrokeColor??"var(--_line)";const d=n.edgeTextColor??"var(--_text-muted)";const{text:u,x:f,y:h,bounds:m}=t.labelPosition;const p={stroke:c,strokeWidth:String(n.lineWidth),...t.lineStyle==="dashed"?{strokeDasharray:"6 4"}:{}};const g={endpoints:{from:t.from,to:t.to},relationship:{kind:"sequence-message",direction:t.isSelf?"self":a&&l?"bidirectional":a?"reverse":l?"forward":"undirected"},route:{ownership:"layout"},labels:t.label?[{text:t.label,...t.labelContent?{textContent:t.labelContent}:{}}]:[]};const y=`<g class="message" data-label="${hn(t.label)}" data-line-style="${t.lineStyle}" data-start-head="${t.startHead}" data-end-head="${t.endHead}" data-central-start="${t.centralStart}" data-central-end="${t.centralEnd}" data-self="${t.isSelf}"${t.parentId===void 0?"":` data-parent-id="${Ye(t.parentId)}"`}>`;if(t.isSelf){s.push({indent:2,node:e.connector({id:`${i}:line`,role:"message",geometry:{kind:"polyline",points:t.points},lineStyle:t.lineStyle,paint:p,markers:{...a?{start:a}:{},mid:[],...l?{end:l}:{}},...g})});const b=r(Oy(m),d);s.push({indent:2,node:e.text({id:`${i}:label`,role:"label",text:u,block:t.labelPosition.block,x:f,y:h,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:b.ink,...vh(b)}})})}else{const b=t.points[0];const S=t.points[t.points.length-1];s.push({indent:2,node:e.connector({id:`${i}:line`,role:"message",geometry:{kind:"line",x1:b.x,y1:b.y,x2:S.x,y2:S.y},lineStyle:t.lineStyle,paint:p,markers:{...a?{start:a}:{},mid:[],...l?{end:l}:{}},...g})});const x=r(Oy(m),d);s.push({indent:2,node:e.text({id:`${i}:label`,role:"label",text:u,block:t.labelPosition.block,x:f,y:h,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"middle",paint:{fill:x.ink,...vh(x)}})})}if(t.centralStart)s.push({indent:2,node:e.shape({id:`${i}:central-start`,role:"chrome",geometry:{kind:"circle",cx:t.x1,cy:t.y,r:4},paint:{fill:"var(--bg)",stroke:c,strokeWidth:"1.5"},attributes:{className:"sequence-central-connection",data:{side:"start"}}})});if(t.centralEnd)s.push({indent:2,node:e.shape({id:`${i}:central-end`,role:"chrome",geometry:{kind:"circle",cx:t.x2,cy:t.y,r:4},paint:{fill:"var(--bg)",stroke:c,strokeWidth:"1.5"},attributes:{className:"sequence-central-connection",data:{side:"end"}}})});return e.group({id:i,role:"message",open:y,close:"</g>",children:s})}function FN(e,t){return e.type==="rect"?e.color??t.groupFillColor??"rgba(128, 128, 128, 0.5)":t.groupFillColor}function kM(e,t,n,i,r="all"){const o=[];const s=t.label?` data-label="${hn(t.label)}"`:"";const a=r==="dividers"?`<g class="sequence-block-divider-overlay" data-owner="${Ye(i)}">`:r==="frame"?`<g class="sequence-block-frame-overlay" data-owner="${Ye(i)}">`:`<g class="block" data-type="${Ye(t.type)}"${s}${t.parentId===void 0?"":` data-parent-id="${Ye(t.parentId)}"`}>`;const l=FN(t,n)??"none";const c=t.type==="rect"?"none":n.groupBorderColor??"var(--_node-stroke)";const d=r==="frame"?"none":l;const u=r==="background"?"none":c;if(r!=="dividers")o.push({indent:2,node:e.shape({id:r==="frame"?`${i}:frame`:`${i}:rect`,role:"block",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:d,stroke:u,strokeWidth:String(n.groupLineWidth)}})});const f=n.edgeStrokeColor??"var(--_line)";let h=0;for(const m of r==="background"||r==="frame"||t.type==="par_over"?[]:t.dividers){const p=`${i}:divider#${h}`;h++;const g=Math.max(.75,n.lineWidth*.75);o.push({indent:2,node:e.connector({id:p,role:"block",geometry:{kind:"line",x1:t.x,y1:m.y,x2:t.x+t.width,y2:m.y},lineStyle:"dashed",paint:{stroke:f,strokeWidth:String(g),strokeDasharray:"6 4"}})})}return e.group({id:r==="dividers"?`${i}:divider-overlay`:r==="frame"?`${i}:frame-overlay`:i,role:"block",open:a,close:"</g>",children:o})}function Q5(e,t,n,i,r){const o=n.edgeTextColor??"var(--_text-muted)";const s=[];t.dividers.forEach((a,l)=>{if(!a.label||!a.labelPosition)return;const{text:c,x:d,y:u,bounds:f}=a.labelPosition;const h=r(Oy(f),o);const m={ink:h.ink,halo:h.halo??n.groupFillColor??"var(--bg)"};s.push({indent:2,node:e.text({id:`${i}:divider#${l}:label`,role:"label",text:c,block:a.labelPosition.block,x:d,y:u,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:m.ink,...vh(m)}})})});return e.group({id:`${i}:divider-labels`,role:"block",open:`<g class="sequence-block-divider-labels" pointer-events="none">`,close:"</g>",children:s})}function Z5(e,t,n,i){const{x:r,y:o,width:s,height:a,label:l}=t;const{text:c,x:d,y:u}=l;const f=n.groupHeaderFillColor??"var(--_group-hdr)";const h=n.groupBorderColor??"var(--_node-stroke)";const m=n.groupTextColor??"var(--_text-sec)";return e.group({id:`${i}:header-overlay`,role:"block",open:`<g class="sequence-block-header-overlay" pointer-events="none" aria-hidden="true">`,close:"</g>",children:[{indent:0,node:e.shape({id:`${i}:tab`,role:"block",geometry:{kind:"rect",x:r,y:o,width:s,height:a},paint:{fill:f,stroke:h,strokeWidth:String(n.groupLineWidth)}})},{indent:0,node:e.text({id:`${i}:label`,role:"label",text:c,block:l.block,x:d,y:u,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"start",paint:{fill:m}})}]})}function e6(e,t,n,i){const r=[];const o=t.label?` data-label="${hn(t.label)}"`:"";const s=`<g class="box"${o}>`;const a=t.color?.toLowerCase()==="transparent"?"none":t.color;const l=a??"color-mix(in srgb, var(--fg) 5%, var(--bg))";r.push({indent:2,node:e.shape({id:`${i}:rect`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:l,stroke:"none"}})});if(t.label){const c=t.block?.text??pi(t.label,n.groupTextTransform);const d=t6(a,n);const u=t.x+t.width/2;const f=t.labelY??t.y+13;r.push({indent:2,node:e.text({id:`${i}:title`,role:"label",text:c,block:t.block,x:u,y:f,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"middle",paint:{fill:d}})})}return e.group({id:i,role:"group",open:s,close:"</g>",children:r})}function t6(e,t){const n=t.groupTextColor??"var(--_text-sec)";if(!e||e==="none")return n;const i=Mw(e);if(!i)return n;const r=t.groupTextColor;if(r){const o=yu(r,i);if(o!==null&&o>=4.5)return r}return Ho(i)??n}function n6(e,t,n){const i=8;const r=n.edgeStrokeColor??"var(--_line)";const o=Math.max(1.5,n.lineWidth);const s=`M ${t.x-i} ${t.y-i} L ${t.x+i} ${t.y+i} M ${t.x-i} ${t.y+i} L ${t.x+i} ${t.y-i}`;return e.shape({id:`destroy:${t.actorId}`,role:"icon",geometry:{kind:"path",d:s},paint:{fill:"none",stroke:r,strokeWidth:String(o)},channels:{category:t.actorId},attributes:{className:"destroy-cross",data:{actor:t.actorId}}})}function i6(e,t,n,i,r){const{x:o,y:s,width:a,height:l}=t;const c=t.actors&&t.actors.length>0?` data-actors="${t.actors.map(Ye).join(",")}"`:"";const d=t.position?` data-position="${Ye(t.position)}"`:"";const u=n.nodeFillColor??"var(--bg)";const f=n.nodeBorderColor??"var(--_node-stroke)";const h=n.nodeTextColor??yi("var(--_text-muted)",u,i);const m=n.cornerRadius??0;const p=t.block?.text??pi(t.text,n.nodeTextTransform);return e.group({id:r,role:"note",open:`<g class="note"${d}${c}${t.parentId===void 0?"":` data-parent-id="${Ye(t.parentId)}"`}>`,close:"</g>",children:[{indent:2,node:e.shape({id:`${r}:rect`,role:"note",geometry:{kind:"rect",x:o,y:s,width:a,height:l,rx:m,ry:m},paint:{fill:u,stroke:f,strokeWidth:String(et.innerBox)}})},{indent:2,node:e.text({id:`${r}:text`,role:"label",text:p,block:t.block,x:o+a/2,y:s+l/2,fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing,anchor:"middle",paint:{fill:h}})}]})}var NN=gt(CM);function $N(e,t={},n,i={}){return Dy(TT(e),t,i,n)}var _N=gt((e,t)=>({...CM(e,t),family:"zenuml"}));function DN(e){const t=jg(e);return{...t,edges:t.edges.map(n=>{const i=n.route;return i&&"family"in i&&i.family==="sequence"?{...n,route:{...i,family:"zenuml"}}:n})}}var wye={statementEnds:Lw,layout:e=>{const t=Up(ya(e.source));t.title??=Ar(e.source.frontmatter);t.accessibilityTitle=e.source.accessibility.title??t.accessibilityTitle;t.accessibilityDescription=e.source.accessibility.descr??t.accessibilityDescription;return mt($N(t,e.renderOptions,e.styleFace))},projectPositioned:ft(DN),lowerScene:ht(_N)};function rs(e,t,n,i,r,o){const s=i.font??"Inter";const a=Zt(i);return{family:t,width:n.width,height:n.height,colors:i,transparent:r,parts:[e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:r,font:s,hasMonoFont:false},`${Ot(n.width,n.height,i,r)}
|
|
25
|
-
${Dt(s,false,i.shadow,i.embedFontImport)}${a?`
|
|
26
|
-
<defs>${a}</defs>`:""}`),...o,e.documentClose()]}}function r6(e,{positioned:t,colors:n,resolved:i}){const r=t.style;const o=Ur(n);const s=r.edgeStrokeColor?{...uc,paint:{...uc.paint,fill:r.edgeStrokeColor}}:uc;const a=[e.definitions({id:"defs",markerResources:[s]},`<defs>${hi([s])}</defs>`)];if(t.title)a.push(e.text(En(t.title,r)));for(const l of t.lanes){const c={id:l.id,role:"group"};a.push(e.group({id:l.id,role:"group",open:"<g>",close:"</g>",children:[{node:e.shape({id:`${l.id}:surface`,role:"group",identity:false,owner:c,geometry:{kind:"rect",x:l.x,y:l.y,width:l.width,height:l.height,rx:r.groupCornerRadius},paint:{fill:r.groupFillColor??"var(--_group-fill)",stroke:r.groupBorderColor??"var(--_node-stroke)",strokeWidth:String(r.groupLineWidth)}}),indent:2},...r.groupHeaderFillColor?[{node:e.shape({id:`${l.id}:header`,role:"chrome",owner:c,geometry:{kind:"rect",x:l.x,y:l.y,width:t.laneWidth,height:l.height,rx:r.groupCornerRadius},paint:{fill:r.groupHeaderFillColor,stroke:"none"}}),indent:2}]:[],{node:e.text({id:`${l.id}:label`,role:"label",owner:c,text:l.block.text,block:l.block,x:l.x+r.groupLabelPaddingX,y:l.y+l.height/2,anchor:"start",fontSize:l.block.fontSize,fontWeight:l.block.fontWeight,letterSpacing:l.block.letterSpacing,paint:{fill:r.groupTextColor??o("var(--_text)",r.groupHeaderFillColor??r.groupFillColor??"var(--_group-fill)")}}),indent:2}]}))}for(const l of t.edges)a.push(e.connector({id:l.id,role:"edge",geometry:l.projection?.geometry??{kind:"polyline",points:l.points},route:{ownership:"layout",bendRadius:r.edgeBendRadius,...l.projection?{contours:l.projection.contours}:{}},lineStyle:"solid",paint:{stroke:r.edgeStrokeColor??"var(--_line)",strokeWidth:String(r.lineWidth)},endpoints:{from:l.from,to:l.to},relationship:{kind:l.explicit?"explicit":"inferred",direction:"forward"},markers:{end:s}}));for(const l of t.nodes){const c={id:l.id,role:"node"},d=r.nodeFillColor??"var(--_node-fill)";a.push(e.group({id:l.id,role:"node",open:`<g data-parent="${l.lane}">`,close:"</g>",children:[{node:e.shape({id:`${l.id}:surface`,role:"node",identity:false,owner:c,geometry:{kind:"rect",x:l.x,y:l.y,width:l.width,height:l.height,rx:r.cornerRadius??5},paint:{fill:d,stroke:r.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(r.nodeLineWidth)}}),indent:2},{node:e.text({id:`${l.id}:label`,role:"label",owner:c,text:l.block.text,block:l.block,x:l.x+l.width/2,y:l.y+l.height/2,anchor:"middle",fontSize:l.block.fontSize,fontWeight:l.block.fontWeight,letterSpacing:l.block.letterSpacing,paint:{fill:r.nodeTextColor??o("var(--_text)",d)}}),indent:2}]}))}return rs(e,"eventmodeling",t,n,i.renderOptions.transparent??false,a)}var ON=gt(r6);var Dye={normalizeRequest:e=>{const t=e.source.config.eventmodeling;const n=t?.padding;const i=t?.rowHeight;return{renderOptions:{...e.renderOptions,...e.renderOptions.padding===void 0&&typeof n==="number"&&Number.isFinite(n)&&n>=0?{padding:n}:{}},familyConfig:{rowHeight:typeof i==="number"&&Number.isFinite(i)&&i>=0?i:0},appearance:{family:{palette:e.colors}}}},statementEnds:UT,layout:e=>{const t=XT(e.source.authoredFamilyBody??e.source.familyBody);if(t.title===void 0&&typeof e.source.frontmatter.title==="string")t.title=e.source.frontmatter.title;return mt(dF(t,e.renderOptions,e.styleFace,e.familyConfig?.rowHeight,e.familyAppearance?.palette))},projectPositioned:ft(({positioned:e})=>({version:1,bounds:{w:ye(e.width),h:ye(e.height)},nodes:e.nodes.map(t=>({id:t.id,x:ye(t.x),y:ye(t.y),w:ye(t.width),h:ye(t.height),shape:"rectangle",label:t.frame.entity,parentId:t.lane,...St(t.block,t.x+t.width/2,t.y+t.height/2,t)})),edges:e.edges.map(t=>({id:t.id,from:t.from,to:t.to,path:t.points.map(n=>[ye(n.x),ye(n.y)])})),groups:e.lanes.map(t=>({id:t.id,label:t.label,x:ye(t.x),y:ye(t.y),w:ye(t.width),h:ye(t.height),members:e.nodes.filter(n=>n.lane===t.id).map(n=>n.id)})),labels:[]})),lowerScene:ht(ON)};var BN=e=>bt("packet",e,{bitsPerRow:an("a positive safe integer",t=>Number.isSafeInteger(t)&&Number(t)>=1),bitOrder:Ws("ascending","descending"),showBits:ct,rowHeight:Kt,bitWidth:Kt,paddingX:jt,paddingY:jt,useMaxWidth:ct});function WN(e,t={},n=ph(),i){const r=e.fields.length?Math.floor(e.fields.at(-1).end/n.bitsPerRow)+1:0;Ve("nodes",r+e.fields.length);const o=Xe(t,void 0,i);const s=t.padding??24;const a=tn(e.title,o);const l=i?.node?.paddingX,c=i?.node?.paddingY??8;const d=Math.max(8,Math.min(11,o.edgeLabelFontSize));const u=n.showBits?d*1.5+4:0;const f=[];const h=Array.from({length:r},()=>n.rowHeight);const m={display:"formatted",transform:o.nodeTextTransform,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,fontFamily:t.font};for(const b of e.fields){let S;for(let x=b.start;x<=b.end;){const k=Math.floor(x/n.bitsPerRow),w=k*n.bitsPerRow;const C=Math.min(b.end,w+n.bitsPerRow-1);const R=(C-x+1)*n.bitWidth;const M=Math.min(n.paddingX,R-1),P=R-M;if(x===C)S??=_e(b.label,m);const E=x===C&&S.lines.length===1&&S.text.length<=4;const v=Math.max(1,P-(l===void 0?E?2:8:l*2));const L=E?Math.max(9,Math.min(m.fontSize,Math.floor(m.fontSize*v/Math.max(1,S.width)))):m.fontSize;const T=_e(b.label,{...m,fontSize:L,maxWidth:v});const A=s+(n.bitOrder==="descending"?n.bitsPerRow-(C-w+1):x-w)*n.bitWidth+M/2;f.push({...b,id:`${b.id}:row-${k}`,fieldId:b.id,start:x,end:C,row:k,x:A,y:0,width:P,slotWidth:R,height:0,labelBlock:T,bitLabels:[]});h[k]=Math.max(h[k],T.height+c*2);Ve("nodes",f.length);x=C+1}}let p=s+(a?.height??0);let g=0;for(let b=0;b<r;b++){while(g<f.length&&f[g].row===b){const S=f[g++];S.y=p+u;S.height=h[b];if(n.showBits){const x=S.start===S.end;const k=n.bitOrder==="descending"?S.end:S.start;const w=n.bitOrder==="descending"?S.start:S.end;const C=x?[{bit:S.start,x:S.x+S.width/2,anchor:"middle"}]:[{bit:k,x:S.x+2,anchor:"start"},{bit:w,x:S.x+S.width-2,anchor:"end"}];S.bitLabels=C.map(R=>({text:String(R.bit),x:R.x,y:p+u/2,anchor:R.anchor,block:_e(String(R.bit),{display:"literal",fontSize:d,fontWeight:400})}))}}p+=u+h[b]+n.paddingY}const y=Math.max(s*2+n.bitsPerRow*n.bitWidth,(a?.width??0)+2*s);return{width:y,height:Math.max(s*2+(a?.height??0),p+s),rows:r,fields:f,visual:n,...a?{title:rn(a,y,s)}:{},accessibility:{title:e.accessibilityTitle,descr:e.accessibilityDescription}}}function zN(e,t={}){const n=Wt(typeof e==="string"?e.split(/\r?\n/):[...e]);const i=[...n.familyLines];while(i.length&&(!i[0].trim()||i[0].trim().startsWith("%%")))i.shift();const r=i.shift()??"";Ge("packet","header",r,{line:1,unit:"normalized"});if(!/^packet(?:-beta)?\s*$/i.test(Gt(r).trim()))throw Je({what:"Invalid packet header",expectedForm:"packet",example:'packet\n+8: "Byte"'});const o={kind:"packet",fields:[],accessibilityTitle:t.title??n.accessibility.title,accessibilityDescription:t.descr??n.accessibility.descr};const s=i.join("\n");const a=/(?:title(?:[ \t]+([^\n]*))?(?:\n|$)|(\+)?(0|[1-9]\d*)[ \t]*(?:-[ \t]*(0|[1-9]\d*))?[ \t]*:[ \t]*("(?:[^"\\]|\\[\s\S])*"|'(?:[^'\\]|\\[\s\S])*')[ \t]*(?:%%[^\n]*)?(?:\n|$))/gy;let l=0,c=-1,d=0,u=2;while(l<s.length){const f=/^(?:\s+|%%[^\n]*(?:\n|$))/.exec(s.slice(l));if(f){l+=f[0].length;continue}a.lastIndex=l;const h=a.exec(s);if(!h){if(!s.slice(l).trim())break;throw Je({what:`Invalid packet statement: ${s.slice(l).split("\n")[0]}`,expectedForm:'start-end: "label" or +bits: "label"',example:'+16: "Source Port"'})}l=a.lastIndex;if(ie("packet")){for(;d<h.index;d++)if(s.charCodeAt(d)===10)u++;Ge("packet",h[2]===void 0&&h[3]===void 0?"title":"field",h[0],{line:u,offset:h.index,endOffset:a.lastIndex,unit:"normalized"})}if(h[2]===void 0&&h[3]===void 0){o.title=Gt(h[1]??"").trim();ue("packet","set-title",o.title);continue}const m=Number(h[3]),p=h[2]==="+";const g=p?c+1:m;const y=p?g+m-1:h[4]===void 0?g:Number(h[4]);if(p&&h[4]!==void 0||!Number.isSafeInteger(g)||!Number.isSafeInteger(y)||g<0||y<g)throw Je({what:`Invalid packet bit range ${g}-${y}`,expectedForm:"a positive bit count or increasing inclusive bit range",example:'+8: "Byte"'});if(g!==c+1)throw Je({what:`Packet block ${g}-${y} is not contiguous; it must start from ${c+1}`,expectedForm:`a field starting at ${c+1}`,example:`+8: "Next byte"`});let b=h[5].slice(1,-1);b=b.replace(/\\([\s\S])/g,(x,k)=>({n:"\n",r:"\r",t:" ",b:"\b",f:"\f",v:"\v"})[k]??k);const S={id:`field-${o.fields.length}`,start:g,end:y,label:b};o.fields.push(S);ue("packet","add-field",S);Ve("nodes",o.fields.length);c=y}return o}function GN({positioned:e}){return{version:1,nodes:e.fields.map(t=>({id:t.id,x:ye(t.x),y:ye(t.y),w:ye(t.width),h:ye(t.height),shape:"rectangle",label:t.label,...St(t.labelBlock,t.x+t.width/2,t.y+t.height/2,Xt(e),"middle")})),edges:[],groups:[],bounds:{w:ye(e.width),h:ye(e.height)}}}function o6(e,{positioned:t,colors:n,resolved:i}){const r=Xe(i.renderOptions,void 0,i.styleFace);const o=i.renderOptions.transparent??false;const s=[];if(t.title)s.push(e.text(En(t.title,r)));const a=r.nodeFillColor??"var(--_node-fill)";const l=r.nodeTextColor??Ts(void 0,n,a)("var(--_text)");for(const c of t.fields){const d=[e.shape({id:`${c.id}:box`,role:"node",identity:false,owner:{id:c.id,role:"node"},geometry:{kind:"rect",x:c.x,y:c.y,width:c.width,height:c.height,rx:r.cornerRadius},paint:{fill:a,stroke:r.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(r.nodeLineWidth)}}),e.text({id:`${c.id}:label`,role:"label",owner:{id:c.id,role:"node"},text:c.labelBlock.text,block:c.labelBlock,x:c.x+c.width/2,y:c.y+c.height/2,fontSize:c.labelBlock.fontSize,fontWeight:c.labelBlock.fontWeight,letterSpacing:c.labelBlock.letterSpacing,anchor:"middle",paint:{fill:l}})];for(const[u,f]of c.bitLabels.entries())d.push(e.text({id:`${c.id}:bit-${u}`,role:"label",text:f.text,block:f.block,x:f.x,y:f.y,fontSize:f.block.fontSize,fontWeight:f.block.fontWeight,anchor:f.anchor,paint:{fill:r.edgeTextColor??"var(--_text-muted)"}}));s.push(e.group({id:c.id,role:"node",open:`<g data-id="${Ye(c.id)}" data-field-id="${Ye(c.fieldId)}" data-start="${c.start}" data-end="${c.end}" data-field-label="${Ye(ia(c.labelBlock.prepared))}">`,close:"</g>",children:d.map(u=>({node:u,indent:2}))}))}return rs(e,"packet",t,n,o,s)}var HN=gt(o6);var yxe={configDiagnostics:BN,normalizeRequest:e=>({familyConfig:{visual:ph(e.source.frontmatter)}}),layout:e=>mt(WN(Tn(zN(e.source.familyBody,e.source.accessibility),e.source.frontmatter),e.renderOptions,e.familyConfig?.visual??ph(),e.styleFace)),projectPositioned:ft(GN),lowerScene:ht(HN)};var jN=e=>{const t=bt("kanban",e,{padding:jt,sectionWidth:Kt,ticketBaseUrl:Dr,useMaxWidth:ct});const n=Kr(e.root,"kanban")?.ticketBaseUrl;if(typeof n==="string"&&n&&!Dp(n,"TICKET"))t.push({code:"INEFFECTIVE_CONFIG",field:"kanban.ticketBaseUrl",message:"kanban.ticketBaseUrl is not a safe inert link; ticket text is preserved without navigation."});return t};function s6(e){const t=[{text:e.label,kind:"label"}];if(e.metadata.ticket)t.push({text:String(e.metadata.ticket),kind:"ticket"});if(e.metadata.assigned)t.push({text:`Assigned: ${e.metadata.assigned}`,kind:"assigned"});if(e.metadata.priority)t.push({text:`Priority: ${e.metadata.priority}`,kind:"priority"});const n=e.icon??e.metadata.icon;if(n)t.push({text:`Icon: ${n}`,kind:"icon"});return t}function YN(e,t={},n=hf(),i){Ve("nodes",e.columns.reduce((E,v)=>E+v.tasks.length+1,0));const r=Xe(t,void 0,i);const o=t.padding??24,s=Math.max(4,n.padding),a=Math.max(8,r.nodePaddingX),l=Math.max(8,r.nodePaddingY),c=i?.group?.paddingX??s,d=i?.group?.paddingY??s,u=i?.group?.paddingX??s+a,f=i?.group?.paddingY??l;const h=Math.max(160,c*2+a*2+24,u*2+24),m=t.kanban?.maxWidth,p=Math.max(m===void 0?0:h,Math.min(Math.max(n.sectionWidth,c*2+a*2+24,u*2+24),m===void 0?Infinity:m-2*o)),g=Math.max(16,s*2);const y=tn(e.title,r);const b=(E,v)=>s6(E).map(({text:L,kind:T})=>{const A=T==="label";const $=_e(L,{display:"formatted",transform:v?r.groupTextTransform:r.nodeTextTransform,fontSize:v?r.groupHeaderFontSize:A?r.nodeLabelFontSize:r.edgeLabelFontSize,fontWeight:v?r.groupHeaderFontWeight:A?r.nodeLabelFontWeight:r.edgeLabelFontWeight,letterSpacing:v?r.groupLetterSpacing:r.nodeLetterSpacing,fontFamily:v?r.groupFont??t.font:t.font,maxWidth:p-2*(v?u:c+a)});return{text:L,kind:T,block:$,x:0,y:0}});const S=e.columns.map(E=>Hd(b(E,true),{top:o+(y?.height??0)+f,gap:6,trailingGap:true}));const x=Math.max(32,...S.map(E=>E.height+2*f));const k=[];e.columns.forEach((E,v)=>{const L=o+v*(p+g),T=o+(y?.height??0);const A=S[v].rows.map(({item:z,textY:F})=>{z.x=L+u;z.y=F;return z});let $=T+x+d;const _=E.tasks.map(z=>{const F=Hd(b(z,false),{top:$+l,gap:6}),G=Math.max(40,F.height+2*l);const I=F.rows.map(({item:B,textY:Y})=>{B.x=L+c+a;B.y=Y;return B});const D={...z,parentId:E.id,x:L+c,y:$,width:p-c*2,height:G,texts:I,...z.metadata.ticket?{ticketUrl:Dp(n.ticketBaseUrl,String(z.metadata.ticket))}:{}};$+=G+s;return D});k.push({...E,x:L,y:T,width:p,height:$-T+d,headerHeight:x,texts:A,tasks:_})});const w=Math.max(x+d*2,...k.map(E=>E.height));for(const E of k)E.height=w;const C=m===void 0?Math.max(1,k.length):Math.max(1,Math.floor((m-2*o+g)/(p+g)));let R=w;if(C<k.length){let E=o+(y?.height??0);for(let v=0;v<k.length;v+=C){const L=k.slice(v,v+C);for(const[T,A]of L.entries()){const $=o+T*(p+g)-A.x,_=E-A.y;A.x+=$;A.y+=_;for(const z of A.texts){z.x+=$;z.y+=_}for(const z of A.tasks){z.x+=$;z.y+=_;for(const F of z.texts){F.x+=$;F.y+=_}}}E+=w+g}R=E-g-o-(y?.height??0)}const M=Math.min(k.length,C);const P=Math.max(o*2+Math.max(0,M*p+Math.max(0,M-1)*g),(y?.width??0)+2*o);return{columns:k,visual:n,width:P,height:o*2+(y?.height??0)+R,...y?{title:rn(y,P,o)}:{}}}function qN({positioned:e}){return{version:1,nodes:e.columns.flatMap(t=>t.tasks.map(n=>({id:n.id,parentId:t.id,x:ye(n.x),y:ye(n.y),w:ye(n.width),h:ye(n.height),shape:"rectangle",label:n.label,...St(n.texts[0]?.block,n.texts[0]?.x??n.x,n.texts[0]?.y??n.y,Xt(e),"start")}))),edges:[],groups:e.columns.map(t=>({id:t.id,label:t.label,x:ye(t.x),y:ye(t.y),w:ye(t.width),h:ye(t.height),members:t.tasks.map(n=>n.id)})),bounds:{w:ye(e.width),h:ye(e.height)}}}function a6(e,{positioned:t,colors:n,resolved:i}){const r=Xe(i.renderOptions,void 0,i.styleFace);const o=Ur(n);const s=i.renderOptions.transparent??false;const a=[];if(t.title)a.push(e.text(En(t.title,r)));const l=(c,d,u,f)=>e.text({id:c,role:"label",owner:f,text:d.block.text,block:d.block,x:d.x,y:d.y,fontSize:d.block.fontSize,fontWeight:d.block.fontWeight,letterSpacing:d.block.letterSpacing,anchor:"start",paint:{fill:u}});for(const c of t.columns){const d=r.groupFillColor??"var(--_group-fill)",u=r.groupHeaderFillColor??"var(--_group-hdr)";const f=[e.shape({id:`${c.id}:surface`,role:"group",identity:false,owner:{id:c.id,role:"group"},geometry:{kind:"rect",x:c.x,y:c.y,width:c.width,height:c.height,rx:r.groupCornerRadius},paint:{fill:d,stroke:r.groupBorderColor??"var(--_node-stroke)",strokeWidth:String(r.groupLineWidth)}}),e.shape({id:`${c.id}:header`,role:"group-header",owner:{id:c.id,role:"group"},geometry:{kind:"rect",x:c.x,y:c.y,width:c.width,height:c.headerHeight,rx:r.groupCornerRadius},paint:{fill:u,stroke:"none"}})];const h=r.groupTextColor??o("var(--_text)",u);c.texts.forEach((p,g)=>f.push(l(`${c.id}:text-${g}`,p,h,{id:c.id,role:"group"})));for(const p of c.tasks){const g=r.nodeFillColor??"var(--_node-fill)",y=r.nodeTextColor??o("var(--_text)",g);const b=[e.shape({id:`${p.id}:surface`,role:"node",identity:false,owner:{id:p.id,role:"node"},geometry:{kind:"rect",x:p.x,y:p.y,width:p.width,height:p.height,rx:r.cornerRadius??5},paint:{fill:g,stroke:r.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(r.nodeLineWidth)}})];p.texts.forEach((k,w)=>b.push(l(`${p.id}:text-${w}`,k,y,{id:p.id,role:"node"})));const S=p.className?.split(/\s+/).filter(k=>/^[\w-]+$/.test(k)).join(" ");const x=p.ticketUrl&&i.renderOptions.security!=="strict"?` data-href="${Ye(p.ticketUrl)}" role="link" tabindex="0"`:"";f.push(e.group({id:p.id,role:"node",open:`<g data-id="${Ye(p.id)}" data-parent="${Ye(c.id)}"${S?` class="${Ye(S)}"`:""}${x}>`,close:"</g>",children:b.map(k=>({node:k,indent:2}))}))}const m=c.className?.split(/\s+/).filter(p=>/^[\w-]+$/.test(p)).join(" ");a.push(e.group({id:c.id,role:"group",open:`<g data-id="${Ye(c.id)}"${m?` class="${Ye(m)}"`:""}>`,close:"</g>",children:f.map(p=>({node:p,indent:2}))}))}return rs(e,"kanban",t,n,s,a)}var XN=gt(a6);var qxe={statementEnds:tL,configDiagnostics:jN,normalizeRequest:e=>({familyConfig:{visual:hf(e.source.frontmatter)}}),layout:e=>mt(YN(Tn(zw(ya(e.source),e.source.accessibility,e.source),e.source.frontmatter),e.renderOptions,e.familyConfig?.visual??hf(),e.styleFace)),projectPositioned:ft(qN),lowerScene:ht(XN)};var UN=e=>bt("requirement",e,{rect_fill:Dr,text_color:Dr,rect_border_color:Dr,rect_border_size:$a(0),rect_min_width:Kt,rect_min_height:jt,rect_padding:jt,line_height:jt,fontSize:Kt,maxWidth:Kt,nodeSpacing:jt,rankSpacing:jt,useMaxWidth:ct,look:Dr,theme:Dr});var Ja=dr("requirement-arrow",{width:9,height:7},"end",{fill:"none",stroke:"var(--_arrow)",strokeWidth:"1"},"userSpaceOnUse");var By=gr([Ja]);function VN(e,t={},n,i={}){hP(e);const r=st(n,"relationship",{},{includeFallback:false}),o=Xe(t,void 0,r?{...n,edge:{...n?.edge,...r}}:n),s=t.padding??32;const a=typeof i.maxWidth==="number"&&i.maxWidth>0?i.maxWidth:320;const l=(v,L,T=0,A=2e3)=>typeof i[v]==="number"&&Number.isFinite(i[v])&&i[v]>=T?Math.min(i[v],A):L;const c=l("rect_padding",16),d=i.rect_padding===void 0?n?.node?.paddingX??c:c,u=i.rect_padding===void 0?n?.node?.paddingY??c:c,f=l("rect_min_width",140,1),h=l("rect_min_height",0),m=l("line_height",0);const p={};for(const[v,L]of[["rect_fill","fill"],["text_color","color"],["rect_border_color","stroke"],["rect_border_size","stroke-width"]])if(typeof i[v]==="string"||v==="rect_border_size"&&typeof i[v]==="number"&&Number.isFinite(i[v]))p[L]=String(i[v]);Lt(p,"requirement config");const g=[...e.requirements.map(v=>({requirement:v,element:void 0})),...e.elements.map(v=>({requirement:void 0,element:v}))].map(({requirement:v,element:L})=>{const T=v??L,A=Lt({...p,...vn(T.cssStyles.join(","))},`style ${T.name}`);const $=Number.parseFloat(A["font-size"]??"")||l("fontSize",o.nodeLabelFontSize,1);const _=A["font-weight"]?.trim().toLowerCase(),z=_===void 0?void 0:_==="normal"?400:_==="bold"?700:Number(_);if(z!==void 0&&(!Number.isFinite(z)||z<1||z>1e3))throw new Error(`style ${T.name}: font-weight must be normal, bold, or a number from 1 to 1000`);const F=_e(`<<${v?.type??"Element"}>>
|
|
27
|
-
${T.name}`,{fontSize:$,fontWeight:z??o.nodeLabelFontWeight,maxWidth:a,transform:o.nodeTextTransform,letterSpacing:o.nodeLetterSpacing,fontFamily:t.font});const G=v?[["ID",v.requirementId],["Text",v.text],["Risk",v.risk],["Verification",v.verifyMethod]]:[["Type",L.type],["Doc Ref",L.docRef]];const I=F.height+Math.max(12,u*1.5);const D=Hd(G.filter(([,O])=>O).map(([O,N])=>{const H=_e(`${O}: ${N}`,{fontSize:$,fontWeight:z??400,maxWidth:a,transform:o.nodeTextTransform,letterSpacing:o.nodeLetterSpacing,fontFamily:t.font});return{label:O,block:H}}),{top:I+8,gap:9,minRowHeight:m,align:"start",trailingGap:true});const B=D.rows.map(({item:O,textY:N})=>({...O,y:N}));const Y=Math.max(h,D.bottom+8),W=Math.max(f,F.width+d*2,D.width+d*2);return{id:T.name,requirement:v,element:L,x:0,y:0,width:W,height:Y,header:F,rows:B,paddingX:d,headerHeight:I,style:A}});const y=new Map(g.map((v,L)=>[v.id,L]));const b=e.relations.map(v=>_e(`<<${v.type}>>`,{fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,transform:o.edgeTextTransform,letterSpacing:o.edgeLetterSpacing}));for(const v of e.relations){if(!y.has(v.src)||!y.has(v.dst))throw new Error(`Requirement relation ${v.id} references an undeclared endpoint`)}const S=t.nodeSpacing??l("nodeSpacing",40,0,Infinity),x=t.layerSpacing??l("rankSpacing",72,0,Infinity);const k=e.relations.some(v=>v.type!=="contains")?By(Ja.id,o.lineWidth,"end")+o.edgeBendRadius:0;const w=Vr(t,()=>{return ei("agentic",()=>Ya({nodes:g.map(v=>({id:v.id,width:v.width,height:v.height})),edges:e.relations.map((v,L)=>({source:y.get(v.src),target:y.get(v.dst),minSpan:1,label:{width:b[L].width+16,height:b[L].height+10}})),direction:e.direction,padding:s,nodeSpacing:S,layerSpacing:x,...k?{minimumTerminalLead:k}:{},edgeSpacing:Math.max(6,o.lineWidth+4)}))},()=>{const v=new Map(g.map((_,z)=>[_.id,`n${z}`]));const L=e.relations.map((_,z)=>({id:`e${z}`,sources:[v.get(_.src)],targets:[v.get(_.dst)],labels:[{text:b[z].text,width:b[z].width+16,height:b[z].height+10}]}));const T={id:"requirement-layout",layoutOptions:{"elk.algorithm":"layered","elk.direction":{TB:"DOWN",BT:"UP",LR:"RIGHT",RL:"LEFT"}[e.direction],"elk.edgeRouting":"ORTHOGONAL","elk.spacing.edgeNode":String(k),"elk.layered.spacing.edgeNodeBetweenLayers":String(k),"elk.spacing.nodeNode":String(S),"elk.layered.spacing.nodeNodeBetweenLayers":String(x),"elk.padding":`[top=${s},left=${s},bottom=${s},right=${s}]`},children:g.map(_=>({id:v.get(_.id),width:_.width,height:_.height})),edges:L};const A=g.length?Ha(T):{...T,width:s*2,height:s*2};const $=g.map(()=>({x:0,y:0}));for(const _ of A.children??[])$[Number(_.id.slice(1))]={x:_.x??0,y:_.y??0};return{width:A.width??0,height:A.height??s*2,nodes:$,edges:e.relations.map((_,z)=>{const F=A.edges?.[z],G=F?.labels?.[0];return{points:qs((F?.sections??[]).flatMap(I=>[I.startPoint,...I.bendPoints??[],I.endPoint])),...G?.x!==void 0?{labelPosition:{x:G.x+(G.width??0)/2,y:(G.y??0)+(G.height??0)/2}}:{}}})}});const C=tn(e.title,o),R=C?.height??0;const M=Math.max(w.width??0,(C?.width??0)+s*2,s*2),P=(w.height??s*2)+R;for(const[v,L]of w.nodes.entries()){const T=g[v];T.x=L.x+(M-w.width)/2;T.y=L.y+R}const E=e.relations.map((v,L)=>{const T=w.edges[L];const A=(T?.points??[]).map(G=>({x:G.x+(M-w.width)/2,y:G.y+R}));if(A.length<2)throw new Error(`No route for requirement relation ${v.id}`);const $=b[L],_=T?.labelPosition,z=A[Math.floor(A.length/2)];const F=_?{x:_.x+(M-w.width)/2,y:_.y+R}:z;return{...v,points:A,label:$,labelPosition:F}});return{model:e,width:M,height:P,nodes:g,edges:E,style:o,...C?{title:rn(C,M,s)}:{}}}var PM={id:"requirement-contains",shape:"circle",size:{width:12,height:12},ref:{x:0,y:6},orient:"auto",units:"userSpaceOnUse",geometry:{kind:"compound",children:[{kind:"circle",cx:6,cy:6,r:5},{kind:"path",d:"M2 6H10M6 2V10"}]},paint:{fill:"var(--bg)",stroke:"var(--_arrow)",strokeWidth:"1"}};function l6(e,t){const{positioned:n,colors:i}=t,r=t.resolved.renderOptions.transparent??false,o=i.font??"Inter",s=[],a=n.style.edgeStrokeColor?{...Ja,paint:{...Ja.paint,stroke:n.style.edgeStrokeColor}}:Ja,l=n.style.edgeStrokeColor?{...PM,paint:{...PM.paint,stroke:n.style.edgeStrokeColor}}:PM,c=[a,l];const d=Ur(i);let u=Ot(n.width,n.height,i,r);if(n.model.accessibilityTitle)u+=`<title>${It(n.model.accessibilityTitle)}</title>`;if(n.model.accessibilityDescription)u+=`<desc>${It(n.model.accessibilityDescription)}</desc>`;u+=Dt(o,false,void 0,i.embedFontImport);s.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:r,font:o,hasMonoFont:false},u),e.definitions({id:"defs",markerResources:c},`<defs>${hi(c)}</defs>`));for(const f of n.nodes){const h=f.style.fill??n.style.nodeFillColor??"var(--_node-fill)",m=f.style.stroke??n.style.nodeBorderColor??"var(--_node-stroke)",p=f.style.color??n.style.nodeTextColor??d("var(--_text)",h);const g=[{indent:2,node:e.shape({id:`frame:${f.id}`,role:"node",identity:false,owner:{id:f.id,role:"node"},geometry:{kind:"rect",x:f.x,y:f.y,width:f.width,height:f.height,rx:n.style.cornerRadius},paint:{fill:h,stroke:m,strokeWidth:f.style["stroke-width"]??String(n.style.nodeLineWidth),...f.style["stroke-dasharray"]!==void 0?{strokeDasharray:f.style["stroke-dasharray"]}:{}}})},{indent:2,node:e.shape({id:`separator:${f.id}`,role:"chrome",geometry:{kind:"line",x1:f.x,y1:f.y+f.headerHeight,x2:f.x+f.width,y2:f.y+f.headerHeight},paint:{stroke:m,strokeWidth:"0.75"}})},{indent:2,node:e.text({id:`header:${f.id}`,role:"label",owner:{id:f.id,role:"node"},text:f.header.text,block:f.header,x:f.x+f.width/2,y:f.y+f.headerHeight/2,fontSize:f.header.fontSize,anchor:"middle",paint:{fill:p}})},...f.rows.map((b,S)=>({indent:2,node:e.text({id:`field:${f.id}:${S}`,role:"attribute",owner:{id:f.id,role:"node"},text:b.block.text,block:b.block,x:f.x+f.paddingX,y:f.y+b.y,fontSize:b.block.fontSize,anchor:"start",paint:{fill:p}})}))];const y=["requirement-node",...(f.requirement??f.element).classes.filter(b=>/^[\w-]+$/.test(b))];s.push(e.group({id:`node:${f.id}`,role:"node",open:`<g class="${Ye(y.join(" "))}" data-id="${Ye(f.id)}">`,close:"</g>",children:g}))}for(const f of n.edges){const h=n.style.edgeBendRadius>0&&f.points.length>2?qn(f.points,n.style.edgeBendRadius,{terminalClearance:{end:f.type==="contains"?0:By(Ja.id,n.style.lineWidth,"end")}}):void 0;s.push(e.connector({id:f.id,role:"relationship",geometry:h?.geometry??{kind:"polyline",points:f.points},lineStyle:f.type==="contains"?"solid":"dashed",paint:{stroke:n.style.edgeStrokeColor??"var(--_line)",strokeWidth:String(n.style.lineWidth),fill:"none",...f.type!=="contains"?{strokeDasharray:"6 4"}:{}},endpoints:{from:f.src,to:f.dst},relationship:{kind:f.type,direction:"forward"},markers:f.type==="contains"?{start:l}:{end:a},labels:[{text:f.label.text,anchor:f.labelPosition}],route:{ownership:"layout",bendRadius:n.style.edgeBendRadius,labelAnchors:[f.labelPosition],...h?{contours:h.contours}:{}}}))}for(const f of n.edges){const h=f.label,m=f.labelPosition;s.push(e.group({id:`edge-label:${f.id}`,role:"edge-label",open:'<g class="requirement-edge-label">',close:"</g>",children:[{indent:2,node:e.shape({id:`label-bg:${f.id}`,role:"chrome",owner:{id:f.id,role:"relationship"},geometry:{kind:"rect",x:m.x-h.width/2-6,y:m.y-h.height/2-4,width:h.width+12,height:h.height+8},paint:{fill:"var(--bg)",stroke:"none"}})},{indent:2,node:e.text({id:`label:${f.id}`,role:"edge-label",owner:{id:f.id,role:"relationship"},text:h.text,block:h,x:m.x,y:m.y,fontSize:h.fontSize,anchor:"middle",paint:{fill:n.style.edgeTextColor??"var(--_text)"}})}]}))}if(n.title)s.push(e.text(En(n.title,n.style)));s.push(e.documentClose());return{family:"requirement",width:n.width,height:n.height,colors:i,transparent:r,parts:s}}function KN({positioned:e}){const t=e.nodes.flatMap(n=>n.rows.map((i,r)=>({id:`field:${n.id}:${r}`,text:i.block.text,bounds:Yt(i.block,n.x+n.paddingX,n.y+i.y,"start"),container:ln(n)})));if(e.title)t.push({id:"title",text:e.title.text,bounds:Yt(e.title.block,e.title.x,e.title.y),container:ln(Xt(e))});return{version:1,bounds:{w:ye(e.width),h:ye(e.height)},nodes:e.nodes.map(n=>({id:n.id,x:ye(n.x),y:ye(n.y),w:ye(n.width),h:ye(n.height),shape:"rectangle",label:n.header.text,role:"box",...St(n.header,n.x+n.width/2,n.y+n.headerHeight/2,n)})),edges:e.edges.map(n=>({id:n.id,from:n.src,to:n.dst,path:n.points.map(i=>[ye(i.x),ye(i.y)]),label:{x:ye(n.labelPosition.x),y:ye(n.labelPosition.y),text:n.label.text,bounds:Yt(n.label,n.labelPosition.x,n.labelPosition.y)}})),groups:[],labels:t}}var JN=gt(l6);var Abe={configDiagnostics:UN,statementEnds:eL,layout:e=>{const t=gF(ya(e.source));t.title??=Ar(e.source.frontmatter);t.accessibilityTitle=e.source.accessibility.title??t.accessibilityTitle;t.accessibilityDescription=e.source.accessibility.descr??t.accessibilityDescription;return mt(VN(t,e.renderOptions,e.styleFace,e.source.config.requirement))},projectPositioned:ft(KN),lowerScene:ht(JN)};function QN(e){const t=Wt(typeof e==="string"?e.split(/\r?\n/):e);pr(t);const n=t.familyLines;const i=n.findIndex(s=>s.trim()&&!s.trim().startsWith("%%"));if(!/^treemap(?:-beta)?\s*$/i.test(Gt(n[i]?.trim()??"")))throw new Error("Treemap source must start with treemap");const r={kind:"treemap",nodes:[],classDefs:Object.create(null),...vr(zo(t.accessibility))};const o=[];for(let s=i+1;s<n.length;s++){const a=n[s];const l=Gt(a).trim();if(!l)continue;Ge("treemap","statement",a,{line:s+1,unit:"normalized"});const c=/^title(?:\s+(.*))?$/i.exec(l);if(c){r.title=yo(Wo(c[1]??""),"\r\n");ue("treemap","set-title",r.title);continue}const d=/^classDef\s+([A-Za-z_]\w*)\s+(.+?);?$/.exec(l);if(d){const m=Lt(vn(d[2]),`classDef ${d[1]}`);r.classDefs[d[1]]={...r.classDefs[d[1]]??{},...m};ue("treemap","define-class",{name:d[1],style:m});continue}const u=a.match(/^[\t ]*/)?.[0].length??0;let f=u;let h=l;while(h){const m=/^(?:"([^"]*)"|'([^']*)')(?:\s*[:,]\s*([0-9_.,]+))?(?:\s*:::\s*([A-Za-z_]\w*))?/.exec(h);if(!m)throw new Error(`Invalid Treemap statement at line ${s+1}: ${h}`);Ve("nodes",r.nodes.length+1);while(o.length&&o.at(-1).indent>=f)o.pop();const p=o.at(-1)?.node.id;const g=m[3]===void 0?void 0:Number(m[3].replace(/[,_]/g,""));Ve("nesting",o.length+(g===void 0?1:0));if(g!==void 0&&(!Number.isFinite(g)||g<0))throw new Error(`Invalid Treemap value at line ${s+1}`);const y={id:`treemap-${r.nodes.length}`,label:yo(Wo(m[1]??m[2]),"\r\n"),...p?{parentId:p}:{},...g===void 0?{}:{value:g},...m[4]?{className:m[4]}:{}};r.nodes.push(y);if(ie("treemap"))ue("treemap","add-node",y,{line:s+1,column:u+l.length-h.length+1,unit:"normalized"});if(g===void 0)o.push({indent:f,node:y});const b=h.slice(m[0].length);f=b.match(/^[\t ]*/)?.[0].length??0;h=b.slice(f)}}return r}import{format as c6}from"d3-format";function EM(e={}){const t=(n,i,r=0)=>{const o=e[n];if(o===void 0)return i;if(typeof o!=="number"||!Number.isFinite(o)||o<r||o>1e4)return i;return o};return{width:t("nodeWidth",96,1)*10,height:t("nodeHeight",50,1)*10,padding:t("padding",10),diagramPadding:t("diagramPadding",16),showValues:e.showValues!==false,labelFontSize:t("labelFontSize",14,1),valueFontSize:t("valueFontSize",12,1),borderWidth:t("borderWidth",1),valueFormat:typeof e.valueFormat==="string"?e.valueFormat:","}}function d6(e){if(e==="$0,0")e="$,";try{return c6(e)}catch{throw new Error(`Invalid treemap.valueFormat ${JSON.stringify(e)}`)}}function u6(e,t){const n=e.map((f,h)=>({...f,index:h})).filter(f=>f.value>0).sort((f,h)=>h.value-f.value||f.index-h.index);const i=n.reduce((f,h)=>f+h.value,0);if(!Number.isFinite(i))throw new Error("Treemap total exceeds the finite numeric range");const r=i>0?t.width*t.height/i:0;const o=n.map(f=>({...f,area:f.value*r}));const s=[];let{x:a,y:l,width:c,height:d}=t;let u=0;while(u<o.length&&c>0&&d>0){const f=Math.min(c,d);let h=u+1;let m=o[u].area;let p=m;const g=m;const y=(w,C)=>Math.max(f*f*g/(w*w),w*w/(f*f*C));let b=y(m,p);while(h<o.length){const w=o[h].area;const C=y(m+w,Math.min(p,w));if(C>b)break;b=C;m+=w;p=Math.min(p,w);h++}const S=c>=d;const x=S?Math.min(c,m/d):Math.min(d,m/c);let k=S?l:a;for(let w=u;w<h;w++){const C=o[w];const R=w===h-1?(S?l+d:a+c)-k:C.area/x;s.push({id:C.id,value:C.value,x:S?a:k,y:S?k:l,width:S?x:R,height:S?R:x});k+=R}if(S){a+=x;c=Math.max(0,c-x)}else{l+=x;d=Math.max(0,d-x)}u=h}for(;u<o.length;u++){const f=o[u];s.push({id:f.id,value:f.value,x:t.x,y:t.y,width:0,height:0})}for(const f of e)if(f.value<=0)s.push({...f,x:t.x,y:t.y,width:0,height:0});return s}function ZN(e,t={},n=EM(),i){ky(e.nodes,S=>S.value===void 0);const r=Xe(t,{...Oi,nodeLabelFontSize:n.labelFontSize,groupHeaderFontSize:n.labelFontSize,groupHeaderFontWeight:Oi.nodeLabelFontWeight},i);const o=Qs(e.nodes);const s=new Map;for(const S of[...e.nodes].reverse())s.set(S.id,S.value??(o.get(S.id)??[]).reduce((x,k)=>x+(s.get(k.id)??0),0));const a=tn(e.title,r);const l=n.diagramPadding;const c=Math.max(n.width,(a?.width??0)+l*2);const d=n.height+(a?.height??0)+l*2;const u=[];const f=[];let h;const m=o.get(void 0)??[];const p=new Map(m.map((S,x)=>[S.id,x]));const g=new Map(e.nodes.map(S=>[S.id,S]));const y=[{items:m,box:{x:l,y:l+(a?.height??0),width:c-l*2,height:n.height},depth:0}];while(y.length){const S=y.pop();const x=u6(S.items.map(k=>({id:k.id,value:s.get(k.id)??0})),S.box);for(const k of x){const w=g.get(k.id);const C=S.category??p.get(w.id)??0;const R={node:w,total:k.value,x:k.x,y:k.y,width:k.width,height:k.height,depth:S.depth,category:C};const M=o.get(w.id);let P=0;if(k.width>0&&k.height>0){const E=w.value===void 0,v=E?i?.group:i?.node,L=v?.paddingX??6,T=v?.paddingY??6,A=Math.max(1,k.width-L*2),$=E?r.groupFont??t.font:t.font,_=E?r.groupLetterSpacing:r.nodeLetterSpacing,z=E?r.groupTextTransform:r.nodeTextTransform;const F=_e(w.label,{fontSize:E?r.groupHeaderFontSize:r.nodeLabelFontSize,fontWeight:E?r.groupHeaderFontWeight:r.nodeLabelFontWeight,letterSpacing:_,transform:z,fontFamily:$,maxWidth:A});const G=n.showValues?_e((h??=d6(n.valueFormat))(k.value),{fontSize:v?.fontSize??i?.text?.fontSize??n.valueFontSize,fontWeight:v?.fontWeight??i?.text?.fontWeight??400,letterSpacing:_,transform:z,fontFamily:$,maxWidth:A}):void 0;P=F.height+(G?G.height+4:0)+T*2;if(F.width<=k.width-L*2&&P<=k.height){R.label=F;R.valueLabel=G;R.labelY=k.y+T+F.height/2;if(G)R.valueY=k.y+T+4+F.height+G.height/2;if(E&&r.groupHeaderFillColor!==void 0)R.headerHeight=P}else f.push(w.label)}else f.push(w.label);u.push(R);if(M?.length){const E=R.label?P:0;const v=Math.min(n.padding,k.width/4,Math.max(0,k.height-E)/4);const L=i?.group?.paddingX===void 0?v:Math.min(i.group.paddingX,k.width/4),T=i?.group?.paddingY===void 0?v:Math.min(i.group.paddingY,Math.max(0,k.height-E)/4);y.push({items:M,box:{x:k.x+L,y:k.y+E+T,width:Math.max(0,k.width-2*L),height:Math.max(0,k.height-E-2*T)},depth:S.depth+1,category:C})}}}const b=new Map(e.nodes.map((S,x)=>[S.id,x]));u.sort((S,x)=>b.get(S.node.id)-b.get(x.node.id));return{width:c,height:d,body:e,cells:u,config:n,hiddenLabels:f,options:t,...a?{title:rn(a,c,l)}:{}}}var Zs="#3b82f6";function Wy(e){const[t,n,i]=w1(e);const r=t/255;const o=n/255;const s=i/255;const a=Math.max(r,o,s);const l=Math.min(r,o,s);const c=(a+l)/2;if(a===l)return[0,0,c*100];const d=a-l;const u=c>.5?d/(2-a-l):d/(a+l);let f;if(a===r)f=((o-s)/d+(o<s?6:0))/6;else if(a===o)f=((s-r)/d+2)/6;else f=((r-o)/d+4)/6;return[f*360,u*100,c*100]}function RM(e,t,n){const i=t/100;const r=n/100;const o=(1-Math.abs(2*r-1))*i;const s=o*(1-Math.abs(e/60%2-1));const a=r-o/2;let l,c,d;if(e<60){l=o;c=s;d=0}else if(e<120){l=s;c=o;d=0}else if(e<180){l=0;c=o;d=s}else if(e<240){l=0;c=s;d=o}else if(e<300){l=s;c=0;d=o}else{l=o;c=0;d=s}const u=f=>Math.round((f+a)*255).toString(16).padStart(2,"0");return`#${u(l)}${u(c)}${u(d)}`}function Th(e){return C1(e)}function vM(e){return Wy(e)[2]<50}function e$(e,t,n){if(e===0)return t;const i=Th(t)?t:Zs;const r=n&&Th(n)?n:void 0;const[o,s]=Wy(i);const a=Math.max(55,Math.min(85,s));const l=Math.ceil(e/2);const c=e%2===1;const d=r&&vM(r)?!c:c;const u=d?Math.max(25,48-l*13):Math.min(78,55+l*11);const f=(d?-8:12)*l;const h=((o+f)%360+360)%360;return RM(h,a,u)}function TM(e){return e<=.0031308?12.92*e:1.055*e**(1/2.4)-.055}function Cr(e){const t=cl(e);if(!t)return null;const n=Qh(t[0]/255);const i=Qh(t[1]/255);const r=Qh(t[2]/255);const o=.4122214708*n+.5363325363*i+.0514459929*r;const s=.2119034982*n+.6806995451*i+.1073969566*r;const a=.0883024619*n+.2817188376*i+.6299787005*r;const l=Math.cbrt(o);const c=Math.cbrt(s);const d=Math.cbrt(a);return{L:.2104542553*l+.793617785*c-.0040720468*d,a:1.9779984951*l-2.428592205*c+.4505937099*d,b:.0259040371*l+.7827717662*c-.808675766*d}}function f6(e){const t=e.L+.3963377774*e.a+.2158037573*e.b;const n=e.L-.1055613458*e.a-.0638541728*e.b;const i=e.L-.0894841775*e.a-1.291485548*e.b;const r=t*t*t;const o=n*n*n;const s=i*i*i;const a=4.0767416621*r-3.3077115913*o+.2309699292*s;const l=-1.2684380046*r+2.6097574011*o-.3413193965*s;const c=-.0041960863*r-.7034186147*o+1.707614701*s;return Yn(TM(a)*255,TM(l)*255,TM(c)*255)}function h6(e){const t=Math.hypot(e.a,e.b);const n=(Math.atan2(e.b,e.a)*180/Math.PI+360)%360;return{L:e.L,C:t,h:n}}function m6(e){const t=e.h*Math.PI/180;return{L:e.L,a:e.C*Math.cos(t),b:e.C*Math.sin(t)}}function bc(e){return f6(m6(e))}function qd(e){const t=Cr(e);return t?h6(t):null}function AM(e,t){const n=Cr(e);const i=Cr(t);if(!n||!i)return null;return Math.hypot(n.L-i.L,n.a-i.a,n.b-i.b)}function Lh(e){let t=Infinity;for(let n=0;n<e.length;n++){for(let i=n+1;i<e.length;i++){const r=AM(e[n],e[i]);if(r!==null&&r<t)t=r}}return t}var LM=2.4;var p6=.2126729;var g6=.7151522;var y6=.072175;var t$=.022;var x6=1.414;var b6=1.14;var S6=1.14;var w6=.027;var M6=.027;var k6=5e-4;var n$=.1;function i$(e){const t=cl(e);if(!t)return null;const n=p6*(t[0]/255)**LM+g6*(t[1]/255)**LM+y6*(t[2]/255)**LM;return n<t$?n+(t$-n)**x6:n}function C6(e,t){const n=i$(e);const i=i$(t);if(n===null||i===null)return null;if(Math.abs(i-n)<k6)return 0;let r;let o;if(i>n){r=(i**.56-n**.57)*b6;o=r<n$?0:r-w6}else{r=(i**.65-n**.62)*S6;o=r>-n$?0:r+M6}return o*100}function Qa(e,t){const n=C6(e,t);return n===null?null:Math.abs(n)}var P6=6;var E6=1.25;var R6=15;var Za=.1;var o$=24;var r$=264;var v6=.11;var IM=.16;function Ji(e,t={}){return T6(e,t)}function T6(e,t,n){const i=Xd(t.labelInk);let r;const o=i===void 0?void 0:()=>r??=_M(Xd(t.bg),n,i);if(e<=P6){const l=t.accent??Zs;const c=Array.from({length:Math.max(0,e)},(d,u)=>e$(u,l,t.bg));return L6(c,t.bg,n,i,o)}const s=Xd(t.bg);const a=Xd(t.accent,s)??Zs;return A6(e,a,s,n,i,o)}function L6(e,t,n,i,r){const o=Xd(t);const s=e.map(u=>Xd(u,o));if(s.some(u=>u===void 0))return e;const a=s;const l=((o===void 0?null:Cr(o))?.L??1)<.55;const c=a.map(u=>{if(os(u,o,i))return u;const f=qd(u);return f?NM(f,o,l,n,i,r):u});const d=c.length>1?a$(c,o,l,n,i,r):c;return d.map((u,f)=>u===a[f]?e[f]:u)}function Xd(e,t){if(e===void 0)return void 0;const n=Vt(e);if(!n)return void 0;if(n[3]===1)return Yn(n[0],n[1],n[2]);if(t===void 0)return void 0;const i=Vt(t);if(!i||i[3]!==1)return void 0;return Yn(n[0]*n[3]+i[0]*(1-n[3]),n[1]*n[3]+i[1]*(1-n[3]),n[2]*n[3]+i[2]*(1-n[3]))}function A6(e,t,n,i,r,o){const s=qd(t)??{L:.6,C:IM,h:r$};const a=s.C<.03;const l=a?r$:s.h;const c=Math.max(v6,Math.min(IM,a?IM:s.C));const d=((n===void 0?null:Cr(n))?.L??1)<.55;const u=d?[.74,.6]:[.56,.7];const f=360/e;const h=Array.from({length:e},(m,p)=>{if(p===0&&os(t,n,r))return t;const g=p===0?l:((l+p*f)%360+360)%360;const y=p===0?s.L:u[p%2];return NM({L:y,C:c,h:g},n,d,i,r,o)});return e<=o$?a$(h,n,d,i,r,o):$6(h,n,d,i,r,o)}function os(e,t,n){if(n!==void 0&&(yu(e,n)??0)<Lc)return false;if(t===void 0)return true;const i=yu(e,t);const r=Qa(e,t);return i!==null&&r!==null&&i>=E6&&r>=R6}function NM(e,t,n,i,r,o){if(i)i.candidateEvaluations++;const s=bc(e);if(os(s,t,r))return s;const a=(t===void 0?void 0:Cr(t))?.L??(n?0:1);const l=e.L>=a?1:-1;for(let d=1;d<=24;d++){const u=d*.04;for(const f of[l,-l]){if(i)i.candidateEvaluations++;const h=bc({...e,L:Ud(e.L+f*u)});if(os(h,t,r))return h}}const c=["#000000","#ffffff"].filter(d=>os(d,t,r));if(c.length>0){return c.sort((d,u)=>t===void 0?0:(Qa(u,t)??0)-(Qa(d,t)??0))[0]}if(r!==void 0){const d=Cr(s);let u;let f=Infinity;for(const h of o?.()??_M(t,i,r)){if(i){i.candidateEvaluations++;if(d)i.pairDistanceChecks++}const m=d?l$(h.lab,d):0;if(m<f){u=h;f=m}}if(u)return u.hex;s$()}return s}function s$(){throw new Error("Cannot derive categorical fills within bounded search with readable label ink, page visibility and distinct peer colors; select a different textColor or explicit fillColor")}function $M(e,t,n){const i=t===void 0?null:Vt(t);if(!i||i[3]!==1)return e;const r=Yn(i[0],i[1],i[2]);const o=Vt(e);if(!o||o[3]!==1)return e;const s=Yn(o[0],o[1],o[2]);const a=u=>Zi(u,r,n);if(os(a(s),r))return e;const l=qd(s);if(!l)return e;const c=Cr(r)?.L??1;const d=l.L>=c?1:-1;for(let u=1;u<=24;u++){const f=u*.04;for(const h of[d,-d]){const m=bc({...l,L:Ud(l.L+h*f)});if(os(a(m),r))return m}}return["#000000","#ffffff"].sort((u,f)=>(Qa(a(f),r)??0)-(Qa(a(u),r)??0))[0]}function a$(e,t,n,i,r,o){const s=[];for(let l=0;l<e.length;l++){const c=e[l];const d=l===0&&os(c,t,r);s.push(d||FM(c,s,i)>=Za?c:I6(c,s,t,n,i,r))}if(i)i.pairDistanceChecks+=s.length*(s.length-1)/2;if(Lh(s)>=Za)return s;const a=N6(s,t,i,r,o);if(r!==void 0&&zy(a,i)<Za)s$();return a}function zy(e,t){if(t)t.pairDistanceChecks+=e.length*(e.length-1)/2;return Lh(e)}function FM(e,t,n){let i=Infinity;for(const r of t){if(n)n.pairDistanceChecks++;const o=AM(e,r);if(o!==null&&o<i)i=o}return i}var Ud=e=>Math.max(.08,Math.min(.97,e));function I6(e,t,n,i,r,o){const s=qd(e);if(!s)return e;let a=e;let l=FM(e,t,r);for(let c=1;c<=12;c++){const d=c*.03;const u=c*7;const f=[{...s,L:Ud(s.L+d)},{...s,L:Ud(s.L-d)},{...s,h:(s.h+u)%360},{...s,h:(s.h-u+360)%360},{...s,L:Ud(i?s.L+d:s.L-d),h:(s.h+u)%360}];for(const h of f){if(r)r.candidateEvaluations++;const m=bc(h);if(!os(m,n,o))continue;const p=FM(m,t,r);if(p>=Za)return m;if(p>l){l=p;a=m}}}return a}function _M(e,t,n){const i=new Map;const r=l=>{if(t)t.candidateEvaluations++;if(i.has(l)||!os(l,e,n))return;const c=Cr(l);if(c)i.set(l,{hex:l,lab:c})};r("#000000");r("#ffffff");const o=n!==void 0;const s=o?44:22;const a=o?Array.from({length:14},(l,c)=>(c+1)*.02):[.04,.08,.12,.16,.2,.24,.28];for(let l=0;l<=s;l++){const c=.08+l*(o?.02:.04);r(bc({L:c,C:0,h:0}));for(const d of a){for(let u=0;u<360;u+=o?5:10)r(bc({L:c,C:d,h:u}))}}if(n!==void 0){for(let l=0;l<=255;l+=17){for(let c=0;c<=255;c+=17){for(let d=0;d<=255;d+=17)r(Yn(l,c,d))}}}return[...i.values()]}var F6=(e,t)=>Math.hypot(e.L-t.L,e.a-t.a,e.b-t.b);var l$=(e,t)=>{const n=e.L-t.L,i=e.a-t.a,r=e.b-t.b;return Math.sqrt(n*n+i*i+r*r)};function N6(e,t,n,i,r){if(e.length<2)return e;const o=i===void 0?F6:l$;const s=r?.()??_M(t,n,i);const a=Cr(e[0]);if(!a)return e;const l={hex:e[0],lab:a};const c=i===void 0?void 0:Float64Array.from(s,b=>{if(n)n.pairDistanceChecks++;return o(b.lab,l.lab)});const d=b=>{const S=b?[l,b]:[l];const x=new Set(S.map(C=>C.hex.toLowerCase()));const k=c?.slice();const w=C=>{if(!k)return;for(let R=0;R<s.length;R++){if(n)n.pairDistanceChecks++;k[R]=Math.min(k[R],o(s[R].lab,C.lab))}};if(b)w(b);while(S.length<e.length){let C;let R=-1;let M=Infinity;const P=Cr(e[S.length]);for(let E=0;E<s.length;E++){const v=s[E];if(x.has(v.hex.toLowerCase()))continue;if(n)n.candidateEvaluations++;let L=k?.[E]??Infinity;if(!k){for(const A of S){if(n)n.pairDistanceChecks++;L=Math.min(L,o(v.lab,A.lab))}}if(P&&i!==void 0&&n)n.pairDistanceChecks++;const T=P?o(v.lab,P):0;if(L>R+1e-12||Math.abs(L-R)<=1e-12&&T<M){C=v;R=L;M=T}}if(!C)return e;S.push(C);x.add(C.hex.toLowerCase());w(C)}return S.map(C=>C.hex)};const u=d();if(i===void 0)return u;let f=zy(u,n);if(f>=Za)return u;let h=u;for(const b of u.slice(2)){const S=Cr(b);if(!S)continue;if(n)n.pairDistanceChecks++;if(o(l.lab,S)<Za)continue;const x=d({hex:b,lab:S});const k=zy(x,n);if(k>=Za)return x;if(k>f){h=x;f=k}}const m=h.map(b=>({hex:b,lab:Cr(b)}));const p=m.length;const g=new Float64Array(s.length*p);const y=b=>{for(let S=0;S<s.length;S++){if(n)n.pairDistanceChecks++;g[S*p+b]=o(s[S].lab,m[b].lab)}};for(let b=0;b<p;b++)y(b);for(let b=0;b<o$;b++){let S=false;for(let k=1;k<p;k++){let w=Infinity;for(let R=0;R<p;R++)if(R!==k){if(n)n.pairDistanceChecks++;w=Math.min(w,o(m[k].lab,m[R].lab))}let C;for(let R=0;R<s.length;R++){if(n)n.candidateEvaluations++;let M=Infinity;for(let P=0;P<p;P++)if(P!==k){M=Math.min(M,g[R*p+P]);if(M<=w+1e-12)break}if(M>w+1e-12){w=M;C=s[R]}}if(C){m[k]=C;y(k);S=true}}const x=m.map(k=>k.hex);if(zy(x,n)>=Za)return x;if(!S)break}return m.map(b=>b.hex)}function $6(e,t,n,i,r,o){const s=new Set;return e.map((a,l)=>{if(i)i.tailItems++;if(!s.has(a.toLowerCase())){s.add(a.toLowerCase());return a}const c=qd(a);if(c){for(let d=1;d<=24;d++){if(i)i.candidateEvaluations++;const u=NM({...c,L:Ud(c.L+(d%2===0?1:-1)*Math.ceil(d/2)*.008),h:(c.h+d*137.508+l*.01)%360},t,n,i,r,o);if(!s.has(u.toLowerCase())){s.add(u.toLowerCase());return u}}}return a})}function _6(e,{positioned:t,colors:n,resolved:i}){const r=Xe(i.renderOptions,{...Oi,nodeLabelFontSize:t.config.labelFontSize},i.styleFace);const o=t.body.nodes.filter(b=>!b.parentId).length,s={accent:n.accent,bg:n.bg},a=Ji(o,s);const l=[];const c=new Map;const d=Ur(n);const u=new Map,f=(i.paintBackendId==="backend:rough"||i.paintBackendId==="backend:hybrid")&&j1("label").textHalo,h=f?Vt(_n("var(--bg)",n)??n.bg):void 0;const m=b=>{if(b===void 0)return a;const S=u.get(b);if(S)return S;const x=Vt(_n(b,n)??b);const k=x?.[3]===1?Yn(x[0],x[1],x[2]):void 0,w=k!==void 0&&h?.[3]===1&&M1(k,Yn(h[0],h[1],h[2]))>=Lc,C=k!==void 0&&!w?Ji(o,{...s,labelInk:k}):a;u.set(b,C);return C};const p=Qs(t.body.nodes);const g=t.cells.filter(b=>!b.node.parentId).reduce((b,S)=>b+S.total,0);if(t.title)l.push(e.text(En(t.title,r)));for(const b of t.cells){if(b.width<=0||b.height<=0){c.set(b.node.id,[]);continue}const S=b.node.value===void 0,x={value:g>0?b.total/g:0,category:String(b.category)},k=st(i.styleFace,"bar",x,{includeFallback:false});const w=b.node.className?t.body.classDefs[b.node.className]:void 0;const C=S?r.groupFillColor:r.nodeFillColor,R=S?r.groupTextColor:r.nodeTextColor,M=w?.color??R,P=S&&b.headerHeight?w?.fill??r.groupHeaderFillColor:void 0,E=w?.fill??k?.fillColor??C,v=E===void 0&&P===void 0&&w?.color===void 0?m(R):a,L=E??v[b.category]??"var(--_node-fill)",T=w?.stroke??k?.strokeColor??k?.borderColor??(S?r.groupBorderColor:r.nodeBorderColor)??"var(--bg)",A=w?.["stroke-width"]??String(k?.lineWidth??(S?i.styleFace?.group?.lineWidth:i.styleFace?.node?.lineWidth)??t.config.borderWidth),$=Math.min((S?r.groupCornerRadius:r.cornerRadius)??0,b.width/2,b.height/2,P?b.headerHeight/2:Infinity);const _=P??L;const z=M??d("var(--_text)",_,Boolean(w?.fill||k?.fillColor||P||!C));const F={id:b.node.id,role:S?"group":"node"};const G=[];if(b.width>0&&b.height>0)G.push(e.shape({id:`cell:${b.node.id}`,role:"bar",owner:F,geometry:{kind:"rect",x:b.x,y:b.y,width:b.width,height:b.height,...$>0?{rx:$,ry:$}:{}},paint:{fill:L,stroke:T,strokeWidth:A},channels:x}));if(P&&b.width>0&&b.height>0){const I=Math.min((Number.parseFloat(A)||0)/2,b.width/2,b.headerHeight/2),D=b.x+I,B=b.y+I,Y=b.width-I*2,W=b.headerHeight-I,O=Math.max(0,$-I);if(Y>0&&W>0)G.push(e.shape({id:`header:${b.node.id}`,role:"chrome",owner:F,geometry:O>0?{kind:"path",d:`M${D+O} ${B}H${D+Y-O}Q${D+Y} ${B} ${D+Y} ${B+O}V${B+W}H${D}V${B+O}Q${D} ${B} ${D+O} ${B}Z`}:{kind:"rect",x:D,y:B,width:Y,height:W},paint:{fill:P,stroke:"none"}}))}if(b.label)G.push(e.text({id:`label:${b.node.id}`,role:"label",owner:F,text:b.label.text,block:b.label,x:b.x+b.width/2,y:b.labelY,fontSize:b.label.fontSize,fontWeight:b.label.fontWeight,anchor:"middle",paint:{fill:z}}));if(b.valueLabel)G.push(e.text({id:`value:${b.node.id}`,role:"label",owner:F,text:b.valueLabel.text,block:b.valueLabel,x:b.x+b.width/2,y:b.valueY,fontSize:b.valueLabel.fontSize,fontWeight:b.valueLabel.fontWeight,anchor:"middle",paint:{fill:z}}));c.set(b.node.id,G)}const y=new Map;for(const b of[...t.cells].reverse()){const S=c.get(b.node.id);for(const w of p.get(b.node.id)??[]){const C=y.get(w.id);if(C)S.push(C)}const x=b.node.value===void 0,k=!b.label?Ye(`${b.node.label}: ${b.total}`):void 0;y.set(b.node.id,e.group({id:b.node.id,role:x?"group":"node",open:`<g${b.node.parentId?` data-parent="${Ye(b.node.parentId)}"`:""}${k===void 0?"":` role="${x?"group":"graphics-symbol"}" aria-roledescription="treemap ${x?"section":"cell"}"`}>${k===void 0?"":`<title>${k}</title>`}`,close:"</g>",children:S.map(w=>({node:w,indent:2}))}))}for(const b of t.cells)if(!b.node.parentId)l.push(y.get(b.node.id));return rs(e,"treemap",t,n,i.renderOptions.transparent??false,l)}var c$=gt(_6);function d$({positioned:e}){const t=Qs(e.body.nodes);return{version:1,bounds:{w:ye(e.width),h:ye(e.height)},nodes:e.cells.filter(n=>n.node.value!==void 0).map(n=>({id:n.node.id,...n.node.parentId?{parentId:n.node.parentId}:{},x:ye(n.x),y:ye(n.y),w:zt(n.x,n.width),h:zt(n.y,n.height),shape:"rectangle",label:n.node.label,role:"mark",labelVisibility:n.label?"visible":"hidden",...n.label?St(n.label,n.x+n.width/2,n.labelY,n):{}})),edges:[],groups:e.cells.filter(n=>n.node.value===void 0).map(n=>({id:n.node.id,...n.node.parentId?{parentId:n.node.parentId}:{},x:ye(n.x),y:ye(n.y),w:zt(n.x,n.width),h:zt(n.y,n.height),members:(t.get(n.node.id)??[]).map(i=>i.id),label:n.node.label,regionKind:"compartment"})),labels:[...e.title?[{id:"title",text:e.title.text,bounds:Yt(e.title.block,e.title.x,e.title.y),container:ln(Xt(e))}]:[],...e.cells.flatMap(n=>[...n.node.value===void 0&&n.label?[{id:`section-label:${n.node.id}`,text:n.label.text,bounds:Yt(n.label,n.x+n.width/2,n.labelY),container:ln(n)}]:[],...n.valueLabel?[{id:`value:${n.node.id}`,text:n.valueLabel.text,bounds:Yt(n.valueLabel,n.x+n.width/2,n.valueY),container:ln(n)}]:[]])]}}var u$=e=>bt("treemap",e,{nodeWidth:wn(1,1e4),nodeHeight:wn(1,1e4),padding:wn(0,1e4),diagramPadding:wn(0,1e4),labelFontSize:wn(1,1e4),valueFontSize:wn(1,1e4),borderWidth:wn(0,1e4),showValues:ct,valueFormat:Dr,useMaxWidth:ct});var kSe={configDiagnostics:u$,normalizeRequest:e=>({familyConfig:{treemap:EM(e.source.config.treemap)}}),layout:e=>{const t=QN(e.source.authoredFamilyBody??e.source.familyBody);t.title??=typeof e.source.frontmatter.title==="string"?e.source.frontmatter.title:void 0;return mt(ZN(t,e.renderOptions,e.familyConfig.treemap,e.styleFace))},projectPositioned:ft(d$),lowerScene:ht(c$)};function f$(e,t={},n,i,r=24){ky(e.nodes);const o=Xe(t,Oi,n);const s=n?.node?.paddingX??12,a=n?.node?.paddingY??8,l=n?.node?.paddingX??16,c=n?.node?.paddingY??12;const d=Qs(e.nodes);const u=(z,F=false)=>_e(z,{fontSize:o.nodeLabelFontSize,fontWeight:F&&n?.node?.fontWeight===void 0&&n?.text?.fontWeight===void 0?Math.max(600,o.nodeLabelFontWeight):o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,transform:o.nodeTextTransform,maxWidth:220});const f=tn(i,o);const h=e.nodes[0];if(!h)return{width:Math.max(100,(f?.width??0)+r*2),height:80+(f?.height??0),body:e,nodes:[],branches:[],spine:[],options:t,...f?{title:rn(f,Math.max(100,f.width+r*2),r)}:{}};const m=(z,F)=>{const G=u(z.label,true);const I=[];const D=[];const B=[];const Y=(N,H,j)=>{for(let q=N.length-1;q>=0;q--)B.push({node:N[F?N.length-1-q:q],depth:H,parent:j,slot:q,bone:-1})};Y(d.get(z.id)??[],2,-1);while(B.length){const N=B.pop();if(N.bone!==-1){D.push(N.bone);continue}const H=I.length;const j=d.get(N.node.id)??[];I.push({node:N.node,block:u(N.node.label),depth:N.depth,parent:N.parent,slot:N.slot,kids:j.length,rise:0,at:0,textEnd:0});if(N.depth%2===0)D.push(H);else B.push({...N,bone:H});Y(j,N.depth+1,H)}let W=16;for(const N of D){const H=I[N].block.height+14;I[N].rise=W+H/2;W+=H}let O=(G.width+s*2)/2;for(const N of I){const H=N.parent<0?void 0:I[N.parent];if(N.depth%2===0){N.at=H?.at??0;N.textEnd=N.at-(N.kids?(N.kids+1)*24:20)-6}else{N.at=H.at-(H.kids-N.slot)*24;N.textEnd=N.at-6}O=Math.max(O,N.block.width-N.textEnd)}return{node:z,block:G,width:G.width+s*2,height:G.height+a*2,bones:I,rise:Math.max(64,W+12),reach:O}};const p=(d.get(h.id)??[]).map((z,F)=>m(z,F%2===0));const g=u(h.label,true);const y=g.width+l*2;const b=Math.max(52,g.height+c*2);const S=[{node:h,block:g,x:0,y:-b/2,width:y,height:b,depth:0}];const x=[];let k=-40;let w=y;let C=-b/2;let R=b/2;let M=-40;const P=[];for(let z=0;z<p.length;z+=2){if(z>0){let F=0;for(let G=0;G<2;G++){const I=p[z-2+G];const D=p[z+G];if(I)F=Math.max(F,I.reach+(D?.width??0)/2+Math.abs((D?.rise??0)-I.rise)/2)}M-=F+32}P.push(M,M)}const E=(z,F,G,I,D,B,Y)=>{S.push({node:z,block:F,x:G,y:I,width:D,height:B,depth:Y});k=Math.min(k,G);w=Math.max(w,G+D);C=Math.min(C,I);R=Math.max(R,I+B)};p.forEach((z,F)=>{const G=F%2===0?-1:1;const I=P[F];const D=(W,O)=>I+W-O/2;const B=D(0,z.rise);const Y=G*z.rise;E(z.node,z.block,B-z.width/2,Y+(G<0?-z.height:0),z.width,z.height,1);x.push({id:`branch:${z.node.id}`,from:z.node.id,to:h.id,points:[{x:B,y:Y},{x:I,y:0}]});for(const W of z.bones){const O=G*W.rise;const N=D(W.textEnd,W.rise);E(W.node,W.block,N-W.block.width,O-W.block.height/2,W.block.width,W.block.height,W.depth);const H=W.depth%2===0?[{x:N+6,y:O},{x:D(W.at,W.rise),y:O}]:[{x:D(W.at,W.rise),y:O},{x:D(W.at,z.bones[W.parent].rise),y:G*z.bones[W.parent].rise}];x.push({id:`branch:${W.node.id}`,from:W.node.id,to:W.node.parentId,points:H})}});const v=Math.min(k-28,M-28);k=Math.min(k,v);const L=Math.max(w-k,f?.width??0);const T=Math.ceil(L+2*r);const A=Math.ceil(R-C+(f?.height??0)+r*2);const $=r-k+(L-(w-k))/2;const _=r-C+(f?.height??0);for(const z of S){z.x+=$;z.y+=_}for(const z of x)for(const F of z.points){F.x+=$;F.y+=_}return{width:T,height:A,body:e,nodes:S,branches:x,spine:[{x:v+$,y:_},{x:$,y:_}],options:t,...f?{title:rn(f,T,r)}:{}}}var DM=dr("ishikawa-arrow",{width:8,height:8},"end",{fill:"var(--_line)"},"userSpaceOnUse");function D6(e,{positioned:t,colors:n,resolved:i}){const r=Xe(i.renderOptions,Oi,i.styleFace);const o=Ur(n);const s=r.edgeStrokeColor?{...DM,paint:{...DM.paint,fill:r.edgeStrokeColor}}:DM;const a=[];a.push(e.definitions({id:"defs",markerResources:[s]},`<defs>${hi([s])}</defs>`));if(t.title)a.push(e.text(En(t.title,r)));const l=t.nodes.find(c=>c.depth===0);if(t.spine.length)a.push(e.connector({id:"spine",role:"rail",geometry:{kind:"polyline",points:t.spine},lineStyle:"solid",paint:{stroke:r.edgeStrokeColor??"var(--_line)",strokeWidth:String(r.lineWidth)},...l?{endpoints:{to:l.node.id,end:{owner:{id:l.node.id,role:"node"},point:t.spine.at(-1)}}}:{},relationship:{kind:"effect-spine",direction:"forward"},markers:{end:s}}));for(const c of t.branches)a.push(e.connector({id:c.id,role:"edge",geometry:{kind:"polyline",points:c.points},lineStyle:"solid",paint:{stroke:r.edgeStrokeColor??"var(--_line)",strokeWidth:String(r.lineWidth)},endpoints:{from:c.from,to:c.to},relationship:{kind:"cause",direction:"forward"}}));for(const c of t.nodes){const d={id:c.node.id,role:"node"};const u=[];const f=r.nodeFillColor??"var(--_node-fill)";const h=r.nodeTextColor??(c.depth<=1?o("var(--_text)",f):"var(--_text)");if(c.depth<=1)u.push(e.shape({id:`box:${c.node.id}`,role:"node",identity:false,owner:d,geometry:{kind:"rect",x:c.x,y:c.y,width:c.width,height:c.height,rx:r.cornerRadius??(c.depth===0?8:3)},paint:{fill:r.nodeFillColor??"var(--_node-fill)",stroke:r.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(r.nodeLineWidth)}}));u.push(e.text({id:`label:${c.node.id}`,role:"label",owner:d,text:c.block.text,block:c.block,x:c.x+c.width/2,y:c.y+c.height/2,fontSize:c.block.fontSize,fontWeight:c.block.fontWeight,anchor:"middle",paint:{fill:h}}));a.push(e.group({id:c.node.id,role:"node",open:"<g>",close:"</g>",children:u.map(m=>({node:m,indent:2}))}))}return rs(e,"ishikawa",t,n,i.renderOptions.transparent??false,a)}var h$=gt(D6);function m$({positioned:e}){return{version:1,bounds:{w:ye(e.width),h:ye(e.height)},nodes:e.nodes.map(t=>({id:t.node.id,x:ye(t.x),y:ye(t.y),w:ye(t.width),h:ye(t.height),shape:"rectangle",label:t.node.label,role:t.depth<=1?"box":"labelled-mark",...St(t.block,t.x+t.width/2,t.y+t.height/2,t)})),edges:e.branches.map(t=>({id:t.id,from:t.from,to:t.to,path:t.points.map(n=>[ye(n.x),ye(n.y)])})),groups:[],labels:e.title?[{id:"title",text:e.title.text,bounds:Yt(e.title.block,e.title.x,e.title.y),container:ln(Xt(e))}]:[]}}var p$=e=>bt("ishikawa",e,{diagramPadding:jt,useMaxWidth:ct});var qSe={configDiagnostics:p$,layout:e=>{const t=e.source.config.ishikawa;return mt(f$(mF(e.source.authoredFamilyBody??e.source.familyBody),e.renderOptions,e.styleFace,typeof e.source.frontmatter.title==="string"?e.source.frontmatter.title:void 0,typeof t?.diagramPadding==="number"&&Number.isFinite(t.diagramPadding)&&t.diagramPadding>=0?t.diagramPadding:void 0))},projectPositioned:ft(m$),lowerScene:ht(h$)};var g$=e=>bt("block",e,{padding:jt,useMaxWidth:ct});var ss={};for(const e of["start","end"]){ss[`arrow_point:${e}`]=dr(`block-arrow-${e}`,{width:8,height:7},e,{fill:"var(--_arrow)",stroke:"none"},"userSpaceOnUse");ss[`arrow_circle:${e}`]={id:`block-circle-${e}`,shape:"circle",size:{width:9,height:9},ref:{x:4.5,y:4.5},orient:"auto",geometry:{kind:"circle",cx:4.5,cy:4.5,r:3.5},paint:{fill:"var(--bg)",stroke:"var(--_arrow)",strokeWidth:"1"},units:"userSpaceOnUse"};ss[`arrow_cross:${e}`]={id:`block-cross-${e}`,shape:"cross",size:{width:9,height:9},ref:{x:4.5,y:4.5},orient:"auto",geometry:{kind:"path",d:"M1 1L8 8M1 8L8 1"},paint:{fill:"none",stroke:"var(--_arrow)",strokeWidth:"1"},units:"userSpaceOnUse"}}var Vd=gr(Object.values(ss));var as=1;var ls=2;var cs=4;var ds=8;var Gy=7;var Hy=20;var tl=12;function Kd(e){let t=0;if(e){for(const n of e){switch(n.trim()){case"right":t|=as;break;case"left":t|=ls;break;case"up":t|=cs;break;case"down":t|=ds;break;case"x":t|=as|ls;break;case"y":t|=cs|ds;break}}}return t}var el=(e,t)=>e&t?1:0;function y$(e){if(e!==0&&(e&(cs|ds))===0)return"x";if(e!==0&&(e&(as|ls))===0)return"y";return""}function Ah(e,t,n){const i=y$(e);const r=el(e,ls)-el(e,as);const o=el(e,cs)-el(e,ds);if(i==="x"){const s=Math.max(n+8,14)+2*Gy;const a=Math.min(s/2,Hy);return{w:Math.max(t+12,16)+a*(e===(as|ls)?2:1),h:s,dx:r*a/2,dy:0}}if(i==="y"){const s=Math.max(t+16,14)+2*Gy;const a=Math.min(s/2,Hy);return{w:s,h:Math.max(n+8,16)+a*(e===(cs|ds)?2:1),dx:0,dy:o*a/2}}return{w:Math.max(t+16,24)+tl*(el(e,ls)+el(e,as)),h:Math.max(n+8,24)+tl*(el(e,cs)+el(e,ds)),dx:r*tl/2,dy:o*tl/2}}function jy(e,t,n){const i=y$(e);const r=t/2;const o=n/2;let s;if(i==="x"){const l=Math.min(o,Hy);const c=o-Gy;const d=e&ls?-r+l:-r;const u=e&as?r-l:r;s=[d,-c,u,-c];if(e&as)s.push(u,-o,r,0,u,o);s.push(u,c,d,c);if(e&ls)s.push(d,o,-r,0,d,-o)}else if(i==="y"){const l=Math.min(r,Hy);const c=r-Gy;const d=e&cs?-o+l:-o;const u=e&ds?o-l:o;s=[c,d,c,u];if(e&ds)s.push(r,u,0,o,-r,u);s.push(-c,u,-c,d);if(e&cs)s.push(-r,d,0,-o,r,d)}else{const l=e&ls?-r+tl:-r;const c=e&as?r-tl:r;const d=e&cs?-o+tl:-o;const u=e&ds?o-tl:o;const f=(l+c)/2;const h=(d+u)/2;const m=Math.min(10,(c-l)/2);const p=Math.min(10,(u-d)/2);s=[l,d];if(e&cs)s.push(f-m,d,f,-o,f+m,d);s.push(c,d);if(e&as)s.push(c,h-p,r,h,c,h+p);s.push(c,u);if(e&ds)s.push(f+m,u,f,o,f-m,u);s.push(l,u);if(e&ls)s.push(l,h+p,-r,h,l,h-p)}const a=[];for(let l=0;l<s.length;l+=2)a.push({x:s[l],y:s[l+1]});return a}var O6=1e3;function B6(e,t){if(e===0||!Number.isInteger(e)){throw new gh("Columns must be an integer !== 0.","semantic",{type:"block"})}if(t<0||!Number.isInteger(t)){throw new gh("Position must be a non-negative integer."+t,"semantic",{type:"block"})}if(e<0)return{px:t,py:0};return{px:t%e,py:Math.floor(t/e)}}function W6(e,t,n,i){const r=e.columns;const o=[];let s=0;let a=0;let l=0;let c=0;for(const u of e.children){const{px:f,py:h}=B6(r,s);let m=u.span>=1?Math.min(u.span,O6):1;if(r>0&&m>r-f)m=r-f;u.span=m;u.col=f;u.row=h;s+=m;if(f+m>a)a=f+m;if(h===o.length)o.push(0);if(u.children.length===0)o[h]=-1;else if(o[h]>=0&&u.nh>o[h])o[h]=u.nh;if(u.space)continue;const p=(u.nw-t*(m-1))/m;if(p>l)l=p;if(u.nh>c)c=u.nh}let d=(o.length-1)*t;for(let u=0;u<o.length;u++){if(o[u]<0)o[u]=c;d+=o[u]}e.cols=a;e.heights=o;e.nw=Math.max(e.nw,a*l+(a-1)*t+2*n);e.nh=d+2*i+e.head}function z6(e,t,n,i){const{cols:r,heights:o}=e;const s=o.length;const a=(e.w-2*n-(r-1)*t)/r;const l=e.h-2*i-e.head-(s-1)*t;let c=0;for(const p of o)c+=p;const d=c>0?l/c:0;const u=c>0?0:l/s;const f=e.x-e.w/2+n;let h=e.y-e.h/2+i+e.head;let m=0;for(const p of e.children){for(;m<p.row;m++)h+=o[m]*d+u+t;p.w=a*p.span+t*(p.span-1);p.h=o[m]*d+u;p.x=f+p.col*(a+t)+p.w/2;p.y=h+p.h/2}}function x$(e,t){const n=[e];for(let i=0;i<n.length;i++){for(const r of n[i].children)n.push(r)}for(let i=n.length-1;i>=0;i--){const r=n[i];if(r.children.length>0)W6(r,t,i===0?0:r.insetX??t,i===0?0:r.insetY??t)}e.w=e.nw;e.h=e.nh;e.x=e.w/2;e.y=e.h/2;for(let i=0;i<n.length;i++){const r=n[i];if(r.children.length>0)z6(r,t,i===0?0:r.insetX??t,i===0?0:r.insetY??t)}return{width:e.w,height:e.h}}function Yy(e){return cr(vt(yt(e)),/&(?:#[xX][0-9a-fA-F]+|#\d+|[a-zA-Z][a-zA-Z0-9]+);|#\w+;/g,t=>{const n=t.startsWith("&")?zp(t):nn(t);if(go.test(n))throw new SyntaxError("Block label entity must display printable text");return n})}function lwe(e){return ia(Yy(e))}var G6={na:"rectangle",square:"rectangle",round:"rounded",circle:"circle",rect_left_inv_arrow:"asymmetric",diamond:"diamond",hexagon:"hexagon",stadium:"stadium",subroutine:"subroutine",cylinder:"cylinder",doublecircle:"doublecircle",lean_right:"lean-r",lean_left:"lean-l",trapezoid:"trapezoid",inv_trapezoid:"trapezoid-alt"};function Jd(e){return{id:e.id,label:e.block.label??e.id,shape:G6[e.block.type??"na"]??"rectangle",x:e.x,y:e.y,width:e.width,height:e.height}}function b$(e,t={},n,i={}){mP(e);const r=Xe(t,void 0,n),o=t.padding??32;const s=e.edges.map(B=>_e(Yy(B.label??""),{fontSize:r.edgeLabelFontSize,fontWeight:r.edgeLabelFontWeight,maxWidth:320,transform:r.edgeTextTransform,letterSpacing:r.edgeLetterSpacing}));let a=0;for(const B of e.edges)a=Math.max(a,Vd(ss[`${B.arrowTypeStart}:start`]?.id,r.lineWidth,"start"),Vd(ss[`${B.arrowTypeEnd}:end`]?.id,r.lineWidth,"end"));const l=Math.max(a?2*(a+r.edgeBendRadius):0,typeof i.padding==="number"&&i.padding>=0?Math.min(i.padding,200):20,...s.filter(B=>B.text).map(B=>B.width+40));const c=new Map(e.classDefs.map(B=>[B.id,B])),d=[];const u=(B,Y)=>{const W=B.type==="composite";const O=[...c.get("default")?.styles??[],...(B.classes??[]).flatMap(U=>c.get(U)?.styles??[]),...B.styles??[]];const N=Lt(vn(O.join(",")),`style ${B.id}`),H=Number.parseFloat(N["font-size"]??"")||(W?r.groupHeaderFontSize:r.nodeLabelFontSize);const j=N["font-weight"]?.trim().toLowerCase(),q=j===void 0?W?r.groupHeaderFontWeight:r.nodeLabelFontWeight:j==="normal"?400:j==="bold"?700:Number(j);if(!Number.isFinite(q)||q<1||q>1e3)throw new Error(`style ${B.id}: font-weight must be normal, bold, or a number from 1 to 1000`);const X=_e(Yy(B.label??(W?"":B.id)),{fontSize:H,fontWeight:q,maxWidth:320,transform:W?r.groupTextTransform:r.nodeTextTransform,letterSpacing:W?r.groupLetterSpacing:r.nodeLetterSpacing,fontFamily:W?r.groupFont??t.font:t.font});let V=Math.max(80,X.width+(W?r.groupLabelPaddingX:r.nodePaddingX)*2),ee=Math.max(44,X.height+(W?r.groupPaddingY:r.nodePaddingY)*2);if(["diamond","hexagon","lean_right","lean_left","trapezoid","inv_trapezoid"].includes(B.type??"")){V+=48;ee+=24}if(["circle","doublecircle"].includes(B.type??""))V=ee=Math.max(V,ee);if(B.type==="cylinder")ee+=24;if(B.type==="block_arrow"){const U=Ah(Kd(B.directions),X.width,X.height);V=U.w;ee=U.h}if(B.type==="space"){V=40;ee=24}const re=B.type==="composite"&&X.text?X.height+16:0;return{block:B,parentId:Y,label:X,style:N,children:[],columns:B.columns??-1,span:B.widthInColumns??1,space:B.type==="space",head:re,insetX:n?.group?.paddingX,insetY:n?.group?.paddingY,nw:B===e.root?0:V,nh:B===e.root?0:ee,col:0,row:0,cols:0,heights:[],x:0,y:0,w:0,h:0}};const f=u(e.root),h=[f];for(let B=0;B<h.length;B++){const Y=h[B];for(const W of Y.block.children??[]){const O=u(W,Y===f?void 0:Y.block.id);Y.children.push(O);h.push(O);d.push(O)}}const m=x$(f,l),p=tn(e.title,r),g=Math.max(m.width+o*2,(p?.width??0)+o*2),y=p?.height??0;const b=o+(g-o*2-m.width)/2,S=o+y;const x=d.map(B=>{let Y=B.w,W=B.h;if(["circle","doublecircle"].includes(B.block.type??""))Y=W=Math.min(B.w,B.h);return{id:B.block.id,block:B.block,parentId:B.parentId,x:B.x-Y/2+b,y:B.y-W/2+S,width:Y,height:W,label:B.label,style:B.style}});const k=new Map(x.map(B=>[B.id,B])),w=x.filter(B=>B.block.type!=="space").map(Jd),C=new Map(w.map(B=>[B.id,Zc(B)])),R=new Map(x.filter(B=>B.block.type==="block_arrow").map(B=>[B.id,{kind:"polygon",points:jy(Kd(B.block.directions),B.width,B.height).map(Y=>({x:Y.x+B.x+B.width/2,y:Y.y+B.y+B.height/2}))}])),M=w.filter(B=>k.get(B.id).block.type!=="composite"),P=new Map;const E=B=>B.start<B.end?`${B.start}\0${B.end}`:`${B.end}\0${B.start}`;e.edges.forEach((B,Y)=>{const W=E(B),O=P.get(W)??[];O.push(Y);P.set(W,O)});const v=new Map;for(const B of P.values()){const Y=Math.max(...B.map(O=>s[O].width)),W=Math.max(...B.map(O=>s[O].height));B.forEach((O,N)=>v.set(O,{slot:N,count:B.length,width:Y,height:W}))}const L=new Set,T=new Set;const A=(B,Y)=>`${B}\0${Y.x}\0${Y.y}`;const $=e.edges.map((B,Y)=>{const W=k.get(B.start),O=k.get(B.end);if(!W||!O)throw new Error(`Block edge ${B.id} references undeclared endpoints`);const N=s[Y];const{slot:H,count:j,width:q,height:X}=v.get(Y),V=H-(j-1)/2,ee=C.get(W.id)??Zc(Jd(W)),re=C.get(O.id)??Zc(Jd(O));let U;const te={x:W.x+W.width/2,y:W.y+W.height/2},J={x:O.x+O.width/2,y:O.y+O.height/2};let ae=Math.abs(J.x-te.x)>=Math.abs(J.y-te.y);const Q=[J.x>=te.x?ee.E:ee.W,J.x>=te.x?re.W:re.E],K=[J.y>=te.y?ee.S:ee.N,J.y>=te.y?re.N:re.S],Z=pe=>L.has(A(W.id,pe[0]))||T.has(A(O.id,pe[1]));if(j===1&&W!==O&&Z(ae?Q:K)&&!Z(ae?K:Q))ae=!ae;if(W===O){const pe=28+H*(Math.max(q,X)+24);U=[ee.E,{x:ee.E.x+pe,y:ee.E.y},{x:ee.E.x+pe,y:W.y-pe},{x:ee.N.x,y:W.y-pe},ee.N]}else if(j>1&&V!==0){const pe=(ae?X:q)+24;if(ae){const Te=V<0?Math.min(W.y,O.y)+V*pe:Math.max(W.y+W.height,O.y+O.height)+V*pe;const Fe=V<0?ee.N:ee.S,De=V<0?re.N:re.S;U=[Fe,{x:Fe.x,y:Te},{x:De.x,y:Te},De]}else{const Te=V<0?Math.min(W.x,O.x)+V*pe:Math.max(W.x+W.width,O.x+O.width)+V*pe;const Fe=V<0?ee.W:ee.E,De=V<0?re.W:re.E;U=[Fe,{x:Te,y:Fe.y},{x:Te,y:De.y},De]}}else if(ae){const pe=J.x>=te.x?ee.E:ee.W,Te=J.x>=te.x?re.W:re.E,Fe=(pe.x+Te.x)/2+H*12;U=[pe,{x:Fe,y:pe.y},{x:Fe,y:Te.y},Te]}else{const pe=J.y>=te.y?ee.S:ee.N,Te=J.y>=te.y?re.N:re.S,Fe=(pe.y+Te.y)/2+H*12;U=[pe,{x:pe.x,y:Fe},{x:Te.x,y:Fe},Te]}T.add(A(W.id,U[0]));L.add(A(O.id,U.at(-1)));const se={id:B.id,source:W.id,target:O.id,style:"solid",hasArrowStart:B.arrowTypeStart!=="none",hasArrowEnd:B.arrowTypeEnd!=="none",points:xt(U.map(pe=>({...pe})))};const oe=W.block.type==="composite"||O.block.type==="composite"?w.filter(pe=>k.get(pe.id).block.type!=="composite"||pe.id===W.id||pe.id===O.id):M;Lo(oe,[se],{direction:ae?"LR":"TB"});U=se.points;for(const[pe,Te,Fe]of[[W,0,1],[O,U.length-1,U.length-2]]){const De=R.get(pe.id);if(!De)continue;const Be=U[Te],me=U[Fe],he=me.x-Be.x,fe=me.y-Be.y,be=Math.abs(he)>Math.abs(fe),ge=be?he>0?"E":"W":fe>0?"S":"N",Re=Fs(De,ge,be?Be.y:Be.x);if(Re)U[Te]=Re}let de=0;for(let pe=1;pe<U.length-1;pe++)if(Math.hypot(U[pe+1].x-U[pe].x,U[pe+1].y-U[pe].y)>Math.hypot(U[de+1].x-U[de].x,U[de+1].y-U[de].y))de=pe;const xe=U[de],Me=U[de+1],Ce={x:(xe.x+Me.x)/2,y:(xe.y+Me.y)/2};return{...B,points:U,labelBlock:N,labelPosition:Ce}});if($.some(B=>B.label)){const B=$.map(Y=>({...Y,source:Y.start,target:Y.end,style:"solid",hasArrowStart:false,hasArrowEnd:false}));for(let Y=0;Y<$.length;Y++){const W=$[Y],O=B[Y];if(!W.label)continue;const N=W.points.slice(1).map((H,j)=>({start:W.points[j],end:H})).sort((H,j)=>Math.hypot(j.end.x-j.start.x,j.end.y-j.start.y)-Math.hypot(H.end.x-H.start.x,H.end.y-H.start.y));for(const{start:H,end:j}of N){const q=ir(O,H,j,{nodes:M,edges:B,axis:{main:"x",cross:"y",sign:1},style:r,finalLabelClearance:true});if(!q)continue;W.labelPosition=O.labelPosition=q;break}}}const _=Math.min(o,...$.flatMap(B=>B.points.map(Y=>Y.x))),z=Math.min(o+y,...$.flatMap(B=>B.points.map(Y=>Y.y))),F=Math.max(0,o-_),G=Math.max(0,o+y-z);if(F||G){for(const B of x){B.x+=F;B.y+=G}for(const B of $){for(const Y of B.points){Y.x+=F;Y.y+=G}B.labelPosition.x+=F;B.labelPosition.y+=G}}let I=m.height+o*2+y+G,D=g+F;for(const B of $)for(const Y of B.points){I=Math.max(I,Y.y+o);D=Math.max(D,Y.x+o)}return{model:e,width:D,height:I,nodes:x,edges:$,style:r,...p?{title:rn(p,D,o)}:{}}}function H6(e,t){const{positioned:n,colors:i}=t,r=t.resolved.renderOptions.transparent??false,o=i.font??"Inter",s=[],a=n.style.edgeStrokeColor?Object.fromEntries(Object.entries(ss).map(([h,m])=>[h,{...m,paint:{...m.paint,...m.paint?.fill==="var(--_arrow)"?{fill:n.style.edgeStrokeColor}:{},...m.paint?.stroke==="var(--_arrow)"?{stroke:n.style.edgeStrokeColor}:{}}}])):ss,l=Object.values(a);const c=Ur(i);let d=Ot(n.width,n.height,i,r);if(n.model.accessibilityTitle)d+=`<title>${It(n.model.accessibilityTitle)}</title>`;if(n.model.accessibilityDescription)d+=`<desc>${It(n.model.accessibilityDescription)}</desc>`;d+=Dt(o,false,void 0,i.embedFontImport);s.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:r,font:o,hasMonoFont:false},d),e.definitions({id:"defs",markerResources:l},`<defs>${hi(l)}</defs>`));const u=(h,m)=>{const p=h.block.type==="composite",g=p?"group":"node",y=h.style.fill??(p?n.style.groupFillColor:n.style.nodeFillColor)??(p?"var(--_group-fill)":"var(--_node-fill)"),b=h.style.stroke??(p?n.style.groupBorderColor:n.style.nodeBorderColor)??"var(--_node-stroke)",S=h.style.fill??n.style.groupHeaderFillColor,x=h.style.color??(p?n.style.groupTextColor:n.style.nodeTextColor)??c("var(--_text)",p?S??y:y);const k=Fr(Jd(h),{fill:y,stroke:b,strokeWidth:h.style["stroke-width"]??String(p?n.style.groupLineWidth:n.style.nodeLineWidth)},p?n.style.groupCornerRadius:n.style.cornerRadius);const w=h.style["stroke-dasharray"];if(w!==void 0){k.paint.strokeDasharray=w;if(k.childPaints)k.childPaints=k.childPaints.map(v=>({...v,strokeDasharray:w}))}const C=Kd(h.block.directions),R=h.block.type==="block_arrow",M=R?Ah(C,h.label.width,h.label.height):{dx:0,dy:0};const P=R?{kind:"polygon",points:jy(C,h.width,h.height).map(v=>({x:v.x+h.x+h.width/2,y:v.y+h.y+h.height/2}))}:k.geometry;const E=[`block-${p?"composite":"node"}`,...(h.block.classes??[]).filter(v=>/^[\w-]+$/.test(v))];return e.group({id:`block:${h.id}`,role:g,open:`<g class="${Ye(E.join(" "))}" data-id="${Ye(h.id)}"${h.parentId?` data-parent="${Ye(h.parentId)}"`:""}>`,close:"</g>",children:[{indent:2,node:e.shape({id:`frame:${h.id}`,role:g,identity:false,owner:{id:h.id,role:g},geometry:P,paint:k.paint,...k.childPaints?{childPaints:k.childPaints}:{}})},...p&&h.label.text&&n.style.groupHeaderFillColor?[{indent:2,node:e.shape({id:`header:${h.id}`,role:"chrome",owner:{id:h.id,role:g},geometry:{kind:"rect",x:h.x+n.style.groupLineWidth,y:h.y+n.style.groupLineWidth,width:Math.max(0,h.width-n.style.groupLineWidth*2),height:h.label.height+16-n.style.groupLineWidth,rx:Math.max(0,n.style.groupCornerRadius-n.style.groupLineWidth)},paint:{fill:S,stroke:"none"}})}]:[],...h.label.text?[{indent:2,node:e.text({id:`label:${h.id}`,role:"label",owner:{id:h.id,role:g},text:h.label.text,block:h.label,x:h.x+h.width/2+M.dx,y:p?h.y+h.label.height/2+8:h.y+h.height/2+M.dy,fontSize:h.label.fontSize,anchor:"middle",paint:{fill:x}})}]:[],...m.map(v=>({node:v,indent:2}))]})};const f=new Map;for(let h=n.nodes.length-1;h>=0;h--){const m=n.nodes[h];if(m.block.type==="space")continue;const p=f.get(m.parentId)??[];p.push(u(m,(f.get(m.id)??[]).reverse()));f.set(m.parentId,p)}s.push(...(f.get(void 0)??[]).reverse());for(const h of n.edges){const m=a[`${h.arrowTypeStart}:start`],p=a[`${h.arrowTypeEnd}:end`],g=n.style.edgeBendRadius>0&&h.points.length>2?qn(h.points,n.style.edgeBendRadius,{terminalClearance:{start:Vd(m?.id,n.style.lineWidth,"start"),end:Vd(p?.id,n.style.lineWidth,"end")}}):void 0;s.push(e.connector({id:h.id,role:"edge",geometry:g?.geometry??{kind:"polyline",points:h.points},lineStyle:h.pattern==="dotted"?"dotted":"solid",paint:{fill:"none",stroke:n.style.edgeStrokeColor??"var(--_line)",strokeWidth:h.thickness==="thick"?"3":String(n.style.lineWidth),...h.pattern==="dotted"?{strokeDasharray:"2 4"}:{}},endpoints:{from:h.start,to:h.end},relationship:{kind:"block-link"},markers:{...m?{start:m}:{},...p?{end:p}:{}},labels:h.label?[{text:h.labelBlock.text,anchor:h.labelPosition}]:[],route:{ownership:"layout",bendRadius:n.style.edgeBendRadius,labelAnchors:h.label?[h.labelPosition]:[],...g?{contours:g.contours}:{}}}))}for(const h of n.edges)if(h.label){const m=h.labelBlock,p=h.labelPosition;s.push(e.group({id:`edge-label:${h.id}`,role:"edge-label",open:'<g class="block-edge-label">',close:"</g>",children:[{indent:2,node:e.shape({id:`label-bg:${h.id}`,role:"chrome",owner:{id:h.id,role:"edge"},geometry:{kind:"rect",x:p.x-m.width/2-6,y:p.y-m.height/2-4,width:m.width+12,height:m.height+8},paint:{fill:"var(--bg)",stroke:"none"}})},{indent:2,node:e.text({id:`label:${h.id}`,role:"edge-label",owner:{id:h.id,role:"edge"},text:m.text,block:m,x:p.x,y:p.y,fontSize:m.fontSize,anchor:"middle",paint:{fill:n.style.edgeTextColor??"var(--_text)"}})}]}))}if(n.title)s.push(e.text(En(n.title,n.style)));s.push(e.documentClose());return{family:"block",width:n.width,height:n.height,colors:i,transparent:r,parts:s}}function S$({positioned:e}){const t=i=>{const r=i.block.type==="block_arrow"?Ah(Kd(i.block.directions),i.label.width,i.label.height):{dx:0,dy:0};return{x:i.x+i.width/2+r.dx,y:i.block.type==="composite"?i.y+i.label.height/2+8:i.y+i.height/2+r.dy}};const n=e.nodes.filter(i=>i.block.type==="composite"&&i.label.text).map(i=>{const r=t(i);return{id:`label:${i.id}`,text:i.label.text,bounds:Yt(i.label,r.x,r.y),container:ln(i)}});if(e.title)n.push({id:"title",text:e.title.text,bounds:Yt(e.title.block,e.title.x,e.title.y),container:ln(Xt(e))});return{version:1,bounds:{w:ye(e.width),h:ye(e.height)},nodes:e.nodes.filter(i=>!["composite","space"].includes(i.block.type??"")).map(i=>{const r=t(i);return{id:i.id,x:ye(i.x),y:ye(i.y),w:ye(i.width),h:ye(i.height),shape:Jd(i).shape,label:i.label.text,role:"box",...St(i.label,r.x,r.y,i),...i.parentId?{parentId:i.parentId}:{}}}),edges:e.edges.map(i=>({id:i.id,from:i.start,to:i.end,path:i.points.map(r=>[ye(r.x),ye(r.y)]),...i.label?{label:{x:ye(i.labelPosition.x),y:ye(i.labelPosition.y),text:i.labelBlock.text,bounds:Yt(i.labelBlock,i.labelPosition.x,i.labelPosition.y)}}:{}})),groups:e.nodes.filter(i=>i.block.type==="composite").map(i=>({id:i.id,x:ye(i.x),y:ye(i.y),w:ye(i.width),h:ye(i.height),label:i.block.label,members:e.nodes.filter(r=>r.parentId===i.id&&r.block.type!=="space").map(r=>r.id),parentId:i.parentId})),labels:n}}var w$=gt(H6);var Gwe={configDiagnostics:g$,layout:e=>{const t=hF(e.source.familyLines);t.title??=Ar(e.source.frontmatter);t.accessibilityTitle=e.source.accessibility.title;t.accessibilityDescription=e.source.accessibility.descr;return mt(b$(t,e.renderOptions,e.styleFace,e.source.config.block))},projectPositioned:ft(S$),lowerScene:ht(w$)};var Ih=class extends RangeError{code="C4_ROUTE_WORK_LIMIT";constructor(){super("C4_ROUTE_WORK_LIMIT: physical corridor checks exceed 400000; split the diagram or reduce its relationships");this.name="C4RouteWorkLimitError"}};var M$=e=>bt("c4",e,pw);function qy(e,t){const n=ec(e),i=new Map;for(const o of e.elements){const s=`${o.external?"external-":""}${o.kind}:${o.shape}`;const a=`${o.external?"External ":""}${o.kind[0].toUpperCase()}${o.kind.slice(1)}${o.shape==="database"?" / Database":o.shape==="queue"?" / Queue":""}`;if(!i.has(s)){const l=t?zs(o,t):void 0;i.set(s,{id:n.generated(`c4:legend:${s}`,["c4","legend",s]),label:a,kind:"element",shape:Ro(o),external:o.external,style:{...o.style,...l?.fill?{bgColor:l.fill}:{},...l?.stroke?{borderColor:l.stroke}:{}}})}}const r=t?.typeLegend!==false&&i.size>1||e.legend?.visible?[...i.values()]:[];return[...r,...e.legend?.visible?e.legend.entries:[]]}function k$({positioned:e,options:t}){const n=e.body;const i=e.textContext;const r=(m,p,g,y)=>{if(!g||g.prepared.source!==p||g.prepared.display!=="literal"||g.prepared.transform!==y)throw new Error("C4 "+m+" changed its retained prepared text")};const o=new Map(n.elements.map(m=>[m.id,m]));const s=new Map(n.relationships.map(m=>[m.id,m]));const a=new Map;const l=new Map;const c=(m,p)=>{for(const g of m){if(a.has(g.id))throw new Error(`C4 boundary "${g.id}" has a repeated positioned frame`);a.set(g.id,g);l.set(g.id,p);c(g.children,g.id)}};c(e.groups);const d=new Set(e.nodes.map(m=>m.id));if(d.size!==e.nodes.length||d.size!==o.size||n.elements.some(m=>!d.has(m.id)))throw new Error("C4 positioned cards do not match the authored identities");if(a.size!==n.boundaries.length)throw new Error("C4 positioned frames do not match the authored boundaries");const u=new Set(e.edges.map(m=>m.id));if(u.size!==e.edges.length||u.size!==s.size)throw new Error("C4 positioned relationships do not match the authored identities");for(const m of e.nodes){const p=Hf(o.get(m.id));if(m.label!==p)throw new Error("C4 card "+m.id+" changed its authored text");r(m.id,p,m.labelBlock,i.node)}for(const m of e.edges){const p=m.id===void 0?void 0:s.get(m.id);if(!p)throw new Error("C4 positioned relationship has no authored interaction identity");const g=Yf(n,p);const y=p.style.lineStyle==="dashed"||p.style.lineStyle==="dotted"?"dotted":"solid";if(m.source!==p.source||m.target!==p.target||m.label!==g||m.style!==y||m.hasArrowStart!==p.bidirectional||!m.hasArrowEnd||(m.startMarker??"arrow")!=="arrow"||(m.endMarker??"arrow")!=="arrow")throw new Error("C4 relationship "+m.id+" changed its authored endpoints, label, shaft or markers");r(m.id,g,m.labelBlock,i.edge)}const f=[];for(const m of n.boundaries){const p=a.get(m.id);if(!p||l.get(m.id)!==m.parentId)throw new Error(`C4 boundary "${m.id}" changed its authored parent`);const g=jf(m);if(p.label!==g)throw new Error("C4 boundary "+m.id+" changed its authored text");r(m.id,g,p.labelBlock,i.group);const y=m.alignment==="left"?"start":m.alignment==="right"?"end":"middle";const b=m.alignment==="left"?p.x+e.config.padding:m.alignment==="right"?p.x+p.width-e.config.padding:p.x+p.width/2;const S=p.headerHeight??36;f.push({id:`boundary-label:${m.id}`,text:p.labelBlock?.text??p.label,bounds:Yt(p.labelBlock,b,p.y+S/2,y),container:ln({...p,height:S})})}if(i.title!==void 0!==(e.title!==void 0))throw new Error("C4 positioned title does not match the authored title");if(e.title){const m=e.title;r("title",i.title,m.block,i.group);f.push({id:"title",text:m.text,bounds:Yt(m.block,m.x,m.y),container:ln(Xt(e))})}const h=qy(n,e.config);if(h.length>0!==(e.legend!==void 0))throw new Error("C4 positioned legend does not match the authored legend");if(e.legend){const m=e.legend;if(m.entries.length!==h.length||m.entries.some((y,b)=>y.id!==h[b].id))throw new Error("C4 positioned legend entries do not match the authored legend");r("legend heading","Legend",m.heading,i.legendHeading);const p=ln(m);f.push({id:"legend:heading",text:m.heading.text,bounds:Yt(m.heading,m.x+12,m.y+8+m.heading.height/2,"start"),container:p});let g=m.y+20+m.heading.height;for(const[y,b]of m.entries.entries()){r(b.id,h[y].label,b.block,i.edge);f.push({id:`legend:entry:${b.id}`,text:b.block.text,bounds:Yt(b.block,m.x+38,g+b.block.height/2,"start"),container:p});g+=b.block.height+10}}return{version:1,nodes:e.nodes.map(m=>{const p=o.get(m.id);const g=Ro(p);const y=m.y+m.height/2+(g==="person"?19:g==="database"?4:0);return{id:p.id,x:rt(m.x),y:rt(m.y),w:rt(m.width),h:rt(m.height),shape:g,label:p.label,role:"box",...St(m.labelBlock,m.x+m.width/2,y,m),...p.parentId!==void 0?{parentId:p.parentId}:{}}}),edges:e.edges.map(m=>{const p=m.id===void 0?void 0:s.get(m.id);if(!p)throw new Error("C4 positioned relationship has no authored interaction identity");return{id:p.id,from:m.source,to:m.target,path:m.points.map(g=>[rt(g.x),rt(g.y)]),...m.label!==void 0&&m.labelPosition?{label:{x:rt(m.labelPosition.x),y:rt(m.labelPosition.y),text:m.label,bounds:Yt(m.labelBlock,m.labelPosition.x,m.labelPosition.y)}}:{},...t.debug&&m.routeCertificate?{route:m.routeCertificate}:{}}}),groups:n.boundaries.map(m=>{const p=a.get(m.id);if(!p)throw new Error(`C4 boundary "${m.id}" has no positioned frame`);return{id:m.id,label:m.label,x:rt(p.x),y:rt(p.y),w:rt(p.width),h:rt(p.height),members:n.elements.filter(g=>g.parentId===m.id).map(g=>g.id),...m.parentId!==void 0?{parentId:m.parentId}:{}}}),bounds:{w:rt(e.width),h:rt(e.height)},labels:f}}function C$(e,t,n){const i=new Map([...t].map(([h,m])=>[h,{...m}])),r=[];const o=new Map(e.statements.map((h,m)=>[h.id,m]));const s=[...e.boundaries,...e.elements].sort((h,m)=>(o.get(h.statementId)??0)-(o.get(m.statementId)??0)),a=new Map(s.map(h=>[h.id,h.parentId]));const l=[...e.layout.hints,...e.relationships.filter(h=>h.direction).map(h=>({from:h.from,to:h.to,direction:h.direction,statementId:h.statementId}))];const c=(h,m)=>{const p=new Set;while(a.get(h)!==m){if(p.has(h))return void 0;p.add(h);const g=a.get(h);if(!g)return void 0;h=g}return h};const d=(h,m,p)=>{const g=s.filter(P=>P.parentId===h&&i.has(P.id));for(const P of g)if(i.get(P.id).container&&!m.has(P.id)){const E=new Set(m);E.add(P.id);const v=d(P.id,E,p===void 0?void 0:Math.max(1,p-n.padding*2)),L=i.get(P.id);L.width=Math.max(L.width,v.width+n.padding*2);L.height=Math.max(L.height,v.height+(L.headerHeight??0)+n.padding+Math.max(n.padding,L.bottomPadding??0))}let y=g.some(P=>i.get(P.id).container)?n.boundariesPerRow:n.shapesPerRow;const b=n.direction,S=b==="LR"||b==="RL";if(!S&&p!==void 0){const P=Math.max(1,...g.map(v=>i.get(v.id).width));const E=Math.max(1,Math.floor((p+n.gapX)/(P+n.gapX)));y=Math.max(y,Math.ceil(g.length/E))}let x=0,k=0,w=0,C=0,R=0;g.forEach(P=>{const E=i.get(P.id);if(R&&(R>=y||S&&p!==void 0&&x+E.width>p)){if(S){x=0;k+=w+n.gapY;w=0}else{k=0;x+=C+n.gapX;C=0};R=0}E.x=x;E.y=k;if(S)x+=E.width+n.gapX;else k+=E.height+n.gapY;w=Math.max(w,E.height);C=Math.max(C,E.width);R++});const M=[];for(const P of l){const E=c(P.from,h),v=c(P.to,h);if(!E||!v||E===v||!i.has(E)||!i.has(v))continue;const L=P.direction==="LR"||P.direction==="RL"?"x":"y";const T=P.direction==="RL"||P.direction==="BT";const A=T?v:E,$=T?E:v;const _=(z,F,G=new Set)=>z===F||!G.has(z)&&(G.add(z),M.some(I=>I.axis===L&&I.before===z&&_(I.after,F,G)));if(_($,A)){r.push({code:"C4_LAYOUT_CONFLICT",severity:"warning",statementId:P.statementId,message:`Conflicting C4 ${L==="x"?"horizontal":"vertical"} direction for ${P.from} and ${P.to}; the earlier constraint is retained.`});continue}M.push({before:A,after:$,axis:L,statementId:P.statementId})}if(M.length){for(const E of g){const v=i.get(E.id);if(M.some(L=>L.axis==="x"&&(L.before===E.id||L.after===E.id)))v.x=0;if(M.some(L=>L.axis==="y"&&(L.before===E.id||L.after===E.id)))v.y=0}const P=()=>{for(let E=0;E<g.length;E++)for(const v of M){const L=i.get(v.before),T=i.get(v.after);T[v.axis]=Math.max(T[v.axis],L[v.axis]+(v.axis==="x"?L.width+n.gapX:L.height+n.gapY))}};P();for(let E=0;E<g.length;E++){let v=false;for(let L=0;L<g.length;L++)for(let T=L+1;T<g.length;T++){const A=i.get(g[L].id),$=i.get(g[T].id);if(A.x<$.x+$.width&&$.x<A.x+A.width&&A.y<$.y+$.height&&$.y<A.y+A.height){$.y=A.y+A.height+n.gapY;v=true}}P();if(!v)break}}else if(b==="RL"||b==="BT"){const P=Math.max(0,...g.map(E=>{const v=i.get(E.id);return b==="RL"?v.x+v.width:v.y+v.height}));for(const E of g){const v=i.get(E.id);if(b==="RL")v.x=P-v.x-v.width;else v.y=P-v.y-v.height}}return{width:Math.max(0,...g.map(P=>{const E=i.get(P.id);return E.x+E.width})),height:Math.max(0,...g.map(P=>{const E=i.get(P.id);return E.y+E.height}))}};const u=d(void 0,new Set,n.maxWidth===void 0?void 0:Math.max(1,n.maxWidth-n.marginX*2));const f=(h,m,p,g)=>{for(const y of s.filter(b=>b.parentId===h)){const b=i.get(y.id);if(!b||g.has(y.id))continue;g.add(y.id);b.x+=m;b.y+=p;if(b.container)f(y.id,b.x+n.padding,b.y+(b.headerHeight??0)+n.padding,g)}};f(void 0,n.marginX,n.marginY,new Set);return{boxes:i,width:u.width+n.marginX*2,height:u.height+n.marginY*2,diagnostics:r}}var P$={T:{x:0,y:-1},R:{x:1,y:0},B:{x:0,y:1},L:{x:-1,y:0}};var Uy=(e,t)=>e.x<=t.x&&e.y<=t.y&&e.x+e.width>=t.x+t.width&&e.y+e.height>=t.y+t.height;var us=e=>({x:e.x+e.width/2,y:e.y+e.height/2});function j6(e,t){if(e.id===t.id)return["R","B"];if(e.container&&Uy(e,t))return["B","B"];if(t.container&&Uy(t,e))return["B","B"];const n=us(e),i=us(t);if(Math.abs(n.x-i.x)>=Math.abs(n.y-i.y))return n.x<=i.x?["R","L"]:["L","R"];return n.y<=i.y?["B","T"]:["T","B"]}function Xy(e,t,n){if(t==="T"||t==="B"){const r=e.cylinder?8*(1-Math.sqrt(Math.max(0,1-(2*n-1)**2))):0;return{x:e.x+e.width*n,y:e.y+(t==="B"?e.height-r:r)}}const i=e.container?e.headerHeight??0:e.cylinder?8:0;return{x:e.x+(t==="R"?e.width:0),y:e.y+i+(e.height-i-(e.cylinder?8:0))*n}}function Vy(e,t,n,i){return Xy(e,t,(n+1)/(i+1))}var E$=8;var Y6={T:"B",R:"L",B:"T",L:"R"};function q6(e,t,n,i,r,o){const s=Vy(n,i,r,o);if(Y6[t]!==i)return s;const a=i==="L"||i==="R"?"y":"x";const l=e[a]-s[a];if(l===0||Math.abs(l)>=E$)return s;const c=Xy(n,i,0),d=Xy(n,i,1);const u=(e[a]-c[a])/(d[a]-c[a]);if(!(u>0&&u<1))return s;const f=Xy(n,i,u);for(let h=0;h<o;h++){if(h!==r&&Math.abs(Vy(n,i,h,o)[a]-f[a])<E$)return s}return f}function X6(e,t,n,i){const r=(y,b)=>{const S=[...new Set(n.flatMap(w=>[w[y]-10,w[y]+w[b]+10]))];const x=[Math.min(e[y],t[y],...S),Math.max(e[y],t[y],...S)];const k=w=>Math.min(Math.abs(w-e[y]),Math.abs(w-t[y]));return[...new Set([...x,...S.sort((w,C)=>k(w)-k(C)||w-C).slice(0,14)])]};const o=r("x","width"),s=r("y","height");const a=[];for(const y of o)a.push([e,{x:y,y:e.y},{x:y,y:t.y},t]);for(const y of s)a.push([e,{x:e.x,y},{x:t.x,y},t]);for(const y of o)for(const b of s){a.push([e,{x:e.x,y:b},{x:y,y:b},{x:y,y:t.y},t]);a.push([e,{x:y,y:e.y},{x:y,y:b},{x:t.x,y:b},t])}const l=y=>y.slice(1).reduce((b,S,x)=>b+Math.hypot(S.x-y[x].x,S.y-y[x].y),0);const c=(y,b)=>n.every(S=>!i(y,b,S));const d=y=>y.map(xt).sort((b,S)=>l(b)-l(S)||b.length-S.length).find(b=>b.slice(1).every((S,x)=>c(b[x],S)));const u=d(a);if(u)return u;const f=s.filter(y=>c(e,{x:e.x,y})),h=s.filter(y=>c({x:t.x,y},t));const m=o.filter(y=>c(e,{x:y,y:e.y})),p=o.filter(y=>c({x:y,y:t.y},t));const g=[];for(const y of o)for(const b of f)for(const S of h)g.push([e,{x:e.x,y:b},{x:y,y:b},{x:y,y:S},{x:t.x,y:S},t]);for(const y of s)for(const b of m)for(const S of p)g.push([e,{x:b,y:e.y},{x:b,y},{x:S,y},{x:S,y:t.y},t]);return d(g)}function R$(e,t,n,i,r){const{edges:o}=t;const s=[...e.values()].filter(x=>x.container).map(x=>({...x,id:r.generated(`c4-header-obstacle:${x.id}`,["c4","header-obstacle",x.id]),height:x.headerHeight??1,shape:"rectangle",label:""}));const a=[...t.nodes,...s];let l=0;const c=()=>{if(++l>4e5)throw new Ih};const d=(x,k,w)=>{c();return Ii(x,k,w)};const u=(x,k,w,C,R)=>{const M={x:P$[k].x*w,y:P$[k].y*w};let P=C;for(const E of a){c();if(E.id===R)continue;const v=M.x?x.y>E.y&&x.y<E.y+E.height:x.x>E.x&&x.x<E.x+E.width;if(!v)continue;const L=M.x>0?E.x-x.x:M.x<0?x.x-E.x-E.width:M.y>0?E.y-x.y:x.y-E.y-E.height;if(L>=0)P=Math.min(P,Math.max(0,L-2))}return{x:x.x+M.x*P,y:x.y+M.y*P}};const f=new Map;const h=new Map,m=new Map;const p=o.flatMap(x=>{const k=e.get(x.source),w=e.get(x.target);if(!k||!w)return[];const[C,R]=j6(k,w);for(const[M,P]of[[k.id,C],[w.id,R]]){const E=`${M}\0${P}`;h.set(E,(h.get(E)??0)+1)};return[{edge:x,source:k,target:w,startSide:C,endSide:R}]});const g=new Map;for(const x of p){const k=JSON.stringify([x.source.id,x.target.id].sort());const w=g.get(k)??[];w.push(x);g.set(k,w)}for(const[x,k]of p.entries()){const{edge:w,source:C,target:R,startSide:M,endSide:P}=k;const E=(O,N)=>{const H=`${O.id}\0${N}`,j=m.get(H)??0;m.set(H,j+1);return{index:j,count:h.get(H)}};const v=E(C,M),L=E(R,P);const T=Vy(C,M,v.index,v.count);const A=C.id===R.id?Vy(R,P,L.index,L.count):q6(T,M,R,P,L.index,L.count);const $=C.container&&C.id!==R.id&&Uy(C,R)?-1:1;const _=R.container&&C.id!==R.id&&Uy(R,C)?-1:1;const z=g.get(JSON.stringify([C.id,R.id].sort()));const F=M==="R"||M==="L"?Math.max(24,...z.map(O=>(O.edge.labelBlock?.width??0)+32)):Math.max(24,...z.map(O=>(O.edge.labelBlock?.height??0)+24));const G=(z.indexOf(k)-(z.length-1)/2)*F;const I=14+x%5*4;const D=$s(w,i);const B=u(T,M,$,Math.max(I,D.start?D.start+(i.edgeBendRadius??0):0),C.id);const Y=u(A,P,_,Math.max(I,D.end?D.end+(i.edgeBendRadius??0):0),R.id);f.set(w,{start:T,end:A,startExit:B,endExit:Y});let W;if(C.id===R.id){const O=C.x+C.width+I+(w.labelBlock?.width??0)/2;const N=C.y+C.height+I+(w.labelBlock?.height??0)/2;W=[B,{x:O,y:B.y},{x:O,y:N},{x:Y.x,y:N},Y]}else if(M==="R"||M==="L"){const O=(B.x+Y.x)/2+G;W=[B,{x:O,y:B.y},{x:O,y:Y.y},Y]}else{const O=(B.y+Y.y)/2+G;W=[B,{x:B.x,y:O},{x:Y.x,y:O},Y]}w.points=xt([T,...W,A]);f.get(w).seed=w.points;if(w.label)w.labelPosition=sn(w.points)}kp(t,n,new Set,i);Cp(t,n,i);sf(t,n,i);Ep(t,n,i);for(const x of o){const k=f.get(x);const w=e.get(x.source),C=e.get(x.target);const R=Math.abs(us(w).x-us(C).x)>=Math.abs(us(w).y-us(C).y);const M=R?us(w).x<=us(C).x?"LR":"RL":us(w).y<=us(C).y?"TB":"BT";const P={id:r.generated(`${x.id}:routing-source`,["c4",x.id,"routing-source"]),label:"",shape:"rectangle",...k.startExit,width:0,height:0};const E={id:r.generated(`${x.id}:routing-target`,["c4",x.id,"routing-target"]),label:"",shape:"rectangle",...k.endExit,width:0,height:0};const v={...x,source:P.id,target:E.id,points:xt([k.startExit,...k.seed.slice(1,-1),k.endExit])};const L=(x.labelBlock?.width??0)/2+10,T=(x.labelBlock?.height??0)/2+8;const A=[...t.nodes,...s].map(_=>_.id===x.source||_.id===x.target?_:{..._,x:_.x-L,y:_.y-T,width:_.width+L*2,height:_.height+T*2});Lo([...A,P,E],[v],{...n,direction:M});const $=v.points.slice(1).some((_,z)=>a.some(F=>d(v.points[z],_,F)));if($)v.points=X6(k.startExit,k.endExit,a,d)??v.points;x.points=xt([k.start,...v.points,k.end]);x.labelPosition=sn(x.points)}Pp(t,n,i);const y=[...t.nodes,...s],b={...t,nodes:y};const{ctx:S}=Uo(y,o,n.direction,i,t.groups);S.finalLabelClearance=true;for(const x of o){if(!x.label)continue;const k=x.points.slice(1).map((w,C)=>({start:x.points[C],end:w})).sort((w,C)=>Math.abs(C.end.x-C.start.x)+Math.abs(C.end.y-C.start.y)-(Math.abs(w.end.x-w.start.x)+Math.abs(w.end.y-w.start.y)));for(const{start:w,end:C}of k){const R=ir(x,w,C,S);if(R){x.labelPosition=R;break}}}sf(b,n,i);for(const x of o){const k=e.get(x.source),w=e.get(x.target);Os(x,x.routeCertificate,{...k,label:"",shape:"rectangle"},{...w,label:"",shape:"rectangle"})}}function il(e){if(!e.label||!e.labelPosition||!e.labelBlock)return void 0;const t=e.labelBlock.width+20,n=e.labelBlock.height+16;return{x:e.labelPosition.x-t/2,y:e.labelPosition.y-n/2,width:t,height:n}}var nl=(e,t)=>Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x))*Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));var Ky=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+t*2,height:e.height+t*2});var OM=e=>e.flatMap(t=>[t,...OM(t.children)]);function v$(e,t,n){let i=0,r=1;for(const o of["x","y"]){const s=t[o]-e[o],a=n[o]+.01,l=n[o]+(o==="x"?n.width:n.height)-.01;if(Math.abs(s)<.001){if(e[o]<=a||e[o]>=l)return false;continue}const c=(a-e[o])/s,d=(l-e[o])/s;i=Math.max(i,Math.min(c,d));r=Math.min(r,Math.max(c,d));if(i>=r)return false}return i<r}function Jy(e,t){const n=[];const i=e.inlineStyle?.["stroke-width"]?1:t*(e.style==="thick"?2:1);const r=bn.width*i,o=(e.inlineStyle?.["stroke-width"]?bn.width:bn.height)*i/2,s=.375*i;for(const a of[true,false]){if(!(a?e.hasArrowStart:e.hasArrowEnd))continue;const l=e.points.at(a?0:-1);const c=(a?e.points.slice(1):e.points.slice(0,-1).reverse()).find(g=>l&&Math.hypot(g.x-l.x,g.y-l.y)>.01);if(!l||!c)continue;const d=Math.hypot(l.x-c.x,l.y-c.y),u=(l.x-c.x)/d,f=(l.y-c.y)/d;const h=[l,{x:l.x-u*r-f*o,y:l.y-f*r+u*o},{x:l.x-u*r+f*o,y:l.y-f*r-u*o}];const m=Math.min(...h.map(g=>g.x)),p=Math.min(...h.map(g=>g.y));n.push({...Ky({x:m,y:p,width:Math.max(...h.map(g=>g.x))-m,height:Math.max(...h.map(g=>g.y))-p},s),endpoint:a?e.source:e.target,polygon:h,strokePadding:s})}return n}function U6(e,t){if(nl(e,t)<=.01)return false;for(const n of[e.polygon,t.polygon])for(const[i,r]of n.entries()){const o=n[(i+1)%n.length],s=-(o.y-r.y),a=o.x-r.x,l=Math.hypot(s,a);if(l<.001)continue;const c=f=>f.polygon.map(h=>(h.x*s+h.y*a)/l);const d=c(e),u=c(t);if(Math.max(...d)+e.strokePadding<=Math.min(...u)-t.strokePadding+.01||Math.max(...u)+t.strokePadding<=Math.min(...d)-e.strokePadding+.01)return false}return true}function T$(e,t){return[...e,...OM(t).flatMap(n=>[{x:n.x,y:n.y,width:n.width,height:n.headerHeight??0},{x:n.x,y:n.y,width:1,height:n.height},{x:n.x+n.width-1,y:n.y,width:1,height:n.height},{x:n.x,y:n.y+n.height-1,width:n.width,height:1}])]}function L$(e,t,n){const{edges:i}=e,r=T$(e.nodes,e.groups),o=i.flatMap(d=>Jy(d,t)),s=[];const a=new Map(n.relationships.map(d=>[d.id,d.style]));const l=i.flatMap(d=>d.points.slice(1).map((u,f)=>({edge:d,start:d.points[f],end:u})));const c=i.map((d,u)=>({edge:d,index:u,rect:il(d)})).filter(d=>d.rect).sort((d,u)=>u.rect.width*u.rect.height-d.rect.width*d.rect.height||d.index-u.index);for(const{edge:d,rect:u}of c){const f=a.get(d.id);const h=M=>Number.isFinite(Number(M))?Number(M):0;const m=h(f?.offsetX),p=h(f?.offsetY);const g=M=>({x:M.x+m,y:M.y+p});const y=g(d.labelPosition),b=[y],S=u.width,x=u.height;const k=M=>{const P={x:M.x-S/2,y:M.y-x/2,width:S,height:x},E=Ky(P,3);return[o.reduce((v,L)=>v+nl(E,L),0),r.reduce((v,L)=>v+nl(E,L),0),s.reduce((v,L)=>v+nl(Ky(P,4),L),0),l.reduce((v,L)=>v+(L.edge!==d&&v$(L.start,L.end,Ky(P,2))?1:0),0)]};let w=y,C=k(y);if(C.every(M=>M===0)){d.labelPosition=y;s.push(il(d));continue}const R=l.filter(M=>M.edge===d).sort((M,P)=>Math.hypot(P.end.x-P.start.x,P.end.y-P.start.y)-Math.hypot(M.end.x-M.start.x,M.end.y-M.start.y));for(const{start:M,end:P}of R){const E=Math.hypot(P.x-M.x,P.y-M.y);if(E<.01)continue;const v=-(P.y-M.y)/E,L=(P.x-M.x)/E;const T=Math.abs(v)*S/2+Math.abs(L)*x/2;for(const A of[.5,.25,.75,.1,.9])for(const $ of[0,T+6,-T-6,T+20,-T-20]){b.push(g({x:M.x+(P.x-M.x)*A+v*$,y:M.y+(P.y-M.y)*A+L*$}))}}b.sort((M,P)=>Math.hypot(M.x-y.x,M.y-y.y)-Math.hypot(P.x-y.x,P.y-y.y));for(const M of b){const P=k(M),E=P.findIndex((v,L)=>v!==C[L]);if(E>=0&&P[E]<C[E]){w=M;C=P}if(P.every(v=>v===0))break}d.labelPosition=w;s.push(il(d))}}function A$(e,t,n,i){const r=[],{edges:o,nodes:s,groups:a}=t,l=T$(s,a),c=o.map(h=>({edge:h,box:il(h)})).filter(h=>h.box);const d=h=>e.relationships.find(m=>m.id===h.id)?.statementId;for(const{edge:h,box:m}of c){if(l.some(p=>nl(m,p)>.01)||c.some(p=>p.edge!==h&&nl(m,p.box)>.01)||o.some(p=>p!==h&&p.points.slice(1).some((g,y)=>v$(p.points[y],g,m))))r.push({code:"C4_LABEL_COLLISION",severity:"warning",statementId:d(h),message:`Relationship ${h.id} has a label halo overlapping another label, card, boundary header/frame or relationship route; all authored text is retained.`})}const u=OM(a).map(h=>({...h,height:h.headerHeight??0}));const f=o.flatMap(h=>Jy(h,n).map(m=>({edge:h,head:m})));for(const h of o){const m=f.filter(p=>p.edge===h).map(p=>p.head);if((h.hasArrowEnd||h.hasArrowStart)&&!m.length||m.some(p=>c.some(g=>nl(p,g.box)>.01)||[...s,...u].some(g=>g.id!==p.endpoint&&nl(p,g)>.01)||f.some(g=>g.head!==p&&U6(p,g.head))||i&&(p.x<-.01||p.y<-.01||p.x+p.width>i.width+.01||p.y+p.height>i.height+.01)))r.push({code:"C4_ARROW_OCCLUDED",severity:"warning",statementId:d(h),message:`Relationship ${h.id} has an arrowhead overlapping a label, card, boundary header or another arrowhead, exceeds the final canvas, or lacks a nonzero terminal segment.`})}return r}function I$(e,t={},n,i={},r={}){Pm(e);const o=Wp({...t.padding===void 0?{}:{diagramMarginX:t.padding,diagramMarginY:t.padding},...t.nodeSpacing===void 0?{}:{c4ShapeMargin:t.nodeSpacing},...t.layerSpacing===void 0?{}:{nextLinePaddingX:t.layerSpacing},...i},r),s=Xe(t,void 0,n);const a=eA(e,o),l=new Map;const c=new Map([...e.elements,...e.boundaries].map(I=>[I.id,I.parentId]));const d=I=>{const D=[];for(let B=c.get(I);B&&!D.includes(B);B=c.get(B))D.push(B);return D};const u=I=>o.input.c4ShapePadding!==void 0?o.padding:o.compact&&n?.node?.[I==="X"?"paddingX":"paddingY"]===void 0?Math.min(o.padding,s[I==="X"?"nodePaddingX":"nodePaddingY"]):s[I==="X"?"nodePaddingX":"nodePaddingY"];const f=I=>{if(o.wrapWidth===void 0)return void 0;if(o.maxWidth===void 0)return o.wrapWidth;const D=I===void 0?0:d(I).length;return Math.max(24,o.minimumWidth-u("X")*2-20,Math.min(o.wrapWidth,o.maxWidth-(o.marginX+40)*2-D*o.boundaryPadding*2-u("X")*2-20))};const h=(I,D,B=false)=>{const Y=zs(I,o);return _e(D,{display:"literal",fontSize:Y.fontSize??(B?s.groupHeaderFontSize:s.nodeLabelFontSize),fontWeight:Y.fontWeight??(B?s.groupHeaderFontWeight:s.nodeLabelFontWeight),transform:B?s.groupTextTransform:s.nodeTextTransform,maxWidth:f(I.id),letterSpacing:B?s.groupLetterSpacing:s.nodeLetterSpacing,fontFamily:Y.fontFamily??(B?s.groupFont:void 0)})};const m=e.elements.map(I=>{const D=Hf(I),B=h(I,D),Y=Ro(I),W=Y==="person"?38:Y==="database"?16:0;const O=Math.max(o.minimumWidth,B.width+u("X")*2+(Y==="queue"?20:0)),N=Math.max(o.minimumHeight,B.height+u("Y")*2+W);l.set(I.id,{id:I.id,x:0,y:0,width:O,height:N,...Y==="database"?{cylinder:true}:{}});return{...a.nodes.get(I.id),x:0,y:0,width:O,height:N,labelBlock:B,inlineStyle:a.nodeStyles.get(I.id)}});const p=new Map;for(const I of e.boundaries){const D=jf(I),B=h(I,D,true),Y=B.height+o.padding*2;const W={id:I.id,label:D,labelBlock:B,x:0,y:0,width:Math.max(o.minimumWidth,B.width+o.padding*2),height:Y+o.boundaryPadding*2,headerHeight:Y,children:[]};p.set(I.id,W);l.set(I.id,{...W,container:true})}const g=a.edges.map((I,D)=>({...I,points:[],labelBlock:_e(Yf(e,e.relationships[D]),{display:"literal",fontSize:s.edgeLabelFontSize,fontWeight:s.edgeLabelFontWeight,letterSpacing:s.edgeLetterSpacing,transform:s.edgeTextTransform,...o.maxWidth===void 0?{}:{maxWidth:f()}}),inlineStyle:a.linkStyles.get(D),edgeIndex:D}));for(const I of e.boundaries){const D=g.filter(B=>B.source===I.id&&d(B.target).includes(I.id)||B.target===I.id&&d(B.source).includes(I.id));if(D.length)l.get(I.id).bottomPadding=Math.max(o.boundaryPadding,...D.map(B=>(B.labelBlock?.height??0)+48))*D.length}const y=a.direction==="LR"||a.direction==="RL";for(const[I,D]of l){const B=g.filter(H=>H.source===I||H.target===I);const Y=Math.max(0,...B.map(H=>(H.labelBlock?.height??0)+28));const W=Math.max(0,...B.map(H=>(H.labelBlock?.width??0)+24));const O=new Map;for(const H of B){const j=H.source===I?H.target:H.source;O.set(j,(O.get(j)??0)+1)}const N=Math.max(0,...O.values());if(y)D.height=Math.max(D.height,(N+1)*Y+(D.headerHeight??0),(B.length+1)*16+(D.headerHeight??0));else D.width=Math.max(D.width,(N+1)*W,(B.length+1)*16)}const b=t.diagramTitle??e.title;const S=b===void 0?void 0:_e(b,{display:"literal",fontSize:Rm,fontWeight:vm,transform:s.groupTextTransform,letterSpacing:s.groupLetterSpacing,fontFamily:s.groupFont,...o.maxWidth===void 0?{}:{maxWidth:Math.max(24,o.maxWidth-o.marginX*2)}});const x=S?{text:S.text,width:S.width,height:S.height+vl,block:S}:void 0,k=Math.max(o.gap,...g.map(I=>(I.labelBlock?.width??0)*2+48)),w=Math.max(o.rowGap,...g.map(I=>(I.labelBlock?.height??0)*2+48));const C=new Map;for(const I of g){const D=JSON.stringify([I.source,I.target].sort());C.set(D,(C.get(D)??0)+1)}const R=Math.max(1,...C.values());const M=R>1?R+1:1;const P=C$(e,l,{gapX:k*M,gapY:w*M,padding:o.boundaryPadding,marginX:o.marginX+40,marginY:o.marginY+40+(x?.height??0),shapesPerRow:e.layout.shapesPerRow??o.shapesPerRow,boundariesPerRow:e.layout.boundariesPerRow??o.boundariesPerRow,direction:a.direction==="TD"?"TB":a.direction,maxWidth:o.maxWidth});for(const I of m)Object.assign(I,P.boxes.get(I.id));const E=[];for(const I of e.boundaries){const D=p.get(I.id);Object.assign(D,P.boxes.get(I.id));const B=I.parentId&&p.get(I.parentId);if(B)B.children.push(D);else E.push(D)}R$(P.boxes,{nodes:m,groups:E,edges:g},a,s,ec(e));L$({nodes:m,groups:E,edges:g},s.lineWidth,e);const v=g.flatMap(I=>{const D=il(I);return D?[{...D,id:I.id,label:"",shape:"rectangle"}]:[]});const L=g.flatMap(I=>Jy(I,s.lineWidth).map(D=>({...D,id:I.id,label:"",shape:"rectangle"})));ef([...m,...v,...L],g,E,Math.max(o.marginX,o.marginY)+(x?.height??0));const T=[...m,...p.values(),...v,...L];let A=Math.max(P.width,...T.map(I=>I.x+I.width+o.marginX),...g.flatMap(I=>[...I.points.map(D=>D.x+o.marginX),(I.labelPosition?.x??0)+(I.labelBlock?.width??0)/2+o.marginX]),x?x.width+o.marginX*2:0);let $=Math.max(P.height,...T.map(I=>I.y+I.height+o.marginY),...g.flatMap(I=>[...I.points.map(D=>D.y+o.marginY),(I.labelPosition?.y??0)+(I.labelBlock?.height??0)/2+o.marginY]));const _=qy(e,o).map(I=>({...I,block:_e(I.label,{display:"literal",fontSize:s.edgeLabelFontSize,fontWeight:s.edgeLabelFontWeight,letterSpacing:s.edgeLetterSpacing,transform:s.edgeTextTransform,...o.maxWidth===void 0?{}:{maxWidth:Math.max(24,o.maxWidth-o.marginX*2-64)}})}));const z=_e("Legend",{display:"literal",fontSize:n?.text?.fontSize??13,fontWeight:n?.text?.fontWeight??600,letterSpacing:n?.text?.letterSpacing??0,transform:n?.text?.textTransform,...o.maxWidth===void 0?{}:{maxWidth:Math.max(24,o.maxWidth-o.marginX*2-24)}});const F=_.length?{x:o.marginX,y:$+12,width:Math.max(z.width+24,..._.map(I=>I.block.width+64)),height:z.height+20+_.reduce((I,D)=>I+D.block.height+10,0),heading:z,entries:_}:void 0;if(F){A=Math.max(A,F.x+F.width+o.marginX);$=F.y+F.height+o.marginY}const G=[...P.diagnostics,...A$(e,{nodes:m,groups:E,edges:g},s.lineWidth,{width:A,height:$})];if(o.maxWidth!==void 0&&A>o.maxWidth+.01)G.push({code:"C4_WIDTH_EXCEEDED",severity:"warning",message:`The requested C4 width ${o.maxWidth}px cannot contain the ${Math.ceil(A)}px artifact without shrinking or clipping content; minimum card widths, nesting, explicit direction constraints and authored offsets retain precedence.`});return{width:A,height:$,...F?{legend:F}:{},nodes:m,groups:E,edges:g,...x?{title:rn(x,A,o.marginY)}:{},body:e,config:o,diagnostics:G,identities:ec(e),textContext:{node:s.nodeTextTransform,edge:s.edgeTextTransform,group:s.groupTextTransform,legendHeading:n?.text?.textTransform,title:b}}}function rl(e){return e.split(/[:/\s-]+/).filter(Boolean).at(-1)?.slice(0,2).toUpperCase()||"?"}var V6=Object.freeze({book:Object.freeze(["M3 5.5C6 4.5 9 4.8 12 6V20C9 18.8 6 18.5 3 19.5Z","M21 5.5C18 4.5 15 4.8 12 6V20C15 18.8 18 18.5 21 19.5Z"]),skull:Object.freeze(["M5 11A7 7 0 1 1 19 11C19 15 17 17 15 18V21H9V18C7 17 5 15 5 11Z","M8 11A1.5 1.5 0 1 0 11 11A1.5 1.5 0 1 0 8 11ZM13 11A1.5 1.5 0 1 0 16 11A1.5 1.5 0 1 0 13 11Z","M10 17V20M12 17V20M14 17V20"])});function ol(e){const t=e.trim().toLowerCase().split(/\s+/).filter(Boolean);const n=t.findLast(a=>!["fa","fas","far","fab","mdi"].includes(a))??"";const i=n.replace(/^(?:fa-|mdi-)/,"");const r=i==="book-open"?"book":i==="skull-outline"?"skull":i;const o=V6[r];if(o)return{viewBox:"0 0 24 24",paths:o,source:"bundled-symbol"};const s=fa(e)??fa(`mdi:${i}`);return s?{viewBox:s.viewBox,paths:[s.path],source:s.source}:null}function WM(e,t,n){const{positioned:i,colors:r,resolved:o}=t;const s=o.renderOptions;const a=r.font??"Inter";const l=s.transparent??false;const c=[];const d=o.familyAppearance?.visual??s.stateVisual;const u=Xe(s,d?.styleDefaults,o.styleFace);c.push(e.documentOpen({id:"prelude",width:i.width,height:i.height,colors:r,transparent:l,font:a,hasMonoFont:false},Ot(i.width,i.height,r,l)+"\n"+Dt(a,false,r.shadow,r.embedFontImport)));const f=[];f.push("<defs>");const h=Zt(r);if(h)f.push(h);const m=new Set;const p=new Set;if(u.edgeStrokeColor)m.add(u.edgeStrokeColor);let g=false;let y=false;for(const C of i.edges){if(C.inlineStyle?.stroke)m.add(C.inlineStyle.stroke);if(C.inlineStyle?.["stroke-width"])p.add(C.inlineStyle.stroke??u.edgeStrokeColor);if(C.startMarker==="circle"||C.endMarker==="circle")g=true;if(C.startMarker==="cross"||C.endMarker==="cross")y=true}const b=lp(m,p,g,y);f.splice(1,0,hi(b));f.push("</defs>");c.push(e.definitions({id:"defs",markerResources:b},f.join("\n")));if(i.title)c.push(e.text(En(i.title,u)));for(const C of n?.surfaces===false?[]:i.groups){c.push(BM(e,C,a,u))}if(n?.beforeEdges)c.push(...n.beforeEdges());const S=new Set(i.nodes.map(C=>C.id));const x=C=>C.forEach(R=>{S.add(R.id);x(R.children)});x(i.groups);const k=new Map;const w=new Map;for(const C of i.edges){if(C.points.length<2)continue;const R=`${C.source}->${C.target}`;const M=k.get(R)??0;k.set(R,M+1);const P=`edge:${R}#${M}`;w.set(C,P);const E=C.id!==void 0&&!S.has(C.id)?C.id:P;c.push(Q6(e,C,u,P,E,b))}for(const C of i.edges){const R=w.get(C);if(n?.edgeLabels!==false&&C.label&&R)c.push(Z6(e,C,a,u,F$(R)))}for(const C of n?.surfaces===false?[]:i.nodes){c.push(e8(e,C,a,u,r,s.security!=="strict"))}for(const C of i.notes??[]){c.push(J6(e,C,a,u))}c.push(e.documentClose());return{family:"flowchart",width:i.width,height:i.height,colors:r,transparent:l,parts:c}}function BM(e,t,n,i,r){if(t.concurrencyRegion){return e.group({id:`group:${t.id}`,role:"group",open:`<g class="concurrency-region" data-id="${Ye(t.id)}"${r?` data-parent-id="${Ye(r)}"`:""}>`,close:"</g>",children:t.children.map(y=>({indent:0,node:BM(e,y,n,i,t.id)}))})}const o=t.labelBlock??Wn(qe(t.label,t.labelContent),i,"group");const s=t.headerHeight??i.groupHeaderFontSize+16+o.height-o.lineHeight;const a=[];const l=`<g class="subgraph" data-id="${Ye(t.id)}" data-region="subgraph" data-label="${hn(t.label)}"${r?` data-parent-id="${Ye(r)}"`:""}>`;const c=t.inlineStyle;const d=c?.fill??i.groupFillColor??"var(--_group-fill)";const u=c?.stroke??i.groupBorderColor??"var(--_node-stroke)";const f=c?.["stroke-width"]??String(i.groupLineWidth);a.push({indent:2,node:e.shape({id:`group-rect:${t.id}`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:i.groupCornerRadius,ry:i.groupCornerRadius},paint:{fill:d,stroke:u,strokeWidth:f}})});const h=i.groupHeaderFillColor??"var(--_group-hdr)";const m=Er(t.x,t.y,t.width,s,i.groupCornerRadius);a.push({indent:2,node:e.shape({id:`group-header:${t.id}`,role:"group-header",geometry:{kind:"path",d:m},paint:{fill:h,stroke:u,strokeWidth:f}})});const p=o.text;const g=c?.color??i.groupTextColor??"var(--_text-sec)";a.push({indent:2,node:e.text({id:`group-label:${t.id}`,role:"group-header",text:p,block:o,x:t.x+i.groupLabelPaddingX,y:t.y+s/2,fontSize:i.groupHeaderFontSize,anchor:"start",paint:{fill:g}})});for(const y of K6(t,s)){a.push({indent:2,node:e.shape({id:`region-separator:${t.id}:${y.index}`,role:"group",geometry:{kind:"line",x1:y.x1,y1:y.y1,x2:y.x2,y2:y.y2},paint:{stroke:u,strokeWidth:String(i.groupLineWidth),strokeDasharray:"6 4"},attributes:{className:"region-separator"}})})}for(const y of t.children){a.push({indent:0,node:BM(e,y,n,i,t.id)})}return e.group({id:`group:${t.id}`,role:"group",open:l,close:"</g>",children:a})}function K6(e,t){const n=e.children.filter(l=>l.concurrencyRegion);if(n.length<2)return[];const i=l=>Math.max(...n.map(l))-Math.min(...n.map(l));const r=i(l=>l.x+l.width/2)>=i(l=>l.y+l.height/2);const o=[...n].sort((l,c)=>r?l.x-c.x:l.y-c.y);const s=4;const a=[];for(let l=1;l<o.length;l++){const c=o[l-1],d=o[l];if(r){const u=(c.x+c.width+d.x)/2;a.push({index:l-1,x1:u,y1:e.y+t+s,x2:u,y2:e.y+e.height-s})}else{const u=(c.y+c.height+d.y)/2;a.push({index:l-1,x1:e.x+s,y1:u,x2:e.x+e.width-s,y2:u})}}return a}function J6(e,t,n,i){void n;const{x:r,y:o,width:s,height:a}=t;const l=i.groupHeaderFillColor??"var(--_group-hdr)";const c=i.groupBorderColor??"var(--_node-stroke)";const d=i.edgeTextColor??"var(--_text-sec)";const u=t.textBlock??Wn(qe(t.text,t.textContent),i,"note");const f=u.text;const h=`state-note:${t.id}`;return e.group({id:h,role:"note",open:`<g class="state-note" data-id="${Ye(t.id)}" data-target="${Ye(t.target)}" data-side="${t.side}">`,close:"</g>",children:[{indent:2,node:e.shape({id:`${h}:rect`,role:"note",geometry:{kind:"rect",x:r,y:o,width:s,height:a,rx:4,ry:4},paint:{fill:l,stroke:c,strokeWidth:String(et.innerBox)}})},{indent:2,node:e.text({id:`${h}:text`,role:"label",text:f,block:u,x:r+s/2,y:o+a/2,fontSize:i.edgeLabelFontSize,anchor:"middle",paint:{fill:d}})}]})}function Q6(e,t,n,i,r,o){const s=t.style==="dotted"?"dotted":t.style==="thick"?"thick":t.style==="invisible"?"invisible":"solid";const a=F$(i);const l=t.labelPosition??sn(t.points);const c=n.edgeTextColor??"var(--_text-sec)";const d=t.label?[{id:`${i}:label`,text:t.label,textContent:{value:t.label,prepared:vt(qe(t.label,t.labelContent))},anchor:l,paint:{fill:c},fontSize:n.edgeLabelFontSize,textAnchor:"middle",visual:{kind:"companion",markId:`${a}:text`}}]:[];const u=(t.classNames??[]).map(w=>w.replace(/[^A-Za-z0-9_-]/g,"")).filter(Boolean);const f={identity:{id:r,...u.length?{classNames:u}:{}},endpoints:{from:t.source,to:t.target},relationship:{kind:"flowchart-edge",direction:t.source===t.target?"self":t.hasArrowStart&&t.hasArrowEnd?"bidirectional":t.hasArrowStart?"reverse":t.hasArrowEnd?"forward":"undirected"},route:{ownership:"layout",bendRadius:n.edgeBendRadius,labelAnchors:t.labelPosition?[t.labelPosition]:[]},labels:d};if(t.style==="invisible"){return e.connector({id:i,role:"edge",geometry:{kind:"polyline",points:t.points},lineStyle:"invisible",paint:{},...f})}const h=Ju(t,n);const m=t.style==="dotted"?`${jc.dash} ${jc.gap}`:t.animate?"8 4":void 0;const p=t.style==="thick"?n.lineWidth*2:n.lineWidth;const g=t.inlineStyle?.stroke??n.edgeStrokeColor;const y=`${g?`-${id(g)}`:""}${t.inlineStyle?.["stroke-width"]?"-fixed":""}`;let b;let S;if(t.hasArrowEnd){const w=Wl(t.endMarker??"arrow");b=o.find(C=>C.id===`${w}${y}`);if(!b)throw new Error(`Missing marker resource "${w}${y}"`)}if(t.hasArrowStart){const w=Wl(t.startMarker??"arrow");S=o.find(C=>C.id===`${w}-start${y}`);if(!S)throw new Error(`Missing marker resource "${w}-start${y}"`)}const x={className:["edge",...u].join(" "),data:{style:t.style,"arrow-start":String(t.hasArrowStart),"arrow-end":String(t.hasArrowEnd),...t.hasArrowStart?{"marker-start":t.startMarker??"arrow"}:{},...t.hasArrowEnd?{"marker-end":t.endMarker??"arrow"}:{},...t.label?{label:Hr(t.label)}:{},...t.curve?{curve:t.curve}:{},...t.animate?{animate:"true",animation:t.animation??"slow"}:{}}};const k={stroke:g??"var(--_line)",strokeWidth:t.inlineStyle?.["stroke-width"]??String(p),...m?{strokeDasharray:m}:{}};if(n.edgeBendRadius>0||t.curve){if(!h)throw new Error(`Missing path projection for flowchart edge "${i}"`);return e.connector({id:i,role:"edge",geometry:h.geometry,lineStyle:s,paint:k,markers:{...S?{start:S}:{},mid:[],...b?{end:b}:{}},...f,route:{...f.route,contours:h.contours},attributes:x})}return e.connector({id:i,role:"edge",geometry:{kind:"polyline",points:t.points},lineStyle:s,paint:k,markers:{...S?{start:S}:{},mid:[],...b?{end:b}:{}},...f,attributes:x})}function F$(e){return e.startsWith("edge:")?`edge-label:${e.slice("edge:".length)}`:`${e}:label`}function Z6(e,t,n,i,r){const o=t.labelPosition??sn(t.points);const s=t.labelBlock??Wn(qe(t.label,t.labelContent),i,"edge");const a=s.text;const l=on;const c=l+Ri(t,i.lineWidth);const d=s;const u=d.width+c*2;const f=d.height+c*2;const h=o.x-u/2;const m=o.y-f/2;const p=e.shape({id:`${r}:halo`,role:"chrome",geometry:{kind:"rect",x:h,y:m,width:u,height:f,rx:4,ry:4},paint:{fill:"var(--bg)",stroke:"none"},attributes:{className:"edge-label-halo"}});const g=d.width+l*2;const y=d.height+l*2;const b=e.shape({id:`${r}:pill`,role:"chrome",geometry:{kind:"rect",x:o.x-g/2,y:o.y-y/2,width:g,height:y,rx:2,ry:2},paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"1"}});const S=i.edgeTextColor??"var(--_text-sec)";const x=e.text({id:`${r}:text`,role:"label",text:a,block:s,x:o.x,y:o.y,fontSize:i.edgeLabelFontSize,anchor:"middle",paint:{fill:S}});return e.group({id:r,role:"edge-label",open:`<g class="edge-label" data-from="${Ye(t.source)}" data-to="${Ye(t.target)}" data-label="${hn(t.label)}">`,close:"</g>",children:[{indent:2,node:p},{indent:2,node:b},{indent:2,node:x}]})}function e8(e,t,n,i,r,o){const s=n8(e,t,i);const a=i8(t,i,r);const l=r8(e,t,n,i,a);const c=(t.classNames??[]).map(y=>y.replace(/[^A-Za-z0-9_-]/g,"")).filter(Boolean);const d=["node",...t.shape==="state-note"?["state-note"]:[],...c].join(" ");const u=t.shape==="state-start"?{status:"start"}:t.shape==="state-end"?{status:"end"}:void 0;const f=[{indent:2,node:s}];const h=t8(e,t,a);if(h)f.push({indent:2,node:h});if(l){f.push({indent:2,node:l})}const m=t.semanticShape?` data-semantic-shape="${Ye(t.semanticShape)}"`:"";const p=o&&t.href?` data-href="${Ye(t.href)}" role="link" tabindex="0"`:"";const g=t.floatingNoteId===void 0?"":` data-floating-note-id="${Ye(t.floatingNoteId)}"`;return e.group({id:`node:${t.id}`,role:t.shape==="state-note"?"note":"node",open:`<g class="${d}" data-id="${Ye(t.id)}" data-label="${hn(t.label)}" data-shape="${t.shape}"${m}${p}${g}>`,close:"</g>",children:f,channels:u})}function t8(e,t,n){const i=Math.min(28,t.height*.4);const r=t.x+t.width/2;const o=t.y+6;if(t.icon){const s=ol(t.icon);if(s){const l=i/24;return e.pathArtwork({id:`node:${t.id}:icon`,paths:s.paths,owner:{id:t.id,role:"node"},open:`<g class="flowchart-icon" data-icon="${Ye(t.icon)}" transform="translate(${r-i/2} ${o}) scale(${l})">`,transform:{kind:"matrix",a:l,b:0,c:0,d:l,e:r-i/2,f:o},paint:{fill:n,stroke:n,strokeWidth:"0.8"}})}const a=rl(t.icon);return e.text({id:`node:${t.id}:icon`,role:"icon",owner:{id:t.id,role:"node"},text:a,block:t.iconFallbackBlock,x:r,y:o+i/2,fontSize:10,anchor:"middle",paint:{fill:n},baselineShift:0,attributes:{className:"flowchart-icon-fallback",data:{icon:t.icon}}})}if(t.image){const s=r-i/2;const a=`M${s+2} ${o+i*.66}L${s+i*.36} ${o+i*.36}L${s+i*.52} ${o+i*.5}L${s+i*.7} ${o+i*.32}L${s+i-2} ${o+i*.66}`;const l={fill:"none",stroke:n,strokeWidth:"1.2"};const c={id:t.id,role:"node"};return e.group({id:`node:${t.id}:image`,role:"icon",owner:c,open:`<g class="flowchart-image-placeholder" data-image-src="${Ye(t.image)}">`,close:"</g>",join:"",children:[{indent:0,node:e.shape({id:`node:${t.id}:image:frame`,role:"icon",owner:c,geometry:{kind:"rect",x:s,y:o,width:i,height:i*.72,rx:2},paint:l})},{indent:0,node:e.shape({id:`node:${t.id}:image:sun`,role:"icon",owner:c,geometry:{kind:"circle",cx:s+i*.72,cy:o+i*.2,r:i*.08},paint:l})},{indent:0,node:e.shape({id:`node:${t.id}:image:landscape`,role:"icon",owner:c,geometry:{kind:"path",d:a},paint:l})}]})}return null}function n8(e,t,n){const{x:i,y:r,width:o,height:s,shape:a,inlineStyle:l}=t;const c=l?.fill??n.nodeFillColor??"var(--_node-fill)";const d=l?.stroke??n.nodeBorderColor??"var(--_node-stroke)";const u=l?.["stroke-width"]??String(n.nodeLineWidth);const f=Fr(t,{fill:c,stroke:d,strokeWidth:u},n.cornerRadius);return e.shape({id:`node-shape:${t.id}`,role:t.shape==="state-note"?"note":"node",geometry:f.geometry,paint:f.paint,...f.childPaints?{childPaints:f.childPaints}:{}})}function i8(e,t,n){const i=t.nodeTextColor??(e.inlineStyle?.fill||!fR(e)?"var(--_text)":yi("var(--_text)",t.nodeFillColor??"var(--_node-fill)",n));return $u(e.inlineStyle,i)}function r8(e,t,n,i,r){if(t.shape==="state-start"||t.shape==="state-end"||t.shape==="state-fork"||t.shape==="state-join"||t.shape==="state-choice"){if(!t.label)return null}const o=t.x+t.width/2;const s=t.y+t.height/2;const a=t.labelBlock??Wn(qe(t.label,t.labelContent),i,"node");const l=a.text;return e.text({id:`node-label:${t.id}`,role:"label",text:l,block:a,x:o,y:s,fontSize:i.nodeLabelFontSize,anchor:"middle",paint:{fill:r}})}var Qy=gt(WM);function o8(e,t){const n=t.positioned,{body:i,config:r,identities:o}=n;const s=Xe(t.resolved.renderOptions,void 0,t.resolved.styleFace);const a=S=>S&&t.resolved.renderOptions.security!=="strict"&&bs(S)?` data-href="${Ye(S)}" role="link" tabindex="0"`:"";const l=(S,x)=>o.generated(`c4:${S}:${x}`,["c4",S,x]);const c=(S,x,k,w,C=false)=>e.shape({id:l(S,x),role:C?"group":"node",geometry:k,paint:w});const d=S=>[`data-id="${Ye(S.id)}"`,`data-c4-kind="${Ye(S.kind)}"`,`data-c4-macro="${Ye(S.macro)}"`,...S.parentId?[`data-parent-id="${Ye(S.parentId)}"`]:[],...S.tags.length?[`data-tags="${Ye(JSON.stringify(S.tags))}"`]:[],...a(S.effectiveLink??S.link)?[a(S.effectiveLink??S.link)]:[],...S.sprite?[`data-sprite="${Ye(S.sprite)}"`]:[],...M0(i,S.statementId)!==void 0?[`data-source-line="${M0(i,S.statementId)}"`]:[],..."external"in S?[`data-external="${S.external}"`,`data-c4-shape="${S.shape}"`,`data-effective-c4-shape="${Ro(S)}"`]:[`data-alignment="${S.alignment??"center"}"`]].join(" ");const u=(S,x)=>{const{x:k,y:w,width:C,height:R}=x,M=zs(S,r),P=Ro(S);const E=M.fill??s.nodeFillColor??"var(--_node-fill)",v=M.stroke??s.nodeBorderColor??"var(--_node-stroke)",L=M.text??$u(M.fill?{fill:M.fill}:void 0,s.nodeTextColor??yi("var(--_text)",E,t.colors)),T=String(s.nodeLineWidth);const A={fill:E,stroke:v,strokeWidth:T,...M.dashed?{strokeDasharray:"5 3"}:{}};const $=[],_=I=>$.push({node:I,indent:2});if(P==="database"){const I=8,D=`M ${k} ${w+I} A ${C/2} ${I} 0 0 1 ${k+C} ${w+I} L ${k+C} ${w+R-I} A ${C/2} ${I} 0 0 1 ${k} ${w+R-I} Z`;_(c(S.id,"surface",{kind:"path",d:D},A));_(c(S.id,"database-rim",{kind:"ellipse",cx:k+C/2,cy:w+I,rx:C/2,ry:I},{fill:"none",stroke:v,strokeWidth:"1"}))}else{_(c(S.id,"surface",{kind:"rect",x:k,y:w,width:C,height:R,rx:s.cornerRadius??0,ry:s.cornerRadius??0},A));if(P==="queue")for(const[I,D]of[k+8,k+C-8].entries())_(c(S.id,`queue-end:${I}`,{kind:"line",x1:D,y1:w,x2:D,y2:w+R},{stroke:v,strokeWidth:"1"}));if(P==="person"){const I=k+C/2,D=w+R/2+19-x.labelBlock.height/2,B=D-31;const Y={fill:L,stroke:L,strokeWidth:"1"};_(c(S.id,"person-head",{kind:"circle",cx:I,cy:B,r:7},Y));const W=`M ${I-16} ${B+26} Q ${I-16} ${B+11} ${I} ${B+11} Q ${I+16} ${B+11} ${I+16} ${B+26} Z`;_(c(S.id,"person-shoulders",{kind:"path",d:W},Y))}}const z=x.labelBlock,F=k+C/2,G=w+R/2+(P==="person"?19:P==="database"?4:0);_(e.text({id:l(S.id,"text"),role:"label",text:z.text,block:z,x:F,y:G,fontSize:z.fontSize,fontWeight:z.fontWeight,letterSpacing:z.letterSpacing,anchor:"middle",paint:{fill:L}}));return e.group({id:l(S.id,"card"),role:"node",open:`<g class="node c4-${S.kind}" ${d(S)}>`,close:"</g>",children:$,channels:{category:`${S.external?"external-":""}${S.kind}`,...S.tags.length?{status:S.tags.join(",")}:{}}})};const f=new Map(i.boundaries.map(S=>[S.id,S]));const h=S=>{const x=f.get(S.id),k=zs(x,r),{x:w,y:C,width:R,height:M}=S;const P=k.stroke??s.groupBorderColor??"var(--_node-stroke)",E=k.fill??s.groupFillColor??"var(--_group-fill)",v=k.fill??s.groupHeaderFillColor??"var(--_group-hdr)",L=k.text??$u(k.fill?{fill:k.fill}:void 0,s.groupTextColor??yi("var(--_text-sec)",v,t.colors)),T=S.headerHeight??36;const A=[],$=W=>A.push({node:W,indent:2});const _=x.style.lineStyle==="solid"?void 0:x.style.lineStyle==="dotted"?"1 3":x.style.lineStyle==="dashed"?"5 3":x.kind==="deployment"?void 0:"6 4";$(c(x.id,"boundary-frame",{kind:"rect",x:w,y:C,width:R,height:M,rx:s.groupCornerRadius,ry:s.groupCornerRadius},{fill:E,stroke:P,strokeWidth:String(s.groupLineWidth),..._?{strokeDasharray:_}:{}},true));const z=Er(w,C,R,T,s.groupCornerRadius);const F={kind:"path",d:z},G={fill:v,stroke:P,strokeWidth:String(s.groupLineWidth)};$(e.shape({id:l(x.id,"boundary-band"),role:"group-header",geometry:F,paint:G}));const I=S.labelBlock,D=x.alignment==="left"?"start":x.alignment==="right"?"end":"middle",B=x.alignment==="left"?w+r.padding:x.alignment==="right"?w+R-r.padding:w+R/2,Y=C+T/2;$(e.text({id:l(x.id,"boundary-text"),role:"group-header",text:I.text,block:I,x:B,y:Y,fontSize:I.fontSize,fontWeight:I.fontWeight,letterSpacing:I.letterSpacing,anchor:D,paint:{fill:L}}));for(const W of S.children)$(h(W));return e.group({id:l(x.id,"frame"),role:"group",open:`<g class="cluster c4-boundary" ${d(x)}>`,close:"</g>",children:A,channels:{category:x.kind}})};const m=new Map(i.relationships.map(S=>[S.id,S]));const p=S=>{const x=_o(S);const k=m.get(x.identity?.id??"");if(!k)return e.connector(S);const w=k.style.lineStyle==="dotted"?{...x.stroke,dash:{array:"1 3"}}:x.stroke;const C=t.resolved.renderOptions.security==="strict"?void 0:k.effectiveLink??k.link;const{markers:R}=x,M=x.labels[0];const P={className:"edge",data:{style:x.lineStyle,"arrow-start":String(!!R.start),"arrow-end":String(!!R.end),...R.start?{"marker-start":R.start.shape}:{},...R.end?{"marker-end":R.end.shape}:{},...M?{label:Hr(M.text)}:{},"c4-macro":k.macro,"authored-from":k.from,"authored-to":k.to,order:String(k.order),...k.index!==void 0?{index:k.index}:{},...k.tags.length?{tags:JSON.stringify(k.tags)}:{},...C&&bs(C)?{href:C}:{}},...C&&bs(C)?{tabIndex:0}:{}};const E={id:l(k.id,"relationship"),role:"edge",identity:x.identity,geometry:x.route.geometry,paint:{stroke:w.color,strokeWidth:String(w.width)},lineStyle:x.lineStyle,endpoints:x.endpoints,relationship:{...x.relationship,kind:`c4-${k.macro}`},route:x.route,stroke:w,markers:x.markers,hit:x.hit,labels:x.labels.map(v=>({...v,visual:{kind:"companion",markId:l(k.id,"label-text")},...k.style.textColor?{paint:{...v.paint,fill:k.style.textColor}}:{}})),channels:{category:"relationship",...k.tags.length?{status:k.tags.join(",")}:{}},attributes:P};return e.connector(E)};const g=WM({...e,connector:p},t,{surfaces:false,edgeLabels:false,beforeEdges:()=>n.groups.map(h)});const y=g.parts;const b=n.edges.flatMap(S=>{if(!S.label||!S.labelBlock||!S.labelPosition)return[];const x=m.get(S.id),k=S.labelBlock,{x:w,y:C}=S.labelPosition,R=x.style.textColor??x.style.fontColor??s.edgeTextColor??"var(--_text-sec)";const M=il(S),P={kind:"rect",...M,rx:3,ry:3},E={fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"1"};return[e.group({id:l(x.id,"relationship-label"),role:"edge-label",open:`<g class="edge-label" data-id="${Ye(l(x.id,"label"))}" data-role="edge-label" data-edge-id="${Ye(x.id)}" data-from="${Ye(x.source)}" data-to="${Ye(x.target)}">`,close:"</g>",children:[{indent:2,node:e.shape({id:l(x.id,"label-halo"),role:"chrome",geometry:P,paint:E})},{indent:2,node:e.text({id:l(x.id,"label-text"),role:"label",text:k.text,block:k,x:w,y:C,fontSize:k.fontSize,fontWeight:k.fontWeight,letterSpacing:k.letterSpacing,anchor:"middle",paint:{fill:R},pageFill:x.style.textColor??x.style.fontColor??yi("var(--_text-sec)","var(--bg)",t.colors)})}]})]});y.splice(y.length-1,0,...b,...n.nodes.map(S=>u(i.elements.find(x=>x.id===S.id),S)));if(n.legend){const S=n.legend,x=[];const k=st(t.resolved.styleFace,"legend",{},{includeFallback:false});const w=k?.textColor??"var(--_text)";const C=S.heading,R=S.x+12,M=S.y+8+C.height/2;const P=e.text({id:l("legend","heading"),role:"legend",text:C.text,block:C,x:R,y:M,fontSize:C.fontSize,fontWeight:C.fontWeight,letterSpacing:C.letterSpacing,anchor:"start",paint:{fill:w}});x.push({node:P,indent:2});let E=S.y+20+C.height;for(const v of S.entries){const{block:L}=v,T=S.x+38,A=E+L.height/2;const $=v.style.borderColor??v.style.lineColor??k?.strokeColor??k?.borderColor??s.nodeBorderColor??"var(--_line)";const _=v.style.bgColor??k?.fillColor??s.nodeFillColor??"var(--_node-fill)",z=String(k?.lineWidth??1);const F=v.style.lineStyle==="dotted"?"1 3":v.style.lineStyle==="dashed"||v.external?"5 3":void 0;const G={fill:_,stroke:$,strokeWidth:z,...F?{strokeDasharray:F}:{}};const I=S.x+10,D=18,B=L.height;const Y=(O,N)=>x.push({indent:2,node:e.shape({id:l(v.id,O),role:"legend",geometry:N,paint:G})});if(v.kind==="relationship")Y("legend-swatch",{kind:"line",x1:I,y1:A,x2:I+D,y2:A});else if(v.shape==="database"){const O=Math.min(3,B/4),N=`M ${I} ${E+O} A 9 ${O} 0 0 1 ${I+D} ${E+O} L ${I+D} ${E+B-O} A 9 ${O} 0 0 1 ${I} ${E+B-O} Z`;Y("legend-swatch",{kind:"path",d:N});Y("legend-rim",{kind:"ellipse",cx:I+9,cy:E+O,rx:9,ry:O})}else if(v.shape==="person"){const O=Math.min(3,B/5),N=I+9;Y("legend-head",{kind:"circle",cx:N,cy:E+O,r:O});const H=`M ${I+3} ${E+B} Q ${I+3} ${E+O*2.5} ${N} ${E+O*2.5} Q ${I+15} ${E+O*2.5} ${I+15} ${E+B} Z`;Y("legend-swatch",{kind:"path",d:H})}else{Y("legend-swatch",{kind:"rect",x:I,y:E,width:D,height:B});if(v.shape==="queue")for(const[O,N]of[I+3,I+15].entries())Y(`legend-end:${O}`,{kind:"line",x1:N,y1:E,x2:N,y2:E+B})}const W=w;x.push({indent:2,node:e.text({id:l(v.id,"legend-text"),role:"legend",text:L.text,block:L,x:T,y:A,fontSize:L.fontSize,fontWeight:L.fontWeight,letterSpacing:L.letterSpacing,anchor:"start",paint:{fill:W}})});E+=L.height+10}y.splice(y.length-1,0,e.group({id:l("legend","container"),role:"legend",open:'<g class="c4-legend">',close:"</g>",children:x}))}return{...g,family:"c4",parts:y}}var N$=gt(o8);var mMe={configDiagnostics:M$,normalizeRequest:e=>{const t=e.source.authoredWrapperLength??e.source.wrapperSource?.length??0;const n=e.source.originalText.slice(0,t);const i=fL(e.source.originalText.slice(t));const r=n.split(/\r\n?|\n/).length-1;for(const s of i.statements){s.span.start+=n.length;s.span.end+=n.length;s.span.line+=r}const o=Ar(e.source.frontmatter);if(i.title===void 0&&o!==void 0)i.title=o;if(e.source.accessibility.title!==void 0)i.accessibilityTitle=e.source.accessibility.title;if(e.source.accessibility.descr!==void 0)i.accessibilityDescription=e.source.accessibility.descr;return{familyConfig:{model:i,c4:e.source.config.c4??{},themeVariables:e.source.config.themeVariables??{}}}},layout:e=>{const t=e.familyConfig;return mt(I$(t.model,e.renderOptions,e.styleFace,t.c4,t.themeVariables))},projectPositioned:ft(k$),lowerScene:ht(N$)};function Qd(e,t={}){const n=e<=6?{accent:t.accent&&Th(t.accent)?t.accent:Zs,bg:t.bg&&Th(t.bg)?t.bg:void 0}:t;const i=Ji(e,n);const r=t.overrides;if(!r||r.length===0)return i;return i.map((o,s)=>r[s%12]??o)}function $$(e,t){return Object.hasOwn(e.nodeColors,t)?e.nodeColors[t]:void 0}var zM={width:600,height:400,linkColor:{mode:"gradient"},nodeAlignment:"justify",showValues:true,prefix:"",suffix:"",labelStyle:"legacy",nodeWidth:10,nodePadding:12,nodeColors:{}};var s8=["justify","center","left","right"];var a8=["legacy","outlined"];var l8=["source","target","gradient"];var Qi=Object.freeze({width:{min:1,max:1e4},height:{min:1,max:1e4},nodeWidth:{min:1,max:200},nodePadding:{min:0,max:200}});function Zy(e,t,n){if(typeof e!=="number"||!Number.isFinite(e))return void 0;if(e<t||e>n)return void 0;return e}function GM(e={}){const t=Sn(e,["sankey"])??{};const n={...zM};const i=Zy(t.width,Qi.width.min,Qi.width.max);if(i!==void 0)n.width=i;const r=Zy(t.height,Qi.height.min,Qi.height.max);if(r!==void 0)n.height=r;const o=Zy(t.nodeWidth,Qi.nodeWidth.min,Qi.nodeWidth.max);if(o!==void 0)n.nodeWidth=o;const s=Zy(t.nodePadding,Qi.nodePadding.min,Qi.nodePadding.max);if(s!==void 0)n.nodePadding=s;const a=t.nodeAlignment;if(typeof a==="string"&&s8.includes(a)){n.nodeAlignment=a}const l=t.labelStyle;if(typeof l==="string"&&a8.includes(l)){n.labelStyle=l}if(typeof t.showValues==="boolean")n.showValues=t.showValues;if(typeof t.prefix==="string")n.prefix=t.prefix;if(typeof t.suffix==="string")n.suffix=t.suffix;const c=t.linkColor;if(typeof c==="string"){if(l8.includes(c)){n.linkColor={mode:c}}else{const u=mn(c,true);if(u!==void 0)n.linkColor={mode:"static",color:u}}}const d=Sn(e,["sankey","nodeColors"]);if(d){const u={};for(const[f,h]of Object.entries(d)){const m=mn(h,n.linkColor.mode!=="gradient");if(m!==void 0)u[f]=m}if(Object.keys(u).length>0)n.nodeColors=Object.freeze(u)}return n}function ex(e){const t=e&&typeof e==="object"&&!Array.isArray(e)?e:{};const n=t.commitLabelFontSize;const i=typeof n==="number"?n:typeof n==="string"?Number.parseFloat(n):11;return Number.isFinite(i)&&i>0?i:11}function HM(e,t){const n={commitLabelFontSize:ex(t)};if(!e||typeof e!=="object"||Array.isArray(e))return n;const i=e;for(const r of["showBranches","showCommitLabel","rotateCommitLabel","parallelCommits"]){if(typeof i[r]==="boolean")n[r]=i[r]}if(typeof i.mainBranchName==="string"&&i.mainBranchName.trim())n.mainBranchName=i.mainBranchName.trim();if(typeof i.mainBranchOrder==="number"&&Number.isFinite(i.mainBranchOrder))n.mainBranchOrder=i.mainBranchOrder;return n}function _$(e,t,n={},i){return LI(e,{...t,renderOptions:n,styleFace:i})}function D$(e){const t=ya(e);if(!t.includes("\r"))return t.split("\n");const n=t.split(/\r|\n/);const i=t.match(/\r|\n/g)??[];const r=[];let o="";let s=0;let a=false;let l=-1;for(let c=0;c<n.length;c++){const d=n[c];o+=d;if(!a&&c>l){if(d.trimStart().startsWith("%%"))l=c;else{const u=Tt(n,c);if(u)l=u.endIndex;else if(u===void 0)l=n.length-1}}if(c>l){for(let u=0;u<d.length;u++){if(d[u]!=='"')continue;if(a&&d[u+1]==='"')u++;else a=!a}}if(a&&i[c]!==void 0){o+=i[c]==="\r"?"\r":"\n";s++}else{r.push(o);while(s>0){r.push("");s--}o=""}}return r}var O$=["actorMargin","width","height","diagramMarginX","diagramMarginY","messageMargin","noteMargin","activationWidth"];var vMe=[...O$,"showSequenceNumbers","wrap"];function B$(e){if(!e)return{};const t={};for(const o of O$){const s=kt(e,["sequence",o]);if(typeof s==="number"&&Number.isFinite(s)&&s>=0)t[o]=s}const n=kt(e,["sequence","showSequenceNumbers"]);if(n===true)t.showSequenceNumbers=true;const i=kt(e,["wrap"]);const r=kt(e,["sequence","wrap"]);if(typeof i==="boolean")t.wrap=i;else if(typeof r==="boolean")t.wrap=r;return t}var c8={padding:$a(0),iconSize:$a(0,true),fontSize:$a(0,true),nodeSeparation:$a(0),idealEdgeLengthMultiplier:$a(0,true)};var W$=e=>bt("architecture",e,c8);var z$={fill:"var(--arch-edge-stroke, var(--_arrow))",stroke:"var(--arch-edge-stroke, var(--_arrow))",strokeWidth:"0.75",strokeLinejoin:"round"};var Zd=[dr("architecture-arrow-end",{width:8,height:5},"end",z$),dr("architecture-arrow-start",{width:8,height:5},"start",z$)];var eu=gr(Zd);var tx=e=>e.trim().toLowerCase().split(/[:/]/).pop()??e.trim().toLowerCase();function jM(e){const t=tx(e).replace(/[^a-z0-9]/g,"");return(t[0]??"?").toUpperCase()}function YM(e,t){if(!e||fa(e)||["cloud","database","disk","internet","server"].includes(tx(e)))return void 0;return _e(jM(e),{fontSize:Math.max(10,t*.56),fontWeight:700})}function tu(e){throw new Error(`LAYOUT_HINT_INVALID: ${e}`)}function G$(e,t,n){if(!n)return;const i=new Map;const r=u=>{for(const f of u.children??[]){i.set(f.id,{node:f,parent:u});r(f)}};r(e);const o=u=>{const f=i.get(u);if(!f||!t.nodes.has(u))tu(`unknown node "${u}"`);return f};const s=new Set;if(n.ranks){for(const[u,f]of Object.entries(n.ranks)){const{node:h,parent:m}=o(u);if(!Number.isSafeInteger(f)||f<0||f>1e4)tu(`rank for "${u}" must be an integer in [0,10000]`);s.add(m);m.layoutOptions={...m.layoutOptions,"elk.partitioning.activate":"true"};h.layoutOptions={...h.layoutOptions,"elk.partitioning.partition":String(f)}}}for(const u of s)for(const f of u.children??[]){f.layoutOptions={"elk.partitioning.partition":"0",...f.layoutOptions}}const a=new Set;for(const u of n.adjacent??[]){if(u.length<2)tu("adjacent needs two or more nodes");const f=u.map(o);const h=f[0].parent;if(f.some(g=>g.parent!==h))tu("adjacent nodes need the same container");for(const g of u){if(a.has(g))tu("a node cannot repeat in adjacency groups");a.add(g)}const m=h.children;const p=Math.min(...f.map(g=>m.indexOf(g.node)));h.children=[...m.slice(0,p),...f.map(g=>g.node),...m.slice(p).filter(g=>!u.includes(g.id))];h.layoutOptions={...h.layoutOptions,"elk.layered.crossingMinimization.forceNodeModelOrder":"true"}}const l=Ad(t.edges);const c=new Set((n.shortEdges??[]).map(u=>{const f=l.get(u);if(f===void 0)tu(`unknown edge "${u}"`);return f}));const d=u=>{for(const f of u.edges??[]){const h=/^e(\d+)(?:_|$)/.exec(f.id);if(h&&c.has(Number(h[1])))f.layoutOptions={...f.layoutOptions,"elk.layered.priority.shortness":"100","elk.layered.priority.direction":"100"}}u.children?.forEach(d)};d(e)}function qM(e){if(e.nodes.size<2||e.subgraphs.length>0||e.stateNotes?.length||e.edges.length>=e.nodes.size||[...e.nodes.values()].some(r=>r.shape!=="rectangle"))return false;const t=new Map,n=new Map;for(const r of e.edges){if(r.label!==void 0||(r.length??1)!==1||r.source===r.target||!e.nodes.has(r.source)||!e.nodes.has(r.target)||t.has(r.target))return false;t.set(r.target,1);const o=n.get(r.source);if(o)o.push(r.target);else n.set(r.source,[r.target])}const i=[...e.nodes.keys()].filter(r=>!t.has(r));for(let r=0;r<i.length;r++)for(const o of n.get(i[r])??[])i.push(o);return i.length===e.nodes.size}function XM(e,t,n,i,r){const o=t.children;if(!o||o.length<2||e.subgraphs.length>0||e.stateNotes?.length||o.length!==e.nodes.size||e.edges.some(c=>c.label!==void 0||(c.length??1)!==1)||[...e.nodes.values()].some(c=>c.shape!=="rectangle")||![n,i,r].every(c=>Number.isFinite(c)&&c>=0)||i===0||r===0)return void 0;const s=new Map(o.map((c,d)=>[c.id,d]));const a=e.edges.map(c=>({source:s.get(c.source)??-1,target:s.get(c.target)??-1,minSpan:1}));const l=iy({nodes:o.map(c=>({id:c.id,width:c.width,height:c.height})),edges:a,direction:e.direction,padding:n,nodeSpacing:i,layerSpacing:r});if(!l)return void 0;return{...t,width:l.width,height:l.height,children:o.map((c,d)=>({...c,...l.nodes[d]})),edges:e.edges.map((c,d)=>{const u=l.edges[d].points;return{id:`e${d}`,sources:[c.source],targets:[c.target],sections:[{id:`e${d}_s0`,startPoint:u[0],bendPoints:u.slice(1,-1),endPoint:u.at(-1)}]}})}}function Io(e,t,n){const i=e.labelBlock??ji(qe(e.label,e.labelContent),n);return{x:t.x-(i.width+16)/2,y:t.y-(i.height+16)/2,width:i.width+16,height:i.height+16}}function UM(e){let t=[e[0],e[e.length-1]];let n=-1;for(let i=1;i<e.length;i++){const r=e[i-1],o=e[i];const s=Math.hypot(o.x-r.x,o.y-r.y);if(s>n){n=s;t=[r,o]}}return{x:(t[0].x+t[1].x)/2,y:(t[0].y+t[1].y)/2}}function Fh(e){return Math.max(8,e.edgeLabelFontSize*.75)}function Sc(e){return Math.max(12,e.edgeLabelFontSize)}function d8(e,t){const n=e.lineWidth??1;const i=t.style==="thick"?n*2:n;return Math.max(18,e.edgeLabelFontSize+bn.width+i*2)}function Y$(e){const t=e.lineWidth??1;const n=t*2;return Math.max(18,e.edgeLabelFontSize+bn.width+n*2)}function u8(){return jc.dash*3+jc.gap*2}function VM(e){return Y$(e)+u8()}function nx(e,t,n){return Math.abs(n.x-t.x)>=Math.abs(n.y-t.y)?e.width/2:e.height/2}function q$(e,t,n,i,r,o){const s=d8(o,e);if(e.hasArrowStart&&n===1){const a=t[0];const l=nx(r,a,t[1]);if(Math.hypot(i.x-a.x,i.y-a.y)<l+s)return false}if(e.hasArrowEnd&&n===t.length-1){const a=t[t.length-1];const l=nx(r,t[t.length-2],a);if(Math.hypot(i.x-a.x,i.y-a.y)<l+s)return false}return true}function f8(e,t,n,i){return{start:e.hasArrowStart&&n===1?Y$(i):Sc(i),end:e.hasArrowEnd&&n===t.length-1?VM(i):Sc(i)}}function h8(e,t,n){return _t(n).isHorizontal?Math.abs(e.y-t.y)<.01:Math.abs(e.x-t.x)<.01}function m8(e,t,n,i,r){const o=nx(e,n,i);return Math.hypot(t.x-n.x,t.y-n.y)>=o+r.start&&Math.hypot(t.x-i.x,t.y-i.y)>=o+r.end}function p8(e,t,n,i){const r=Math.hypot(n.x-t.x,n.y-t.y);if(r===0)return[];const o=nx(e,t,n);const s=(o+i.start)/r;const a=1-(o+i.end)/r;if(s>a)return[];return[(s+a)/2]}function X$(e,t,n,i,r){if(!e.label)return 0;const o=_t(t);const s=Io(e,{x:0,y:0},n);const a=o.isHorizontal?s.width:s.height;const l=Math.max(Sc(n),e.hasArrowEnd?VM(n):Sc(n));const c=(r-i)*o.sign;const d=(c-a)/3;if(d>=l-.001)return a+d*2;return a+Sc(n)+l+2}function U$(e,t,n){if(!e.label)return 0;const i=Io(e,{x:0,y:0},n);const r=_t(t).isHorizontal?i.width:i.height;const o=Math.max(Sc(n),e.hasArrowEnd?VM(n):Sc(n));return r+o*3}function nu(e,t,n,i,r,o){if(!e.label)return[];const s=Tp(t);if(s===0)return[];const a=s/2;const l=[];const c=[.5,.45,.55,.4,.6,.35,.65,.3,.7,.25,.75,.2,.8,1/6,5/6];let d=0;for(let u=1;u<t.length;u++){const f=t[u-1],h=t[u];const m=Math.hypot(h.x-f.x,h.y-f.y);if(m===0)continue;const p=h8(f,h,i);const g=e.hasArrowStart&&u===1||e.hasArrowEnd&&u===t.length-1;const y=Io(e,{x:0,y:0},r);const b=f8(e,t,u,r);const S=[...c,...p8(y,f,h,b)].filter((C,R,M)=>C>=0&&C<=1&&M.findIndex(P=>Math.abs(P-C)<.001)===R);const x=Math.abs(f.x-h.x)<.01;const k=Math.min(y.height/2+3,(x?y.width:y.height)/2-1);const w=o?[0,k/4,-k/4,k/2,-k/2,k,-k]:[0];for(let C=0;C<S.length;C++){const R=S[C];for(const M of w){const P={x:f.x+(h.x-f.x)*R+(x?M:0),y:f.y+(h.y-f.y)*R+(x?0:M)};const E=Io(e,P,r);if(n.some(T=>Li(E,T,2)))continue;if(!q$(e,t,u,P,E,r))continue;const v=m8(E,P,f,h,b);const L=x?E.y>=Math.min(f.y,h.y)&&E.y+E.height<=Math.max(f.y,h.y):E.x>=Math.min(f.x,h.x)&&E.x+E.width<=Math.max(f.x,h.x);if(o&&(!v||!L||!o(e,P)))continue;l.push({point:P,box:E,order:C,rank:0,pathDistance:d+m*R,routeMidpointDistance:Math.abs(d+m*R-a),segmentMidpointDistance:Math.abs(m*(R-.5)),straightRunPenalty:p&&v?0:p?2:10,terminalSegmentPenalty:g?1:0})}}d+=m}l.sort((u,f)=>u.straightRunPenalty-f.straightRunPenalty||u.terminalSegmentPenalty-f.terminalSegmentPenalty||u.segmentMidpointDistance-f.segmentMidpointDistance||u.routeMidpointDistance-f.routeMidpointDistance||u.order-f.order||u.pathDistance-f.pathDistance);return l.map((u,f)=>({...u,rank:f}))}function H$(e,t,n,i,r){return nu(e,t,n,i,r)[0]?.point??sn(t)}function g8(e,t){const n=_t(t);const i=e.map(d=>d.point[n.main]);const r=Math.max(...i)-Math.min(...i);const o=e.reduce((d,u)=>d+u.straightRunPenalty,0);const s=e.reduce((d,u)=>d+u.terminalSegmentPenalty,0);const a=e.reduce((d,u)=>d+u.segmentMidpointDistance,0);const l=e.reduce((d,u)=>d+u.routeMidpointDistance,0);const c=e.reduce((d,u)=>d+u.rank,0);return o*1e4+r*100+s*1e3+a*4+c*.25+l*.1}function j$(e,t){let n=0;const i=[];for(let a=1;a<t.length;a++){const l=Math.hypot(t[a].x-t[a-1].x,t[a].y-t[a-1].y);i.push(l);n+=l}let r=Infinity,o=0,s=0;for(let a=1;a<t.length;a++){const l=t[a-1],c=t[a],d=c.x-l.x,u=c.y-l.y,f=d*d+u*u;let h=f?((e.x-l.x)*d+(e.y-l.y)*u)/f:0;h=Math.max(0,Math.min(1,h));const m=l.x+h*d,p=l.y+h*u,g=Math.hypot(e.x-m,e.y-p);if(g<r){r=g;o=s+h*i[a-1]}s+=i[a-1]}return n?o/n:.5}function y8(e,t){const n=_t(t);const i=e.map(s=>s[n.main]);const r=(Math.min(...i)+Math.max(...i))/2;let o=null;for(let s=1;s<e.length;s++){const a=e[s-1],l=e[s];const c=Math.min(a[n.main],l[n.main]),d=Math.max(a[n.main],l[n.main]);if(r<c-1e-6||r>d+1e-6)continue;const u=l[n.main]-a[n.main];if(Math.abs(u)<=1e-6)continue;const f=(r-a[n.main])/u;const h={[n.main]:r,[n.cross]:a[n.cross]+f*(l[n.cross]-a[n.cross])};if(Math.abs(a[n.cross]-l[n.cross])<.01)return h;o??=h}return o}function x8(e,t,n,i,r,o=[],s=0){if(!e.label||!e.labelPosition)return;const a=y8(t,i);if(!a)return;const l=Math.abs(j$(e.labelPosition,t)-.5);const c=Math.abs(j$(a,t)-.5);if(c>=l-1e-6)return;const d=Io(e,a,r);if(n.some(f=>Li(d,f,2)))return;if(o.some(f=>Li(d,f,s)))return;const u=_t(i);for(let f=1;f<t.length;f++){const h=t[f-1],m=t[f];const p=Math.min(h[u.main],m[u.main]),g=Math.max(h[u.main],m[u.main]);if(Math.abs(m[u.main]-h[u.main])<=1e-6)continue;if(a[u.main]<p-1e-6||a[u.main]>g+1e-6)continue;if(!q$(e,t,f,a,d,r))return;break}e.labelPosition=a}function iu(e,t,n,i,r=false,o){const s=e.filter(({edge:c})=>c.label);if(s.length===0)return true;if(s.length===1){const c=s[0];const d=nu(c.edge,c.points,t,n,i,o);if(o&&d.length===0)return false;c.edge.labelPosition=d[0]?.point??sn(c.points)}else{const c=s.map(({edge:d,points:u})=>nu(d,u,t,n,i,o));if(c.some(d=>d.length===0)){if(o)return false;for(const{edge:d,points:u}of s)d.labelPosition=H$(d,u,t,n,i)}else{const d=Fh(i);let u;let f=Number.POSITIVE_INFINITY;const h=[];const m=p=>{if(p===c.length){const g=g8(h,n);if(g<f){f=g;u=h.slice()}return}for(const g of c[p]){if(h.some(y=>Li(g.box,y.box,d)))continue;h.push(g);m(p+1);h.pop()}};m(0);if(!u){if(o)return false;for(const{edge:p,points:g}of s)p.labelPosition=H$(p,g,t,n,i)}else{for(let p=0;p<s.length;p++)s[p].edge.labelPosition=u[p].point}}}if(!r)return true;const a=[];const l=Fh(i);for(const{edge:c}of s){if(c.labelPosition)a.push(Io(c,c.labelPosition,i))}for(let c=0;c<s.length;c++){const{edge:d,points:u}=s[c];const f=d.labelPosition;const h=a.filter((m,p)=>p!==c);x8(d,u,t,n,i,h,l);if(d.labelPosition&&d.labelPosition!==f)a[c]=Io(d,d.labelPosition,i)}return true}function b8(e,t,n,i,r){const o=(d,u)=>Math.min(d.x1,u.x1)-Math.max(d.x0,u.x0)>1e-6&&Math.min(d.y1,u.y1)-Math.max(d.y0,u.y0)>1e-6;const s=d=>({x0:d.x,y0:d.y,x1:d.x+d.width,y1:d.y+d.height});const a=new Map(e.map(d=>[d.id,d]));const l=new Map(t.map(d=>[d.id,d]));const c=n.flatMap(d=>{const u=Pt(d,r);if(!u)return[];const f=Math.max(4,r.lineWidth*(d.style==="thick"?2:1)*2);return[{x0:u.x-f,y0:u.y-f,x1:u.x+u.w+f,y1:u.y+u.h+f}]});for(const d of c){if(t.some((u,f)=>o(d,s(u))&&!o(d,s(e[f]))))return false}for(const d of n){const u=yr(d,r);if(u.length===0)continue;let f=d.points;const h=l.get(d.source),m=l.get(d.target);if(h)f=wa(f,h,true);if(m)f=wa(f,m,false);const p={...d,points:f};cc(t,[p],i,r);f=p.points;for(const y of[true,false]){if(!(y?d.hasArrowStart:d.hasArrowEnd))continue;const b=y?d.source:d.target;const S=a.get(b),x=l.get(b);const k=y?d.points:[...d.points].reverse();const w=y?f:[...f].reverse();const C=k[0],R=w[0];const M=C&&k.find(E=>E.x!==C.x||E.y!==C.y);const P=R&&w.find(E=>E.x!==R.x||E.y!==R.y);if(S&&C&&M&&Ns(S,C,M)===true&&(!x||!R||!P||Ns(x,R,P)!==true))return false}const g=yr(p,r);for(let y=0;y<u.length;y++){const b=u[y],S=g[y];if(!b.bounds)continue;if(!S?.bounds)return false;const x=S.position==="start"?d.source:d.target;if(t.some((k,w)=>k.id!==x&&o(S.bounds,s(k))&&!o(b.bounds,s(e[w]))))return false;if(c.some(k=>o(k,S.bounds)&&!o(k,b.bounds)))return false}}return true}function KM(e,t,n,i,r){const o=Co(i.edges);const s=new Map(e.map(m=>[m.id,m]));const a=new Map;const l=new Map;for(const m of t){if(!co(m,s,i.direction))continue;if(!a.has(m.target))a.set(m.target,[]);a.get(m.target).push(m);if(!l.has(m.source))l.set(m.source,[]);l.get(m.source).push(m)}const c=[];const d=m=>{if(m.length<2||m.length>5)return;if(!m.every(g=>g.shape==="rectangle"))return;if(m.some(g=>zn(g,n)))return;if(!ac(m,i.direction))return;const p=m.map(g=>g.id).sort().join("\0");if(c.some(g=>g.map(y=>y.id).sort().join("\0")===p))return;c.push(m)};for(const m of a.values()){const p=m[0]?.target;const g=m.map(y=>s.get(y.source)).filter(Boolean);if(!p||!g.every(y=>t.every(b=>b.source!==y.id||b.target===p)))continue;d(g)}for(const m of l.values()){const p=m[0]?.source;const g=m.map(b=>s.get(b.target)).filter(Boolean);if(!p||!g.every(b=>t.every(S=>S.target!==b.id||S.source===p)&&t.every(S=>S.source!==b.id)))continue;let y=true;for(let b=0;b<g.length;b++)for(let S=0;S<g.length;S++){if(b!==S&&o(g[b].id,g[S].id))y=false}if(y)d(g)}let u=false;let f;const h=_t(i.direction);for(const m of c){const p=Math.max(...m.map(F=>F.width));const g=Math.max(...m.map(F=>F.height));if(m.every(F=>Math.abs(F.width-p)<.5&&Math.abs(F.height-g)<.5))continue;f??=e.map(F=>({...F}));const y=[...m].sort((F,G)=>rr(F,i.direction)-rr(G,i.direction));let b=Math.min(...y.map(F=>rr(F,i.direction)));const S=Math.min(...y.map(F=>Po(F,i.direction)));const x=[];for(const F of y){x.push({node:F,x:h.isHorizontal?S:b,y:h.isHorizontal?b:S});b+=(h.isHorizontal?g:p)+24}const k=new Set(m.map(F=>F.id));const w=(F,G,I,D)=>F<D-.01&&I<G-.01;const C=F=>{const G=h.isHorizontal?F.x:F.y;return[G,G+(h.isHorizontal?F.width:F.height)]};const R=F=>{const G=h.isHorizontal?F.y:F.x;return[G,G+(h.isHorizontal?F.height:F.width)]};const M=x.map(({node:F,x:G,y:I})=>({id:F.id,x:G,y:I,width:p,height:g,orig:C(F)}));let P=0;const E=new Set;for(const F of M){const[G,I]=C(F),[D,B]=R(F),[Y,W]=F.orig;for(const O of e){if(k.has(O.id))continue;const[N,H]=C(O),[j,q]=R(O);if(w(G,I,N,H)&&!w(Y,W,N,H)&&w(D,B,j,q)){E.add(O.id);P=Math.max(P,I+24-N)}}}const v=new Set;const L=F=>{if(v.has(F)||k.has(F))return;v.add(F);for(const G of a.get(F)??[])L(G.source)};for(const F of E)L(F);const T=e.filter(F=>v.has(F.id));const A=new Map(T.map(F=>[F.id,C(F)]));const $=[...m,...T].map(F=>({n:F,x:F.x,y:F.y,w:F.width,h:F.height}));if(P>0)for(const F of T)F[h.main]+=P;for(const{node:F,x:G,y:I}of x){F.x=G;F.y=I;F.width=p;F.height=g}const _=new Set([...k,...v]);const z=[...m,...T].some(F=>{const[G,I]=C(F),[D,B]=R(F);const[Y,W]=A.get(F.id)??M.find(O=>O.id===F.id).orig;return e.some(O=>{if(_.has(O.id))return false;const[N,H]=C(O),[j,q]=R(O);return w(G,I,N,H)&&!w(Y,W,N,H)&&w(D,B,j,q)})});if(z){for(const F of $){F.n.x=F.x;F.n.y=F.y;F.n.width=F.w;F.n.height=F.h};continue}u=true}if(u){dI(e,i.direction);if(!b8(f,e,t,i,r)){e.forEach((m,p)=>{const g=f[p];m.x=g.x;m.y=g.y;m.width=g.width;m.height=g.height})}}}function JM(e,t,n,i,r,o){const s=Co(i.edges);const a=new Map(e.map(d=>[d.id,d]));const l=!or("APL_NO_CORANK_FANIN");const c=(d,u,f=false)=>{if(d.length<2||d.length>6)return void 0;const h=d[0].style;if(d.some(y=>y.style!==h))return void 0;if(!f&&d.some(y=>y.label))return void 0;const m=d.map(y=>y[u]);if(new Set(m).size!==m.length)return void 0;const p=m.map(y=>a.get(y)).filter(y=>!!y);if(p.length!==m.length)return void 0;const g=u==="source"?y=>gn.has(y.shape):y=>y.shape==="rectangle";if(!p.every(y=>g(y)&&!zn(y,n)))return void 0;if(!ac(p,i.direction,28))return void 0;for(let y=0;y<p.length;y++)for(let b=0;b<p.length;b++){if(y!==b&&s(p[y].id,p[b].id))return void 0}return p};for(let d=0;d<3;d++){const u=new Map;const f=new Map;for(const x of t){if(!co(x,a,i.direction))continue;if(!u.has(x.source))u.set(x.source,[]);u.get(x.source).push(x);if(!f.has(x.target))f.set(x.target,[]);f.get(x.target).push(x)}let h=false;const m=x=>x.reduce((k,w)=>k+Kn(w,i.direction),0)/x.length;const p=(x,k)=>k.every(w=>t.every(C=>C.source!==w.id&&(C.target!==w.id||C.source===x)));const g=(x,k)=>k.length>=2&&k.length<=3&&p(x,k);const y=1.5;const b=(x,k,w)=>{if(!x||!gn.has(x.shape)||zn(x,n))return;const C=w?m(w):void 0;const R=k?m(k):void 0;if(C!==void 0&&R!==void 0&&k.length>=4&&p(x.id,k)&&Math.abs(C-R)>y){const L=new Set(k.map(_=>_.id));const T=new Set([x.id]);const A=C-R;const $=C-Kn(x,i.direction);if(lh(L,e,t,i.direction,A,r)&&lh(T,e,t,i.direction,$,r)){o?.();ah(L,e,t,i.direction,A);if(Math.abs($)>.5)ah(T,e,t,i.direction,$);Ia("[peer-barycenter] trunk-shift",x.id,"outs by",A.toFixed(1));h=true;return}}const M=[];if(C!==void 0)M.push(C);if(R!==void 0&&!(k&&g(x.id,k)))M.push(R);if(M.length===0&&R!==void 0)M.push(R);if(M.length===0)return;const P=M.length===1?M[0]:(Math.min(...M)+Math.max(...M))/2;const E=P-Kn(x,i.direction);if(Math.abs(E)<=.5)return;const v=new Set([x.id]);if(!lh(v,e,t,i.direction,E,r))return;Ia("[peer-barycenter] center",x.id,"by",E.toFixed(1),M.length===2?"(mixed)":"");o?.();ah(v,e,t,i.direction,E);h=true};const S=[...new Set([...u.keys(),...f.keys()])].sort();for(const x of S){const k=u.get(x);const w=f.get(x);const C=k?c(k,"target"):void 0;const R=w?c(w,"source",l):void 0;b(a.get(x),C,R)}if(!h)break}}function ix(e,t,n,i){const r=new Map;if(or("APL_NO_CORANK_FANIN"))return r;const o=Co(i.edges);const s=new Map(e.map(d=>[d.id,d]));const a=d=>!!d&&gn.has(d.shape)&&!zn(d,n);const l=d=>!!d&&d.shape==="rectangle"&&!zn(d,n);const c=new Map;for(const d of t){if(d.source===d.target)continue;if(!co(d,s,i.direction))continue;if(!c.has(d.target))c.set(d.target,[]);c.get(d.target).push(d)}for(const[d,u]of c){if(u.length<2||u.length>6)continue;const f=s.get(d);if(!a(f))continue;const h=u.filter(y=>!!y.label);if(h.length===0||h.length===u.length)continue;const m=u[0].style;if(u.some(y=>y.style!==m))continue;const p=u.map(y=>s.get(y.source)).filter(y=>!!y);if(p.length!==u.length)continue;if(new Set(p.map(y=>y.id)).size!==p.length)continue;if(!p.every(l))continue;if(!ac(p,i.direction,28))continue;let g=true;for(let y=0;y<p.length&&g;y++)for(let b=0;b<p.length;b++)if(y!==b&&o(p[y].id,p[b].id)){g=false;break}if(!g)continue;r.set(d,u)}return r}function QM(e,t,n,i,r,o){const s=new Map(e.map(l=>[l.id,l]));const a=_t(i.direction);for(const[l,c]of ix(e,t,n,i)){const d=s.get(l);const u=[...c].sort((R,M)=>Kn(s.get(R.source),i.direction)-Kn(s.get(M.source),i.direction));const f=u.map(R=>s.get(R.source));const h=Ft(d)[a.targetSide];const m=(a.isHorizontal?d.height:d.width)/2;const p=m*1.6;const g=Math.min(28,u.length>1?p/(u.length-1):0);let y=oy(u.length,g);const b=R=>a.isHorizontal?{x:h.x,y:h.y+R}:{x:h.x+R,y:h.y};if(!y.every(R=>Ai(d,b(R))))y=y.map(()=>0);const S=a.isHorizontal?a.sourceSide==="E"?Math.max(...f.map(R=>R.x+R.width)):Math.min(...f.map(R=>R.x)):a.sourceSide==="S"?Math.max(...f.map(R=>R.y+R.height)):Math.min(...f.map(R=>R.y));const x=a.isHorizontal?h.x:h.y;const k=S+(x-S)/2;const w=[];let C=true;for(let R=0;R<u.length;R++){const M=u[R];const P=f[R];const E=Ft(P)[a.sourceSide];const v=b(y[R]);const L=Vs(E,v,i.direction,k);if(!ci(L,e,new Set([M.source,M.target]))){C=false;break}w.push({edge:M,points:L})}if(!C)continue;for(const{edge:R,points:M}of w){R.points=M;R.routeCertificate=void 0}ko(w.map(R=>R.edge),r);iu(w,e,i.direction,o,true)}}function ZM(e,t,n,i,r){const o=Co(i.edges);const s=new Map(e.map(u=>[u.id,u]));const a=new Map;for(const u of t){if(!co(u,s,i.direction))continue;if(!a.has(u.source))a.set(u.source,[]);a.get(u.source).push(u)}const l=u=>t.filter(f=>f.target===u&&co(f,s,i.direction)).length;const c=u=>t.filter(f=>f.source===u&&f.target!==u&&co(f,s,i.direction));const d=(u,f)=>{const h=[];const m=new Set(f);const p=[u];while(p.length>0){const g=p.shift();if(m.has(g.id))continue;m.add(g.id);h.push(g);for(const y of c(g.id)){const b=s.get(y.target);if(!b||m.has(b.id))continue;if(l(b.id)===1)p.push(b)}}return h};for(const[u,f]of a){if(f.length!==3)continue;const h=s.get(u);if(!h||h.shape!=="diamond"||zn(h,n))continue;const m=[...f].sort((C,R)=>Kn(s.get(C.target),i.direction)-Kn(s.get(R.target),i.direction));const p=m.map(C=>s.get(C.target)).filter(C=>!!C);if(p.length!==m.length)continue;if(!p.every(C=>C.shape==="rectangle"&&!zn(C,n)))continue;if(!ac(p,i.direction,28))continue;let g=true;for(let C=0;C<p.length;C++)for(let R=0;R<p.length;R++){if(C!==R&&o(p[C].id,p[R].id))g=false}if(!g)continue;const y=p.map(C=>c(C.id));if(!y.every(C=>C.length===1))continue;const b=y[0][0].target;if(!y.every(C=>C[0].target===b))continue;const S=s.get(b);if(!S||zn(S,n))continue;const x=new Set(p.map(C=>C.id));for(const C of d(S,x))x.add(C.id);if([...x].some(C=>{const R=s.get(C);return!R||zn(R,n)}))continue;const k=(Kn(p[0],i.direction)+Kn(p[p.length-1],i.direction))/2;const w=Kn(h,i.direction)-k;if(Math.abs(w)<=.5)continue;if(!lh(x,e,t,i.direction,w,r))continue;Ia("[fork-rejoin] center",h.id,"peer island by",w.toFixed(1));ah(x,e,t,i.direction,w)}}function ek(e,t,n,i){if(!i.edges.some(Q=>(Q.length??1)>1))return;const r=Ea(i);const o=_t(i.direction);const s=new Map(e.map(Q=>[Q.id,Q]));const a=new Map;const l=Q=>{for(const K of Q){a.set(K.id,K);l(K.children)}};l(n);const c=(Q,K)=>{for(const Z of Q.nodeIds)K.push(Z);for(const Z of Q.children)c(Z,K)};const d=Q=>{if(s.has(Q))return[Q];const K=ql(i.subgraphs,Q);if(!K)return[];const Z=[];c(K,Z);return Z};const u=new Map;const f=(Q,K)=>{for(const Z of Q){const se=[...K,Z.id];for(const oe of Z.nodeIds)u.set(oe,se);f(Z.children,se)}};f(i.subgraphs,[]);const h=(Q,K)=>{if(a.has(K))return d(K);const Z=u.get(K)??[];const se=new Set(u.get(Q)??[]);if(a.has(Q))se.add(Q);for(const oe of Z)if(!se.has(oe))return d(oe);return[K]};const m=Q=>{const K=i.edges[Q];if(r[Q]==="feedback")return{source:K.target,target:K.source};return{source:K.source,target:K.target}};const p=Q=>{const K=s.get(Q);if(K)return{start:K[o.main],size:hd(K,i.direction)};const Z=a.get(Q);if(Z)return{start:Z[o.main],size:o.main==="x"?Z.width:Z.height};return null};const g=Q=>{const K=p(Q);return K?o.sign===1?K.start:K.start+K.size:null};const y=Q=>{const K=p(Q);return K?o.sign===1?K.start+K.size:K.start:null};const b=(Q,K)=>{const Z=y(Q),se=g(K);return Z!==null&&se!==null&&(se-Z)*o.sign>0};const S=new Map;for(let Q=0;Q<i.edges.length;Q++){const K=m(Q);if(!b(K.source,K.target))continue;for(const Z of d(K.source))for(const se of d(K.target)){if(!S.has(Z))S.set(Z,[]);S.get(Z).push(se)}}const x=new Map;const k=new Set;const w=(Q,K)=>{if(Math.abs(K)<.5)return;const Z=new Set;const se=[...Q];while(se.length>0){const oe=se.pop();if(Z.has(oe))continue;Z.add(oe);const de=s.get(oe);if(de){const xe=de[o.main];de[o.main]+=K;if(de[o.main]!==xe)k.add(de);x.set(oe,(x.get(oe)??0)+K)}for(const xe of S.get(oe)??[])se.push(xe)}};const C=new Map;const R=Q=>{let K=Infinity,Z=Infinity,se=-Infinity,oe=-Infinity;const de=ql(i.subgraphs,Q.id);for(const xe of de?.nodeIds??[]){const Me=s.get(xe);if(!Me)continue;K=Math.min(K,Me.x);Z=Math.min(Z,Me.y);se=Math.max(se,Me.x+Me.width);oe=Math.max(oe,Me.y+Me.height)}for(const xe of Q.children){K=Math.min(K,xe.x);Z=Math.min(Z,xe.y);se=Math.max(se,xe.x+xe.width);oe=Math.max(oe,xe.y+xe.height)}return Number.isFinite(K)?{x:K,y:Z,r:se,b:oe}:null};const M=Q=>{for(const Z of Q.children)M(Z);const K=R(Q);if(K)C.set(Q.id,{l:K.x-Q.x,t:K.y-Q.y,r:Q.x+Q.width-K.r,b:Q.y+Q.height-K.b})};const P=Q=>{for(const se of Q.children)P(se);const K=R(Q);const Z=C.get(Q.id);if(!K||!Z)return;Q.x=K.x-Z.l;Q.y=K.y-Z.t;Q.width=K.r+Z.r-Q.x;Q.height=K.b+Z.b-Q.y};for(const Q of n)M(Q);const E=(Q,K)=>{const Z=Math.min(Q.x+Q.width,K.x+K.width)-Math.max(Q.x,K.x);const se=Math.min(Q.y+Q.height,K.y+K.height)-Math.max(Q.y,K.y);return Z>.5&&se>.5};const v=(Q,K)=>Q.id<K.id?`${Q.id}\0${K.id}`:`${K.id}\0${Q.id}`;const L=new Set;for(let Q=0;Q<e.length;Q++)for(let K=Q+1;K<e.length;K++){if(E(e[Q],e[K]))L.add(v(e[Q],e[K]))}const T=new Map;const A=(Q,K)=>{const Z=e[Q],se=e[K],oe=Q*e.length+K;const de=v(Z,se);if(L.has(de)||!E(Z,se))T.delete(oe);else if(!T.has(oe))T.set(oe,{a:Z,b:se,key:de,index:oe})};const $=()=>{if(!k.size)return;if(k.size>e.length/2){for(let Q=0;Q<e.length;Q++)for(let K=Q+1;K<e.length;K++)A(Q,K)}else{for(let Q=0;Q<e.length;Q++){if(!k.has(e[Q]))continue;for(let K=0;K<e.length;K++){if(Q===K||K<Q&&k.has(e[K]))continue;A(Math.min(Q,K),Math.max(Q,K))}}}k.clear()};for(let Q=0;Q<i.edges.length;Q++){const K=i.edges[Q];const Z=m(Q);const se=K.length??1;if(se<=1)continue;if(!b(Z.source,Z.target))continue;const oe=y(Z.source),de=g(Z.target);if(oe===null||de===null)continue;const xe=(de-oe)*o.sign;const Me=Rp(se,ni.layerSpacing);if(xe<Me)w(h(Z.source,Z.target),(Me-xe)*o.sign)}if(!k.size)return;$();const _=(Q,K)=>{const Z=new Set(u.get(K)??[]);for(const se of u.get(Q)??[])if(!Z.has(se))return d(se);return[Q]};for(let Q=0;Q<e.length*4;Q++){let K;for(const Ce of T.values()){if(!K||Ce.key<K.key||Ce.key===K.key&&Ce.index<K.index)K=Ce}if(!K)break;const{a:Z,b:se}=K;const oe=(af(Z,i.direction)-af(se,i.direction))*o.sign;const[de,xe]=(oe!==0?oe>0:Z.id>se.id)?[se,Z]:[Z,se];const Me=o.sign===1?de[o.main]+hd(de,i.direction)+ni.nodeSpacing-xe[o.main]:xe[o.main]+hd(xe,i.direction)+ni.nodeSpacing-de[o.main];w(_(xe.id,de.id),o.sign===1?Me:-Me);$()}const z=new Map;for(const[Q,K]of a)z.set(Q,{start:K[o.main],size:o.main==="x"?K.width:K.height});for(const Q of n)P(Q);const F=10;const G=Q=>Kn(Q,i.direction)+Eo(Q,i.direction)/2;const I=Q=>Kn(Q,i.direction)-Eo(Q,i.direction)/2;const D=Math.max(...e.map(G))+F;const B=Math.min(...e.map(I))-F;const Y=(Q,K)=>o.main==="x"?{x:Q,y:K}:{x:K,y:Q};const W=(Q,K)=>{const Z=s.get(Q);if(Z)return Ft(Z)[K];const se=a.get(Q);if(!se)return null;const oe=se.x+se.width/2,de=se.y+se.height/2;switch(K){case"E":return{x:se.x+se.width,y:de};case"W":return{x:se.x,y:de};case"S":return{x:oe,y:se.y+se.height};default:return{x:oe,y:se.y}}};const O=Q=>{for(const K of a.values()){if(K.concurrencyRegion||K.width===0)continue;const Z=K.headerHeight??K.height;if(!Number.isFinite(Z)||Z<0)return false;if(Z===0||K.width<=0)continue;for(let se=1;se<Q.length;se++){const oe=Q[se-1],de=Q[se];if(Math.max(oe.x,de.x)>K.x&&Math.min(oe.x,de.x)<K.x+K.width&&Math.max(oe.y,de.y)>K.y&&Math.min(oe.y,de.y)<K.y+Z)return false}}return true};const N=Q=>{const K=new Set;for(const oe of e){K.add(oe[Q]);K.add(oe[Q]+(Q==="x"?oe.width:oe.height))}for(const oe of a.values()){const de=oe.concurrencyRegion?0:oe.headerHeight??oe.height;if(!(de>0&&Number.isFinite(de)&&oe.width>0))continue;K.add(oe[Q]);K.add(oe[Q]+(Q==="x"?oe.width:de))}const Z=[...K].sort((oe,de)=>oe-de);const se=[];for(let oe=1;oe<Z.length;oe++)if(Z[oe]-Z[oe-1]>2)se.push((Z[oe]+Z[oe-1])/2);if(Q===o.cross&&a.size&&Z.length>0){se.push(Z[0]-F,Z.at(-1)+F)}return se};const H=o.main==="x"?"y":"x";const j=(Q,K)=>[...Q].sort((Z,se)=>Math.abs(Z-K)-Math.abs(se-K)||Z-se).slice(0,16);const q=new Map;const X=(Q,K)=>{for(const Z of Q){q.set(Z.id,K);X(Z.children,Z.id)}};X(i.subgraphs);const V=(Q,K)=>{if((u.get(K)??[]).includes(Q))return true;for(let Z=q.get(K);Z!==void 0;Z=q.get(Z))if(Z===Q)return true;return false};const ee=(Q,K)=>{for(const Z of[K.source,K.target]){const se=s.get(Z);if(!se)continue;for(let oe=1;oe<Q.length;oe++)if(Ii(Q[oe-1],Q[oe],se))return false}return true};const re=Q=>{const K=s.get(Q),Z=a.get(Q),se=z.get(Q);return K?x.get(Q)??0:Z&&se?Z[o.main]-se.start:void 0};const U=(Q,K)=>{const Z=s.get(Q),se=x.get(Q)??0;const oe=new Set(u.get(K)??[]);if(a.has(K))oe.add(K);const de=a.has(Q)?Q:(u.get(Q)??[]).find(xe=>!oe.has(xe));if(de&&a.has(de)){const xe=z.get(de),Me=a.get(de),Ce=d(de);const pe=Ce.length?x.get(Ce[0])??0:0;if(Ce.every(Te=>(x.get(Te)??0)===pe)&&(o.main==="x"?Me.width:Me.height)===xe.size){return{...xe,delta:Me[o.main]-xe.start}}if(!Z)return null}return Z?{start:Z[o.main]-se,size:hd(Z,i.direction),delta:se}:null};const te=Q=>{const K=U(Q.source,Q.target),Z=U(Q.target,Q.source);if(!K||!Z||Q.points.length<2)return null;const[se,oe]=K.start<=Z.start?[K,Z]:[Z,K];const de=se.start+se.size,xe=oe.start;const Me=xe-de,Ce=xe+oe.delta-(de+se.delta);const pe=K.delta===Z.delta&&Number.isFinite(K.delta);if(!pe&&!(Me>0&&Ce>0&&[de,xe,Me,Ce,se.delta,oe.delta].every(Number.isFinite)))return null;const Te=pe?1:Ce/Me;if(!(Te>0&&Number.isFinite(Te)))return null;const Fe=ge=>pe?ge+K.delta:ge<=de?ge+se.delta:ge>=xe?ge+oe.delta:de+se.delta+(ge-de)*Te;const De=Q.points.map(ge=>({...ge,[o.main]:Fe(ge[o.main])}));if(De.some(ge=>!Number.isFinite(ge.x)||!Number.isFinite(ge.y)))return null;const Be=Q.points.map(ge=>ge[o.main]).sort((ge,Re)=>ge<Re?-1:ge>Re?1:0);for(let ge=1;ge<Be.length;ge++)if(Be[ge]>Be[ge-1]&&!(Fe(Be[ge])>Fe(Be[ge-1])))return null;const me=(ge,Re)=>ge===Re||Math.abs(ge-Re)<=8*Number.EPSILON*Math.max(1,Math.abs(ge),Math.abs(Re))&&Ue(ge)===Ue(Re);for(let ge=1;ge<De.length;ge++){const Re=De[ge-1],Ie=De[ge];if(!me(Re.x,Ie.x)&&!me(Re.y,Ie.y))return null;for(const ne of e)if(Ii(Re,Ie,ne))return null}const he=re(Q.source),fe=re(Q.target);if(he===void 0||fe===void 0||De[0][o.main]!==Q.points[0][o.main]+he||De.at(-1)[o.main]!==Q.points.at(-1)[o.main]+fe)return null;if(!ae(De,Q))return null;const be=new Set([Q.source,Q.target]);return ci(De,e,be)&&O(De)?De:null};const J=(Q,K)=>{if(!K)return null;const Z=re(Q);if(Z===void 0)return null;return{...K,[o.main]:K[o.main]+Z}};const ae=(Q,K)=>{for(const[Z,se]of[[K.source,true],[K.target,false]]){const oe=s.get(Z),de=a.get(Z);const xe=oe??(de?{id:de.id,label:de.label,shape:"rectangle",x:de.x,y:de.y,width:de.width,height:de.height}:void 0);if(!xe)return false;const Me=se?Q[0]:Q.at(-1);if(!Me)return false;let Ce;for(let Fe=se?1:Q.length-2;Fe>=0&&Fe<Q.length;Fe+=se?1:-1){const De=Q[Fe];if(De.x!==Me.x||De.y!==Me.y){Ce=De;break}}if(!Ce||!Ai(xe,Me))return false;const pe=!oe&&V(Z,se?K.target:K.source);const Te=pe?{x:Me.x-(Ce.x-Me.x),y:Me.y-(Ce.y-Me.y)}:Ce;if(!Number.isFinite(Te.x)||!Number.isFinite(Te.y)||!Ns(xe,Me,Te))return false}return true};for(const Q of t){const K=Q.edgeIndex!==void 0?r[Q.edgeIndex]??"primary-forward":"primary-forward";if(K==="self-loop"){const De=x.get(Q.source)??0;if(De!==0)Q.points=Q.points.map(Be=>({...Be,[o.main]:Be[o.main]+De}));if(De!==0&&Q.labelPosition)Q.labelPosition[o.main]+=De;continue}const Z=a.size>0&&(K==="cross-hierarchy"||K==="container");const se=Z?te(Q):null;if(se){Q.points=se;if(Q.label)Q.labelPosition=sn(se);continue}if(K==="feedback"){const De=s.get(Q.source),Be=s.get(Q.target);if(!De||!Be)continue;const me=af(De,i.direction),he=af(Be,i.direction);const fe=(Ee,ke)=>[Y(me,ke(De)),Y(me,Ee),Y(he,Ee),Y(he,ke(Be))];const be=(Ee,ke,le,Se)=>[Y(me,ke(De)),Y(me,Ee),Y(le,Ee),Y(le,Se),Y(he,Se),Y(he,ke(Be))];const ge=(Ee,ke,le,Se)=>[Y(me,ke(De)),Y(me,Se),Y(le,Se),Y(le,Ee),Y(he,Ee),Y(he,ke(Be))];const Re=new Set([Q.source,Q.target]);const Ie=Ee=>ci(xt(Ee),e,Re)&&O(Ee);const ne=[[D,G],[B,I]];let we;for(const[Ee,ke]of ne){const le=fe(Ee,ke);if(Ie(le)){we=le;break}}if(!we){const Ee=j(N(o.main==="x"?"x":"y"),he);e:for(const[ke,le]of ne){const Se=j(N(H),le(Be));for(const Pe of[be,ge]){for(const Ae of Ee){for(const Ne of Se){const Oe=Pe(ke,le,Ae,Ne);if(Ie(Oe)){we=xt(Oe);break e}}}}}}Q.points=we??fe(D,G);if(Q.label)Q.labelPosition=sn(Q.points);continue}const oe=Z?J(Q.source,Q.points[0]):W(Q.source,o.sourceSide);const de=Z?J(Q.target,Q.points.at(-1)):W(Q.target,o.targetSide);if(!oe||!de)continue;const xe=new Set([Q.source,Q.target]);const Me=De=>ci(De,e,xe)&&O(De)&&(!Z||ae(De,Q)&&ee(De,Q));const Ce=Math.min(oe[o.main],de[o.main]),pe=Math.max(oe[o.main],de[o.main]);let Te=Vs(oe,de,i.direction,(Ce+pe)/2);let Fe=Me(Te);if(!Fe){let De;const Be=j(N(o.main==="x"?"x":"y").filter(me=>me>Ce&&me<pe),(Ce+pe)/2);for(const me of Be){const he=Vs(oe,de,i.direction,me);if(Me(he)){De=he;break}}if(!De){const me=oe[H],he=de[H];const fe=j(N(H),(me+he)/2);e:for(const be of fe){for(const ge of Be){for(const Re of j(Be.filter(Ie=>(Ie-ge)*o.sign>0),de[o.main])){const Ie=xt([oe,Y(ge,me),Y(ge,be),Y(Re,be),Y(Re,he),de]);if(Me(Ie)){De=Ie;break e}}}}}if(De){Te=De;Fe=true}}if(Z&&!Fe)throw new Qe([{strategy:"link-rank-reconnect",violations:[`edge ${Q.source}->${Q.target}: no proven contact-preserving route after rank move`]}]);Q.points=Te;if(Q.label)Q.labelPosition=sn(Q.points)}}function K$(e,t,n,i,r,o){let s=4e6;const a=fp(t,n,i,o,p=>(s-=p)>=0);if(!a)return false;const l=Yl({nodes:t,edges:n,groups:i},o);const c=new Set(e.map(({edge:p})=>p));const d=t.find(p=>p.id===e[0].edge.source);const u=Od(i).filter(p=>ry(d,p));const f=(p,g)=>{const y=Pt({...p,labelPosition:g},o);const b=y&&l.clearPaintRect(y,Ri(p,o.lineWidth??1),p);return!!b&&u.every(S=>b.x>S.x&&b.y>S.y&&b.x+b.w<S.x+S.width&&b.y+b.h<S.y+S.height)&&a.clear(p,g,new Map,void 0,c)};const h=()=>e.every(({edge:p})=>!p.label||!!p.labelPosition&&a.clear(p,p.labelPosition,new Map));const m=e.every(({edge:p,points:g})=>{if(!p.label)return true;if(!p.labelPosition||!f(p,p.labelPosition))return false;const y=Pt(p,o);return g.some((b,S)=>{if(!S)return false;const x=g[S-1];return x.x===b.x&&x.x>=y.x&&x.x<=y.x+y.w&&y.y>=Math.min(x.y,b.y)&&y.y+y.h<=Math.max(x.y,b.y)||x.y===b.y&&x.y>=y.y&&x.y<=y.y+y.h&&y.x>=Math.min(x.x,b.x)&&y.x+y.w<=Math.max(x.x,b.x)})});return m&&h()||iu(e,t,r,o,false,f)&&h()}function tk(e,t,n,i,r,o=[]){const s=new Map(e.map(l=>[l.id,l]));const a=new Map;for(const l of t){if(!n.has(l)||!l.label||!co(l,s,i))continue;if(!a.has(l.source))a.set(l.source,[]);a.get(l.source).push(l)}for(const l of a.values()){if(l.length<2||l.length>3)continue;if(new Set(l.map(u=>u.target)).size<l.length)continue;const c=[...l].sort((u,f)=>{const h=s.get(u.target);const m=s.get(f.target);if(!h||!m)return(u.edgeIndex??0)-(f.edgeIndex??0);return Kn(h,i)-Kn(m,i)});const d=s.get(c[0].source);if(d?.shape==="rectangle"&&zn(d,o)){const u=c.map(h=>({edge:{...h},points:h.points}));const f=new Map(c.map((h,m)=>[h,u[m].edge]));if(K$(u,e,t.map(h=>f.get(h)??h),o,i,r)){c.forEach((h,m)=>{h.labelPosition=u[m].edge.labelPosition})}}else iu(c.map(u=>({edge:u,points:u.points})),e,i,r)}}function V$(e,t){return Od(t).filter(n=>ry(e,n)).map(n=>n.id).join("\0")}function nk(e,t,n,i,r,o,s){if(t.length<2||t.length>3)return void 0;if(e.shape!=="rectangle"&&e.shape!=="diamond")return void 0;const a=e.shape!=="diamond"&&zn(e,r);const l=[...t].sort((u,f)=>Kn(i.get(u.target),o)-Kn(i.get(f.target),o));const c=l.map(u=>i.get(u.target)).filter(Boolean);if(c.length!==l.length)return void 0;const d=a?V$(e,r):"";if(!c.every(u=>u.shape==="rectangle"&&(a?V$(u,r)===d:e.shape==="diamond"||!zn(u,r))))return void 0;if(!ac(c,o,40))return void 0;if(!c.every(u=>n.every(f=>f.source!==u.id&&(f.target!==u.id||f.source===e.id))))return void 0;for(let u=0;u<c.length;u++)for(let f=0;f<c.length;f++){if(u!==f&&s(c[u].id,c[f].id))return void 0}return l}function ik(e,t,n,i,r,o){const s=Co(i.edges);const a=new Map(e.map(d=>[d.id,d]));const l=new Map;for(const d of t){if(!co(d,a,i.direction))continue;if(!l.has(d.source))l.set(d.source,[]);l.get(d.source).push(d)}const c=_t(i.direction);for(const[d,u]of l){const f=a.get(d);const h=f&&nk(f,u,t,a,n,i.direction,s);if(!f||!h)continue;const m=h.map(Y=>a.get(Y.target));const p=f.shape!=="diamond"&&zn(f,n);if(p){const{ctx:Y,axis:W}=Uo(e,t,i.direction,o,n);const O=Kn(f,i.direction);const N=h.map(H=>rf(H,f,a.get(H.target),Y,W));if(N.every((H,j)=>H!==null&&Math.abs(H-O+(N[N.length-1-j]-O))<=1))continue}const g=m.map(Y=>({t:Y,x:Y.x,y:Y.y,width:Y.width,height:Y.height}));const y=Od(n).map(Y=>({group:Y,x:Y.x,y:Y.y,width:Y.width,height:Y.height}));const b=()=>{for(const Y of g){Y.t.x=Y.x;Y.t.y=Y.y;Y.t.width=Y.width;Y.t.height=Y.height}for(const Y of y){Y.group.x=Y.x;Y.group.y=Y.y;Y.group.width=Y.width;Y.group.height=Y.height}};const S=Math.max(...m.map(Y=>Y.width));const x=Math.max(...m.map(Y=>Y.height));const k=Kn(f,i.direction);const w=Math.min(...m.map(Y=>Po(Y,i.direction)));const C=(c.isHorizontal?x:S)+28;const R=oy(m.length,C);const M=f.shape==="diamond"?h.map((Y,W)=>j0(f,i.direction,W,h.length)[c.cross]):void 0;const P=Y=>{for(let W=0;W<m.length;W++){const O=m[W];O.width=S;O.height=x;if(c.isHorizontal){O.x=w;O.y=Y[W]-x/2}else{O.x=Y[W]-S/2;O.y=w}}};if(!p)P(M??R.map(Y=>k+Y));const E=new Set(m.map(Y=>Y.id));const v=()=>{for(let Y=0;Y<m.length;Y++){const W=m[Y];if(W.x<0||W.y<0)return false;for(let O=Y+1;O<m.length;O++){if(Li(W,m[O],8))return false}}for(const Y of m){for(const W of e){if(E.has(W.id))continue;if(Li(Y,W,8))return false}}return true};let L=p||v();if(!L&&M){P(R.map(Y=>k+Y));L=v()}if(!L){b();continue}const T=c.isHorizontal?c.sourceSide==="E"?f.x+f.width:f.x:c.sourceSide==="S"?f.y+f.height:f.y;let A=c.isHorizontal?c.sign>0?Math.min(...m.map(Y=>Y.x)):Math.max(...m.map(Y=>Y.x+Y.width)):c.sign>0?Math.min(...m.map(Y=>Y.y)):Math.max(...m.map(Y=>Y.y+Y.height));const $=Math.max(0,...h.map(Y=>U$(Y,i.direction,o)));const _=(A-T)*c.sign;if(!p&&$>_+.001){const Y=$-_;const W=m.map(O=>({x:O.x,y:O.y,width:O.width,height:O.height}));for(const O of m){if(c.isHorizontal)O.x+=Y*c.sign;else O.y+=Y*c.sign}uI(n,W,i.direction,Y);L=v();if(!L){b();continue}A=c.isHorizontal?c.sign>0?Math.min(...m.map(O=>O.x)):Math.max(...m.map(O=>O.x+O.width)):c.sign>0?Math.min(...m.map(O=>O.y)):Math.max(...m.map(O=>O.y+O.height))}const z=Math.max(0,...h.map(Y=>X$(Y,i.direction,o,T,A)));const F=T+(A-T)*.5;const G=A-c.sign*z;const I=(G-F)*c.sign<0?G:F;if(p&&(I-T)*c.sign<Math.max(...h.map(Y=>Yi(o,Y,"start")))-.001)continue;const D=[];for(let Y=0;Y<h.length;Y++){const W=h[Y];const O=a.get(W.target);const N=Vs(j0(f,i.direction,Y,h.length),fI(O,i.direction),i.direction,I);if(!ci(N,e,new Set([W.source,W.target]))){L=false;break}D.push({edge:W,points:N})}if(L&&p){const Y=t.filter(O=>!u.includes(O)&&O.style!=="invisible");const W=O=>Y.reduce((N,H)=>N+xp(O,H.points),0);L=D.reduce((O,{points:N})=>O+W(N),0)<=D.reduce((O,{edge:N})=>O+W(N.points),0)}if(!L){b();continue}const B=D.map(({edge:Y,points:W})=>({edge:{...Y,points:W},points:W}));if(p&&B.some(({edge:Y})=>Y.label)){const Y=new Map(D.map(({edge:O},N)=>[O,B[N].edge]));const W=t.map(O=>Y.get(O)??O);if(!K$(B,e,W,n,i.direction,o)){b();continue}}else iu(B,e,i.direction,o);for(let Y=0;Y<D.length;Y++){const{edge:W,points:O}=D[Y];W.points=O;W.labelPosition=B[Y].edge.labelPosition;W.routeCertificate=void 0}ko(D.map(Y=>Y.edge),r)}}function Nh(e,t,n){if(e.length>_s||t.length>ka)return false;let i=_s-e.length;const r=o=>o.every(s=>--i>=0&&r(s.children));return r(n)}var ru=(e,t)=>e.points.length!==t.points.length||e.points.some((n,i)=>n.x!==t.points[i].x||n.y!==t.points[i].y);function $h(){return{remaining:_s*ka}}function wc(e,t,n,i,r,o,s=$h()){const a=e.map((m,p)=>m.x!==n[p].x||m.y!==n[p].y);const l=t.map((m,p)=>ru(m,i[p]));if(!a.some(Boolean)&&!l.some(Boolean))return true;const c=()=>--s.remaining>=0;const d=new Map;const u=m=>{if(!d.has(m))d.set(m,up(m,o,c));return d.get(m)};const f=new Map;const h=m=>{if(!f.has(m)){const p=Fr(m,{fill:m.inlineStyle?.fill??o.nodeFillColor??"var(--_node-fill)",stroke:m.inlineStyle?.stroke??o.nodeBorderColor??"var(--_node-stroke)",strokeWidth:Xn("stroke-width",m.inlineStyle?.["stroke-width"]??String(o.nodeLineWidth??et.innerBox))},o.cornerRadius);f.set(m,Pi({kind:"shape",id:m.id,role:"node",geometry:ad(p.geometry),paint:p.paint,...p.childPaints?{childPaints:p.childPaints}:{}}))}return f.get(m)};try{for(let m=0;m<e.length;m++){if(!a[m])continue;const p=h(e[m]);if(!vi(p))return false;for(let g=0;g<e.length;g++){if(g===m||a[g]&&g<m)continue;if(!c())return false;const y=h(e[g]);if(!vi(y)||Xi(p,y))return false}}for(let m=0;m<e.length;m++){const p=e[m];for(let g=0;g<t.length;g++){const y=t[g];if(!a[m]&&!l[g]||y.style==="invisible")continue;if(!c())return false;if(y.source===p.id&&bi(y,p)>bi(i[g],n[m]))return false;if(y.target===p.id&&bi(y,void 0,p)>bi(i[g],void 0,n[m]))return false;const b=u(y);if(!b)return false;const S=h(p);if(!vi(S))return false;if(y.source!==p.id&&y.target!==p.id){for(const x of b.shafts)if(!c()||Xi(S,x))return false}for(const x of b.markers){const k=x.position==="start"?y.source:y.target;if(k!==p.id&&(!c()||!vi(x.bounds)||Xi(S,x.bounds)))return false}if(b.label&&(!c()||Xi(S,b.label)))return false}}return w8(e,t,n,i,r,u,h,c)}catch{return false}}function J$(e,t){return{nodes:e.map(n=>({...n})),edges:t.map(n=>({...n,points:n.points.map(i=>({...i})),...n.labelPosition?{labelPosition:{...n.labelPosition}}:{}}))}}function Q$(e,t,n,i){e.forEach((r,o)=>{if(r.x!==n[o].x)r.x=n[o].x;if(r.y!==n[o].y)r.y=n[o].y});t.forEach((r,o)=>{const s=i[o];if(ru(s,r))r.points=s.points;if(s.labelPosition?.x!==r.labelPosition?.x||s.labelPosition?.y!==r.labelPosition?.y)r.labelPosition=s.labelPosition;if(s.routeCertificate!==r.routeCertificate)r.routeCertificate=s.routeCertificate})}function rk(e,t,n,i,r,o){if(or("APL_NO_LABELED_SOURCE_PORT"))return;if(!Nh(e,t,n))return;if(!t.some(l=>l.label))return;const s=J$(e,t);S8(s.nodes,s.edges,n,i,r,o);const a=$h();if(!wc(s.nodes,s.edges,e,t,n,o,a)){if(a.remaining<0)return;const{ctx:l,axis:c}=Uo(s.nodes,s.edges,r,o,n);for(let h=0;h<s.edges.length;h++){const m=s.edges[h];if(!m.label||!ru(m,t[h]))continue;const p=s.nodes.find(y=>y.id===m.source),g=s.nodes.find(y=>y.id===m.target);if(!p||!g||!jl(m,p,g,l,c,m.points[0][c.cross]).applied)return;Os(m,m.routeCertificate,p,g)}const d=Symbol();const u=()=>--a.remaining>=0;const f=()=>{if(!u())throw d};try{const h=Yl({...s,groups:n},o,f);const m=(p,g)=>{f();const y=Pt(p,o);if(!y)return false;const b=h.clearPaintRect(y,Ri(p,o.lineWidth??1),p);if(!b)return false;const S={x0:b.x,y0:b.y,x1:b.x+b.w,y1:b.y+b.h};for(const x of s.edges){f();const k=up(x,o,u);if(!k||k.markers.some(C=>{f();return Xi(S,C.bounds)}))return false;if(x===p)continue;if(k.shafts.some(C=>{f();return Xi(S,C)}))return false;const w=Pt(x,o);if(w){f();const C=Ri(x,o.lineWidth??1);if(Xi(S,{x0:w.x-C,y0:w.y-C,x1:w.x+w.w+C,y1:w.y+w.h+C}))return false}}return wc(s.nodes,[p],e,[g],n,o,a)};for(let p=0;p<s.edges.length;p++){f();const g=s.edges[p],y=t[p];if(!g.label||!ru(g,y)||m(g,y))continue;const b=Pt(g,o),S=g.points[0],x=g.points[1];if(!b||g.points.length!==2)return;const k=Math.hypot(x.x-S.x,x.y-S.y),w=(c.main==="x"?b.w:b.h)/2;if(!(k>2*w))return;let C=false;for(const R of fd(w/k,f)){f();g.labelPosition={x:S.x+(x.x-S.x)*R,y:S.y+(x.y-S.y)*R};if(m(g,y)){C=true;break}}if(!C)return}}catch(h){if(h===d)return;throw h}if(!wc(s.nodes,s.edges,e,t,n,o,a))return}Q$(e,t,s.nodes,s.edges)}function S8(e,t,n,i,r,o){const s=new Set;for(const[x]of ix(e,t,n,i))s.add(x);const a=r==="LR"||r==="RL";const l=a?"y":"x";const c=a?"x":"y";const d=a?r==="LR"?"E":"W":r==="BT"?"N":"S";const u=x=>a?x.height:x.width;const f=x=>x[l]+u(x)/2;const h=2;const m=[];const p=x=>{for(const k of x){m.push(k);p(k.children)}};p(n);const g=x=>m.some(k=>x.x>=k.x-.5&&x.y>=k.y-.5&&x.x+x.width<=k.x+k.width+.5&&x.y+x.height<=k.y+k.height+.5);const y=new Map(e.map(x=>[x.id,x]));const b=x=>c==="x"?d==="E"?x.x+x.width:x.x:d==="S"?x.y+x.height:x.y;const S=(x,k)=>{const w=new Set([x.id]);const C=[x.id];while(C.length){const R=C.pop();for(const M of t){if(M.target!==R||M===k)continue;const P=y.get(M.source);if(!P||w.has(P.id))continue;if(t.filter(E=>E.source===P.id).length!==1)return null;if(!gn.has(P.shape)||g(P))return null;w.add(P.id);C.push(P.id)}}return w};for(const x of t){if(!x.label||x.points.length<2||x.source===x.target)continue;if(s.has(x.target))continue;const k=y.get(x.source);if(!k||!gn.has(k.shape)||g(k))continue;if(t.some(_=>_!==x&&_.source===k.id&&_.target!==k.id))continue;if(Math.abs(x.points[0][c]-b(k))>1)continue;const w=y.get(x.target);if(!w||!gn.has(w.shape)||g(w))continue;const{ctx:C,axis:R}=Uo(e,t,r,o,n);let M=0;let P=false;const E={...k};for(let _=0;_<4;_++){const z=rf(x,E,w,C,R);if(z===null)break;const F=z-f(E);M+=F;E[l]+=F;if(Math.abs(F)<=.5){P=true;break}}if(!P||Math.abs(M)<=1)continue;const v=S(k,x);if(!v)continue;const L=[...v].map(_=>y.get(_)).filter(Boolean);const T=_=>({x:a?_.x:_.x+M,y:a?_.y+M:_.y,width:_.width,height:_.height});const A=e.some(_=>!v.has(_.id)&&L.some(z=>{const F=T(z);return F.x-h<_.x+_.width&&F.x+F.width+h>_.x&&F.y-h<_.y+_.height&&F.y+F.height+h>_.y}));if(A)continue;const $=t.some(_=>!v.has(_.source)&&!v.has(_.target)&&L.some(z=>{const F=T(z);return _.points.some((G,I)=>{if(I===0)return false;const D=_.points[I-1];return Math.max(G.x,D.x)>F.x+.5&&Math.min(G.x,D.x)<F.x+F.width-.5&&Math.max(G.y,D.y)>F.y+.5&&Math.min(G.y,D.y)<F.y+F.height-.5})}));if($)continue;for(const _ of L){if(a)_.y+=M;else _.x+=M}for(const _ of t){if(v.has(_.source)&&v.has(_.target))for(const z of _.points)z[l]+=M}x.points[0]=Ft(k)[d]}}function w8(e,t,n,i,r,o,s,a){const l=e.filter((u,f)=>u.x!==n[f].x||u.y!==n[f].y);const c=t.filter((u,f)=>u.style!=="invisible"&&ru(u,i[f]));const d=u=>{if(!a())return false;if(!u.concurrencyRegion&&u.width!==0){const f=u.headerHeight??u.height;if(!Number.isFinite(u.width)||u.width<0||!Number.isFinite(f)||f<0)return false;if(f>0&&u.width>0){const h=ra({x0:u.x,y0:u.y,x1:u.x+u.width,y1:u.y+f},F1(ad({kind:"rect",x:u.x,y:u.y,width:u.width,height:f})));if(!vi(h))return false;for(const m of l){if(!a())return false;const p=s(m);if(!vi(p))return false;const g=ra(p,{x0:m.x,y0:m.y,x1:m.x+m.width,y1:m.y+m.height});if(!vi(g)||Xi(g,h))return false}for(const m of c){const p=o(m);if(!p)return false;for(const g of p.shafts)if(!a()||Xi(g,h))return false;for(const g of p.markers)if(!a()||!vi(g.bounds)||Xi(g.bounds,h))return false}}}return u.children.every(d)};return r.every(d)}function ok(e,t,n,i,r){if(!Nh(e,t,n))return;const{nodes:o,edges:s}=J$(e,t);M8(o,s,n,i,r);const a=$h();if(!wc(o,s,e,t,n,r,a)){if(a.remaining<0)return;const l=s.filter((c,d)=>ru(c,t[d]));cc(o,l,{direction:i},r);if(!wc(o,s,e,t,n,r,a))return}if(cf({nodes:o,edges:s},true)+1e-6<cf({nodes:e,edges:t},true))return;Q$(e,t,o,s)}function M8(e,t,n,i,r){const o=i==="LR"||i==="RL";const s=o?"y":"x";const a=o?"x":"y";const l=i==="LR"||i==="TD"?1:-1;const c=new Set;const d=8;const u=W=>o?W.height:W.width;const f=W=>W[s]+u(W)/2;const h=new Map(e.map(W=>[W.id,W]));const m=[];const p=W=>{for(const O of W){m.push(O);p(O.children)}};p(n);const g=W=>m.some(O=>W.x>=O.x-.5&&W.y>=O.y-.5&&W.x+W.width<=O.x+O.width+.5&&W.y+W.height<=O.y+O.height+.5);const y=(W,O,N,H,j,q,X,V)=>W<j+X&&W+N>j&&O<q+V&&O+H>q;const b=W=>o?W.width:W.height;const S=(W,O,N,H)=>e.some(j=>!H.has(j.id)&&W>j[s]-4&&W<j[s]+u(j)+4&&N>j[a]-4&&O<j[a]+b(j)+4);const x=(W,O,N,H)=>e.some(j=>!H.has(j.id)&&W>j[a]-4&&W<j[a]+b(j)+4&&N>j[s]-4&&O<j[s]+u(j)+4);const k=(W,O)=>{const N=O?W.length-1:0;const H=O?-1:1;const j=W[N][s];let q=N;while(q>=0&&q<W.length&&Math.abs(W[q][s]-j)<=.5)q+=H;if(q<0||q>=W.length)return null;const X=W[q];const V=W[q-H];return{mainPos:X[a],far:X[s],orthogonal:Math.abs(X[a]-V[a])<=.5}};const w=(W,O)=>{const N=O?W.length-1:0;const H=O?-1:1;const j=W[N][s];let q=Infinity;let X=-Infinity;for(let V=N;V>=0&&V<W.length;V+=H){if(Math.abs(W[V][s]-j)>.5)break;q=Math.min(q,W[V][a]);X=Math.max(X,W[V][a])}return{ref:j,lo:q,hi:X}};const C=(W,O,N,H,j=false)=>{const q=W.points,X=O?q.length-1:0,V=O?-1:1;const ee=O?0:q.length-1,re=q[X][s];let U=Infinity,te=-Infinity;for(let ae=X;ae>=0&&ae<q.length&&Math.abs(q[ae][s]-re)<=.5;ae+=V){if(j&&ae===ee)break;U=Math.min(U,ae);te=Math.max(te,ae)}if(te<U)return false;const J=ae=>ae>=U&&ae<=te?{...q[ae],[s]:q[ae][s]+N}:q[ae];for(let ae=Math.max(1,U);ae<=Math.min(q.length-1,te+1);ae++){if(Ii(J(ae-1),J(ae),H))return true}return false};const R=(W,O,N,H=false)=>{if(c.has(W.id)||g(W))return false;const j=h.get(N.source);const q=h.get(N.target);const X=f(W.id===N.source?q:j);const V=Math.min(j[a]+b(j)/2,q[a]+b(q)/2);const ee=Math.max(j[a]+b(j)/2,q[a]+b(q)/2);if(S(X,V,ee,new Set([N.source,N.target])))return false;for(const te of t){const J=te.source===W.id;const ae=te.target===W.id;if(!J&&!ae)continue;const Q=te===N;if(Q&&te.points.length===2&&Math.abs(te.points[0][s]-te.points[1][s])<=.5)continue;if(!Q){if(te.points.length<3)return false;const de=ae?te.points[te.points.length-1]:te.points[0];if(!te.points.some(xe=>Math.abs(xe[s]-de[s])>.5))return false}const K=new Set([te.source,te.target]);const Z=w(te.points,ae);if(S(Z.ref+O,Z.lo,Z.hi,K))return false;const se=k(te.points,ae);if(se){if(!se.orthogonal)return false;const de=Math.min(Z.ref+O,se.far);const xe=Math.max(Z.ref+O,se.far);if(x(se.mainPos,de,xe,K))return false}const oe=h.get(ae?te.source:te.target);if(oe&&oe!==W&&!(Q&&H)&&C(te,ae,O,oe))return false}const re=o?W.x:W.x+O;const U=o?W.y+O:W.y;for(const te of e){if(te===W)continue;if(y(re-d,U-d,W.width+2*d,W.height+2*d,te.x,te.y,te.width,te.height))return false}for(const te of t){if(te.source===W.id||te.target===W.id)continue;for(let J=1;J<te.points.length;J++){const ae=te.points[J-1],Q=te.points[J];if(Math.max(ae.x,Q.x)>re+.5&&Math.min(ae.x,Q.x)<re+W.width-.5&&Math.max(ae.y,Q.y)>U+.5&&Math.min(ae.y,Q.y)<U+W.height-.5)return false}}for(const te of t){if(te===N)continue;const J=Pt(te,r);if(J&&y(re-d,U-d,W.width+2*d,W.height+2*d,J.x,J.y,J.w,J.h))return false}return true};const M=(W,O,N,H=false)=>{const j=W.points;const q=O?j.length-1:0;const X=O?-1:1;const V=O?0:j.length-1;const ee=j[q][s];let re=Infinity;let U=-Infinity;for(let te=q;te>=0&&te<j.length;te+=X){if(Math.abs(j[te][s]-ee)>.5)break;if(H&&te===V)break;re=Math.min(re,j[te][a]);U=Math.max(U,j[te][a]);j[te][s]+=N}if(W.labelPosition&&Math.abs(W.labelPosition[s]-ee)<=12&&W.labelPosition[a]>=re-.5&&W.labelPosition[a]<=U+.5){W.labelPosition[s]+=N}};const P=(W,O,N)=>{if(o)W.y+=O;else W.x+=O;for(const q of t){if(q===N||q.points.length===0)continue;const X=q.source===W.id;const V=q.target===W.id;if(X&&V){for(const ee of q.points)ee[s]+=O;if(q.labelPosition)q.labelPosition[s]+=O;continue}if(V)M(q,true,O);if(X)M(q,false,O)}const H=N.points[0];const j=N.points[N.points.length-1];if(N.points.length===2&&Math.abs(H[s]-j[s])<=.5){const q=o?l>0?"E":"W":l>0?"S":"N";const X=o?l>0?"W":"E":l>0?"N":"S";N.points=[Ft(h.get(N.source))[q],Ft(h.get(N.target))[X]];if(N.labelPosition)N.labelPosition[s]=f(h.get(N.source))}else{M(N,N.target===W.id,O)}};const E=W=>{if(W.points.length<2||W.source===W.target)return false;const O=xt(W.points);for(let N=1;N<O.length;N++){if((O[N][a]-O[N-1][a])*l<-.5)return false}return true};const v=(W,O,N)=>{const H=o?W.x:W.x+O;const j=o?W.y+O:W.y;for(const q of e){if(q===W)continue;if(y(H-d,j-d,W.width+2*d,W.height+2*d,q.x,q.y,q.width,q.height))return false}for(const q of t){if(N.has(`${q.source}->${q.target}`))continue;for(let X=1;X<q.points.length;X++){const V=q.points[X-1],ee=q.points[X];if(Math.max(V.x,ee.x)>H+.5&&Math.min(V.x,ee.x)<H+W.width-.5&&Math.max(V.y,ee.y)>j+.5&&Math.min(V.y,ee.y)<j+W.height-.5)return false}}for(const q of t){if(N.has(`${q.source}->${q.target}`))continue;const X=Pt(q,r);if(X&&y(H-d,j-d,W.width+2*d,W.height+2*d,X.x,X.y,X.w,X.h))return false}return true};const L=new Set;const T=W=>t.filter(O=>O.source===W&&E(O));const A=W=>t.filter(O=>O.target===W&&E(O)).length;const $=W=>{const O=[];const N=new Set;const H=[W];while(H.length>0){const j=H.shift();if(N.has(j.id))continue;N.add(j.id);O.push(j);for(const q of T(j.id)){const X=h.get(q.target);if(!X||N.has(X.id))continue;if(A(X.id)===1)H.push(X)}}return O};const _=W=>Number(Ue(W));const z=W=>W.points.length===2&&_(W.points[0][s])===_(W.points[1][s])&&_(W.points[0][a])!==_(W.points[1][a]);const F=(W,O,N)=>{if(W.routeCertificate)return void 0;const H=h.get(W.source),j=h.get(W.target);if(!H||!j)return void 0;const q=O.has(H.id)?{...H,[s]:H[s]+N}:H;const X=O.has(j.id)?{...j,[s]:j[s]+N}:j;const V=o?l>0?"E":"W":l>0?"S":"N";const ee=o?l>0?"W":"E":l>0?"N":"S";const re=Ft(q)[V],U=Ft(X)[ee];if(![re.x,re.y,U.x,U.y].every(Number.isFinite)||_(re[s])!==_(U[s]))return void 0;if(l>0?_(re[a])>=_(U[a]):_(re[a])<=_(U[a]))return void 0;return[re,U]};const G=(W,O)=>{const N=new Set(W.map(H=>H.id));for(const H of W){const j=o?H.x:H.x+O;const q=o?H.y+O:H.y;for(const X of e){if(N.has(X.id))continue;if(y(j-d,q-d,H.width+2*d,H.height+2*d,X.x,X.y,X.width,X.height))return false}}for(const H of t){const j=N.has(H.source),q=N.has(H.target);if(j===q||H.points.length===0)continue;if(z(H)&&!F(H,N,O))return false;const X=h.get(q?H.source:H.target);if(X&&C(H,q,O,X,true))return false}return true};const I=(W,O)=>{const N=new Set(W.map(j=>j.id));const H=new Map;for(const j of t)if(N.has(j.source)!==N.has(j.target)&&z(j)){const q=F(j,N,O);if(!q)return false;H.set(j,q)}for(const j of W){if(o)j.y+=O;else j.x+=O}for(const j of t){const q=N.has(j.source);const X=N.has(j.target);if(q&&X){for(const V of j.points)V[s]+=O;if(j.labelPosition)j.labelPosition[s]+=O}else if(H.has(j)){j.points=H.get(j);if(j.labelPosition)j.labelPosition[s]=j.points[0][s]}else if(X){M(j,true,O,true)}else if(q){M(j,false,O,true)}}return true};for(const W of or("APL_NO_CENTER")?[]:e){if(c.has(W.id)||g(W)||!gn.has(W.shape))continue;const O=t.filter(J=>J.target===W.id&&J.source!==W.id&&J.points.length>=2);const N=new Map;let H=O.length>=2;for(const J of O){if(J.label||!E(J)){H=false;break}const ae=h.get(J.source);if(!ae||!gn.has(ae.shape)){H=false;break}N.set(ae.id,ae)}if(!H||N.size<2)continue;if(t.filter(J=>J.source===W.id&&J.target!==W.id&&E(J)).length>1)continue;const j=[...N.values()];const q=j.map(J=>J[a]+b(J)/2);const X=Math.max(...q)-Math.min(...q);const V=Math.max(...j.map(b));if(X>V+ni.layerSpacing*.6)continue;const ee=j.reduce((J,ae)=>J+f(ae),0)/j.length;const re=ee-f(W);if(Math.abs(re)<=.5){L.add(W.id);continue}const U=$(W);const te=new Set(t.filter(J=>J.source===W.id||J.target===W.id).map(J=>`${J.source}->${J.target}`));if(!v(W,re,te)||!G(U,re))continue;Ia("[apl] center hub",W.id,"by",re.toFixed(1),"over",j.length,"sources");if(!I(U,re))continue;for(const J of U){L.add(J.id);c.add(J.id)}for(const J of O)c.add(J.source)}const D=new Set;if(!or("APL_NO_FACET")){const W=()=>{if(o)return l>0?["NE","SE"]:["NW","SW"];return l>0?["SW","SE"]:["NW","NE"]};for(const O of e){if(O.shape!=="diamond"||c.has(O.id)||g(O))continue;const N=t.filter(Z=>Z.source===O.id&&Z.target!==O.id&&Z.points.length>=2&&E(Z));if(N.length!==2)continue;if(N.some(Z=>{const se=h.get(Z.target);return!se||!gn.has(se.shape)}))continue;if(N.some(Z=>c.has(Z.target)||L.has(Z.target)||g(h.get(Z.target))))continue;const H=[...N].sort((Z,se)=>f(h.get(Z.target))-f(h.get(se.target)));const[j,q]=W();const X=Yo(O);const V=[[H[0],j],[H[1],q]];const ee=Ft(O);const re=V.map(([Z,se])=>({edge:Z,src:{x:X[se].x,y:X[se].y},cross:X[se][s]}));const U=!o&&V[0]&&V[1]?[{edge:V[0][0],src:{x:ee.W.x,y:ee.W.y},cross:ee.W[s]},{edge:V[1][0],src:{x:ee.E.x,y:ee.E.y},cross:ee.E[s]}]:null;const te=Z=>{const se=Z.map(xe=>{const Me=h.get(xe.edge.target);const Ce=xe.cross-f(Me);return{x:o?Me.x:Me.x+Ce,y:o?Me.y+Ce:Me.y,w:Me.width,h:Me.height}});const[oe,de]=se;return!!(oe&&de&&y(oe.x-d,oe.y-d,oe.w+2*d,oe.h+2*d,de.x,de.y,de.w,de.h))};const J=Z=>Z.every(se=>{const oe=h.get(se.edge.target);const de=se.cross-f(oe);return Math.abs(de)<=.5||R(oe,de,se.edge,true)});const ae=Z=>!!Z&&J(Z)&&!te(Z);let Q;if(ae(re))Q=re;else if(ae(U))Q=U;else continue;const K=o?l>0?"W":"E":l>0?"N":"S";for(const Z of Q){const se=Z.edge;const oe=h.get(se.target);const de=Z.cross-f(oe);if(Math.abs(de)>.5){if(o)oe.y+=de;else oe.x+=de;for(const xe of t){if(xe===se)continue;const Me=xe.source===oe.id,Ce=xe.target===oe.id;if(Me&&Ce){for(const pe of xe.points)pe[s]+=de;if(xe.labelPosition)xe.labelPosition[s]+=de}else if(Ce)M(xe,true,de);else if(Me)M(xe,false,de)}}se.points=[{x:Z.src.x,y:Z.src.y},Ft(oe)[K]];if(se.labelPosition)se.labelPosition[s]=Z.cross;D.add(se);c.add(se.target)}c.add(O.id)}}if(!or("APL_NO_SVERTEX")){for(const W of t){if(D.has(W)||W.points.length<2||W.source===W.target)continue;const O=h.get(W.source);const N=h.get(W.target);if(!O||!N||N.shape!=="diamond")continue;if(c.has(O.id)||c.has(N.id)||g(O)||g(N))continue;if(!E(W)||W.label)continue;const H=N[s]+u(N)/2;const j=t.some(Z=>{if(Z===W||Z.target!==N.id||!E(Z)||Z.points.length<2)return false;const se=h.get(Z.source);if(!se)return false;return Math.abs(se[s]+u(se)/2-H)<=u(N)/2});if(!j)continue;const q=N[s]+u(N)/2;const X=O[s]+u(O)/2;const V=X>q;const ee=o?V?"S":"N":V?"E":"W";const re=Ft(N)[ee];const U=u(N)/2;if(Math.abs(X-q)<U*.5)continue;const te=re[s]-f(O);if(Math.abs(te)>.5&&!R(O,te,W,true))continue;const J=o?l>0?"E":"W":l>0?"S":"N";const ae=Ft(O)[J];const Q=Math.min(ae[a],re[a]);const K=Math.max(ae[a],re[a]);if((re[a]-ae[a])*l<=.5)continue;if(S(re[s],Q,K,new Set([O.id,N.id])))continue;Ia("[apl] svertex",W.source,"->",W.target,"into",ee,"vertex");if(Math.abs(te)>.5){if(o)O.y+=te;else O.x+=te;for(const Z of t){if(Z===W)continue;const se=Z.source===O.id,oe=Z.target===O.id;if(se&&oe){for(const de of Z.points)de[s]+=te;if(Z.labelPosition)Z.labelPosition[s]+=te}else if(oe)M(Z,true,te);else if(se)M(Z,false,te)}}W.points=[{x:Ft(O)[J].x,y:Ft(O)[J].y},{x:re.x,y:re.y}];D.add(W);c.add(O.id);c.add(N.id)}}let B;const Y=W=>nk(W,t.filter(O=>O.source===W.id&&co(O,h,i)),t,h,n,i,B??=Co(t))!==void 0;for(const W of t){if(D.has(W))continue;if(W.points.length<2||W.source===W.target)continue;const O=h.get(W.source);const N=h.get(W.target);if(!O||!N)continue;if(!gn.has(O.shape)||!gn.has(N.shape))continue;if(L.has(N.id))continue;if(O.shape==="diamond"&&t.some(q=>q!==W&&q.source===W.source&&E(q)))continue;const H=f(O)-f(N);if(Math.abs(H)<=.5)continue;if(!E(W)||xt(W.points).length>4)continue;const j=R(N,H,W)?N:!Y(O)&&R(O,-H,W)?O:null;if(j){Ia("[apl] slide",j.id,"by",(j===N?H:-H).toFixed(1),"for",W.source,"->",W.target);P(j,j===N?H:-H,W);c.add(W.source);c.add(W.target)}}}function k8(e,t,n,i=2){const r=n.x-i,o=n.x+n.w+i,s=n.y-i,a=n.y+n.h+i;if(Math.abs(e.x-t.x)<.01){const l=Math.min(e.y,t.y),c=Math.max(e.y,t.y);return e.x>=r&&e.x<=o&&c>=s&&l<=a}if(Math.abs(e.y-t.y)<.01){const l=Math.min(e.x,t.x),c=Math.max(e.x,t.x);return e.y>=s&&e.y<=a&&c>=r&&l<=o}return false}function sk(e,t,n){for(const i of n){if(i===e)continue;for(let r=1;r<i.points.length;r++){if(k8(i.points[r-1],i.points[r],t))return true}}return false}function Z$(e,t){for(let n=1;n<e.length;n++)for(let i=1;i<t.length;i++){const r=e[n-1],o=e[n],s=t[i-1],a=t[i];const l=(o.x-r.x)*(a.y-s.y)-(o.y-r.y)*(a.x-s.x);if(Math.abs(l)<1e-9)continue;const c=((s.x-r.x)*(a.y-s.y)-(s.y-r.y)*(a.x-s.x))/l;const d=((s.x-r.x)*(o.y-r.y)-(s.y-r.y)*(o.x-r.x))/l;if(c>.001&&c<.999&&d>.001&&d<.999)return true}return false}function C8(e,t,n,i,r,o,s=(r+1)/(o+1),a=s){const l=_t(n);if(l.isHorizontal){const m={x:l.sourceSide==="E"?e.x+e.width:e.x,y:e.y+e.height*s};const p={x:l.targetSide==="W"?t.x:t.x+t.width,y:t.y+t.height*a};const g=Math.min(28,Math.max(14,Math.abs(p.x-m.x)*.18));const y=m.x+l.sign*g;const b=p.x-l.sign*g;return xt([m,{x:y,y:m.y},{x:y,y:i},{x:b,y:i},{x:b,y:p.y},p])}const c={x:e.x+e.width*s,y:l.sourceSide==="S"?e.y+e.height:e.y};const d={x:t.x+t.width*a,y:l.targetSide==="N"?t.y:t.y+t.height};const u=Math.min(28,Math.max(14,Math.abs(d.y-c.y)*.18));const f=c.y+l.sign*u;const h=d.y-l.sign*u;return xt([c,{x:c.x,y:f},{x:i,y:f},{x:i,y:h},{x:d.x,y:h},d])}function ak(e,t,n,i,r,o){const s=new Map(e.map(c=>[c.id,c]));const a=_t(i.direction);const l=new Map;for(const c of t){if(c.source===c.target||!c.label)continue;const d=s.get(c.source);const u=s.get(c.target);if(!d||!u||!gn.has(d.shape)||!gn.has(u.shape))continue;if(zn(d,n)||zn(u,n))continue;const f=`${c.source}\0${c.target}`;if(!l.has(f))l.set(f,[]);l.get(f).push(c)}for(const c of l.values()){c.sort((S,x)=>(S.edgeIndex??0)-(x.edgeIndex??0));if(c.length!==2)continue;const d=s.get(c[0].source);const u=s.get(c[0].target);const f=c.map(S=>Io(S,{x:0,y:0},o));const h=f.map(S=>S.width);const m=f.map(S=>S.height);const p=(a.isHorizontal?Math.max(...m):Math.max(...h))/2+18;const g=[p,p+16,p+32,p+52];const y=[[1/3,2/3],[1/6,1/3],[2/3,5/6]];const b=g.map(S=>({lanes:a.isHorizontal?[Math.min(d.y,u.y)-S,Math.max(d.y+d.height,u.y+u.height)+S]:[Math.min(d.x,u.x)-S,Math.max(d.x+d.width,u.x+u.width)+S],sourceSlots:y[0],targetSlots:y[0]}));if(d.shape==="diamond")for(const S of[...b]){for(const x of y)for(const k of y){const w=k.map(R=>u[a.cross]+Eo(u,i.direction)*R);const C=x.map(R=>d[a.cross]+Eo(d,i.direction)*R);for(const R of[S.lanes,[S.lanes[0],w[1]],[w[0],S.lanes[1]],[S.lanes[0],C[1]],[C[0],S.lanes[1]]]){b.push({lanes:R,sourceSlots:x,targetSlots:k})}}}for(const{lanes:S,sourceSlots:x,targetSlots:k}of b){const w=[];let C=true;for(let R=0;R<c.length;R++){const M=c[R];const P=xt(si(si(C8(d,u,i.direction,S[R],R,c.length,x[R],k[R]),d,true),u,false));if(!Ai(d,P[0])||!Ai(u,P.at(-1))){C=false;break}if(!ci(P,e,new Set([d.id,u.id]))){C=false;break}w.push({edge:M,points:P,label:UM(P)})}if(!C)continue;if(d.shape==="diamond"){const R=t.filter(E=>!c.includes(E));if(Z$(w[0].points,w[1].points)||w.some(E=>R.some(v=>Z$(E.points,v.points))))continue;const M=w.map(E=>{const v=[...R,...w.filter(L=>L!==E).map(L=>({...L.edge,points:L.points}))];return nu(E.edge,E.points,e,i.direction,o).filter(L=>!sk(E.edge,{x:L.box.x,y:L.box.y,w:L.box.width,h:L.box.height},v))});let P;for(const E of M[0]){const v=M[1].find(L=>!Li(E.box,L.box,Fh(o)));if(v){P=[E,v];break}}if(!P)continue;w[0].label=P[0].point;w[1].label=P[1].point}for(const R of w){const M=Io(R.edge,R.label,o);if(d.shape!=="diamond"&&sk(R.edge,{x:M.x,y:M.y,w:M.width,h:M.height},t))C=false}if(!C||rx(t,w,o)!==true)continue;for(const{edge:R,points:M,label:P}of w){R.points=M;R.labelPosition=P;R.routeCertificate=void 0}ko(w.map(R=>R.edge),r);break}}}function e_(e,t,n){const i=new Map(t.map(l=>[l.edge,l]));const r=new Set;const o=e.map((l,c)=>{const d=i.get(l);if(!d)return l;r.add(c);return{...l,points:d.points,labelPosition:d.label}});const{nodes:s,style:a}=n;return Fa({nodes:s,edges:o},a,r).total<=Fa({nodes:s,edges:e},a,r).total}function rx(e,t,n,i){const r=new Map(t.map(c=>[c.edge,c.points]));const o=new Set;const s=e.map((c,d)=>{const u=r.get(c);if(!u)return c;o.add(d);return{...c,points:u}});for(const c of o){const d=e[c],u=s[c];if(Ds(d,u.points,s,n,u))return"marker-blocked"}if(i?.labelClearance&&!e_(e,t,i.labelClearance))return false;const a=Xl(s,o)-Xl(e,o);if(!i?.allowCrossingsForOverlap)return a<=0;const l=Na(e,o)-Na(s,o);if(l<0)return false;if(a<=0)return true;return a<=l}function lk(e,t,n,i,r,o,s){const a=new Map(e.map(T=>[T.id,T]));const l=_t(i.direction);const c=14;const d=5;const u=16;const f={allowCrossingsForOverlap:true,...s?{labelClearance:{nodes:e,style:s}}:{}};const h=T=>l.isHorizontal?T.width:T.height;const m=T=>l.isHorizontal?T.height:T.width;const p=(T,A)=>l.isHorizontal?{x:T,y:A}:{x:A,y:T};const g=T=>T[l.main]+h(T);const y=T=>T[l.main];const b=l.sourceSide==="E"||l.sourceSide==="S";const S=l.targetSide==="W"||l.targetSide==="N";const x=(T,A)=>b!==A?g(T):y(T);const k=(T,A)=>S!==A?y(T):g(T);const w=new Set;const C=(T,A)=>{for(let $=1;$<T.points.length;$++){const _=T.points[$-1],z=T.points[$];const F=Math.abs(_.x-z.x)<.5;const G=Math.abs(_.y-z.y)<.5;if(!F&&!G)continue;for(let I=1;I<A.points.length;I++){const D=A.points[I-1],B=A.points[I];if(F){if(Math.abs(D.x-B.x)>=.5||Math.abs(_.x-D.x)>=1)continue;const Y=Math.min(Math.max(_.y,z.y),Math.max(D.y,B.y))-Math.max(Math.min(_.y,z.y),Math.min(D.y,B.y));if(Y>1)return true}else if(G){if(Math.abs(D.y-B.y)>=.5||Math.abs(_.y-D.y)>=1)continue;const Y=Math.min(Math.max(_.x,z.x),Math.max(D.x,B.x))-Math.max(Math.min(_.x,z.x),Math.min(D.x,B.x));if(Y>1)return true}}}return false};const R=new Map;for(const T of t){if(T.source===T.target)continue;const A=a.get(T.source);const $=a.get(T.target);if(!A||!$)continue;if(!gn.has(A.shape)||!gn.has($.shape))continue;if(zn(A,n)||zn($,n))continue;const _=(k($,false)-x(A,false))*l.sign;const z=(x(A,true)-k($,true))*l.sign;if(_<=u&&z<=u)continue;const F=`${T.source}\0${T.target}`;if(!R.has(F))R.set(F,[]);R.get(F).push(T)}const M=(T,A)=>{const $=Io(T,A,o),_=Ri(T,o.lineWidth??1);return{x:$.x-_,y:$.y-_,width:$.width+2*_,height:$.height+2*_}};const P=(T,A,$,_,z=0)=>{T.sort((V,ee)=>(V.edgeIndex??0)-(ee.edgeIndex??0));const F=a.get(T[0].source);const G=a.get(T[0].target);const I=x(F,A);const D=k(G,A);const B=T.length;if($<4)return false;const Y=T.every(V=>V.label)?Math.max($,...T.map(V=>{const ee=M(V,{x:0,y:0});return(l.isHorizontal?ee.width:ee.height)+Fh(o)})):$;const W=_==="target";const O=F[l.cross]+m(F)/2+z;const N=G[l.cross]+m(G)/2+z;const H=[];const j=[];for(let V=0;V<B;V++){const ee=O+(V-(B-1)/2)*$;const re=N+(V-(B-1)/2)*$;const U=(A?-1:1)*l.sign;let te=W?D-U*(u+V*Y):I+U*(u+V*Y);const J=Math.min(I,D),ae=Math.max(I,D);if(te<=J+4||te>=ae-4)te=(I+D)/2;H.push({edge:T[V],sCross:ee,tCross:re});j.push(te)}if(H[0].tCross-H[0].sCross>0!==W)j.reverse();const q=[];for(let V=0;V<B;V++){const{edge:ee,sCross:re,tCross:U}=H[V];const te=j[V];const J=re===U?[p(I,re),p(D,U)]:[p(I,re),p(te,re),p(te,U),p(D,U)];const ae=xt(si(si(J,F,true),G,false));if(ae.length<2||!Ai(F,ae[0])||!Ai(G,ae[ae.length-1])||!ci(ae,e,new Set([F.id,G.id]))){return false}q.push({edge:ee,points:ae,label:ee.label?UM(ae):void 0})}const X=rx(t,q,o,{allowCrossingsForOverlap:true});if(X!==true)return X;if(_!=="original"){const V=t.filter(te=>!T.includes(te));const ee=[...V,...q.map(te=>({...te.edge,points:te.points}))];const re=ee.flatMap(te=>yr(te,o)).flatMap(te=>te.bounds?[{x:te.bounds.x0,y:te.bounds.y0,width:te.bounds.x1-te.bounds.x0,height:te.bounds.y1-te.bounds.y0}]:[]);const U=V.filter(te=>te.label).map(te=>M(te,te.labelPosition??sn(te.points)));for(const te of q){if(!te.edge.label)continue;const J=[...V,...q.filter(Q=>Q!==te).map(Q=>({...Q.edge,points:Q.points}))];const ae=nu(te.edge,te.points,e,i.direction,o).find(Q=>{const K=M(te.edge,Q.point);return!e.some(Z=>Li(K,Z,2))&&!re.some(Z=>Li(K,Z,0))&&!U.some(Z=>Li(K,Z,2))&&!sk(te.edge,{x:K.x,y:K.y,w:K.width,h:K.height},J)});if(!ae)return false;te.label=ae.point;U.push(M(te.edge,te.label))}}if(f.labelClearance&&!e_(t,q,f.labelClearance))return false;for(const{edge:V,points:ee,label:re}of q){V.points=ee;V.labelPosition=re;V.routeCertificate=void 0;w.add(V)}ko(q.map(V=>V.edge),r);return true};for(const T of R.values()){if(T.length<2||!T.some(I=>I.label))continue;if(!T.some(I=>I.label&&T.some(D=>D!==I&&C(I,D))))continue;if(T.every(I=>I.label)&&Fa({nodes:[],edges:T},o).labelLabel===0)continue;const A=a.get(T[0].source);const $=a.get(T[0].target);if(!A||!$)continue;const _=!((k($,false)-x(A,false))*l.sign>u);const z=(Math.min(m(A),m($))-2*d)/(T.length-1);const F=Math.max(c,...T.filter(I=>I.label).map(I=>{const D=M(I,{x:0,y:0});return(l.isHorizontal?D.height:D.width)/2+3}));const G=(I,D)=>{const B=P(T,_,I,D);if(B===true)return true;if(B!=="marker-blocked"||!Nh(e,t,n))return false;const Y=(z-I)*(T.length-1)/2;return Y>0&&fd(0).some(W=>{const O=(2*W-1)*Y;return O!==0&&P(T,_,I,D,O)===true})};if(F<=z&&(G(F,"source")||G(F,"target")))continue;if(G(Math.min(c,z),"original"))continue;if(T.every(I=>I.label)){const I=Math.min(c/2,z);G(I,"source")||G(I,"target")||G(I,"original")}}const E=new Map;const v=new Map;for(const T of t){if(w.has(T))continue;if(T.source===T.target||T.label)continue;const A=a.get(T.source);const $=a.get(T.target);if(!A||!$)continue;if(!gn.has(A.shape)||!gn.has($.shape))continue;if(zn(A,n)||zn($,n))continue;const _=z=>{if(!z.has(T.target))z.set(T.target,[]);z.get(T.target).push(T)};if((k($,false)-x(A,false))*l.sign>u)_(E);else if((x(A,true)-k($,true))*l.sign>u)_(v)}const L=(T,A)=>{if(T.length<2)return;const $=new Map;for(const j of T)$.set(j.source,($.get(j.source)??0)+1);if(![...$.values()].some(j=>j>=2))return;const _=a.get(T[0].target);const z=k(_,A);const F=_[l.cross]+m(_)/2;const G=j=>{const q=a.get(j.source);return q[l.cross]+m(q)/2};T.sort((j,q)=>G(j)-G(q)||(j.edgeIndex??0)-(q.edgeIndex??0));const I=T.length;const D=Math.min(c,(m(_)-2*d)/(I-1));if(D<4)return;const B=new Map;for(const j of T){if(!B.has(j.source))B.set(j.source,[]);B.get(j.source).push(j)}const Y=[];const W=[];for(let j=0;j<I;j++){const q=T[j];const X=a.get(q.source);const V=x(X,A);const ee=F+(j-(I-1)/2)*D;const re=B.get(q.source);const U=re.length>1?Math.min(D,(m(X)-2*d)/(re.length-1)):0;const te=X[l.cross]+m(X)/2+(re.indexOf(q)-(re.length-1)/2)*U;let J=V+(A?-1:1)*l.sign*(u+j*D);const ae=Math.min(V,z),Q=Math.max(V,z);if(J<=ae+4||J>=Q-4)J=(V+z)/2;Y.push({edge:q,source:X,exitMain:V,sCross:te,tCross:ee});W.push(J)}for(let j=0;j<I;){let q=j;while(q+1<I&&T[q+1].source===T[j].source)q++;if(q>j&&Y[j].tCross-Y[j].sCross>0){const X=W.slice(j,q+1).reverse();for(let V=j;V<=q;V++)W[V]=X[V-j]}j=q+1}const O=j=>{const q=[];for(let X=0;X<I;X++){const{edge:V,source:ee,exitMain:re}=Y[X];const U=Y[X].sCross,te=Y[X].tCross+j;const J=W[X];let ae;if(U===te){ae=[p(re,U),p(z,te)]}else{ae=[p(re,U),p(J,U),p(J,te),p(z,te)]}ae=si(ae,ee,true);ae=si(ae,_,false);ae=xt(ae);const Q=va(ae,$s(V,o));if(!Q)return void 0;ae=Q;if(ae.length<2||!Ai(ee,ae[0])||!Ai(_,ae[ae.length-1])||!ci(ae,e,new Set([ee.id,_.id])))return void 0;q.push({edge:V,points:ae})}return q};let N=O(0);if(!N)return;const H=rx(t,N,o,f);if(H!==true){if(H!=="marker-blocked"||!Nh(e,t,n))return;let j=-Infinity,q=Infinity;for(const re of Y){j=Math.max(j,re.source[l.cross]+d-re.sCross,_[l.cross]+d-re.tCross);q=Math.min(q,re.source[l.cross]+m(re.source)-d-re.sCross,_[l.cross]+m(_)-d-re.tCross)}if(!Number.isFinite(j)||!Number.isFinite(q)||j>0||q<0)return;const X=$h();const V={...f,labelClearance:{nodes:e,style:o}};let ee;for(const re of[j,q]){if(X.remaining<=0)break;if(re===0)continue;const U=O(re);if(!U||rx(t,U,o,V)!==true)continue;const te=new Map(U.map(ae=>[ae.edge,ae.points]));const J=t.map(ae=>te.has(ae)?{...ae,points:te.get(ae)}:ae);if(!wc(e,J,e,t,n,o,X))continue;ee=U;break}if(!ee)return;N=ee}for(const{edge:j,points:q}of N){j.points=q;j.labelPosition=void 0;j.routeCertificate=void 0}ko(N.map(j=>j.edge),r)};for(const T of E.values())L(T,false);for(const T of v.values())L(T,true)}function ox(e,t,n){if(!t)return void 0;const i=n?0:e.length-1,r=n?1:-1;const o=e[i];if(!o)return false;for(let s=i+r;s>=0&&s<e.length;s+=r){const a=e[s];if(a.x!==o.x||a.y!==o.y)return Ns(t,o,a)}return false}function t_(e,t,n){const i={...e,points:e.points.filter((r,o)=>o===0||r.x!==e.points[o-1].x||r.y!==e.points[o-1].y).map(r=>({...r}))};Qu(i,t,n);if(t)i.points=si(i.points,t,true);if(n)i.points=si(i.points,n,false);return i}function ck(e,t,n,i){if(e.length<2||n===void 0&&i===void 0)return e;const r=e.map(s=>({...s}));const o=t?"x":"y";for(const[s,a,l]of[[n,0,1],[i,r.length-1,r.length-2]]){if(s===void 0)continue;const c=r[a],d=r[l];c[o]+=s;if(d[o]===c[o]-s)d[o]+=s}return r}function sx(e,t,n){if(e.length===0)return;const i=n==="LR"||n==="RL";const r=new Set;const o=new Map;for(const h of t){r.add(`${h.source}:${h.target}`);r.add(`${h.target}:${h.source}`);for(const m of new Set([h.source,h.target])){const p=o.get(m)??[];p.push(h);o.set(m,p)}}const s=new Map(e.map(h=>[h.id,h]));const a=ni.layerSpacing*.6;const l=[...e].sort((h,m)=>i?h.x-m.x:h.y-m.y);const c=[];let d=[l[0]];for(let h=1;h<l.length;h++){const m=i?l[h].x:l[h].y;const p=i?l[h-1].x:l[h-1].y;const g=m-p;const y=d.some(b=>r.has(`${b.id}:${l[h].id}`));if(g<=a&&!y){d.push(l[h])}else{c.push(d);d=[l[h]]}}c.push(d);const u=new Map;const f=(h,m)=>{const p=i?m:h.x;const g=i?h.y:m;for(const y of t){if(y.source===h.id||y.target===h.id)continue;for(let b=1;b<y.points.length;b++){const S=y.points[b-1],x=y.points[b];const k=Math.min(S.x,x.x),w=Math.max(S.x,x.x);const C=Math.min(S.y,x.y),R=Math.max(S.y,x.y);if(w>p+.5&&k<p+h.width-.5&&R>g+.5&&C<g+h.height-.5){return true}}}return false};for(const h of c){if(h.length<=1)continue;const m=h.map(w=>i?w.x:w.y);const p=Math.min(...m);const g=Math.max(...m);if(g-p<=1)continue;const y=(p+g)/2;if(h.some(w=>{const C=i?w.x:w.y;return Math.abs(y-C)>.5&&f(w,y)}))continue;const b=new Map(h.flatMap(w=>{const C=y-(i?w.x:w.y);return Math.abs(C)>.5?[[w.id,C]]:[]}));const S=new Map(h.map(w=>[w.id,{...w,...i?{x:w.x+(b.get(w.id)??0)}:{y:w.y+(b.get(w.id)??0)}}]));const x=new Set;let k=false;for(const w of b.keys()){for(const C of o.get(w)??[]){if(x.has(C)||C.style==="invisible")continue;x.add(C);const R={...C,points:ck(C.points,i,u.get(C.source),u.get(C.target))};const M={...C,points:ck(C.points,i,b.get(C.source)??u.get(C.source),b.get(C.target)??u.get(C.target))};let P,E;for(const v of[true,false]){const L=v?C.source:C.target;const T=s.get(L),A=S.get(L)??T;let $=ox(R.points,T,v),_;if($===true)_=ox(M.points,A,v);else{P??=t_(R,s.get(C.source),s.get(C.target));E??=t_(M,S.get(C.source)??s.get(C.source),S.get(C.target)??s.get(C.target));$=ox(P.points,T,v);_=ox(E.points,A,v)}if($===true&&_!==true)k=true}}}if(k)continue;for(const w of h){const C=i?w.x:w.y;const R=y-C;if(Math.abs(R)>.5){if(i){w.x=y}else{w.y=y}u.set(w.id,R)}}}if(u.size===0)return;for(const h of t){h.points=ck(h.points,i,u.get(h.source),u.get(h.target))}}function dk(e,t,n){const i=[];for(const r of n){if(e>=r.x&&e<=r.x+r.width&&t>=r.y&&t<=r.y+r.height){i.push(r);i.push(...dk(e,t,r.children))}}return i}function P8(e,t,n,i){const r=(m,p)=>{if(m!==void 0&&!/^\s*[+]?(?:\d+\.?\d*|\.\d+)(?:e[+-]?\d+)?(?:px)?\s*$/i.test(m))return void 0;const g=m===void 0?p:Number.parseFloat(m);return Number.isFinite(g)&&g>=0?Number(Ue(g)):void 0};const o=r(e.inlineStyle?.["stroke-width"],i.lineWidth*(e.style==="thick"?2:1));const s=i.edgeBendRadius;if(o===void 0||!Number.isFinite(s)||s<0)return false;const a=$n({stroke:"#000",strokeWidth:String(o)},true);if(a===void 0)return false;const l=a+s;const c=e.points.map(m=>({x:Number(Ue(m.x)),y:Number(Ue(m.y))}));if(!c.every(m=>Number.isFinite(m.x)&&Number.isFinite(m.y)))return false;const d=c.slice(1).map((m,p)=>{const g=c[p];return{x0:Math.min(g.x,m.x)-l,x1:Math.max(g.x,m.x)+l,y0:Math.min(g.y,m.y)-l,y1:Math.max(g.y,m.y)+l}});const u=(m,p)=>{const g=(Math.abs(m.x0)+Math.abs(m.x1)+Math.abs(m.y0)+Math.abs(m.y1)+Math.abs(p.x0)+Math.abs(p.x1)+Math.abs(p.y0)+Math.abs(p.y1))*1e-10+1e-9;return!Number.isFinite(g)||m.x1+g>p.x0&&m.x0<p.x1+g&&m.y1+g>p.y0&&m.y0<p.y1+g};const f=sd(e,i);if(!f||f.length!==Number(Boolean(e.hasArrowStart))+Number(Boolean(e.hasArrowEnd)))return false;for(const m of t){const p=r(m.inlineStyle?.["stroke-width"],i.nodeLineWidth);if(p===void 0)return false;const g=Fr(m,{fill:"#000",stroke:"#000",strokeWidth:String(p)},i.cornerRadius);const y=Pi(um({id:m.id,role:"node",geometry:g.geometry,paint:g.paint,...g.childPaints?{childPaints:g.childPaints}:{}}));if(!y)return false;if(m.id!==e.source&&m.id!==e.target&&d.some(b=>u(b,y)))return false;for(const b of f){const S=b.position==="start"?e.source:e.target;if(S!==m.id&&(!b.bounds||u(b.bounds,y)))return false}}const h=m=>{const p=m.concurrencyRegion?0:m.headerHeight??m.height;if(p>0){const g={x0:m.x,x1:m.x+m.width,y0:m.y,y1:m.y+p};if(d.some(y=>u(y,g))||f.some(y=>!y.bounds||u(y.bounds,g)))return false}return m.children.every(h)};return n.every(h)}function ax(e,t,n,i,r){const o=12;const s=r==="LR";const a=r==="RL";const l=r==="BT";const c=s||a;const d=new Set(dk(t,n,i).map(p=>p.id));const u=c?e:t;const f=c?n:e;const h=dk(u,f,i);const m=h.find(p=>!d.has(p.id));if(!m)return e;if(s)return m.x-o;if(a)return m.x+m.width+o;if(l)return m.y+m.height+o;return m.y-o}function uk(e,t,n,i,r){const o=new Map(t.map(p=>[p.id,p]));const s=new Set;const a=(p,g)=>{for(const[k,w]of g){const C=o.get(k.source),R=o.get(k.target);g.set(k,si(si(w,C,true),R,false))}const y=e.map(k=>g.has(k)?{...k,points:g.get(k)}:k);const b=(k,w,C)=>e.some(R=>R.source===k&&R.target===w&&R.style!=="invisible"&&Mo(C,R)&&R.hasArrowStart===C.hasArrowStart&&R.hasArrowEnd===C.hasArrowEnd&&(R.startMarker??"arrow")===(C.startMarker??"arrow")&&(R.endMarker??"arrow")===(C.endMarker??"arrow"));const S=(k,w)=>!Mo(k,w)||!b(k.source,w.target,k)||!b(w.source,k.target,w);const x=(k,w)=>{const C=e.filter(M=>M!==k);const R=new Set(_S(k,C));return _S(w,C).some(M=>!R.has(M)&&S(k,M))};return p.filter(k=>{const w=g.get(k.edge);const C=y[e.indexOf(k.edge)];return P8(C,t,n,r)&&!Ds(k.edge,w,y,r,C)&&!x(k.edge,C)})};const l=i==="LR";const c=i==="RL";const d=i==="BT";const u=l||c;const f=(p,g)=>Math.max(...p.map(({edge:y})=>Yi(r,y,g)));const h=new Map;for(const p of e){if(p.source===p.target)continue;if(!h.has(p.source))h.set(p.source,[]);h.get(p.source).push(p)}for(const[p,g]of h){if(g.length<2)continue;const y=g[0].style;if(g.some(C=>C.label||C.style!==y))continue;const b=o.get(p);if(!b)continue;const S=g.filter(C=>{const R=o.get(C.target);if(!R)return false;if(l)return R.x>b.x+b.width;if(c)return R.x+R.width<b.x;if(d)return R.y+R.height<b.y;return R.y>b.y+b.height});if(S.length<2)continue;if(new Set(S.map(C=>C.target)).size<2)continue;const x=b.x+b.width/2;const k=b.y+b.height/2;let w=S.map(C=>({edge:C,node:o.get(C.target)}));while(w.length>=2){const C=new Map;if(u){const M=l?b.x+b.width:b.x;const P=k;const E=l?Math.min(...w.map(L=>L.node.x)):Math.max(...w.map(L=>L.node.x+L.node.width));let v=lc(M,E,f(w,"start"),f(w,"end"));v=ax(v,x,k,n,i);for(const{edge:L,node:T}of w){const A=l?T.x:T.x+T.width;const $=T.y+T.height/2;C.set(L,[{x:M,y:P},{x:v,y:P},{x:v,y:$},{x:A,y:$}])}}else{const M=x;const P=d?b.y:b.y+b.height;const E=d?Math.max(...w.map(L=>L.node.y+L.node.height)):Math.min(...w.map(L=>L.node.y));let v=lc(P,E,f(w,"start"),f(w,"end"));v=ax(v,x,k,n,i);for(const{edge:L,node:T}of w){const A=T.x+T.width/2;const $=d?T.y+T.height:T.y;C.set(L,[{x:M,y:P},{x:M,y:v},{x:A,y:v},{x:A,y:$}])}}const R=a(w,C);if(R.length===w.length){for(const{edge:M}of w){M.points=C.get(M)}ko(w.map(M=>M.edge),s);break}w=R;if(new Set(w.map(M=>M.edge.target)).size<2)break}}const m=new Map;for(const p of e){if(s.has(p)||p.source===p.target)continue;if(!m.has(p.target))m.set(p.target,[]);m.get(p.target).push(p)}for(const[p,g]of m){if(g.length<2)continue;const y=g[0].style;if(g.some(C=>C.label||C.style!==y))continue;const b=o.get(p);if(!b)continue;const S=g.filter(C=>{const R=o.get(C.source);if(!R)return false;if(l)return R.x+R.width<b.x;if(c)return R.x>b.x+b.width;if(d)return R.y>b.y+b.height;return R.y+R.height<b.y});if(S.length<2)continue;if(new Set(S.map(C=>C.source)).size<2)continue;const x=b.x+b.width/2;const k=b.y+b.height/2;let w=S.map(C=>({edge:C,node:o.get(C.source)}));while(w.length>=2){const C=new Map;if(u){const M=l?b.x:b.x+b.width;const P=k;const E=l?Math.max(...w.map(L=>L.node.x+L.node.width)):Math.min(...w.map(L=>L.node.x));let v=lc(E,M,f(w,"start"),f(w,"end"));v=ax(v,x,k,n,i);for(const{edge:L,node:T}of w){const A=l?T.x+T.width:T.x;const $=T.y+T.height/2;C.set(L,[{x:A,y:$},{x:v,y:$},{x:v,y:P},{x:M,y:P}])}}else{const M=x;const P=d?b.y+b.height:b.y;const E=d?Math.min(...w.map(L=>L.node.y)):Math.max(...w.map(L=>L.node.y+L.node.height));let v=lc(E,P,f(w,"start"),f(w,"end"));v=ax(v,x,k,n,i);for(const{edge:L,node:T}of w){const A=T.x+T.width/2;const $=d?T.y:T.y+T.height;C.set(L,[{x:A,y:$},{x:A,y:v},{x:M,y:v},{x:M,y:P}])}}const R=a(w,C);if(R.length===w.length){for(const{edge:M}of w){M.points=C.get(M)}ko(w.map(M=>M.edge),s);break}w=R;if(new Set(w.map(M=>M.edge.source)).size<2)break}}return s}function lx(e,t,n=0){if(e.length<2)return e;let i=false;for(let s=1;s<e.length;s++){const a=Math.abs(e[s].x-e[s-1].x);const l=Math.abs(e[s].y-e[s-1].y);if(a>1&&l>1){i=true;break}}if(!i)return e;const r=12;const o=[e[0]];for(let s=1;s<e.length;s++){const a=o[o.length-1];const l=e[s];const c=Math.abs(l.x-a.x);const d=Math.abs(l.y-a.y);if(c>1&&d>1){if(t){const u=n%2===0;const f=Math.floor(n/2)*r;const h=u?t.rightX+f:t.leftX-f;o.push({x:h,y:a.y});o.push({x:h,y:l.y})}else{const u=(a.y+l.y)/2;o.push({x:a.x,y:u});o.push({x:l.x,y:u})}}o.push(l)}return o}function fk(e,t,n,i,r,o){const s=new Map;const a=new Map;const l=(d,u,f)=>{a.set(d.id,{x:u,y:f});for(const h of d.children??[])l(h,u+(h.x??0),f+(h.y??0))};l(e,i,r);n_(e,s,i,r,a);let c=0;for(const[d,u]of s){const f=t.edges[d];if(!f)continue;const h=[];for(const g of u.sort((y,b)=>y.order-b.order)){const y=h.at(-1);const b=y?qs([y,...g.points]).slice(1):qs(g.points);const S=b[0],x=b[1];const k=y&&S&&Math.abs(y.x-S.x)<1e-6&&Math.abs(y.y-S.y)<1e-6;const w=y&&S&&x&&(y.x===S.x&&S.x===x.x&&S.y>=Math.min(y.y,x.y)&&S.y<=Math.max(y.y,x.y)||y.y===S.y&&S.y===x.y&&S.x>=Math.min(y.x,x.x)&&S.x<=Math.max(y.x,x.x));h.push(...k||w?b.slice(1):b)}let m;if(f.label&&h.length>=2){const g=u.find(y=>y.labelPosition)?.labelPosition;m=g??sn(h)}const p=lx(h,o,c);if(p!==h){c++}if(f.label&&p!==h&&p.length>=2){m=sn(p)}n.push({source:f.source,target:f.target,...f.id!==void 0?{id:f.id}:{},label:f.label,...f.labelContent?{labelContent:f.labelContent}:{},style:f.style,hasArrowStart:f.hasArrowStart,hasArrowEnd:f.hasArrowEnd,startMarker:f.startMarker,endMarker:f.endMarker,...f.curve?{curve:f.curve}:{},...f.animate?{animate:true}:{},...f.animation?{animation:f.animation}:{},points:p,labelPosition:m,inlineStyle:Yc(d,t),...f.id&&t.classAssignments.has(f.id)?{classNames:t.classAssignments.get(f.id).split(/\s+/).filter(Boolean)}:{},edgeIndex:d})}}function n_(e,t,n,i,r){if(e.edges){for(const o of e.edges){const s=o.hierarchySegment;const a=s?.edgeIndex??parseInt(o.id.substring(1),10);if(isNaN(a))continue;const l=o.container?r.get(o.container):void 0;const c=l?.x??n,d=l?.y??i;const u=[];if(o.sections&&o.sections.length>0){const m=o.sections[0];u.push({x:m.startPoint.x+c,y:m.startPoint.y+d});if(m.bendPoints){for(const p of m.bendPoints){u.push({x:p.x+c,y:p.y+d})}}u.push({x:m.endPoint.x+c,y:m.endPoint.y+d})}let f;if(o.labels&&o.labels.length>0){const m=o.labels[0];if(m.x!=null&&m.y!=null){f={x:m.x+(m.width??0)/2+c,y:m.y+(m.height??0)/2+d}}}const h=t.get(a)??[];h.push({order:s?.order??0,points:u,labelPosition:f});t.set(a,h)}}if(e.children){for(const o of e.children){n_(o,t,n+(o.x??0),i+(o.y??0),r)}}}function l_(e,t){const n=new Set(e);const i=new Map(e.map((u,f)=>[u,f]));const r=new Map(e.map(u=>[u,new Set]));const o=new Map(e.map(u=>[u,0]));const s=(u,f)=>{const h=new Set;const m=[u];while(m.length>0){const p=m.pop();if(p===f)return true;if(h.has(p))continue;h.add(p);for(const g of r.get(p)??[])m.push(g)}return false};for(const u of t){if(u.source===u.target||!n.has(u.source)||!n.has(u.target))continue;const f=u.source;const h=u.target;const m=r.get(f);if(m.has(h))continue;if(s(h,f))continue;m.add(h);o.set(h,(o.get(h)??0)+1)}const a=(u,f)=>(i.get(u)??0)-(i.get(f)??0);const l=e.filter(u=>(o.get(u)??0)===0).sort(a);const c=u=>{let f=l.length;l.push(u);while(f>0){const h=f-1>>>1;if(a(l[h],u)<=0)break;l[f]=l[h];f=h}l[f]=u};const d=[];while(l.length>0){const u=l[0];const f=l.pop();if(l.length){let h=0;while(h*2+1<l.length){let m=h*2+1;if(m+1<l.length&&a(l[m+1],l[m])<0)m++;if(a(f,l[m])<=0)break;l[h]=l[m];h=m}l[h]=f}d.push(u);for(const h of Array.from(r.get(u)??[]).sort(a)){const m=(o.get(h)??0)-1;o.set(h,m);if(m===0){c(h)}}}if(d.length<e.length){const u=new Set(d);d.push(...e.filter(f=>!u.has(f)).sort(a))}return d}function c_(e,t,n,i,r="TB",o,s){void e;const a=s??Wn(t,i,"node");if(n==="state-fork"||n==="state-join"){const d=r==="LR"||r==="RL";const u=o?.forkWidth??70;const f=o?.forkHeight??10;return d?{width:f,height:u}:{width:u,height:f}}if(n==="state-choice"){return{width:36,height:36}}if(n==="state-history"){return{width:32,height:32}}let l=a.width+i.nodePaddingX*2;let c=a.height+i.nodePaddingY*2;if(n==="service"){l=Math.max(l+34,120);c=Math.max(c+6,48)}if(n==="diamond"){const d=Math.max(l,c)+i.diamondExtraPadding;l=d;c=d}if(n==="circle"||n==="doublecircle"){const d=Math.ceil(Math.sqrt(l*l+c*c))+8;l=n==="doublecircle"?d+12:d;c=l}if(n==="ellipse"){l=Math.ceil(l*Math.SQRT2);c=Math.ceil(c*Math.SQRT2)}if(n==="hexagon"){l+=i.nodePaddingX}if(n==="trapezoid"||n==="trapezoid-alt"||n==="lean-r"||n==="lean-l"){l+=i.nodePaddingX}if(n==="asymmetric"){l+=12}if(n==="cylinder"){c+=14}if(n==="state-start"||n==="state-end"){return{width:28,height:28}}l=Math.max(l,60);c=Math.max(c,36);return{width:l,height:c}}function d_(e,t){const n=new Map;if(or("APL_NO_CORANK_FANIN"))return n;const i=new Map;for(let r=0;r<e.edges.length;r++){const o=e.edges[r];if(o.source===o.target)continue;if(!i.has(o.target))i.set(o.target,[]);i.get(o.target).push(r)}for(const[r,o]of i){if(o.length<2)continue;const s=o.filter(f=>!!e.edges[f].label);const a=o.filter(f=>!e.edges[f].label);if(s.length===0||a.length===0)continue;const l=e.nodes.get(r)?.shape;if(l===void 0||!gn.has(l))continue;const c=f=>e.nodes.get(f)?.shape==="rectangle";if(!o.every(f=>c(e.edges[f].source)))continue;let d=0;let u=0;for(const f of s){const h=Wn(qe(e.edges[f].label,e.edges[f].labelContent),t,"edge");const m=h.text;d=Math.max(d,h.width+8);u=Math.max(u,h.height+6)}for(const f of a)n.set(f,{width:d,height:u})}return n}function gk(e){return{text:" ",width:e.width,height:e.height,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}}function E8(e,t){const n=new Map;for(let r=0;r<e.edges.length;r++){const o=e.edges[r],s=e.nodes.get(o.target);if(!s||s.shape!=="rectangle"||s.semanticShape||o.style==="invisible"||o.source===o.target)continue;const a=n.get(s.id)??{count:0,span:0,known:true};a.count++;const l=o.style==="thick"?2:1;const c=t.lineWidth*l;const d=Number.isFinite(c)&&c>0?yr({...o,curve:void 0,points:[{x:0,y:0},{x:100,y:0}],inlineStyle:Yc(r,e)},{...t,lineWidth:Number(Ue(c))/l,edgeBendRadius:0}):void 0;const u=d?.find(f=>f.position==="end");if(o.hasArrowEnd&&(!u?.bounds||!Object.values(u.bounds).every(Number.isFinite)))a.known=false;else if(u?.bounds)a.span=Math.max(a.span,u.bounds.y1-u.bounds.y0);n.set(s.id,a)}const i=new Map;for(const[r,o]of n){if(o.count<2||!o.known||o.span<=0)continue;i.set(r,{count:o.count,span:o.span})}return i}function u_(e,t){return t>Yi({})&&v8(e.edges)?{"elk.spacing.edgeNode":String(t)}:{}}function R8(e,t){let n=Yi(e);let i=0;for(const[r,o]of t.edges.entries()){if(o.style==="invisible")continue;const s={...o,inlineStyle:Yc(r,t)};const a=Yi(e,s,"start"),l=Yi(e,s,"end");n=Math.max(n,a,l);i=Math.max(i,(o.hasArrowStart?a-(e.edgeBendRadius??0):0)+(o.hasArrowEnd?l-(e.edgeBendRadius??0):0))}return{hook:n,corridor:i}}function v8(e){const t=new Map,n=new Map;for(const{source:o,target:s}of e){if(o===s)return true;t.set(o,t.get(o)??0);t.set(s,(t.get(s)??0)+1);n.set(o,[...n.get(o)??[],s])}const i=[...t].filter(([,o])=>o===0).map(([o])=>o);let r=0;for(let o=i.pop();o!==void 0;o=i.pop()){r++;for(const s of n.get(o)??[]){const a=t.get(s)-1;t.set(s,a);if(a===0)i.push(s)}}return r<t.size}function i_(e,t,n){const{hook:i,corridor:r}=R8(n,e);t={...t,layerSpacing:Math.max(t.layerSpacing??ni.layerSpacing,r),markerPortExtents:t.preserveSubgraphChildOrder||t.stateVisual?void 0:E8(e,n)};const o=new Set;const s=new Set;for(const T of e.subgraphs){s.add(T.id);g_(T,o,s)}const a=new Map;for(const T of e.edges){if(T.source!==T.target)continue;a.set(T.source,(a.get(T.source)??0)+1)}const l=Math.max(0,...a.values());if(l>4){t={...t,layerSpacing:Math.max(t.layerSpacing,t.layerSpacing+(l-4)*16)}}const c=t.disableCorankFanIn?new Map:d_(e,n);const d=D8(e.subgraphs);const u=O8(e.subgraphs);const f=B8(e.subgraphs);const h=W8(e.subgraphs);const m=z8(e.subgraphs);const p=T=>d.get(T)??h.get(T);const g=T=>f.get(T)??m.get(T)?.slice(0,-1)??[];const y=m_(e,t);const b=N8(e,s);const S=new Map;const x=new Map;let k;const w=T=>{k??=new Set([...e.nodes.keys(),...s,...[...b.byEndpoint.values()].map($=>$.portId)]);let A=T;while(k.has(A))A+="_";k.add(A);return A};const C=(T,A,$)=>{const _=w(`${T}_${$}_${A}`);const z=S.get(T)??[];z.push({id:_,direction:$});S.set(T,z);return _};const R=(T,A)=>{const $=s.has(T.source)&&g(T.target).includes(T.source);const _=s.has(T.target)&&g(T.source).includes(T.target);const z=$?m.get(T.source):g(T.source);const F=_?m.get(T.target):g(T.target);const G=a_(z,F);const I=G?z.indexOf(G)+1:0;let D=$?C(T.source,A,"in"):b.byEndpoint.get(Mc(A,"source"))?.portId??T.source;const B=_?C(T.target,A,"out"):b.byEndpoint.get(Mc(A,"target"))?.portId??T.target;let Y=0;const W=(N,H,j,q=false)=>{const X=q?$8(A,T,H,j,n,c):{id:`e${A}_internal_${Y}`,sources:[H],targets:[j]};const V={...X,id:w(X.id),hierarchySegment:{edgeIndex:A,order:Y++}};const ee=x.get(N??null)??[];ee.push(V);x.set(N??null,ee)};for(const N of z.slice(I).reverse()){const H=C(N,A,"out");W(N,D,H);D=H}const O=F.slice(I).map(N=>({scope:N,port:C(N,A,"in")}));W(G,D,O[0]?.port??B,true);for(let N=0;N<O.length;N++){const H=O[N];W(H.scope,H.port,O[N+1]?.port??B)}};const M=new Map;M.set(null,[]);for(let T=0;T<e.edges.length;T++){const A=e.edges[T];const $=p(A.source);const _=p(A.target);if($&&$===_){if(!M.has($)){M.set($,[])}M.get($).push({index:T,edge:A})}else if(!$&&!_){M.get(null).push({index:T,edge:A})}else if(!y){const z=a_(g(A.source),g(A.target));if(z){if(!M.has(z))M.set(z,[]);M.get(z).push({index:T,edge:A})}else{M.get(null).push({index:T,edge:A})}}else{R(A,T)}}const P={id:"root",layoutOptions:{"elk.algorithm":"layered","elk.direction":ma(e.direction),"elk.spacing.nodeNode":String(t.nodeSpacing),"elk.layered.spacing.nodeNodeBetweenLayers":String(t.layerSpacing),"elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":String(i),...u_(e,i),"elk.padding":`[top=${t.padding},left=${t.padding},bottom=${t.padding},right=${t.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.contentAlignment":"H_CENTER V_CENTER","elk.layered.thoroughness":String(ni.thoroughness),"elk.layered.highDegreeNodes.treatment":"true","elk.layered.highDegreeNodes.threshold":"8","elk.layered.compaction.postCompaction.strategy":"LEFT_RIGHT_CONSTRAINT_LOCKING","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.feedbackEdges":"true","elk.layered.crossingMinimization.forceNodeModelOrder":"true","elk.layered.wrapping.strategy":"OFF","elk.hierarchyHandling":y?"SEPARATE":"INCLUDE_CHILDREN"},children:[],edges:[]};const E=!t.preserveSubgraphChildOrder;const v=new Map(e.subgraphs.map(T=>[T.id,T]));const L=G8(e,o,s,u,Boolean(t.preserveSubgraphChildOrder));for(const T of L){const A=v.get(T);if(A){P.children.push(p_(A,e,t,n,i,M,S,x,b,E,c,y,e.direction));continue}const $=e.nodes.get(T);if($&&!o.has(T)&&!s.has(T)){P.children.push(h_(T,$,n,b,e.direction,t.stateVisual,t.nodeSizes?.get(T),t.markerPortExtents?.get(T)))}}for(const{index:T,edge:A}of M.get(null)){const $={id:`e${T}`,sources:[b.byEndpoint.get(Mc(T,"source"))?.portId??A.source],targets:[b.byEndpoint.get(Mc(T,"target"))?.portId??A.target]};if(A.label&&!or("APL_DECOUPLE_LABELS")){const _=Wn(qe(A.label,A.labelContent),n,"edge");const z=_.text;$.labels=[{text:z,width:_.width+8,height:_.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}else if(!A.label&&c.has(T)){$.labels=[gk(c.get(T))]}P.edges.push($)}for(const T of x.get(null)??[]){P.edges.push(T)}G$(P,e,t.layoutHints);if(y&&S.size>0)_8(P,S);return P}function Mc(e,t){return`${e}:${t}`}function T8(e){const t=new Set;const n=(i,r)=>{const o=r||i.direction!==void 0;if(o)for(const s of i.nodeIds)t.add(s);for(const s of i.children)n(s,o)};for(const i of e)n(i,false);return t}function L8(e){switch(e){case"RL":return{source:"W",target:"E"};case"BT":return{source:"N",target:"S"};case"TD":case"TB":return{source:"S",target:"N"};case"LR":default:return{source:"E",target:"W"}}}function A8(e,t){const n=L8(e);if(t==="feedback")return{source:n.target,target:n.source};return n}function r_(e){return e?.shape==="rectangle"||e?.shape==="diamond"}function I8(e){return e?.shape==="rectangle"}function F8(e){if(e.length<2)return false;if(!e.every(r=>r.routeClass==="primary-forward"&&!r.labeled))return false;const t=e[0].side;if(!e.every(r=>r.side===t))return false;const n=new Map;for(const r of e){const o=`${r.sourceId}\0${r.targetId}`;n.set(o,(n.get(o)??0)+1)}const i=[...n.values()].some(r=>r>=2);if(!i)return false;if(e.every(r=>r.endpoint==="target"))return true;if(e.every(r=>r.endpoint==="source")){return e.every(r=>(n.get(`${r.sourceId}\0${r.targetId}`)??0)>=2)}return false}function N8(e,t){const n=Ea(e);const i=new Set;const r=new Set;const o=T8(e.subgraphs);const s=new Set;for(let h=0;h<e.edges.length;h++){const m=e.edges[h];const p=n[h]??"primary-forward";if(p==="primary-forward"&&m.label)s.add(`${m.source}\0${m.target}`);if(p!=="primary-forward"){i.add(m.source);i.add(m.target)}if(p!=="primary-forward"&&p!=="feedback"){r.add(m.source);r.add(m.target)}}const a=[];const l=[];const c=h=>h.replace(/[^A-Za-z0-9_\-]/g,"_");const d=(h,m,p)=>{l.push({edgeIndex:h,routeClass:m,reason:p})};for(let h=0;h<e.edges.length;h++){const m=e.edges[h];const p=n[h]??"primary-forward";if(m.source===m.target){d(h,p,"self-loop");continue}if(t.has(m.source)||t.has(m.target)){d(h,p,"subgraph-endpoint");continue}if(!e.nodes.has(m.source)||!e.nodes.has(m.target)){d(h,p,"missing-node");continue}if(p!=="primary-forward"&&p!=="feedback"){d(h,p,"unsupported-route-class");continue}if(p==="primary-forward"&&(i.has(m.source)||i.has(m.target))){d(h,p,"unsafe-non-primary-incident");continue}if(p==="feedback"&&m.label){d(h,p,"unsupported-route-class");continue}if(p==="feedback"&&s.has(`${m.target}\0${m.source}`)){d(h,p,"labeled-reciprocal-primary");continue}if(p==="feedback"&&(!r_(e.nodes.get(m.source))||!r_(e.nodes.get(m.target)))){d(h,p,"unsupported-shape");continue}if(r.has(m.source)||r.has(m.target)){d(h,p,"unsafe-non-primary-incident");continue}if(o.has(m.source)||o.has(m.target)){d(h,p,"direction-override-node");continue}const g=A8(e.direction,p);a.push({nodeId:m.source,portId:`rp_${c(m.source)}_${h}_s`,side:g.source,edgeIndex:h,sourceId:m.source,targetId:m.target,endpoint:"source",slotIndex:0,routeClass:p,labeled:Boolean(m.label),constraint:"FIXED_SIDE"});a.push({nodeId:m.target,portId:`rp_${c(m.target)}_${h}_t`,side:g.target,edgeIndex:h,sourceId:m.source,targetId:m.target,endpoint:"target",slotIndex:0,routeClass:p,labeled:Boolean(m.label),constraint:"FIXED_SIDE"})}const u=new Map;for(const h of a){const m=u.get(h.nodeId)??[];m.push(h);u.set(h.nodeId,m)}for(const h of u.values()){h.sort((g,y)=>o_(g.side)-o_(y.side)||g.edgeIndex-y.edgeIndex||s_(g.endpoint)-s_(y.endpoint));const m=new Map;for(const g of h){const y=m.get(g.side)??0;g.slotIndex=y;m.set(g.side,y+1)}const p=I8(e.nodes.get(h[0].nodeId))&&F8(h);for(const g of h){if(p){g.constraint="FIXED_ORDER";g.orderReason="primary-duplicate-face"}else{g.constraint="FIXED_SIDE";g.orderReason=void 0}}}const f=new Map;for(const h of a)f.set(Mc(h.edgeIndex,h.endpoint),h);return{byEndpoint:f,byNode:u,relaxations:l}}function o_(e){return{N:0,E:1,S:2,W:3}[e]}function s_(e){return e==="source"?0:1}function f_(e){switch(e){case"N":return"NORTH";case"E":return"EAST";case"S":return"SOUTH";case"W":return"WEST"}}function h_(e,t,n,i,r="TB",o,s,a){const l=s??c_(e,qe(t.label,t.labelContent),t.shape,n,r,o,t.labelBlock);const c=r==="LR"||r==="RL";let d=c?l.height:l.width;if(!s&&a){const h=Math.max(a.span,Math.min(n.cornerRadius??0,(c?l.width:l.height)/2));if(!(d/(a.count+1)>h)){const m=(a.count+1)*(h+1);if(Number.isFinite(m)&&m>d)d=m}}const u={id:e,width:c?l.width:d,height:c?d:l.height,labels:[{text:t.label}]};const f=i.byNode.get(e);if(f&&f.length>0){const h=f.some(m=>m.constraint==="FIXED_ORDER")?"FIXED_ORDER":"FIXED_SIDE";u.layoutOptions={...u.layoutOptions??{},"elk.portConstraints":h};u.ports=f.map(m=>({id:m.portId,width:0,height:0,layoutOptions:{"elk.port.side":f_(m.side),"elk.port.index":String(m.slotIndex)}}))}return u}function $8(e,t,n,i,r,o){const s={id:`e${e}`,sources:[n],targets:[i]};if(t.label&&!or("APL_DECOUPLE_LABELS")){const a=Wn(qe(t.label,t.labelContent),r,"edge");const l=a.text;s.labels=[{text:l,width:a.width+8,height:a.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}else if(!t.label&&o?.has(e)){s.labels=[gk(o.get(e))]}return s}function m_(e,t){const n=i=>i.direction!==void 0||i.children.some(n);return t.separateHierarchy===true||e.subgraphs.some(n)}function _8(e,t){const n=r=>r==="RIGHT"||r==="LEFT";const i=r=>{const o=n(r.layoutOptions?.["elk.direction"]);let s=false;for(const a of r.children??[]){if(a.children===void 0)continue;if(!s&&t.has(a.id)){s=n(a.layoutOptions?.["elk.direction"])!==o||(a.ports??[]).some(l=>{const c=l.layoutOptions?.["elk.port.side"];return o?c==="NORTH"||c==="SOUTH":c==="EAST"||c==="WEST"})}i(a)}if(s&&r.layoutOptions?.["elk.layered.crossingMinimization.forceNodeModelOrder"]==="true"){r.layoutOptions["elk.layered.crossingMinimization.forceNodeModelOrder"]="false";r.layoutOptions["elk.layered.considerModelOrder.strategy"]??="NODES_AND_EDGES"}};i(e)}function yk(e,t){if(!e.label||e.concurrencyRegion||e.headerMinHeight===void 0&&e.nodeIds.length===0&&e.children.length===0)return 0;const n=Wn(qe(e.label,e.labelContent),t,"group").width;return Math.ceil((e.titleOffset??t.groupLabelPaddingX)+n+t.groupLabelPaddingX)}function xk(e,t,n=Wn(qe(e.label,e.labelContent),t,"group")){if(e.concurrencyRegion)return 0;const i=t.groupHeaderFontSize+16+n.height-n.lineHeight;if(e.headerMinHeight===void 0)return i;if(!Number.isFinite(e.headerMinHeight)||e.headerMinHeight<=0)throw new RangeError("Invalid internal group header minimum");return Math.max(i,e.headerMinHeight)}function p_(e,t,n,i,r,o,s,a,l,c,d,u,f="TB"){const h=xk(e,i);const m=e.concurrencyRegion?n.stateVisual?.dividerMargin??0:0;const p=e.direction??f;const g={"elk.algorithm":"layered","elk.padding":`[top=${h+i.groupPaddingY+m},left=${i.groupPaddingX+m},bottom=${i.groupPaddingY+m},right=${i.groupPaddingX+m}]`,"elk.edgeRouting":"ORTHOGONAL","elk.contentAlignment":"H_CENTER V_CENTER","elk.spacing.edgeEdge":"12","elk.layered.spacing.edgeEdgeBetweenLayers":"12","elk.layered.spacing.edgeNodeBetweenLayers":String(r),...u_(t,r),"elk.layered.nodePlacement.bk.fixedAlignment":"BALANCED","elk.layered.spacing.nodeNodeBetweenLayers":String(n.layerSpacing),"elk.spacing.nodeNode":String(n.nodeSpacing)};if(e.direction||u){g["elk.direction"]=ma(p)}const y=yk(e,i);if(y>0&&u){g["elk.nodeSize.constraints"]="MINIMUM_SIZE";g["elk.nodeSize.minimum"]=`(${y}, 0)`}const b={id:e.id,layoutOptions:g,labels:e.label?[{text:e.label}]:void 0,children:[],edges:[],...e.headerMinHeight!==void 0&&e.nodeIds.length===0&&e.children.length===0?{width:Math.max(y,2*i.groupPaddingX),height:h+2*i.groupPaddingY}:{}};const S=s.get(e.id)??[];if(S.length>0){const w=h>0;const C=_t(t.direction);b.ports=S.map(R=>{const M=R.direction==="in"?C.targetSide:C.sourceSide;const P=M==="N"?R.direction==="in"?"W":"E":M;return{id:R.id,...w&&(M==="N"||p==="BT")?{layoutOptions:{"elk.port.side":f_(P)}}:{}}});if(w)b.layoutOptions["elk.portConstraints"]="FIXED_SIDE"}const x=c?l_(e.nodeIds,t.edges):e.nodeIds;for(const w of x){const C=t.nodes.get(w);if(C){b.children.push(h_(w,C,i,l,p,n.stateVisual,n.nodeSizes?.get(w),n.markerPortExtents?.get(w)))}}for(const w of e.children){b.children.push(p_(w,t,n,i,r,o,s,a,l,c,d,u,p))}const k=o.get(e.id)??[];for(const{index:w,edge:C}of k){const R={id:`e${w}`,sources:[l.byEndpoint.get(Mc(w,"source"))?.portId??C.source],targets:[l.byEndpoint.get(Mc(w,"target"))?.portId??C.target]};if(C.label&&!or("APL_DECOUPLE_LABELS")){const M=Wn(qe(C.label,C.labelContent),i,"edge");const P=M.text;R.labels=[{text:P,width:M.width+8,height:M.height+6,layoutOptions:{"elk.edgeLabels.inline":"true","elk.edgeLabels.placement":"CENTER"}}]}else if(!C.label&&d.has(w)){R.labels=[gk(d.get(w))]}b.edges.push(R)}for(const w of a.get(e.id)??[]){b.edges.push(w)}return b}function g_(e,t,n){for(const i of e.nodeIds){t.add(i)}for(const i of e.children){n.add(i.id);g_(i,t,n)}}function D8(e){const t=new Map;function n(i){for(const r of i.nodeIds){t.set(r,i.id)}for(const r of i.children){n(r)}}for(const i of e){n(i)}return t}function O8(e){const t=new Map;function n(i,r){for(const o of i.nodeIds)t.set(o,r);for(const o of i.children)n(o,r)}for(const i of e)n(i,i.id);return t}function B8(e){const t=new Map;function n(i,r){const o=[...r,i.id];for(const s of i.nodeIds)t.set(s,o);for(const s of i.children)n(s,o)}for(const i of e)n(i,[]);return t}function W8(e){const t=new Map;function n(i,r){t.set(i.id,r);for(const o of i.children)n(o,i.id)}for(const i of e)n(i,void 0);return t}function z8(e){const t=new Map;function n(i,r){const o=[...r,i.id];t.set(i.id,o);for(const s of i.children)n(s,o)}for(const i of e)n(i,[]);return t}function a_(e,t){let n;for(let i=0;i<Math.min(e.length,t.length);i++){if(e[i]!==t[i])break;n=e[i]}return n}function G8(e,t,n,i,r){const o=[];const s=new Set;const a=u=>{if(s.has(u))return;s.add(u);o.push(u)};const l=()=>{for(const u of e.nodes.keys()){const f=i.get(u);if(f)a(f);else if(!t.has(u)&&!n.has(u))a(u)}};const c=()=>{for(const u of e.subgraphs)a(u.id)};if(r){c();l()}else{l();c()}const d=e.edges.map(u=>({source:i.get(u.source)??u.source,target:i.get(u.target)??u.target}));return l_(o,d)}function hk(e,t=false){const n=new Set;for(const i of e){if(i.source===i.target||t&&!i.label)continue;const r=JSON.stringify([i.source,i.target]);if(n.has(r))return true;n.add(r)}return false}function H8(e){const t=e.nodes.map(i=>({node:i,x:i.x,y:i.y}));const n=e.edges.map(i=>({edge:i,points:i.points.map(r=>({...r})),labelPosition:i.labelPosition?{...i.labelPosition}:void 0}));return()=>{for(const{node:i,x:r,y:o}of t){i.x=r;i.y=o}for(const{edge:i,points:r,labelPosition:o}of n){i.points=r;i.labelPosition=o}}}var j8=[{id:"extractEdgesRecursively",doc:"flatten ELK edges to absolute coords (+orthogonalize cross-hierarchy)",after:[],mutates:["extract"],determinism:"pure-order",run:e=>{if(e.elkResult)fk(e.elkResult,e.graph,e.edges,0,0,e.margins);dx(e,e.style)}},{id:"alignLayerNodes",doc:"snap same-layer nodes onto a shared flow-axis line",after:["extractEdgesRecursively"],mutates:["positions","edges"],determinism:"in-place",enabled:e=>Boolean(e.elkResult)||e.mergeEdges,mayChangeMetrics:{bends:"improve-only",straight:"improve-only"},run:e=>{sx(e.nodes,e.edges,e.graph.direction)}},{id:"equalizePeerNodeDimensions",doc:"equalize peer box sizes + pack layers so symmetry is visible downstream",after:["alignLayerNodes"],mutates:["positions","dimensions"],determinism:"in-place",enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{KM(e.nodes,e.edges,e.groups,e.graph,e.style)}},{id:"alignForkRejoinPeerCenters",doc:"center fork/rejoin hubs on their peer barycenter",after:["equalizePeerNodeDimensions"],mutates:["positions"],determinism:"in-place",mayChangeMetrics:{symErr:"improve-only",bends:{worsenBy:2}},enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{ZM(e.nodes,e.edges,e.groups,e.graph,e.style)}},{id:"alignPortLanes",doc:"slide one endpoint node so a floating-straight edge becomes port-exact (Ruegg GD15)",after:["alignForkRejoinPeerCenters"],mutates:["positions","edges"],determinism:"in-place",enabled:e=>Boolean(e.elkResult),mayChangeMetrics:{straight:"improve-only",portRate:"improve-only",bends:"improve-only"},run:e=>{ok(e.nodes,e.edges,e.groups,e.graph.direction,e.style)}},{id:"centerPeerBarycenters",proposal:true,doc:"center peer fan-in/fan-out trunks over peer barycenters (#57/#61)",after:["alignPortLanes"],mutates:["positions"],determinism:"in-place",mayChangeMetrics:{symErr:"improve-only",bends:{worsenBy:2}},enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{let t;JM(e.nodes,e.edges,e.groups,e.graph,e.style,()=>{t??=H8(e)});return t}},{id:"honorLinkRankDistance",doc:"shove target sub-DAG to honor variable-length link rank distance; push ahead anything the shove lands on and rebuild blocked reconnect routes through free channels (#81)",after:["centerPeerBarycenters"],mutates:["positions"],determinism:"in-place",enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{ek(e.nodes,e.edges,e.groups,e.graph)}},{id:"alignLabeledSourcePort",doc:"slide a single-outgoing labelled source onto the lane the straightener will use so the exit stays mid-port (alignPortLanes excludes labelled edges)",after:["honorLinkRankDistance"],mutates:["positions","edges"],determinism:"in-place",mayChangeMetrics:{portRate:"improve-only"},enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{rk(e.nodes,e.edges,e.groups,e.graph,e.graph.direction,e.style)}},{id:"bundleEdgePaths",doc:"bundle fan-out/fan-in edges into shared trunks (when mergeEdges)",after:["alignLabeledSourcePort"],mutates:["edges"],determinism:"pure-order",enabled:e=>e.mergeEdges,run:e=>{e.bundled=uk(e.edges,e.nodes,e.groups,e.graph.direction,e.style);e.genericBundled=e.bundled.size>0}},{id:"markCorankFanInBundles",doc:"re-route + mark co-ranked mixed-label fan-in spokes bundle-owned (justified symmetric-convergence bend)",after:["bundleEdgePaths"],mutates:["edges"],determinism:"in-place",enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{QM(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style)}},{id:"clipEdgeToShape",doc:"clip edge endpoints to real (non-rect) shape outlines",after:["bundleEdgePaths"],mutates:["edges"],determinism:"in-place",mayChangeMetrics:{portRate:{worsenBy:1,whenImproves:"endpointApproaches"},endpointApproaches:"improve-only"},run:e=>{const t=new Map(e.nodes.map(n=>[n.id,n]));for(const n of e.edges){const i=e.bundled.has(n)?zl(n):void 0;n.points=n.points.filter((s,a,l)=>a===0||s.x!==l[a-1].x||s.y!==l[a-1].y);const r=t.get(n.source);const o=t.get(n.target);Qu(n,r,o);if(r)n.points=si(n.points,r,true);if(o)n.points=si(n.points,o,false);La(n,i)}}},{id:"applySymmetricFanoutEmissions",doc:"re-route small equivalent fan-outs symmetrically; mark bundle-owned",after:["clipEdgeToShape"],mutates:["edges"],determinism:"in-place",mayChangeMetrics:{symErr:"improve-only",bends:{worsenBy:2}},enabled:e=>Boolean(e.elkResult)||e.mergeEdges,run:e=>{ik(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style)}},{id:"applySymmetricParallelEdgeLanes",doc:"separate parallel edges into symmetric non-crossing lanes",after:["clipEdgeToShape"],mutates:["edges"],determinism:"in-place",enabled:e=>(Boolean(e.elkResult)||e.mergeEdges)&&hk(e.edges,true),mayChangeMetrics:{symErr:"improve-only",crossings:"improve-only"},run:e=>{ak(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style)}},{id:"applyParallelDuplicateLanes",doc:"split exact duplicate edges into separated lanes",after:["clipEdgeToShape"],mutates:["edges"],determinism:"in-place",enabled:e=>(Boolean(e.elkResult)||e.mergeEdges)&&hk(e.edges),mayChangeMetrics:{crossings:{worsenBy:1,whenImproves:"parallelOverlaps",perImprovement:true},parallelOverlaps:"improve-only"},run:e=>{lk(e.nodes,e.edges,e.groups,e.graph,e.bundled,e.style,e.elkResult?void 0:e.style)}},{id:"collapseTinyBundledHitches",doc:"remove sub-perceptual hitches introduced by bundling",after:["applySymmetricFanoutEmissions","applySymmetricParallelEdgeLanes","applyParallelDuplicateLanes"],mutates:["edges"],determinism:"in-place",mayChangeMetrics:{bends:"improve-only"},run:e=>{Y0(e.nodes,e.edges,e.bundled)}},{id:"reassignBundledSiblingLabels",doc:"re-home labels onto the correct bundled sibling segment",after:["collapseTinyBundledHitches"],mutates:["edges"],determinism:"in-place",run:e=>{tk(e.nodes,e.edges,e.bundled,e.graph.direction,e.style,e.groups)}},{id:"applyRouteContracts",doc:"classify -> simplify -> straighten (fixed-point) -> certify; FREEZES node geometry",after:["reassignBundledSiblingLabels"],mutates:["edges"],determinism:"fixed-point",freezesNodes:true,mayChangeMetrics:{straight:{worsenBy:1,whenImproves:["hard","crossings","endpointApproaches"],perImprovement:true},bends:{worsenBy:4,whenImproves:["hard","crossings","endpointApproaches"],perImprovement:true},portRate:{worsenBy:1,whenImproves:["hard","crossings","bends","endpointApproaches","opposingOverlaps"]}},run:e=>{kp({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.bundled,e.style,e.elkResult?void 0:{preserveSelfLoops:true,preserveLabels:true,preserveStraightRoutes:true})}},{id:"reanchorOffOutlineEndpoints",doc:"re-route an edge whose endpoint dangles off a moved node onto that node's flow port (edge-only, freeze-safe)",after:["applyRouteContracts"],mutates:["edges"],determinism:"in-place",run:e=>{cc(e.nodes,e.edges,e.graph,e.style)}},{id:"rerouteEdgesThroughNodes",doc:"re-route an edge left running through a node by a node-mover (honorLinkRankDistance/alignPortLanes) around the obstacle and restore protected marker leads before label placement (edge-only, freeze-safe)",after:["reanchorOffOutlineEndpoints"],mutates:["edges"],determinism:"in-place",run:e=>{Lo(e.nodes,e.edges,e.graph,void 0,e.groups);Pp({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"repairLabelsOnSharedTrunks",doc:"re-slot a labeled edge whose pill sits on a trunk shared with another edge (label-only, freeze-safe)",after:["rerouteEdgesThroughNodes"],mutates:["edges"],determinism:"in-place",run:e=>{qR({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"repairLabelsOffOwnRoute",doc:"re-slot a labeled edge whose pill sits off its OWN route onto it \u2014 ELK offset placement on an already-straight edge (label-only, freeze-safe)",after:["repairLabelsOnSharedTrunks"],mutates:["edges"],determinism:"in-place",run:e=>{Cp({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"separateEdgeLabelPills",doc:"slide colliding edge-label pills along their own routes into clear slots \u2014 parallel/reciprocal lane labels stack at midpoints (label-only, freeze-safe)",after:["repairLabelsOffOwnRoute"],mutates:["edges"],determinism:"in-place",run:e=>{sf({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style,e.elkResult?void 0:{preserveRouteClearance:true})}},{id:"closeRouteContracts",doc:"re-prove settled final routes and re-certify only auditor-proven hitches; each scan monotonically removes bends (edge-only)",after:["separateEdgeLabelPills"],mutates:["edges"],determinism:"fixed-point",mayChangeMetrics:{straight:"improve-only",bends:"improve-only"},run:e=>{Ep({nodes:e.nodes,edges:e.edges,groups:e.groups},e.graph,e.style)}},{id:"translateGeometryToNonNegativeOrigin",doc:"shift whole graph to a non-negative origin (allowed after freeze)",after:["closeRouteContracts"],mutates:["translate"],determinism:"in-place",run:e=>{ef(e.nodes,e.edges,e.groups,e.layoutPadding,e.style)}},{id:"placeStateNotes",doc:"place state-diagram note boxes on their declared side, clear of nodes/groups/routes (state diagrams only; translate-only)",after:["translateGeometryToNonNegativeOrigin"],mutates:["translate"],determinism:"in-place",enabled:e=>Boolean(e.graph.stateNotes?.length),run:e=>{e.notes=U8(e.nodes,e.edges,e.groups,e.graph,e.style,e.layoutPadding,e.stateNoteMargin)}}];function dx(e,t){for(const i of e.nodes){i.labelBlock??=Wn(qe(i.label,i.labelContent),t,"node");if(i.icon&&!i.iconFallbackBlock&&!ol(i.icon))i.iconFallbackBlock=_e(rl(i.icon),{fontSize:10,fontWeight:400})}for(const i of e.edges)if(i.label!==void 0)i.labelBlock??=Wn(qe(i.label,i.labelContent),t,"edge");const n=i=>{i.labelBlock??=Wn(qe(i.label,i.labelContent),t,"group");i.headerHeight=xk(i,t,i.labelBlock);i.children.forEach(n)};e.groups.forEach(n)}function Y8(e,t){const n={nodes:e.nodes,edges:e.edges,groups:e.groups,width:0,height:0};return ov(e.graph,n,t,e.style,e.bundled)}var ou=6;var q8=10;var X8=8;function U8(e,t,n,i,r,o,s){const a=i.stateNotes??[];if(a.length===0)return[];const l=[];const c=p=>{for(const g of p){l.push(g);c(g.children)}};c(n);const d=[];for(const p of e)d.push({x:p.x,y:p.y,w:p.width,h:p.height});for(const p of l)d.push({x:p.x,y:p.y,w:p.width,h:p.height});for(const p of t){if(p.style==="invisible")continue;for(let y=1;y<p.points.length;y++){const b=p.points[y-1],S=p.points[y];d.push({x:Math.min(b.x,S.x)-2,y:Math.min(b.y,S.y)-2,w:Math.abs(b.x-S.x)+4,h:Math.abs(b.y-S.y)+4})}const g=p.label?Pt(p,r):null;if(g)d.push(g)}const u=(p,g)=>p.x<g.x+g.w&&p.x+p.w>g.x&&p.y<g.y+g.h&&p.y+p.h>g.y;const f=[];for(const p of a){const g=e.find(R=>R.id===p.target);const y=g?void 0:l.find(R=>R.id===p.target);const b=g??y;if(!b)continue;const S=Wn(qe(p.text,p.textContent),r,"note");const x=S.width+q8*2;const k=S.height+X8*2;const w=b.y+(b.height-k)/2;let C=p.side==="left"?b.x-s-x:b.x+b.width+s;for(let R=0;R<d.length+f.length+4;R++){const M={x:C-ou,y:w-ou,w:x+ou*2,h:k+ou*2};const P=d.find(E=>u(M,E))??f.map(E=>({x:E.x,y:E.y,w:E.width,h:E.height})).find(E=>u(M,E));if(!P)break;C=p.side==="left"?P.x-ou-x:P.x+P.w+ou}f.push({id:p.id,target:p.target,side:p.side,text:p.text,...p.textContent?{textContent:p.textContent}:{},textBlock:S,x:C,y:w,width:x,height:k})}let h=0;let m=0;for(const p of f){h=Math.min(h,p.x);m=Math.min(m,p.y)}if(h<0||m<0){const p=h<0?-h+o:0;const g=m<0?-m+o:0;const y=b=>{b.x+=p;b.y+=g;b.children.forEach(y)};for(const b of e){b.x+=p;b.y+=g}for(const b of n)y(b);for(const b of t){for(const S of b.points){S.x+=p;S.y+=g}if(b.labelPosition){b.labelPosition.x+=p;b.labelPosition.y+=g}}for(const b of f){b.x+=p;b.y+=g}}return f}function _h(e,t,n=false,i=ni.padding,r=Xe({}),o=18){const s=[];const a=[];const l=[];const c=new Set;for(const d of t.subgraphs){x_(d,c)}mk(e,t,c,s,l,0,0);return y_({width:e.width??800,height:e.height??600,nodes:s,edges:a,groups:l},t,n,i,r,o,e)}function y_(e,t,n,i,r,o,s,a){const{nodes:l,edges:c,groups:d}=e;const u=vp(d);const f=u.length>0?{leftX:Math.min(...u.map(b=>b.x))-20,rightX:Math.max(...u.map(b=>b.right))+20}:void 0;const h={elkResult:s,graph:t,nodes:l,edges:c,groups:d,notes:[],margins:f,bundled:new Set,genericBundled:false,mergeEdges:n,style:r,layoutPadding:i,stateNoteMargin:o,frozen:false};if(a)for(const b of a)h.bundled.add(c[b]);dx(h,r);vR(h,j8,{measureMetrics:Y8});let m=e.width;let p=e.height;const g=bn.width;const y=i;for(const b of l){m=Math.max(m,b.x+b.width+y);p=Math.max(p,b.y+b.height+y)}for(const b of vp(d)){m=Math.max(m,b.right+y);p=Math.max(p,b.bottom+y)}for(const b of c){for(const x of b.points){m=Math.max(m,x.x+g+y);p=Math.max(p,x.y+g+y)}const S=b.labelBlock?Pt(b,r):null;if(S){m=Math.max(m,b.labelPosition.x+60+y,S.x+S.w+y);p=Math.max(p,b.labelPosition.y+20+y,S.y+S.h+y)}}for(const b of h.notes){m=Math.max(m,b.x+b.width+y);p=Math.max(p,b.y+b.height+y)}return{genericBundled:h.genericBundled,positioned:{width:m,height:p,nodes:l,edges:c,groups:d,...h.notes.length>0?{notes:h.notes}:{}}}}function mk(e,t,n,i,r,o,s){if(!e.children)return;for(const a of e.children){const l=(a.x??0)+o;const c=(a.y??0)+s;const d=a.width??0;const u=a.height??0;if(n.has(a.id)){const f=[];mk(a,t,n,i,f,l,c);const h=ql(t.subgraphs,a.id);const m=h?.stateComposite?Db(a.id,t):void 0;r.push({id:a.id,label:h?.label??"",...h?.labelContent?{labelContent:h.labelContent}:{},x:l,y:c,width:d,height:u,children:f,...h?.headerMinHeight===void 0?{}:{headerMinHeight:h.headerMinHeight},...h?.concurrencyRegion?{concurrencyRegion:true}:{},...m?{inlineStyle:m}:{}})}else{const f=t.nodes.get(a.id);if(f){const h=_b(a.id,t);const m=t.classAssignments.get(a.id);const p=m?m.split(/\s+/).filter(Boolean):void 0;i.push({id:a.id,label:f.label,...f.labelContent?{labelContent:f.labelContent}:{},...f.labelBlock?{labelBlock:f.labelBlock}:{},shape:f.shape,...f.floatingNoteId!==void 0?{floatingNoteId:f.floatingNoteId}:{},...f.semanticShape!==void 0?{semanticShape:f.semanticShape}:{},x:l,y:c,width:d,height:u,inlineStyle:h,classNames:p,...f.icon?{icon:f.icon}:{},...f.image?{image:f.image}:{},...f.iconForm?{iconForm:f.iconForm}:{},...f.href?{href:f.href}:{}})}if(a.children&&a.children.length>0){mk(a,t,n,i,r,l,c)}}}}function x_(e,t){t.add(e.id);for(const n of e.children){x_(n,t)}}function ux(e,t={}){wm(e);const n=K8(e,t);const i=Xe(t,t.stateVisual?.styleDefaults,t.styleFace);dx(n,i);const r=tn(t.diagramTitle,Xe(t,t.stateVisual?.styleDefaults,t.styleFace));if(!r)return n;const o=t.padding??ni.padding;if(n.width===0&&n.height===0)return Object.assign(n,da(r,o));V8(n,r.height);n.height+=r.height;n.width=Math.max(n.width,r.width+2*o);n.title=rn(r,n.width,o);const s=JS(n,i);if(s.length)throw new Qe([{strategy:"final-title-projection",violations:s}]);return n}function b_(e,t={}){wm(e);const n=pk(e,t,"placement");dx({...n,edges:[]},Xe(t,void 0,t.styleFace));return n}function S_(e,t={}){wm(e);const n=Xe(t,void 0,t.styleFace);return iI(e,t,n,w_)}function V8(e,t){const n=i=>{i.y+=t;for(const r of i.children)n(r)};for(const i of e.nodes)i.y+=t;for(const i of e.groups)n(i);for(const i of e.edges){for(const r of i.points)r.y+=t;if(i.labelPosition)i.labelPosition.y+=t}for(const i of e.notes??[])i.y+=t}function Dh(e,t,n,i=false){const r=t.stateVisual;const o={...ni,...t,...r?{stateVisual:r}:{}};const s=Xe(t,r?.styleDefaults,t.styleFace);const a=i_(e,o,s);if(i&&!r){const g=XM(e,a,o.padding,o.nodeSpacing,o.layerSpacing);if(!g)throw new Error("Graph is ineligible for indexed forest layout");const y=_h(g,e,ni.mergeEdges,o.padding,s,18);if(y.genericBundled){n?.(y.positioned,()=>_h(g,e,false,o.padding,s,18).positioned)}return y.positioned}if(e.nodes.size===1&&e.edges.length===0&&e.subgraphs.length===0&&!e.stateNotes?.length&&!r&&a.children?.length===1){const g=a.children[0];const y={...a,width:g.width+2*o.padding,height:g.height+2*o.padding,children:[{...g,x:o.padding,y:o.padding}]};return _h(y,e,ni.mergeEdges,o.padding,s,18).positioned}const l=[{},{"elk.layered.feedbackEdges":"false"},{"elk.layered.feedbackEdges":"false","elk.layered.compaction.postCompaction.strategy":"NONE"},{"elk.layered.feedbackEdges":"false","elk.layered.compaction.postCompaction.strategy":"NONE","elk.layered.crossingMinimization.forceNodeModelOrder":"false","elk.layered.highDegreeNodes.treatment":"false"}];let c;let d;let u="exception";let f=0;for(const g of l){if(++f>1)pl("elk-degradation",u,f);const y=Object.keys(g).length===0?a:i_(e,o,s);if(Object.keys(g).length>0){y.layoutOptions={...y.layoutOptions,...g}}try{const b=Ha(y);if(cx(b)){d=new Error("ELK returned non-finite layout geometry");u="non-finite-geometry";continue}c=b;break}catch(b){if(b instanceof Ps||b instanceof Ei)throw b;d=b;u="exception"}}if(!c)throw d;const h=c;const m=r?.noteMargin??18;const p=_h(h,e,ni.mergeEdges,o.padding,s,m);if(p.genericBundled){n?.(p.positioned,()=>_h(h,e,false,o.padding,s,m).positioned)}return p.positioned}var w_={edgeSelectorIndices:Ad,graphEdgeMarkerPaintRegions:yr,customTextMeasurementActive:Gr,certifyCandidate:QS,retainSelection:ZS,countEdgeCrossings:Xl,countOpposingRouteOverlaps:Xo,countParallelRouteOverlaps:Na,measureLabelConflicts:Fa,DEFAULTS:ni,LABEL_PILL_PADDING:on,measureRenderStage:ei,graphTextBlock:Wn,resolveLabelContent:qe,groupTitleWidth:yk,groupHeaderHeight:xk,estimateNodeSize:c_,resolveNodeInlineStyle:_b,resolveEdgeInlineStyle:Yc,resolveClassInlineStyle:Db,containsNonFiniteNumber:cx,finishGraphGeometry:y_,unsupported:e=>{throw new bo(e)}};function K8(e,t){if(!t.graphLayout)return pk(e,t);return Vr(t,()=>{const n=Xe(t,t.stateVisual?.styleDefaults,t.styleFace);return nI(e,t,n,w_)},()=>pk(e,t),true,(n,i)=>{n.layoutDecision=i})}function pk(e,t,n){const i=Xe(t,t.stateVisual?.styleDefaults,t.styleFace);const r=f=>M_(f.groups,e,i);const o=t.compareRoutePreferences!==false;const s=new WeakMap;const a=o&&Ca(e)&&!hk(e.edges)?(f,h)=>{s.set(f,h)}:void 0;const l=e.subgraphs.length>0&&!m_(e,t);const c=[{strategy:"default",produce:()=>Dh(e,t,a),preferNext:r}];const d=(t.nodeSpacing??ni.nodeSpacing)>0&&(t.layerSpacing??ni.layerSpacing)>0;const u=t.graphLayout===void 0&&Ic("indexed-layout")&&d&&!t.stateVisual&&!t.preserveSubgraphChildOrder&&qM(e)?{strategy:"indexed-forest",produce:()=>Dh(e,t,a,true),preferNext:r}:void 0;if(!t.separateHierarchy){c.push({strategy:"separate-hierarchy",produce:()=>Dh(e,{...t,separateHierarchy:true},a),preferNext:r,qualityAlternative:o&&l})}if(!t.disableCorankFanIn&&!or("APL_NO_CORANK_FANIN")){c.push({strategy:"without-corank",produce:()=>Dh(e,{...t,disableCorankFanIn:true},a),preferNext:r,qualityAlternative:o&&d_(e,i).size>0});if(!t.separateHierarchy)c.push({strategy:"separate-without-corank",produce:()=>Dh(e,{...t,separateHierarchy:true,disableCorankFanIn:true},a),preferNext:r,qualityAlternative:o&&l})}if(n==="placement")return dv(e,i,c,u);return uv(e,i,c,(f,h)=>{const m=s.get(f);if(!m||h.edgeCrossings===0&&h.labelConflicts===0)return void 0;return{strategy:"without-generic-bundling",produce:m,preferNext:r}},u)}function M_(e,t,n){return e.some(i=>{const r=ql(t.subgraphs,i.id);return r!==void 0&&i.width+.5<yk(r,n)||M_(i.children,t,n)})}function cx(e,t=new Set){if(typeof e==="number")return!Number.isFinite(e);if(e===null||typeof e!=="object")return false;if(t.has(e))return false;t.add(e);if(Array.isArray(e))return e.some(n=>cx(n,t));return Object.values(e).some(n=>cx(n,t))}var bk=16;var Pr=18;var k_=6;var Oh=18;var Mk=600;var C_=20;var J8=40;function T_(e,t={},n){Cm(e);const i=n??Mb(un);const r=(S,x)=>_e(S,{display:"formatted",transform:i[`${x}TextTransform`],fontSize:i[`${x}FontSize`],fontWeight:i[`${x}FontWeight`],letterSpacing:i[`${x}LetterSpacing`],fontFamily:x==="group"?i.groupFont:void 0});const o=new Map(e.services.map(S=>[S.id,r(S.label,"service")]));const s=new Map(e.groups.map(S=>[S.id,r(S.label,"group")]));const a=e.edges.map(S=>S.label===void 0?void 0:r(S.label,"edge"));const l=_P(e);const c=t.architecture?.visual?.groupHeaderHeight;if(c!==void 0&&(!Number.isFinite(c)||c<=0))throw new RangeError("Invalid Architecture group-header minimum");const d=c===void 0?void 0:Math.max(Pr,i.groupPaddingY);const u=2*(i.junctionOuterRadius??un.junctionOuterRadius);for(const[S,x]of o)l.nodes.get(S).label=x.text;const f=new Map(e.services.filter(S=>S.iconText!==void 0).map(S=>[S.id,_e(S.iconText,{display:"literal",fontSize:i.serviceFontSize,fontWeight:700})]));for(const[S,x]of f){const k=o.get(S);l.nodes.get(S).labelBlock={...k,width:k.width+x.width+(x.width?10:0),height:Math.max(k.height,x.height)}}const h=S=>{S.label=s.get(S.id).text;if(c!==void 0)S.headerMinHeight=c;S.children.forEach(h)};l.subgraphs.forEach(h);l.edges.forEach((S,x)=>{S.label=a[x]?.text});const m={nodeSizes:new Map(e.junctions.map(S=>[S.id,{width:u+2*k_,height:u+2*k_}])),padding:t.padding??40,nodeSpacing:t.nodeSpacing??Am,layerSpacing:t.layerSpacing??wb,compareRoutePreferences:false,styleFace:n?{node:{fontSize:n.serviceFontSize,fontWeight:n.serviceFontWeight,letterSpacing:n.serviceLetterSpacing,textTransform:void 0,paddingX:n.servicePaddingX,paddingY:n.servicePaddingY,cornerRadius:n.serviceCornerRadius,lineWidth:n.serviceLineWidth},edge:{fontSize:n.edgeFontSize,fontWeight:n.edgeFontWeight,letterSpacing:n.edgeLetterSpacing,textTransform:void 0,lineWidth:n.edgeLineWidth,bendRadius:n.edgeBendRadius},group:{fontSize:n.groupFontSize,fontWeight:n.groupFontWeight,letterSpacing:n.groupLetterSpacing,fontFamily:n.groupFont,textTransform:void 0,paddingX:n.groupPaddingX,paddingY:n.groupPaddingY,cornerRadius:n.groupCornerRadius,lineWidth:n.groupLineWidth}}:void 0};const p=new Map(e.services.map(S=>[S.id,S]));const g=new Map(e.groups.map(S=>[S.id,S]));const y=new Map(e.junctions.map(S=>[S.id,S]));const b=(S,x)=>{const k=[];const w=[];const C=new Map;const R=new Map;for(const B of S.nodes){if(p.has(B.id)){const Y=p.get(B.id);const W={x:B.x,y:B.y,width:B.width,height:B.height,id:Y.id,label:Y.label,labelBlock:o.get(Y.id),...Y.iconText!==void 0?{iconText:Y.iconText,iconTextBlock:f.get(Y.id)}:{},iconFallbackBlock:YM(Y.icon,i.serviceIconSize??un.serviceIconSize),icon:Y.icon,parentId:Y.parentId};k.push(W);C.set(B.id,W)}else if(y.has(B.id)){const Y=y.get(B.id);const W={x:B.x+(B.width-u)/2,y:B.y+(B.height-u)/2,width:u,height:u,id:Y.id,parentId:Y.parentId};w.push(W);R.set(B.id,W)}}const M=new Map(e.services.map((B,Y)=>[B.id,Y]));k.sort((B,Y)=>{const W=Number(Boolean(B.parentId))-Number(Boolean(Y.parentId));return W||(M.get(B.id)??0)-(M.get(Y.id)??0)});Q8(e,k,w,t.nodeSpacing??Am);const P=new Map;const E=S.groups.map(B=>L_(B,g,P));for(const B of P.values()){B.labelBlock=s.get(B.id);B.iconFallbackBlock=YM(B.icon,i.iconSize??un.iconSize)}Bh(E,k,w,e.alignments.length>0,d);let v;const L=Z8(e,k,w,P,t.nodeSpacing??Am,p,g,y,C,R,x?B=>{v=B}:void 0,d);if(L){Bh(E,k,w,true,d)}if(e.alignments.length){const B=new Map([...k,...w].map(W=>[W.id,W]));const Y=e.alignments.flatMap(W=>{const O=W.members.map(N=>{const H=B.get(N);return W.axis==="row"?H.y+H.height/2:H.x+H.width/2});return Math.max(...O)-Math.min(...O)<=Qt?[]:[`${W.axis} alignment lost for ${W.members.join(", ")}`]});if(Y.length)throw new Qe([{strategy:"architecture-final-alignments",violations:Y}])}const T=()=>e.edges.map(B=>eU(B,p,C,R,P,k,R,{start:B.hasArrowStart?eu("architecture-arrow-start",i.edgeLineWidth,"start"):0,end:B.hasArrowEnd?eu("architecture-arrow-end",i.edgeLineWidth,"end"):0},i.edgeBendRadius));let A=T();if(v)A=Zg(e,k,A,T,v,B=>{const Y=B.map(({points:W})=>({points:W,style:"solid",source:"",target:"_"}));return Xo(Y)||Na(Y)});A.forEach((B,Y)=>{B.labelBlock=a[Y]});iU(A,k,n);const $=e.title?_e(e.title,{display:"formatted",transform:n?.groupTextTransform,fontSize:Oh,fontWeight:Mk,safeFont:true}):void 0;const _=$?.text;const z=$?$.height-($.lineHeight-$.fontSize):0;let F=S.width;let G=S.height;if(e.alignments.length>0||L){F=Math.max(80,...k.map(B=>B.x+B.width+40),...w.map(B=>B.x+B.width+40),...E.map(B=>B.x+B.width+40));G=Math.max(80,...k.map(B=>B.y+B.height+40),...w.map(B=>B.y+B.height+40),...E.map(B=>B.y+B.height+40))}if(_){F=Math.max(F,$.width+J8*2);const B=C_-Oh/2;const Y=Math.min(...k.map(N=>N.y),...w.map(N=>N.y),...[...P.values()].map(N=>N.y));const W=Math.max(0,B+z+11-Y);const O=N=>{N.y+=W;N.children.forEach(O)};E.forEach(O);for(const N of k)N.y+=W;for(const N of w)N.y+=W;for(const N of A){for(const H of N.points)H.y+=W;if(N.labelPosition)N.labelPosition.y+=W}G=Math.max(G+W,B+z+20)}for(const B of A){for(const Y of B.points){F=Math.max(F,Y.x+40);G=Math.max(G,Y.y+40)}if(B.labelPosition){F=Math.max(F,B.labelPosition.x+72);G=Math.max(G,B.labelPosition.y+28)}}for(const B of k){const Y=B.x+i.servicePaddingX;B.labelPosition={x:B.iconTextBlock?Y+B.iconTextBlock.width+(B.iconTextBlock.width?10:0):B.icon?Y+(i.serviceIconSize??un.serviceIconSize)+Math.max(10,i.servicePaddingX*.7):Y,y:B.y+B.height/2}}const I=[...P.values()].flatMap(B=>{const Y=I_(B);return Y?[Y]:[]});const D=A.flatMap(B=>I.filter(Y=>!mx(B.points,[Y])).map(Y=>`edge ${B.source.id}->${B.target.id}: crosses group ${Y.id} header`));if(d!==void 0)for(const B of P.values()){const Y=[...B.children,...k.filter(W=>W.parentId===B.id),...w.filter(W=>W.parentId===B.id)];for(const W of Y)if(W.y<B.y+B.headerHeight+d)D.push(`group ${B.id}: child ${W.id} lacks reserved header clearance`)}if(D.length)throw new Qe([{strategy:"architecture-final-headers",violations:D}]);return{width:F,height:G,..._?{title:{text:_,x:F/2,y:C_+(z-Oh)/2,block:$}}:{},groups:E,services:k,junctions:w,edges:A,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription}};return Vr(t,()=>b(S_(l,m),true),()=>b(b_(l,{...m,preserveSubgraphChildOrder:true}),false),true)}function Q8(e,t,n,i){const r=new Map;for(const h of t)r.set(h.id,h);for(const h of n)r.set(h.id,h);const o=new Set(e.alignments.filter(h=>h.axis==="row").flatMap(h=>h.members));const s=[...e.alignments.filter(h=>h.axis==="row"),...e.alignments.filter(h=>h.axis==="column")];for(const h of s){const m=h.members.map(p=>r.get(p)).filter(p=>p!==void 0);if(m.length<2)continue;if(h.axis==="row"){const p=Math.min(...m.map(y=>y.y+y.height/2));let g=Math.min(...m.map(y=>y.x));for(const y of m){y.x=g;y.y=p-y.height/2;g+=y.width+i}}else{const p=Math.min(...m.map(b=>b.x+b.width/2));const g=m.every(b=>!o.has(b.id));let y=Math.min(...m.map(b=>b.y));for(const b of m){b.x=p-b.width/2;if(g){b.y=y;y+=b.height+i}}}}const a=new Map;const l=h=>{const m=a.get(h)??h;if(m===h){a.set(h,h);return h}const p=l(m);a.set(h,p);return p};const c=(h,m)=>{const p=l(h),g=l(m);if(p!==g)a.set(g,p)};for(const h of e.alignments){if(h.axis!=="column")continue;for(let m=1;m<h.members.length;m++)c(h.members[0],h.members[m])}const d=new Map;const u=h=>{const m=d.get(h)??h;if(m===h){d.set(h,h);return h}const p=u(m);d.set(h,p);return p};const f=(h,m)=>{const p=u(h),g=u(m);if(p!==g)d.set(g,p)};for(const h of e.alignments){if(h.axis!=="row")continue;for(let m=1;m<h.members.length;m++)f(h.members[0],h.members[m])}if(e.alignments.length){const h=new Map;for(const m of r.values()){const p=u(m.id),g=l(m.id);let y=h.get(p);if(!y){y=new Map;h.set(p,y)}const b=y.get(g);if(b!==void 0)throw new Qe([{strategy:"architecture-alignments",violations:[`incompatible row and column constraints tie distinct items ${b} and ${m.id}`]}]);y.set(g,m.id)}}if(e.alignments.length){for(const h of["row","column"]){const m=h==="row"?u:l;const p=new Map;for(const g of r.values()){const y=m(g.id),b=h==="row"?g.y+g.height/2:g.x+g.width/2;p.set(y,Math.min(p.get(y)??Infinity,b))}for(const g of r.values()){const y=p.get(m(g.id));const b=h==="row"?g.y+g.height/2:g.x+g.width/2;if(Math.abs(b-y)<=Qt)continue;if(h==="row")g.y=y-g.height/2;else g.x=y-g.width/2}}}if(e.alignments.length)for(const h of["row","column"]){const m=h==="row"?u:l,p=h==="row"?l:u;const g=h==="row"?"x":"y",y=h==="row"?"width":"height";const b=new Map,S=new Map;for(const M of r.values()){const P=p(M.id),E=m(M.id);const v=b.get(P)??[];v.push(M);b.set(P,v);const L=S.get(E)??[];L.push(M);S.set(E,L)}const x=new Map,k=new Map;for(const[M,P]of b){x.set(M,Math.min(...P.map(E=>E[g]+E[y]/2)));k.set(M,P.map(E=>E.id).sort(Bn)[0])}const w=[...b.keys()].sort((M,P)=>x.get(M)-x.get(P)||Bn(k.get(M),k.get(P)));const C=new Map(w.map((M,P)=>[M,P]));const R=new Map;for(const M of S.values()){M.sort((P,E)=>C.get(p(P.id))-C.get(p(E.id)));for(let P=1;P<M.length;P++){const E=M[P-1],v=M[P],L=p(v.id);const T=R.get(L)??[];T.push({before:E,after:v});R.set(L,T)}}for(const M of w){let P=0;for(const{before:E,after:v}of R.get(M)??[])P=Math.max(P,E[g]+E[y]+i-v[g]);if(P>0)for(const E of b.get(M))E[g]+=P}}for(let h=0;h<2;h++){for(const m of e.alignments){if(m.axis!=="row")continue;const p=m.members.map(k=>r.get(k)).filter(k=>k!==void 0);if(p.length<2)continue;const g=u(p[0].id);const y=Math.min(...p.map(k=>k.x));const b=Math.max(...p.map(k=>k.x+k.width));const S=Math.min(...p.map(k=>k.y));const x=Math.max(...p.map(k=>k.y+k.height));for(const k of r.values()){if(u(k.id)===g)continue;const w=k.x<b&&k.x+k.width>y&&k.y<x&&k.y+k.height>S;if(!w)continue;const C=u(k.id);const R=[...r.values()].filter(E=>u(E.id)===C);const M=Math.min(...R.map(E=>E.y));const P=x+i-M;for(const E of R)E.y+=P}}}}function Z8(e,t,n,i,r,o,s,a,l,c,d,u){let f=false;const h=(L,T)=>`${L}:${T}`;const m=L=>{const T=L.indexOf(":");return{kind:L.slice(0,T),id:L.slice(T+1)}};const p=L=>{const T=[];let A=L;while(A){T.push(h("group",A));A=s.get(A)?.parentId}return T.reverse()};const g=(L,T="item")=>{const A=o.get(L);if(A){const _=p(A.parentId);return T==="group"?_:[..._,h("service",L)]}const $=a.get(L);if($)return[...p($.parentId),h("junction",L)];return null};const y=[];for(const L of e.edges){const T=g(L.source.id,L.source.boundary);const A=g(L.target.id,L.target.boundary);if(!T||!A)continue;let $=0;while($<T.length&&$<A.length&&T[$]===A[$])$++;if($>=T.length||$>=A.length)continue;const _=$===0?void 0:m(T[$-1]).id;const z=T[$];const F=A[$];const G=(I,D,B)=>{const Y=B==="L"||B==="R"?"x":"y";const W=B==="R"||B==="B";y.push({axis:Y,parentId:_,before:W?I:D,after:W?D:I,depth:$})};G(z,F,L.source.side);G(F,z,L.target.side)}const b=L=>L?s.get(L)?.children??[]:e.rootChildren;const S=L=>{const{kind:T,id:A}=m(L);if(T==="group")return i.get(A);if(T==="service")return l.get(A);return c.get(A)};const x=(L,T,A)=>{if(Math.abs(A)<=Qt)return;const{kind:$,id:_}=m(L);if($!=="group"){const F=$==="service"?l.get(_):c.get(_);if(F)F[T]+=A;return}const z=F=>{const G=i.get(F);if(G)G[T]+=A;for(const I of s.get(F)?.children??[]){if(I.kind==="group")z(I.id);else x(h(I.kind,I.id),T,A)}};z(_)};const k=[...i.values()].filter(L=>!L.parentId);const w=L=>b(L).map(T=>h(T.kind,T.id)).filter(T=>S(T)!==void 0);const C=(L,T,A)=>{const $=new Map(L.map(G=>[G,G]));const _=G=>{const I=$.get(G)??G;if(I===G)return G;const D=_(I);$.set(G,D);return D};for(const G of e.alignments){if(G.axis!==A)continue;const I=G.members.map(D=>{const B=g(D);if(!B)return void 0;if(!T)return B[0];const Y=B.indexOf(h("group",T));return Y>=0?B[Y+1]:void 0}).filter(D=>D!==void 0&&$.has(D));for(const D of I.slice(1))$.set(_(D),_(I[0]))}const z=new Map;for(const G of L){const I=_(G);const D=z.get(I)??[];D.push(G);z.set(I,D)}const F=G=>{const I=z.get(G).map(O=>S(O));const D=Math.min(...I.map(O=>O.x));const B=Math.min(...I.map(O=>O.y));const Y=Math.max(...I.map(O=>O.x+O.width));const W=Math.max(...I.map(O=>O.y+O.height));return{x:D,y:B,width:Y-D,height:W-B}};return{find:_,members:z,bounds:F}};const R=new Map;for(const L of y){const T=`${L.depth}:${L.parentId??""}:${L.axis}`;const A=R.get(T)??[];A.push(L);R.set(T,A)}const M=[...R.values()].sort((L,T)=>T[0].depth-L[0].depth||Bn(L[0].parentId??"",T[0].parentId??"")||Bn(L[0].axis,T[0].axis));for(const L of M){const{axis:T,parentId:A}=L[0];const $=w(A);if($.length<2)continue;const{find:_,members:z,bounds:F}=C($,A,T==="x"?"column":"row");const G=new Map;let I=false;for(const H of L){const j=_(H.before);const q=_(H.after);if(j===q){I=true;break}const X=G.get(j)??new Set;X.add(q);G.set(j,X)}if(I)continue;const D=[...z.keys()];const B=(H,j)=>{const q=F(H),X=F(j);return T==="x"?q.x+q.width+r<=X.x+Qt:q.y+q.height+r<=X.y+Qt};if([...G].every(([H,j])=>[...j].every(q=>B(H,q))))continue;const Y=new Map(D.map(H=>[H,0]));for(const H of G.values())for(const j of H)Y.set(j,(Y.get(j)??0)+1);const W=[];while(W.length<D.length){const H=D.filter(q=>!W.includes(q)&&Y.get(q)===0).sort((q,X)=>{const V=F(q),ee=F(X);const re=T==="x"?V.x-ee.x:V.y-ee.y;return re||Bn(q,X)});if(H.length===0)break;const j=H[0];W.push(j);for(const q of G.get(j)??[])Y.set(q,Y.get(q)-1)}if(W.length!==D.length)continue;const O=D.map(F);let N=Math.min(...O.map(H=>T==="x"?H.x:H.y));for(const H of W){const j=F(H);const q=T==="x"?j.x:j.y;const X=N-q;if(Math.abs(X)>Qt)f=true;for(const V of z.get(H))x(V,T,X);N+=(T==="x"?j.width:j.height)+r}Bh(k,t,n,true,u)}let P=false;for(const L of e.alignments){const T=L.axis==="row"?"y":"x";const A=T==="y"?"height":"width";const $=[...new Set(L.members)].flatMap(z=>{const F=g(z);const G=l.get(z)??c.get(z);return F&&G?[{path:F,item:G}]:[]});const _=(z,F)=>{if(z.length<2)return;const G=Math.min(...z.map(B=>B.path.length));while(F<G&&z.every(B=>B.path[F]===z[0].path[F]))F++;if(F>=G)return;const I=new Map;for(const B of z){const Y=B.path[F];const W=I.get(Y)??[];W.push(B);I.set(Y,W)}for(const B of I.values())_(B,F+1);const D=Math.max(...z.map(B=>B.item[T]+B.item[A]/2));for(const[B,Y]of I){const W=D-(Y[0].item[T]+Y[0].item[A]/2);if(W>Qt){x(B,T,W);P=f=true}}};_($,0)}if(P)Bh(k,t,n,true,u);const E=[...e.groups.map(L=>({parentId:L.id,depth:p(L.id).length})),{parentId:void 0,depth:0}].sort((L,T)=>T.depth-L.depth||Bn(L.parentId??"",T.parentId??""));const v=(L,T)=>L.x<T.x+T.width-Qt&&T.x<L.x+L.width-Qt&&L.y<T.y+T.height-Qt&&T.y<L.y+L.height-Qt;for(const L of E){const T=w(L.parentId);if(T.length<2)continue;const{members:A,bounds:$}=C(T,L.parentId,"row");const{find:_,members:z}=C(T,L.parentId,"column");for(let I=0;I<T.length;I++){let D=false;for(const B of A.values()){const Y=[...B].sort((N,H)=>S(N).x-S(H).x||Bn(N,H));let W=-Infinity;const O=new Set;for(const N of Y){const H=_(N);if(O.has(H))continue;O.add(H);const j=S(N);if(j.x<W-Qt){const q=W-j.x;for(const X of z.get(H))x(X,"x",q);D=f=true}W=j.x+j.width+r}}if(!D)break}const F=[...A.keys()].sort((I,D)=>{const B=$(I),Y=$(D);return B.y-Y.y||B.x-Y.x||Bn(I,D)});const G=[];for(const I of F){for(let D=0;D<=G.length;D++){const B=$(I);const Y=G.map($).filter(N=>v(B,N));if(Y.length===0)break;const W=Math.max(...Y.map(N=>N.y+N.height+r));const O=W-B.y;for(const N of A.get(I))x(N,"y",O);f=true}G.push(I)}Bh(k,t,n,true,u)}d?.(()=>y.every(({axis:L,before:T,after:A})=>{const $=S(T),_=S(A);return $[L]+(L==="x"?$.width:$.height)+r<=_[L]+Qt})&&(u===void 0||[...i.values()].every(L=>b(L.id).every(T=>{const A=S(h(T.kind,T.id));return A===void 0||A.y>=L.y+L.headerHeight+u})))&&E.every(L=>{const T=b(L.parentId).map(A=>S(h(A.kind,A.id))).filter(A=>A!==void 0);return T.every((A,$)=>T.slice($+1).every(_=>!v(A,_)))}));return f}function L_(e,t,n){const i=t.get(e.id);const r={id:e.id,label:i?.label??e.id,icon:i?.icon,parentId:i?.parentId,x:e.x,y:e.y,width:e.width,height:e.height,headerHeight:e.headerHeight,children:e.children.map(o=>L_(o,t,n))};n.set(r.id,r);return r}function Bh(e,t,n,i,r){for(const o of e)A_(o,t,n,i,r)}function A_(e,t,n,i,r){const o=[];for(const u of e.children)o.push(A_(u,t,n,i,r));for(const u of t){if(u.parentId===e.id)o.push(u)}for(const u of n){if(u.parentId===e.id)o.push(u)}if(o.length===0)return e;const s=Math.min(e.x,...o.map(u=>u.x-Pr));const a=r===void 0?Pr:e.headerHeight+r;const l=Math.min(e.y,...o.map(u=>u.y-a));const c=Math.max(e.x+e.width,...o.map(u=>u.x+u.width+Pr));const d=i?Math.max(e.y+48,...o.map(u=>u.y+u.height+Pr)):Math.max(e.y+e.height,...o.map(u=>u.y+u.height+Pr));e.x=s;e.y=l;e.width=c-s;e.height=d-l;return e}function eU(e,t,n,i,r,o,s,a,l){const c=E_(e.source,t,n,i,r,a.start?a.start+l:0);const d=E_(e.target,t,n,i,r,a.end?a.end+l:0);const u=tU(e,t,r,o,s);for(const b of[e.source,e.target]){const S=b.boundary==="group"?r.get(t.get(b.id).parentId):void 0;const x=S??n.get(b.id)??i.get(b.id);u.push({...x,id:S?.id??b.id,kind:S?"group":n.has(b.id)?"service":"junction"})}for(const[b,S]of[[c,e.source.side],[d,e.target.side]]){const x=S==="L"||S==="R";const k=S==="R"||S==="B";let w=Math.abs(x?b.exit.x-b.anchor.x:b.exit.y-b.anchor.y);for(const C of u){const R=x?b.anchor.y:b.anchor.x;const M=x?C.y:C.x;const P=x?C.height:C.width;if(R<=M+Qt||R>=M+P-Qt)continue;const E=x?C.x+(k?0:C.width):C.y+(k?0:C.height);const v=(E-(x?b.anchor.x:b.anchor.y))*(k?1:-1);if(v>Qt)w=Math.min(w,v)}b.exit=px(b.anchor,S,w)}const f=wk([c.exit,...aU(c.exit,d.exit,e.source.side,e.target.side),d.exit]);const h=mx(f,u)?f:nU(c.exit,d.exit,u)??f;let m=wk([c.anchor,...h,d.anchor]);const p=va(m,a);if(p&&p!==m&&mx(p,u))m=p;const g=P_(c.anchor,e.source.side,d.anchor);const y=P_(d.anchor,e.target.side,c.anchor);return{source:e.source,target:e.target,label:e.label,hasArrowStart:e.hasArrowStart,hasArrowEnd:e.hasArrowEnd,points:m,labelPosition:e.label?kk(m):void 0,placement:g&&y?"satisfied":"conflicted",sourceFacesTarget:g,targetFacesSource:y,obstacleFree:mx(m,u)}}var fx=6;var Qt=.001;function I_(e){const t=e.headerHeight;if(t===void 0||!Number.isFinite(t)||t<0){throw new Qe([{strategy:"architecture-final-headers",violations:[`group ${e.id}: missing or invalid measured header height`]}])}return t>0?{id:e.id,kind:"group-header",x:e.x,y:e.y,width:e.width,height:t}:void 0}function tU(e,t,n,i,r){const o=new Set;const s=c=>{let d=c;while(d){if(o.has(d))break;o.add(d);d=n.get(d)?.parentId}};s(t.get(e.source.id)?.parentId??r.get(e.source.id)?.parentId);s(t.get(e.target.id)?.parentId??r.get(e.target.id)?.parentId);const a=(c,d,u)=>({id:c,kind:d,x:u.x-fx,y:u.y-fx,width:u.width+fx*2,height:u.height+fx*2});const l=[];for(const c of i){if(c.id===e.source.id||c.id===e.target.id)continue;l.push(a(c.id,"service",c))}for(const c of r.values()){if(c.id===e.source.id||c.id===e.target.id)continue;l.push(a(c.id,"junction",c))}for(const c of n.values()){if(o.has(c.id)){const d=I_(c);if(d)l.push(d)}else l.push(a(c.id,"group",c))}return l}function P_(e,t,n){switch(t){case"L":return n.x<e.x-Qt;case"R":return n.x>e.x+Qt;case"T":return n.y<e.y-Qt;case"B":return n.y>e.y+Qt}}function mx(e,t){for(let n=1;n<e.length;n++){if(t.some(i=>F_(e[n-1],e[n],i)))return false}return true}function F_(e,t,n){if(n.kind==="group-header"){let i=0,r=1;for(const[o,s,a,l]of[[e.x,t.x-e.x,n.x,n.x+n.width],[e.y,t.y-e.y,n.y,n.y+n.height]]){if(s===0){if(o<=a||o>=l)return false;continue}const c=(a-o)/s,d=(l-o)/s;i=Math.max(i,Math.min(c,d));r=Math.min(r,Math.max(c,d));if(i>=r)return false}return i<r}if(Math.abs(e.y-t.y)<=Qt){return e.y>n.y+Qt&&e.y<n.y+n.height-Qt&&Math.min(e.x,t.x)<n.x+n.width-Qt&&Math.max(e.x,t.x)>n.x+Qt}if(Math.abs(e.x-t.x)<=Qt){return e.x>n.x+Qt&&e.x<n.x+n.width-Qt&&Math.min(e.y,t.y)<n.y+n.height-Qt&&Math.max(e.y,t.y)>n.y+Qt}return true}var Sk=class{entries=[];push(t){this.entries.push(t);let n=this.entries.length-1;while(n>0){const i=Math.floor((n-1)/2);if(!this.before(t,this.entries[i]))break;this.entries[n]=this.entries[i];n=i}this.entries[n]=t}pop(){const t=this.entries[0];const n=this.entries.pop();if(!t||!n||this.entries.length===0)return t;let i=0;this.entries[0]=n;while(true){const r=i*2+1;const o=r+1;if(r>=this.entries.length)break;let s=r;if(o<this.entries.length&&this.before(this.entries[o],this.entries[r]))s=o;if(!this.before(this.entries[s],this.entries[i]))break;const a=this.entries[i];this.entries[i]=this.entries[s];this.entries[s]=a;i=s}return t}before(t,n){return t.cost<n.cost||t.cost===n.cost&&t.state<n.state}};function nU(e,t,n){const i=[...new Set([e.x,t.x,...n.flatMap(x=>[x.x,x.x+x.width])])].sort((x,k)=>x-k);const r=[...new Set([e.y,t.y,...n.flatMap(x=>[x.y,x.y+x.height])])].sort((x,k)=>x-k);const o=[];const s=new Map;const a=(x,k)=>`${x}\0${k}`;const l=(x,k)=>n.some(w=>{const C=w.kind==="group-header"?0:Qt;return x>w.x+C&&x<w.x+w.width-C&&k>w.y+C&&k<w.y+w.height-C});for(const x of r){for(const k of i){if(l(k,x)&&!(k===e.x&&x===e.y)&&!(k===t.x&&x===t.y))continue;s.set(a(k,x),o.length);o.push({x:k,y:x})}}const c=s.get(a(e.x,e.y));const d=s.get(a(t.x,t.y));if(c===void 0||d===void 0)return null;const u=o.map(()=>[]);const f=(x,k)=>{for(let w=1;w<x.length;w++){const C=x[w-1];const R=x[w];const M=o[C];const P=o[R];if(n.some(v=>F_(M,P,v)))continue;const E=Math.abs(M.x-P.x)+Math.abs(M.y-P.y);u[C].push({point:R,direction:k,length:E});u[R].push({point:C,direction:k,length:E})}};for(const x of r){const k=o.map((w,C)=>({point:w,index:C})).filter(w=>w.point.y===x).sort((w,C)=>w.point.x-C.point.x).map(w=>w.index);f(k,1)}for(const x of i){const k=o.map((w,C)=>({point:w,index:C})).filter(w=>w.point.x===x).sort((w,C)=>w.point.y-C.point.y).map(w=>w.index);f(k,2)}const h=o.length*3;const m=new Array(h).fill(Infinity);const p=new Array(h).fill(-1);const g=c*3;m[g]=0;const y=new Sk;y.push({state:g,cost:0});let b=-1;while(true){const x=y.pop();if(!x)break;if(x.cost!==m[x.state])continue;const k=Math.floor(x.state/3);const w=x.state%3;if(k===d){b=x.state;break}for(const C of u[k]){const R=C.point*3+C.direction;const M=w!==0&&w!==C.direction?8:0;const P=x.cost+C.length+M;if(P>=m[R])continue;m[R]=P;p[R]=x.state;y.push({state:R,cost:P})}}if(b<0)return null;const S=[];for(let x=b;x>=0;x=p[x]){S.push(o[Math.floor(x/3)]);if(x===g)break}return wk(S.reverse())}function iU(e,t,n){const i=n?.edgeFontSize??11;const r=n?.edgeFontWeight??400;const o=6;const s=(u,f,h)=>{const m=u.labelBlock??_e(u.label,{display:"formatted",fontSize:i,fontWeight:r,letterSpacing:n?.edgeLetterSpacing});const p=m.width+o*2;const g=m.height+o*2;return{x0:f-p/2,y0:h-g/2,x1:f+p/2,y1:h+g/2}};const a=(u,f)=>Math.min(u.x1,f.x1)-Math.max(u.x0,f.x0)>.5&&Math.min(u.y1,f.y1)-Math.max(u.y0,f.y0)>.5;const l=t.map(u=>({x0:u.x,y0:u.y,x1:u.x+u.width,y1:u.y+u.height}));const c=e.filter(u=>u.label&&u.labelPosition&&u.points.length>=2);const d=[];for(const u of c){const f=s(u,u.labelPosition.x,u.labelPosition.y);const h=x=>d.some(k=>a(x,k))||l.some(k=>a(x,k));if(!h(f)){d.push(f);continue}const m=u.points;const p=[];let g=0;for(let x=1;x<m.length;x++){const k=Math.hypot(m[x].x-m[x-1].x,m[x].y-m[x-1].y);p.push(k);g+=k}const y=x=>{let k=x;for(let w=0;w<p.length;w++){if(k<=p[w]||w===p.length-1){const C=p[w]===0?0:Math.max(0,Math.min(1,k/p[w]));return{x:m[w].x+(m[w+1].x-m[w].x)*C,y:m[w].y+(m[w+1].y-m[w].y)*C}}k-=p[w]}return m[m.length-1]};const b=[.5,.4,.6,.3,.7,.25,.75,.2,.8,.15,.85];let S=f;for(const x of b){const k=y(g*x);const w=s(u,k.x,k.y);if(!h(w)){u.labelPosition={x:k.x,y:k.y};S=w;break}}d.push(S)}}function E_(e,t,n,i,r,o=0){if(e.boundary==="group"){const c=t.get(e.id);const d=n.get(e.id);const u=r.get(c.parentId);const f=sU(u,d,e.side);return{anchor:f,exit:px(f,e.side,Math.max(bk,o))}}const s=n.get(e.id);if(s){const c=rU(s,e.side);return{anchor:c,exit:px(c,e.side,Math.max(bk,o))}}const a=i.get(e.id);if(!a){throw new Error(`Unknown architecture endpoint "${e.id}"`)}const l=oU(a,e.side);return{anchor:l,exit:px(l,e.side,Math.max(bk*.75,o))}}function rU(e,t){switch(t){case"L":return{x:e.x,y:e.y+e.height/2};case"R":return{x:e.x+e.width,y:e.y+e.height/2};case"T":return{x:e.x+e.width/2,y:e.y};case"B":return{x:e.x+e.width/2,y:e.y+e.height}}}function oU(e,t){const n=e.x+e.width/2;const i=e.y+e.height/2;const r=Math.min(e.width,e.height)/2;switch(t){case"L":return{x:n-r,y:i};case"R":return{x:n+r,y:i};case"T":return{x:n,y:i-r};case"B":return{x:n,y:i+r}}}function sU(e,t,n){const i=t.x+t.width/2;const r=t.y+t.height/2;switch(n){case"L":return{x:e.x,y:hx(r,e.y+Pr,e.y+e.height-Pr)};case"R":return{x:e.x+e.width,y:hx(r,e.y+Pr,e.y+e.height-Pr)};case"T":return{x:hx(i,e.x+Pr,e.x+e.width-Pr),y:e.y};case"B":return{x:hx(i,e.x+Pr,e.x+e.width-Pr),y:e.y+e.height}}}function aU(e,t,n,i){if(e.x===t.x||e.y===t.y)return[];const r=R_(n);const o=R_(i);if(r!==o){return r==="horizontal"?[{x:t.x,y:e.y}]:[{x:e.x,y:t.y}]}if(r==="horizontal"){const a=(e.x+t.x)/2;return[{x:a,y:e.y},{x:a,y:t.y}]}const s=(e.y+t.y)/2;return[{x:e.x,y:s},{x:t.x,y:s}]}function R_(e){return e==="L"||e==="R"?"horizontal":"vertical"}function px(e,t,n){switch(t){case"L":return{x:e.x-n,y:e.y};case"R":return{x:e.x+n,y:e.y};case"T":return{x:e.x,y:e.y-n};case"B":return{x:e.x,y:e.y+n}}}function wk(e){const t=[];let n;for(const i of e){if(n&&n.x===i.x&&n.y===i.y)continue;n=i;while(t.length>1){const r=t[t.length-2],o=t[t.length-1];if(r.x===o.x&&o.x===i.x||r.y===o.y&&o.y===i.y)t.pop();else break}t.push(i)}return t}function kk(e){if(e.length===0)return{x:0,y:0};if(e.length===1)return e[0];let t=0;for(let i=1;i<e.length;i++){t+=v_(e[i-1],e[i])}let n=t/2;for(let i=1;i<e.length;i++){const r=e[i-1];const o=e[i];const s=v_(r,o);if(n<=s){const a=s===0?0:n/s;return{x:r.x+(o.x-r.x)*a,y:r.y+(o.y-r.y)*a}}n-=s}return e[e.length-1]}function v_(e,t){return Math.abs(t.x-e.x)+Math.abs(t.y-e.y)}function hx(e,t,n){return Math.max(t,Math.min(n,e))}function lU(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l={...un,...r.familyAppearance?.visual??o.architecture?.visual};const c=[];const d=[l.groupSurface?`--arch-group-fill:${l.groupSurface}`:"",l.groupHeaderSurface?`--arch-group-band:${l.groupHeaderSurface}`:"",l.groupBorder?`--arch-group-stroke:${l.groupBorder}`:"",l.groupText?`--arch-group-label:${l.groupText}`:"",l.serviceSurface?`--arch-service-fill:${l.serviceSurface}`:"",l.serviceBorder?`--arch-service-stroke:${l.serviceBorder}`:"",l.serviceText?`--arch-service-label:${l.serviceText}`:"",l.edgeStroke?`--arch-edge-stroke:${l.edgeStroke}`:"",l.edgeText?`--arch-edge-label:${l.edgeText}`:""].filter(Boolean).join(";");const u=cU(l,i);const f=n.accessibilityTitle??n.title?.text;const h=Boolean(f);const m=Boolean(n.accessibilityDescription);const p=`arch-${mi(n.width,n.height,n.title?.text??"",n.services.map(w=>w.id).join(","),n.groups.map(w=>w.id).join(","))}`;const g=`${p}-title`;const y=`${p}-desc`;const b={};if(h||m){b["role"]="img";b["aria-roledescription"]="architecture"}if(h)b["aria-labelledby"]=g;if(m)b["aria-describedby"]=y;const S=[];S.push(Ot(n.width,n.height,i,a,{style:d,attrs:b}));if(h)S.push(`<title id="${g}">${It(f)}</title>`);if(m)S.push(`<desc id="${y}">${It(n.accessibilityDescription)}</desc>`);S.push(Dt(s,false,void 0,i.embedFontImport));c.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},S.join("\n")));c.push(e.definitions({id:"defs",markerResources:Zd},["<defs>",hi(Zd),"</defs>"].join("\n")));if(n.title){c.push(e.text({id:"title",role:"title",text:n.title.text,x:n.title.x,y:n.title.y,fontSize:Oh,block:n.title.block,anchor:"middle",fontWeight:Mk,paint:{fill:"var(--arch-service-label, var(--_text))"},attributes:{className:"architecture-title"}}))}for(const w of n.groups){c.push(N_(e,w,l,u))}const x=new Map;for(const w of n.edges){const C=`${w.source.id}->${w.target.id}`;const R=x.get(C)??0;x.set(C,R+1);c.push(fU(e,w,l,`edge:${C}#${R}`))}const k=new Map;for(const w of n.edges){if(!w.label)continue;const C=`${w.source.id}->${w.target.id}`;const R=k.get(C)??0;k.set(C,R+1);for(const M of hU(e,w,l,`edge-label:${C}#${R}`)){c.push(M)}}for(const w of n.junctions){c.push(uU(e,w,l))}for(const w of n.services){c.push(dU(e,w,l,u))}c.push(e.documentClose());return{family:"architecture",width:n.width,height:n.height,colors:i,transparent:a,parts:c}}function cU(e,t){const n=_n("var(--bg)",t);const i=_n("var(--_node-fill)",t);const r=n?_n(e.groupSurface??n,t):void 0;const o=_n(e.edgeStroke??"var(--_arrow)",t);const s=e.groupHeaderSurface??(r&&o?Zi(o,r,5):void 0);const a=e.serviceSurface??(n&&i?Zi(i,n,92):void 0);return{group:`var(--arch-group-label, ${s?yi("var(--_text-sec)",s,t):"var(--_text-sec)"})`,service:`var(--arch-service-label, ${a?yi("var(--_text)",a,t):"var(--_text)"})`}}function N_(e,t,n,i){const r=[];const o=`<g class="architecture-group" data-id="${Ye(t.id)}" data-label="${hn(t.label)}">`;r.push({indent:2,node:e.shape({id:`group-frame:${t.id}`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:"var(--arch-group-fill, color-mix(in srgb, var(--_node-fill) 82%, var(--bg)))",stroke:"none"},attributes:{className:"architecture-group-frame"}})});const s=Er(t.x,t.y,t.width,t.headerHeight??n.groupHeaderHeight,n.groupCornerRadius);r.push({indent:2,node:e.shape({id:`group-band:${t.id}`,role:"group-header",geometry:{kind:"path",d:s},paint:{fill:"var(--arch-group-band, color-mix(in srgb, var(--arch-edge-stroke, var(--_arrow)) 5%, var(--arch-group-fill, var(--bg))))",stroke:"none"},attributes:{className:"architecture-group-band"}})});r.push({indent:2,node:e.shape({id:`group-outline:${t.id}`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:"none",stroke:"var(--arch-group-stroke, var(--_node-stroke))",strokeWidth:String(n.groupLineWidth)},attributes:{className:"architecture-group-outline"}})});if(t.icon){r.push({indent:0,node:$_(e,t.x+10,t.y+6,n.iconSize,t.icon,true,`icon:${t.id}`,{id:t.id,role:"group"},t.iconFallbackBlock)})}const a=t.labelBlock??_e(t.label,{display:"formatted",transform:n.groupTextTransform,fontSize:n.groupFontSize,fontWeight:n.groupFontWeight,letterSpacing:n.groupLetterSpacing,fontFamily:n.groupFont});const l=a.text;const c=t.x+(t.icon?Im:n.groupLabelPaddingX);const d=t.y+(t.headerHeight??n.groupHeaderHeight)/2;r.push({indent:2,node:e.text({id:`group-label:${t.id}`,role:"label",text:l,x:c,y:d,fontSize:n.groupFontSize,block:a,anchor:"start",paint:{fill:i.group},attributes:{className:"architecture-group-label"}})});for(const u of t.children){r.push({indent:0,node:N_(e,u,n,i)})}return e.group({id:`group:${t.id}`,role:"group",open:o,close:"</g>",children:r})}function dU(e,t,n,i){const r=[];const o=Boolean(t.icon);const s=t.iconText===void 0?void 0:t.iconTextBlock??_e(t.iconText,{display:"literal",fontSize:n.serviceFontSize,fontWeight:700});const a=t.x+n.servicePaddingX;const l=t.y+t.height/2-n.serviceIconSize/2;const c=t.labelPosition?.x??(s?a+s.width+(s.width?10:0):o?a+n.serviceIconSize+Math.max(10,n.servicePaddingX*.7):t.x+n.servicePaddingX);const d=`<g class="architecture-service" data-id="${Ye(t.id)}" data-label="${hn(t.label)}">`;r.push({indent:2,node:e.shape({id:`service-card:${t.id}`,role:"service",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.serviceCornerRadius,ry:n.serviceCornerRadius},paint:{fill:"var(--arch-service-fill, color-mix(in srgb, var(--_node-fill) 92%, var(--bg)))",stroke:"none"},attributes:{className:"architecture-service-card"}})});r.push({indent:2,node:e.shape({id:`service-outline:${t.id}`,role:"service",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.serviceCornerRadius,ry:n.serviceCornerRadius},paint:{fill:"none",stroke:"var(--arch-service-stroke, var(--_node-stroke))",strokeWidth:String(n.serviceLineWidth)},attributes:{className:"architecture-service-outline"}})});if(t.icon){r.push({indent:0,node:$_(e,a,l,n.serviceIconSize,t.icon,false,`icon:${t.id}`,{id:t.id,role:"service"},t.iconFallbackBlock)})}if(s){const m=s;r.push({indent:2,node:e.text({id:`icon-text:${t.id}`,role:"icon",text:m.text,block:m,x:a,y:t.y+t.height/2,anchor:"start",fontSize:n.serviceFontSize,fontWeight:700,paint:{fill:i.service},attributes:{className:"architecture-icon-text"}})})}const u=t.labelPosition?.y??t.y+t.height/2;const f=t.labelBlock??_e(t.label,{display:"formatted",transform:n.serviceTextTransform,fontSize:n.serviceFontSize,fontWeight:n.serviceFontWeight,letterSpacing:n.serviceLetterSpacing});const h=f.text;r.push({indent:2,node:e.text({id:`service-label:${t.id}`,role:"label",text:h,x:c,y:u,fontSize:n.serviceFontSize,block:f,anchor:"start",paint:{fill:i.service},attributes:{className:"architecture-service-label"}})});return e.group({id:`service:${t.id}`,role:"service",open:d,close:"</g>",children:r})}function uU(e,t,n){const i=t.x+t.width/2;const r=t.y+t.height/2;const o=e.shape({id:`junction-ring:${t.id}`,role:"junction",geometry:{kind:"circle",cx:i,cy:r,r:t.width/2},paint:{fill:"var(--bg)",stroke:"var(--arch-edge-stroke, var(--_arrow))",strokeWidth:"1.25"},attributes:{className:"architecture-junction-ring"}});const s=e.shape({id:`junction-core:${t.id}`,role:"junction",geometry:{kind:"circle",cx:i,cy:r,r:n.junctionInnerRadius},paint:{fill:"color-mix(in srgb, var(--arch-edge-stroke, var(--_arrow)) 24%, var(--bg))",stroke:"var(--arch-edge-stroke, var(--_arrow))",strokeWidth:"0.75"},attributes:{className:"architecture-junction-core"}});return e.group({id:`junction:${t.id}`,role:"junction",open:`<g class="architecture-junction" data-id="${Ye(t.id)}">`,close:"</g>",children:[{indent:2,node:o},{indent:2,node:s}]})}function fU(e,t,n,i){const r=t.hasArrowStart?Zd[1]:void 0;const o=t.hasArrowEnd?Zd[0]:void 0;const s={className:"architecture-edge",data:{"from-side":t.source.side,"to-side":t.target.side,"from-boundary":t.source.boundary,"to-boundary":t.target.boundary,...t.label?{label:Hr(t.label)}:{}}};const a={stroke:"var(--arch-edge-stroke, var(--_line))",strokeWidth:String(n.edgeLineWidth),strokeLinejoin:"round"};const l={endpoints:{from:t.source.id,to:t.target.id},relationship:{kind:"architecture-edge"},route:{ownership:"layout",bendRadius:n.edgeBendRadius,labelAnchors:t.labelPosition?[t.labelPosition]:[]},labels:t.label?[{text:t.label,...t.labelPosition?{anchor:t.labelPosition}:{}}]:[],attributes:s};if(n.edgeBendRadius>0&&t.points.length>2){const c=qn(t.points,n.edgeBendRadius,{terminalClearance:{start:eu(r?.id,n.edgeLineWidth,"start"),end:eu(o?.id,n.edgeLineWidth,"end")},metric:"manhattan"});return e.connector({id:i,role:"edge",geometry:c.geometry,lineStyle:"solid",paint:a,markers:{...r?{start:r}:{},mid:[],...o?{end:o}:{}},...l,route:{...l.route,contours:c.contours}})}return e.connector({id:i,role:"edge",geometry:{kind:"polyline",points:t.points},lineStyle:"solid",paint:a,markers:{...r?{start:r}:{},mid:[],...o?{end:o}:{}},...l})}function hU(e,t,n,i){const r=t.labelBlock??_e(t.label,{display:"formatted",transform:n.edgeTextTransform,fontSize:n.edgeFontSize,fontWeight:n.edgeFontWeight,letterSpacing:n.edgeLetterSpacing});const o=r.text;const s=t.labelPosition??kk(t.points);const a=7;const l=r.width+a*2;const c=r.height+a*2;return[e.shape({id:`${i}:bg`,role:"chrome",geometry:{kind:"rect",x:s.x-l/2,y:s.y-c/2,width:l,height:c,rx:0,ry:0},paint:{fill:"color-mix(in srgb, var(--bg) 90%, var(--_group-hdr))",stroke:"color-mix(in srgb, var(--arch-edge-stroke, var(--_line)) 18%, var(--bg))",strokeWidth:"0.75"},attributes:{className:"architecture-edge-label-bg"}}),e.text({id:i,role:"label",text:o,x:s.x,y:s.y,fontSize:n.edgeFontSize,block:r,anchor:"middle",paint:{fill:"var(--arch-edge-label, var(--_text-muted))"},attributes:{className:"architecture-edge-label-text"}})]}function $_(e,t,n,i,r,o,s,a,l){const c=r.trim().toLowerCase();const d=!c.includes(":")&&!c.includes("/")&&["cloud","database","disk","internet","server"].includes(c);const u=d?null:fa(r);const f=u?` data-icon-source="${u.source}" data-icon-license="${u.license}"`:"";const h="var(--arch-edge-stroke, var(--_arrow))";const m={fill:"none",stroke:h,strokeWidth:"1.25",strokeLinecap:"round",strokeLinejoin:"round"};const p=[];const g=(R,M="architecture-icon-mark",P=m,E)=>{p.push(e.shape({id:xn(s,"part",p.length),role:"icon",owner:a,geometry:R,paint:P,...E?{transform:E}:{},attributes:{className:M}}))};const y=R=>g({kind:"path",d:R});const b=(R,M,P)=>g({kind:"circle",cx:R,cy:M,r:P});const S=(R,M,P,E)=>g({kind:"ellipse",cx:R,cy:M,rx:P,ry:E});const x=tx(r),k=t+i/2,w=n+i/2,C=o?i*.92:i;if(u){const R=(i-C)/2,M=C/24;g({kind:"path",d:u.path},"architecture-icon-glyph",{fill:h},{kind:"matrix",a:M,b:0,c:0,d:M,e:t+R,f:n+R})}else switch(x){case"cloud":b(k-C*.18,w+C*.02,C*.16);b(k+C*.02,w-C*.08,C*.2);b(k+C*.2,w+C*.02,C*.15);y(`M ${k-C*.34} ${w+C*.16} H ${k+C*.33}`);break;case"database":S(k,w-C*.16,C*.24,C*.1);y(`M ${k-C*.24} ${w-C*.16} V ${w+C*.2}`);y(`M ${k+C*.24} ${w-C*.16} V ${w+C*.2}`);S(k,w+C*.02,C*.24,C*.1);S(k,w+C*.2,C*.24,C*.1);break;case"disk":b(k,w,C*.26);b(k,w,C*.09);break;case"internet":b(k,w,C*.26);y(`M ${k-C*.26} ${w} H ${k+C*.26}`);y(`M ${k} ${w-C*.26} V ${w+C*.26}`);y(`M ${k-C*.14} ${w-C*.22} Q ${k} ${w} ${k-C*.14} ${w+C*.22}`);y(`M ${k+C*.14} ${w-C*.22} Q ${k} ${w} ${k+C*.14} ${w+C*.22}`);break;case"server":g({kind:"rect",x:k-C*.22,y:w-C*.24,width:C*.44,height:C*.48,rx:0,ry:0});y(`M ${k-C*.16} ${w-C*.08} H ${k+C*.16}`);y(`M ${k-C*.16} ${w+C*.06} H ${k+C*.16}`);break;default:{const R=jM(r),M=Math.max(10,i*.56);const P=l;p.push(e.text({id:xn(s,"fallback"),role:"icon",owner:a,text:R,block:P,x:k,y:w,fontSize:M,fontWeight:700,anchor:"middle",paint:{fill:h},attributes:{className:"architecture-icon-glyph architecture-icon-fallback",data:{fallback:"true"}}}))}}return e.group({id:s,role:"icon",owner:a,open:` <g class="architecture-icon" data-icon="${Ye(r)}"${f}>`,close:"</g>",children:p.map((R,M)=>({node:R,indent:M===0?2:0}))})}var __=gt(lU);var PPe={configDiagnostics:W$,statementEnds:Eb,normalizeRequest:e=>{const t=wP(e.source.frontmatter,e.colors,e.renderOptions,e.styleFace);const n={...e.renderOptions,padding:e.renderOptions.padding??t.padding,nodeSpacing:e.renderOptions.nodeSpacing??t.nodeSpacing,layerSpacing:e.renderOptions.layerSpacing??t.layerSpacing};return{renderOptions:n,familyConfig:{layout:t.layout},appearance:{family:{visual:t.visual}}}},layout:e=>{const t=e.familyConfig;const n=Tn(qr($P(AP(e.source)),e.source.accessibility),e.source.frontmatter);return mt(T_(n,e.renderOptions,t?.layout),{injectAccessibility:false})},projectPositioned:ft(aA),lowerScene:ht(__)};var mU={nodeSpacing:jt,rankSpacing:jt,hierarchicalNamespaces:ct};var D_=e=>bt("class",e,mU);function Fo(e){const t=e.edgeStrokeColor??"var(--_arrow)";const n=[{x:0,y:0},{x:12,y:5},{x:0,y:10}];const i=[{x:7,y:1},{x:13,y:6},{x:7,y:11},{x:1,y:6}];return[{id:"cls-inherit",shape:"triangle",size:{width:12,height:10},ref:{x:12,y:5},orient:"auto-start-reverse",overflow:"visible",geometry:{kind:"polygon",points:n},paint:{fill:"var(--bg)",stroke:t,strokeWidth:"1.5"}},{id:"cls-composition",shape:"diamond",size:{width:14,height:12},viewBox:{x:0,y:0,width:14,height:12},ref:{x:13,y:6},orient:"auto-start-reverse",overflow:"hidden",geometry:{kind:"polygon",points:i},paint:{fill:t,stroke:t,strokeWidth:"1"}},{id:"cls-aggregation",shape:"diamond-open",size:{width:14,height:12},viewBox:{x:0,y:0,width:14,height:12},ref:{x:13,y:6},orient:"auto-start-reverse",overflow:"hidden",geometry:{kind:"polygon",points:i},paint:{fill:"var(--bg)",stroke:t,strokeWidth:"1.5"}},{id:"cls-arrow",shape:"open-arrow",size:{width:8,height:6},ref:{x:8,y:3},orient:"auto-start-reverse",overflow:"visible",geometry:{kind:"polyline",points:[{x:0,y:0},{x:8,y:3},{x:0,y:6}]},paint:{fill:"none",stroke:t,strokeWidth:"1.5"}},lg(t)]}var O_=gr(Fo({}));function kc(e,t){return{start:O_(e.markerAt==="from"||e.markerAt==="both"?Ci(e.fromType??e.type)??void 0:void 0,t.lineWidth,"start"),end:O_(e.markerAt==="to"||e.markerAt==="both"?Ci(e.toType??e.type)??void 0:void 0,t.lineWidth,"end")}}function Ci(e){switch(e){case"inheritance":case"realization":return"cls-inherit";case"composition":return"cls-composition";case"aggregation":return"cls-aggregation";case"association":case"dependency":return"cls-arrow";case"lollipop":return"cls-lollipop";default:return null}}var su=3;var ea=8;function au(e){return e.label&&e.points.length>=2?e.labelPosition??e.points[Math.floor(e.points.length/2)]:void 0}function Cc(e,t){if(!e[`${t}Cardinality`]||e.points.length<2)return void 0;const n=e[`${t}CardinalityPosition`];if(n)return n;const i=t==="from"?e.points[0]:e.points.at(-1),r=t==="from"?e.points[1]:e.points.at(-2),o=r.x-i.x,s=r.y-i.y;return Math.abs(o)>Math.abs(s)?{x:i.x+(o>0?14:-14),y:i.y-10}:{x:i.x-14,y:i.y+(s>0?14:-14)}}var Ck=(Math.floor((150-14)/10)+1)*2*(Math.floor((190-10)/12)+1);function*gx(e,t){const n=t.x-e.x,i=t.y-e.y,r=Math.abs(n)>=Math.abs(i),o=r?Math.sign(n||1):0,s=r?0:Math.sign(i||1);for(let a=14;a<=150;a+=10)for(let l=10;l<=190;l+=12)for(const c of[-l,l])yield{x:e.x+o*a-s*c,y:e.y+s*a+o*c}}var Pk=Symbol("Class header numeric snapshot");function yx(e,t){e[Pk]=t}var B_=Symbol("Class header candidate authority");var Ek=class{#e;#t;#n;#i;constructor(t,n,i,r,o){if(t!==B_)throw new TypeError("Unauthorized Class header candidate proof");this.#e=n;this.#t=i;this.#n=r;this.#i=o}clear(t){at(this.#i);if(!this.#e.active)throw new Qe([{strategy:"class-header-lanes",violations:["Stale Class header candidate proof"]}]);return wU(t,this.#t,this.#n,this.#i)}};var cn=e=>Number(Ue(e));var at=e=>{if(!e())throw new Qe([{strategy:"class-header-lanes",violations:["Class header carrier proof work limit"]}])};var pU=(e,t)=>Math.max(e.x0,t.x0)<Math.min(e.x1,t.x1)&&Math.max(e.y0,t.y0)<Math.min(e.y1,t.y1);var lu=(e,t)=>e.x===t.x&&e.y===t.y;function Rk(e,t,n,i,r,o=e){const s=[];for(let a=1;a<e.length;a++){at(r);const l=e[a-1],c=e[a];if(lu(l,c)||l.x!==c.x&&l.y!==c.y)return void 0;if(n>0)s.push({owner:t,kind:"strip",segment:a-1,axis:l.y===c.y?"x":"y",box:l.y===c.y?{x0:Math.min(l.x,c.x),x1:Math.max(l.x,c.x),y0:l.y-n,y1:l.y+n}:{x0:l.x-n,x1:l.x+n,y0:Math.min(l.y,c.y),y1:Math.max(l.y,c.y)}});if(a+1===e.length)continue;const d=e[a+1],u=Math.sign(c.x-l.x),f=Math.sign(c.y-l.y),h=Math.sign(d.x-c.x),m=Math.sign(d.y-c.y),p=u*m-f*h;if(!p||n<=0)continue;if(i>0){const g=o[a-1],y=o[a],b=o[a+1],S=Math.abs(y.x-g.x)+Math.abs(y.y-g.y),x=Math.abs(b.x-y.x)+Math.abs(b.y-y.y),k=Math.min(i,S/2,x/2);const w={x:cn(y.x+(g.x-y.x)*(k/S)),y:cn(y.y+(g.y-y.y)*(k/S))},C={x:cn(y.x+(b.x-y.x)*(k/x)),y:cn(y.y+(b.y-y.y)*(k/x))};s.push({owner:t,kind:"curve",segment:a-1,axis:"x",box:{x0:Math.min(w.x,c.x,C.x)-n,x1:Math.max(w.x,c.x,C.x)+n,y0:Math.min(w.y,c.y,C.y)-n,y1:Math.max(w.y,c.y,C.y)+n}})}else{const g=p>0?-1:1,y=(-f*g+-m*g)*n,b=(u*g+h*g)*n;s.push({owner:t,kind:"join",segment:a-1,axis:"x",box:{x0:Math.min(c.x,c.x+y),x1:Math.max(c.x,c.x+y),y0:Math.min(c.y,c.y+b),y1:Math.max(c.y,c.y+b)}})}}return s}function vk(e,t,n){const i=cn(t.lineWidth)/2,r=t.edgeBendRadius,o=[],s=[];if(![i,r].every(Number.isFinite)||i<0||r<0)throw new TypeError("Nonfinite Class header stroke");for(let a=0;a<e.length;a++){at(n);const l=e[a],c=[],d=[];for(const f of l.points){at(n);if(![f.x,f.y].every(Number.isFinite))throw new TypeError("Nonfinite Class header carrier");c.push({x:f.x,y:f.y});d.push({x:cn(f.x),y:cn(f.y)})}o.push({from:l.from,to:l.to,dashed:Jl(l)==="dashed",raw:c,points:d});const u=Rk(d,a,i,r,n,c);if(!u)throw new Qe([{strategy:"class-header-lanes",violations:["Unproved noncardinal Class header carrier"]}]);s.push(...u)}return{...W_(s,o,n),routes:o,pieces:s,half:i,radius:r}}function W_(e,t,n){const i=[],r=[],o=[],s=[],a=[],l=[];let c=0,d=0;for(const u of e){at(n);if(u.kind==="strip"){const f=t[u.owner].points[u.segment],h=t[u.owner].points[u.segment+1];if(u.axis==="x"){i.push({key:f.y,piece:u});o.push({key:f.x,piece:u},{key:h.x,piece:u})}else{r.push({key:f.x,piece:u});s.push({key:f.y,piece:u},{key:h.y,piece:u})}}else{a.push({key:(u.box.x0+u.box.x1)/2,piece:u});l.push({key:(u.box.y0+u.box.y1)/2,piece:u});c=Math.max(c,(u.box.x1-u.box.x0)/2);d=Math.max(d,(u.box.y1-u.box.y0)/2)}}for(const u of[i,r,o,s,a,l])u.sort((f,h)=>{at(n);return f.key-h.key||f.piece.owner-h.piece.owner||f.piece.segment-h.piece.segment});return{horizontal:i,vertical:r,horizontalEnds:o,verticalEnds:s,cornersX:a,cornersY:l,cornerHalfX:c,cornerHalfY:d}}function*zr(e,t,n,i){let r=0,o=e.length;while(r<o){at(i);const s=r+o>>>1;if(e[s].key<t)r=s+1;else o=s}for(;r<e.length;r++){at(i);const s=e[r];if(s.key>n)break;yield s.piece}}function*gU(e,t,n){const i=e.box,r=t.half;const o=new Set;const s=[];if(e.kind==="strip"&&e.axis==="x")s.push(zr(t.horizontal,i.y0-r,i.y1+r,n),zr(t.vertical,i.x0-r,i.x0+r,n),zr(t.vertical,i.x1-r,i.x1+r,n),zr(t.verticalEnds,i.y0-r,i.y1+r,n),zr(t.cornersY,i.y0-t.cornerHalfY,i.y1+t.cornerHalfY,n));else if(e.kind==="strip")s.push(zr(t.vertical,i.x0-r,i.x1+r,n),zr(t.horizontal,i.y0-r,i.y0+r,n),zr(t.horizontal,i.y1-r,i.y1+r,n),zr(t.horizontalEnds,i.x0-r,i.x1+r,n),zr(t.cornersX,i.x0-t.cornerHalfX,i.x1+t.cornerHalfX,n));else s.push(zr(t.horizontal,i.y0-r,i.y1+r,n),zr(t.vertical,i.x0-r,i.x1+r,n),zr(t.cornersX,i.x0-t.cornerHalfX,i.x1+t.cornerHalfX,n));for(const a of s)for(const l of a){at(n);if(!o.has(l)){o.add(l);yield l}}}function yU(e,t,n,i){if(e.x===t.x&&n.y===i.y)return Math.min(e.y,t.y)<n.y&&n.y<Math.max(e.y,t.y)&&Math.min(n.x,i.x)<e.x&&e.x<Math.max(n.x,i.x);return e.y===t.y&&n.x===i.x&&Math.min(e.x,t.x)<n.x&&n.x<Math.max(e.x,t.x)&&Math.min(n.y,i.y)<e.y&&e.y<Math.max(n.y,i.y)}function xU(e,t,n,i,r,o,s){if(i.kind!=="strip"||r.kind!=="strip"||i.axis===r.axis)return false;for(const a of[true,false])for(const l of[true,false]){at(s);if(i.segment!==(a?0:t.points.length-2)||r.segment!==(l?0:n.points.length-2))continue;if((a?t.from:t.to)!==(l?n.from:n.to))continue;const c=t.points[a?0:t.points.length-1],d=n.points[l?0:n.points.length-1];if(lu(c,d)&&e.x0>=c.x-o&&e.x1<=c.x+o&&e.y0>=c.y-o&&e.y1<=c.y+o)return true}return false}function bU(e,t,n,i){if(e.routes.length!==t.length||e.half!==cn(n.lineWidth)/2||e.radius!==n.edgeBendRadius)return false;for(let r=0;r<t.length;r++){at(i);const o=t[r],s=e.routes[r];if(o.from!==s.from||o.to!==s.to||Jl(o)==="dashed"!==s.dashed||o.points.length!==s.raw.length)return false;for(let a=0;a<o.points.length;a++){at(i);if(!lu(o.points[a],s.raw[a]))return false}}return true}function SU(e,t,n,i){if(bU(e,t,n,i))return e;if(e.routes.length!==t.length||e.half!==cn(n.lineWidth)/2||e.radius!==n.edgeBendRadius)return vk(t,n,i);at(i);const r=new Set,o=[],s=[],a=[];for(let d=0;d<t.length;d++){at(i);const u=t[d],f=e.routes[d],h=Jl(u)==="dashed";let m=u.from===f.from&&u.to===f.to&&h===f.dashed&&u.points.length===f.raw.length;if(m)for(let b=0;b<u.points.length;b++){at(i);if(!lu(u.points[b],f.raw[b])){m=false;break}}if(m){o.push(f);continue}r.add(d);const p=[],g=[];for(const b of u.points){at(i);if(![b.x,b.y].every(Number.isFinite))throw new TypeError("Nonfinite Class header carrier");p.push({x:b.x,y:b.y});g.push({x:cn(b.x),y:cn(b.y)})}o.push({from:u.from,to:u.to,dashed:h,raw:p,points:g});const y=Rk(g,d,e.half,e.radius,i,p);if(!y)throw new Qe([{strategy:"class-header-lanes",violations:["Unproved noncardinal Class header carrier"]}]);for(const b of y){at(i);a.push(b)}}for(const d of e.pieces){at(i);if(!r.has(d.owner))s.push(d)}for(const d of a){at(i);s.push(d)}const l=W_(a,o,i);const c=(d,u)=>{at(i);const f=[];let h=0;for(const m of d){at(i);if(r.has(m.piece.owner))continue;while(h<u.length){at(i);const p=u[h];if((p.key-m.key||p.piece.owner-m.piece.owner||p.piece.segment-m.piece.segment)>0)break;f.push(p);h++}f.push(m)}for(;h<u.length;h++){at(i);f.push(u[h])}return f};return{routes:o,pieces:s,half:e.half,radius:e.radius,horizontal:c(e.horizontal,l.horizontal),vertical:c(e.vertical,l.vertical),horizontalEnds:c(e.horizontalEnds,l.horizontalEnds),verticalEnds:c(e.verticalEnds,l.verticalEnds),cornersX:c(e.cornersX,l.cornersX),cornersY:c(e.cornersY,l.cornersY),cornerHalfX:Math.max(e.cornerHalfX,l.cornerHalfX),cornerHalfY:Math.max(e.cornerHalfY,l.cornerHalfY)}}function z_(e,t,n,i){at(i);const r=e[Pk];if(!r)return void 0;at(i);e[Pk]=void 0;at(i);const o=S=>{for(let x=0;x<S;x++)at(i)};if(n.edgeBendRadius!==0||r.radius!==0||r.routes.length!==t.length)return void 0;let s;if(Number.isSafeInteger(n.lineWidth)){o(2);s=n.lineWidth/2}else{o(133);s=cn(n.lineWidth)/2}if(r.half!==s)return void 0;let a;for(let S=0;S<t.length;S++){at(i);const x=t[S],k=r.routes[S];if(x.from!==k.from||x.to!==k.to||Jl(x)==="dashed"!==k.dashed)return void 0;let w=x.points.length===k.raw.length;if(w)for(let C=0;C<x.points.length;C++){at(i);if(!lu(x.points[C],k.raw[C])){w=false;break}}if(!w){if(!a){at(i);a=new Set}at(i);a.add(S)}}if(!a){o(6);return{routes:r.routes,horizontal:r.horizontal,vertical:r.vertical,horizontalEnds:r.horizontalEnds,verticalEnds:r.verticalEnds}}o(r.routes.length+5);const l=r.routes.slice(),c=[],d=[],u=[],f=[];for(const S of a){at(i);const x=t[S];o(5);const k=[],w=[];for(const C of x.points){at(i);const R=Vi(C,o,o);if(!R)return void 0;o(R===C?8:5);k.push({x:C.x,y:C.y});w.push(R===C?{x:C.x,y:C.y}:R)}l[S]={raw:k,points:w};for(let C=1;C<w.length;C++){at(i);const R=w[C-1],M=w[C];if(lu(R,M)||R.x!==M.x&&R.y!==M.y)return void 0;o(15);const P={owner:S,segment:C-1},E=R.y===M.y;(E?c:d).push({key:E?R.y:R.x,piece:P});(E?u:f).push({key:E?R.x:R.y,piece:P},{key:E?M.x:M.y,piece:P})}}at(i);const h=(S,x)=>{at(i);return S.key-x.key||S.piece.owner-x.piece.owner||S.piece.segment-x.piece.segment};c.sort(h);d.sort(h);u.sort(h);f.sort(h);at(i);const m=(S,x)=>{at(i);const k=[];let w=0;for(const C of S){at(i);if(a.has(C.piece.owner))continue;while(w<x.length&&h(x[w],C)<=0){at(i);k.push(x[w++])}at(i);k.push(C)}for(;w<x.length;w++){o(2);k.push(x[w])}return k};const p=m(r.horizontal,c),g=m(r.vertical,d),y=m(r.horizontalEnds,u),b=m(r.verticalEnds,f);o(6);return{routes:l,horizontal:p,vertical:g,horizontalEnds:y,verticalEnds:b}}function wU(e,t,n,i){const r=n.routes[t],o={from:r.from,to:r.to,dashed:r.dashed,raw:e.map(s=>{at(i);return{...s}}),points:e.map(s=>{at(i);return{x:cn(s.x),y:cn(s.y)}})};return G_(o,t,n,i)}function G_(e,t,n,i){const r=Rk(e.points,t,n.half,n.radius,i,e.raw);if(!r)return false;for(const o of r)for(const s of gU(o,n,i)){at(i);if(s.owner===t||!pU(o.box,s.box))continue;const a=n.routes[s.owner];if(o.kind==="strip"&&s.kind==="strip"){at(i);if(yU(e.points[o.segment],e.points[o.segment+1],a.points[s.segment],a.points[s.segment+1]))continue}const l={x0:Math.max(o.box.x0,s.box.x0),x1:Math.min(o.box.x1,s.box.x1),y0:Math.max(o.box.y0,s.box.y0),y1:Math.min(o.box.y1,s.box.y1)};if(!xU(l,e,a,o,s,n.half,i))return false}return true}function*H_(e){const{charge:t}=e,n=e.peerContext?SU(e.peerContext,e.relationships,e.style,t):vk(e.relationships,e.style,t),i={x:cn(e.a.x),y:cn(e.a.y)},r={x:cn(e.b.x),y:cn(e.b.y)};const o=i.x===r.x;if(!o&&i.y!==r.y)return;const s=o?"y":"x",a=o?"x":"y",l=e.header;const c=cn(l[s]),d=cn(o?l.height:l.width),u=cn(c-e.gap),f=cn(c+d+e.gap);if(Math.min(i[s],r[s])>=u||Math.max(i[s],r[s])<=f)return;const h=[{side:"low",lane:cn(l[a]-e.escape)},{side:"high",lane:cn(l[a]+(o?l.width:l.height)+e.escape)}].sort((S,x)=>Math.abs(S.lane-i[a])-Math.abs(x.lane-i[a]));const m=Math.min(u-Math.min(i[s],r[s]),Math.max(i[s],r[s])-f),p=Math.max(1,cn(e.style.lineWidth)),g=new Set([0]);const y=S=>{if(S>0&&Number.isFinite(S)){const x=Math.ceil(S/p)*p;if(x<m)g.add(x)}};for(const S of n.pieces){at(t);if(S.owner===e.owner)continue;const x=o?S.box.y0:S.box.x0,k=o?S.box.y1:S.box.x1,w=o?S.box.x0:S.box.y0,C=o?S.box.x1:S.box.y1;y(u+n.half-x);y(k+n.half-f);y(h.find(R=>R.side==="low").lane+n.half-w);y(C+n.half-h.find(R=>R.side==="high").lane)}const b=[...g].sort((S,x)=>{at(t);return S-x});for(const S of b)for(const x of h){at(t);const k=cn(u-S),w=cn(f+S),C=cn(x.lane+(x.side==="low"?-S:S));const R={...i,[s]:i[s]<r[s]?k:w},M={...r,[s]:i[s]<r[s]?w:k};const P=[R,{...R,[a]:C},{...M,[a]:C},M];if(P.some(L=>L.x<n.half||L.y<n.half||L.x>e.width-n.half||L.y>e.height-n.half))continue;at(t);at(t);at(t);const E={active:true},v=new Ek(B_,E,e.owner,n,t);try{yield{points:P,side:x.side,offset:S,lane:C,low:k,high:w,peerContext:n,peerProof:v}}finally{E.active=false}}}function j_(e,t,n,i){if(!t.size)return;const r=vk(e.relationships,n,i);for(const o of t){at(i);if(!G_(r.routes[o],o,r,i))throw new Qe([{strategy:"class-header-lanes",violations:[`No proved final header carrier separation for ${r.routes[o].from} -> ${r.routes[o].to}`]}])}}var Mt=e=>{if(!Number.isFinite(e))throw new Qe([{strategy:"class-owned-surfaces",violations:["Nonfinite retained Class geometry"]}]);return Number(Ue(e))};var kn=e=>({x:Mt(e.x),y:Mt(e.y)});function Tk(e,t){const n=t?.get(e);if(n)return n;const i=Ue(e),r=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(i);const o={n:BigInt(r[1]+r[2]+(r[3]??"")),e:Number(r[4]??0)-(r[3]?.length??0)};t?.set(e,o);return o}function Wh(e,t,n,i){const r=t+n,o=e-r;if(Math.abs(o)>8*Number.EPSILON*Math.max(1,Math.abs(e),Math.abs(t),Math.abs(n)))return Math.sign(o);const s=Tk(e,i),a=Tk(t,i),l=Tk(n,i),c=Math.min(s.e,a.e,l.e),d=s.e===c?s.n:s.n*10n**BigInt(s.e-c),u=a.e===c?a.n:a.n*10n**BigInt(a.e-c),f=l.e===c?l.n:l.n*10n**BigInt(l.e-c),h=d-u-f;return h<0n?-1:h>0n?1:0}function hs(e,t,n){return Wh(Mt(e),Mt(t),Mt(n))}function wx(e,t){const n=[e,t].map(s=>{const a=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(Ue(Mt(s)));return{n:BigInt(a[1]+a[2]+(a[3]??"")),e:Number(a[4]??0)-(a[3]?.length??0)}});const i=Math.min(...n.map(s=>s.e)),r=n.reduce((s,a)=>s+a.n*10n**BigInt(a.e-i),0n),o=Number(`${r}e${i}`);return Number.isFinite(o)&&hs(o,e,t)===0?o:void 0}var fo=e=>{if(e.width<0||e.height<0||!Number.isFinite(e.x+e.width)||!Number.isFinite(e.y+e.height))throw new Qe([{strategy:"class-owned-surfaces",violations:["Invalid retained Class surface"]}]);return{x:Mt(e.x),y:Mt(e.y),width:Mt(e.width),height:Mt(e.height)}};var bx=(e,t)=>{const n=fo(e),i=fo(t);return n.x<i.x+i.width&&n.x+n.width>i.x&&n.y<i.y+i.height&&n.y+n.height>i.y};var Mx=4;var MU=8;var sl=(e,t)=>({x:e.x-t,y:e.y-t,width:e.width+2*t,height:e.height+2*t});function al(e,t,n){return Sx(kn(e),kn(t),fo(n))}function Sx(e,t,n,i){if(!(n.width>0&&n.height>0))return false;let r=0,o=1;for(let s=0;s<2;s++){const a=s===0?"x":"y";const l=a==="x"?n.width:n.height,c=n[a];if(e[a]<=c&&t[a]<=c)return false;const d=Wh(e[a],c,l,i),u=e[a]===t[a]?d:Wh(t[a],c,l,i);if(d>=0&&u>=0)return false;const f=d===0?l:e[a]-c,h=u===0?l:t[a]-c,m=h-f;if(m===0){if(e[a]<=c||d>=0)return false}else{const p=-f/m,g=(l-f)/m;r=Math.max(r,Math.min(p,g));o=Math.min(o,Math.max(p,g))}}return r<o}var cu=(e,t)=>e.some((n,i)=>i>0&&al(e[i-1],n,t));function xx(e,t,n,i,r,o){const s=(e.x-n)/r,a=(e.y-i)/o,l=(t.x-e.x)/r,c=(t.y-e.y)/o,d=l*l+c*c;const u=d?Math.max(0,Math.min(1,-(s*l+a*c)/d)):0;return(s+u*l)**2+(a+u*c)**2<1}function Y_(e,t,n,i){return q_({emitted:kn(e)},{emitted:kn(t)},{source:n,radius:i})}function q_(e,t,n,i){const r=n.emitted??=fo(n.inflation===void 0?n.source:sl(n.source,n.inflation));const o=n.rx??=Math.min(Math.max(0,n.radius),r.width/2),s=n.ry??=Math.min(Math.max(0,n.radius),r.height/2);const a=e.clipped??=kn(e.emitted),l=t.clipped??=kn(t.emitted);if(!o||!s)return Sx(a,l,n.unrounded??=fo(r),i);const c=n.firstStrip??=fo({x:r.x+o,y:r.y,width:r.width-2*o,height:r.height});if(Sx(a,l,c,i))return true;const d=n.secondStrip??=fo({x:r.x,y:r.y+s,width:r.width,height:r.height-2*s});if(Sx(a,l,d,i))return true;const u=n.left??=r.x+o,f=n.right??=r.x+r.width-o,h=n.top??=r.y+s,m=n.bottom??=r.y+r.height-s;if(e.emitted.x===t.emitted.x&&Math.abs((e.emitted.x-u)/o)>=1&&Math.abs((e.emitted.x-f)/o)>=1||e.emitted.y===t.emitted.y&&Math.abs((e.emitted.y-h)/s)>=1&&Math.abs((e.emitted.y-m)/s)>=1)return false;return xx(e.emitted,t.emitted,u,h,o,s)||xx(e.emitted,t.emitted,u,m,o,s)||xx(e.emitted,t.emitted,f,h,o,s)||xx(e.emitted,t.emitted,f,m,o,s)}function X_(e,t,n){if(e.length<3||t.length<3)return false;const i=e[0],r=e.map(a=>{n?.();return{x:a.x-i.x,y:a.y-i.y}}),o=t.map(a=>{n?.();return{x:a.x-i.x,y:a.y-i.y}}),s=[];for(const a of[r,o])for(let l=0;l<a.length;l++){n?.();const c=a[l],d=a[(l+1)%a.length];if(c.x!==d.x||c.y!==d.y)s.push({x:c.y-d.y,y:d.x-c.x})}for(const a of s){n?.();let l=Infinity,c=-Infinity,d=Infinity,u=-Infinity;for(const f of r){n?.();const h=f.x*a.x+f.y*a.y;l=Math.min(l,h);c=Math.max(c,h)}for(const f of o){n?.();const h=f.x*a.x+f.y*a.y;d=Math.min(d,h);u=Math.max(u,h)}if(Math.min(c,u)<=Math.max(l,d))return false}return s.length>0}function U_(e,t,n){if(t.width<=0||t.height<=0)return false;return X_(e,[{x:t.x,y:t.y},{x:t.x+t.width,y:t.y},{x:t.x+t.width,y:t.y+t.height},{x:t.x,y:t.y+t.height}],n)}function V_(e,t,n,i){if(n<=0||i.length<3)return false;let r=0,o=true,s=0;for(let a=0;a<i.length;a++){const l=i[a],c=i[(a+1)%i.length],d=c.x-l.x,u=c.y-l.y,f=d*(t-l.y)-u*(e-l.x);s+=(l.x-i[0].x)*(c.y-i[0].y)-(l.y-i[0].y)*(c.x-i[0].x);if(f){if(r&&Math.sign(f)!==r)o=false;r||=Math.sign(f)}const h=d*d+u*u,m=h?Math.max(0,Math.min(1,((e-l.x)*d+(t-l.y)*u)/h)):0;if((l.x+m*d-e)**2+(l.y+m*u-t)**2<n*n)return true}return s!==0&&o}function zh(e,t,n){const i=fo(t);return e.some(r=>{n?.();return r.kind==="polygon"?U_(r.points,i,n):CU(r.cx,r.cy,r.r,i)})}function Lk(e,t,n,i){e=kn(e);t=kn(t);const r=t.x-e.x,o=t.y-e.y,s=Math.hypot(r,o),a=i/2;if(!s||!(a>0))return false;const l=-o/s*a,c=r/s*a,d=[{x:e.x+l,y:e.y+c},{x:t.x+l,y:t.y+c},{x:t.x-l,y:t.y-c},{x:e.x-l,y:e.y-c}];return n.some(u=>u.kind==="polygon"?X_(d,u.points):V_(u.cx,u.cy,u.r,d))}function kU(e,t,n,i){const r=i/2;if(!(r>0))return false;for(let o=1;o+1<e.length;o++){const s=kn(e[o-1]),a=kn(e[o]),l=kn(e[o+1]);if(!(s.x===a.x&&a.y===l.y||s.y===a.y&&a.x===l.x))continue;if(t.some((c,d)=>d>0&&d+1<t.length&&Mt(c.x)===a.x&&Mt(c.y)===a.y&&Mt(t[d-1].x)===s.x&&Mt(t[d-1].y)===s.y&&Mt(t[d+1].x)===l.x&&Mt(t[d+1].y)===l.y))continue;if(zh(n,{x:a.x-r,y:a.y-r,width:i,height:i}))return true}return false}function K_(e,t,n,i,r,o){if(!(r.edgeBendRadius>0))return true;const s=Mt(r.lineWidth)/2;for(let a=1;a+1<e.length;a++){o?.();const l=e[a-1],c=e[a],d=e[a+1];if(t.some((b,S)=>{o?.();return S>0&&S+1<t.length&&b.x===c.x&&b.y===c.y&&t[S-1].x===l.x&&t[S-1].y===l.y&&t[S+1].x===d.x&&t[S+1].y===d.y}))continue;const u=qn([l,c,d],r.edgeBendRadius,{metric:"manhattan"});if(u.geometry.kind!=="path")return false;const f=/L([^LQ]+)Q([^LQ]+)/.exec(u.geometry.d);if(!f)continue;const h=(f[1]+" "+f[2]).trim().split(/[ ,]+/).map(Number);if(h.length!==6||h.some(b=>!Number.isFinite(b)))return false;const m=[{x:Mt(h[0]),y:Mt(h[1])},{x:Mt(h[2]),y:Mt(h[3])},{x:Mt(h[4]),y:Mt(h[5])}];if(n.some(b=>{o?.();return U_(m,sl(fo(b),s),o)}))return false;const p=m.map(b=>b.x),g=m.map(b=>b.y),y={x:Math.min(...p)-s,y:Math.min(...g)-s,width:Math.max(...p)-Math.min(...p)+2*s,height:Math.max(...g)-Math.min(...g)+2*s};if(i.some(b=>{o?.();return zh(b,y,o)}))return false}return true}function J_(e,t){const n=fo(t),i=Math.min(2,n.width/2,n.height/2);if(!i)return false;const r=[{x:n.x+i,y:n.y,width:n.width-2*i,height:n.height},{x:n.x,y:n.y+i,width:n.width,height:n.height-2*i}];if(r.some(o=>zh(e,o)))return true;for(const o of[n.x+i,n.x+n.width-i])for(const s of[n.y+i,n.y+n.height-i])for(const a of e){if(a.kind==="circle"?(a.cx-o)**2+(a.cy-s)**2<(a.r+i)**2:V_(o,s,i,a.points))return true}return false}function CU(e,t,n,i){if(n<=0||i.width<=0||i.height<=0)return false;const r=e-Math.max(i.x,Math.min(i.x+i.width,e)),o=t-Math.max(i.y,Math.min(i.y+i.height,t));return r*r+o*o<n*n}function No(e,t,n=true,i,r=true){const o=[],s=n?Fo(t):[],a=su/2;e.relationships.forEach((l,c)=>{i?.();const d=au(l);if(r&&l.label&&d&&l.labelBlock?.text)o.push({edge:c,kind:"label",box:{x:d.x-l.labelBlock.width/2-a,y:d.y-ea-l.labelBlock.height/2-a,width:l.labelBlock.width+2*a,height:l.labelBlock.height+2*a}});for(const b of["from","to"]){i?.();const S=l[`${b}CardinalityBlock`],x=Cc(l,b);if(r&&S?.text&&x)o.push({edge:c,kind:"cardinality",box:{x:x.x-S.width/2-a,y:x.y-S.height/2-a,width:S.width+2*a,height:S.height+2*a}})}if(!n)return;const u=l.markerAt==="from"||l.markerAt==="both"?Ci(l.fromType??l.type):null,f=l.markerAt==="to"||l.markerAt==="both"?Ci(l.toType??l.type):null;const h=kn(l.points[0]??{x:0,y:0}),m=kn(l.points.at(-1)??h);let p=h,g=m;for(let b=1;b<l.points.length;b++){i?.();const S=kn(l.points[b]);if(S.x!==h.x||S.y!==h.y){p=S;break}}for(let b=l.points.length-2;b>=0;b--){i?.();const S=kn(l.points[b]);if(S.x!==m.x||S.y!==m.y){g=S;break}}const y=_o({id:"class-owned-paint",role:"relationship",geometry:{kind:"polyline",points:[h,p,g,m]},lineStyle:"solid",paint:{strokeWidth:String(Mt(t.lineWidth))},markers:{...u?{start:s.find(b=>b.id===u)}:{},...f?{end:s.find(b=>b.id===f)}:{}}});for(const b of jr(y)){i?.();const S=b.bounds;if(!S)throw new TypeError("Class marker paint has no finite bound");const x=b.position==="start",k=s.find(L=>L.id===b.resource);const w=x?h:m,C=x?{x:p.x-h.x,y:p.y-h.y}:{x:m.x-g.x,y:m.y-g.y};const R=Do(k,w,C,x?"start":"end",Mt(t.lineWidth),i);let M=S.x0,P=S.y0,E=S.x1,v=S.y1;for(const L of R){i?.();if(L.kind==="circle"){M=Math.min(M,L.cx-L.r);E=Math.max(E,L.cx+L.r);P=Math.min(P,L.cy-L.r);v=Math.max(v,L.cy+L.r)}else for(const T of L.points){i?.();M=Math.min(M,T.x);E=Math.max(E,T.x);P=Math.min(P,T.y);v=Math.max(v,T.y)}}o.push({edge:c,kind:"marker",endpoint:x?"from":"to",pieces:R,box:{x:M,y:P,width:E-M,height:v-P}})}});return o}function PU(e){const t=ii(e.map(kn));for(let n=1;n<t.length;n++){const i=t[n-1],r=t[n],o=i.x===r.x;if(!o&&i.y!==r.y)return false;for(let s=1;s<n;s++){const a=t[s-1],l=t[s],c=a.x===l.x;if(o===c){const d=o?"y":"x",u=o?"x":"y";if(i[u]!==a[u])continue;const f=Math.max(Math.min(i[d],r[d]),Math.min(a[d],l[d])),h=Math.min(Math.max(i[d],r[d]),Math.max(a[d],l[d]));if(s===n-1?f<h:f<=h)return false}else if(s!==n-1){const d=o?i.x:a.x,u=o?a.y:i.y;if(d>=Math.min(i.x,r.x)&&d<=Math.max(i.x,r.x)&&u>=Math.min(i.y,r.y)&&u<=Math.max(i.y,r.y)&&d>=Math.min(a.x,l.x)&&d<=Math.max(a.x,l.x)&&u>=Math.min(a.y,l.y)&&u<=Math.max(a.y,l.y))return false}}}return true}function Ak(e,t,n){n();if(!(t>0)||!Number.isFinite(t))return void 0;let i=Infinity,r=Infinity,o=-Infinity,s=-Infinity;for(const a of e){n();if(!Number.isFinite(a.x)||!Number.isFinite(a.y))return void 0;i=Math.min(i,a.x);r=Math.min(r,a.y);o=Math.max(o,a.x);s=Math.max(s,a.y)}i-=t;r-=t;o+=t;s+=t;if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(o)||!Number.isFinite(s))return void 0;for(let a=0;a<5;a++)n();return{x0:i,y0:r,x1:o,y1:s}}function Ik(e,t,n){n();if(!e||!(t.width>=0&&t.height>=0))return true;const i=t.x+t.width,r=t.y+t.height,o=(Math.abs(e.x0)+Math.abs(e.y0)+Math.abs(e.x1)+Math.abs(e.y1)+Math.abs(t.x)+Math.abs(t.y)+Math.abs(i)+Math.abs(r))*1e-10+1e-9,s=t.x-e.x1,a=e.x0-i,l=t.y-e.y1,c=e.y0-r;return!Number.isFinite(o)||!Number.isFinite(s)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)||!(s>o||a>o||l>o||c>o)}function Q_(e,t,n,i){const r=new Set;if(!e.namespaces.length){if(i){const y=n??fs();if(!ri(y))throw new Qe([{strategy:"class-header-lanes",violations:["Class header proof work limit"]}]);yx(i,void 0)}return r}const o=n??fs(),s=()=>ri(o),a=()=>{if(!s())throw new Qe([{strategy:"class-header-lanes",violations:["Class header proof work limit"]}])};if(i){a();yx(i,void 0)}const l=e.namespaces.map(y=>{a();return sl({x:y.x,y:y.y,width:y.width,height:y.headerHeight},t.lineWidth/2)}),c=No(e,t,true,a,false),d=e.classes.filter(y=>{a();return!y.isInterface}),u=[];const f=c;let h=0;for(const y of e.classes){a();if(!y.isInterface)continue;if(y.interfaceBox)u.push(y.interfaceBox);const b=y.labelBlock;if(b)u.push({x:y.x+(y.width-b.width)/2,y:y.y+y.headerHeight/2-b.height/2,width:b.width,height:b.height})}if(e.title){a();const y=e.title,b=y.block??tn(y.text,t)?.block;if(b){u.push({x:y.x-b.width/2,y:y.y-b.height/2,width:b.width,height:b.height});h=y.y+b.height/2+t.lineWidth/2}}const m=[...d.map(y=>{a();return sl(y,t.lineWidth/2)}),...l,...u.map(y=>{a();return sl(y,t.lineWidth/2)})];let p;const g=e.relationships.map((y,b)=>{a();let S=Infinity;for(const x of l)for(let k=1;k<y.points.length;k++){a();const w=kn(y.points[k-1]),C=kn(y.points[k]);if(!al(w,C,x))continue;const R=w.x===C.x;if(!R&&w.y!==C.y)continue;const M=R?"y":"x",P=Mt(x[M]),E=Mt(R?x.height:x.width),v=Math.max(Mx,t.lineWidth/2),L=Mt(P-v),T=Mt(P+E+v);S=Math.min(S,L-Math.min(w[M],C[M]),Math.max(w[M],C[M])-T)}return{ri:b,slack:S}}).sort((y,b)=>{a();return y.slack-b.slack||y.ri-b.ri});for(const{ri:y}of g){a();const b=e.relationships[y];for(const S of l){a();if(!cu(b.points,S))continue;for(let x=1;x<b.points.length;x++){a();const k=b.points[x-1],w=b.points[x];if(!al(k,w,S))continue;const C=Math.max(Mx,t.lineWidth/2),R=Math.max(MU,t.edgeBendRadius+t.lineWidth/2);let M;for(const P of H_({header:S,a:k,b:w,owner:y,relationships:e.relationships,width:e.width,height:e.height,style:t,gap:C,escape:R,charge:s,peerContext:p})){p=P.peerContext;a();const E=P.points;if(E.some(A=>{a();return A.y<h}))continue;if(m.some(A=>{a();return cu(E,A)}))continue;const v=Ak(E,t.lineWidth,a);if(f.some(A=>Ik(v,A.box,a)&&E.some(($,_)=>{a();return _>0&&Lk(E[_-1],$,A.pieces??[],t.lineWidth)})))continue;const L=ii([...b.points.slice(0,x),...E,...b.points.slice(x)]);const T=va(L,kc(b,t));if(!T)continue;if(T!==L&&f.some(A=>T.some(($,_)=>{a();if(!_||A.edge===y&&(A.endpoint==="from"&&_===1||A.endpoint==="to"&&_===T.length-1))return false;const z=T[_-1],F=L[_-1],G=L[_];if(z.x===F.x&&z.y===F.y&&$.x===G.x&&$.y===G.y)return false;return Lk(z,$,A.pieces??[],t.lineWidth)})))continue;if(!PU(T)||t.edgeBendRadius<=0&&f.some(A=>{a();return kU(T,b.points,A.pieces??[],t.lineWidth)}))continue;if(t.edgeBendRadius>0&&!K_(T,b.points,m,c.filter(A=>A.kind==="marker").map(A=>A.pieces??[]),t,a))continue;if(T[0].x!==b.points[0].x||T[0].y!==b.points[0].y||T.at(-1).x!==b.points.at(-1).x||T.at(-1).y!==b.points.at(-1).y)continue;if([...d,...u,...l.filter(A=>A!==S&&!cu(b.points,A))].some(A=>{a();return cu(T,A)}))continue;if(!P.peerProof.clear(T))continue;a();M={points:T,length:E.length};break}if(M){a();b.points=M.points;r.add(y);x+=Math.max(0,M.length-2)}}}}if(i){a();yx(i,p)}return r}function Fk(e,t,n,i){if(!e.notes.length)return;const r=i??fs(),o=()=>{if(!ri(r))throw new Qe([{strategy:"class-owned-note",violations:["Class note proof work limit"]}])},s=e.title?e.title.block??tn(e.title.text,t)?.block:void 0,a=Math.max(n,e.title&&s?e.title.y+s.height/2+vl:n),l=e.namespaces.map(f=>{o();return{x:f.x,y:f.y,width:f.width,height:f.headerHeight}});let c=No(e,t,true,o,false);const d=e.classes.filter(f=>{o();return f.isInterface}).map(f=>{o();const h=f.labelBlock;return h?{x:f.x+(f.width-h.width)/2,y:f.y+f.headerHeight/2-h.height/2,width:h.width,height:h.height}:{x:f.x,y:f.y,width:f.width,height:f.height}});const u=(f,h,m=false)=>{o();if(!m&&f.y<a)return false;const p=e.notes.filter((y,b)=>{o();return b!==h}),g=[...e.classes.filter(y=>{o();return!y.isInterface}),...d,...l,...p];if(g.some(y=>{o();return bx(f,y)})||c.some(y=>{o();return y.kind==="marker"&&J_(y.pieces??[],f)}))return false;for(const y of e.relationships)for(let b=1;b<y.points.length;b++){o();if(Y_(y.points[b-1],y.points[b],f,2))return false}if(t.edgeBendRadius>0)for(const y of e.relationships){o();if(!K_(y.points,[],[f],[],t,o))return false}if(f.targetX!==void 0&&f.targetY!==void 0){const y={x:f.targetX,y:f.targetY},b={x:f.noteX??f.x,y:f.noteY??f.y+f.height/2};if(g.some(C=>{o();return al(y,b,C)})||c.some(C=>{o();return C.kind==="marker"&&Lk(y,b,C.pieces??[],1)}))return false;const S=kn(y),x=kn(b),k=S.y===x.y,w=S.x===x.x;if(k&&w)return false;if((k||w)&&t.lineWidth>0)for(const C of e.relationships)for(let R=1;R<C.points.length;R++){o();const M=kn(C.points[R-1]),P=kn(C.points[R]),E=(1+Mt(t.lineWidth))/2;const v=k?M.y===P.y&&Math.abs(M.y-S.y)<E:M.x===P.x&&Math.abs(M.x-S.x)<E;if(!v)continue;const L=k?"x":"y";if(Math.max(Math.min(S[L],x[L]),Math.min(M[L],P[L]))<Math.min(Math.max(S[L],x[L]),Math.max(M[L],P[L])))return false}}return true};for(let f=0;f<e.notes.length;f++){o();const h=e.notes[f];if(u(h,f))continue;const m=e.classes.find(S=>{o();return S.id===h.for}),p=[];if(m){for(let x=0;x<Math.max(4,e.notes.length+1);x++){o();const k=x*(h.height+12);p.push({...h,x:m.x+m.width+24,y:m.y+k,targetX:m.x+m.width,targetY:m.y+m.height/2,noteX:m.x+m.width+24,noteY:m.y+k+h.height/2},{...h,x:m.x-h.width-24,y:m.y+k,targetX:m.x,targetY:m.y+m.height/2,noteX:m.x-24,noteY:m.y+k+h.height/2},{...h,x:m.x,y:m.y+m.height+24+k,targetX:m.x+m.width/2,targetY:m.y+m.height,noteX:m.x+h.width/2,noteY:m.y+m.height+24+k})}p.push({...h,x:e.width+24,y:m.y,targetX:m.x+m.width,targetY:m.y+m.height/2,noteX:e.width+24,noteY:m.y+h.height/2});const S=Math.min(t.cornerRadius??0,m.width/2,m.height/2);for(let x=0;x<Math.max(4,e.notes.length+1);x++){const k=m.y+m.height+12+x*(h.height+12);for(const w of[true,false]){o();const C=m.x+(w?m.width:0),R=m.x+(w?Math.min(m.width*.75,m.width-S):Math.max(m.width*.25,S));p.push({...h,x:C-h.width/2,y:k,targetX:R,targetY:m.y+m.height,noteX:C,noteY:k})}}}else p.push({...h,x:n,y:e.height+16});let g=p.find(S=>{o();return S.x>=n&&S.y>=a&&u(S,f)});if(!g)g=p.find(S=>{o();return S.x<n&&S.y>=a&&u(S,f)});if(!g&&m&&!m.isInterface){const S=Math.min(t.cornerRadius??0,m.width/2,m.height/2);e:for(let x=0;x<Math.max(4,e.notes.length+1);x++)for(const k of[true,false]){o();const w=m.x+(k?m.width:0),C=m.x+(k?Math.min(m.width*.75,m.width-S):Math.max(m.width*.25,S)),R=m.y-h.height-12-x*(h.height+12),M={...h,x:w-h.width/2,y:R,targetX:C,targetY:m.y,noteX:w,noteY:R+h.height};if(u(M,f,true)){g=M;break e}}}if(!g)throw new Qe([{strategy:"class-owned-note",violations:[`No safe note seat for ${h.for??"unattached annotation"}`]}]);const y=Math.max(0,n-g.x),b=Math.max(0,a-g.y);if(!Number.isFinite(e.width+y)||!Number.isFinite(e.height+b))throw new Qe([{strategy:"class-owned-note",violations:["No finite leading room for note"]}]);for(const S of Object.keys(g))o();Object.assign(h,g);if(y>0||b>0){const S=[];for(const x of e.notes){o();const k=e.classes.find(C=>{o();return C.id===x.for});if(!k||k.isInterface||x.targetX===void 0||x.targetY===void 0)continue;const w=x.x>k.x+k.width?"E":x.x+x.width<k.x?"W":x.y>k.y+k.height?"S":x.y+x.height<k.y?"N":void 0;if(w){o();S.push({note:x,node:k,side:w})}}for(const x of e.classes){o();x.x+=y;x.y+=b;if(x.interfaceBox){o();x.interfaceBox.x+=y;x.interfaceBox.y+=b}}for(const x of e.namespaces){o();x.x+=y;x.y+=b}for(const x of e.notes){o();x.x+=y;x.y+=b;if(x.targetX!==void 0)x.targetX+=y;if(x.targetY!==void 0)x.targetY+=b;if(x.noteX!==void 0)x.noteX+=y;if(x.noteY!==void 0)x.noteY+=b}for(const x of e.relationships){o();for(const k of x.points){o();k.x+=y;k.y+=b}for(const k of[x.labelPosition,x.fromCardinalityPosition,x.toCardinalityPosition])if(k){o();k.x+=y;k.y+=b}}for(const x of l){o();x.x+=y;x.y+=b}for(const x of d){o();x.x+=y;x.y+=b}e.width+=y;e.height+=b;for(const{note:x,node:k,side:w}of S){o();const C=w==="E"||w==="S",R=w==="E"||w==="W"?"x":"y",M=k[R],P=R==="x"?k.width:k.height,E=C?wx(M,P):Mt(M),v=C?Mt(x[R]):wx(x[R],R==="x"?x.width:x.height);if(E===void 0||v===void 0)throw new Qe([{strategy:"class-owned-note",violations:["Exact note contact is not representable"]}]);if(R==="x"){x.targetX=E;x.noteX=v}else{x.targetY=E;x.noteY=v}}c=No(e,t,true,o,false)}e.width=Math.max(e.width,h.x+h.width+n);e.height=Math.max(e.height,h.y+h.height+n);if(e.title)e.title.x=e.width/2;if(!u(h,f))throw new Qe([{strategy:"class-owned-note",violations:["Unproved translated note seat"]}])}}function Z_(e,t){const n=[],i=e.namespaces.map(d=>({id:d.id,x:d.x,y:d.y,width:d.width,height:d.headerHeight})),r=No(e,t,i.length>0||e.notes.length>0),o=t.lineWidth/2;for(const d of[...e.classes,...e.notes,...i])fo(d);const s=new Map(e.classes.map(d=>[d.id,d]));const a=new Map;const l=[],c=[];for(let d=0;d<e.relationships.length;d++){const u=e.relationships[d];if(u.points.length<2){n.push(`Relationship ${u.from} -> ${u.to} has no visible route`);continue}for(const m of[true,false]){const p=s.get(m?u.from:u.to);if(!p){n.push("Undeclared Class endpoint");continue}if(p.isInterface)continue;const g=kn(m?u.points[0]:u.points.at(-1)),y=kn(m?u.points[1]:u.points.at(-2)),b=fo(p),S=b.x+b.width,x=b.y+b.height;if(!(g.x===b.x&&g.y>=b.y&&g.y<=x&&y.x<g.x&&y.y===g.y||Wh(g.x,b.x,b.width,a)===0&&g.y>=b.y&&g.y<=x&&y.x>g.x&&y.y===g.y||g.y===b.y&&g.x>=b.x&&g.x<=S&&y.y<g.y&&y.x===g.x||Wh(g.y,b.y,b.height,a)===0&&g.x>=b.x&&g.x<=S&&y.y>g.y&&y.x===g.x))n.push(`Relationship ${u.from} -> ${u.to} lacks an outward Class contact`)}const f=[];const h=m=>f[m]??={emitted:kn(u.points[m])};for(let m=1;m<u.points.length;m++){const p=u.points[m-1],g=u.points[m];for(const y of i)if(al(p,g,sl(y,o)))n.push(`Relationship ${u.from} -> ${u.to} enters namespace header ${y.id}`);for(const y of e.notes)if(Y_(p,g,sl(y,o),2+o))n.push(`Relationship ${u.from} -> ${u.to} enters note ${y.for??""}`);for(let y=0;y<e.classes.length;y++){const b=e.classes[y];if(b.isInterface)continue;const S=m===1&&b.id===u.from||m===u.points.length-1&&b.id===u.to;const x=t.cornerRadius??0,k=S?l:c;const w=k[y]??={source:b,...S?{}:{inflation:o},radius:S?x:x+o};if(q_(h(m-1),h(m),w,a))n.push(`Relationship ${u.from} -> ${u.to} enters card ${b.id}`)}}}for(let d=0;d<r.length;d++){const u=r[d],f=e.relationships[u.edge];for(const h of i)if(u.kind==="marker"?zh(u.pieces??[],h):bx(u.box,h))n.push(`${u.kind} enters namespace header ${h.id}`);for(const h of e.notes)if(u.kind==="marker"?J_(u.pieces??[],h):bx(u.box,h))n.push(`${u.kind} enters note ${h.for??""}`);if(u.kind!=="marker"){for(const h of e.classes)if(!h.isInterface&&bx(u.box,h))n.push(`${u.kind} enters card ${h.id}`)}}return n}function eD(e,t,n,i){const r=new Map(n),o=No(e,t).filter(h=>h.kind==="marker"),s=new Map(e.namespaces.map(h=>[h.id,h])),a=new Map(e.namespaces.flatMap(h=>h.classIds.map(m=>[m,h.id])));for(const h of e.namespaces){const m={x:h.x,y:h.y,width:h.width,height:h.headerHeight},p=e.relationships.some(y=>cu(y.points,m))?Mx+t.lineWidth/2:0,g={...m,height:m.height+p};for(const y of o){if(!zh(y.pieces??[],g))continue;const b=e.relationships[y.edge],S=y.endpoint==="from"?b.from:b.to,x=e.classes.find(C=>C.id===S);let k=a.get(S);for(let C=0;k&&k!==h.id&&C<=s.size;C++)k=s.get(k)?.parentId;if(k!==h.id||!x||x.y<m.y+m.height)continue;const w=m.y+m.height+p-y.box.y;if(w>0&&Number.isFinite(w))r.set(h.id,Math.max(r.get(h.id)??t.groupPaddingY,Math.ceil((n.get(h.id)??t.groupPaddingY)+w)))}}const l=Mt(t.lineWidth)/2;if(!(l>0))return r;const c=()=>{if(i&&!ri(i))throw new Qe([{strategy:"class-header-capacity",violations:["Class header capacity proof work limit"]}])},d=new Map(e.classes.map(h=>{c();return[h.id,h]})),u=new Map(o.map(h=>{c();return[`${h.edge}:${h.endpoint}`,h]})),f=new Map;for(let h=0;h<e.relationships.length;h++){const m=e.relationships[h];for(const p of[true,false]){c();const g=d.get(p?m.from:m.to);if(!g||g.isInterface||m.points.length<2)continue;const y=p?m.points[0]:m.points.at(-1),b=p?m.points[1]:m.points.at(-2);if(hs(y.y,g.y,0)!==0||Mt(b.x)!==Mt(y.x)||Mt(b.y)>=Mt(y.y))continue;let S=l;const x=u.get(`${h}:${p?"from":"to"}`);for(const R of x?.pieces??[]){c();if(R.kind==="circle")S=Math.max(S,Mt(y.y)-R.cy+R.r);else for(const M of R.points){c();S=Math.max(S,Mt(y.y)-M.y)}}const k=Math.max(0,t.edgeBendRadius);let w=Mt(y.y)-S-Math.min(k,l+S),C=a.get(g.id);for(let R=0;C&&R<=s.size;R++){c();const M=s.get(C);const P={x:M.x,y:M.y,width:M.width,height:M.headerHeight};if(cu(m.points,sl(P,l))){const E=w-Mt(M.y)-Mt(M.headerHeight),v=f.get(C);f.set(C,{count:(v?.count??0)+1,free:Math.min(v?.free??Infinity,E)});w=Mt(M.y)-k-l}C=M.parentId}}}for(const[h,m]of f){c();const p=Math.ceil(m.count/2),g=Mx+2*l+(p-1)*Math.max(1,Mt(t.lineWidth));if(m.free<g){const y=Math.ceil((n.get(h)??t.groupPaddingY)+g-m.free);if(Number.isFinite(y))r.set(h,Math.max(r.get(h)??t.groupPaddingY,y))}}return r}function fs(){return{operations:0,pairs:0,exhausted:false}}function ri(e){if(e.exhausted||e.operations>=ws){e.exhausted=true;return false}e.operations++;return true}var tD=(e,t)=>e.x0<=t.x&&t.x<=e.x1&&e.y0<=t.y&&t.y<=e.y1;var EU=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1;function nD(e,t,n,i=fs()){if(t.edgeBendRadius>0||i.exhausted)return;const r=()=>ri(i);const o=om();const s=u=>o(u,n);const a=Xn("stroke-width",String(t.lineWidth)),l=Fo(t),c=[];for(let u=0;u<e.relationships.length;u++){if(!r())return;const f=e.relationships[u];if(f.points.length<2)continue;const h=f.markerAt==="from"||f.markerAt==="both"?l.find(x=>x.id===Ci(f.fromType??f.type)):void 0;const m=f.markerAt==="to"||f.markerAt==="both"?l.find(x=>x.id===Ci(f.toType??f.type)):void 0;if(!h&&!m)continue;const p={x:Number(Ue(f.points[0].x)),y:Number(Ue(f.points[0].y))},g={x:Number(Ue(f.points.at(-1).x)),y:Number(Ue(f.points.at(-1).y))};let y=p,b=g;for(let x=1;x<f.points.length;x++){if(!r())return;const k=f.points[x],w=Number(Ue(k.x)),C=Number(Ue(k.y));if(w!==p.x||C!==p.y){y={x:w,y:C};break}}for(let x=f.points.length-2;x>=0;x--){if(!r())return;const k=f.points[x],w=Number(Ue(k.x)),C=Number(Ue(k.y));if(w!==g.x||C!==g.y){b={x:w,y:C};break}}const S=_o({id:`class-marker-proof:${u}`,role:"chrome",owner:{id:`relationship:${u}`,role:"relationship"},geometry:{kind:"polyline",points:[p,y,b,g]},lineStyle:"solid",paint:{fill:"none",stroke:t.edgeStrokeColor??"var(--_line)",strokeWidth:a},stroke:{opacity:0},endpoints:{from:f.from,to:f.to},markers:{...h?{start:h}:{},mid:[],...m?{end:m}:{}}});for(const x of jr(S)){if(!r()||!x.bounds)return;const k=x.position==="start"?h:x.position==="end"?m:void 0;const w=tb({colors:n},S,k,x.position,r,s);if(i.exhausted)return;c.push({owner:`relationship ${u} ${f.from}->${f.to} ${x.position}`,bounds:x.bounds,proof:w})}}if(c.length<2)return;if(e.relationships.some(u=>!!u.label&&!u.labelPosition))return;const d=No(e,t,false).map(u=>({x0:u.box.x,y0:u.box.y,x1:u.box.x+u.box.width,y1:u.box.y+u.box.height}));for(const u of e.notes){if(!r())return;d.push({x0:u.x-1,y0:u.y-1,x1:u.x+u.width+1,y1:u.y+u.height+1});if(u.targetX!==void 0&&u.targetY!==void 0){const f=u.noteX??u.x,h=u.noteY??u.y+u.height/2;d.push({x0:Math.min(u.targetX,f)-1,y0:Math.min(u.targetY,h)-1,x1:Math.max(u.targetX,f)+1,y1:Math.max(u.targetY,h)+1})}}for(let u=0;u<c.length;u++)for(let f=u+1;f<c.length;f++){if(!r())return;const h=c[u],m=c[f];if(!EU(h.bounds,m.bounds))continue;if(i.pairs>=Oo){i.exhausted=true;return}i.pairs++;let p=0;while(h.proof&&p<h.proof.strokeWitnesses.length){const g=nb(h.proof,m.proof,r,p);if(i.exhausted)return;if(typeof g==="string")break;let y=p;for(;y<h.proof.strokeWitnesses.length;y++){if(!r())return;if(h.proof.strokeWitnesses[y]===g)break}if(y===h.proof.strokeWitnesses.length)return;p=y+1;let b=false;for(let S=f+1;S<c.length;S++){if(!r())return;if(tD(c[S].bounds,g)){b=true;break}}if(!b)for(const S of d){if(!r())return;if(tD(S,g)){b=true;break}}if(!b)throw new Qe([{strategy:"class-marker-meaning",violations:[`Later marker ${m.owner} covers actual stroke ink of ${h.owner}`]}])}}}var ho=e=>Number(Ue(e));var Nk=(e,t)=>e.x<t.x+t.width&&t.x<e.x+e.width&&e.y<t.y+t.height&&t.y<e.y+e.height;var $k=(e,t)=>{const n=ho(e.block.width),i=ho(e.block.height),r=su/2;return{x:t.x-n/2-r,y:t.y-i/2-r,width:n+2*r,height:i+2*r}};var iD=(e,t)=>({x:ho(e.x),y:ho(e.y-(t==="caption"?ea:0))});function _k(e,t,n,i){if(!e.relationships.some(f=>f.markerAt!=="none")&&!i?.size||!e.relationships.some(f=>f.label||f.fromCardinality||f.toCardinality))return;const r=()=>{if(!ri(n))throw new Qe([{strategy:"class-owned-annotation",violations:["Class annotation proof work limit"]}])};const o=[];for(const[f,h]of e.relationships.entries()){r();if(h.points.length<2)continue;const m=(p,g,y)=>{if(!g||!y.text)return;r();o.push({rel:h,edge:f,role:p,original:g,block:y,center:iD(g,p)})};if(h.label)m("caption",au(h),h.labelBlock??di(qe(h.label,h.labelContent),t,"edge"));for(const p of["from","to"])if(h[`${p}Cardinality`])m(p,Cc(h,p),h[`${p}CardinalityBlock`]??_e(qe(h[`${p}Cardinality`],h[`${p}CardinalityContent`]),{fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing}))}const s=No(e,t,true,r,false).filter(f=>{r();return f.kind==="marker"});const a=[];if(e.title){r();const f=e.title,h=f.block??tn(f.text,t)?.block;if(h)a.push({x:ho(f.x)-ho(h.width)/2,y:ho(f.y)-ho(h.height)/2,width:ho(h.width),height:ho(h.height)})}for(const f of e.classes){r();if(!f.isInterface)a.push({x:f.x-1,y:f.y-1,width:f.width+2,height:f.height+2});else{if(f.interfaceBox)a.push(f.interfaceBox);const h=f.labelBlock;if(h)a.push({x:f.x+(f.width-h.width)/2,y:f.y+f.headerHeight/2-h.height/2,width:h.width,height:h.height})}}for(const f of e.namespaces){r();a.push({x:f.x,y:f.y,width:f.width,height:f.headerHeight})}for(const f of e.notes){r();a.push(f)}const l=(f,h)=>{r();const m=$k(f,h);if(f.role==="caption"&&i?.has(f.edge)){const p={x:m.x-8,y:m.y-8,width:m.width+16,height:m.height+16};let g=false;for(let y=1;y<f.rel.points.length;y++){r();if(al(f.rel.points[y-1],f.rel.points[y],p)){g=true;break}}if(!g)return false}if(m.x<0||m.y<0||m.x+m.width>e.width||m.y+m.height>e.height)return false;for(const p of a){r();if(Nk(m,p))return false}for(const p of e.notes){r();if(p.targetX!==void 0&&p.targetY!==void 0&&al({x:p.targetX,y:p.targetY},{x:p.noteX??p.x,y:p.noteY??p.y+p.height/2},{x:m.x-.5,y:m.y-.5,width:m.width+1,height:m.height+1}))return false}for(const p of s){r();if(Nk(m,p.box))return false}return true};const c=(f,h,m)=>{r();return!Nk($k(f,h),$k(m,m.next??m.center))};for(const f of o){if(!l(f,f.center))continue;f.fixed=true;for(const h of o)if(h!==f&&!c(f,f.center,h)){f.fixed=false;break}}const d=o.filter(f=>{r();return f.fixed});const u=(f,h)=>{if(!l(f,h))return false;for(const m of d)if(!c(f,h,m))return false;f.next=h;d.push(f);return true};for(const f of o){r();if(f.fixed)continue;if(u(f,f.center))continue;let h=false,m=0;if(f.role!=="caption"){const p=f.role==="from",g=f.rel.points,y=p?g[0]:g.at(-1),b=p?g[1]:g.at(-2);const S=[];for(const x of gx(y,b)){r();const k=iD(x,f.role);S.push({point:k,distance:(k.x-f.center.x)**2+(k.y-f.center.y)**2,order:S.length})}S.sort((x,k)=>{r();return x.distance-k.distance||x.order-k.order});for(const{point:x}of S){r();if(++m>Ck)break;if(u(f,x)){h=true;break}}}else{const p=[];for(let g=1;g<f.rel.points.length;g++){r();const y=f.rel.points[g-1],b=f.rel.points[g],S=b.x-y.x,x=b.y-y.y,k=S*S+x*x?Math.max(0,Math.min(1,((f.center.x-y.x)*S+(f.center.y-y.y)*x)/(S*S+x*x))):0;p.push({a:y,b,index:g,distance:(f.center.x-y.x-S*k)**2+(f.center.y-y.y-x*k)**2})}p.sort((g,y)=>{r();return g.distance-y.distance||g.index-y.index});e:for(const{a:g,b:y}of p){r();if(g.x!==y.x&&g.y!==y.y)continue;for(const b of[.5,1/3,2/3,.25,.75,1/6,5/6])for(const S of[-1,1]){r();if(++m>Ck)break e;const x=g.x===y.x,k={x:ho(g.x+(y.x-g.x)*b+(x?S*(f.block.width/2+ea):0)),y:ho(g.y+(y.y-g.y)*b+(x?0:S*ea))};if(u(f,k)){h=true;break e}}}}if(!h)throw new Qe([{strategy:"class-owned-annotation",violations:[`No separated ${f.role} text seat for ${f.rel.from} -> ${f.rel.to} in the existing bounded candidates`]}])}for(const f of o){const h=f.next??f.center;if(!l(f,h))throw new Qe([{strategy:"class-owned-annotation",violations:["Unproved final annotation seat"]}]);for(const m of o)if(m!==f&&!c(f,h,m))throw new Qe([{strategy:"class-owned-annotation",violations:["Unproved final text separation"]}])}for(const f of o)r();for(const f of o){if(!f.next||f.next.x===f.center.x&&f.next.y===f.center.y)continue;const h={x:f.next.x,y:f.next.y+(f.role==="caption"?ea:0)};if(f.role==="caption")f.rel.labelPosition=h;else f.rel[`${f.role}CardinalityPosition`]=h}}var ta=(e,t=1)=>{for(let n=0;n<t;n++)if(e&&!ri(e))throw new Qe([{strategy:"class-elk-contact",violations:["Class contact projection proof work limit"]}])};function rD(e,t,n){if(t.edgeBendRadius!==0||t.cornerRadius!==0)return;let i;ta(n,2);const r=(a=1)=>ta(n,a);const o=a=>{r(2);const l=String(a);r(l.length);return Number(Ue(a))};const s=(a,l,c)=>{r(2048);return hs(a,l,c)};for(let a=0;a<e.relationships.length;a++){r(8);const l=e.relationships[a];if(l.from!==l.to||l.markerAt!=="none"||l.label!==void 0||l.fromCardinality!==void 0||l.toCardinality!==void 0||l.points.length!==4)continue;const c=l.points[0],d=l.points[1],u=l.points[2],f=l.points[3];if((c.x===d.x||c.y===d.y)&&(u.x===f.x||u.y===f.y))continue;let h;for(const v of e.classes){r();if(v.id===l.from){h=v;break}}if(!h||h.isInterface)continue;r(32);if(![c.x,c.y,d.x,d.y,u.x,u.y,f.x,f.y,h.x,h.y,h.width,h.height,t.lineWidth].every(Number.isFinite)||!(h.width>0&&h.height>0&&t.lineWidth>0))continue;r(12);const m={x:o(c.x),y:o(c.y)},p={x:o(d.x),y:o(d.y)},g={x:o(u.x),y:o(u.y)},y={x:o(f.x),y:o(f.y)};if((m.x===p.x||m.y===p.y)&&(g.x===y.x||g.y===y.y))continue;const b=o(h.x),S=o(h.y),x=o(h.width),k=o(h.height);let w,C=0;if(m.x===y.x&&m.y>S&&y.y>S&&s(m.y,S,k)<0&&s(y.y,S,k)<0){if(m.x===b){w="x";C=-1}else if(s(m.x,b,x)===0){w="x";C=1}}else if(m.y===y.y&&m.x>b&&y.x>b&&s(m.x,b,x)<0&&s(y.x,b,x)<0){if(m.y===S){w="y";C=-1}else if(s(m.y,S,k)===0){w="y";C=1}}if(!w)continue;const R=w==="x"?"y":"x";r(10);if(p[w]!==g[w]||Math.sign(p[w]-m[w])!==C||m[R]===y[R]||Math.sign(g[R]-p[R])!==Math.sign(y[R]-m[R]))continue;if(m[R]===p[R]&&g[R]===y[R])continue;r(4);if($d(Ue(m[R]),Ue(y[R]),Ue(o(t.lineWidth)),r,r)!==false)continue;r(13);const M={x:d.x,y:d.y},P={x:u.x,y:u.y};M[R]=c[R];P[R]=f[R];P[w]=M[w];const E=[c,M,P,f];if(!i){r();i=new Set}l.points=E;i.add(a)}return i}function oD(e,t,n,i){if(!n?.size)return;ta(i);const r=(l=1)=>ta(i,l);const o=()=>{throw new Qe([{strategy:"class-elk-contact",violations:["Constructed Class self contact has unproved final support"]}])};r(2);const s=Number(Ue(t.lineWidth));r(512);for(const l of e.relationships){r(128);for(const c of l.points){r(8);const d=String(c.x),u=String(c.y);r(4*(d.length+u.length))}if(l.markerAt==="from"||l.markerAt==="both")r(4096);if(l.markerAt==="to"||l.markerAt==="both")r(4096)}const a=No(e,t,true,r,false);for(const l of n){r();const c=e.relationships[l].points;if(c.length!==4)o();r(18);const d=c.map(y=>{r(2);const b=String(y.x),S=String(y.y);r(b.length+S.length);return{x:Number(Ue(y.x)),y:Number(Ue(y.y))}});const u=d[0],f=d[1],h=d[2],m=d[3],p=u.x===f.x;r(8);if(p?f.y!==h.y||h.x!==m.x||u.y!==m.y||u.x===m.x||u.y===f.y:u.y!==f.y||f.x!==h.x||h.y!==m.y||u.x!==m.x||u.y===m.y||u.x===f.x)o();r(4);if($d(Ue(p?u.x:u.y),Ue(p?m.x:m.y),Ue(s),r,r)!==false)o();r(4);const g=[];for(let y=1;y<d.length;y++){r(3);g.push(Ak([d[y-1],d[y]],s,r))}for(const y of a){r();for(const b of g){r();if(Ik(b,y.box,r))o()}}}}function sD(e,t){const n=new Map(e.classes.map(r=>{ta(t);return[r.id,r]})),i=[];for(const r of e.relationships)for(const o of[true,false]){ta(t);const s=n.get(o?r.from:r.to);if(!s||s.isInterface||r.points.length<2)continue;const a=o?r.points[0]:r.points.at(-1),l=o?r.points[1]:r.points.at(-2);let c;if(a.x===s.x+s.width&&l.x>a.x&&l.y===a.y&&a.y>s.y&&a.y<s.y+s.height)c="x";else if(a.y===s.y+s.height&&l.y>a.y&&l.x===a.x&&a.x>s.x&&a.x<s.x+s.width)c="y";if(c)i.push({node:s,relation:r,from:o,axis:c})}return i}function kx(e,t){const n=[];for(const{node:i,relation:r,from:o,axis:s}of e){ta(t);const a=o?r.points[0]:r.points.at(-1),l=o?r.points[1]:r.points.at(-2),c=s==="x"?"y":"x",d=s==="x"?i.width:i.height;if(hs(a[s],i[s],d)===0)continue;const u=wx(i[s],d);if(u===void 0)throw new Qe([{strategy:"class-elk-contact",violations:["Exact written Class rectangle face is not representable"]}]);if(!(Number(Ue(l[s]))>u)||Number(Ue(l[c]))!==Number(Ue(a[c])))throw new Qe([{strategy:"class-elk-contact",violations:["Written Class contact has no outward lead"]}]);ta(t);n.push({point:a,axis:s,value:u})}for(const i of n)ta(t);for(const{point:i,axis:r,value:o}of n)i[r]=o}function aD(e,t){const n=Fo(t).map(i=>({id:i.id,start:Do(i,{x:0,y:0},{x:1,y:0},"start",t.lineWidth),end:Do(i,{x:0,y:0},{x:-1,y:0},"end",t.lineWidth)}));return e.map(i=>{const r=i.markerAt==="from"||i.markerAt==="both"?i.fromType??i.type:void 0;const o=i.markerAt==="to"||i.markerAt==="both"?i.toType??i.type:void 0;const s=r?n.find(l=>l.id===Ci(r))?.start:void 0;const a=o?n.find(l=>l.id===Ci(o))?.end:void 0;return{...s?.length?{start:s}:{},...a?.length?{end:a}:{}}})}function lD(e,t,n){const i=()=>ri(n),r=u=>{for(let f=0;f<u;f++)if(!i())return false;return true};const o=Number.parseFloat(Xn("stroke-width",String(t.lineWidth)));if(!(o>0)||!Number.isFinite(o)||!r(5))return new Map;const s=Fo(t),a=new Map,l=new Map,c=new Map,d=new Map;for(const u of e.classes){if(!i())return new Map;if(!u.isInterface)l.set(u.id,u)}for(const u of e.relationships)for(const f of["from","to"]){if(!i())return new Map;const h=l.get(u[f]),m=u.points;if(!h||m.length<2)continue;const p=f==="from"?m[0]:m.at(-1),g={x:Number(Ue(p.x)),y:Number(Ue(p.y))};let y=g;for(let v=1;v<m.length;v++){if(!i())return new Map;const L=m[f==="from"?v:m.length-v-1],T={x:Number(Ue(L.x)),y:Number(Ue(L.y))};if(T.x!==g.x||T.y!==g.y){y=T;break}}const b=y.x-g.x,S=y.y-g.y;let x;if(S===0&&b<0&&hs(g.x,h.x,0)===0)x="W";else if(S===0&&b>0&&hs(g.x,h.x,h.width)===0)x="E";else if(b===0&&S<0&&hs(g.y,h.y,0)===0)x="N";else if(b===0&&S>0&&hs(g.y,h.y,h.height)===0)x="S";if(!x)continue;const k=x==="W"||x==="E",w=u.markerAt==="both"||u.markerAt===f,C=w?Ci((f==="from"?u.fromType:u.toType)??u.type):null,R=`${f}:${x}:${C??""}`;let M=a.get(R);if(!M){let v=-o/2,L=o/2;let T;if(C)for(const A of s){if(!i())return new Map;if(A.id===C){T=A;break}}if(T){const A={x:x==="E"?1:x==="W"?-1:0,y:x==="S"?1:x==="N"?-1:0},$=f==="from"?A:{x:-A.x,y:-A.y};const _={};let z;try{z=Do(T,{x:0,y:0},$,f==="from"?"start":"end",o,()=>{if(!i())throw _})}catch(F){if(F===_)return new Map;throw F}for(const F of z){if(!i())return new Map;if(F.kind==="circle"){const G=k?F.cy:F.cx;v=Math.min(v,G-F.r);L=Math.max(L,G+F.r)}else for(const G of F.points){if(!i())return new Map;const I=k?G.y:G.x;v=Math.min(v,I);L=Math.max(L,I)}}}a.set(R,M={low:v,high:L})}let P=c.get(h.id);if(!P)c.set(h.id,P=new Map);let E=P.get(x);if(!E)P.set(x,E=[]);E.push({along:k?g.y-h.y:g.x-h.x,low:M.low,high:M.high,marker:C})}for(const[u,f]of c){if(!i())return new Map;const h=l.get(u);let m=h.width,p=h.height;for(const[g,y]of f){if(!i())return new Map;let b=false;for(const v of y){if(!i())return new Map;b||=v.marker!==null}if(!b)continue;const S={};try{y.sort((v,L)=>{if(!i())throw S;return v.along-L.along})}catch(v){if(v===S)return new Map;throw v}const x=y[0],k=y.at(-1),w=g==="W"||g==="E"?h.height:h.width,C=Math.max(0,t.cornerRadius??0),R=Math.min(C,h.width/2,h.height/2);let M=x.along<Math.max(-x.low,R)||w-k.along<Math.max(k.high,R),P=Math.max(-x.low,k.high,C);for(let v=1;v<y.length;v++){if(!i())return new Map;const L=y[v-1],T=y[v],A=L.high-T.low;M||=T.along-L.along<A;P=Math.max(P,A)}if(!M)continue;const E=Math.ceil((y.length+1)*P);if(!Number.isSafeInteger(E)||E<0)throw new Qe([{strategy:"class-marker-capacity",violations:["Nonfinite Class marker face reservation"]}]);if(g==="W"||g==="E")p=Math.max(p,E);else m=Math.max(m,E)}if(m>h.width||p>h.height)d.set(u,{width:m,height:p})}return d}function cD(e,t,n,i,r,o){const s=(c=1)=>{for(let d=0;d<c;d++)if(!ri(o))throw new Qe([{strategy:"class-native-marker-capacity",violations:["Class marker capacity work limit"]}])};s(3);const a=new Map,l=new Map;for(const c of e){s(5);if(!c.isInterface)a.set(c.id,{count:0,low:-i/2,high:i/2,marked:false})}for(let c=0;c<t.length;c++)for(let d=0;d<2;d++){s(8);const u=t[c],f=a.get(d===0?u.from:u.to);if(!f)continue;f.count++;const h=d===0?n[c]?.start:n[c]?.end;if(!h?.length)continue;f.marked=true;for(const m of h){s();if(m.kind==="circle"){s(4);f.low=Math.min(f.low,m.cy-m.r);f.high=Math.max(f.high,m.cy+m.r)}else for(const p of m.points){s(3);f.low=Math.min(f.low,p.y);f.high=Math.max(f.high,p.y)}}}for(const[c,d]of a){s(7);if(!d.marked)continue;const u=d.high-d.low+i,f=Math.ceil((d.count+1)*u);if(!Number.isSafeInteger(f)||f<=0)throw new Qe([{strategy:"class-native-marker-capacity",violations:["Nonfinite Class marker face reservation"]}]);s(4);l.set(c,{width:r==="LR"||r==="RL"?0:f,height:r==="LR"||r==="RL"?f:0,portSpacing:u})}return l}var Ut={padding:40,boxPadX:8,headerBaseHeight:32,annotationHeight:16,memberRowHeight:20,sectionPadY:8,emptySectionHeight:8,minWidth:120,memberFontSize:11,memberFontWeight:400,nodeSpacing:40,layerSpacing:60};var Cx={nodeLabelFontSize:er.nodeLabel,edgeLabelFontSize:er.edgeLabel,groupHeaderFontSize:er.groupHeader,nodeLabelFontWeight:700,edgeLabelFontWeight:Lr.edgeLabel,groupHeaderFontWeight:Lr.groupHeader,nodePaddingX:Ut.boxPadX,nodePaddingY:Ut.sectionPadY,nodeCornerRadius:0,nodeLineWidth:et.outerBox,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:Ut.boxPadX,groupPaddingY:Ut.sectionPadY,groupLineWidth:et.outerBox};function hD(e,t){if(!e)return t;const n=Dd(e,"class","nodeSpacing");const i=Dd(e,"class","rankSpacing");const r=kt(e,["class","hierarchicalNamespaces"]);const o=t.class?.hierarchicalNamespaces??(typeof r==="boolean"?r:void 0);if(n===void 0&&i===void 0&&o===void 0)return t;return{...t,nodeSpacing:t.nodeSpacing??n,layerSpacing:t.layerSpacing??i,...o!==void 0?{class:{...t.class,hierarchicalNamespaces:o}}:{}}}function di(e,t,n,i){return n==="node"?_e(e,{transform:t.nodeTextTransform,fontSize:t.nodeLabelFontSize,fontWeight:t.nodeLabelFontWeight,letterSpacing:t.nodeLetterSpacing,maxWidth:i}):n==="edge"?_e(e,{transform:t.edgeTextTransform,fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing,maxWidth:i}):_e(e,{transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing,fontFamily:t.groupFont,maxWidth:i})}function Gh(e){return _e(mD(Lf(e),e.isAbstract),{display:"literal",fontSize:Ut.memberFontSize,fontWeight:400,monospace:true})}function mD(e,t=false){const n=vt(e,"literal");return t?{...n,lines:n.lines.map(i=>i.map(r=>({...r,italic:true})))}:n}function Px(e){return _e(mD(`<<${e}>>`,true),{display:"literal",fontSize:10,fontWeight:500})}var pD="ns:";function Ex(e,t,n=true){const i=[];for(const r of e){const o=t?`${t.path}.${r.name}`:r.name;const s={path:o,parentPath:n?t?.path:void 0,ns:!n&&r.label===void 0?{...r,label:o}:r,ancestors:n&&t?[...t.ancestors,o]:[o]};if(n||r.classIds.length>0||r.label!==void 0||r.children.length===0)i.push(s);i.push(...Ex(r.children,s,n))}return i}function Dk(e,t){const n=t===void 0?1:t.split("\n").length;return e.groupHeaderFontSize+16+(n-1)*e.groupHeaderFontSize*fi}function RU(e,t){const n=new Map;for(const i of e.classes){const r=di(qe(i.label,i.labelContent),t,"node");if(i.isInterface){const p=r.height+2*Math.max(16,t.nodePaddingY);n.set(i.id,{width:r.width+2*Math.max(16,t.nodePaddingX),height:p,headerHeight:p,attrHeight:0,methodHeight:0});continue}const o=Math.max(Ut.headerBaseHeight,r.height+t.nodePaddingY*2);const s=i.annotation!==void 0?o+Ut.annotationHeight:o;const a=i.attributes.length>0?i.attributes.length*Ut.memberRowHeight+t.nodePaddingY:Ut.emptySectionHeight;const l=i.methods.length>0?i.methods.length*Ut.memberRowHeight+t.nodePaddingY:Ut.emptySectionHeight;const c=i.annotation===void 0?0:Px(i.annotation).width;const d=Math.max(r.width,c);const u=fD(i.attributes);const f=fD(i.methods);const h=Math.max(Ut.minWidth,d+t.nodePaddingX*2,u+t.nodePaddingX*2,f+t.nodePaddingX*2);const m=s+a+l;n.set(i.id,{width:h,height:m,headerHeight:s,attrHeight:a,methodHeight:l})}return n}function gD(e,t){let n=0;for(const i of e.relationships){const r=kc(i,t);n=Math.max(n,r.start,r.end)}return n?n+t.edgeBendRadius:0}function vU(e,t,n,i,r=new Map,o=new Map){const s=Xe(t,Cx,i);const a=t.nodeSpacing??Ut.nodeSpacing;const l=t.layerSpacing??Ut.layerSpacing;const c=t.class?.hierarchicalNamespaces!==false;const d=Ex(e.namespaces,void 0,c);const u=d.length>0;const f=gD(e,s);const h={"elk.spacing.edgeNode":String(f),"elk.layered.spacing.edgeNodeBetweenLayers":String(f),"elk.algorithm":"layered","elk.direction":ma(e.direction??"TB"),"elk.spacing.nodeNode":String(a),"elk.layered.spacing.nodeNodeBetweenLayers":String(l),"elk.padding":`[top=${Ut.padding},left=${Ut.padding},bottom=${Ut.padding},right=${Ut.padding}]`,"elk.edgeRouting":"ORTHOGONAL","elk.edgeLabels.placement":"CENTER"};if(u)h["elk.hierarchyHandling"]="INCLUDE_CHILDREN";const m={id:"root",layoutOptions:h,children:[],edges:[]};const p=new Map;for(const S of d){for(const x of S.ns.classIds){if(!p.has(x))p.set(x,S)}}const g=gi(e.classes.map(S=>S.id));const y=new Map;const b=new Map;for(const S of d){const x=di(qe(S.ns.label??S.ns.name,S.ns.labelContent),s,"group");const k=Dk(s,r.get(S.path)??x.text);const w={id:g(pD+S.path,["class","elk-namespace",S.path]),layoutOptions:{"elk.padding":`[top=${k+Math.max(s.groupPaddingY,o.get(S.path)??0)},left=${s.groupPaddingX+8},bottom=${s.groupPaddingY+8},right=${s.groupPaddingX+8}]`,"elk.spacing.nodeNode":String(a),"elk.layered.spacing.nodeNodeBetweenLayers":String(l),"elk.edgeRouting":"ORTHOGONAL","elk.spacing.edgeNode":String(f),"elk.layered.spacing.edgeNodeBetweenLayers":String(f),"elk.edgeLabels.placement":"CENTER"},children:[],edges:[]};y.set(w.id,{...S,headerHeight:k,labelWidth:x.width});b.set(S.path,w);const C=S.parentPath?b.get(S.parentPath):m;C.children.push(w)}for(const S of e.classes){const x=n.get(S.id);const k={id:S.id,width:x.width,height:x.height};const w=p.get(S.id);(w?b.get(w.path):m).children.push(k)}for(const S of y.values()){const x=b.get(S.path);if(x.children.length)continue;x.width=S.labelWidth+2*Math.max(s.groupLabelPaddingX,s.groupPaddingX+8);x.height=S.headerHeight+2*s.groupPaddingY+8}for(let S=0;S<e.relationships.length;S++){const x=e.relationships[S];const k={id:`e${S}`,sources:[x.from],targets:[x.to]};if(x.label){const M=di(qe(x.label,x.labelContent),s,"edge");if(M.lineBlocks.some(P=>P.runs.some(E=>E.text.trim().length>0))){k.labels=[{text:M.text,width:M.width+8,height:M.height+6}]}}const w=p.get(x.from)?.ancestors??[];const C=p.get(x.to)?.ancestors??[];let R;for(let M=0;M<Math.min(w.length,C.length);M++){if(w[M]===C[M])R=w[M];else break};(R?b.get(R):m).edges.push(k)}return{elkGraph:m,namespaceLayouts:y}}function TU(e,t){const n=[],i=new Map;const r=(o,s,a)=>{for(const l of o.edges??[]){const c=[];if(l.sections&&l.sections.length>0){const f=l.sections[0];c.push({x:f.startPoint.x+s,y:f.startPoint.y+a});for(const h of f.bendPoints??[]){c.push({x:h.x+s,y:h.y+a})}c.push({x:f.endPoint.x+s,y:f.endPoint.y+a})}let d;const u=l.labels?.[0];if(u&&u.x!=null&&u.y!=null){d={x:u.x+(u.width??0)/2+s,y:u.y+(u.height??0)/2+a}}i.set(Number(l.id.slice(1)),{points:qs(c),labelPosition:d})}for(const l of o.children??[]){const c=(l.x??0)+s,d=(l.y??0)+a;const u=t.get(l.id)?.path;n.push({id:l.id,x:c,y:d,width:l.width,height:l.height,...u!==void 0?{namespacePath:u}:{}});if(u!==void 0)r(l,c,d)}};r(e,0,0);return{width:e.width,height:e.height,nodes:n,routes:i,namespaceLayouts:t}}function yD(e,t){const n=t.isInterface?void 0:e.classDefs.get("default"),i=t.className?e.classDefs.get(t.className):void 0;if(!n&&!i&&!t.inlineStyle)return void 0;return{...Lt(n,"classDef default"),...Lt(i,`classDef ${t.className}`),...Lt(t.inlineStyle,`style ${t.id}`)}}function dD(e,t,n,i,r,o=new Map){const s=new Map;for(const b of t.classes)s.set(b.id,b);const a=e.namespaceLayouts?void 0:new Map(Ex(t.namespaces,void 0,r).map(b=>[b.path,b]));const l=[];const c=[];const d=e.routes;for(const b of e.nodes){const{x:S,y:x}=b;if(b.namespacePath!==void 0){const w=b.namespacePath;const C=e.namespaceLayouts?.get(b.id);const R=C??a?.get(w);c.push({id:w,name:R?.ns.name??w,label:R?.ns.label??R?.ns.name??w,...R?.ns.labelContent?{labelContent:R.ns.labelContent}:{},parentId:R?.parentPath,classIds:R?[...R.ns.classIds]:[],x:S,y:x,width:b.width??0,height:b.height??0,headerHeight:C?.headerHeight??Dk(i,o.get(w)??di(qe(R?.ns.label??R?.ns.name??w,R?.ns.labelContent),i,"group").text),...o.has(w)?{title:o.get(w)}:{}});continue}const k=s.get(b.id);if(k){const w=n.get(k.id),C=yD(t,k);l.push({id:k.id,...k.isInterface?{isInterface:true}:{},label:k.label,...k.labelContent?{labelContent:k.labelContent}:{},annotation:k.annotation,attributes:k.attributes,methods:k.methods,x:S,y:x,width:b.width??w.width,height:b.height??w.height,headerHeight:w.headerHeight,attrHeight:w.attrHeight,methodHeight:w.methodHeight+Math.max(0,(b.height??w.height)-w.height),...k.className?{className:k.className}:{},...k.href?{href:k.href}:{},...k.tooltip!==void 0?{tooltip:k.tooltip}:{},...C?{inlineStyle:C}:{}})}}const u=[];for(let b=0;b<t.relationships.length;b++){const S=t.relationships[b];const x=d.get(b);u.push({from:S.from,to:S.to,type:S.type,lineStyle:S.lineStyle,markerAt:S.markerAt,fromType:S.fromType,toType:S.toType,label:S.label,...S.labelContent?{labelContent:S.labelContent}:{},fromCardinality:S.fromCardinality,...S.fromCardinalityContent?{fromCardinalityContent:S.fromCardinalityContent}:{},toCardinality:S.toCardinality,...S.toCardinalityContent?{toCardinalityContent:S.toCardinalityContent}:{},points:x?.points??[],labelPosition:x?.labelPosition})}let f=e.width??600;let h=e.height??400;xD(u,l,i,f,h);const m=l.map(b=>({x:b.x,y:b.y,width:b.width,height:b.height}));const p=(b,S,x=8)=>b.x<S.x+S.width+x&&b.x+b.width+x>S.x&&b.y<S.y+S.height+x&&b.y+b.height+x>S.y;let g=Math.max(h+16,Ut.padding);const y=t.notes.map(b=>{const S=_e(qe(b.text,b.textContent),{fontSize:12,fontWeight:400});const x=Math.max(90,S.width+24);const k=Math.max(40,S.height+18);const w=b.for?l.find(R=>R.id===b.for):void 0;let C;if(w){const R=[];for(let M=0;M<Math.max(4,t.notes.length+1);M++){const P=M*(k+12);R.push({x:w.x+w.width+24,y:w.y+P,width:x,height:k,targetX:w.x+w.width,targetY:w.y+w.height/2,noteX:w.x+w.width+24,noteY:w.y+P+k/2},{x:w.x-x-24,y:w.y+P,width:x,height:k,targetX:w.x,targetY:w.y+w.height/2,noteX:w.x-24,noteY:w.y+P+k/2},{x:w.x,y:w.y+w.height+24+P,width:x,height:k,targetX:w.x+w.width/2,targetY:w.y+w.height,noteX:w.x+x/2,noteY:w.y+w.height+24+P})}C=R.find(M=>M.x>=Ut.padding&&M.y>=Ut.padding&&!m.some(P=>p(M,P)))??{x:f+24,y:w.y,width:x,height:k,targetX:w.x+w.width,targetY:w.y+w.height/2,noteX:f+24,noteY:w.y+k/2}}else{C={x:Ut.padding,y:g,width:x,height:k};g+=k+12}m.push(C);f=Math.max(f,C.x+x+Ut.padding);h=Math.max(h,C.y+k+Ut.padding);return{text:b.text,...b.textContent?{textContent:b.textContent}:{},...b.for?{for:b.for}:{},...C}});return{width:f,height:h,accessibilityTitle:t.accessibilityTitle,accessibilityDescription:t.accessibilityDescription,classes:l,relationships:u,notes:y,namespaces:c}}function xD(e,t,n,i,r,o=[],s=false){if(!e.some(u=>u.fromCardinality||u.toCardinality))return;const a=(u,f)=>Math.min(u.x1,f.x1)>Math.max(u.x0,f.x0)&&Math.min(u.y1,f.y1)>Math.max(u.y0,f.y0);const l=(u,f)=>Math.min(u.x1,f.x1)-Math.max(u.x0,f.x0)>.5&&Math.min(u.y1,f.y1)-Math.max(u.y0,f.y0)>.5;const c=t.map(u=>({x0:u.x-1,y0:u.y-1,x1:u.x+u.width+1,y1:u.y+u.height+1}));for(const u of e){if(!u.label||!u.labelPosition)continue;const f=di(qe(u.label,u.labelContent),n,"edge");c.push({x0:u.labelPosition.x-f.width/2-2,y0:u.labelPosition.y-8-f.height/2-2,x1:u.labelPosition.x+f.width/2+2,y1:u.labelPosition.y-8+f.height/2+2})}const d=(u,f,h,m)=>{const p=_e(u,{fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing});const g=p.width/2+2;const y=p.height/2+2;const b=k=>k.x0>=0&&k.y0>=0&&k.x1<=i&&k.y1<=r&&c.every(w=>!l(k,w))&&o.every(w=>!a(k,w));if(s&&m){const k={x0:m.x-g,y0:m.y-y,x1:m.x+g,y1:m.y+y};if(b(k)){c.push(k);return m}}const S=[];for(const k of gx(f,h)){const w={x0:k.x-g,y0:k.y-y,x1:k.x+g,y1:k.y+y};S.push({point:k,box:w});if(b(w)){c.push(w);return k}}if(s)throw new Qe([{strategy:"class-owned-cardinality",violations:["No collision-free endpoint text seat in the existing bounded candidates"]}]);const x=S.map(k=>({...k,collisions:c.filter(w=>l(k.box,w)).length})).sort((k,w)=>k.collisions-w.collisions||k.point.y-w.point.y||k.point.x-w.point.x)[0]??{point:f,box:{x0:f.x,y0:f.y,x1:f.x,y1:f.y}};c.push(x.box);return x.point};for(const u of e){if(u.points.length<2)continue;if(u.fromCardinality){u.fromCardinalityPosition=d(qe(u.fromCardinality,u.fromCardinalityContent),u.points[0],u.points[1],u.fromCardinalityPosition)}if(u.toCardinality){const f=u.points.length-1;u.toCardinalityPosition=d(qe(u.toCardinality,u.toCardinalityContent),u.points[f],u.points[f-1],u.toCardinalityPosition)}}}function bD(e,t={},n,i){Mm(e);const r=Xe(t,Cx,n);const o=i===void 0||i==="backend:default"||(i==="backend:rough"||i==="backend:hybrid")&&e.notes.length===0;const s=e.relationships.some(f=>f.markerAt!=="none");const a=fs();const l=o&&s?{colors:Object.freeze(Ym(t,t.mermaidConfig??{})),work:a}:void 0;if(e.classes.length===0&&!e.namespaces.length&&!e.notes.length){const f=()=>SD({width:0,height:0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,classes:[],relationships:[],notes:[],namespaces:[]},e.title,r);return Vr(t,f,f)}const c=RU(e,r);const d=t.class?.hierarchicalNamespaces!==false;let u=new Map;return Vr(t,()=>{const f=Ex(e.namespaces,void 0,d);const h=new Map(f.map((P,E)=>[P.path,E]));if(h.size!==f.length)throw new bo("ambiguous Class namespace paths");const m=new Map;for(const[P,E]of f.entries())for(const v of E.ns.classIds)if(!m.has(v))m.set(v,P);const p=gi(e.classes.map(P=>P.id));const g=f.map(P=>{const E=di(qe(P.ns.label??P.ns.name,P.ns.labelContent),r,"group");const v=Dk(r,E.text);return{id:p(`class-namespace:${P.path}`,["class","namespace",P.path]),...P.parentPath?{parent:h.get(P.parentPath)}:{},minWidth:E.width+2*Math.max(r.groupLabelPaddingX,r.groupPaddingX+8),headerHeight:v,padding:{top:v+r.groupPaddingY,right:r.groupPaddingX+8,bottom:r.groupPaddingY+8,left:r.groupPaddingX+8}}});const y=new Map(e.classes.map((P,E)=>[P.id,E]));const b=e.relationships.map(P=>{const E=P.label?di(qe(P.label,P.labelContent),r,"edge"):void 0;return E?.lineBlocks.some(v=>v.runs.some(L=>L.text.trim()))?{width:E.width+8,height:E.height+6}:void 0});const S=aD(e.relationships,r);const x=a?cD(e.classes,e.relationships,S,r.lineWidth,e.direction??"TB",a):void 0;const k=P=>{for(let E=0;E<P;E++)if(!ri(a))throw new Qe([{strategy:"class-native-marker-capacity",violations:["Class marker capacity work limit"]}])};let w=c;for(const[P,E]of x??[]){k(5);const v=c.get(P),L=Math.max(v.height,E.height),T=Math.max(v.width,E.width);if(L===v.height&&T===v.width)continue;if(w===c){k(c.size+1);w=new Map(c)}k(3);w.set(P,{...v,width:T,height:L,methodHeight:v.methodHeight+(L-v.height)})}const C=e.classes.map(P=>{const E=yD(e,P);const v=Number.parseFloat(E?.["stroke-width"]??"");return Number.isFinite(v)&&v>0?v:r.nodeLineWidth});const R=ei("agentic",()=>Ya({nodes:e.classes.map((P,E)=>({id:P.id,width:w.get(P.id).width,height:w.get(P.id).height,paintStrokeWidth:C[E],...!P.isInterface&&(i===void 0||i==="backend:default")?{paintCornerRadius:r.cornerRadius??0}:{},...x?.has(P.id)?{minimumPortSpacing:x.get(P.id).portSpacing}:{},...m.has(P.id)?{parent:m.get(P.id)}:{}})),groups:g.map(P=>({...P,paintStrokeWidth:r.groupLineWidth,...i===void 0||i==="backend:default"?{paintCornerRadius:r.groupCornerRadius}:{}})),edges:e.relationships.map((P,E)=>{const v=y.get(P.from),L=y.get(P.to);if(v===void 0||L===void 0)throw new Error("Class relationship references an undeclared card");return{source:v,target:L,minSpan:1,markerPaint:S[E],...b[E]?{label:b[E]}:{}}}),direction:e.direction??"TB",padding:Ut.padding,nodeSpacing:t.nodeSpacing??Ut.nodeSpacing,layerSpacing:t.layerSpacing??Ut.layerSpacing,edgeSpacing:Math.max(6,r.lineWidth+4),minimumTerminalLead:Math.max(1,gD(e,r)),maximumEdgeStrokeWidth:r.lineWidth,maximumEdgeBendRadius:r.edgeBendRadius}));if(R.nodes.length!==e.classes.length||(R.groups?.length??0)!==f.length||R.edges.length!==e.relationships.length){throw new TypeError("Native Class placement lost measured subjects")}const M={width:R.width,height:R.height,nodes:[...R.nodes.map((P,E)=>({...P,id:e.classes[E].id,width:w.get(e.classes[E].id).width,height:w.get(e.classes[E].id).height})),...f.map((P,E)=>({...R.groups[E],id:pD+P.path,namespacePath:P.path}))],routes:new Map(R.edges.map((P,E)=>[E,{points:P.points,...P.labelPosition?{labelPosition:{x:P.labelPosition.x,y:P.labelPosition.y+8}}:{}}]))};return uD(dD(M,e,w,r,d),e,r,l,a)},()=>{let f;let h=new Map;let m=c;for(let p=0;p<3;p++){const{elkGraph:g,namespaceLayouts:y}=vU(e,t,m,n,u,h);const b=g.children?.length||g.edges?.length?Ha(g):{...g,width:0,height:0};f=dD(TU(b,y),e,m,r,d,u);const S=IU(f.namespaces,r);const x=f.namespaces.length?eD(f,r,h,a):h;const k=l?lD(f,r,l.work):new Map;let w=m;for(const[C,R]of k){const M=m.get(C);const P=Math.max(M.width,R.width),E=Math.max(M.height,R.height);if(P===M.width&&E===M.height)continue;if(w===m)w=new Map(m);w.set(C,{...M,width:P,height:E,methodHeight:M.methodHeight+E-M.height})}if(w===m&&S.size===u.size&&[...S].every(([C,R])=>u.get(C)===R)&&x.size===h.size&&[...x].every(([C,R])=>h.get(C)===R))break;u=S;h=x;m=w}return uD(f,e,r,l,a,true,i===void 0||i==="backend:default")},true)}function uD(e,t,n,i,r,o=false,s=false){for(const d of e.classes){d.labelBlock=di(qe(d.label,d.labelContent),n,"node");d.attributeBlocks=d.attributes.map(Gh);d.methodBlocks=d.methods.map(Gh);if(d.annotation!==void 0)d.annotationBlock=Px(d.annotation)}for(const d of e.namespaces)d.labelBlock=di(qe(d.label,d.labelContent),n,"group",d.width-2*n.groupLabelPaddingX);for(const d of e.notes)d.textBlock=_e(qe(d.text,d.textContent),{fontSize:12,fontWeight:400});for(const d of e.relationships){if(d.label!==void 0)d.labelBlock=di(qe(d.label,d.labelContent),n,"edge");for(const u of["from","to"]){const f=d[`${u}Cardinality`];if(f!==void 0)d[`${u}CardinalityBlock`]=_e(qe(f,d[`${u}CardinalityContent`]),{fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing})}}const a=o&&s&&r?rD(e,n,r):void 0;const l=o?sD(e,r):void 0;const c=SD(e,t.title,n);if(c.classes.some(d=>d.isInterface)){const d=new Map(c.classes.filter(f=>f.isInterface).map(f=>[f.id,f]));const u={...lg("none"),paint:{fill:"none",stroke:"none",strokeWidth:"0"}};for(const f of c.relationships){const h=d.get(f.from),m=d.get(f.to);if(!h&&!m)continue;const p=_o({id:"interface-projection",role:"relationship",geometry:{kind:"polyline",points:f.points},lineStyle:"solid",paint:{strokeWidth:String(n.lineWidth)},markers:{...h?{start:u}:{},...m?{end:u}:{}}});for(const g of jr(p)){const y=g.position==="start"?h:m,b=g.bounds;if(y&&b)y.interfaceBox={x:b.x0,y:b.y0,width:b.x1-b.x0,height:b.y1-b.y0}}}}LU(c,n,r,l,true,a);if(i)nD(c,n,i.colors,i.work);return c}function LU(e,t,n,i,r=false,o){if(i)kx(i,n);const s=n??fs();let a;if(r&&t.edgeBendRadius===0&&e.namespaces.length&&e.relationships.length){if(!ri(s))throw new Qe([{strategy:"class-final-sharp-contacts",violations:["Class final contact capture work limit"]}]);a={}}const l=Q_(e,t,n,a);const c=[...e.namespaces.map(f=>({x0:f.x,y0:f.y,x1:f.x+f.width,y1:f.y+f.headerHeight})),...e.notes.map(f=>({x0:f.x,y0:f.y,x1:f.x+f.width,y1:f.y+f.height}))];if(e.relationships.some(f=>f.markerAt!=="none")){const f=e.classes[0]?.x,h=e.classes[0]?.y;Fk(e,t,Ut.padding,n);if(i&&(e.classes[0]?.x!==f||e.classes[0]?.y!==h))kx(i,n);_k(e,t,n??fs(),l)}else{xD(e.relationships,e.classes,t,e.width,e.height,c,true);const f=e.classes[0]?.x,h=e.classes[0]?.y;Fk(e,t,Ut.padding,n);if(i&&(e.classes[0]?.x!==f||e.classes[0]?.y!==h))kx(i,n)}if(!e.relationships.some(f=>f.markerAt!=="none")&&l.size)_k(e,t,n??fs(),l);oD(e,t,o,s);const d=Z_(e,t);if(d.length)throw new Qe([{strategy:"class-owned-surfaces",violations:d}]);if(!r||t.edgeBendRadius!==0)j_(e,l,t,()=>ri(s));let u;if(a){if(!ri(s))throw new Qe([{strategy:"class-final-sharp-contacts",violations:["Class final contact capture work limit"]}]);u=z_(a,e.relationships,t,()=>ri(s))}AU(e,t,s,r,l.size>0||!!o?.size,u)}function AU(e,t,n,i,r=false,o){if(t.edgeBendRadius!==0||e.relationships.length<2&&!(i&&r))return;const s=h=>{throw new Qe([{strategy:"class-final-sharp-contacts",violations:[h]}])};const a=(h=1)=>{for(let m=0;m<h;m++)if(!ri(n))s("Class final sharp contact work limit")};a(2*e.classes.length+3*e.relationships.length+8);const l=new Map(e.classes.map((h,m)=>[h.id,m]));const c={nodes:[],edges:e.relationships.map(h=>{const m=l.get(h.from),p=l.get(h.to);if(m===void 0||p===void 0)s("Undeclared final Class endpoint");return{source:m,target:p,minSpan:1}}),direction:"TB",padding:0,nodeSpacing:0,layerSpacing:0,maximumEdgeStrokeWidth:t.lineWidth,maximumEdgeBendRadius:0};const d=e.relationships.map(h=>({points:h.points,style:"solid"}));a();if(i){const h=bA(d,c,a,a,r,o);if(h===false)s("Final Class routes have unsupported cardinal support");const m=typeof h==="function"?h:s("Class final sharp contact work limit");for(let p=0;p+1<d.length;p++){if(!m(p))s("Final Class routes have an uncertified shared contact");d[p].style="invisible"}return}const u=Us(c);let f=0;for(const h of d){a();f+=Math.max(0,h.points.length-1)}for(let h=0;h+1<d.length;h++){const m=d[h],p=Math.max(0,m.points.length-1);f-=p;a(u*p*f+m.points.length+f+d.length);if(ts(m.points,h,d,c,a,a,void 0,u,i)===void 0)s("Final Class routes have an uncertified shared contact");m.style="invisible"}}function SD(e,t,n){const i=tn(t,n);if(!i)return e;if(e.width===0&&e.height===0)return{...e,...da(i,Ut.padding)};const r=i.height;for(const s of e.classes)s.y+=r;for(const s of e.namespaces)s.y+=r;for(const s of e.notes){s.y+=r;if(s.targetY!==void 0)s.targetY+=r;if(s.noteY!==void 0)s.noteY+=r}for(const s of e.relationships){for(const a of s.points)a.y+=r;for(const a of[s.labelPosition,s.fromCardinalityPosition,s.toCardinalityPosition]){if(a)a.y+=r}}const o=Math.max(e.width,i.width+2*Ut.padding);return{...e,width:o,height:e.height+r,title:rn(i,o,Ut.padding)}}function IU(e,t){const n=new Map;for(const i of e){const r=i.width-2*t.groupLabelPaddingX;const o=di(qe(i.label,i.labelContent),t,"group",r);const s=di(qe(i.label,i.labelContent),t,"group");if(o.text!==s.text)n.set(i.id,o.text)}return n}function fD(e){if(e.length===0)return 0;let t=0;for(const n of e){const i=Gh(n).width;if(i>t)t=i}return t}var CD={memberSize:11,annotationSize:10};function FU(e,t){const n=e.lineBlocks.length===1?e.lineBlocks[0]:void 0;const i=!!n&&!n.fragments&&e.letterSpacing===0&&/^[\x20-\x7e]*$/.test(e.text)&&n.runs.every(r=>!r.bold&&!r.italic&&!r.underline&&!r.strikethrough)&&t.map(r=>r.text).join("")===e.text;return i?{spans:t}:{}}function NU(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=[];const c=Xe(o,Cx,r.styleFace);const d=`class-${mi(n.width,n.height,n.classes.length,n.relationships.length)}`;const u=`${d}-title`;const f=`${d}-desc`;const h=Mi(n.accessibilityTitle,n.accessibilityDescription,u,f);l.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:true},Ot(n.width,n.height,i,a,h)+"\n"+Dt(s,true,i.shadow,i.embedFontImport)));const m=[];m.push("<defs>");const p=Fo(c);m.push(hi(p));const g=Zt(i);if(g)m.push(g);m.push("</defs>");l.push(e.definitions({id:"defs",markerResources:p},m.join("\n")));if(n.accessibilityTitle){l.push(e.documentContent({id:"title",role:"chrome",nonPaint:"accessibility"},`<title id="${u}">${kD(n.accessibilityTitle)}</title>`))}if(n.accessibilityDescription){l.push(e.documentContent({id:"desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${f}">${kD(n.accessibilityDescription)}</desc>`))}if(n.title)l.push(e.text(En(n.title,c)));for(const x of n.namespaces){l.push($U(e,x,c))}const y=new Map;for(const x of n.relationships){const k=`${x.from}->${x.to}`;const w=y.get(k)??0;y.set(k,w+1);l.push(OU(e,x,c,`rel:${k}#${w}`,p))}for(const x of n.classes){l.push(_U(e,x,c,o.security!=="strict",i))}const b=new Map;n.relationships.forEach((x,k)=>{const w=`${x.from}->${x.to}`;const C=b.get(w)??0;b.set(w,C+1);const R=BU(e,x,c,k,`rel:${w}#${C}`,p);if(R)l.push(R)});for(let x=0;x<n.notes.length;x++)l.push(DU(e,n.notes[x],c,x));const S=new Map;for(const x of n.relationships){const k=`${x.from}->${x.to}`;const w=S.get(k)??0;S.set(k,w+1);l.push(...WU(e,x,c,`${k}#${w}`))}l.push(e.documentClose());return{family:"class",width:n.width,height:n.height,colors:i,transparent:a,parts:l}}function $U(e,t,n){const i=[];const r=`<g class="namespace" data-id="${Ye(t.id)}" data-label="${hn(t.label)}"${t.parentId?` data-parent-id="${Ye(t.parentId)}"`:""}>`;const o=n.groupFillColor??"var(--_group-fill)";const s=n.groupBorderColor??"var(--_node-stroke)";i.push({indent:2,node:e.shape({id:`namespace-rect:${t.id}`,role:"group",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:o,stroke:s,strokeWidth:String(n.groupLineWidth)}})});const a=n.groupHeaderFillColor??"var(--_group-hdr)";const l=Er(t.x,t.y,t.width,t.headerHeight,n.groupCornerRadius);i.push({indent:2,node:e.shape({id:`namespace-header:${t.id}`,role:"group-header",geometry:{kind:"path",d:l},paint:{fill:a,stroke:s,strokeWidth:String(n.groupLineWidth)}})});const c=t.labelBlock??di(qe(t.label,t.labelContent),n,"group",t.width-2*n.groupLabelPaddingX);const d=c.text;const u=n.groupTextColor??"var(--_text-sec)";i.push({indent:2,node:e.text({id:`namespace-label:${t.id}`,role:"group-header",text:d,block:c,x:t.x+n.groupLabelPaddingX,y:t.y+t.headerHeight/2,fontSize:n.groupHeaderFontSize,anchor:"start",paint:{fill:u}})});return e.group({id:`namespace:${t.id}`,role:"group",open:r,close:"</g>",children:i})}function _U(e,t,n,i,r){const{x:o,y:s,width:a,height:l,headerHeight:c,attrHeight:d}=t;const u=[];if(t.isInterface){const z=t.labelBlock??di(qe(t.label,t.labelContent),n,"node");return e.group({id:`class:${t.id}`,role:"class-box",open:`<g class="class-interface" data-id="${Ye(t.id)}" data-label="${hn(t.label)}" data-interface="true">`,close:"</g>",children:[{indent:2,node:e.text({id:`class:${t.id}:name`,role:"label",text:z.text,block:z,x:o+a/2,y:s+c/2,fontSize:z.fontSize,anchor:"middle",paint:{fill:n.nodeTextColor??"var(--_text)"}})}]})}const f=t.annotation!==void 0?` data-annotation="${Ye(t.annotation)}"`:"";const h=t.className?` ${Ye(t.className)}`:"";const m=t.className?` data-class="${Ye(t.className)}"`:"";const p=i&&t.href?` data-href="${Ye(t.href)}" role="link" tabindex="0"`:"";const g=`<g class="class-node${h}" data-id="${Ye(t.id)}" data-label="${hn(t.label)}"${f}${m}${p}>`;if(i&&t.href&&t.tooltip!==void 0){u.push({indent:2,node:e.documentContent({id:`class:${t.id}:tooltip`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${It(t.tooltip)}</title>`)})}const y=t.inlineStyle??{};const b=n.nodeTextColor!==void 0;const S=Ts(t.inlineStyle,r,b?void 0:n.groupHeaderFillColor??"var(--_group-hdr)");const x=Ts(t.inlineStyle,r,b?void 0:n.nodeFillColor??"var(--_node-fill)");const k=y.fill??n.nodeFillColor??"var(--_node-fill)";const w=y.stroke??n.nodeBorderColor??"var(--_node-stroke)";const C=Number.parseFloat(y["stroke-width"]??"");const R=Number.isFinite(C)&&C>0?C:n.nodeLineWidth;u.push({indent:2,node:e.shape({id:`class:${t.id}:box`,role:"class-box",geometry:{kind:"rect",x:o,y:s,width:a,height:l,rx:n.cornerRadius??0,ry:n.cornerRadius??0},paint:{fill:k,stroke:w,strokeWidth:String(R),...y["stroke-dasharray"]!==void 0?{strokeDasharray:y["stroke-dasharray"]}:{}}})});const M=y.fill??n.groupHeaderFillColor??"var(--_group-hdr)";const P=Er(o,s,a,c,n.cornerRadius??0);u.push({indent:2,node:e.shape({id:`class:${t.id}:header`,role:"group-header",geometry:{kind:"path",d:P},paint:{fill:M,stroke:w,strokeWidth:String(R),...y["stroke-dasharray"]!==void 0?{strokeDasharray:y["stroke-dasharray"]}:{}}})});let E=s+c/2;if(t.annotation!==void 0){const z=t.annotationBlock??Px(t.annotation);const F=s+12;const G=S(n.nodeTextColor??"var(--_text-muted)");u.push({indent:2,node:e.text({id:`class:${t.id}:annotation`,role:"label",text:`<<${t.annotation}>>`,block:z,x:o+a/2,y:F,fontSize:CD.annotationSize,fontStyle:"italic",anchor:"middle",paint:{fill:G}})});E=s+c/2+6}const v=S(n.nodeTextColor??"var(--_text)");const L=t.labelBlock??di(qe(t.label,t.labelContent),n,"node");const T=L.text;u.push({indent:2,node:e.text({id:`class:${t.id}:name`,role:"label",text:T,block:L,x:o+a/2,y:E,fontSize:n.nodeLabelFontSize,anchor:"middle",paint:{fill:v}})});const A=s+c;u.push({indent:2,node:wD(e,t.id,"attrs",o,A,a,n,y["stroke-dasharray"])});const $=20;for(let z=0;z<t.attributes.length;z++){const F=t.attributes[z];const G=A+4+z*$+$/2;u.push({indent:2,node:MD(e,F,o+n.nodePaddingX,G,n,`member:${t.id}:${F.name}`,x,t.attributeBlocks?.[z])})}const _=A+d;u.push({indent:2,node:wD(e,t.id,"methods",o,_,a,n,y["stroke-dasharray"])});for(let z=0;z<t.methods.length;z++){const F=t.methods[z];const G=_+4+z*$+$/2;u.push({indent:2,node:MD(e,F,o+n.nodePaddingX,G,n,`member:${t.id}:${F.name}`,x,t.methodBlocks?.[z])})}return e.group({id:`class:${t.id}`,role:"class-box",open:g,close:"</g>",children:u})}function wD(e,t,n,i,r,o,s,a){const l=s.nodeBorderColor??"var(--_node-stroke)";const c=Math.min(s.nodeLineWidth,et.innerBox);return e.shape({id:`class:${t}:divider:${n}`,role:"chrome",geometry:{kind:"line",x1:i,y1:r,x2:i+o,y2:r},paint:{stroke:l,strokeWidth:String(c),...a!==void 0?{strokeDasharray:a}:{}}})}function MD(e,t,n,i,r,o,s,a){const l=a??Gh(t);const c=Lf(t);const d=s(r.nodeTextColor??"var(--_text-sec)");const u=[];if(!t.isMethod&&t.sourceText){if(t.visibility&&c.startsWith(t.visibility)){u.push({text:t.visibility,fill:s("var(--_text-faint)")},{text:c.slice(1),fill:d})}else{u.push({text:c,fill:d})}}else{if(t.visibility)u.push({text:`${t.visibility} `,fill:s("var(--_text-muted)")});const f=t.isMethod?`${t.name}(${t.params||""})`:t.name;u.push({text:Oa(f),fill:d});if(t.type){u.push({text:": ",fill:s("var(--_text-faint)")},{text:Oa(t.type),fill:s("var(--_text-muted)")})}}return e.text({id:o,role:"member",text:c,block:l,x:n,y:i,fontSize:CD.memberSize,anchor:"start",paint:{fill:d},...t.isAbstract?{fontStyle:"italic"}:{},...t.isStatic?{textDecoration:"underline"}:{},...FU(l,u),attributes:{className:"mono"}})}function DU(e,t,n,i){const r=n.groupBorderColor??"var(--_node-stroke)";const o=n.groupFillColor??"var(--_group-hdr)";const s=n.groupTextColor??"var(--_text)";const a=t.textBlock??_e(qe(t.text,t.textContent),{fontSize:12,fontWeight:400});const l=[];if(t.targetX!==void 0&&t.targetY!==void 0){l.push({node:e.connector({id:`class-note:${i}:connector`,role:"relationship",geometry:{kind:"line",x1:t.targetX,y1:t.targetY,x2:t.noteX??t.x,y2:t.noteY??t.y+t.height/2},lineStyle:"dashed",paint:{stroke:r,strokeWidth:"1",strokeDasharray:"4 3"},...t.for?{endpoints:{from:t.for,to:`class-note:${i}`,start:{owner:{id:t.for,role:"class-box"}},end:{owner:{id:`class-note:${i}`,role:"note"}}}}:{},attributes:{className:"class-note-connector"}}),indent:2})}l.push({node:e.shape({id:`class-note:${i}:box`,role:"note",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:2,ry:2},paint:{fill:o,stroke:r,strokeWidth:"1"}}),indent:2});l.push({node:e.text({id:`class-note:${i}:label`,role:"label",text:t.text,block:a,x:t.x+t.width/2,y:t.y+t.height/2,fontSize:12,anchor:"middle",paint:{fill:s}}),indent:2});return e.group({id:`class-note:${i}`,role:"note",open:`<g class="class-note" data-note-index="${i}"${t.for?` data-for="${Ye(t.for)}"`:""}>`,close:"</g>",children:l})}function Ok(e){return{from:e.from,to:e.to,start:{owner:{id:e.from,role:"class-box"}},end:{owner:{id:e.to,role:"class-box"}}}}function OU(e,t,n,i,r){const o=t.label?[{text:t.label,textContent:{value:t.label,prepared:vt(qe(t.label,t.labelContent))},...t.labelPosition?{anchor:t.labelPosition}:{}}]:[];if(t.points.length<2){return e.connector({id:i,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:"invisible",paint:{},endpoints:Ok(t),relationship:{kind:t.type},labels:o})}const s=Jl(t)==="dashed";const a=s?"dashed":"solid";const l=t.markerAt==="from"||t.markerAt==="both"?t.fromType??t.type:void 0;const c=t.markerAt==="to"||t.markerAt==="both"?t.toType??t.type:void 0;const d=l?Ci(l):null;const u=c?Ci(c):null;const f=d?r.find(b=>b.id===d):void 0;const h=u?r.find(b=>b.id===u):void 0;const m={className:"class-relationship",data:{type:t.type,"relation-type":t.type,"marker-at":t.markerAt,...t.label?{label:Hr(t.label)}:{},...t.fromCardinality?{"from-cardinality":t.fromCardinality}:{},...t.toCardinality?{"to-cardinality":t.toCardinality}:{}}};const p=n.edgeStrokeColor??"var(--_line)";const g={stroke:p,strokeWidth:String(n.lineWidth),...s?{strokeDasharray:"6 4"}:{}};const y={endpoints:Ok(t),relationship:{kind:t.type},route:{ownership:"layout",bendRadius:n.edgeBendRadius,labelAnchors:t.labelPosition?[t.labelPosition]:[]},labels:o};if(n.edgeBendRadius>0&&t.points.length>2){const b=qn(t.points,n.edgeBendRadius,{metric:"manhattan",terminalClearance:kc(t,n)});return e.connector({id:i,role:"relationship",geometry:b.geometry,lineStyle:a,paint:g,markers:{...f?{start:f}:{},mid:[],...h?{end:h}:{}},...y,route:{...y.route,contours:b.contours},attributes:m})}return e.connector({id:i,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:a,paint:g,markers:{...f?{start:f}:{},mid:[],...h?{end:h}:{}},...y,attributes:m})}function BU(e,t,n,i,r,o){if(t.points.length<2)return null;const s=t.markerAt==="from"||t.markerAt==="both"?t.fromType??t.type:void 0;const a=t.markerAt==="to"||t.markerAt==="both"?t.toType??t.type:void 0;const l=s?Ci(s):null;const c=a?Ci(a):null;if(!l&&!c)return null;const d=o.find(h=>h.id===l);const u=o.find(h=>h.id===c);const f={id:`marker-overlay:${i}`,role:"chrome",owner:{id:r,role:"relationship"},lineStyle:"solid",paint:{fill:"none",stroke:n.edgeStrokeColor??"var(--_line)",strokeWidth:String(n.lineWidth)},stroke:{opacity:0},endpoints:Ok(t),relationship:{kind:"marker-carrier"},markers:{...d?{start:d}:{},mid:[],...u?{end:u}:{}},hit:{pointerEvents:"none"},attributes:{className:"class-marker-overlay",ariaHidden:true}};if(n.edgeBendRadius>0&&t.points.length>2){const h=qn(t.points,n.edgeBendRadius,{metric:"manhattan",terminalClearance:kc(t,n)});return e.connector({...f,geometry:h.geometry,route:{contours:h.contours}})}return e.connector({...f,geometry:{kind:"polyline",points:t.points}})}function WU(e,t,n,i){if(!t.label&&!t.fromCardinality&&!t.toCardinality||t.points.length<2){return[e.documentContent({id:`rel-labels:${i}`,role:"chrome"},"")]}const r=[];const o=n.edgeTextColor??"var(--_text-muted)";const s={fill:o,stroke:"var(--bg)",strokeWidth:String(su),strokeLinejoin:"round",paintOrder:"stroke"};if(t.label){const a=au(t);const l=t.labelBlock??di(qe(t.label,t.labelContent),n,"edge");const c=l.text;r.push(e.text({id:`rel-label:${i}`,role:"label",text:c,block:l,x:a.x,y:a.y-ea,fontSize:n.edgeLabelFontSize,anchor:"middle",paint:s}))}if(t.fromCardinality){const a=Cc(t,"from");const l=t.fromCardinalityBlock??_e(qe(t.fromCardinality,t.fromCardinalityContent),{fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing});r.push(e.text({id:`rel-card:${i}:from`,role:"cardinality",text:t.fromCardinality,block:l,x:a.x,y:a.y,fontSize:n.edgeLabelFontSize,anchor:"middle",paint:s}))}if(t.toCardinality){const a=Cc(t,"to");const l=t.toCardinalityBlock??_e(qe(t.toCardinality,t.toCardinalityContent),{fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing});r.push(e.text({id:`rel-card:${i}:to`,role:"cardinality",text:t.toCardinality,block:l,x:a.x,y:a.y,fontSize:n.edgeLabelFontSize,anchor:"middle",paint:s}))}return r}var kD=It;var PD=gt(NU);var WRe={configDiagnostics:D_,statementEnds:Zw,normalizeRequest:e=>({renderOptions:hD(e.source.frontmatter,e.renderOptions)}),layout:e=>{const t=Tn(qr(TL(e.source.familyLines,e.source.authoredFamilyLines??e.source.familyLines),e.source.accessibility),e.source.frontmatter);Hm(t.classDefs,t.classes);return mt(bD(t,e.renderOptions,e.styleFace,e.paintBackendId))},projectPositioned:ft(lA),lowerScene:ht(PD)};var zU={layoutDirection:Bp("TB","TD","BT","LR","RL"),nodeSpacing:jt,rankSpacing:jt};var ED=e=>bt("er",e,zU);var Hh={attrSize:11,keySize:9};function GU(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=[];const c=Xe(o,Bd,r.styleFace);const d=`er-${mi(n.width,n.height,n.entities.length,n.relationships.length)}`;const u=`${d}-title`;const f=`${d}-desc`;const h=Mi(n.accessibilityTitle,n.accessibilityDescription,u,f);l.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:true},Ot(n.width,n.height,i,a,h)+"\n"+Dt(s,true,i.shadow,i.embedFontImport)));const m=[];m.push("<defs>");const p=Zt(i);if(p)m.push(p);m.push("</defs>");l.push(e.definitions({id:"defs"},m.join("\n")));if(n.accessibilityTitle){l.push(e.documentContent({id:"acc-title",role:"chrome",nonPaint:"accessibility"},`<title id="${u}">${Bk(n.accessibilityTitle)}</title>`))}if(n.accessibilityDescription){l.push(e.documentContent({id:"acc-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${f}">${Bk(n.accessibilityDescription)}</desc>`))}if(n.title)l.push(e.text(En(n.title,c)));for(const w of n.groups)l.push(HU(e,w,c));const g=new Map;const y=new Set(n.groups.map(w=>w.id));const b=w=>({id:w,role:y.has(w)?"group":"entity"});for(const w of n.relationships){const C=`${w.entity1}-${w.entity2}`;const R=g.get(C)??0;g.set(C,R+1);l.push(qU(e,w,c,r.styleFace,`rel:${C}#${R}`,b))}for(const w of n.entities){l.push(jU(e,w,c,i))}const S=new Map;for(const w of n.relationships){const C=`${w.entity1}-${w.entity2}`;const R=S.get(C)??0;S.set(C,R+1);l.push(...UU(e,w,c,`card:${C}#${R}`))}const x=qa(n)??Ks(n,c,r.styleFace);const k=new Map;for(const w of n.relationships){const C=`${w.entity1}-${w.entity2}`;const R=k.get(C)??0;k.set(C,R+1);l.push(...XU(e,w,c,r.styleFace,`rel-label:${C}#${R}`,x.get(w)))}l.push(e.documentClose());return{family:"er",width:n.width,height:n.height,colors:i,transparent:a,parts:l}}function HU(e,t,n){const i=n.groupBorderColor??"var(--_node-stroke)";const r=n.groupFillColor??"var(--_group-fill)";const o=n.groupHeaderFillColor??"var(--_group-hdr)";const s=n.groupTextColor??"var(--_text)";const a=t.labelBlock??Wd(qe(t.label,t.labelContent),n);return e.group({id:`er-group:${t.id}`,role:"group",open:`<g class="er-subgraph" data-id="${Ye(t.id)}" data-label="${hn(t.label)}"${t.parentId?` data-parent-id="${Ye(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:r,stroke:i,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:o,stroke:"none"}}),indent:2},{node:e.text({id:`er-group:${t.id}:label`,role:"label",text:a.text,block:a,x:t.x+10,y:t.y+t.headerHeight/2,fontSize:a.fontSize,anchor:"start",paint:{fill:s}}),indent:2}]})}function jU(e,t,n,i){const{id:r,x:o,y:s,width:a,height:l,headerHeight:c,rowHeight:d,label:u,attributes:f}=t;const h=[];const m=t.className?` ${Ye(t.className)}`:"";const p=t.className?` data-class="${Ye(t.className)}"`:"";const g=`<g class="entity${m}" data-id="${Ye(r)}" data-label="${hn(u)}"${p}>`;const y=t.inlineStyle??{};const b=n.nodeTextColor!==void 0;const S=Ts(t.inlineStyle,i,b?void 0:n.groupHeaderFillColor??"var(--_group-hdr)");const x=Ts(t.inlineStyle,i,b?void 0:n.nodeFillColor??"var(--_node-fill)");const k=y.fill??n.nodeFillColor??"var(--_node-fill)";const w=y.stroke??n.nodeBorderColor??"var(--_node-stroke)";const C=Number.parseFloat(y["stroke-width"]??"");const R=Number.isFinite(C)&&C>0?C:n.nodeLineWidth;const M=y["stroke-dasharray"];const P=M===void 0?{}:{strokeDasharray:M};h.push({indent:2,node:e.shape({id:`entity-rect:${r}`,role:"entity",geometry:{kind:"rect",x:o,y:s,width:a,height:l,rx:n.cornerRadius??0,ry:n.cornerRadius??0},paint:{fill:k,stroke:w,strokeWidth:String(R),...P}})});const E=y.fill??n.groupHeaderFillColor??"var(--_group-hdr)";const v=Er(o,s,a,c,n.cornerRadius??0);h.push({indent:2,node:e.shape({id:`entity-header:${r}`,role:"group-header",geometry:{kind:"path",d:v},paint:{fill:E,stroke:w,strokeWidth:String(R),...P}})});const L=S(n.nodeTextColor??"var(--_text)");const T=t.labelBlock??dy(qe(u,t.labelContent),n);const A=T.text;h.push({indent:2,node:e.text({id:`entity-name:${r}`,role:"label",text:A,block:T,x:o+a/2,y:s+c/2,fontSize:n.nodeLabelFontSize,anchor:"middle",paint:{fill:L}})});const $=s+c;const _=Math.min(n.nodeLineWidth,et.innerBox);h.push({indent:2,node:e.shape({id:`entity-divider:${r}`,role:"chrome",geometry:{kind:"line",x1:o,y1:$,x2:o+a,y2:$},paint:{stroke:w,strokeWidth:String(_),...P}})});const z=V0(f);for(let F=0;F<f.length;F++){const G=f[F];const I=$+F*d+d/2;for(const D of YU(e,G,r,o,I,a,n,x,z,t.attributeBlocks?.[F])){h.push({indent:2,node:D})}}if(f.length===0){const F=x(n.nodeTextColor??"var(--_text-muted)");const G=t.emptyAttributeBlock??uy();h.push({indent:2,node:e.text({id:`entity-empty:${r}`,role:"attribute",text:G.text,block:G,x:o+a/2,y:$+d/2,fontSize:Hh.attrSize,anchor:"middle",paint:{fill:F}})})}return e.group({id:`entity:${r}`,role:"entity",open:g,close:"</g>",children:h})}function YU(e,t,n,i,r,o,s,a,l,c){const d=[];const u=`attr:${n}:${t.name}`;const f=c??ch(t);const h=s.nodeTextColor??"var(--_text-sec)";const m=a(h);const p=a(s.nodeTextColor??"var(--_text-muted)");let g=0;if(t.keys.length>0){const k=t.keys.join(",");g=f.keys.width+8;const w=i+Math.max(6,s.nodePaddingX/2);d.push(e.shape({id:`${u}:key-badge`,role:"chrome",geometry:{kind:"rect",x:w,y:r-7,width:g,height:14,rx:2,ry:2},paint:{fill:"var(--_key-badge)"}}));d.push(e.text({id:`${u}:key-text`,role:"attribute",text:k,block:f.keys,x:w+g/2,y:r,fontSize:Hh.keySize,anchor:"middle",paint:{fill:h}}))}const y=i+Math.max(8,s.nodePaddingX/2)+(g>0?g+6:0);d.push(e.text({id:`${u}:type`,role:"attribute",text:t.type,block:f.type,x:y,y:r,fontSize:Hh.attrSize,anchor:"start",paint:{fill:p},attributes:{className:"mono"}}));const b=i+o-Math.max(8,s.nodePaddingX/2);const S=b-l;d.push(e.text({id:u,role:"attribute",text:t.name,block:f.name,x:S,y:r,fontSize:Hh.attrSize,anchor:"end",paint:{fill:m},attributes:{className:"mono"}}));if(t.comment){const k=sh(t.comment,t.commentContent);d.push(e.text({id:`${u}:comment`,role:"attribute",text:k,block:f.comment,x:b,y:r,fontSize:Hh.attrSize,anchor:"end",paint:{fill:p}}))}const x=t.comment&&t.comment.length>0;if(x){const k=gs(t.comment);return[e.group({id:`${u}:row`,role:"attribute",open:`<g><title>${Bk(k)}</title>`,close:"</g>",children:d.map(w=>({node:w,indent:0}))})]}return d}function qU(e,t,n,i,r,o){const s=t.identifying?"solid":"dashed";const a={category:t.identifying?"identifying":"non-identifying"};const l=st(i,"relationship",a,{includeFallback:false});const c=l?.bendRadius??n.edgeBendRadius;const d={endpoints:{from:t.entity1,to:t.entity2,start:{owner:o(t.entity1)},end:{owner:o(t.entity2)}},relationship:{kind:t.identifying?"identifying":"non-identifying"},route:{ownership:"layout",bendRadius:c},labels:t.label?[{text:t.label,textContent:{value:t.label,prepared:vt(qe(t.label,t.labelContent))}}]:[]};if(t.points.length<2){return e.connector({id:r,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:"invisible",paint:{},channels:a,...d})}const u={className:"er-relationship",data:{cardinality1:t.cardinality1,cardinality2:t.cardinality2,identifying:String(t.identifying),...t.label?{label:Hr(t.label)}:{}}};const f=l?.strokeColor??n.edgeStrokeColor??"var(--_line)";const h=l?.lineWidth??n.lineWidth;const m={stroke:f,strokeWidth:String(h),...!t.identifying?{strokeDasharray:"6 4"}:{}};if(c>0&&t.points.length>2){const p=qn(t.points,c,{metric:"manhattan"});return e.connector({id:r,role:"relationship",geometry:p.geometry,lineStyle:s,paint:m,channels:a,...d,route:{...d.route,contours:p.contours},attributes:u})}return e.connector({id:r,role:"relationship",geometry:{kind:"polyline",points:t.points},lineStyle:s,paint:m,channels:a,...d,attributes:u})}function XU(e,t,n,i,r,o){if(!t.label||t.points.length<2){return[]}const s={category:t.identifying?"identifying":"non-identifying"};const a=st(i,"relationship",s,{includeFallback:false});const l=a?.fontSize??n.edgeLabelFontSize;const c=o??X0(t.points);const d=t.labelBlock??Mr(t,n,i);const u=d.text;const f=e.shape({id:`${r}:bg`,role:"chrome",geometry:E0(d,c),paint:{fill:"var(--bg)",stroke:"var(--_inner-stroke)",strokeWidth:"0.5"},channels:s});const h=a?.textColor??n.edgeTextColor??"var(--_text-muted)";const m=e.text({id:r,role:"label",text:u,block:d,x:c.x,y:c.y,fontSize:l,anchor:"middle",paint:{fill:h},channels:s});return[f,m]}function UU(e,t,n,i){if(t.points.length<2){return[e.shape({id:i,role:"cardinality",geometry:{kind:"compound",children:[]},paint:{}})]}const r=t.points[0];const o=t.points[1];const s=t.points[t.points.length-1];const a=t.points[t.points.length-2];return[RD(e,r,o,t.cardinality1,n,`${i}:1`),RD(e,s,a,t.cardinality2,n,`${i}:2`)]}function RD(e,t,n,i,r,o){const s={stroke:r.edgeStrokeColor??"var(--_line)",strokeWidth:String(r.lineWidth+.25)};const a=P0(t,n,i,s);return e.shape({id:o,role:"cardinality",geometry:{kind:"compound",children:a.map(l=>l.geometry)},paint:s,...a.some(l=>l.paint!==s)?{childPaints:a.map(l=>l.paint)}:{},channels:{category:i}})}var Bk=It;var vD=gt(GU);var Mve={configDiagnostics:ED,normalizeRequest:e=>({renderOptions:xI(e.source.frontmatter,e.renderOptions)}),layout:e=>{const t=Tn(yI(qr(WF(e.source.familyLines),e.source.accessibility),e.source.frontmatter),e.source.frontmatter);Hm(t.classDefs,t.entities);return mt(EI(t,e.renderOptions,e.styleFace))},projectPositioned:ft(RI),lowerScene:ht(vD)};var VU={nodeSpacing:Kt,rankSpacing:Kt,wrappingWidth:Kt};var TD=e=>bt("flowchart",e,VU);var KU=200;function LD(e,t){if(!e)return t;const n=Wk(e,"nodeSpacing");const i=Wk(e,"rankSpacing");const r=Wk(e,"wrappingWidth");if(n===void 0&&i===void 0&&r===void 0)return t;return{...t,nodeSpacing:t.nodeSpacing??n,layerSpacing:t.layerSpacing??i,wrappingWidth:t.wrappingWidth??r}}function Wk(e,t){const n=kt(e,["flowchart",t]);return typeof n==="number"&&Number.isFinite(n)&&n>0?n:void 0}function AD(e,t,n){const i=t.wrappingWidth;const r=Xe(t,void 0,n);for(const o of e.nodes.values()){const s=i??(o.markdownLabel?KU:void 0);if(s===void 0||!o.label){delete o.labelBlock;continue}o.labelBlock=_e(qe(o.label,o.labelContent),{maxWidth:s,transform:r.nodeTextTransform,fontSize:r.nodeLabelFontSize,fontWeight:r.nodeLabelFontWeight,letterSpacing:r.nodeLetterSpacing})}}var Gve={configDiagnostics:TD,statementEnds:GT,normalizeRequest:e=>({renderOptions:LD(e.source.frontmatter,e.renderOptions)}),layout:e=>{const t=F2(e.source.authoredFamilyBody??e.source.familyBody,e.source.familyBody);Gm(t);AD(t,e.renderOptions,e.styleFace);const n=Ar(e.source.frontmatter);return mt(ux(t,{...e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{},...n?{diagramTitle:n}:{}}))},projectPositioned:ft(fy),lowerScene:ht(Qy)};var JU={displayMode:Bp("compact"),barHeight:Kt,topAxis:ct,axisFormat:bd,tickInterval:an('a positive Mermaid interval such as "1day" or "2week"',e=>typeof e==="string"&&/^[1-9]\d*(?:millisecond|second|minute|hour|day|week|month)$/i.test(e.trim()))};var ID=e=>bt("gantt",e,JU);function Rx(e,t){return{id:e,shape:"arrow",size:{width:8,height:7},ref:{x:8,y:3.5},orient:"auto",geometry:{kind:"path",d:"M0,0 L8,3.5 L0,7 Z"},paint:{fill:t}}}var du=(e,t)=>t?Math.max(1.8,e*1.5):Math.max(1.2,e);var QU=gr([Rx("dependency","black")]);var zk=e=>QU("dependency",e,"end");function FD(e){const t=new Map;for(const n of e){let i=t.get(n.sectionIndex);if(!i)t.set(n.sectionIndex,i=[]);i.push(n)}return t}var qk=120;var ZU=220;var eV=1e4;var tV=2;var Hn={plotWidth:600,padding:16,titleHeight:34,axisHeight:24,rowGap:8,sectionGap:6,barHeight:22,labelGap:12,labelFontSize:13,sectionFontSize:13};var nV={nodeLabelFontSize:Hn.labelFontSize,edgeLabelFontSize:11,groupHeaderFontSize:Hn.sectionFontSize,nodeLabelFontWeight:500,edgeLabelFontWeight:500,groupHeaderFontWeight:600,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:et.innerBox,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:et.outerBox};var Yh={millisecond:1,second:1e3,minute:6e4,hour:36e5,day:An,week:7*An,month:30*An};var Gk=[{unit:"minute",count:1,format:"%H:%M"},{unit:"minute",count:15,format:"%H:%M"},{unit:"hour",count:1,format:"%H:%M"},{unit:"hour",count:6,format:"%H:%M"},{unit:"day",count:1,format:"%m-%d"},{unit:"week",count:1,format:"%m-%d"},{unit:"week",count:2,format:"%m-%d"},{unit:"month",count:1,format:"%b %Y"},{unit:"month",count:3,format:"%b %Y"},{unit:"month",count:12,format:"%Y"}];function Xk(e={},t){return Xe(e,nV,t)}function qh(e){return Math.max(17,e.groupHeaderFontSize)}function Uk(e){return Math.max(e.groupHeaderFontWeight,600)}function Vk(e){const t=_D(e);return Math.max(t===Hn.titleHeight?18:t/2,qh(e)+1)}function Kk(e){return Math.max(10,e.edgeLabelFontSize*.75)}function _D(e){return Math.max(Hn.titleHeight,Math.ceil(qh(e)*1.5)+8)}function iV(e){return Math.max(Hn.axisHeight,Math.ceil(Kk(e)+e.edgeLabelFontSize*.65+4))}function rV(e,t){const n=Math.max(e.nodeLabelFontSize,e.groupHeaderFontSize)*1.3;return Math.ceil(Math.max(t,n))+Hn.rowGap}function oV(e,t,n=8){const i=e.timeMax-e.timeMin;if(t.tickInterval){const s=Yh[t.tickInterval.unit]*t.tickInterval.count;if(i/s<=qk){return{...t.tickInterval,format:t.axisFormat??sV(t.tickInterval.unit)}}}for(const s of Gk){const a=Yh[s.unit]*s.count;if(i/a<=n){return{unit:s.unit,count:s.count,format:t.axisFormat??s.format}}}const r=Gk[Gk.length-1];let o=r.count;while(i/(Yh.month*o)>qk)o*=2;return{unit:"month",count:o,format:t.axisFormat??r.format}}function sV(e){switch(e){case"millisecond":case"second":return"%H:%M:%S";case"minute":case"hour":return"%H:%M";case"day":case"week":return"%m-%d";case"month":return"%b %Y"}}function aV(e,t,n){if(t.unit==="week"){let r=Xf(e);let o=0;while(tc(r)!==n&&o++<7)r-=An;return r}if(t.unit==="month"){const r=new Date(e);return Date.UTC(r.getUTCFullYear(),r.getUTCMonth(),1)}if(t.unit==="day")return Xf(e);const i=Yh[t.unit]*t.count;return Math.floor(e/i)*i}function lV(e,t){if(t.unit==="month"){const n=new Date(e);return Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t.count,1)}return e+Yh[t.unit]*t.count}function cV(e,t,n=8){if(e.tasks.length===0)return[];const i=oV(e,t,n);const r=k0[t.weekStart];const o=[];let s=aV(e.timeMin,i,r);let a=0;while(s<=e.timeMax&&a++<=qk){if(s>=e.timeMin)o.push({time:s,label:C0(s,i.format)});s=lV(s,i)}if(o.length===0){o.push({time:e.timeMin,label:C0(e.timeMin,i.format)})}return o}function dV(e){const t=[];const n=[];let i=0;let r;for(const o of e){let s=-1;if(r){if(r[1]<=o.start){let l=1;while(l<i)l=r[l*2]<=o.start?l*2:l*2+1;s=l-i}}else{s=t.findIndex(l=>l<=o.start)}if(s===-1)s=t.length;const a=s===t.length;t[s]=o.end;n.push(s);if(r&&t.length<=i){let l=i+s;r[l]=t[s];while((l>>=1)>0)r[l]=Math.min(r[l*2],r[l*2+1])}else if(r||a&&t.length===33&&n.length<e.length&&e.every(l=>Number.isFinite(l.start)&&Number.isFinite(l.end))){i=i===0?64:i*2;r=new Array(i*2).fill(Infinity);for(let l=0;l<t.length;l++)r[i+l]=t[l];for(let l=i-1;l>0;l--){r[l]=Math.min(r[l*2],r[l*2+1])}}}return n}var Jk=8;var Jn=.01;function Hk(e){if(e.milestoneX!==void 0)return{x:e.milestoneX-e.h/2,y:e.y,w:e.h,h:e.h};return{x:e.x,y:e.y,w:e.w,h:e.h}}function uV(e,t,n,i){const[r,o]=t<=n?[t,n]:[n,t];return e>i.y+Jn&&e<i.y+i.h-Jn&&o>i.x+Jn&&r<i.x+i.w-Jn}function Qk(e,t,n,i){const[r,o]=t<=n?[t,n]:[n,t];return e>i.x+Jn&&e<i.x+i.w-Jn&&o>i.y+Jn&&r<i.y+i.h-Jn}function jh(e,t,n){if(Math.abs(e.x-t.x)<=Jn)return n.some(i=>Qk(e.x,e.y,t.y,i));return n.some(i=>uV(e.y,e.x,t.x,i))}function fV(e){return e.map(t=>({y:t.y,h:t.h})).sort((t,n)=>t.y-n.y)}function ND(e,t){return e.findIndex(n=>t>=n.y-Jn&&t<=n.y+n.h+Jn)}function jk(e,t,n){const i=e[t].y+e[t].h;const r=t+1<e.length?e[t+1].y:n.y+n.h;return(i+r)/2}function Yk(e,t,n){const i=e[t].y;const r=t>0?e[t-1].y+e[t-1].h:n.y;return(r+i)/2}function hV(e,t,n,i){const r=Jk;const o=n.x-r;const s=n.x+n.w+r;const a=t.filter(u=>u.y<e.y+e.h-Jn&&u.y+u.h>e.y+Jn);const l=new Set([o]);for(const u of a){l.add(Math.max(o,Math.min(s,u.x-r)));l.add(Math.max(o,Math.min(s,u.x+u.w+r)))}let c=o;let d=Infinity;for(const u of l){if(a.some(h=>Qk(u,e.y-1,e.y+e.h+1,h)))continue;const f=Math.abs(u-i);if(f<d-Jn||Math.abs(f-d)<=Jn&&u<c){c=u;d=f}}return c}function mV(e){const t=[];for(const n of e){const i=t[t.length-1];if(i&&Math.abs(i.x-n.x)<=Jn&&Math.abs(i.y-n.y)<=Jn)continue;t.push({x:n.x,y:n.y});const r=t.length;if(r>=3){const o=t[r-3];const s=t[r-2];const a=t[r-1];if(Math.abs(o.x-s.x)<=Jn&&Math.abs(s.x-a.x)<=Jn||Math.abs(o.y-s.y)<=Jn&&Math.abs(s.y-a.y)<=Jn){t.splice(r-2,1)}}}return t}function pV(e,t,n,i,r,o=Jk){const s=o;const a=e.rect;const l=t.rect;const c=a.y+a.h/2;const d=l.y+l.h/2;const u=ND(i,c);const f=ND(i,d);if(u===-1||f===-1)return null;const h=u===f;const m=h||f>u;const p=m?jk(i,u,r):Yk(i,u,r);const g=h?p:m?Yk(i,f,r):jk(i,f,r);const y=[];const b=a.x+a.w;const S=[{x:b,y:c},{x:b+s,y:c},{x:b+s,y:p}];if(!jh(S[0],S[1],n)&&!jh(S[1],S[2],n)){y.push(...S)}else{const E=e.tipX??(a.w>=2*s?b-s:a.x+a.w/2);y.push({x:E,y:m?a.y+a.h:a.y},{x:E,y:p})}let x=y[y.length-1].x;const k=l.x-s;if(!h){const E=m?1:-1;for(let v=u+E;v!==f;v+=E){const L=i[v];if(n.some(T=>Qk(x,L.y-1,L.y+L.h+1,T))){const T=m?Yk(i,v,r):jk(i,v,r);const A=hV(L,n,r,k);y.push({x,y:T},{x:A,y:T});x=A}}}const w=l.x-s;const C=[{x:w,y:g},{x:w,y:d},{x:l.x,y:d}];let R;let M;if(!jh(C[0],C[1],n)&&!jh(C[1],C[2],n)){M=C;R="right"}else{const E=t.tipX??(l.w>=2*s?l.x+s:l.x+l.w/2);const v=g<l.y;M=[{x:E,y:g},{x:E,y:v?l.y:l.y+l.h}];R=v?"down":"up"}y.push({x,y:g},...M);const P=mV(y);for(let E=1;E<P.length;E++){if(jh(P[E-1],P[E],n))return null}return{points:P,arrowDir:R}}function gV(e,t,n,i,r,o,s={}){const a=oA(e);if(a.length===0)return[];const l=new Map(n.map(h=>[h.taskIndex,h]));const c=n.map(Hk);const d=fV(i);const u=new Set(t.analysis?.criticalPathTaskIds??[]);const f=[];for(const h of a){const m=l.get(h.from);const p=l.get(h.to);if(!m||!p)continue;const g=t.tasks[h.from];const y=t.tasks[h.to];const b=h.kind==="after"&&g.id!==void 0&&y.id!==void 0&&u.has(g.id)&&u.has(y.id)&&g.end===y.start;const S=pV({rect:Hk(m),tipX:m.milestoneX},{rect:Hk(p),tipX:p.milestoneX},c,d,r,s.gantt?.dependencyArrows?zk(du(o.lineWidth,s.gantt.criticalPath===true&&b)):Jk);if(!S)continue;f.push({fromTaskIndex:h.from,toTaskIndex:h.to,kind:h.kind,critical:b,points:S.points,arrowDir:S.arrowDir})}return f}function $D(e,t,n,i,r){const o=_e(e,{display:"literal",transform:t,fontSize:n,fontWeight:i,letterSpacing:r,maxWidth:ZU});return{lines:[...o.lines],width:o.width,block:o}}function DD(e,t,n={}){const i=Xk(n.renderOptions,n.styleFace);const r=n.compact??e.displayMode==="compact";const o=t.tasks.length===0?_e("No tasks scheduled",{fontSize:i.nodeLabelFontSize,fontWeight:i.nodeLabelFontWeight,transform:i.nodeTextTransform,letterSpacing:i.nodeLetterSpacing}):void 0;const s=n.barHeight??e.barHeight??Hn.barHeight;let a=rV(i,s);const l=t.tasks.filter(U=>U.tags.includes("vert"));const c=t.tasks.filter(U=>!U.tags.includes("vert"));const d=FD(c);const u=new Map;const f=new Map;let h=0;for(const U of c){if(r){const te=_e(U.label,{display:"literal",transform:i.nodeTextTransform,fontSize:i.nodeLabelFontSize,fontWeight:i.nodeLabelFontWeight,letterSpacing:i.nodeLetterSpacing});u.set(U.index,{lines:te.lines,width:te.width,block:te});h=Math.max(h,te.width)}else{const te=$D(U.label,i.nodeTextTransform,i.nodeLabelFontSize,i.nodeLabelFontWeight,i.nodeLetterSpacing);u.set(U.index,te);h=Math.max(h,te.width)}}for(let U=0;U<e.sections.length;U++){const te=e.sections[U];if(te.label){const J=$D(gs(te.label),i.groupTextTransform,i.groupHeaderFontSize,i.groupHeaderFontWeight,i.groupLetterSpacing);f.set(U,J);h=Math.max(h,J.width)}}h=Math.ceil(h)+Math.max(Hn.labelGap,n.renderOptions?.gantt?.dependencyArrows?zk(du(i.lineWidth,n.renderOptions.gantt.criticalPath===true))+4:0);if(r)a=Math.max(a,...[...u.values()].map(U=>Math.ceil(U.block.height)+Hn.rowGap));const m=new Map(l.map(U=>[U.index,_e(U.label,{display:"literal",transform:i.edgeTextTransform,fontSize:i.edgeLabelFontSize,fontWeight:Math.max(i.edgeLabelFontWeight,600),letterSpacing:i.edgeLetterSpacing})]));const p=Math.max(1,t.timeMax-t.timeMin);const g=cV(t,e).map(U=>({...U,block:_e(U.label,{display:"literal",transform:i.edgeTextTransform,fontSize:i.edgeLabelFontSize,fontWeight:i.edgeLabelFontWeight,letterSpacing:i.edgeLetterSpacing})}));const y=U=>Math.max(0,...g.map(te=>{const J=te.block.width/2;return J-(t.timeMax-te.time)/p*U}));const b=Hn.padding+h;const S=n.width??Hn.padding*2+h+Hn.plotWidth;const x=Math.max(Hn.padding,Math.ceil(y(Math.max(120,S-b-Hn.padding))+tV));const k=e.title?_e(e.title,{display:"literal",transform:i.groupTextTransform,fontSize:qh(i),fontWeight:Uk(i),letterSpacing:i.groupLetterSpacing,...n.width===void 0?{}:{maxWidth:Math.max(1,n.width-Hn.padding*2)}}):void 0;const w=k?.width??0;const C=k?k.height-k.lineHeight:0;const R=n.width??Math.max(S+x-Hn.padding,Math.ceil(w)+Hn.padding*2);const M=Math.max(120,R-b-x);const P=k?Math.max(_D(i)+C,k.height):0;const E=iV(i);const v=e.topAxis?E:0;const L=Math.max(0,...[...m.values()].map(U=>(U.height-U.lineHeight)/2));const T=Hn.padding+P+v+L;const A=U=>b+(U-t.timeMin)/p*M;const $=[];const _=[];const z=[];let F=T;const G=(U,te)=>Math.max(a,Math.ceil(s/2+(U-.5)*te)+Hn.rowGap);const I=Math.max(i.nodeLabelFontSize*1.3,...[...u.values()].map(U=>U.block.lineHeight));const D=Math.max(i.groupHeaderFontSize*1.3,...[...f.values()].map(U=>U.block.lineHeight));for(let U=0;U<e.sections.length;U++){const te=e.sections[U];const J=d.get(U)??[];if(J.length===0&&te.label===void 0)continue;const ae=z.length;const Q=F;const K=_.length;const Z=f.get(U)?.lines;if(te.label!==void 0)F+=G(Z?.length??1,D);const se=r?dV(J):J.map((xe,Me)=>Me);const oe=J.length===0?0:Math.max(...se)+1;const de=[];if(r){for(let xe=0;xe<oe;xe++){de.push({barIndexes:[],sectionIndex:ae,y:F+xe*a,h:s})}}else{let xe=F;for(const Me of J){de.push({barIndexes:[],sectionIndex:ae,y:xe,h:s});xe+=G(u.get(Me.index)?.lines.length??1,I)}}J.forEach((xe,Me)=>{const Ce=se[Me];const pe=de[Ce];const Te=A(xe.start);const Fe=Math.max(xe.renderEnd>xe.start?2:0,A(xe.renderEnd)-Te);const De=xe.tags.includes("milestone");let Be;if(De){const he=s/2;const fe=b+he;const be=Math.max(fe,b+M-he);Be=Math.min(be,Math.max(fe,Te+Fe/2))}const me=u.get(xe.index)?.lines;$.push({taskIndex:xe.index,id:xe.id,label:xe.label,labelBlock:u.get(xe.index)?.block,tags:xe.tags,sectionIndex:ae,x:Te,y:pe.y,w:Fe,h:s,milestoneX:Be,rowIndex:K+(te.label!==void 0?1:0)+Ce,start:xe.start,end:xe.renderEnd,...me&&me.length>1?{labelLines:me}:{}});pe.barIndexes.push($.length-1)});_.push(...de);if(r){F+=oe*a}else{for(const xe of J)F+=G(u.get(xe.index)?.lines.length??1,I)}z.push({label:te.label,labelBlock:f.get(U)?.block,y:Q,h:F-Q,rowStart:K,rowEnd:_.length,...Z&&Z.length>1?{labelLines:Z}:{}});F+=Hn.sectionGap}const B=Math.max(a,F-T,o?o.height+Hn.padding:0);const Y=T+B+E+Hn.padding;const W=g.map(U=>({time:U.time,x:A(U.time),label:U.label,labelBlock:U.block}));const O=l.map(U=>({taskIndex:U.index,label:U.label,labelBlock:m.get(U.index),x:A(U.start+(U.renderEnd-U.start)/2),time:U.start}));const N=n.today!==void 0&&n.today>=t.timeMin&&n.today<=t.timeMax?A(n.today):void 0;const H=[];if(e.excludes.length>0&&t.dateOnly&&(t.timeMax-Xf(t.timeMin))/An<=eV){let U;const te=J=>{if(U===void 0)return;const ae=Math.max(U,t.timeMin);const Q=Math.min(J,t.timeMax);if(Q>ae)H.push({x:A(ae),w:A(Q)-A(ae),start:ae,end:Q});U=void 0};for(let J=Xf(t.timeMin);J<t.timeMax;J+=An){if(t.isExcludedDay(J)){if(U===void 0)U=J}else{te(J)}}te(t.timeMax)}const j=new Set(t.analysis?.criticalPathTaskIds??[]);const q=t.tasks.filter(U=>U.id!==void 0&&j.has(U.id)).map(U=>U.index);const X=gV(e,t,$,_,{x:b,y:T,w:M,h:B},i,n.renderOptions);const V=new Map(e.tasks.flatMap(U=>U.id?[[U.id,U.index]]:[]));const ee=e.clicks.flatMap(U=>{if(U.action!=="href")return[];const te=V.get(U.taskId);const J=U.rest.match(/^"((?:\\.|[^"])*)"|^(\S+)/)?.slice(1).find(Boolean);if(te===void 0||!J||!/^(?:https?:|mailto:)/i.test(J))return[];return[{taskIndex:te,href:J.replace(/\\(["\\])/g,"$1")}]});const re=new Map;for(const U of $){const te=re.get(U.y)??[];te.push(U);re.set(U.y,te)}for(const U of re.values()){U.sort((te,J)=>te.x-J.x);U.forEach((te,J)=>{const ae=te.labelBlock;if(!ae)return;const Q=te.y+te.h/2;const K=J>0?U[J-1].x+U[J-1].w+4:2;const Z=J+1<U.length?U[J+1].x-4:R-2;te.labelPosition=!r?{x:16,y:Q,anchor:"start"}:te.x-6-ae.width>=K?{x:te.x-6,y:Q,anchor:"end"}:te.x+te.w+6+ae.width<=Z?{x:te.x+te.w+6,y:Q,anchor:"start"}:{x:16,y:Q,anchor:"start"}})}return{...o?{emptyLabel:o}:{},title:k?.text,titleBlock:k,titleY:Math.max(Vk(i),(k?.lineHeight??0)/2)+C/2,width:R,height:Y,plot:{x:b,y:T,w:M,h:B},labelColumnWidth:h,rows:_,sections:z,bars:$,links:ee,verts:O,ticks:W,dependencies:X,criticalTaskIndexes:q,excludedBands:H,topAxis:e.topAxis,todayX:N,...e.todayMarker?.style!==void 0?{todayMarkerStyle:e.todayMarker.style}:{},timeMin:t.timeMin,timeMax:t.timeMax,dateOnly:t.dateOnly,compact:r,barHeight:s}}function OD(e,t,n={}){const i=r0(BL(e),t);const r=rA(i,n.clock);const o=DD(i,r,{...n.layout,today:r.today});return{model:i,schedule:r,positioned:o}}var BD={barRadius:3};var WD={plain:"0.6",critical:"0.95"};function yV(e){return{groupFill:e.groupFillColor??"var(--surface, var(--fg))",groupOpacity:e.groupFillColor?"1":"0.07",excludedFill:e.edgeStrokeColor??"var(--muted, var(--line, var(--fg)))",edgeStroke:e.edgeStrokeColor??"var(--line, var(--border, var(--fg)))",nodeFill:e.nodeFillColor??"var(--accent, var(--fg))",nodeBorder:e.nodeBorderColor??"var(--fg)",doneFill:e.nodeFillColor??"var(--muted, var(--line, var(--fg)))",criticalFill:e.nodeFillColor??"var(--fg)",criticalStroke:e.nodeBorderColor??e.edgeStrokeColor??"var(--accent, var(--fg))",titleFill:e.groupTextColor??e.nodeTextColor??"var(--_text)",groupText:e.groupTextColor??e.nodeTextColor??"var(--_text)",taskText:e.nodeTextColor??"var(--_text)",axisText:e.edgeTextColor??e.groupTextColor??"var(--_text-muted)"}}function xV(e){if(e.includes("crit"))return"gantt-bar gantt-bar-crit";if(e.includes("active"))return"gantt-bar gantt-bar-active";if(e.includes("done"))return"gantt-bar gantt-bar-done";return"gantt-bar"}function zD(e){if(e.includes("crit"))return"crit";if(e.includes("active"))return"active";if(e.includes("done"))return"done";return void 0}function bV(e,t,n){const i={stroke:n.nodeBorderColor?t.nodeBorder:"none",...n.nodeBorderColor?{strokeWidth:String(n.nodeLineWidth)}:{}};switch(e){case"crit":return{fill:t.criticalFill,stroke:t.criticalStroke,strokeWidth:String(Math.max(1.5,n.nodeLineWidth)),opacity:"0.95"};case"active":return{fill:t.nodeFill,stroke:t.nodeBorder,strokeWidth:String(Math.max(1.5,n.nodeLineWidth)),opacity:"1"};case"done":return{fill:t.doneFill,...i,opacity:n.nodeFillColor?"0.72":"0.55"};default:return{fill:t.nodeFill,...i,opacity:"0.92"}}}function $o(e,t,n,i,r,o,s,a,l,c,d="start",u=0,f,h){return e.text({id:t,role:n,text:o,x:Bt(i),y:Bt(r),fontSize:a,block:h,fontWeight:l,letterSpacing:u,display:"literal",anchor:d,paint:{fill:c},channels:f,attributes:{className:s},...h?{}:{baselineShift:0,dominantBaseline:"middle"}})}function GD(e){if(!e)return{};const t=e.lineWidth===void 0?void 0:e.cue==="outline"?e.lineWidth+1:e.cue==="double-line"?e.lineWidth+2:e.lineWidth;const n=e.cue==="pattern"?"3 2":e.cue==="double-line"?"8 2 2 2":void 0;return{...e.fillColor!==void 0?{fill:e.fillColor}:{},...e.strokeColor??e.borderColor?{stroke:e.strokeColor??e.borderColor}:{},...t!==void 0?{strokeWidth:String(t)}:{},...n!==void 0?{strokeDasharray:n}:{}}}function HD(e,t,n,i){return{className:e,data:{task:t,...n?.cue&&n.cue!=="none"?{"brand-cue":n.cue}:{},...i?{href:i}:{}}}}function Bt(e){return Math.round(e*100)/100}function SV(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=Xk(o,r.styleFace);const c=yV(l);const d=[];const u=o.gantt??{};const f={dependencyArrows:u.dependencyArrows===true&&n.dependencies.length>0,criticalBars:u.criticalPath===true&&n.criticalTaskIndexes.length>0,criticalArrows:u.dependencyArrows===true&&u.criticalPath===true&&n.dependencies.some(F=>F.critical)};const h=new Set(f.criticalBars?n.criticalTaskIndexes:[]);d.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},Ot(n.width,n.height,i,a)+"\n"+Dt(s,false,i.shadow,i.embedFontImport)));const m=Zt(i);if(m)d.push(e.definitions({id:"shadow-defs"},`<defs>${m}</defs>`));const p=`${wV(n)}-dep-arrow`;const g=`${p}-crit`;const y=[Rx(p,c.edgeStroke),...f.criticalArrows?[Rx(g,c.criticalStroke)]:[]];if(f.dependencyArrows){d.push(e.definitions({id:"defs",markerResources:y},`<defs>
|
|
28
|
-
${hi(y)}
|
|
29
|
-
</defs>`))}const b=n.plot;const S=b.y+b.h;const x=new Map;n.sections.forEach((F,G)=>{if(G%2===0){const I=F.label??"";const D=x.get(I)??0;x.set(I,D+1);d.push(e.shape({id:`section-band:${I}#${D}`,role:"section",geometry:{kind:"rect",x:Bt(b.x),y:Bt(F.y),width:Bt(b.w),height:Bt(F.h)},paint:{fill:c.groupFill,opacity:c.groupOpacity},channels:F.label!==void 0?{category:F.label}:void 0,attributes:{className:"gantt-section-band"}}))}});const k={fill:c.excludedFill,opacity:"0.1"};for(const F of n.excludedBands){d.push(e.shape({id:`excluded:${F.start}`,role:"grid",geometry:{kind:"rect",x:Bt(F.x),y:Bt(b.y),width:Bt(F.w),height:Bt(b.h)},paint:k,attributes:{className:"gantt-excluded-band"}}))}const w={stroke:c.edgeStroke,strokeWidth:String(l.lineWidth),opacity:l.edgeStrokeColor?"0.6":"0.45"};for(const F of n.ticks){d.push(e.shape({id:`grid:${F.time}`,role:"grid",geometry:{kind:"line",x1:Bt(F.x),y1:Bt(b.y),x2:Bt(F.x),y2:Bt(S)},paint:w,attributes:{className:"gantt-grid-line"}}))}const C=Kk(l);const R=C===10&&l.edgeLabelFontSize===11?12:Math.max(12,C);for(const F of n.ticks){const G=F.labelBlock?.text??pi(F.label,l.edgeTextTransform);d.push($o(e,`axis:${F.time}:bottom`,"axis",F.x,S+R,G,"gantt-axis-label",l.edgeLabelFontSize,l.edgeLabelFontWeight,c.axisText,"middle",l.edgeLetterSpacing,void 0,F.labelBlock));if(n.topAxis){d.push($o(e,`axis:${F.time}:top`,"axis",F.x,b.y-C,G,"gantt-axis-label",l.edgeLabelFontSize,l.edgeLabelFontWeight,c.axisText,"middle",l.edgeLetterSpacing,void 0,F.labelBlock))}}const M=l.groupHeaderFontSize*1.3;const P=l.nodeLabelFontSize*1.3;const E=new Map;for(const F of n.sections){if(F.label!==void 0){const G=E.get(F.label)??0;E.set(F.label,G+1);const I=F.labelBlock?.lines??F.labelLines??[pi(F.label,l.groupTextTransform)];I.forEach((D,B)=>{const Y=B===0?`section-label:${F.label}#${G}`:`section-label:${F.label}#${G}/${B}`;d.push($o(e,Y,"section",8,F.y+n.barHeight/2+4+B*(F.labelBlock?.lineHeight??M),D,"gantt-section-label",l.groupHeaderFontSize,l.groupHeaderFontWeight,c.groupText,"start",l.groupLetterSpacing,{category:F.label},zx(F.labelBlock,B)))})}}const v=new Map;const L=F=>{const G=v.get(F)??0;v.set(F,G+1);return G===0?`task-label:${F}`:`task-label:${F}#${G}`};if(!n.compact){for(const F of n.bars){const G=F.labelBlock?.lines??F.labelLines??[pi(F.label,l.nodeTextTransform)];const I=L(F.id??F.label);G.forEach((D,B)=>{const Y=B===0?I:`${I}/${B}`;d.push($o(e,Y,"label",F.labelPosition?.x??16,(F.labelPosition?.y??F.y+F.h/2)+B*(F.labelBlock?.lineHeight??P),D,"gantt-task-label",l.nodeLabelFontSize,l.nodeLabelFontWeight,c.taskText,"start",l.nodeLetterSpacing,void 0,zx(F.labelBlock,B)))})}}else{const F=new Map;for(const G of n.bars){const I=F.get(G.y)??[];I.push(G);F.set(G.y,I)}for(const G of F.values()){G.sort((I,D)=>I.x-D.x);G.forEach((I,D)=>{const B=I.labelBlock??_e(I.label,{display:"literal",transform:l.nodeTextTransform,fontSize:l.nodeLabelFontSize,fontWeight:l.nodeLabelFontWeight,letterSpacing:l.nodeLetterSpacing});const Y=B.text;const W=B.width;const O=I.y+I.h/2;if(I.labelPosition){d.push($o(e,L(I.id??I.label),"label",I.labelPosition.x,I.labelPosition.y,Y,"gantt-task-label",l.nodeLabelFontSize,l.nodeLabelFontWeight,c.taskText,I.labelPosition.anchor,l.nodeLetterSpacing,void 0,B));return}const N=D>0?G[D-1].x+G[D-1].w+4:2;const H=D+1<G.length?G[D+1].x-4:n.width-2;if(I.x-6-W>=N){d.push($o(e,L(I.id??I.label),"label",I.x-6,O,Y,"gantt-task-label",l.nodeLabelFontSize,l.nodeLabelFontWeight,c.taskText,"end",l.nodeLetterSpacing,void 0,B))}else if(I.x+I.w+6+W<=H){d.push($o(e,L(I.id??I.label),"label",I.x+I.w+6,O,Y,"gantt-task-label",l.nodeLabelFontSize,l.nodeLabelFontWeight,c.taskText,"start",l.nodeLetterSpacing,void 0,B))}else{d.push($o(e,L(I.id??I.label),"label",16,O,Y,"gantt-task-label",l.nodeLabelFontSize,l.nodeLabelFontWeight,c.taskText,"start",l.nodeLetterSpacing,void 0,B))}})}}const T=new Map;const A=F=>{const G=T.get(F)??0;T.set(F,G+1);return G===0?`task:${F}`:`task:${F}#${G}`};const $=new Map(n.links.map(F=>[F.taskIndex,F.href]));for(const F of n.bars){const G=n.sections[F.sectionIndex]?.label;const I=o.security==="strict"?void 0:$.get(F.taskIndex);const D=F.id??F.label;const B=h.has(F.taskIndex);const Y=B?" gantt-bar-critical-path":"";const W=B?{stroke:c.criticalStroke,strokeWidth:String(Math.max(2,l.nodeLineWidth*1.5))}:{};if(F.milestoneX!==void 0){const q=F.milestoneX;const X=F.y+F.h/2;const V=F.h/2;const ee=zD(F.tags);const re="gantt-milestone"+(ee!==void 0?` gantt-milestone-${ee}`:"")+Y;const U=`M ${Bt(q)} ${Bt(X-V)} L ${Bt(q+V)} ${Bt(X)} L ${Bt(q)} ${Bt(X+V)} L ${Bt(q-V)} ${Bt(X)} Z`;const te=ee==="crit"?{fill:c.criticalFill,stroke:c.criticalStroke,strokeWidth:String(Math.max(1.5,l.nodeLineWidth))}:ee==="active"?{fill:c.nodeFill,stroke:c.nodeBorder,strokeWidth:String(Math.max(1.5,l.nodeLineWidth)),opacity:"1"}:ee==="done"?{fill:c.doneFill,stroke:c.nodeBorder,strokeWidth:String(Math.max(1,l.nodeLineWidth)),opacity:l.nodeFillColor?"0.72":"0.55"}:{fill:c.nodeFill,stroke:c.nodeBorder,strokeWidth:String(Math.max(1,l.nodeLineWidth))};const J={...ee!==void 0?{status:ee}:{},...ee==="done"?{progress:1}:{},...B?{emphasis:true}:{},...G!==void 0?{category:G}:{}};const ae=st(r.styleFace,"milestone",J,{includeFallback:false});const Q={...te,...GD(ae),...W};d.push(e.shape({id:A(D),role:"milestone",geometry:{kind:"path",d:U},paint:Q,channels:J,attributes:HD(re,D,ae,I)}));continue}const O=zD(F.tags);const N={...O!==void 0?{status:O}:{},...O==="done"?{progress:1}:{},...B?{emphasis:true}:{},...G!==void 0?{category:G}:{}};const H=st(r.styleFace,"task",N,{includeFallback:false});const j={...bV(O,c,l),...GD(H),...W};d.push(e.shape({id:A(D),role:"task",geometry:{kind:"rect",x:Bt(F.x),y:Bt(F.y),width:Bt(Math.max(2,F.w)),height:Bt(F.h),rx:BD.barRadius,ry:BD.barRadius},paint:j,channels:N,attributes:HD(`${xV(F.tags)}${Y}`,D,H,I)}))}if(f.dependencyArrows){const F=new Map(n.bars.map(I=>[I.taskIndex,I]));const G=new Map;for(const I of n.dependencies){const D=jD(F.get(I.fromTaskIndex));const B=jD(F.get(I.toTaskIndex));const Y=`${D}->${B}:${I.kind}`;const W=G.get(Y)??0;G.set(Y,W+1);const O=f.criticalArrows&&I.critical;const N=O?"gantt-dep-arrow gantt-dep-arrow-crit":"gantt-dep-arrow";const H=O?g:p;const j=I.points.map(ee=>({x:Bt(ee.x),y:Bt(ee.y)}));const q=j.map((ee,re)=>`${re===0?"M":"L"} ${ee.x} ${ee.y}`).join(" ");const X=W===0?`dep:${Y}`:`dep:${Y}#${W}`;const V=e.connector({id:X,role:"edge",geometry:{kind:"path",d:q,points:j},lineStyle:"solid",paint:O?{stroke:c.criticalStroke,strokeWidth:String(du(l.lineWidth,true))}:{stroke:c.edgeStroke,strokeWidth:String(du(l.lineWidth,false))},markers:{mid:[],end:y.find(ee=>ee.id===H)},endpoints:{from:D,to:B},relationship:{kind:I.kind,direction:"forward"},route:{ownership:"layout"},channels:O?{status:"crit",emphasis:true}:void 0,attributes:{className:N}});d.push(e.group({id:`${X}:fade`,role:"chrome",open:"<g>",close:"</g>",paint:{opacity:O?WD.critical:WD.plain},children:[{node:V,indent:0}]}))}}const _={stroke:c.edgeStroke,strokeWidth:String(Math.max(2,l.lineWidth)),strokeDasharray:"6 3"};const z=new Map;for(const F of n.verts){const G=z.get(F.label)??0;z.set(F.label,G+1);d.push(e.shape({id:`vert:${F.label}#${G}`,role:"marker-line",geometry:{kind:"line",x1:Bt(F.x),y1:Bt(b.y),x2:Bt(F.x),y2:Bt(S)},paint:_,attributes:{className:"gantt-vert-marker"}}));const I=F.labelBlock?.text??pi(F.label,l.edgeTextTransform);const D=n.topAxis?Math.max(24,C+l.edgeLabelFontSize*1.25):C===10&&l.edgeLabelFontSize===11?8:C;d.push($o(e,`vert-label:${F.label}#${G}`,"axis",F.x,b.y-D,I,"gantt-axis-label",l.edgeLabelFontSize,Math.max(l.edgeLabelFontWeight,600),c.axisText,"middle",l.edgeLetterSpacing,void 0,F.labelBlock))}if(n.todayX!==void 0){const F=n.todayMarkerStyle!==void 0?mg(n.todayMarkerStyle):void 0;const G=Object.fromEntries(F?.applied??[]);d.push(e.shape({id:"today-marker",role:"marker-line",geometry:{kind:"line",x1:Bt(n.todayX),y1:Bt(b.y),x2:Bt(n.todayX),y2:Bt(S)},paint:{stroke:G["stroke"]??l.edgeStrokeColor??"var(--accent, var(--fg))",strokeWidth:G["stroke-width"]??String(Math.max(2,l.lineWidth)),strokeDasharray:G["stroke-dasharray"]??"4 3",...G["opacity"]!==void 0?{opacity:G["opacity"]}:{}},attributes:{className:"gantt-today-marker"}}))}if(n.title){const F=n.titleBlock?.text??pi(n.title,l.groupTextTransform);const G=n.titleY??Vk(l);d.push($o(e,"title","title",n.width/2,G,F,"gantt-title",qh(l),Uk(l),c.titleFill,"middle",l.groupLetterSpacing,void 0,n.titleBlock))}if(n.emptyLabel){const F=n.emptyLabel;d.push($o(e,"empty-state","label",b.x+b.w/2,b.y+b.h/2,F.text,"gantt-empty-state",F.fontSize,F.fontWeight,c.axisText,"middle",F.letterSpacing,void 0,F))}d.push(e.documentClose());return{family:"gantt",width:n.width,height:n.height,colors:i,transparent:a,parts:d}}function wV(e){return`gantt-${mi(e.width,e.height,...e.bars.map(t=>`${t.taskIndex}:${t.id??t.label}`),...e.dependencies.map(t=>`${t.fromTaskIndex}>${t.toTaskIndex}:${t.kind}`))}`}function jD(e){return e===void 0?"":e.id??e.label}var YD=gt(SV);var PTe={configDiagnostics:ID,normalizeRequest:e=>({familyConfig:{config:Ff(e.source.frontmatter)}}),layout:e=>{const t=e.familyConfig?.config??Ff(void 0);const n=OD(e.source.familyLines,t,{clock:{today:e.renderOptions.ganttToday},layout:{renderOptions:e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{}}});return mt(n.positioned)},projectPositioned:ft(vI),lowerScene:ht(YD)};var MV={showBranches:ct,showCommitLabel:ct,parallelCommits:ct,rotateCommitLabel:ct,mainBranchName:bd,mainBranchOrder:Op};var qD=e=>bt("gitgraph",e,MV);function XD(e){const t=e&&typeof e==="object"&&!Array.isArray(e)?e:{};const n={commitLabelFontSize:ex(t)};for(let i=0;i<8;i++){for(const r of[`git${i}`,`gitBranchLabel${i}`,`gitInv${i}`]){const o=Zn(t[r]);if(o!==void 0)n[r]=o}}for(const i of["commitLabelColor","commitLabelBackground"]){const r=Zn(t[i]);if(r!==void 0)n[i]=r}return n}function kV(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l="gitgraph-title";const c="gitgraph-desc";const d=Mi(n.accessibilityTitle??"Git graph",n.accessibilityDescription,l,c,"git graph");const u=[Ot(n.width,n.height,i,a,{attrs:d}),Dt(s,false,i.shadow,i.embedFontImport)];const f=Zt(i);if(f)u.push(`<defs>${f}</defs>`);const h=r.familyAppearance;if(!h)throw new Error("GitGraph rendering requires request-boundary family appearance resolution");const m=h.themeVariables;const p=EV(n,m,i);const g=[e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},u.join("\n"))];g.push(e.documentText({id:"acc-title",element:"title",domId:l,text:n.accessibilityTitle??"Git graph"}));if(n.accessibilityDescription)g.push(e.documentText({id:"acc-desc",element:"description",domId:c,text:n.accessibilityDescription}));if(n.title){const b=n.titleBlock??kr(n.title,16,600);g.push(e.text({id:"gitgraph-visible-title",role:"title",identity:{id:"gitgraph-title",classNames:["gitgraph-title"]},text:b.text,block:b,x:n.width/2,y:8+(n.titleBlock?.fontSize??16)*.65+((n.titleBlock?.height??0)-(n.titleBlock?.lineHeight??0))/2,fontSize:b.fontSize,anchor:"middle",paint:{fill:"var(--_text)"},attributes:{className:"gitgraph-title"}}))}if(n.showBranches){for(const b of n.branches){const S=_c("branch",b.name);const x=p.branches.get(b.name);const k=Rt(n.direction==="LR"?b.x1-10:b.x1);const w=Rt(n.direction==="LR"?b.y1:b.y1-16);const C=b.labelBlock??kr(b.name,12,600);const R=C.height-C.lineHeight;const M=Rt(C.width+10);const P=Rt(n.direction==="LR"?k-M:k-M/2);g.push(e.group({id:S,role:"group",channels:{category:b.name},open:`<g class="git-branch" data-id="${Ye(S)}" data-branch="${Ye(b.name)}">`,close:"</g>",children:[{node:e.shape({id:xn(S,"label-bg"),role:"chrome",geometry:{kind:"rect",x:P,y:Rt(w-C.fontSize-1-R/2),width:M,height:Rt(C.fontSize+6+R),rx:4,ry:4},paint:{fill:x.labelBackground,stroke:x.line,strokeWidth:"1"},attributes:{className:"git-branch-label-background"}}),indent:2},{node:e.shape({id:xn(S,"line"),role:"rail",geometry:{kind:"line",x1:Rt(b.x1),y1:Rt(b.y1),x2:Rt(b.x2),y2:Rt(b.y2)},paint:{stroke:x.line,strokeWidth:"3"},channels:{category:b.name},attributes:{className:"git-branch-line",data:{branch:b.name}}}),indent:2},{node:e.text({id:xn(S,"label"),role:"label",text:C.text,block:C,x:k,y:w-C.fontSize*.35,fontSize:C.fontSize,anchor:n.direction==="LR"?"end":"middle",paint:{fill:x.label},channels:{category:b.name},attributes:{className:"git-branch-label",data:{branch:b.name}}}),indent:2}]}))}}const y=new Map(n.commits.map(b=>[b.id,b]));for(const b of n.edges){const S=y.get(b.to)?.branch;const x=S?p.branches.get(S)?.line??"var(--_line)":"var(--_line)";g.push(e.connector({id:sm(b.from,b.to),role:"edge",geometry:{kind:"polyline",points:b.points.map(k=>({x:Rt(k.x),y:Rt(k.y)}))},lineStyle:b.kind==="cherry-pick"?"dashed":"solid",paint:{fill:"none",stroke:x,strokeWidth:b.kind==="parent"?"2":"2.5",...b.kind==="cherry-pick"?{strokeDasharray:"4 3"}:{}},endpoints:{from:b.from,to:b.to},relationship:{kind:b.kind,direction:"forward"},route:{ownership:"layout"},channels:{category:b.kind},attributes:{className:`git-edge git-edge-${b.kind}`}}))}for(const b of n.commits)g.push(CV(e,b,n,p));g.push(e.documentClose());return{family:"gitgraph",width:n.width,height:n.height,colors:i,transparent:a,parts:g}}function CV(e,t,n,i){const r=t.customType??t.type;const o=PV(t);const s=i.branches.get(t.branch);const a=r==="HIGHLIGHT"?s.highlight:r==="MERGE"?s.line:s.normalFill;const l=s.line;const c=[{node:e.shape({id:xn(t.id,"shape"),role:"chrome",geometry:o,paint:{fill:a,stroke:l,strokeWidth:"2"},channels:{status:r.toLowerCase(),category:t.branch}}),indent:2}];if(r==="MERGE"){c.push({node:e.shape({id:xn(t.id,"inner"),role:"chrome",geometry:{kind:"circle",cx:Rt(t.x),cy:Rt(t.y),r:5},paint:{fill:"none",stroke:"var(--bg)",strokeWidth:"1.5"}}),indent:2})}if(r==="REVERSE"){for(const u of[-1,1])c.push({node:e.shape({id:xn(t.id,"cross",u),role:"chrome",geometry:{kind:"line",x1:Rt(t.x-6),y1:Rt(t.y+u*6),x2:Rt(t.x+6),y2:Rt(t.y-u*6)},paint:{stroke:"var(--_arrow)",strokeWidth:"2"}}),indent:2})}if(n.showCommitLabel){const u=t.labelBlock??kr(ha(t),i.commitLabelFontSize,500);const f=u.text;const h=u.height-u.lineHeight;const m=n.direction==="LR"?t.x:t.x+14;const p=t.y+Xa(u,n.direction);const g=n.direction==="LR"?"middle":"start";const y=n.direction==="LR"&&n.rotateCommitLabel?{kind:"rotate",angle:45,cx:Rt(m),cy:Rt(p)}:void 0;if(i.commitLabelBackground){const b=Rt(Math.max(18,u.width+dh*2));const S=Rt(g==="middle"?m-b/2:m-dh);c.push({node:e.shape({id:xn(t.id,"label-bg"),role:"chrome",geometry:{kind:"rect",x:S,y:Rt(p-u.fontSize-h/2),width:b,height:Rt(u.fontSize+6+h),rx:3,ry:3},paint:{fill:i.commitLabelBackground,fillOpacity:"0.94",stroke:s.line,strokeWidth:"0.75"},transform:y,attributes:{className:"git-commit-label-background"}}),indent:2})}c.push({node:e.text({id:xn(t.id,"label"),role:"label",text:f,block:u,x:m,y:p-u.fontSize*.35,fontSize:u.fontSize,anchor:g,paint:{fill:i.commitLabelColor},transform:y,attributes:{className:"git-commit-label"}}),indent:2})}const d=t.tagBlocks??t.tags.map(u=>kr(u,10,600));t.tags.forEach((u,f)=>{const h=d[f];const m=h.height-h.lineHeight;const p=t.x+14;const g=t.y+hy(d,f);const y=Rt(h.width+10);c.push({node:e.shape({id:xn(t.id,"tag-bg",f),role:"chrome",geometry:{kind:"rect",x:Rt(p-4),y:Rt(g-h.fontSize-1-m/2),width:y,height:Rt(h.fontSize+5+m),rx:4,ry:4},paint:{fill:s.labelBackground,stroke:s.line,strokeWidth:"0.75"},attributes:{className:"git-tag-background"}}),indent:2});c.push({node:e.text({id:xn(t.id,"tag",f),role:"label",text:h.text,block:h,x:p,y:g-h.fontSize*.35,fontSize:h.fontSize,anchor:"start",paint:{fill:s.label},attributes:{className:"git-tag"}}),indent:2})});return e.group({id:t.id,role:"node",channels:{status:r.toLowerCase(),category:t.branch},open:`<g class="git-commit type-${r.toLowerCase()}" data-id="${Ye(t.id)}" data-branch="${Ye(t.branch)}" data-commit-type="${t.type}"${r!==t.type?` data-visual-type="${r}"`:""}>`,close:"</g>",children:c})}function PV(e){const t=e.customType??e.type;if(t==="HIGHLIGHT")return{kind:"rect",x:Rt(e.x-9),y:Rt(e.y-9),width:18,height:18,rx:2,ry:2};if(t==="CHERRY_PICK")return{kind:"polygon",points:[{x:Rt(e.x),y:Rt(e.y-10)},{x:Rt(e.x+10),y:Rt(e.y)},{x:Rt(e.x),y:Rt(e.y+10)},{x:Rt(e.x-10),y:Rt(e.y)}]};return{kind:"circle",cx:Rt(e.x),cy:Rt(e.y),r:t==="MERGE"?10:8}}function EV(e,t,n){const i=t&&typeof t==="object"&&!Array.isArray(t)?t:{};const r=typeof n.accent==="string"?n.accent:"#3b82f6";const o=typeof n.bg==="string"?n.bg:"#ffffff";const s=/^#[0-9a-f]{6}$/i.test(r)?r:"#3b82f6";const a=/^#[0-9a-f]{6}$/i.test(o)?o:"#ffffff";const l=Ji(e.branches.length,e.branches.length<=6?{accent:s,bg:a}:{accent:r,bg:o});const c=new Map;e.branches.forEach((u,f)=>{const h=f%8;const m=Zn(i[`git${h}`])??l[f];const p=Zn(i[`gitBranchLabel${h}`])??m;const g=Zn(i[`gitInv${h}`])??m;const y=Nn(m)&&Nn(a)?Zi(m,a,18):"var(--_node-fill)";const b=Nn(m)&&Nn(a)?Zi(m,a,9):"var(--bg)";const S=pu(p,b,4.5,n.fg);c.set(u.name,{line:m,label:S,highlight:g,normalFill:y,labelBackground:b})});const d=ex(i);return{branches:c,commitLabelColor:Zn(i.commitLabelColor)??"var(--_text-sec)",commitLabelBackground:Zn(i.commitLabelBackground)??(Nn(a)?a:"var(--bg)"),commitLabelFontSize:d}}function Rt(e){return Math.round(e*1e3)/1e3}var UD=gt(kV);var KTe={configDiagnostics:qD,statementEnds:vb,normalizeRequest:e=>({familyConfig:{position:HM(e.source.config.gitGraph,e.source.config.themeVariables),...typeof e.source.frontmatter.title==="string"?{title:e.source.frontmatter.title}:{}},appearance:{family:{themeVariables:XD(e.source.config.themeVariables)}}}),layout:e=>{const t=e.familyConfig;const n=t?.position??HM(void 0);const i=qr(GP(e.source.familyBody,{mainBranchName:n.mainBranchName,mainBranchOrder:n.mainBranchOrder,title:t?.title}),e.source.accessibility);return mt(_$(i,n,e.renderOptions,e.styleFace),{injectAccessibility:false})},projectPositioned:ft(AI),lowerScene:ht(UD)};var RV=Object.fromEntries([...["diagramMarginX","diagramMarginY","leftMargin","maxLabelWidth","width","height","taskMargin"].map(e=>[e,Kt]),...["taskFontSize","titleFontSize"].map(e=>[e,Vv]),...["taskFontFamily","titleFontFamily"].map(e=>[e,Uv]),["titleColor",bd],...["actorColours","sectionFills","sectionColours"].map(e=>[e,mf]),["useMaxWidth",ct]]);var VD=e=>bt("journey",e,RV);var ot={paddingX:32,paddingY:28,titleFontSize:18,titleFontWeight:600,titleGap:22,sectionFontSize:12,sectionFontWeight:600,sectionHeaderMinHeight:36,sectionHeaderPadX:16,sectionTaskGap:30,sectionSpanPadX:10,sectionGap:8,legendGap:26,legendMinWidth:96,legendTitleGap:26,legendRowGap:22,legendDotRadius:5,legendDotLabelGap:12,scoreLabelGutter:22,scoreLabelGap:12,taskGap:26,taskMinWidth:124,taskMinHeight:58,taskFontSize:13,taskFontWeight:500,taskPadX:14,taskPadY:12,actorDotRadius:4,actorDotGap:8,taskToGuideGap:56,scoreStep:40,markerRadius:16,baselineGap:32,baselineClearance:6,arrowOverhang:28,minPlotWidth:200};var KD={nodeLabelFontSize:ot.taskFontSize,edgeLabelFontSize:11,groupHeaderFontSize:ot.sectionFontSize,nodeLabelFontWeight:ot.taskFontWeight,edgeLabelFontWeight:600,groupHeaderFontWeight:ot.sectionFontWeight,nodePaddingX:ot.taskPadX,nodePaddingY:ot.taskPadY,nodeCornerRadius:5,nodeLineWidth:et.outerBox,edgeLineWidth:et.connector,groupCornerRadius:6,groupPaddingX:ot.sectionHeaderPadX,groupPaddingY:10,groupLabelPaddingX:ot.sectionHeaderPadX,groupLineWidth:et.outerBox};function vV(e){const t=e.mermaidConfig?.journey;const n=ZD(t?.titleFontSize,ot.titleFontSize);const i={paddingX:Pc(t?.diagramMarginX,ot.paddingX),paddingY:Pc(t?.diagramMarginY,ot.paddingY),legendMinWidth:Pc(t?.leftMargin,ot.legendMinWidth),maxLabelWidth:Pc(t?.maxLabelWidth,360),taskGap:Pc(t?.taskMargin,ot.taskGap),taskMinWidth:Pc(t?.width,ot.taskMinWidth),taskMinHeight:Pc(t?.height,ot.taskMinHeight),titleFontSize:n,titleFontSizeCss:String(t?.titleFontSize??n),titleFontFamily:mo(t?.titleFontFamily),titleColor:IV(t?.titleColor),taskFontFamily:mo(t?.taskFontFamily),actorColours:t?.actorColours??[],sectionFills:t?.sectionFills??[],sectionColours:t?.sectionColours??[]};return{visual:i,styleDefaults:TV(t),useMaxWidth:t?.useMaxWidth===true}}function Zk(e={}){return vV(e)}function TV(e){return{...KD,nodeLabelFontSize:ZD(e?.taskFontSize,KD.nodeLabelFontSize)}}function QD(e,t,n={},i){const r=t.visual;const o=Xe(n,t.styleDefaults,i);const s=e.sections.some(I=>!!I.label);const a=e.title?_e(qe(e.title,e.titleContent),{transform:o.groupTextTransform,fontSize:r.titleFontSize,fontWeight:ot.titleFontWeight,letterSpacing:o.groupLetterSpacing,fontFamily:r.titleFontFamily}):void 0;const l=a?.text;const c=a;const d=AV(e).map(I=>{const D=_e(qe(I.value,I.content),{transform:o.edgeTextTransform,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing,maxWidth:r.maxLabelWidth});return{raw:I.value,key:Wa(I.value,I.content),label:D.text,block:D}});const u=new Map(d.map((I,D)=>[I.key,D]));const f=d.map(I=>I.block);const h=_e("Actors",{transform:o.groupTextTransform,fontSize:o.groupHeaderFontSize,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing});const m=[5,4,3,2,1].map(I=>_e(String(I),{transform:o.edgeTextTransform,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing}));const p=d.length>0?Math.max(r.legendMinWidth,ot.legendDotRadius*2+ot.legendDotLabelGap+Math.max(h.width,...f.map(I=>I.width))):0;const g=e.sections.map(I=>{const D=I.label??I.id;const B=st(i,"group-header",{category:D},{includeFallback:false});const Y=B?.fontSize??o.groupHeaderFontSize;const W=B?.fontWeight??o.groupHeaderFontWeight;const O=B?.letterSpacing??o.groupLetterSpacing;const N=I.label?_e(qe(I.label,I.labelContent),{transform:B?.textTransform??o.groupTextTransform,fontSize:Y,fontWeight:W,letterSpacing:O,fontFamily:B?.fontFamily??o.groupFont,maxWidth:r.maxLabelWidth}):void 0;const H=N?.text;const j=N;const q=j?.width??0;const X=j?.height??0;const V=I.tasks.map(re=>LV(qe(re.text,re.textContent),re.actors.length,o,r));const ee=Math.max(r.taskMinWidth,q+ot.sectionHeaderPadX*2);return{category:D,label:H,block:N,labelWidth:q,labelHeight:X,tasks:V,emptyWidth:ee}});const y=Math.max(r.taskMinHeight,...g.flatMap(I=>I.tasks.map(D=>D.height)));let b=r.paddingY;if(c)b+=c.height+ot.titleGap;const S=s?Math.max(ot.sectionHeaderMinHeight,...g.map(I=>I.label?I.labelHeight+o.groupPaddingY*2:0)):0;const x=b;const k=Math.max(x+(s?S+ot.sectionTaskGap:0),d.length>0?ot.legendTitleGap-ot.legendDotRadius+h.height/2:0);const w=k+y+ot.taskToGuideGap;const C=ot.scoreStep*4;const R=w+C;const M=R+ot.baselineGap;const P=r.paddingX+p+(p>0?ot.legendGap:0)+Math.max(ot.scoreLabelGutter,...m.map(I=>I.width+ot.scoreLabelGap));let E=P;const v=[];for(let I=0;I<e.sections.length;I++){const D=e.sections[I];const B=g[I];const Y=!!B.label;if(I>0)E+=ot.sectionGap;const W=B.tasks.length>0?B.tasks.reduce((q,X)=>q+X.width,0)+(B.tasks.length-1)*r.taskGap:0;const O=Y?Math.max(W>0?W+ot.sectionSpanPadX*2:B.emptyWidth,B.labelWidth+ot.sectionHeaderPadX*2):Math.max(W,B.tasks.length===0?B.emptyWidth:0);const N=E;const H=[];let j=N+(O-W)/2;for(let q=0;q<D.tasks.length;q++){const X=D.tasks[q];const V=B.tasks[q];if(q>0)j+=r.taskGap;const ee=j;const re=ee+V.width/2;const U=JD(X.score,w);const te=FV(X,u,re,k+V.height-o.nodePaddingY-ot.actorDotRadius);H.push({id:X.id,sectionId:D.id,text:V.text,block:V.block,score:X.score,actors:X.actors,x:ee,y:k,width:V.width,height:V.height,textX:re,textY:k+o.nodePaddingY+V.textHeight/2,centerX:re,track:{x:re,y1:k+V.height,y2:M},marker:{cx:re,cy:U,r:ot.markerRadius,score:X.score},actorDots:te});j+=V.width}E=N+O;v.push({id:D.id,category:B.category,label:B.label,block:B.block,x:N,y:x,width:O,height:Y?S:0,labelX:N+O/2,labelY:x+S/2,framed:Y,headerHeight:Y?S:0,tasks:H})}const L=E+ot.arrowOverhang;const T=Math.max(L,P+ot.minPlotWidth);const A=Math.max(T,...v.map(I=>I.x+I.width));const $=Math.max(A+r.paddingX,c?c.width+2*r.paddingX:0);let _=k+ot.legendDotRadius;const z=d.map((I,D)=>{const B=f[D];const Y={category:I.raw,key:I.key,label:I.label,block:I.block,x:r.paddingX+ot.legendDotRadius,y:_,colorIndex:D};const W=I.label.includes("\n");_+=W?Math.max(ot.legendRowGap,B.height+8):ot.legendRowGap;return Y});const F=z.length>0?Math.max(...z.map(I=>I.y+Math.max(ot.legendDotRadius,(I.block?.height??0)/2))):0;const G=Math.max(M+ot.baselineClearance+r.paddingY,F+r.paddingY);return{width:$,height:G,title:l?{text:l,block:a,x:$/2,y:r.paddingY+c.height/2}:void 0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,actors:z,actorLegendTitle:h,scoreGuide:{x:P,y:w,width:T-P,height:C,ticks:[5,4,3,2,1].map((I,D)=>{const B=JD(I,w);return{score:I,block:m[D],x1:P,x2:T,y:B,labelX:P-ot.scoreLabelGap,labelY:B}}),baseline:{x1:P,y1:M,x2:T,y2:M}},sections:v}}function LV(e,t,n,i){const r=_e(e,{transform:n.nodeTextTransform,fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing,fontFamily:i.taskFontFamily,maxWidth:i.maxLabelWidth});const o=r.text;const s=r;const a=t>0?t*ot.actorDotRadius*2+(t-1)*ot.actorDotGap:0;const l=Math.max(i.taskMinWidth,s.width+n.nodePaddingX*2,a+n.nodePaddingX*2);const c=t>0?ot.actorDotRadius*2:0;const d=Math.max(i.taskMinHeight,n.nodePaddingY*2+s.height+(c>0?12+c:0));return{text:o,block:r,textWidth:s.width,textHeight:s.height,actorDotsWidth:a,width:l,height:d}}function AV(e){const t=[];const n=new Set;for(const i of e.sections){for(const r of i.tasks){for(const[o,s]of r.actors.entries()){const a=Wa(s,r.actorContents?.[o]);if(n.has(a))continue;n.add(a);t.push({value:s,content:r.actorContents?.[o]})}}}return t}function ZD(e,t){if(typeof e==="number"&&Number.isFinite(e)&&e>0)return e;if(typeof e!=="string")return t;const n=e.trim();const i=Number.parseFloat(n);if(!Number.isFinite(i)||i<=0)return t;if(/^[0-9.]+(?:px)?$/i.test(n))return i;if(/^[0-9.]+ex$/i.test(n))return i*8;if(/^[0-9.]+em$/i.test(n))return i*t;return t}function Pc(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>0?e:t}function IV(e){return typeof e==="string"&&e.trim().length>0?e.trim():void 0}function FV(e,t,n,i){const r=e.actors.length;if(r===0)return[];const o=r*ot.actorDotRadius*2+(r-1)*ot.actorDotGap;let s=n-o/2+ot.actorDotRadius;return e.actors.map((a,l)=>{const c={label:a,key:Wa(a,e.actorContents?.[l]),colorIndex:t.get(Wa(a,e.actorContents?.[l]))??0,x:s,y:i,r:ot.actorDotRadius};s+=ot.actorDotRadius*2+ot.actorDotGap;return c})}function JD(e,t){return t+(NV-e)*ot.scoreStep}var NV=5;function eO(e,t={}){const n={sections:[],...vr(t)};if(ie("journey")){Ge("journey","header",e[0]??"",{line:1,unit:"normalized"});ue("journey","initialize",n)}let i;let r=0;let o=0;const s=()=>{if(i)return i;i={id:`section-${r++}`,tasks:[]};n.sections.push(i);if(ie("journey"))ue("journey","addImplicitSection",i);return i};YL(e,1,{title:(a,l,c)=>{if(ie("journey"))Ge("journey","title",a,{line:l+1,unit:"normalized"});n.title=a;if(c)n.titleContent=c;else delete n.titleContent;if(ie("journey"))ue("journey","setTitle",a,{line:l+1,unit:"normalized"})},accTitle:(a,l)=>{if(ie("journey"))Ge("journey","accTitle",a,{line:l+1,unit:"normalized"});n.accessibilityTitle=a;if(ie("journey"))ue("journey","setAccessibilityTitle",a,{line:l+1,unit:"normalized"})},accDescr:(a,l)=>{if(ie("journey"))Ge("journey","accDescr",a,{line:l+1,unit:"normalized"});n.accessibilityDescription=a;if(ie("journey"))ue("journey","setAccessibilityDescription",a,{line:l+1,unit:"normalized"})},section:(a,l,c)=>{if(ie("journey"))Ge("journey","section",a,{line:l+1,unit:"normalized"});i={id:`section-${r++}`,label:a,...c?{labelContent:c}:{},tasks:[]};n.sections.push(i);if(ie("journey"))ue("journey","addSection",i,{line:l+1,unit:"normalized"})},task:(a,l,c,d,u,f)=>{if(ie("journey"))Ge("journey","task",a,{line:d+1,unit:"normalized"});const h={id:`task-${o++}`,text:a,...u?{textContent:u}:{},score:l,actors:c,...f?{actorContents:f}:{}};s().tasks.push(h);if(ie("journey"))ue("journey","addTask",{...h,sectionId:i.id},{line:d+1,unit:"normalized"})},issue:a=>{if(ie("journey"))Ge("journey",`invalid:${a.code}`,a.statement,{line:a.lineIndex+1,unit:"normalized"});throw $V(a)}});return n}function $V(e){switch(e.code){case"section_colon":return Je({what:`Invalid user journey section: "${e.statement}"`,expectedForm:"section Section name",example:"section Go to work"});case"empty_task_text":return Je({what:`Invalid user journey task: "${e.statement}"`,expectedForm:"Task name: score: Actor[, Actor\u2026]",example:"Pay: 3: Shopper"});case"invalid_score":case"unclosed_accdescr":return new Error(e.detail);case"empty_title":case"unrecognized_line":return new Error(`Invalid user journey line: "${e.statement}". Expected title, section, accessibility metadata, or "Task name: 3: Actor"`)}}var uu={titleFontSize:18,titleFontWeight:600,sectionFontSize:12,sectionFontWeight:600,taskFontSize:13,taskFontWeight:500,actorFontSize:11,actorFontWeight:600,legendDotRadius:5,legendLabelGap:12,legendTitleGap:26};var vx=5;function _V(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=[];const c=r.familyAppearance;if(!c)throw new Error("Journey rendering requires request-boundary family appearance resolution");const d=Xe(o,c.styleDefaults,r.styleFace);const u=c.visual;const f=n9(d,u,i,{sectionCount:n.sections.length,actorCount:n.actors.length});const h=OV(n);const m=DV(n);const p=`${m}-arrowhead`;const g=WV(p,f.arrow);const y=`${m}-title`;const b=`${m}-desc`;const S=o.journey?.experienceCurve!==false?n.sections.flatMap(R=>R.tasks.map(M=>M.marker)):[];const x=S.length>=2;const k=GV(u);l.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false,...k?{extraCss:k}:{}},BV(n,i,a,h,y,b,c.useMaxWidth)));if(h.title){l.push(e.documentContent({id:"a11y-title",role:"chrome",nonPaint:"accessibility"},`<title id="${y}">${It(h.title)}</title>`))}if(h.description){l.push(e.documentContent({id:"a11y-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${b}">${It(h.description)}</desc>`))}l.push(e.documentContent({id:"style",role:"chrome",nonPaint:"stylesheet"},Dt(s,false,i.shadow,i.embedFontImport)));l.push(e.definitions({id:"defs",markerResources:[g]},zV(i,g)));if(k)l.push(e.documentContent({id:"journey-style",role:"chrome",nonPaint:"stylesheet"},k));l.push(YV(e,n.scoreGuide,d,g));if(n.actors.length>0){l.push(qV(e,n.actors,d,f,n.actorLegendTitle))}const w=o.mermaidConfig?.journey;const C=w?.sectionFills!==void 0||w?.sectionColours!==void 0;n.sections.forEach((R,M)=>{if(R.framed){l.push(XV(e,R,d,f,M,r.styleFace,C))}});if(x){l.push(HV(e,S,d,f))}for(const R of n.sections){for(const M of R.tasks){l.push(VV(e,M,R.label,d,f))}}if(n.title){l.push(e.text({id:"title",role:"title",text:n.title.text,block:n.title.block,x:n.title.x,y:n.title.y,fontSize:u.titleFontSize,fontWeight:uu.titleFontWeight,anchor:"middle",paint:{fill:f.titleColor},attributes:{className:"journey-title"}}))}l.push(e.documentClose());return{family:"journey",width:n.width,height:n.height,colors:i,transparent:a,parts:l}}function DV(e){const t=e.sections.flatMap(n=>[n.id,n.label??"",...n.tasks.flatMap(i=>[i.id,i.text,String(i.score),...i.actors])]);return`journey-${mi(e.width,e.height,e.title?.text??"",e.accessibilityTitle??"",e.accessibilityDescription??"",...t)}`}function OV(e){return{title:e.accessibilityTitle??e.title?.text,description:e.accessibilityDescription}}function BV(e,t,n,i,r,o,s){return Ot(e.width,e.height,t,n,{...s?{width:"100%",height:"100%",style:`max-width:${e.width}px`}:{},attrs:Mi(i.title,i.description,r,o,"user journey")})}function WV(e,t){return{id:e,shape:"arrow",size:{width:10,height:8},ref:{x:9,y:4},orient:"auto",geometry:{kind:"path",d:"M0,0 L10,4 L0,8 Z"},paint:{fill:t}}}function zV(e,t){const n=[Zt(e),am(t)].filter(Boolean);return`<defs>
|
|
30
|
-
${n.join("\n")}
|
|
31
|
-
</defs>`}function GV(e){return e.taskFontFamily?`<style>
|
|
32
|
-
.journey-task-text { font-family: ${e.taskFontFamily}; }
|
|
33
|
-
</style>`:void 0}function HV(e,t,n,i){const r=t.map(s=>({x:s.cx,y:s.cy}));const o=jV(r);return e.connector({id:"experience-curve",role:"series",geometry:o.geometry,lineStyle:"solid",paint:{stroke:`color-mix(in srgb, ${i.arrow} 55%, var(--bg))`,strokeWidth:String(Math.max(2,n.lineWidth*2)),strokeLinecap:"round"},route:{ownership:"family",contours:o.contours},attributes:{className:"journey-curve"}})}function jV(e){const t=e[0];let n=`M${t.x},${t.y}`;const i=[];for(let r=1;r<e.length;r++){const o=e[r-1];const s=e[r];const a=(s.x-o.x)/3;const l={x:o.x+a,y:o.y};const c={x:s.x-a,y:s.y};n+=` C${l.x},${l.y} ${c.x},${c.y} ${s.x},${s.y}`;i.push({kind:"cubic",control1:l,control2:c,end:s})}return Ac(n,t,i)}function YV(e,t,n,i){const r=[];for(const s of t.ticks){r.push({indent:2,node:e.connector({id:`score-guide:${s.score}`,role:"grid",geometry:{kind:"line",x1:s.x1,y1:s.y,x2:s.x2,y2:s.y},lineStyle:"solid",paint:{stroke:`color-mix(in srgb, ${n.nodeBorderColor??"var(--_node-stroke)"} 62%, var(--bg))`,strokeWidth:"1"},channels:{value:s.score/vx},attributes:{className:"journey-guide"}})});r.push({indent:2,node:e.text({id:`score-label:${s.score}`,role:"axis",text:s.block?.text??String(s.score),block:s.block,x:s.labelX,y:s.labelY,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"end",paint:{fill:n.edgeTextColor??"var(--_text-sec)"},channels:{value:s.score/vx},attributes:{className:"journey-score-label"}})})}const o=t.baseline;r.push({indent:2,node:e.connector({id:"journey-baseline",role:"rail",geometry:{kind:"line",x1:o.x1,y1:o.y1,x2:o.x2,y2:o.y2},lineStyle:"solid",paint:{stroke:n.edgeStrokeColor??"var(--_arrow)",strokeWidth:String(Math.max(2,n.lineWidth*2))},markers:{mid:[],end:i},attributes:{className:"journey-baseline"}})});return e.group({id:"score-guide",role:"grid",open:`<g class="journey-score-guide" data-score-min="1" data-score-max="5">`,close:"</g>",children:r})}function qV(e,t,n,i,r){const o=t[0];const s=o.x-uu.legendDotRadius;const a=o.y-uu.legendTitleGap;const l=r?.text??pi("Actors",n.groupTextTransform);const c=[{indent:2,node:e.text({id:"actor-legend-title",role:"legend",text:l,block:r,x:s,y:a,fontSize:n.groupHeaderFontSize,fontWeight:n.groupHeaderFontWeight,letterSpacing:n.groupLetterSpacing,anchor:"start",paint:{fill:n.groupTextColor??"var(--_text-sec)"},attributes:{className:"journey-actor-legend-title"}})}];for(const d of t){c.push({indent:2,node:e.shape({id:_c("actor-legend-dot",d.category,...e1(d.category,d.key)),role:"actor",geometry:{kind:"circle",cx:d.x,cy:d.y,r:uu.legendDotRadius},paint:{fill:aO(d.colorIndex,i),stroke:"var(--bg)",strokeWidth:"1"},channels:{category:d.category},attributes:{className:`journey-actor-dot ${sO(d.colorIndex,i)}`,data:{actor:d.category}}})});c.push({indent:2,node:e.text({id:_c("actor-legend-label",d.category,...e1(d.category,d.key)),role:"legend",text:d.label,block:d.block,x:d.x+uu.legendDotRadius+uu.legendLabelGap,y:d.y,fontSize:n.edgeLabelFontSize,fontWeight:n.edgeLabelFontWeight,letterSpacing:n.edgeLetterSpacing,anchor:"start",paint:{fill:n.groupTextColor??"var(--_text-sec)"},channels:{category:d.category},attributes:{className:"journey-actor-legend-text"}})})}return e.group({id:"actor-legend",role:"legend",open:`<g class="journey-actor-legend">`,close:"</g>",children:c})}function XV(e,t,n,i,r,o,s){const a=t.category;const l=t.label?` data-label="${hn(t.label)}"`:"";const c=[];c.push({indent:2,node:e.shape({id:`section-bg:${t.id}`,role:"section",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.groupCornerRadius,ry:n.groupCornerRadius},paint:{fill:l9(r,i),stroke:c9(r,i),strokeWidth:String(n.groupLineWidth)},attributes:{className:`journey-section-bg journey-section-${r%i.sectionFills.length}`}})});if(t.label){const d={category:a};const u=st(o,"group-header",d,{includeFallback:false});const f=t.block?.text??pi(t.label,u?.textTransform??n.groupTextTransform);const h=u?.fontSize??n.groupHeaderFontSize;const m=u?.fontWeight??n.groupHeaderFontWeight;const p=u?.letterSpacing??n.groupLetterSpacing;const g=s?nO(r,i):u?.textColor??nO(r,i);c.push({indent:2,node:UV(e,t,n,i,r,o,s)});c.push({indent:2,node:e.text({id:`section-label:${t.id}`,role:"group-header",text:f,block:t.block,x:t.labelX,y:t.labelY,fontSize:h,fontWeight:m,letterSpacing:p,anchor:"middle",paint:{fill:g},attributes:{className:`journey-section-label journey-section-label-${r%i.sectionTextColors.length}`}})})}return e.group({id:`section:${t.id}`,role:"section",open:`<g class="journey-section" data-id="${Ye(t.id)}"${l}>`,close:"</g>",children:c,channels:{category:a}})}function UV(e,t,n,i,r,o,s){const a={category:t.category};const l=st(o,"group-header",a,{includeFallback:false});const c=s?tO(r,i):l?.fillColor??tO(r,i);const d=l?.cue??"none";const u=l?.strokeColor??l?.borderColor??(d!=="none"?"var(--fg)":"none");const f=l?.lineWidth??(d!=="none"?n.groupLineWidth:void 0);const h=f===void 0?void 0:d==="outline"?f+1:d==="double-line"?f+2:f;const m=d==="pattern"?"3 2":d==="double-line"?"8 2 2 2":void 0;const p=Math.min(6,Math.max(3,t.height/6));const g=Math.max(18,Math.min(t.height-p*2,n.groupHeaderFontSize+n.groupPaddingY));const y=t.x+p;const b=t.labelY-g/2;const S=Math.max(0,t.width-p*2);const x=Math.min(n.groupCornerRadius,g/2);return e.shape({id:`section-band:${t.id}`,role:"group-header",geometry:{kind:"rect",x:y,y:b,width:S,height:g,rx:x,ry:x},paint:{fill:c,stroke:u,...h!==void 0?{strokeWidth:String(h)}:{},...m?{strokeDasharray:m}:{}},channels:a,attributes:{className:`journey-section-label-band journey-section-band-${r%i.sectionBands.length}`,...d!=="none"?{data:{"brand-cue":d}}:{}}})}function VV(e,t,n,i,r){const o=n?` data-section="${Ye(n)}"`:"";const s=t.actors.length>0?` data-actors="${Ye(t.actors.join(", "))}"`:"";const a=t.score/vx;const l=n?{value:a,category:n}:{value:a};const c=[{indent:2,node:KV(e,t.track,t,i,r)},{indent:2,node:JV(e,t,i,r,l)},{indent:2,node:QV(e,t,i,r,l)}];const d=new Map;for(const u of t.actorDots){const f=u.key??Wa(u.label);const h=d.get(f)??0;d.set(f,h+1);c.push({indent:2,node:ZV(e,u,t.id,h,r)})}c.push({indent:2,node:e9(e,t.marker,t.id,r,l)});return e.group({id:`task:${t.id}`,role:"task",open:`<g class="journey-task" data-id="${Ye(t.id)}" data-score="${t.score}"${o}${s}>`,close:"</g>",children:c,channels:l})}function KV(e,t,n,i,r){return e.connector({id:`track:${n.id}`,role:"marker-line",geometry:{kind:"line",x1:t.x,y1:t.y1,x2:t.x,y2:t.y2},lineStyle:"dashed",paint:{stroke:`color-mix(in srgb, ${r.nodeStroke} 78%, var(--bg))`,strokeWidth:String(i.lineWidth),strokeDasharray:"4 7"},channels:{value:n.score/vx},attributes:{className:"journey-track"}})}function JV(e,t,n,i,r){return e.shape({id:`task-box:${t.id}`,role:"task",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:n.cornerRadius??0,ry:n.cornerRadius??0},paint:{fill:i.nodeFill,stroke:i.nodeStroke,strokeWidth:String(n.nodeLineWidth)},channels:r,attributes:{className:"journey-task-box"}})}function QV(e,t,n,i,r){return e.text({id:`task-label:${t.id}`,role:"label",text:t.text,block:t.block,x:t.textX,y:t.textY,fontSize:n.nodeLabelFontSize,fontWeight:n.nodeLabelFontWeight,letterSpacing:n.nodeLetterSpacing,anchor:"middle",paint:{fill:i.taskText},channels:r,attributes:{className:"journey-task-text"}})}function e1(e,t){return t!==void 0&&t!==Wa(e)?[t]:[]}function ZV(e,t,n,i,r){return e.shape({id:_c("actor-dot",n,t.label,...e1(t.label,t.key),...i>0?[i]:[]),role:"actor",geometry:{kind:"circle",cx:t.x,cy:t.y,r:t.r},paint:{fill:aO(t.colorIndex,r),stroke:"var(--bg)",strokeWidth:"1"},channels:{category:t.label},attributes:{className:`journey-actor-dot ${sO(t.colorIndex,r)}`,data:{actor:t.label}}})}function e9(e,t,n,i,r){const o=t.cy-4.5;const s=t.cx-5.5;const a=t.cx+5.5;const l=t9(t);return e.group({id:`score-marker:${n}`,role:"score",open:`<g class="journey-score-marker" data-score="${t.score}">`,close:"</g>",children:[{indent:2,node:e.shape({id:`score-face:${n}`,role:"score",geometry:{kind:"circle",cx:t.cx,cy:t.cy,r:t.r},paint:{fill:i.scoreFaceFill,stroke:i.scoreFaceStroke,strokeWidth:"1.2"},channels:r,attributes:{className:"journey-score-face"}})},{indent:2,node:e.shape({id:`score-eye-left:${n}`,role:"score",geometry:{kind:"circle",cx:s,cy:o,r:2},paint:{fill:i.scoreFaceInk},channels:r,attributes:{className:"journey-face-eye"}})},{indent:2,node:e.shape({id:`score-eye-right:${n}`,role:"score",geometry:{kind:"circle",cx:a,cy:o,r:2},paint:{fill:i.scoreFaceInk},channels:r,attributes:{className:"journey-face-eye"}})},{indent:2,node:e.shape({id:`score-mouth:${n}`,role:"score",geometry:{kind:"path",d:l},paint:{fill:"none",stroke:i.scoreFaceInk,strokeWidth:"1.6",strokeLinecap:"round"},channels:r,attributes:{className:"journey-face-mouth"}})}],channels:r})}function t9(e){const t=e.cx;const n=e.cy;if(e.score>=4.5)return`M${t-8},${n+4} Q${t},${n+13} ${t+8},${n+4}`;if(e.score>3)return`M${t-8},${n+5} Q${t},${n+11} ${t+8},${n+5}`;if(e.score===3)return`M${t-8},${n+6} L${t+8},${n+6}`;if(e.score>=1.5)return`M${t-8},${n+10} Q${t},${n+2} ${t+8},${n+10}`;return`M${t-9},${n+11} Q${t},${n} ${t+9},${n+11}`}function n9(e,t,n,i){const r=e.edgeStrokeColor??"var(--_arrow)";const o=e.nodeFillColor??"var(--_node-fill)";const s=e.nodeBorderColor??"var(--_node-stroke)";const a=i9(r,n,e,i.sectionCount);const l=Math.max(t.sectionFills.length,t.sectionColours.length,Math.min(a.length,Math.max(i.sectionCount,1)));const c=Array.from({length:l},(p,g)=>{const y=t.sectionFills[g%t.sectionFills.length];return y??e.groupFillColor??`color-mix(in srgb, ${a[g%a.length]} ${g===0?8:9}%, var(--bg))`});const d=Array.from({length:l},(p,g)=>{const y=t.sectionFills[g%t.sectionFills.length];return y??e.groupHeaderFillColor??`color-mix(in srgb, ${a[g%a.length]} ${g===0?14:16}%, var(--bg))`});const u=Array.from({length:l},(p,g)=>{const y=t.sectionFills[g%t.sectionFills.length];return y?`color-mix(in srgb, ${y} ${g===0?42:38}%, var(--bg))`:e.groupBorderColor??`color-mix(in srgb, ${a[g%a.length]} ${g===0?42:38}%, var(--bg))`});const f=d.map((p,g)=>{const y=a[g%a.length];const b=t.sectionFills[g%t.sectionFills.length];return b===void 0&&e.groupHeaderFillColor===void 0&&Nn(y)&&Nn(n.bg)?Zi(y,n.bg,g===0?14:16):p});const h=Array.from({length:l},(p,g)=>r9(t.sectionColours.length>0?t.sectionColours[g%t.sectionColours.length]:void 0,f[g],e.groupTextColor??"var(--_text)",n));const m=t.actorColours.length>0?t.actorColours:o9(r,n,e,i.actorCount);return{arrow:r,nodeFill:o,nodeStroke:s,taskText:e.nodeTextColor??yi("var(--_text)",o,n),titleColor:t.titleColor??e.groupTextColor??e.nodeTextColor??"var(--_text)",sectionFills:c,sectionBands:d,sectionStrokes:u,sectionTextColors:h,actorColors:m,scoreFaceFill:`color-mix(in srgb, ${r} 22%, var(--bg))`,scoreFaceStroke:r,scoreFaceInk:e.edgeTextColor??e.nodeTextColor??"var(--_text)"}}function i9(e,t,n,i){const r=a9(t,n,Math.max(6,i));if(r)return r;return[e,"var(--line, var(--_line))","var(--accent, var(--_arrow))","var(--muted, var(--_text-sec))","var(--border, var(--_node-stroke))","var(--fg)"]}function r9(e,t,n,i){const r=i.bg;if(e){const a=na(e,t,r);if(a!==null&&a>=4.5)return e}else{const a=_n(n,i);if(a!==void 0&&Nn(t))return ms(a,t)}const o=na("#000000",t,r);const s=na("#ffffff",t,r);if(o!==null&&s!==null)return o>=s?"#000000":"#ffffff";return n}function o9(e,t,n,i){const r=Math.max(i,1);if(r>6&&oO(t.bg)){const s=rO(n.edgeStrokeColor,t.accent);if(s)return Ji(r,{accent:s,bg:t.bg})}if(Nn(t.bg)&&Nn(t.fg)){const s=bl(t);const a=iO(n.edgeStrokeColor,t.accent,s.arrow);if(a){if(r<=6){const l=s9(a,t.bg,r);if((r<2||Lh(l)>=.1)&&l.every(c=>na(c,t.bg)>=1.25&&Math.abs(Qa(c,t.bg))>=15))return l}return Ji(r,{accent:a,bg:t.bg})}}const o=[e,"var(--line, var(--_line))","var(--accent, var(--_arrow))","var(--muted, var(--_text-sec))","var(--border, var(--_node-stroke))","var(--fg)","color-mix(in srgb, var(--accent, var(--_arrow)) 62%, var(--bg))","color-mix(in srgb, var(--line, var(--_line)) 72%, var(--bg))"];return o.slice(0,Math.max(r<=o.length?r:o.length,1))}function s9(e,t,n){const[i,r]=Wy(e);const o=vM(t);const s=r<20?230:i;const a=Math.min(72,Math.max(42,r<20?46:r));const l=o?64:38;const c=[];const d=new Set;const u=Math.min(n,a0);for(let f=0;c.length<u&&f<a0*16;f++){const h=Math.floor(f/360);const m=(s+f%360*137.508)%360;const p=RM(m,Math.max(34,a-h%4*7),Math.max(o?46:24,Math.min(o?78:58,l+(h%2===0?-h*2:h*2))));if(!d.has(p)){d.add(p);c.push(p)}}return Array.from({length:n},(f,h)=>c[h%c.length])}function a9(e,t,n){if(n>6&&oO(e.bg)){const o=rO(t.edgeStrokeColor,e.accent);if(o)return Ji(n,{accent:o,bg:e.bg})}if(!Nn(e.bg)||!Nn(e.fg))return void 0;const i=bl(e);const r=iO(t.edgeStrokeColor,e.accent,i.arrow);if(!r)return void 0;return Ji(n,{accent:r,bg:e.bg})}function iO(...e){return e.find(t=>t!==void 0&&Nn(t))}function rO(...e){return e.find(t=>t!==void 0&&Vt(t)!==null)}function oO(e){return Vt(e)?.[3]===1}function sO(e,t){return`journey-actor-${e%t.actorColors.length}`}function aO(e,t){return t.actorColors[e%t.actorColors.length]}function l9(e,t){return t.sectionFills[e%t.sectionFills.length]}function tO(e,t){return t.sectionBands[e%t.sectionBands.length]}function c9(e,t){return t.sectionStrokes[e%t.sectionStrokes.length]}function nO(e,t){return t.sectionTextColors[e%t.sectionTextColors.length]}var lO=gt(_V);var OLe={configDiagnostics:VD,normalizeRequest:e=>({appearance:{family:Zk(e.renderOptions)}}),layout:e=>mt(QD(Tn(eO(e.source.authoredFamilyLines??e.source.familyLines,e.source.accessibility),e.source.frontmatter),e.familyAppearance??Zk(e.renderOptions),e.renderOptions,e.styleFace)),projectPositioned:ft(II),lowerScene:ht(lO)};var d9={padding:jt,maxNodeWidth:Kt};var cO=e=>{const t=bt("mindmap",e,d9);const n=e.root;const i=n&&typeof n==="object"&&!Array.isArray(n)?n:void 0;if(i&&"layout"in i&&!["tidy-tree","cose-bilkent","radial"].includes(String(i.layout)))t.push({code:"INEFFECTIVE_CONFIG",field:"layout",message:'layout must be "cose-bilkent", "radial", or "tidy-tree" for mindmap diagrams; the invalid value has no effect.'});return t};var t1=.38;function n1(e,t){const n=e.width*(e.shape==="bang"?t1:.5);return e.x+e.width/2+(t==="right"?n:-n)}var u9=13;var f9=500;function dO(e,t={}){const n=Xh(t.padding,32);const i=Xh(t.maxNodeWidth,180);const r=Xh(t.nodeGap,40);const o=Xh(t.layerGap,20);const s=h9(e.root,i,t.textStyle);return t.layout==="tidy-tree"?m9(e,s,n,r,o):p9(e,s,n,r,o)}function h9(e,t,n){const i=new Map;const r=(o,s,a)=>{const l=_e(o.label,{fontSize:n?.nodeLabelFontSize??u9,fontWeight:n?.nodeLabelFontWeight??f9,letterSpacing:n?.nodeLetterSpacing,transform:n?.nodeTextTransform,maxWidth:t});const c=l.text;const d=l;let u=Math.max(56,d.width+24);let f=Math.max(34,d.height+18+(o.icon?14:0));if(o.shape==="circle")u=f=Math.max(u,f,54);if(o.shape==="bang"||o.shape==="cloud"){u+=18;f+=10}i.set(o.id,{id:o.id,label:c,labelBlock:l,iconFallbackBlock:o.icon&&!ol(o.icon)?_e(rl(o.icon),{fontSize:9,fontWeight:400}):void 0,shape:o.shape,markdown:o.markdown,icon:o.icon,className:o.className,...a?{parentId:a}:{},depth:s,side:s===0?"root":"right",x:0,y:0,width:u,height:f});for(const h of o.children)r(h,s+1,o.id)};r(e,0);return i}function m9(e,t,n,i,r){const o=g9(t);const s=new Map([[0,n]]);const a=Math.max(...Array.from(t.values(),d=>d.depth));for(let d=1;d<=a;d++){s.set(d,s.get(d-1)+(o.get(d-1)??0)+r)}let l=n;const c=d=>{const u=t.get(d.id);u.side=u.depth===0?"root":"right";u.x=s.get(u.depth);if(d.children.length===0){u.y=l;l+=u.height+i;return u.y+u.height/2}const f=d.children.map(c);const h=(f[0]+f.at(-1))/2;u.y=Math.max(n,h-u.height/2);return u.y+u.height/2};c(e.root);uO(t,n);return fO(e,t,n)}function p9(e,t,n,i,r){const o=t.get(e.root.id);const s=R=>{const M=t.get(R.id).height;if(R.children.length===0)return M;return Math.max(M,R.children.reduce((P,E)=>P+s(E),0)+i*(R.children.length-1))};const a=[];const l=[];let c=0;let d=0;e.root.children.forEach((R,M)=>{const P=s(R)+i;const E=M===1||M>1&&c<d;if(E){a.push(R);c+=P}else{l.push(R);d+=P}});const u=(R,M)=>{t.get(R.id).side=M;R.children.forEach(P=>u(P,M))};a.forEach(R=>u(R,"left"));l.forEach(R=>u(R,"right"));const f=R=>{const M=new Map;for(const P of t.values()){if(P.side!==R)continue;M.set(P.depth,Math.max(M.get(P.depth)??0,P.width))}return M};const h=f("left");const m=f("right");const p=R=>[...R.values()].reduce((M,P)=>M+P+r,0);o.x=n+p(h);const g=(R,M)=>{const P=new Map;let E=R==="left"?o.x:o.x+o.width;const v=Math.max(0,...M.keys());for(let L=1;L<=v;L++){const T=M.get(L)??0;if(R==="left"){E-=r+T;P.set(L,E)}else{E+=r;P.set(L,E);E+=T}}return P};const y=g("left",h);const b=g("right",m);const S=(R,M)=>{let P=n;const E=M==="left"?h:m;const v=M==="left"?y:b;const L=T=>{const A=t.get(T.id);const $=v.get(A.depth);A.x=M==="left"?$+(E.get(A.depth)-A.width):$;if(T.children.length===0){A.y=P;P+=A.height+i;return A.y+A.height/2}const _=T.children.map(L);const z=(_[0]+_.at(-1))/2;A.y=z-A.height/2;return z};R.forEach(L);return{min:n,max:Math.max(n,P-i)}};const x=S(a,"left");const k=S(l,"right");const w=Math.max(o.height,x.max-x.min,k.max-k.min);o.y=n+Math.max(0,(w-o.height)/2);const C=(R,M)=>{if(R.length===0)return;const P=M.max-M.min;const E=n+(w-P)/2-M.min;const v=L=>{t.get(L.id).y+=E;L.children.forEach(v)};R.forEach(v)};C(a,x);C(l,k);uO(t,n);return fO(e,t,n)}function g9(e){const t=new Map;for(const n of e.values())t.set(n.depth,Math.max(t.get(n.depth)??0,n.width));return t}function uO(e,t){const n=Math.min(...Array.from(e.values(),i=>i.y));if(n<t)for(const i of e.values())i.y+=t-n}function fO(e,t,n){const i=Array.from(t.values()).flatMap(a=>{if(!a.parentId)return[];const l=t.get(a.parentId);const c=a.side==="left";const d={x:n1(l,c?"left":"right"),y:l.y+l.height/2};const u={x:n1(a,c?"right":"left"),y:a.y+a.height/2};const f=Math.abs(u.x-d.x)*.42;const h={x:d.x+(c?-f:f),y:d.y};const m={x:u.x+(c?f:-f),y:u.y};return[{from:l.id,to:a.id,points:[d,h,m,u],d:`M ${In(d.x)} ${In(d.y)} C ${In(h.x)} ${In(h.y)} ${In(m.x)} ${In(m.y)} ${In(u.x)} ${In(u.y)}`}]});const r=Math.min(...Array.from(t.values(),a=>a.x));if(r<n){const a=n-r;for(const l of t.values())l.x+=a;for(const l of i){l.points.forEach(h=>{h.x+=a});const[c,d,u,f]=l.points;l.d=`M ${In(c.x)} ${In(c.y)} C ${In(d.x)} ${In(d.y)} ${In(u.x)} ${In(u.y)} ${In(f.x)} ${In(f.y)}`}}const o=Math.max(...Array.from(t.values(),a=>a.x+a.width))+n;const s=Math.max(...Array.from(t.values(),a=>a.y+a.height))+n;return{width:o,height:s,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,nodes:[...t.values()],edges:i}}function hO(e,t,n,i={}){const r=tn(t,n);if(!r)return e;const o=Xh(i.padding,32);const s=r.height;const a=e.nodes.map(d=>({...d,y:d.y+s}));const l=e.edges.map(d=>{const u=d.points.map(g=>({x:g.x,y:g.y+s}));const[f,h,m,p]=u;return{...d,points:u,d:`M ${In(f.x)} ${In(f.y)} C ${In(h.x)} ${In(h.y)} ${In(m.x)} ${In(m.y)} ${In(p.x)} ${In(p.y)}`}});const c=Math.max(e.width,r.width+2*o);return{...e,width:c,height:e.height+s,nodes:a,edges:l,title:rn(r,c,o)}}function Xh(e,t){return typeof e==="number"&&Number.isFinite(e)&&e>=0?e:t}function In(e){return Math.round(e*1e3)/1e3}function i1(e,t){const n={layout:t==="tidy-tree"?"tidy-tree":"radial"};if(!e||typeof e!=="object"||Array.isArray(e))return n;const i=e;if(typeof i.padding==="number"&&Number.isFinite(i.padding)&&i.padding>=0)n.padding=i.padding;if(typeof i.maxNodeWidth==="number"&&Number.isFinite(i.maxNodeWidth)&&i.maxNodeWidth>0)n.maxNodeWidth=i.maxNodeWidth;return n}function mO(e,t,n={groupLetterSpacing:0}){return hO(dO(e,{...t,textStyle:n}),e.title,n,t)}var y9=13;function x9(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l="mindmap-title";const c="mindmap-desc";const d=Mi(n.accessibilityTitle??n.nodes[0]?.label,n.accessibilityDescription,l,c,"mindmap");const u=[Ot(n.width,n.height,i,a,{attrs:d}),Dt(s,false,i.shadow,i.embedFontImport)];const f=Zt(i);if(f)u.push(`<defs>${f}</defs>`);const h=w9(n);const m=new Set(h.values()).size;const p=Nn(i.accent??"")?i.accent:"#3b82f6";const g=Nn(i.bg)?i.bg:"#ffffff";const y=Ji(m,m<=6?{accent:p,bg:g}:{accent:i.accent??p,bg:i.bg});const b=k=>{const w=h.get(k)??0;return y[w]??p};const S=[e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},u.join("\n"))];const x=n.accessibilityTitle??n.nodes[0]?.label;if(x)S.push(e.documentText({id:"acc-title",element:"title",domId:l,text:x}));if(n.accessibilityDescription)S.push(e.documentText({id:"acc-desc",element:"description",domId:c,text:n.accessibilityDescription}));if(n.title)S.push(e.text(En(n.title,Xe(o,void 0,r.styleFace))));for(const k of n.edges){const w=b(k.to);const[C,R,M,P]=k.points;if(!C||!R||!M||!P){throw new Error(`Mindmap edge "${k.from}" -> "${k.to}" requires four cubic control points`)}const E=Ac(k.d,C,[{kind:"cubic",control1:R,control2:M,end:P}]);S.push(e.connector({id:sm(k.from,k.to),role:"edge",geometry:E.geometry,lineStyle:"solid",paint:{fill:"none",stroke:w,strokeWidth:"2.5"},endpoints:{from:k.from,to:k.to},relationship:{kind:"mindmap-branch",direction:"forward"},route:{ownership:"layout",contours:E.contours},stroke:{lineCap:"round"},channels:{importance:1,category:String(h.get(k.to)??0)},attributes:{className:"mindmap-edge",data:{"branch-index":String(h.get(k.to)??0)}}}))}for(const k of n.nodes)S.push(b9(e,k,i,h.get(k.id),b(k.id)));S.push(e.documentClose());return{family:"mindmap",width:n.width,height:n.height,colors:i,transparent:a,parts:S}}function b9(e,t,n,i,r){const o=Nn(n.bg)&&Nn(n.fg)&&(n.accent===void 0||Nn(n.accent));const s=o?bl(n).arrow:"var(--_arrow)";const a=o?Zi(r,n.bg,t.depth===1?30:t.depth===2?20:13):"var(--_node-fill)";const l=t.depth===0?s:a;const c=t.depth===0?s:r;const d=t.depth===0?o?pu(n.bg,s,4.5,n.fg):"var(--bg)":o?pu(n.fg,a,4.5):"var(--_text)";const u=S9(t);const f=[{node:e.shape({id:xn(t.id,"shape"),role:"chrome",geometry:u,paint:{fill:l,stroke:c,strokeWidth:"1.5"}}),indent:2}];if(t.icon){const b=ol(t.icon);if(b){const S=14;const x=t.x+t.width/2-S/2;const k=t.y+4;const w=S/24;f.push({node:e.pathArtwork({id:xn(t.id,"icon"),paths:b.paths,owner:{id:t.id,role:"node"},open:`<g class="mindmap-icon-glyph" data-icon="${Ye(t.icon)}" data-icon-source="${Ye(b.source)}" transform="translate(${jn(x)} ${jn(k)}) scale(${jn(w)})">`,transform:{kind:"matrix",a:jn(w),b:0,c:0,d:jn(w),e:jn(x),f:jn(k)},paint:{fill:d,stroke:d,strokeWidth:"0.8"}}),indent:2})}else{const S=rl(t.icon);f.push({node:e.text({id:xn(t.id,"icon"),role:"icon",owner:{id:t.id,role:"node"},text:S,block:t.iconFallbackBlock,x:jn(t.x+t.width/2),y:jn(t.y+12),fontSize:9,anchor:"middle",paint:{fill:d},baselineShift:0,attributes:{className:"mindmap-icon-fallback",data:{icon:t.icon}}}),indent:2})}}const h=t.y+t.height/2+(t.icon?5:0);const m=t.labelBlock?.fontSize??y9;const p=t.labelBlock?.fontWeight??500;const g=t.labelBlock?.letterSpacing??0;f.push({node:e.text({id:xn(t.id,"label"),role:"label",text:t.label,block:t.labelBlock,x:t.x+t.width/2,y:h,fontSize:m,fontWeight:p,letterSpacing:g,anchor:"middle",paint:{fill:d}}),indent:2});const y=t.className?` ${Ye(t.className)}`:"";return e.group({id:t.id,role:"node",channels:{importance:Math.max(1,5-t.depth),...i===void 0?{}:{category:String(i)}},open:`<g class="mindmap-node depth-${t.depth}${y}" data-id="${Ye(t.id)}" data-label="${hn(t.label)}"${i===void 0?"":` data-branch-index="${i}"`}${t.parentId?` data-parent-id="${Ye(t.parentId)}"`:""}>`,close:"</g>",children:f})}function S9(e){const{x:t,y:n,width:i,height:r}=e;const o=(s,a)=>({x:jn(s),y:jn(a)});if(e.shape==="circle")return{kind:"circle",cx:jn(t+i/2),cy:jn(n+r/2),r:jn(Math.min(i,r)/2)};if(e.shape==="cloud")return{kind:"ellipse",cx:jn(t+i/2),cy:jn(n+r/2),rx:jn(i/2),ry:jn(r/2)};if(e.shape==="hexagon")return{kind:"polygon",points:[o(t+12,n),o(t+i-12,n),o(t+i,n+r/2),o(t+i-12,n+r),o(t+12,n+r),o(t,n+r/2)]};if(e.shape==="bang"){const s=[];for(let a=0;a<12;a++){const l=-Math.PI/2+a*Math.PI/6;const c=a%2===0?i/2:i*t1;const d=a%2===0?r/2:r*.38;s.push(o(t+i/2+Math.cos(l)*c,n+r/2+Math.sin(l)*d))}return{kind:"polygon",points:s}}return{kind:"rect",x:jn(t),y:jn(n),width:jn(i),height:jn(r),rx:e.shape==="rect"?0:e.shape==="rounded"?10:16,ry:e.shape==="rect"?0:e.shape==="rounded"?10:16}}function w9(e){const t=new Map;const n=e.nodes.find(r=>r.depth===0);if(!n)return t;let i=0;for(const r of[...e.nodes].sort((o,s)=>o.depth-s.depth)){if(r.depth===0)continue;if(r.parentId===n.id)t.set(r.id,i++);else if(r.parentId&&t.has(r.parentId))t.set(r.id,t.get(r.parentId))}return t}function jn(e){return Math.round(e*1e3)/1e3}var pO=gt(x9);var w2e={configDiagnostics:cO,statementEnds:Om,normalizeRequest:e=>({familyConfig:{position:i1(e.source.config.mindmap,e.source.config.layout)}}),layout:e=>mt(mO(Tn(qr(jP(e.source.authoredFamilyBody??e.source.familyBody),e.source.accessibility),e.source.frontmatter),e.familyConfig?.position??i1(void 0,void 0),Xe(e.renderOptions,void 0,e.styleFace)),{injectAccessibility:false}),projectPositioned:ft(FI),lowerScene:ht(pO)};var M9={textPosition:wn(0,1),donutHole:wn(0,.9),legendPosition:Ws("top","bottom","left","right","center")};var gO=e=>bt("pie",e,M9);function k9(e){return(Math.round(e*100)/100).toString()}function Ec(e,t,n,i,r){if(!n)throw new TypeError(`Missing retained tooltip layout for ${i}`);const{block:o,bgW:s,bgX:a,bgY:l,textX:c,textY:d,ptrPath:u}=n;const f=h=>Number(k9(h));return e.group({id:i,role:"chrome",owner:r,visibility:"conditional",open:`<g class="${t}-tip">`,close:"</g>",join:"",children:[{indent:0,node:e.shape({id:`${i}:background`,role:"chrome",owner:r,geometry:{kind:"rect",x:f(a),y:f(l),width:f(s),height:$i.height,rx:$i.rx},paint:{fill:"var(--_text)"},attributes:{className:`${t}-tip ${t}-tip-bg`}})},{indent:0,node:e.shape({id:`${i}:pointer`,role:"chrome",owner:r,geometry:{kind:"path",d:u},paint:{fill:"var(--_text)"},attributes:{className:`${t}-tip ${t}-tip-ptr`}})},{indent:0,node:e.text({id:`${i}:text`,role:"label",owner:r,text:o.text,block:o,x:f(c),y:f(d),fontSize:$i.fontSize,fontWeight:$i.fontWeight,anchor:"middle",paint:{fill:"var(--bg)"},attributes:{className:`${t}-tip ${t}-tip-text`}})}]})}function fu(e,t){const n=t.map(i=>`.${i}:hover .${e}-tip`).join(",\n ");return`
|
|
34
|
-
.${e}-tip { opacity: 0; pointer-events: none; }
|
|
35
|
-
.${e}-tip-bg { fill: var(--_text); }
|
|
36
|
-
.${e}-tip-text { fill: var(--bg); font-size: ${$i.fontSize}px; font-weight: ${$i.fontWeight}; }
|
|
37
|
-
.${e}-tip-ptr { fill: var(--_text); }
|
|
38
|
-
${n} { opacity: 1; }`}var r1={titleFontSize:18,titleFontWeight:600,legendFontSize:13,legendFontWeight:500,sliceStrokeWidth:1.5,dimOpacity:.4};var C9=e=>/[<>*~]/.test(e);function P9(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=o.interactive??false;const c=Xe(o,eM,r.styleFace);const d=st(r.styleFace,"pie-slice",{},{includeFallback:false});const u=n.visual;const f=[];const h=Qd(n.slices.length,{accent:i.accent,bg:i.bg,overrides:u.paletteOverrides});const m=u.highlightSlice==="hover";const p=!m&&n.slices.some(C=>u.highlightSlice===C.label);const g=[];g.push(R9(n,i,a));g.push(Dt(s,false,i.shadow,i.embedFontImport));const y=Zt(i);if(y)g.push(`<defs>${y}</defs>`);const b=v9(c,u,l,d);g.push(b);f.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false,extraCss:b},g.join("\n")));if(u.outerStrokeWidth!==void 0||u.outerStrokeColor!==void 0){const C=u.outerStrokeWidth??2;const R=xO(n.radius+C/2);f.push(e.shape({id:"outer-circle",role:"chrome",geometry:{kind:"circle",cx:n.cx,cy:n.cy,r:R},paint:{fill:"none",stroke:E9(u,c),strokeWidth:String(C)},attributes:{className:"pie-outer-circle"}}))}const S=new Map;const x=[];const k=(C,R)=>{const M=`${C}:${R}`;const P=S.get(M)??0;S.set(M,P+1);return P===0?M:`${M}#${P}`};const w=o1(u.strokeWidth??d?.lineWidth??c.nodeLineWidth);for(let C=0;C<n.slices.length;C++){const R=n.slices[C];const M=dc(R.fraction);const P={category:R.label,value:R.fraction};const E=st(r.styleFace,"pie-slice",P,{includeFallback:false});const v=u.paletteOverrides[C]??E?.fillColor??h[C];h[C]=v;const L=u.strokeColor??E?.strokeColor??E?.borderColor??c.nodeBorderColor??"var(--bg)";const T=u.strokeWidth??E?.lineWidth??c.nodeLineWidth;const A=E?.cue??"none";const $=A==="outline"?T+1:A==="double-line"?T+2:T;const _=A==="pattern"?"3 2":A==="double-line"?"8 2 2 2":void 0;const z=o1($);const F=p&&u.highlightSlice===R.label;const G=p&&!F;const I=`pie-slice${F?" highlighted":""}${m?" highlighted-on-hover":""}${G?" pie-dim":""}`;const D=F?1:G?xO((u.opacity??1)*r1.dimOpacity):u.opacity;const B=k("slice",R.label);x[C]=B;f.push(e.shape({id:B,role:"pie-slice",geometry:{kind:"path",d:R.path},paint:{fill:v,stroke:F?"var(--fg)":L,strokeWidth:String(F?z:$),..._?{strokeDasharray:_}:{},...D!==void 0?{opacity:String(D)}:{}},channels:{...P,...F?{emphasis:true}:{}},attributes:{className:I,data:{label:R.label,value:String(R.value),percent:M,...A!=="none"?{"brand-cue":A}:{},...F?{highlighted:"true"}:{}}}}))}for(let C=0;C<n.slices.length;C++){const R=n.slices[C];const M=R.pctLabel;if(!M)continue;const P=p&&u.highlightSlice!==R.label;const E=p&&!P?1:P?(u.opacity??1)*r1.dimOpacity:u.opacity??1;const v=T9(h[C],E,i);const L=c.nodeTextColor??i.fg;const T=u.sectionTextColor??(v===void 0?P?L:Ho(h[C])??L:P?ms(_n(L,i)??L,v):Ho(v)??L);f.push(e.text({id:k("slice-label",R.label),role:"label",text:M.text,x:M.x,y:M.y,fontSize:M.fontSize,fontWeight:_I,block:M.block,anchor:"middle",dominantBaseline:"middle",paint:{fill:T},channels:{category:R.label,value:R.fraction},attributes:{className:"pie-slice-label"}}))}for(let C=0;C<n.legend.length;C++){const R=n.legend[C];const M=h[C];const P=p&&u.highlightSlice===R.label;const E=p&&!P;const v=P?fh:c.nodeLabelFontWeight;f.push(e.shape({id:k("legend",R.label),role:"legend",geometry:{kind:"rect",x:R.x,y:R.y,width:R.swatchSize,height:R.swatchSize,rx:2,ry:2},paint:{fill:M,stroke:c.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(c.nodeBorderColor?Math.max(1,c.nodeLineWidth):1),...E?{opacity:String(r1.dimOpacity)}:{}},channels:{category:R.label,value:R.fraction},attributes:{className:`pie-legend-swatch${E?" pie-dim":""}`}}));const L=R.lines.join("\n");f.push(e.text({id:k("legend-label",R.label),role:"legend",text:L,x:R.textX,y:R.textY,fontSize:u.legendTextSize??c.nodeLabelFontSize,fontWeight:v,letterSpacing:c.nodeLetterSpacing,block:R.block,...R.literalText===true?{display:"literal"}:{},anchor:"start",dominantBaseline:"middle",paint:{fill:u.legendTextColor??c.nodeTextColor??"var(--_text)"},channels:{category:R.label,value:R.fraction},attributes:{className:"pie-legend-text",...yO(R.literalText===true,L)}}))}if(n.title){const C=n.title.text;f.push(e.text({id:"title",role:"title",text:C,x:n.title.x,y:n.title.y,fontSize:u.titleTextSize??c.groupHeaderFontSize,fontWeight:c.groupHeaderFontWeight,letterSpacing:c.groupLetterSpacing,block:n.title.block,...n.title.literalText===true?{display:"literal"}:{},anchor:"middle",dominantBaseline:"middle",paint:{fill:u.titleTextColor??c.groupTextColor??c.nodeTextColor??"var(--_text)"},attributes:{className:"pie-title",...yO(n.title.literalText===true,C)}}))}if(l||m){for(const[C,R]of n.slices.entries()){const M=`${(R.displayLabel??R.label).replace(/\n/g," ")}: ${gy(R.value)} (${dc(R.fraction)})`;const P=k("tooltip:slice",R.label);const E={id:x[C],role:"pie-slice"};f.push(e.group({id:P,role:"chrome",owner:E,open:'<g class="pie-slice-group">',close:"</g>",join:"",children:[{indent:0,node:e.shape({id:`${P}:hit`,role:"chrome",owner:E,...m?{visibility:"conditional",conditionalPaint:{fill:"transparent",stroke:"var(--fg)",strokeWidth:String(w)}}:{},geometry:{kind:"path",d:R.path},paint:{fill:"transparent",...m?{stroke:"transparent",strokeWidth:String(w)}:{}},...m?{attributes:{className:"pie-slice-hover-target"}}:{}})},...l?[{indent:0,node:e.documentContent({id:`${P}:title`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${It(M)}</title>`)},{indent:0,node:Ec(e,"pie",R.tooltip,`${P}:body`,E)}]:[]]}))}}f.push(e.documentClose());return{family:"pie",width:n.width,height:n.height,colors:i,transparent:a,parts:f}}function E9(e,t){return e.outerStrokeColor??t.nodeBorderColor??"var(--_node-stroke)"}function R9(e,t,n){return Ot(e.width,e.height,t,n,{attrs:{role:"img","aria-roledescription":"pie chart"}})}function v9(e,t,n,i){const r=t.strokeWidth??i?.lineWidth??e.nodeLineWidth;const o=o1(r);const s=n?fu("pie",["pie-slice-group"]):"";const a=t.highlightSlice==="hover"?",\n .pie-slice-group:hover > .pie-slice-hover-target":"";return`<style>
|
|
39
|
-
.pie-slice.highlighted-on-hover:hover${a} { stroke: var(--fg); stroke-width: ${o}; opacity: 1; }${s}
|
|
40
|
-
</style>`}function o1(e){return Math.max(e+1,2.5)}function yO(e,t){return e&&C9(t)?{data:{"literal-text":"true"}}:{}}function xO(e){return Math.round(e*100)/100}function T9(e,t,n){const i=_n("var(--bg)",n);if(i===void 0||!Nn(e))return void 0;return t>=1?e:Zi(e,i,t*100)}var bO=gt(P9);var Z2e={configDiagnostics:gO,statementEnds:S0,normalizeRequest:e=>({familyConfig:{visual:Z0(e.source.frontmatter)}}),layout:e=>mt(DI(Tn(X2(XL(e.source)),e.source.frontmatter),e.renderOptions,e.familyConfig?.visual??Z0(),e.styleFace)),projectPositioned:ft(OI),lowerScene:ht(bO)};var L9=Object.fromEntries([...["chartWidth","chartHeight","titleFontSize","quadrantLabelFontSize","xAxisLabelFontSize","yAxisLabelFontSize","pointLabelFontSize","pointRadius"].map(e=>[e,Kt]),...["titlePadding","quadrantPadding","xAxisLabelPadding","yAxisLabelPadding","pointTextPadding","quadrantInternalBorderStrokeWidth","quadrantExternalBorderStrokeWidth"].map(e=>[e,jt]),["useMaxWidth",ct]]);var SO=e=>bt("quadrant",e,L9);var A9=["chartWidth","chartHeight","titleFontSize","quadrantLabelFontSize","xAxisLabelFontSize","yAxisLabelFontSize","pointLabelFontSize","pointRadius"];var I9=["titlePadding","quadrantPadding","xAxisLabelPadding","yAxisLabelPadding","pointTextPadding","quadrantInternalBorderStrokeWidth","quadrantExternalBorderStrokeWidth"];function s1(e={}){const t=Sn(e,["quadrantChart"])??{};const n={};for(const r of A9){const o=kt(t,[r]);if(typeof o==="number"&&Number.isFinite(o)&&o>0)n[r]=o}for(const r of I9){const o=kt(t,[r]);if(typeof o==="number"&&Number.isFinite(o)&&o>=0)n[r]=o}const i=kt(t,["useMaxWidth"]);if(typeof i==="boolean")n.useMaxWidth=i;return n}var _i={paddingX:24,paddingY:24,titleFontSize:18,titleGap:18,plotSize:380,axisFontSize:13,axisLabelPadding:4,quadrantFontSize:15,pointRadius:6,pointFontSize:12,pointTextPadding:4};function l1(e={}){return{nodeLabelFontSize:e.pointLabelFontSize??_i.pointFontSize,edgeLabelFontSize:e.xAxisLabelFontSize??_i.axisFontSize,groupHeaderFontSize:e.quadrantLabelFontSize??_i.quadrantFontSize,nodeLabelFontWeight:500,edgeLabelFontWeight:500,groupHeaderFontWeight:600,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:et.innerBox,edgeLineWidth:1,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:2}}function qt(e){return Math.round(e*100)/100}function Tx(e,t,n,i,r,o){return _e(e,{display:"formatted",transform:o,maxWidth:t,fontSize:n,fontWeight:i,letterSpacing:r})}function F9(e){if(e<=8)return _i.plotSize;return Math.min(720,_i.plotSize+(e-8)*20)}var Vh=class{cells=new Map;values=[];wide=[];visited=[];query=0;cellsOf(t){const n=Math.floor(t.x0/64),i=Math.floor(t.x1/64);const r=Math.floor(t.y0/64),o=Math.floor(t.y1/64);if(![n,i,r,o].every(Number.isSafeInteger)||i<n||o<r||(i-n+1)*(o-r+1)>256)return void 0;return[n,i,r,o]}add(t,n){const i=this.values.length;this.values.push(n);const r=this.cellsOf(t);if(!r){this.wide.push(i);return}const[o,s,a,l]=r;for(let c=a;c<=l;c++)for(let d=o;d<=s;d++){const u=`${d},${c}`,f=this.cells.get(u);if(f)f.push(i);else this.cells.set(u,[i])}}some(t,n){const i=this.cellsOf(t);if(!i)return this.values.some(n);const r=++this.query;const o=d=>{if(this.visited[d]===r)return false;this.visited[d]=r;return n(this.values[d])};for(const d of this.wide)if(o(d))return true;const[s,a,l,c]=i;for(let d=l;d<=c;d++)for(let u=s;u<=a;u++){for(const f of this.cells.get(`${u},${d}`)??[])if(o(f))return true}return false}};var Lx=(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;var N9=[0,Math.PI,-Math.PI/2,Math.PI/2,-Math.PI/4,Math.PI/4,-3*Math.PI/4,3*Math.PI/4,-Math.PI/8,Math.PI/8,-3*Math.PI/8,3*Math.PI/8,-5*Math.PI/8,5*Math.PI/8,-7*Math.PI/8,7*Math.PI/8];var $9=10;var _9=N9.map(e=>{const t=Math.cos(e);return{cos:t,sin:Math.sin(e),anchor:t>.38?"start":t<-.38?"end":"middle"}});function*D9(e,t,n,i,r){yield{x:e+n,y:t,anchor:"start",far:false,box:{x0:e+n,y0:t-r/2,x1:e+n+i,y1:t+r/2}};yield{x:e-n,y:t,anchor:"end",far:false,box:{x0:e-n-i,y0:t-r/2,x1:e-n,y1:t+r/2}};yield{x:e,y:t+n+r/2,anchor:"middle",far:false,box:{x0:e-i/2,y0:t+n,x1:e+i/2,y1:t+n+r}};yield{x:e,y:t-n-r/2,anchor:"middle",far:false,box:{x0:e-i/2,y0:t-n-r,x1:e+i/2,y1:t-n}};for(let o=1;o<=$9;o++){const s=n+o*(r+6);for(const{cos:a,sin:l,anchor:c}of _9){const d=e+a*s;const u=t+l*s;const f=c==="start"?d:c==="end"?d-i:d-i/2;yield{x:d,y:u,anchor:c,far:true,box:{x0:f,y0:u-r/2,x1:f+i,y1:u+r/2}}}}}function wO(e,t,n,i){const r=i.x-e;const o=i.y-t;const s=Math.hypot(r,o)||1;const a=r/s;const l=o/s;const c=i.anchor==="start"?i.box.x0-2:i.anchor==="end"?i.box.x1+2:i.x;const d=i.anchor==="middle"?i.y>t?i.box.y0-1:i.box.y1+1:i.y;return{x1:qt(e+a*n),y1:qt(t+l*n),x2:qt(c),y2:qt(d)}}function Uh(e,t,n,i,r,o){return(n-e)*(o-t)-(i-t)*(r-e)}function Ax(e,t,n){const i=n.x2-n.x1,r=n.y2-n.y1;const o=i*i+r*r;const s=o===0?0:Math.max(0,Math.min(1,((e-n.x1)*i+(t-n.y1)*r)/o));return Math.hypot(e-(n.x1+s*i),t-(n.y1+s*r))}function a1(e,t){if(Math.hypot(e.x1-t.x1,e.y1-t.y1)<=.5)return false;const n=.01;const i=(l,c,d)=>Math.abs(Uh(l.x1,l.y1,l.x2,l.y2,c,d))<=n&&c>=Math.min(l.x1,l.x2)-n&&c<=Math.max(l.x1,l.x2)+n&&d>=Math.min(l.y1,l.y2)-n&&d<=Math.max(l.y1,l.y2)+n;const r=Uh(e.x1,e.y1,e.x2,e.y2,t.x1,t.y1);const o=Uh(e.x1,e.y1,e.x2,e.y2,t.x2,t.y2);const s=Uh(t.x1,t.y1,t.x2,t.y2,e.x1,e.y1);const a=Uh(t.x1,t.y1,t.x2,t.y2,e.x2,e.y2);if(r*o<-n&&s*a<-n||i(e,t.x1,t.y1)||i(e,t.x2,t.y2)||i(t,e.x1,e.y1)||i(t,e.x2,e.y2))return true;return Math.min(Ax(e.x1,e.y1,t),Ax(e.x2,e.y2,t),Ax(t.x1,t.y1,e),Ax(t.x2,t.y2,e))<3}function MO(e,t){const n={x0:t.x0-2,y0:t.y0-2,x1:t.x1+2,y1:t.y1+2};if(Math.max(e.x1,e.x2)<n.x0||Math.min(e.x1,e.x2)>n.x1||Math.max(e.y1,e.y2)<n.y0||Math.min(e.y1,e.y2)>n.y1)return false;const i=(o,s)=>o>=n.x0&&o<=n.x1&&s>=n.y0&&s<=n.y1;if(i(e.x1,e.y1)||i(e.x2,e.y2))return true;const r=[{x1:n.x0,y1:n.y0,x2:n.x1,y2:n.y0},{x1:n.x1,y1:n.y0,x2:n.x1,y2:n.y1},{x1:n.x1,y1:n.y1,x2:n.x0,y2:n.y1},{x1:n.x0,y1:n.y1,x2:n.x0,y2:n.y0}];return r.some(o=>a1(e,o))}function kO(e,t={},n={},i){const r=Xe(t,l1(n),i);const o=n.quadrantPadding??_i.paddingX;const s=n.quadrantPadding??_i.paddingY;const a=n.titleFontSize??_i.titleFontSize;const l=n.titlePadding??_i.titleGap;const c=Math.max(r.groupHeaderFontWeight,600);let d=e.title?_e(e.title,{display:"formatted",transform:r.groupTextTransform,fontSize:a,fontWeight:c,letterSpacing:r.groupLetterSpacing}):void 0;let u=d?.text;let f=e.title?a+l:0;const h=n.xAxisLabelFontSize??r.edgeLabelFontSize;const m=n.yAxisLabelFontSize??r.edgeLabelFontSize;const p=n.xAxisLabelPadding??_i.axisLabelPadding;const g=n.yAxisLabelPadding??_i.axisLabelPadding;const y=h+p*2+7;const b=m+g*2+7;let S=y;let x=b;let k=F9(e.points.length);let w;let C;for(let X=0;X<2;X++){if(n.chartWidth!==void 0||n.chartHeight!==void 0){const U=o*2+x;const te=s*2+f+S;const J=n.chartWidth!==void 0?n.chartWidth-U:Number.POSITIVE_INFINITY;const ae=n.chartHeight!==void 0?n.chartHeight-te:Number.POSITIVE_INFINITY;k=Math.max(60,Math.min(J,ae))}const V=Math.max(24,k/2-12);w=e.xAxis?{near:Tx(e.xAxis.near,V,h,r.edgeLabelFontWeight,r.edgeLetterSpacing,r.edgeTextTransform),...e.xAxis.far?{far:Tx(e.xAxis.far,V,h,r.edgeLabelFontWeight,r.edgeLetterSpacing,r.edgeTextTransform)}:{}}:void 0;C=e.yAxis?{near:Tx(e.yAxis.near,V,m,r.edgeLabelFontWeight,r.edgeLetterSpacing,r.edgeTextTransform),...e.yAxis.far?{far:Tx(e.yAxis.far,V,m,r.edgeLabelFontWeight,r.edgeLetterSpacing,r.edgeTextTransform)}:{}}:void 0;if(e.title){d=_e(e.title,{display:"formatted",transform:r.groupTextTransform,fontSize:a,fontWeight:c,letterSpacing:r.groupLetterSpacing,maxWidth:k});u=d.text;f=d.height-(d.lineHeight-d.fontSize)+l}const ee=Math.max(h*fi,...[w?.near,w?.far].map(U=>U?.height??0));const re=Math.max(m*fi,...[C?.near,C?.far].map(U=>U?.height??0));S=y+ee-h*fi;x=b+re-m*fi}const R=o+x;const M=s+f;const P=k/2;const E=R+k+o;const v=M+k+S+s;const L=[{number:2,col:0,row:0},{number:1,col:1,row:0},{number:3,col:0,row:1},{number:4,col:1,row:1}];const T=L.map(({number:X,col:V,row:ee})=>{const re=R+V*P;const U=M+ee*P;return{number:X,label:e.quadrants[X-1],labelBlock:e.quadrants[X-1]===void 0?void 0:_e(e.quadrants[X-1],{display:"formatted",transform:r.groupTextTransform,fontSize:r.groupHeaderFontSize,fontWeight:r.groupHeaderFontWeight,letterSpacing:r.groupLetterSpacing}),x:qt(re),y:qt(U),width:qt(P),height:qt(P),labelX:qt(re+P/2),labelY:qt(U+P/2)}});const A=r.nodeLabelFontSize;const $=r.nodeLabelFontWeight;const _=n.pointTextPadding??_i.pointTextPadding;const z=T.filter(X=>X.label).map(X=>{const V=X.labelBlock.width;return{x0:X.labelX-V/2,y0:X.labelY-X.labelBlock.height/2,x1:X.labelX+V/2,y1:X.labelY+X.labelBlock.height/2}});const F=n.pointRadius??_i.pointRadius;const G=e.points.map(X=>KL(X,e.classDefs,{radius:F}));const I=e.points.map((X,V)=>{const ee=R+X.x*k,re=M+(1-X.y)*k,U=G[V].radius+1;return{x0:ee-U,y0:re-U,x1:ee+U,y1:re+U}});const D={x0:2,y0:2,x1:E-2,y1:v-2};const B=[];const Y=e.points.length>=128;const W=Y?new Vh:void 0;const O=Y?new Vh:void 0;const N=Y?new Vh:void 0;if(W&&O){for(const X of z)W.add(X,X);for(const X of I)O.add(X,X)}const H=e.points.map((X,V)=>{const ee=G[V];const re=qt(R+X.x*k);const U=qt(M+(1-X.y)*k);const te=_e(X.label,{display:"formatted",transform:r.nodeTextTransform,fontSize:A,fontWeight:$,letterSpacing:r.nodeLetterSpacing});const J=te.text;const ae=te.width;const Q=te.height;const K=ee.radius+_;const Z=xe=>{const Me=xe.box;if(!(Me.x0>=D.x0&&Me.y0>=D.y0&&Me.x1<=D.x1&&Me.y1<=D.y1)||(W?W.some(Me,De=>Lx(Me,De)):z.some(De=>Lx(Me,De)))||(O?O.some(Me,De=>Lx(Me,De)):I.some(De=>Lx(Me,De))))return false;if(!xe.far)return true;const Ce=wO(re,U,ee.radius,xe);if(!W||!N)return!z.some(De=>MO(Ce,De))&&!B.some(De=>a1(Ce,De));const pe={x0:Math.min(Ce.x1,Ce.x2),y0:Math.min(Ce.y1,Ce.y2),x1:Math.max(Ce.x1,Ce.x2),y1:Math.max(Ce.y1,Ce.y2)};const Te={x0:pe.x0-2,y0:pe.y0-2,x1:pe.x1+2,y1:pe.y1+2};const Fe={x0:pe.x0-3,y0:pe.y0-3,x1:pe.x1+3,y1:pe.y1+3};return!W.some(Te,De=>MO(Ce,De))&&!N.some(Fe,De=>a1(Ce,De))};let se;let oe;for(const xe of D9(re,U,K,ae,Q)){se??=xe;if(Z(xe)){oe=xe;break}}const de={label:J,labelBlock:te,nx:X.x,ny:X.y,cx:re,cy:U,radius:ee.radius,labelX:qt((oe??se).x),labelY:qt((oe??se).y),labelAnchor:(oe??se).anchor};de.tooltip=Ua(re,U-ee.radius,`${J}: [${X.x}, ${X.y}]`);if(ee.fill!==void 0)de.fill=ee.fill;if(ee.stroke!==void 0)de.stroke=ee.stroke;if(ee.strokeWidth!==void 0)de.strokeWidth=ee.strokeWidth;if(X.className!==void 0)de.className=X.className;if(oe){z.push(oe.box);W?.add(oe.box,oe.box);const xe={x0:qt(oe.box.x0),y0:qt(oe.box.y0),x1:qt(oe.box.x1),y1:qt(oe.box.y1)};de.labelBox=xe;if(oe.far){de.leader=wO(re,U,ee.radius,oe);B.push(de.leader);const Me=de.leader;N?.add({x0:Math.min(Me.x1,Me.x2),y0:Math.min(Me.y1,Me.y2),x1:Math.max(Me.x1,Me.x2),y1:Math.max(Me.y1,Me.y2)},Me)}}else{de.labelHidden=true}return de});const j=[];const q=X=>M+k+Math.max(h,X.lineHeight/2)+p;if(w){j.push({text:w.near.text,block:w.near,x:qt(R+4),y:qt(q(w.near)),anchor:"start",fontSize:h});if(w.far){j.push({text:w.far.text,block:w.far,x:qt(R+k-4),y:qt(q(w.far)),anchor:"end",fontSize:h})}}if(C){const X=V=>o+Math.max(m,V.lineHeight/2);j.push({text:C.near.text,block:C.near,x:qt(X(C.near)),y:qt(M+k-4),anchor:"start",fontSize:m});if(C.far){j.push({text:C.far.text,block:C.far,x:qt(X(C.far)),y:qt(M+4),anchor:"end",fontSize:m})}}return{width:qt(E),height:qt(v),title:u!==void 0?{text:u,block:d,x:qt(R+k/2),y:qt(s+(f-l)/2),fontSize:a}:void 0,accessibility:e.accessibility?{...e.accessibility}:void 0,plot:{x:qt(R),y:qt(M),size:qt(k)},regions:T,points:H,axisLabels:j,visual:n}}var uAe={titleFontSize:_i.titleFontSize,axisFontSize:_i.axisFontSize,quadrantFontSize:_i.quadrantFontSize,pointFontSize:_i.pointFontSize};function O9(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=o.interactive??false;const c=Xe(o,l1(n.visual),r.styleFace);const d=[];const u={title:n.accessibility?.title??n.title?.text,description:n.accessibility?.description};const f=`quadrant-${mi(n.width,n.height,u.title??"",u.description??"",...n.points.flatMap(E=>[E.label,E.nx,E.ny]))}`;const h=`${f}-title`;const m=`${f}-desc`;const p=G9(l);const g=[B9(n,i,a,u,f,h,m)];if(u.title)g.push(`<title id="${h}">${It(u.title)}</title>`);if(u.description)g.push(`<desc id="${m}">${It(u.description)}</desc>`);g.push(Dt(s,false,i.shadow,i.embedFontImport));const y=Zt(i);if(y)g.push(`<defs>${y}</defs>`);if(p)g.push(p);d.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false,...p?{extraCss:p}:{}},g.join("\n")));const{plot:b}=n;const S=b.size/2;const x=n.visual.quadrantInternalBorderStrokeWidth??c.lineWidth;const k=n.visual.quadrantExternalBorderStrokeWidth??c.groupLineWidth;for(const E of n.regions){const v=CO(E.number,c);d.push(e.shape({id:`plate:${E.number}`,role:"plate",geometry:{kind:"rect",x:E.x,y:E.y,width:E.width,height:E.height},paint:{fill:v,stroke:"none"},channels:E.label?{category:E.label}:void 0,attributes:{className:"quadrant-region",data:{quadrant:String(E.number)}}}))}const w=b.x+S;const C=b.y+S;const R={stroke:c.edgeStrokeColor??"var(--_line)",strokeWidth:String(x)};d.push(e.shape({id:"divider:v",role:"grid",geometry:{kind:"line",x1:w,y1:b.y,x2:w,y2:b.y+b.size},paint:R,attributes:{className:"quadrant-divider"}}));d.push(e.shape({id:"divider:h",role:"grid",geometry:{kind:"line",x1:b.x,y1:C,x2:b.x+b.size,y2:C},paint:R,attributes:{className:"quadrant-divider"}}));d.push(e.shape({id:"border",role:"chrome",geometry:{kind:"rect",x:b.x,y:b.y,width:b.size,height:b.size},paint:{fill:"none",stroke:c.groupBorderColor??c.nodeBorderColor??"var(--_node-stroke)",strokeWidth:String(k)},attributes:{className:"quadrant-border"}}));for(const E of n.regions){if(!E.label)continue;const v=E.labelBlock?.text??E.label;d.push(e.text({id:`quadrant-label:${E.number}`,role:"label",text:v,x:E.labelX,y:E.labelY,fontSize:c.groupHeaderFontSize,fontWeight:c.groupHeaderFontWeight,letterSpacing:c.groupLetterSpacing,block:E.labelBlock,anchor:"middle",dominantBaseline:"middle",paint:{fill:c.groupTextColor??"var(--_text-sec)"},channels:{category:E.label},attributes:{className:"quadrant-label"}}))}const M=[];const P=new Map;for(const E of n.points){const v=P.get(E.label)??0;P.set(E.label,v+1);const L=v===0?`point:${E.label}`:`point:${E.label}#${v}`;if(E.leader){const A=E.leader;d.push(e.shape({id:`leader:${E.label}`,role:"chrome",geometry:{kind:"line",x1:A.x1,y1:A.y1,x2:A.x2,y2:A.y2},paint:{stroke:c.edgeStrokeColor??"var(--_line)",strokeWidth:"1"},attributes:{className:"quadrant-leader"}}))}const T=E.className?`quadrant-point ${E.className}`:"quadrant-point";d.push(e.shape({id:L,role:"point",geometry:{kind:"circle",cx:E.cx,cy:E.cy,r:E.radius},paint:{fill:E.fill??c.nodeFillColor??"var(--accent, var(--_arrow))",stroke:E.stroke??c.nodeBorderColor??"var(--bg)",strokeWidth:E.strokeWidth??String(Math.max(1,c.nodeLineWidth))},attributes:{className:T,data:{label:E.label,x:String(E.nx),y:String(E.ny)}}}));if(!E.labelHidden){const A=z9(E,n,c);d.push(e.text({id:`${L}:label`,role:"label",text:E.label,x:E.labelX,y:E.labelY,fontSize:c.nodeLabelFontSize,fontWeight:c.nodeLabelFontWeight,letterSpacing:c.nodeLetterSpacing,block:E.labelBlock,anchor:E.labelAnchor,dominantBaseline:"middle",paint:{fill:c.nodeTextColor??"var(--_text)",stroke:A,strokeWidth:String(W9),strokeLinejoin:"round",paintOrder:"stroke"},attributes:{className:"quadrant-point-label"}}))}if(l){const A=`${E.label}: [${E.nx}, ${E.ny}]`;const $={id:L,role:"point"};M.push(e.group({id:`tooltip:${L}`,role:"chrome",owner:$,open:'<g class="quadrant-point-group">',close:"</g>",join:"",children:[{indent:0,node:e.shape({id:`${L}:hit`,role:"chrome",owner:$,geometry:{kind:"circle",cx:E.cx,cy:E.cy,r:E.radius+6},paint:{fill:"transparent"}})},{indent:0,node:e.documentContent({id:`${L}:title`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${It(A)}</title>`)},{indent:0,node:Ec(e,"quadrant",E.tooltip,`${L}:tooltip`,$)}]}))}}d.push(...M);for(const E of n.axisLabels){const v=E.text.split("\n");const L=v.join("\n");const T=E.x<b.x;const A=T?{kind:"rotate",angle:-90,cx:E.x,cy:E.y}:void 0;const $=E.block?.lineHeight??E.fontSize*1.3;const _=E.y+(v.length-1)*$/2-E.fontSize*.35;d.push(e.text({id:`axis:${E.text}`,role:"axis",text:L,x:E.x,y:_,fontSize:E.fontSize,fontWeight:c.edgeLabelFontWeight,letterSpacing:c.edgeLetterSpacing,block:E.block,anchor:E.anchor,paint:{fill:c.edgeTextColor??"var(--_text-muted)"},transform:A,attributes:{className:"quadrant-axis-label"}}))}if(n.title){const E=n.title.text;d.push(e.text({id:"title",role:"title",text:E,x:n.title.x,y:n.title.y,fontSize:n.title.fontSize,fontWeight:Math.max(c.groupHeaderFontWeight,600),letterSpacing:c.groupLetterSpacing,block:n.title.block,anchor:"middle",dominantBaseline:"middle",paint:{fill:c.groupTextColor??c.nodeTextColor??"var(--_text)"},attributes:{className:"quadrant-title"}}))}d.push(e.documentClose());return{family:"quadrant",width:n.width,height:n.height,colors:i,transparent:a,parts:d}}function B9(e,t,n,i,r,o,s){const a=e.visual.useMaxWidth?{width:"100%",height:"100%",style:`max-width:${e.width}px`}:{};return Ot(e.width,e.height,t,n,{...a,attrs:{id:r,...Mi(i.title,i.description,o,s,"quadrant chart")}})}var W9=3;function z9(e,t,n){const i=e.labelBox;const r=i?(i.x0+i.x1)/2:e.labelX;const o=i?(i.y0+i.y1)/2:e.labelY;const s=t.regions.find(a=>r>=a.x&&r<=a.x+a.width&&o>=a.y&&o<=a.y+a.height);return s?CO(s.number,n):"var(--bg)"}function CO(e,t){const n=e===1||e===3?10:5;if(t.groupFillColor){const i=e===1||e===3?88:76;return`color-mix(in srgb, ${t.groupFillColor} ${i}%, var(--bg))`}return`color-mix(in srgb, var(--accent, var(--_arrow)) ${n}%, var(--bg))`}function G9(e){return e?`<style>${fu("quadrant",["quadrant-point-group"])}
|
|
41
|
-
</style>`:void 0}var PO=gt(O9);var IAe={configDiagnostics:SO,statementEnds:vy,normalizeRequest:e=>({familyConfig:{visual:s1(e.source.frontmatter)}}),layout:e=>mt(kO(Tn(xm(YF(e.source.familyLines),e.source.accessibility),e.source.frontmatter),e.renderOptions,e.familyConfig?.visual??s1(),e.styleFace)),projectPositioned:ft(BI),lowerScene:ht(PO)};var EO=["axisColor","axisStrokeWidth","axisLabelFontSize","curveOpacity","curveStrokeWidth","graticuleColor","graticuleStrokeWidth","graticuleOpacity","legendBoxSize","legendFontSize"];var H9=["width","height","axisScaleFactor"];var Cn=Object.freeze({dimension:4096,margin:4096,factor:8,axisLabelFactorMin:1.1,fontSize:256,lineWidth:64,legendBoxSize:512});var j9=["marginTop","marginRight","marginBottom","marginLeft"];function c1(e={}){const t=Sn(e,["radar"])??{};const n={};for(const m of H9){const p=kt(t,[m]);const g=m==="width"||m==="height"?Cn.dimension:Cn.factor;if(typeof p==="number"&&Number.isFinite(p)&&p>0&&p<=g)n[m]=p}const i=kt(t,["axisLabelFactor"]);if(typeof i==="number"&&Number.isFinite(i)&&i>=Cn.axisLabelFactorMin&&i<=Cn.factor){n.axisLabelFactor=i}for(const m of j9){const p=kt(t,[m]);if(typeof p==="number"&&Number.isFinite(p)&&p>=0&&p<=Cn.margin)n[m]=p}const r=kt(t,["curveTension"]);if(typeof r==="number"&&Number.isFinite(r)&&r>=0&&r<=1){n.curveTension=r}const o=kt(t,["useMaxWidth"]);if(typeof o==="boolean")n.useMaxWidth=o;const s=kt(t,["tickLabels"]);if(typeof s==="boolean")n.tickLabels=s;const a=Sn(e,["themeVariables","radar"])??{};const l=["axisStrokeWidth","axisLabelFontSize","curveStrokeWidth","graticuleStrokeWidth","legendBoxSize","legendFontSize"];for(const m of l){const p=kt(a,[m]);const g=m==="legendBoxSize"?Cn.legendBoxSize:m.endsWith("FontSize")?Cn.fontSize:Cn.lineWidth;if(typeof p==="number"&&Number.isFinite(p)&&p>0&&p<=g)n[m]=p}for(const m of["curveOpacity","graticuleOpacity"]){const p=kt(a,[m]);if(typeof p==="number"&&Number.isFinite(p)&&p>=0&&p<=1)n[m]=p}for(const m of["axisColor","graticuleColor"]){const p=mn(kt(a,[m]),m==="graticuleColor");if(p)n[m]=p}const c=mn(kt(e,["themeVariables","titleColor"]));if(c)n.titleColor=c;const d=kt(e,["themeVariables","fontSize"]);const u=typeof d==="number"?d:typeof d==="string"&&/^\d+(?:\.\d+)?(?:px)?$/i.test(d.trim())?Number.parseFloat(d):Number.NaN;if(Number.isFinite(u)&&u>0&&u<=Cn.fontSize){n.titleFontSize=u}const f=[];let h=false;for(let m=0;m<12;m++){const p=mn(kt(e,["themeVariables",`cScale${m}`]));if(p){f[m]=p;h=true}}if(h)n.paletteOverrides=Array.from(f,m=>m??null);return n}var Y9={width:Ko(Cn.dimension),height:Ko(Cn.dimension),marginTop:Ul(Cn.margin),marginRight:Ul(Cn.margin),marginBottom:Ul(Cn.margin),marginLeft:Ul(Cn.margin),axisScaleFactor:Ko(Cn.factor),axisLabelFactor:wn(Cn.axisLabelFactorMin,Cn.factor),curveTension:wn(0,1),useMaxWidth:ct,tickLabels:ct};function q9(e){const t=Kr(e,"themeVariables");if(!t||!("radar"in t))return[];const n=Kr(t,"radar");if(!n)return[{code:"INEFFECTIVE_CONFIG",field:"themeVariables.radar",message:"themeVariables.radar must be an object; the invalid value has no effect."}];const i=new Set(EO);const r=[];const o=new Set(["axisStrokeWidth","curveStrokeWidth","graticuleStrokeWidth"]);const s=new Set(["axisLabelFontSize","legendFontSize"]);const a=new Set(["curveOpacity","graticuleOpacity"]);const l=new Set(["axisColor","graticuleColor"]);for(const c of Object.keys(n).sort(Bn)){const d=n[c];let u;if(!i.has(c))u="a documented radar theme field";else if(o.has(c)&&!Ko(Cn.lineWidth).valid(d))u=Ko(Cn.lineWidth).expected;else if(s.has(c)&&!Ko(Cn.fontSize).valid(d))u=Ko(Cn.fontSize).expected;else if(c==="legendBoxSize"&&!Ko(Cn.legendBoxSize).valid(d))u=Ko(Cn.legendBoxSize).expected;else if(a.has(c)&&!wn(0,1).valid(d))u="a finite number from 0 through 1";else if(l.has(c)&&!yl(d))u="a safe CSS color without url(), variables, or context-breaking characters";if(u)r.push({code:"INEFFECTIVE_CONFIG",field:`themeVariables.radar.${c}`,message:`themeVariables.radar.${c} must be ${u}; the invalid value has no effect.`})}return r}var RO=e=>[...q9(e.root),...bt("radar",e,Y9)];var pt={radius:120,margin:22,titleFontSize:18,titleGap:16,axisFontSize:12.5,axisLabelPad:8,axisLabelMaxWidth:96,axisLabelMinWidth:58,labelClearGap:7,leaderMinPush:9,legendFontSize:13,legendLabelMaxWidth:168,legendSwatch:14,legendGap:30,legendRowGap:9,legendColumnGap:16,legendSwatchToText:8,ringLabelFontSize:9.5,tickBoxPadX:4,tickBoxPadY:3,dotRadius:3,curveStrokeWidth:2.2};function d1(e={}){return{nodeLabelFontSize:e.legendFontSize??pt.legendFontSize,edgeLabelFontSize:e.axisLabelFontSize??pt.axisFontSize,groupHeaderFontSize:e.titleFontSize??pt.titleFontSize,nodeLabelFontWeight:500,edgeLabelFontWeight:500,groupHeaderFontWeight:600,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:e.curveStrokeWidth??pt.curveStrokeWidth,edgeLineWidth:e.axisStrokeWidth??1,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:et.outerBox}}function At(e){return Math.round(e*100)/100}function X9(e,t,n){return Math.min(Math.max(e,t),n)}function vc(e,t){return 2*Math.PI*e/t}function Rc(e,t,n,i){return{x:e+n*Math.sin(i),y:t-n*Math.cos(i)}}function vO(e,t,n=0){return e.left<t.right+n&&t.left<e.right+n&&e.top<t.bottom+n&&t.top<e.bottom+n}function U9(e,t,n){if(e.length===0)return"";if(!t||e.length<3){return"M "+e.map(o=>`${At(o.x)} ${At(o.y)}`).join(" L ")+" Z"}const i=e.length;let r=`M ${At(e[0].x)} ${At(e[0].y)}`;for(let o=0;o<i;o++){const s=e[(o-1+i)%i],a=e[o],l=e[(o+1)%i],c=e[(o+2)%i];const d=a.x+(l.x-s.x)*n,u=a.y+(l.y-s.y)*n;const f=l.x-(c.x-a.x)*n,h=l.y-(c.y-a.y)*n;r+=` C ${At(d)} ${At(u)} ${At(f)} ${At(h)} ${At(l.x)} ${At(l.y)}`}return r+" Z"}function LO(e,t={},n={},i){const r=TO(e,t,n,i);const o=t.radar?.maxWidth;if(o===void 0)return r;return my(r,o,(s,a)=>{if(s===2&&(n.width!==void 0||n.height!==void 0))return void 0;let l;if(s===2){const d=e.axes.map((h,m)=>Math.sin(vc(m,e.axes.length)));const u=Math.max(0,...d)-Math.min(0,...d);const f=Math.max(1,n.axisScaleFactor??1)+(n.axisLabelFactor===void 0?0:n.axisLabelFactor-1.05);l=Math.max(60,r.radius-Math.max(0,a.width-o)/Math.max(1,u*f))}const c=TO(e,t,n,i,{maxWidth:o,...l===void 0?{}:{radius:l}});return r.tickLabels.some((d,u)=>c.tickLabels[u]?.text!==d.text)?a:c})}function TO(e,t,n,i,r){const o=Xe(t,d1(n),i);const s=e.axes.length;if(s>wh)throw new Error(`Radar charts support at most ${wh} axes.`);let a=pt.radius;if(n.width!==void 0||n.height!==void 0){const le=n.width??n.height??pt.radius*2;const Se=n.height??n.width??pt.radius*2;a=X9(Math.min(le,Se)/2-56,40,400)}if(r?.radius!==void 0)a=r.radius;const l=n.axisScaleFactor??1;const c=n.axisLabelFactor??1.05;const d=n.curveTension??.17;const u=e.graticule==="circle"&&d>0;const f=cN(e);const{min:h,max:m}=f;const p=le=>a*dN(le,f);const g=o.edgeLabelFontSize;const y=o.edgeLabelFontWeight;const b=g*1.3;const S=o.groupHeaderFontSize;const x=Math.max(o.groupHeaderFontWeight,600);const k=Math.max(pt.axisLabelMinWidth,Math.min(pt.axisLabelMaxWidth,a*1.05));const w=le=>e.axes.map(Se=>_e(Se.label,{display:"literal",transform:o.edgeTextTransform,fontSize:g,fontWeight:y,letterSpacing:o.edgeLetterSpacing,maxWidth:le}));let C=pt.axisLabelMaxWidth;let R=w(C);for(let le=0;le<8&&Math.max(0,...R.map(Se=>Se.width))>k&&C>pt.axisLabelMinWidth;le++){C=Math.max(pt.axisLabelMinWidth,C-12);R=w(C)}const M=R.map(le=>le.lines);const P=R.map(le=>le.width);const E=R.map(le=>le.height);const v=new Array(s).fill(0);for(const le of e.curves){if(le.values.length!==s)continue;le.values.forEach((Se,Pe)=>{v[Pe]=Math.max(v[Pe],p(Se))})}const L=a*1.05+pt.axisLabelPad;const T=n.axisLabelFactor===void 0?0:a*(c-1.05);const A=e.axes.map((le,Se)=>{const Pe=Math.sin(vc(Se,s));return Pe>.3?"start":Pe<-.3?"end":"middle"});const $=Math.max(a,a*l,...v)+pt.dotRadius+pt.labelClearGap;const _=new Array(s).fill(0).map((le,Se)=>Math.max(0,$+E[Se]/2-L)+T);const z=new Array(s).fill(false);const F=le=>{const Se=vc(le,s);const Pe=L+_[le];const Ae=Pe*Math.sin(Se);const Ne=-Pe*Math.cos(Se);const Oe=P[le];const We=A[le]==="start"?Ae:A[le]==="end"?Ae-Oe:Ae-Oe/2;return{left:We,right:We+Oe,top:Ne-E[le]/2,bottom:Ne+E[le]/2,rx:Ae,ry:Ne}};const G=[];for(let le=0;le<s;le++){const Se=_[le];const Pe=()=>G.some(Ae=>vO(F(le),F(Ae),2));if(Pe()){z[le]=true;let Ae=6;let Ne=false;for(let Oe=0;Oe<48;Oe++){_[le]=Se+Ae;if(!Pe()){Ne=true;break}Ae*=2}if(!Ne)throw new Error("Radar axis labels could not be placed within finite layout bounds.")}G.push(le)}const I=n.marginLeft??pt.margin;const D=n.marginRight??pt.margin;const B=n.marginTop??pt.margin;const Y=n.marginBottom??pt.margin;const W=a*Math.max(1,l);let O=W,N=W,H=W,j=W;for(let le=0;le<s;le++){const Se=F(le);O=Math.max(O,-Se.left);N=Math.max(N,Se.right);H=Math.max(H,-Se.top);j=Math.max(j,Se.bottom)}if(n.width){const le=n.width/2;O=Math.max(O,le);N=Math.max(N,le)}if(n.height){const le=n.height/2;H=Math.max(H,le);j=Math.max(j,le)}const q=r?Math.max(r.maxWidth,I+O+N+D):void 0;const X=o.nodeLabelFontSize;const V=o.nodeLabelFontWeight;const ee=X*1.25;const re=e.showLegend&&e.curves.length>0;const U=n.legendBoxSize??pt.legendSwatch;const te=X*(pt.legendLabelMaxWidth/pt.legendFontSize);const J=q===void 0?0:q-I-D-U-pt.legendSwatchToText;const ae=J>0?J:te;const Q=re?e.curves.map(le=>{const Se=_e(le.label,{display:"literal",transform:o.nodeTextTransform,fontSize:X,fontWeight:V,letterSpacing:o.nodeLetterSpacing,maxWidth:ae});return r&&Se.width>ae+.01?_e(Se.prepared,{...Se,maxWidth:te}):Se}):[];const K=Q.map(le=>({block:le}));const Z={gap:pt.legendRowGap,minRowHeight:U,leadingWidth:U+pt.legendSwatchToText,columnGap:pt.legendColumnGap,...q===void 0?{}:{maxWidth:q-I-D}};const se=jd(K,Z);const oe=re?se.width:0;const de=se.height;if(re&&!r){H=Math.max(H,de/2);j=Math.max(j,de/2)}let xe=e.title?_e(e.title,{display:"literal",transform:o.groupTextTransform,fontSize:S,fontWeight:x,letterSpacing:o.groupLetterSpacing,...q===void 0?{}:{maxWidth:Math.max(1,q-I-D)}}):void 0;if(xe&&q!==void 0&&xe.width>q-I-D+.01){xe=_e(xe.prepared,xe)}const Me=xe?xe.height:0;const Ce=xe?Me+pt.titleGap:0;const pe=re&&!r?pt.legendGap+oe:0;const Te=I+O+N+pe+D;const Fe=r&&re?Math.max(Te,I+oe+D):Te;const De=I+O+(Fe-Te)/2;const Be=xe?.width??0;const me=Math.max(0,Be/2-De);const he=Math.max(0,De+Be/2-Fe);const fe=Fe+me+he;const be=B+Ce+H+j+Y+(r&&re?pt.legendGap+de:0);const ge=De+me;const Re=B+Ce+H;const Ie=[];for(let le=1;s>0&&le<=e.ticks;le++){const Se=a*le/e.ticks;const Pe=le===e.ticks?m:h+(m-h)*(le/e.ticks);const Ae=e.graticule==="polygon"?e.axes.map((Ne,Oe)=>{const We=Rc(ge,Re,Se,vc(Oe,s));return{x:At(We.x),y:At(We.y)}}):[];Ie.push({r:At(Se),value:Pe,points:Ae,emphasized:le===e.ticks})}const ne=e.axes.map((le,Se)=>{const Pe=vc(Se,s);const Ae=Rc(ge,Re,a*l,Pe);const Ne=L+_[Se];const Oe=Rc(ge,Re,Ne,Pe);const We=z[Se]||_[Se]>pt.leaderMinPush?(()=>{const ce=Rc(ge,Re,Math.max(a,a*l)+1,Pe);const Le=Rc(ge,Re,Ne-E[Se]/2-2,Pe);return{x1:At(ce.x),y1:At(ce.y),x2:At(Le.x),y2:At(Le.y)}})():void 0;return{id:le.id,label:le.label,block:R[Se],x:At(Ae.x),y:At(Ae.y),labelX:At(Oe.x),labelY:At(Oe.y),anchor:A[Se],lines:M[Se],labelWidth:At(P[Se]),leader:We}});const we=e.curves.map((le,Se)=>{const Pe=le.values.length===s;const Ae=Pe?le.values.map((Ne,Oe)=>{const We=Rc(ge,Re,p(Ne),vc(Oe,s));return{x:At(We.x),y:At(We.y)}}):[];return{id:le.id,label:le.label,colorIndex:Se,areaPath:Pe?U9(Ae,u,d):"",vertices:Ae,arityMismatch:!Pe}});const Ee=[];if(n.tickLabels&&s>0){const le=vc(0,s)+Math.PI/s;for(const Se of[...Ie].reverse()){const Pe=Rc(ge,Re,Se.r,le);const Ae=Gd(Se.value);const Ne=_e(Ae,{display:"literal",fontSize:pt.ringLabelFontSize,fontWeight:y,letterSpacing:o.edgeLetterSpacing});const Oe=Ne.width+pt.tickBoxPadX*2;const We=pt.ringLabelFontSize+pt.tickBoxPadY*2;const ce={text:Ae,block:Ne,x:At(Pe.x),y:At(Pe.y),w:At(Oe),h:At(We)};const Le={left:ce.x-ce.w/2,right:ce.x+ce.w/2,top:ce.y-ce.h/2,bottom:ce.y+ce.h/2};const ve=Ee.some(He=>vO(Le,{left:He.x-He.w/2,right:He.x+He.w/2,top:He.y-He.h/2,bottom:He.y+He.h/2},1));if(!ve)Ee.unshift(ce)}}const ke=[];if(re){const le=r?(fe-oe)/2:me+I+O+N+pt.legendGap;const Se=r?Re+j+pt.legendGap:Re-de/2;const Pe=jd(K,{...Z,top:Se});e.curves.forEach((Ae,Ne)=>{const{item:{block:Oe},x:We=0,top:ce,height:Le,textY:ve}=Pe.rows[Ne];ke.push({label:Ae.label,lines:Oe.lines,block:Oe,colorIndex:Ne,x:At(le+We),y:At(ce+(Le-U)/2),swatchSize:U,textX:At(le+We+U+pt.legendSwatchToText),textY:At(ve)})})}return{width:At(fe),height:At(be),cx:At(ge),cy:At(Re),radius:At(a),title:e.title?{text:xe.text,block:xe,x:At(ge),y:At(B+Me/2),fontSize:S}:void 0,accessibility:e.accessibility?{...e.accessibility}:void 0,rings:Ie,axes:ne,curves:we,tickLabels:Ee,legend:ke,polygonGraticule:e.graticule==="polygon",typography:{axisFontSize:g,axisFontWeight:y,legendFontSize:X,legendFontWeight:V,titleFontSize:S,titleFontWeight:x,tickFontSize:pt.ringLabelFontSize,tickFontWeight:y},visual:n}}var KAe={radius:pt.radius,axisFontSize:pt.axisFontSize,titleFontSize:pt.titleFontSize,legendFontSize:pt.legendFontSize,dotRadius:pt.dotRadius};var JAe={axisLabelMaxWidth:pt.axisLabelMaxWidth,axisLabelMinWidth:pt.axisLabelMinWidth,legendLabelMaxWidth:pt.legendLabelMaxWidth,leaderMinPush:pt.leaderMinPush,tickBoxPadX:pt.tickBoxPadX,tickBoxPadY:pt.tickBoxPadY};function AO(e,t,n){const i=na(e,t);if(i!==null&&i>=4.5)return e;const r=[n,"#000000","#ffffff"].map(s=>({color:s,ratio:na(s,t)})).filter(s=>s.ratio!==null).sort((s,a)=>a.ratio-s.ratio);const o=r[0];return o&&o.ratio>=4.5?o.color:n}function V9(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=Xe(o,d1(n.visual),r.styleFace);const c=[];const d=Qd(n.curves.length,{accent:i.accent,bg:i.bg,overrides:n.visual.paletteOverrides});const u=n.visual.curveOpacity??.5;const f=n.visual.axisColor??l.edgeStrokeColor??"var(--_line)";const h=n.visual.graticuleColor??l.edgeStrokeColor??"var(--_line)";const m=n.visual.axisStrokeWidth??1;const p=n.visual.graticuleStrokeWidth??1;const g=n.visual.graticuleOpacity??.7;const y=n.visual.titleColor??l.groupTextColor??l.nodeTextColor??"var(--_text)";const b=l.nodeBorderColor??"var(--bg)";const S=n.visual.axisColor??AO(l.edgeTextColor??i.fg,i.bg,i.fg);const x=AO(l.edgeTextColor??i.fg,i.bg,i.fg);const k={title:n.accessibility?.title??n.title?.text??"Radar chart",description:n.accessibility?.description};const w=IO(n.axes.map(A=>A.id));const C=IO(n.curves.map(A=>A.id));const R=[n.width,n.height,k.title??""];for(const A of n.axes)R.push(A.id);for(const A of n.curves)R.push(A.label);const M=`radar-${mi(R.join("|"))}`;const P=`${M}-title`;const E=`${M}-desc`;const v=[J9(n,i,a,k,M,P,E)];if(k.title)v.push(`<title id="${P}">${It(k.title)}</title>`);if(k.description)v.push(`<desc id="${E}">${It(k.description)}</desc>`);v.push(Dt(s,false,i.shadow,i.embedFontImport));const L=Zt(i);if(L)v.push(`<defs>${L}</defs>`);c.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},v.join("\n")));for(let A=0;A<n.rings.length;A++){const $=n.rings[A];c.push(e.shape({id:`ring:${A}`,role:"grid",geometry:n.polygonGraticule?{kind:"polygon",points:$.points}:{kind:"circle",cx:n.cx,cy:n.cy,r:$.r},paint:{fill:"none",stroke:h,strokeOpacity:String(g),strokeWidth:String($.emphasized?K9(p):p)},attributes:{className:`radar-ring${$.emphasized?" radar-ring-outer":""}`}}))}for(const[A,$]of n.axes.entries()){const _=w[A];c.push(e.shape({id:`spoke:${_}`,role:"grid",geometry:{kind:"line",x1:n.cx,y1:n.cy,x2:$.x,y2:$.y},paint:{stroke:f,strokeWidth:String(m)},attributes:{className:"radar-axis-line"}}))}const T=new Map;for(const[A,$]of n.curves.entries()){if($.arityMismatch||$.vertices.length===0)continue;const _=C[A];const z={category:$.label};const F=st(r.styleFace,"pie-slice",z,{includeFallback:false});const G=n.visual.paletteOverrides?.[$.colorIndex];const I=G??F?.fillColor??d[$.colorIndex];const D=G??F?.strokeColor??F?.borderColor??I;T.set($.colorIndex,D);const B=F?.lineWidth??l.nodeLineWidth;const Y={fill:I,fillOpacity:String(u),stroke:D,strokeWidth:String(B),strokeLinejoin:"round"};const W={className:"radar-area",data:{curve:$.label}};c.push(e.shape({id:`curve:${_}`,role:"pie-slice",geometry:n.polygonGraticule?{kind:"polygon",points:$.vertices}:{kind:"path",d:$.areaPath},paint:Y,channels:z,attributes:W}))}for(const[A,$]of n.curves.entries()){if($.arityMismatch)continue;const _=C[A];const z={category:$.label};const F=st(r.styleFace,"point",z,{includeFallback:false});const G=n.visual.paletteOverrides?.[$.colorIndex];const I=G??F?.fillColor??T.get($.colorIndex)??d[$.colorIndex];const D=F?.strokeColor??F?.borderColor??b;const B=F?.lineWidth??1.2;$.vertices.forEach((Y,W)=>{c.push(e.shape({id:`dot:${_}:${W}`,role:"point",geometry:{kind:"circle",cx:Y.x,cy:Y.y,r:3},paint:{fill:I,stroke:D,strokeWidth:String(B)},channels:z,attributes:{className:"radar-dot"}}))})}for(const[A,$]of n.axes.entries()){if(!$.leader)continue;const _=w[A];const z=$.leader;c.push(e.shape({id:`leader:${_}`,role:"grid",geometry:{kind:"line",x1:z.x1,y1:z.y1,x2:z.x2,y2:z.y2},paint:{stroke:h,strokeOpacity:"0.5",strokeWidth:"1"},attributes:{className:"radar-leader"}}))}for(let A=0;A<n.tickLabels.length;A++){const $=n.tickLabels[A];const _=u1($.x-$.w/2);const z=u1($.y-$.h/2);c.push(e.shape({id:`tick-box:${A}`,role:"grid",geometry:{kind:"rect",x:_,y:z,width:$.w,height:$.h,rx:4,ry:4},paint:{fill:"var(--bg)",stroke:h,strokeOpacity:"0.35",strokeWidth:"0.75"},attributes:{className:"radar-tick-box"}}))}for(let A=0;A<n.tickLabels.length;A++){const $=n.tickLabels[A];c.push(e.text({id:`tick:${A}`,role:"axis",text:$.text,x:$.x,y:$.y,fontSize:n.typography.tickFontSize,fontWeight:n.typography.tickFontWeight,letterSpacing:l.edgeLetterSpacing,block:$.block,display:"literal",anchor:"middle",dominantBaseline:"middle",baselineShift:0,paint:{fill:x},attributes:{className:"radar-tick-label"}}))}for(const[A,$]of n.axes.entries()){const _=w[A];const z=$.lines;c.push(e.text({id:`axis-label:${_}`,role:"axis",text:z.join("\n"),x:$.labelX,y:$.labelY,fontSize:n.typography.axisFontSize,block:$.block,fontWeight:n.typography.axisFontWeight,letterSpacing:l.edgeLetterSpacing,display:"literal",anchor:$.anchor,dominantBaseline:"middle",baselineShift:0,paint:{fill:S},attributes:{className:"radar-axis-label",ariaLabel:$.label}}))}for(const A of n.legend){const $={category:A.label};const _=st(r.styleFace,"legend",$,{includeFallback:false});const z=n.visual.paletteOverrides?.[A.colorIndex];const F=z??_?.fillColor??T.get(A.colorIndex)??d[A.colorIndex];const G=_?.strokeColor??_?.borderColor??l.nodeBorderColor??"var(--_node-stroke)";const I=_?.lineWidth??1;c.push(e.shape({id:`legend-swatch:${A.colorIndex}`,role:"legend",geometry:{kind:"rect",x:A.x,y:A.y,width:A.swatchSize,height:A.swatchSize,rx:2,ry:2},paint:{fill:F,fillOpacity:"1",stroke:G,strokeWidth:String(I)},channels:$,attributes:{className:"radar-legend-swatch"}}));c.push(e.text({id:`legend-label:${A.colorIndex}`,role:"legend",text:A.lines.join("\n"),x:A.textX,y:A.textY,fontSize:n.typography.legendFontSize,fontWeight:n.typography.legendFontWeight,letterSpacing:l.nodeLetterSpacing,block:A.block,display:"literal",anchor:"start",dominantBaseline:"middle",baselineShift:0,paint:{fill:_?.textColor??l.nodeTextColor??"var(--_text)"},attributes:{className:"radar-legend-text"}}))}if(n.title){c.push(e.text({id:"title",role:"title",text:n.title.text,x:n.title.x,y:n.title.y,fontSize:n.title.fontSize,fontWeight:n.typography.titleFontWeight,letterSpacing:l.groupLetterSpacing,block:n.title.block,display:"literal",anchor:"middle",dominantBaseline:"middle",baselineShift:0,paint:{fill:y},attributes:{className:"radar-title"}}))}c.push(e.documentClose());return{family:"radar",width:n.width,height:n.height,colors:i,transparent:a,parts:c}}function u1(e){return Math.round(e*100)/100}function K9(e){return u1(e*1.4)}function J9(e,t,n,i,r,o,s){const a=e.visual.useMaxWidth?{width:"100%",height:"100%",style:`max-width:${e.width}px`}:{};return Ot(e.width,e.height,t,n,{...a,attrs:{id:r,"aria-roledescription":"radar chart",...Mi(i.title,i.description,o,s,"radar chart")}})}function IO(e){const t=new Map;for(const i of e)t.set(i,(t.get(i)??0)+1);const n=new Map;return e.map(i=>{if((t.get(i)??0)<=1)return i;const r=n.get(i)??0;n.set(i,r+1);return`${i}#${r}`})}var FO=gt(V9);var xIe={configDiagnostics:RO,statementEnds:sN,normalizeRequest:e=>({familyConfig:{visual:c1(e.source.frontmatter)}}),layout:e=>mt(LO(lN(e.source.lines,{title:typeof e.source.frontmatter.title==="string"?e.source.frontmatter.title:void 0}),e.renderOptions,e.familyConfig?.visual??c1(e.source.frontmatter),e.styleFace),{injectAccessibility:false}),projectPositioned:ft(WI),lowerScene:ht(FO)};var Q9={width:wn(Qi.width.min,Qi.width.max),height:wn(Qi.height.min,Qi.height.max),nodeWidth:wn(Qi.nodeWidth.min,Qi.nodeWidth.max),nodePadding:Ul(Qi.nodePadding.max),linkColor:an("source, target, gradient, or a drawable CSS color",e=>typeof e==="string"&&(["source","target","gradient"].includes(e)||mn(e,true)!==void 0)),nodeAlignment:Ws("justify","center","left","right"),showValues:ct,prefix:Dr,suffix:Dr,labelStyle:Ws("legacy","outlined"),nodeColors:an("an object mapping node labels to drawable CSS colors",e=>Boolean(e)&&typeof e==="object"&&!Array.isArray(e)&&Object.values(e).every(t=>mn(t,true)!==void 0))};var NO=e=>bt("sankey",e,Q9);import{sankey as Z9,sankeyCenter as eK,sankeyJustify as tK,sankeyLeft as nK,sankeyRight as iK}from"d3-sankey";function $O(e){const t=gi(e.nodes);const n=new Map;const i=e.links.map(({source:r,target:o})=>{let s=n.get(r);if(!s)n.set(r,s=new Map);const a=s.get(o)??0;s.set(o,a+1);const l=`link:${r}->${o}`;const c=a===0?l:`${l}#${a}`;return{id:t(c,["link",r,o,a]),source:r,target:o,occurrence:a}});return{links:i,...e.title?{titleId:t("title",["title"])}:{}}}function _O(e,t){return`${t.prefix}${Gd(e)}${t.suffix}`}var oi={padding:24,titleFontSize:18,titleFontWeight:600,titleGap:20,labelFontSize:13,labelFontWeight:500,valueFontWeight:400,labelGap:6,labelLineHeight:13*1.3,minNodeHeight:1,nodeStrokeWidth:1};var f1={nodeLabelFontSize:oi.labelFontSize,edgeLabelFontSize:oi.labelFontSize,groupHeaderFontSize:oi.titleFontSize,nodeLabelFontWeight:oi.labelFontWeight,edgeLabelFontWeight:oi.labelFontWeight,groupHeaderFontWeight:oi.titleFontWeight,nodePaddingX:0,nodePaddingY:0,nodeLineWidth:oi.nodeStrokeWidth,edgeLineWidth:et.connector,groupCornerRadius:0,groupPaddingX:0,groupPaddingY:0,groupLineWidth:et.outerBox};function Di(e){return Math.round(e*100)/100}var rK={left:nK,right:iK,center:eK,justify:tK};function lr(e,t){if(e===void 0||!Number.isFinite(e)){throw new Error(`d3-sankey did not assign ${t}`)}return e}function oK(e){const t=new Map(e.nodes.map(o=>[o,0]));const n=new Map;for(const o of e.links){t.set(o.target,(t.get(o.target)??0)+1);n.set(o.source,[...n.get(o.source)??[],o.target])}const i=new Map(e.nodes.map(o=>[o,0]));const r=e.nodes.filter(o=>t.get(o)===0);for(let o=0;o<r.length;o++){const s=r[o];for(const a of n.get(s)??[]){i.set(a,Math.max(i.get(a)??0,(i.get(s)??0)+1));const l=(t.get(a)??1)-1;t.set(a,l);if(l===0)r.push(a)}}return Math.max(1,...i.values())+1}function sK(e){const t=new Map(e.nodes.map(i=>[i,0]));const n=new Map(e.nodes.map(i=>[i,0]));for(const i of e.links){n.set(i.source,(n.get(i.source)??0)+i.value);t.set(i.target,(t.get(i.target)??0)+i.value)}return new Map(e.nodes.map(i=>[i,Math.max(t.get(i)??0,n.get(i)??0)]))}function DO(e,t={},n=zM,i){const r=$O(e);const o=Xe(t,f1,i);const s=o.nodeLabelFontSize;const a=n.nodePadding+(n.showValues?15:0);const l=Math.max(n.width,n.nodeWidth*oK(e));const c=e.links.every(N=>N.value===0);const d=sK(e);const u={nodes:e.nodes.map((N,H)=>({id:N,authoredIndex:H})),links:e.links.map((N,H)=>({source:N.source,target:N.target,value:c?1:N.value,authoredIndex:H,authoredValue:N.value}))};Z9().nodeId(N=>N.id).nodeWidth(n.nodeWidth).nodePadding(a).nodeAlign(rK[n.nodeAlignment]).extent([[0,0],[l,n.height]])(u);const f=u.nodes;const h=u.links;const m=new Map(f.map(N=>{const H=d.get(N.id)??0;const j=n.showValues?`${N.id}
|
|
42
|
-
${_O(H,n)}`:N.id;return[N,_e(j,{display:"formatted",transform:o.nodeTextTransform,fontSize:s,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,safeFont:true})]}));const p=new Map(h.map(N=>[N,Di(Math.max(N.authoredValue>0?1:0,c?0:N.width??0))]));const g=new Map;for(const N of f){const H=(N.sourceLinks??[]).reduce((X,V)=>X+p.get(V),0);const j=(N.targetLinks??[]).reduce((X,V)=>X+p.get(V),0);const q=c?0:lr(N.y1,`y1 for node ${N.id}`)-lr(N.y0,`y0 for node ${N.id}`);g.set(N,Math.max(oi.minNodeHeight,q,H,j))}const y=new Map;for(const N of f){const H=N.layer??N.depth??0;y.set(H,[...y.get(H)??[],N])}const b=new Map;let S=n.height;for(const N of y.values()){N.sort((j,q)=>lr(j.y0,`y0 for node ${j.id}`)-lr(q.y0,`y0 for node ${q.id}`)||j.authoredIndex-q.authoredIndex);let H=0;for(const[j,q]of N.entries()){const X=g.get(q);const V=Math.max(0,(m.get(q).height-X)/2);const ee=Math.max(lr(q.y0,`y0 for node ${q.id}`),j===0?0:H+V);b.set(q,ee);H=ee+X+V+a}S=Math.max(S,H-a)}const x=new Map;const k=new Map;for(const N of f){const H=b.get(N);const j=g.get(N);const q=(X,V)=>{const ee=(X==="source"?N.sourceLinks:N.targetLinks)??[];const re=J=>lr(X==="source"?J.y0:J.y1,`${X} y for link ${J.authoredIndex}`);ee.sort((J,ae)=>re(J)-re(ae)||J.authoredIndex-ae.authoredIndex);const U=ee.reduce((J,ae)=>J+p.get(ae),0);let te=H+(j-U)/2;for(const J of ee){const ae=p.get(J);V.set(J,te+ae/2);te+=ae}};q("source",x);q("target",k)}const w=oi.padding;const C=o.groupHeaderFontSize;const R=e.title?_e(e.title,{display:"formatted",transform:o.groupTextTransform,fontSize:C,fontWeight:o.groupHeaderFontWeight,letterSpacing:o.groupLetterSpacing,safeFont:true}):void 0;const M=R?.text;const P=R?R.height-(R.lineHeight-R.fontSize):0;const E=R?P+oi.titleGap:0;const v=oi.padding+E;const L=w+l/2;const T=f.reduce((N,H)=>(d.get(H.id)??0)>(d.get(N.id)??0)?H:N,f[0]).layer??0;const A=new Map;for(const N of f){const H=N.layer??N.depth??0;const j=lr(N.x0,`x0 for node ${N.id}`);const q=m.get(N);const X=q.lines;const V=n.labelStyle==="outlined"?H<T?"end":"start":w+j<L?"start":"end";const ee=q.width;A.set(N,{lines:X,block:q,anchor:V,width:ee})}let $=w;let _=w+l;let z=v;let F=v+S;for(const N of f){const H=A.get(N);const j=w+lr(N.x0,`x0 for node ${N.id}`);const q=w+lr(N.x1,`x1 for node ${N.id}`);if(H.anchor==="start"){_=Math.max(_,q+oi.labelGap+H.width)}else{$=Math.min($,j-oi.labelGap-H.width)}const X=v+b.get(N)+g.get(N)/2;z=Math.min(z,X-H.block.height/2);F=Math.max(F,X+H.block.height/2)}for(const N of h){const H=w+lr(N.source.x1,`x1 for node ${N.source.id}`);const j=w+lr(N.target.x0,`x0 for node ${N.target.id}`);if(!(j>H))continue;const q=_1((j-H)/2,(j-H)/2,Math.abs(k.get(N)-x.get(N)),p.get(N)/2);$=Math.min($,H-q);_=Math.max(_,j+q)}const G=oi.padding-$;const I=v-z;const D=Math.max(_+G+oi.padding,(R?.width??0)+2*oi.padding);const B=F+I+oi.padding;const Y=f.map(N=>{const H=A.get(N);const j=w+lr(N.x0,`x0 for node ${N.id}`)+G;const q=w+lr(N.x1,`x1 for node ${N.id}`)+G;const X=v+b.get(N)+I;const V=X+g.get(N);return{id:`sankey-node-${N.authoredIndex+1}`,label:N.id,value:d.get(N.id)??0,layer:N.layer??N.depth??0,x0:Di(j),y0:Di(X),x1:Di(q),y1:Di(V),labelLines:H.lines,labelBlock:H.block,labelX:Di(H.anchor==="start"?q+oi.labelGap:j-oi.labelGap),labelY:Di((X+V)/2),labelAnchor:H.anchor}});const W=new Map(Y.map(N=>[N.label,N]));const O=h.map(N=>{const H=N.source;const j=N.target;const q=r.links[N.authoredIndex];const X=Di(w+lr(H.x1,`x1 for node ${H.id}`)+G);const V=Di(w+lr(j.x0,`x0 for node ${j.id}`)+G);const ee=Di(v+x.get(N)+I);const re=Di(v+k.get(N)+I);const U=aK(X,ee,V,re);return{id:q.id,sceneId:`sankey-link-${N.authoredIndex+1}`,source:q.source,target:q.target,sourceId:W.get(H.id).id,targetId:W.get(j.id).id,value:N.authoredValue,path:U.path,points:U.points,width:p.get(N),sx:X,sy:ee,tx:V,ty:re}});return{width:Di(D),height:Di(B),...M?{title:{id:r.titleId,text:M,block:R,x:Di(D/2),y:oi.padding+P/2}}:{},nodes:Y,links:O,total:e.links.reduce((N,H)=>N+H.value,0),visual:n}}function aK(e,t,n,i){const r=Di((e+n)/2);const o=`M ${e} ${t} C ${r} ${t}, ${r} ${i}, ${n} ${i}`;const s=[];for(const a of[0,.25,.5,.75,1]){const l=1-a;const c=l*l*l*e+3*l*l*a*r+3*l*a*a*r+a*a*a*n;const d=l*l*l*t+3*l*l*a*t+3*l*a*a*i+a*a*a*i;s.push({x:Di(c),y:Di(d)})}return{path:o,points:s}}var h1=.5;var lK=3;function cK(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=Xe(o,f1,r.styleFace);const c=n.visual;const d=[];const u=dK(i.bg);const f=Qd(n.nodes.length,{accent:i.accent,bg:i.bg});const h=new Map;const m=l.nodeBorderColor??"var(--_node-stroke)";const p=l.nodeLineWidth;n.nodes.forEach((x,k)=>{const w=st(r.styleFace,"bar",{category:x.label,value:x.value},{includeFallback:false});const C=$$(c,x.label);const R=w?.fillColor;h.set(x.label,{color:C??R??f[k],derived:C===void 0&&R===void 0,stroke:w?.strokeColor??w?.borderColor??m,strokeWidth:w?.lineWidth??p})});const g=[];g.push(Ot(n.width,n.height,i,a,{attrs:{role:"img","aria-roledescription":"sankey diagram"}}));g.push(Dt(s,false,i.shadow,i.embedFontImport));const y=Zt(i);if(y)g.push(`<defs>${y}</defs>`);d.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},g.join("\n")));const b=new Map;if(c.linkColor.mode==="gradient"){const x=n.links.map((k,w)=>{const C=`sankey-gradient-${w+1}`;b.set(k.sceneId,C);const R=h.get(k.source);const M=h.get(k.target);return{id:C,units:"userSpaceOnUse",x1:k.sx,y1:k.sy,x2:k.tx,y2:k.ty,stops:[{offset:0,color:OO(R,i.bg)},{offset:1,color:OO(M,i.bg)}]}});if(x.length>0){d.push(e.definitions({id:"sankey-gradient-definitions",gradientResources:x},`<defs>
|
|
43
|
-
${gC(x)}
|
|
44
|
-
</defs>`))}}for(const x of n.links){const k=String(x.width);const w=uK(c,i.bg,h.get(x.source),h.get(x.target),b.get(x.sceneId));d.push(e.connector({id:x.sceneId,role:"edge",geometry:{kind:"path",d:x.path,points:x.points},lineStyle:"solid",paint:{fill:"none",stroke:w,strokeWidth:k,opacity:String(h1)},stroke:{mixBlendMode:u,encodesValue:true},identity:{id:x.id,from:x.source,to:x.target},endpoints:{from:x.sourceId,to:x.targetId},relationship:{kind:"flow",direction:"forward"},channels:{category:x.source,value:x.value},attributes:{className:"sankey-link",data:{source:x.source,target:x.target,value:String(x.value)}}}))}for(const x of n.nodes){const k=h.get(x.label);const w=k.color;d.push(e.shape({id:x.id,role:"bar",identity:{id:x.label},geometry:{kind:"rect",x:x.x0,y:x.y0,width:BO(x.x1-x.x0),height:BO(x.y1-x.y0)},paint:{fill:w,stroke:k.stroke,strokeWidth:String(k.strokeWidth)},channels:{category:x.label,value:x.value},attributes:{className:"sankey-node",data:{label:Hr(x.label),value:String(x.value),layer:String(x.layer)}}}))}const S=l.nodeTextColor??"var(--_text)";for(const x of n.nodes){const k=x.labelLines.join("\n");d.push(e.text({id:`${x.id}:label`,role:"label",text:k,x:x.labelX,y:x.labelY,fontSize:l.nodeLabelFontSize,fontWeight:l.nodeLabelFontWeight,letterSpacing:l.nodeLetterSpacing,block:x.labelBlock,anchor:x.labelAnchor,dominantBaseline:"middle",paint:{fill:S,stroke:"var(--bg)",strokeWidth:String(lK),paintOrder:"stroke fill"},channels:{category:x.label,value:x.value},attributes:{className:"sankey-node-label"}}))}if(n.title){const x=n.title.text;d.push(e.text({id:"title",identity:{id:n.title.id},role:"title",text:x,x:n.title.x,y:n.title.y,fontSize:l.groupHeaderFontSize,fontWeight:l.groupHeaderFontWeight,letterSpacing:l.groupLetterSpacing,block:n.title.block,anchor:"middle",dominantBaseline:"middle",paint:{fill:l.groupTextColor??l.nodeTextColor??"var(--_text)"},attributes:{className:"sankey-title"}}))}d.push(e.documentClose());return{family:"sankey",width:n.width,height:n.height,colors:i,transparent:a,parts:d}}function OO(e,t){return e.derived?$M(e.color,t,h1*100):e.color}function dK(e){const t=e?Zh(e):null;return t!==null&&t<.18?"normal":"multiply"}function uK(e,t,n,i,r){const o=(s,a)=>a?$M(s,t,h1*100):s;switch(e.linkColor.mode){case"source":return o(n.color,n.derived);case"target":return o(i.color,i.derived);case"static":return e.linkColor.color;default:if(!r)throw new Error("Sankey gradient mode requires a typed local gradient resource");return`url(#${r})`}}function BO(e){return Math.round(e*100)/100}var WO=gt(cK);var nFe={configDiagnostics:NO,normalizeRequest:e=>({familyConfig:{visual:GM(e.source.frontmatter)}}),layout:e=>mt(DO(fN(D$(e.source),{title:typeof e.source.frontmatter.title==="string"?e.source.frontmatter.title:void 0}),e.renderOptions,e.familyConfig?.visual??GM(e.source.frontmatter),e.styleFace)),projectPositioned:ft(zI),lowerScene:ht(WO)};var fK=Object.fromEntries([...["actorMargin","width","height","diagramMarginX","diagramMarginY","messageMargin","noteMargin","activationWidth"].map(e=>[e,jt]),["showSequenceNumbers",ct],["wrap",ct]]);var zO=e=>bt("sequence",e,fK);var yFe={configDiagnostics:zO,normalizeRequest:e=>({familyConfig:{sequence:B$(e.source.frontmatter)}}),layout:e=>{const t=e.familyConfig?.sequence??{};const n=eT(e.source,"decoded");const i=Tn(qr(mT(n.familyLines,{...t,authoredLine:pT(n)}),e.source.accessibility),e.source.frontmatter);return mt(Dy(i,e.renderOptions,t,e.styleFace))},projectPositioned:ft(jg),lowerScene:ht(NN)};var hK=["compositTitleSize","dividerMargin","fontSize","forkHeight","forkWidth","nodeSpacing","noteMargin","padding","radius","rankSpacing"];var mK=["arrowMarkerAbsolute","edgeLengthFactor","fontSizeFactor","labelHeight","miniPadding","sizeUnit","textHeight","titleShift","titleTopMargin"];var pK=["layout","look","minNodeWidth","theme","wrappingWidth"];var gK=["arrowMarkerAbsolute","compositTitleSize","defaultRenderer","dividerMargin","edgeLengthFactor","fontSize","fontSizeFactor","forkHeight","forkWidth","labelHeight","layout","look","miniPadding","minNodeWidth","nodeSpacing","noteMargin","padding","radius","rankSpacing","sizeUnit","textHeight","theme","titleShift","titleTopMargin","wrappingWidth"];var yK=new Set(gK);var xK=new Set(hK);var bK=new Set(mK);var SK=new Set(pK);var wK=new Set(["fontSize","compositTitleSize","forkWidth","forkHeight"]);var Kh=e=>typeof e==="number"&&Number.isFinite(e)&&e>0?e:void 0;var Tc=e=>typeof e==="number"&&Number.isFinite(e)&&e>=0?e:void 0;function MK(e){return e.filter(t=>Boolean(t)&&typeof t==="object"&&!Array.isArray(t))}function HO(e,t=false){const n=new Map;for(const r of MK(e)){for(const[o,s]of Object.entries(r))n.set(o,s)}const i=[];for(const[r,o]of[...n].sort(([s],[a])=>Bn(s,a))){if(!yK.has(r)){if(t)i.push({code:"INEFFECTIVE_CONFIG",field:`state.${r}`,message:`State config field "state.${r}" is unknown and has no effect; check the spelling or remove it.`});continue}if(bK.has(r)){i.push({code:"INEFFECTIVE_CONFIG",field:`state.${r}`,message:`State config field "state.${r}" is a legacy Dagre/fixed-metric option with no faithful effect in the ELK measured-text renderer.`});continue}if(SK.has(r)){i.push({code:"INEFFECTIVE_CONFIG",field:`state.${r}`,message:`State config field "state.${r}" is accepted for Mermaid compatibility but has no effect on this renderer.`});continue}if(r==="defaultRenderer"){if(o!=="elk")i.push({code:"INEFFECTIVE_CONFIG",field:"state.defaultRenderer",message:`State config field "state.defaultRenderer" requested ${JSON.stringify(o)}; this renderer supports only "elk" and will not silently select a different engine.`});continue}if(xK.has(r)){const s=wK.has(r);const a=s?Kh(o)!==void 0:Tc(o)!==void 0;if(!a)i.push({code:"INEFFECTIVE_CONFIG",field:`state.${r}`,message:`State config field "state.${r}" must be a ${s?"positive":"non-negative"} finite number; the supplied value was ignored.`})}}return i}function GO(e){const t=e?.state;return t&&typeof t==="object"&&!Array.isArray(t)?t:{}}function jO(e,t){const n={...GO(e),...GO(t.mermaidConfig)};const i=Tc(n.nodeSpacing);const r=Tc(n.rankSpacing);const o=Tc(n.padding);const s=Tc(n.radius);const a=Kh(n.fontSize);const l=Kh(n.compositTitleSize);const c={...Oi,...o===void 0?{}:{nodePaddingX:o,nodePaddingY:o},...s===void 0?{}:{nodeCornerRadius:s},...a===void 0?{}:{nodeLabelFontSize:a,edgeLabelFontSize:a},...l===void 0?{}:{groupHeaderFontSize:l}};const d=t.nodeSpacing??i;const u=t.layerSpacing??r;return{...t,...d===void 0?{}:{nodeSpacing:d},...u===void 0?{}:{layerSpacing:u},stateVisual:{forkWidth:Kh(n.forkWidth)??70,forkHeight:Kh(n.forkHeight)??10,noteMargin:Tc(n.noteMargin)??18,dividerMargin:Tc(n.dividerMargin)??0,styleDefaults:c}}}var YO=({root:e,config:t})=>{const n=Kr(e,t.section);return n?HO([n],true):dS("state",e,t)};var $Fe={configDiagnostics:YO,statementEnds:k2,normalizeRequest:e=>{const t=jO(e.source.frontmatter,e.renderOptions);const{stateVisual:n,...i}=t;return{renderOptions:i,...n?{appearance:{family:{visual:n}}}:{}}},layout:e=>{const t=e.familyAppearance?.visual;const n=Ar(e.source.frontmatter);const i=_f(e.source.familyText);Gm(i);return mt(ux(i,{...e.renderOptions,...e.styleFace?{styleFace:e.styleFace}:{},...t?{stateVisual:t}:{},...n?{diagramTitle:n}:{}}))},projectPositioned:ft(fy),lowerScene:ht(Qy)};var kK={disableMulticolor:ct,sectionFills:mf,sectionColours:mf};var qO=e=>bt("timeline",e,kK);var lt={paddingX:32,paddingY:28,titleFontSize:18,titleFontWeight:600,titleGap:24,titleWrapWidth:420,sectionHeaderHeight:24,sectionFontSize:12,sectionFontWeight:600,sectionHeaderPadX:12,sectionHeaderGap:14,sectionWrapWidth:168,sectionPadX:18,sectionPadBottom:18,sectionGap:28,columnGap:24,pillFontSize:12,pillFontWeight:600,pillWrapWidth:116,pillPadX:12,pillPadY:8,pillMinWidth:72,railToPillGap:22,railToEventsGap:28,markerRadius:8,eventFontSize:12,eventFontWeight:400,eventWrapWidth:148,eventPadX:14,eventPadY:10,eventMinWidth:128,eventGap:10};var XO=36;var m1={nodeLabelFontSize:lt.eventFontSize,edgeLabelFontSize:lt.pillFontSize,groupHeaderFontSize:lt.sectionFontSize,nodeLabelFontWeight:lt.eventFontWeight,edgeLabelFontWeight:lt.pillFontWeight,groupHeaderFontWeight:lt.sectionFontWeight,nodePaddingX:lt.eventPadX,nodePaddingY:lt.eventPadY,nodeCornerRadius:0,nodeLineWidth:et.outerBox,edgeLineWidth:1.5,groupCornerRadius:0,groupPaddingX:lt.sectionPadX,groupPaddingY:lt.sectionPadBottom,groupLabelPaddingX:lt.sectionHeaderPadX,groupLineWidth:et.outerBox};var CK={pill:lt.pillWrapWidth,event:lt.eventWrapWidth,pillMinWidth:lt.pillMinWidth,eventMinWidth:lt.eventMinWidth};function VO(e,t={},n){const i=Xe(t,m1,n);const r=e.direction==="TD";const o=(I,D)=>r?D:I;const s=(I,D)=>r?I:D;const a=e.sections.some(I=>!!I.label);const l=e.sections.length>1||a;let c=a?Math.max(lt.sectionHeaderHeight,i.groupHeaderFontSize+i.groupPaddingY):0;const d=l?i.groupPaddingX:0;const u=e.title?_e(e.title,{display:"literal",transform:i.groupTextTransform,fontSize:lt.titleFontSize,fontWeight:lt.titleFontWeight,letterSpacing:i.groupLetterSpacing,maxWidth:lt.titleWrapWidth}):void 0;const f=u?.text;const h=u;let m=UO(e,i,CK,r);const p=t.timeline?.maxWidth;if(!r&&typeof p==="number"&&Number.isFinite(p)&&p>0){const I=PK(m,d,l);const D=m.reduce((B,Y)=>B+Y.periods.length,0);if(I>p&&D>0){const B=m.reduce((O,N)=>O+N.periods.reduce((H,j)=>H+j.mainExtent,0),0);const Y=Math.max(XO+i.nodePaddingX*2,(p-(I-B))/D);const W=Math.max(XO,Y-i.nodePaddingX*2);m=UO(e,i,{pill:Math.min(lt.pillWrapWidth,W),event:Math.min(lt.eventWrapWidth,W),pillMinWidth:Math.min(lt.pillMinWidth,Y),eventMinWidth:Math.min(lt.eventMinWidth,Y)},r)}}c=Math.max(c,...m.map(I=>I.block?I.block.height+i.groupPaddingY:0));const g=Math.max(0,...m.flatMap(I=>I.periods.map(D=>s(D.pillWidth,D.pillHeight))));let y=lt.paddingY;if(h){y+=h.height;y+=lt.titleGap}const b=c+(a?lt.sectionHeaderGap:0);const S=r?lt.paddingX:y;const x=S+(r?l?d:0:b);const k=x+g+lt.railToPillGap;const w=k+lt.railToEventsGap;const C=r?b:0;let R=r?y:lt.paddingX;const M=[];let P=k+lt.markerRadius;for(let I=0;I<e.sections.length;I++){const D=e.sections[I];const B=m[I];const Y=R;const W=C+B.innerMain+d*2;const O=R+C+d+(B.innerMain-B.runMain)/2;let N=O;const H=[];let j=k+lt.markerRadius;for(let q=0;q<D.periods.length;q++){const X=D.periods[q];const V=B.periods[q];const ee=N+V.mainExtent/2;let re=w;const U=X.events.map((Q,K)=>{const Z=V.events[K];const se=ee-o(Z.width,Z.height)/2;const oe={id:Q.id,sectionId:D.id,periodId:X.id,periodLabel:V.label,text:Z.text,block:Z.block,x:r?re:se,y:r?se:re,width:Z.width,height:Z.height};re+=s(Z.width,Z.height)+lt.eventGap;return oe});const te=k+lt.markerRadius;const J=U.length>0?w-10:k+16;const ae=ee-o(V.pillWidth,V.pillHeight)/2;H.push({id:X.id,sectionId:D.id,label:V.label,block:V.block,centerX:r?x+V.pillWidth/2:ee,markerX:r?k:ee,markerY:r?ee:k,pillX:r?x:ee-V.pillWidth/2,pillY:r?ae:x,pillWidth:V.pillWidth,pillHeight:V.pillHeight,stem:r?{x1:te,y1:ee,x2:J,y2:ee}:{x1:ee,y1:te,x2:ee,y2:J},events:U});if(U.length>0){const Q=U[U.length-1];j=Math.max(j,r?Q.x+Q.width:Q.y+Q.height)}N+=V.mainExtent+lt.columnGap}j+=i.groupPaddingY;P=Math.max(P,j);M.push({id:D.id,label:B.label,block:B.block,x:r?S:Y,y:r?Y:S,width:r?j-S:W,height:r?W:j-S,framed:l,headerHeight:c,periods:H});R+=W;if(I<e.sections.length-1){R+=l?lt.sectionGap:lt.columnGap}}const E=R+(r?lt.paddingY:lt.paddingX);const v=P+(r?lt.paddingX:lt.paddingY);const L=Math.max(r?v:E,h?h.width+2*lt.paddingX:0);const T=r?E:v;const A=M.flatMap(I=>I.periods);const $=I=>r?I.markerY:I.centerX;const _=A.length>0?$(A[0]):r?y:lt.paddingX;const z=A.length>0?$(A[A.length-1]):E-(r?lt.paddingY:lt.paddingX);const F=_===z?_-42:_;const G=_===z?z+42:z;for(const I of M)for(const D of I.periods)for(const B of D.events){B.labelX=B.x+i.nodePaddingX}return{width:L,height:T,title:f?{text:f,block:u,x:L/2,y:lt.paddingY+h.height/2}:void 0,accessibilityTitle:e.accessibilityTitle,accessibilityDescription:e.accessibilityDescription,rail:r?{x1:k,y1:F,x2:k,y2:G}:{x1:F,y1:k,x2:G,y2:k},sections:M}}function UO(e,t,n,i){const r=(o,s)=>i?s:o;return e.sections.map(o=>{const s=o.label?_e(o.label,{display:"literal",transform:t.groupTextTransform,fontSize:t.groupHeaderFontSize,fontWeight:t.groupHeaderFontWeight,letterSpacing:t.groupLetterSpacing,fontFamily:t.groupFont,maxWidth:lt.sectionWrapWidth}):void 0;const a=s?.text;const l=o.periods.map(f=>{const h=_e(f.label,{display:"literal",transform:t.edgeTextTransform,fontSize:t.edgeLabelFontSize,fontWeight:t.edgeLabelFontWeight,letterSpacing:t.edgeLetterSpacing,maxWidth:n.pill});const m=h.text;const p=Math.max(n.pillMinWidth,h.width+t.nodePaddingX*2);const g=h.height+t.nodePaddingY*2;const y=f.events.map(S=>{const x=_e(S.text,{display:"literal",transform:t.nodeTextTransform,fontSize:t.nodeLabelFontSize,fontWeight:t.nodeLabelFontWeight,letterSpacing:t.nodeLetterSpacing,maxWidth:n.event});const k=x.text;return{text:k,block:x,width:Math.max(n.eventMinWidth,x.width+t.nodePaddingX*2),height:x.height+t.nodePaddingY*2}});const b=Math.max(r(p,g),...y.map(S=>r(S.width,S.height)));return{label:m,block:h,pillWidth:p,pillHeight:g,mainExtent:b,events:y}});const c=l.reduce((f,h,m)=>{const p=m===0?0:lt.columnGap;return f+p+h.mainExtent},0);const d=a?s.width+t.groupLabelPaddingX*2:0;const u=i?c:Math.max(c,d);return{label:a,block:s,headerWidth:d,runMain:c,innerMain:u,periods:l}})}function PK(e,t,n){let i=lt.paddingX;for(let r=0;r<e.length;r++){i+=e[r].innerMain+t*2;if(r<e.length-1)i+=n?lt.sectionGap:lt.columnGap}return i+lt.paddingX}var Ix={titleFontSize:18,titleFontWeight:600,sectionFontSize:12,sectionFontWeight:600,pillFontSize:12,pillFontWeight:600,eventFontSize:12,eventFontWeight:400,markerOuterRadius:8,markerInnerRadius:4.5};function EK(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=r.familyAppearance;if(!l)throw new Error("Timeline rendering requires request-boundary family appearance resolution");const c=l.timelineConfig;const d=[];const u=Xe(o,m1,r.styleFace);const f=l.familyPalettes;const h=RK(u,i,f);const m=vK(u,h);const p=n.accessibilityTitle??n.title?.text.replace(/\n+/g," ");const g=n.accessibilityDescription;const y=!c.disableMulticolor;const b=y&&n.sections.some(P=>Boolean(P.label));const S=`tl-${mi(n.width,n.height,n.sections.map(P=>P.periods.length).join(","))}`;const x=`${S}-title`;const k=`${S}-desc`;const w=Mi(p,g,x,k);const C=[Ot(n.width,n.height,i,a,w),Dt(s,false,i.shadow,i.embedFontImport)];const R=Zt(i);if(R)C.push(`<defs>${R}</defs>`);d.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false},C.join("\n")));if(p){d.push(e.documentContent({id:"a11y-title",role:"chrome",nonPaint:"accessibility"},`<title id="${x}">${It(p)}</title>`))}if(g){d.push(e.documentContent({id:"a11y-desc",role:"chrome",nonPaint:"accessibility"},`<desc id="${k}">${It(g)}</desc>`))}for(let P=0;P<n.sections.length;P++){const E=n.sections[P];const v=b?P:0;if(E.framed){d.push(TK(e,E,v,f,u,m))}}d.push(e.shape({id:"rail",role:"rail",geometry:{kind:"line",x1:n.rail.x1,y1:n.rail.y1,x2:n.rail.x2,y2:n.rail.y2},paint:m.rail,attributes:{className:"timeline-rail"}}));let M=0;for(let P=0;P<n.sections.length;P++){const E=n.sections[P];const v=b?P:void 0;for(const L of E.periods){const T=v??(y?M++:0);d.push(LK(e,L,E.label,T,f,u,m))}}if(n.title){d.push(e.text({id:"title",role:"title",text:n.title.text,block:n.title.block,x:n.title.x,y:n.title.y,fontSize:Ix.titleFontSize,fontWeight:Ix.titleFontWeight,display:"literal",anchor:"middle",paint:m.title,attributes:Fx("timeline-title")}))}d.push(e.documentClose());return{family:"timeline",width:n.width,height:n.height,colors:i,transparent:a,parts:d}}function RK(e,t,n){const i=e.nodeTextColor??"var(--tl-label, var(--_text-muted))";if(e.nodeTextColor!==void 0||n.some(o=>o.label!=="var(--_text)"))return i;const r=yi("var(--_text)",e.nodeFillColor??"var(--_node-fill)",t);return r==="var(--_text)"?i:r}function vK(e,t){return{title:{fill:e.groupTextColor??e.nodeTextColor??"var(--_text)"},rail:{stroke:e.edgeStrokeColor??"var(--_line)",strokeWidth:String(e.lineWidth),strokeLinecap:"round"},sectionBg:{fill:e.groupFillColor??"var(--tl-section-bg, color-mix(in srgb, var(--_node-fill) 88%, var(--bg)))",stroke:e.groupBorderColor??"var(--tl-line, var(--_node-stroke))",strokeWidth:String(e.groupLineWidth)},sectionBand:{fill:e.groupHeaderFillColor??"var(--tl-section-band, color-mix(in srgb, var(--_arrow) 8%, var(--bg)))",stroke:e.groupBorderColor??"var(--tl-line, var(--_node-stroke))",strokeWidth:String(e.groupLineWidth)},sectionLabel:{fill:e.groupTextColor??"var(--tl-label, var(--_text-sec))"},stem:{stroke:e.edgeStrokeColor??"var(--tl-line, color-mix(in srgb, var(--_arrow) 32%, var(--_line)))",strokeWidth:String(Math.max(1,e.lineWidth*.75)),strokeDasharray:"3 4"},markerRing:{fill:"var(--bg)",stroke:e.edgeStrokeColor??"var(--tl-line, var(--_arrow))",strokeWidth:"1.5"},markerCore:{fill:e.edgeStrokeColor??"var(--tl-accent, var(--_arrow))"},pill:{fill:e.nodeFillColor??"var(--tl-pill-fill, color-mix(in srgb, var(--_arrow) 7%, var(--bg)))",stroke:e.nodeBorderColor??"var(--tl-pill-stroke, color-mix(in srgb, var(--_arrow) 20%, var(--bg)))",strokeWidth:String(e.nodeLineWidth)},periodText:{fill:e.nodeTextColor??"var(--tl-label, var(--_text))"},eventCard:{fill:e.nodeFillColor??"var(--tl-event-fill, var(--_node-fill))",stroke:e.nodeBorderColor??"var(--tl-line, var(--_node-stroke))",strokeWidth:String(e.nodeLineWidth)},eventText:{fill:t}}}function Fx(e){return{className:e,data:{"literal-text":"true"}}}function TK(e,t,n,i,r,o){const s=t.label??t.id;const a=t.label?` data-label="${hn(t.label)}"`:"";const l=KO(n,i);const c=[];c.push({indent:2,node:e.shape({id:`section-bg:${s}`,role:"section",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:r.groupCornerRadius,ry:r.groupCornerRadius},paint:o.sectionBg,attributes:{className:"timeline-section-bg"}})});if(t.headerHeight>0){const d=Er(t.x,t.y,t.width,t.headerHeight,r.groupCornerRadius);c.push({indent:2,node:e.shape({id:`section-band:${s}`,role:"group-header",geometry:{kind:"path",d},paint:o.sectionBand,attributes:{className:"timeline-section-band"}})});if(t.label){c.push({indent:2,node:e.text({id:`section-label:${s}`,role:"group-header",text:t.label,block:t.block,x:t.x+r.groupLabelPaddingX,y:t.y+t.headerHeight/2,fontSize:r.groupHeaderFontSize,fontWeight:r.groupHeaderFontWeight,letterSpacing:r.groupLetterSpacing,display:"literal",anchor:"start",paint:o.sectionLabel,attributes:Fx("timeline-section-label")})})}}return e.group({id:`section:${s}`,role:"section",open:`<g class="timeline-section" data-id="${Ye(t.id)}"${a}${l}>`,close:"</g>",children:c,channels:{category:s}})}function LK(e,t,n,i,r,o,s){const a=n?` data-section="${Ye(n)}"`:"";const l=KO(i,r);const c=[];c.push({indent:2,node:e.shape({id:`period-stem:${t.id}`,role:"period",geometry:{kind:"line",x1:t.stem.x1,y1:t.stem.y1,x2:t.stem.x2,y2:t.stem.y2},paint:s.stem,attributes:{className:"timeline-stem"}})});c.push({indent:2,node:e.shape({id:`period-pill:${t.id}`,role:"period",geometry:{kind:"rect",x:t.pillX,y:t.pillY,width:t.pillWidth,height:t.pillHeight,rx:o.cornerRadius??0,ry:o.cornerRadius??0},paint:s.pill,attributes:{className:"timeline-period-pill"}})});c.push({indent:2,node:e.text({id:`period-label:${t.id}`,role:"label",text:t.label,block:t.block,x:t.centerX,y:t.pillY+t.pillHeight/2,fontSize:o.edgeLabelFontSize,fontWeight:o.edgeLabelFontWeight,letterSpacing:o.edgeLetterSpacing,display:"literal",anchor:"middle",paint:s.periodText,attributes:Fx("timeline-period-text")})});c.push({indent:2,node:e.shape({id:`period-marker-ring:${t.id}`,role:"period",geometry:{kind:"circle",cx:t.markerX,cy:t.markerY,r:Ix.markerOuterRadius},paint:s.markerRing,attributes:{className:"timeline-marker-ring"}})});c.push({indent:2,node:e.shape({id:`period-marker-core:${t.id}`,role:"period",geometry:{kind:"circle",cx:t.markerX,cy:t.markerY,r:Ix.markerInnerRadius},paint:s.markerCore,attributes:{className:"timeline-marker-core"}})});for(let d=0;d<t.events.length;d++){c.push({indent:0,node:AK(e,t.events[d],n,i,r,o,s)})}return e.group({id:`period:${t.id}`,role:"period",open:`<g class="timeline-period" data-id="${Ye(t.id)}" data-label="${hn(t.label)}"${a}${l}>`,close:"</g>",children:c})}function AK(e,t,n,i,r,o,s){const a=n?` data-section="${Ye(n)}"`:"";const l=` data-family="${i%r.length}"`;const c=`event:${t.id}`;const d=e.shape({id:c,role:"event",geometry:{kind:"rect",x:t.x,y:t.y,width:t.width,height:t.height,rx:o.cornerRadius??0,ry:o.cornerRadius??0},paint:s.eventCard,attributes:{className:"timeline-event-card"}});const u=e.text({id:`${c}:label`,role:"label",text:t.text,block:t.block,x:t.labelX??t.x+o.nodePaddingX,y:t.y+t.height/2,fontSize:o.nodeLabelFontSize,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,display:"literal",anchor:"start",paint:s.eventText,attributes:Fx("timeline-event-text")});return e.group({id:`${c}:group`,role:"event",open:`<g class="timeline-event" data-id="${Ye(t.id)}" data-period="${Ye(t.periodLabel)}"${a}${l}>`,close:"</g>",children:[{indent:2,node:d},{indent:2,node:u}]})}function KO(e,t){const n=e%t.length;const i=t[n];const r=[`--tl-accent:${i.accent}`,`--tl-fill:${i.fill}`,`--tl-label:${i.label}`,`--tl-line:${i.line}`,`--tl-section-bg:${hu(i.fill,"var(--bg)",6)}`,`--tl-section-band:${hu(i.fill,"var(--bg)",12)}`,`--tl-pill-fill:${hu(i.fill,"var(--bg)",11)}`,`--tl-pill-stroke:${hu(i.fill,i.line,36)}`,`--tl-event-fill:${hu(i.fill,"var(--_node-fill)",16)}`].join(";");return` data-family="${n}" style="${Ye(r)}"`}function JO(e={}){const t=e.mermaidConfig?.timeline??{};return{timelineConfig:t,familyPalettes:IK(t,e.mermaidConfig?.themeVariables)}}function IK(e,t){const n=e.sectionFills??[];const i=e.sectionColours??[];return Array.from({length:12},(r,o)=>{const s=n[o%Math.max(n.length,1)]??p1(t,"cScale",o);const a=s??"var(--_node-fill)";const l=i[o%Math.max(i.length,1)]??p1(t,"cScaleLabel",o)??"var(--_text)";const c=p1(t,"cScaleInv",o)??(s?hu(a,"var(--_line)",48):"var(--_line)");const d=s??"var(--_arrow)";return{accent:d,fill:a,label:l,line:c}})}function hu(e,t,n){return`color-mix(in srgb, ${e} ${n}%, ${t})`}function p1(e,t,n){if(!e)return void 0;const i=e[`${t}${n}`];return typeof i==="string"&&i.length>0?i:void 0}var QO=gt(EK);var lNe={configDiagnostics:qO,normalizeRequest:e=>({appearance:{family:{...JO(e.renderOptions)}}}),layout:e=>mt(VO(Tn(hN(e.source.familyLines,e.source.accessibility),e.source.frontmatter),e.renderOptions,e.styleFace)),projectPositioned:ft(GI),lowerScene:ht(QO)};var FK={width:Kt,height:Kt,useMaxWidth:ct,useWidth:Kt,titleFontSize:Kt,titlePadding:jt,chartOrientation:Ws("vertical","horizontal"),plotReservedSpacePercent:wn(0,100,false),showDataLabel:ct,showDataLabelOutsideBar:ct,showTitle:ct,showLegend:ct,legendFontSize:Kt,legendPadding:jt,xAxis:an("an axis-config object",e=>Boolean(e)&&typeof e==="object"&&!Array.isArray(e)),yAxis:an("an axis-config object",e=>Boolean(e)&&typeof e==="object"&&!Array.isArray(e))};var NK={showLabel:ct,labelFontSize:Kt,labelPadding:jt,labelRotation:Op,showTitle:ct,titleFontSize:Kt,titlePadding:jt,showTick:ct,tickLength:jt,tickWidth:Kt,showAxisLine:ct,axisLineWidth:Kt};var ZO=e=>{const t=bt("xychart",e,FK);const n=Kr(e.root,e.config.section);if(!n)return t;const i=(r,o)=>{t.push({code:"INEFFECTIVE_CONFIG",field:r,message:`${r} must be ${o}; the invalid value has no effect.`})};for(const r of["xAxis","yAxis"]){const o=n[r];if(!o||typeof o!=="object"||Array.isArray(o))continue;const s=o;for(const a of Object.keys(s).sort()){const l=NK[a];if(!l)i(`xyChart.${r}.${a}`,"a documented axis-config field");else if(!l.valid(s[a]))i(`xyChart.${r}.${a}`,l.expected);else if(a==="labelRotation")t.push({code:"INEFFECTIVE_CONFIG",field:`xyChart.${r}.${a}`,message:`xyChart ${r}.${a} is accepted for Mermaid compatibility but has no effect on this renderer.`})}}return t};var $K=3;var Nx={titleWeight:500,axisTitleWeight:400,labelWeight:400,dotRadius:by,lineWidth:3};function _K(e,t){const{positioned:n,colors:i,resolved:r}=t;const o=r.renderOptions;const s=i.font??"Inter";const a=o.transparent??false;const l=o.interactive??false;const c=[];const d=Xe(o,tM,r.styleFace);const u=DK(n,d);const f=Boolean(n.theme.plotColorPalette?.length);const h=Math.max(0,...n.bars.map(T=>T.colorIndex),...n.lines.map(T=>T.colorIndex));const m=zK(n);const p=Ot(n.width,n.height,i,a,m.openTag).replace("<svg ",`<svg data-xychart-colors="${h}" `);const{style:g,defs:y}=BK(n,l,i.accent,i.bg);c.push(e.documentOpen({id:"prelude",width:n.width,height:n.height,colors:i,transparent:a,font:s,hasMonoFont:false,extraCss:g},p+"\n"+Dt(s,false,i.shadow,i.embedFontImport)+"\n"+g));const b=Zt(i);if(b)c.push(e.definitions({id:"shadow-defs"},`<defs>${b}</defs>`));if(y)c.push(e.definitions({id:"defs"},y));if(m.title)c.push(e.documentContent({id:"acc-title",role:"chrome",nonPaint:"accessibility"},m.title));if(m.description)c.push(e.documentContent({id:"acc-desc",role:"chrome",nonPaint:"accessibility"},m.description));const S={stroke:u.gridStroke,strokeWidth:"1",...d.edgeStrokeColor?{opacity:"0.25"}:{}};n.gridLines.forEach((T,A)=>{c.push(e.shape({id:`grid:y:${A}`,role:"grid",geometry:{kind:"line",x1:Et(T.x1),y1:Et(T.y1),x2:Et(T.x2),y2:Et(T.y2)},paint:S,attributes:{className:"xychart-grid"}}))});eB(e,c,n.xAxis,"x",u.xAxisLineColor,u.xAxisTickColor);eB(e,c,n.yAxis,"y",u.yAxisLineColor,u.yAxisTickColor);const x=Math.max(0,...n.bars.map(T=>Math.abs(T.value)),...n.lines.flatMap(T=>T.points.map(A=>Math.abs(A.value))));const k=T=>x>0?T/x:void 0;const w=[];const C=new Map;const R=nB(n,i.accent,i.bg);const M=new Map;const P=new Map;for(const T of n.bars){const A=C.get(T.seriesIndex)??0;C.set(T.seriesIndex,A+1);const $=`bar:${T.seriesIndex}:${T.label??A}`;const _={category:`bar-${T.seriesIndex}`,value:k(T.value)};const z=st(r.styleFace,"bar",_,{includeFallback:false});const F=`var(--xychart-color-${T.colorIndex})`;const G=f?F:z?.fillColor??F;P.set(_.category,G);M.set(T,f?R.concrete(T.colorIndex):z?.fillColor??R.concrete(T.colorIndex));const I=z?.strokeColor??z?.borderColor;const D=z?.lineWidth;c.push(e.shape({id:$,role:"bar",geometry:{kind:"rect",x:Et(T.x),y:Et(T.y),width:Et(T.width),height:Et(T.height)},paint:{fill:G,stroke:I??"none",...D!==void 0?{strokeWidth:String(D)}:{}},channels:_,attributes:{className:`xychart-bar xychart-color-${T.colorIndex}`,data:{value:String(T.value),...T.label?{label:T.label}:{}}}}));if(l){const B=Zl(T.value);const Y=T.label?`${T.label}: ${B}`:B;const W={id:$,role:"bar"};w.push(e.group({id:`tooltip:${$}`,role:"chrome",owner:W,open:'<g class="xychart-bar-group">',close:"</g>",join:"",children:[{indent:0,node:e.shape({id:`${$}:hit`,role:"chrome",owner:W,geometry:{kind:"rect",x:Et(T.x),y:Et(T.y),width:Et(T.width),height:Et(T.height)},paint:{fill:"transparent"}})},{indent:0,node:e.documentContent({id:`${$}:title`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${It(Y)}</title>`)},{indent:0,node:Ec(e,"xychart",T.tooltip,`${$}:tooltip`,W)}]}))}}for(const T of n.lines){const A={category:`line-${T.seriesIndex}`};const $=st(r.styleFace,"series",A,{includeFallback:false});const _=`var(--xychart-color-${T.colorIndex})`;const z=f?_:$?.strokeColor??$?.borderColor??_;P.set(A.category,z);if(T.points.length<2)continue;const F=WK(T.points);const G=$?.lineWidth??d.lineWidth;c.push(e.connector({id:`series:line-${T.seriesIndex}`,role:"series",geometry:{kind:"path",d:F,points:T.points},lineStyle:"solid",paint:{stroke:z,strokeWidth:String(G),strokeLinecap:"round",strokeLinejoin:"round"},channels:A,attributes:{className:`xychart-line xychart-color-${T.colorIndex}`}}))}const E=(T,A,$)=>{const _=`line-${T}`;const z=st(r.styleFace,"point",{category:_,value:k($)},{includeFallback:false});const F=`var(--xychart-color-${A})`;return{fill:f?F:z?.fillColor??P.get(_)??F,stroke:z?.strokeColor??z?.borderColor??"var(--bg)",strokeWidth:String(z?.lineWidth??2)}};for(const T of n.lines){T.points.forEach((A,$)=>{if(A.textLabel===void 0)return;const _=A.textPosition;const z=_?.placement??(n.horizontal?"right":"above");const F=_?.x??A.x+(n.horizontal?8:0);const G=_?.y??A.y+(n.horizontal?4:-8);const I=_?.anchor??(n.horizontal?"start":"middle");c.push(e.shape({id:`point-label-dot:${T.seriesIndex}:${$}`,role:"point",geometry:{kind:"circle",cx:Et(A.x),cy:Et(A.y),r:Nx.dotRadius},paint:E(T.seriesIndex,T.colorIndex,A.value),channels:{category:`line-${T.seriesIndex}`,value:k(A.value)},attributes:{className:`xychart-dot xychart-color-${T.colorIndex}`,data:{value:String(A.value)}}}));c.push(e.text({id:`point-label:${T.seriesIndex}:${$}`,role:"label",text:A.textBlock?.text??A.textLabel,block:A.textBlock,x:Et(F),y:Et(G),fontSize:12,fontWeight:d.nodeLabelFontWeight,letterSpacing:d.nodeLetterSpacing,display:"literal",anchor:I,baselineShift:_?.35:0,paint:{fill:P.get(`line-${T.seriesIndex}`)??`var(--xychart-color-${T.colorIndex})`},channels:{category:`line-${T.seriesIndex}`,value:k(A.value)},attributes:{className:`xychart-point-label xychart-color-${T.colorIndex}`,data:{"label-position":z}}}))})}const v=[];if(l){for(const T of n.lines){T.points.forEach((A,$)=>{const _=`point:line-${T.seriesIndex}:${A.label??$}`;const z=Zl(A.value);const F=A.label?`${A.label}: ${z}`:z;v.push(e.group({id:`point-group:line-${T.seriesIndex}:${A.label??$}`,role:"chrome",open:`<g class="xychart-dot-group">`,close:`</g>`,join:"",children:[{node:e.shape({id:`hit:${_}`,role:"chrome",owner:{id:_,role:"point"},geometry:{kind:"circle",cx:Et(A.x),cy:Et(A.y),r:Nx.dotRadius*3},paint:{fill:"transparent"},attributes:{className:"xychart-hit"}}),indent:0},{node:e.shape({id:_,role:"point",geometry:{kind:"circle",cx:Et(A.x),cy:Et(A.y),r:Nx.dotRadius},paint:E(T.seriesIndex,T.colorIndex,A.value),channels:{category:`line-${T.seriesIndex}`,value:k(A.value)},attributes:{className:`xychart-dot xychart-color-${T.colorIndex}`,data:{value:String(A.value),...A.label?{label:A.label}:{}}}}),indent:0},{node:e.documentContent({id:`title:${_}`,role:"chrome",nonPaint:"interaction-metadata"},`<title>${It(F)}</title>`),indent:0},{node:Ec(e,"xychart",A.tooltip,`tooltip:${_}`,{id:_,role:"point"}),indent:0}]}))})}}const L=new Map;for(const T of n.dataLabels){const A=T.block?.text??pi(T.text,d.nodeTextTransform);const $=L.get(T.bar.seriesIndex)??0;L.set(T.bar.seriesIndex,$+1);const _=n.theme.dataLabelColor===void 0&&T.placement==="inside"?OK(M.get(T.bar)):void 0;const z=n.theme.dataLabelColor??_??u.labelColor;const F=T.placement==="inside"?M.get(T.bar)??"var(--bg)":"var(--bg)";c.push(e.text({id:`label:bar:${T.bar.seriesIndex}:${T.bar.label??$}`,role:"label",text:A,block:T.block,x:Et(T.x),y:Et(T.y),fontSize:T.fontSize,fontWeight:d.nodeLabelFontWeight,letterSpacing:d.nodeLetterSpacing,display:"literal",anchor:T.anchor,...T.dominantBaseline?{dominantBaseline:T.dominantBaseline}:{},baselineShift:0,paint:{fill:z,stroke:F,strokeWidth:String($K),strokeLinejoin:"round",paintOrder:"stroke"},..._?{pageFill:u.labelColor}:{},channels:{category:`bar-${T.bar.seriesIndex}`,value:k(T.bar.value)},attributes:{className:"xychart-data-label",data:{"literal-text":"true"}}}))}tB(e,c,n.xAxis.ticks,n.xAxis.config.labelFontSize,"x",d,u.xAxisLabelColor);tB(e,c,n.yAxis.ticks,n.yAxis.config.labelFontSize,"y",d,u.yAxisLabelColor);if(n.xAxis.title){const T=n.xAxis.title;const A=T.block?.text??pi(T.text,d.edgeTextTransform);const $=T.rotate?{kind:"rotate",angle:T.rotate,cx:T.x,cy:T.y}:void 0;c.push(e.text({id:"axis:x:title",role:"axis",text:A,block:T.block,x:T.x,y:T.y,fontSize:n.xAxis.config.titleFontSize,fontWeight:d.edgeLabelFontWeight,letterSpacing:d.edgeLetterSpacing,display:"literal",anchor:"middle",paint:{fill:u.xAxisTitleColor},transform:$,attributes:{className:"xychart-axis-title xychart-x-axis-title"}}))}if(n.yAxis.title){const T=n.yAxis.title;const A=T.block?.text??pi(T.text,d.edgeTextTransform);const $=T.rotate?{kind:"rotate",angle:T.rotate,cx:T.x,cy:T.y}:void 0;c.push(e.text({id:"axis:y:title",role:"axis",text:A,block:T.block,x:T.x,y:T.y,fontSize:n.yAxis.config.titleFontSize,fontWeight:d.edgeLabelFontWeight,letterSpacing:d.edgeLetterSpacing,display:"literal",anchor:"middle",paint:{fill:u.yAxisTitleColor},transform:$,attributes:{className:"xychart-axis-title xychart-y-axis-title"}}))}if(n.title){const T=n.title.text;c.push(e.text({id:"title",role:"title",text:T,block:n.title.block,x:n.title.x,y:n.title.y,fontSize:n.config.titleFontSize,fontWeight:d.groupHeaderFontWeight,letterSpacing:d.groupLetterSpacing,display:"literal",anchor:"middle",paint:{fill:u.titleColor},attributes:{className:"xychart-title"}}))}if(n.legend.length>0){const T=[];for(const A of n.legend){const $=A.y+Math.max(uo,A.block?.height??0)/2;if(A.type==="bar"){T.push({node:e.shape({id:`legend:swatch:${A.colorIndex}`,role:"legend",geometry:{kind:"rect",x:Et(A.x),y:Et(A.y),width:uo,height:uo,rx:2,ry:2},paint:{fill:P.get(`bar-${A.seriesIndex}`)??`var(--xychart-color-${A.colorIndex})`},channels:{category:`bar-${A.seriesIndex}`},attributes:{className:"xychart-legend-swatch"}}),indent:2})}else{T.push({node:e.shape({id:`legend:swatch:${A.colorIndex}`,role:"legend",geometry:{kind:"line",x1:Et(A.x),y1:Et($),x2:Et(A.x+uo),y2:Et($)},paint:{stroke:P.get(`line-${A.seriesIndex}`)??`var(--xychart-color-${A.colorIndex})`,strokeWidth:String(Nx.lineWidth),strokeLinecap:"round"},channels:{category:`line-${A.seriesIndex}`},attributes:{className:"xychart-legend-swatch"}}),indent:2});T.push({node:e.shape({id:`legend:dot:${A.colorIndex}`,role:"legend",geometry:{kind:"circle",cx:Et(A.x+uo/2),cy:Et($),r:2.5},paint:{fill:P.get(`line-${A.seriesIndex}`)??`var(--xychart-color-${A.colorIndex})`,stroke:"var(--bg)",strokeWidth:"1"},channels:{category:`line-${A.seriesIndex}`},attributes:{className:"xychart-legend-dot"}}),indent:2})}const _=A.block?.text??pi(A.label,d.nodeTextTransform);const z=A.x+uo+mh;T.push({node:e.text({id:`legend:label:${A.colorIndex}`,role:"legend",text:_,block:A.block,x:Et(z),y:Et($),fontSize:n.config.legendFontSize,fontWeight:d.nodeLabelFontWeight,letterSpacing:d.nodeLetterSpacing,display:"literal",anchor:"start",dominantBaseline:"middle",baselineShift:0,paint:{fill:u.legendTextColor},attributes:{className:"xychart-legend-label"}}),indent:2})}c.push(e.group({id:"legend",role:"legend",open:'<g class="xychart-legend">',close:"</g>",children:T}))}for(const T of w)c.push(T);for(const T of v)c.push(T);c.push(e.documentClose());return{family:"xychart",width:n.width,height:n.height,colors:i,transparent:a,parts:c}}function eB(e,t,n,i,r,o){if(n.config.showAxisLine){t.push(e.shape({id:`axis:${i}:line`,role:"axis",geometry:{kind:"line",x1:Et(n.line.x1),y1:Et(n.line.y1),x2:Et(n.line.x2),y2:Et(n.line.y2)},paint:{stroke:r,strokeWidth:String(n.config.axisLineWidth)},attributes:{className:`xychart-axis-line xychart-${i}-axis-line`}}))}if(!n.config.showTick)return;for(const s of n.ticks){t.push(e.shape({id:`axis:${i}:tick:${s.label}`,role:"axis",geometry:{kind:"line",x1:Et(s.x),y1:Et(s.y),x2:Et(s.tx),y2:Et(s.ty)},paint:{stroke:o,strokeWidth:String(n.config.tickWidth)},attributes:{className:`xychart-tick xychart-${i}-tick`}}))}}function tB(e,t,n,i,r,o,s){for(const a of n){const l=a.block?.text??pi(a.label,o.edgeTextTransform);const c=a.textAnchor==="end";t.push(e.text({id:`axis:${r}:label:${a.label}`,role:"axis",text:l,block:a.block,x:a.labelX,y:a.labelY,fontSize:i,fontWeight:o.nodeLabelFontWeight,letterSpacing:o.nodeLetterSpacing,display:"literal",anchor:a.textAnchor,...c?{dominantBaseline:"middle",baselineShift:0}:{},paint:{fill:s},attributes:{className:`xychart-label xychart-${r}-label`}}))}}function DK(e,t){const n=e.theme;return{gridStroke:t.edgeStrokeColor??"color-mix(in srgb, var(--fg) 14%, transparent)",titleColor:n.titleColor??t.groupTextColor??t.nodeTextColor??"var(--_text)",labelColor:t.nodeTextColor??"var(--_text)",xAxisLabelColor:n.xAxisLabelColor??t.nodeTextColor??"var(--_text)",yAxisLabelColor:n.yAxisLabelColor??t.nodeTextColor??"var(--_text)",xAxisTickColor:n.xAxisTickColor??t.groupTextColor??"var(--_text-sec)",yAxisTickColor:n.yAxisTickColor??t.groupTextColor??"var(--_text-sec)",xAxisLineColor:n.xAxisLineColor??t.edgeStrokeColor??"var(--_text-sec)",yAxisLineColor:n.yAxisLineColor??t.edgeStrokeColor??"var(--_text-sec)",xAxisTitleColor:n.xAxisTitleColor??t.edgeTextColor??t.nodeTextColor??"var(--_text)",yAxisTitleColor:n.yAxisTitleColor??t.edgeTextColor??t.nodeTextColor??"var(--_text)",legendTextColor:n.legendTextColor??t.nodeTextColor??"var(--_text)"}}function nB(e,t,n){const i=t??Zs;const r=e.theme.plotColorPalette;const o=Math.max(0,...e.bars.map(l=>l.colorIndex),...e.lines.map(l=>l.colorIndex));const s=Ji(o+1,{accent:i,bg:n});const a=l=>r&&r.length>0?r[l%r.length]:s[l];return{concrete:a,css:l=>!(r&&r.length>0)&&l===0&&s.length<=6&&s[0]===i?`var(--accent, ${Zs})`:a(l)}}function OK(e){const t=e===void 0?null:Vt(e);return t&&t[3]===1?Ho(Yn(t[0],t[1],t[2])):void 0}function BK(e,t,n,i){const r=new Set;for(const u of e.bars)r.add(u.colorIndex);for(const u of e.lines)r.add(u.colorIndex);const o=[];const s=nB(e,n,i);for(const u of[...r].sort((f,h)=>f-h)){o.push(` --xychart-color-${u}: ${s.css(u)};`)}const a=t?fu("xychart",["xychart-bar-group","xychart-dot-group"]):"";const l=o.length>0?`
|
|
45
|
-
svg {
|
|
46
|
-
${o.join("\n")}
|
|
47
|
-
}`:"";const c=e.theme.themeCss?`
|
|
48
|
-
${e.theme.themeCss}
|
|
49
|
-
`:"";const d=`<style>
|
|
50
|
-
.xychart-data-label { pointer-events: none; }${l}${a}${c}
|
|
51
|
-
</style>`;return{style:d,defs:""}}function WK(e){if(e.length===0)return"";let t=`M${$x(e[0].x)},${$x(e[0].y)}`;for(let n=1;n<e.length;n++){t+=` L${$x(e[n].x)},${$x(e[n].y)}`}return t}function Et(e){return Math.round(e*100)/100}function $x(e){return Et(e).toString()}function zK(e){const t=`mermaid-${GK(e)}`;const n=e.accessibility?.title?`chart-title-${t}`:void 0;const i=e.accessibility?.description?`chart-desc-${t}`:void 0;const r=e.config.useWidth??e.width;const o=e.config.useMaxWidth?"100%":String(r);const s=e.config.useMaxWidth?"100%":String(Math.round(e.height*(r/Math.max(1,e.width))));const a=e.config.useMaxWidth?`max-width:${r}px`:void 0;return{openTag:{width:o,height:s,style:a,attrs:{id:t,class:"xychart",role:n||i?"img":void 0,"aria-roledescription":"xychart","aria-labelledby":n,"aria-describedby":i}},title:e.accessibility?.title?`<title id="${n}">${It(e.accessibility.title)}</title>`:void 0,description:e.accessibility?.description?`<desc id="${i}">${It(e.accessibility.description)}</desc>`:void 0}}function GK(e){const t=[e.width,e.height,e.title?.text??"",e.accessibility?.title??"",e.accessibility?.description??"",e.bars.length,e.lines.length].join("|");let n=5381;for(let i=0;i<t.length;i++){n=(n<<5)+n^t.charCodeAt(i)}return Math.abs(n>>>0).toString(36)}var iB=gt(_K);var ONe={configDiagnostics:ZO,statementEnds:xM,normalizeRequest:e=>{const t=Ph(e.source.frontmatter);const n=Eh(e.source.frontmatter);return{familyConfig:{config:t},appearance:{...e.renderOptions.bg===void 0&&n.backgroundColor?{colors:{bg:n.backgroundColor}}:{},family:{theme:n}}}},layout:e=>{const t=e.familyConfig;const n=e.familyAppearance;const i=yM(Tn(xm(bN(e.source.familyLines),e.source.accessibility),e.source.frontmatter),t?.config??Ph({}),n?.theme??Eh({}));return mt(UI(i,e.renderOptions,e.styleFace),{injectAccessibility:false})},projectPositioned:ft(lF),lowerScene:ht(iB)};export{f7 as a,h7 as b,ym as c,ab as d,lb as e,cb as f,A7 as g,I7 as h,F7 as i,N7 as j,$7 as k,_7 as l,D7 as m,O7 as n,B7 as o,W7 as p,z7 as q,G7 as r,H7 as s,j7 as t,Y7 as u,q7 as v,X7 as w,U7 as x,V7 as y,K7 as z,J7 as A,Q7 as B,Z7 as C,eJ as D,tJ as E,nJ as F,iJ as G,rJ as H,oJ as I,sJ as J,aJ as K,lJ as L,cJ as M,dJ as N,uJ as O,kv as P,Cv as Q,QP as R,ZP as S,eE as T,nE as U,pa as V,go as W,Un as X,nP as Y,Dn as Z,dn as _,rP as $,zo as aa,EJ as ba,Qe as ca,g7 as da,hr as ea,fr as fa,vB as ga,vu as ha,kl as ia,Tu as ja,Wc as ka,yJ as la,xJ as ma,bJ as na,fb as oa,zc as pa,Tt as qa,Wt as ra,Gc as sa,vr as ta,qr as ua,El as va,Bu as wa,jb as xa,Yb as ya,As as za,Qb as Aa,ZW as Ba,Es as Ca,Ll as Da,qc as Ea,tS as Fa,Jm as Ga,Tn as Ha,Ar as Ia,OZ as Ja,sz as Ka,ya as La,bE as Ma,SE as Na,BZ as Oa,WZ as Pa,Hu as Qa,cz as Ra,ME as Sa,Xc as Ta,Sn as Ua,kt as Va,oS as Wa,pme as Xa,ph as Ya,Tre as Za,hf as _a,Dp as $a,rb as ab,UC as bb,OQ as cb,EW as db,BQ as eb,zm as fb,vn as gb,vW as hb,Fu as ib,LW as jb,Lt as kb,Gm as lb,Hm as mb,WQ as nb,zQ as ob,Ro as pb,Wp as qb,zs as rb,XH as sb,_re as tb,Ps as ub,Ve as vb,wm as wb,Pm as xb,Vl as yb,pf as zb,zre as Ab,VC as Bb,Qv as Cb,bw as Db,ZH as Eb,eT as Fb,ooe as Gb,n4 as Hb,i4 as Ib,o4 as Jb,Gp as Kb,cT as Lb,dT as Mb,mT as Nb,pT as Ob,m4 as Pb,yT as Qb,voe as Rb,xT as Sb,Yp as Tb,x4 as Ub,ST as Vb,Sd as Wb,Aoe as Xb,Ioe as Yb,qp as Zb,Xp as _b,Foe as $b,M4 as ac,Noe as bc,k4 as cc,$oe as dc,C4 as ec,_oe as fc,sb as gc,JC as hc,Rr as ic,ks as jc,Cs as kc,Up as lc,I4 as mc,Joe as nc,TT as oc,Qp as pc,_T as qc,Kl as rc,Nw as sc,$w as tc,cse as uc,eg as vc,Sf as wc,J4 as xc,tg as yc,dse as zc,yb as Ac,OJ as Bc,cP as Cc,uP as Dc,fP as Ec,BJ as Fc,Sm as Gc,Sse as Hc,wf as Ic,Dw as Jc,XT as Kc,aj as Lc,lj as Mc,KT as Nc,RX as Oc,Ow as Pc,Tme as Qc,hF as Rc,Cd as Sc,Ise as Tc,Ww as Uc,jJ as Vc,Xr as Wc,Gt as Xc,Rl as Yc,aa as Zc,xj as _c,zw as $c,NX as ad,mF as bd,Qs as cd,Kme as dd,ky as ed,zN as fd,fc as gd,Ey as hd,xh as id,Ka as jd,gF as kd,QN as ld,gi as md,iL as nd,qw as od,wj as pd,vf as qd,Hs as rd,Cf as sd,Pf as td,Ef as ud,Rf as vd,dL as wd,iae as xd,Ej as yd,Rj as zd,rae as Ad,vj as Bd,fL as Cd,qJ as Dd,Eb as Ed,AP as Fd,rW as Gd,oW as Hd,fQ as Id,hQ as Jd,mQ as Kd,NP as Ld,$P as Md,_P as Nd,uae as Od,ag as Pd,Aj as Qd,fae as Rd,Xw as Sd,pL as Td,Sae as Ud,Oa as Vd,Ba as Wd,wae as Xd,Lf as Yd,Af as Zd,_j as _d,EL as $d,so as ae,RL as be,$ae as ce,fg as de,cg as ee,Zw as fe,wL as ge,_ae as he,hg as ie,Dae as je,Kj as ke,TL as le,Jj as me,Qj as ne,dg as oe,ug as pe,Jl as qe,yF as re,rh as se,oh as te,sh as ue,q3 as ve,tfe as we,nfe as xe,hc as ye,kpe as ze,SF as Ae,UX as Be,Cpe as Ce,Ppe as De,IF as Ee,Epe as Fe,Rpe as Ge,i5 as He,WF as Ie,r5 as Je,vpe as Ke,PF as Le,Ni as Me,jae as Ne,Yae as Oe,qae as Pe,sY as Qe,mg as Re,lY as Se,tle as Te,n0 as Ue,BL as Ve,nle as We,Ff as Xe,r0 as Ye,a0 as Ze,bg as _e,kY as $e,Wa as af,CY as bf,YL as cf,wg as df,XL as ef,RY as ff,Mg as gf,ble as hf,KL as if,Sle as jf,vy as kf,h5 as lf,_pe as mf,YF as nf,XF as of,Wpe as pf,UF as qf,KF as rf,ZF as sf,eN as tf,Nm as uf,fa as vf,gQ as wf,Cg as xf,o2 as yf,zY as zf,$le as Af,GY as Bf,Eg as Cf,u2 as Df,Rg as Ef,f2 as Ff,h2 as Gf,KY as Hf,vg as If,Tg as Jf,m2 as Kf,p2 as Lf,Lg as Mf,Ag as Nf,g2 as Of,Ig as Pf,y2 as Qf,zle as Rf,x2 as Sf,Fg as Tf,$f as Uf,Ng as Vf,b2 as Wf,S2 as Xf,w2 as Yf,k2 as Zf,C2 as _f,P2 as $f,za as ag,Rle as bg,i2 as cg,Tle as dg,jm as eg,F2 as fg,_f as gg,dq as hg,$2 as ig,Sq as jg,yce as kg,y0 as lg,Ad as mg,ha as ng,Rn as og,Rb as pg,GP as qg,PQ as rg,SW as sg,tr as tg,Tb as ug,jP as vg,Om as wg,IQ as xg,YP as yg,XP as zg,FQ as Ag,NQ as Bg,X2 as Cg,tN as Dg,sN as Eg,lN as Fg,cN as Gg,dN as Hg,uN as Ig,fN as Jg,L5 as Kg,A5 as Lg,hN as Mg,bN as Ng,yge as Og,yM as Pg,xge as Qg,bge as Rg,Bf as Sg,Wg as Tg,K2 as Ug,Zl as Vg,Gg as Wg,Wf as Xg,kge as Yg,vN as Zg,Ym as _g,_b as $g,Yc as ah,Fce as bh,wye as ch,Dye as dh,Gb as eh,xa as fh,Yu as gh,Il as hh,$E as ih,cS as jh,$z as kh,bo as lh,VP as mh,_z as nh,$l as oh,Jc as ph,bee as qh,See as rh,wee as sh,QE as th,ZE as uh,Gz as vh,Mee as wh,gS as xh,Fl as yh,Ir as zh,Gi as Ah,eR as Bh,Dl as Ch,tR as Dh,Qz as Eh,kee as Fh,wS as Gh,Ea as Hh,_r as Ih,Xo as Jh,jR as Kh,Sne as Lh,yxe as Mh,s6 as Nh,qxe as Oh,Abe as Ph,EM as Qh,d6 as Rh,Zs as Sh,Ji as Th,kSe as Uh,qSe as Vh,Lne as Wh,Na as Xh,x$ as Yh,lwe as Zh,Gwe as _h,ec as $h,Hf as ai,jf as bi,Yf as ci,M0 as di,eA as ei,qy as fi,C$ as gi,Ih as hi,mMe as ii,qi as ji,NS as ki,T_ as li,rA as mi,C0 as ni,FD as oi,cV as pi,dV as qi,eO as ri,Gd as si,NI as ti,Z0 as ui,gy as vi,dc as wi,Qd as xi,c1 as yi,$$ as zi,GM as Ai,$O as Bi,_O as Ci,fX as Di,YI as Ei,D$ as Fi,PPe as Gi,WRe as Hi,Fd as Ii,Nt as Ji,es as Ki,Mve as Li,Gve as Mi,PTe as Ni,KTe as Oi,OLe as Pi,w2e as Qi,Z2e as Ri,IAe as Si,xIe as Ti,nFe as Ui,yFe as Vi,$Fe as Wi,lNe as Xi,ONe as Yi,hv as Zi,aw as _i,lw as $i,Lie as aj,Wv as bj,cw as cj,Xv as dj,$H as ej,OH as fj,Pre as gj};
|
|
52
|
-
//# sourceMappingURL=chunk-EHCMJUMD.js.map
|