agentic-mermaid 0.5.1 → 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.
Files changed (175) hide show
  1. package/AGENT_NATIVE.md +63 -375
  2. package/CHANGELOG.md +73 -0
  3. package/README.md +87 -50
  4. package/assets/hero.png +0 -0
  5. package/dist/agent-core.d.ts +7 -7
  6. package/dist/agent-core.js +1 -1
  7. package/dist/agent.d.ts +7 -7
  8. package/dist/agent.js +1 -1
  9. package/dist/agentic-mermaid-mcp.js +1 -1
  10. package/dist/am.js +1 -1
  11. package/dist/browser-lazy/chunks/agentic-producer-core-ECZ3CMZM.js +1 -0
  12. package/dist/browser-lazy/chunks/architecture-H5LTMKQW.js +13 -0
  13. package/dist/browser-lazy/chunks/block-566X6FNV.js +11 -0
  14. package/dist/browser-lazy/chunks/builtin-backends-VAFEZXKY.js +12 -0
  15. package/dist/browser-lazy/chunks/c4-ZXFDLBFK.js +10 -0
  16. package/dist/browser-lazy/chunks/{chunk-REBVEXI2.js → chunk-2JQXRKBC.js} +1 -1
  17. package/dist/browser-lazy/chunks/chunk-37FZNMPR.js +1 -0
  18. package/dist/browser-lazy/chunks/chunk-3JTYTXA6.js +22 -0
  19. package/dist/browser-lazy/chunks/{chunk-2J5K6NIP.js → chunk-4NILRBC7.js} +1 -1
  20. package/dist/browser-lazy/chunks/chunk-5LKPDHPC.js +4 -0
  21. package/dist/browser-lazy/chunks/chunk-62MR3LWJ.js +1 -0
  22. package/dist/browser-lazy/chunks/chunk-64JFHCJC.js +1 -0
  23. package/dist/browser-lazy/chunks/chunk-6GPDLZFQ.js +1 -0
  24. package/dist/browser-lazy/chunks/chunk-6UOOATQR.js +1 -0
  25. package/dist/browser-lazy/chunks/chunk-7TTFBJYA.js +1 -0
  26. package/dist/browser-lazy/chunks/chunk-7UFOFWBA.js +20 -0
  27. package/dist/browser-lazy/chunks/{chunk-HR5TE7TE.js → chunk-A7V5VDKN.js} +1 -1
  28. package/dist/browser-lazy/chunks/chunk-CPO5P4L2.js +1 -0
  29. package/dist/browser-lazy/chunks/chunk-EIYLJ4FI.js +20 -0
  30. package/dist/browser-lazy/chunks/{chunk-GMTB5UTY.js → chunk-G4JBA7HU.js} +3 -3
  31. package/dist/browser-lazy/chunks/chunk-HJVO5VC3.js +1 -0
  32. package/dist/browser-lazy/chunks/chunk-IUI4DYC3.js +3 -0
  33. package/dist/browser-lazy/chunks/{chunk-SBXYR7Z3.js → chunk-J57YRC2M.js} +1 -1
  34. package/dist/browser-lazy/chunks/chunk-LBXXKLIR.js +3 -0
  35. package/dist/browser-lazy/chunks/chunk-NKW2ZNCD.js +1 -0
  36. package/dist/browser-lazy/chunks/chunk-O34YYEQV.js +1 -0
  37. package/dist/browser-lazy/chunks/{chunk-E7UIB4SZ.js → chunk-OBI5U5XU.js} +1 -1
  38. package/dist/browser-lazy/chunks/{chunk-LLPBKBIG.js → chunk-OFOS57WQ.js} +1 -1
  39. package/dist/browser-lazy/chunks/chunk-PSZEE64O.js +16 -0
  40. package/dist/browser-lazy/chunks/chunk-PXTLV57R.js +1 -0
  41. package/dist/browser-lazy/chunks/chunk-QVSZOF5M.js +1 -0
  42. package/dist/browser-lazy/chunks/chunk-TLFX3U6S.js +1 -0
  43. package/dist/browser-lazy/chunks/{chunk-MSP3S2VS.js → chunk-TT5GR5EJ.js} +1 -1
  44. package/dist/browser-lazy/chunks/{chunk-KXPF5KIU.js → chunk-V6I2VGNQ.js} +5 -5
  45. package/dist/browser-lazy/chunks/{chunk-HDKHAM2V.js → chunk-VRZKI33U.js} +1 -1
  46. package/dist/browser-lazy/chunks/chunk-XHU3A432.js +1 -0
  47. package/dist/browser-lazy/chunks/chunk-YVNJDVQO.js +1 -0
  48. package/dist/browser-lazy/chunks/chunk-Z7UHFVKN.js +6 -0
  49. package/dist/browser-lazy/chunks/class-XIFNVBFE.js +13 -0
  50. package/dist/{zenuml/chunks/decode-BWERFDGK.js → browser-lazy/chunks/decode-5MFOG3AZ.js} +1 -1
  51. package/dist/browser-lazy/chunks/{elk.bundled-L4CADV5W.js → elk.bundled-RYWHIS5N.js} +8 -8
  52. package/dist/browser-lazy/chunks/er-VEUYJBGG.js +11 -0
  53. package/dist/browser-lazy/chunks/eventmodeling-G7DITZX7.js +19 -0
  54. package/dist/browser-lazy/chunks/flowchart-SSFIU4EU.js +4 -0
  55. package/dist/browser-lazy/chunks/{forest-implementation-AEP24AIP.js → forest-implementation-RWFF7XDV.js} +1 -1
  56. package/dist/browser-lazy/chunks/gantt-HQNVDX2B.js +11 -0
  57. package/dist/browser-lazy/chunks/{gitgraph-W26QIMTY.js → gitgraph-Z5MN6M6L.js} +4 -4
  58. package/dist/browser-lazy/chunks/ishikawa-UEERNFQV.js +6 -0
  59. package/dist/browser-lazy/chunks/journey-3BEWWGB5.js +16 -0
  60. package/dist/browser-lazy/chunks/kanban-2WFNCWLB.js +20 -0
  61. package/dist/{zenuml/chunks/mermaid-yaml-runtime-KZVU74WU.js → browser-lazy/chunks/mermaid-yaml-runtime-IK4ET4BT.js} +8 -8
  62. package/dist/browser-lazy/chunks/{mindmap-5A3MVHNH.js → mindmap-R2C6SNYR.js} +6 -6
  63. package/dist/browser-lazy/chunks/{packet-AL6VDOMY.js → packet-GMVCI5YZ.js} +5 -5
  64. package/dist/browser-lazy/chunks/pie-WER45DKC.js +15 -0
  65. package/dist/browser-lazy/chunks/{quadrant-RJ56XFBR.js → quadrant-NCUPSFKN.js} +5 -5
  66. package/dist/browser-lazy/chunks/radar-WLYS4YC5.js +16 -0
  67. package/dist/browser-lazy/chunks/render-core-42UVWIPF.js +3 -0
  68. package/dist/browser-lazy/chunks/requirement-AK3NWMJ6.js +19 -0
  69. package/dist/browser-lazy/chunks/{sankey-WKTBEZSS.js → sankey-C2DY6WVU.js} +8 -8
  70. package/dist/browser-lazy/chunks/sequence-D4WJB44W.js +5 -0
  71. package/dist/browser-lazy/chunks/state-YUQVESE7.js +4 -0
  72. package/dist/browser-lazy/chunks/{timeline-PRV5PWGP.js → timeline-BMBJJXWR.js} +4 -4
  73. package/dist/browser-lazy/chunks/{treemap-BVME3JLI.js → treemap-B66XBZZ6.js} +4 -4
  74. package/dist/browser-lazy/chunks/{xychart-XBI2RNHD.js → xychart-HAVFROGT.js} +6 -6
  75. package/dist/browser-lazy/chunks/{zenuml-GQKPRQFJ.js → zenuml-62RLYFWP.js} +8 -8
  76. package/dist/browser-lazy/index.d.ts +10 -0
  77. package/dist/browser-lazy/index.js +1 -1
  78. package/dist/browser.global.js +541 -541
  79. package/dist/{chunk-AVS4T4NO.js → chunk-2DNGDTJD.js} +2 -2
  80. package/dist/{chunk-AWZBTOV6.js → chunk-4F2UGYTM.js} +2 -2
  81. package/dist/{chunk-6JBQYHWB.js → chunk-7XYB2LNC.js} +2 -2
  82. package/dist/chunk-DOFB572I.js +58 -0
  83. package/dist/chunk-EHJI3QYE.js +52 -0
  84. package/dist/{chunk-YISEN5SO.js → chunk-HINRNKPO.js} +2 -2
  85. package/dist/{chunk-ORYXYGDV.js → chunk-KXMANAST.js} +33 -33
  86. package/dist/chunk-U4MT3RRE.js +2 -0
  87. package/dist/{chunk-AIWXP4OF.js → chunk-WYIB6BUR.js} +2 -2
  88. package/dist/{cli-BOEN5YAF.js → cli-ZYIDBYNS.js} +2 -2
  89. package/dist/{index-Cr3xjRw9.d.ts → index-Bvhprdxz.d.ts} +3 -3
  90. package/dist/index.d.ts +4 -4
  91. package/dist/index.js +1 -1
  92. package/dist/{mcp-cli-NM3P4VPC.js → mcp-cli-YVDCORWA.js} +2 -2
  93. package/dist/{paint-certification-C33LRvWT.d.ts → paint-certification-BoLyr006.d.ts} +22 -2
  94. package/dist/{server-FY5Z7F32.js → server-4JGAVXR3.js} +2 -2
  95. package/dist/{svg-styles-C_v2tnxG.d.ts → svg-styles-BnCoXyYe.d.ts} +1 -1
  96. package/dist/svg-styles.d.ts +1 -1
  97. package/dist/svg-styles.js +1 -1
  98. package/dist/svg.d.ts +4 -4
  99. package/dist/svg.js +1 -1
  100. package/dist/{types-DxOTIgwg.d.ts → types-CLVJCaH2.d.ts} +11 -1
  101. package/dist/zenuml/chunks/{appearance-FTQ2722O.js → appearance-5RM5MVM2.js} +1 -1
  102. package/dist/zenuml/chunks/{builtin-backends-QLY75JCL.js → builtin-backends-UTNWL4N3.js} +11 -11
  103. package/dist/zenuml/chunks/{chunk-LYIRUTCM.js → chunk-3A6S6GNB.js} +2 -2
  104. package/dist/zenuml/chunks/{chunk-6OONHTSD.js → chunk-55WS466K.js} +9 -9
  105. package/dist/zenuml/chunks/chunk-6J4BGPB2.js +29 -0
  106. package/dist/zenuml/chunks/chunk-CNLL4BGF.js +1 -0
  107. package/dist/zenuml/chunks/{chunk-YFCDP4ZS.js → chunk-IARQ24W3.js} +13 -13
  108. package/dist/zenuml/chunks/chunk-ZNZRIISS.js +4 -0
  109. package/dist/{browser-lazy/chunks/decode-63UIZGD2.js → zenuml/chunks/decode-LDNNXEAO.js} +1 -1
  110. package/dist/{browser-lazy/chunks/mermaid-yaml-runtime-QVYX4EWK.js → zenuml/chunks/mermaid-yaml-runtime-A5CNJ3IE.js} +8 -8
  111. package/dist/zenuml/chunks/render-core-ECIWU5ZS.js +3 -0
  112. package/dist/zenuml/chunks/{zenuml-URQ4HIMD.js → zenuml-N3LZMB2G.js} +9 -9
  113. package/dist/zenuml.d.ts +2 -2
  114. package/dist/zenuml.js +1 -1
  115. package/docs/MCP-DIRECTORY-LISTINGS.md +81 -12
  116. package/docs/README.md +59 -110
  117. package/docs/api.md +3 -1
  118. package/docs/config.md +37 -0
  119. package/docs/getting-started.md +27 -44
  120. package/examples/styles/readme-hero.md +25 -0
  121. package/examples/styles/readme-hero.mmd +13 -0
  122. package/examples/styles/readme-hero.style.json +7 -0
  123. package/package.json +1 -1
  124. package/server.json +2 -2
  125. package/dist/browser-lazy/chunks/agentic-producer-core-MGU4FD6J.js +0 -1
  126. package/dist/browser-lazy/chunks/architecture-KZTC3672.js +0 -13
  127. package/dist/browser-lazy/chunks/block-J5PD6HQM.js +0 -11
  128. package/dist/browser-lazy/chunks/builtin-backends-GSGJPT5A.js +0 -12
  129. package/dist/browser-lazy/chunks/c4-VNQSIA5M.js +0 -10
  130. package/dist/browser-lazy/chunks/chunk-4C2BVM5Y.js +0 -1
  131. package/dist/browser-lazy/chunks/chunk-5GE2SFLQ.js +0 -4
  132. package/dist/browser-lazy/chunks/chunk-6YGQR6R4.js +0 -16
  133. package/dist/browser-lazy/chunks/chunk-7AHX3HH7.js +0 -1
  134. package/dist/browser-lazy/chunks/chunk-B5PDJUJG.js +0 -3
  135. package/dist/browser-lazy/chunks/chunk-CXQWSLJV.js +0 -1
  136. package/dist/browser-lazy/chunks/chunk-DWDYWUAS.js +0 -1
  137. package/dist/browser-lazy/chunks/chunk-EUBVLDYV.js +0 -29
  138. package/dist/browser-lazy/chunks/chunk-FBL4ONAL.js +0 -20
  139. package/dist/browser-lazy/chunks/chunk-NQF75XGM.js +0 -3
  140. package/dist/browser-lazy/chunks/chunk-P7DO3MRP.js +0 -13
  141. package/dist/browser-lazy/chunks/chunk-QQ2U2KAY.js +0 -1
  142. package/dist/browser-lazy/chunks/chunk-SJYDRC6G.js +0 -1
  143. package/dist/browser-lazy/chunks/chunk-UUTB6MDK.js +0 -1
  144. package/dist/browser-lazy/chunks/chunk-WEREIH5P.js +0 -1
  145. package/dist/browser-lazy/chunks/chunk-WHNTP27R.js +0 -6
  146. package/dist/browser-lazy/chunks/chunk-YXGB25MZ.js +0 -1
  147. package/dist/browser-lazy/chunks/class-FNDNJGYH.js +0 -13
  148. package/dist/browser-lazy/chunks/er-P263BDFG.js +0 -11
  149. package/dist/browser-lazy/chunks/eventmodeling-XX3VCGSC.js +0 -19
  150. package/dist/browser-lazy/chunks/flowchart-GTLWJA3P.js +0 -4
  151. package/dist/browser-lazy/chunks/gantt-SRIHFAIC.js +0 -11
  152. package/dist/browser-lazy/chunks/ishikawa-NTHJ7BUO.js +0 -6
  153. package/dist/browser-lazy/chunks/journey-3T62IEHN.js +0 -16
  154. package/dist/browser-lazy/chunks/kanban-U6DQ7LWQ.js +0 -20
  155. package/dist/browser-lazy/chunks/pie-4QYMTQ7W.js +0 -15
  156. package/dist/browser-lazy/chunks/radar-L5B4CNEL.js +0 -16
  157. package/dist/browser-lazy/chunks/render-core-CIGKBI2T.js +0 -3
  158. package/dist/browser-lazy/chunks/requirement-5QVLRI6Z.js +0 -19
  159. package/dist/browser-lazy/chunks/sequence-G6DQHPR7.js +0 -5
  160. package/dist/browser-lazy/chunks/state-6DEA5BXE.js +0 -4
  161. package/dist/chunk-PNL435CH.js +0 -58
  162. package/dist/chunk-XCEEF3NJ.js +0 -2
  163. package/dist/chunk-YQKNJNU4.js +0 -52
  164. package/dist/zenuml/chunks/chunk-4VRUBLG4.js +0 -29
  165. package/dist/zenuml/chunks/chunk-7QDAZ2HL.js +0 -4
  166. package/dist/zenuml/chunks/chunk-GDLMM3YO.js +0 -1
  167. package/dist/zenuml/chunks/render-core-DNCYYOIB.js +0 -3
  168. /package/dist/browser-lazy/chunks/{chunk-5FQ534HP.js → chunk-BMZ24VPS.js} +0 -0
  169. /package/dist/browser-lazy/chunks/{chunk-2I4UPL7Q.js → chunk-D6MQ7QSU.js} +0 -0
  170. /package/dist/browser-lazy/chunks/{chunk-LH7HUDKW.js → chunk-L4UC3KGS.js} +0 -0
  171. /package/dist/browser-lazy/chunks/{chunk-NMQQMRIR.js → chunk-MFTQWHUB.js} +0 -0
  172. /package/dist/browser-lazy/chunks/{chunk-N5ELX7LR.js → chunk-PJJSDGLB.js} +0 -0
  173. /package/dist/browser-lazy/chunks/{chunk-CSFUKSU6.js → chunk-QCU5G5PZ.js} +0 -0
  174. /package/dist/browser-lazy/chunks/{chunk-5UVGUSD6.js → chunk-YHMTSXIR.js} +0 -0
  175. /package/dist/zenuml/chunks/{chunk-EVPSMEKN.js → chunk-GC7IPQ5P.js} +0 -0
@@ -0,0 +1 @@
1
+ import{a as e,b as t}from"./chunk-HJVO5VC3.js";import{b as n,c as i}from"./chunk-L4UC3KGS.js";import{d as r}from"./chunk-BMZ24VPS.js";import{a as a}from"./chunk-62MR3LWJ.js";import{a as o,b as s,c as l,d as h,f as u,g as d,h as x,i as y,j as c}from"./chunk-PXTLV57R.js";import{i as f}from"./chunk-5LKPDHPC.js";import{l as g,o as p,p as m,q as M,r as b,s as $,t as w,x as k}from"./chunk-QVSZOF5M.js";import{r as v}from"./chunk-3JTYTXA6.js";import{c as S,d as P,h as C}from"./chunk-YVNJDVQO.js";import{C as N,Ma as W,Na as L,Q as E,Qa as I,R as R,Ua as B,Wa as H,da as A,ea as F,ha as O,t as z}from"./chunk-EIYLJ4FI.js";function j(e,t){return"invisible"===e.style?[]:e.points.slice(1).flatMap((n,i)=>{let r=e.points[i],a=.01>=Math.abs(r.y-n.y);if(!a&&Math.abs(r.x-n.x)>.01)return[];let o=a?r.x:r.y,s=a?n.x:n.y;if(.01>=Math.abs(s-o))return[];let l=a?r.y:r.x;return[{edgeIndex:t,horizontal:a,cross:l,bucket:Math.floor(l/.01),lo:Math.min(o,s),hi:Math.max(o,s),sign:Math.sign(s-o)}]})}function V(e){let t=e.flatMap(j).sort((e,t)=>e.lo-t.lo||e.edgeIndex-t.edgeIndex),n=new Map,i=new Set;for(let e of t){for(let t=-1;t<=1;t++){let r=`${e.horizontal}:${e.bucket+t}`,a=(n.get(r)??[]).filter(t=>t.hi-e.lo>.01);for(let t of(n.set(r,a),a))t.edgeIndex===e.edgeIndex||t.sign===e.sign||Math.abs(t.cross-e.cross)>.01||Math.min(e.hi,t.hi)-e.lo<=.01||i.add(`${Math.min(e.edgeIndex,t.edgeIndex)}:${Math.max(e.edgeIndex,t.edgeIndex)}`)}let t=`${e.horizontal}:${e.bucket}`;n.get(t).push(e)}return i.size}function Y(e,t){let n=j(e,0),i=[];if(0===n.length)return i;let r=Q(e);for(let e of t){let t=Q(e);t.x0>r.x1+.01||t.x1<r.x0-.01||t.y0>r.y1+.01||t.y1<r.y0-.01||j(e,1).some(e=>n.some(t=>t.horizontal===e.horizontal&&t.sign!==e.sign&&.01>=Math.abs(t.cross-e.cross)&&Math.min(t.hi,e.hi)-Math.max(t.lo,e.lo)>.01))&&i.push(e)}return i}function Q(e){let t=1/0,n=1/0,i=-1/0,r=-1/0;for(let a of e.points)t=Math.min(t,a.x),i=Math.max(i,a.x),n=Math.min(n,a.y),r=Math.max(r,a.y);return{x0:t,y0:n,x1:i,y1:r}}function q(e,t=!1){let n=P.width,i=t?n:P.height,r=e??"var(--_arrow)",a=`${e?`-${_(e)}`:""}${t?"-fixed":""}`,o={fill:r,stroke:r,strokeWidth:String(P.strokeWidth),strokeLinejoin:"round"};return[v(`arrowhead${a}`,{width:n,height:i},"end",o,t?"userSpaceOnUse":void 0),v(`arrowhead-start${a}`,{width:n,height:i},"start",o,t?"userSpaceOnUse":void 0)]}function T(e,t=!1){let n=P.width,i=`${e?`-${_(e)}`:""}${t?"-fixed":""}`,r=e??"var(--_arrow)",a={shape:"circle",size:{width:n,height:n},...t?{units:"userSpaceOnUse"}:{},orient:"auto",geometry:{kind:"circle",cx:n/2,cy:n/2,r:n/2-.75},paint:{fill:"none",stroke:r,strokeWidth:"1"}};return[{...a,id:`circlehead${i}`,ref:{x:n-.5,y:n/2}},{...a,id:`circlehead-start${i}`,ref:{x:.5,y:n/2}}]}function J(e,t=!1){let n=P.width,i=`${e?`-${_(e)}`:""}${t?"-fixed":""}`,r=e??"var(--_arrow)",a=n-1.25,o={shape:"cross",size:{width:n,height:n},...t?{units:"userSpaceOnUse"}:{},orient:"auto",geometry:{kind:"compound",children:[{kind:"line",x1:1.25,y1:1.25,x2:a,y2:a},{kind:"line",x1:1.25,y1:a,x2:a,y2:1.25}]},paint:{stroke:r,strokeWidth:String(1.25),strokeLinecap:"round"}};return[{...o,id:`crosshead${i}`,ref:{x:a+.625,y:n/2}},{...o,id:`crosshead-start${i}`,ref:{x:.625,y:n/2}}]}function Z(e,t,n,i){let r=[...q()];for(let t of(n&&r.push(...T()),i&&r.push(...J()),e))r.push(...q(t)),n&&r.push(...T(t)),i&&r.push(...J(t));for(let e of t)r.push(...q(e,!0)),n&&r.push(...T(e,!0)),i&&r.push(...J(e,!0));return r}function U(e){return"circle"===e?"circlehead":"cross"===e?"crosshead":"arrowhead"}function _(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;let t=`color-u-${Array.from(e,e=>e.codePointAt(0).toString(16)).join("-")}`;return t.length<=233?t:`color-h-${f(e).slice(8)}`}var X=a(Z(new Set,new Set([void 0]),!0,!0));function D(e,t){let n=e.inlineStyle?.["stroke-width"]?"-fixed":"",i=(t.lineWidth??1)*("thick"===e.style?2:1);return{start:e.hasArrowStart?X(`${U(e.startMarker??"arrow")}-start${n}`,i,"start"):0,end:e.hasArrowEnd?X(`${U(e.endMarker??"arrow")}${n}`,i,"end"):0}}function G(e,t){return e.curve?function(e){let t=e[0],n=`M ${t.x} ${t.y}`,i=[];for(let t=1;t<e.length;t++){let r=e[t-1],a=e[t],o=(r.x+a.x)/2;n+=` C ${o} ${r.y}, ${o} ${a.y}, ${a.x} ${a.y}`,i.push({kind:"cubic",control1:{x:o,y:r.y},control2:{x:o,y:a.y},end:a})}return A(n,t,i)}(e.points):(t.edgeBendRadius??0)>0?F(e.points,t.edgeBendRadius,{terminalClearance:D(e,t)}):void 0}function K(e,t){if("invisible"===e.style||e.points.length<2||!e.hasArrowStart&&!e.hasArrowEnd)return[];let n=e.inlineStyle?.stroke??t.edgeStrokeColor,i=!!e.inlineStyle?.["stroke-width"],r=Z(new Set(n?[n]:[]),new Set(i?[n]:[]),"circle"===e.startMarker||"circle"===e.endMarker,"cross"===e.startMarker||"cross"===e.endMarker),a=`${n?`-${_(n)}`:""}${i?"-fixed":""}`,o=e.hasArrowStart?r.find(t=>t.id===`${U(e.startMarker??"arrow")}-start${a}`):void 0,s=e.hasArrowEnd?r.find(t=>t.id===`${U(e.endMarker??"arrow")}${a}`):void 0,l=G(e,t),h=l?.geometry??{kind:"polyline",points:e.points};return I({route:{geometry:h,closed:!1,contours:l?.contours??O(h,!1)},stroke:{width:e.inlineStyle?.["stroke-width"]??String((t.lineWidth??1)*("thick"===e.style?2:1))},markers:{start:o,mid:[],end:s}})}var ee=new WeakMap,et=e=>({fill:e.fill,stroke:e.stroke,strokeWidth:e.strokeWidth}),en=e=>({stroke:e.stroke,strokeWidth:e.strokeWidth}),ei=(e,t)=>({geometry:{kind:"polygon",points:e},paint:et(t),routing:{kind:"polygon",points:e}}),er=(e,t,n,i={})=>({geometry:{kind:"path",d:t},paint:{...et(n),fill:"none"===i.fill?"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 ea(e,t,n){var i,r,a,o;let s=function(e,t){var n,i,r,a;let{x:o,y:s,width:l,height:h}=e,u=o+l,d=s+h,x=o+l/2,y=s+h/2;switch(e.semanticShape){case"bang":return ei(Array.from({length:16},(e,t)=>{let n=-Math.PI/2+t*Math.PI/8,i=t%2==0?1:.62;return{x:x+Math.cos(n)*l/2*i,y:y+Math.sin(n)*h/2*i}}),t);case"notch-rect":case"tag-rect":return ei([{x:o+10,y:s},{x:u,y:s},{x:u,y:d},{x:o,y:d},{x:o,y:s+10}],t);case"cloud":return er(e,`M${o+.18*l} ${d}C${o-4} ${d} ${o-4} ${y} ${o+.12*l} ${y}C${o+.08*l} ${s+.15*h} ${o+.38*l} ${s-4} ${o+.48*l} ${s+.18*h}C${o+.65*l} ${s-5} ${u} ${s+.16*h} ${o+.88*l} ${y}C${u+5} ${y} ${u+5} ${d} ${o+.72*l} ${d}Z`,t);case"hourglass":return ei([{x:o,y:s},{x:u,y:s},{x:o+.62*l,y:y},{x:u,y:d},{x:o,y:d},{x:o+.38*l,y:y}],t);case"bolt":return ei([{x:o+.55*l,y:s},{x:o+.25*l,y:y},{x:o+.48*l,y:y},{x:o+.35*l,y:d},{x:o+.78*l,y:s+.4*h},{x:o+.55*l,y:s+.4*h}],t);case"brace":return ep(e,`M${u} ${s}C${o+.4*l} ${s} ${o+.7*l} ${y} ${o} ${y}C${o+.7*l} ${y} ${o+.4*l} ${d} ${u} ${d}`,t);case"brace-r":return ep(e,`M${o} ${s}C${o+.6*l} ${s} ${o+.3*l} ${y} ${u} ${y}C${o+.3*l} ${y} ${o+.6*l} ${d} ${o} ${d}`,t);case"braces":return ep(e,`M${o+.25*l} ${s}C${o} ${s} ${o+.15*l} ${y} ${o} ${y}C${o+.15*l} ${y} ${o} ${d} ${o+.25*l} ${d}M${o+.75*l} ${s}C${u} ${s} ${o+.85*l} ${y} ${u} ${y}C${o+.85*l} ${y} ${u} ${d} ${o+.75*l} ${d}`,t);case"datastore":return ep(e,`M${o+8} ${s}H${u}V${d}H${o+8}M${o+8} ${s}C${o-2} ${s+.2*h} ${o-2} ${d-.2*h} ${o+8} ${d}`,t);case"delay":return er(e,`M${o} ${s}H${u-h/2}A${h/2} ${h/2} 0 0 1 ${u-h/2} ${d}H${o}Z`,t);case"h-cyl":return er(e,`M${o+10} ${s}H${u-10}A10 ${h/2} 0 0 1 ${u-10} ${d}H${o+10}A10 ${h/2} 0 0 1 ${o+10} ${s}Z M${u-10} ${s}A10 ${h/2} 0 0 0 ${u-10} ${d}`,t);case"lin-cyl":return er(e,`M${o} ${s+8}A${l/2} 8 0 0 1 ${u} ${s+8}V${d-8}A${l/2} 8 0 0 1 ${o} ${d-8}Z M${o} ${s+8}A${l/2} 8 0 0 0 ${u} ${s+8}M${o} ${d-16}A${l/2} 8 0 0 0 ${u} ${d-16}`,t);case"curv-trap":return er(e,`M${o+12} ${s}Q${x} ${s+8} ${u-12} ${s}L${u} ${d}Q${x} ${d-8} ${o} ${d}Z`,t);case"div-rect":return em(e,`M${o} ${s}H${u}V${d}H${o}ZM${o} ${y}H${u}`,t);case"doc":return er(e,`M${o} ${s}H${u}V${d-8}Q${o+.75*l} ${d+2} ${x} ${d-8}Q${o+.25*l} ${d-18} ${o} ${d-8}Z`,t);case"tri":return ei([{x:x,y:s},{x:u,y:d},{x:o,y:d}],t);case"fork":return{geometry:{kind:"rect",x:o,y:n=y-4,width:l,height:8},paint:{fill:i=t.stroke,stroke:i,strokeWidth:t.strokeWidth},routing:{kind:"rect",x:o,y:n,width:l,height:8}};case"win-pane":return em(e,`M${o} ${s}H${u}V${d}H${o}ZM${o+.28*l} ${s}V${d}M${o} ${s+.32*h}H${u}`,t);case"f-circ":return{geometry:{kind:"circle",cx:x,cy:y,r:r=Math.min(l,h)/2},paint:{fill:a=t.stroke,stroke:a,strokeWidth:t.strokeWidth},routing:{kind:"ellipse",cx:x,cy:y,rx:r,ry:r}};case"lin-doc":return er(e,`M${o} ${s}H${u}V${d-8}Q${o+.75*l} ${d+2} ${x} ${d-8}Q${o+.25*l} ${d-18} ${o} ${d-8}ZM${o+8} ${s+8}H${u-8}`,t);case"lin-rect":return em(e,`M${o} ${s}H${u}V${d}H${o}ZM${o+6} ${s}V${d}M${u-6} ${s}V${d}`,t);case"notch-pent":return ei([{x:o,y:s},{x:u-10,y:s},{x:u,y:y},{x:u-10,y:d},{x:o,y:d},{x:o+8,y:y}],t);case"flip-tri":return ei([{x:o,y:s},{x:u,y:s},{x:x,y:d}],t);case"docs":return er(e,`M${o+8} ${s}H${u}V${d-8}Q${o+.7*l} ${d} ${o+.45*l} ${d-8}Q${o+.22*l} ${d-16} ${o+8} ${d-8}ZM${o} ${s+8}H${o+8}M${o} ${s+8}V${d}`,t);case"st-rect":return er(e,`M${o+8} ${s}H${u}V${d-8}H${o+8}ZM${o} ${s+8}H${u-8}V${d}H${o}Z`,t);case"flag":return er(e,`M${o} ${s+6}Q${o+.25*l} ${s-4} ${x} ${s+6}Q${o+.75*l} ${s+16} ${u} ${s+6}V${d-6}Q${o+.75*l} ${d+4} ${x} ${d-6}Q${o+.25*l} ${d-16} ${o} ${d-6}Z`,t);case"sm-circ":return ec(x,y,.22*Math.min(l,h),t);case"cross-circ":{let n=er(e,`M${x} ${s}A${l/2} ${h/2} 0 1 1 ${x-.01} ${s}M${o+.28*l} ${s+.28*h}L${o+.72*l} ${s+.72*h}M${o+.72*l} ${s+.28*h}L${o+.28*l} ${s+.72*h}`,t);return n.routing={kind:"ellipse",cx:x,cy:y,rx:l/2,ry:h/2},n}case"bow-rect":return er(e,`M${o} ${s}Q${o+12} ${y} ${o} ${d}H${u}Q${u-12} ${y} ${u} ${s}Z`,t);case"tag-doc":return er(e,`M${o+10} ${s}H${u}V${d-8}Q${o+.7*l} ${d} ${x} ${d-8}Q${o+.25*l} ${d-16} ${o} ${d-8}V${s+10}ZM${o} ${s+10}L${o+10} ${s}`,t);case"text":return{geometry:{kind:"path",d:`M${o} ${s}`},paint:{fill:"none",stroke:"none"},routing:{kind:"none",reason:"text blocks have no painted enclosure"}};default:return null}}(e,t);if(s)return s;let{x:l,y:h,width:u,height:d}=e,x=l+u/2,y=h+d/2;switch(e.shape){case"state-note":{let e=Math.min(12,u/6,d/4);return ei([{x:l,y:h},{x:l+u-e,y:h},{x:l+u,y:h+e},{x:l+u,y:h+d},{x:l,y:h+d}],t)}case"diamond":case"state-choice":return ei([{x:x,y:y-d/2},{x:x+u/2,y:y},{x:x,y:y+d/2},{x:x-u/2,y:y}],t);case"stadium":{let e=d/2;return{geometry:{kind:"rect",x:l,y:h,width:u,height:d,rx:e,ry:e},paint:et(t),routing:{kind:"stadium",cx:x,cy:y,halfWidth:u/2,radius:e}}}case"ellipse":return{geometry:{kind:"ellipse",cx:x,cy:y,rx:u/2,ry:d/2},paint:et(t),routing:{kind:"ellipse",cx:x,cy:y,rx:u/2,ry:d/2}};case"circle":case"state-history":return ec(x,y,Math.min(u,d)/2,t);case"doublecircle":let c;return c=Math.max(0,(i=Math.min(u,d)/2)-5),{geometry:{kind:"compound",children:[{kind:"circle",cx:x,cy:y,r:i},{kind:"circle",cx:x,cy:y,r:c}]},paint:et(t),routing:{kind:"ellipse",cx:x,cy:y,rx:i,ry:i}};case"hexagon":{let e=d/4;return ei([{x:l+e,y:h},{x:l+u-e,y:h},{x:l+u,y:y},{x:l+u-e,y:h+d},{x:l+e,y:h+d},{x:l,y:y}],t)}case"cylinder":let f,g,p;return f=l+u/2,{geometry:{kind:"compound",children:[{kind:"rect",x:l,y:g=h+7,width:u,height:p=d-14},{kind:"line",x1:l,y1:g,x2:l,y2:g+p},{kind:"line",x1:l+u,y1:g,x2:l+u,y2:g+p},{kind:"ellipse",cx:f,cy:h+d-7,rx:u/2,ry:7},{kind:"ellipse",cx:f,cy:g,rx:u/2,ry:7}]},paint:et(t),childPaints:[{fill:t.fill,stroke:"none"},en(t),en(t),et(t),et(t)],routing:{kind:"cylinder",cx:f,y:h,width:u,height:d,capRadiusY:7}};case"asymmetric":return ei([{x:l+12,y:h},{x:l+u,y:h},{x:l+u,y:h+d},{x:l+12,y:h+d},{x:l,y:y}],t);case"trapezoid":{let e=.15*u;return ei([{x:l+e,y:h},{x:l+u-e,y:h},{x:l+u,y:h+d},{x:l,y:h+d}],t)}case"trapezoid-alt":{let e=.15*u;return ei([{x:l,y:h},{x:l+u,y:h},{x:l+u-e,y:h+d},{x:l+e,y:h+d}],t)}case"lean-r":{let e=.15*u;return ei([{x:l+e,y:h},{x:l+u,y:h},{x:l+u-e,y:h+d},{x:l,y:h+d}],t)}case"lean-l":{let e=.15*u;return ei([{x:l,y:h},{x:l+u-e,y:h},{x:l+u,y:h+d},{x:l+e,y:h+d}],t)}case"subroutine":return{geometry:{kind:"compound",children:[{kind:"rect",x:l,y:h,width:u,height:d,rx:r=n??0,ry:r},{kind:"line",x1:l+8,y1:h,x2:l+8,y2:h+d},{kind:"line",x1:l+u-8,y1:h,x2:l+u-8,y2:h+d}]},paint:et(t),childPaints:[et(t),en(t),en(t)],routing:{kind:"rect",x:l,y:h,width:u,height:d}};case"state-start":return{geometry:{kind:"circle",cx:x,cy:y,r:a=Math.max(0,Math.min(u,d)/2-2)},paint:{fill:"var(--_text)",stroke:"none"},routing:{kind:"ellipse",cx:x,cy:y,rx:a,ry:a}};case"state-end":let m;return m=Math.max(0,(o=Math.max(0,Math.min(u,d)/2-2))-4),{geometry:{kind:"compound",children:[{kind:"circle",cx:x,cy:y,r:o},{kind:"circle",cx:x,cy:y,r:m}]},paint:{fill:"var(--_text)",stroke:"var(--_text)"},childPaints:[{fill:"none",stroke:"var(--_text)",strokeWidth:String(2*S.innerBox)},{fill:"var(--_text)",stroke:"none"}],routing:{kind:"ellipse",cx:x,cy:y,rx:o,ry:o}};case"state-fork":case"state-join":let M;return M=Math.min(u,d)/2,{geometry:{kind:"rect",x:l,y:h,width:u,height:d,rx:M,ry:M},paint:{fill:"var(--_text)",stroke:"none"},routing:{kind:"rect",x:l,y:h,width:u,height:d}};case"rounded":return ey(l,h,u,d,t,n??6);default:return ey(l,h,u,d,t,n??0)}}function eo(e){let t,n,i=ee.get(e);if(i&&i.x===e.x&&i.y===e.y&&i.width===e.width&&i.height===e.height&&i.shape===e.shape&&i.semanticShape===e.semanticShape)return i.profile;let r=ea(e,{fill:"",stroke:"",strokeWidth:""}).routing,a=(t=e.x+e.width/2,n=e.y+e.height/2,{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}}),o={};for(let e of["N","E","S","W"]){let t=function(e,t){let n=ed(e);if(!n)return null;let i="E"===t||"W"===t?"x":"y",r="x"===i?n.y+n.height/2:n.x+n.width/2;return ex(e,i,r,"E"===t||"S"===t)}(r,e)??a[e];if("none"===r.kind){o[e]={kind:"none",preferred:t};continue}if("envelope"===r.kind){let[n,i]=eh(r,e);o[e]={kind:"envelope",lo:n,hi:i,preferred:t};continue}let n=function(e,t,n){let[i,r]=eh(t,n);if("rect"===t.kind)return eu(i,r,4);if("stadium"===t.kind&&("N"===n||"S"===n))return eu(t.cx-(t.halfWidth-t.radius),t.cx+(t.halfWidth-t.radius),2);if("cylinder"===t.kind&&("E"===n||"W"===n))return eu(t.y+t.capRadiusY,t.y+t.height-t.capRadiusY,2);if("polygon"!==t.kind)return null;let a=ed(t),o="E"===n||"W"===n?"x":"y",s="x"===o?"E"===n?a.x+a.width:a.x:"S"===n?a.y+a.height:a.y,l=[];for(let e=0;e<t.points.length;e++){let n=t.points[e],i=t.points[(e+1)%t.points.length];if(Math.abs(n[o]-s)>1e-9||Math.abs(i[o]-s)>1e-9)continue;let r="x"===o?n.y:n.x,a="x"===o?i.y:i.x;l.push([Math.min(r,a),Math.max(r,a)])}if(l.length>0){let e=l.sort((e,t)=>t[1]-t[0]-(e[1]-e[0]))[0];return eu(e[0],e[1],2)}if(4===t.points.length&&function(e,t){let n=t.x+t.width/2,i=t.y+t.height/2,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(e=>r.some(t=>1e-8>Math.abs(e.x-t.x)&&1e-8>Math.abs(e.y-t.y)))}(t.points,a)){let e=r-i;return eu(i,r,e<=40?e/4:10)}return null}(0,r,e);o[e]=n?{kind:"dynamic",...n,preferred:t}:{kind:"port",point:t,preferred:t}}let s={boundary:r,sides:o};return ee.set(e,{x:e.x,y:e.y,width:e.width,height:e.height,shape:e.shape,semanticShape:e.semanticShape,profile:s}),s}function es(e){let t=eo(e);return{N:{...t.sides.N.preferred},E:{...t.sides.E.preferred},S:{...t.sides.S.preferred},W:{...t.sides.W.preferred}}}function el(e,t,n){return ex(e,"E"===t||"W"===t?"x":"y",n,"E"===t||"S"===t)}function eh(e,t){let n=ed(e);return"E"===t||"W"===t?[n.y,n.y+n.height]:[n.x,n.x+n.width]}function eu(e,t,n){return t-e>2*n?{lo:e+n,hi:t-n}:null}function ed(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:2*e.rx,height:2*e.ry};case"stadium":return{x:e.cx-e.halfWidth,y:e.cy-e.radius,width:2*e.halfWidth,height:2*e.radius};case"cylinder":return{x:e.cx-e.width/2,y:e.y,width:e.width,height:e.height};case"polygon":{if(0===e.points.length)return null;let t=e.points.map(e=>e.x),n=e.points.map(e=>e.y),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 ex(e,t,n,i){let r=e=>"x"===t?{x:e,y:n}:{x:n,y:e};switch(e.kind){case"rect":case"envelope":{let a="x"===t?e.y:e.x,o=a+("x"===t?e.height:e.width);return n<a-1e-9||n>o+1e-9?null:r("x"===t?i?e.x+e.width:e.x:i?e.y+e.height:e.y)}case"ellipse":{let a="x"===t?e.cy:e.cx,o="x"===t?e.ry:e.rx,s="x"===t?e.cx:e.cy,l="x"===t?e.rx:e.ry;if(o<=0||l<=0)return null;let h=(n-a)/o;return Math.abs(h)>1+1e-9?null:r(s+(i?1:-1)*l*Math.sqrt(Math.max(0,1-h*h)))}case"stadium":{if("x"===t){let t=n-e.cy;if(Math.abs(t)>e.radius+1e-9)return null;let a=e.halfWidth-e.radius+Math.sqrt(Math.max(0,e.radius**2-t**2));return r(e.cx+(i?a:-a))}let a=Math.abs(n-e.cx);if(a>e.halfWidth+1e-9)return null;let o=Math.max(0,a-(e.halfWidth-e.radius));return r(e.cy+(i?1:-1)*Math.sqrt(Math.max(0,e.radius**2-o**2)))}case"cylinder":{let a=e.width/2,o=e.y+e.capRadiusY,s=e.y+e.height-e.capRadiusY;if("x"===t){if(n<e.y-1e-9||n>e.y+e.height+1e-9)return null;let t=n<o?o:n>s?s:n,l=t===n?0:(n-t)/e.capRadiusY;return r(e.cx+(i?1:-1)*a*Math.sqrt(Math.max(0,1-l*l)))}let l=(n-e.cx)/a;if(Math.abs(l)>1+1e-9)return null;let h=e.capRadiusY*Math.sqrt(Math.max(0,1-l*l));return r(i?s+h:o-h)}case"polygon":{let a=[];for(let i=0;i<e.points.length;i++){let r=e.points[i],o=e.points[(i+1)%e.points.length],s="x"===t?r.y:r.x,l="x"===t?o.y:o.x,h=r[t],u=o[t],d=l-s;if(1e-9>Math.abs(d)){1e-9>Math.abs(n-s)&&a.push(h,u);continue}let x=(n-s)/d;x>=-1e-9&&x<=1+1e-9&&a.push(h+x*(u-h))}let o=0===a.length?null:i?Math.max(...a):Math.min(...a);return null===o?null:r(o)}case"none":return null}}function ey(e,t,n,i,r,a){return{geometry:{kind:"rect",x:e,y:t,width:n,height:i,rx:a,ry:a},paint:et(r),routing:{kind:"rect",x:e,y:t,width:n,height:i}}}function ec(e,t,n,i){return{geometry:{kind:"circle",cx:e,cy:t,r:n},paint:et(i),routing:{kind:"ellipse",cx:e,cy:t,rx:n,ry:n}}}var ef=new Set(["text","brace","brace-r","braces","datastore","fork","f-circ","state-start","state-end","state-fork","state-join"]);function eg(e){return!ef.has(e.semanticShape??e.shape)}function ep(e,t,n){let i=er(e,t,n,{fill:"none",reason:"open symbol has no enclosing painted boundary"});return i.routing={kind:"envelope",x:e.x,y:e.y,width:e.width,height:e.height,reason:"open symbol routes to its layout envelope"},i}function em(e,t,n){let i=er(e,t,n);return i.routing={kind:"rect",x:e.x,y:e.y,width:e.width,height:e.height},i}function eM(e,t,n,i=1e-6){let r=eo(e).boundary;if("envelope"!==r.kind&&"none"!==r.kind)return eb(r,t,n,i)}function eb(e,t,n,i){let r=n.x-t.x,a=n.y-t.y,o=Math.hypot(r,a);if(o<=1e-9||Math.abs(r)>i&&Math.abs(a)>i)return!1;let s=Math.abs(r)>Math.abs(a)?r>0?"E":"W":a>0?"S":"N",l="E"===s||"W"===s?t.y:t.x,h=el(e,s,l);if(!h||Math.hypot(h.x-t.x,h.y-t.y)>i)return!1;let u=0,d=0;if("ellipse"===e.kind)u=(t.x-e.cx)/e.rx/e.rx,d=(t.y-e.cy)/e.ry/e.ry;else if("stadium"===e.kind){let n=e.halfWidth-e.radius;u=t.x-Math.max(e.cx-n,Math.min(e.cx+n,t.x)),d=t.y-e.cy}else{if("cylinder"!==e.kind)return!0;let n=e.y+e.capRadiusY,i=e.y+e.height-e.capRadiusY;t.y>=n&&t.y<=i?u=t.x-e.cx:(u=(t.x-e.cx)/(e.width/2)/(e.width/2),d=(t.y-(t.y<n?n:i))/e.capRadiusY/e.capRadiusY)}let x=Math.hypot(u,d);return x>0&&Number.isFinite(x)&&(r/o*u+a/o*d)/x>0}function e$(e,t){if("polygon"===e.kind){let n=!1;for(let i=0,r=e.points.length-1;i<e.points.length;r=i++){let a=e.points[i],o=e.points[r],s=o.x-a.x,l=o.y-a.y;if(Math.abs((t.x-a.x)*l-(t.y-a.y)*s)<=1e-6*Math.hypot(s,l)&&(t.x-a.x)*(t.x-o.x)+(t.y-a.y)*(t.y-o.y)<=1e-6)return!0;a.y>t.y!=o.y>t.y&&t.x<(o.x-a.x)*(t.y-a.y)/(o.y-a.y)+a.x&&(n=!n)}return n}let n=el(e,"W",t.y),i=el(e,"E",t.y);return!!(n&&i&&t.x>=n.x-1e-6&&t.x<=i.x+1e-6)}function ew(e,t,n){if(!e$(e,t)||!e$(e,n))return!0;if("polygon"!==e.kind)return!1;let i=n.x-t.x,r=n.y-t.y,a=1e-6>=Math.abs(i),o=a?r:i;if(1e-9>=Math.abs(o))return!1;let s=[0,1];for(let n=0;n<e.points.length;n++){let i=e.points[n],r=e.points[(n+1)%e.points.length],l=a?eW(t.x,i,r):eN(t.y,i,r);if(l){let e=(a?l.y-t.y:l.x-t.x)/o;e>0&&e<1&&s.push(e)}}return s.sort((e,t)=>e-t),s.some((n,a)=>{let o=s[a+1];if(void 0===o||o-n<=1e-9)return!1;let l=(n+o)/2;return!e$(e,{x:t.x+i*l,y:t.y+r*l})})}function ek(e,t,n){if(e.length<2)return e;let i=eo(t).boundary;if("envelope"===i.kind||"none"===i.kind)return e;let r=n?e:[...e].reverse(),a=r[0];if(!e$(i,a))return e;let o=r.find(e=>Math.hypot(e.x-a.x,e.y-a.y)>1e-9);if(!o||eb(i,a,o,1e-6))return e;for(let t=0;t<r.length-1;t++){let a=r[t],o=r[t+1],s=o.x-a.x,l=o.y-a.y,h=Math.hypot(s,l);if(h<=1e-9)continue;if(Math.abs(s)>1e-6&&Math.abs(l)>1e-6)break;let u=Math.abs(s)>Math.abs(l)?s>0?"E":"W":l>0?"S":"N",d="polygon"===i.kind?eC(a,o,i.points):el(i,u,"E"===u||"W"===u?a.y:a.x);if(d){let u=((d.x-a.x)*s+(d.y-a.y)*l)/h**2,x=r.slice(t+1),y=x.find(e=>Math.hypot(e.x-d.x,e.y-d.y)>1e-9);if(u>=-1e-9&&u<=1+1e-9&&y&&eb(i,d,y,1e-6)){if(ew(i,a,d))return e;let t=1e-9>=Math.hypot(d.x-o.x,d.y-o.y)?x:[d,...x];return n?t:t.reverse()}}if(ew(i,a,o))break}return e}function ev(e,t,n){if(e.length<2)return e;let i=eo(t).boundary;if("rect"===i.kind||"envelope"===i.kind||"none"===i.kind)return e;let r=[...e];if(n)r[0]=eS(e[0],e[1],t,i);else{let n=e.length-1;r[n]=eS(e[n],e[n-1],t,i)}return r}function eS(e,t,n,i){let r=function(e,t,n){switch(n.kind){case"ellipse":return function(e,t,n){let{cx:i,cy:r,rx:a,ry:o}=n;if(a<=0||o<=0)return null;let{vertical:s,dir:l}=eP(e,t);if(s){let t=(e.x-i)/a;return Math.abs(t)>1?null:{x:e.x,y:r-l*o*Math.sqrt(Math.max(0,1-t*t))}}let h=(e.y-r)/o;return Math.abs(h)>1?null:{x:i-l*a*Math.sqrt(Math.max(0,1-h*h)),y:e.y}}(e,t,n);case"stadium":return function(e,t,n){let{cx:i,cy:r,halfWidth:a,radius:o}=n,{vertical:s,dir:l}=eP(e,t);if(s){let t=Math.abs(e.x-i);if(t<=a-o)return{x:e.x,y:r-l*o};let n=t-(a-o);return n>o?null:{x:e.x,y:r-l*Math.sqrt(Math.max(0,o*o-n*n))}}let h=Math.abs(e.y-r);return h>o?null:{x:i-l*(a-o+Math.sqrt(Math.max(0,o*o-h*h))),y:e.y}}(e,t,n);case"cylinder":return function(e,t,n){let{cx:i,y:r,width:a,height:o,capRadiusY:s}=n,l=a/2,h=r+s,u=r+o-s,{vertical:d,dir:x}=eP(e,t);if(!d){if(e.y>=h&&e.y<=u)return{x:i-x*l,y:e.y};let t=e.y<h?h:u,n=(e.y-t)/s;return Math.abs(n)>1?null:{x:i-x*l*Math.sqrt(Math.max(0,1-n*n)),y:e.y}}let y=(e.x-i)/l;if(Math.abs(y)>1)return null;let c=s*Math.sqrt(Math.max(0,1-y*y));return x>0?{x:e.x,y:h-c}:{x:e.x,y:u+c}}(e,t,n);case"polygon":return eC(e,t,n.points);case"rect":case"envelope":case"none":return e}}(e,t,i);if(null!==r)return r;if(e.x<n.x-1e-6||e.x>n.x+n.width+1e-6||e.y<n.y-1e-6||e.y>n.y+n.height+1e-6)return e;let a=[1e-6>=Math.abs(e.y-n.y)?"N":void 0,1e-6>=Math.abs(e.y-n.y-n.height)?"S":void 0,1e-6>=Math.abs(e.x-n.x)?"W":void 0,1e-6>=Math.abs(e.x-n.x-n.width)?"E":void 0].filter(e=>void 0!==e),o=1===a.length?a[0]:void 0;return o?el(i,o,"N"===o||"S"===o?e.x:e.y)??e:e}function eP(e,t){let n=e.x-t.x,i=e.y-t.y,r=Math.abs(n)<Math.abs(i);return{vertical:r,dir:(r?i:n)>=0?1:-1}}function eC(e,t,n){let{vertical:i}=eP(e,t),r=null,a=1/0;for(let o=0;o<n.length;o++){let s=n[o],l=n[(o+1)%n.length],h=l.x-s.x,u=l.y-s.y,d=e.x-s.x,x=e.y-s.y;if(1e-6>Math.abs(d*u-x*h)&&d*(e.x-l.x)+x*(e.y-l.y)<=1e-6){let i=Math.hypot(t.x-e.x,t.y-e.y),r=i>0?Math.min(1e-4/i,.5):0,a={x:e.x+(t.x-e.x)*r,y:e.y+(t.y-e.y)*r},o=!1,s=!1;for(let r=0,l=n.length-1;r<n.length;l=r++){let h=n[r],u=n[l],d=t.x-e.x,x=t.y-e.y,y=u.x-h.x,c=u.y-h.y,f=d*c-x*y;if(Math.abs(f)>1e-9){let t=h.x-e.x,n=h.y-e.y,r=(t*c-n*y)/f,a=(t*x-n*d)/f;r*i>1e-6&&r<=1&&a>=0&&a<=1&&(s=!0)}h.y>a.y!=u.y>a.y&&a.x<(u.x-h.x)*(a.y-h.y)/(u.y-h.y)+h.x&&(o=!o)}if(!o&&!s)return e}let y=i?eW(e.x,s,l):eN(e.y,s,l);if(!y)continue;let c=Math.hypot(y.x-t.x,y.y-t.y);c<a&&(r=y,a=c)}return r}function eN(e,t,n){let i=n.y-t.y;if(1e-6>Math.abs(i))return null;let r=(e-t.y)/i;return r<0||r>1?null:{x:t.x+r*(n.x-t.x),y:e}}function eW(e,t,n){let i=n.x-t.x;if(1e-6>Math.abs(i))return null;let r=(e-t.x)/i;return r<0||r>1?null:{x:e,y:t.y+r*(n.y-t.y)}}var eL=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 eE(e,t,n=1.5){if("text"===e.semanticShape)return{policy:"none",onBoundary:!1};if(e.semanticShape&&eL.has(e.semanticShape))return{policy:"envelope",onBoundary:eI(t,e.x,e.y,e.width,e.height,n)};let i=function(e){let{x:t,y:n,width:i,height:r}=e,a=t+i,o=n+r,s=t+i/2,l=n+r/2;switch(e.semanticShape){case"bang":return Array.from({length:16},(e,t)=>{let n=-Math.PI/2+t*Math.PI/8,a=t%2==0?1:.62;return{x:s+Math.cos(n)*i/2*a,y:l+Math.sin(n)*r/2*a}});case"notch-rect":case"tag-rect":return[{x:t+10,y:n},{x:a,y:n},{x:a,y:o},{x:t,y:o},{x:t,y:n+10}];case"hourglass":return[{x:t,y:n},{x:a,y:n},{x:t+.62*i,y:l},{x:a,y:o},{x:t,y:o},{x:t+.38*i,y:l}];case"bolt":return[{x:t+.55*i,y:n},{x:t+.25*i,y:l},{x:t+.48*i,y:l},{x:t+.35*i,y:o},{x:t+.78*i,y:n+.4*r},{x:t+.55*i,y:n+.4*r}];case"tri":return[{x:s,y:n},{x:a,y:o},{x:t,y:o}];case"notch-pent":return[{x:t,y:n},{x:a-10,y:n},{x:a,y:l},{x:a-10,y:o},{x:t,y:o},{x:t+8,y:l}];case"flip-tri":return[{x:t,y:n},{x:a,y:n},{x:s,y:o}];default:return null}}(e);if(i)return{policy:"exact",onBoundary:eB(t,i,n)};let r=e.x+e.width/2,a=e.y+e.height/2,o=Math.min(e.width,e.height)/2;if("fork"===e.semanticShape)return{policy:"exact",onBoundary:eI(t,e.x,a-4,e.width,8,n)};if("sm-circ"===e.semanticShape){let i=.22*Math.min(e.width,e.height);return{policy:"exact",onBoundary:eR(t,r,a,i,i,n)}}if("cross-circ"===e.semanticShape)return{policy:"exact",onBoundary:eR(t,r,a,e.width/2,e.height/2,n)};if("f-circ"===e.semanticShape)return{policy:"exact",onBoundary:eR(t,r,a,o,o,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-a)/(e.height/2)-1)*Math.min(e.width,e.height)/2<n};case"circle":case"doublecircle":case"state-history":return{policy:"exact",onBoundary:eR(t,r,a,o,o,n)};case"state-start":case"state-end":{let e=Math.max(0,o-2);return{policy:"exact",onBoundary:eR(t,r,a,e,e,n)}}case"stadium":{let i=e.height/2,o=e.width/2-i,s=Math.abs(t.x-r);return{policy:"exact",onBoundary:s<=o?Math.abs(Math.abs(t.y-a)-i)<n:Math.abs(Math.hypot(s-o,t.y-a)-i)<n}}case"hexagon":{let i=e.height/4;return{policy:"exact",onBoundary:eB(t,[{x:e.x+i,y:e.y},{x:e.x+e.width-i,y:e.y},{x:e.x+e.width,y:a},{x:e.x+e.width-i,y:e.y+e.height},{x:e.x+i,y:e.y+e.height},{x:e.x,y:a}],n)}}case"cylinder":return{policy:"exact",onBoundary:function(e,t,n){let i=e.x+e.width/2,r=e.y+e.height/2,a=e.width/2;if(t.y>=e.y+7-n&&t.y<=e.y+e.height-7+n&&Math.abs(Math.abs(t.x-i)-a)<n)return!0;let o=t.y<r?e.y+7:e.y+e.height-7;return Math.abs(Math.hypot((t.x-i)/a,(t.y-o)/7)-1)*Math.min(a,7)<2*n}(e,t,n)};case"trapezoid":case"trapezoid-alt":case"lean-r":case"lean-l":case"asymmetric":return{policy:"exact",onBoundary:eB(t,function(e){let{x:t,y:n,width:i,height:r}=e,a=t+i,o=n+r,s=.15*i;switch(e.shape){case"trapezoid":return[{x:t+s,y:n},{x:a-s,y:n},{x:a,y:o},{x:t,y:o}];case"trapezoid-alt":return[{x:t,y:n},{x:a,y:n},{x:a-s,y:o},{x:t+s,y:o}];case"lean-r":return[{x:t+s,y:n},{x:a,y:n},{x:a-s,y:o},{x:t,y:o}];case"lean-l":return[{x:t,y:n},{x:a-s,y:n},{x:a,y:o},{x:t+s,y:o}];default:return[{x:t+12,y:n},{x:a,y:n},{x:a,y:o},{x:t+12,y:o},{x:t,y:n+r/2}]}}(e),n)};default:return{policy:"exact",onBoundary:eI(t,e.x,e.y,e.width,e.height,n)}}}function eI(e,t,n,i,r,a){let o=Math.abs(e.x-t)<a||Math.abs(e.x-(t+i))<a,s=Math.abs(e.y-n)<a||Math.abs(e.y-(n+r))<a;return o&&e.y>=n-a&&e.y<=n+r+a||s&&e.x>=t-a&&e.x<=t+i+a}function eR(e,t,n,i,r,a){return!(i<=0)&&!(r<=0)&&Math.abs(Math.hypot((e.x-t)/i,(e.y-n)/r)-1)*Math.min(i,r)<a}function eB(e,t,n){let i=1/0;for(let n=0;n<t.length;n++)i=Math.min(i,function(e,t,n){let i=n.x-t.x,r=n.y-t.y,a=i*i+r*r;if(0===a)return Math.hypot(e.x-t.x,e.y-t.y);let o=Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/a));return Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*r))}(e,t[n],t[(n+1)%t.length]));return i<=n}var eH=64,eA=128;function eF(e){let t=e.nodes.size,n=e=>{for(let i of e)t++,n(i.children)};return n(e.subgraphs),t<=eH&&e.edges.length<=eA}function eO(e,t,n="end"){return Math.max(12,D(t??{style:"solid",hasArrowStart:!0,hasArrowEnd:!0},e)[n]+(e.edgeBendRadius??0))}var ez=new Set([...new Set(["rectangle","service","rounded","subroutine","state-fork","state-join"]),"diamond","circle","ellipse","doublecircle","stadium","hexagon","cylinder","state-start","state-end","state-choice","state-history","trapezoid","trapezoid-alt","asymmetric","lean-r","lean-l"]);function ej(e){return es(e)}function eV(e){let t=e.x+e.width/2,n=e.y+e.height/2,i=e.width/4,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 eY(e,t){let n=eo(e);if("envelope"!==n.boundary.kind&&"none"!==n.boundary.kind){for(let e of["N","E","S","W"]){let i=n.sides[e].preferred;if(.5>=Math.abs(i.x-t.x)&&.5>=Math.abs(i.y-t.y))return e}if(eJ(e)){let n=eV(e);for(let e of["NE","SE","SW","NW"])if(.5>=Math.abs(n[e].x-t.x)&&.5>=Math.abs(n[e].y-t.y))return e}}}function eQ(e,t,n){let i=0;for(let[r,a]of[[t,!0],[n,!1]]){if(!r)continue;let t=eo(r);if("envelope"===t.boundary.kind||"none"===t.boundary.kind)continue;let n=a?e.points:[...e.points].reverse(),o=n[0],s=o&&n.find(e=>Math.hypot(e.x-o.x,e.y-o.y)>.01);if(!o||!s){i++;continue}let l=s.x-o.x,h=s.y-o.y;Math.abs(l)>.01&&Math.abs(h)>.01||eM(r,o,s,.5)||i++}return i}function eq(e,t,n){for(let[i,r]of[[t,!0],[n,!1]]){if(!i)continue;let t=eo(i);if("envelope"!==t.boundary.kind&&"none"!==t.boundary.kind)for(;e.points.length>2;){let[t,n]=r?e.points:[...e.points].reverse(),a={x:(t.x+n.x)/2,y:(t.y+n.y)/2};if(![t,n,a].every(e=>eE(i,e,.01).onBoundary))break;let o={...e,points:r?e.points.slice(1):e.points.slice(0,-1)};if(0!==eQ(o,r?i:void 0,r?void 0:i))break;e.points=o.points}}}function eT(e){let t=eo(e).boundary;return"envelope"!==t.kind&&"none"!==t.kind}function eJ(e){let t=eo(e);return"polygon"===t.boundary.kind&&["N","E","S","W"].every(e=>"dynamic"===t.sides[e].kind)}function eZ(e){let t=new Set,n=new Map,i=(e,r)=>{for(let r of e){for(let e of(t.add(r.id),r.nodeIds))n.set(e,r.id);i(r.children,r.id)}};i(e.subgraphs,"");let r=new Map;return e.edges.map(e=>{if(e.source===e.target)return"self-loop";if(t.has(e.source)||t.has(e.target))return"container";let i=((e,t)=>{let n=new Set,i=[e];for(;i.length>0;){let e=i.pop();if(e===t)return!0;if(!n.has(e))for(let t of(n.add(e),r.get(e)??[]))i.push(t)}return!1})(e.target,e.source)?"feedback":(n.get(e.source)??"")!==(n.get(e.target)??"")?"cross-hierarchy":"primary-forward";return"feedback"!==i&&(r.has(e.source)||r.set(e.source,new Set),r.get(e.source).add(e.target)),i})}function eU(e){let t="LR"===e||"RL"===e;return{main:t?"x":"y",cross:t?"y":"x",sign:"RL"===e||"BT"===e?-1:1}}function e_(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 eX(e){let t=e;for(let e=0;e<8&&!(t.length<3);e++){let e=[t[0]];for(let n=1;n<t.length;n++){let i=t[n],r=e[e.length-1];if(.01>Math.abs(i.x-r.x)&&.01>Math.abs(i.y-r.y)){let e=t[n+1];if(e?!e_(r,i,e):i.x===r.x&&i.y===r.y)continue}e.push(i)}let n=e.length<3?e:[e[0]];if(e.length>=3){for(let t=1;t<e.length-1;t++){let i=n[n.length-1],r=e[t],a=e[t+1];.01>Math.abs((r.x-i.x)*(a.y-i.y)-(r.y-i.y)*(a.x-i.x))&&!e_(i,r,a)||n.push(r)}n.push(e[e.length-1])}if(n.length===t.length)return n;t=n}return t}function eD(e){let t=!1;for(let n=1;n<e.length;n++){let i=e[n-1],r=e[n];if(Math.abs(i.x-r.x)>.01&&Math.abs(i.y-r.y)>.01){t=!0;break}}if(!t)return e;let n=[e[0]];for(let t=1;t<e.length;t++){let i=n[n.length-1],r=e[t];if(Math.abs(i.x-r.x)>.01&&Math.abs(i.y-r.y)>.01){let e=n.length>=2?n[n.length-2]:void 0,t=!e||.01>Math.abs(e.y-i.y);n.push(t?{x:r.x,y:i.y}:{x:i.x,y:r.y})}n.push(r)}return n}function eG(e){return e.length<3?0:Math.max(0,eX(e.map(e=>({x:Number(E(e.x)),y:Number(E(e.y))}))).length-2)}function eK(e,t){for(let n=1;n<e.length;n++){let i=e[n-1],r=e[n],a=(r[t.main]-i[t.main])*t.sign,o=Math.abs(r[t.cross]-i[t.cross]);if(a>.01&&o>.01||a<-.01)return!1}return!0}function e1(e,t,n){let i=eo(e).sides[e2(t,n)];if("dynamic"===i.kind)return{lo:i.lo,hi:i.hi};if("port"===i.kind){let e=i.point[t.cross];return{lo:e-.5,hi:e+.5}}return null}function e0(e,t,n,i){var r,a;let o;return(r=eo(e),a=e2(n,i),"none"===(o=r.sides[a]).kind?null:"port"===o.kind?o.point:el(r.boundary,a,t))?.[n.main]??null}function e2(e,t){let n=t*e.sign>0;return"x"===e.main?n?"E":"W":n?"S":"N"}function e5(e,t,n){return{role:`${"feedback"===e||"self-loop"===e||"container"===e||"cross-hierarchy"===e?e:"flow"}-${t}`,side:e2(n,"source"===t!=("feedback"===e)?1:-1)}}function e8(e,t,n){return n?"N"===e||"S"===e?n.x:n.y:"N"===e||"S"===e?t.x+t.width/2:t.y+t.height/2}function e4(e,t,n=eZ(t)){return tt(e,t,n,!0)}function e6(e,t,n,i,r,a=!1){let o=eU(t.direction),s=tt(e,t,i,!1).sideUse;for(let t of e.edges){if(!r(t)||void 0===t.edgeIndex)continue;let e=i[t.edgeIndex];if("primary-forward"===e||"feedback"===e&&!t.label)for(let n of["source","target"]){let i="source"===n?t.source:t.target,{side:r}=e5(e,n,o),a=`${i}:${r}`,l=(s.get(a)??0)-1;l>0?s.set(a,l):s.delete(a)}}return{axis:o,ctx:{nodes:e.nodes,edges:e.edges,groups:e.groups,axis:o,style:n,classes:i,sideUse:s,finalLabelClearance:a,nodeLaneIndexes:z()?void 0:{},routeChannelGeometry:z()?void 0:new WeakMap}}}function e3(e,t,n){return"x"===e.main?{x:t,y:n}:{x:n,y:t}}function e9(e,t,n){return{main:e.cross,cross:e.main,sign:t<n?1:-1}}function e7(e,t,n){e.routeChannelGeometry?.delete(t),t.points=n}function te(e){let t=new Map;return e.forEach(e=>t.set(e.id,e)),t}function tt(e,t,n,i){let r=eU(t.direction),a=te(e.nodes),o=[],s=new Map,l=(e,t)=>{let n=`${e}:${t}`;s.set(n,(s.get(n)??0)+1)};for(let t of e.edges){if(void 0===t.edgeIndex)continue;let e=n[t.edgeIndex]??"primary-forward";for(let n of["source","target"]){let s="source"===n?t.source:t.target,h=a.get(s);if(!h)continue;let{role:u,side:d}=e5(e,n,r),x="source"===n?t.points[0]:t.points[t.points.length-1],y=x?eY(h,x):void 0,c=y?"N"===y||"E"===y||"S"===y||"W"===y?y:y.includes(d)?d:y[0]:d;if("primary-forward"!==e&&("feedback"!==e||t.label)||l(s,d),!i){e8(c,h,x);continue}o.push({edge:t,endpoint:n,nodeId:s,side:c,role:u,coord:e8(c,h,x),edgeIndex:t.edgeIndex,port:y})}}if(!i)return{byEdge:new Map,sideUse:s};let h=new Map;for(let e of o){let t=`${e.nodeId}:${e.side}`;h.has(t)||h.set(t,[]),h.get(t).push(e)}let u=new Map,d=e=>+("source"!==e);for(let e of h.values()){e.sort((e,t)=>e.coord-t.coord||e.edgeIndex-t.edgeIndex||d(e.endpoint)-d(t.endpoint));let t=e.length;e.forEach((e,n)=>{let i={side:e.side,slotIndex:n,slotCount:t,role:e.role,...e.port?{port:e.port}:{}},r=u.get(e.edge)??{};r[e.endpoint]=i,u.set(e.edge,r)})}return{byEdge:u,sideUse:s}}function tn(e,t,n,i,r){let a=0,o=0,s=e=>{for(let t of(a=Math.min(a,e.x),o=Math.min(o,e.y),e.children))s(t)};for(let t of e)a=Math.min(a,t.x),o=Math.min(o,t.y);for(let e of n)s(e);for(let e of t){for(let t of e.points)a=Math.min(a,t.x),o=Math.min(o,t.y);let t=r&&e.labelBlock?x(e,r):null;t?(a=Math.min(a,t.x),o=Math.min(o,t.y)):e.labelPosition&&(a=Math.min(a,e.labelPosition.x),o=Math.min(o,e.labelPosition.y))}if(a>=0&&o>=0)return;let l=a<0?-a+i:0,h=o<0?-o+i:0,u=e=>{for(let t of(e.x+=l,e.y+=h,e.children))u(t)};for(let t of e)t.x+=l,t.y+=h;for(let e of n)u(e);for(let e of t){for(let t of e.points)t.x+=l,t.y+=h;e.labelPosition&&(e.labelPosition.x+=l,e.labelPosition.y+=h)}}function ti(e,t){return e.some((n,i)=>i>0&&t.some((r,a)=>a>0&&((e,t,n,i)=>{let r=.01>=Math.abs(e.x-t.x);if(r===.01>=Math.abs(n.x-i.x)){if(!(r?.01>=Math.abs(e.x-n.x):.01>=Math.abs(e.y-n.y)))return!1;let[a,o]=r?[Math.min(e.y,t.y),Math.max(e.y,t.y)]:[Math.min(e.x,t.x),Math.max(e.x,t.x)],[s,l]=r?[Math.min(n.y,i.y),Math.max(n.y,i.y)]:[Math.min(n.x,i.x),Math.max(n.x,i.x)];return Math.min(o,l)-Math.max(a,s)>.01}let a=r?{a:e,b:t}:{a:n,b:i},o=r?{a:n,b:i}:{a:e,b:t},s=a.a.x,l=o.a.y;return s>Math.min(o.a.x,o.b.x)+.01&&s<Math.max(o.a.x,o.b.x)-.01&&l>Math.min(a.a.y,a.b.y)+.01&&l<Math.max(a.a.y,a.b.y)-.01})(e[i-1],n,t[a-1],r)))}function tr(e,t){for(let n=1;n<e.length;n++){t?.(1);let i=e[n-1],r=e[n];if(!Number.isFinite(i.x)||!Number.isFinite(i.y)||!Number.isFinite(r.x)||!Number.isFinite(r.y)||i.x!==r.x&&i.y!==r.y||i.x===r.x&&i.y===r.y)return!1;let a=i.x===r.x;for(let o=1;o<n;o++){t?.(1);let s=e[o-1],l=e[o];if(a===(s.x===l.x)){let e=a?"y":"x",t=a?"x":"y";if(i[t]!==s[t])continue;let h=Math.max(Math.min(i[e],r[e]),Math.min(s[e],l[e])),u=Math.min(Math.max(i[e],r[e]),Math.max(s[e],l[e]));if(o===n-1?h<u:h<=u)return!1}else if(o!==n-1){let e=a?i.x:s.x,t=a?s.y:i.y;if(e>=Math.min(i.x,r.x)&&e<=Math.max(i.x,r.x)&&t>=Math.min(i.y,r.y)&&t<=Math.max(i.y,r.y)&&e>=Math.min(s.x,l.x)&&e<=Math.max(s.x,l.x)&&t>=Math.min(s.y,l.y)&&t<=Math.max(s.y,l.y))return!1}}}return!0}var ta=new WeakMap;function to(e){let t=e.points[0];if(!t)return;let n=[];for(let i of e.points)n.push(i.x-t.x,i.y-t.y);ta.set(e,{source:e.source,target:e.target,edgeIndex:e.edgeIndex,coordinates:n})}function ts(e,t){let n=e[0];if(!n||e.length<2||!(e.every(e=>e.source===n.source)||e.every(e=>e.target===n.target)||e.every(e=>e.source===n.source&&e.target===n.target||e.source===n.target&&e.target===n.source)))throw Error("Bundle construction requires related fan or parallel routes");for(let n of e)to(n),t.add(n)}function tl(e){let t=ta.get(e);if(!t||e.source!==t.source||e.target!==t.target||e.edgeIndex!==t.edgeIndex||2*e.points.length!==t.coordinates.length)return!1;let n=e.points[0];if(!n)return!1;for(let i=0;i<e.points.length;i++){let r=e.points[i];if(!(1e-6>=Math.abs(r.x-n.x-t.coordinates[2*i]))||!(1e-6>=Math.abs(r.y-n.y-t.coordinates[2*i+1])))return!1}return!0}function th(e){return tl(e)?ta.get(e):void 0}function tu(e,t){t&&ta.get(e)===t&&e.source===t.source&&e.target===t.target&&e.edgeIndex===t.edgeIndex&&to(e)}function td(e,t){for(let n=1;n<e.length;n++){let i=e[n-1],a=e[n],o=Math.min(i.x,a.x),s=Math.max(i.x,a.x),l=Math.min(i.y,a.y),h=Math.max(i.y,a.y);for(let n=1;n<t.length;n++){let u=t[n-1],d=t[n];if(!(s<Math.min(u.x,d.x)||o>Math.max(u.x,d.x)||h<Math.min(u.y,d.y)||l>Math.max(u.y,d.y))&&(i.x!==a.x||u.x!==d.x)&&(i.y!==a.y||u.y!==d.y))return r([{points:e},{points:t}])}}return 0}function tx(e,t){let n=e.points.map(e=>({x:Number(E(e.x)),y:Number(E(e.y))})),i="thick"===e.style?2:1,r=Number(E((t.lineWidth??1)*i))/i,a={...t,lineWidth:r},o=!e.curve&&!(t.edgeBendRadius&&t.edgeBendRadius>0);return o?{regions:K({...e,points:n},a),points:n,directional:o}:{regions:K(e,a).map(e=>{let t="start"===e.position?n[0]:n.at(-1),i=e.bounds;if(!i)return{...e,anchor:t};let r=Math.max(...[i.x0,i.x1].flatMap(t=>[i.y0,i.y1].map(n=>Math.hypot(t-e.anchor.x,n-e.anchor.y))));return{...e,anchor:t,bounds:{x0:t.x-r,y0:t.y-r,x1:t.x+r,y1:t.y+r}}}),points:n,directional:o}}function ty(e,t){if("invisible"===e.style||!e.hasArrowStart&&!e.hasArrowEnd)return[];if(!tc(e,t))return;let{regions:n}=tx(e,t);return n.length===+!!e.hasArrowStart+ +!!e.hasArrowEnd&&n.every(tf)?n:void 0}function tc(e,t){if(!e.points.every(e=>Number.isFinite(e.x)&&Number.isFinite(e.y))||void 0!==t.edgeBendRadius&&!(Number.isFinite(t.edgeBendRadius)&&t.edgeBendRadius>=0))return!1;let n=(t.lineWidth??1)*("thick"===e.style?2:1);return!!e.inlineStyle?.["stroke-width"]||Number.isFinite(n)&&n>0}function tf(e){let 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 tg(e,t,n){if("mid"===n)return!1;let i=e=>"start"===n?e[0]:e.at(-1),r=i(e),a=i(t);if(!r||!a||r.x!==a.x||r.y!==a.y)return!1;let o=e=>{for(let t=1;t<e.length;t++){let i=e["start"===n?t:e.length-t-1];if(i.x!==r.x||i.y!==r.y)return i}},s=o(e),l=o(t);return!!s&&!!l&&(s.x===l.x&&s.y===l.y||(r.x===s.x||r.y===s.y)&&(r.x===l.x||r.y===l.y)&&Math.sign(s.x-r.x)===Math.sign(l.x-r.x)&&Math.sign(s.y-r.y)===Math.sign(l.y-r.y))}function tp(e,t){let n=e.bounds,i=t.bounds;if(!n||!i||!tf(e)||!tf(t))return!1;let r=[n.x0,n.y0,n.x1,n.y1,i.x0,i.y0,i.x1,i.y1];if(!r.every(Number.isFinite))return!1;let a=1e-10*r.reduce((e,t)=>e+Math.abs(t),0)+1e-9;return Number.isFinite(a)&&(n.x1+a<i.x0||i.x1+a<n.x0||n.y1+a<i.y0||i.y1+a<n.y0)}function tm(e,t){if(e.label&&t.label||e.style!==t.style||e.curve!==t.curve||e.animate!==t.animate||e.animation!==t.animation)return!1;let n=e.inlineStyle??{},i=t.inlineStyle??{};for(let e in n)if(!(e in i)||i[e]!==n[e])return!1;for(let e in i)if(!(e in n))return!1;let r=e.classNames??[],a=t.classNames??[];if(r.length!==a.length)return!1;for(let e=0;e<r.length;e++)if(r[e]!==a[e])return!1;return!0}function tM(e,t,n,i,r=e){if(!e.hasArrowStart&&!e.hasArrowEnd||"invisible"===e.style)return;let a=(e,t,i)=>({kind:"port",id:`${i}:${e.id??`${e.source}->${e.target}[${e.edgeIndex??n.indexOf(e)}]`}:${t}`});if(!tc({...e,points:t},i))return a(r,"mapping","marker");let o=tx(e,i),s=tx({...e,points:t},i),l=o.regions,h=s.regions;if(h.length!==+!!e.hasArrowStart+ +!!e.hasArrowEnd)return a(r,"unmeasured","marker");for(let u of h){let d=l.find(e=>e.position===u.position);if(!(d&&d.resource===u.resource&&d.repaint===u.repaint&&d.anchor.x===u.anchor.x&&d.anchor.y===u.anchor.y&&(o.directional&&s.directional?tg(o.points,s.points,u.position):e.curve?e.points.length===t.length&&e.points.every((e,n)=>e.x===t[n].x&&e.y===t[n].y):function(e,t,n){if("mid"===n||e.length<2||t.length<2)return!1;let i=e=>"start"===n?[e[0],e[1]]:[e.at(-1),e.at(-2)],[r,a]=i(e),[o,s]=i(t);return r.x===o.x&&r.y===o.y&&a.x===s.x&&a.y===s.y}(e.points,t,u.position)))){if(!tf(u))return a(r,u.position,"marker");for(let e of h)if(e!==u&&!tp(u,e))return a(r,e.position,"opposite-marker");for(let t of n){if(t===r||"invisible"===t.style||!t.hasArrowStart&&!t.hasArrowEnd)continue;if(!tc(t,i))return a(t,"mapping","peer-marker");let n=tx(t,i);for(let i of n.regions){let r="start"===u.position?e.source:e.target,o="start"===i.position?t.source:t.target;if(!(s.directional&&n.directional&&tf(i)&&u.position===i.position&&r===o&&u.resource===i.resource&&u.repaint===i.repaint&&u.anchor.x===i.anchor.x&&u.anchor.y===i.anchor.y&&tg(s.points,n.points,u.position)&&tm(e,t))&&!tp(u,i))return a(t,i.position,"peer-marker")}}}}}function tb(e,t,n,i,r=e){return void 0===tM(e,t,n,i,r)}function t$(e){return eJ(e)?2:1}function tw(e,t){return eJ(e)&&("NE"===t||"SE"===t||"SW"===t||"NW"===t)?eV(e)[t]:ej(e)[t]}function tk(e,t,n,i){let r=eo(t).boundary;if("rect"!==r.kind||e.points.length<2)return;let a=n?0:e.points.length-1,o=e.points[a],s=r.x,l=r.x+r.width,h=r.y,u=r.y+r.height,d=(e,t)=>.5>=Math.abs(e-t),x=(t,r)=>{let o=[...e.points];if(o[a]=t,Math.abs(t.x-r.x)>.01||Math.abs(t.y-r.y)>.01)if(n){let e=o[1];(!e||Math.abs(e.x-r.x)>.01||Math.abs(e.y-r.y)>.01)&&o.splice(1,0,r)}else{let e=o[o.length-2];(!e||Math.abs(e.x-r.x)>.01||Math.abs(e.y-r.y)>.01)&&o.splice(o.length-1,0,r)}tb(e,o,i.edges,i.style)&&e7(i,e,o)};if(d(o.x,s)||d(o.x,l)){let e=d(o.x,s)?s:l;o.y<h-.5?x({x:e,y:h},{x:e,y:o.y}):o.y>u+.5&&x({x:e,y:u},{x:e,y:o.y});return}if(d(o.y,h)||d(o.y,u)){let e=d(o.y,h)?h:u;o.x<s-.5?x({x:s,y:e},{x:o.x,y:e}):o.x>l+.5&&x({x:l,y:e},{x:o.x,y:e})}}function tv(e,t,n,i){if(!eJ(t)||void 0===e.edgeIndex||n.classes?.[e.edgeIndex]!=="primary-forward")return null;let r=te(n.nodes),a=n.edges.filter(t=>t.source===e.source&&void 0!==t.edgeIndex&&n.classes?.[t.edgeIndex]==="primary-forward"&&r.has(t.target)).sort((e,t)=>{let n=r.get(e.target),a=r.get(t.target);return n[i.cross]+("y"===i.cross?n.height:n.width)/2-(a[i.cross]+("y"===i.cross?a.height:a.width)/2)||(e.edgeIndex??0)-(t.edgeIndex??0)}),o=function(e,t){if(2!==t&&3!==t)return null;let n=e2(e,1),i="E"===n?"NE":"S"===n?"SW":"NW",r="W"===n?"SW":"N"===n?"NE":"SE";return 2===t?[i,r]:[i,n,r]}(i,a.length);if(!o)return null;let s=a.indexOf(e);if(s<0)return null;let l=o[s],h=a.map(e=>{let t=r.get(e.target);return t[i.main]+("x"===i.main?t.width:t.height)/2});return{sourcePort:l,sourceLane:tw(t,l)[i.cross],targetsShareRank:Math.max(...h)-Math.min(...h)<=1}}function tS(e,t,n,i,r){let a=tv(e,t,i,r);if(!a||!a.targetsShareRank)return null;let o=e2(r,-1),s=ej(n)[o][r.cross];return .5>=Math.abs(a.sourceLane-s)?null:{sourcePort:a.sourcePort,sourceLane:a.sourceLane,targetPort:o,targetLane:s}}function tP(e,t,n){return!n.fixedLabels&&!n.finalLabelClearance&&!!n.classes&&void 0!==e.edgeIndex&&void 0!==t.edgeIndex&&"primary-forward"===n.classes[e.edgeIndex]&&"feedback"===n.classes[t.edgeIndex]&&t.source===e.target&&t.target===e.source}function tC(e){return`${e.source}->${e.target}`}function tN(e,t,n,i,r,a=r.axis){return tL(e,t,n,i,r,a,!1)}function tW(e,t,n,i,r,a){return tL(e,t,n,i,r,a,!0)}function tL(e,t,r,a,s,h,u){let d=u?void 0:[],x=i(s.nodeLaneIndexes,s.nodes,h.cross,4),y=x?n(x,t):null,c=x&&null!==y,f=c?x.offsets[y]??0:0,g=c?x.offsets[y+1]??0:s.nodes.length;for(let n=f;n<g;n++){let i=s.nodes[c?x.ordinals[n]:n];if(i.id===e.source||i.id===e.target)continue;let o=("x"===h.cross?i.x:i.y)-4,l=("x"===h.cross?i.x:i.y)+("y"===h.cross?i.height:i.width)+4;if(t>o&&t<l){let e=("x"===h.main?i.x:i.y)-4;if(Math.min(a,("x"===h.main?i.x:i.y)+("x"===h.main?i.width:i.height)+4)-Math.max(r,e)>.01){if(u)return!0;d.push({kind:"node",id:i.id})}}}if(s.groups?.length&&"invisible"!==e.style){let e=n=>{let i=n.concurrencyRegion?0:n.headerHeight??n.height,o=!Number.isFinite(i)||i<0,s="x"===h.cross?n.x:n.y,l=s+("x"===h.cross?n.width:i),x="x"===h.main?n.x:n.y,y=x+("x"===h.main?n.width:i);if(o||i>0&&n.width>0&&t>s&&t<l&&Math.min(a,y)>Math.max(r,x)){if(u)return!0;d.push({kind:"group-header",id:n.id})}for(let t of n.children)if(e(t))return!0;return!1};for(let t of s.groups)if(e(t))return!0}let p=s.routeChannelGeometry;for(let n=0;n<s.edges.length;n++){let i=s.edges[n];if(i===e||void 0!==e.edgeIndex&&i.edgeIndex===e.edgeIndex)continue;let x=!tP(e,i,s)&&i.label&&i.labelPosition?i.labelBlock??o(N(i.label,i.labelContent),s.style):void 0;if(x){let e=x.width+2*l,n=x.height+2*l,o=i.labelPosition.x-e/2,s=i.labelPosition.y-n/2,y=("x"===h.main?o:s)-4,c=y+("x"===h.main?e:n)+8,f=("y"===h.cross?s:o)-4,g=f+("y"===h.cross?n:e)+8;if(t>f&&t<g&&Math.min(a,c)-Math.max(r,y)>.01){if(u)return!0;d.push({kind:"label",id:tC(i)})}}if(!(p&&!function(e,t,n,i,r,a,o,s){if(!Number.isFinite(i)||!Number.isFinite(r)||!Number.isFinite(a))return!0;if(t.points.length<2)return!1;let l=e.get(t);if(void 0===l&&(l=function(e){let t=1/0,n=-1/0,i=1/0,r=-1/0;for(let a of e){let e=a.x,o=a.y;if(!Number.isFinite(e)||!Number.isFinite(o))return null;t=Math.min(t,e),n=Math.max(n,e),i=Math.min(i,o),r=Math.max(r,o)}return{minX:t,maxX:n,minY:i,maxY:r}}(t.points),e.set(t,l)),!l)return!0;let h="x"===n?l.minX:l.minY,u="x"===n?l.maxX:l.maxY;if(i<h&&h-i>=4||i>u&&i-u>=4)return!1;let d="x"===n?l.minY:l.minX;return Math.min(a,"x"===n?l.maxY:l.maxX)-Math.max(r,d)>.01}(p,i,h.cross,t,r,a,0,0)))for(let n=1;n<i.points.length;n++){let o=i.points[n-1],s=i.points[n];if(Math.abs(("x"===h.cross?o.x:o.y)-("x"===h.cross?s.x:s.y))>.01||Math.abs(("x"===h.cross?o.x:o.y)-t)>=4)continue;let l=Math.min("x"===h.main?o.x:o.y,"x"===h.main?s.x:s.y);if(Math.min(a,Math.max("x"===h.main?o.x:o.y,"x"===h.main?s.x:s.y))-Math.max(r,l)>.01){if(i.target===e.target&&i.source!==e.source&&tm(e,i)&&.01>Math.abs(("x"===h.cross?o.x:o.y)-t)&&n===i.points.length-1)continue;if(u)return!0;d.push({kind:"channel",id:tC(i)});break}}}if(e.label){let t=e.labelBlock??o(N(e.label,e.labelContent),s.style);if(a-r<("x"===h.main?t.width:t.height)+2*l+8){if(u)return!0;d.push({kind:"label",id:tC(e)})}}return!u&&tB(d)}function tE(e,t,n,i){if(!e.label)return{x:(t.x+n.x)/2,y:(t.y+n.y)/2};let r=e.labelBlock??o(N(e.label,e.labelContent),i.style),a=2,s=i.style.lineWidth??1,h=u(e,s,"start"),y=u(e,s,"end"),c=t=>Math.max(i.finalLabelClearance?8:a,t.id===e.source?h:0,t.id===e.target?y:0),f=i.finalLabelClearance?16:a,g=i.finalLabelClearance?8:a,p=i.edges.filter(t=>t!==e&&(void 0===e.edgeIndex||t.edgeIndex!==e.edgeIndex)),m=t=>!i.finalLabelClearance&&tP(e,t,i)?null:x(t,i.style),M=.01>Math.abs(t.x-n.x),b=M!==.01>Math.abs(t.y-n.y),$=M?"y":"x",w=M?"x":"y",k=M?"x1":"y1",v=M?"y1":"x1",S=(M?r.height:r.width)/2+l,P=(M?r.width:r.height)/2+l,C=Math.min(t[w],n[w])-P-1e-6,W=Math.max(t[w],n[w])+P+1e-6,L=Math.min(t[$],n[$])-S-1e-6,E=Math.max(t[$],n[$])+S+1e-6,I,R=()=>{if(I)return I;let e=I=[],t=(t,n,i,r,a,o,s)=>{(!b||(M?a:o)+s>=C&&(M?t:n)-s<=W&&(M?o:a)+s>=L&&(M?n:t)-s<=E)&&e.push({x:t,y:n,w:i,h:r,x1:a,y1:o,gap:s})};for(let e of i.nodes)t(e.x,e.y,e.width,e.height,e.x+e.width,e.y+e.height,c(e));for(let e of p){let n=m(e);n&&t(n.x,n.y,n.w,n.h,n.x+n.w,n.y+n.h,f);for(let n=1;n<e.points.length;n++){let i=e.points[n-1],r=e.points[n],a=Math.min(i.x,r.x),o=Math.max(i.x,r.x),s=Math.min(i.y,r.y),l=Math.max(i.y,r.y);t(a,s,o-a,l-s,o,l,g)}}return e},B=(e,t)=>{let n=d(e,t,r);return!R().some(e=>((e,t,n,i,r,o,s,l,h=a)=>e<r+s+h&&e+n+h>r&&t<o+l+h&&t+i+h>o)(n.x,n.y,n.w,n.h,e.x,e.y,e.w,e.h,e.gap))};for(let e of[.5,1/3,2/3,.25,.75,1/6,5/6]){let i=t.x+(n.x-t.x)*e,r=t.y+(n.y-t.y)*e;if(B(i,r))return{x:i,y:r}}if(!b)return null;let H=Math.min(t[$],n[$]),A=Math.max(t[$],n[$]),F=(H+A)/2;if(A-H<2*S-.02)return null;let O=[F];for(let e of R())e[k]+e.gap<=t[w]-P||e[w]-e.gap>=t[w]+P||O.push(e[$]-e.gap-S-.01,e[v]+e.gap+S+.01);for(let e of O.filter(e=>e>=H+S-.01&&e<=A-S+.01).sort((e,t)=>Math.abs(e-F)-Math.abs(t-F)||e-t).slice(0,16)){let n="x"===$?{x:e,y:t.y}:{x:t.x,y:e};if(B(n.x,n.y))return n}return null}function tI(e,t,n,i=1/0){if("invisible"===t.style)return 0;let r=0;for(let a of n.edges)if(a!==t&&"invisible"!==a.style&&(void 0===t.edgeIndex||a.edgeIndex!==t.edgeIndex)&&(r+=td(e,a.points))>i)break;return r}function tR(e,t){for(let n of t.nodes)if(n.id!==e.source&&n.id!==e.target&&tY(e.points,n))return!0;return!1}function tB(e){let t=new Set;return e.filter(e=>{let n=`${e.kind}:${e.id}`;return!t.has(n)&&(t.add(n),!0)})}function tH(e,t,n,i,r,a){let o=e1(t,r,1),s=e1(n,r,-1);if(!o||!s)return null;let l=Math.max(o.lo,s.lo),h=Math.min(o.hi,s.hi),u=(e,t)=>eJ(e)?{lo:e[r.cross]+2,hi:e[r.cross]+("y"===r.cross?e.height:e.width)-2}:t,d=Math.max(u(t,o).lo,u(n,s).lo),x=Math.min(u(t,o).hi,u(n,s).hi),y=e=>e[r.cross]+("y"===r.cross?e.height:e.width)/2,c=e=>.5>=Math.abs(e-y(n))||.5>=Math.abs(e-y(t));if(d>x)return{overlapLo:l,overlapHi:h,relaxedLo:d,relaxedHi:x,candidates:[],isPortLane:c,emptyRelaxed:!0};let f=[],g=e=>{f.every(t=>Math.abs(t-e)>.5)&&f.push(e)},p=n[r.cross]+("y"===r.cross?n.height:n.width)/2,m=t[r.cross]+("y"===r.cross?t.height:t.width)/2,M=i.sideUse?.get(`${t.id}:${e2(r,1)}`)??1,b=eJ(t)&&1===M&&t$(t)>=t$(n),$=i.classes&&i.edges.some(t=>t!==e&&t.source===e.target&&t.target===e.source&&!t.label&&!e.label&&void 0!==t.edgeIndex&&void 0!==e.edgeIndex),w=$&&eJ(t)&&eJ(n);if(void 0!==a)f.push(a);else if(w){let n="feedback"===i.classes[e.edgeIndex]?1:-1;g(t[r.cross]+("y"===r.cross?t.height:t.width)/2+n*(("y"===r.cross?t.height:t.width)/4)),g((l+h)/2+12*n/2),g(p),g(m)}else if($)g((l+h)/2+("feedback"===i.classes[e.edgeIndex]?1:-1)*12/2),g(p),g(m);else if(b)g(m),g(p);else{let n=tv(e,t,i,r)?.sourceLane;void 0!==n&&g(n),g(p),g(m)}if(void 0===a){if(e.points.length>0){g(e.points[e.points.length-1][r.cross]),g(e.points[0][r.cross]);let t=e.points.map(e=>e[r.cross]);g(Math.min(...t)),g(Math.max(...t))}g((l+h)/2),g((l+(l+h)/2)/2),g(((l+h)/2+h)/2)}return{overlapLo:l,overlapHi:h,relaxedLo:d,relaxedHi:x,candidates:f,isPortLane:c,emptyRelaxed:!1}}function tA(e,t,n,i,r,a,o){let s=o.isPortLane(i)?o.relaxedLo:o.overlapLo,l=o.isPortLane(i)?o.relaxedHi:o.overlapHi;if(i<s-.01||i>l+.01)return{blockers:[{kind:"span",id:tC(e)}]};let h=e0(t,i,a,1),u=e0(n,i,a,-1);if(null===h||null===u||(u-h)*a.sign<=.01)return{blockers:[{kind:"span",id:tC(e)}]};let d=tN(e,i,Math.min(h,u),Math.max(h,u),r,a);if(d.length>0)return{blockers:d};let x=e3(a,h,i),y=e3(a,u,i),c=r.nodeLaneIndexes&&!z()?o.priorCrossings??=tI(e.points,e,r):tI(e.points,e,r);if(tI([x,y],e,r,c)>c)return{blockers:[{kind:"crossing",id:tC(e)}]};let f=tE(e,x,y,r);return null===f?{blockers:[{kind:"label",id:tC(e)}]}:{start:x,end:y,slot:f}}function tF(e,t,n,i,r=i.axis,a,o=e){let s=tH(e,t,n,i,r,a);if(!s)return{applied:!1,blockers:[]};if(s.emptyRelaxed)return{applied:!1,blockers:[{kind:"span",id:tC(e)}]};let l=[];for(let a=0;a<s.candidates.length;a++){let h=tA(e,t,n,s.candidates[a],i,r,s);if("blockers"in h){l.push(...h.blockers);continue}let u=tM(e,[h.start,h.end],i.edges,i.style,o);if(u){l.push(u);continue}let d=eX(e.points);if(2===d.length&&.01>=Math.abs(d[0][r.cross]-d[1][r.cross])){let a=+!!eY(t,d[0])+ +!!eY(n,d[1]),o=+!!eY(t,h.start)+ +!!eY(n,h.end)<a,u=()=>{let t=i.edges.filter(t=>t!==e);return V([{...e,points:[h.start,h.end]},...t])<V([{...e,points:d},...t])};if(o&&tI([h.start,h.end],e,i)>=tI(d,e,i)&&!u()){let a=d[0][r.cross],o=tA(e,t,n,a,i,r,{...s,overlapLo:Math.min(s.overlapLo,a),overlapHi:Math.max(s.overlapHi,a),relaxedLo:Math.min(s.relaxedLo,a),relaxedHi:Math.max(s.relaxedHi,a)});if(!("blockers"in o)&&.01>=Math.hypot(o.start.x-d[0].x,o.start.y-d[0].y)&&.01>=Math.hypot(o.end.x-d[1].x,o.end.y-d[1].y))return e.label&&(e.labelPosition=o.slot??void 0),{applied:!0,blockers:[]};"blockers"in o&&l.push(...o.blockers);continue}}return e7(i,e,[h.start,h.end]),e.label&&(e.labelPosition=h.slot??void 0),{applied:!0,blockers:[],usedCandidateIndex:a}}return{applied:!1,blockers:tB(l)}}function tO(e,t,n,i,r=i.axis){let a=tH(e,t,n,i,r);if(!a||a.emptyRelaxed||!eT(t)||!eT(n)||!eK(e.points,r))return null;for(let o of a.candidates)if(!("blockers"in tA(e,t,n,o,i,r,a)))return o;return null}function tz(e,t,n,i,r){let a=eU(n);return{ctx:{nodes:e,edges:t,groups:r,axis:a,style:i},axis:a}}function tj(e,t,n,i=e.labelPosition){if(!e.label||!i)return null;let r=e.labelBlock??o(N(e.label,e.labelContent),n),a=d(i.x,i.y,r);for(let n of t)if(n!==e&&(void 0===e.edgeIndex||n.edgeIndex!==e.edgeIndex))for(let t=1;t<n.points.length;t++){let i=n.points[t-1],r=n.points[t],o=.01>Math.abs(i.x-r.x),s=.01>Math.abs(i.y-r.y);if(!o&&!s)continue;let l=Math.min(i.x,r.x),h=Math.max(i.x,r.x),u=Math.min(i.y,r.y),d=Math.max(i.y,r.y);if(h>=a.x&&l<=a.x+a.w&&d>=a.y&&u<=a.y+a.h)for(let t=1;t<e.points.length;t++){let r=e.points[t-1],a=e.points[t];if(!(o?.01>Math.abs(r.x-a.x)&&4>Math.abs(r.x-i.x):.01>Math.abs(r.y-a.y)&&4>Math.abs(r.y-i.y)))continue;let s=o?Math.min(r.y,a.y):Math.min(r.x,a.x),x=o?Math.max(r.y,a.y):Math.max(r.x,a.x),y=o?u:l;if(Math.min(x,o?d:h)-Math.max(s,y)>.01)return n}}return null}function tV(e,t,n){let i=tI(t.points,t,n);return tI(e,t,n,i)>i}function tY(e,t){let n="cylinder"===t.shape?eo(t).boundary:void 0,i=.5*("rectangle"!==t.shape&&"subroutine"!==t.shape||void 0!==t.semanticShape&&"rect"!==t.semanticShape&&"fr-rect"!==t.semanticShape&&"lin-rect"!==t.semanticShape&&"div-rect"!==t.semanticShape&&"win-pane"!==t.semanticShape);for(let r=1;r<e.length;r++){let a=e[r-1],o=e[r],s=Math.min(a.x,o.x),l=Math.max(a.x,o.x),h=Math.min(a.y,o.y),u=Math.max(a.y,o.y);if(n?.kind==="cylinder"&&n.height>2*n.capRadiusY&&l>t.x&&s<t.x+t.width&&u>n.y+n.capRadiusY&&h<n.y+n.height-n.capRadiusY||l>t.x+i&&s<t.x+t.width-i&&u>t.y+i&&h<t.y+t.height-i)return!0}return!1}function tQ(e){return"compound"===e.kind?{...e,children:e.children.map(tQ)}:"path"===e.kind?{...e,d:R("d",e.d)}:"polygon"===e.kind||"polyline"===e.kind?{...e,points:e.points.map(tq)}:Object.fromEntries(Object.entries(e).map(([e,t])=>[e,"number"==typeof t?Number(E(t)):t]))}var tq=e=>({x:Number(E(e.x)),y:Number(E(e.y))}),tT=e=>!!e&&Object.values(e).every(Number.isFinite)&&e.x0<=e.x1&&e.y0<=e.y1,tJ=(e,t)=>{let 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 tZ(e,t,n){if("invisible"===e.style)return{shafts:[],markers:[]};if(e.points.length>eH*eA||void 0!==t.edgeBendRadius&&!(Number.isFinite(t.edgeBendRadius)&&t.edgeBendRadius>=0))return;let i={stroke:e.inlineStyle?.stroke??t.edgeStrokeColor??"var(--_line)",strokeWidth:R("stroke-width",e.inlineStyle?.["stroke-width"]??String((t.lineWidth??1)*("thick"===e.style?2:1)))},r=B(i,e.points.length>2||!!e.curve||(t.edgeBendRadius??0)>0);if(void 0===r||e.points.length<2||(e.hasArrowStart||e.hasArrowEnd)&&void 0===B({...i,stroke:"black"},!1))return;let a=[],o=e=>{if(!n())return!1;let t=W(e,r);return!!tT(t)&&(r>0&&a.push(t),!0)},s=G(e,t);if(s){if(!L(R("d",s.geometry.d),e=>o(e.bounds),n))return}else{let t=e.points.map(tq);for(let e=1;e<t.length;e++){let n=t[e-1],i=t[e];if(!o({x0:Math.min(n.x,i.x),y0:Math.min(n.y,i.y),x1:Math.max(n.x,i.x),y1:Math.max(n.y,i.y)}))return}}let l=ty(e,t);if(!l)return;for(let e of l)if(!n()||!tT(e.bounds))return;let u=x(e,t),d=u?h(e,t.lineWidth??1):0,y=u?{x0:u.x-d,y0:u.y-d,x1:u.x+u.w+d,y1:u.y+u.h+d}:void 0;if(!(y&&!tT(y)))return{shafts:a,markers:l,...y?{label:y}:{}}}function tU(e,t,n,i,r){if(!r(16))return;let a=[],o=[],s=new Map,l=new Map,u=e=>!!r(32)&&("compound"===e.kind?r(e.children.length+1)&&e.children.every(u):"path"===e.kind?r(6*e.d.length+16):"polygon"===e.kind||"polyline"===e.kind?r(772*e.points.length+4):r(3104));for(let t of e){let e=t.inlineStyle?.["stroke-width"]??String(i.nodeLineWidth??S.innerBox);if(!r(512+6*e.length+t.id.length))return;let n=ea(t,{fill:t.inlineStyle?.fill??i.nodeFillColor??"var(--_node-fill)",stroke:t.inlineStyle?.stroke??i.nodeBorderColor??"var(--_node-stroke)",strokeWidth:R("stroke-width",e)},i.cornerRadius);if(!u(n.geometry))return;let o=H({kind:"shape",id:t.id,role:"node",geometry:tQ(n.geometry),paint:n.paint,...n.childPaints?{childPaints:n.childPaints}:{}});if(!tT(o))return;a.push(o)}let d=(e,t=0)=>{if(t>64||!r(e.length+1))return!1;for(let n of e){let e=n.concurrencyRegion?0:n.headerHeight??n.height,a=n.inlineStyle?.["stroke-width"]??String(i.groupLineWidth??S.innerBox);if(!r(3072+6*a.length+88)||!Number.isFinite(e)||e<0||void 0!==i.groupCornerRadius&&!(Number.isFinite(i.groupCornerRadius)&&i.groupCornerRadius>=0))return!1;if(e>0){let t=tQ({kind:"rect",x:n.x,y:n.y,width:n.width,height:e}),r={fill:"black",stroke:n.inlineStyle?.stroke??"black",strokeWidth:R("stroke-width",a)},s;if(0===i.groupCornerRadius)s=H({kind:"shape",id:n.id,role:"group-header",geometry:t,paint:r});else{let e=B(r,!0),i=H({kind:"shape",id:n.id,role:"group-header",geometry:t,paint:{fill:"black",stroke:"none"}});if(void 0===e||!tT(i))return!1;s=W(i,e)}if(!tT(s))return!1;o.push(s)}if(!d(n.children,t+1))return!1}return!0};if(!d(n))return;for(let e of t){if(e.label&&!e.labelPosition)return;let t=e.inlineStyle?.["stroke-width"]??"",n=e.curve||(i.edgeBendRadius??0)>0?18:4,a=e.inlineStyle?.stroke??i.edgeStrokeColor??"";if(!r(2048+e.points.length*(384*n+32)+8*t.length+(e.label?.length??0)*12+(a.length+e.source.length+e.target.length+(e.id?.length??0))*8))return;let o=tZ(e,i,()=>r(1));if(!o)return;s.set(e,o)}let y=(e,t)=>{if(!r(4))return;let n=l.get(e);if(n&&n.x===t.x&&n.y===t.y)return n.box;if(!r(64+(e.label?.length??0)*12))return;let a=x({...e,labelPosition:t},i);if(!a)return;let o=h(e,i.lineWidth??1),s={x0:a.x-o,y0:a.y-o,x1:a.x+a.w+o,y1:a.y+a.h+o};if(!(!tT(s)||!r(6)))return l.set(e,{x:t.x,y:t.y,box:s}),s};return{clear:(e,n,i,l,h)=>{let u=y(e,n);if(!u)return!1;for(let e of a)if(!r(1)||tJ(u,e))return!1;for(let e of o)if(!r(1)||tJ(u,e))return!1;let d=!0;for(let n of t){if(!r(1))return!1;let t=s.get(n);for(let e of t.markers)if(!r(1)||!tT(e.bounds)||tJ(u,e.bounds))return!1;if(n===e)continue;for(let e of t.shafts)if(!r(1)||tJ(u,e))return!1;if(h instanceof Set?h.has(n):n===h)continue;let a=i.get(n)??n.labelPosition;if(!n.label||!a)continue;let o=y(n,a);if(!o)return!1;if(tJ(u,o)){if(l&&!l.has(n)){if(!r(1))return!1;l.add(n)}d=!1}}return d},label:y}}function t_(e,t,n,i,r){if("feedback"!==t)return null;if(!n||!i)return"feedback-detour";let a=e=>"y"===r.cross?e.height:e.width,o=Math.min(n[r.cross],i[r.cross])-2,s=Math.max(n[r.cross]+a(n),i[r.cross]+a(i))+2;return e.points.some(e=>e[r.cross]<o||e[r.cross]>s)?"outer-feedback":"feedback-detour"}function tX(e){return e.routeCertificate?.invariant==="bundle"&&tl(e)}function tD(e){return e.some((t,n)=>n>0&&Math.abs(t.x-e[n-1].x)>.01&&Math.abs(t.y-e[n-1].y)>.01)}function tG(e,t=!1){e.invariant="straight",e.bendCount=0,e.directLaneClear=!0,t&&(e.straightened=!0),e.directLaneBlockedBy=void 0}function tK(e,t,n,i,r){let a=eZ(t),{axis:s,ctx:u}=e6(e,t,i,a,e=>n.has(e)&&tl(e),!!r?.preserveLabels);u.fixedLabels=!!r?.preserveLabels;let d=te(e.nodes),y=function e(t,n=new Map){for(let i of t)n.set(i.id,i),e(i.children,n);return n}(e.groups),c=[],f,g=(e,t)=>{let n="feedback"===t.routeClass?{...s,sign:1===s.sign?-1:1}:s,i=d.get(e.source),a=d.get(e.target);if(!(i&&a&&eT(i)&&eT(a)&&("feedback"===t.routeClass||eK(eD(e.points),n))))return t.invariant=t_(e,t.routeClass,i,a,u.axis)??"unverified-shape",{applied:!1,mutated:!1};if(r?.preserveStraightRoutes&&2===e.points.length){let r=e.points[0],o=e.points[1],l=s.main,h=s.cross;if(r[h]===o[h]&&0===eQ(e,i,a)&&!tW(e,r[h],Math.min(r[l],o[l]),Math.max(r[l],o[l]),u,n))return tG(t),{applied:!0,mutated:!1}}let o=u.sideUse?.get(`${i.id}:${e2(n,1)}`)??1,l="primary-forward"===t.routeClass&&eJ(i)&&1===o&&t$(i)>=t$(a),h=JSON.stringify(e.points);if(l){let r=i[n.cross]+("y"===n.cross?i.height:i.width)/2,o=tF(e,i,a,u,n,r);if(o.applied){let n=JSON.stringify(e.points)!==h;return tG(t,n),{applied:!0,mutated:n}}if(function(e,t,n,i,r){if(e.points.length<2)return!1;let a=t[r.cross]+("y"===r.cross?t.height:t.width)/2,o=n[r.cross],s=o+("y"===r.cross?n.height:n.width),l;if(a<o-.01)l="y"===r.cross?"N":"W";else{if(!(a>s+.01))return!1;l="y"===r.cross?"S":"E"}let h=ej(n)[l][r.cross];if(8>Math.abs(h-a))return!1;let u=ej(n)[e2(r,-1)];if(i.edges.some(t=>t!==e&&t.target===e.target&&t.source!==e.source&&t.points.length>0&&tm(e,t)&&.5>=Math.abs(t.points[t.points.length-1].x-u.x)&&.5>=Math.abs(t.points[t.points.length-1].y-u.y)))return!1;let d=ej(n)[l][r.main],x=e0(t,a,r,1);if(null===x||(d-x)*r.sign<=.01)return!1;let y={...e,points:[],label:void 0};if(tW(e,a,Math.min(x,d),Math.max(x,d),i,r))return!1;let c=e9(r,a,h);if(tW(y,d,Math.min(a,h),Math.max(a,h),i,c))return!1;let f=[e3(r,x,a),e3(r,d,a),e3(r,d,h)];if(!tb(e,f,i.edges,i.style)||!tR(e,i)&&tV(f,e,i))return!1;if(e.label){let t=tE(e,f[0],f[1],i);if(!t)return!1;e.labelPosition=t}return e7(i,e,f),!0}(e,i,a,u,n)||m(e,i,a,u,n,!0))return t.invariant="explained-detour",t.directLaneClear=!1,t.directLaneBlockedBy=tB(o.blockers),t.bendCount=eG(e.points),{applied:!1,mutated:JSON.stringify(e.points)!==h}}let y=tS(e,i,a,u,n);if(y&&m(e,i,a,u,n,!1,{sourceLane:y.sourceLane,targetLane:y.targetLane,preferSourceJog:!0}))return t.invariant="explained-detour",t.directLaneClear=!1,t.directLaneBlockedBy=[{kind:"port",id:tC(e)}],t.bendCount=eG(e.points),{applied:!1,mutated:JSON.stringify(e.points)!==h};let c=tF(e,i,a,u,n);if(c.applied){let n=JSON.stringify(e.points)!==h;return tG(t,n),{applied:!0,mutated:n,upgradeable:(c.usedCandidateIndex??0)>0}}t.invariant=t_(e,t.routeClass,i,a,u.axis)??"explained-detour",t.directLaneClear=!1,t.directLaneBlockedBy=c.blockers;let f=!1;if("outer-feedback"===t.invariant||"feedback-detour"===t.invariant)"outer-feedback"===t.invariant&&(f=function(e,t,n){let i=eX(e.points);if(i.length<4)return!1;let r=t.axis,a=e=>e[r.cross],o=e=>e[r.main],s=-1,l=.01;for(let e=1;e<i.length;e++){if(Math.abs(a(i[e-1])-a(i[e]))>=.01)continue;let t=(o(i[e-1])-o(i[e]))*r.sign;t>l&&(l=t,s=e-1)}if(s<1)return!1;let h=a(i[s]),u=[i[s],i[s+1]],d=Math.sign(o(u[1])-o(u[0])),y=i[0],c=t.nodes.find(t=>t.id===e.source),f=e=>d>0?e>=o(u[0])-.01&&e<o(u[1])-.01:e<=o(u[0])+.01&&e>o(u[1])+.01,g=(n,i)=>{if(.01>Math.abs(i-h))return!0;let a="x"===r.main?{main:"y",cross:"x",sign:i<h?1:-1}:{main:"x",cross:"y",sign:i<h?1:-1};return 0===tN({...e,points:[],label:void 0},n,Math.min(i,h),Math.max(i,h),t,a).length},p=(e,t,n)=>{let a=e3(r,e,h);return .01>Math.abs(t-h)?[a,...i.slice(s+1)]:[n,a,...i.slice(s+1)]},m=null;if(c&&eT(c)){let e=c[r.cross],t="y"===r.cross?h>e?"S":"N":h>e?"E":"W",n=ej(c)[t],i=n[r.cross],a=n[r.main];f(a)&&g(a,i)&&(m=p(a,i,n))}if(!m&&c){let e=d===r.sign?1:-1,t=e1(c,r,e);if("dynamic"===eo(c).sides[e2(r,e)].kind&&t&&h>=t.lo-.01&&h<=t.hi+.01){let t=e0(c,h,r,e);if(null!==t&&f(t)&&g(t,h)){let e=e3(r,t,h);m=p(t,h,e)}}}if(!m&&f(o(y))&&g(o(y),a(y))&&(m=p(o(y),a(y),y)),!m&&2===s&&.01>Math.abs(a(i[1])-a(y))&&t.edges.some(n=>n.source===e.source&&n!==e&&tj(n,t.edges,t.style))){let n=Math.sign(o(i[1])-o(y)),l=[o(y)+12*n];for(let i of t.edges){if(i===e)continue;for(let e of i.points)l.push(o(e)+12*n);let a=x(i,t.style);a&&l.push(("x"===r.main?a.x+(n>0?a.w:0):a.y+(n>0?a.h:0))+4.01*n)}for(let u of(l.sort((e,t)=>(e-t)*n),l)){if((u-o(y))*n<11.99||(o(i[1])-u)*n<=.01||!f(u)||!g(u,a(y)))continue;let l="x"===r.main?{x:u,y:a(y)}:{x:a(y),y:u},d=[y,l,"x"===r.main?{x:u,y:h}:{x:h,y:u},...i.slice(s+1)];if(!(tI(d,e,t)>tI(i,e,t))){m=d;break}}}let M=m??i;{let n=-1;for(let e=1;e<M.length;e++)if(.01>Math.abs(a(M[e-1])-h)&&.01>Math.abs(a(M[e])-h)){n=e-1;break}let i=t.nodes.find(t=>t.id===e.target);if(n>=0&&n+1<M.length-1&&i&&eT(i)){let e=i[r.cross],t="y"===r.cross?h>e?"S":"N":h>e?"E":"W",a=ej(i)[t],s=a[r.cross],l=a[r.main],u=M[n],d=M[n+1];if((Math.sign(o(d)-o(u))>0?l>o(u)+.01&&l<=o(d)+.01:l<o(u)-.01&&l>=o(d)-.01)&&g(l,s)){let e=e3(r,l,h);m=[...M.slice(0,n+1),e,a]}}}if(!m)return!1;let b=eX(m),$=n.get(e.target);if(eQ({...e,points:b},c,$)>0)return!1;let w=B({stroke:"black",strokeWidth:R("stroke-width",e.inlineStyle?.["stroke-width"]??String((t.style.lineWidth??S.connector)*("thick"===e.style?2:1)))},!0);if(!c||!$||void 0===w)return!1;let k=e=>{let n=B({stroke:"black",strokeWidth:R("stroke-width",e.inlineStyle?.["stroke-width"]??String(t.style.nodeLineWidth??S.innerBox))},!0);if(void 0===n)return;let i=Math.max(4,n+w)+.01,r=e.x-i,a=e.y-i,o=e.width+2*i,s=e.height+2*i;if([r,a,o,s].every(Number.isFinite))return{...e,shape:"rectangle",semanticShape:void 0,x:r,y:a,width:o,height:s}},v=k(c),P=k($);if(!v||!P||tY(b.slice(1),v)||tY(b.slice(0,-1),P)||tV(b,e,t)||!tb(e,b,t.edges,t.style))return!1;let C=e.points;if(e7(t,e,b),e.label&&e.labelPosition){let n=e.labelPosition;if(!e.points.some((t,i)=>{if(0===i)return!1;let r=e.points[i-1],a=Math.min(r.x,t.x)-1,o=Math.max(r.x,t.x)+1,s=Math.min(r.y,t.y)-1,l=Math.max(r.y,t.y)+1;return n.x>=a&&n.x<=o&&n.y>=s&&n.y<=l})){let n=null;for(let i=1;i<e.points.length;i++){let r=e.points[i-1],o=e.points[i];if(.01>Math.abs(a(r)-h)&&.01>Math.abs(a(o)-h)){n=tE(e,r,o,t);break}}if(!n)return e7(t,e,C),!1;e.labelPosition=n}}return JSON.stringify(e.points)!==JSON.stringify(C)}(e,u,d),t.bendCount=eG(e.points)),tR(e,u)&&m(e,i,a,u,n)&&(t.bendCount=eG(e.points),f=!0);else if("explained-detour"===t.invariant&&(t.bendCount>2||tD(e.points)||tR(e,u)||!eY(i,e.points[0])||!eY(a,e.points[e.points.length-1]))){let r=m(e,i,a,u,n)||function(e,t,n,i,r){if(!tR(e,i))return!1;let a=e1(t,r,1),o=e1(n,r,-1);if(!a||!o)return!1;let s={...e,points:[],label:void 0},l=e=>"y"===r.cross?e.height:e.width,h=e=>"x"===r.main?e.width:e.height,u=t[r.cross]+l(t)/2,d=e0(t,u,r,1),x=n[r.cross]+l(n)/2,y=e0(n,x,r,-1);if(null===d||null===y||Math.abs(u-a.lo)>.01&&Math.abs(u-a.hi)>.01&&(u<a.lo-.01||u>a.hi+.01))return!1;let c=[];for(let t of i.nodes){if(t.id===e.source||t.id===e.target)continue;let n=t[r.main],i=n+h(t),a=(n-d)*r.sign>.01||(i-d)*r.sign>.01,o=(y-n)*r.sign>.01||(y-i)*r.sign>.01;if(!a||!o)continue;let s=r.sign>0?n:i;c.push({mainNear:s,crossLo:t[r.cross],crossHi:t[r.cross]+l(t)})}let f=c.filter(e=>u>e.crossLo-4&&u<e.crossHi+4);if(0===f.length)return!1;let g=f.reduce((e,t)=>(t.mainNear-d)*r.sign<(e-d)*r.sign?t.mainNear:e,f[0].mainNear);if((g-d)*r.sign<=4)return!1;let m=d+(g-d)/2,M=[x];p(e,x,r)&&M.push(x+12,x-12);let b=[],$=e=>{b.every(t=>Math.abs(t-e)>.5)&&b.push(e)};for(let e of c)$(e.crossLo-4-.01),$(e.crossHi+4+.01);let w=[...c].sort((e,t)=>e.crossLo-t.crossLo);for(let e=1;e<w.length;e++){let t=w[e-1].crossHi,n=w[e].crossLo;n-t>8&&$((t+n)/2)}b.sort((e,t)=>Math.abs(e-u)-Math.abs(t-u));let k=null;for(let t of M){if(t<o.lo-.01||t>o.hi+.01)continue;let a=e0(n,t,r,-1);if(null===a)continue;let l=a-r.sign*eO(i.style,e,"end");if(!((l-m)*r.sign<=.01))for(let n of b){if(4>Math.abs(n-u)||tW(s,u,Math.min(d,m),Math.max(d,m),i,r)||tW(s,m,Math.min(u,n),Math.max(u,n),i,e9(r,u,n))||tW(s,n,Math.min(m,l),Math.max(m,l),i,r)||tW(s,l,Math.min(n,t),Math.max(n,t),i,e9(r,n,t))||tW(s,t,Math.min(l,a),Math.max(l,a),i,r))continue;let o=eX([e3(r,d,u),e3(r,m,u),e3(r,m,n),e3(r,l,n),e3(r,l,t),e3(r,a,t)]);if(!tb(e,o,i.edges,i.style))continue;let h=[e3(r,m,n),e3(r,l,n)];if(e.label){let t=tE(e,h[0],h[1],i);if(t)return e.labelPosition=t,e7(i,e,o),!0;k||(k={route:o,labelMid:{x:(h[0].x+h[1].x)/2,y:(h[0].y+h[1].y)/2}});continue}return e7(i,e,o),!0}}return!!k&&(e7(i,e,k.route),e.label&&(e.labelPosition=k.labelMid),!0)}(e,i,a,u,n);((function(e,t,n,i){let r;if(e.points.length<3||!n.edges.some(t=>t!==e&&t.target===e.target))return!1;let a=ej(t);if(!(p(e,r=a[e2(i,-1)][i.cross],i)||u.edges.some(t=>{if(t===e||t.target!==e.target||t.source===e.target||tm(e,t))return!1;let n=d.get(t.source);return void 0!==n&&.5>=Math.abs(n[i.cross]+("y"===i.cross?n.height:n.width)/2-r)})))return!1;let o=t[i.cross],s=o+("y"===i.cross?t.height:t.width),l=-1;for(let t=e.points.length-1;t>0&&l<0;t--){let n=e.points[t-1],r=e.points[t],a=r[i.cross];.01>=Math.abs(n[i.cross]-a)&&Math.abs(n[i.main]-r[i.main])>.01&&(a<=o-4||a>=s+4)&&(l=t)}if(l<1)return!1;let h=e.points[l][i.cross],x=a["y"===i.cross?h<o?"N":"S":h<o?"W":"E"],y=e.points[l-1];if((x[i.main]-y[i.main])*Math.sign(e.points[l][i.main]-y[i.main])<=.01)return!1;let c={...e,points:[],label:void 0};if(tW(c,h,Math.min(y[i.main],x[i.main]),Math.max(y[i.main],x[i.main]),n,i))return!1;let f=e9(i,h,x[i.cross]);if(tW(c,x[i.main],Math.min(h,x[i.cross]),Math.max(h,x[i.cross]),n,f))return!1;let g=eX([...e.points.slice(0,l),e3(i,x[i.main],h),x]);if(eG(g)>eG(e.points)||tV(g,e,n)||!tb(e,g,n.edges,n.style))return!1;if(e.label){let t;for(let e=1;e<g.length;e++){let n=Math.abs(g[e].x-g[e-1].x)+Math.abs(g[e].y-g[e-1].y);(!t||n>Math.abs(t[1].x-t[0].x)+Math.abs(t[1].y-t[0].y))&&(t=[g[e-1],g[e]])}let i=t&&tE(e,t[0],t[1],n);if(!i)return!1;e.labelPosition=i}return e7(n,e,g),!0})(e,a,u,n)||r)&&(t.bendCount=eG(e.points),f=!0)}return{applied:!1,mutated:f}},p=(e,t,n)=>u.edges.some(i=>i!==e&&i.target===e.target&&i.points.length>1&&.5>=Math.abs(i.points.at(-1)[n.cross]-t)&&!tm(e,i));function m(e,t,n,i,r,a=!1,o){if(e.points.length<2)return!1;let s=e1(t,r,1),l=e1(n,r,-1);if(!s||!l)return!1;let h=e.points.map(e=>e[r.cross]),u=[],x=[],y=(e,t)=>{e.every(e=>Math.abs(e-t)>.5)&&e.push(t)};if(o?.sourceLane!==void 0)y(u,o.sourceLane);else if(y(u,t[r.cross]+("y"===r.cross?t.height:t.width)/2),!a)for(let t of(y(u,e.points[0][r.cross]),h))y(u,t);if(o?.targetLane!==void 0)y(x,o.targetLane);else{let t=n[r.cross]+("y"===r.cross?n.height:n.width)/2;if(i.edges.some(n=>{if(n===e||n.target!==e.target||n.source===e.target||tm(e,n))return!1;let i=d.get(n.source);return void 0!==i&&.5>=Math.abs(i[r.cross]+("y"===r.cross?i.height:i.width)/2-t)})&&y(x,e.points[e.points.length-1][r.cross]),y(x,t),y(x,e.points[e.points.length-1][r.cross]),p(e,t,r))for(let e of[12,-12])y(x,t+e)}let c=e=>{let t=e[r.main];return[t,t+("x"===r.main?e.width:e.height)]},[f,g]=c(t),[M,b]=c(n),$=Math.min(f,g,M,b),w=Math.max(f,g,M,b),k=(t,n)=>{if(n)for(let a of i.nodes){if(a.id===e.source||a.id===e.target)continue;let[i,o]=c(a);if(o<=$+.01||i>=w-.01)continue;let s=a[r.cross],l=s+("y"===r.cross?a.height:a.width);for(let e of[s-4-.01,l+4+.01])e>=n.lo-.01&&e<=n.hi+.01&&y(t,e)}};k(u,o?.sourceLane===void 0?s:null),k(x,o?.targetLane===void 0?l:null);let v=(e,t)=>eJ(e)?{lo:e[r.cross]+2,hi:e[r.cross]+("y"===r.cross?e.height:e.width)-2}:t,S=v(t,s),P=v(n,l),C=!o?.requireFewerCrossings&&tR(e,i),N=null,W={...e,points:[],label:void 0},L,E=!z(),I,R=eO(i.style,e,"start"),B=eO(i.style,e,"end");for(let a of x){if(a<P.lo-.01||a>P.hi+.01)continue;let s=e0(n,a,r,-1);if(null!==s)for(let l=0;l<u.length;l++){let h=u[l];if(h<S.lo-.01||h>S.hi+.01||4>Math.abs(h-a))continue;let d=e0(t,h,r,1);if(null===d||o?.requireFewerCrossings&&(d!==(1===r.sign?g:f)||s!==(1===r.sign?M:b))||(s-d)*r.sign<=.01)continue;let x=o?.preferSourceJog?[d+r.sign*R,(d+s)/2,s-r.sign*B]:[s-r.sign*B,(d+s)/2,d+r.sign*R];for(let u=0;u<x.length;u++){let y=x[u];if((y-d)*r.sign<=.01||(s-y)*r.sign<=.01)continue;let c=Math.abs(y-d)>=Math.abs(s-y),f=E?(3*l+u)*2+Number(c):0,g=E?I?.[f]:void 0,p;if(g&&Object.is(g.jog,y)?p=g.blocked:(p=tW(c?e:W,h,Math.min(d,y),Math.max(d,y),i,r),E&&(g?(g.jog=y,g.blocked=p):(I??=[])[f]={jog:y,blocked:p})),p)continue;let m=e9(r,h,a);if(tW(W,y,Math.min(h,a),Math.max(h,a),i,m)||tW(c?W:e,a,Math.min(y,s),Math.max(y,s),i,r))continue;let M=[e3(r,d,h),e3(r,y,h),e3(r,y,a),e3(r,s,a)],b=c?[M[0],M[1]]:[M[2],M[3]],$=null;if(e.label){if(!($=tE(e,b[0],b[1],i))){let t=c?tE(e,M[2],M[3],i):tE(e,M[0],M[1],i);t&&!tW(e,c?a:h,Math.min(c?y:d,c?s:y),Math.max(c?y:d,c?s:y),i,r)&&($=t)}if(!$&&!(C&&!N))continue}if(!tb(e,M,i.edges,i.style))continue;let w=+!!eY(t,e.points[0])+ +!!eY(n,e.points.at(-1)),k=+!!eY(t,M[0])+ +!!eY(n,M.at(-1));L??=C?0:tI(e.points,e,i);let v=C?0:tI(M,e,i,L);if(!(!C&&v>L)&&!(o?.requireFewerCrossings&&v>=L)&&!(!C&&v>=L&&eQ({...e,points:M},t,n)>=eQ(e,t,n)&&(eG(M)>eG(e.points)||eG(M)===eG(e.points)&&k<w))){if(e.label){if(!$){C&&!N&&(N={route:M,labelMid:{x:(b[0].x+b[1].x)/2,y:(b[0].y+b[1].y)/2}});continue}e.labelPosition=$}return e7(i,e,M),!0}}}}return!!N&&(e7(i,e,N.route),e.label&&(e.labelPosition=N.labelMid),!0)}let M=[],b=new Set,$=function(e,t,n,i,r=new Set){let a=n.style,s=new Map,u=[],d=new Map,y=(e,t)=>Math.min(e.x+e.w,t.x+t.w)>Math.max(e.x,t.x)&&Math.min(e.y+e.h,t.y+t.h)>Math.max(e.y,t.y);return c=>{let f=e.get(c.source);if(!f)return null;let g=f.x+f.width/2,p=f.y+f.height/2,m=c.points.slice(1,-1),M=m.length>0?{x:m.reduce((e,t)=>e+t.x,0)/m.length,y:m.reduce((e,t)=>e+t.y,0)/m.length}:c.points[0]??{x:f.x,y:p},b=(M.x-g)/Math.max(f.width/2,1),$=(M.y-p)/Math.max(f.height/2,1),w=Math.abs(b)>=Math.abs($)?b<0?"W":"E":$<0?"N":"S",k=[w,function(e){switch(e){case"N":return"S";case"S":return"N";case"E":return"W";case"W":return"E"}}(w),..."W"===w||"E"===w?["N","S"]:["W","E"]],v=c.label?c.labelBlock??o(N(c.label,c.labelContent),a):null,P=e=>v?("N"===e||"S"===e?v.height:v.width)+2*l:0,C=e=>"N"===e||"S"===e?f.width:f.height,W=e=>`${f.id}:${e}`,L=e=>s.get(W(e))??0,E=e=>Math.min(Math.max(C(e)/4,6),10,Math.max(C(e)/2-2,3)),I=e=>E(e)+6*L(e)<=C(e)/2-2,R=e=>{let i=L(e),r=E(e)+6*i;return{d:r,desired:24+i*Math.max(14,P(e)+8),clear:((e,i)=>{let r="N"===e||"S"===e,o=r?g:p,s=o-i-6,l=o+i+6,h="W"===e?f.x:"E"===e?f.x+f.width:"N"===e?f.y:f.y+f.height,u="W"===e||"N"===e?-1:1,d=1e3,y=(e,t,n,i)=>{if(t<s||e>l)return;let r=(n-h)*u;r>0&&(d=Math.min(d,r-(i?2:6)))};for(let e of n.nodes)e.id!==f.id&&y(r?e.x:e.y,r?e.x+e.width:e.y+e.height,r?u<0?e.y+e.height:e.y:u<0?e.x+e.width:e.x,!1);for(let e of t.values())if(g>e.x&&g<e.x+e.width&&p>e.y&&p<e.y+e.height){let t=((r?u<0?e.y:e.y+e.height:u<0?e.x:e.x+e.width)-h)*u;t>0&&(d=Math.min(d,t-4))}else y(r?e.x:e.y,r?e.x+e.width:e.y+e.height,r?u<0?e.y+e.height:e.y:u<0?e.x+e.width:e.x,!1);for(let e of n.edges){if(e===c||e.source===e.target||!e.label)continue;let t=x(e,a);t&&y(r?t.x:t.y,r?t.x+t.w:t.y+t.h,r?u<0?t.y+t.h:t.y:u<0?t.x+t.w:t.x,!1)}return d})(e,r)}},A=(e,o)=>{let s=Math.max(Math.min(o.desired,o.clear),8),m=o.d,M=ev(ev((()=>{switch(e){case"W":return[{x:f.x,y:p-m},{x:f.x-s,y:p-m},{x:f.x-s,y:p+m},{x:f.x,y:p+m}];case"E":return[{x:f.x+f.width,y:p-m},{x:f.x+f.width+s,y:p-m},{x:f.x+f.width+s,y:p+m},{x:f.x+f.width,y:p+m}];case"N":return[{x:g-m,y:f.y},{x:g-m,y:f.y-s},{x:g+m,y:f.y-s},{x:g+m,y:f.y}];default:return[{x:g-m,y:f.y+f.height},{x:g-m,y:f.y+f.height+s},{x:g+m,y:f.y+f.height+s},{x:g+m,y:f.y+f.height}]}})(),f,!0),f,!1);if([...r].some(e=>e!==c&&ti(M,e.points)))return null;let b=tM(c,M,n.edges,a);if(b)return i?.push(b),null;let $=((e,i,r)=>{if(!c.label||!v)return[];let o="N"===e||"S"===e,s="W"===e||"N"===e?-1:1,m="W"===e||"S"===e?-1:1,M=("W"===e?f.x:"E"===e?f.x+f.width:"N"===e?f.y:f.y+f.height)+s*(i+P(e)/2+4),b=(o?v.width:v.height)+2*l+2,$=L(e),w=o?{x:g,y:M}:{x:M,y:p},k=e=>({x:e.x-v.width/2-l,y:e.y-v.height/2-l,w:v.width+2*l,h:v.height+2*l}),C=W(e),N=d.get(C)??[],E=[],I=u.slice();if($>0){for(let e of N){let t=e.edge.labelPosition,n=o?{x:g-m*b,y:t.y}:{x:t.x,y:p-m*b};E.push({edge:e.edge,position:n,rectIndex:e.rectIndex}),I[e.rectIndex]=x({...e.edge,labelPosition:n},a)}w=o?{x:g+m*b*$,y:M}:{x:M,y:p+m*b*$}}if(I.some(e=>y(k(w),e)))for(let e=0;e<8;e++){let t=e%2==0?m:-m,n=(1+Math.floor(e/2))*b,i=o?{x:g+t*n,y:M}:{x:M,y:p+t*n};if(!I.some(e=>y(k(i),e))){w=i;break}}E.push({edge:c,position:w});let R=new Map(E.map(e=>[e.edge,e.position])),A=(e,t)=>{let n=x({...e,labelPosition:t},a);if(!n)return null;let i=h(e,a.lineWidth??1);return{x:n.x-i,y:n.y-i,w:n.w+2*i,h:n.h+2*i}};for(let e of E){let i=A(e.edge,e.position),o=x({...e.edge,labelPosition:e.position},a);if(!i||!o||!Object.values(i).every(Number.isFinite))return null;let s=e.edge===c?r:e.edge.points,l=1/0;for(let e=1;e<s.length;e++){let t=s[e-1],n=s[e];if(t.x!==n.x&&t.y!==n.y)return null;l=Math.min(l,Math.max(o.x-Math.max(t.x,n.x),Math.min(t.x,n.x)-o.x-o.w,0)+Math.max(o.y-Math.max(t.y,n.y),Math.min(t.y,n.y)-o.y-o.h,0))}if(!(l<=o.h/2+4))return null;let h=(e,t,n,r)=>{let a=(Math.abs(e)+Math.abs(t)+Math.abs(n)+Math.abs(r)+Math.abs(i.x)+Math.abs(i.y)+i.w+i.h)*1e-10+1e-9;return!Number.isFinite(a)||y(i,{x:e-a,y:t-a,w:n+2*a,h:r+2*a})};for(let e of n.nodes){let t=ea(e,{fill:e.inlineStyle?.fill??a.nodeFillColor??"var(--_node-fill)",stroke:e.inlineStyle?.stroke??a.nodeBorderColor??"var(--_node-stroke)",strokeWidth:e.inlineStyle?.["stroke-width"]??String(a.nodeLineWidth??S.innerBox)},a.cornerRadius??0),n=H({kind:"shape",id:e.id,role:"node",geometry:t.geometry,paint:t.paint,...t.childPaints?{childPaints:t.childPaints}:{}});if(!n||h(n.x0,n.y0,n.x1-n.x0,n.y1-n.y0))return null}for(let e of t.values()){let t=e.concurrencyRegion?0:e.headerHeight??e.height;if(!Number.isFinite(t)||t<0)return null;let n=B({stroke:e.inlineStyle?.stroke??"black",strokeWidth:e.inlineStyle?.["stroke-width"]??String(a.groupLineWidth??S.innerBox)},!0);if(void 0===n||t>0&&h(e.x-n,e.y-n,e.width+2*n,t+2*n))return null}for(let t of n.edges){let n=ty(t===c?{...t,points:r}:t,a);if(!n||n.some(e=>!e.bounds||h(e.bounds.x0,e.bounds.y0,e.bounds.x1-e.bounds.x0,e.bounds.y1-e.bounds.y0)))return null;if(t===e.edge||!t.label)continue;let i=R.get(t)??t.labelPosition;if(!i)continue;let o=A(t,i);if(!o||h(o.x,o.y,o.w,o.h))return null}}return E})(e,s,M);return $?{points:M,labels:$}:null},F=null,O=null,z=null,j=[],V=k.map((e,t)=>({side:e,preference:t,rank:L(e)})).sort((e,t)=>e.rank-t.rank||e.preference-t.preference).map(e=>e.side);for(let e of V){if(!I(e))continue;let t=R(e);if(t.clear<Math.min(t.desired,14))continue;let n=A(e,t);if(n){F=e,O=t,z=n.points,j=n.labels;break}}if(!F||!O||!z){let e=V.filter(I);if(0===e.length)return null;let t=e.reduce((e,t)=>R(t).clear>R(e).clear?t:e,e[0]),n=R(t),i=A(t,n);if(!i)return null;F=t,O=n,z=i.points,j=i.labels}r.add(c),s.set(W(F),L(F)+1),e7(n,c,z);let Y=W(F),Q=d.get(Y)??[];for(let e of j){e.edge.labelPosition=e.position;let t=x(e.edge,a);if(void 0!==e.rectIndex)u[e.rectIndex]=t;else{let n=u.push(t)-1;Q.push({edge:e.edge,rectIndex:n})}}return j.length&&d.set(Y,Q),F}}(d,y,u,M,b),w=[];for(let i of e.edges){let o=n.has(i)?th(i):void 0,s=eX(eD(i.points)),l=d.get(i.source),h=d.get(i.target);l&&(s=ek(s,l,!0)),h&&(s=ek(s,h,!1)),tb(i,s,u.edges,u.style)&&e7(u,i,s),tu(i,o);let x=i.edgeIndex??-1,p=a[x]??"primary-forward",k={edgeIndex:x,routeClass:p,bendCount:eG(i.points),invariant:"straight"};if(n.has(i)&&tl(i))k.invariant="bundle";else if("self-loop"===p){let t;if(r?.preserveSelfLoops){let e=d.get(i.source),n=(e,t)=>.01>=Math.abs(e.x-t.x)&&Math.abs(e.y-t.y)>.01?t.y>e.y?"S":"N":.01>=Math.abs(e.y-t.y)&&Math.abs(e.x-t.x)>.01?t.x>e.x?"E":"W":void 0,r=i.points[0],a=i.points.at(-1),o=r&&i.points.find(e=>Math.hypot(e.x-r.x,e.y-r.y)>.01),s=a&&[...i.points].reverse().find(e=>Math.hypot(e.x-a.x,e.y-a.y)>.01);t=e&&r&&a&&o&&s&&Math.hypot(r.x-a.x,r.y-a.y)>=8&&n(r,o)===n(a,s)?n(r,o):void 0}M.length=0,t&&e.edges.some(e=>e!==i&&e.source===e.target&&ti(i.points,e.points))&&(t=void 0);let n=t??$(i);n?(b.add(i),k.invariant="self-loop",k.loopSide=n,k.bendCount=eG(i.points)):(k.invariant="explained-detour",M.length&&(k.directLaneBlockedBy=[...M]))}else if("container"===p){k.invariant="container-attach";let n=function(e,t,n){let i=e=>{let i=t.get(e);if(i)return{id:e,label:"",shape:"rectangle",x:i.x,y:i.y,width:i.width,height:i.height};let r=n.get(e);return r&&eT(r)?r:null},r=i(e.source),a=i(e.target);if(!r||!a)return null;let o=eX(e.points);if(2===o.length&&t2(o[0],r.x,r.y,r.width,r.height,1)&&t2(o[1],a.x,a.y,a.width,a.height,1))return null;let s=[{gap:a.y-(r.y+r.height),axis:{main:"y",cross:"x",sign:1}},{gap:r.y-(a.y+a.height),axis:{main:"y",cross:"x",sign:-1}},{gap:a.x-(r.x+r.width),axis:{main:"x",cross:"y",sign:1}},{gap:r.x-(a.x+a.width),axis:{main:"x",cross:"y",sign:-1}}].filter(e=>e.gap>.01).sort((e,t)=>t.gap-e.gap)[0];return s?{source:r,target:a,axis:s.axis}:null}(i,y,d);if(n){let r=tF(i,n.source,n.target,u,n.axis).applied,a=!r&&(f??=eF(t)&&!z()&&!e.edges.some(e=>e.label))&&tI(i.points,i,u)>0&&m(i,n.source,n.target,u,n.axis,!1,{requireFewerCrossings:!0});(r||a)&&(k.bendCount=eG(i.points),r&&(k.directLaneClear=!0,k.straightened=!0))}}else if("primary-forward"===p||"feedback"===p)if(i.points.length>2){let e=g(i,k);(!e.applied||e.upgradeable)&&w.push({edge:i,cert:k})}else{let t=d.get(i.source),n=d.get(i.target),r=!i.label&&void 0!==i.edgeIndex&&e.edges.some(e=>e!==i&&e.source===i.target&&e.target===i.source&&!e.label&&void 0!==e.edgeIndex),[a,o]=[i.points[0],i.points[i.points.length-1]];if(t&&n&&(tD(i.points)||!eY(t,a)||!eY(n,o)||eQ(i,t,n)>0||tR(i,u)||r)){let e=g(i,k);(!e.applied||e.upgradeable)&&w.push({edge:i,cert:k})}}c.push({edge:i,cert:k})}for(let e=0;e<4&&w.length>0;e++){let e=[],t=!1;for(let n of w){if("unverified-shape"===n.cert.invariant)continue;let i=g(n.edge,n.cert);i.mutated&&(t=!0),(!i.applied||i.upgradeable)&&e.push(n)}if(!t)break;w.length=0,w.push(...e)}for(let t of e.edges){let e=n.has(t)?th(t):void 0,i=d.get(t.source),r=d.get(t.target);i&&tk(t,i,!0,u),r&&tk(t,r,!1,u);let a=t.points;i&&(a=ek(a,i,!0)),r&&(a=ek(a,r,!1)),tb(t,a,u.edges,u.style)&&e7(u,t,a),tu(t,e)}let k=[],v=e4(e,t,a),P=(e,t)=>{let n=eG(e.points),i=d.get(e.source),r=d.get(e.target),a=v.byEdge.get(e),o={edgeIndex:t.edgeIndex,routeClass:t.routeClass,bendCount:n,directLaneClear:t.directLaneClear,directLaneBlockedBy:t.directLaneBlockedBy,sourcePort:i&&e.points.length>0?eY(i,e.points[0]):void 0,targetPort:r&&e.points.length>0?eY(r,e.points[e.points.length-1]):void 0,sourcePortAssignment:a?.source,targetPortAssignment:a?.target,...void 0!==t.loopSide?{loopSide:t.loopSide}:{}};return"straight"===t.invariant&&0===n&&2===e.points.length?{...o,invariant:"straight",...t.straightened?{straightened:!0}:{}}:{...o,invariant:"straight"===t.invariant?"explained-detour":t.invariant}};for(let{edge:e,cert:t}of c){let n=P(e,t);e.routeCertificate=n,k.push(n)}return k}function t1(e,t,n,i){if(!t){e.routeCertificate=void 0;return}let r={edgeIndex:t.edgeIndex,routeClass:t.routeClass,bendCount:eG(e.points),directLaneClear:t.directLaneClear,directLaneBlockedBy:t.directLaneBlockedBy,sourcePort:n&&e.points.length>0?eY(n,e.points[0]):t.sourcePort,targetPort:i&&e.points.length>0?eY(i,e.points[e.points.length-1]):t.targetPort,sourcePortAssignment:t.sourcePortAssignment,targetPortAssignment:t.targetPortAssignment,...void 0!==t.loopSide?{loopSide:t.loopSide}:{}};if(2===e.points.length&&0===eG(e.points)){e.routeCertificate={...r,invariant:"straight"};return}e.routeCertificate={...r,invariant:"straight"!==t.invariant&&("bundle"!==t.invariant||tl(e))?t.invariant:"explained-detour"}}function t0(e,t,n,i){let r=[];for(let t of e.edges)void 0!==t.edgeIndex&&t.routeCertificate&&(r[t.edgeIndex]=t.routeCertificate.routeClass);let{axis:a,ctx:o}=e6(e,t,n,r,tX,!0),s=te(e.nodes),l=o.sideUse,h=[],u=new Set;for(let t of e.edges){let e=t.routeCertificate;if(!e||tX(t)||"primary-forward"!==e.routeClass&&"feedback"!==e.routeClass)continue;let n="feedback"===e.routeClass?{...a,sign:1===a.sign?-1:1}:a,r=eX(t.points);if(r.length<=2)continue;let d=s.get(t.source),x=s.get(t.target);if(!d||!x||!eT(d)||!eT(x)||"feedback"!==e.routeClass&&!eK(r,n))continue;let y=tS(t,d,x,o,n);if(y&&function(e,t,n,i){if(e.points.length<=2)return!1;let r=e.points[0],a=e.points[e.points.length-1],o=tw(t,i.sourcePort),s=ej(n)[i.targetPort];return .5>=Math.abs(r.x-o.x)&&.5>=Math.abs(r.y-o.y)&&.5>=Math.abs(a.x-s.x)&&.5>=Math.abs(a.y-s.y)}(t,d,x,y))continue;let c=l.get(`${t.source}:${e2(n,1)}`)??1,f="primary-forward"===e.routeClass&&eJ(d)&&1===c&&t$(d)>=t$(x)?d[n.cross]+("y"===n.cross?d.height:d.width)/2:void 0;tF(i?t:{...t,points:r.map(e=>({...e}))},d,x,o,n,f,t).applied&&(h.push({edge:tC(t),deviationPx:Math.round(10*function(e,t){let n=1/0,i=-1/0;for(let r of e)n=Math.min(n,r[t.cross]),i=Math.max(i,r[t.cross]);return i-n}(r,n))/10}),i&&u.add(t))}if(u.size>0){let n=e4(e,t,r);for(let e of u){let t=e.routeCertificate;if(!t||2!==e.points.length||0!==eG(e.points))continue;let i=s.get(e.source),r=s.get(e.target),a=n.byEdge.get(e);e.routeCertificate={edgeIndex:t.edgeIndex,routeClass:t.routeClass,invariant:"straight",bendCount:0,directLaneClear:!0,sourcePort:i?eY(i,e.points[0]):void 0,targetPort:r?eY(r,e.points[1]):void 0,sourcePortAssignment:a?.source,targetPortAssignment:a?.target,straightened:!0}}}return h}function t2(e,t,n,i,r,a){let o=(Math.abs(e.x-t)<=a||Math.abs(e.x-(t+i))<=a)&&e.y>=n-a&&e.y<=n+r+a,s=(Math.abs(e.y-n)<=a||Math.abs(e.y-(n+r))<=a)&&e.x>=t-a&&e.x<=t+i+a;return o||s}var t5=Symbol("label-seat-sort-denied");function t8(e,t){if(t&&!t(1))return;let n=[];for(let i=1;i<e.points.length;i++){if(t&&!t(2))return;let r=e.points[i-1],a=e.points[i],o=.01>Math.abs(r.x-a.x);if(o||.01>Math.abs(r.y-a.y)){if(t&&!t(12))return;n.push({a:r,b:a,vertical:o,len:Math.abs(r.x-a.x)+Math.abs(r.y-a.y),i:i})}}if(!t||t(2*n.length+1)){try{n.sort((e,n)=>{if(t&&!t(4))throw t5;return n.len-e.len||e.i-n.i})}catch(e){if(e===t5)return;throw e}return n}}function t4(e,t){t?.();let n=[];for(let i=0;i<11;i++)t?.(),n.push(e+i/10*(1-2*e));return n.sort((e,n)=>(t?.(),Math.abs(e-.5)-Math.abs(n-.5)))}function*t6(e,t,n,i=0,r=!1,a=!1,o){if(e)for(let s of e){let e=(s.vertical?n:t)/2;if(!r&&s.len<=2*e)continue;let l=r?0:e/s.len;if(o&&!o(160))return;for(let e of a?[5,4,6,3,7,2,8,1,9,0,10].map(e=>l+e/10*(1-2*l)):t4(l))yield{x:s.a.x+(s.b.x-s.a.x)*e+(s.vertical?i:0),y:s.a.y+(s.b.y-s.a.y)*e+(s.vertical?0:i)}}}function t3(e,t){return h(e,t.lineWidth??1)}function t9(e,t,n){n?.();let i,r=(e,t)=>t.some(t=>{n?.();let i=t.concurrencyRegion?0:t.headerHeight??t.height;return i>0&&e.x<t.x+t.width&&e.x+e.w>t.x&&e.y<t.y+i&&e.y+e.h>t.y||r(e,t.children)}),a=r=>{for(let a of z()?e.edges.flatMap(e=>(n?.(),K(e,t))):i??=e.edges.flatMap(e=>(n?.(),K(e,t)))){n?.();let e=a.bounds;if(e&&r.x<e.x1&&r.x+r.w>e.x0&&r.y<e.y1&&r.y+r.h>e.y0)return!0}return!1};return{overlapsMarker:a,clearPaintRect:(i,o,s)=>{n?.();let l={x:i.x-o,y:i.y-o,w:i.w+2*o,h:i.h+2*o},h=t.lineWidth??1,d=u(s,h,"start")-o,x=u(s,h,"end")-o;if(!(e.nodes.some(e=>{n?.();let t=Math.max(0,e.id===s.source?d:0,e.id===s.target?x:0);return l.x<e.x+e.width+t&&l.x+l.w+t>e.x&&l.y<e.y+e.height+t&&l.y+l.h+t>e.y})||r(l,e.groups)||a(l)))return l}}}function t7(e,t,n){let i,r=[];for(let t of e.edges){if(!t.label||!t.labelPosition||t.points.length<2||!tj(t,e.edges,n))continue;let a=i??=t9(e,n),s=t3(t,n),h=t.labelBlock??o(N(t.label,t.labelContent),n),u=h.width+2*l,x=h.height+2*l,y=t8(t),c=t.labelPosition,f=!1,g=Math.min(u,x)/2-1;for(let i of[0,g,-g]){if(f)break;for(let r of t6(y,u,x,i,!1,!0))if(t.labelPosition=r,a.clearPaintRect(d(r.x,r.y,h),s,t)&&!tj(t,e.edges,n)){f=!0;break}}f||(t.labelPosition=c,r.push({edge:t,width:h.width}))}for(let{edge:a}of(r.sort((e,t)=>e.width-t.width),r))if(tj(a,e.edges,n)&&!ne(a,e,t,n,i))for(let r=0;r<e.edges.length;r++){let r=tj(a,e.edges,n);if(!r||!ne(r,e,t,n,i,a))break}}function ne(t,n,i,r,a,s=t){if(!eF(i)||z()||t.source===t.target||n.groups.length||t.curve||(r.edgeBendRadius??0)>0||(r.lineWidth??1)>2||t.inlineStyle?.["stroke-width"])return!1;let h=t.points,u=h[0],y=h.at(-1),c=h[1],f=h.at(-2),g=u.y===c.y?"x":"y",p="x"===g?"y":"x";if(u[p]!==c[p]||y[p]!==f[p])return!1;let m=Math.sign(c[g]-u[g]),M=Math.sign(f[g]-y[g]);if(!m||!M)return!1;let b=m===M,$=b?g:p,w=b?p:g,k=(t.label?t:s).labelBlock??o(N((t.label?t:s).label,(t.label?t:s).labelContent),r),v=("x"===$?k.width:k.height)/2+l+8,S=(t.labelPosition??s.labelPosition)[$],P=(e,i,a)=>{let o=[];for(let t of n.nodes)o.push(t[e]-i-4,t[e]+("x"===e?t.width:t.height)+i+4);for(let s of n.edges){if(a)for(let t of s.points)o.push(t[e]-i-4,t[e]+i+4);let n=s!==t||a?x(s,r):null;n&&o.push(("x"===e?n.x:n.y)-i-8-.01,("x"===e?n.x+n.w:n.y+n.h)+i+8+.01)}return o},C=[S-v-4,S+v+4,...P($,v,!0)];C.sort((e,t)=>Math.abs(e-S)-Math.abs(t-S)||e-t);let W=tz(n.nodes,n.edges,i.direction,r,n.groups).ctx;W.fixedLabels=!0,W.finalLabelClearance=!0;let L=te(n.nodes),E=L.get(t.source),I=L.get(t.target);if(!E||!I)return!1;let R={start:eO(r,t,"start"),end:eO(r,t,"end")},B={start:e(h,!0),end:e(h,!1)},H=b?p:g,A=[c[H],f[H],...P(H,0,!1)],F=[];for(let e of n.edges){if(e===t)continue;let n=ty(e,r);if(!n)return!1;F.push(...n)}let O=(r.lineWidth??1)*("thick"===t.style?2:1)/2+.01,j=(e,n)=>{let i=e.x===n.x,r=i?"y":"x",a=i?"x":"y",o=Math.min(e[r],n[r]),s=Math.max(e[r],n[r]);for(let t=1;t<h.length;t++){let n=h[t-1],i=h[t];if(n[a]!==e[a]||i[a]!==e[a])continue;let l=Math.min(n[r],i[r]),u=Math.max(n[r],i[r]);l<=o&&u>=o&&(o=Math.min(s,u)),l<=s&&u>=s&&(s=Math.max(o,l))}if(o>=s)return!0;let l=i?e.x:o,u=i?e.x:s,d=i?o:e.y,x=i?s:e.y;return!F.some(e=>{let t=e.bounds;return l-O<=t.x1&&u+O>=t.x0&&d-O<=t.y1&&x+O>=t.y0})&&!tW({...t,label:void 0},e[a],o,s,W,{main:r,cross:a,sign:e[r]>n[r]?1:-1})},V=(e,i,r,a,o)=>{let s=R[o];for(let t of F){let n=t.bounds;if(e.x<n.x0-O||e.x>n.x1+O||e.y<n.y0-O||e.y>n.y1+O)continue;let i="x"===g?r>0?n.x1:n.x0:r>0?n.y1:n.y0;s=Math.max(s,r*(i-e[g])+O+.01)}let l=Math.min(s,B[o]),h={...e,[g]:e[g]+r*l},u=[...new Set([b?e[p]:h[g],...A])].filter(t=>b||r*(t-e[g])>=l).sort((t,n)=>Math.abs(t-e[H])-Math.abs(n-e[H])||t-n),d=[];for(let i of u){let r={...b?h:e,[H]:i},o={...r,[$]:a},s=eX(b?[e,h,r,o]:[e,r,o]);if(!n.nodes.some(e=>tY(e.id===t.source||e.id===t.target?s.slice(1):s,e))&&!s.slice(1).some((e,t)=>!j(e,s[t]))&&(d.push(s),8===d.length))break}return d},Y=tI(h,t,W),Q=n.edges.filter(e=>e!==t&&"invisible"!==e.style),q=Q.map(e=>td(h,e.points)),T;e:for(let e of[...new Set(C)].slice(0,128)){if(b&&(m*(e-u[g])<R.start||M*(e-y[g])<R.end))continue;let i=V(u,c,m,e,"start"),o=V(y,f,M,e,"end");for(let e of i)for(let i of o){let o=e.at(-1),l=i.at(-1),h=eX([...e,...i.toReversed()]);if(!tr(h)||h[1][p]!==u[p]||h.at(-2)[p]!==y[p]||.01>=Math.abs(o[w]-l[w])||eQ({...t,points:h},E,I)||n.nodes.some(e=>tY(e.id===t.source?h.slice(1):e.id===t.target?h.slice(0,-1):h,e))||h.slice(1).some((e,t)=>!j(e,h[t]))||!tb(t,h,n.edges,r))continue;let x=0;if(Q.some((e,t)=>{let n=td(h,e.points);return x+=n,n>q[t]+2})||T&&x>=T.crossings)continue;let c={...t,points:h},f;if(t.label)for(let e of t8(c)){let i=tE(c,e.a,e.b,W);if(i&&a.clearPaintRect(d(i.x,i.y,k),t3(t,r),t)&&!tj(c,n.edges,r,i)){f=i;break}}if(!(t.label&&!f)&&!(s!==t&&tj(s,[s,c],r))&&(T={points:h,label:f,crossings:x},x<=Y))break e}}if(T){let e=t.routeCertificate;return t.points=T.points,t.label&&(t.labelPosition=T.label),t1(t,e,E,I),!0}return!1}function nt(e,t,n){let i=(e,t,n)=>{let i=n.x-t.x,r=n.y-t.y,a=i*i+r*r;if(0===a)return Math.hypot(e.x-t.x,e.y-t.y);let o=Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/a));return Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*r))},r;for(let t of e.edges){if(!t.label||!t.labelPosition||t.points.length<2||t.source===t.target)continue;let a=t.labelBlock??o(N(t.label,t.labelContent),n),s=a.width+2*l,h=a.height+2*l,u=h/2+4,x=e=>{let n=1/0;for(let r=1;r<t.points.length;r++)n=Math.min(n,i(e,t.points[r-1],t.points[r]));return n};if(x(t.labelPosition)<=u)continue;let y=r??=t9(e,n),c=t3(t,n),f=(i,r)=>x({x:i,y:r})<=u&&!!y.clearPaintRect(d(i,r,a),c,t)&&!tj(t,e.edges,n,{x:i,y:r}),g=t8(t),p=!1;for(let e of t6(g,s,h))if(f(e.x,e.y)){t.labelPosition=e,p=!0;break}if(!p){let e=t.points[0],n=1/0;for(let i of g.length?g:[]){let r=i.b.x-i.a.x,a=i.b.y-i.a.y,o=r*r+a*a||1,s=Math.max(0,Math.min(1,((t.labelPosition.x-i.a.x)*r+(t.labelPosition.y-i.a.y)*a)/o)),l=i.a.x+s*r,h=i.a.y+s*a,u=Math.hypot(t.labelPosition.x-l,t.labelPosition.y-h);u<n&&(n=u,e={x:l,y:h})}let i=n>.01?(t.labelPosition.x-e.x)/n:0,r=n>.01?(t.labelPosition.y-e.y)/n:-1,a=u-1;for(let n of[1,-1]){let o=e.x+i*a*n,s=e.y+r*a*n;if(f(o,s)){t.labelPosition={x:o,y:s};break}}}}}function nn(e,t,n=C({}),i){let r=1e6,a=e.edges.filter(e=>e.label&&e.labelPosition&&e.points.length>=2);if(0===a.length)return;let s=e=>{let t=x(e,n),i=t3(e,n);return t&&{x:t.x-i,y:t.y-i,w:t.w+2*i,h:t.h+2*i}},h=(e,t)=>Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x)>.5&&Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y)>.5,{overlapsMarker:u,clearPaintRect:y}=t9(e,n),f=function*(t,a,u=!1,x,f=!0){if(x&&!x.pay(16))return;let g=t.labelBlock??o(N(t.label,t.labelContent),n),p=g.width+2*l,m=g.height+2*l,M=t3(t,n),b=(o,l,u)=>{if(x)return x.pay(3)&&x.clear({x:o,y:l});if(i?.preserveRouteClearance&&r<=0)return!1;let f=y(d(o,l,g),M,t);if(!f)return!1;for(let e of a){let t=s(e);if(t&&h(f,t))return!1}if(tj(t,e.edges,n,{x:o,y:l}))return!1;if(i?.preserveRouteClearance||u){for(let n of e.edges)if(n!==t&&"invisible"!==n.style){for(let e=1;e<n.points.length;e++)if(i?.preserveRouteClearance&&--r<0||c(n.points[e-1],n.points[e],f))return!1}}return!0},$=x?t8(t,x.pay):t8(t);if(!$)return;let w=m/2+4,k=[w-1,-(w-1),(w-1)/2,-(w-1)/2];for(let[e,t]of[[0,!1],...k.map(e=>[e,!0]),...f?k.map(e=>[e,!1]):[]])for(let n of t6($,p,m,e,u,!1,x?.pay)){if(i?.preserveRouteClearance&&r<=0)return;b(n.x,n.y,t)&&(yield n)}},g=(e,t,n=!0)=>{for(let i of f(e,t,!1,void 0,n))return e.labelPosition=i,!0;return!1},p=(e,t)=>{let n=a.filter(n=>n!==e&&n!==t);for(let i of[!1,!0]){let r=e=>{let t=[];for(let r of f(e,n,i))if(t.push(r),64===t.length)break;return t},a=r(e),o=r(t);for(let n of a)for(let i of o)if(!h(s({...e,labelPosition:n}),s({...t,labelPosition:i})))return e.labelPosition=n,t.labelPosition=i,!0}return!1},m=()=>{if(z())return;let t=e=>e>r?(r=0,!1):(r-=e,!0);if(!t(8))return;let i=(n,i)=>{for(let r of e.edges){if(!t(1))break;if(r!==n&&"invisible"!==r.style)for(let e=1;e<r.points.length;e++){if(!t(1))return!1;if(c(r.points[e-1],r.points[e],i))return!0}}return!1},o;for(let l of a){if(!t(64+(l.label?.length??0)*12+2*e.edges.length))return;let h=s(l);if(!h||!u(h)&&!i(l,h))continue;if(!t(l.points.length+2))return;if(l.curve||(n.edgeBendRadius??0)!==0||l.points.some((e,t)=>t>0&&e.x!==l.points[t-1].x&&e.y!==l.points[t-1].y))continue;if(!(o??=tU(e.nodes,e.edges,e.groups,n,t))||!t(8))return;let d=new Set,y=new Map,c=(e,i,a,s)=>{if(!t(8))return;let l=[],h=new Map,u=i=>{if(e.source===e.target){if(!t(e.points.length+8))return!1;let r=x({...e,labelPosition:i},n);if(!r||e.points.some((t,n)=>{var i;return n>0&&(.01>=Math.abs((i=e.points[n-1]).x-t.x)?i.x>r.x+.01&&i.x<r.x+r.w-.01&&Math.min(Math.max(i.y,t.y),r.y+r.h)-Math.max(Math.min(i.y,t.y),r.y)>.01:.01>=Math.abs(i.y-t.y)&&i.y>r.y+.01&&i.y<r.y+r.h-.01&&Math.min(Math.max(i.x,t.x),r.x+r.w)-Math.max(Math.min(i.x,t.x),r.x)>.01)}))return!1}return o.clear(e,i,h,s,a)};for(let n of f(e,[],i,{clear:u,pay:t})){if(!t(1))return;if(l.push(n),64===l.length)break}return r>0?l:void 0},g=!1,p=c(l,!0,void 0,d);if(!p)return;for(let e of p){if(!t(3))return;if(y.set(l,e),o.clear(l,e,y)){l.labelPosition=e,g=!0;break}}if(g)continue;let m=a.filter(e=>d.has(e)&&!e.curve&&!e.points.some((t,n)=>n>0&&t.x!==e.points[n-1].x&&t.y!==e.points[n-1].y));for(let e of a){if(!t(1))return;if(m.includes(e)){if(!t(e.points.length+6))return;for(let n of[!1,!0]){let i=c(l,n,e),r=c(e,n,l);if(!i||!r)return;e:for(let n of i)for(let i of r){if(!t(16))return;let r=new Map([[l,n],[e,i]]);if(!(!o.clear(l,n,r)||!o.clear(e,i,r))){l.labelPosition=n,e.labelPosition=i,g=!0;break e}}if(g)break}if(g)break}}if(g||m.length<2)continue;let M=new Set(m);for(let e of[!1,!0]){let n=c(l,e,M);if(!n)return;e:for(let i of n){if(!t(8+4*m.length))return;let n=new Map([[l,i]]);for(let t of m){let i=c(t,e,l);if(!i)return;let r=i.find(e=>o.clear(t,e,new Map(n).set(t,e)));if(!r)continue e;n.set(t,r)}if([...n].every(([e,t])=>o.clear(e,t,n))){for(let[e,t]of n)e.labelPosition=t;g=!0;break}}if(g)break}}};for(let e=0;e<3;e++){if(i?.preserveRouteClearance&&r<=0)return;let t=0;for(let e of a){let n=s(e);n&&u(n)&&(t++,g(e,a.filter(t=>t!==e),!1))}for(let e=0;e<a.length;e++)for(let n=e+1;n<a.length;n++){let i=a[e],r=a[n],o=s(i),l=s(r);!o||!l||!h(o,l)||(t++,g(r,a.filter(e=>e!==r))||g(i,a.filter(e=>e!==i))||p(i,r))}if(0===t){m();break}2===e&&m()}}function ni(n,i,r){let a;for(let o of n.edges){if("invisible"===o.style||o.points.length<3||!o.hasArrowStart&&!o.hasArrowEnd)continue;let s=D(o,r);if(e(o.points,!0)+1e-7>=s.start&&e(o.points,!1)+1e-7>=s.end)continue;let l=t(o.points,s);if(!l)continue;let{ctx:h}=a??=tz(n.nodes,n.edges,i.direction,r,n.groups),u=h.nodes.find(e=>e.id===o.source),d=h.nodes.find(e=>e.id===o.target);if(eQ({...o,points:l},u,d)||tV(l,o,h)||!tb(o,l,n.edges,r))continue;let x=!0;for(let e=1;e<l.length&&x;e++){let t=l[e-1],n=l[e],i=eU(t.x===n.x?"TB":"LR");x=!tW(o,t[i.cross],Math.min(t[i.main],n[i.main]),Math.max(t[i.main],n[i.main]),h,i)}x&&(o.points=l,t1(o,o.routeCertificate,u,d))}}function nr(e,t,n){for(let i=0;i<e.edges.length&&0!==t0(e,t,n,!0).length;i++);return function(e,t,n){let i=te(e);for(let e of t){let r=e.routeCertificate,a=!1,o=e.points;for(let t of[!0,!1]){let[n,r,s]=(t?[...o].reverse():o).slice(-3),l=i.get(t?e.source:e.target);if(!l||"rectangle"!==l.shape||void 0!==l.semanticShape&&"rect"!==l.semanticShape||!n||!r||!s||Math.hypot(s.x-r.x,s.y-r.y)>=1)continue;let h=(.01>Math.abs(r.x-l.x)||.01>Math.abs(r.x-l.x-l.width))&&.01>Math.abs(s.x-r.x)&&.01>Math.abs(n.y-r.y)&&r.y>l.y&&r.y<l.y+l.height&&s.y>l.y&&s.y<l.y+l.height&&(n.x-r.x)*(r.x-l.x-l.width/2)>0,u=(.01>Math.abs(r.y-l.y)||.01>Math.abs(r.y-l.y-l.height))&&.01>Math.abs(s.y-r.y)&&.01>Math.abs(n.x-r.x)&&r.x>l.x&&r.x<l.x+l.width&&s.x>l.x&&s.x<l.x+l.width&&(n.y-r.y)*(r.y-l.y-l.height/2)>0;(h||u)&&(o=t?o.slice(1):o.slice(0,-1),a=!0)}a&&tb(e,o,t,n)&&(e.points=o,t1(e,r,i.get(e.source),i.get(e.target)))}}(e.nodes,e.edges,n),e.edges.flatMap(e=>e.routeCertificate?[e.routeCertificate]:[])}function na(){return{total:0,labelLabel:0,labelNode:0,labelEdge:0}}function no(e,t){return Math.min(e.x+e.w,t.x+t.w)-Math.max(e.x,t.x)>y&&Math.min(e.y+e.h,t.y+t.h)-Math.max(e.y,t.y)>y}function ns(e,t,n){let i=e.edges.flatMap((e,n)=>{if(!e.label)return[];let i=x(e.labelPosition?e:{...e,labelPosition:p(e.points)},t);return i?[{edgeIndex:n,rect:i}]:[]});return 0===i.length?na():function(e,t,n,i){let r=na(),a=i?e.filter(e=>i.has(e.edgeIndex)):e,o=i?[...i].filter(e=>void 0!==n[e]):[];for(let s=0;s<e.length;s++){let l=e[s],h=!i||i.has(l.edgeIndex),u=h?e:a;for(let e=h?s+1:0;e<u.length;e++){let t=u[e];!h&&t.edgeIndex<=l.edgeIndex||no(l.rect,t.rect)&&r.labelLabel++}if(h)for(let e of t)no(l.rect,e)&&r.labelNode++;for(let e=0;e<(h?n.length:o.length);e++){let t=h?e:o[e],i=n[t];if(!(t===l.edgeIndex||i.hidden)){for(let e=1;e<i.points.length;e++)if(c(i.points[e-1],i.points[e],l.rect)){r.labelEdge++;break}}}}return r.total=r.labelLabel+r.labelNode+r.labelEdge,r}(i,e.nodes.map(e=>({x:e.x,y:e.y,w:e.width,h:e.height})),e.edges.map(e=>({points:e.points,hidden:"invisible"===e.style})),n)}var nl={edgeThroughNode:"primary",nodeOverlaps:"primary",diagonalSegments:"secondary",unexplainedBends:"secondary",hitches:"secondary",offOutlineEndpoints:"cosmetic",endpointApproaches:"primary",labelOffRoute:"cosmetic"},nh={primary:0,secondary:1,cosmetic:2};function nu(e,t){let n=e=>.5>=Math.abs(e.x-t.x)&&.5>=Math.abs(e.y-t.y);return!!(Object.values(ej(e)).some(n)||"diamond"===e.shape&&Object.values(eV(e)).some(n))}function nd(e,t,n=1.5){let i=eE(e,t,n);return"none"===i.policy||i.onBoundary}function nx(e,t,n){let i=n.x+n.width/2,r=n.y+n.height/2,a=n.width/2,o=n.height/2,s=Math.min(e.x,t.x),l=Math.max(e.x,t.x),h=Math.min(e.y,t.y),u=Math.max(e.y,t.y);if("cylinder"===n.shape&&(void 0===n.semanticShape||"cyl"===n.semanticShape)&&n.height>14&&l>n.x&&s<n.x+n.width&&u>n.y+7&&h<n.y+n.height-7)return!0;let d=.5*("rectangle"!==n.shape&&"subroutine"!==n.shape||void 0!==n.semanticShape&&"rect"!==n.semanticShape&&"fr-rect"!==n.semanticShape&&"lin-rect"!==n.semanticShape&&"div-rect"!==n.semanticShape&&"win-pane"!==n.semanticShape);if(!(l>n.x+d&&s<n.x+n.width-d&&u>n.y+d&&h<n.y+n.height-d))return!1;switch(n.shape){case"ellipse":case"circle":case"doublecircle":case"state-start":case"state-end":return nm({x:0,y:0},{x:(e.x-i)/a,y:(e.y-r)/o},{x:(t.x-i)/a,y:(t.y-r)/o})<1-2.5/Math.min(a,o);case"stadium":return ny(e,t,{x:i-(a-o),y:r},{x:i+(a-o),y:r})<o-2.5;case"diamond":case"hexagon":case"trapezoid":case"trapezoid-alt":case"lean-r":case"lean-l":case"asymmetric":{let s,l="diamond"===n.shape?[{x:i,y:n.y},{x:n.x+n.width,y:r},{x:i,y:n.y+n.height},{x:n.x,y:r}]:"hexagon"===n.shape?(s=n.height/4,[{x:n.x+s,y:n.y},{x:n.x+n.width-s,y:n.y},{x:n.x+n.width,y:r},{x:n.x+n.width-s,y:n.y+n.height},{x:n.x+s,y:n.y+n.height},{x:n.x,y:r}]):function(e){let{x:t,y:n,width:i,height:r}=e,a=.15*i;switch(e.shape){case"trapezoid":return[{x:t+a,y:n},{x:t+i-a,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-a,y:n+r},{x:t+a,y:n+r}];case"lean-r":return[{x:t+a,y:n},{x:t+i,y:n},{x:t+i-a,y:n+r},{x:t,y:n+r}];case"lean-l":return[{x:t,y:n},{x:t+i-a,y:n},{x:t+i,y:n+r},{x:t+a,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}]}}(n),h=Math.max(0,1-2.5/Math.min(a,o));return function(e,t,n){let i=e=>{for(let t=0;t<n.length;t++){let i=n[t],r=n[(t+1)%n.length];if((r.x-i.x)*(e.y-i.y)-(r.y-i.y)*(e.x-i.x)<-.5)return!1}return!0},r={x:(e.x+t.x)/2,y:(e.y+t.y)/2};if(i(e)||i(t)||i(r))return!0;for(let i=0;i<n.length;i++)if(nc(e,t,n[i],n[(i+1)%n.length]))return!0;return!1}(e,t,l.map(e=>({x:i+(e.x-i)*h,y:r+(e.y-r)*h})))}default:return!0}}function ny(e,t,n,i){return nc(e,t,n,i)?0:Math.min(nm(e,n,i),nm(t,n,i),nm(n,e,t),nm(i,e,t))}function nc(e,t,n,i){let r=(t.x-e.x)*(i.y-n.y)-(t.y-e.y)*(i.x-n.x);if(1e-9>Math.abs(r))return!1;let a=((n.x-e.x)*(i.y-n.y)-(n.y-e.y)*(i.x-n.x))/r,o=((n.x-e.x)*(t.y-e.y)-(n.y-e.y)*(t.x-e.x))/r;return a>.001&&a<.999&&o>.001&&o<.999}function nf(e,t){return r(e.map(e=>({points:e.points,visible:"invisible"!==e.style})),t)}function ng(e,t){let n=new Map;e.forEach((e,t)=>{if("invisible"===e.style||e.source===e.target)return;let i=JSON.stringify([e.source,e.target]),r=n.get(i)??[];r.push({edge:e,index:t}),n.set(i,r)});let i=(e,t)=>{for(let n=1;n<e.points.length;n++)for(let i=1;i<t.points.length;i++){let r=e.points[n-1],a=e.points[n],o=t.points[i-1],s=t.points[i];if(.01>=Math.abs(r.x-a.x)&&.01>=Math.abs(o.x-s.x)&&.5>=Math.abs(r.x-o.x)&&Math.min(Math.max(r.y,a.y),Math.max(o.y,s.y))-Math.max(Math.min(r.y,a.y),Math.min(o.y,s.y))>1||.01>=Math.abs(r.y-a.y)&&.01>=Math.abs(o.y-s.y)&&.5>=Math.abs(r.y-o.y)&&Math.min(Math.max(r.x,a.x),Math.max(o.x,s.x))-Math.max(Math.min(r.x,a.x),Math.min(o.x,s.x))>1)return!0}return!1},r=0;for(let e of n.values())for(let n=0;n<e.length;n++)for(let a=n+1;a<e.length;a++){let o=e[n],s=e[a];(!t||t.has(o.index)||t.has(s.index))&&i(o.edge,s.edge)&&r++}return r}function np(e,t=!1){let n=new Map(e.nodes.map(e=>[e.id,e])),i=0,r=0;for(let a of e.edges)if(!(t&&"invisible"===a.style))for(let[e,t]of[[a.source,a.points[0]],[a.target,a.points.at(-1)]]){let a=n.get(e);a&&(i++,t&&nu(a,t)&&r++)}return 0===i?1:r/i}function nm(e,t,n){let i=n.x-t.x,r=n.y-t.y,a=i*i+r*r;if(0===a)return Math.hypot(e.x-t.x,e.y-t.y);let o=Math.max(0,Math.min(1,((e.x-t.x)*i+(e.y-t.y)*r)/a));return Math.hypot(e.x-(t.x+o*i),e.y-(t.y+o*r))}function nM(e,t){return"LR"===t||"RL"===t?e.y+e.height/2:e.x+e.width/2}function nb(e,t){return"LR"===t||"RL"===t?e.x:e.y}function n$(e,t){return"LR"===t||"RL"===t?e.x+e.width:e.y+e.height}function nw(e,t){let n=t=>t.some(t=>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||n(t.children));return n(t)}function nk(e,t){let n=g(t.edges),i=new Map(e.nodes.map(e=>[e.id,e])),r=new Map,a=new Map;for(let n of e.edges){var o;let e=i.get(n.source),s=i.get(n.target);e&&s&&("LR"===(o=t.direction)?nb(s,o)>n$(e,o):"RL"===o||"BT"===o?n$(s,o)<nb(e,o):nb(s,o)>n$(e,o))&&(r.has(n.source)||r.set(n.source,[]),r.get(n.source).push(s),a.has(n.target)||a.set(n.target,[]),a.get(n.target).push(e))}let s=0,l=(i,r,a)=>{if(!i||r.length<2||r.length>6||!function(e,t,n=1){if(e.length<2)return!1;let i=e.map(e=>nb(e,t));return Math.max(...i)-Math.min(...i)<=n}(r,t.direction,28)||!ez.has(i.shape)||nw(i,e.groups)||!r.every(t=>("in"===a?ez.has(t.shape):"rectangle"===t.shape)&&!nw(t,e.groups))||new Set(r.map(e=>e.id)).size!==r.length)return;for(let e=0;e<r.length;e++)for(let t=0;t<r.length;t++)if(e!==t&&n(r[e].id,r[t].id))return;let o=r.reduce((e,n)=>e+nM(n,t.direction),0)/r.length;s=Math.max(s,Math.abs(nM(i,t.direction)-o))};for(let[e,t]of r)l(i.get(e),t,"out");for(let[e,t]of a)l(i.get(e),t,"in");return s}function nv(e,t,n=C({})){return nS(e,t,n,!0)}function nS(e,t,n,i){let r=[],a=new Map(t.nodes.map(e=>[e.id,e])),o=0,l=0,h=0,u=0,d=0,x=0,y=0,c=0,f=0;for(let e of t.edges){let t=`${e.source}->${e.target}`,g=Math.max(0,e.points.length-2);if("invisible"!==e.style){let n=eQ(e,a.get(e.source),a.get(e.target));n&&(l+=n,r.push({metric:"endpointApproaches",detail:`${t}: ${n} inward or tangent exact endpoint shaft(s)`}))}let p=tX(e);"invisible"===e.style||p||(x+=g,y=Math.max(y,g)),g>0&&e.routeCertificate?.invariant==="straight"&&(u+=g,r.push({metric:"unexplainedBends",detail:`${t} certified straight with ${g} bends`}));for(let n=1;n<e.points.length;n++){let i=e.points[n-1],a=e.points[n];Math.abs(i.x-a.x)>.01&&Math.abs(i.y-a.y)>.01&&(h++,r.push({metric:"diagonalSegments",detail:`${t} segment ${n}`}))}for(let[n,i,s]of[[e.source,e.points[0],"source"],[e.target,e.points[e.points.length-1],"target"]]){let e=a.get(n);!e||i&&nd(e,i)||(o++,r.push({metric:"offOutlineEndpoints",detail:i?`${t} ${s} on ${n}(${e.shape}) at (${i.x.toFixed(1)},${i.y.toFixed(1)})`:`${t} missing ${s} endpoint on ${n}`}))}let m=a.get(e.source),M=a.get(e.target),b=(e,t)=>!!e&&!!t&&nu(e,t);if((b(m,e.points[0])||b(M,e.points[e.points.length-1]))&&c++,e.label&&e.labelPosition&&e.points.length>=2){let a=e.labelBlock??s(e.label,n,"edge"),o=(a.height+16)/2+4,l=e.source===e.target,h=1/0;for(let t=1;t<e.points.length;t++)h=Math.min(h,l?function(e,t,n,i,r,a){let o=r=>r.x>=e-n&&r.x<=e+n&&r.y>=t-i&&r.y<=t+i;if(o(r)||o(a))return 0;let s=[{x:e-n,y:t-i},{x:e+n,y:t-i},{x:e+n,y:t+i},{x:e-n,y:t+i}],l=1/0;for(let e=0;e<4;e++)l=Math.min(l,ny(s[e],s[(e+1)%4],r,a));return l}(e.labelPosition.x,e.labelPosition.y,(a.width+16)/2,(a.height+16)/2,e.points[t-1],e.points[t]):nm(e.labelPosition,e.points[t-1],e.points[t]));h>o&&(d++,r.push({metric:"labelOffRoute",detail:`${t} label ${h.toFixed(1)}px from its route (allowed ${o.toFixed(1)})`})),i&&(f=Math.max(f,e.label&&e.labelPosition&&!(e.points.length<2)?Math.abs(function(e,t){let n=0,i=[];for(let e=1;e<t.length;e++){let r=Math.hypot(t[e].x-t[e-1].x,t[e].y-t[e-1].y);i.push(r),n+=r}let r=1/0,a=0,o=0;for(let n=1;n<t.length;n++){let s=t[n-1],l=t[n],h=l.x-s.x,u=l.y-s.y,d=h*h+u*u,x=d?((e.x-s.x)*h+(e.y-s.y)*u)/d:0;x=Math.max(0,Math.min(1,x));let y=s.x+x*h,c=s.y+x*u,f=Math.hypot(e.x-y,e.y-c);f<r&&(r=f,a=o+x*i[n-1]),o+=i[n-1]}return n?a/n:.5}(e.labelPosition,e.points)-.5):0))}}let g=0;for(let e of t.edges)for(let n of t.nodes)if(n.id!==e.source&&n.id!==e.target){for(let t=1;t<e.points.length;t++)if(nx(e.points[t-1],e.points[t],n)){g++,r.push({metric:"edgeThroughNode",detail:`${e.source}->${e.target} segment ${t} through ${n.id}`});break}}let p=i?nf(t.edges):0,m=0;for(let e=0;e<t.nodes.length;e++)for(let n=e+1;n<t.nodes.length;n++){let i=t.nodes[e],a=t.nodes[n],o=Math.min(i.x+i.width,a.x+a.width)-Math.max(i.x,a.x),s=Math.min(i.y+i.height,a.y+a.height)-Math.max(i.y,a.y);o>.5&&s>.5&&(m++,r.push({metric:"nodeOverlaps",detail:`${i.id} overlaps ${a.id}`}))}let M=function(e,t,n=C({})){return t0(e,t,n,!1)}(t,e,n);for(let e of M)r.push({metric:"hitches",detail:`${e.edge} deviates ${e.deviationPx}px with a clear lane`});return{metrics:{edges:t.edges.length,offOutlineEndpoints:o,endpointApproaches:l,diagonalSegments:h,unexplainedBends:u,hitches:M.length,nodeOverlaps:m,labelOffRoute:d,edgeThroughNode:g,labelConflicts:i?ns(t,n).total:0,edgeCrossings:p,totalBends:x,maxBendsPerEdge:y,portEndpointRate:np(t),portAnchoredEdgeRate:0===t.edges.length?1:c/t.edges.length,peerBarycenterDelta:i?nk(t,e):0,worstLabelOffset:f},violations:r.map(e=>({...e,severity:nl[e.metric]??"secondary"})).sort((e,t)=>nh[e.severity]-nh[t.severity])}}function nP(e,t,n,i,r=new Set){let a={};for(let o of n)switch(o){case"hard":a.hard=nN(nS(e,t,i,!1)).length;break;case"crossings":a.crossings=nf(t.edges);break;case"portRate":a.portRate=np(t,!0);break;case"symErr":a.symErr=nk(t,e);break;case"parallelOverlaps":a.parallelOverlaps=ng(t.edges);break;case"opposingOverlaps":a.opposingOverlaps=V(t.edges);break;case"endpointApproaches":{let e=new Map(t.nodes.map(e=>[e.id,e]));a.endpointApproaches=t.edges.reduce((t,n)=>t+("invisible"===n.style?0:eQ(n,e.get(n.source),e.get(n.target))),0);break}case"bends":a.bends=t.edges.reduce((e,t)=>e+("invisible"===t.style||(t.routeCertificate?tX(t):r.has(t)&&tl(t))?0:Math.max(0,t.points.length-2)),0);break;case"straight":a.straight=t.edges.filter(e=>"invisible"!==e.style&&2===e.points.length).length}return a}var nC=["offOutlineEndpoints","endpointApproaches","diagonalSegments","unexplainedBends","hitches","nodeOverlaps","labelOffRoute","edgeThroughNode"];function nN(e){let t=new Set(nC);return e.violations.filter(e=>t.has(e.metric))}function nW(e,t,n){if(e.source===e.target)return!1;let i=t.get(e.source),r=t.get(e.target);if(!i||!r)return!1;let a=m(n),o=M(i),s=M(r);return(a.isHorizontal?s.x-o.x:s.y-o.y)*a.sign>8}function nL(e,t,n=18){if(e.length<2)return!1;let i=e.map(e=>b(e,t));return Math.max(...i)-Math.min(...i)<=n}function nE(e,t){let n=m(t),i=[];for(let n of[...e].sort((e,n)=>b(e,t)-b(n,t)||$(e,t)-$(n,t))){let e=b(n,t),r=i.find(n=>18>=Math.abs(b(n[0],t)-e));r||(r=[],i.push(r)),r.push(n)}for(let e of i){let i=[...e].sort((e,n)=>$(e,t)-$(n,t)),r=$(i[0],t);for(let e of i){let i=$(e,t);if(i<r){let t=r-i;n.isHorizontal?e.y+=t:e.x+=t}r=$(e,t)+w(e,t)+24}}}function nI(e,t){let n=t=>t.some(t=>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||n(t.children));return n(t)}function nR(e,t=[]){for(let n of e)t.push(n),nR(n.children,t);return t}function nB(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 nH(e,t,n,i){if(i<=0)return;let r=m(n),a=new Set;for(let n of nR(e))a.has(n)||!t.some(e=>nB(e,n))||(a.add(n),r.isHorizontal?(r.sign>0||(n.x-=i),n.width+=i):(r.sign>0||(n.y-=i),n.height+=i))}function nA(e,t,n,i){if("diamond"===e.shape){let r=(2===i?{LR:["NE","SE"],RL:["NW","SW"],BT:["NW","NE"],TD:["SW","SE"],TB:["SW","SE"]}:3===i?{LR:["NE","E","SE"],RL:["NW","W","SW"],BT:["NW","N","NE"],TD:["SW","S","SE"],TB:["SW","S","SE"]}:{})[t]?.[n];if(r)return"diamond"===e.shape&&("NE"===r||"SE"===r||"SW"===r||"NW"===r)?eV(e)[r]:ej(e)[r]}let r=m(t),a=(n+1)/(i+1);return r.isHorizontal?{x:"E"===r.sourceSide?e.x+e.width:e.x,y:e.y+e.height*a}:{x:e.x+e.width*a,y:"S"===r.sourceSide?e.y+e.height:e.y}}function nF(e,t){return ej(e)[m(t).targetSide]}function nO(e,t){return Array.from({length:e},(n,i)=>(i-(e-1)/2)*t)}function nz(e,t,n,i){let r=Math.abs(t-e);return r/2>=i||r<n+i?e+(t-e)/2:t-Math.sign(t-e)*i}function nj(e,t,n,i){return m(n).isHorizontal?eX([e,{x:i,y:e.y},{x:i,y:t.y},t]):eX([e,{x:e.x,y:i},{x:t.x,y:i},t])}function nV(e,t,n,i){for(let r=1;r<e.length;r++)if(!function(e,t,n,i,r=1,a){let o=Math.min(e.x,t.x),s=Math.max(e.x,t.x),l=Math.min(e.y,t.y),h=Math.max(e.y,t.y);for(let u of n){if(a?.(1),i.has(u.id))continue;let n=u.x-r,d=u.x+u.width+r,x=u.y-r,y=u.y+u.height+r;if(.01>Math.abs(e.x-t.x)){if(e.x>=n&&e.x<=d&&l<y&&h>x)return!1}else if(.01>Math.abs(e.y-t.y)&&e.y>=x&&e.y<=y&&o<d&&s>n)return!1}return!0}(e[r-1],e[r],t,n,1,i))return!1;return!0}function nY(e,t,n,i){if(0===e.points.length)return;let r=m(t),a=n?e.points.length-1:0,o=n?-1:1,s=e.points[a][r.cross],l=1/0,h=-1/0;for(let t=a;t>=0&&t<e.points.length&&!(Math.abs(e.points[t][r.cross]-s)>.5);t+=o)l=Math.min(l,e.points[t][r.main]),h=Math.max(h,e.points[t][r.main]),e.points[t][r.cross]+=i;e.labelPosition&&12>=Math.abs(e.labelPosition[r.cross]-s)&&e.labelPosition[r.main]>=l-.5&&e.labelPosition[r.main]<=h+.5&&(e.labelPosition[r.cross]+=i)}function nQ(e,t,n,i,r){let a=m(i);for(let n of t)e.has(n.id)&&(n[a.cross]+=r);for(let t of n){let n=e.has(t.source),o=e.has(t.target);if(n&&o){for(let e of t.points)e[a.cross]+=r;t.labelPosition&&(t.labelPosition[a.cross]+=r)}else o?nY(t,i,!0,r):n&&nY(t,i,!1,r)}}function nq(e,t,n,i,r,a){let o=m(i),s=t.filter(t=>e.has(t.id)),l=new Map(s.map(e=>[e.id,{x:o.isHorizontal?e.x:e.x+r,y:o.isHorizontal?e.y+r:e.y,width:e.width,height:e.height}]));for(let e of l.values())if(e.x<0||e.y<0)return!1;for(let n=0;n<s.length;n++){let i=l.get(s[n].id);for(let e=n+1;e<s.length;e++)if(k(i,l.get(s[e].id),8))return!1;for(let n of t)if(!e.has(n.id)&&k(i,n,8))return!1}for(let t of s){let i=l.get(t.id);for(let t of n){if(e.has(t.source)||e.has(t.target))continue;for(let e=1;e<t.points.length;e++){let n=t.points[e-1],r=t.points[e];if(Math.max(n.x,r.x)>i.x+.5&&Math.min(n.x,r.x)<i.x+i.width-.5&&Math.max(n.y,r.y)>i.y+.5&&Math.min(n.y,r.y)<i.y+i.height-.5)return!1}let n=x(t,a);if(n&&k(i,{x:n.x,y:n.y,width:n.w,height:n.h},8))return!1}}return!0}function nT(e,t,n,i={}){let r=new Map(e.map(e=>[e.id,e])),a=m(n.direction);for(let o of t){if(o.source===o.target||o.points.length<2)continue;let t=r.get(o.source),s=r.get(o.target);if(!t||!s)continue;let l=!nd(t,o.points[0]),h=!nd(s,o.points[o.points.length-1]);if(!l&&!h)continue;let u=ej(t)[a.sourceSide],d=ej(s)[a.targetSide],x=nz(u[a.main],d[a.main],eO(i,o,"start"),eO(i,o,"end")),y=nj(u,d,n.direction,x);if(!nV(y,e,new Set([o.source,o.target])))continue;let c=o.routeCertificate;o.points=y,t1(o,c,t,s),o.label&&(o.labelPosition=p(y))}}function nJ(e,t,n,i,r=[]){let a=m(n.direction);i?.(e.length);let o=new Map(e.map(e=>[e.id,e])),s=(t,n)=>{for(let r of e)if(i?.(1),!n.has(r.id)){for(let e=1;e<t.length;e++)if(i?.(1),nx(t[e-1],t[e],r))return!0}return!1},l=e=>{let t=n=>{i?.(1);let r=n.concurrencyRegion?0:n.headerHeight;if(0!==n.width&&(void 0===r||!Number.isFinite(r)||r<0))return!1;if(void 0!==r&&r>0&&n.width>0)for(let t=1;t<e.length;t++){i?.(1);let a=e[t-1],o=e[t];if(Math.max(a.x,o.x)>n.x&&Math.min(a.x,o.x)<n.x+n.width&&Math.max(a.y,o.y)>n.y&&Math.min(a.y,o.y)<n.y+r)return!1}for(let e of n.children)if(!t(e))return!1;return!0};for(let e of r)if(!t(e))return!1;return!0},h=(t,n)=>{for(let r=1;r<=t.length-3;r++){let a=t[r],o=t[r+1],h=t[r-1],u=t[r+2],d=.5>Math.abs(a.x-o.x);if(d===.5>Math.abs(a.y-o.y)||!s([a,o],n))continue;let x=d?"x":"y",y=d?"y":"x";if(Math.abs(h[y]-a[y])>.5||Math.abs(u[y]-o[y])>.5)continue;let c=a[x],f=[];for(let t of e)i?.(1),n.has(t.id)||f.push(t[x]-10,t[x]+("x"===x?t.width:t.height)+10);for(let a of(f.sort((e,t)=>Math.abs(e-c)-Math.abs(t-c)),f)){let o=t.map(e=>({...e}));if(o[r][x]=a,o[r+1][x]=a,!s(o,n)&&nV(o,e,n,i)&&l(o))return eX(o)}}return null},u=(t,r)=>{let o=t[0],h=t[t.length-1],u=Math.min(o[a.main],h[a.main]),d=Math.max(o[a.main],h[a.main]),x=1/0,y=-1/0,c=[];for(let t of e){if(i?.(1),r.has(t.id))continue;let e=t[a.main];if(t[a.main]+("x"===a.main?t.width:t.height)<=u||e>=d)continue;let o=$(t,n.direction),s=o+w(t,n.direction);x=Math.min(x,o),y=Math.max(y,s),c.push(o-10,s+10)}if(!Number.isFinite(x))return null;c.push(x-10,y+10);let f=(e,t)=>"x"===a.main?{x:e,y:t}:{x:t,y:e},g=Math.sign(h[a.main]-o[a.main])||1,p=Math.min(12,Math.abs(h[a.main]-o[a.main])/3),m=o[a.main]+g*p,M=h[a.main]-g*p,b=(o[a.cross]+h[a.cross])/2;for(let t of[...new Set(c)].sort((e,t)=>Math.abs(e-b)-Math.abs(t-b))){let n=eX([o,f(m,o[a.cross]),f(m,t),f(M,t),f(M,h[a.cross]),h]);if(!s(n,r)&&nV(n,e,r,i)&&l(n))return n}return null};i?.(1);let d=new Set,x=(t,n)=>{if(t.length<3)return null;let r=t.at(-1),a=t.at(-2),o=t.at(-3),h=a.y===r.y&&a.x!==r.x?"x":a.x===r.x&&a.y!==r.y?"y":void 0;if(!h)return null;let u="x"===h?"y":"x";if(o[h]!==a[h]||o[u]===a[u]||!s([a,r],n))return null;let x=[];for(let t of e)i?.(1),n.has(t.id)||!nx(a,r,t)||(i?.(2),x.push(t[u]-10,t[u]+("x"===u?t.width:t.height)+10));x.sort((e,t)=>(i?.(1),Math.abs(e-a[u])-Math.abs(t-a[u])));let y=r[h]+Math.sign(a[h]-r[h])*Math.min(10,Math.abs(a[h]-r[h])/2);for(let o of x){i?.(2*t.length+12);let x={...a,[u]:o},c={...r,[h]:y,[u]:o},f={...r,[h]:y},g=eX([...t.slice(0,-2),x,c,f,r]),p=(e,t,n)=>t.x===e.x&&n.x===e.x&&Math.sign(t.y-e.y)===Math.sign(n.y-e.y)||t.y===e.y&&n.y===e.y&&Math.sign(t.x-e.x)===Math.sign(n.x-e.x);if(!(!p(t[0],t[1],g[1])||!p(r,a,g.at(-2)))&&!s(g,d)&&nV(g,e,n,i)&&l(g)&&tr(g,i))return g}return null};for(let e of t){if(i?.(1),e.source===e.target||e.points.length<2)continue;let t=o.get(e.source),n=o.get(e.target);if(!t||!n)continue;let r=new Set([e.source,e.target]);if(!s(e.points,r)||!nd(t,e.points[0])||!nd(n,e.points[e.points.length-1]))continue;let a=h(e.points,r)??u(e.points,r)??x(e.points,r);if(a||(i?.(e.points.length),a=x(e.points.toReversed(),r)?.reverse()??null),!a)continue;let l=e.routeCertificate;e.points=a,t1(e,l,t,n),e.label&&(e.labelPosition=p(a))}}function nZ(e,t,n){let i=new Map(e.map(e=>[e.id,e]));for(let r of t){if(!n.has(r)||r.label||4!==r.points.length)continue;let t=th(r),[a,o,s,l]=r.points;if(!a||!o||!s||!l)continue;let h=i.get(r.target);if(!h||"rectangle"!==h.shape)continue;let u=new Set([r.source,r.target]);if(.01>Math.abs(a.y-o.y)&&.01>Math.abs(o.x-s.x)&&.01>Math.abs(s.y-l.y)&&6>=Math.abs(o.y-s.y)){let n={x:l.x,y:a.y};(.01>Math.abs(l.x-h.x)||.01>Math.abs(l.x-(h.x+h.width)))&&n.y>=h.y-.5&&n.y<=h.y+h.height+.5&&nV([a,n],e,u)&&(r.points=[a,n],r.routeCertificate=void 0,tu(r,t));continue}if(.01>Math.abs(a.x-o.x)&&.01>Math.abs(o.y-s.y)&&.01>Math.abs(s.x-l.x)&&6>=Math.abs(o.x-s.x)){let n={x:a.x,y:l.y};(.01>Math.abs(l.y-h.y)||.01>Math.abs(l.y-(h.y+h.height)))&&n.x>=h.x-.5&&n.x<=h.x+h.width+.5&&nV([a,n],e,u)&&(r.points=[a,n],r.routeCertificate=void 0,tu(r,t))}}}export{V as a,Y as b,td as c,Z as d,U as e,_ as f,D as g,G as h,K as i,ty as j,tm as k,tM as l,ea as m,es as n,el as o,eg as p,eM as q,ek as r,ev as s,eH as t,eA as u,eF as v,eO as w,ez as x,ej as y,eV as z,eQ as A,eq as B,eZ as C,eX as D,tn as E,tQ as F,tT as G,tJ as H,tZ as I,tU as J,ts as K,th as L,tu as M,tE as N,tF as O,tO as P,tz as Q,tK as R,t1 as S,t4 as T,t9 as U,t7 as V,nt as W,nn as X,ni as Y,nr as Z,ns as _,nd as $,nx as aa,nf as ba,ng as ca,np as da,nv as ea,nP as fa,nN as ga,nW as ha,nL as ia,nE as ja,nI as ka,nR as la,nB as ma,nH as na,nA as oa,nF as pa,nO as qa,nz as ra,nj as sa,nV as ta,nQ as ua,nq as va,nT as wa,nJ as xa,nZ as ya};
@@ -0,0 +1 @@
1
+ import{Q as t}from"./chunk-G4JBA7HU.js";import{g as e}from"./chunk-3JTYTXA6.js";import{B as a,Ob as r,Qb as o,Yb as n,ab as i}from"./chunk-EIYLJ4FI.js";async function s(){l=(await import("./elk.bundled-RYWHIS5N.js")).default}var l,u,c,h,d,f=null,m=null;function p(a){return r("elk",()=>(function(a){if(t(a),!g)return i("elk-layout","bypass","disabled"),w(a);let r=JSON.stringify(a,(t,e)=>void 0===e?"\0undefined":"number"!=typeof e||Number.isFinite(e)?"string"==typeof e&&e.startsWith("\0")?`\0${e}`:e:`\0${e}`),o=b.get(r);if(o)return i("elk-layout","hit"),structuredClone(o);i("elk-layout","miss");let n=w(a);if(r.length<=1048576){let t=Math.max(8*r.length,2*r.length+e(n,8388608));t<=8388608?b.set(r,structuredClone(n),t):i("elk-layout","store-skipped","weight-limit")}else i("elk-layout","store-skipped","key-limit");return n})(a))}var y=globalThis,g=(y.process?.env?.AGENTIC_MERMAID_ELK_CACHE??y.AGENTIC_MERMAID_ELK_CACHE)!=="0",b=new a(64,8388608);function w(t){!function(){if(f)return;let t=function(){if(!l)throw new o("ELK",s);return l}(),e=[],a=globalThis.setTimeout;globalThis.setTimeout=(t,r)=>0===r?(e.push(t),0):a(t,r);let r=globalThis,n="u">typeof r.document;n||(r.document={}),f=new t,n||delete r.document,globalThis.setTimeout=a,e.forEach(t=>t()),m=f.worker.worker}();let e,a,r=m.onmessage;if(m.onmessage=t=>{t.data.error?a=t.data.error:e=t.data.data},m.dispatcher.saveDispatch({data:{id:0,cmd:"layout",graph:t}}),m.onmessage=r,a)throw a;if(!e)throw Error("ELK layout did not return synchronously");return e}function k(t){let e;for(let r of["x","y"]){let o=t[0]?.[r];for(let n=1;n<t.length;n++){var a;let i=t[n][r];i!==o&&(void 0!==o&&Math.abs(i-(a=o))<=Math.min(1e-6,8*Number.EPSILON*Math.max(1,Math.abs(i),Math.abs(a)))?(e??=t.map(t=>({...t})))[n][r]=o:o=i)}}return e??t}async function E(){await (c??=import("./forest-implementation-RWFF7XDV.js").then(t=>{u=t}).catch(t=>{throw c=void 0,t}))}function M(){if(!u)throw new o("Forest layout",E);return u}async function v(){await (d??=Promise.all([import("./agentic-producer-core-ECZ3CMZM.js"),E()]).then(([t])=>{let e=M();h={candidate:t.layoutNativeGraphCandidate,placement:t.layoutNativeGraphPlacement,architectureSlots:t.improveArchitectureSiblingSlots,graph:t.createMeasuredLayoutCache(a=>t.layoutLayeredGraph(a,e.layoutMeasuredForest,t=>{throw new n(t)}))}}).catch(t=>{throw d=void 0,t}))}function C(){if(!h)throw new o("Agentic layout",v);return h}function T(t){return C().graph(t)}var A=(t,e,a,r)=>C().candidate(t,e,a,T,r),N=(t,e,a,r)=>C().placement(t,e,a,T,r),I=(...t)=>C().architectureSlots(...t);export{p as a,k as b,M as c,T as d,A as e,N as f,I as g};
@@ -1 +1 @@
1
- import{a as t,b as e,c as i,d as n}from"./chunk-5FQ534HP.js";import{K as r,L as x}from"./chunk-P7DO3MRP.js";function a(t,e,i){return t.x===e.x?t.x>i.x&&t.x<i.x+i.width&&Math.max(t.y,e.y)>i.y&&Math.min(t.y,e.y)<i.y+i.height:t.y>i.y&&t.y<i.y+i.height&&Math.max(t.x,e.x)>i.x&&Math.min(t.x,e.x)<i.x+i.width}function f(t,e,i){return(e.x===i.x?1e-7>Math.abs(t.x-e.x):1e-7>Math.abs(t.y-e.y))&&t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x)&&t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y)}function u(t,e){return t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height}function y(t,e,i,n,r){if(t){if(r?.(3)===!1)return;t.candidateSegment=e,t.peerIndex=i,t.peerSegment=n}return!1}function o(t,e="complete"){return"complete"===e&&void 0!==t.maximumEdgeStrokeWidth&&0===t.maximumEdgeBendRadius?1:3}function l(t,e,i,n,r){let x=(Math.abs(t.x)+Math.abs(t.y)+Math.abs(e.x)+Math.abs(e.y)+Math.abs(i.x)+Math.abs(i.y)+Math.abs(n.x)+Math.abs(n.y)+r)*1e-10+1e-9,a=r+x,f=Math.min(t.x,e.x)-Math.max(i.x,n.x),u=Math.min(i.x,n.x)-Math.max(t.x,e.x),y=Math.min(t.y,e.y)-Math.max(i.y,n.y),o=Math.min(i.y,n.y)-Math.max(t.y,e.y);return Number.isFinite(a)&&Number.isFinite(f)&&Number.isFinite(u)&&Number.isFinite(y)&&Number.isFinite(o)&&(f>a||u>a||y>a||o>a)}function h(t,e,i,n){if(i?.(1)===!1)return;let r=e.get(t);if(r)return r;if(i?.(128)===!1||n?.(14)===!1)return;let x=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(t),a={n:BigInt(x[1]+x[2]+(x[3]??"")),e:Number(x[4]??0)-(x[3]?.length??0)};if(n?.(2)!==!1&&i?.(1)!==!1)return e.set(t,a),a}function s(t,e,i,n,r,x=!1,a){let f,u,y;if(n?.(8)===!1)return;let o=Number(t),l=Number(e),m=Number(i),M=Math.abs(o-l)*(x?2:1)-m;if(Math.abs(M)>8*Number.EPSILON*Math.max(1,Math.abs(o),Math.abs(l),m))return M<0?-1:1;if(a){let x=h(t,a,n,r);if(!x)return;f=x;let o=h(e,a,n,r);if(!o)return;u=o;let l=h(i,a,n,r);if(!l)return;y=l}else{if(n?.(384)===!1||r?.(42)===!1)return;let x=t=>{let e=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(t);return{n:BigInt(e[1]+e[2]+(e[3]??"")),e:Number(e[4]??0)-(e[3]?.length??0)}};f=x(t),u=x(e),y=x(i)}let g=Math.min(f.e,u.e,y.e);if(n?.(32+f.e-g+u.e-g+y.e-g)===!1)return;let d=f.n*10n**BigInt(f.e-g)-u.n*10n**BigInt(u.e-g),c=(d<0n?-d:d)*(x?2n:1n)-y.n*10n**BigInt(y.e-g);return c<0n?-1:+(c>0n)}function m(t,e,i,n,r){let x=s(t,e,i,n,r);return void 0===x?void 0:x<0}function M(t,e){return t.x===e.x&&t.y===e.y}function g(t,e,i,n,r,x,a,f){let u,y;if(x?.(3)===!1)return;let o=n-e;if(!o)return t<i;if(t===i)return o>0;if(t>i?o<0:o>0)return t<i;if(x?.(6)===!1)return;let l=Number(r),h=2*(t-i)-o*l,m=32*Number.EPSILON*Math.max(1,Math.abs(t)+Math.abs(i)+Math.abs(o*l));if(Number.isFinite(h)&&Math.abs(h)>m)return h<0;if(f){let e=v(t,f,x,a);if(void 0===e)return;u=e;let n=v(i,f,x,a);if(void 0===n)return;y=n}else{if(a?.(10)===!1||x?.(64)===!1)return;u=String(t),y=String(i)}let M=s(u,y,r,x,a,1===Math.abs(o),f?.parts);return void 0===M?void 0:o>0?M<0:M>0}function d(t,e,i,n,r,x){if(x){if(void 0!==x.width){if(n?.(1)===!1)return;let i=x.width,r=i/2,a=(Math.abs(t.x0)+Math.abs(t.x1)+Math.abs(t.y0)+Math.abs(t.y1)+Math.abs(e.x0)+Math.abs(e.x1)+Math.abs(e.y0)+Math.abs(e.y1)+i)*1e-10+1e-9;if(t.x0-e.x1+(t.ox0-e.ox1)*r>a||e.x0-t.x1+(e.ox0-t.ox1)*r>a||t.y0-e.y1+(t.oy0-e.oy1)*r>a||e.y0-t.y1+(e.oy0-t.oy1)*r>a)return!1}if(n?.(4)===!1)return;let a=t.ox0===e.ox1,f=e.ox0===t.ox1,u=t.oy0===e.oy1,y=e.oy0===t.oy1;if(a){if(n?.(1)===!1)return;if(!(t.x0<e.x1))return!1}if(f){if(n?.(1)===!1)return;if(!(e.x0<t.x1))return!1}if(u){if(n?.(1)===!1)return;if(!(t.y0<e.y1))return!1}if(y){if(n?.(1)===!1)return;if(!(e.y0<t.y1))return!1}if(!a){let a=g(t.x0,t.ox0,e.x1,e.ox1,i,n,r,x);if(!0!==a)return a}if(!f){let a=g(e.x0,e.ox0,t.x1,t.ox1,i,n,r,x);if(!0!==a)return a}if(!u){let a=g(t.y0,t.oy0,e.y1,e.oy1,i,n,r,x);if(!0!==a)return a}return!!y||g(e.y0,e.oy0,t.y1,t.oy1,i,n,r,x)}let a=g(t.x0,t.ox0,e.x1,e.ox1,i,n,r,x);if(!0!==a)return a;let f=g(e.x0,e.ox0,t.x1,t.ox1,i,n,r,x);if(!0!==f)return f;let u=g(t.y0,t.oy0,e.y1,e.oy1,i,n,r,x);return!0!==u?u:g(e.y0,e.oy0,t.y1,t.oy1,i,n,r,x)}function c(t,e,i){if(e?.(2)===!1)return;if(Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y))return t;if(e?.(66)===!1||i?.(13)===!1||!Number.isFinite(t.x)||!Number.isFinite(t.y))return;let n=String(t.x),a=String(t.y);if(n.length>=14&&r.test(n)){if(i?.(5)===!1||e?.(128)===!1)return;n=x(t.x)}if(a.length>=14&&r.test(a)){if(i?.(5)===!1||e?.(128)===!1)return;a=x(t.y)}return{x:Number(n),y:Number(a)}}function b(t,e,i){if(i?.(9)!==!1&&(t.x!==e.x||t.y!==e.y)){if(t.x===e.x)return{x0:t.x,x1:t.x,y0:Math.min(t.y,e.y),y1:Math.max(t.y,e.y),ox0:-1,ox1:1,oy0:0,oy1:0};if(t.y===e.y)return{x0:Math.min(t.x,e.x),x1:Math.max(t.x,e.x),y0:t.y,y1:t.y,ox0:0,ox1:0,oy0:-1,oy1:1}}}function p(t,e,i,n,r){if(n?.(8)===!1)return;let x=Math.sign(e.x-t.x),a=Math.sign(e.y-t.y),f=Math.sign(i.x-e.x),u=Math.sign(i.y-e.y),y=x*u-a*f;if(!y)return x*f+a*u<0&&void 0;if(t.x!==e.x&&t.y!==e.y||e.x!==i.x&&e.y!==i.y||r?.(9)===!1)return;let o=y>0?-1:1,l=(-a-u)*o,h=(x+f)*o;return{x0:e.x,x1:e.x,y0:e.y,y1:e.y,ox0:Math.min(0,l),ox1:Math.max(0,l),oy0:Math.min(0,h),oy1:Math.max(0,h)}}function v(t,e,i,n){if(i?.(1)===!1)return;let r=e.texts.get(t);if(void 0!==r)return r;if(n?.(5)===!1||i?.(32)===!1)return;let x=String(t);if(n?.(2)!==!1&&i?.(1)!==!1)return e.texts.set(t,x),x}function N(t,e,i,n,r,x){if(r?.(3)!==!1)return n.rows[e]?.[i]}function w(t,e,i,n,r,x,a,f){if(a?.(2)===!1)return;let u=x.strips[e];if(!u){if(f?.(t.length+1)===!1)return;u=x.strips[e]=Array(t.length)}let y=u[i];if(y)return y;let o=b(n,r,f);if(o&&a?.(1)!==!1)return u[i]=o,o}function S(t,e,i,n,r,x,a,f){if(a?.(2)===!1)return;let u=x.joins[e];if(!u){if(f?.(t.length+1)===!1)return;u=x.joins[e]=Array(t.length)}let y=u[i];if(void 0!==y)return y;let o=N(t,e,i+1,x,a,f);if(!o)return;let l=p(n,r,o,a,f);if(void 0!==l&&a?.(1)!==!1)return u[i]=l,l}function I(t,e,i,n,r,x,a,f=-1){let u=e-1,y=e,o,l;for(;u>=0;){if(r?.(1)===!1||!(o=n?a?N(t,f,u,a,r,x):c(t[u],r,x):t[u]))return;if(o.x!==i.x||o.y!==i.y)break;u--}for(;y<t.length;){if(r?.(1)===!1||!(l=n?a?N(t,f,y,a,r,x):c(t[y],r,x):t[y]))return;if(l.x!==i.x||l.y!==i.y)break;y++}return!(u<0)&&!(y>=t.length)&&!!o&&!!l&&(o.x===i.x&&l.x===i.x&&Math.min(o.y,l.y)<i.y&&i.y<Math.max(o.y,l.y)||o.y===i.y&&l.y===i.y&&Math.min(o.x,l.x)<i.x&&i.x<Math.max(o.x,l.x))}function F(t){for(let e=0;e<t.length;e++){let i=t[e];if(!Number.isFinite(i.x)||!Number.isFinite(i.y)||e&&i.x!==t[e-1].x&&i.y!==t[e-1].y)return!1}return!0}function E(t,e,i,n,r,x,a,f=3,u=!1){return B(t,e,i,n,r,x,!0,a,f,u)}function k(t,e,i,n,r=!1,a){if(!a&&void 0!==e.maximumEdgeStrokeWidth&&0===e.maximumEdgeBendRadius){let e=function(t,e,i){let n=!1;for(let i of t)for(let t=1;t<i.points.length;t++){if(e?.(1)===!1)return;let r=i.points[t-1],x=i.points[t];r.x!==x.x&&r.y!==x.y&&(n=!0)}if(!n)return!1;if(i?.(t.length+18)===!1)return;let r=Array(t.length),x=[],a=[],f=[],u=[];for(let n=0;n<t.length;n++){let y=t[n].points;if(e?.(1)===!1||i?.(5*y.length+5)===!1)return;let o=Array(y.length),l=Array(y.length);for(let t=0;t<y.length;t++){if(e?.(3)===!1)return;let n=y[t],r=c(n,e,i);if(!r)return;if(o[t]={x:n.x,y:n.y},r===n){if(i?.(3)===!1)return;l[t]={x:r.x,y:r.y}}else l[t]=r}r[n]={raw:o,points:l};for(let t=0;t+1<l.length;t++){if(e?.(4)===!1)return;let r=l[t],y=l[t+1];if(r.x===y.x==(r.y===y.y))return!1;if(i?.(15)===!1)return;let o={owner:n,segment:t},h=r.x===y.x;(h?a:x).push({key:h?r.x:r.y,piece:o}),(h?u:f).push({key:h?r.y:r.x,piece:o},{key:h?y.y:y.x,piece:o})}}let y={},o=(t,i)=>{if(e?.(1)===!1)throw y;return t.key-i.key||t.piece.owner-i.piece.owner||t.piece.segment-i.piece.segment};try{for(let t of[x,a,f,u])t.sort(o)}catch(t){if(t===y)return;throw t}return{routes:r,horizontal:x,vertical:a,horizontalEnds:f,verticalEnds:u}}(t,i,n);if(void 0===e)return;e&&(a=e)}if(!a){if(r)for(let e of t){let t;for(let r of e.points){let e=c(r,i,n);if(!e||i?.(2)===!1)return;if(t&&(e.x===t.x&&e.y===t.y||e.x!==t.x&&e.y!==t.y))return!1;t=e}}return n?.(1)===!1?void 0:(r,x)=>{if(i?.(t.length)===!1)return!1;let a=0;for(let e=0;e<t.length;e++)e!==r&&"invisible"!==t[e].style&&(a+=Math.max(0,t[e].points.length-1));let f=t[r].points,u=o(e);return i?.(u*Math.max(0,f.length-1)*a+f.length+a+t.length)!==!1&&void 0!==E(f,r,t,e,i,n,x,u,!0)}}if(i?.(t.length+1)===!1)return;if(a.routes.length!==t.length)return!1;let f=0;for(let e of t)f+=Math.max(0,e.points.length-1);if(n?.(4*t.length+28+2*f+4)===!1)return;let u=Array(t.length),y=Array(t.length),l=[],h=[],s=0,m=0;for(let e=0;e<t.length;e++){let n;if(i?.(3)===!1)return;let r=t[e].points,x=a.routes[e];if(y[e]=m,m+=Math.max(0,r.length-1),r.length!==x.raw.length||r.length!==x.points.length)return!1;u[e]=x.points;for(let t=0;t<r.length;t++){if(i?.(7)===!1)return;let e=r[t],a=x.raw[t],f=x.points[t];if(e.x!==a.x||e.y!==a.y||!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(f.x)||!Number.isFinite(f.y)||n&&(f.x===n.x&&f.y===n.y||f.x!==n.x&&f.y!==n.y))return!1;n=f,s+=Math.abs(e.x)+Math.abs(e.y)}}let M=e.maximumEdgeStrokeWidth,g,d;if(Number.isSafeInteger(M)&&M>0){if(n?.(4)===!1||i?.(M<10?2:17)===!1)return;g=M,d=String(M)}else{if(n?.(5)===!1||i?.(128)===!1)return;g=Number(d=x(M))}if(!Number.isFinite(g)||g<=0||0!==e.maximumEdgeBendRadius)return!1;let b=Math.max(g,.01)+(s+g)*1e-10+1e-9,p=.01+(s+g)*1e-10+1e-9,v=s>Math.sqrt(Number.MAX_VALUE)/4,N=new Uint8Array(f);for(let e=0;e<2;e++)for(let r of e?a.horizontal:a.vertical){if(i?.(3)===!1)return;let x=function(t,e,i,n,r,x){if(x?.(4)===!1)return;let a=t[i],f=t[i+1],u=e[i],y=e[i+1];if(r||a.x!==f.x&&a.y!==f.y)return!0;for(let i=0;i<2;i++){if(x?.(2)===!1)return;let r=i?t.length-1:0,o=t[r],l=e[r];if((o.x!==a.x||o.y!==a.y||l.x!==u.x||l.y!==u.y)&&(o.x!==f.x||o.y!==f.y||l.x!==y.x||l.y!==y.y))for(let t=0;t<2;t++){if(x?.(1)===!1)return;let e=t?u:a,i=t?y:f,r=t?l:o;if(r.x>=Math.min(e.x,i.x)-n&&r.x<=Math.max(e.x,i.x)+n&&r.y>=Math.min(e.y,i.y)-n&&r.y<=Math.max(e.y,i.y)+n)return!0}}return!1}(t[r.piece.owner].points,a.routes[r.piece.owner].points,r.piece.segment,p,v,i);if(void 0===x)return;if(x){if(n?.(1)===!1||i?.(1)===!1)return;N[y[r.piece.owner]+r.piece.segment]=1,(e?l:h).push(r)}}let w={rows:u,rangeStarts:new Map,parts:new Map,texts:new Map,strips:Array(t.length),joins:Array(t.length),numericSeed:a,width:g,widthText:d,margin:b,offsets:y,driftHorizontal:l,driftVertical:h,seen:new Uint32Array(f),fullCandidates:N,epoch:0,contactOnly:!0};return(r,x)=>void 0!==B(t[r].points,r,t,e,i,n,!0,x,1,!1,w)}function A(t,e,i,n,r,x){return B(t,e,i,n,r,x,!1)}function B(r,a,f,u,o,h,s,v,E=3,k=!1,A){let O=0,z,R;if(A){if(o?.(2)===!1)return;z=A.width,R=A.widthText}else if(void 0!==u.maximumEdgeStrokeWidth){if(h?.(4)===!1)return;let t=u.maximumEdgeStrokeWidth;if(Number.isSafeInteger(t)&&t>0){if(o?.(t<10?2:17)===!1)return;z=t,R=String(t)}else{if(o?.(128)===!1)return;z=Number(R=x(t))}if(!Number.isFinite(z)||z<=0)throw TypeError("Measured stroke width must be finite and positive")}let j,W=!1;if(A){if(o?.(2)===!1)return;W=A.contactOnly&&void 0!==z&&0===u.maximumEdgeBendRadius}if(s&&void 0!==z&&0===u.maximumEdgeBendRadius){if(h?.(1)===!1)return;j=[]}let H=!1;if(A){if(void 0===(H=function(t,e,i,n,r,x){let a,f=n.numericSeed,u=n.margin;for(let y=1;y<t.length;y++){if(r?.(4)===!1)return;let o=t[y-1],h=t[y];if(n.contactOnly&&r?.(1)===!1)return;let s=o.x===h.x,m=n.contactOnly&&!n.fullCandidates[n.offsets[e]+y-1];if(n.contactOnly){if(r?.(1)===!1)return;if(n.epoch++,0x100000000===n.epoch){if(r?.(n.seen.length)===!1)return;n.seen.fill(0),n.epoch=1}}for(let t=0;t<(m?5:2);t++){let M,g,d;if(r?.(4)===!1)return;if(m)if(0===t)M=s?f.vertical:f.horizontal,g=(s?o.x:o.y)-u,d=(s?o.x:o.y)+u;else if(1===t||2===t){M=s?f.horizontal:f.vertical;let e=1===t?o:h;g=(s?e.y:e.x)-u,d=(s?e.y:e.x)+u}else 3===t?(M=s?f.horizontalEnds:f.verticalEnds,g=(s?o.x:o.y)-u,d=(s?o.x:o.y)+u):(M=s?n.driftHorizontal:n.driftVertical,g=Math.min(s?o.y:o.x,s?h.y:h.x)-u,d=Math.max(s?o.y:o.x,s?h.y:h.x)+u);else M=t?f.horizontal:f.vertical,g=Math.min(t?o.y:o.x,t?h.y:h.x)-u,d=Math.max(t?o.y:o.x,t?h.y:h.x)+u;let c=function(t,e,i,n,r){if(n?.(2)===!1)return;let x=i.rangeStarts.get(t),a=x?.get(e);if(void 0!==a)return a;let f=0,u=t.length;for(;f<u;){if(n?.(1)===!1)return;let i=f+u>>>1;t[i].key<e?f=i+1:u=i}if(!x){if(r?.(3)===!1||n?.(1)===!1)return;x=new Map,i.rangeStarts.set(t,x)}if(r?.(2)!==!1&&n?.(1)!==!1)return x.set(e,f),f}(M,g,n,r,x);if(void 0===c)return;for(let t=c;t<M.length;t++){if(r?.(3)===!1)return;let f=M[t];if(f.key>d)break;let u=f.piece;if(u.owner===e||"invisible"===i[u.owner].style)continue;if(n.contactOnly){if(r?.(2)===!1)return;let t=n.offsets[u.owner]+u.segment;if(n.seen[t]===n.epoch)continue;n.seen[t]=n.epoch}if(r?.(1)===!1)return;let s=i[u.owner].points;if(l(o,h,s[u.segment],s[u.segment+1],n.width))continue;if(!a){if(x?.(i.length+1)===!1)return;a=Array(i.length)}let m=a[u.owner];if(!m){if(x?.(1)===!1)return;m=a[u.owner]=[]}if(x?.(3)===!1||r?.(1)===!1)return;m.push(y,u.segment+1,0)}}}return a??null}(r,a,f,A,o,h)))return;if(null===H)return 0}let P,$,L=u.edges[a],U=[{points:r},{points:[]}];if(!(A&&o?.(f.length)===!1)){for(let y=0;y<f.length;y++){let M,g=f[y];if(y===a||"invisible"===g.style)continue;let d=!k;if(H){if(o?.(1)===!1)return;if(!H[y]?.length)continue}if(j){if(h?.(1)===!1||o?.(1)===!1)return;d&&j.push(y)}let b=u.edges[y],p,v;if(A){if(o?.(1)===!1)return;U[1].points=g.points}let N=0,w=H?H[y]:void 0;for(let e=1;H?N<w.length:e<r.length;e++)for(let n=1;H?N<w.length:n<g.points.length;n++){let a=N;if(H){if(o?.(2)===!1)return;e=w[N],n=w[N+1],N+=3}if(A&&!H&&o?.(E)===!1)return;let f=r[e-1],y=r[e],M=g.points[n-1],S=g.points[n];if(!H&&s&&void 0!==z&&0===u.maximumEdgeBendRadius){let t=function(t,e,i,n,r){if((t.x===e.x||t.y===e.y)&&(i.x===n.x||i.y===n.y))return l(t,e,i,n,r)}(f,y,M,S,z);if(void 0===t){let t=c(f,o,h);if(!t)return;let e=c(y,o,h);if(!e)return;let i=c(M,o,h);if(!i)return;let n=c(S,o,h);if(!n||o?.(4)===!1||t.x!==e.x&&t.y!==e.y||i.x!==n.x&&i.y!==n.y)return}if(!0===t)continue;d=!0}if((H||1===E)&&o?.(W?1:2)===!1)return;if(!W){if(void 0===z){if(f.x===y.x&&M.x===S.x&&.5>=Math.abs(f.x-M.x)&&Math.min(Math.max(f.y,y.y),Math.max(M.y,S.y))-Math.max(Math.min(f.y,y.y),Math.min(M.y,S.y))>.01||f.y===y.y&&M.y===S.y&&.5>=Math.abs(f.y-M.y)&&Math.min(Math.max(f.x,y.x),Math.max(M.x,S.x))-Math.max(Math.min(f.x,y.x),Math.min(M.x,S.x))>.01)return}else if(!1!==function(t,e,i,n,r,a,f,u){let y=t.x===e.x;if(i.x===n.x!==y||!y&&(t.y!==e.y||i.y!==n.y))return!1;if(f?.(2)===!1)return;let o=y?t.x:t.y,l=y?i.x:i.y,h=Math.abs(o-l),s=(Math.abs(o)+Math.abs(l)+r)*1e-10+1e-9;if(h>r+s)return!1;let M=y?t.y:t.x,g=y?e.y:e.x,d=y?i.y:i.x,c=y?n.y:n.x,b=Math.min(Math.max(M,g),Math.max(d,c))-Math.max(Math.min(M,g),Math.min(d,c)),p=(Math.abs(M)+Math.abs(g)+Math.abs(d)+Math.abs(c))*1e-10+1e-9;if(b<-p)return!1;if(0===b){if(f?.(2)===!1)return;if(Math.abs(M-g)>2*p&&Math.abs(d-c)>2*p)return!1}if(f?.(2)===!1)return;if(h<r-s&&b>p)return!0;if(f?.(6)===!1||!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(M)||!Number.isFinite(g)||!Number.isFinite(d)||!Number.isFinite(c)||u?.(10)===!1||f?.(256)===!1)return;let v=m(x(o),x(l),a,f,u);if(!0!==v)return v;if(u?.(20)===!1||f?.(512)===!1)return;let N=Number(x(M)),w=Number(x(g)),S=Number(x(d)),I=Number(x(c));return Math.max(Math.min(N,w),Math.min(S,I))<Math.min(Math.max(N,w),Math.max(S,I))}(f,y,M,S,z,R,o,h))return}if(A){if(o?.(1)===!1)return;if((f.x!==y.x||f.y!==y.y)&&(M.x!==S.x||M.y!==S.y)&&Math.min(f.x,y.x)<=Math.max(M.x,S.x)&&Math.min(M.x,S.x)<=Math.max(f.x,y.x)&&Math.min(f.y,y.y)<=Math.max(M.y,S.y)&&Math.min(M.y,S.y)<=Math.max(f.y,y.y)){if(!P){if(h?.(13)===!1)return;P=[{a:f,b:y,edgeIndex:0,pointIndex:e-1},{a:M,b:S,edgeIndex:1,pointIndex:n-1}]}if(o?.(7+r.length+g.points.length)===!1||h?.(4)===!1)return;let x=P[0],u=P[1];x.a=f,x.b=y,x.pointIndex=e-1,u.a=M,u.b=S,u.pointIndex=n-1;let l=i(x,u,U);if(l){if(!v){if(h?.(1)===!1)return;v=[]}if(o?.(v.length)===!1||h?.(2)===!1)return;if(t(v,l),W&&(f.x!==y.x&&f.y!==y.y||M.x!==S.x&&M.y!==S.y)){if(o?.(1)===!1)return;w[a+2]=1}}}}let I=f.x===y.x,F=M.x===S.x,k=0,B=0,O=!1;if(I!==F)k=I?f.x:M.x,B=I?M.y:f.y,O=k>=Math.min(f.x,y.x)&&k<=Math.max(f.x,y.x)&&B>=Math.min(f.y,y.y)&&B<=Math.max(f.y,y.y)&&k>=Math.min(M.x,S.x)&&k<=Math.max(M.x,S.x)&&B>=Math.min(M.y,S.y)&&B<=Math.max(M.y,S.y);else if(I?f.x===M.x:f.y===M.y){let t=Math.max(I?Math.min(f.y,y.y):Math.min(f.x,y.x),I?Math.min(M.y,S.y):Math.min(M.x,S.x));Math.min(I?Math.max(f.y,y.y):Math.max(f.x,y.x),I?Math.max(M.y,S.y):Math.max(M.x,S.x))>=t&&(k=I?f.x:t,B=I?t:f.y,O=!0)}if(!O)continue;let j=r[0],$=r.at(-1),T=g.points[0],V=g.points.at(-1),q=j.x===k&&j.y===B,C=$.x===k&&$.y===B,K=T.x===k&&T.y===B,D=V.x===k&&V.y===B;L.source===b.source&&q&&K||L.source===b.target&&q&&D||L.target===b.source&&C&&K||L.target===b.target&&C&&D||(p??=new Set).add(`${k},${B}`)}if(j&&k&&d&&j.push(y),A)if(v){let t=v.length;if(o?.(2*t*t+t)===!1||h?.(2*t+1)===!1)return;M=e(v)}else M=0;else{if(!p&&($??=F(r))&&F(g.points))continue;U[1].points=g.points,M=n(U)}if(M<(p?.size??0))return;O+=M}if(!(s&&void 0!==z&&0===u.maximumEdgeBendRadius&&j.length&&!0!==function(t,e,n,r,x,a,f,u,o,l,h,s){let m=r.edges[e],v,F,E;if(h){let t=function(t,e,i){if(i?.(2)!==!1)return e.rows[t]}(e,h,u);if(!t)return;E=t}else{if(o?.(t.length+2)===!1)return;E=Array(t.length)}for(let k=0;k<f.length;k++){if(u?.(1)===!1)return;let A=f[k],B=n[A],O=r.edges[A];if(h&&u?.(1)===!1)return;let z=h?.rows[A],R=s?.[A],j=0;for(let n=1;s?R&&j<R.length:n<t.length;n++)for(let r=1;s?j<R.length:r<B.points.length;r++){let f=j;if(s){if(u?.(2)===!1)return;n=R[j],r=R[j+1],j+=3}if(u?.(1)===!1)return;let k=t[n-1],W=t[n],H=B.points[r-1],P=B.points[r],$=(Math.abs(k.x)+Math.abs(k.y)+Math.abs(W.x)+Math.abs(W.y)+Math.abs(H.x)+Math.abs(H.y)+Math.abs(P.x)+Math.abs(P.y)+x)*1e-10+1e-9,L=x+$;if(Math.min(k.x,W.x)-Math.max(H.x,P.x)>L||Math.min(H.x,P.x)-Math.max(k.x,W.x)>L||Math.min(k.y,W.y)-Math.max(H.y,P.y)>L||Math.min(H.y,P.y)-Math.max(k.y,W.y)>L)continue;let U=k.x===W.x;if(U!==(H.x===P.x)&&(k.x===W.x||k.y===W.y)&&(H.x===P.x||H.y===P.y)){let t=U?k.x:H.x,e=U?H.y:k.y,i=U?H:k,n=U?P:W,r=U?k:H,x=U?W:P;if(t>Math.min(i.x,n.x)+L&&t<Math.max(i.x,n.x)-L&&e>Math.min(r.y,x.y)+L&&e<Math.max(r.y,x.y)-L)continue}if(!z){if(h||o?.(B.points.length+1)===!1)return;z=Array(B.points.length)}if(u?.(4)===!1)return;let T=E[n-1]??(E[n-1]=h?N(t,e,n-1,h,u,o):c(k,u,o));if(!T)return;let V=E[n]??(E[n]=h?N(t,e,n,h,u,o):c(W,u,o));if(!V)return;let q=z[r-1]??(z[r-1]=h?N(B.points,A,r-1,h,u,o):c(H,u,o));if(!q)return;let C=z[r]??(z[r]=h?N(B.points,A,r,h,u,o):c(P,u,o));if(!C)return;let K=h?w(t,e,n,T,V,h,u,o):b(T,V,o);if(!K)return;let D=h?w(B.points,A,r,q,C,h,u,o):b(q,C,o);if(!D)return;let J=T.x===V.x,Q=q.x===C.x;if(h?.contactOnly&&J===Q){if(u?.(2)===!1)return;if(Math.max(J?Math.min(T.y,V.y):Math.min(T.x,V.x),J?Math.min(q.y,C.y):Math.min(q.x,C.x))<Math.min(J?Math.max(T.y,V.y):Math.max(T.x,V.x),J?Math.max(q.y,C.y):Math.max(q.x,C.x))){let t=J?T.x:T.y,e=J?q.x:q.y,i=g(Math.max(t,e),-2,Math.min(t,e),0,a,u,o,h);if(!1!==i)return void 0===i?void 0:y(l,n,A,r,u)}}else if(J===Q&&(k.x!==W.x&&k.y!==W.y||H.x!==P.x&&H.y!==P.y)){let t=d(K,D,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}if(J!==Q){let x=d(K,D,a,u,o,h);if(void 0===x)return;if(x){if(o?.(6)===!1)return;let x={x:J?k.x:H.x,y:J?H.y:k.y},a={x:J?T.x:q.x,y:J?q.y:T.y},s=!1;if(h?.contactOnly&&h.numericSeed&&(k.x!==W.x&&k.y!==W.y||H.x!==P.x&&H.y!==P.y)){if(u?.(1)===!1)return;if(R?.[f+2]===1){if(!v){if(o?.(20)===!1)return;v=[{points:E},{points:z}],F=[{a:T,b:V,edgeIndex:0,pointIndex:n-1},{a:q,b:C,edgeIndex:1,pointIndex:r-1}]}if(u?.(7+E.length+z.length)===!1||o?.(4)===!1)return;v[1].points=z;let t=F[0],e=F[1];t.a=T,t.b=V,t.pointIndex=n-1,e.a=q,e.b=C,e.pointIndex=r-1,s=!!i(t,e,v)}}else{let i=I(t,n,x,!1,u,o);if(void 0===i)return;let f=I(B.points,r,x,!1,u,o);if(void 0===f)return;if(i&&f){let i=I(t,n,a,!0,u,o,h,e);if(void 0===i)return;let x=I(B.points,r,a,!0,u,o,h,A);if(void 0===x)return;s=i&&x}}let g=t[0],d=t.at(-1),c=B.points[0],b=B.points.at(-1);if(u?.(4)===!1)return;let p=1===n&&1===r&&m.source===O.source&&M(x,g)&&M(x,c)||1===n&&r===B.points.length-1&&m.source===O.target&&M(x,g)&&M(x,b)||n===t.length-1&&1===r&&m.target===O.source&&M(x,d)&&M(x,c)||n===t.length-1&&r===B.points.length-1&&m.target===O.target&&M(x,d)&&M(x,b);if(!s&&!p)return y(l,n,A,r,u)}}let X=!1,_=!1;if(n+1<t.length)if(h){let i=S(t,e,n,T,V,h,u,o);if(void 0===i)return;X=i}else{if(u?.(1)===!1)return;let e=E[n+1]??(E[n+1]=c(t[n+1],u,o));if(!e)return;let i=p(T,V,e,u,o);if(void 0===i)return;X=i}if(r+1<B.points.length)if(h){let t=S(B.points,A,r,q,C,h,u,o);if(void 0===t)return;_=t}else{if(u?.(1)===!1)return;let t=z[r+1]??(z[r+1]=c(B.points[r+1],u,o));if(!t)return;let e=p(q,C,t,u,o);if(void 0===e)return;_=e}if(X){let t=d(X,D,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}if(_){let t=d(K,_,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}if(X&&_){let t=d(X,_,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}}}return!0}(r,a,f,u,z,R,j,o,h,v,A,H||void 0)))return O}}function O(t){let e=[];for(let i of t)if(e.at(-1)?.x!==i.x||e.at(-1)?.y!==i.y)for(e.push({...i});e.length>2;){let t=e.at(-3),i=e.at(-2),n=e.at(-1);if(!(t.x===i.x&&i.x===n.x&&i.y>=Math.min(t.y,n.y)&&i.y<=Math.max(t.y,n.y)||t.y===i.y&&i.y===n.y&&i.x>=Math.min(t.x,n.x)&&i.x<=Math.max(t.x,n.x)))break;e.splice(e.length-2,1)}return e}export{a as a,f as b,u as c,o as d,m as e,c as f,E as g,k as h,A as i,O as j};
1
+ import{a as t,b as e,c as i,d as n}from"./chunk-BMZ24VPS.js";import{P as r,Q as x}from"./chunk-EIYLJ4FI.js";function a(t,e,i){return t.x===e.x?t.x>i.x&&t.x<i.x+i.width&&Math.max(t.y,e.y)>i.y&&Math.min(t.y,e.y)<i.y+i.height:t.y>i.y&&t.y<i.y+i.height&&Math.max(t.x,e.x)>i.x&&Math.min(t.x,e.x)<i.x+i.width}function f(t,e,i){return(e.x===i.x?1e-7>Math.abs(t.x-e.x):1e-7>Math.abs(t.y-e.y))&&t.x>=Math.min(e.x,i.x)&&t.x<=Math.max(e.x,i.x)&&t.y>=Math.min(e.y,i.y)&&t.y<=Math.max(e.y,i.y)}function u(t,e){return t.x<e.x+e.width&&e.x<t.x+t.width&&t.y<e.y+e.height&&e.y<t.y+t.height}function y(t,e,i,n,r){if(t){if(r?.(3)===!1)return;t.candidateSegment=e,t.peerIndex=i,t.peerSegment=n}return!1}function o(t,e="complete"){return"complete"===e&&void 0!==t.maximumEdgeStrokeWidth&&0===t.maximumEdgeBendRadius?1:3}function l(t,e,i,n,r){let x=(Math.abs(t.x)+Math.abs(t.y)+Math.abs(e.x)+Math.abs(e.y)+Math.abs(i.x)+Math.abs(i.y)+Math.abs(n.x)+Math.abs(n.y)+r)*1e-10+1e-9,a=r+x,f=Math.min(t.x,e.x)-Math.max(i.x,n.x),u=Math.min(i.x,n.x)-Math.max(t.x,e.x),y=Math.min(t.y,e.y)-Math.max(i.y,n.y),o=Math.min(i.y,n.y)-Math.max(t.y,e.y);return Number.isFinite(a)&&Number.isFinite(f)&&Number.isFinite(u)&&Number.isFinite(y)&&Number.isFinite(o)&&(f>a||u>a||y>a||o>a)}function h(t,e,i,n){if(i?.(1)===!1)return;let r=e.get(t);if(r)return r;if(i?.(128)===!1||n?.(14)===!1)return;let x=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(t),a={n:BigInt(x[1]+x[2]+(x[3]??"")),e:Number(x[4]??0)-(x[3]?.length??0)};if(n?.(2)!==!1&&i?.(1)!==!1)return e.set(t,a),a}function s(t,e,i,n,r,x=!1,a){let f,u,y;if(n?.(8)===!1)return;let o=Number(t),l=Number(e),m=Number(i),M=Math.abs(o-l)*(x?2:1)-m;if(Math.abs(M)>8*Number.EPSILON*Math.max(1,Math.abs(o),Math.abs(l),m))return M<0?-1:1;if(a){let x=h(t,a,n,r);if(!x)return;f=x;let o=h(e,a,n,r);if(!o)return;u=o;let l=h(i,a,n,r);if(!l)return;y=l}else{if(n?.(384)===!1||r?.(42)===!1)return;let x=t=>{let e=/^(-?)(\d+)(?:\.(\d+))?(?:e([+-]?\d+))?$/.exec(t);return{n:BigInt(e[1]+e[2]+(e[3]??"")),e:Number(e[4]??0)-(e[3]?.length??0)}};f=x(t),u=x(e),y=x(i)}let g=Math.min(f.e,u.e,y.e);if(n?.(32+f.e-g+u.e-g+y.e-g)===!1)return;let d=f.n*10n**BigInt(f.e-g)-u.n*10n**BigInt(u.e-g),c=(d<0n?-d:d)*(x?2n:1n)-y.n*10n**BigInt(y.e-g);return c<0n?-1:+(c>0n)}function m(t,e,i,n,r){let x=s(t,e,i,n,r);return void 0===x?void 0:x<0}function M(t,e){return t.x===e.x&&t.y===e.y}function g(t,e,i,n,r,x,a,f){let u,y;if(x?.(3)===!1)return;let o=n-e;if(!o)return t<i;if(t===i)return o>0;if(t>i?o<0:o>0)return t<i;if(x?.(6)===!1)return;let l=Number(r),h=2*(t-i)-o*l,m=32*Number.EPSILON*Math.max(1,Math.abs(t)+Math.abs(i)+Math.abs(o*l));if(Number.isFinite(h)&&Math.abs(h)>m)return h<0;if(f){let e=v(t,f,x,a);if(void 0===e)return;u=e;let n=v(i,f,x,a);if(void 0===n)return;y=n}else{if(a?.(10)===!1||x?.(64)===!1)return;u=String(t),y=String(i)}let M=s(u,y,r,x,a,1===Math.abs(o),f?.parts);return void 0===M?void 0:o>0?M<0:M>0}function d(t,e,i,n,r,x){if(x){if(void 0!==x.width){if(n?.(1)===!1)return;let i=x.width,r=i/2,a=(Math.abs(t.x0)+Math.abs(t.x1)+Math.abs(t.y0)+Math.abs(t.y1)+Math.abs(e.x0)+Math.abs(e.x1)+Math.abs(e.y0)+Math.abs(e.y1)+i)*1e-10+1e-9;if(t.x0-e.x1+(t.ox0-e.ox1)*r>a||e.x0-t.x1+(e.ox0-t.ox1)*r>a||t.y0-e.y1+(t.oy0-e.oy1)*r>a||e.y0-t.y1+(e.oy0-t.oy1)*r>a)return!1}if(n?.(4)===!1)return;let a=t.ox0===e.ox1,f=e.ox0===t.ox1,u=t.oy0===e.oy1,y=e.oy0===t.oy1;if(a){if(n?.(1)===!1)return;if(!(t.x0<e.x1))return!1}if(f){if(n?.(1)===!1)return;if(!(e.x0<t.x1))return!1}if(u){if(n?.(1)===!1)return;if(!(t.y0<e.y1))return!1}if(y){if(n?.(1)===!1)return;if(!(e.y0<t.y1))return!1}if(!a){let a=g(t.x0,t.ox0,e.x1,e.ox1,i,n,r,x);if(!0!==a)return a}if(!f){let a=g(e.x0,e.ox0,t.x1,t.ox1,i,n,r,x);if(!0!==a)return a}if(!u){let a=g(t.y0,t.oy0,e.y1,e.oy1,i,n,r,x);if(!0!==a)return a}return!!y||g(e.y0,e.oy0,t.y1,t.oy1,i,n,r,x)}let a=g(t.x0,t.ox0,e.x1,e.ox1,i,n,r,x);if(!0!==a)return a;let f=g(e.x0,e.ox0,t.x1,t.ox1,i,n,r,x);if(!0!==f)return f;let u=g(t.y0,t.oy0,e.y1,e.oy1,i,n,r,x);return!0!==u?u:g(e.y0,e.oy0,t.y1,t.oy1,i,n,r,x)}function c(t,e,i){if(e?.(2)===!1)return;if(Number.isSafeInteger(t.x)&&Number.isSafeInteger(t.y))return t;if(e?.(66)===!1||i?.(13)===!1||!Number.isFinite(t.x)||!Number.isFinite(t.y))return;let n=String(t.x),a=String(t.y);if(n.length>=14&&r.test(n)){if(i?.(5)===!1||e?.(128)===!1)return;n=x(t.x)}if(a.length>=14&&r.test(a)){if(i?.(5)===!1||e?.(128)===!1)return;a=x(t.y)}return{x:Number(n),y:Number(a)}}function b(t,e,i){if(i?.(9)!==!1&&(t.x!==e.x||t.y!==e.y)){if(t.x===e.x)return{x0:t.x,x1:t.x,y0:Math.min(t.y,e.y),y1:Math.max(t.y,e.y),ox0:-1,ox1:1,oy0:0,oy1:0};if(t.y===e.y)return{x0:Math.min(t.x,e.x),x1:Math.max(t.x,e.x),y0:t.y,y1:t.y,ox0:0,ox1:0,oy0:-1,oy1:1}}}function p(t,e,i,n,r){if(n?.(8)===!1)return;let x=Math.sign(e.x-t.x),a=Math.sign(e.y-t.y),f=Math.sign(i.x-e.x),u=Math.sign(i.y-e.y),y=x*u-a*f;if(!y)return x*f+a*u<0&&void 0;if(t.x!==e.x&&t.y!==e.y||e.x!==i.x&&e.y!==i.y||r?.(9)===!1)return;let o=y>0?-1:1,l=(-a-u)*o,h=(x+f)*o;return{x0:e.x,x1:e.x,y0:e.y,y1:e.y,ox0:Math.min(0,l),ox1:Math.max(0,l),oy0:Math.min(0,h),oy1:Math.max(0,h)}}function v(t,e,i,n){if(i?.(1)===!1)return;let r=e.texts.get(t);if(void 0!==r)return r;if(n?.(5)===!1||i?.(32)===!1)return;let x=String(t);if(n?.(2)!==!1&&i?.(1)!==!1)return e.texts.set(t,x),x}function N(t,e,i,n,r,x){if(r?.(3)!==!1)return n.rows[e]?.[i]}function w(t,e,i,n,r,x,a,f){if(a?.(2)===!1)return;let u=x.strips[e];if(!u){if(f?.(t.length+1)===!1)return;u=x.strips[e]=Array(t.length)}let y=u[i];if(y)return y;let o=b(n,r,f);if(o&&a?.(1)!==!1)return u[i]=o,o}function S(t,e,i,n,r,x,a,f){if(a?.(2)===!1)return;let u=x.joins[e];if(!u){if(f?.(t.length+1)===!1)return;u=x.joins[e]=Array(t.length)}let y=u[i];if(void 0!==y)return y;let o=N(t,e,i+1,x,a,f);if(!o)return;let l=p(n,r,o,a,f);if(void 0!==l&&a?.(1)!==!1)return u[i]=l,l}function I(t,e,i,n,r,x,a,f=-1){let u=e-1,y=e,o,l;for(;u>=0;){if(r?.(1)===!1||!(o=n?a?N(t,f,u,a,r,x):c(t[u],r,x):t[u]))return;if(o.x!==i.x||o.y!==i.y)break;u--}for(;y<t.length;){if(r?.(1)===!1||!(l=n?a?N(t,f,y,a,r,x):c(t[y],r,x):t[y]))return;if(l.x!==i.x||l.y!==i.y)break;y++}return!(u<0)&&!(y>=t.length)&&!!o&&!!l&&(o.x===i.x&&l.x===i.x&&Math.min(o.y,l.y)<i.y&&i.y<Math.max(o.y,l.y)||o.y===i.y&&l.y===i.y&&Math.min(o.x,l.x)<i.x&&i.x<Math.max(o.x,l.x))}function F(t){for(let e=0;e<t.length;e++){let i=t[e];if(!Number.isFinite(i.x)||!Number.isFinite(i.y)||e&&i.x!==t[e-1].x&&i.y!==t[e-1].y)return!1}return!0}function E(t,e,i,n,r,x,a,f=3,u=!1){return B(t,e,i,n,r,x,!0,a,f,u)}function k(t,e,i,n,r=!1,a){if(!a&&void 0!==e.maximumEdgeStrokeWidth&&0===e.maximumEdgeBendRadius){let e=function(t,e,i){let n=!1;for(let i of t)for(let t=1;t<i.points.length;t++){if(e?.(1)===!1)return;let r=i.points[t-1],x=i.points[t];r.x!==x.x&&r.y!==x.y&&(n=!0)}if(!n)return!1;if(i?.(t.length+18)===!1)return;let r=Array(t.length),x=[],a=[],f=[],u=[];for(let n=0;n<t.length;n++){let y=t[n].points;if(e?.(1)===!1||i?.(5*y.length+5)===!1)return;let o=Array(y.length),l=Array(y.length);for(let t=0;t<y.length;t++){if(e?.(3)===!1)return;let n=y[t],r=c(n,e,i);if(!r)return;if(o[t]={x:n.x,y:n.y},r===n){if(i?.(3)===!1)return;l[t]={x:r.x,y:r.y}}else l[t]=r}r[n]={raw:o,points:l};for(let t=0;t+1<l.length;t++){if(e?.(4)===!1)return;let r=l[t],y=l[t+1];if(r.x===y.x==(r.y===y.y))return!1;if(i?.(15)===!1)return;let o={owner:n,segment:t},h=r.x===y.x;(h?a:x).push({key:h?r.x:r.y,piece:o}),(h?u:f).push({key:h?r.y:r.x,piece:o},{key:h?y.y:y.x,piece:o})}}let y={},o=(t,i)=>{if(e?.(1)===!1)throw y;return t.key-i.key||t.piece.owner-i.piece.owner||t.piece.segment-i.piece.segment};try{for(let t of[x,a,f,u])t.sort(o)}catch(t){if(t===y)return;throw t}return{routes:r,horizontal:x,vertical:a,horizontalEnds:f,verticalEnds:u}}(t,i,n);if(void 0===e)return;e&&(a=e)}if(!a){if(r)for(let e of t){let t;for(let r of e.points){let e=c(r,i,n);if(!e||i?.(2)===!1)return;if(t&&(e.x===t.x&&e.y===t.y||e.x!==t.x&&e.y!==t.y))return!1;t=e}}return n?.(1)===!1?void 0:(r,x)=>{if(i?.(t.length)===!1)return!1;let a=0;for(let e=0;e<t.length;e++)e!==r&&"invisible"!==t[e].style&&(a+=Math.max(0,t[e].points.length-1));let f=t[r].points,u=o(e);return i?.(u*Math.max(0,f.length-1)*a+f.length+a+t.length)!==!1&&void 0!==E(f,r,t,e,i,n,x,u,!0)}}if(i?.(t.length+1)===!1)return;if(a.routes.length!==t.length)return!1;let f=0;for(let e of t)f+=Math.max(0,e.points.length-1);if(n?.(4*t.length+28+2*f+4)===!1)return;let u=Array(t.length),y=Array(t.length),l=[],h=[],s=0,m=0;for(let e=0;e<t.length;e++){let n;if(i?.(3)===!1)return;let r=t[e].points,x=a.routes[e];if(y[e]=m,m+=Math.max(0,r.length-1),r.length!==x.raw.length||r.length!==x.points.length)return!1;u[e]=x.points;for(let t=0;t<r.length;t++){if(i?.(7)===!1)return;let e=r[t],a=x.raw[t],f=x.points[t];if(e.x!==a.x||e.y!==a.y||!Number.isFinite(e.x)||!Number.isFinite(e.y)||!Number.isFinite(f.x)||!Number.isFinite(f.y)||n&&(f.x===n.x&&f.y===n.y||f.x!==n.x&&f.y!==n.y))return!1;n=f,s+=Math.abs(e.x)+Math.abs(e.y)}}let M=e.maximumEdgeStrokeWidth,g,d;if(Number.isSafeInteger(M)&&M>0){if(n?.(4)===!1||i?.(M<10?2:17)===!1)return;g=M,d=String(M)}else{if(n?.(5)===!1||i?.(128)===!1)return;g=Number(d=x(M))}if(!Number.isFinite(g)||g<=0||0!==e.maximumEdgeBendRadius)return!1;let b=Math.max(g,.01)+(s+g)*1e-10+1e-9,p=.01+(s+g)*1e-10+1e-9,v=s>Math.sqrt(Number.MAX_VALUE)/4,N=new Uint8Array(f);for(let e=0;e<2;e++)for(let r of e?a.horizontal:a.vertical){if(i?.(3)===!1)return;let x=function(t,e,i,n,r,x){if(x?.(4)===!1)return;let a=t[i],f=t[i+1],u=e[i],y=e[i+1];if(r||a.x!==f.x&&a.y!==f.y)return!0;for(let i=0;i<2;i++){if(x?.(2)===!1)return;let r=i?t.length-1:0,o=t[r],l=e[r];if((o.x!==a.x||o.y!==a.y||l.x!==u.x||l.y!==u.y)&&(o.x!==f.x||o.y!==f.y||l.x!==y.x||l.y!==y.y))for(let t=0;t<2;t++){if(x?.(1)===!1)return;let e=t?u:a,i=t?y:f,r=t?l:o;if(r.x>=Math.min(e.x,i.x)-n&&r.x<=Math.max(e.x,i.x)+n&&r.y>=Math.min(e.y,i.y)-n&&r.y<=Math.max(e.y,i.y)+n)return!0}}return!1}(t[r.piece.owner].points,a.routes[r.piece.owner].points,r.piece.segment,p,v,i);if(void 0===x)return;if(x){if(n?.(1)===!1||i?.(1)===!1)return;N[y[r.piece.owner]+r.piece.segment]=1,(e?l:h).push(r)}}let w={rows:u,rangeStarts:new Map,parts:new Map,texts:new Map,strips:Array(t.length),joins:Array(t.length),numericSeed:a,width:g,widthText:d,margin:b,offsets:y,driftHorizontal:l,driftVertical:h,seen:new Uint32Array(f),fullCandidates:N,epoch:0,contactOnly:!0};return(r,x)=>void 0!==B(t[r].points,r,t,e,i,n,!0,x,1,!1,w)}function A(t,e,i,n,r,x){return B(t,e,i,n,r,x,!1)}function B(r,a,f,u,o,h,s,v,E=3,k=!1,A){let z=0,O,R;if(A){if(o?.(2)===!1)return;O=A.width,R=A.widthText}else if(void 0!==u.maximumEdgeStrokeWidth){if(h?.(4)===!1)return;let t=u.maximumEdgeStrokeWidth;if(Number.isSafeInteger(t)&&t>0){if(o?.(t<10?2:17)===!1)return;O=t,R=String(t)}else{if(o?.(128)===!1)return;O=Number(R=x(t))}if(!Number.isFinite(O)||O<=0)throw TypeError("Measured stroke width must be finite and positive")}let j,W=!1;if(A){if(o?.(2)===!1)return;W=A.contactOnly&&void 0!==O&&0===u.maximumEdgeBendRadius}if(s&&void 0!==O&&0===u.maximumEdgeBendRadius){if(h?.(1)===!1)return;j=[]}let $=!1;if(A){if(void 0===($=function(t,e,i,n,r,x){let a,f=n.numericSeed,u=n.margin;for(let y=1;y<t.length;y++){if(r?.(4)===!1)return;let o=t[y-1],h=t[y];if(n.contactOnly&&r?.(1)===!1)return;let s=o.x===h.x,m=n.contactOnly&&!n.fullCandidates[n.offsets[e]+y-1];if(n.contactOnly){if(r?.(1)===!1)return;if(n.epoch++,0x100000000===n.epoch){if(r?.(n.seen.length)===!1)return;n.seen.fill(0),n.epoch=1}}for(let t=0;t<(m?5:2);t++){let M,g,d;if(r?.(4)===!1)return;if(m)if(0===t)M=s?f.vertical:f.horizontal,g=(s?o.x:o.y)-u,d=(s?o.x:o.y)+u;else if(1===t||2===t){M=s?f.horizontal:f.vertical;let e=1===t?o:h;g=(s?e.y:e.x)-u,d=(s?e.y:e.x)+u}else 3===t?(M=s?f.horizontalEnds:f.verticalEnds,g=(s?o.x:o.y)-u,d=(s?o.x:o.y)+u):(M=s?n.driftHorizontal:n.driftVertical,g=Math.min(s?o.y:o.x,s?h.y:h.x)-u,d=Math.max(s?o.y:o.x,s?h.y:h.x)+u);else M=t?f.horizontal:f.vertical,g=Math.min(t?o.y:o.x,t?h.y:h.x)-u,d=Math.max(t?o.y:o.x,t?h.y:h.x)+u;let c=function(t,e,i,n,r){if(n?.(2)===!1)return;let x=i.rangeStarts.get(t),a=x?.get(e);if(void 0!==a)return a;let f=0,u=t.length;for(;f<u;){if(n?.(1)===!1)return;let i=f+u>>>1;t[i].key<e?f=i+1:u=i}if(!x){if(r?.(3)===!1||n?.(1)===!1)return;x=new Map,i.rangeStarts.set(t,x)}if(r?.(2)!==!1&&n?.(1)!==!1)return x.set(e,f),f}(M,g,n,r,x);if(void 0===c)return;for(let t=c;t<M.length;t++){if(r?.(3)===!1)return;let f=M[t];if(f.key>d)break;let u=f.piece;if(u.owner===e||"invisible"===i[u.owner].style)continue;if(n.contactOnly){if(r?.(2)===!1)return;let t=n.offsets[u.owner]+u.segment;if(n.seen[t]===n.epoch)continue;n.seen[t]=n.epoch}if(r?.(1)===!1)return;let s=i[u.owner].points;if(l(o,h,s[u.segment],s[u.segment+1],n.width))continue;if(!a){if(x?.(i.length+1)===!1)return;a=Array(i.length)}let m=a[u.owner];if(!m){if(x?.(1)===!1)return;m=a[u.owner]=[]}if(x?.(3)===!1||r?.(1)===!1)return;m.push(y,u.segment+1,0)}}}return a??null}(r,a,f,A,o,h)))return;if(null===$)return 0}let H,L,P=u.edges[a],U=[{points:r},{points:[]}];if(!(A&&o?.(f.length)===!1)){for(let y=0;y<f.length;y++){let M,g=f[y];if(y===a||"invisible"===g.style)continue;let d=!k;if($){if(o?.(1)===!1)return;if(!$[y]?.length)continue}if(j){if(h?.(1)===!1||o?.(1)===!1)return;d&&j.push(y)}let b=u.edges[y],p,v;if(A){if(o?.(1)===!1)return;U[1].points=g.points}let N=0,w=$?$[y]:void 0;for(let e=1;$?N<w.length:e<r.length;e++)for(let n=1;$?N<w.length:n<g.points.length;n++){let a=N;if($){if(o?.(2)===!1)return;e=w[N],n=w[N+1],N+=3}if(A&&!$&&o?.(E)===!1)return;let f=r[e-1],y=r[e],M=g.points[n-1],S=g.points[n];if(!$&&s&&void 0!==O&&0===u.maximumEdgeBendRadius){let t=function(t,e,i,n,r){if((t.x===e.x||t.y===e.y)&&(i.x===n.x||i.y===n.y))return l(t,e,i,n,r)}(f,y,M,S,O);if(void 0===t){let t=c(f,o,h);if(!t)return;let e=c(y,o,h);if(!e)return;let i=c(M,o,h);if(!i)return;let n=c(S,o,h);if(!n||o?.(4)===!1||t.x!==e.x&&t.y!==e.y||i.x!==n.x&&i.y!==n.y)return}if(!0===t)continue;d=!0}if(($||1===E)&&o?.(W?1:2)===!1)return;if(!W){if(void 0===O){if(f.x===y.x&&M.x===S.x&&.5>=Math.abs(f.x-M.x)&&Math.min(Math.max(f.y,y.y),Math.max(M.y,S.y))-Math.max(Math.min(f.y,y.y),Math.min(M.y,S.y))>.01||f.y===y.y&&M.y===S.y&&.5>=Math.abs(f.y-M.y)&&Math.min(Math.max(f.x,y.x),Math.max(M.x,S.x))-Math.max(Math.min(f.x,y.x),Math.min(M.x,S.x))>.01)return}else if(!1!==function(t,e,i,n,r,a,f,u){let y=t.x===e.x;if(i.x===n.x!==y||!y&&(t.y!==e.y||i.y!==n.y))return!1;if(f?.(2)===!1)return;let o=y?t.x:t.y,l=y?i.x:i.y,h=Math.abs(o-l),s=(Math.abs(o)+Math.abs(l)+r)*1e-10+1e-9;if(h>r+s)return!1;let M=y?t.y:t.x,g=y?e.y:e.x,d=y?i.y:i.x,c=y?n.y:n.x,b=Math.min(Math.max(M,g),Math.max(d,c))-Math.max(Math.min(M,g),Math.min(d,c)),p=(Math.abs(M)+Math.abs(g)+Math.abs(d)+Math.abs(c))*1e-10+1e-9;if(b<-p)return!1;if(0===b){if(f?.(2)===!1)return;if(Math.abs(M-g)>2*p&&Math.abs(d-c)>2*p)return!1}if(f?.(2)===!1)return;if(h<r-s&&b>p)return!0;if(f?.(6)===!1||!Number.isFinite(o)||!Number.isFinite(l)||!Number.isFinite(M)||!Number.isFinite(g)||!Number.isFinite(d)||!Number.isFinite(c)||u?.(10)===!1||f?.(256)===!1)return;let v=m(x(o),x(l),a,f,u);if(!0!==v)return v;if(u?.(20)===!1||f?.(512)===!1)return;let N=Number(x(M)),w=Number(x(g)),S=Number(x(d)),I=Number(x(c));return Math.max(Math.min(N,w),Math.min(S,I))<Math.min(Math.max(N,w),Math.max(S,I))}(f,y,M,S,O,R,o,h))return}if(A){if(o?.(1)===!1)return;if((f.x!==y.x||f.y!==y.y)&&(M.x!==S.x||M.y!==S.y)&&Math.min(f.x,y.x)<=Math.max(M.x,S.x)&&Math.min(M.x,S.x)<=Math.max(f.x,y.x)&&Math.min(f.y,y.y)<=Math.max(M.y,S.y)&&Math.min(M.y,S.y)<=Math.max(f.y,y.y)){if(!H){if(h?.(13)===!1)return;H=[{a:f,b:y,edgeIndex:0,pointIndex:e-1},{a:M,b:S,edgeIndex:1,pointIndex:n-1}]}if(o?.(7+r.length+g.points.length)===!1||h?.(4)===!1)return;let x=H[0],u=H[1];x.a=f,x.b=y,x.pointIndex=e-1,u.a=M,u.b=S,u.pointIndex=n-1;let l=i(x,u,U);if(l){if(!v){if(h?.(1)===!1)return;v=[]}if(o?.(v.length)===!1||h?.(2)===!1)return;if(t(v,l),W&&(f.x!==y.x&&f.y!==y.y||M.x!==S.x&&M.y!==S.y)){if(o?.(1)===!1)return;w[a+2]=1}}}}let I=f.x===y.x,F=M.x===S.x,k=0,B=0,z=!1;if(I!==F)k=I?f.x:M.x,B=I?M.y:f.y,z=k>=Math.min(f.x,y.x)&&k<=Math.max(f.x,y.x)&&B>=Math.min(f.y,y.y)&&B<=Math.max(f.y,y.y)&&k>=Math.min(M.x,S.x)&&k<=Math.max(M.x,S.x)&&B>=Math.min(M.y,S.y)&&B<=Math.max(M.y,S.y);else if(I?f.x===M.x:f.y===M.y){let t=Math.max(I?Math.min(f.y,y.y):Math.min(f.x,y.x),I?Math.min(M.y,S.y):Math.min(M.x,S.x));Math.min(I?Math.max(f.y,y.y):Math.max(f.x,y.x),I?Math.max(M.y,S.y):Math.max(M.x,S.x))>=t&&(k=I?f.x:t,B=I?t:f.y,z=!0)}if(!z)continue;let j=r[0],L=r.at(-1),V=g.points[0],T=g.points.at(-1),q=j.x===k&&j.y===B,C=L.x===k&&L.y===B,J=V.x===k&&V.y===B,K=T.x===k&&T.y===B;P.source===b.source&&q&&J||P.source===b.target&&q&&K||P.target===b.source&&C&&J||P.target===b.target&&C&&K||(p??=new Set).add(`${k},${B}`)}if(j&&k&&d&&j.push(y),A)if(v){let t=v.length;if(o?.(2*t*t+t)===!1||h?.(2*t+1)===!1)return;M=e(v)}else M=0;else{if(!p&&(L??=F(r))&&F(g.points))continue;U[1].points=g.points,M=n(U)}if(M<(p?.size??0))return;z+=M}if(!(s&&void 0!==O&&0===u.maximumEdgeBendRadius&&j.length&&!0!==function(t,e,n,r,x,a,f,u,o,l,h,s){let m=r.edges[e],v,F,E;if(h){let t=function(t,e,i){if(i?.(2)!==!1)return e.rows[t]}(e,h,u);if(!t)return;E=t}else{if(o?.(t.length+2)===!1)return;E=Array(t.length)}for(let k=0;k<f.length;k++){if(u?.(1)===!1)return;let A=f[k],B=n[A],z=r.edges[A];if(h&&u?.(1)===!1)return;let O=h?.rows[A],R=s?.[A],j=0;for(let n=1;s?R&&j<R.length:n<t.length;n++)for(let r=1;s?j<R.length:r<B.points.length;r++){let f=j;if(s){if(u?.(2)===!1)return;n=R[j],r=R[j+1],j+=3}if(u?.(1)===!1)return;let k=t[n-1],W=t[n],$=B.points[r-1],H=B.points[r],L=(Math.abs(k.x)+Math.abs(k.y)+Math.abs(W.x)+Math.abs(W.y)+Math.abs($.x)+Math.abs($.y)+Math.abs(H.x)+Math.abs(H.y)+x)*1e-10+1e-9,P=x+L;if(Math.min(k.x,W.x)-Math.max($.x,H.x)>P||Math.min($.x,H.x)-Math.max(k.x,W.x)>P||Math.min(k.y,W.y)-Math.max($.y,H.y)>P||Math.min($.y,H.y)-Math.max(k.y,W.y)>P)continue;let U=k.x===W.x;if(U!==($.x===H.x)&&(k.x===W.x||k.y===W.y)&&($.x===H.x||$.y===H.y)){let t=U?k.x:$.x,e=U?$.y:k.y,i=U?$:k,n=U?H:W,r=U?k:$,x=U?W:H;if(t>Math.min(i.x,n.x)+P&&t<Math.max(i.x,n.x)-P&&e>Math.min(r.y,x.y)+P&&e<Math.max(r.y,x.y)-P)continue}if(!O){if(h||o?.(B.points.length+1)===!1)return;O=Array(B.points.length)}if(u?.(4)===!1)return;let V=E[n-1]??(E[n-1]=h?N(t,e,n-1,h,u,o):c(k,u,o));if(!V)return;let T=E[n]??(E[n]=h?N(t,e,n,h,u,o):c(W,u,o));if(!T)return;let q=O[r-1]??(O[r-1]=h?N(B.points,A,r-1,h,u,o):c($,u,o));if(!q)return;let C=O[r]??(O[r]=h?N(B.points,A,r,h,u,o):c(H,u,o));if(!C)return;let J=h?w(t,e,n,V,T,h,u,o):b(V,T,o);if(!J)return;let K=h?w(B.points,A,r,q,C,h,u,o):b(q,C,o);if(!K)return;let X=V.x===T.x,Y=q.x===C.x;if(h?.contactOnly&&X===Y){if(u?.(2)===!1)return;if(Math.max(X?Math.min(V.y,T.y):Math.min(V.x,T.x),X?Math.min(q.y,C.y):Math.min(q.x,C.x))<Math.min(X?Math.max(V.y,T.y):Math.max(V.x,T.x),X?Math.max(q.y,C.y):Math.max(q.x,C.x))){let t=X?V.x:V.y,e=X?q.x:q.y,i=g(Math.max(t,e),-2,Math.min(t,e),0,a,u,o,h);if(!1!==i)return void 0===i?void 0:y(l,n,A,r,u)}}else if(X===Y&&(k.x!==W.x&&k.y!==W.y||$.x!==H.x&&$.y!==H.y)){let t=d(J,K,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}if(X!==Y){let x=d(J,K,a,u,o,h);if(void 0===x)return;if(x){if(o?.(6)===!1)return;let x={x:X?k.x:$.x,y:X?$.y:k.y},a={x:X?V.x:q.x,y:X?q.y:V.y},s=!1;if(h?.contactOnly&&h.numericSeed&&(k.x!==W.x&&k.y!==W.y||$.x!==H.x&&$.y!==H.y)){if(u?.(1)===!1)return;if(R?.[f+2]===1){if(!v){if(o?.(20)===!1)return;v=[{points:E},{points:O}],F=[{a:V,b:T,edgeIndex:0,pointIndex:n-1},{a:q,b:C,edgeIndex:1,pointIndex:r-1}]}if(u?.(7+E.length+O.length)===!1||o?.(4)===!1)return;v[1].points=O;let t=F[0],e=F[1];t.a=V,t.b=T,t.pointIndex=n-1,e.a=q,e.b=C,e.pointIndex=r-1,s=!!i(t,e,v)}}else{let i=I(t,n,x,!1,u,o);if(void 0===i)return;let f=I(B.points,r,x,!1,u,o);if(void 0===f)return;if(i&&f){let i=I(t,n,a,!0,u,o,h,e);if(void 0===i)return;let x=I(B.points,r,a,!0,u,o,h,A);if(void 0===x)return;s=i&&x}}let g=t[0],d=t.at(-1),c=B.points[0],b=B.points.at(-1);if(u?.(4)===!1)return;let p=1===n&&1===r&&m.source===z.source&&M(x,g)&&M(x,c)||1===n&&r===B.points.length-1&&m.source===z.target&&M(x,g)&&M(x,b)||n===t.length-1&&1===r&&m.target===z.source&&M(x,d)&&M(x,c)||n===t.length-1&&r===B.points.length-1&&m.target===z.target&&M(x,d)&&M(x,b);if(!s&&!p)return y(l,n,A,r,u)}}let Z=!1,_=!1;if(n+1<t.length)if(h){let i=S(t,e,n,V,T,h,u,o);if(void 0===i)return;Z=i}else{if(u?.(1)===!1)return;let e=E[n+1]??(E[n+1]=c(t[n+1],u,o));if(!e)return;let i=p(V,T,e,u,o);if(void 0===i)return;Z=i}if(r+1<B.points.length)if(h){let t=S(B.points,A,r,q,C,h,u,o);if(void 0===t)return;_=t}else{if(u?.(1)===!1)return;let t=O[r+1]??(O[r+1]=c(B.points[r+1],u,o));if(!t)return;let e=p(q,C,t,u,o);if(void 0===e)return;_=e}if(Z){let t=d(Z,K,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}if(_){let t=d(J,_,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}if(Z&&_){let t=d(Z,_,a,u,o,h);if(!1!==t)return void 0===t?void 0:y(l,n,A,r,u)}}}return!0}(r,a,f,u,O,R,j,o,h,v,A,$||void 0)))return z}}function z(t){let e=[];for(let i of t)if(e.at(-1)?.x!==i.x||e.at(-1)?.y!==i.y)for(e.push({...i});e.length>2;){let t=e.at(-3),i=e.at(-2),n=e.at(-1);if(!(t.x===i.x&&i.x===n.x&&i.y>=Math.min(t.y,n.y)&&i.y<=Math.max(t.y,n.y)||t.y===i.y&&i.y===n.y&&i.x>=Math.min(t.x,n.x)&&i.x<=Math.max(t.x,n.x)))break;e.splice(e.length-2,1)}return e}export{a as a,f as b,u as c,o as d,m as e,c as f,E as g,k as h,A as i,z as j};
@@ -1 +1 @@
1
- import{z as t}from"./chunk-KXPF5KIU.js";function e(e,r,i){let n=t(e,[r,i]);return"number"==typeof n&&Number.isFinite(n)&&n>=0?n:void 0}var r=/^direction\s+(TB|TD|BT|LR|RL)\s*$/i;function i(t){let e=t.match(r);return e?e[1].toUpperCase():void 0}export{e as a,i as b};
1
+ import{z as t}from"./chunk-V6I2VGNQ.js";function e(e,r,i){let n=t(e,[r,i]);return"number"==typeof n&&Number.isFinite(n)&&n>=0?n:void 0}var r=/^direction\s+(TB|TD|BT|LR|RL)\s*$/i;function i(t){let e=t.match(r);return e?e[1].toUpperCase():void 0}export{e as a,i as b};