@tobisk/codesafari 1.0.0 → 1.0.2

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 (174) hide show
  1. package/README.md +173 -0
  2. package/dist/cli.js +22 -1
  3. package/dist/cli.js.map +1 -1
  4. package/dist/commands/export.d.ts +2 -0
  5. package/dist/commands/export.js +6 -0
  6. package/dist/commands/export.js.map +1 -1
  7. package/dist/commands/gitignore.d.ts +8 -0
  8. package/dist/commands/gitignore.js +31 -0
  9. package/dist/commands/gitignore.js.map +1 -0
  10. package/dist/commands/insert.d.ts +49 -0
  11. package/dist/commands/insert.js +279 -0
  12. package/dist/commands/insert.js.map +1 -0
  13. package/dist/commands/validate.js +1 -1
  14. package/dist/commands/validate.js.map +1 -1
  15. package/dist/content/frontmatter.js +9 -1
  16. package/dist/content/frontmatter.js.map +1 -1
  17. package/dist/content/loadContent.d.ts +9 -1
  18. package/dist/content/loadContent.js +87 -1
  19. package/dist/content/loadContent.js.map +1 -1
  20. package/dist/ignore/ignore.d.ts +1 -0
  21. package/dist/ignore/ignore.js +54 -2
  22. package/dist/ignore/ignore.js.map +1 -1
  23. package/dist/manifest/build.js +21 -12
  24. package/dist/manifest/build.js.map +1 -1
  25. package/dist/model/types.d.ts +26 -0
  26. package/package.json +13 -10
  27. package/skills/README.md +53 -0
  28. package/skills/authoring-code-safaris/SKILL.md +411 -0
  29. package/viewer-dist/assets/abnfDiagram-XWFEHMT6-C79KnTw8.js +1 -0
  30. package/viewer-dist/assets/arc-l-ZAXPJO.js +1 -0
  31. package/viewer-dist/assets/architecture-WOLXFQ4H-BgLy9Yqp.js +1 -0
  32. package/viewer-dist/assets/architectureDiagram-CSQXQB3N-TJ9cXrHq.js +36 -0
  33. package/viewer-dist/assets/blockDiagram-BEDRHYPZ-By3kvess.js +140 -0
  34. package/viewer-dist/assets/bpmnIcons-APHXDYXF-C0jbCElo.js +1 -0
  35. package/viewer-dist/assets/c4Diagram-M2UUVUY5-CEeFbn5F.js +38 -0
  36. package/viewer-dist/assets/chunk-2Q5K7J3B-DKYFIUDS.js +1 -0
  37. package/viewer-dist/assets/chunk-3BJB4PZV-D3hUDXSk.js +1 -0
  38. package/viewer-dist/assets/chunk-3GCGMST5-C9FeQipv.js +1 -0
  39. package/viewer-dist/assets/{chunk-5VM5RSS4-BEPuob2j.js → chunk-5VM5RSS4-CdmEoR_J.js} +2 -2
  40. package/viewer-dist/assets/chunk-7U7NFRK5-CTLlozLY.js +88 -0
  41. package/viewer-dist/assets/chunk-CNRTWJTD-Ccr1NK1L.js +1 -0
  42. package/viewer-dist/assets/chunk-D5HYT7QG-Bj30JPRv.js +1 -0
  43. package/viewer-dist/assets/chunk-EBZ3SEQC-Sk8u_9ep.js +2 -0
  44. package/viewer-dist/assets/chunk-JWPE2WC7-COMTgl4A.js +1 -0
  45. package/viewer-dist/assets/chunk-KTR4FSNJ-WfEV-uOS.js +1 -0
  46. package/viewer-dist/assets/chunk-VN5WK6U6-C6BzLJ3g.js +213 -0
  47. package/viewer-dist/assets/chunk-XXDRQBXY-B_jRWCc3.js +1 -0
  48. package/viewer-dist/assets/classDiagram-v2-IZLYA2OM-CMUybpF2.js +217 -0
  49. package/viewer-dist/assets/cose-bilkent-JH36ORCC-BPaMzy85.js +1 -0
  50. package/viewer-dist/assets/cynefin-EF2NZ3EQ-DWzUaEWi.js +1 -0
  51. package/viewer-dist/assets/cynefinDiagram-NJNITYFG-C8QaCQXp.js +62 -0
  52. package/viewer-dist/assets/cytoscape.esm-DTfjcSDB.js +321 -0
  53. package/viewer-dist/assets/dagre-KIHZ2IZ3-BOPsr9LQ.js +4 -0
  54. package/viewer-dist/assets/defaultLocale-DeDIAtVl.js +1 -0
  55. package/viewer-dist/assets/diagram-7YQZDPLS-mYVjZ8Lx.js +41 -0
  56. package/viewer-dist/assets/diagram-QBROCOUO-DvI2mJSr.js +200 -0
  57. package/viewer-dist/assets/diagram-RJJCUUZO-CUPJGu2H.js +30 -0
  58. package/viewer-dist/assets/diagram-WERXNKYE-LcjJC6e6.js +24 -0
  59. package/viewer-dist/assets/diagram-YHHI257C-CcytRL3C.js +3 -0
  60. package/viewer-dist/assets/diagram-YR4HJLHV-DSNAvpUg.js +24 -0
  61. package/viewer-dist/assets/ebnfDiagram-N527522P-DCRtXms7.js +1 -0
  62. package/viewer-dist/assets/elk-O5DQBFGD-DMI6Zpvy.js +27 -0
  63. package/viewer-dist/assets/erDiagram-GT5GOJPG-D1F-hqWB.js +99 -0
  64. package/viewer-dist/assets/eventmodeling-K75KTNOO-4qs67wAF.js +1 -0
  65. package/viewer-dist/assets/flowDiagram-JAYNFW54-7bC7dhfH.js +1 -0
  66. package/viewer-dist/assets/ganttDiagram-3PRQTZWP-c3vw-KzJ.js +292 -0
  67. package/viewer-dist/assets/gitGraph-VSP46ZUC-CFMJazMp.js +1 -0
  68. package/viewer-dist/assets/gitGraphDiagram-VXDFKS5L-CXwZYVtU.js +106 -0
  69. package/viewer-dist/assets/graphlib-7nQ5Ng6P.js +1 -0
  70. package/viewer-dist/assets/grid-E2QIVN74-ryRc6Wgk.js +1 -0
  71. package/viewer-dist/assets/index-BLTUQmtP.css +1 -0
  72. package/viewer-dist/assets/index-LgGsGSUh.js +398 -0
  73. package/viewer-dist/assets/info-OHQRW6UA-rYwbZW6Y.js +1 -0
  74. package/viewer-dist/assets/infoDiagram-ATMJ4U3S-qX5Cid2q.js +2 -0
  75. package/viewer-dist/assets/init-C-OQMol4.js +1 -0
  76. package/viewer-dist/assets/ishikawaDiagram-S3EKX5GW-CSUJfCgm.js +70 -0
  77. package/viewer-dist/assets/journeyDiagram-POQNLL5X--_T-gdww.js +139 -0
  78. package/viewer-dist/assets/kanban-definition-BH5XI6FM-BsWjihcO.js +89 -0
  79. package/viewer-dist/assets/katex-CePi8B18.js +257 -0
  80. package/viewer-dist/assets/linear-BjnGGdIE.js +1 -0
  81. package/viewer-dist/assets/mermaid-parser.core-D9IKLdIu.js +141 -0
  82. package/viewer-dist/assets/mindmap-definition-WVAN44T4-vxwY3Xnu.js +98 -0
  83. package/viewer-dist/assets/ordinal-BDEzSJ7C.js +1 -0
  84. package/viewer-dist/assets/packet-JDAUHWVQ-CEegYGRn.js +1 -0
  85. package/viewer-dist/assets/pegDiagram-D4NLKWP3-8tSu4Jqx.js +1 -0
  86. package/viewer-dist/assets/pie-XZMESJXO-exj595wL.js +1 -0
  87. package/viewer-dist/assets/pieDiagram-36ENHN4W-CNY-FqqW.js +39 -0
  88. package/viewer-dist/assets/quadrantDiagram-ZQUDMS73-CqGaRuIP.js +7 -0
  89. package/viewer-dist/assets/radar-ABXABTNO-CmxHfKAF.js +1 -0
  90. package/viewer-dist/assets/railroad-I3PHUGI6-DXY0-ZL-.js +1 -0
  91. package/viewer-dist/assets/railroad-abnf-LNEFI6M7-v-M60bY5.js +1 -0
  92. package/viewer-dist/assets/railroad-ebnf-DWYD2UWJ-C7Ubri5u.js +1 -0
  93. package/viewer-dist/assets/railroad-peg-JR7BVNR7-DpAM4Usk.js +1 -0
  94. package/viewer-dist/assets/railroadDiagram-JIZHGYPL-D6LbsW-D.js +1 -0
  95. package/viewer-dist/assets/render-VIF2ZAQL-B9RjOjNU.js +2 -0
  96. package/viewer-dist/assets/requirementDiagram-AXW2TVFA-FxNR3nZg.js +84 -0
  97. package/viewer-dist/assets/sankeyDiagram-FBCJTAIF-pSJfgdmf.js +40 -0
  98. package/viewer-dist/assets/sequenceDiagram-3LA2ROMG-R5T9FB-U.js +169 -0
  99. package/viewer-dist/assets/sizeCapture-2Q2CQKSF-BuZ6aVhF.js +1 -0
  100. package/viewer-dist/assets/stateDiagram-v2-XZFR63ZJ-y2ApNDME.js +291 -0
  101. package/viewer-dist/assets/swimlanes-YQL5WMAO-Dqbpsu6u.js +1 -0
  102. package/viewer-dist/assets/swimlanesDiagram-BA3ZWDFA-iEZapiU_.js +8 -0
  103. package/viewer-dist/assets/timeline-definition-7Z437IG3-DAxdChcP.js +120 -0
  104. package/viewer-dist/assets/treeView-D4JQ5SDB-DE5B8wLE.js +1 -0
  105. package/viewer-dist/assets/treemap-SAJKECNS-fnWCJ5Gb.js +1 -0
  106. package/viewer-dist/assets/usecaseDiagram-RDK6N6HP-bXXWy_jN.js +328 -0
  107. package/viewer-dist/assets/vennDiagram-SHRQU5PJ-CjOBjqdM.js +34 -0
  108. package/viewer-dist/assets/wardley-7MLQ67FV-COzPZ67W.js +1 -0
  109. package/viewer-dist/assets/wardleyDiagram-F3OXNVQS-BjHoJgg7.js +78 -0
  110. package/viewer-dist/assets/xychartDiagram-GDYJKCDI-CwJZcH_5.js +7 -0
  111. package/viewer-dist/index.html +2 -2
  112. package/viewer-dist/assets/abnfDiagram-VRR7QNED-D3fx4JHm.js +0 -1
  113. package/viewer-dist/assets/arc-CDTQlIOl.js +0 -1
  114. package/viewer-dist/assets/architectureDiagram-ZJ3FMSHR-Bc-C9AOz.js +0 -36
  115. package/viewer-dist/assets/blockDiagram-677ZJIJ3-ZChUq7oC.js +0 -132
  116. package/viewer-dist/assets/c4Diagram-LMCZKHZV-Bh84Wvzw.js +0 -10
  117. package/viewer-dist/assets/channel-c5yLhzg_.js +0 -1
  118. package/viewer-dist/assets/chunk-2Q5K7J3B-BL2GPise.js +0 -1
  119. package/viewer-dist/assets/chunk-32BRIVSS-C8J4_0PY.js +0 -1
  120. package/viewer-dist/assets/chunk-EX3LRPZG-C8dshNGY.js +0 -231
  121. package/viewer-dist/assets/chunk-JWPE2WC7-DB3UPcb9.js +0 -1
  122. package/viewer-dist/assets/chunk-MOJQB5TN-CoW82BtI.js +0 -88
  123. package/viewer-dist/assets/chunk-RYQCIY6F-BSkOviuC.js +0 -1
  124. package/viewer-dist/assets/chunk-V7JOEXUC-C3uhoOMH.js +0 -206
  125. package/viewer-dist/assets/chunk-VR4S4FIN-IAlLBWOE.js +0 -1
  126. package/viewer-dist/assets/chunk-XXDRQBXY-BZ2dkDjb.js +0 -1
  127. package/viewer-dist/assets/classDiagram-OUVF2IWQ-t57CRPeZ.js +0 -1
  128. package/viewer-dist/assets/classDiagram-v2-EOCWNBFH-t57CRPeZ.js +0 -1
  129. package/viewer-dist/assets/cose-bilkent-JH36ORCC-qThT2S0A.js +0 -1
  130. package/viewer-dist/assets/cynefin-VYW2F7L2-DMuuSzID.js +0 -178
  131. package/viewer-dist/assets/cynefinDiagram-TSTJHNR4-58B-tzsV.js +0 -62
  132. package/viewer-dist/assets/cytoscape.esm-CUqq0XTU.js +0 -331
  133. package/viewer-dist/assets/dagre-VKFMJZFB-DD2dvjEA.js +0 -4
  134. package/viewer-dist/assets/defaultLocale-DX6XiGOO.js +0 -1
  135. package/viewer-dist/assets/diagram-FQU43EPY-BwhXWJOe.js +0 -3
  136. package/viewer-dist/assets/diagram-G47NLZAW-Bvw3coaF.js +0 -24
  137. package/viewer-dist/assets/diagram-NH7WQ7WH-Cug3_TDj.js +0 -24
  138. package/viewer-dist/assets/diagram-OA4YK3LP-COuB13FS.js +0 -30
  139. package/viewer-dist/assets/diagram-WEI45ONY-Cs9bIVJ-.js +0 -41
  140. package/viewer-dist/assets/ebnfDiagram-CCIWWBDH-DNxW5fFn.js +0 -1
  141. package/viewer-dist/assets/erDiagram-Q63AITRT-CoxCZQYq.js +0 -85
  142. package/viewer-dist/assets/flowDiagram-23GEKE2U-DDOkOM11.js +0 -156
  143. package/viewer-dist/assets/ganttDiagram-NO4QXBWP-BMIv-Vup.js +0 -292
  144. package/viewer-dist/assets/gitGraphDiagram-IHSO6WYX-CaYRI7Ti.js +0 -106
  145. package/viewer-dist/assets/graph-C2PyVmSI.js +0 -1
  146. package/viewer-dist/assets/index-DPa56qLF.js +0 -430
  147. package/viewer-dist/assets/index-sJB3TFqL.css +0 -1
  148. package/viewer-dist/assets/infoDiagram-FWYZ7A6U-CG1-XeBO.js +0 -2
  149. package/viewer-dist/assets/init-Gi6I4Gst.js +0 -1
  150. package/viewer-dist/assets/ishikawaDiagram-FXEZZL3T-BAaIgDfG.js +0 -70
  151. package/viewer-dist/assets/journeyDiagram-5HDEW3XC-oPpLTcMj.js +0 -139
  152. package/viewer-dist/assets/kanban-definition-HUTT4EX6-wplcQi9I.js +0 -89
  153. package/viewer-dist/assets/katex-C5jXJg4s.js +0 -257
  154. package/viewer-dist/assets/layout-HEHzrzvT.js +0 -1
  155. package/viewer-dist/assets/linear-3o0ZqjSV.js +0 -1
  156. package/viewer-dist/assets/map-BQHxRNoK.js +0 -1
  157. package/viewer-dist/assets/mindmap-definition-LN4V7U3C-FkdX9xoS.js +0 -96
  158. package/viewer-dist/assets/ordinal-Cboi1Yqb.js +0 -1
  159. package/viewer-dist/assets/pegDiagram-2B236MQR-UcxUgXaX.js +0 -1
  160. package/viewer-dist/assets/pieDiagram-ENE6RG2P-BEujiO1u.js +0 -39
  161. package/viewer-dist/assets/quadrantDiagram-ABIIQ3AL-BsWx4RNa.js +0 -7
  162. package/viewer-dist/assets/railroadDiagram-RFXS5EU6-CaiR8155.js +0 -1
  163. package/viewer-dist/assets/requirementDiagram-TGXJPOKE-B7WepZjB.js +0 -84
  164. package/viewer-dist/assets/sankeyDiagram-HTMAVEWB-D2ys-GcR.js +0 -40
  165. package/viewer-dist/assets/sequenceDiagram-DBY2YBRQ-BCx5Lqm4.js +0 -162
  166. package/viewer-dist/assets/sizeCapture-X5ZJPWSS-CdyWDUKU.js +0 -1
  167. package/viewer-dist/assets/stateDiagram-2N3HPSRC-CKjHd02p.js +0 -1
  168. package/viewer-dist/assets/stateDiagram-v2-6OUMAXLB-oQDdTlVJ.js +0 -1
  169. package/viewer-dist/assets/swimlanes-5IMT3BWC-wE7K0Eo8.js +0 -2
  170. package/viewer-dist/assets/swimlanesDiagram-G3AALYLV-Axc7yQiy.js +0 -8
  171. package/viewer-dist/assets/timeline-definition-FHXFAJF6-B9iZKy9Y.js +0 -120
  172. package/viewer-dist/assets/vennDiagram-L72KCM5P-CIMukQYN.js +0 -34
  173. package/viewer-dist/assets/wardleyDiagram-EHGQE667-JZnnBRHP.js +0 -78
  174. package/viewer-dist/assets/xychartDiagram-FW5EYKEG-BphHZiLL.js +0 -7
@@ -0,0 +1,106 @@
1
+ import{t as e}from"./chunk-JWPE2WC7-COMTgl4A.js";import{t}from"./chunk-2Q5K7J3B-DKYFIUDS.js";import{Bn as n,Cn as r,En as i,Hn as a,K as o,Ln as s,Qn as c,Rn as l,Sn as u,Tn as d,V as f,gn as p,pn as m,q as h,tr as g,vn as _,wn as v,xn as y}from"./index-LgGsGSUh.js";import{n as b}from"./mermaid-parser.core-D9IKLdIu.js";var x={NORMAL:0,REVERSE:1,HIGHLIGHT:2,MERGE:3,CHERRY_PICK:4},ee=y.gitGraph,S=g(()=>f({...ee,...v().gitGraph}),`getConfig`),C=new t(()=>{let e=S(),t=e.mainBranchName,n=e.mainBranchOrder;return{mainBranchName:t,commits:new Map,head:null,branchConfig:new Map([[t,{name:t,order:n}]]),branches:new Map([[t,null]]),currBranch:t,direction:`LR`,seq:0,options:{}}});function w(){return o({length:7})}g(w,`getID`);function T(e,t){let n=Object.create(null);return e.reduce((e,r)=>{let i=t(r);return n[i]||(n[i]=!0,e.push(r)),e},[])}g(T,`uniqBy`);var te=g(function(e){C.records.direction=e},`setDirection`),ne=g(function(e){c.debug(`options str`,e),e=e?.trim(),e||=`{}`;try{C.records.options=JSON.parse(e)}catch(e){c.error(`error while parsing gitGraph options`,e.message)}},`setOptions`),re=g(function(){return C.records.options},`getOptions`),ie=g(function(e){let t=e.msg,n=e.id,r=e.type,i=e.tags;c.info(`commit`,t,n,r,i),c.debug(`Entering commit:`,t,n,r,i);let a=S();n=_.sanitizeText(n,a),t=_.sanitizeText(t,a),i=i?.map(e=>_.sanitizeText(e,a));let o={id:n||C.records.seq+`-`+w(),message:t,seq:C.records.seq++,type:r??x.NORMAL,tags:i??[],parents:C.records.head==null?[]:[C.records.head.id],branch:C.records.currBranch};C.records.head=o,c.info(`main branch`,a.mainBranchName),C.records.commits.has(o.id)&&c.warn(`Commit ID ${o.id} already exists`),C.records.commits.set(o.id,o),C.records.branches.set(C.records.currBranch,o.id),c.debug(`in pushCommit `+o.id)},`commit`),ae=g(function(e){let t=e.name,n=e.order;if(t=_.sanitizeText(t,S()),C.records.branches.has(t))throw Error(`Trying to create an existing branch. (Help: Either use a new name if you want create a new branch or try using "checkout ${t}")`);C.records.branches.set(t,C.records.head==null?null:C.records.head.id),C.records.branchConfig.set(t,{name:t,order:n}),E(t),c.debug(`in createBranch`)},`branch`),oe=g(e=>{let t=e.branch,n=e.id,r=e.type,i=e.tags,a=S();t=_.sanitizeText(t,a),n&&=_.sanitizeText(n,a);let o=C.records.branches.get(C.records.currBranch),s=C.records.branches.get(t),l=o?C.records.commits.get(o):void 0,u=s?C.records.commits.get(s):void 0;if(l&&u&&l.branch===t)throw Error(`Cannot merge branch '${t}' into itself.`);if(C.records.currBranch===t){let e=Error(`Incorrect usage of "merge". Cannot merge a branch to itself`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch abc`]},e}if(l===void 0||!l){let e=Error(`Incorrect usage of "merge". Current branch (${C.records.currBranch})has no commits`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`commit`]},e}if(!C.records.branches.has(t)){let e=Error(`Incorrect usage of "merge". Branch to be merged (`+t+`) does not exist`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch ${t}`]},e}if(u===void 0||!u){let e=Error(`Incorrect usage of "merge". Branch to be merged (`+t+`) has no commits`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`"commit"`]},e}if(l===u){let e=Error(`Incorrect usage of "merge". Both branches have same head`);throw e.hash={text:`merge ${t}`,token:`merge ${t}`,expected:[`branch abc`]},e}if(n&&C.records.commits.has(n)){let e=Error(`Incorrect usage of "merge". Commit with id:`+n+` already exists, use different custom id`);throw e.hash={text:`merge ${t} ${n} ${r} ${i?.join(` `)}`,token:`merge ${t} ${n} ${r} ${i?.join(` `)}`,expected:[`merge ${t} ${n}_UNIQUE ${r} ${i?.join(` `)}`]},e}let d=s||``,f={id:n||`${C.records.seq}-${w()}`,message:`merged branch ${t} into ${C.records.currBranch}`,seq:C.records.seq++,parents:C.records.head==null?[]:[C.records.head.id,d],branch:C.records.currBranch,type:x.MERGE,customType:r,customId:!!n,tags:i??[]};C.records.head=f,C.records.commits.set(f.id,f),C.records.branches.set(C.records.currBranch,f.id),c.debug(C.records.branches),c.debug(`in mergeBranch`)},`merge`),se=g(function(e){let t=e.id,n=e.targetId,r=e.tags,i=e.parent;c.debug(`Entering cherryPick:`,t,n,r);let a=S();if(t=_.sanitizeText(t,a),n=_.sanitizeText(n,a),r=r?.map(e=>_.sanitizeText(e,a)),i=_.sanitizeText(i,a),!t||!C.records.commits.has(t)){let e=Error(`Incorrect usage of "cherryPick". Source commit id should exist and provided`);throw e.hash={text:`cherryPick ${t} ${n}`,token:`cherryPick ${t} ${n}`,expected:[`cherry-pick abc`]},e}let o=C.records.commits.get(t);if(o===void 0||!o)throw Error(`Incorrect usage of "cherryPick". Source commit id should exist and provided`);if(i&&!(Array.isArray(o.parents)&&o.parents.includes(i)))throw Error(`Invalid operation: The specified parent commit is not an immediate parent of the cherry-picked commit.`);let s=o.branch;if(o.type===x.MERGE&&!i)throw Error(`Incorrect usage of cherry-pick: If the source commit is a merge commit, an immediate parent commit must be specified.`);if(!n||!C.records.commits.has(n)){if(s===C.records.currBranch){let e=Error(`Incorrect usage of "cherryPick". Source commit is already on current branch`);throw e.hash={text:`cherryPick ${t} ${n}`,token:`cherryPick ${t} ${n}`,expected:[`cherry-pick abc`]},e}let e=C.records.branches.get(C.records.currBranch);if(e===void 0||!e){let e=Error(`Incorrect usage of "cherry-pick". Current branch (${C.records.currBranch})has no commits`);throw e.hash={text:`cherryPick ${t} ${n}`,token:`cherryPick ${t} ${n}`,expected:[`cherry-pick abc`]},e}let a=C.records.commits.get(e);if(a===void 0||!a){let e=Error(`Incorrect usage of "cherry-pick". Current branch (${C.records.currBranch})has no commits`);throw e.hash={text:`cherryPick ${t} ${n}`,token:`cherryPick ${t} ${n}`,expected:[`cherry-pick abc`]},e}let l={id:C.records.seq+`-`+w(),message:`cherry-picked ${o?.message} into ${C.records.currBranch}`,seq:C.records.seq++,parents:C.records.head==null?[]:[C.records.head.id,o.id],branch:C.records.currBranch,type:x.CHERRY_PICK,tags:r?r.filter(Boolean):[`cherry-pick:${o.id}${o.type===x.MERGE?`|parent:${i}`:``}`]};C.records.head=l,C.records.commits.set(l.id,l),C.records.branches.set(C.records.currBranch,l.id),c.debug(C.records.branches),c.debug(`in cherryPick`)}},`cherryPick`),E=g(function(e){if(e=_.sanitizeText(e,S()),C.records.branches.has(e)){C.records.currBranch=e;let t=C.records.branches.get(C.records.currBranch);t===void 0||!t?C.records.head=null:C.records.head=C.records.commits.get(t)??null}else{let t=Error(`Trying to checkout branch which is not yet created. (Help try using "branch ${e}")`);throw t.hash={text:`checkout ${e}`,token:`checkout ${e}`,expected:[`branch ${e}`]},t}},`checkout`);function D(e,t,n){let r=e.indexOf(t);r===-1?e.push(n):e.splice(r,1,n)}g(D,`upsert`);function O(e){let t=e.reduce((e,t)=>e.seq>t.seq?e:t,e[0]),n=``;e.forEach(function(e){n+=e===t?` *`:` |`});let r=[n,t.id,t.seq];for(let e in C.records.branches)C.records.branches.get(e)===t.id&&r.push(e);if(c.debug(r.join(` `)),t.parents&&t.parents.length==2&&t.parents[0]&&t.parents[1]){let n=C.records.commits.get(t.parents[0]);D(e,t,n),t.parents[1]&&e.push(C.records.commits.get(t.parents[1]))}else if(t.parents.length==0)return;else if(t.parents[0]){let n=C.records.commits.get(t.parents[0]);D(e,t,n)}e=T(e,e=>e.id),O(e)}g(O,`prettyPrintCommitHistory`);var ce=g(function(){c.debug(C.records.commits),O([k()[0]])},`prettyPrint`),le=g(function(){C.reset(),p()},`clear`),ue=g(function(){return[...C.records.branchConfig.values()].map((e,t)=>e.order!==null&&e.order!==void 0?e:{...e,order:parseFloat(`0.${t}`)}).sort((e,t)=>(e.order??0)-(t.order??0)).map(({name:e})=>({name:e}))},`getBranchesAsObjArray`),de=g(function(){return C.records.branches},`getBranches`),fe=g(function(){return C.records.commits},`getCommits`),k=g(function(){let e=[...C.records.commits.values()];return e.forEach(function(e){c.debug(e.id)}),e.sort((e,t)=>e.seq-t.seq),e},`getCommitsArray`),A={commitType:x,getConfig:S,setDirection:te,setOptions:ne,getOptions:re,commit:ie,branch:ae,merge:oe,cherryPick:se,checkout:E,prettyPrint:ce,clear:le,getBranchesAsObjArray:ue,getBranches:de,getCommits:fe,getCommitsArray:k,getCurrentBranch:g(function(){return C.records.currBranch},`getCurrentBranch`),getDirection:g(function(){return C.records.direction},`getDirection`),getHead:g(function(){return C.records.head},`getHead`),setAccTitle:l,getAccTitle:r,getAccDescription:u,setAccDescription:s,setDiagramTitle:n,getDiagramTitle:i},pe=g((t,n)=>{e(t,n),t.dir&&n.setDirection(t.dir);for(let e of t.statements)me(e,n)},`populate`),me=g((e,t)=>{let n={Commit:g(e=>t.commit(he(e)),`Commit`),Branch:g(e=>t.branch(ge(e)),`Branch`),Merge:g(e=>t.merge(_e(e)),`Merge`),Checkout:g(e=>t.checkout(ve(e)),`Checkout`),CherryPicking:g(e=>t.cherryPick(ye(e)),`CherryPicking`)}[e.$type];n?n(e):c.error(`Unknown statement type: ${e.$type}`)},`parseStatement`),he=g(e=>({id:e.id,msg:e.message??``,type:e.type===void 0?x.NORMAL:x[e.type],tags:e.tags??void 0}),`parseCommit`),ge=g(e=>({name:e.name,order:e.order??0}),`parseBranch`),_e=g(e=>({branch:e.branch,id:e.id??``,type:e.type===void 0?void 0:x[e.type],tags:e.tags??void 0}),`parseMerge`),ve=g(e=>e.branch,`parseCheckout`),ye=g(e=>({id:e.id,targetId:``,tags:e.tags?.length===0?void 0:e.tags,parent:e.parent}),`parseCherryPicking`),be={parse:g(async e=>{let t=await b(`gitGraph`,e);c.debug(t),pe(t,A)},`parse`)},j=10,M=40,N=4,P=2,F=8,I=new Set([`redux`,`redux-dark`,`redux-color`,`redux-dark-color`]),L=12,R=new Set([`redux-color`,`redux-dark-color`]),xe=new Set([`dark`,`redux-dark`,`redux-dark-color`,`neo-dark`]),z=g((e,t,n=!1)=>n&&e>0?(e-1)%(t-1)+1:e%t,`calcColorIndex`),B=new Map,V=new Map,H=30,U=new Map,W=[],G=0,K=`LR`,q=g(()=>{B.clear(),V.clear(),U.clear(),G=0,W=[],K=`LR`},`clear`),J=g(e=>{let t=document.createElementNS(`http://www.w3.org/2000/svg`,`text`);return(typeof e==`string`?e.split(/\\n|\n|<br\s*\/?>/gi):e).forEach(e=>{let n=document.createElementNS(`http://www.w3.org/2000/svg`,`tspan`);n.setAttributeNS(`http://www.w3.org/XML/1998/namespace`,`xml:space`,`preserve`),n.setAttribute(`dy`,`1em`),n.setAttribute(`x`,`0`),n.setAttribute(`class`,`row`),n.textContent=e.trim(),t.appendChild(n)}),t},`drawText`),Y=g(e=>{let t,n,r;return K===`BT`?(n=g((e,t)=>e<=t,`comparisonFunc`),r=1/0):(n=g((e,t)=>e>=t,`comparisonFunc`),r=0),e.forEach(e=>{let i=K===`TB`||K==`BT`?V.get(e)?.y:V.get(e)?.x;i!==void 0&&n(i,r)&&(t=e,r=i)}),t},`findClosestParent`),Se=g(e=>{let t=``,n=1/0;return e.forEach(e=>{let r=V.get(e).y;r<=n&&(t=e,n=r)}),t||void 0},`findClosestParentBT`),Ce=g((e,t,n)=>{let r=n,i=n,a=[];e.forEach(e=>{let n=t.get(e);if(!n)throw Error(`Commit not found for key ${e}`);n.parents.length?(r=Te(n),i=Math.max(r,i)):a.push(n),Ee(n,r)}),r=i,a.forEach(e=>{De(e,r,n)}),e.forEach(e=>{let n=t.get(e);if(n?.parents.length){let e=Se(n.parents);r=V.get(e).y-M,r<=i&&(i=r);let t=B.get(n.branch).pos,a=r-j;V.set(n.id,{x:t,y:a})}})},`setParallelBTPos`),we=g(e=>{let t=Y(e.parents.filter(e=>e!==null));if(!t)throw Error(`Closest parent not found for commit ${e.id}`);let n=V.get(t)?.y;if(n===void 0)throw Error(`Closest parent position not found for commit ${e.id}`);return n},`findClosestParentPos`),Te=g(e=>we(e)+M,`calculateCommitPosition`),Ee=g((e,t)=>{let n=B.get(e.branch);if(!n)throw Error(`Branch not found for commit ${e.id}`);let r=n.pos,i=t+j;return V.set(e.id,{x:r,y:i}),{x:r,y:i}},`setCommitPosition`),De=g((e,t,n)=>{let r=B.get(e.branch);if(!r)throw Error(`Branch not found for commit ${e.id}`);let i=t+n,a=r.pos;V.set(e.id,{x:a,y:i})},`setRootPosition`),Oe=g((e,t,n,r,i,a)=>{let{theme:o}=d(),s=I.has(o??``),c=R.has(o??``),l=xe.has(o??``);if(a===x.HIGHLIGHT)e.append(`rect`).attr(`x`,n.x-10+(s?3:0)).attr(`y`,n.y-10+(s?3:0)).attr(`width`,s?14:20).attr(`height`,s?14:20).attr(`class`,`commit ${t.id} commit-highlight${z(i,F,c)} ${r}-outer`),e.append(`rect`).attr(`x`,n.x-6+(s?2:0)).attr(`y`,n.y-6+(s?2:0)).attr(`width`,s?8:12).attr(`height`,s?8:12).attr(`class`,`commit ${t.id} commit${z(i,F,c)} ${r}-inner`);else if(a===x.CHERRY_PICK)e.append(`circle`).attr(`cx`,n.x).attr(`cy`,n.y).attr(`r`,s?7:10).attr(`class`,`commit ${t.id} ${r}`),e.append(`circle`).attr(`cx`,n.x-3).attr(`cy`,n.y+2).attr(`r`,s?2.5:2.75).attr(`fill`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`),e.append(`circle`).attr(`cx`,n.x+3).attr(`cy`,n.y+2).attr(`r`,s?2.5:2.75).attr(`fill`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`),e.append(`line`).attr(`x1`,n.x+3).attr(`y1`,n.y+1).attr(`x2`,n.x).attr(`y2`,n.y-5).attr(`stroke`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`),e.append(`line`).attr(`x1`,n.x-3).attr(`y1`,n.y+1).attr(`x2`,n.x).attr(`y2`,n.y-5).attr(`stroke`,l?`#000000`:`#fff`).attr(`class`,`commit ${t.id} ${r}`);else{let o=e.append(`circle`);if(o.attr(`cx`,n.x),o.attr(`cy`,n.y),o.attr(`r`,s?7:10),o.attr(`class`,`commit ${t.id} commit${z(i,F,c)}`),a===x.MERGE){let a=e.append(`circle`);a.attr(`cx`,n.x),a.attr(`cy`,n.y),a.attr(`r`,s?5:6),a.attr(`class`,`commit ${r} ${t.id} commit${z(i,F,c)}`)}if(a===x.REVERSE){let a=e.append(`path`),o=s?4:5;a.attr(`d`,`M ${n.x-o},${n.y-o}L${n.x+o},${n.y+o}M${n.x-o},${n.y+o}L${n.x+o},${n.y-o}`).attr(`class`,`commit ${r} ${t.id} commit${z(i,F,c)}`)}}},`drawCommitBullet`),ke=g((e,t,n,r,i)=>{if(t.type!==x.CHERRY_PICK&&(t.customId&&t.type===x.MERGE||t.type!==x.MERGE)&&i.showCommitLabel){let a=e.append(`g`),o=a.insert(`rect`).attr(`class`,`commit-label-bkg`),s=a.append(`text`).attr(`x`,r).attr(`y`,n.y+25).attr(`class`,`commit-label`).text(t.id),c=s.node()?.getBBox();if(c&&(o.attr(`x`,n.posWithOffset-c.width/2-P).attr(`y`,n.y+13.5).attr(`width`,c.width+2*P).attr(`height`,c.height+2*P),K===`TB`||K===`BT`?(o.attr(`x`,n.x-(c.width+4*N+5)).attr(`y`,n.y-12),s.attr(`x`,n.x-(c.width+4*N)).attr(`y`,n.y+c.height-12)):s.attr(`x`,n.posWithOffset-c.width/2),i.rotateCommitLabel)){if(K===`TB`||K===`BT`)s.attr(`transform`,`rotate(-45, `+n.x+`, `+n.y+`)`),o.attr(`transform`,`rotate(-45, `+n.x+`, `+n.y+`)`);else{let e=-7.5-(c.width+10)/25*9.5,t=10+c.width/25*8.5;a.attr(`transform`,`translate(`+e+`, `+t+`) rotate(-45, `+r+`, `+n.y+`)`)}}}},`drawCommitLabel`),Ae=g((e,t,n,r)=>{if(t.tags.length>0){let i=0,a=0,o=0,s=[];for(let r of t.tags.reverse()){let t=e.insert(`polygon`),c=e.append(`circle`),l=e.append(`text`).attr(`y`,n.y-16-i).attr(`class`,`tag-label`).text(r),u=l.node()?.getBBox();if(!u)throw Error(`Tag bbox not found`);a=Math.max(a,u.width),o=Math.max(o,u.height),l.attr(`x`,n.posWithOffset-u.width/2),s.push({tag:l,hole:c,rect:t,yOffset:i}),i+=20}for(let{tag:e,hole:t,rect:i,yOffset:c}of s){let s=o/2,l=n.y-19.2-c;if(i.attr(`class`,`tag-label-bkg`).attr(`points`,`
2
+ ${r-a/2-N/2},${l+P}
3
+ ${r-a/2-N/2},${l-P}
4
+ ${n.posWithOffset-a/2-N},${l-s-P}
5
+ ${n.posWithOffset+a/2+N},${l-s-P}
6
+ ${n.posWithOffset+a/2+N},${l+s+P}
7
+ ${n.posWithOffset-a/2-N},${l+s+P}`),t.attr(`cy`,l).attr(`cx`,r-a/2+N/2).attr(`r`,1.5).attr(`class`,`tag-hole`),K===`TB`||K===`BT`){let o=r+c;i.attr(`class`,`tag-label-bkg`).attr(`points`,`
8
+ ${n.x},${o+2}
9
+ ${n.x},${o-2}
10
+ ${n.x+j},${o-s-2}
11
+ ${n.x+j+a+4},${o-s-2}
12
+ ${n.x+j+a+4},${o+s+2}
13
+ ${n.x+j},${o+s+2}`).attr(`transform`,`translate(12,12) rotate(45, `+n.x+`,`+r+`)`),t.attr(`cx`,n.x+N/2).attr(`cy`,o).attr(`transform`,`translate(12,12) rotate(45, `+n.x+`,`+r+`)`),e.attr(`x`,n.x+5).attr(`y`,o+3).attr(`transform`,`translate(14,14) rotate(45, `+n.x+`,`+r+`)`)}}}},`drawCommitTags`),je=g(e=>{switch(e.customType??e.type){case x.NORMAL:return`commit-normal`;case x.REVERSE:return`commit-reverse`;case x.HIGHLIGHT:return`commit-highlight`;case x.MERGE:return`commit-merge`;case x.CHERRY_PICK:return`commit-cherry-pick`;default:return`commit-normal`}},`getCommitClassType`),Me=g((e,t,n,r)=>{let i={x:0,y:0};if(e.parents.length>0){let n=Y(e.parents);if(n){let a=r.get(n)??i;return t===`TB`?a.y+M:t===`BT`?(r.get(e.id)??i).y-M:a.x+M}}else if(t===`TB`)return H;else if(t===`BT`)return(r.get(e.id)??i).y-M;else return 0;return 0},`calculatePosition`),Ne=g((e,t,n)=>{let r=K===`BT`&&n?t:t+j,i=B.get(e.branch)?.pos,a=K===`TB`||K===`BT`?B.get(e.branch)?.pos:r;if(a===void 0||i===void 0)throw Error(`Position were undefined for commit ${e.id}`);let o=I.has(d().theme??``);return{x:a,y:K===`TB`||K===`BT`?r:i+(o?L/2+1:-2),posWithOffset:r}},`getCommitPosition`),X=g((e,t,n,r)=>{let i=e.append(`g`).attr(`class`,`commit-bullets`),a=e.append(`g`).attr(`class`,`commit-labels`),o=K===`TB`||K===`BT`?H:0,s=[...t.keys()],c=r.parallelCommits??!1,l=g((e,n)=>{let r=t.get(e)?.seq,i=t.get(n)?.seq;return r!==void 0&&i!==void 0?r-i:0},`sortKeys`),u=s.sort(l);K===`BT`&&(c&&Ce(u,t,o),u=u.reverse()),u.forEach(e=>{let s=t.get(e);if(!s)throw Error(`Commit not found for key ${e}`);c&&(o=Me(s,K,o,V));let l=Ne(s,o,c);if(n){let e=je(s),t=s.customType??s.type,n=B.get(s.branch)?.index??0;Oe(i,s,l,e,n,t),ke(a,s,l,o,r),Ae(a,s,l,o)}K===`TB`||K===`BT`?V.set(s.id,{x:l.x,y:l.posWithOffset}):V.set(s.id,{x:l.posWithOffset,y:l.y}),o=K===`BT`&&c?o+M:o+M+j,o>G&&(G=o)})},`drawCommits`),Pe=g((e,t,n,r,i)=>{let a=(K===`TB`||K===`BT`?n.x<r.x:n.y<r.y)?t.branch:e.branch,o=g(e=>e.branch===a,`isOnBranchToGetCurve`),s=g(n=>n.seq>e.seq&&n.seq<t.seq,`isBetweenCommits`);return[...i.values()].some(e=>s(e)&&o(e))},`shouldRerouteArrow`),Z=g((e,t,n=0)=>{let r=e+Math.abs(e-t)/2;return n>5?r:W.every(e=>Math.abs(e-r)>=10)?(W.push(r),r):Z(e,t-Math.abs(e-t)/5,n+1)},`findLane`),Fe=g((e,t,n,r)=>{let{theme:i}=d(),a=R.has(i??``),o=V.get(t.id),s=V.get(n.id);if(o===void 0||s===void 0)throw Error(`Commit positions not found for commits ${t.id} and ${n.id}`);let c=Pe(t,n,o,s,r),l=``,u=``,f=0,p=0,m=B.get(n.branch)?.index;n.type===x.MERGE&&t.id!==n.parents[0]&&(m=B.get(t.branch)?.index);let h;if(c){l=`A 10 10, 0, 0, 0,`,u=`A 10 10, 0, 0, 1,`,f=10,p=10;let e=o.y<s.y?Z(o.y,s.y):Z(s.y,o.y),n=o.x<s.x?Z(o.x,s.x):Z(s.x,o.x);K===`TB`?o.x<s.x?h=`M ${o.x} ${o.y} L ${n-f} ${o.y} ${u} ${n} ${o.y+p} L ${n} ${s.y-f} ${l} ${n+p} ${s.y} L ${s.x} ${s.y}`:(m=B.get(t.branch)?.index,h=`M ${o.x} ${o.y} L ${n+f} ${o.y} ${l} ${n} ${o.y+p} L ${n} ${s.y-f} ${u} ${n-p} ${s.y} L ${s.x} ${s.y}`):K===`BT`?o.x<s.x?h=`M ${o.x} ${o.y} L ${n-f} ${o.y} ${l} ${n} ${o.y-p} L ${n} ${s.y+f} ${u} ${n+p} ${s.y} L ${s.x} ${s.y}`:(m=B.get(t.branch)?.index,h=`M ${o.x} ${o.y} L ${n+f} ${o.y} ${u} ${n} ${o.y-p} L ${n} ${s.y+f} ${l} ${n-p} ${s.y} L ${s.x} ${s.y}`):o.y<s.y?h=`M ${o.x} ${o.y} L ${o.x} ${e-f} ${l} ${o.x+p} ${e} L ${s.x-f} ${e} ${u} ${s.x} ${e+p} L ${s.x} ${s.y}`:(m=B.get(t.branch)?.index,h=`M ${o.x} ${o.y} L ${o.x} ${e+f} ${u} ${o.x+p} ${e} L ${s.x-f} ${e} ${l} ${s.x} ${e-p} L ${s.x} ${s.y}`)}else l=`A 20 20, 0, 0, 0,`,u=`A 20 20, 0, 0, 1,`,f=20,p=20,K===`TB`?(o.x<s.x&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y-f} ${l} ${o.x+p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${u} ${s.x} ${o.y+p} L ${s.x} ${s.y}`),o.x>s.x&&(l=`A 20 20, 0, 0, 0,`,u=`A 20 20, 0, 0, 1,`,f=20,p=20,h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y-f} ${u} ${o.x-p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x+f} ${o.y} ${l} ${s.x} ${o.y+p} L ${s.x} ${s.y}`),o.x===s.x&&(h=`M ${o.x} ${o.y} L ${s.x} ${s.y}`)):K===`BT`?(o.x<s.x&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y+f} ${u} ${o.x+p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${l} ${s.x} ${o.y-p} L ${s.x} ${s.y}`),o.x>s.x&&(l=`A 20 20, 0, 0, 0,`,u=`A 20 20, 0, 0, 1,`,f=20,p=20,h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${o.x} ${s.y+f} ${l} ${o.x-p} ${s.y} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${s.x+f} ${o.y} ${u} ${s.x} ${o.y-p} L ${s.x} ${s.y}`),o.x===s.x&&(h=`M ${o.x} ${o.y} L ${s.x} ${s.y}`)):(o.y<s.y&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${u} ${s.x} ${o.y+p} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${o.x} ${s.y-f} ${l} ${o.x+p} ${s.y} L ${s.x} ${s.y}`),o.y>s.y&&(h=n.type===x.MERGE&&t.id!==n.parents[0]?`M ${o.x} ${o.y} L ${s.x-f} ${o.y} ${l} ${s.x} ${o.y-p} L ${s.x} ${s.y}`:`M ${o.x} ${o.y} L ${o.x} ${s.y+f} ${u} ${o.x+p} ${s.y} L ${s.x} ${s.y}`),o.y===s.y&&(h=`M ${o.x} ${o.y} L ${s.x} ${s.y}`));if(h===void 0)throw Error(`Line definition not found`);e.append(`path`).attr(`d`,h).attr(`class`,`arrow arrow`+z(m,F,a))},`drawArrow`),Ie=g((e,t)=>{let n=e.append(`g`).attr(`class`,`commit-arrows`);[...t.keys()].forEach(e=>{let r=t.get(e);r.parents&&r.parents.length>0&&r.parents.forEach(e=>{Fe(n,t.get(e),r,t)})})},`drawArrows`),Le=g((e,t,n,r)=>{let{look:i,theme:a,themeVariables:o}=d(),{dropShadow:s,THEME_COLOR_LIMIT:c}=o,l=I.has(a??``),u=R.has(a??``),f=e.append(`g`);t.forEach((e,t)=>{let a=z(t,l?c:F,u),o=B.get(e.name)?.pos;if(o===void 0)throw Error(`Position not found for branch ${e.name}`);let d=K===`TB`||K===`BT`?o:l?o+L/2+1:o-2,p=f.append(`line`);p.attr(`x1`,0),p.attr(`y1`,d),p.attr(`x2`,G),p.attr(`y2`,d),p.attr(`class`,`branch branch`+a),K===`TB`?(p.attr(`y1`,H),p.attr(`x1`,o),p.attr(`y2`,G),p.attr(`x2`,o)):K===`BT`&&(p.attr(`y1`,G),p.attr(`x1`,o),p.attr(`y2`,H),p.attr(`x2`,o)),W.push(d);let m=J(e.name),h=f.insert(`rect`),g=f.insert(`g`).attr(`class`,`branchLabel`).insert(`g`).attr(`class`,`label branch-label`+a);g.node().appendChild(m);let _=m.getBBox(),v=l?0:4,y=l?16:0,b=l?L:0;i===`neo`&&h.attr(`data-look`,`neo`),h.attr(`class`,`branchLabelBkg label`+a).attr(`style`,i===`neo`?`filter:${l?`url(#${r}-drop-shadow)`:s}`:``).attr(`rx`,v).attr(`ry`,v).attr(`x`,-_.width-4-(n.rotateCommitLabel===!0?30:0)).attr(`y`,-_.height/2+10).attr(`width`,_.width+18+y).attr(`height`,_.height+4+b),g.attr(`transform`,`translate(`+(-_.width-14-(n.rotateCommitLabel===!0?30:0)+y/2)+`, `+(d-_.height/2-2)+`)`),K===`TB`?(h.attr(`x`,o-_.width/2-10).attr(`y`,0),g.attr(`transform`,`translate(`+(o-_.width/2-5)+`, 0)`),l&&(h.attr(`transform`,`translate(${-y/2-3}, ${-b-10})`),g.attr(`transform`,`translate(`+(o-_.width/2-5)+`, `+(-b*2+7)+`)`))):K===`BT`?(h.attr(`x`,o-_.width/2-10).attr(`y`,G),g.attr(`transform`,`translate(`+(o-_.width/2-5)+`, `+G+`)`),l&&(h.attr(`transform`,`translate(${-y/2-3}, ${b+10})`),g.attr(`transform`,`translate(`+(o-_.width/2-5)+`, `+(G+b*2+4)+`)`))):h.attr(`transform`,`translate(-19, `+(d-12-b/2)+`)`)})},`drawBranches`),Re=g(function(e,t,n,r,i){return B.set(e,{pos:t,index:n}),t+=50+(i?40:0)+(K===`TB`||K===`BT`?r.width/2:0),t},`setBranchPosition`),ze={draw:g(function(e,t,n,r){q(),c.debug(`in gitgraph renderer`,e+`
14
+ `,`id:`,t,n);let i=r.db;if(!i.getConfig){c.error(`getConfig method is not available on db`);return}let o=i.getConfig(),s=o.rotateCommitLabel??!1;U=i.getCommits();let l=i.getBranchesAsObjArray();K=i.getDirection();let u=m(`[id="${t}"]`),{look:f,theme:p,themeVariables:g}=d(),{useGradient:_,gradientStart:v,gradientStop:y,filterColor:b}=g;if(_){let e=u.append(`defs`).append(`linearGradient`).attr(`id`,t+`-gradient`).attr(`gradientUnits`,`objectBoundingBox`).attr(`x1`,`0%`).attr(`y1`,`0%`).attr(`x2`,`100%`).attr(`y2`,`0%`);e.append(`stop`).attr(`offset`,`0%`).attr(`stop-color`,v).attr(`stop-opacity`,1),e.append(`stop`).attr(`offset`,`100%`).attr(`stop-color`,y).attr(`stop-opacity`,1)}f===`neo`&&I.has(p??``)&&u.append(`defs`).append(`filter`).attr(`id`,t+`-drop-shadow`).attr(`height`,`130%`).attr(`width`,`130%`).append(`feDropShadow`).attr(`dx`,`4`).attr(`dy`,`4`).attr(`stdDeviation`,0).attr(`flood-opacity`,`0.06`).attr(`flood-color`,b);let x=0;l.forEach((e,t)=>{let n=J(e.name),r=u.append(`g`),i=r.insert(`g`).attr(`class`,`branchLabel`),a=i.insert(`g`).attr(`class`,`label branch-label`);a.node()?.appendChild(n);let o=n.getBBox();x=Re(e.name,x,t,o,s),a.remove(),i.remove(),r.remove()}),X(u,U,!1,o),o.showBranches&&Le(u,l,o,t),Ie(u,U),X(u,U,!0,o),h.insertTitle(u,`gitTitleText`,o.titleTopMargin??0,i.getDiagramTitle()),a(void 0,u,o.diagramPadding,o.useMaxWidth)},`draw`)},Q=8,$=new Set([`redux`,`redux-dark`,`redux-color`,`redux-dark-color`]),Be=new Set([`redux-color`,`redux-dark-color`]),Ve=new Set([`neo`,`neo-dark`]),He=new Set([`dark`,`redux-dark`,`redux-dark-color`,`neo-dark`]),Ue=new Set([`redux`,`redux-dark`,`redux-color`,`redux-dark-color`,`neo`,`neo-dark`]),We=g(e=>{let{svgId:t}=e,n=``;if(e.useGradient&&t)for(let r=0;r<e.THEME_COLOR_LIMIT;r++)n+=`
15
+ .label${r} { fill: ${e.mainBkg}; stroke: url(${t}-gradient); stroke-width: ${e.strokeWidth};}
16
+ `;return n},`genGitGraphGradient`),Ge=g(e=>{let{theme:t,themeVariables:n}=v(),{borderColorArray:r}=n,i=$.has(t);if(Ve.has(t)){let t=``;for(let n=0;n<e.THEME_COLOR_LIMIT;n++)if(n===0)t+=`
17
+ .branch-label${n} { fill: ${e.nodeBorder};}
18
+ .commit${n} { stroke: ${e.nodeBorder}; }
19
+ .commit-highlight${n} { stroke: ${e.nodeBorder}; fill: ${e.nodeBorder}; }
20
+ .arrow${n} { stroke: ${e.nodeBorder}; }
21
+ .commit-bullets { fill: ${e.nodeBorder}; }
22
+ .commit-cherry-pick${n} { stroke: ${e.nodeBorder}; }
23
+ ${We(e)}`;else{let r=n%Q;t+=`
24
+ .branch-label${n} { fill: ${e[`gitBranchLabel`+r]}; }
25
+ .commit${n} { stroke: ${e[`git`+r]}; fill: ${e[`git`+r]}; }
26
+ .commit-highlight${n} { stroke: ${e[`gitInv`+r]}; fill: ${e[`gitInv`+r]}; }
27
+ .arrow${n} { stroke: ${e[`git`+r]}; }
28
+ `}return t}if(Be.has(t)){let n=``;for(let a=0;a<e.THEME_COLOR_LIMIT;a++)if(a===0)n+=`
29
+ .branch-label${a} { fill: ${e.nodeBorder}; ${i?`font-weight:${e.noteFontWeight}`:``} }
30
+ .commit${a} { stroke: ${e.nodeBorder}; }
31
+ .commit-highlight${a} { stroke: ${e.nodeBorder}; fill: ${e.mainBkg}; }
32
+ .label${a} { fill: ${e.mainBkg}; stroke: ${e.nodeBorder}; stroke-width: ${e.strokeWidth}; ${i?`font-weight:${e.noteFontWeight}`:``} }
33
+ .arrow${a} { stroke: ${e.nodeBorder}; }
34
+ .commit-bullets { fill: ${e.nodeBorder}; }
35
+ `;else{let o=a%r.length;n+=`
36
+ .branch-label${a} { fill: ${e.nodeBorder}; ${i?`font-weight:${e.noteFontWeight}`:``} }
37
+ .commit${a} { stroke: ${r[o]}; fill: ${r[o]}; }
38
+ .commit-highlight${a} { stroke: ${r[o]}; fill: ${r[o]}; }
39
+ .label${a} { fill: ${He.has(t)?e.mainBkg:r[o]}; stroke: ${r[o]}; stroke-width: ${e.strokeWidth}; }
40
+ .arrow${a} { stroke: ${r[o]}; }
41
+ `}return n}{let t=``;for(let n=0;n<e.THEME_COLOR_LIMIT;n++)t+=`
42
+ .branch-label${n} { fill: ${e.nodeBorder}; ${i?`font-weight:${e.noteFontWeight}`:``} }
43
+ .commit${n} { stroke: ${e.nodeBorder}; }
44
+ .commit-highlight${n} { stroke: ${e.nodeBorder}; fill: ${e.nodeBorder}; }
45
+ .label${n} { fill: ${e.mainBkg}; stroke: ${e.nodeBorder}; stroke-width: ${e.strokeWidth}; ${i?`font-weight:${e.noteFontWeight}`:``}}
46
+ .arrow${n} { stroke: ${e.nodeBorder}; }
47
+ .commit-bullets { fill: ${e.nodeBorder}; }
48
+ .commit-cherry-pick${n} { stroke: ${e.nodeBorder}; }
49
+ `;return t}},`genColor`),Ke=g(e=>`${Array.from({length:e.THEME_COLOR_LIMIT},(e,t)=>t).map(t=>{let n=t%Q;return`
50
+ .branch-label${t} { fill: ${e[`gitBranchLabel`+n]}; }
51
+ .commit${t} { stroke: ${e[`git`+n]}; fill: ${e[`git`+n]}; }
52
+ .commit-highlight${t} { stroke: ${e[`gitInv`+n]}; fill: ${e[`gitInv`+n]}; }
53
+ .label${t} { fill: ${e[`git`+n]}; }
54
+ .arrow${t} { stroke: ${e[`git`+n]}; }
55
+ `}).join(`
56
+ `)}`,`normalTheme`),qe={parser:be,db:A,renderer:ze,styles:g(e=>{let{theme:t}=v(),n=Ue.has(t);return`
57
+ .commit-id,
58
+ .commit-msg,
59
+ .branch-label {
60
+ fill: lightgrey;
61
+ color: lightgrey;
62
+ font-family: 'trebuchet ms', verdana, arial, sans-serif;
63
+ font-family: var(--mermaid-font-family);
64
+ }
65
+
66
+ ${n?Ge(e):Ke(e)}
67
+
68
+ .branch {
69
+ stroke-width: ${e.strokeWidth};
70
+ stroke: ${e.commitLineColor??e.lineColor};
71
+ stroke-dasharray: ${n?`4 2`:`2`};
72
+ }
73
+ .commit-label { font-size: ${e.commitLabelFontSize}; fill: ${n?e.nodeBorder:e.commitLabelColor}; ${n?`font-weight:${e.noteFontWeight};`:``}}
74
+ .commit-label-bkg { font-size: ${e.commitLabelFontSize}; fill: ${n?`transparent`:e.commitLabelBackground}; opacity: ${n?``:.5}; }
75
+ .tag-label { font-size: ${e.tagLabelFontSize}; fill: ${e.tagLabelColor};}
76
+ .tag-label-bkg { fill: ${n?e.mainBkg:e.tagLabelBackground}; stroke: ${n?e.nodeBorder:e.tagLabelBorder}; ${n?`filter:${e.dropShadow}`:``} }
77
+ .tag-hole { fill: ${e.textColor}; }
78
+
79
+ .commit-merge {
80
+ stroke: ${n?e.mainBkg:e.primaryColor};
81
+ fill: ${n?e.mainBkg:e.primaryColor};
82
+ }
83
+ .commit-reverse {
84
+ stroke: ${n?e.mainBkg:e.primaryColor};
85
+ fill: ${n?e.mainBkg:e.primaryColor};
86
+ stroke-width: ${n?e.strokeWidth:3};
87
+ }
88
+ .commit-highlight-outer {
89
+ }
90
+ .commit-highlight-inner {
91
+ stroke: ${n?e.mainBkg:e.primaryColor};
92
+ fill: ${n?e.mainBkg:e.primaryColor};
93
+ }
94
+
95
+ .arrow {
96
+ /* Intentional: neo themes keep the bold 8px arrow (like classic themes); only redux-geometry themes use the thinner options.strokeWidth. */
97
+ stroke-width: ${$.has(t)?e.strokeWidth:8};
98
+ stroke-linecap: round;
99
+ fill: none
100
+ }
101
+ .gitTitleText {
102
+ text-anchor: middle;
103
+ font-size: 18px;
104
+ fill: ${e.textColor};
105
+ }
106
+ `},`getStyles`)};export{qe as diagram};
@@ -0,0 +1 @@
1
+ var e=typeof global==`object`&&global&&global.Object===Object&&global,t=typeof self==`object`&&self&&self.Object===Object&&self,n=e||t||Function(`return this`)(),r=n.Symbol,i=Object.prototype,a=i.hasOwnProperty,o=i.toString,s=r?r.toStringTag:void 0;function c(e){var t=a.call(e,s),n=e[s];try{e[s]=void 0;var r=!0}catch{}var i=o.call(e);return r&&(t?e[s]=n:delete e[s]),i}var l=Object.prototype.toString;function u(e){return l.call(e)}var d=`[object Null]`,f=`[object Undefined]`,p=r?r.toStringTag:void 0;function m(e){return e==null?e===void 0?f:d:p&&p in Object(e)?c(e):u(e)}function h(e){return typeof e==`object`&&!!e}var g=`[object Symbol]`;function _(e){return typeof e==`symbol`||h(e)&&m(e)==g}function v(e,t){for(var n=-1,r=e==null?0:e.length,i=Array(r);++n<r;)i[n]=t(e[n],n,e);return i}var y=Array.isArray,ee=1/0,te=r?r.prototype:void 0,ne=te?te.toString:void 0;function re(e){if(typeof e==`string`)return e;if(y(e))return v(e,re)+``;if(_(e))return ne?ne.call(e):``;var t=e+``;return t==`0`&&1/e==-ee?`-0`:t}function b(e){var t=typeof e;return e!=null&&(t==`object`||t==`function`)}function x(e){return e}var ie=`[object AsyncFunction]`,ae=`[object Function]`,oe=`[object GeneratorFunction]`,se=`[object Proxy]`;function S(e){if(!b(e))return!1;var t=m(e);return t==ae||t==oe||t==ie||t==se}var ce=n[`__core-js_shared__`],le=function(){var e=/[^.]+$/.exec(ce&&ce.keys&&ce.keys.IE_PROTO||``);return e?`Symbol(src)_1.`+e:``}();function ue(e){return!!le&&le in e}var de=Function.prototype.toString;function C(e){if(e!=null){try{return de.call(e)}catch{}try{return e+``}catch{}}return``}var fe=/[\\^$.*+?()[\]{}|]/g,pe=/^\[object .+?Constructor\]$/,me=Function.prototype,he=Object.prototype,ge=me.toString,_e=he.hasOwnProperty,ve=RegExp(`^`+ge.call(_e).replace(fe,`\\$&`).replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,`$1.*?`)+`$`);function ye(e){return!b(e)||ue(e)?!1:(S(e)?ve:pe).test(C(e))}function be(e,t){return e?.[t]}function w(e,t){var n=be(e,t);return ye(n)?n:void 0}var xe=w(n,`WeakMap`);function Se(e,t,n){switch(n.length){case 0:return e.call(t);case 1:return e.call(t,n[0]);case 2:return e.call(t,n[0],n[1]);case 3:return e.call(t,n[0],n[1],n[2])}return e.apply(t,n)}function Ce(){}var we=800,Te=16,Ee=Date.now;function De(e){var t=0,n=0;return function(){var r=Ee(),i=Te-(r-n);if(n=r,i>0){if(++t>=we)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}function T(e){return function(){return e}}var Oe=function(){try{var e=w(Object,`defineProperty`);return e({},``,{}),e}catch{}}(),ke=De(Oe?function(e,t){return Oe(e,`toString`,{configurable:!0,enumerable:!1,value:T(t),writable:!0})}:x);function Ae(e,t){for(var n=-1,r=e==null?0:e.length;++n<r&&t(e[n],n,e)!==!1;);return e}function je(e,t,n,r){for(var i=e.length,a=n+(r?1:-1);r?a--:++a<i;)if(t(e[a],a,e))return a;return-1}function Me(e){return e!==e}function Ne(e,t,n){for(var r=n-1,i=e.length;++r<i;)if(e[r]===t)return r;return-1}function Pe(e,t,n){return t===t?Ne(e,t,n):je(e,Me,n)}function Fe(e,t){return!!(e!=null&&e.length)&&Pe(e,t,0)>-1}var Ie=0x1fffffffffffff,Le=/^(?:0|[1-9]\d*)$/;function Re(e,t){var n=typeof e;return t??=Ie,!!t&&(n==`number`||n!=`symbol`&&Le.test(e))&&e>-1&&e%1==0&&e<t}function ze(e,t){return e===t||e!==e&&t!==t}var Be=Math.max;function Ve(e,t,n){return t=Be(t===void 0?e.length-1:t,0),function(){for(var r=arguments,i=-1,a=Be(r.length-t,0),o=Array(a);++i<a;)o[i]=r[t+i];i=-1;for(var s=Array(t+1);++i<t;)s[i]=r[i];return s[t]=n(o),Se(e,this,s)}}function He(e,t){return ke(Ve(e,t,x),e+``)}var Ue=0x1fffffffffffff;function We(e){return typeof e==`number`&&e>-1&&e%1==0&&e<=Ue}function E(e){return e!=null&&We(e.length)&&!S(e)}var Ge=Object.prototype;function Ke(e){var t=e&&e.constructor;return e===(typeof t==`function`&&t.prototype||Ge)}function qe(e,t){for(var n=-1,r=Array(e);++n<e;)r[n]=t(n);return r}var Je=`[object Arguments]`;function Ye(e){return h(e)&&m(e)==Je}var Xe=Object.prototype,Ze=Xe.hasOwnProperty,Qe=Xe.propertyIsEnumerable,D=Ye(function(){return arguments}())?Ye:function(e){return h(e)&&Ze.call(e,`callee`)&&!Qe.call(e,`callee`)};function $e(){return!1}var et=typeof exports==`object`&&exports&&!exports.nodeType&&exports,tt=et&&typeof module==`object`&&module&&!module.nodeType&&module,nt=tt&&tt.exports===et?n.Buffer:void 0,O=(nt?nt.isBuffer:void 0)||$e,rt=`[object Arguments]`,it=`[object Array]`,at=`[object Boolean]`,ot=`[object Date]`,st=`[object Error]`,ct=`[object Function]`,lt=`[object Map]`,ut=`[object Number]`,dt=`[object Object]`,ft=`[object RegExp]`,pt=`[object Set]`,mt=`[object String]`,ht=`[object WeakMap]`,gt=`[object ArrayBuffer]`,_t=`[object DataView]`,vt=`[object Float32Array]`,yt=`[object Float64Array]`,bt=`[object Int8Array]`,xt=`[object Int16Array]`,St=`[object Int32Array]`,Ct=`[object Uint8Array]`,wt=`[object Uint8ClampedArray]`,Tt=`[object Uint16Array]`,Et=`[object Uint32Array]`,k={};k[vt]=k[yt]=k[bt]=k[xt]=k[St]=k[Ct]=k[wt]=k[Tt]=k[Et]=!0,k[rt]=k[it]=k[gt]=k[at]=k[_t]=k[ot]=k[st]=k[ct]=k[lt]=k[ut]=k[dt]=k[ft]=k[pt]=k[mt]=k[ht]=!1;function Dt(e){return h(e)&&We(e.length)&&!!k[m(e)]}function Ot(e){return function(t){return e(t)}}var kt=typeof exports==`object`&&exports&&!exports.nodeType&&exports,A=kt&&typeof module==`object`&&module&&!module.nodeType&&module,At=A&&A.exports===kt&&e.process,jt=function(){try{return A&&A.require&&A.require(`util`).types||At&&At.binding&&At.binding(`util`)}catch{}}(),Mt=jt&&jt.isTypedArray,j=Mt?Ot(Mt):Dt,Nt=Object.prototype.hasOwnProperty;function Pt(e,t){var n=y(e),r=!n&&D(e),i=!n&&!r&&O(e),a=!n&&!r&&!i&&j(e),o=n||r||i||a,s=o?qe(e.length,String):[],c=s.length;for(var l in e)(t||Nt.call(e,l))&&!(o&&(l==`length`||i&&(l==`offset`||l==`parent`)||a&&(l==`buffer`||l==`byteLength`||l==`byteOffset`)||Re(l,c)))&&s.push(l);return s}function Ft(e,t){return function(n){return e(t(n))}}var It=Ft(Object.keys,Object),Lt=Object.prototype.hasOwnProperty;function Rt(e){if(!Ke(e))return It(e);var t=[];for(var n in Object(e))Lt.call(e,n)&&n!=`constructor`&&t.push(n);return t}function M(e){return E(e)?Pt(e):Rt(e)}var zt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Bt=/^\w*$/;function Vt(e,t){if(y(e))return!1;var n=typeof e;return n==`number`||n==`symbol`||n==`boolean`||e==null||_(e)?!0:Bt.test(e)||!zt.test(e)||t!=null&&e in Object(t)}var N=w(Object,`create`),Ht=`__lodash_hash_undefined__`,Ut=Object.prototype.hasOwnProperty,Wt=Object.prototype.hasOwnProperty,Gt=`__lodash_hash_undefined__`;function P(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}P.prototype.clear=function(){this.__data__=N?N(null):{},this.size=0},P.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=+!!t,t},P.prototype.get=function(e){var t=this.__data__;if(N){var n=t[e];return n===Ht?void 0:n}return Ut.call(t,e)?t[e]:void 0},P.prototype.has=function(e){var t=this.__data__;return N?t[e]!==void 0:Wt.call(t,e)},P.prototype.set=function(e,t){var n=this.__data__;return this.size+=+!this.has(e),n[e]=N&&t===void 0?Gt:t,this};function F(e,t){for(var n=e.length;n--;)if(ze(e[n][0],t))return n;return-1}var Kt=Array.prototype.splice;function I(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}I.prototype.clear=function(){this.__data__=[],this.size=0},I.prototype.delete=function(e){var t=this.__data__,n=F(t,e);return n<0?!1:(n==t.length-1?t.pop():Kt.call(t,n,1),--this.size,!0)},I.prototype.get=function(e){var t=this.__data__,n=F(t,e);return n<0?void 0:t[n][1]},I.prototype.has=function(e){return F(this.__data__,e)>-1},I.prototype.set=function(e,t){var n=this.__data__,r=F(n,e);return r<0?(++this.size,n.push([e,t])):n[r][1]=t,this};var L=w(n,`Map`);function qt(e){var t=typeof e;return t==`string`||t==`number`||t==`symbol`||t==`boolean`?e!==`__proto__`:e===null}function R(e,t){var n=e.__data__;return qt(t)?n[typeof t==`string`?`string`:`hash`]:n.map}function z(e){var t=-1,n=e==null?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}z.prototype.clear=function(){this.size=0,this.__data__={hash:new P,map:new(L||I),string:new P}},z.prototype.delete=function(e){var t=R(this,e).delete(e);return this.size-=+!!t,t},z.prototype.get=function(e){return R(this,e).get(e)},z.prototype.has=function(e){return R(this,e).has(e)},z.prototype.set=function(e,t){var n=R(this,e),r=n.size;return n.set(e,t),this.size+=n.size==r?0:1,this};var Jt=`Expected a function`;function Yt(e,t){if(typeof e!=`function`||t!=null&&typeof t!=`function`)throw TypeError(Jt);var n=function(){var r=arguments,i=t?t.apply(this,r):r[0],a=n.cache;if(a.has(i))return a.get(i);var o=e.apply(this,r);return n.cache=a.set(i,o)||a,o};return n.cache=new(Yt.Cache||z),n}Yt.Cache=z;var Xt=500;function Zt(e){var t=Yt(e,function(e){return n.size===Xt&&n.clear(),e}),n=t.cache;return t}var Qt=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,$t=/\\(\\)?/g,en=Zt(function(e){var t=[];return e.charCodeAt(0)===46&&t.push(``),e.replace(Qt,function(e,n,r,i){t.push(r?i.replace($t,`$1`):n||e)}),t});function tn(e){return e==null?``:re(e)}function nn(e,t){return y(e)?e:Vt(e,t)?[e]:en(tn(e))}var rn=1/0;function B(e){if(typeof e==`string`||_(e))return e;var t=e+``;return t==`0`&&1/e==-rn?`-0`:t}function an(e,t){t=nn(t,e);for(var n=0,r=t.length;e!=null&&n<r;)e=e[B(t[n++])];return n&&n==r?e:void 0}function on(e,t,n){var r=e==null?void 0:an(e,t);return r===void 0?n:r}function sn(e,t){for(var n=-1,r=t.length,i=e.length;++n<r;)e[i+n]=t[n];return e}var cn=r?r.isConcatSpreadable:void 0;function ln(e){return y(e)||D(e)||!!(cn&&e&&e[cn])}function un(e,t,n,r,i){var a=-1,o=e.length;for(n||=ln,i||=[];++a<o;){var s=e[a];t>0&&n(s)?t>1?un(s,t-1,n,r,i):sn(i,s):r||(i[i.length]=s)}return i}function dn(e,t,n,r){var i=-1,a=e==null?0:e.length;for(r&&a&&(n=e[++i]);++i<a;)n=t(n,e[i],i,e);return n}var fn=200;function V(e){var t=this.__data__=new I(e);this.size=t.size}V.prototype.clear=function(){this.__data__=new I,this.size=0},V.prototype.delete=function(e){var t=this.__data__,n=t.delete(e);return this.size=t.size,n},V.prototype.get=function(e){return this.__data__.get(e)},V.prototype.has=function(e){return this.__data__.has(e)},V.prototype.set=function(e,t){var n=this.__data__;if(n instanceof I){var r=n.__data__;if(!L||r.length<fn-1)return r.push([e,t]),this.size=++n.size,this;n=this.__data__=new z(r)}return n.set(e,t),this.size=n.size,this};function pn(e,t){for(var n=-1,r=e==null?0:e.length,i=0,a=[];++n<r;){var o=e[n];t(o,n,e)&&(a[i++]=o)}return a}function mn(){return[]}var hn=Object.prototype.propertyIsEnumerable,gn=Object.getOwnPropertySymbols,_n=gn?function(e){return e==null?[]:(e=Object(e),pn(gn(e),function(t){return hn.call(e,t)}))}:mn;function vn(e,t,n){var r=t(e);return y(e)?r:sn(r,n(e))}function yn(e){return vn(e,M,_n)}var bn=w(n,`DataView`),xn=w(n,`Promise`),H=w(n,`Set`),Sn=`[object Map]`,Cn=`[object Object]`,wn=`[object Promise]`,Tn=`[object Set]`,En=`[object WeakMap]`,Dn=`[object DataView]`,On=C(bn),kn=C(L),An=C(xn),jn=C(H),Mn=C(xe),U=m;(bn&&U(new bn(new ArrayBuffer(1)))!=Dn||L&&U(new L)!=Sn||xn&&U(xn.resolve())!=wn||H&&U(new H)!=Tn||xe&&U(new xe)!=En)&&(U=function(e){var t=m(e),n=t==Cn?e.constructor:void 0,r=n?C(n):``;if(r)switch(r){case On:return Dn;case kn:return Sn;case An:return wn;case jn:return Tn;case Mn:return En}return t});var W=U,Nn=n.Uint8Array,Pn=`__lodash_hash_undefined__`;function G(e){var t=-1,n=e==null?0:e.length;for(this.__data__=new z;++t<n;)this.add(e[t])}G.prototype.add=G.prototype.push=function(e){return this.__data__.set(e,Pn),this},G.prototype.has=function(e){return this.__data__.has(e)};function Fn(e,t){for(var n=-1,r=e==null?0:e.length;++n<r;)if(t(e[n],n,e))return!0;return!1}function In(e,t){return e.has(t)}var Ln=1,Rn=2;function zn(e,t,n,r,i,a){var o=n&Ln,s=e.length,c=t.length;if(s!=c&&!(o&&c>s))return!1;var l=a.get(e),u=a.get(t);if(l&&u)return l==t&&u==e;var d=-1,f=!0,p=n&Rn?new G:void 0;for(a.set(e,t),a.set(t,e);++d<s;){var m=e[d],h=t[d];if(r)var g=o?r(h,m,d,t,e,a):r(m,h,d,e,t,a);if(g!==void 0){if(g)continue;f=!1;break}if(p){if(!Fn(t,function(e,t){if(!In(p,t)&&(m===e||i(m,e,n,r,a)))return p.push(t)})){f=!1;break}}else if(!(m===h||i(m,h,n,r,a))){f=!1;break}}return a.delete(e),a.delete(t),f}function Bn(e){var t=-1,n=Array(e.size);return e.forEach(function(e,r){n[++t]=[r,e]}),n}function Vn(e){var t=-1,n=Array(e.size);return e.forEach(function(e){n[++t]=e}),n}var Hn=1,Un=2,Wn=`[object Boolean]`,Gn=`[object Date]`,Kn=`[object Error]`,qn=`[object Map]`,Jn=`[object Number]`,Yn=`[object RegExp]`,Xn=`[object Set]`,Zn=`[object String]`,Qn=`[object Symbol]`,$n=`[object ArrayBuffer]`,er=`[object DataView]`,tr=r?r.prototype:void 0,nr=tr?tr.valueOf:void 0;function rr(e,t,n,r,i,a,o){switch(n){case er:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case $n:return!(e.byteLength!=t.byteLength||!a(new Nn(e),new Nn(t)));case Wn:case Gn:case Jn:return ze(+e,+t);case Kn:return e.name==t.name&&e.message==t.message;case Yn:case Zn:return e==t+``;case qn:var s=Bn;case Xn:var c=r&Hn;if(s||=Vn,e.size!=t.size&&!c)return!1;var l=o.get(e);if(l)return l==t;r|=Un,o.set(e,t);var u=zn(s(e),s(t),r,i,a,o);return o.delete(e),u;case Qn:if(nr)return nr.call(e)==nr.call(t)}return!1}var ir=1,ar=Object.prototype.hasOwnProperty;function or(e,t,n,r,i,a){var o=n&ir,s=yn(e),c=s.length;if(c!=yn(t).length&&!o)return!1;for(var l=c;l--;){var u=s[l];if(!(o?u in t:ar.call(t,u)))return!1}var d=a.get(e),f=a.get(t);if(d&&f)return d==t&&f==e;var p=!0;a.set(e,t),a.set(t,e);for(var m=o;++l<c;){u=s[l];var h=e[u],g=t[u];if(r)var _=o?r(g,h,u,t,e,a):r(h,g,u,e,t,a);if(!(_===void 0?h===g||i(h,g,n,r,a):_)){p=!1;break}m||=u==`constructor`}if(p&&!m){var v=e.constructor,y=t.constructor;v!=y&&`constructor`in e&&`constructor`in t&&!(typeof v==`function`&&v instanceof v&&typeof y==`function`&&y instanceof y)&&(p=!1)}return a.delete(e),a.delete(t),p}var sr=1,cr=`[object Arguments]`,lr=`[object Array]`,K=`[object Object]`,ur=Object.prototype.hasOwnProperty;function dr(e,t,n,r,i,a){var o=y(e),s=y(t),c=o?lr:W(e),l=s?lr:W(t);c=c==cr?K:c,l=l==cr?K:l;var u=c==K,d=l==K,f=c==l;if(f&&O(e)){if(!O(t))return!1;o=!0,u=!1}if(f&&!u)return a||=new V,o||j(e)?zn(e,t,n,r,i,a):rr(e,t,c,n,r,i,a);if(!(n&sr)){var p=u&&ur.call(e,`__wrapped__`),m=d&&ur.call(t,`__wrapped__`);if(p||m){var h=p?e.value():e,g=m?t.value():t;return a||=new V,i(h,g,n,r,a)}}return f?(a||=new V,or(e,t,n,r,i,a)):!1}function fr(e,t,n,r,i){return e===t?!0:e==null||t==null||!h(e)&&!h(t)?e!==e&&t!==t:dr(e,t,n,r,fr,i)}var pr=1,mr=2;function hr(e,t,n,r){var i=n.length,a=i,o=!r;if(e==null)return!a;for(e=Object(e);i--;){var s=n[i];if(o&&s[2]?s[1]!==e[s[0]]:!(s[0]in e))return!1}for(;++i<a;){s=n[i];var c=s[0],l=e[c],u=s[1];if(o&&s[2]){if(l===void 0&&!(c in e))return!1}else{var d=new V;if(r)var f=r(l,u,c,e,t,d);if(!(f===void 0?fr(u,l,pr|mr,r,d):f))return!1}}return!0}function gr(e){return e===e&&!b(e)}function _r(e){for(var t=M(e),n=t.length;n--;){var r=t[n],i=e[r];t[n]=[r,i,gr(i)]}return t}function vr(e,t){return function(n){return n!=null&&n[e]===t&&(t!==void 0||e in Object(n))}}function yr(e){var t=_r(e);return t.length==1&&t[0][2]?vr(t[0][0],t[0][1]):function(n){return n===e||hr(n,e,t)}}function br(e,t){return e!=null&&t in Object(e)}function xr(e,t,n){t=nn(t,e);for(var r=-1,i=t.length,a=!1;++r<i;){var o=B(t[r]);if(!(a=e!=null&&n(e,o)))break;e=e[o]}return a||++r!=i?a:(i=e==null?0:e.length,!!i&&We(i)&&Re(o,i)&&(y(e)||D(e)))}function Sr(e,t){return e!=null&&xr(e,t,br)}var Cr=1,wr=2;function Tr(e,t){return Vt(e)&&gr(t)?vr(B(e),t):function(n){var r=on(n,e);return r===void 0&&r===t?Sr(n,e):fr(t,r,Cr|wr)}}function Er(e){return function(t){return t?.[e]}}function Dr(e){return function(t){return an(t,e)}}function Or(e){return Vt(e)?Er(B(e)):Dr(e)}function kr(e){return typeof e==`function`?e:e==null?x:typeof e==`object`?y(e)?Tr(e[0],e[1]):yr(e):Or(e)}function Ar(e){return function(t,n,r){for(var i=-1,a=Object(t),o=r(t),s=o.length;s--;){var c=o[e?s:++i];if(n(a[c],c,a)===!1)break}return t}}var jr=Ar();function Mr(e,t){return e&&jr(e,t,M)}function Nr(e,t){return function(n,r){if(n==null)return n;if(!E(n))return e(n,r);for(var i=n.length,a=t?i:-1,o=Object(n);(t?a--:++a<i)&&r(o[a],a,o)!==!1;);return n}}var q=Nr(Mr);function Pr(e){return h(e)&&E(e)}function Fr(e,t,n){for(var r=-1,i=e==null?0:e.length;++r<i;)if(n(t,e[r]))return!0;return!1}function Ir(e){return typeof e==`function`?e:x}function J(e,t){return(y(e)?Ae:q)(e,Ir(t))}function Lr(e,t){var n=[];return q(e,function(e,r,i){t(e,r,i)&&n.push(e)}),n}function Y(e,t){return(y(e)?pn:Lr)(e,kr(t,3))}function Rr(e,t){return v(t,function(t){return e[t]})}function X(e){return e==null?[]:Rr(e,M(e))}var zr=`[object Map]`,Br=`[object Set]`,Vr=Object.prototype.hasOwnProperty;function Hr(e){if(e==null)return!0;if(E(e)&&(y(e)||typeof e==`string`||typeof e.splice==`function`||O(e)||j(e)||D(e)))return!e.length;var t=W(e);if(t==zr||t==Br)return!e.size;if(Ke(e))return!Rt(e).length;for(var n in e)if(Vr.call(e,n))return!1;return!0}function Z(e){return e===void 0}function Ur(e,t,n,r,i){return i(e,function(e,i,a){n=r?(r=!1,e):t(n,e,i,a)}),n}function Wr(e,t,n){var r=y(e)?dn:Ur,i=arguments.length<3;return r(e,kr(t,4),n,i,q)}var Gr=H&&1/Vn(new H([,-0]))[1]==1/0?function(e){return new H(e)}:Ce,Kr=200;function qr(e,t,n){var r=-1,i=Fe,a=e.length,o=!0,s=[],c=s;if(n)o=!1,i=Fr;else if(a>=Kr){var l=t?null:Gr(e);if(l)return Vn(l);o=!1,i=In,c=new G}else c=t?[]:s;e:for(;++r<a;){var u=e[r],d=t?t(u):u;if(u=n||u!==0?u:0,o&&d===d){for(var f=c.length;f--;)if(c[f]===d)continue e;t&&c.push(d),s.push(u)}else i(c,d,n)||(c!==s&&c.push(d),s.push(u))}return s}var Jr=He(function(e){return qr(un(e,1,Pr,!0))}),Yr=`\0`,Q=`\0`,Xr=``,Zr=class{constructor(e={}){this._isDirected=!Object.prototype.hasOwnProperty.call(e,`directed`)||e.directed,this._isMultigraph=Object.prototype.hasOwnProperty.call(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.prototype.hasOwnProperty.call(e,`compound`)?e.compound:!1,this._label=void 0,this._defaultNodeLabelFn=T(void 0),this._defaultEdgeLabelFn=T(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[Q]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return S(e)||(e=T(e)),this._defaultNodeLabelFn=e,this}nodeCount(){return this._nodeCount}nodes(){return M(this._nodes)}sources(){var e=this;return Y(this.nodes(),function(t){return Hr(e._in[t])})}sinks(){var e=this;return Y(this.nodes(),function(t){return Hr(e._out[t])})}setNodes(e,t){var n=arguments,r=this;return J(e,function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.prototype.hasOwnProperty.call(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=Q,this._children[e]={},this._children[Q][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.prototype.hasOwnProperty.call(this._nodes,e)}removeNode(e){if(Object.prototype.hasOwnProperty.call(this._nodes,e)){var t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],J(this.children(e),e=>{this.setParent(e)}),delete this._children[e]),J(M(this._in[e]),t),delete this._in[e],delete this._preds[e],J(M(this._out[e]),t),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(Z(t))t=Q;else{t+=``;for(var n=t;!Z(n);n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==Q)return t}}children(e){if(Z(e)&&(e=Q),this._isCompound){var t=this._children[e];if(t)return M(t)}else if(e===Q)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return M(t)}successors(e){var t=this._sucs[e];if(t)return M(t)}neighbors(e){var t=this.predecessors(e);if(t)return Jr(t,this.successors(e))}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;J(this._nodes,function(n,r){e(r)&&t.setNode(r,n)}),J(this._edgeObjs,function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&J(t.nodes(),function(e){t.setParent(e,i(e))}),t}setDefaultEdgeLabel(e){return S(e)||(e=T(e)),this._defaultEdgeLabelFn=e,this}edgeCount(){return this._edgeCount}edges(){return X(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return Wr(e,function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,r,i=!1,a=arguments[0];typeof a==`object`&&a&&`v`in a?(e=a.v,t=a.w,n=a.name,arguments.length===2&&(r=arguments[1],i=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),e=``+e,t=``+t,Z(n)||(n=``+n);var o=$(this._isDirected,e,t,n);if(Object.prototype.hasOwnProperty.call(this._edgeLabels,o))return i&&(this._edgeLabels[o]=r),this;if(!Z(n)&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[o]=i?r:this._defaultEdgeLabelFn(e,t,n);var s=ei(this._isDirected,e,t,n);return e=s.v,t=s.w,Object.freeze(s),this._edgeObjs[o]=s,Qr(this._preds[t],e),Qr(this._sucs[e],t),this._in[t][o]=s,this._out[e][o]=s,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?ti(this._isDirected,arguments[0]):$(this._isDirected,e,t,n);return this._edgeLabels[r]}hasEdge(e,t,n){var r=arguments.length===1?ti(this._isDirected,arguments[0]):$(this._isDirected,e,t,n);return Object.prototype.hasOwnProperty.call(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?ti(this._isDirected,arguments[0]):$(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],$r(this._preds[t],e),$r(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=X(n);return t?Y(r,function(e){return e.v===t}):r}}outEdges(e,t){var n=this._out[e];if(n){var r=X(n);return t?Y(r,function(e){return e.w===t}):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}};Zr.prototype._nodeCount=0,Zr.prototype._edgeCount=0;function Qr(e,t){e[t]?e[t]++:e[t]=1}function $r(e,t){--e[t]||delete e[t]}function $(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}return i+Xr+a+Xr+(Z(r)?Yr:r)}function ei(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function ti(e,t){return $(e,t.v,t.w,t.name)}export{v as $,Rt as A,He as B,un as C,nn as D,B as E,Ot as F,Ae as G,ze as H,O as I,T as J,ke as K,D as L,Pt as M,j as N,tn as O,jt as P,y as Q,Ke as R,V as S,an as T,Re as U,Ve as V,je as W,x as X,S as Y,b as Z,W as _,Y as a,_n as b,Pr as c,jr as d,_ as et,kr as f,Nn as g,xr as h,X as i,n as it,Ft as j,M as k,q as l,Sr as m,Wr as n,m as nt,J as o,Er as p,Oe as q,Z as r,r as rt,Ir as s,Zr as t,h as tt,Mr as u,yn as v,sn as w,mn as x,vn as y,E as z};
@@ -0,0 +1 @@
1
+ import{n as e,t}from"./chunk-3GCGMST5-C9FeQipv.js";import{i as n}from"./chunk-EBZ3SEQC-Sk8u_9ep.js";import{Mn as r,Qn as i,Un as a,_ as o,jn as s,tr as c}from"./index-LgGsGSUh.js";var l=1;function u(e,t,n=l){let r=Math.abs(t.x-e.x),i=Math.abs(t.y-e.y);return r<=n&&i<=n?`Z`:i<=n?`H`:`V`}c(u,`segmentOrientation`);function d(e,t=l){let n=[];for(let r=0;r<e.length-1;r++){let i=e[r],a=e[r+1];n.push({a:i,b:a,orientation:u(i,a,t)})}return n}c(d,`segmentsFromPoints`);function f(e,t=l){if(e.length===0)return[];let n=[],r={...e[0]};for(let i=1;i<e.length;i++){let a=e[i];a.orientation!==`Z`&&(r.orientation===`Z`?r={...a}:r.orientation===a.orientation&&(r.orientation===`H`&&Math.abs(r.b.y-a.a.y)<=t&&Math.abs(r.a.y-a.a.y)<=t||r.orientation===`V`&&Math.abs(r.b.x-a.a.x)<=t&&Math.abs(r.a.x-a.a.x)<=t)?r.b=a.b:(r.orientation!==`Z`&&n.push(r),r={...a}))}return r.orientation!==`Z`&&n.push(r),n}c(f,`mergeCollinear`);function p(e,t=l){if(e.length<2)return{points:[...e],segments:[],bends:0};let n=f(d(e,t).filter(e=>e.orientation!==`Z`),t),r=[];for(let[e,t]of n.entries())e===0&&r.push(t.a),r.push(t.b);let i=0;for(let e=1;e<n.length;e++)n[e-1].orientation!==n[e].orientation&&i++;return{points:r.length>0?r:[...e],segments:n,bends:i}}c(p,`normalizePolyline`);function m(e,t){if(e.orientation===`Z`||t.orientation===`Z`||e.orientation===t.orientation)return!1;let n=e.orientation===`H`?e:t,r=e.orientation===`V`?e:t,i=n.a.y,a=Math.min(n.a.x,n.b.x),o=Math.max(n.a.x,n.b.x),s=r.a.x,c=Math.min(r.a.y,r.b.y),l=Math.max(r.a.y,r.b.y);if(s>=a&&s<=o&&i>=c&&i<=l){let e=1e-6,t=s,a=i,o=Math.abs(t-n.a.x)<e&&Math.abs(a-n.a.y)<e||Math.abs(t-n.b.x)<e&&Math.abs(a-n.b.y)<e,c=Math.abs(t-r.a.x)<e&&Math.abs(a-r.a.y)<e||Math.abs(t-r.b.x)<e&&Math.abs(a-r.b.y)<e;return!(o&&c)}return!1}c(m,`segmentsCross`);function h(e,t){return e<t?-1:+(e>t)}c(h,`compareCodeUnits`);function g(e){let t=e.x??0,n=e.y??0,r=e.width??40,i=e.height??40;return{cx:t,cy:n,left:t-r/2,right:t+r/2,top:n-i/2,bottom:n+i/2}}c(g,`rectForNode`);function _(e,t,n,r,i=0){if(e.length<2)return null;let a=t===`end`?e[e.length-1]:e[0],o=t===`end`?e[e.length-2]:e[1],s=o.x-a.x,c=o.y-a.y;if(Math.abs(s)<=i&&Math.abs(c)<=i)return null;if(Math.abs(c)<=i){let e=a.x+Math.sign(s)*n,t=Math.min(a.x,e),i=Math.max(a.x,e);return{cx:(t+i)/2,cy:a.y,left:t,right:i,top:a.y-r,bottom:a.y+r}}if(Math.abs(s)<=i){let e=a.y+Math.sign(c)*n,t=Math.min(a.y,e),i=Math.max(a.y,e);return{cx:a.x,cy:(t+i)/2,left:a.x-r,right:a.x+r,top:t,bottom:i}}return null}c(_,`terminalMarkerClearanceRect`);function v(e,t){let n=t===`start`?e.arrowTypeStart:e.arrowTypeEnd;if(typeof n==`string`){let e=n.trim();if(e.length>0)return e!==`none`&&e!==`arrow_open`}return typeof e.type==`string`?t===`start`&&e.type.startsWith(`double_`)?!0:t===`end`&&/arrow_(point|cross|circle|barb)|double_arrow/.test(e.type):!1}c(v,`hasTerminalMarker`);function y(e,t,n=1e-6){return Math.abs(e-t)<=n}c(y,`approxEqual`);function b(e,t,n=1e-6){for(let r=1;r<e.length;r++){let i=e[r-1],a=e[r];if(y(i.y,a.y,n)&&!y(i.x,a.x,n)){if(y(t.y,i.y,n)&&t.x>=Math.min(i.x,a.x)-n&&t.x<=Math.max(i.x,a.x)+n)return!0}else if(y(i.x,a.x,n)&&!y(i.y,a.y,n)&&y(t.x,i.x,n)&&t.y>=Math.min(i.y,a.y)-n&&t.y<=Math.max(i.y,a.y)+n)return!0}return!1}c(b,`orthogonalPolylineContainsPoint`);function x(e){let t=0;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];t+=Math.abs(i.x-r.x)+Math.abs(i.y-r.y)}return t}c(x,`manhattanLength`);function S(e,t,n){if(e.x===t.x&&e.y===t.y)return!1;if(e.y===t.y){let r=e.y,i=Math.min(e.x,t.x),a=Math.max(e.x,t.x),o=r>=n.top&&r<=n.bottom,s=Math.max(i,n.left)<Math.min(a,n.right);return o&&s}if(e.x===t.x){let r=e.x,i=Math.min(e.y,t.y),a=Math.max(e.y,t.y),o=r>=n.left&&r<=n.right,s=Math.max(i,n.top)<Math.min(a,n.bottom);return o&&s}return!1}c(S,`segmentIntersectsRectInterior`);function C(e,t){for(let n=1;n<e.length;n++)if(S(e[n-1],e[n],t))return!0;return!1}c(C,`polylineIntersectsRect`);function w(e,t,n){return Math.max(t,Math.min(n,e))}c(w,`clamp`);var T=`__grid_root__`,E=`edge-label-`;function D(e,t,n){let r=Error(`${e}: ${t}`);return r.code=e,r.details=n,r}c(D,`gridError`);var O={columns:0,rowGap:50,columnGap:50,cellGap:20,containerPadding:20,titleGap:8,horizontalAlign:`center`,verticalAlign:`center`,curve:`rounded`,edgeCornerRadius:5};function k(e){return!!e.isEdgeLabel}c(k,`isEdgeLabelNode`);function A(e){return typeof e==`number`&&Number.isFinite(e)&&e>0}c(A,`isFinitePositiveNumber`);var j=6,M=12,ee=2;function N(e,t){if(!A(e.width)||!A(e.height))return null;let n=t===`H`?e.width:e.height,r=t===`H`?e.height:e.width,i=Math.max(j,M),a=Math.max(j,M);return{along:n,cross:r,startInset:i,endInset:a,requiredAlongSpan:n+i+a+ee}}c(N,`gridLabelSpanRequirement`);function P(e,t){let n=t===`H`?e.width:e.height;return A(n)?n+j*2:0}c(P,`gridLabelRequiredSegmentLength`);var F=j,I=14,L=18,te=16,R=128,ne=64,re=2e6,ie=M,z=1e-6,B=7,ae=8,V=c(e=>p(e,z),`normalizePolyline`);function oe(e,t,n,r){return Math.max(0,Math.min(Math.max(e,t),Math.max(n,r))-Math.max(Math.min(e,t),Math.min(n,r)))}c(oe,`rangeOverlapLength`);function se(e){let t=V([...e]).segments;for(let e=0;e<t.length;e++){let n=t[e];for(let r=e+2;r<t.length;r++){let e=t[r];if(m(n,e))return!0;if(n.orientation!==e.orientation||n.orientation===`Z`)continue;let i=n.orientation===`H`?Math.abs(n.a.y-e.a.y)<=z:Math.abs(n.a.x-e.a.x)<=z,a=n.orientation===`H`?oe(n.a.x,n.b.x,e.a.x,e.b.x):oe(n.a.y,n.b.y,e.a.y,e.b.y);if(i&&a>z)return!0;let o=n.orientation===`H`?Math.abs(n.a.y-e.a.y):Math.abs(n.a.x-e.a.x);if(!i&&o<B&&a>=ae)return!0}}return!1}c(se,`polylineHasSelfConflict`);var ce=class extends Error{constructor(e){super(`Could not place label for edge "${e.edgeId}"`),this.details=e,this.name=`LabelPlacementSearchExhaustedError`}static{c(this,`LabelPlacementSearchExhaustedError`)}},le=class extends Error{static{c(this,`LabelIndexWorkLimitError`)}constructor(){super(`Grid label index work cap exceeded`),this.name=`LabelIndexWorkLimitError`}},ue=class{constructor(e,t){this.limit=e,this.metrics=t,this.used=0}static{c(this,`LabelIndexWorkBudget`)}charge(e){if(!(e<=0)){if(this.used+e>this.limit)throw new le;this.used+=e,H(this.metrics,`indexWorkUnits`,e)}}},de=class{constructor(e,t){this.workBudget=e,this.metrics=t,this.entriesById=new Map,this.sortedByLeft=[],this.dirty=!1}static{c(this,`CompressedBoundsIndex`)}upsert(e){let t=!this.entriesById.has(e.id);this.entriesById.set(e.id,e),this.dirty=!0,t&&this.metrics&&(this.metrics.indexCoordinateCount+=4)}remove(e){this.entriesById.delete(e)&&(this.dirty=!0)}query(e){if(this.dirty){let e=this.entriesById.size;this.workBudget.charge(e*Math.max(1,Math.ceil(Math.log2(e+1)))),this.sortedByLeft=[...this.entriesById.values()].sort((e,t)=>e.bounds.left-t.bounds.left||h(e.id,t.id)),this.dirty=!1}let t=[];for(let n of this.sortedByLeft){if(this.workBudget.charge(1),n.bounds.left>e.right)break;xe(n.bounds,e)&&t.push(n)}return t}};function fe(e,t){return e.left<t.right&&e.right>t.left&&e.top<t.bottom&&e.bottom>t.top}c(fe,`rectOverlap`);function pe(e,t){let n=e.width??0,r=e.height??0;return{cx:t.x,cy:t.y,left:t.x-n/2,right:t.x+n/2,top:t.y-r/2,bottom:t.y+r/2}}c(pe,`labelRectAt`);function me(e){let t=e.groupTitleRect;return t?{cx:(t.left+t.right)/2,cy:(t.top+t.bottom)/2,left:t.left,right:t.right,top:t.top,bottom:t.bottom}:null}c(me,`groupTitleRect`);function H(e,t,n=1){e&&(e[t]+=n)}c(H,`incrementMetric`);function he(e){return{...e}}c(he,`clonePoint`);function ge(e){return{left:e.left,right:e.right,top:e.top,bottom:e.bottom}}c(ge,`boundsForRect`);function _e(e){return{left:Math.min(e.a.x,e.b.x),right:Math.max(e.a.x,e.b.x),top:Math.min(e.a.y,e.b.y),bottom:Math.max(e.a.y,e.b.y)}}c(_e,`boundsForSegment`);function ve(e){if(e.length===0)return null;let t=e[0].x,n=e[0].x,r=e[0].y,i=e[0].y;for(let a of e.slice(1))t=Math.min(t,a.x),n=Math.max(n,a.x),r=Math.min(r,a.y),i=Math.max(i,a.y);return{left:t,right:n,top:r,bottom:i}}c(ve,`boundsForPoints`);function ye(e,t){return{left:Math.min(e.left,t.left),right:Math.max(e.right,t.right),top:Math.min(e.top,t.top),bottom:Math.max(e.bottom,t.bottom)}}c(ye,`mergeBounds`);function be(e,t){return{left:e.left-t,right:e.right+t,top:e.top-t,bottom:e.bottom+t}}c(be,`expandBounds`);function xe(e,t){return e.left<=t.right&&e.right>=t.left&&e.top<=t.bottom&&e.bottom>=t.top}c(xe,`boundsOverlap`);function Se(e){return(e.length<=2?e.map((e,t)=>t):[...e.slice(1,-1).map((e,t)=>t+1),0,e.length-1]).map((t,n)=>({segment:e[t],segmentIndex:t,order:n}))}c(Se,`candidateSegmentsFromSegments`);function Ce(e,t){return[`start`,`end`].filter(t=>v(e,t)).map(e=>_(t,e,ie,7,z)).filter(e=>e!==null)}c(Ce,`markerClearanceRectsFromPoints`);function we(e,t){let n=V(t);return{points:n.points,segments:n.segments,candidateSegments:Se(n.segments),markerRects:Ce(e,n.points)}}c(we,`buildEdgeGeometry`);function Te(e){return e.orientation===`H`?Math.abs(e.b.x-e.a.x):Math.abs(e.b.y-e.a.y)}c(Te,`segmentLength`);function Ee(e,t){let n=[{x:t.left,y:t.top},{x:t.right,y:t.top},{x:t.right,y:t.bottom},{x:t.left,y:t.bottom}];for(let t=0;t<n.length;t++)if(S(n[t],n[(t+1)%n.length],e))return!0;return!1}c(Ee,`borderCutsRect`);function De(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)}c(De,`hasFinitePosition`);function U(e,t,n){let r=t?.get(e.id);if(r)return V(r).points;let i=n?.edgeGeometryById.get(e.id);return i?i.points:V(e.points??[]).points}c(U,`pointsForEdge`);function Oe(e,t,n){if(!t?.has(e.id)){let t=n?.edgeGeometryById.get(e.id);if(t)return t.markerRects}return Ce(e,U(e,t,n))}c(Oe,`markerClearanceRectsForEdge`);function ke(e,t,n,r){return Math.max(Math.min(e,t),Math.min(n,r))<Math.min(Math.max(e,t),Math.max(n,r))-z}c(ke,`rangeOverlaps`);function Ae(e,t,n){let r=w(Math.min(e.start,e.end),t,n),i=w(Math.max(e.start,e.end),t,n);return i-r>z?{start:r,end:i}:null}c(Ae,`clampInterval`);function je(e,t,n){let r=e.map(e=>Ae(e,t,n)).filter(e=>e!==null).sort((e,t)=>e.start-t.start||e.end-t.end);if(r.length===0)return[];let i=[r[0]];for(let e=1;e<r.length;e++){let t=r[e],n=i[i.length-1];t.start<=n.end+z?n.end=Math.max(n.end,t.end):i.push(t)}return i}c(je,`mergeBlockedLabelIntervals`);function Me(e,t,n,r){if(t-e<=z)return[];let i=[],a=e;for(let r of je(n,e,t))r.start-a>z&&i.push({start:a,end:r.start}),a=Math.max(a,r.end);t-a>z&&i.push({start:a,end:t});let o=i.map(e=>({value:w(r,e.start,e.end),start:e.start,end:e.end}));o.sort((e,t)=>{let n=Math.abs(e.value-r)-Math.abs(t.value-r);if(Math.abs(n)>z)return n;let i=t.end-t.start-(e.end-e.start);return Math.abs(i)>z?i:e.value-t.value});let s=new Set,c=[];for(let e of o){let t=Math.round(e.value*1e6)/1e6;s.has(t)||(s.add(t),c.push(e.value))}return c}c(Me,`centerCandidatesFromIntervals`);function Ne(e){return e.isGroup||k(e)&&!De(e)?null:g(e)}c(Ne,`obstacleRectForNode`);function Pe(e,t){let n=t?.edgeGeometryById.get(e.id);return n?n.candidateSegments:Se(V(e.points??[]).segments)}c(Pe,`candidateSegments`);function Fe(e,t,n){let r=e.edgeGeometryById.get(t);r&&r.segments.forEach((n,r)=>e.segmentIndex.remove(`${t}:${r}`)),e.edgeGeometryById.set(t,n),n.segments.forEach((n,r)=>{e.segmentIndex.upsert({id:`${t}:${r}`,edgeId:t,segment:n,bounds:_e(n)})})}c(Fe,`storeEdgeGeometry`);function Ie(e,t,n){let r=we(t,n);t.points=r.points.map(he),Fe(e,t.id,r)}c(Ie,`setEdgePoints`);function Le(e,t){e.placedLabelIndex.upsert({id:`label:${t.nodeId}`,nodeId:t.nodeId,rect:t.rect,bounds:ge(t.rect)})}c(Le,`upsertPlacedLabelObstacle`);function Re(e,t,n){let r={edgeById:new Map,edgeGeometryById:new Map,obstacleIndex:new de(t,n),placedLabelIndex:new de(t,n),groupBorderIndex:new de(t,n),segmentIndex:new de(t,n),searchBounds:{left:0,right:0,top:0,bottom:0},metrics:n},i=null,a=c(e=>{i=i?ye(i,e):{...e}},`rememberBounds`);for(let t of e.nodes){if(t.isGroup){let e=g(t),n=ge(e);r.groupBorderIndex.upsert({id:`border:${t.id}`,rect:e,bounds:n}),a(n);let i=me(t);if(i){let e=ge(i);r.obstacleIndex.upsert({id:`title:${t.id}`,rect:i,bounds:e}),a(e)}continue}let e=Ne(t);if(!e)continue;let n={id:`${k(t)?`label`:`node`}:${t.id}`,rect:e,bounds:ge(e),nodeId:t.id};k(t)?r.placedLabelIndex.upsert(n):r.obstacleIndex.upsert(n),a(n.bounds)}for(let t of e.edges){r.edgeById.set(t.id,t);let e=we(t,t.points??[]);Fe(r,t.id,e);let n=ve(e.points);n&&a(n)}return r.searchBounds=be(i??{left:0,right:0,top:0,bottom:0},128),r}c(Re,`createEdgeLabelContext`);function ze(e,t,n,r={}){H(e.metrics,n);let i=[],a=c(e=>{for(let t of e)(!t.nodeId||t.nodeId!==r.excludeNodeId&&!r.skipNodeIds?.has(t.nodeId))&&i.push(t)},`appendEntries`);return a(e.obstacleIndex.query(t)),a(e.placedLabelIndex.query(t)),H(e.metrics,`obstacleCandidatesVisited`,i.length),i}c(ze,`queryObstacleEntries`);function Be(e,t,n,r,i){H(e.metrics,i);let a=r?new Set(r.keys()):void 0,o=[],s=e.segmentIndex.query(t);for(let e of s)e.edgeId===n||a?.has(e.edgeId)||o.push(e);let c=s.length;if(r)for(let[i,a]of r){if(i===n)continue;let r=e.edgeById.get(i);r&&we(r,a).segments.forEach((e,n)=>{let r=_e(e);xe(r,t)&&(c+=1,o.push({id:`override:${i}:${n}`,edgeId:i,segment:e,bounds:r}))})}return H(e.metrics,`segmentCandidatesVisited`,c),o}c(Be,`queryForeignSegments`);function Ve(e,t,n,r){H(e.metrics,`foreignEdgeLookups`);let i=new Set;for(let a of Be(e,ge(t),n,r,`segmentRectQueries`))S(a.segment.a,a.segment.b,t)&&i.add(a.edgeId);return[...i].sort(h)}c(Ve,`foreignEdgeIdsIntersectingRect`);function He(e,t){return!A(t.width)||!A(t.height)?null:e.orientation===`H`?{left:Math.min(e.a.x,e.b.x)-t.width/2,right:Math.max(e.a.x,e.b.x)+t.width/2,top:e.a.y-t.height/2,bottom:e.a.y+t.height/2}:{left:e.a.x-t.width/2,right:e.a.x+t.width/2,top:Math.min(e.a.y,e.b.y)-t.height/2,bottom:Math.max(e.a.y,e.b.y)+t.height/2}}c(He,`obstacleBandQueryBounds`);function Ue(e,t,n){if(e.orientation===`H`){let r=(t.width??0)+F*2+I;return{left:Math.min(e.a.x,e.b.x)-r,right:Math.max(e.a.x,e.b.x)+r,top:n.top,bottom:n.bottom}}let r=(t.height??0)+F*2+I;return{left:n.left,right:n.right,top:Math.min(e.a.y,e.b.y)-r,bottom:Math.max(e.a.y,e.b.y)+r}}c(Ue,`detourLineQueryBounds`);function We(e,t){return e.orientation===`H`?{left:Math.min(e.a.x,e.b.x)-F,right:Math.max(e.a.x,e.b.x)+F,top:t.top,bottom:t.bottom}:{left:t.left,right:t.right,top:Math.min(e.a.y,e.b.y)-F,bottom:Math.max(e.a.y,e.b.y)+F}}c(We,`rerouteLineQueryBounds`);function Ge(e,t,n,r,i,a){for(let t of ze(r,ge(e),`obstacleRectQueries`,{excludeNodeId:n}))if(fe(e,t.rect))return!1;for(let t of r.groupBorderIndex.query(ge(e)))if(Ee(e,t.rect))return!1;for(let n of Oe(t,i,r))if(fe(e,n))return!1;for(let n of Be(r,ge(e),t.id,i,`segmentRectQueries`))if(!a?.has(n.edgeId)&&S(n.segment.a,n.segment.b,e))return!1;return!0}c(Ge,`rectSafeForLabel`);function Ke(e,t){return t.orientation===`Z`?0:P(e,t.orientation)}c(Ke,`requiredSegmentLength`);function qe(e,t,n,r,i,a){if(!A(t.width)||!A(t.height))return null;let o=t.width,s=t.height,l=n.orientation===`H`?o/2+F:s/2+F,u=n.orientation===`H`?Math.min(n.a.x,n.b.x)+l:Math.min(n.a.y,n.b.y)+l,d=n.orientation===`H`?Math.max(n.a.x,n.b.x)-l:Math.max(n.a.y,n.b.y)-l;if(d-u<=z)return null;let f=[],p=He(n,t);if(!p)return null;let m=c(e=>{n.orientation===`H`?ke(n.a.y-s/2,n.a.y+s/2,e.top,e.bottom)&&f.push({start:e.left-o/2,end:e.right+o/2}):ke(n.a.x-o/2,n.a.x+o/2,e.left,e.right)&&f.push({start:e.top-s/2,end:e.bottom+s/2})},`addRect`);for(let e of ze(r,p,`obstacleBandQueries`,{excludeNodeId:t.id}))m(e.rect);for(let t of Oe(e,i,r))m(t);if(a)for(let a of Be(r,p,e.id,i,`segmentBandQueries`)){let e=a.segment;if(n.orientation===`H`){let r=n.a.y-t.height/2,i=n.a.y+t.height/2;e.orientation===`H`?r<e.a.y&&i>e.a.y&&f.push({start:Math.min(e.a.x,e.b.x)-t.width/2,end:Math.max(e.a.x,e.b.x)+t.width/2}):ke(r,i,Math.min(e.a.y,e.b.y),Math.max(e.a.y,e.b.y))&&f.push({start:e.a.x-t.width/2,end:e.a.x+t.width/2});continue}let r=n.a.x-t.width/2,i=n.a.x+t.width/2;e.orientation===`V`?r<e.a.x&&i>e.a.x&&f.push({start:Math.min(e.a.y,e.b.y)-t.height/2,end:Math.max(e.a.y,e.b.y)+t.height/2}):ke(r,i,Math.min(e.a.x,e.b.x),Math.max(e.a.x,e.b.x))&&f.push({start:e.a.y-t.height/2,end:e.a.y+t.height/2})}return{low:u,high:d,blocked:f}}c(qe,`blockedCenterIntervals`);function Je(e,t,n,r){if(Te(n)<Ke(t,n))return null;let i=qe(e,t,n,r,void 0,!0);if(!i)return null;let a=n.orientation===`H`?(Math.min(n.a.x,n.b.x)+Math.max(n.a.x,n.b.x))/2:(Math.min(n.a.y,n.b.y)+Math.max(n.a.y,n.b.y))/2,o=Me(i.low,i.high,i.blocked,a);for(let i of o){let a=n.orientation===`H`?{x:i,y:n.a.y}:{x:n.a.x,y:i};if(Ge(pe(t,a),e,t.id,r))return a}return null}c(Je,`placementOnExistingSegment`);function Ye(e,t,n,r,i){let a=qe(e,t,n,r,void 0,!1);if(!a)return null;let o=n.orientation===`H`?(Math.min(n.a.x,n.b.x)+Math.max(n.a.x,n.b.x))/2:(Math.min(n.a.y,n.b.y)+Math.max(n.a.y,n.b.y))/2,s=Me(a.low,a.high,a.blocked,o);for(let a of s){let o=n.orientation===`H`?{x:a,y:n.a.y}:{x:n.a.x,y:a},s=pe(t,o),c=new Map,l=Ve(r,s,e.id).map(e=>r.edgeById.get(e)).filter(e=>e!==void 0),u=!0;for(let e of l){let t=mt(e,s,r,i,c);if(!t){u=!1;break}c.set(e.id,t)}if(u&&Ge(s,e,t.id,r,c)){for(let[e,t]of c){let n=r.edgeById.get(e);n&&Ie(r,n,t)}return o}}return null}c(Ye,`placementOnExistingSegmentWithReroutes`);function Xe(e,t,n){for(let r of V(e).segments)for(let e of ze(t,_e(r),`obstaclePolylineQueries`,{skipNodeIds:n}))if(S(r.a,r.b,e.rect))return!0;return!1}c(Xe,`polylineHitsProtectedObstacles`);function Ze(e,t,n){let r=n.get(e);return!r||b(t,r.center,z)}c(Ze,`labelStillAnchored`);function Qe(e){let t=[];for(let n=0;n<te;n++){let r=e+I+n*L;t.push(-r,r)}return t}c(Qe,`detourOffsets`);function $e(e,t){let n=new Map;for(let t of e){let e=Math.round(t*1e6)/1e6;n.has(e)||n.set(e,t)}return[...n.values()].sort((e,n)=>{let r=Math.abs(e-t)-Math.abs(n-t);return Math.abs(r)>z?r:e-n})}c($e,`uniqueSortedCandidates`);function et(e,t,n,r){if(!A(t.width)||!A(t.height))return[];let i=t.width,a=t.height,o=n.orientation===`H`?n.a.y:n.a.x,s=n.orientation===`H`?a/2:i/2,l=Qe(s).map(e=>o+e),u=c(e=>{n.orientation===`H`?(l.push(e.top-s-I),l.push(e.bottom+s+I)):(l.push(e.left-s-I),l.push(e.right+s+I))},`addRect`);for(let e of ze(r,Ue(n,t,r.searchBounds),`obstacleBandQueries`,{excludeNodeId:t.id}))u(e.rect);for(let t of Oe(e,void 0,r))u(t);return $e(l,o).slice(0,R)}c(et,`detourLineCandidates`);function tt(e,t,n,r,i){let a=e.orientation===`H`?e.a.y:e.a.x,o=[];for(let n of Qe(0))e.orientation===`H`?o.push(n<0?t.top+n:t.bottom+n):o.push(n<0?t.left+n:t.right+n);let s=c(t=>{e.orientation===`H`?(o.push(t.top-I),o.push(t.bottom+I)):(o.push(t.left-I),o.push(t.right+I))},`addRect`);for(let t of ze(n,We(e,n.searchBounds),`obstacleBandQueries`,{skipNodeIds:r}))s(t.rect);let l=$e(o,a);return(i?.orientation===e.orientation?l.filter(e=>i.side===`top`?e<t.top:i.side===`bottom`?e>t.bottom:i.side===`left`?e<t.left:e>t.right):l).slice(0,R)}c(tt,`rerouteLineCandidates`);function nt(e,t,n,r,i){if(!A(t.width)||!A(t.height))return[];let a=t.width,o=t.height,s=n.orientation===`H`?{orientation:`H`,a:{x:n.a.x,y:r},b:{x:n.b.x,y:r}}:{orientation:`V`,a:{x:r,y:n.a.y},b:{x:r,y:n.b.y}},l=qe(e,t,s,i,void 0,!1);if(!l){let e=n.orientation===`H`?(Math.min(n.a.x,n.b.x)+Math.max(n.a.x,n.b.x))/2:(Math.min(n.a.y,n.b.y)+Math.max(n.a.y,n.b.y))/2,r=[e],l=He(s,t),u=c(e=>{n.orientation===`H`?(r.push(e.left-I-a/2),r.push(e.right+I+a/2)):(r.push(e.top-I-o/2),r.push(e.bottom+I+o/2))},`addRect`);if(l)for(let e of ze(i,l,`obstacleBandQueries`,{excludeNodeId:t.id}))u(e.rect);return $e(r,e).slice(0,ne)}let u=n.orientation===`H`?(Math.min(n.a.x,n.b.x)+Math.max(n.a.x,n.b.x))/2:(Math.min(n.a.y,n.b.y)+Math.max(n.a.y,n.b.y))/2;return Me(l.low,l.high,l.blocked,u)}c(nt,`detourCenterCandidates`);function rt(e,t,n){return t+(t>=e?1:-1)*(n+F)}c(rt,`detourReturnCoordinate`);var it={along:c(e=>e.x,`along`),cross:c(e=>e.y,`cross`),point:c((e,t)=>({x:e,y:t}),`point`),labelAlongSize:c(e=>e.width??0,`labelAlongSize`),labelCrossSize:c(e=>e.height??0,`labelCrossSize`)},at={along:c(e=>e.y,`along`),cross:c(e=>e.x,`cross`),point:c((e,t)=>({x:t,y:e}),`point`),labelAlongSize:c(e=>e.height??0,`labelAlongSize`),labelCrossSize:c(e=>e.width??0,`labelCrossSize`)};function ot(e){return e.orientation===`H`?it:at}c(ot,`detourAxis`);function st(e,t,n,r,i,a){if(!A(r.width)||!A(r.height))return null;let o=e[t],s=e[t+1],c=ot(n),l=c.cross(n.a),u=c.along(o),d=c.along(s),f=c.labelAlongSize(r)+F*2,p=i-f/2,m=i+f/2,h=p<Math.min(u,d)-z,g=m>Math.max(u,d)+z,_=d>=u?1:-1,v=Math.max(0,Math.min(ie,Math.abs(d-u)/2-z)),y=u+_*v,b=d-_*v;if(!h&&!g)return V([...e.slice(0,t),o,c.point(p,l),c.point(p,a),c.point(m,a),c.point(m,l),s,...e.slice(t+2)]).points;let x=rt(l,a,c.labelCrossSize(r)/2),S=[...e.slice(0,t),o];return h?S.push(c.point(y,l),c.point(y,x),c.point(p,x),c.point(p,a)):S.push(c.point(p,l),c.point(p,a)),S.push(c.point(m,a)),g?S.push(c.point(m,x),c.point(b,x),c.point(b,l)):S.push(c.point(m,l)),S.push(s,...e.slice(t+2)),V(S).points}c(st,`buildLabelDetourPoints`);function ct(e,t,n,r,i,a,o){if(!A(r.width)||!A(r.height))return null;let s=e[t],c=e[t+1],l=o?4:2,u=ot(n),d=u.cross(n.a),f=u.along(s),p=u.along(c),m=u.labelAlongSize(r)+F*2,h=i-m/2,g=i+m/2,_=p>=f?1:-1,v=Math.max(0,Math.min(ie,Math.abs(p-f)/l-z)),y=f+_*v,b=p-_*v,x=rt(d,a,u.labelCrossSize(r)/2);return V([...e.slice(0,t),s,u.point(y,d),u.point(y,a),u.point(h,a),u.point(g,a),u.point(g,x),u.point(b,x),u.point(b,d),c,...e.slice(t+2)]).points}c(ct,`buildExtendedLabelDetourPoints`);function lt(e,t){if(!A(t.width)||!A(t.height))return[];if(e.orientation===`H`){let n=Math.min(e.a.x,e.b.x),r=Math.max(e.a.x,e.b.x);return[n-t.width/2-I,r+t.width/2+I]}let n=Math.min(e.a.y,e.b.y),r=Math.max(e.a.y,e.b.y);return[n-t.height/2-I,r+t.height/2+I]}c(lt,`externalDetourCenterCandidates`);function ut(e,t){let n=0,r=0;for(let i of V([...e]).segments)S(i.a,i.b,t)&&(n++,i.orientation===`H`?r+=Math.max(0,Math.min(Math.max(i.a.x,i.b.x),t.right)-Math.max(Math.min(i.a.x,i.b.x),t.left)):i.orientation===`V`&&(r+=Math.max(0,Math.min(Math.max(i.a.y,i.b.y),t.bottom)-Math.max(Math.min(i.a.y,i.b.y),t.top))));return{count:n,length:r}}c(ut,`blockedIntersectionScore`);function dt(e,t,n){let r=ut(e,t);return r.count<n.count||r.count===n.count&&r.length<n.length-z}c(dt,`reducesBlockedIntersections`);function ft(e,t,n){let r=V([...e]).segments.find(e=>S(e.a,e.b,t));if(!r||r.orientation===`Z`)return null;let i=r.orientation===`H`?Math.abs(r.a.y-t.top)<=Math.abs(t.bottom-r.a.y)?`top`:`bottom`:Math.abs(r.a.x-t.left)<=Math.abs(t.right-r.a.x)?`left`:`right`,a=n.map(e=>e.edgeId).sort(h);return{key:JSON.stringify([a,r.orientation,i]),orientation:r.orientation,side:i}}c(ft,`rerouteLane`);function pt(e,t,n,r,i,a,o){let s=V(t),c=ut(s.points,r),l=s.segments[n];if(!l||l.orientation===`Z`)return null;let u=s.points[n],d=s.points[n+1],f=a.get(e.id)?.nodeId,p=new Set;if(f&&p.add(f),l.orientation===`H`){let t=Math.min(u.x,d.x),f=Math.max(u.x,d.x),m=Math.max(t,r.left-F),h=Math.min(f,r.right+F);if(h-m<=z)return H(i.metrics,`rerouteRejectedDegenerateSpan`),null;for(let t of tt(l,r,i,p,o)){H(i.metrics,`rerouteCandidatesEvaluated`);let o=V([...s.points.slice(0,n),u,{x:m,y:l.a.y},{x:m,y:t},{x:h,y:t},{x:h,y:l.a.y},d,...s.points.slice(n+2)]).points;if(C(o,r)&&!dt(o,r,c))H(i.metrics,`rerouteRejectedBlockedRect`);else if(C(o,r)&&H(i.metrics,`reroutePartialProgressCandidates`),Xe(o,i,p))H(i.metrics,`rerouteRejectedProtectedObstacle`);else if(!Ze(e.id,o,a))H(i.metrics,`rerouteRejectedLabelAnchor`);else return o}return null}let m=Math.min(u.y,d.y),h=Math.max(u.y,d.y),g=Math.max(m,r.top-F),_=Math.min(h,r.bottom+F);if(_-g<=z)return H(i.metrics,`rerouteRejectedDegenerateSpan`),null;for(let t of tt(l,r,i,p,o)){H(i.metrics,`rerouteCandidatesEvaluated`);let o=V([...s.points.slice(0,n),u,{x:l.a.x,y:g},{x:t,y:g},{x:t,y:_},{x:l.a.x,y:_},d,...s.points.slice(n+2)]).points;if(C(o,r)&&!dt(o,r,c))H(i.metrics,`rerouteRejectedBlockedRect`);else if(C(o,r)&&H(i.metrics,`reroutePartialProgressCandidates`),Xe(o,i,p))H(i.metrics,`rerouteRejectedProtectedObstacle`);else if(!Ze(e.id,o,a))H(i.metrics,`rerouteRejectedLabelAnchor`);else return o}return null}c(pt,`rerouteSegmentAroundRect`);function mt(e,t,n,r,i,a){let o=U(e,i,n);for(let i=0;i<8;i++){if(!C(o,t))return o;let i=V(o),s=i.points.findIndex((e,n)=>n!==i.points.length-1&&S(e,i.points[n+1],t));if(s<0)return o;let c=pt(e,i.points,s,t,n,r,a);if(!c)return null;o=c}return C(o,t)?null:o}c(mt,`rerouteForeignEdgeAroundRect`);function ht(e,t,n,r,i){let a=U(e,i,n),o=a;for(let s=0;s<2;s++){let s=!1;for(let c of t){if(!C(o,c.rect))continue;H(n.metrics,`individualLabelRerouteAttempts`),i.set(e.id,o);let t=mt(e,c.rect,n,r,i);if(!t)return i.set(e.id,a),null;H(n.metrics,`individualLabelRerouteSuccesses`),o=t,s=!0}if(t.every(e=>!C(o,e.rect)))return o;if(!s)break}return i.set(e.id,a),null}c(ht,`rerouteForeignEdgeAroundLabels`);function gt(e,t,n,r,i){if(!A(t.width)||!A(t.height))return null;let a=U(e,void 0,r),o=n.segment;for(let s of et(e,t,o,r)){let c=$e(lt(o,t),o.orientation===`H`?(Math.min(o.a.x,o.b.x)+Math.max(o.a.x,o.b.x))/2:(Math.min(o.a.y,o.b.y)+Math.max(o.a.y,o.b.y))/2);for(let l of c){let c=ct(a,n.segmentIndex,o,t,l,s,e.start===e.end);if(!c||e.start===e.end&&se(c)||Xe(c,r,new Set([t.id])))continue;let u=o.orientation===`H`?{x:l,y:s}:{x:s,y:l},d=pe(t,u),f=new Map([[e.id,c]]),p=Ve(r,d,e.id,f).map(e=>r.edgeById.get(e)).filter(e=>e!==void 0),m=!0;for(let e of p){let t=mt(e,d,r,i,f);if(!t){m=!1;break}f.set(e.id,t)}if(m&&Ge(d,e,t.id,r,f)){Ie(r,e,c);for(let[t,n]of f){if(t===e.id)continue;let i=r.edgeById.get(t);i&&Ie(r,i,n)}return u}}}return null}c(gt,`labelPlacementWithExtendedDetour`);function _t(e,t,n,r,i){if(!A(t.width)||!A(t.height))return null;let a=U(e,void 0,r),o=n.segment;for(let s of et(e,t,o,r)){let c=nt(e,t,o,s,r);for(let l of c){let c=st(a,n.segmentIndex,o,t,l,s);if(!c||e.start===e.end&&se(c)||Xe(c,r,new Set([t.id])))continue;let u=o.orientation===`H`?{x:l,y:s}:{x:s,y:l},d=pe(t,u),f=new Map([[e.id,c]]),p=Ve(r,d,e.id,f).map(e=>r.edgeById.get(e)).filter(e=>e!==void 0),m=!0;for(let e of p){let t=mt(e,d,r,i,f);if(!t){m=!1;break}f.set(e.id,t)}if(m&&Ge(d,e,t.id,r,f)){Ie(r,e,c);for(let[t,n]of f){if(t===e.id)continue;let i=r.edgeById.get(t);i&&Ie(r,i,n)}return u}}}return null}c(_t,`labelPlacementWithDetour`);function vt(e){return!!(e&&k(e))}c(vt,`isPreparedLabelNode`);function yt(e,t,n){let r=e.points?.find(e=>Number.isFinite(e.x)&&Number.isFinite(e.y)),i=e.start?n.get(e.start):void 0,a=e.end?n.get(e.end):void 0,o=r??(i&&De(i)?i:void 0)??a;o&&Number.isFinite(o.x)&&Number.isFinite(o.y)?(t.x=o.x,t.y=o.y):(delete t.x,delete t.y)}c(yt,`parkDegenerateLabel`);function bt(e,t,n){let r;for(let t of V(e.points??[]).segments)t.orientation!==`Z`&&(!r||Te(t)>Te(r))&&(r=t);r?(t.x=(r.a.x+r.b.x)/2,t.y=(r.a.y+r.b.y)/2):yt(e,t,n)}c(bt,`placeLabelAtRouteMidpoint`);function xt(e){return`${E}${e.start??``}-${e.end??``}-${e.id}`}c(xt,`preferredGridLabelNodeId`);function St(e,t){let n=e.labelNodeId??xt(e),r=n,i=1;for(;;){if(!t.has(r))return r;r=`${n}-${i}`,i+=1}}c(St,`ensureUniqueGridLabelNodeId`);function Ct(e){let t=new Map;for(let n of e.nodes)t.set(n.id,n);let n=[];for(let r of e.edges){if(!r.label||r.label.length===0)continue;let e=r.start?t.get(r.start):void 0,i=r.labelNodeId?t.get(r.labelNodeId):void 0;if(vt(i)){i.label=r.label,i.labelStyle=Array.isArray(r.labelStyle)?r.labelStyle[0]:r.labelStyle??``,i.edgeStart=r.start??``,i.edgeEnd=r.end??``,e?.dir&&(i.dir=e.dir),r.label=void 0,r.text=void 0;continue}let a=St(r,t),o={id:a,label:r.label,edgeStart:r.start??``,edgeEnd:r.end??``,shape:`labelRect`,width:0,height:0,isEdgeLabel:!0,isDummy:!0,isGroup:!1,parentId:void 0,labelStyle:Array.isArray(r.labelStyle)?r.labelStyle[0]:r.labelStyle??``,...e?.dir?{dir:e.dir}:{}};n.push(o),t.set(a,o),r.labelNodeId=a,r.label=void 0,r.text=void 0}e.nodes.push(...n)}c(Ct,`prepareGridLayout`);function wt(e,t,n,r={}){let a=new Map;for(let t of e.nodes)a.set(t.id,t);let o=e.nodes.filter(k),s=new Map(o.map(e=>[e.id,{x:e.x,y:e.y}]));for(let e of o)delete e.x,delete e.y;let l=e.edges.map((e,n)=>{if(!e.labelNodeId)return null;let r=a.get(e.labelNodeId);return r?!A(r.width)||!A(r.height)?(H(t,`unmeasuredLabelsSkipped`),null):{edge:e,labelNode:r,sourceIndex:n}:null}).filter(e=>e!==null);if(l.length===0)return;let u=new Map(e.edges.map(e=>[e.id,e.points?.map(e=>({...e}))])),d=c(()=>{for(let t of e.edges){let e=u.get(t.id);e?t.points=e.map(e=>({...e})):delete t.points}},`restoreBaseEdgePoints`),f=c(()=>{d();for(let e of o){let t=s.get(e.id);t&&Number.isFinite(t.x)&&Number.isFinite(t.y)?(e.x=t.x,e.y=t.y):(delete e.x,delete e.y)}},`restoreBaseState`),p=l.filter(({edge:e,labelNode:n})=>V(e.points??[]).segments.length>0||(yt(e,n,a),H(t,`degenerateLabelRoutesSkipped`),!1)).sort((e,t)=>e.sourceIndex-t.sourceIndex||h(e.edge.id,t.edge.id));if(p.length===0)return;let m=c(()=>{d();for(let{edge:e,labelNode:t}of p)bt(e,t,a)},`placeLabelsAtRouteMidpoints`),g=r.maxIndexWork??re,_=new ue(Number.isFinite(g)&&g>=0?Math.floor(g):re,t),v=[];for(let r=1;r<=2;r++){H(t,`labelPasses`);let i=Re(e,_,t),a=new Map,o=new Map,s=new Map(e.edges.map(e=>[e.id,U(e,void 0,i).map(he)])),c=new Map;try{for(let{edge:e,labelNode:t}of p){let n=[...Pe(e,i)].sort((e,t)=>{let n=Te(t.segment)-Te(e.segment);return Math.abs(n)>z?n:e.order-t.order}),o=null;for(let r of n)if(o=Je(e,t,r.segment,i),o)break;if(!o){for(let r of n)if(o=Ye(e,t,r.segment,i,a),o)break}if(r===2&&!o){for(let r of n)if(o=_t(e,t,r,i,a),o)break}if(r===2&&!o){for(let r of n)if(o=gt(e,t,r,i,a),o)break}if(!o)throw new ce({edgeId:e.id,labelNodeId:t.id,labelWidth:t.width,labelHeight:t.height,pointCount:e.points?.length??0,points:e.points?.map(e=>({...e}))??[],segments:n.map(({segment:e})=>({orientation:e.orientation,length:Te(e),a:{...e.a},b:{...e.b}}))});t.x=o.x,t.y=o.y;let s={edgeId:e.id,nodeId:t.id,center:o,rect:pe(t,o)};a.set(e.id,s),Le(i,s)}let l=[...a.values()];H(t,`frozenReservations`,l.length),n&&(n.labelOverlayBuilds++,n.labelOverlayVertices+=l.length*4);for(let t of e.edges){let e=s.get(t.id)??[],n=U(t,void 0,i);JSON.stringify(n)!==JSON.stringify(e)&&c.set(t.id,n.map(he)),Ie(i,t,e.map(he))}for(let[e,t]of c){if(!a.has(e))continue;let n=i.edgeById.get(e);n&&Ie(i,n,t)}let u=new Set(c.keys());for(let t of e.edges){let e=a.get(t.id),n=U(t,void 0,i);for(let e of l)e.edgeId!==t.id&&C(n,e.rect)&&u.add(t.id);e&&!Ze(t.id,n,a)&&u.add(t.id)}let d=new Map;for(let n of e.edges){if(!u.has(n.id))continue;let e=U(n,void 0,i),s=new Map([[n.id,e]]),c=l.filter(t=>t.edgeId!==n.id&&C(e,t.rect));if(c.length>0){let r=c.slice(1).reduce((e,t)=>({cx:(Math.min(e.left,t.rect.left)+Math.max(e.right,t.rect.right))/2,cy:(Math.min(e.top,t.rect.top)+Math.max(e.bottom,t.rect.bottom))/2,left:Math.min(e.left,t.rect.left),right:Math.max(e.right,t.rect.right),top:Math.min(e.top,t.rect.top),bottom:Math.max(e.bottom,t.rect.bottom)}),{...c[0].rect}),l=ft(e,r,c),u=l?d.get(l.key)??0:0,f=(u+2)*12,p=mt(n,{cx:r.cx,cy:r.cy,left:r.left-f,right:r.right+f,top:r.top-f,bottom:r.bottom+f},i,a,s,l??void 0),m=p!==null;if(p??=ht(n,c,i,a,s),p)e=p,s.set(n.id,e),l&&m&&d.set(l.key,u+1);else{H(t,`labelOverlapFallbacks`);for(let r of c){if(!C(e,r.rect))continue;let i=o.get(r.edgeId)??new Set;i.has(n.id)||H(t,`labelOverlapReservations`),i.add(n.id),o.set(r.edgeId,i)}}}if(!Ze(n.id,e,a))throw D(`GRID_ROUTE_NOT_FOUND`,`Label anchor was lost for edge "${n.id}"`,{edgeId:n.id,pass:r});a.has(n.id)&&H(t,`preservedAnchors`),Ie(i,n,e),H(t,`impactedEdgeReroutes`)}for(let{edge:e,labelNode:t}of p){let n=a.get(e.id);if(!n||!Ze(e.id,U(e,void 0,i),a)||!Ge(n.rect,e,t.id,i,void 0,o.get(e.id)))throw D(`GRID_ROUTE_NOT_FOUND`,`Label pass ${r} did not validate`,{edgeId:e.id,pass:r})}return}catch(e){if(e instanceof le){m(),H(t,`indexWorkLimitFallbacks`),n&&(n.resourceLimitFallbacks++,n.fallbackReasons.label_index_work_cap++);return}if(!(e instanceof ce))throw f(),H(t,`rollbacks`),e;v.push(e),d();for(let{labelNode:e}of p)delete e.x,delete e.y}}m(),H(t,`placementSearchFallbacks`),n&&n.fallbackReasons.label_placement_exhausted++,i.warn(`[grid]`,`Label placement search exhausted; using route midpoints. Labels may overlap.`,{reason:`label_placement_exhausted`,edgeIds:p.map(({edge:e})=>e.id),failures:v.map(({details:e})=>e)})}c(wt,`positionGridEdgeLabels`);function Tt(e){return e.isGroup?e:void 0}c(Tt,`asGroup`);function Et(e){let t=new Map,n=new Map,r=new Set;for(let i of e){if(i.id===T)throw D(`GRID_INVALID_CONTAINMENT`,`Node id "${T}" is reserved for the grid layout root`,{traversedIds:[i.id]});if(t.has(i.id))throw D(`GRID_INVALID_CONTAINMENT`,`Duplicate node id "${i.id}"`,{traversedIds:[i.id]});if(t.set(i.id,i),k(i)){r.add(i.id);continue}let e=Tt(i);e&&n.set(e.id,e)}let i=new Map;i.set(T,[]);for(let t of e){if(r.has(t.id))continue;let e=t.parentId??T;if(e!==T&&!n.get(e))throw D(`GRID_INVALID_CONTAINMENT`,`Missing parent "${e}" for "${t.id}"`,{traversedIds:[t.id,e]});i.has(e)||i.set(e,[]),i.get(e).push(t)}let a=new Map,o=[],s=c(e=>(i.get(e)??[]).map(e=>Tt(e)).filter(e=>e!==void 0),`directChildGroups`),l=c(e=>{let t=a.get(e)??0;if(t===1)throw D(`GRID_INVALID_CONTAINMENT`,`Containment cycle at "${e}"`,{traversedIds:[e]});if(t===2)return;a.set(e,1);let r=[{groupId:e,childGroups:s(e),nextChildIndex:0}];for(;r.length>0;){let e=r[r.length-1],t=e.childGroups[e.nextChildIndex];if(t){e.nextChildIndex+=1;let n=a.get(t.id)??0;if(n===1)throw D(`GRID_INVALID_CONTAINMENT`,`Containment cycle at "${t.id}"`,{traversedIds:[...r.map(e=>e.groupId),t.id]});if(n===2)continue;a.set(t.id,1),r.push({groupId:t.id,childGroups:s(t.id),nextChildIndex:0});continue}r.pop(),a.set(e.groupId,2);let i=n.get(e.groupId);i&&o.push(i)}},`visit`);for(let e of i.get(T)??[]){let t=Tt(e);t&&l(t.id)}for(let e of n.keys())(a.get(e)??0)===0&&l(e);return{nodeById:t,groupById:n,childrenByParent:i,rootChildren:i.get(T)??[],postOrderGroups:o,helperNodeIds:r}}c(Et,`buildGridForest`);function Dt(e,t,n){let r=t,i=new Set;for(;r?.parentId;){if(r.parentId===e)return!0;if(i.has(r.parentId))return!1;i.add(r.parentId),r=n.get(r.parentId)}return!1}c(Dt,`isAncestorGroup`);function Ot(e,t,n){let r=new Map,i=new Map;for(let a of e.edges){if(!a.start||!a.end||!a.labelNodeId)continue;n&&n.labelSpacingEdgesExamined++;let e=t.nodeById.get(a.labelNodeId),o=t.nodeById.get(a.start),s=t.nodeById.get(a.end);if(!e||!o||!s)continue;if(a.start===a.end){let t=N(e,`H`);t&&i.set(a.id,t);continue}let c=o.parentId??T;if(c!==(s.parentId??T))continue;let l=r.get(c);l?l.push({edge:a,labelNode:e}):r.set(c,[{edge:a,labelNode:e}])}return{byContainer:r,selfLoops:i}}c(Ot,`buildGridLabelRequirements`);function kt(e,t,n){let r=new Map,i=0;for(let a of e)r.set(a,i),i+=(t.get(a)??0)+n;return r}c(kt,`trackOrigins`);function At(e,t,n,r,i){let a=kt(n,r,i),o=a.get(e),s=r.get(e);if(o===void 0||s===void 0)return!1;let c=o+s/2,l=c-t/2,u=c+t/2;return n.every(t=>{if(t===e)return!0;let n=a.get(t),i=n+(r.get(t)??0);return u<=n||l>=i})}c(At,`crossAxisFits`);function jt(e){let t=new Map;for(let n of e.values())for(let e of n.items)t.set(e.item.id,e);return t}c(jt,`placementByNodeId`);function Mt(e,t,n){let r=Math.min(e,t),i=Math.max(e,t),a=n.indexOf(r);return a>=0&&n[a+1]===i}c(Mt,`areConsecutive`);function Nt(e,t,n){e.set(t,Math.max(e.get(t)??0,n))}c(Nt,`addGapRequirement`);function Pt(e,t,n,r,i,a,o,s,l){let u=new Map,d=new Map,f=jt(t),p=c((e,t)=>N(e.labelNode,t),`requirementFor`);for(let t of e){let e=t.edge.start?f.get(t.edge.start):void 0,c=t.edge.end?f.get(t.edge.end):void 0;if(e&&c){if(e.row===c.row&&Mt(e.column,c.column,a)){let r=p(t,`H`);r&&At(e.row,r.cross,i,n,o)&&(l&&l.labelSpacingEligibleEdges++,Nt(d,Math.min(e.column,c.column),r.requiredAlongSpan))}else if(e.column===c.column&&Mt(e.row,c.row,i)){let n=p(t,`V`);n&&At(e.column,n.cross,a,r,s)&&(l&&l.labelSpacingEligibleEdges++,Nt(u,Math.min(e.row,c.row),n.requiredAlongSpan))}}}return{rowGapAfter:u,columnGapAfter:d}}c(Pt,`deriveGridContainerLabelGaps`);var Ft=`[grid]`,It=new Set([`basis`,`bumpX`,`bumpY`,`cardinal`,`catmullRom`,`linear`,`monotoneX`,`monotoneY`,`natural`,`step`,`stepAfter`,`stepBefore`,`rounded`]);function Lt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}c(Lt,`isObjectRecord`);function Rt(e){if(!Lt(e))return{};let t={};return Object.hasOwn(e,`row`)&&(t.row=e.row),Object.hasOwn(e,`column`)&&(t.column=e.column),s(e.horizontalAlign)&&(t.horizontalAlign=e.horizontalAlign),r(e.verticalAlign)&&(t.verticalAlign=e.verticalAlign),t}c(Rt,`ownPlacementFrom`);function zt(e){let t=new Map,n=0;for(let r of e)t.has(r.id)||t.set(r.id,n++);return t}c(zt,`buildGridSourceOrder`);function Bt(e){let t=Lt(e.config?.grid)?e.config.grid:{},n=Lt(t.placements)?t.placements:{},i=new Map;for(let e of Object.keys(n)){let t=n[e],r=Array.isArray(t)?t:[t];i.set(e,r.map(e=>Rt(e)))}return{placements:i,columns:typeof t.columns==`number`&&Number.isFinite(t.columns)&&t.columns>=0?Math.trunc(t.columns):O.columns,rowGap:typeof t.rowGap==`number`&&Number.isFinite(t.rowGap)&&t.rowGap>=0?t.rowGap:O.rowGap,columnGap:typeof t.columnGap==`number`&&Number.isFinite(t.columnGap)&&t.columnGap>=0?t.columnGap:O.columnGap,cellGap:typeof t.cellGap==`number`&&Number.isFinite(t.cellGap)&&t.cellGap>=0?t.cellGap:O.cellGap,containerPadding:typeof t.containerPadding==`number`&&Number.isFinite(t.containerPadding)&&t.containerPadding>=0?t.containerPadding:O.containerPadding,titleGap:typeof t.titleGap==`number`&&Number.isFinite(t.titleGap)&&t.titleGap>=0?t.titleGap:O.titleGap,horizontalAlign:s(t.horizontalAlign)?t.horizontalAlign:O.horizontalAlign,verticalAlign:r(t.verticalAlign)?t.verticalAlign:O.verticalAlign,curve:typeof t.curve==`string`&&It.has(t.curve)?t.curve:O.curve,edgeCornerRadius:o(t.edgeCornerRadius)}}c(Bt,`readGridConfig`);function Vt(e,t){let n=new Map;for(let t of e){let e=t.placementId??t.id;n.set(e,(n.get(e)??0)+1)}for(let[e,r]of t.placements){let t=n.get(e)??0;t===0?i.warn(Ft,`Ignoring grid placement for unknown target "${e}"`):r.length>t&&i.warn(Ft,`Ignoring ${r.length-t} extra grid placement occurrence(s) for target "${e}"; found ${t} matching node(s)`)}}c(Vt,`validateGridPlacementMap`);function Ht(e){return(t,n)=>{let r=e.get(t.id)??2**53-1,i=e.get(n.id)??2**53-1;return r===i?h(t.id,n.id):r-i}}c(Ht,`itemComparator`);function Ut(e,t,n,r){let o=e.placementId??e.id,s=n.placements.get(o)?.[r]??{},c=Rt(e.metadata);for(let t of[`row`,`column`,`horizontalAlign`,`verticalAlign`])Object.hasOwn(s,t)&&Object.hasOwn(c,t)&&s[t]!==c[t]&&i.debug(Ft,`metadata overrides placement map`,{nodeId:e.id,field:t,metadata:c[t],config:s[t]});let l=Object.hasOwn(c,`row`)?c.row:s.row,u=Object.hasOwn(c,`column`)?c.column:s.column;return a(o,`row`,l,e.id),a(o,`column`,u,e.id),{item:e,row:l??0,column:u??0,horizontalAlign:c.horizontalAlign??s.horizontalAlign??n.horizontalAlign,verticalAlign:c.verticalAlign??s.verticalAlign??n.verticalAlign,sourceOrder:t.get(e.id)??2**53-1,explicitRow:l!==void 0,explicitColumn:u!==void 0,explicitCell:l!==void 0&&u!==void 0}}c(Ut,`resolveItemPlacement`);function Wt(e,t,n){let r=n;for(;t.has(`${e}:${r}`);)r++;return r}c(Wt,`nextFreeColumn`);function Gt(e,t,n){let r=n;for(;t.has(`${r}:${e}`);)r++;return r}c(Gt,`nextFreeRow`);function Kt(e,t,n){let r=n;for(;;){let n=Math.floor(r/t)+1,i=r%t+1;if(r++,!e.has(`${n}:${i}`))return{row:n,column:i,nextIndex:r}}}c(Kt,`nextAutoCell`);function qt(e,t,n){let r=[...e].sort(Ht(t)),i=new Map,a=r.map(e=>{let r=e.placementId??e.id,a=i.get(r)??0;return i.set(r,a+1),Ut(e,t,n,a)}),o=new Map,s=new Set;for(let e of a){if(!e.explicitCell)continue;let t=`${e.row}:${e.column}`;s.add(t);let n=o.get(t);if(n){if(n.verticalAlign!==e.verticalAlign)throw D(`GRID_CELL_ALIGNMENT_CONFLICT`,`Conflicting vertical alignment in cell (${e.row}, ${e.column})`,{containerId:e.item.parentId??`root`,row:e.row,column:e.column,itemIds:[...n.items.map(e=>e.item.id),e.item.id],values:[...n.items.map(e=>e.verticalAlign),e.verticalAlign]});n.items.push(e)}else o.set(t,{row:e.row,column:e.column,items:[e],width:0,height:0,verticalAlign:e.verticalAlign})}let c=n.columns>0?n.columns:Math.max(1,Math.ceil(Math.sqrt(r.length))),l=0,u=new Map,d=new Map;for(let e of a){if(e.explicitCell)continue;if(e.explicitRow){let t=Wt(e.row,s,u.get(e.row)??1);e.column=t,u.set(e.row,t+1)}else if(e.explicitColumn){let t=Gt(e.column,s,d.get(e.column)??1);e.row=t,d.set(e.column,t+1)}else{let t=Kt(s,c,l);e.row=t.row,e.column=t.column,l=t.nextIndex}let t=`${e.row}:${e.column}`;s.add(t),o.set(t,{row:e.row,column:e.column,items:[e],width:0,height:0,verticalAlign:e.verticalAlign})}return{placements:a,cells:o}}c(qt,`resolveGridPlacements`);var Jt=class extends Error{constructor(e,t,n){super(t),this.reason=e,this.searchStateScope=n,this.name=`GridRoutingResourceLimitError`}static{c(this,`GridRoutingResourceLimitError`)}},W=6,Yt=24,Xt=5e4,Zt=4,Qt=67108864,$t=class{constructor(e,t){this.bands=e,this.strictBoundaryIntervals=t,this.byLow=new Map,this.byHigh=new Map,this.coordinateCount=new Set(e.flatMap(({low:e,high:t})=>[e,t])).size;let n=e.reduce((e,t)=>e+t.intervals.length,0);for(let e of t.values())n+=e.length;this.intervalCount=n;for(let t of e)this.byLow.set(t.low,t),this.byHigh.set(t.high,t);Object.freeze(this.bands),Object.freeze(this)}static{c(this,`CompressedIntervalIndex`)}containingBand(e){let t=0,n=this.bands.length-1;for(;t<=n;){let r=t+n>>>1,i=this.bands[r];if(e<=i.low)n=r-1;else if(e>=i.high)t=r+1;else return i}}overlaps(e,t,n){let r=0,i=e.length;for(;r<i;){let n=r+i>>>1;e[n][1]<=t?r=n+1:i=n}return r<e.length&&e[r][0]<n}intersects(e,t,n){let r=Math.min(t,n),i=Math.max(t,n),a=this.byHigh.get(e),o=this.byLow.get(e),s=a||o?void 0:this.containingBand(e);if(s)return this.overlaps(s.intervals,r,i);if(!a||!o)return!1;let c=0,l=0;for(;c<a.intervals.length&&l<o.intervals.length;){if(Math.max(r,a.intervals[c][0],o.intervals[l][0])<Math.min(i,a.intervals[c][1],o.intervals[l][1]))return!0;a.intervals[c][1]<o.intervals[l][1]?c++:l++}return!1}contains(e,t){let n=this.strictBoundaryIntervals.get(e)??this.containingBand(e)?.intervals;if(!n)return!1;let r=0,i=n.length;for(;r<i;){let e=r+i>>>1;n[e][0]<t?r=e+1:i=e}return r>0&&t<n[r-1][1]}nearestBoundary(e,t,n){let r=this.strictBoundaryIntervals.get(e)??this.containingBand(e)?.intervals;if(!r)return;if(n<0){let e=0,n=r.length;for(;e<n;){let i=e+n>>>1;r[i][1]<=t?e=i+1:n=i}return e>0?r[e-1][1]:void 0}let i=0,a=r.length;for(;i<a;){let e=i+a>>>1;r[e][0]<t?i=e+1:a=e}return i<r.length?r[i][0]:void 0}},en,tn=class{constructor(e){this.backing=e,this[en]=`ImmutableMap`,Object.freeze(this)}static{c(this,`ImmutableMap`)}get size(){return this.backing.size}entries(){return this.backing.entries()}forEach(e,t){for(let[n,r]of this.backing)e.call(t,r,n,this)}get(e){return this.backing.get(e)}has(e){return this.backing.has(e)}keys(){return this.backing.keys()}values(){return this.backing.values()}[(en=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}},nn,rn=class{constructor(e,t){this.base=e,this.overrides=t,this[nn]=`OverlayMap`}static{c(this,`OverlayMap`)}get size(){let e=0;for(let t of this.overrides.keys())this.base.has(t)||e++;return this.base.size+e}materialize(){return new Map([...this.base,...this.overrides])}entries(){return this.materialize().entries()}forEach(e,t){for(let[n,r]of this)e.call(t,r,n,this)}get(e){return this.overrides.get(e)??this.base.get(e)}has(e){return this.overrides.has(e)||this.base.has(e)}keys(){return this.materialize().keys()}values(){return this.materialize().values()}[(nn=Symbol.toStringTag,Symbol.iterator)](){return this.entries()}};function an(e,t){return new Proxy([],{get(n,r){if(r===`length`)return e.length+t.length;if(r===Symbol.iterator)return function*(){yield*e,yield*t};if(typeof r==`string`&&/^\d+$/.test(r)){let n=Number(r);return n<e.length?e[n]:t[n-e.length]}return Reflect.get(Array.prototype,r)}})}c(an,`overlayArray`);function on(e,t,n){return new Proxy([],{get(r,i){if(i===`length`)return n;if(i===Symbol.iterator)return function*(){for(let r=0;r<n;r++)yield t.get(r)??e[r]};if(typeof i==`string`&&/^\d+$/.test(i)){let n=Number(i);return t.get(n)??e[n]}return Reflect.get(Array.prototype,i)}})}c(on,`overrideArray`);var sn=class{constructor(e){this.base=e,this.addedVertices=[],this.adjacencyOverrides=new Map,this.searchAdjacencyOverrides=new Map,this.pointOverrides=new Map,this.undoLog=[],this.resetCount=0}static{c(this,`EndpointOverlayScratch`)}reset(e){if(e!==this.base)throw Error(`Endpoint overlay scratch cannot be shared across base topologies`);for(let e of this.undoLog)this.adjacencyOverrides.delete(e),this.searchAdjacencyOverrides.delete(e);this.undoLog.length=0,this.addedVertices.length=0,this.pointOverrides.clear(),this.resetCount++}setArcs(e,t){this.adjacencyOverrides.has(e)||this.undoLog.push(e),this.adjacencyOverrides.set(e,t),this.searchAdjacencyOverrides.set(e,Cn(t))}};function cn(e){return Object.is(e,-0)?0:e}c(cn,`normalizeCoordinate`);function ln(e){if(![e.left,e.right,e.top,e.bottom].every(Number.isFinite))throw Error(`Grid routing geometry must contain only finite coordinates`);let t=cn(Math.min(e.left,e.right)),n=cn(Math.max(e.left,e.right)),r=cn(Math.min(e.top,e.bottom)),i=cn(Math.max(e.top,e.bottom));if(t===n||r===i)throw Error(`Grid routing rectangles must have positive area`);return{left:t,right:n,top:r,bottom:i}}c(ln,`normalizeRect`);function un(e,t){let n=ln(e.bounds),r={id:e.id,left:Math.max(t.left,n.left-W),right:Math.min(t.right,n.right+W),top:Math.max(t.top,n.top-W),bottom:Math.min(t.bottom,n.bottom+W)};return r.left<r.right&&r.top<r.bottom?r:void 0}c(un,`inflateAndClip`);function dn(e){let t=[...e].sort((e,t)=>e.low-t.low||e.high-t.high||h(e.id,t.id)),n=[];for(let e of t){let t=n.at(-1);!t||e.low>t.high?n.push({...e}):(t.high=Math.max(t.high,e.high),h(e.id,t.id)<0&&(t.id=e.id))}return n}c(dn,`mergeObstacleIntervals`);function fn(e){let t=new Map;for(let n of e){let e=t.get(n.left)??{starts:[],ends:[]};e.starts.push(n),t.set(n.left,e);let r=t.get(n.right)??{starts:[],ends:[]};r.ends.push(n),t.set(n.right,r)}let n=[...t.keys()].sort((e,t)=>e-t),r=new Set,i=[],a=new Map;for(let e=0;e<n.length-1;e++){let o=n[e],s=n[e+1],c=t.get(o);for(let e of c.ends)r.delete(e);for(let e of c.starts)r.add(e);let l=new Map;for(let e of dn([...r].map(e=>({low:e.top,high:e.bottom,id:e.id})))){let t=`${e.low}:${e.high}`,n=a.get(t);if(n)n.right=s,h(e.id,n.id)<0&&(n.id=e.id);else{let n={id:e.id,left:o,right:s,top:e.low,bottom:e.high};i.push(n),l.set(t,n);continue}l.set(t,n)}a=l}return i.sort((e,t)=>e.top-t.top||e.left-t.left||e.bottom-t.bottom||e.right-t.right||h(e.id,t.id))}c(fn,`unionObstacles`);function G(e){return`${cn(e.x)}:${cn(e.y)}`}c(G,`routingPointKey`);function pn(e){return e===`left`?0:e===`right`?1:e===`top`?2:e===`bottom`?3:4}c(pn,`topologySideOrdinal`);function mn(e,t){return h(e.kind,t.kind)||pn(e.side)-pn(t.side)||e.point.x-t.point.x||e.point.y-t.point.y||h(e.ownerId??``,t.ownerId??``)}c(mn,`vertexRecordOrder`);function hn(e){let t=new Map;for(let n of[...e].sort(mn)){let e={...n,point:{x:cn(n.point.x),y:cn(n.point.y)}},r=G(e.point);t.has(r)||t.set(r,e)}return[...t.values()]}c(hn,`canonicalRecords`);function gn(e,t,n=`corner`){return[{point:{x:e.left,y:e.top},kind:n,ownerId:t},{point:{x:e.right,y:e.top},kind:n,ownerId:t},{point:{x:e.left,y:e.bottom},kind:n,ownerId:t},{point:{x:e.right,y:e.bottom},kind:n,ownerId:t}]}c(gn,`cornerRecords`);function _n(e,t){let n=e.coordinate??(e.side===`left`?t.left:e.side===`right`?t.right:e.side===`top`?t.top:t.bottom);return(e.side===`left`||e.side===`right`?[{x:n,y:e.low},{x:n,y:e.high}]:[{x:e.low,y:n},{x:e.high,y:n}]).map(t=>({point:t,kind:`portal`,ownerId:e.ownerId,side:e.side}))}c(_n,`portalRecords`);function vn(e,t,n,r,i){if(t===`left`||t===`right`)return{x:r.nearestBoundary(e.y,e.x,t===`left`?-1:1)??(t===`left`?n.left:n.right),y:e.y};let a=i.nearestBoundary(e.x,e.y,t===`top`?-1:1)??(t===`top`?n.top:n.bottom);return{x:e.x,y:a}}c(vn,`rayHit`);function yn(e,t,n){let r=[...new Set(e.flatMap(e=>t===`H`?[e.top,e.bottom]:[e.left,e.right]))].sort((e,t)=>e-t),i=[],a=new Map,o=new Map,s=new Map;for(let n of e){let e=t===`H`?n.top:n.left,r=t===`H`?n.bottom:n.right,i=o.get(e)??[];i.push(n),o.set(e,i);let a=s.get(r)??[];a.push(n),s.set(r,a)}let l=new Set,u=c(()=>dn([...l].map(e=>t===`H`?{low:e.left,high:e.right,id:e.id}:{low:e.top,high:e.bottom,id:e.id})),`activeIntervals`),d=c(t=>{let r=n.intervalCount+t.length;return xn(bn(0,0,e.length,r),n.maxEstimatedBytes,`estimated_memory_cap`),n.intervalCount=r,Object.freeze(t.map(e=>Object.freeze([e.low,e.high])))},`freezeIntervals`);for(let e=0;e<r.length;e++){let t=r[e];for(let e of s.get(t)??[])l.delete(e);a.set(t,d(u()));for(let e of o.get(t)??[])l.add(e);let n=r[e+1];if(n===void 0)continue;let c=u();c.length>0&&i.push({low:t,high:n,intervals:d(c)})}return new $t(Object.freeze(i),new tn(a))}c(yn,`createIntervalIndex`);function bn(e,t,n,r){return e*64+t*56+n*48+r*24}c(bn,`estimatedTopologyBytes`);function xn(e,t,n){if(e>t)throw new Jt(n,`Grid routing ${n} exceeded: ${e} > ${t}`)}c(xn,`enforceCap`);function Sn(e,t){let n=new Map;for(let r of e){let e=t===`H`?r.point.y:r.point.x,i=n.get(e)??[];i.push(r),n.set(e,i)}for(let e of n.values())e.sort((e,n)=>t===`H`?e.point.x-n.point.x||e.id-n.id:e.point.y-n.point.y||e.id-n.id),Object.freeze(e);return new tn(n)}c(Sn,`indexVertexLines`);function Cn(e){return Object.freeze(e.map(e=>Object.freeze({to:e.to,orientationOrdinal:e.orientation===`H`?1:2,length:e.length,boundaryTransitions:+(e.kind===`portal`)})))}c(Cn,`searchArcs`);function wn(e,t,n,r){let i=hn(e).sort(mn),a=r.maxVertices??Xt;xn(i.length,a,`vertex_cap`);let o=i.map((e,t)=>Object.freeze({id:t,...e,point:Object.freeze({...e.point})})),s=new Map(o.map(e=>[e.id,[]])),l=c((e,t,n)=>{let r=Math.abs(e.point.x-t.point.x)+Math.abs(e.point.y-t.point.y);if(r===0)return;let i=n===`H`?Math.min(e.point.x,t.point.x):Math.min(e.point.y,t.point.y),a=i+r;for(let[o,c]of[[e,t],[t,e]])s.get(o.id).push({from:o.id,to:c.id,orientation:n,length:r,kind:`visibility`,intervalStart:i,intervalEnd:a})},`addArcPair`);for(let e of[`H`,`V`]){let r=new Map;for(let t of o){let n=e===`H`?t.point.y:t.point.x,i=r.get(n)??[];i.push(t),r.set(n,i)}for(let[i,a]of r){a.sort((t,n)=>e===`H`?t.point.x-n.point.x||t.id-n.id:t.point.y-n.point.y||t.id-n.id);for(let r=1;r<a.length;r++){let o=a[r-1],s=a[r],c=e===`H`?o.point.x:o.point.y,u=e===`H`?s.point.x:s.point.y;(e===`H`?t:n).intersects(i,c,u)||l(o,s,e)}}}let u={visibility:0,terminal:1,portal:2,lane:3},d=0,f=new Map;for(let e of o){let t=s.get(e.id);t.sort((e,t)=>u[e.kind]-u[t.kind]||h(e.orientation,t.orientation)||o[e.to].point.x-o[t.to].point.x||o[e.to].point.y-o[t.to].point.y||e.to-t.to);let n=t.filter((e,n)=>n===0||e.to!==t[n-1].to||e.orientation!==t[n-1].orientation||e.kind!==t[n-1].kind);d+=n.length,f.set(e.id,Object.freeze(n.map(e=>Object.freeze(e))))}return xn(d,r.maxAdjacencyEntries??a*Zt,`adjacency_cap`),{vertices:Object.freeze(o),adjacency:new tn(f),adjacencyEntries:d}}c(wn,`buildVisibilityGraph`);function Tn(e,t,n){let r=ln(t),i=n?ln(n):void 0,a=Math.max(r.top+W,(i?.bottom??-1/0)+W),o=r.bottom-W,s=r.left+W,c=r.right-W,l=[];return a<=o&&l.push({ownerId:e,side:`left`,low:a,high:o},{ownerId:e,side:`right`,low:a,high:o}),s<=c&&(l.push({ownerId:e,side:`bottom`,low:s,high:c}),(!i||i.bottom+W<=r.top)&&l.push({ownerId:e,side:`top`,low:s,high:c})),l}c(Tn,`derivePortalRanges`);function En(e,t,n,r,i){let a=Tn(e,t,n).find(e=>e.side===r);if(!a||i<a.low||i>a.high)throw Error(`Illegal ${r} portal for "${e}" at ${i}`);let o=r===`left`?t.left:r===`right`?t.right:r===`top`?t.top:t.bottom,s=r===`left`||r===`top`?o+W:o-W,c=r===`left`||r===`top`?o-W:o+W,l=r===`left`||r===`right`?{x:s,y:i}:{x:i,y:s},u=r===`left`||r===`right`?{x:c,y:i}:{x:i,y:c};return{ownerId:e,side:r,tangentialCoordinate:i,interior:l,exterior:u,transition:{from:l,to:u,orientation:r===`left`||r===`right`?`H`:`V`,length:W*2,kind:`portal`}}}c(En,`buildPairedPortal`);function Dn(e,t={}){let n=ln(e.bounds),r=fn([...e.obstacles,...e.titleExclusions??[]].map(e=>un(e,n)).filter(e=>!!e)),i=[...e.portalRanges??[]].sort((e,t)=>pn(e.side)-pn(t.side)||e.low-t.low||e.high-t.high||h(e.ownerId,t.ownerId)),a=hn([...gn(n,e.containerId),...r.flatMap(e=>gn(e,e.id)),...i.flatMap(e=>_n(e,n))]),o={intervalCount:0,maxEstimatedBytes:t.caps?.maxEstimatedBytes??Qt};xn(bn(0,0,r.length,0),o.maxEstimatedBytes,`estimated_memory_cap`);let s=yn(r,`H`,o),c=yn(r,`V`,o),l=[],u=[`left`,`right`,`top`,`bottom`];for(let e of a)for(let t of u){let r=vn(e.point,t,n,s,c);(r.x!==e.point.x||r.y!==e.point.y)&&l.push({point:r,kind:`projection`,side:t})}let{vertices:d,adjacency:f,adjacencyEntries:p}=wn([...a,...l],s,c,t.caps??{}),m=bn(d.length,p,r.length,s.intervalCount+c.intervalCount);return xn(m,t.caps?.maxEstimatedBytes??Qt,`estimated_memory_cap`),t.metrics&&(t.metrics.containersBuilt++,t.metrics.baseTopologyBuilds++,t.metrics.baseVertices+=d.length,t.metrics.baseAdjacencyEntries+=p,t.metrics.buildSweepEvents+=a.length*4+r.length*4,t.metrics.estimatedBytes+=m),Object.freeze({containerId:e.containerId,bounds:Object.freeze(n),obstacles:Object.freeze(r.map(e=>Object.freeze(e))),vertices:Object.freeze(d),pointVertexIds:new tn(new Map(d.map(({id:e,point:t})=>[G(t),e]))),horizontalVertexLines:Sn(d,`H`),verticalVertexLines:Sn(d,`V`),adjacency:f,adjacencyByVertex:Object.freeze(d.map(({id:e})=>f.get(e)??[])),searchAdjacencyByVertex:Object.freeze(d.map(({id:e})=>Cn(f.get(e)??[]))),adjacencyEntries:p,horizontalIntervals:s,verticalIntervals:c,portalRanges:Object.freeze(i.map(e=>Object.freeze(e))),seedCount:a.length,estimatedBytes:m})}c(Dn,`buildContainerRoutingTopology`);function On(e,t){return t.contains(e.y,e.x)}c(On,`pointInsideObstacle`);function kn(e,t,n,r,i,a=[]){let o=i??new sn(e);o.reset(e);let s=[{point:t,kind:`endpoint`,ownerId:`source`},{point:n,kind:`endpoint`,ownerId:`target`},...a.filter(t=>!On(t,e.horizontalIntervals)).map(e=>({point:e,kind:`lane`}))];for(let r of[{x:t.x,y:n.y},{x:n.x,y:t.y}])On(r,e.horizontalIntervals)||s.push({point:r,kind:`projection`});for(let t of s.slice(0,2))for(let n of[`left`,`right`,`top`,`bottom`]){let r=vn(t.point,n,e.bounds,e.horizontalIntervals,e.verticalIntervals);(r.x!==t.point.x||r.y!==t.point.y)&&s.push({point:r,kind:`projection`,side:n})}let l=hn(s).filter(({point:t})=>!e.pointVertexIds.has(G(t))).sort(mn);xn(l.length,32,`vertex_cap`),o.addedVertices.push(...l.map((t,n)=>Object.freeze({id:e.vertices.length+n,...t,point:Object.freeze({...t.point})})));let u=an(e.vertices,o.addedVertices),d=c(t=>t<e.vertices.length?e.vertices[t]:o.addedVertices[t-e.vertices.length],`vertexAt`),f=new Map,p=c(t=>{let n=f.get(t);return n||(n=[...e.adjacency.get(t)??[]],f.set(t,n)),n},`mutableArcs`);for(let e of o.addedVertices)f.set(e.id,[]);let m=new Set(o.addedVertices.map(({id:e})=>e)),g=new Set,_=c((t,n,r)=>{let i=Math.abs(t.point.x-n.point.x)+Math.abs(t.point.y-n.point.y);if(i===0)return;let a=r===`H`?Math.min(t.point.x,n.point.x):Math.min(t.point.y,n.point.y),o=a+i;for(let[s,c]of[[t,n],[n,t]]){let t=`${s.id}:${c.id}:${r}:visibility`;g.has(t)||(e.adjacency.get(s.id)??[]).some(e=>e.to===c.id&&e.orientation===r&&e.kind===`visibility`)||(g.add(t),p(s.id).push({from:s.id,to:c.id,orientation:r,length:i,kind:`visibility`,intervalStart:a,intervalEnd:o}))}},`connect`);for(let t of[`H`,`V`]){let n=t===`H`?e.horizontalVertexLines:e.verticalVertexLines,r=new Set(o.addedVertices.map(({point:e})=>t===`H`?e.y:e.x));for(let i of r){let r=[...n.get(i)??[],...o.addedVertices.filter(({point:e})=>(t===`H`?e.y:e.x)===i)];r.sort((e,n)=>t===`H`?e.point.x-n.point.x||e.id-n.id:e.point.y-n.point.y||e.id-n.id);for(let n=1;n<r.length;n++){let a=r[n-1],o=r[n];if(!m.has(a.id)&&!m.has(o.id))continue;let s=t===`H`?a.point.x:a.point.y,c=t===`H`?o.point.x:o.point.y;(t===`H`?e.horizontalIntervals:e.verticalIntervals).intersects(i,s,c)||_(a,o,t)}}}for(let[e,t]of f){t.sort((e,t)=>h(e.kind,t.kind)||h(e.orientation,t.orientation)||d(e.to).point.x-d(t.to).point.x||d(e.to).point.y-d(t.to).point.y||e.to-t.to);let n=Object.freeze(t.map(e=>Object.freeze(e)));o.setArcs(e,n)}let v=e.adjacencyEntries+g.size;xn(v,e.adjacencyEntries+64,`adjacency_cap`);let y=l.length,b=e.estimatedBytes+y*64+(v-e.adjacencyEntries)*56;r&&(r.endpointOverlayBuilds++,r.endpointOverlayVertices+=y,r.estimatedBytes=Math.max(r.estimatedBytes,b));let x=e.vertices.length+o.addedVertices.length,S=on(e.adjacencyByVertex,o.adjacencyOverrides,x),C=on(e.searchAdjacencyByVertex,o.searchAdjacencyOverrides,x);for(let e of o.addedVertices)o.pointOverrides.set(G(e.point),e.id);return Object.freeze({...e,vertices:u,pointVertexIds:new rn(e.pointVertexIds,o.pointOverrides),adjacency:new rn(e.adjacency,o.adjacencyOverrides),adjacencyByVertex:S,searchAdjacencyByVertex:C,adjacencyEntries:v,estimatedBytes:b,vertexCount:x,getVertex:d,getSearchArcs:c(t=>o.searchAdjacencyOverrides.get(t)??e.searchAdjacencyByVertex[t]??[],`getSearchArcs`)})}c(kn,`buildEndpointRoutingOverlay`);var An=4,K=20,jn=8;function Mn(e){return!!e.groupTitleRect}c(Mn,`ownerGroupTitle`);function Nn(e,t){return JSON.stringify([e,t])}c(Nn,`ownerSideKey`);function Pn(e,t){let n=g(e),r=t.x-n.cx,i=t.y-n.cy,a=e.isGroup&&Mn(e);return Math.abs(r)>=Math.abs(i)?r>=0?`right`:`left`:i>=0?`bottom`:a?r>=0?`right`:`left`:`top`}c(Pn,`preferredSide`);function Fn(e,t){let n=[],r=e.parentId??T,i=new Set;for(;n.push(r),!(r===T||i.has(r));)i.add(r),r=t.get(r)?.parentId??T;return n}c(Fn,`containerChain`);function In(e,t,n){if(e.isGroup&&Dt(e.id,t,n))return e.parentId??T;if(t.isGroup&&Dt(t.id,e,n))return t.parentId??T;let r=new Set(Fn(t,n));for(let t of Fn(e,n))if(r.has(t))return t;return T}c(In,`commonContainerId`);function Ln(e,t){return t===`left`||t===`right`?e.cy:e.cx}c(Ln,`oppositeCoordFor`);function Rn(e,t){return t===`left`||t===`right`?{x:t===`left`?e.left:e.right,y:e.cy}:{x:e.cx,y:t===`top`?e.top:e.bottom}}c(Rn,`sideMidpoint`);function zn(e,t){return t===`left`||t===`right`?e.y:e.x}c(zn,`tangentialCoordinate`);function Bn(e,t,n,r,i,a){let o=[],s=g(e),c=g(t),u={x:t.x??0,y:t.y??0},d=e;for(;;){let f=d.parentId??T,p=r.get(f),m={x:d.x??0,y:d.y??0},h=u.x-m.x,g=u.y-m.y,_=g<0&&Math.abs(h)<=l&&!!((d.isGroup?d.groupTitleRect:void 0)??p?.groupTitleRect),v=[];Math.abs(Math.abs(h)-Math.abs(g))<=l&&Math.abs(h)>l&&v.push(h>=0?`right`:`left`,g>=0?`bottom`:`top`);let y=!!((d.isGroup?d.groupTitleRect:void 0)??p?.groupTitleRect),b=(_?[`left`,`right`]:v).filter(e=>e!==`top`||!y),x=Pn(d,u);if(x===`top`&&p?.groupTitleRect&&(x=h>=0?`right`:`left`),o.push({ownerId:d.id,side:x,demandKey:JSON.stringify([i,a,d.id,x]),oppositeCoord:Ln(c,x),preferredCoord:Ln(s,x),compactPortal:d.id!==e.id,ambiguousSides:b.length>1?b:void 0,inner:o.length?{demandKey:o[o.length-1].demandKey,side:o[o.length-1].side}:void 0}),d.isGroup&&d.id===n&&Dt(d.id,t,r))return{chain:o,finalKind:`boundary`};if(f===n)return{chain:o,finalKind:`item`};if(!p?.isGroup)throw D(`GRID_INVALID_CONTAINMENT`,`Missing parent group "${f}"`,{traversedIds:o.map(e=>e.ownerId)});d=p}}c(Bn,`buildEndpointPlan`);function Vn(e){let t=new Map;for(let n of e){if(!n.start||!n.end)continue;let e=n.start<n.end?`${n.start}|${n.end}`:`${n.end}|${n.start}`;t.has(e)||t.set(e,[]),t.get(e).push(n)}let n=new Map;for(let[e,r]of t)r.sort((e,t)=>h(`${e.start}|${e.end}`,`${t.start}|${t.end}`)||h(e.id,t.id)),r.forEach((t,i)=>n.set(t.id,{index:i,size:r.length,offset:(i-(r.length-1)/2)*jn,pairKey:e}));return n}c(Vn,`buildPairLanes`);function Hn(e,t){let n=new Map,r=c((e,t)=>Nn(e,t),`reservationKey`);for(let t of e)for(let e of[...t.source.chain,...t.target.chain])if(!e.ambiguousSides){let t=r(e.ownerId,e.side);n.set(t,(n.get(t)??0)+1)}let i=c((e,i,a)=>{let o=i.chain.filter(({ambiguousSides:e})=>e);if(o.length===0)return;let s=[`right`,`bottom`,`left`,`top`].filter(e=>o.every(t=>t.ambiguousSides?.includes(e))&&o.every(n=>{let r=t.forest.nodeById.get(n.ownerId);return r!==void 0&&q(r,e)!==void 0})).sort((e,t)=>o.reduce((t,i)=>t+(n.get(r(i.ownerId,e))??0),0)-o.reduce((e,i)=>e+(n.get(r(i.ownerId,t))??0),0)||Number(e!==o[0].side)-Number(t!==o[0].side))[0];if(s){for(let e of o){e.side=s;let i=r(e.ownerId,s);n.set(i,(n.get(i)??0)+1);let a=t.forest.nodeById.get(e.ownerId);a&&(e.preferredCoord=Ln(g(a),s))}for(let[t,n]of i.chain.entries())n.demandKey=JSON.stringify([e.edge.id,a,n.ownerId,n.side]),n.inner=t>0?{demandKey:i.chain[t-1].demandKey,side:i.chain[t-1].side}:void 0}},`resolveEndpoint`),a=e.flatMap(e=>[{plan:e,endpoint:e.source,role:`source`},{plan:e,endpoint:e.target,role:`target`}]).sort((e,t)=>h(`${e.plan.edge.start??``}|${e.plan.edge.end??``}|${e.plan.edge.id}|${e.role}`,`${t.plan.edge.start??``}|${t.plan.edge.end??``}|${t.plan.edge.id}|${t.role}`));for(let{plan:e,endpoint:t,role:n}of a)i(e,t,n);for(let n of e){let e=n.source.chain.at(-1),r=n.target.chain.at(-1),i=e?t.forest.nodeById.get(e.ownerId):void 0,a=r?t.forest.nodeById.get(r.ownerId):void 0;if(!e||!r||!i||!a)continue;let o=Rn(g(i),e.side),s=Rn(g(a),r.side);for(let e of n.source.chain)e.oppositeCoord=zn(s,e.side);for(let e of n.target.chain)e.oppositeCoord=zn(o,e.side)}}c(Hn,`resolveAmbiguousEndpointSides`);function Un(e,t){let n=t.forest.nodeById,r=Vn(e.edges),i=e.edges.map(e=>{let t=e.start?n.get(e.start):void 0,i=e.end?n.get(e.end):void 0;if(!t||!i)throw D(`GRID_MISSING_ENDPOINT`,`Missing endpoint for edge "${e.id}"`,{edgeId:e.id,start:e.start,end:e.end});let a=In(t,i,n),o=r.get(e.id)??{index:0,size:1,offset:0,pairKey:qn(e)};return{edge:e,lcaContainerId:a,source:Bn(t,i,a,n,e.id,`source`),target:Bn(i,t,a,n,e.id,`target`),laneIndex:o.index,laneOffset:o.offset,bundleSize:o.size,pairKey:o.pairKey}});return Hn(i,t),i}c(Un,`collectRoutePlans`);function Wn(e,t,n){let r=[];for(let[t,n]of e.entries())r.push(t===0?n:Math.max(n,r[t-1]+An));for(let e=r.length-1;e>=0;e--)r[e]=Math.min(r[e],e===r.length-1?n:r[e+1]-An);let i=e.reduce((e,t)=>e+t,0)/e.length,a=r.reduce((e,t)=>e+t,0)/r.length,o=t-r[0],s=n-r[r.length-1],c=w(i-a,o,s);return r.map(e=>e+c)}c(Wn,`assignCompactPortalCoordinates`);function Gn(e,t,n){let r=t.forest.nodeById,i=new Map(e.map(e=>[e.edge.id,e])),a=new Map;for(let t of e)if(t.edge.start!==t.edge.end)for(let e of[...t.source.chain,...t.target.chain])a.has(e.demandKey)||a.set(e.demandKey,{ownerId:e.ownerId,side:e.side,edgeId:t.edge.id,demandKey:e.demandKey,oppositeCoord:e.oppositeCoord,preferredCoord:e.preferredCoord,compactPortal:e.compactPortal,inner:e.inner});let o=new Map;for(let e of a.values()){let t=Nn(e.ownerId,e.side),n=o.get(t)??{ownerId:e.ownerId,side:e.side,demands:[]};n.demands.push(e),o.set(t,n)}let s=c(e=>{let t=r.get(e);return t?Fn(t,r).length:0},`depthOf`),u=[...o.values()].sort((e,t)=>Number(e.demands.every(e=>e.compactPortal))-Number(t.demands.every(e=>e.compactPortal))||s(t.ownerId)-s(e.ownerId)),d=new Map;for(let{ownerId:e,side:o,demands:s}of u){let u=r.get(e);if(!u)continue;let f=g(u),p=o===`left`||o===`right`?f.top+W:f.left+W,m=o===`left`||o===`right`?f.bottom-W:f.right-W;(o===`left`||o===`right`)&&u.groupTitleRect&&(p=Math.max(p,u.groupTitleRect.bottom+W));let _=Math.max(0,m-p);s.sort((e,t)=>e.oppositeCoord-t.oppositeCoord||h(e.edgeId,t.edgeId));let v=s.map(e=>i.get(e.edgeId)),y=new Set(v.map(e=>e?.pairKey)),b=u.isGroup&&s.every(({compactPortal:e})=>e);if(!(b&&s.length===1)&&y.size===1&&v.every(e=>e&&e.bundleSize===s.length&&n.get(e.edge.start)===e.bundleSize&&n.get(e.edge.end)===e.bundleSize)){let e=(p+m)/2,t=v.map(t=>e+t.laneOffset);if(t.every(e=>e>=p&&e<=m)){s.forEach((e,n)=>d.set(e.demandKey,t[n]));continue}}if(b){let e=t.containers.get(u.id),n=o===`left`||o===`right`?e?.horizontalCorridors:e?.verticalCorridors,i=c(e=>{let t=e.inner?a.get(e.inner.demandKey):void 0,n=t?r.get(t.ownerId):void 0,i=t?d.get(t.demandKey):void 0;if(!t||!n||i===void 0)return e.preferredCoord;let s=Rn(g(n),t.side);return t.side===`left`||t.side===`right`?s.y=i:s.x=i,zn(s,o)},`innerCoordinate`),f=c(e=>{let t=e.inner?d.get(e.inner.demandKey):void 0,r=w(e.inner!==void 0&&t!==void 0&&(e.inner.side===`left`||e.inner.side===`right`)==(o===`left`||o===`right`)?t:e.preferredCoord,p,m),i=n?.reduce((e,t)=>Math.abs(t-r)<Math.abs(e-r)?t:e,n[0]);return i!==void 0&&Math.abs(i-r)<=l?i:r},`preferredCoordinate`);if(s.length===1){d.set(s[0].demandKey,f(s[0]));continue}if(_>=An*(s.length-1)){s.sort((e,t)=>i(e)-i(t)||e.oppositeCoord-t.oppositeCoord||h(e.edgeId,t.edgeId));let e=Wn(s.map(f),p,m);s.forEach((t,n)=>d.set(t.demandKey,e[n]));continue}}if(s.length===1||_<=0){d.set(s[0].demandKey,(p+m)/2);continue}let x=_/(s.length-1);s.forEach((e,t)=>{d.set(e.demandKey,p+x*t)})}for(let t of e){if(t.bundleSize!==1)continue;let e=t.source.chain.at(-1),n=t.target.chain.at(-1);if(!e||!n)continue;let i=c(e=>e===`left`||e===`right`,`verticalSide`);if(i(e.side)!==i(n.side))continue;let a=d.get(e.demandKey),o=d.get(n.demandKey);if(a===void 0||o===void 0||Math.abs(a-o)>l)continue;let s=[...t.source.chain,...t.target.chain];if(s.some(t=>i(t.side)!==i(e.side)))continue;let u=[a,o].find(e=>s.every(t=>{let n=r.get(t.ownerId),i=n?q(n,t.side):void 0;return i!==void 0&&e>=i.low-l&&e<=i.high+l}));u!==void 0&&s.forEach(e=>d.set(e.demandKey,u))}return d}c(Gn,`assignDemandCoordinates`);function Kn(e){return e===`right`?0:e===`bottom`?1:e===`left`?2:3}c(Kn,`sideOrder`);function q(e,t){let n=g(e);if(t===`top`&&e.groupTitleRect)return;let r=t===`left`||t===`right`?n.top+W:n.left+W,i=t===`left`||t===`right`?n.bottom-W:n.right-W;return(t===`left`||t===`right`)&&e.groupTitleRect&&(r=Math.max(r,e.groupTitleRect.bottom+W)),r<=i?{low:r,high:i}:void 0}c(q,`sideInterval`);function qn(e){let t=e.start??``,n=e.end??``;return t<n?`${t}|${n}`:`${n}|${t}`}c(qn,`endpointPairKey`);function Jn(e,t,n){let r=g(e.opposite),i=g(t.opposite);return(n===`left`||n===`right`?r.cy:r.cx)-(n===`left`||n===`right`?i.cy:i.cx)||h(qn(e.plan.edge),qn(t.plan.edge))||h(`${e.plan.edge.start}|${e.plan.edge.end}`,`${t.plan.edge.start}|${t.plan.edge.end}`)||h(e.plan.edge.id,t.plan.edge.id)||h(e.role,t.role)}c(Jn,`compareEndpointDemands`);function Yn(e){return`${e.plan.edge.id}:${e.role}`}c(Yn,`endpointDemandKey`);function Xn(e,t){return h(qn(e.plan.edge),qn(t.plan.edge))||h(`${e.plan.edge.start}|${e.plan.edge.end}`,`${t.plan.edge.start}|${t.plan.edge.end}`)||h(e.plan.edge.id,t.plan.edge.id)||h(e.role,t.role)}c(Xn,`compareEndpointDemandIdentity`);function Zn(e,t,n){let r=q(e,t);if(!r||n.length===0)return new Map;let i=[...n].sort((e,n)=>Jn(e,n,t));if(i.length===1){let n=g(e),a=t===`left`||t===`right`?n.cy:n.cx;return new Map([[i[0],w(a,r.low,r.high)]])}if((r.high-r.low)/(i.length-1)<An)return new Map(i.map((e,t)=>[e,r.low+t*(r.high-r.low)/(i.length-1)]));let a=Wn(i.map(({opposite:e})=>{let n=g(e);return w(t===`left`||t===`right`?n.cy:n.cx,r.low,r.high)}),r.low,r.high);return new Map(i.map((e,t)=>[e,a[t]]))}c(Zn,`preferredEndpointCoordinates`);function Qn(e,t){let n=q(e,t);return n?1+Math.floor((n.high-n.low)/An):0}c(Qn,`endpointSideCapacity`);function $n(e,t){let n=g(t.opposite),r=Pn(e,{x:n.cx,y:n.cy});return[`right`,`bottom`,`left`,`top`].filter(t=>Qn(e,t)>0).sort((t,i)=>{if(t===r)return-1;if(i===r)return 1;let a=g(e),o=Rn(a,t),s=Rn(a,i);return Math.abs(o.x-n.cx)+Math.abs(o.y-n.cy)-(Math.abs(s.x-n.cx)+Math.abs(s.y-n.cy))||Kn(t)-Kn(i)})}c($n,`endpointSidePreferences`);function er(e,t){let n=g(e),r=g(t.opposite);return Math.abs(n.cx-r.cx)<=l||Math.abs(n.cy-r.cy)<=l}c(er,`isAxisAlignedDemand`);function tr(e,t,n,r){let i=q(e,t);if(!i)return;let a=[...n],o=new Map;for(let e of r){let n=g(e.opposite),r=w(t===`left`||t===`right`?n.cy:n.cx,i.low,i.high),s=[r,i.low,i.high,...a.flatMap(e=>[e-Yt,e+Yt])].filter(e=>e>=i.low-l&&e<=i.high+l&&a.every(t=>Math.abs(e-t)>=Yt-l)).sort((e,t)=>Math.abs(e-r)-Math.abs(t-r)||e-t);if(s.length===0)return;o.set(e,s[0]),a.push(s[0])}return o}c(tr,`placePortsBesideFixed`);function nr(e,t){let n=new Map,r=new Map([`right`,`bottom`,`left`,`top`].map(t=>[t,Qn(e,t)])),i=[...t].sort(Xn),a=i.filter(t=>er(e,t)),o=i.filter(t=>!er(e,t)),s=new Set,l=new Map,u=new Map,d=c(e=>(n.get(e)?.length??0)<(r.get(e)??0),`hasCapacity`),f=c((e,t)=>{let r=n.get(t)??[];r.push(e),n.set(t,r)},`record`),p=c(t=>{let n=$n(e,t).find(d);n&&(f(t,n),s.add(n))},`assignAligned`),m=c((t,n)=>{let r=u.get(n)??new Map,i=tr(e,n,[...l.get(n)??[],...r.values()],[t]);return i?(r.set(t,i.get(t)),u.set(n,r),f(t,n),!0):!1},`tryShareReservedSide`),h=c(t=>{let n=$n(e,t).filter(d),r=n.find(e=>!s.has(e));if(n.find(e=>(r===void 0||n.indexOf(e)<n.indexOf(r))&&s.has(e)&&m(t,e)))return;let i=r??n[0];i&&f(t,i)},`assignUnaligned`);for(let e of a)p(e);for(let[t,r]of n)l.set(t,[...Zn(e,t,r).values()]);for(let e of o)h(e);let g=new Map;for(let[t,r]of n){let n=q(e,t);if(!n)continue;let i=u.get(t),a=i?r.filter(e=>!i.has(e)):r,o=new Map([...Zn(e,t,a),...i??[]]),s=[...r].sort((e,n)=>Jn(e,n,t));for(let[e,r]of s.entries()){let i=o.get(r)??(s.length===1?(n.low+n.high)/2:n.low+e*(n.high-n.low)/(s.length-1));g.set(Yn(r),{side:t,coordinate:i})}}return g}c(nr,`allocateEndpointSlots`);function rr(e,t,n,r,i,a){let o=t===`source`?e.edge.start:e.edge.end,s=t===`source`?e.edge.end:e.edge.start,l=a.forest.nodeById.get(o),u=a.forest.nodeById.get(s);if(!l||!u)throw D(`GRID_MISSING_ENDPOINT`,`Missing endpoint for edge "${e.edge.id}"`);let d=g(u),f=[],p=new Set,m=r.get(o)?.get(`${e.edge.id}:${t}`),h=i.has(o)&&m!==void 0,_=c((e,t,n)=>{let r=q(l,e);if(!r||t<r.low||t>r.high)return;let i=g(l),a=e===`left`||e===`right`?{x:e===`left`?i.left:i.right,y:t}:{x:t,y:e===`top`?i.top:i.bottom},s=`${e}:${G(a)}`;p.has(s)||(p.add(s),f.push({ownerId:o,side:e,port:a,connect:{x:a.x+(e===`left`?-K:e===`right`?K:0),y:a.y+(e===`top`?-K:e===`bottom`?K:0)},rank:n,onAssignedSide:h?e===m.side:void 0}))},`addCandidate`);if(m&&e.bundleSize===1&&_(m.side,m.coordinate,-2),e.bundleSize>1){let t=Pn(l,{x:d.cx,y:d.cy}),n=g(l);_(t,(t===`left`||t===`right`?n.cy:n.cx)+e.laneOffset,-1)}let v=[...n.get(o)??[]];for(let n of[`right`,`bottom`,`left`,`top`]){if(!q(l,n))continue;let r=Zn(l,n,v),i=v.find(n=>n.plan===e&&n.role===t),a=i?r.get(i):void 0;if(a===void 0)continue;let o=g(l),s=n===`left`||n===`right`?{x:n===`left`?o.left:o.right,y:a}:{x:a,y:n===`top`?o.top:o.bottom};_(n,a,Math.abs(s.x-d.cx)+Math.abs(s.y-d.cy))}return f.sort((e,t)=>e.rank-t.rank||Kn(e.side)-Kn(t.side)),f.forEach((e,t)=>{e.rank=t}),f}c(rr,`endpointCandidates`);function ir(e,t){let n=Un(e,t),r=new Map,i=new Map;for(let e of n){let t=qn(e.edge);r.set(t,(r.get(t)??0)+1),e.edge.start&&i.set(e.edge.start,(i.get(e.edge.start)??0)+1),e.edge.end&&e.edge.end!==e.edge.start&&i.set(e.edge.end,(i.get(e.edge.end)??0)+1)}let a=n.filter(e=>e.edge.start!==e.edge.end&&e.source.chain.length===1&&e.target.chain.length===1&&e.source.finalKind===`item`&&e.target.finalKind===`item`),o=new Map;for(let e of a){let n=t.forest.nodeById.get(e.edge.start),r=t.forest.nodeById.get(e.edge.end);if(!n||!r)continue;let i=o.get(n.id)??[];i.push({plan:e,role:`source`,opposite:r}),o.set(n.id,i);let a=o.get(r.id)??[];a.push({plan:e,role:`target`,opposite:n}),o.set(r.id,a)}let s=new Map([...o].map(([e,n])=>{let r=t.forest.nodeById.get(e);return[e,r?nr(r,n):new Map]})),l=new Set,u=new Set;for(let[e,n]of o){let r=t.forest.nodeById.get(e);if(!r)continue;let i=n.some(e=>er(r,e)),a=n.some(e=>!er(r,e));if(i&&a){u.add(e);for(let e of n)er(r,e)||l.add(e.plan.edge.id)}}let d=new Map(a.map(e=>[e.edge.id,{sources:rr(e,`source`,o,s,u,t),targets:rr(e,`target`,o,s,u,t)}])),f=new Map([...d].map(([e,t])=>[e,t.sources.length*t.targets.length])),p=c(e=>{let n=t.forest.nodeById.get(e.edge.start),i=t.forest.nodeById.get(e.edge.end);return e.edge.start===e.edge.end?0:n?.isGroup&&i&&Dt(n.id,i,t.forest.nodeById)||i?.isGroup&&n&&Dt(i.id,n,t.forest.nodeById)?1:(n?.parentId??T)===(i?.parentId??T)?r.get(qn(e.edge))>1?3:4:2},`routeClass`),m=[...n].sort((e,t)=>{let n=qn(e.edge),r=qn(t.edge),i=`${e.edge.start??``}|${e.edge.end??``}`,a=`${t.edge.start??``}|${t.edge.end??``}`,o=e.source.chain.length+e.target.chain.length-2,s=t.source.chain.length+t.target.chain.length-2;return p(e)-p(t)||s-o||(f.get(e.edge.id)??0)-(f.get(t.edge.id)??0)||h(n,r)||h(i,a)||h(e.edge.id,t.edge.id)});return{plans:n,eligiblePlans:a,eligibleIds:new Set(a.map(({edge:e})=>e.id)),orderedPlans:m,demandCoords:Gn(m,t,i),endpointCandidatesByEdge:d,endpointIncidentCounts:i,coordinatedEndpointIds:l}}c(ir,`prepareEdgeRoutes`);function ar(e){if(!(e instanceof Error)||!(`details`in e))return!1;let t=e.details;return typeof t==`object`&&!!t&&`reason`in t&&t.reason===`pair-separation`}c(ar,`isPairSeparationError`);function or(e){let t=g(e);return{left:t.left,right:t.right,top:t.top,bottom:t.bottom}}c(or,`routerRect`);function sr(e){if(e.length<2||e.some(({x:e,y:t})=>!Number.isFinite(e)||!Number.isFinite(t)))return;let t=[{...e[0]}];for(let n=1;n<e.length;n++){let r=e[n],i=t.at(-1);if(!(Math.abs(r.x-i.x)<=l&&Math.abs(r.y-i.y)<=l))t.push({...r});else if(n===e.length-1){for(;t.length>1;){let e=t.at(-2);if(Math.abs(r.x-e.x)>l||Math.abs(r.y-e.y)>l)break;t.pop()}if(t.length===1)return;t[t.length-1]={...r}}}if(t.length<2)return;let n=[];for(let e=0;e<t.length-1;e++){let r=t[e],i=t[e+1],a=Math.abs(i.x-r.x);if(Math.abs(i.y-r.y)<=l)n.push(`H`);else if(a<=l)n.push(`V`);else return}let r=t.map(e=>({...e}));for(let e=0;e<n.length;){let i=n[e],a=e+1;for(;a<n.length&&n[a]===i;)a++;let o=i===`H`?`y`:`x`;if(e===0&&a===t.length-1&&t[e][o]!==t[a][o])return;let s=a===t.length-1?t[a][o]:t[e][o];for(let n=e;n<=a;n++){if(Math.abs(t[n][o]-s)>l)return;r[n][o]=s}e=a}return r}c(sr,`canonicalizeOrthogonalPolyline`);function cr(e,t,n){return e.y===t.y?e.y>n.top&&e.y<n.bottom&&Math.max(e.x,t.x)>n.left&&Math.min(e.x,t.x)<n.right:e.x!==t.x||e.x>n.left&&e.x<n.right&&Math.max(e.y,t.y)>n.top&&Math.min(e.y,t.y)<n.bottom}c(cr,`segmentEntersRect`);function lr(e){let t=or(e);return{left:t.left-W,right:t.right+W,top:t.top-W,bottom:t.bottom+W}}c(lr,`inflatedRect`);function J(e,t,n,r,i){let a=sr(e);if(!a)return!1;let o=p(a);if(o.points.length<2||o.segments.length>1&&(Math.abs(o.segments[0].a.x-o.segments[0].b.x)+Math.abs(o.segments[0].a.y-o.segments[0].b.y)<K||Math.abs(o.segments.at(-1).a.x-o.segments.at(-1).b.x)+Math.abs(o.segments.at(-1).a.y-o.segments.at(-1).b.y)<K))return!1;let s=(i.forest.childrenByParent.get(r)??[]).filter(e=>!k(e));for(let e of s){let r=lr(e);for(let i=0;i<o.points.length-1;i++)if(e.id===t.id&&i===0||e.id===n.id&&i===o.points.length-2){if(cr(o.points[i],o.points[i+1],or(e)))return!1}else if(cr(o.points[i],o.points[i+1],r))return!1}return!0}c(J,`validateSameContainerRoute`);function ur(e,t,n,r,i){let a=sr(e);if(!a)return!1;let o=p(a);if(o.points.length<2)return!1;let s=(i.forest.childrenByParent.get(r)??[]).filter(e=>!k(e));for(let e of s){let r=lr(e);for(let i=0;i<o.points.length-1;i++)if(e.id===t&&i===0||e.id===n&&i===o.points.length-2){if(cr(o.points[i],o.points[i+1],or(e)))return!1}else if(cr(o.points[i],o.points[i+1],r))return!1}return!0}c(ur,`validateContainerSegment`);function dr(e){return e.orientation===`H`?{low:Math.min(e.a.x,e.b.x),high:Math.max(e.a.x,e.b.x)}:{low:Math.min(e.a.y,e.b.y),high:Math.max(e.a.y,e.b.y)}}c(dr,`segmentSpan`);function fr(e){let t=p([...e]).segments.filter(e=>e.orientation!==`Z`).map(e=>({a:{...e.a},b:{...e.b},orientation:e.orientation}));if(t.length===0||t.length===1&&Math.abs(t[0].a.x-t[0].b.x)+Math.abs(t[0].a.y-t[0].b.y)<=K*2)return[];let n=c((e,t)=>{if(e.orientation===`H`){let n=Math.sign(e.b.x-e.a.x);t?e.a.x+=n*K:e.b.x-=n*K}else{let n=Math.sign(e.b.y-e.a.y);t?e.a.y+=n*K:e.b.y-=n*K}},`trim`);return n(t[0],!0),n(t[t.length-1],!1),t.filter(({a:e,b:t})=>e.x!==t.x||e.y!==t.y)}c(fr,`nonterminalSegments`);function pr(e,t){if(e.orientation!==t.orientation)return!1;let n=dr(e),r=dr(t),i=Math.max(0,Math.min(n.high,r.high)-Math.max(n.low,r.low));if(i<=0)return!1;let a=e.orientation===`H`?Math.abs(e.a.y-t.a.y):Math.abs(e.a.x-t.a.x);return a===0&&i>=jn||a>0&&a<jn}c(pr,`pairSegmentsConflict`);function Y(e,t){let n=p([...e]).points,r=[n[0],n.at(-1)],i=fr(n);return t.every(e=>{let t=p([...e]).points,n=[t[0],t.at(-1)];return!r.some(e=>n.some(t=>e.x===t.x&&e.y===t.y))&&i.every(e=>fr(t).every(t=>!pr(e,t)))})}c(Y,`routeSatisfiesPairConstraints`);function mr(e,t){let n=p([...e]).points,r=[n[0],n.at(-1)];return t.every(e=>{let t=p([...e]).points,n=[t[0],t.at(-1)];return!r.some(e=>n.some(t=>e.x===t.x&&e.y===t.y))})}c(mr,`routeHasDistinctPairPorts`);function hr(e,t,n){let r={a:e,b:t,orientation:e.y===t.y?`H`:`V`};return n.every(e=>fr(e).every(e=>!pr(r,e)))}c(hr,`pairArcAllowed`);function gr(e,t){let n=e.side===`left`||e.side===`right`?`H`:`V`,r=t.side===`left`||t.side===`right`?`H`:`V`,i=Math.abs(e.connect.x-t.connect.x),a=Math.abs(e.connect.y-t.connect.y),o;if(i===0&&a===0)o=Number(n!==r);else if(i===0||a===0){let e=i===0?`V`:`H`;o=Number(n!==e)+Number(r!==e)}else o=Math.min(Number(n!==`H`)+1+Number(r!==`V`),Number(n!==`V`)+1+Number(r!==`H`));return[K*2+i+a,o]}c(gr,`endpointPairLowerBound`);function _r(e,t){if(e.orientation!==t.orientation)return!1;let n=e.orientation===`H`,r=c(e=>n?Math.min(e.a.x,e.b.x):Math.min(e.a.y,e.b.y),`lowOf`),i=c(e=>n?Math.max(e.a.x,e.b.x):Math.max(e.a.y,e.b.y),`highOf`),a=Math.min(i(e),i(t))-Math.max(r(e),r(t)),o=Math.abs(n?e.a.y-t.a.y:e.a.x-t.a.x);return a>0&&o<Yt}c(_r,`segmentsTooClose`);var vr=class{constructor(){this.lines={H:new Map,V:new Map},this.sortedCoordinates={H:void 0,V:void 0},this.log=[]}static{c(this,`RouteOccupancyIndex`)}get size(){return this.log.length}add(e,t){for(let n of fr(e)){let e=n.orientation,r=e===`H`?n.a.y:n.a.x,i=this.lines[e].get(r);i?i.push({segment:n,pairKey:t}):(this.lines[e].set(r,[{segment:n,pairKey:t}]),this.sortedCoordinates[e]=void 0),this.log.push({orientation:e,coordinate:r})}}truncate(e){for(;this.log.length>e;){let{orientation:e,coordinate:t}=this.log.pop();this.lines[e].get(t)?.pop()}}conflictsWithRoute(e,t){return fr(e).some(e=>this.conflicts(e,t))}conflictsWithArc(e,t,n){let r=e.y===t.y?`H`:`V`;return this.conflicts({a:e,b:t,orientation:r},n)}conflicts(e,t){let n=e.orientation;if(n!==`H`&&n!==`V`)return!1;let r=n===`H`?e.a.y:e.a.x,i=this.coordinatesFor(n),a=0,o=i.length;for(;a<o;){let e=a+o>>1;i[e]<=r-Yt?a=e+1:o=e}for(let o=a;o<i.length;o++){let a=i[o];if(a>=r+Yt)break;for(let r of this.lines[n].get(a))if(r.pairKey!==t&&_r(e,r.segment))return!0}return!1}coordinatesFor(e){return this.sortedCoordinates[e]??=[...this.lines[e].keys()].sort((e,t)=>e-t)}},X=24,Z=18,Q=14,yr=4,br=18,xr=4,Sr=64,Cr=4;function wr(e,t,n,r){if(!t.conflictsWithRoute(e,n))return[...e];let i=p([...e]).points;for(let e=1;e<=Cr;e++)for(let a of[1,-1]){let o=a*e*jn;for(let e=1;e<i.length-2;e++){let a=i[e].x===i[e+1].x,s=i.map((t,n)=>n===e||n===e+1?a?{x:t.x+o,y:t.y}:{x:t.x,y:t.y+o}:t);if(!t.conflictsWithRoute(s,n)&&r(s))return s}}}c(wr,`separateRouteFromOccupied`);function Tr(e){let t=c((e,t)=>Math.abs(e.x-t.x)+Math.abs(e.y-t.y),`stub`);return t(e[0],e[1])>=K&&t(e.at(-1),e.at(-2))>=K}c(Tr,`terminalStubsAreLongEnough`);function Er(e,t,n,r,i=3){let a=[...r.filter(e=>e>=t&&e<=n).sort((t,n)=>Math.abs(t-e)-Math.abs(n-e)||t-n),(t+n)/2,t,n],o=new Set([e]),s=[];for(let e of a)if(!o.has(e)&&(o.add(e),s.push(e),s.length===i))break;return s}c(Er,`boundedAlternativePortalCoordinates`);function Dr(e,t){return Math.abs(e.x-t.x)<=1e-6&&Math.abs(e.y-t.y)<=1e-6}c(Dr,`equalPoint`);function Or(e,t){return e.x===t.x||e.y===t.y}c(Or,`areExactlyAxisAligned`);function kr(e,t,n,r){let i=[...e].sort((e,r)=>Math.abs(e-t)+Math.abs(e-n)-(Math.abs(r-t)+Math.abs(r-n))||e-r);return i[Math.min(r,Math.max(0,i.length-1))]??(t+n)/2}c(kr,`chooseIntermediateCoordinate`);function Ar(e){let t=[];for(let n of e)t.length!==0&&Dr(t[t.length-1],n)||t.push(n);return t}c(Ar,`dedupeConsecutive`);function jr(e,t,n,r,i){let a=t.containers.get(e);if(!a)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing container layout "${e}"`);let o=[n.port,n.connect];if(n.orientation===`V`&&r.orientation===`V`){if(!Dr(n.connect,r.connect)&&Math.abs(n.connect.x-r.connect.x)>1e-6){let e=kr(a.horizontalCorridors,n.connect.y,r.connect.y,i);o.push({x:n.connect.x,y:e},{x:r.connect.x,y:e})}else if(!Dr(n.connect,r.connect)&&Math.abs(n.connect.y-r.connect.y)>1e-6&&i>0){let e=a.verticalCorridors.filter(e=>Math.abs(e-n.connect.x)>1e-6),t=kr(e.length>0?e:a.verticalCorridors,n.connect.x,r.connect.x,i-1);o.push({x:t,y:n.connect.y},{x:t,y:r.connect.y})}}else if(n.orientation===`H`&&r.orientation===`H`){if(!Dr(n.connect,r.connect)&&Math.abs(n.connect.y-r.connect.y)>1e-6){let e=kr(a.verticalCorridors,n.connect.x,r.connect.x,i);o.push({x:e,y:n.connect.y},{x:e,y:r.connect.y})}}else n.orientation===`V`&&r.orientation===`H`?o.push({x:n.connect.x,y:r.connect.y}):o.push({x:r.connect.x,y:n.connect.y});return o.push(r.connect,r.port),p(Ar(o)).points}c(jr,`routeWithinContainer`);function Mr(e,t,n,r,i,a,o){let s=i.forest.nodeById.get(e),c=i.itemMeta.get(e);if(!s||!c||c.containerId!==r)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing item metadata for "${e}" in "${r}"`);let l=g(s),u=o??a.get(n)??(t===`left`||t===`right`?l.cy:l.cx);switch(t){case`left`:return{port:{x:l.left,y:u},connect:{x:c.leftCorridorX,y:u},orientation:`V`,side:t};case`right`:return{port:{x:l.right,y:u},connect:{x:c.rightCorridorX,y:u},orientation:`V`,side:t};case`top`:return{port:{x:u,y:l.top},connect:{x:u,y:c.topCorridorY},orientation:`H`,side:t};case`bottom`:return{port:{x:u,y:l.bottom},connect:{x:u,y:c.bottomCorridorY},orientation:`H`,side:t}}}c(Mr,`itemAttachment`);function Nr(e,t,n,r,i){let a=r.forest.nodeById.get(e),o=r.containers.get(e);if(!a||!o)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing boundary metadata for "${e}"`);let s=g(a),c=i.get(n)??(t===`left`||t===`right`?s.cy:s.cx);switch(t){case`left`:return{port:{x:s.left,y:c},connect:{x:o.verticalCorridors[0],y:c},orientation:`V`,side:t};case`right`:return{port:{x:s.right,y:c},connect:{x:o.verticalCorridors[o.verticalCorridors.length-1],y:c},orientation:`V`,side:t};case`top`:return{port:{x:c,y:s.top},connect:{x:c,y:o.horizontalCorridors[0]},orientation:`H`,side:t};case`bottom`:return{port:{x:c,y:s.bottom},connect:{x:c,y:o.horizontalCorridors[o.horizontalCorridors.length-1]},orientation:`H`,side:t}}}c(Nr,`boundaryAttachment`);function Pr(e){return{x:(e.interior.x+e.exterior.x)/2,y:(e.interior.y+e.exterior.y)/2}}c(Pr,`portalBoundaryPoint`);function Fr(e,t){return{ownerId:e.ownerId,port:Pr(e),connect:t?e.interior:e.exterior,orientation:e.side===`left`||e.side===`right`?`V`:`H`,side:e.side}}c(Fr,`portalAttachment`);function Ir(e,t,n,r,i){let a=r.forest.nodeById.get(e);if(!a?.isGroup)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing group endpoint "${e}"`);let o=g(a),s=i.get(n)??(t===`left`||t===`right`?o.cy:o.cx),c=t===`left`||t===`right`?{x:t===`left`?o.left:o.right,y:s}:{x:s,y:t===`top`?o.top:o.bottom};return{ownerId:e,port:c,connect:{x:c.x+(t===`left`?K:t===`right`?-K:0),y:c.y+(t===`top`?K:t===`bottom`?-K:0)},orientation:t===`left`||t===`right`?`V`:`H`,side:t}}c(Ir,`groupBoundaryEndpointAttachment`);function Lr(e){return[...e].reverse()}c(Lr,`reversePoints`);function Rr(e){let t=[];for(let n of e)for(let e of n)t.length!==0&&Dr(t[t.length-1],e)||t.push(e);return p(t).points}c(Rr,`combinePointChains`);function zr(e,t,n,r){let i=g(e),a=Q+(n+1)*br,o=n*xr;switch(t){case`right`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:i.right,y:e},{x:i.right+Q,y:e},{x:i.right+a,y:e},{x:i.right+a,y:t},{x:i.right+Q,y:t},{x:i.right,y:t}]).points}case`left`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:i.left,y:e},{x:i.left-Q,y:e},{x:i.left-a,y:e},{x:i.left-a,y:t},{x:i.left-Q,y:t},{x:i.left,y:t}]).points}case`top`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:e,y:i.top},{x:e,y:i.top-Q},{x:e,y:i.top-a},{x:t,y:i.top-a},{x:t,y:i.top-Q},{x:t,y:i.top}]).points}case`bottom`:{let e=r-Z/2-o,t=r+Z/2+o;return p([{x:e,y:i.bottom},{x:e,y:i.bottom+Q},{x:e,y:i.bottom+a},{x:t,y:i.bottom+a},{x:t,y:i.bottom+Q},{x:t,y:i.bottom}]).points}}}c(zr,`routeSelfLoop`);function Br(e,t,n,r,i){let a=g(e),o=Q+(n+1)*br,s=n*xr,c=Z+s*2,l=t===`left`||t===`right`,u=Math.max(c,(l?i.cross:i.along)+j*2+ee),d=Math.max(o,(l?i.along:i.cross)/2+j),f=l?[a.top,a.bottom]:[a.left,a.right],m=r-u/2,h=r+u/2;if(m-f[0]>=yr&&f[1]-h>=yr)switch(t){case`right`:return[p([{x:a.right,y:m},{x:a.right+d,y:m},{x:a.right+d,y:h},{x:a.right,y:h}]).points];case`left`:return[p([{x:a.left,y:m},{x:a.left-d,y:m},{x:a.left-d,y:h},{x:a.left,y:h}]).points];case`top`:return[p([{x:m,y:a.top},{x:m,y:a.top-d},{x:h,y:a.top-d},{x:h,y:a.top}]).points];case`bottom`:return[p([{x:m,y:a.bottom},{x:m,y:a.bottom+d},{x:h,y:a.bottom+d},{x:h,y:a.bottom}]).points]}let _=r-Z/2-s,v=r+Z/2+s;if(_<f[0]||v>f[1])return[];let y=r-u/2,b=r+u/2,x=Math.max(Q,K),S=Math.max(d,x+(l?i.along:i.cross)/2+j);switch(t){case`right`:return[p([{x:a.right,y:_},{x:a.right+x,y:_},{x:a.right+x,y},{x:a.right+S,y},{x:a.right+S,y:b},{x:a.right+x,y:b},{x:a.right+x,y:v},{x:a.right,y:v}]).points];case`left`:return[p([{x:a.left,y:_},{x:a.left-x,y:_},{x:a.left-x,y},{x:a.left-S,y},{x:a.left-S,y:b},{x:a.left-x,y:b},{x:a.left-x,y:v},{x:a.left,y:v}]).points];case`top`:return[p([{x:_,y:a.top},{x:_,y:a.top-x},{x:y,y:a.top-x},{x:y,y:a.top-S},{x:b,y:a.top-S},{x:b,y:a.top-x},{x:v,y:a.top-x},{x:v,y:a.top}]).points];case`bottom`:return[p([{x:_,y:a.bottom},{x:_,y:a.bottom+x},{x:y,y:a.bottom+x},{x:y,y:a.bottom+S},{x:b,y:a.bottom+S},{x:b,y:a.bottom+x},{x:v,y:a.bottom+x},{x:v,y:a.bottom}]).points]}}c(Br,`labelAwareSelfLoopCandidates`);function Vr(e,t,n){return(e.isGroup&&Mn(e)?[`left`,`right`,`bottom`]:[`left`,`right`,`top`,`bottom`]).sort((r,i)=>(t.get(Nn(e.id,r))??0)+(n.get(`${e.id}:${r}`)??0)-((t.get(Nn(e.id,i))??0)+(n.get(`${e.id}:${i}`)??0)))}c(Vr,`orderedSelfLoopSides`);function Hr(e,t){let n=[];for(let r of t.forest.nodeById.values())if(r.id!==e.id&&!r.isGroup&&r.x!==void 0&&r.y!==void 0&&n.push(g(r)),r.id!==e.id&&r.groupTitleRect){let{left:e,right:t,top:i,bottom:a}=r.groupTitleRect;n.push({cx:(e+t)/2,cy:(i+a)/2,left:e,right:t,top:i,bottom:a})}return n}c(Hr,`selfLoopObstacles`);function Ur(e,t,n,r,i,a){let o=g(e),s=Hr(e,r);for(let r of Vr(e,t,n)){let t=`${e.id}:${r}`,c=n.get(t)??0,l=r===`left`||r===`right`?o.cy:o.cx,u=i?Br(e,r,c,l,i):[zr(e,r,c,l)];i&&a&&(a.labelAwareSelfLoopCandidates+=u.length);for(let e of u)if(!s.some(t=>C(e,t)))return{points:e,side:r,index:c}}throw D(`GRID_ROUTE_NOT_FOUND`,`No obstacle-clear self-loop route for "${e.id}"`,{nodeId:e.id})}c(Ur,`routeObstacleClearSelfLoop`);function Wr(e){if(e.containers.has(T))return;let t=0,n=0,r=0,i=0,a=!0;for(let o of e.itemMeta.values())o.containerId===T&&(a?(t=o.cellLeft,n=o.cellLeft+o.cellWidth,r=o.cellTop,i=o.cellTop+o.cellHeight,a=!1):(t=Math.min(t,o.cellLeft),n=Math.max(n,o.cellLeft+o.cellWidth),r=Math.min(r,o.cellTop),i=Math.max(i,o.cellTop+o.cellHeight)));let o=new Set([r-X,i+X]),s=new Set([t-X,n+X]);for(let t of e.itemMeta.values())t.containerId===T&&(o.add(t.topCorridorY),o.add(t.bottomCorridorY),s.add(t.leftCorridorX),s.add(t.rightCorridorX));e.containers.set(T,{id:T,left:t-X,top:r-X,width:n-t+X*2,height:i-r+X*2,contentLeft:t,contentTop:r,contentRight:n,contentBottom:i,verticalCorridors:[...s].sort((e,t)=>e-t),horizontalCorridors:[...o].sort((e,t)=>e-t)})}c(Wr,`rootContainerMeta`);function Gr(e,t){let n=t.containers.get(e);if(!n)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing container layout "${e}"`);if(e===T){let e=[...t.itemMeta.values()].filter(({containerId:e})=>e===T);return e.length>0?{left:Math.min(...e.map(({cellLeft:e})=>e))-X,right:Math.max(...e.map(({cellLeft:e,cellWidth:t})=>e+t))+X,top:Math.min(...e.map(({cellTop:e})=>e))-X,bottom:Math.max(...e.map(({cellTop:e,cellHeight:t})=>e+t))+X}:{left:n.left,right:n.left+n.width,top:n.top,bottom:n.top+n.height}}let r=t.forest.nodeById.get(e);if(!r)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing container owner "${e}"`);let i=or(r);return{left:i.left+W,right:i.right-W,top:i.top+W,bottom:i.bottom-W}}c(Gr,`containerBounds`);function Kr(e,t,n){return(t===`left`?e.left:t===`right`?e.right:t===`top`?e.top:e.bottom)+(t===`left`||t===`top`?1:-1)*W*(n?1:-1)}c(Kr,`portalCoordinate`);function qr(e,t){let n=[];if(e!==T){let r=t.forest.nodeById.get(e);if(r){let t=or(r);n.push(...Tn(e,t,r.groupTitleRect).map(e=>({...e,coordinate:Kr(t,e.side,!0)})))}}for(let r of t.forest.childrenByParent.get(e)??[]){if(!r.isGroup)continue;let e=or(r);n.push(...Tn(r.id,e,r.groupTitleRect).map(t=>({...t,coordinate:Kr(e,t.side,!1)})))}return n}c(qr,`containerPortalRanges`);function Jr(e,t,n,r){let i={topologies:new Map,fallbackContainers:new Map,searchBudget:{expandedStates:0},searchBudgetWarningEmitted:!1,baseEstimatedBytes:0,metrics:n},a=0;for(let o of[...new Set(e)].sort()){let e=(t.forest.childrenByParent.get(o)??[]).filter(e=>!k(e)),s=t.forest.nodeById.get(o)?.groupTitleRect;try{let c=Dn({containerId:o,bounds:Gr(o,t),obstacles:e.map(e=>({id:e.id,bounds:or(e)})),titleExclusions:s?[{id:`${o}:title`,bounds:{...s}}]:void 0,portalRanges:qr(o,t)},{caps:r.topologyCaps}),l=r.topologyCaps?.maxEstimatedBytes??Qt;if(a+c.estimatedBytes>l){i.fallbackContainers.set(o,`estimated_memory_cap`);continue}a+=c.estimatedBytes,i.baseEstimatedBytes=a,i.topologies.set(o,c),n&&(n.containersBuilt++,n.baseTopologyBuilds++,n.baseVertices+=c.vertices.length,n.baseAdjacencyEntries+=c.adjacencyEntries,n.buildSweepEvents+=c.seedCount*4+c.obstacles.length*4,n.estimatedBytes=a)}catch(e){if(!(e instanceof Jt))throw e;i.fallbackContainers.set(o,e.reason)}}return i}c(Jr,`buildRoutingContext`);function Yr(e,t,n,r,i,a,o){let s=i();if(o&&o.compatibilitySegments++,ur(s,n.ownerId,r.ownerId,t,a))return s;throw o&&(o.compatibilityValidationFailures++,o.routesImpossible++),D(`GRID_ROUTE_NOT_FOUND`,`Invalid compatibility route for "${e}"`,{edgeId:e,containerId:t})}c(Yr,`validatedCompatibilitySegment`);function Xr(e,t,n){let r=e.source.chain.at(-1),i=e.target.chain.at(-1),a=c((r,i)=>({ownerId:i.ownerId,...r.finalKind===`boundary`?Nr(e.lcaContainerId,i.side,i.demandKey,t,n):Mr(i.ownerId,i.side,i.demandKey,e.lcaContainerId,t,n)}),`finalAttachment`);return{start:a(e.source,r),end:a(e.target,i)}}c(Xr,`compatibilityLcaAttachments`);function Zr(e,t,n){return e.chain.slice(0,-1).map((r,i)=>{let a=e.chain[i+1];return{containerId:a.ownerId,start:{ownerId:r.ownerId,...Mr(r.ownerId,r.side,r.demandKey,a.ownerId,t,n)},end:{ownerId:a.ownerId,...Nr(a.ownerId,a.side,a.demandKey,t,n)}}})}c(Zr,`compatibilityHierarchyAttachments`);function Qr(e,t,n){let r=c((n,r,i)=>ur(jr(n,t,r,i,e.laneIndex),r.ownerId,i.ownerId,n,t),`segmentIsValid`);for(let i of[e.source,e.target])for(let{containerId:e,start:a,end:o}of Zr(i,t,n))if(!r(e,a,o))return!1;let i=Xr(e,t,n);return r(e.lcaContainerId,i.start,i.end)}c(Qr,`compatibilityPlanIsValid`);function $r(e,t,n,r){let{plans:i,eligiblePlans:a,eligibleIds:o,demandCoords:s,endpointCandidatesByEdge:l,endpointIncidentCounts:u,coordinatedEndpointIds:d}=e,f=c(e=>(u.get(e.edge.start)??0)===e.bundleSize&&(u.get(e.edge.end)??0)===e.bundleSize,`hasIsolatedEndpoints`),m=c(e=>{let n=t.forest.nodeById.get(e.edge.start),r=t.forest.nodeById.get(e.edge.end);return!!(n&&r&&(n.isGroup&&Dt(n.id,r,t.forest.nodeById)||r.isGroup&&Dt(r.id,n,t.forest.nodeById)))},`hasAncestorEndpoint`),h=new Map,g=new Map,_=i.length<=Sr,v=r.topologyCaps===void 0&&r.searchCaps===void 0&&r.onDualRouteComparison===void 0;for(let e of v?a:[]){if(d.has(e.edge.id))continue;let r=l.get(e.edge.id);if(e.bundleSize!==1||!r?.sources.length||!r.targets.length)continue;let i=t.forest.nodeById.get(e.edge.start),a=t.forest.nodeById.get(e.edge.end);if(!i||!a)continue;let o=Xr(e,t,s),c=jr(e.lcaContainerId,t,o.start,o.end,e.laneIndex),u=p(c),f=u.points[0],m=u.points.at(-1);if(!f||!m)continue;let v=r.sources.find(({port:e})=>e.x===f.x&&e.y===f.y),y=r.targets.find(({port:e})=>e.x===m.x&&e.y===m.y);if(!v||!y)continue;n&&n.compatibilityFastPathAttempts++;let b=Math.abs(f.x-m.x)+Math.abs(f.y-m.y);if(!J(c,i,a,e.lcaContainerId,t)){n&&n.compatibilityFastPathValidationFailures++;continue}if(x(u.points)!==b){n&&n.compatibilityFastPathNonMinimalRoutes++;continue}let S=g.get(e.lcaContainerId);if(S||(S=new vr,g.set(e.lcaContainerId,S)),S.conflictsWithRoute(u.points,e.pairKey)&&_)continue;let C=wr(u.points,S,e.pairKey,n=>Tr(n)&&x(n)===b&&J(n,i,a,e.lcaContainerId,t))??c;S.add(C,e.pairKey),h.set(e.edge.id,C)}let y=c(e=>!o.has(e.edge.id)&&e.edge.start!==e.edge.end&&(e.bundleSize>1||f(e)||!Qr(e,t,s)),`sparseCandidate`),b=new Map,S=new Set;if(_)for(let n of e.orderedPlans){if(o.has(n.edge.id)||n.edge.start===n.edge.end||m(n)||y(n))continue;let e=Xr(n,t,s),r=jr(n.lcaContainerId,t,e.start,e.end,n.laneIndex),i=b.get(n.lcaContainerId);i||(i=new vr,b.set(n.lcaContainerId,i)),i.conflictsWithRoute(r,n.pairKey)?S.add(n.edge.id):i.add(r,n.pairKey)}let C=new Set([...i.filter(y).map(({edge:e})=>e.id),...S]),w=new Set([...C,...i.filter(m).map(({edge:e})=>e.id)]);return{overlapAvoidanceEnabled:_,compatibilityFastRoutes:h,sparseHierarchyIds:C,sparseLcaIds:w,routedContainerIds:i.filter(e=>o.has(e.edge.id)&&!h.has(e.edge.id)||w.has(e.edge.id)||e.edge.start===e.edge.end).flatMap(e=>[e.lcaContainerId,...e.source.chain.slice(1).map(({ownerId:e})=>e),...e.target.chain.slice(1).map(({ownerId:e})=>e)]),routeOccupancy:g}}c($r,`prepareRoutingModes`);var ei={containersBuilt:`cumulative`,baseTopologyBuilds:`cumulative`,baseVertices:`cumulative`,baseAdjacencyEntries:`cumulative`,buildSweepEvents:`cumulative`,endpointOverlayBuilds:`cumulative`,endpointOverlayVertices:`cumulative`,hierarchyPortalPairs:`transactional`,hierarchyPortalTransitionLength:`transactional`,hierarchyPortalAlternativeAttempts:`cumulative`,hierarchyPortalAlternativeSelections:`transactional`,hierarchyBoundaryTransitions:`transactional`,labelOverlayBuilds:`cumulative`,labelOverlayVertices:`cumulative`,labelSpacingEdgesExamined:`cumulative`,labelSpacingEligibleEdges:`cumulative`,labelSpacingBoundariesExpanded:`cumulative`,labelSpacingPixelsAdded:`cumulative`,labelAwareSelfLoopCandidates:`cumulative`,labelAwareSelfLoopsCommitted:`transactional`,labelAwareSelfLoopFallbacks:`cumulative`,searches:`cumulative`,expandedStates:`cumulative`,maxOpenSet:`cumulative`,routesFound:`transactional`,routesImpossible:`transactional`,resourceLimitFallbacks:`cumulative`,fallbackReasons:`cumulative`,fallbackValidationFailures:`cumulative`,compatibilitySegments:`transactional`,compatibilityFastPathAttempts:`cumulative`,compatibilityFastPaths:`cumulative`,compatibilityFastPathValidationFailures:`cumulative`,compatibilityFastPathNonMinimalRoutes:`cumulative`,compatibilityRecoveries:`transactional`,compatibilityValidationFailures:`cumulative`,bundleSeparationRelaxations:`transactional`,routeLength:`transactional`,bendCount:`transactional`,crossingCount:`transactional`,sharedLength:`transactional`,estimatedBytes:`cumulative`,searchWorkspaceBytes:`cumulative`,routeOrder:`transactional`,routes:`transactional`},ti=Object.keys(ei).filter(e=>ei[e]===`transactional`&&e!==`routeOrder`&&e!==`routes`);function ni(e){return{routeOrderLength:e.routeOrder.length,routesLength:e.routes.length,values:Object.fromEntries(ti.map(t=>[t,e[t]]))}}c(ni,`createGridRoutingInstrumentationCheckpoint`);function ri(e,t){e.routeOrder.length=t.routeOrderLength,e.routes.length=t.routesLength,Object.assign(e,t.values)}c(ri,`restoreGridRoutingInstrumentationCheckpoint`);function ii(e,t,n,r){return Math.max(0,Math.min(Math.max(e,t),Math.max(n,r))-Math.max(Math.min(e,t),Math.min(n,r)))}c(ii,`intervalOverlap`);function ai(e,t){let n=p(e).segments,r=p(t).segments,i=0;for(let e of n)for(let t of r)e.orientation===t.orientation&&(e.orientation===`H`&&e.a.y===t.a.y?i+=ii(e.a.x,e.b.x,t.a.x,t.b.x):e.orientation===`V`&&e.a.x===t.a.x&&(i+=ii(e.a.y,e.b.y,t.a.y,t.b.y)));return i}c(ai,`sharedSegmentLength`);function oi(e,t,n,r,i=0,a=0){let o=p(n),s=0,c=0;for(let e of r){let t=p(e).segments;for(let e of o.segments)for(let n of t)m(e,n)&&s++;c+=ai(o.points,e)}let l={edgeId:t,routeOrder:e.routes.length,laneOffset:a,routeLength:x(o.points),bendCount:o.bends,crossingCount:s,sharedLength:c,boundaryTransitionCount:i,routeSignature:JSON.stringify(o.points)};e.routeOrder.push(t),e.routes.push(l),e.routesFound++,e.routeLength+=l.routeLength,e.bendCount+=l.bendCount,e.crossingCount+=l.crossingCount,e.sharedLength+=l.sharedLength,e.hierarchyBoundaryTransitions+=i}c(oi,`recordGridRoute`);var si=1e5,ci=2e6,li=class{constructor(){this.stateVertices=new Int32Array(256),this.orientations=new Uint8Array(256),this.gLengths=new Float64Array(256),this.gBends=new Float64Array(256),this.gBoundaryTransitions=new Float64Array(256),this.fLengths=new Float64Array(256),this.fBends=new Float64Array(256),this.predecessors=new Int32Array(256),this.depths=new Int32Array(256),this.ancestor4=new Int32Array(256),this.best=new Int32Array(256),this.heapChildren=new Int32Array(256),this.heapSiblings=new Int32Array(256),this.heapPairs=[],this.touchedBestIndices=[],this.best.fill(-1)}static{c(this,`RouterSearchWorkspace`)}reset(e){let t=e*3;if(this.best.length<t)this.best=new Int32Array(t),this.best.fill(-1);else for(let e of this.touchedBestIndices)this.best[e]=-1;this.touchedBestIndices.length=0,this.heapPairs.length=0}setBest(e,t){this.best[e]<0&&this.touchedBestIndices.push(e),this.best[e]=t}ensureStateCapacity(e){if(this.stateVertices.length>=e)return;let t=Math.max(e,this.stateVertices.length*2);this.stateVertices=$(this.stateVertices,t),this.orientations=$(this.orientations,t),this.gLengths=$(this.gLengths,t),this.gBends=$(this.gBends,t),this.gBoundaryTransitions=$(this.gBoundaryTransitions,t),this.fLengths=$(this.fLengths,t),this.fBends=$(this.fBends,t),this.predecessors=$(this.predecessors,t),this.depths=$(this.depths,t),this.ancestor4=$(this.ancestor4,t),this.heapChildren=$(this.heapChildren,t),this.heapSiblings=$(this.heapSiblings,t)}estimatedBytes(){return this.stateVertices.byteLength+this.orientations.byteLength+this.gLengths.byteLength+this.gBends.byteLength+this.gBoundaryTransitions.byteLength+this.fLengths.byteLength+this.fBends.byteLength+this.predecessors.byteLength+this.depths.byteLength+this.ancestor4.byteLength+this.best.byteLength+this.heapChildren.byteLength+this.heapSiblings.byteLength+(this.heapPairs.length+this.touchedBestIndices.length)*8}};function ui(e){let t=e.caps?.maxExpandedStates??si,n=e.caps?.maxInvocationExpandedStates??ci,r=e.budget?.expandedStates??e.metrics?.expandedStates??0;if(!(t>0&&r<n))throw new Jt(`search_state_cap`,`Grid routing search-state cap exceeded`,r>=n?`invocation`:`edge`)}c(ui,`assertSearchBudgetAvailable`);function $(e,t){let n=new e.constructor(t);return n.set(e),n}c($,`growTypedArray`);function di(e,t){for(let n=0;n<4;n++){if(e[n]<t[n])return-1;if(e[n]>t[n])return 1}return 0}c(di,`compareTupleCost`);function fi(e,t,n,r){return e===0&&t===0?n&&r?Number(n!==r):0:e===0?(n?Number(n!==`V`):0)+(r?Number(r!==`V`):0):t===0?(n?Number(n!==`H`):0)+(r?Number(r!==`H`):0):Math.min((n?Number(n!==`H`):0)+1+(r?Number(r!==`V`):0),(n?Number(n!==`V`):0)+1+(r?Number(r!==`H`):0))}c(fi,`minimumBends`);function pi(e){return e===void 0?0:e===`H`?1:2}c(pi,`orientationOrdinal`);function mi(e,t,n){return n===`left`?e.y===t.y&&t.x>e.x:n===`right`?e.y===t.y&&t.x<e.x:n===`top`?e.x===t.x&&t.y>e.y:e.x===t.x&&t.y<e.y}c(mi,`movesTowardOwner`);function hi(e,t){return e*3+pi(t)}c(hi,`stateIndex`);function gi(e){let t=[];for(let n of e){let e=t.at(-1);if(e&&e.x===n.x&&e.y===n.y)continue;let r=t.at(-2);r&&e&&(r.x===e.x&&e.x===n.x||r.y===e.y&&e.y===n.y)?t[t.length-1]={...n}:t.push({...n})}return t}c(gi,`normalizePoints`);function _i(e,t,n,r,i){let a=[],o=e;for(;o>=0;)a.push(t[o]),o=n[o];return a.reverse(),{points:gi(a.map(e=>i(e).point)),vertexIds:a,cost:r}}c(_i,`reconstruct`);function vi(e){for(let t of e.vertices){if(t.id<0||e.vertices[t.id]!==t||!Number.isFinite(t.point.x)||!Number.isFinite(t.point.y))throw Error(`Malformed grid routing vertex`);for(let n of e.adjacency.get(t.id)??[]){let r=e.vertices[n.to],i=r&&(n.orientation===`H`?t.point.y===r.point.y:t.point.x===r.point.x),a=r?Math.abs(t.point.x-r.point.x)+Math.abs(t.point.y-r.point.y):NaN;if(n.from!==t.id||!i||!Number.isFinite(n.length)||n.length<=0||n.length!==a)throw Error(`Malformed grid routing arc`)}}}c(vi,`validateSearchTopology`);function yi(e,t,n,r){let i=c(t=>{let n=e.getVertex?.(t)??e.vertices[t];if(!n)throw Error(`Missing grid routing vertex ${t}`);return n},`vertexAt`),a=i(t),o=i(n);r.topologyValidated||vi(e);let s=r.metrics;s&&s.searches++,ui(r);let l=r.workspace??new li;l.reset(e.vertexCount??e.vertices.length);let u=l.stateVertices,d=l.orientations,f=l.gLengths,p=l.gBends,m=l.gBoundaryTransitions,h=l.fLengths,g=l.fBends,_=l.predecessors,v=l.depths,y=l.ancestor4,b=l.heapChildren,x=l.heapSiblings,S=l.best,C=l.heapPairs,w=1,T=r.endpointCandidateRank??0,E=r.heuristic!==`zero`;function D(e,t){return u[e]-u[t]||d[e]-d[t]||_[e]-_[t]||e-t}c(D,`nonCostOrder`);function O(e,t){return h[e]-h[t]||g[e]-g[t]||m[e]-m[t]||(r.queueOrder===`reverse`?-D(e,t):D(e,t))}c(O,`compareStates`);function k(e,t){if(e===t)return 0;if(e<0)return-1;if(t<0)return 1;let n=v[e],r=v[t],i=e,a=t;for(;v[i]>v[a];)i=_[i];for(;v[a]>v[i];)a=_[a];if(i===a)return n-r;for(;y[i]>=0&&y[a]>=0&&y[i]!==y[a];)i=y[i],a=y[a];for(;_[i]!==_[a];)i=_[i],a=_[a];return u[i]-u[a]||d[i]-d[a]}c(k,`compareChains`);let A=-1,j=0;function M(e,t){return e<0?t:t<0?e:O(e,t)<=0?(x[t]=b[e],b[e]=t,e):(x[e]=b[t],b[t]=e,t)}c(M,`heapMeld`);let ee=c(e=>{b[e]=-1,x[e]=-1,A=M(A,e),j++},`heapPush`),N=c(()=>{if(A<0)return;let e=A;C.length=0;let t=b[e];for(;t>=0;){let e=x[t];x[t]=-1,C.push(t),t=e}for(let e=0;e+1<C.length;e+=2)C[e>>>1]=M(C[e],C[e+1]);let n=Math.ceil(C.length/2);for(C.length%2!=0&&(C[n-1]=C[C.length-1]),A=-1;n>0;)A=M(C[--n],A);return j--,e},`heapPop`),P=0,F=r.caps?.maxExpandedStates??si,I=r.caps?.maxInvocationExpandedStates??ci,L=r.budget?.expandedStates??s?.expandedStates??0,te=c(()=>{let e=l.estimatedBytes(),t=(r.estimatedBytesBase??0)+e;if(s&&(s.searchWorkspaceBytes=Math.max(s.searchWorkspaceBytes,e),s.estimatedBytes=Math.max(s.estimatedBytes,t)),t>(r.caps?.maxEstimatedBytes??1/0))throw new Jt(`estimated_memory_cap`,`Grid routing search workspace memory cap exceeded`)},`recordWorkspaceBytes`);te();let R=c(()=>{r.budget&&(r.budget.expandedStates+=P),s&&(s.expandedStates+=P)},`commitExpandedStates`),ne=r.initialLength??0;u[0]=t,d[0]=pi(r.initialOrientation),f[0]=ne,p[0]=0,m[0]=0;let re=Math.abs(a.point.x-o.point.x),ie=Math.abs(a.point.y-o.point.y);h[0]=ne+(E?re+ie:0),g[0]=E?fi(re,ie,r.initialOrientation,r.targetOrientation):0,_[0]=-1,v[0]=1,y[0]=-1,l.setBest(hi(t,r.initialOrientation),0),ee(0),s&&(s.maxOpenSet=Math.max(s.maxOpenSet,j));let z=-1,B,ae=c(e=>{let t=[f[e]+(r.targetLength??0),p[e]+ +(r.targetOrientation!==void 0&&d[e]!==0&&pi(r.targetOrientation)!==d[e]),m[e],T];(!B||di(t,B)<0||di(t,B)===0&&k(e,z)<0)&&(z=e,B=t)},`considerGoal`),V=c((e,t,a,s,c,C)=>{let T=i(a).point;if(r.arcAllowed&&!r.arcAllowed(t,T)||r.initialSide&&_[e]<0&&mi(t,T,r.initialSide)||r.targetSide&&a===n&&mi(o.point,t,r.targetSide))return;let D=a*3+s,O=S[D],A=f[e]+c,j=p[e]+ +(d[e]!==0&&d[e]!==s),M=m[e]+C,N=O>=0?A-f[O]||j-p[O]||M-m[O]:-1;if(O>=0&&(N>0||N===0&&k(e,_[O])>=0))return;let P=w++;w>u.length&&(l.ensureStateCapacity(w),u=l.stateVertices,d=l.orientations,f=l.gLengths,p=l.gBends,m=l.gBoundaryTransitions,h=l.fLengths,g=l.fBends,_=l.predecessors,v=l.depths,y=l.ancestor4,b=l.heapChildren,x=l.heapSiblings,te()),u[P]=a,d[P]=s,f[P]=A,p[P]=j,m[P]=M;let F=Math.abs(T.x-o.point.x),I=Math.abs(T.y-o.point.y);h[P]=A+(E?F+I:0),g[P]=j+(E?fi(F,I,s===1?`H`:`V`,r.targetOrientation):0),_[P]=e,v[P]=v[e]+1;let L=_[e],R=L>=0?_[L]:-1;y[P]=R>=0?_[R]:-1,l.setBest(D,P),ee(P)},`relaxArc`);for(;j>0;){let t=A;if(B&&(h[t]-B[0]||g[t]-B[1]||m[t]-B[2]||T-B[3])>0)break;let a=N();if(S[u[a]*3+d[a]]!==a)continue;if(P>=F||L+P>=I){if(z>=0&&B)return s&&r.recordOutcome!==!1&&s.routesFound++,R(),_i(z,u,_,B,i);throw R(),new Jt(`search_state_cap`,`Grid routing search-state cap exceeded`,L+P>=I?`invocation`:`edge`)}if(P++,u[a]===n){ae(a);continue}let o=u[a],c=i(o).point,l=e.getSearchArcs?.(o)??e.searchAdjacencyByVertex?.[o];if(l)for(let e of l)V(a,c,e.to,e.orientationOrdinal,e.length,e.boundaryTransitions);else for(let t of e.adjacencyByVertex?.[o]??e.adjacency.get(o)??[])V(a,c,t.to,pi(t.orientation),t.length,+(t.kind===`portal`));s&&(s.maxOpenSet=Math.max(s.maxOpenSet,j))}if(z<0||!B)R(),s&&r.recordOutcome!==!1&&s.routesImpossible++;else return s&&r.recordOutcome!==!1&&s.routesFound++,R(),_i(z,u,_,B,i)}c(yi,`search`);function bi(e,t,n,r={}){return yi(e,t,n,r)}c(bi,`findShortestRoute`);var xi=`grid-router`;function Si(e,t,n,r,a){e.metrics&&(e.metrics.resourceLimitFallbacks++,e.metrics.fallbackReasons[t]++),i.debug(xi,`GRID_ROUTING_RESOURCE_FALLBACK`,{edgeId:n,containerId:r,reason:t}),t===`search_state_cap`&&a===`invocation`&&!e.searchBudgetWarningEmitted&&(e.searchBudgetWarningEmitted=!0,i.warn(xi,`GRID_ROUTING_INVOCATION_SEARCH_BUDGET_EXHAUSTED`,{edgeId:n,containerId:r,expandedStates:e.searchBudget.expandedStates}))}c(Si,`recordFallback`);function Ci({context:e,reason:t,edgeId:n,containerId:r,searchStateScope:i,route:a,isValid:o,includeContainerIdInError:s}){let c=a();if(Si(e,t,n,r,i),o(c))return c;throw e.metrics&&e.metrics.fallbackValidationFailures++,D(`GRID_ROUTE_NOT_FOUND`,`Invalid legacy fallback for "${n}"`,{edgeId:n,...s?{containerId:r}:{},reason:t})}c(Ci,`runValidatedFallback`);function wi(e,t,n,r,i,a,o,s,l,u,d,f,m){let h=s.fallbackContainers.get(e.lcaContainerId);if(h)return Ci({context:s,reason:h,edgeId:e.edge.id,containerId:e.lcaContainerId,route:a,isValid:c(t=>J(t,r,i,e.lcaContainerId,o)&&(e.bundleSize<=1||Y(t,f)),`isValid`)});let g=s.topologies.get(e.lcaContainerId);if(!g)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing routing topology "${e.lcaContainerId}"`);if(t.length===0||n.length===0)throw s.metrics&&s.metrics.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,e.bundleSize>1?`No distinct lane route for "${e.edge.id}"`:`No legal endpoint candidates for "${e.edge.id}"`,{edgeId:e.edge.id});let _,v,y=t.flatMap(e=>n.map(t=>{let r=e.rank*n.length+t.rank,[i,a]=gr(e,t);return{sourceCandidate:e,targetCandidate:t,pairRank:r,lowerCost:[i,a,0,r]}})).sort((e,t)=>di(e.lowerCost,t.lowerCost)||Kn(e.sourceCandidate.side)-Kn(t.sourceCandidate.side)||Kn(e.targetCandidate.side)-Kn(t.targetCandidate.side)),b=c((t,n=`all`)=>{let a=e.bundleSize>1||t?(n,r)=>(e.bundleSize<=1||hr(n,r,f))&&!(t&&m.index.conflictsWithArc(n,r,m.pairKey)):void 0;for(let{sourceCandidate:c,targetCandidate:h,pairRank:b,lowerCost:x}of y)if((n!==`preferred`||b===0)&&(n!==`assigned-side`||c.onAssignedSide!==!1&&h.onAssignedSide!==!1)){if(_&&di(_.result.cost,x)<=0)break;try{ui({metrics:s.metrics,caps:d.searchCaps,budget:s.searchBudget});let n=kn(g,c.connect,h.connect,s.metrics,u,e.bundleSize>1&&(c.connect.x===h.connect.x||c.connect.y===h.connect.y)?[{x:(c.connect.x+h.connect.x)/2,y:(c.connect.y+h.connect.y)/2}]:[]),y=s.baseEstimatedBytes+n.estimatedBytes-g.estimatedBytes;if(y>(d.topologyCaps?.maxEstimatedBytes??Qt))throw new Jt(`estimated_memory_cap`,`Grid routing estimated_memory_cap exceeded`);s.metrics&&(s.metrics.estimatedBytes=Math.max(s.metrics.estimatedBytes,y));let x=n.pointVertexIds.get(G(c.connect)),S=n.pointVertexIds.get(G(h.connect));if(x===void 0||S===void 0)throw D(`GRID_ROUTE_NOT_FOUND`,`Endpoint projection is missing from the routing overlay for "${e.edge.id}"`,{edgeId:e.edge.id,containerId:e.lcaContainerId,source:c.connect,target:h.connect});let C=c.side===`left`||c.side===`right`?`H`:`V`,w=h.side===`left`||h.side===`right`?`H`:`V`,T=bi(n,x,S,{metrics:s.metrics,caps:{...d.searchCaps,maxEstimatedBytes:d.searchCaps?.maxEstimatedBytes??d.topologyCaps?.maxEstimatedBytes??Qt},endpointCandidateRank:b,recordOutcome:!1,budget:s.searchBudget,initialOrientation:C,initialLength:K,targetOrientation:w,targetLength:K,topologyValidated:!0,workspace:l,estimatedBytesBase:y,arcAllowed:a});if(!T)continue;let E=p([c.port,...T.points,h.port]).points;if(!J(E,r,i,e.lcaContainerId,o)||e.bundleSize>1&&!Y(E,f)||t&&m.index.conflictsWithRoute(E,m.pairKey))continue;(!_||di(T.cost,_.result.cost)<0)&&(_={result:T,points:E},v=void 0)}catch(e){if(!(e instanceof Jt))throw e;if(_)break;v=e;break}}},`searchPairs`),S=m!==void 0&&m.index.size>0;if(m?.prioritizeEndpointCandidates&&(b(S,`preferred`),b(S,`assigned-side`)),_||b(S),!_&&!v&&m!==void 0&&m.index.size>0&&b(!1),v)return Ci({context:s,reason:v.reason,edgeId:e.edge.id,containerId:e.lcaContainerId,searchStateScope:v.searchStateScope,route:a,isValid:c(t=>J(t,r,i,e.lcaContainerId,o)&&(e.bundleSize<=1||Y(t,f)),`isValid`)});if(!_)throw s.metrics&&s.metrics.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,e.bundleSize>1?`No distinct lane route for "${e.edge.id}"`:`No cell-aware route for "${e.edge.id}"`,{edgeId:e.edge.id});if(d.onDualRouteComparison){let t=a(),n=p(_.points),s=p(t);d.onDualRouteComparison({edgeId:e.edge.id,sparse:{valid:!0,length:x(n.points),bends:n.bends},legacy:{valid:J(t,r,i,e.lcaContainerId,o),length:x(s.points),bends:s.bends}})}return _.points}c(wi,`sparseSameContainerRoute`);function Ti(e,t,n){let r=q(e,t);if(!r||r.high-r.low<Z)return;let i=g(e),a=(r.low+r.high)/2,o=n*xr,s=[a-Z/2-o,a+Z/2+o];if(s[0]<r.low||s[1]>r.high)return;let l=c(n=>{let r=t===`left`||t===`right`?{x:t===`left`?i.left:i.right,y:n}:{x:n,y:t===`top`?i.top:i.bottom};return{ownerId:e.id,side:t,port:r,connect:{x:r.x+(t===`left`?-K:t===`right`?K:0),y:r.y+(t===`top`?-K:t===`bottom`?K:0)},rank:0}},`candidate`);return{start:l(s[0]),target:l(s[1])}}c(Ti,`selfLoopAttachments`);function Ei(e,t,n,r,i,a,o,s,l,u){let d=t.parentId??T,f=n.labelRequirements.selfLoops.get(e.edge.id),m=r.fallbackContainers.get(d),h=c(()=>Ur(t,o,s,n,f,r.metrics),`legacyRoute`);if(m){let i=Ci({context:r,reason:m,edgeId:e.edge.id,containerId:d,route:h,isValid:c(e=>J(e.points,t,t,d,n)&&Y(e.points,l),`isValid`)});return f&&r.metrics&&r.metrics.labelAwareSelfLoopsCommitted++,i}let _=r.topologies.get(d);if(!_||!a)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing routing topology "${d}"`);let v=Vr(t,o,s);if(f){for(let e of v){let i=s.get(`${t.id}:${e}`)??0,a=g(t),o=Br(t,e,i,e===`left`||e===`right`?a.cy:a.cx,f);r.metrics&&(r.metrics.labelAwareSelfLoopCandidates+=o.length);for(let a of o)if(J(a,t,t,d,n)&&Y(a,l))return r.metrics&&r.metrics.labelAwareSelfLoopsCommitted++,{points:a,side:e,index:i}}r.metrics&&r.metrics.labelAwareSelfLoopFallbacks++}for(let o of v){let m=s.get(`${t.id}:${o}`)??0,g=Ti(t,o,m);if(!g)continue;let{start:v,target:y}=g;try{ui({metrics:r.metrics,caps:u.searchCaps,budget:r.searchBudget});let s=kn(_,v.connect,y.connect,r.metrics,a,[{x:(v.connect.x+y.connect.x)/2,y:(v.connect.y+y.connect.y)/2}]),f=s.pointVertexIds.get(G(v.connect)),h=s.pointVertexIds.get(G(y.connect));if(f===void 0||h===void 0)throw D(`GRID_ROUTE_NOT_FOUND`,`Self-loop endpoint projection is missing from the routing overlay for "${e.edge.id}"`,{edgeId:e.edge.id,containerId:d,source:v.connect,target:y.connect,side:o});let g=o===`left`||o===`right`?`H`:`V`,b=bi(s,f,h,{metrics:r.metrics,caps:{...u.searchCaps,maxEstimatedBytes:u.searchCaps?.maxEstimatedBytes??u.topologyCaps?.maxEstimatedBytes??Qt},recordOutcome:!1,budget:r.searchBudget,initialOrientation:g,initialSide:o,initialLength:K,targetOrientation:g,targetSide:o,targetLength:K,topologyValidated:!0,workspace:i,estimatedBytesBase:r.baseEstimatedBytes+s.estimatedBytes-_.estimatedBytes,arcAllowed:c((e,t)=>hr(e,t,l),`arcAllowed`)});if(!b)continue;let x=p([v.port,...b.points,y.port]).points;if(J(x,t,t,d,n)&&Y(x,l))return{points:x,side:o,index:m}}catch(i){if(!(i instanceof Jt))throw i;let a=Ci({context:r,reason:i.reason,edgeId:e.edge.id,containerId:d,searchStateScope:i.searchStateScope,route:h,isValid:c(e=>J(e.points,t,t,d,n)&&Y(e.points,l),`isValid`)});return f&&r.metrics&&r.metrics.labelAwareSelfLoopsCommitted++,a}}throw r.metrics&&r.metrics.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,`No distinct self-loop route for "${e.edge.id}"`,{edgeId:e.edge.id,nodeId:t.id})}c(Ei,`sparseSelfLoopRoute`);function Di(e,t,n,r,i,a,o,s,l,u,d=[],f=()=>[],m=()=>[],h=!1,g){let _=o.fallbackContainers.get(t);if(_)return Ci({context:o,reason:_,edgeId:e,containerId:t,route:i,isValid:c(e=>ur(e,n.ownerId,r.ownerId,t,a)&&Y(e,d),`isValid`),includeContainerIdInError:!0});let v=o.topologies.get(t);if(!v||!l)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing routing topology "${t}"`);let y=[{start:n,end:r,select:[]}],b=!1,x=c(()=>{if(b)return;b=!0;let e=m(),t=f();y.push(...t.map(e=>({start:n,end:e.attachment,select:[e.select]})),...e.map(e=>({start:e.attachment,end:r,select:[e.select]})),...e.flatMap(e=>t.map(t=>({start:e.attachment,end:t.attachment,select:[e.select,t.select]}))))},`appendAlternatives`),S=g!==void 0&&g.index.size>0?[!0,!1]:[!1];try{for(let e of S)for(let[n,r]of y.entries()){let i=r.start,c=r.end;if(n>0&&o.metrics&&o.metrics.hierarchyPortalAlternativeAttempts++,Or(i.connect,c.connect)){let s=p([i.port,i.connect,c.connect,c.port]).points;if(ur(s,i.ownerId,c.ownerId,t,a)&&Y(s,d)&&!(e&&g.index.conflictsWithRoute(s,g.pairKey))){for(let e of r.select)e();return n>0&&o.metrics&&o.metrics.hierarchyPortalAlternativeSelections++,s}}ui({metrics:o.metrics,caps:u.searchCaps,budget:o.searchBudget});let f=kn(v,i.connect,c.connect,o.metrics,l),m=o.baseEstimatedBytes+f.estimatedBytes-v.estimatedBytes;if(m>(u.topologyCaps?.maxEstimatedBytes??Qt))throw new Jt(`estimated_memory_cap`,`Grid routing estimated_memory_cap exceeded`);let h=f.pointVertexIds.get(G(i.connect)),_=f.pointVertexIds.get(G(c.connect));if(h===void 0||_===void 0){n===0&&x();continue}let y=bi(f,h,_,{metrics:o.metrics,caps:{...u.searchCaps,maxEstimatedBytes:u.searchCaps?.maxEstimatedBytes??u.topologyCaps?.maxEstimatedBytes??Qt},recordOutcome:!1,budget:o.searchBudget,initialOrientation:i.side===`left`||i.side===`right`?`H`:`V`,initialSide:i.side,initialLength:Math.abs(i.port.x-i.connect.x)+Math.abs(i.port.y-i.connect.y),targetOrientation:c.side===`left`||c.side===`right`?`H`:`V`,targetSide:c.side,targetLength:Math.abs(c.port.x-c.connect.x)+Math.abs(c.port.y-c.connect.y),topologyValidated:!0,workspace:s,estimatedBytesBase:m,arcAllowed:d.length>0||e?(t,n)=>(d.length===0||hr(t,n,d))&&!(e&&g.index.conflictsWithArc(t,n,g.pairKey)):void 0});if(!y){n===0&&x();continue}let b=p([i.port,...y.points,c.port]).points;if(!ur(b,i.ownerId,c.ownerId,t,a)||!Y(b,d)||e&&g.index.conflictsWithRoute(b,g.pairKey))n===0&&x();else{for(let e of r.select)e();return n>0&&o.metrics&&o.metrics.hierarchyPortalAlternativeSelections++,b}}}catch(s){if(!(s instanceof Jt))throw s;return Ci({context:o,reason:s.reason,edgeId:e,containerId:t,searchStateScope:s.searchStateScope,route:i,isValid:c(e=>ur(e,n.ownerId,r.ownerId,t,a)&&Y(e,d),`isValid`),includeContainerIdInError:!0})}let C=i();if(ur(C,n.ownerId,r.ownerId,t,a)&&(Y(C,d)||h&&mr(C,d)))return o.metrics&&(o.metrics.compatibilitySegments++,o.metrics.compatibilityRecoveries++),C;throw D(`GRID_ROUTE_NOT_FOUND`,`No hierarchy route for "${e}" in "${t}" from ${G(n.connect)} to ${G(r.connect)}`,{edgeId:e,containerId:t})}c(Di,`sparseContainerSegment`);function Oi(e,t,n,r,i,a,o){let s=e[0].pairKey,c=t.get(s),l=[...new Set(e.flatMap(e=>[...e.source.chain,...e.target.chain].map(({demandKey:e})=>e)))],u=new Map,d=new Map;for(let e of l){let t=n.get(e);t&&u.set(e,t);let i=r.get(e);i!==void 0&&d.set(e,i)}let f=o.get(e[0].lcaContainerId);return{pairKey:s,occupancy:f?{index:f,size:f.size}:void 0,pairRoutes:c?[...c]:void 0,demandKeys:l,pairedPortals:u,demandCoords:d,edges:e.map(({edge:e})=>({edge:e,points:e.points,curve:e.curve,cornerRadius:e.cornerRadius})),instrumentedRoutesLength:i?.length,metrics:a?ni(a):void 0}}c(Oi,`createBundleCheckpoint`);function ki(e,t,n,r,i,a){e.occupancy?.index.truncate(e.occupancy.size),e.pairRoutes?t.set(e.pairKey,[...e.pairRoutes]):t.delete(e.pairKey);for(let t of e.demandKeys){let i=e.pairedPortals.get(t);i?n.set(t,i):n.delete(t);let a=e.demandCoords.get(t);a===void 0?r.delete(t):r.set(t,a)}for(let t of e.edges)t.edge.points=t.points,t.edge.curve=t.curve,t.edge.cornerRadius=t.cornerRadius;i&&e.instrumentedRoutesLength!==void 0&&(i.length=e.instrumentedRoutesLength),a&&e.metrics&&ri(a,e.metrics)}c(ki,`restoreBundleCheckpoint`);var Ai=class{constructor(e,t,n,r){this.layout=e,this.result=t,this.metrics=n,this.options=r,this.searchWorkspace=new li,this.pairedPortals=new Map,this.ownerSideCounts=new Map,this.selfLoopCounts=new Map,this.pairRoutes=new Map,this.routed=!1}static{c(this,`GridEdgeRoutingSession`)}route(){if(this.routed)throw Error(`Grid edge routing session can only be run once`);this.routed=!0,this.prepare();let e=new Map;for(let t of this.prepared.orderedPlans){let n=e.get(t.pairKey)??[];n.push(t),e.set(t.pairKey,n)}for(let t of e.values())this.routeBundle(t)}prepare(){Wr(this.result),this.prepared=ir(this.layout,this.result),this.modes=$r(this.prepared,this.result,this.metrics,this.options),this.routingContext=Jr(this.modes.routedContainerIds,this.result,this.metrics,this.options),this.endpointOverlayScratch=new Map([...this.routingContext.topologies].map(([e,t])=>[e,new sn(t)])),this.instrumentedRoutes=this.metrics?[]:void 0;let e=new Set;for(let t of this.prepared.orderedPlans)if(t.edge.start!==t.edge.end)for(let n of[...t.source.chain,...t.target.chain]){if(e.has(n.demandKey))continue;e.add(n.demandKey);let t=Nn(n.ownerId,n.side);this.ownerSideCounts.set(t,(this.ownerSideCounts.get(t)??0)+1)}}pairedPortal(e){let t=this.pairedPortals.get(e.demandKey);if(t)return t;let n=this.result.forest.nodeById.get(e.ownerId);if(!n?.isGroup)throw D(`GRID_ROUTE_NOT_FOUND`,`Missing portal owner "${e.ownerId}"`);let r=or(n),i=this.prepared.demandCoords.get(e.demandKey)??(e.side===`left`||e.side===`right`?(r.top+r.bottom)/2:(r.left+r.right)/2),a=Tn(e.ownerId,r,n.groupTitleRect).find(({side:t})=>t===e.side);if(!a)throw D(`GRID_ROUTE_NOT_FOUND`,`No legal ${e.side} portal for "${e.ownerId}"`);let o=En(e.ownerId,r,n.groupTitleRect?{...n.groupTitleRect}:void 0,e.side,w(i,a.low,a.high));return this.pairedPortals.set(e.demandKey,o),this.metrics&&(this.metrics.hierarchyPortalPairs++,this.metrics.hierarchyPortalTransitionLength+=o.transition.length),o}alternativePairedPortals(e,t=!0){let n=this.pairedPortal(e),r=this.result.forest.nodeById.get(e.ownerId);if(!r?.isGroup)return[];let i=or(r),a=Tn(e.ownerId,i,r.groupTitleRect).find(({side:t})=>t===e.side);if(!a)return[];let o=this.result.containers.get(r.id),s=e.side===`left`||e.side===`right`?o?.horizontalCorridors:o?.verticalCorridors;return Er(n.tangentialCoordinate,a.low,a.high,s??[]).map(n=>{let a=En(e.ownerId,i,r.groupTitleRect?{...r.groupTitleRect}:void 0,e.side,n);return{attachment:Fr(a,t),select:c(()=>{this.pairedPortals.set(e.demandKey,a),this.prepared.demandCoords.set(e.demandKey,n)},`select`)}})}itemSegmentAttachment(e,t){return{ownerId:e.ownerId,...Mr(e.ownerId,e.side,e.demandKey,t,this.result,this.prepared.demandCoords)}}alternativeItemAttachments(e,t,n){let r=this.itemSegmentAttachment(t,n),i=this.result.forest.nodeById.get(t.ownerId);return i?[`right`,`bottom`,`left`,`top`].filter(e=>e!==r.side&&!(e===`top`&&Mn(i))).map(r=>{let a=q(i,r);if(!a)return;let o=g(i),s=r===`left`||r===`right`?o.cy:o.cx,c=Math.max(a.low,Math.min(a.high,s+e.laneOffset));return{ownerId:t.ownerId,...Mr(t.ownerId,r,t.demandKey,n,this.result,this.prepared.demandCoords,c)}}).filter(e=>e!==void 0).slice(0,3).map(e=>({attachment:e,select:c(()=>void 0,`select`)})):[]}routePlan(e,t=!0){let n=this.result,r=this.routingContext,i=this.searchWorkspace,a=this.endpointOverlayScratch,o=this.prepared.demandCoords,s=this.ownerSideCounts,l=this.selfLoopCounts,u=this.pairRoutes,d=this.instrumentedRoutes,f=this.metrics,p=this.options,m=this.prepared.eligibleIds,h=this.prepared.endpointCandidatesByEdge,g=this.modes.compatibilityFastRoutes,_=this.modes.sparseHierarchyIds,v=this.modes.sparseLcaIds,y=e.edge,b=y.start?n.forest.nodeById.get(y.start):void 0,x=y.end?n.forest.nodeById.get(y.end):void 0;if(!b||!x)throw D(`GRID_MISSING_ENDPOINT`,`Missing endpoint for edge "${y.id}"`,{edgeId:y.id});if(b.id===x.id){let t=u.get(e.pairKey)??[],{points:o,side:c,index:m}=Ei(e,b,n,r,i,a.get(b.parentId??T),s,l,t,p),h=`${b.id}:${c}`;l.set(h,m+1),y.points=o,y.curve=n.config.curve,y.cornerRadius=n.config.edgeCornerRadius,t.push(o),u.set(e.pairKey,t),f&&d&&(oi(f,y.id,o,d,0,e.laneOffset),d.push(o));return}let S=e.source.chain[e.source.chain.length-1],C=e.target.chain[e.target.chain.length-1],w=v.has(y.id),E=w?void 0:Xr(e,n,o),O=E?E.start:e.source.finalKind===`boundary`?Ir(S.ownerId,S.side,S.demandKey,n,o):e.source.chain.length>1?Fr(this.pairedPortal(S),!1):this.itemSegmentAttachment(S,e.lcaContainerId),k=E?E.end:e.target.finalKind===`boundary`?Ir(C.ownerId,C.side,C.demandKey,n,o):e.target.chain.length>1?Fr(this.pairedPortal(C),!1):this.itemSegmentAttachment(C,e.lcaContainerId),A,j=c(()=>A??=jr(e.lcaContainerId,n,O,k,e.laneIndex),`legacyRoute`),M=g.get(y.id),ee=M?(f&&f.compatibilityFastPaths++,M):m.has(y.id)?wi(e,h.get(y.id).sources,h.get(y.id).targets,b,x,j,n,r,i,a.get(e.lcaContainerId),p,u.get(e.pairKey)??[],{index:this.occupancyFor(e.lcaContainerId),pairKey:e.pairKey,prioritizeEndpointCandidates:this.prepared.coordinatedEndpointIds.has(y.id)}):w?Di(y.id,e.lcaContainerId,O,k,j,n,r,i,a.get(e.lcaContainerId),p,u.get(e.pairKey)??[],()=>e.target.finalKind===`item`&&e.target.chain.length>1?this.alternativePairedPortals(C,!1):[],()=>e.source.finalKind===`item`&&e.source.chain.length>1?this.alternativePairedPortals(S,!1):[],e.bundleSize>1,this.modes.overlapAvoidanceEnabled?{index:this.occupancyFor(e.lcaContainerId),pairKey:e.pairKey}:void 0):Yr(y.id,e.lcaContainerId,O,k,j,n,f),N=c((t,s)=>{if(_.has(y.id))for(let o=0;o<t.chain.length-1;o++){let c=t.chain[o],l=t.chain[o+1],d=o===0?this.itemSegmentAttachment(c,l.ownerId):Fr(this.pairedPortal(c),!1),f=Fr(this.pairedPortal(l),!0);s.push(Di(y.id,l.ownerId,d,f,()=>jr(l.ownerId,n,d,f,e.laneIndex),n,r,i,a.get(l.ownerId),p,u.get(e.pairKey)??[],()=>this.alternativePairedPortals(l),()=>o===0?this.alternativeItemAttachments(e,c,l.ownerId):[],e.bundleSize>1))}else for(let{containerId:r,start:i,end:a}of Zr(t,n,o))s.push(Yr(y.id,r,i,a,()=>jr(r,n,i,a,e.laneIndex),n,f))},`routeHierarchyChain`),P=[],F=[];N(e.source,P),N(e.target,F);let I=Rr([...P,ee,...F.reverse().map(e=>Lr(e))]),L=u.get(e.pairKey)??[],te=Y(I,L),R=!te&&e.bundleSize>1&&e.source.chain.length+e.target.chain.length>2&&mr(I,L);if(e.bundleSize>1&&!te&&(!R||!t))throw f&&f.routesImpossible++,D(`GRID_ROUTE_NOT_FOUND`,`No distinct lane route for "${y.id}"`,{edgeId:y.id,reason:R?`pair-separation`:`no-distinct-route`});if(R&&f&&f.bundleSeparationRelaxations++,y.points=I,y.curve=n.config.curve,y.cornerRadius=n.config.edgeCornerRadius,L.push(I),u.set(e.pairKey,L),M||this.occupancyFor(e.lcaContainerId).add(ee,e.pairKey),f&&d){let t=e.source.chain.length+e.target.chain.length-2;oi(f,y.id,I,d,t,e.laneOffset),d.push(I)}}occupancyFor(e){let t=this.modes.routeOccupancy.get(e);return t||(t=new vr,this.modes.routeOccupancy.set(e,t)),t}createBundleCheckpoint(e){return this.occupancyFor(e[0].lcaContainerId),Oi(e,this.pairRoutes,this.pairedPortals,this.prepared.demandCoords,this.instrumentedRoutes,this.metrics,this.modes.routeOccupancy)}restoreBundleCheckpoint(e){ki(e,this.pairRoutes,this.pairedPortals,this.prepared.demandCoords,this.instrumentedRoutes,this.metrics)}routeBundle(e){if(!(e.length>1&&e.length<=8&&e.every(({edge:e})=>e.start!==e.end))){for(let t of e)this.routePlan(t);return}let t=this.createBundleCheckpoint(e),n;try{for(let t of e)this.routePlan(t,!1);return}catch(e){n=e,this.restoreBundleCheckpoint(t)}if(!ar(n))throw n;for(let t of e)this.routePlan(t)}};function ji(e,t,n,r={}){new Ai(e,t,n,r).route()}c(ji,`routeGridEdges`);var Mi=24,Ni=20;function Pi(e,t){return!e.label||!e.labelBBox||!(e.labelBBox.height>0)?0:e.labelBBox.height+t}c(Pi,`titleBandFor`);function Fi(e){if(!A(e.width)||!A(e.height))throw D(`GRID_MISSING_MEASUREMENT`,`Node "${e.id}" must have width and height greater than 0 (width: ${e.width}, height: ${e.height})`,{nodeId:e.id,width:e.width,height:e.height})}c(Fi,`ensureMeasuredNode`);function Ii(e){return Fi(e),{width:e.width,height:e.height}}c(Ii,`measureChild`);function Li(e,t,n,r,i){let{forest:a,config:o,sourceOrder:s}=t,l=e===T?void 0:a.groupById.get(e),u=l?Math.max(l.padding??0,o.containerPadding):0,d=l?Pi(l,o.titleGap):0,f=l?Mi:0,p=l?u+d+f:0,{cells:m}=qt((a.childrenByParent.get(e)??[]).filter(e=>!k(e)),s,o),h=[...m.values()].sort((e,t)=>e.row-t.row||e.column-t.column),g=new Map,_=new Map,v=new Set,y=new Set;for(let e of h){let t=0,n=0;for(let r of e.items){let e=Ii(r.item);t=Math.max(t,e.width),n+=e.height}e.items.length>1&&(n+=o.cellGap*(e.items.length-1)),e.width=t,e.height=n,v.add(e.row),y.add(e.column),g.set(e.column,Math.max(g.get(e.column)??0,t)),_.set(e.row,Math.max(_.get(e.row)??0,n))}let b=[...v].sort((e,t)=>e-t),x=[...y].sort((e,t)=>e-t),S=Pt(t.labelRequirements.byContainer.get(e)??[],m,_,g,b,x,o.rowGap,o.columnGap,i),C=c(e=>Math.max(o.rowGap,S.rowGapAfter.get(e)??0),`rowGapAfter`),w=c(e=>Math.max(o.columnGap,S.columnGapAfter.get(e)??0),`columnGapAfter`);if(i){for(let e of S.rowGapAfter.values())e>o.rowGap&&(i.labelSpacingBoundariesExpanded++,i.labelSpacingPixelsAdded+=e-o.rowGap);for(let e of S.columnGapAfter.values())e>o.columnGap&&(i.labelSpacingBoundariesExpanded++,i.labelSpacingPixelsAdded+=e-o.columnGap)}let E=x.reduce((e,t,n)=>e+(g.get(t)??0)+(n<x.length-1?w(t):0),0),D=l?Math.max(E+(u+f)*2,(l.labelBBox?.width??0)+u*2):E,A=l?(D-E)/2:0,j=new Map,M=A;for(let[e,t]of x.entries())j.set(t,M),M+=(g.get(t)??0)+(e<x.length-1?w(t):0);let ee=new Map,N=p;for(let[e,t]of b.entries())ee.set(t,N),N+=(_.get(t)??0)+(e<b.length-1?C(t):0);let P=b.length?N-p:0,F=l?A-Ni:-Math.max(o.columnGap/2,O.containerPadding),I=l?A+E+Ni:A+E+Math.max(o.columnGap/2,O.containerPadding),L=l?p-Ni:-Math.max(o.rowGap/2,O.containerPadding),te=l?p+P+Ni:p+P+Math.max(o.rowGap/2,O.containerPadding),R=new Set([F,I]),ne=new Set([L,te]),re=new Map,ie=new Map,z=new Map,B=new Map;x.length>0&&(re.set(x[0],F),ie.set(x.at(-1),I));for(let e=0;e<x.length-1;e++){let t=x[e],n=x[e+1],r=(j.get(t)+(g.get(t)??0)+j.get(n))/2;R.add(r),ie.set(t,r),re.set(n,r)}b.length>0&&(z.set(b[0],L),B.set(b.at(-1),te));for(let e=0;e<b.length-1;e++){let t=b[e],n=b[e+1],r=(ee.get(t)+(_.get(t)??0)+ee.get(n))/2;ne.add(r),B.set(t,r),z.set(n,r)}for(let t of h){let n=j.get(t.column)??A,i=ee.get(t.row)??p,a=g.get(t.column)??t.width,s=_.get(t.row)??t.height,c=t.verticalAlign===`top`?0:t.verticalAlign===`bottom`?1:.5,l=i+(s-t.height)*c;for(let[c,u]of t.items.entries()){let{width:d,height:f}=Ii(u.item),p=u.horizontalAlign===`left`?0:u.horizontalAlign===`right`?1:.5,m=n+(a-d)*p;u.item.x=m+d/2,u.item.y=l+f/2;let h=c>0?l-o.cellGap/2:z.get(t.row)??L,g=c<t.items.length-1?l+f+o.cellGap/2:B.get(t.row)??te;c>0&&ne.add(h),c<t.items.length-1&&ne.add(g),r.set(u.item.id,{containerId:e,row:t.row,column:t.column,cellLeft:n,cellTop:i,cellWidth:a,cellHeight:s,leftCorridorX:re.get(t.column)??F,rightCorridorX:ie.get(t.column)??I,topCorridorY:h,bottomCorridorY:g}),l+=f+o.cellGap}}let ae=l?P+d+(u+f)*2:P;n.set(e,{id:e,left:0,top:0,width:D,height:ae,contentLeft:A,contentTop:p,contentRight:l?A+E:E,contentBottom:l?p+P:P,verticalCorridors:[...R].sort((e,t)=>e-t),horizontalCorridors:[...ne].sort((e,t)=>e-t)}),l&&(l.width=D,l.height=ae,l.x=D/2,l.y=ae/2,d>0?l.groupTitleRect={left:0,right:D,top:0,bottom:u+d}:delete l.groupTitleRect)}c(Li,`layoutContainer`);function Ri(e,t,n){return{left:e.left+t,right:e.right+t,top:e.top+n,bottom:e.bottom+n}}c(Ri,`translateRect`);function zi(e){let{forest:t,containers:n,itemMeta:r}=e,i=[{containerId:T,offsetX:0,offsetY:0,children:t.childrenByParent.get(T)??[],nextChildIndex:0,entered:!1}];for(;i.length>0;){let e=i[i.length-1];if(!e.entered){e.entered=!0;let t=n.get(e.containerId);t&&(t.left+=e.offsetX,t.top+=e.offsetY,t.contentLeft+=e.offsetX,t.contentRight+=e.offsetX,t.contentTop+=e.offsetY,t.contentBottom+=e.offsetY,t.verticalCorridors=t.verticalCorridors.map(t=>t+e.offsetX),t.horizontalCorridors=t.horizontalCorridors.map(t=>t+e.offsetY))}let a=e.children[e.nextChildIndex];if(!a){i.pop();continue}if(e.nextChildIndex+=1,k(a))continue;let o=r.get(a.id);o&&(o.cellLeft+=e.offsetX,o.cellTop+=e.offsetY,o.leftCorridorX+=e.offsetX,o.rightCorridorX+=e.offsetX,o.topCorridorY+=e.offsetY,o.bottomCorridorY+=e.offsetY),a.x=(a.x??0)+e.offsetX,a.y=(a.y??0)+e.offsetY,a.isGroup&&(a.groupTitleRect&&=Ri(a.groupTitleRect,a.x-(a.width??0)/2,a.y-(a.height??0)/2),i.push({containerId:a.id,offsetX:a.x-(a.width??0)/2,offsetY:a.y-(a.height??0)/2,children:t.childrenByParent.get(a.id)??[],nextChildIndex:0,entered:!1}))}}c(zi,`materializeAbsoluteGeometry`);function Bi(e,t){let n=new Map(e.nodes.map(e=>[e.id,e]));for(let e of t.nodes){let t=n.get(e.id);t&&(e.x=t.x,e.y=t.y,e.width=t.width,e.height=t.height,t.groupTitleRect?e.groupTitleRect={...t.groupTitleRect}:delete e.groupTitleRect)}let r=new Map(e.edges.map(e=>[e.id,e]));for(let e of t.edges){let t=r.get(e.id);t&&(e.points=t.points?.map(e=>({...e})),e.curve=t.curve,e.cornerRadius=t.cornerRadius,e.portClipping=`outline-orthogonal`,e.skipCornerFix=t.curve===`linear`)}}c(Bi,`commitGridGeometry`);function Vi(e){return{...e,nodes:e.nodes.map(e=>({...e,labelBBox:e.labelBBox?{...e.labelBBox}:e.labelBBox,groupTitleRect:e.groupTitleRect?{...e.groupTitleRect}:e.groupTitleRect})),edges:e.edges.map(e=>({...e,points:e.points?.map(e=>({...e}))}))}}c(Vi,`cloneGridLayoutData`);function Hi(e,t){let n=new Map(t.map(e=>[e.id,e])),r=c(e=>{let t=n.get(e.id);if(!t)throw Error(`Missing committed grid node "${e.id}"`);return t},`originalNode`),i=c(e=>{let t=r(e);if(!t.isGroup)throw Error(`Committed grid node "${e.id}" is no longer a group`);return t},`originalGroup`);return{nodeById:n,groupById:new Map([...e.groupById].map(([e,t])=>[e,i(t)])),childrenByParent:new Map([...e.childrenByParent].map(([e,t])=>[e,t.map(r)])),rootChildren:e.rootChildren.map(r),postOrderGroups:e.postOrderGroups.map(i),helperNodeIds:new Set(e.helperNodeIds)}}c(Hi,`rebindGridForest`);function Ui(e,t){let n=Et(e.nodes),r=Bt(e),i=zt(e.nodes.filter(e=>!k(e)));Vt(e.nodes.filter(e=>!k(e)),r);let a={forest:n,config:r,containers:new Map,itemMeta:new Map,sourceOrder:i,labelRequirements:Ot(e,n,t.metrics)};for(let e of n.postOrderGroups)Li(e.id,a,a.containers,a.itemMeta,t.metrics);return Li(T,a,a.containers,a.itemMeta,t.metrics),zi(a),ji(e,a,t.metrics,t.routing),wt(e,void 0,t.metrics),a}c(Ui,`runGridLayoutCoreInPlace`);function Wi(e,t={}){let n=e,r=Vi(n),i=Ui(r,t);return Bi(r,n),{...i,forest:Hi(i.forest,n.nodes)}}c(Wi,`runGridLayoutCore`);function Gi(n,{measure:r}){let i=e(n.config.grid?.lineHops);if(i===!1)return;let a=n.edges.filter(e=>Array.isArray(e.points)&&e.points.length>=2).map(e=>({id:e.id,points:e.points,curve:e.curve,cornerRadius:e.cornerRadius,arrowTypeStart:e.arrowTypeStart,arrowTypeEnd:e.arrowTypeEnd}));t(r.groups.edgePaths,a,{enabled:!0,jumpRadius:6,jumpStyle:i})}c(Gi,`applyGridLineJumps`);var Ki=n({prepareLayout:Ct,runLayoutCore:c(e=>Wi(e),`runLayoutCore`),afterPaint:Gi});export{Ct as prepareGridLayout,Ki as render,Wi as runGridLayoutCore};
@@ -0,0 +1 @@
1
+ .cv-root{flex-direction:column;flex:1 1 0;height:100%;min-height:0;display:flex}.cv-header{background:var(--bg-panel);border-bottom:1px solid var(--border);color:var(--fg-dim);font-family:var(--font-mono);flex:none;align-items:center;gap:8px;padding:4px 8px 4px 14px;font-size:12px;display:flex}.cv-path{text-overflow:ellipsis;white-space:nowrap;flex:auto;overflow:hidden}.cv-close{width:22px;height:22px;color:var(--fg-dim);background:0 0;border:none;border-radius:4px;flex:none;justify-content:center;align-items:center;display:inline-flex}.cv-close:hover{color:var(--fg);background:var(--bg-elev)}.cv-scroll{flex:auto;min-height:0;overflow:auto}.cv-code{font-family:var(--font-mono);tab-size:2;min-width:max-content;margin:0;padding:8px 0;font-size:13px;line-height:1.5}.cv-line{white-space:pre;transition:opacity .15s;display:flex}.cv-line-hit{background:var(--highlight);box-shadow:inset 2px 0 0 0 var(--highlight-border)}.cv-line-context{background:var(--highlight)}.cv-line-focus{box-shadow:inset 2px 0 0 0 var(--highlight-border)}.cv-line-dim{opacity:.32}.cv-gutter{text-align:right;color:#75715e;-webkit-user-select:none;user-select:none;flex:none;width:44px;padding-right:14px}.cv-content{white-space:pre;flex:auto;padding-right:16px}:root{--bg:#272822;--bg-elev:#2f302a;--bg-panel:#1e1f1c;--border:#3e3d32;--fg:#f8f8f2;--fg-dim:#a6a28c;--accent:#66d9ef;--accent-2:#a6e22e;--pink:#f92672;--orange:#fd971f;--purple:#ae81ff;--yellow:#e6db74;--highlight:#66d9ef24;--highlight-border:#66d9ef;--font-ui:-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;--font-mono:"SFMono-Regular", "JetBrains Mono", Menlo, Consolas, monospace}*{box-sizing:border-box}html,body,#root{height:100%;margin:0}body{background:var(--bg);color:var(--fg);font-family:var(--font-ui);font-size:14px;line-height:1.6}a{color:var(--accent);text-decoration:none}a:hover{text-decoration:underline}code{font-family:var(--font-mono);background:var(--bg-panel);border-radius:3px;padding:.1em .35em;font-size:.9em}pre{overflow-x:auto}button{font-family:var(--font-ui);cursor:pointer}.app{flex-direction:column;height:100%;display:flex}.topbar{background:var(--bg-panel);border-bottom:1px solid var(--border);flex:none;align-items:center;gap:16px;padding:10px 18px;display:flex}.topbar .brand{color:var(--fg);font-weight:700}.topbar .brand .dot{color:var(--pink);font-weight:700}.topbar nav{align-items:center;gap:14px;display:flex}.navlink{font:inherit;color:var(--accent);cursor:pointer;background:0 0;border:none;padding:0}.navlink:hover{text-decoration:underline}.topbar .spacer{flex:1}.topbar .repo{color:var(--fg-dim)}.topbar .keep-files{color:var(--fg-dim);cursor:pointer;-webkit-user-select:none;user-select:none;align-items:center;gap:6px;font-size:13px;display:flex}.topbar .keep-files input{cursor:pointer;margin:0}.body{flex:auto;min-height:0;display:flex}.route{flex-direction:column;flex:1 1 0;min-width:0;min-height:0;display:flex;overflow-y:auto}.explorer{display:contents}.activity-bar{background:var(--bg-panel);border-right:1px solid var(--border);flex-direction:column;flex:0 0 48px;align-items:center;padding-top:8px;display:flex}.activity-btn{width:40px;height:40px;color:var(--fg-dim);background:0 0;border:none;border-left:2px solid #0000;border-radius:6px;justify-content:center;align-items:center;display:inline-flex}.activity-btn:hover{color:var(--fg);background:var(--bg-elev)}.activity-btn.active{color:var(--accent);border-left-color:var(--accent)}.pane-header{color:var(--fg-dim);text-transform:uppercase;letter-spacing:.08em;border-bottom:1px solid var(--border);padding:8px 14px;font-size:11px}.page{width:100%;max-width:900px;margin:0 auto;padding:28px 32px}.page h1{color:var(--fg);margin-top:0}.section-title{color:var(--orange);border-bottom:1px solid var(--border);margin-top:32px;padding-bottom:6px}.card-grid{grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:14px;display:grid}.card{background:var(--bg-elev);border:1px solid var(--border);color:var(--fg);border-radius:8px;padding:14px 16px;display:block}.card:hover{border-color:var(--accent);text-decoration:none}.card .card-title{color:var(--accent-2);font-weight:600}.card .card-summary{color:var(--fg-dim);margin-top:4px;font-size:.92em}.btn{background:var(--pink);color:#fff;border:none;border-radius:6px;padding:9px 18px;font-size:14px;font-weight:600;display:inline-block}.btn:hover{filter:brightness(1.1);text-decoration:none}.btn.secondary{background:var(--bg-elev);color:var(--fg);border:1px solid var(--border)}.btn:disabled{opacity:.4;cursor:not-allowed}.md img{max-width:100%}.md pre{background:var(--bg-panel);border:1px solid var(--border);border-radius:6px;padding:12px 14px}.md pre code{background:0 0;padding:0}.md blockquote{border-left:3px solid var(--purple);color:var(--fg-dim);margin-left:0;padding-left:14px}.md table{border-collapse:collapse}.md th,.md td{border:1px solid var(--border);padding:6px 10px}.pane{min-height:0}.explorer .pane.tree{background:var(--bg-panel);flex:none;overflow:auto}.explorer .pane.code{background:var(--bg);border-right:1px solid var(--border);flex-direction:column;flex:1 1 0;min-width:220px;display:flex}.resize-handle{cursor:col-resize;background:var(--border);flex:0 0 5px;transition:background .12s}.resize-handle:hover{background:var(--accent)}.tabs{background:var(--bg-panel);border-bottom:1px solid var(--border);scrollbar-width:none;flex:none;display:flex;overflow-x:auto}.tabs::-webkit-scrollbar{height:0}.tab{border-right:1px solid var(--border);color:var(--fg-dim);white-space:nowrap;cursor:pointer;border-top:2px solid #0000;align-items:center;gap:6px;padding:6px 8px 6px 12px;font-size:12.5px;display:flex}.tab:hover{color:var(--fg)}.tab.active{color:var(--fg);background:var(--bg);border-top-color:var(--accent)}.tab-label{text-overflow:ellipsis;max-width:180px;overflow:hidden}.tab-close{width:18px;height:18px;color:var(--fg-dim);opacity:.6;background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;display:inline-flex}.tab:hover .tab-close,.tab.active .tab-close{opacity:1}.tab-close:hover{background:var(--bg-elev);color:var(--fg)}.tree{-webkit-user-select:none;user-select:none;padding:4px 0}.tree-row{text-align:left;width:100%;color:var(--fg-dim);min-height:24px;font-size:13px;font-family:var(--font-ui);white-space:nowrap;background:0 0;border:none;align-items:stretch;gap:5px;padding:0 10px 0 8px;line-height:24px;display:flex}.tree-row:hover{color:var(--fg);background:var(--bg-elev)}.tree-file-row.active,.tree-doc-row.active{color:var(--fg);background:var(--highlight);box-shadow:inset 2px 0 0 0 var(--highlight-border)}.tree-doc-row{text-decoration:none}.tree-chevron-hit{cursor:pointer;border-radius:3px;flex:none;justify-content:center;align-self:stretch;align-items:center;margin:0 -3px;padding:0 3px;display:inline-flex}.tree-chevron-hit:hover{background:var(--border)}.indent-guides{flex:none;align-self:stretch;display:flex}.indent-guide{border-left:1px solid var(--border);flex:0 0 12px;align-self:stretch}.tree-row:hover .indent-guide{border-left-color:#57564a}.tree-label{text-overflow:ellipsis;overflow:hidden}.tree-chevron{width:10px;height:10px;color:var(--fg-dim);flex:none;justify-content:center;align-items:center;transition:transform .1s;display:inline-flex}.tree-icon{flex:none;justify-content:center;align-items:center;width:16px;height:16px;display:inline-flex}.file-badge{font-family:var(--font-mono);letter-spacing:-.5px;border-radius:3px;font-weight:700;line-height:1}.link-button{color:var(--accent);font:inherit;cursor:pointer;background:0 0;border:none;padding:0}.link-button:hover{text-decoration:underline}.tour-panel.standalone{background:var(--bg-elev);flex-direction:column;flex:auto;min-height:0;display:flex}.tour-panel-head{border-bottom:1px solid var(--border);padding:16px 20px}.tour-panel-body{flex:1;padding:16px 20px;overflow-y:auto}.tour-panel-nav{border-top:1px solid var(--border);align-items:center;gap:8px;padding:14px 20px;display:flex}.step-counter{color:var(--fg-dim);font-size:13px}.step-overview{margin-top:8px}.step-overview-item{text-align:left;width:100%;color:var(--fg-dim);background:0 0;border:none;border-left:2px solid #0000;padding:5px 12px;font-size:13px;display:block}.step-overview-item:hover{color:var(--fg)}.step-overview-item.active{color:var(--fg);border-left-color:var(--pink);background:var(--highlight)}.step-overview-item .order{color:var(--purple);font-family:var(--font-mono);margin-right:8px}.step-overview-item.detail{padding-left:26px;font-size:12.5px}.step-overview-item.detail .detail-dot{color:var(--fg-dim);font-family:var(--font-mono);margin-right:6px}.step-overview-item.detail.active .detail-dot{color:var(--accent)}.detail-crumb{color:var(--fg-dim);text-transform:uppercase;letter-spacing:.05em;margin-bottom:4px;font-size:12px}.callout{--callout-accent:var(--orange);background:var(--bg-panel);border-left:3px solid var(--callout-accent);border-radius:0 4px 4px 0;margin:10px 0;padding:8px 12px}.callout .callout-title{color:var(--callout-accent);font-weight:600}.callout .callout-body>:first-child{margin-top:4px}.callout .callout-body>:last-child{margin-bottom:0}.callout-note,.callout-info{--callout-accent:var(--accent)}.callout-tip,.callout-success{--callout-accent:var(--accent-2)}.callout-important{--callout-accent:var(--purple)}.callout-warning,.callout-caution{--callout-accent:var(--yellow)}.callout-danger,.callout-error,.callout-bug{--callout-accent:var(--pink)}.empty{color:var(--fg-dim);font-style:italic}.banner{background:var(--pink);color:#fff;padding:6px 18px;font-size:13px}.md a.file-link{color:var(--accent-2);text-underline-offset:2px;cursor:pointer;text-decoration-line:underline;text-decoration-style:dotted}.md a.file-link:before{content:"▸";color:var(--fg-dim);margin-right:3px;font-size:.85em}.md a.doc-link{color:var(--accent);text-underline-offset:2px;text-decoration-line:underline;text-decoration-style:dotted}.md a.doc-link:before{content:"📄";opacity:.75;margin-right:4px;font-size:.8em}.doc-breadcrumb{color:var(--fg-dim);font-size:13px}.glossary-panel{background:var(--bg-panel);border-left:1px solid var(--border);flex-direction:column;flex:0 0 360px;max-width:60%;min-height:0;display:flex}.glossary-head{border-bottom:1px solid var(--border);flex:none;justify-content:space-between;align-items:center;padding:10px 12px 10px 16px;display:flex}.glossary-title{color:var(--fg-dim);text-transform:uppercase;letter-spacing:.08em;font-size:11px;font-weight:600}.glossary-close{width:24px;height:24px;color:var(--fg-dim);background:0 0;border:none;border-radius:4px;justify-content:center;align-items:center;display:inline-flex}.glossary-close:hover{background:var(--bg-elev);color:var(--fg)}.glossary-search{border-bottom:1px solid var(--border);flex:none;padding:10px 12px}.glossary-search input{background:var(--bg);border:1px solid var(--border);width:100%;color:var(--fg);font-family:var(--font-ui);border-radius:6px;padding:7px 10px;font-size:13px}.glossary-search input:focus{border-color:var(--accent);outline:none}.glossary-body{flex:auto;min-height:0;padding:4px 16px 20px;overflow-y:auto}.glossary-concept{border-bottom:1px solid var(--border);padding:12px 0}.glossary-concept:last-child{border-bottom:none}.glossary-concept h3{color:var(--orange);margin:0 0 4px;font-size:15px}*{scrollbar-width:thin;scrollbar-color:var(--border) transparent}::-webkit-scrollbar{width:12px;height:12px}::-webkit-scrollbar-track{background:0 0}::-webkit-scrollbar-thumb{background-color:var(--border);background-clip:padding-box;border:3px solid #0000;border-radius:7px}::-webkit-scrollbar-thumb:hover{background-color:#57564a;background-clip:padding-box}::-webkit-scrollbar-corner{background:0 0}.landing-credit{text-align:center;color:var(--fg-dim);margin-top:3rem;font-size:.85rem}