repo-harness-operator-web 0.33.0 → 0.33.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 (93) hide show
  1. package/dist/assets/{ArchitectureWorkspace-Ct_jHQUL.js → ArchitectureWorkspace-D9xBWWNX.js} +4 -4
  2. package/dist/assets/DocsPage-D-TDxd3u.js +33 -0
  3. package/dist/assets/{abnfDiagram-S7VZAUFO-EWJnIFpr.js → abnfDiagram-S7VZAUFO-BMdQYPka.js} +1 -1
  4. package/dist/assets/{architecture-WOLXFQ4H-CohwaElX.js → architecture-WOLXFQ4H-DkfKX5Dq.js} +1 -1
  5. package/dist/assets/{architectureDiagram-YGSQEFNW-DI_tYY1m.js → architectureDiagram-YGSQEFNW-DkWdq-JZ.js} +1 -1
  6. package/dist/assets/{blockDiagram-APKKGZFW-FZ5KXr6b.js → blockDiagram-APKKGZFW-DNyO_n7h.js} +1 -1
  7. package/dist/assets/{c4Diagram-KJ2TOQU5-BYMYEb7c.js → c4Diagram-KJ2TOQU5-DxwpnfpQ.js} +1 -1
  8. package/dist/assets/{chunk-6MUBBAK2-CxWTBJUa.js → chunk-6MUBBAK2-BdWqPs1z.js} +1 -1
  9. package/dist/assets/{chunk-AXFCVDMN-B11KMJBB.js → chunk-AXFCVDMN-A0UaaW53.js} +1 -1
  10. package/dist/assets/{chunk-BG4553SI-C06tWZkB.js → chunk-BG4553SI-JQovfikF.js} +1 -1
  11. package/dist/assets/{chunk-DQASFODM-D01Lwpd7.js → chunk-DQASFODM-DeKEUSn4.js} +1 -1
  12. package/dist/assets/{chunk-HFQBQIA3-B09dXYxm.js → chunk-HFQBQIA3-QG-Zi_gz.js} +1 -1
  13. package/dist/assets/{chunk-KQLB2F66-CJ9lxhvD.js → chunk-KQLB2F66-BNzSAZYv.js} +1 -1
  14. package/dist/assets/{chunk-KS47KZWR-CWEp4e0K.js → chunk-KS47KZWR-Br4k6Of9.js} +1 -1
  15. package/dist/assets/{chunk-LEVMRMFU-DodyAObK.js → chunk-LEVMRMFU-Cx3yThXe.js} +1 -1
  16. package/dist/assets/{chunk-M57EVK23-CupqpPot.js → chunk-M57EVK23-Dd5WZh7i.js} +1 -1
  17. package/dist/assets/{chunk-OY52VR5R-C7C4jz_R.js → chunk-OY52VR5R-2Yzd_na6.js} +1 -1
  18. package/dist/assets/{chunk-QB3YPZ4I-Yy2xavUh.js → chunk-QB3YPZ4I-CHJ8i9qs.js} +1 -1
  19. package/dist/assets/{chunk-R3KSYZAL-861ZmOoj.js → chunk-R3KSYZAL-CXvec6Gn.js} +1 -1
  20. package/dist/assets/{chunk-STOXU5M4-BhNPxGiq.js → chunk-STOXU5M4-GPAWllEy.js} +1 -1
  21. package/dist/assets/{chunk-TU62E6Q5-fO9iaPI7.js → chunk-TU62E6Q5-r_WNTgJd.js} +1 -1
  22. package/dist/assets/{chunk-X4PVCEUW-CSvDEu_r.js → chunk-X4PVCEUW-GqziBKoe.js} +1 -1
  23. package/dist/assets/{classDiagram-v2-L25IHNXF-DiA7zJBq.js → classDiagram-v2-L25IHNXF-BnjvNpae.js} +1 -1
  24. package/dist/assets/cynefin-EF2NZ3EQ-wV28XTUF.js +1 -0
  25. package/dist/assets/{cynefinDiagram-L36ESFBY-XojF-Rlg.js → cynefinDiagram-L36ESFBY-ZpUZ7Y52.js} +1 -1
  26. package/dist/assets/{dagre-SPEB5RXH-C3s1TK9p.js → dagre-SPEB5RXH-Dz3ALJs3.js} +1 -1
  27. package/dist/assets/{diagram-3B7GL73J-Rb_LxJzG.js → diagram-3B7GL73J-CI6vfFME.js} +1 -1
  28. package/dist/assets/{diagram-DNEMPZML-BBRa_csW.js → diagram-DNEMPZML-Dm9xeF4f.js} +1 -1
  29. package/dist/assets/{diagram-L3MUGCDN-BbVfZxgP.js → diagram-L3MUGCDN-B4Df4y1y.js} +1 -1
  30. package/dist/assets/{diagram-LA4NIPWU-CDxSZu0g.js → diagram-LA4NIPWU-CscFtNdz.js} +1 -1
  31. package/dist/assets/{diagram-MHCOC4E2-CrsdLjJN.js → diagram-MHCOC4E2-CQV7-04C.js} +1 -1
  32. package/dist/assets/{diagram-XPFHEONP-CXp8fDD8.js → diagram-XPFHEONP-DK2dH_hJ.js} +1 -1
  33. package/dist/assets/{ebnfDiagram-UZSYDL2S-DcwSFGOa.js → ebnfDiagram-UZSYDL2S-CpRYqL5z.js} +1 -1
  34. package/dist/assets/{elk-XV6XMXQE-D3STAWYR.js → elk-XV6XMXQE-C73_VWt1.js} +1 -1
  35. package/dist/assets/{erDiagram-EYBAPDEH-DWRLNdIC.js → erDiagram-EYBAPDEH-Bs7sweQK.js} +1 -1
  36. package/dist/assets/{eventmodeling-K75KTNOO-Cvp5yZHI.js → eventmodeling-K75KTNOO-BNujnBw6.js} +1 -1
  37. package/dist/assets/flowDiagram-MALGAFMO-B06x0Us9.js +1 -0
  38. package/dist/assets/{ganttDiagram-23REXITY-C-StMmdJ.js → ganttDiagram-23REXITY-DsNKi0B8.js} +1 -1
  39. package/dist/assets/gitGraph-VSP46ZUC-D3OGjYzW.js +1 -0
  40. package/dist/assets/{gitGraphDiagram-STJD7YCW-cXxZbO9e.js → gitGraphDiagram-STJD7YCW-Cy-ZMu4N.js} +1 -1
  41. package/dist/assets/index-CI7xAfcZ.css +1 -0
  42. package/dist/assets/index-DUe-MPm9.js +39 -0
  43. package/dist/assets/info-OHQRW6UA-WyDhDa0m.js +1 -0
  44. package/dist/assets/{infoDiagram-KBXO4MBG-3x2W0Ulo.js → infoDiagram-KBXO4MBG-lNzdqxQy.js} +1 -1
  45. package/dist/assets/{ishikawaDiagram-M35NCXHK-C4t7CmQ5.js → ishikawaDiagram-M35NCXHK-Ce4_oVcs.js} +1 -1
  46. package/dist/assets/{journeyDiagram-OPLOXDXO-uQFL0qDD.js → journeyDiagram-OPLOXDXO-DDxSSmQ6.js} +1 -1
  47. package/dist/assets/{kanban-definition-BZKZHSQY-CbHPljwW.js → kanban-definition-BZKZHSQY-wfhj180_.js} +1 -1
  48. package/dist/assets/{line-Drh_D-tk.js → line-CLWYGDAf.js} +1 -1
  49. package/dist/assets/{mermaid-parser.core-DdHIqKW8.js → mermaid-parser.core-CBhYcmlU.js} +3 -3
  50. package/dist/assets/{mermaid.core-CQ2MjaA1.js → mermaid.core-BaW6IpwH.js} +4 -4
  51. package/dist/assets/{mindmap-definition-I2QAS2VK-BTMyEIeR.js → mindmap-definition-I2QAS2VK-C0usipex.js} +1 -1
  52. package/dist/assets/packet-JDAUHWVQ-COJd8qgZ.js +1 -0
  53. package/dist/assets/{pegDiagram-FD4XPPHP-DzmNwNiE.js → pegDiagram-FD4XPPHP-BuZGcP2k.js} +1 -1
  54. package/dist/assets/pie-XZMESJXO-D5kglymR.js +1 -0
  55. package/dist/assets/{pieDiagram-J4AKIIQI-CEGfxfXL.js → pieDiagram-J4AKIIQI-Dpn7ykJr.js} +1 -1
  56. package/dist/assets/{quadrantDiagram-XTYBLID2-klLnrjh0.js → quadrantDiagram-XTYBLID2-DxmqzKan.js} +1 -1
  57. package/dist/assets/radar-ABXABTNO-PMJU2l3f.js +1 -0
  58. package/dist/assets/railroad-I3PHUGI6-BxFuljCU.js +1 -0
  59. package/dist/assets/{railroad-abnf-LNEFI6M7-D9_M2yfg.js → railroad-abnf-LNEFI6M7-B5VEAY1X.js} +1 -1
  60. package/dist/assets/{railroad-ebnf-DWYD2UWJ-CYD0C0JH.js → railroad-ebnf-DWYD2UWJ-BGCjLcEq.js} +1 -1
  61. package/dist/assets/{railroad-peg-JR7BVNR7-DAIZtMyU.js → railroad-peg-JR7BVNR7-FtX8cGuM.js} +1 -1
  62. package/dist/assets/{railroadDiagram-MRQ6NCDL-DdUa5oAU.js → railroadDiagram-MRQ6NCDL-XzUdmv6V.js} +1 -1
  63. package/dist/assets/{requirementDiagram-Y7LWUY3S-BXq_-NUv.js → requirementDiagram-Y7LWUY3S-DspclkMC.js} +1 -1
  64. package/dist/assets/{sankeyDiagram-WGJFYUXA-C4Z-LSYq.js → sankeyDiagram-WGJFYUXA-B9JRvsET.js} +1 -1
  65. package/dist/assets/{sequenceDiagram-5NDRBG5M-DTWUF0R7.js → sequenceDiagram-5NDRBG5M-F69qUBSl.js} +1 -1
  66. package/dist/assets/{stateDiagram-v2-FJ4FJNEA-DKVJtNr7.js → stateDiagram-v2-FJ4FJNEA-BaOt35SX.js} +1 -1
  67. package/dist/assets/{swimlanes-UMQ2AFYF-Dm-_4Uy0.js → swimlanes-UMQ2AFYF-CdRhUtVR.js} +1 -1
  68. package/dist/assets/swimlanesDiagram-OMPLPG4O-DxSW_nUS.js +8 -0
  69. package/dist/assets/{timeline-definition-SEUHKTQE-DMegKY7s.js → timeline-definition-SEUHKTQE-zkhgi48N.js} +1 -1
  70. package/dist/assets/treeView-D4JQ5SDB-DKauZxTC.js +1 -0
  71. package/dist/assets/treemap-SAJKECNS-Be7YfKIU.js +1 -0
  72. package/dist/assets/{usecaseDiagram-AFA6YXN4-BwSZRGRM.js → usecaseDiagram-AFA6YXN4-JFtQs7gE.js} +1 -1
  73. package/dist/assets/{vennDiagram-NNMJR3RB-Bx3DK_6a.js → vennDiagram-NNMJR3RB-CZks_Cqk.js} +1 -1
  74. package/dist/assets/wardley-7MLQ67FV-D9LRPq4B.js +1 -0
  75. package/dist/assets/{wardleyDiagram-S7YFUSEH-DEfTBZA4.js → wardleyDiagram-S7YFUSEH-BMpHt07k.js} +1 -1
  76. package/dist/assets/{xychartDiagram-GGNKY7IX-CDtSZDUn.js → xychartDiagram-GGNKY7IX-BL4IaOac.js} +1 -1
  77. package/dist/index.html +2 -2
  78. package/package.json +1 -1
  79. package/dist/assets/DocsPage-DFZZ8yfT.js +0 -33
  80. package/dist/assets/cynefin-EF2NZ3EQ-B9T0GnTj.js +0 -1
  81. package/dist/assets/flowDiagram-MALGAFMO-C--4LNs9.js +0 -1
  82. package/dist/assets/gitGraph-VSP46ZUC-D9HPl_FK.js +0 -1
  83. package/dist/assets/index-DArrWrCS.js +0 -31
  84. package/dist/assets/index-DEMWQOS_.css +0 -1
  85. package/dist/assets/info-OHQRW6UA-aDviRpIn.js +0 -1
  86. package/dist/assets/packet-JDAUHWVQ-DVDyO1D2.js +0 -1
  87. package/dist/assets/pie-XZMESJXO-D4ZnJoVI.js +0 -1
  88. package/dist/assets/radar-ABXABTNO-CHtDNwI1.js +0 -1
  89. package/dist/assets/railroad-I3PHUGI6-D9IX8VYQ.js +0 -1
  90. package/dist/assets/swimlanesDiagram-OMPLPG4O-Bc_s-QbF.js +0 -8
  91. package/dist/assets/treeView-D4JQ5SDB-ffxbDUPZ.js +0 -1
  92. package/dist/assets/treemap-SAJKECNS-C_tNyRp_.js +0 -1
  93. package/dist/assets/wardley-7MLQ67FV-I2RPoQB0.js +0 -1
@@ -1,10 +1,10 @@
1
- import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{C as t,E as n,T as r,_ as i,a,d as o,g as s,h as c,m as l,n as u,o as d,p as f,s as p,v as m,x as h}from"./index-DArrWrCS.js";import{C as g,S as _,T as v,_ as y,b,i as x,n as S,r as C,t as w,v as T,w as E,x as D,y as O}from"./src-C_gRsKqw.js";import{t as k}from"./value-CHmTzbgv.js";var A=e=>()=>e;function j(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}j.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function M(e){return!e.ctrlKey&&!e.button}function N(){return this.parentNode}function P(e,t){return t??{x:e.x,y:e.y}}function F(){return navigator.maxTouchPoints||`ontouchstart`in this}function ee(){var e=M,t=N,n=P,r=F,i={},a=v(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,x).on(`touchmove.drag`,S,b).on(`touchend.drag touchcancel.drag`,C).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=w(this,t.call(this,n,r),n,r,`mouse`);i&&(E(n.view).on(`mousemove.drag`,m,D).on(`mouseup.drag`,h,D),y(n.view),_(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(O(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){E(e.view).on(`mousemove.drag mouseup.drag`,null),T(e.view,l),O(e),i.mouse(`end`,e)}function x(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=w(this,a,n,r,i[s].identifier,i[s]))&&(_(n),c(`start`,n,i[s]))}function S(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(O(e),a(`drag`,e,t[r]))}function C(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(_(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=g(l||r,t),p,m,h;if((h=n.call(e,new j(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var _=d,v;switch(r){case`start`:i[c]=n,v=o++;break;case`end`:delete i[c],--o;case`drag`:d=g(l||a,t),v=o}u.call(r,e,new j(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:v,x:d[0]+p,y:d[1]+m,dx:d[0]-_[0],dy:d[1]-_[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:A(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:A(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:A(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:A(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var I=e(n(),1);function te(e){return e.kind===`group`}var L=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,R=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,z=e=>typeof e==`string`,B=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ne=e=>B(e)&&e>0,re=e=>typeof e==`boolean`,ie=e=>t=>z(t)&&e.test(t),V=(...e)=>t=>e.includes(t),ae=e=>t=>t===null||e(t),H=e=>t=>Array.isArray(t)&&t.every(e),U=e=>t=>{if(!t||typeof t!=`object`||Array.isArray(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},oe=ie(/^[0-9a-f]{64}$/),se=ie(R),ce=ie(L),le=e=>z(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),ue=U({model_valid:V(`valid`,`invalid`,`unknown`),generated_summary:V(`fresh`,`stale`,`unknown`),section3:V(`present`,`pending`)}),de=U({id:z,from:z,to:z,label:z,evidence:U({entrypointId:z,sourceSymbol:z,sinkId:z})}),fe=e=>U({id:z,capabilityId:ce,name:z,applicability:V(`not-applicable`),rationale:z})(e)||U({id:z,capabilityId:ce,name:z,applicability:V(`required`),participants:H(U({id:z,nodeId:z})),steps:H(de),outcomes:H(U({id:z,kind:V(`success`,`error`),label:z,steps:H(de),terminal:U({participant:z,label:z})}))})(e),pe=e=>typeof e==`string`&&e.length>0&&e!==`group`,me=U({include:H(z),exclude:H(z)}),he=e=>U({id:z,kind:pe,name:z,role:V(`center`,`child`,`caller`,`callee`)})(e)||U({id:z,kind:V(`group`),role:V(`caller`,`callee`),count:ne,members:H(U({id:z,name:z}))})(e),ge=U({schema_version:V(`repo-harness.architecture-modules.v1`),commit:se,modules:H(U({id:ce,domain:z,name:z,status:z,components:B,state:ue}))}),_e=U({schema_version:V(`repo-harness.architecture-module.v1`),commit:se,module:U({id:ce,name:z,status:z,summary:z,responsibilities:H(z),notes:H(z),source:me,verification:H(z),entrypoints:H(U({id:z,path:le,symbols:H(U({name:z,sinks:H(U({id:z,path:le,symbol:z}))}))})),components:H(U({id:z,kind:pe,name:z,summary:z,source:me}))}),graph:U({center:ce,nodes:H(he),edges:H(U({source:z,target:z,intent:z,relation_kind:z,direction:V(`directed`)}))}),flows:H(fe),section3:ae(z),linked_docs:H(U({path:le,kind:V(`contract`,`plan`),status:ae(z)})),state:ue}),ve=U({schema_version:V(`repo-harness.module-review-prompt.v1`),prompt_version:z,package_version:z,repository_id:ie(/^repo_[0-9a-f]{16}$/),capability_id:ce,commit:se,mode:V(`module`,`diff`),base:ae(se),head:ae(se),worktree_dirty_paths:H(le),dirty_content_sha256:ae(oe),model_sha256:oe,doc_sha256:ae(oe),sources:H(U({path:le,sha256:oe,bytes:B,class:V(`required`,`optional`),disposition:V(`included`,`omitted`,`chunked`)})),budget:U({input_cap_bytes:ne,used_bytes:B,incomplete:re,omitted_sections:H(z)}),shard:U({index:ne,count:ne,bytes:B}),full_prompt_sha256:oe,prompt:z,digest:oe});function ye(e){if(!ge(e))throw Error(`architecture_module_index_invalid`);return e}function be(e){if(!_e(e))throw Error(`architecture_module_detail_invalid`);let t=e,n=new Set(t.graph.nodes.map(e=>e.id));if(t.graph.center!==t.module.id||!n.has(t.graph.center)||n.size!==t.graph.nodes.length||t.graph.edges.some(e=>!n.has(e.source)||!n.has(e.target))||t.graph.nodes.some(e=>te(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function xe(e){if(!ve(e))throw Error(`architecture_review_prompt_invalid`);let t=e;if(t.shard.index>t.shard.count||(t.mode===`module`?t.base!==null||t.head!==null:t.base===null||t.head===null)||t.worktree_dirty_paths.length===0!=(t.dirty_content_sha256===null))throw Error(`architecture_review_prompt_invalid`);return t}var Se=Object.defineProperty,Ce=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,we=(e,t)=>{for(var n in t)Se(e,n,{get:t[n],enumerable:!0})},Te=(e,t,n)=>Ce(e,typeof t==`symbol`?t:t+``,n),Ee={};we(Ee,{Graph:()=>dt,alg:()=>ze});var De=Object.defineProperty,Oe=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})},ke=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}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 this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][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 e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(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(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;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}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Me(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Ne(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ae(this._preds[a],i),Ae(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Pe(this._isDirected,e):Me(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Pe(this._isDirected,e):Me(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Pe(this._isDirected,e):Me(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],je(this._preds[t],e),je(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Ae(e,t){e[t]?e[t]++:e[t]=1}function je(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Me(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Ne(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Pe(e,t){return Me(e,t.v,t.w,t.name)}Oe({},{read:()=>Re,write:()=>Fe});function Fe(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Ie(e),edges:Le(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Ie(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Le(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Re(e){let t=new ke(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var ze={};Oe(ze,{CycleException:()=>et,bellmanFord:()=>Ve,components:()=>Ue,dijkstra:()=>Ke,dijkstraAll:()=>Je,findCycles:()=>Xe,floydWarshall:()=>Qe,isAcyclic:()=>nt,postorder:()=>ot,preorder:()=>st,prim:()=>ct,shortestPaths:()=>lt,tarjan:()=>Ye,topsort:()=>tt});var Be=()=>1;function Ve(e,t,n,r){return He(e,String(t),n||Be,r||function(t){return e.outEdges(t)??[]})}function He(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function Ue(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var We=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},Ge=()=>1;function Ke(e,t,n,r){return qe(e,String(t),n||Ge,r||function(t){return e.outEdges(t)??[]})}function qe(e,t,n,r){let i={},a=new We,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function Je(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=Ke(e,i,t,n),r},{})}function Ye(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function Xe(e){return Ye(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var Ze=()=>1;function Qe(e,t,n){return $e(e,t||Ze,n||function(t){return e.outEdges(t)??[]})}function $e(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var et=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function tt(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new et;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new et;return r}function nt(e){try{tt(e)}catch(e){if(e instanceof et)return!1;throw e}return!0}function rt(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=it(e,t,n===`post`,o,a,r,i)}),i}function it(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=it(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function at(e,t,n){return rt(e,t,n,function(e,t){return e.push(t),e},[])}function ot(e,t){return at(e,t,`post`)}function st(e,t){return at(e,t,`pre`)}function ct(e,t){var n;let r=new ke,i={},a=new We,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function lt(e,t,n,r){return ut(e,t,n,r??(t=>e.outEdges(t)??[]))}function ut(e,t,n,r){if(n===void 0)return Ke(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return Ve(e,t,n,r)}return Ke(e,t,n,r)}var dt=ke;function ft(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Dt(r);return n.dummy=t,e.setNode(i,n),i}function pt(e){let t=new dt().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function mt(e){let t=new dt({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function ht(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return i===0||Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function gt(e){let t=Ot(Ct(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function _t(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=St(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function vt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=St(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function yt(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),ft(e,`border`,i,t)}function bt(e,t=xt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var xt=65535;function St(e,t){return t.length>xt?e(...bt(t).map(t=>e(...t))):e(...t)}function Ct(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return St(Math.max,t)}function wt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Tt(e,t){return t()}var Et=0;function Dt(e){return e+(``+ ++Et)}function Ot(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function kt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function At(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function jt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Mt=`\0`;function Nt(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var Pt=class{constructor(){Te(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Ft(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Ft(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,It)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Ft(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function It(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Lt=Pt,Rt=()=>1;function zt(e,t){if(e.nodeCount()<=1)return[];let n=Ht(e,t||Rt);return Bt(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function Bt(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Vt(e,t,n,o);for(;o=i.dequeue();)Vt(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(Vt(e,t,n,o,!0)||[]);break}}}return r}function Vt(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,Ut(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,Ut(t,n,o)}),e.removeNode(r.v),o}function Ht(e,t){let n=new dt,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=Wt(i+r+3).map(()=>new Lt),o=r+1;return n.nodes().forEach(e=>{Ut(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function Ut(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Wt(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function Gt(e,t){(e.graph().acyclicer===`greedy`?zt(e,n(e)):Kt(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Dt(`rev`))});function n(e){return t=>e.edge(t).weight}}function Kt(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&Jt(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function qt(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Jt(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function Yt(e){e.graph().dummyChains=[],e.edges().forEach(t=>Xt(e,t))}function Xt(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=ft(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Zt(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Qt(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=St(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function $t(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var en=tn;function tn(e){let t=new dt({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;nn(t,e)<i&&(a=rn(t,e),a);)o=t.hasNode(a.v)?$t(e,a):-$t(e,a),an(t,e,o);return t}function nn(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!$t(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function rn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=$t(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function an(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:on,postorder:sn}=ze,cn=ln;ln.initLowLimValues=pn,ln.initCutValues=un,ln.calcCutValue=fn,ln.leaveEdge=hn,ln.enterEdge=gn,ln.exchangeEdges=_n;function ln(e){e=pt(e),Qt(e);let t=en(e);pn(t),un(t,e);let n,r;for(;n=hn(t);)r=gn(t,e,n),_n(t,e,n,r)}function un(e,t){let n=sn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>dn(e,t,n))}function dn(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=fn(e,t,n)}function fn(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,yn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function pn(e,t){arguments.length<2&&(t=e.nodes()[0]),mn(e,{},1,t)}function mn(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=mn(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function hn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function gn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===bn(e,e.node(t.v),s)&&c!==bn(e,e.node(t.w),s)).reduce((e,n)=>$t(t,n)<$t(t,e)?n:e)}function _n(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),pn(e),un(e,t),vn(e,t)}function vn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=on(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function yn(e,t,n){return e.hasEdge(t,n)}function bn(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var xn=Sn;function Sn(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Tn(e);break;case`tight-tree`:wn(e);break;case`longest-path`:Cn(e);break;case`none`:break;default:Tn(e)}}var Cn=Qt;function wn(e){Qt(e),en(e)}function Tn(e){cn(e)}var En=Dn;function Dn(e){let t=kn(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=On(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function On(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function kn(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Mt).forEach(r),t}function An(e){let t=ft(e,`root`,{},`_root`),n=Mn(e),r=Object.values(n),i=St(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Nn(e)+1;e.children(Mt).forEach(r=>{jn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function jn(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=yt(e,`_bt`),l=yt(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{jn(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Mn(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Mt).forEach(e=>n(e,1)),t}function Nn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Pn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Fn=In;function In(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)Ln(e,`borderLeft`,`_bl`,n,i,t),Ln(e,`borderRight`,`_br`,n,i,t)}}e.children(Mt).forEach(t)}function Ln(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=ft(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Rn(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Bn(e)}function zn(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&Hn(e),(t===`lr`||t===`rl`)&&(Wn(e),Bn(e))}function Bn(e){e.nodes().forEach(t=>Vn(e.node(t))),e.edges().forEach(t=>Vn(e.edge(t)))}function Vn(e){let t=e.width;e.width=e.height,e.height=t}function Hn(e){e.nodes().forEach(t=>Un(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Un),Object.hasOwn(r,`y`)&&Un(r)})}function Un(e){e.y=-e.y}function Wn(e){e.nodes().forEach(t=>Gn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Gn),Object.hasOwn(r,`x`)&&Gn(r)})}function Gn(e){let t=e.x;e.x=e.y,e.y=t}function Kn(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Ot(St(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return Nt(t,e.node(n),e.node(r))}return a}function qn(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Jn(e,t[r-1],t[r]);return n}function Jn(e,t,n){let r=jt(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function Yn(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Xn(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Zn(Object.values(n).filter(e=>!e.indegree))}function Zn(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Qn(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>kt(e,[`vs`,`i`,`barycenter`,`weight`]))}function Qn(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function $n(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=wt(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(tr(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=er(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=er(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function er(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function tr(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=Nt(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function nr(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=Yn(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=nr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&ir(t,r)}});let h=Xn(m,n);rr(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]||(g[r]=h[n],h.splice(n,1),n--)}else _=!0}let v=$n(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function rr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function ir(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function ar(e,t,n,r){r||=e.nodes();let i=or(e),a=new dt({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function or(e){let t;for(;e.hasNode(t=Dt(`_root`)););return t}function sr(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function cr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,cr);return}let r=Ct(e),i=lr(e,Ot(1,r+1),`inEdges`),a=lr(e,Ot(r-1,-1,-1),`outEdges`),o=Kn(e,n);if(dr(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){ur(t%2?i:a,t%4>=2,l,n),o=gt(e);let u=qn(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}dr(e,c)}function lr(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return ar(e,t,n,r.get(t)||[])})}function ur(e,t,n,r){let i=!0,a=new dt;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=nr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),sr(e,a,s.vs)})}function dr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function fr(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=mr(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&hr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function pr(e,t){let n={};function r(t){return e.node(t)?.dummy===`border`}if(!e.nodes().some(r))return n;function i(t,r,i,a,o){Ot(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&hr(n,t,i)})}})}function a(t,n){let a=-1,o=-1,s=0;return n.forEach((c,l)=>{if(r(c)){let t=e.predecessors(c);if(t&&t.length){let r=t[0];if(r===void 0)return;o=e.node(r).order,i(n,s,l,a,o),s=l,a=o}}i(n,s,n.length,o,t.length)}),n}return t.length&&t.reduce(a),n}function mr(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function hr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function gr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function _r(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Er(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Er(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!gr(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function vr(e,t,n,r,i=!1){let a={},o=yr(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function yr(e,t,n,r){let i=new dt,a=e.graph(),o=wr(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function br(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Tr(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function xr(e,t){let n=Object.values(t),r=St(Math.min,n),i=St(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-St(Math.min,c);a!==`l`&&(l=i-St(Math.max,c)),l&&(e[o]=At(s,e=>e+l))})})}function Sr(e,t=void 0){let n=e.ul;return n?At(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function Cr(e,t){let n=gt(e),r=Object.assign(fr(e,n),pr(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=_r(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=vr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=At(c,e=>-e)),i[o+n]=c})}),xr(i,br(e,i)),Sr(i,e.graph().align)}function wr(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Tr(e,t){return e.node(t).width}function Er(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function Dr(e,t){e=mt(e),Or(e),Object.entries(Cr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Or(e){let t=gt(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var kr=new WeakMap;function Ar(e,t={}){return Mr(e,Tt,t),e}function jr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Mr(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new dt({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=jr(e,t.v,r),i=jr(e,t.w,r);if(n===t.v&&i===t.w)o.setEdge(t,{...e.edge(t)});else if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),Mr(o,t,n);let l=Wr(o);Pr(l,t,n,null),Fr(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),isFinite(u)&&isFinite(d)&&isFinite(f)&&isFinite(p)||(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=Wr(e),g=Pr(h,t,n,kr.get(e)??null);kr.set(e,g),Fr(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),Nr(e,n,s-l,c-u),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),Nr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function Nr(e,t,n,r){t.edges().forEach(i=>{if(!e.hasEdge(i))return;let a=t.edge(i),o=e.edge(i);o.points=a.points.map(e=>({x:e.x+n,y:e.y+r})),Object.hasOwn(a,`x`)&&(o.x=a.x+n,o.y=a.y+r)})}function Pr(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>Gr(e)),t(` removeSelfEdges`,()=>ei(e)),t(` acyclic`,()=>Gt(e,s)),t(` nestingGraph.run`,()=>An(e)),t(` rank`,()=>xn(mt(e))),t(` injectEdgeLabelProxies`,()=>Kr(e)),t(` removeEmptyRanks`,()=>vt(e)),t(` nestingGraph.cleanup`,()=>Pn(e)),t(` normalizeRanks`,()=>_t(e)),t(` assignRankMinMax`,()=>qr(e)),t(` removeEdgeLabelProxies`,()=>Jr(e)),t(` normalize.run`,()=>Yt(e)),t(` parentDummyChains`,()=>En(e)),t(` addBorderSegments`,()=>Fn(e)),t(` order`,()=>cr(e,n,c)),t(` insertSelfEdges`,()=>ti(e)),t(` adjustCoordinateSystem`,()=>Rn(e)),t(` position`,()=>Dr(e,n.corePath)),t(` positionSelfEdges`,()=>ni(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>$r(e)),t(` normalize.undo`,()=>Zt(e)),t(` fixupEdgeLabelCoords`,()=>Zr(e)),t(` undoCoordinateSystem`,()=>zn(e)),t(` translateGraph`,()=>Yr(e)),t(` assignNodeIntersects`,()=>Xr(e)),t(` reversePoints`,()=>Qr(e)),t(` acyclic.undo`,()=>qt(e)),{graph:e,rawNodes:l}}function Fr(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Ir=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Lr={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Rr=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],zr=[`width`,`height`,`rank`],Br={width:0,height:0},Vr=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Hr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Ur=[`labelpos`];function Wr(e){let t=new dt({multigraph:!0,compound:!0}),n=ii(e.graph());return t.setGraph(Object.assign({},Lr,ri(n,Ir),kt(n,Rr))),e.nodes().forEach(n=>{let r=ri(ii(e.node(n)),zr);Object.keys(Br).forEach(e=>{r[e]===void 0&&(r[e]=Br[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=ii(e.edge(n));t.setEdge(n,Object.assign({},Hr,ri(r,Vr),kt(r,Ur)))}),t}function Gr(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Kr(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);ft(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function qr(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Jr(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Yr(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function Xr(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(ht(r,a)),n.points.push(ht(i,o))})}function Zr(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function Qr(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function $r(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function ei(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function ti(e){gt(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{ft(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),Array.isArray(t.label.points)&&t.label.points.length===7||(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function ni(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function ri(e,t){return At(kt(e,t),Number)}function ii(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var ai=7,oi=16,si=1.5,ci=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function li(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&ci.has(r)?2:1;return Math.ceil(n*ai*(t===`title`?si:1))}var ui=12,di=e=>Math.round(e*10)/10,fi=e=>Math.round(e*100)/100,pi=(e,t)=>[fi((e[0]+t[0])/2),fi((e[1]+t[1])/2)],mi=([e,t])=>`${e} ${t}`;function hi(e){let t=e.length-1;if(t===1)return`M${mi(e[0])} L${mi(e[1])}`;let n=[`M${mi(e[0])}`,`L${mi(pi(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${mi(e[r])} ${mi(pi(e[r],e[r+1]))}`);return n.push(`L${mi(e[t])}`),n.join(` `)}var gi=16;function _i(e,t,n){return Array.from({length:gi},(r,i)=>{let a=(i+1)/gi,o=1-a;return[o*o*e[0]+2*o*a*t[0]+a*a*n[0],o*o*e[1]+2*o*a*t[1]+a*a*n[1]]})}var vi=e=>e.slice(1).map((t,n)=>[e[n],t]);function yi(e,t,n){let r=li(e,`label`);return{text:e,x:di(t[0]-r/2),y:di(t[1]-oi/2),width:r,height:oi,route:n}}function bi(e){let t=e.slice(1).map((t,n)=>Math.hypot(t[0]-e[n][0],t[1]-e[n][1])),n=t.reduce((e,t)=>e+t,0)/2;for(let[r,i]of t.entries()){if(n<=i&&i>0){let[t,a]=[e[r],e[r+1]];return[di(t[0]+(a[0]-t[0])*n/i),di(t[1]+(a[1]-t[1])*n/i)]}n-=i}return e[e.length-1]}function xi(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t[0]-n,a=t[1]-r;if(i===0&&a===0)return[di(n),di(e.y)];let o=Math.min(i===0?1/0:e.width/2/Math.abs(i),a===0?1/0:e.height/2/Math.abs(a));return[di(n+i*o),di(r+a*o)]}function Si(e,t,n,r){let i=t[0]-e[0],a=t[1]-e[1],o=0,s=1,c=[[-i,e[0]-(n.x-r)],[i,n.x+n.width+r-e[0]],[-a,e[1]-(n.y-r)],[a,n.y+n.height+r-e[1]]];for(let[e,t]of c){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0?o=Math.max(o,n):s=Math.min(s,n),o>s)return null}return[o,s]}function Ci(e,t,n){let r=Si(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var wi=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),Ti=e=>[[e.x-ui,e.y-ui],[e.x+e.width+ui,e.y-ui],[e.x-ui,e.y+e.height+ui],[e.x+e.width+ui,e.y+e.height+ui]],Ei=(e,t)=>e[0]>t.x+.5&&e[0]<t.x+t.width-.5&&e[1]>t.y+.5&&e[1]<t.y+t.height-.5;function Di(e,t,n){let r=[e,t,...n.flatMap(Ti).filter(e=>!n.some(t=>Ei(e,t)))],i=r.map(()=>1/0),a=r.map(()=>-1),o=r.map(()=>!1);for(i[0]=0;;){let e=-1;for(let[t,n]of i.entries())!o[t]&&n<1/0&&(e<0||n<i[e])&&(e=t);if(e<0)return null;if(e===1)break;o[e]=!0;for(let[t,s]of r.entries()){let c=i[e]+wi(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>Ci(r[e],s,t))&&(i[t]=c,a[t]=e)}}let s=[];for(let e=1;e>=0;e=a[e])s.unshift(r[e]);return s}function Oi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>Ci(n,i,e))?[n]:(Di(n,i,t)??[n,i]).slice(0,-1)})}function ki(e){let t=[];for(let n of e){let e=t.findIndex(e=>e[0]===n[0]&&e[1]===n[1]);e>=0&&(t.length=e),t.push(n)}return t}function Ai(e,t,n){let r=Math.min(n/Math.max(wi(e,t),.01),.25);return[di(e[0]+(t[0]-e[0])*r),di(e[1]+(t[1]-e[1])*r)]}function ji(e,t){let n=[...e];for(let e=0,r=8;e<6;e++,r/=2){let e=e=>e>0&&e<n.length-1&&vi([pi(n[e-1],n[e]),..._i(pi(n[e-1],n[e]),n[e],pi(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>Ci(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Ai(t,n[i-1],r),t,Ai(t,n[i+1],r)]:[t])}return n}function Mi(e,t){return ki(ji(Oi(e,t),t))}function Ni(e){let t=[...e.boxes,...e.labels,...e.routes.flatMap(e=>e.points.map(([e,t])=>({x:e,y:t,width:0,height:0})))];if(t.length===0)return{x:0,y:0,width:0,height:0};let n=Math.min(...t.map(e=>e.x)),r=Math.min(...t.map(e=>e.y));return{x:n,y:r,width:Math.max(...t.map(e=>e.x+e.width))-n,height:Math.max(...t.map(e=>e.y+e.height))-r}}function Pi(e,t,n,r=[]){let i=Ni({boxes:e,routes:t,labels:r});return{width:Math.max(0,i.x+i.width)+n,height:Math.max(0,i.y+i.height)+n}}function Fi(e,t=!0){let n=new Ee.Graph({multigraph:!0});n.setGraph({rankdir:`TB`,nodesep:e.nodesep,ranksep:e.ranksep,marginx:e.margin,marginy:e.margin});for(let t of e.nodes)n.setNode(t.id,{width:t.width,height:t.height});for(let t of e.edges)n.setEdge(t.source,t.target,{weight:t.weight},t.id);Ar(n);let r=e.nodes.map(e=>{let{x:t,y:r}=n.node(e.id);return{id:e.id,parent:null,x:di(t-e.width/2),y:di(r-e.height/2),width:e.width,height:e.height,kind:e.kind}}),i=e.edges.map(({weight:e,...i})=>{let a=n.edge(i.source,i.target,i.id).points.map(({x:e,y:t})=>[di(e),di(t)]),o=r.filter(e=>e.id!==i.source&&e.id!==i.target);return{...i,points:t?Mi(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Pi(r,i,e.margin)}}var Ii=`text{font-family:system-ui,sans-serif;font-size:12px;fill:#1F2328}.box{fill:#F2F4F7;stroke:#D3D9E0}.frame{fill:#FFFFFF;stroke:#D3D9E0}.external{fill:#FFFFFF;stroke:#D3D9E0;stroke-dasharray:6 4}.member{fill:#FFFFFF;stroke:#D3D9E0}.writer{fill:#E4F2EA;stroke:#1F8A5B}.reader{fill:#FFFFFF;stroke:#8C96A3;stroke-dasharray:4 3}.point{fill:#E8EFFB;stroke:#2D5BB8}.title{font-size:13px;font-weight:600}.detail{fill:#5B6573}.route{fill:none;stroke:#5B6573}.route.dashed{stroke-dasharray:6 4}.label-box{fill:#FFFFFF}.label{font-family:ui-monospace,monospace;font-size:11px;fill:#1F2328}`,Li={band:`.band{fill:none;stroke:none}`,selected:`.selected{stroke:#F08A3C;stroke-width:2}`,lifeline:`.lifeline{fill:#8C96A3;stroke:none}`,fragment:`.fragment{stroke-dasharray:5 4}`,terminal:`.terminal{fill:#FFFFFF}`,success:`.fragment.success{fill:#EDF7F0;stroke:#2C6A3D}.terminal.success{stroke:#2C6A3D}`,error:`.fragment.error{fill:#FBEFEF;stroke:#B42318}.terminal.error{stroke:#B42318}`},Ri=e=>e.replace(/[&<>"]/gu,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]);function zi(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${Ri(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${Ri(t)}</text>`).join(``)}function Bi(e,t){let{width:n,height:r}=e.extent,i=[];for(let[n,r]of e.boxes.entries())i.push(`<clipPath id="clip-${n}"><rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/></clipPath>`,`<rect class="${r.kind}" x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/>`,`<g clip-path="url(#clip-${n})">${zi(r,t(r))}</g>`);for(let t of e.routes){let e=`${t.arrows.start?` marker-start="url(#arrow)"`:``}${t.arrows.end?` marker-end="url(#arrow)"`:``}`;i.push(`<path class="route${t.dashed?` dashed`:``}" stroke-width="${t.width}" d="${hi(t.points)}"${e}/>`)}for(let t of e.labels)i.push(`<rect class="label-box" x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="3"/>`,`<text class="label" x="${t.x+t.width/2}" y="${t.y+12}" text-anchor="middle">${Ri(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries(Li).filter(([e])=>a.has(e)).map(([,e])=>e).join(``);return[`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">`,`<style>${Ii}${o}</style>`,`<defs><marker id="arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0 0L8 4L0 8z" fill="#5B6573"/></marker></defs>`,`<rect width="${n}" height="${r}" fill="#FFFFFF"/>`,...i,`</svg>`].join(`
2
- `)}var Vi=12,Hi=12,Ui=24,Wi=64,Gi=24,Ki=`removed`,qi=new Set([`spawns`,`runs-in`,`deployed-on`,`mounts`,`reads`,`writes`,`publishes`,`subscribes`]);function Ji(e,t){let n=Math.ceil(Math.sqrt(e.length)),r=Math.ceil(e.length/n),i=Array.from({length:n},(t,r)=>Math.max(0,...e.filter((e,t)=>t%n===r).map(e=>e.width))),a=Array.from({length:r},(t,r)=>Math.max(0,...e.slice(r*n,(r+1)*n).map(e=>e.height))),o=(e,n)=>e.slice(0,n).reduce((e,n)=>e+n+t,0);return{cells:e.map((e,t)=>({x:o(i,t%n),y:o(a,Math.floor(t/n))})),width:i.reduce((e,t)=>e+t,0)+(n-1)*t,height:a.reduce((e,t)=>e+t,0)+(r-1)*t}}function Yi(e){let t=new Map;for(let n of e.nodes)n.parent!==null&&t.set(n.parent,[...t.get(n.parent)??[],n]);let n=new Map,r=new Map,i=e=>{let a=r.get(e);if(a)return a;let o=t.get(e),s={width:160,height:48};if(o){let e=Ji(o.map(e=>i(e.id)),Hi);o.forEach((t,r)=>n.set(t.id,{x:Vi+e.cells[r].x,y:36+e.cells[r].y})),s={width:Math.max(160,e.width)+24,height:36+e.height+Vi}}return r.set(e,s),s},a=new Map(e.nodes.map(e=>[e.id,e.parent])),o=e=>{let t=e;for(;a.get(t);)t=a.get(t);return t},s=new Map;for(let t of e.relations){let[e,n]=[o(t.source),o(t.target)];if(e===n)continue;let r=`${t.kind}:${e}->${n}`;s.has(r)||s.set(r,{source:e,target:n,kind:t.kind,relations:[]}),s.get(r).relations.push(t.id)}let c=e.nodes.filter(e=>e.parent===null),l=new Set([...s.values()].flatMap(e=>[e.source,e.target])),u=e=>t.has(e)?`frame`:`box`,d=Fi({nodes:c.filter(e=>l.has(e.id)).map(e=>({id:e.id,kind:u(e.id),...i(e.id)})),edges:[...s].map(([e,t])=>({id:e,source:t.source,target:t.target,kind:t.kind,arrows:{start:!1,end:!0},dashed:t.kind===Ki,width:t.kind===`relation`?1.5:2,weight:t.relations.length})),nodesep:Ui,ranksep:Wi,margin:Gi}),f=c.filter(e=>!l.has(e.id)),p=d.boxes.length===0?Gi:Math.max(...d.boxes.map(e=>e.y+e.height))+Wi,m=f.map(e=>i(e.id)),h=Ji(m,Ui).cells.map((e,t)=>({id:f[t].id,parent:null,x:Gi+e.x,y:p+e.y,...m[t],kind:u(f[t].id)})),g=new Map([...d.boxes,...h].map(e=>[e.id,e])),_=[],v=(e,r)=>{let a=n.get(e.id),o=r===null?g.get(e.id):{id:e.id,parent:r.id,x:r.x+a.x,y:r.y+a.y,...i(e.id),kind:u(e.id)};_.push(o);for(let n of t.get(e.id)??[])v(n,o)};for(let e of c)v(e,null);let y=d.routes;return{scene:{boxes:_,routes:y,labels:[],extent:Pi(_,y,Gi)},relations:new Map([...s].map(([e,t])=>[e,t.relations]))}}var W=t();function Xi(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Xi(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Zi={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Qi=[[-1/0,-1/0],[1/0,1/0]],$i=[`Enter`,` `,`Escape`],ea={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},ta;(function(e){e.Strict=`strict`,e.Loose=`loose`})(ta||={});var na;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(na||={});var ra;(function(e){e.Partial=`partial`,e.Full=`full`})(ra||={});var ia={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},aa;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(aa||={});var oa;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(oa||={});var G;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(G||={});var sa={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},ca=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,la=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),ua=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),da=(e,t=[0,0])=>{let{width:n,height:r}=Ga(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},fa=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):ua(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ta(e,ka(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Da(r):{x:0,y:0,width:0,height:0}},pa=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Ta(n,ka(e)),r=!0)}),r?Da(n):{x:0,y:0,width:0,height:0}},ma=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=ja(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},ha=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ga(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=Ga(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function _a({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Ha(pa(ga(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function va({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,Zi.error005());else{let{width:e,height:t}=Ga(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Wa(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Wa(d)?xa(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Zi.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function ya({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=ha(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var ba=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),xa=(e={x:0,y:0},t,n)=>({x:ba(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ba(e.y,t[0][1],t[1][1]-(n?.height??0))});function Sa(e,t,n){let{width:r,height:i}=Ga(n),{x:a,y:o}=n.internals.positionAbsolute;return xa(e,[[a,o],[a+r,o+i]],t)}var Ca=(e,t,n)=>e<t?ba(Math.abs(e-t),1,t)/t:e>n?-ba(Math.abs(e-n),1,t)/t:0,wa=(e,t,n=15,r=40)=>[Ca(e.x,r,t.width-r)*n,Ca(e.y,r,t.height-r)*n],Ta=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ea=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Da=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Oa=(e,t=[0,0])=>{let{x:n,y:r}=ua(e)?e.internals.positionAbsolute:da(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ka=(e,t=[0,0])=>{let{x:n,y:r}=ua(e)?e.internals.positionAbsolute:da(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Aa=(e,t)=>Da(Ta(Ea(e),Ea(t))),ja=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Ma=(e,t)=>ja(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Na=e=>Pa(e.width)&&Pa(e.height)&&Pa(e.x)&&Pa(e.y),Pa=e=>!isNaN(e)&&isFinite(e),Fa=(e,t)=>(e,t)=>{},Ia=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),La=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Ia(s,o):s},Ra=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function za(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ba(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=za(e,n),i=za(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=za(e.top??e.y??0,n),i=za(e.bottom??e.y??0,n),a=za(e.left??e.x??0,t),o=za(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Va(e,t,n,r,i,a){let{x:o,y:s}=Ra(e,[t,n,r]),{x:c,y:l}=Ra({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Ha=(e,t,n,r,i,a)=>{let o=Ba(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=ba(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Va(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Ua=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Wa(e){return e!=null&&e!==`parent`}function Ga(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ka(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function qa(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Ja(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ya(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Xa(e){return{...ea,...e||{}}}function Za(e){return e===null?null:e?`valid`:`invalid`}function Qa(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=io(e),s=La({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Ia(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var $a=e=>({width:e.offsetWidth,height:e.offsetHeight}),eo=e=>e?.getRootNode?.()||window?.document,to=[`INPUT`,`SELECT`,`TEXTAREA`];function no(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?to.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var ro=e=>`clientX`in e,io=(e,t)=>{let n=ro(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},ao=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...$a(t)}})};function oo({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function so(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function co({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case G.Left:return[t-so(t-r,a),n];case G.Right:return[t+so(r-t,a),n];case G.Top:return[t,n-so(n-i,a)];case G.Bottom:return[t,n+so(i-n,a)]}}function lo({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top,curvature:o=.25}){let[s,c]=co({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=co({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=oo({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function uo({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function fo({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function po({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ta(ka(e),ka(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Ma({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Da(a))>0}var mo=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ho=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),go=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,Zi.error006()),t;let r=n.getEdgeId||mo,i;return i=ca(e)?{...e}:{...e,id:r(e)},ho(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function _o({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=uo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var vo={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},yo=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},bo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),xo=(e,t,n)=>e.x===t.x&&t.x===n.x&&(t.y-e.y)*(n.y-t.y)>=0||e.y===t.y&&t.y===n.y&&(t.x-e.x)*(n.x-t.x)>=0;function So({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:r=G.Top,center:i,offset:a,stepPosition:o}){let s=vo[t],c=vo[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=yo({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=uo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y},C=[];for(let t of[e,x,...m,S,n]){let[e,n]=C.slice(-2);n&&xo(e,n,t)&&C.pop(),C.push(t)}return[C,h,g,y,b]}function Co(e,t,n,r){let i=Math.min(bo(e,t)/2,bo(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function wo({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=So({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=Co(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function To(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Eo(e){let{sourceNode:t,targetNode:n}=e;if(!To(t)||!To(n))return null;let r=t.internals.handleBounds||Do(t.handles),i=n.internals.handleBounds||Do(n.handles),a=ko(r?.source??[],e.sourceHandle),o=ko(e.connectionMode===ta.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Zi.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||G.Bottom,c=o?.position||G.Top,l=Oo(t,a,s),u=Oo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Do(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function Oo(e,t,n=G.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??Ga(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case G.Top:return{x:i+o/2,y:a};case G.Right:return{x:i+o,y:a+s/2};case G.Bottom:return{x:i+o/2,y:a+s};case G.Left:return{x:i,y:a+s/2}}}function ko(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Ao(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function jo(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Ao(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Mo=1e3,No=10,Po={nodeOrigin:[0,0],nodeExtent:Qi,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Fo={...Po,checkEquality:!0};function Io(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Lo(e,t,n){let r=Io(Po,n);for(let n of e.values())if(n.parentId)Ho(n,e,t,r);else{let e=xa(da(n,r.nodeOrigin),Wa(n.extent)?n.extent:r.nodeExtent,Ga(n));n.internals.positionAbsolute=e}}function Ro(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function zo(e){return e===`manual`}function Bo(e,t,n,r={}){let i=Io(Fo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!zo(i.zIndexMode)?Mo:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=xa(da(u,i.nodeOrigin),Wa(u.extent)?u.extent:i.nodeExtent,Ga(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Ro(u,e),z:Uo(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}e.measured!==void 0&&e.measured.width!==void 0&&e.measured.height!==void 0||e.hidden||(c=!1),u.parentId&&Ho(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Vo(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ho(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Io(Po,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Vo(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*No),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Wo(e,u,o,s,a&&!zo(c)?Mo:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Uo(e,t,n){let r=Pa(e.zIndex)?e.zIndex:0;return zo(n)?r:r+(e.selected?t:0)}function Wo(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Ga(e),l=da(e,n),u=Wa(e.extent)?xa(l,e.extent,c):l,d=xa({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Sa(d,c,t));let f=Uo(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Go(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Aa(a.get(n.parentId)?.expandedRect??Oa(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Ga(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Ko(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=$a(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Wa(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Sa(h,s,n))}else m&&(h=xa(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:ao(`source`,r.nodeElement,p,d,e.id),target:ao(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&Ho(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:Oa(g,i)}))}}if(f.length>0){let e=Go(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function qo({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function Jo(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Yo(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Jo(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Jo(`target`,s,c,e,i,o),t.set(r.id,r)}}function Xo(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Xo(n,t):!1}function Zo(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Qo(e,t,n,r,i){let a=new Map;for(let[o,s]of e)if((i?s.id===r:s.selected||s.id===r)&&(i||!s.parentId||!Xo(s,e))&&(s.draggable||t&&s.draggable===void 0)){let t=e.get(o);t&&a.set(o,{id:o,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return a}function $o({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function es({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Ia(a,t);return{x:o.x-a.x,y:o.y-a.y}}function ts({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=E(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Ea(pa(s)):null,x=v&&l?es({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Ia(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=va({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=$o({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=wa(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0;let v=!!b&&!o&&!i.get(b)?.selected;m&&y||o||!b||i.get(b)?.selected||_(),y&&m&&b&&e?.(b);let x=Qa(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=x,s=Qo(i,c,x,b,v),s.size>0&&(n||h||!b&&g)){let[e,t]=$o({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=ee().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Qa(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=io(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Qa(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=io(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=io(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=$o({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!Zo(t,`.${g}`,v))&&(!_||Zo(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function ns(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Ma(i,Oa(e))>0&&r.push(e);return r}var rs=250;function is(e,t,n,r){let i=[],a=1/0,o=ns(e,n,t+rs);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Oo(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function as(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Oo(o,c,c.position,!0)}:c}function os(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function ss(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var cs=()=>!0;function ls(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=cs,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=eo(e.target),E=0,D,{x:O,y:k}=io(e),A=os(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=as(i,A,r,c,t);if(!N)return;let P=io(e,j),F=!1,ee=null,I=!1,te=null;function L(){if(!u||!j)return;let[e,t]=wa(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(L)}let R={...N,nodeId:i,type:A,position:N.position},z=c.get(i),B={inProgress:!0,isValid:null,from:Oo(z,R,G.Left,!0),fromHandle:R,fromPosition:R.position,fromNode:z,to:P,toHandle:null,toPosition:sa[R.position],toNode:null,pointer:P};function ne(){M=!0,y(B),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ne();function re(e){if(!M){let{x:t,y:n}=io(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ne()}if(!x()||!R){ie(e);return}let a=b();P=io(e,j),D=is(La(P,a,!1,[1,1]),n,c,R),F||=(L(),!0);let s=us(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});te=s.handleDomNode,ee=s.connection,I=ss(!!D,s.isValid);let u=c.get(i),f=u?Oo(u,R,G.Left,!0):B.from,p={...B,from:f,isValid:I,to:s.toHandle&&I?Ra({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:I&&s.toHandle?s.toHandle.position:sa[R.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),B=p}function ie(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||te)&&ee&&I&&h?.(ee);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,I=!1,ee=null,te=null,T.removeEventListener(`mousemove`,re),T.removeEventListener(`mouseup`,ie),T.removeEventListener(`touchmove`,re),T.removeEventListener(`touchend`,ie)}}T.addEventListener(`mousemove`,re),T.addEventListener(`mouseup`,ie),T.addEventListener(`touchmove`,re),T.addEventListener(`touchend`,ie)}function us(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=cs,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=io(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=os(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===ta.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=as(t,e,a,u,n,!0)}return _}var ds={onPointerDown:ls,isValid:us};function fs({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=E(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Ua()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=w().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:g}}var ps=e=>({x:e.x,y:e.y,zoom:e.k}),ms=({x:e,y:t,zoom:n})=>S.translate(e,t).scale(n),hs=(e,t)=>e.target.closest(`.${t}`),gs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_s=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vs=(e,t=0,n=_s,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},ys=e=>{let t=e.ctrlKey&&Ua()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function bs({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(hs(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=g(u),t=d*2**ys(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===na.Vertical?0:u.deltaX*f,m=i===na.Horizontal?0:u.deltaY*f;!Ua()&&u.shiftKey&&i!==na.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=ps(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function xs({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=hs(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ss({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=ps(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Cs({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&gs(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,ps(a.transform))}}function ws({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&gs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=ps(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Ts({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(hs(f,`${u}-flow__node`)||hs(f,`${u}-flow__edge`)||hs(f,`${u}-flow__selection`)||hs(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||hs(f,c)&&h||hs(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function Es({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]],f=typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t?.contentRect&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null;f?.observe(e);let p=w().extent(()=>d).scaleExtent([t,n]).translateExtent(r),m=E(e).call(p);b({x:i.x,y:i.y,zoom:ba(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let h=m.on(`wheel.zoom`),g=m.on(`dblclick.zoom`);p.wheelDelta(ys);async function _(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?k:x).transform(vs(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function v({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:f,preventScrolling:_,zoomOnPinch:v,zoomOnScroll:y,zoomOnDoubleClick:b,panActivationKeyPressed:x=!1,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&p.on(`zoom`,null);let O=i&&!S&&!r;p.clickDistance(D?1/0:!Pa(E)||E<0?0:E);let k=O?bs({zoomPanValues:l,noWheelClassName:e,d3Selection:m,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):xs({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:h});m.on(`wheel.zoom`,k,{passive:!1});let A=Ss({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,A);let j=Cs({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});p.on(`zoom`,j);let M=ws({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,M);let N=Ts({panActivationKeyPressed:x,zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:y,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:v,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});p.filter(N),b?m.on(`dblclick.zoom`,g):m.on(`dblclick.zoom`,null)}function y(){p.on(`zoom`,null),f?.disconnect()}async function b(e,t,n){let r=ms(e),i=p?.constrain()(r,t,n);return i&&await _(i),i}async function S(e,t){let n=ms(e);return await _(n,t),n}function T(e){if(m){let t=ms(e),n=m.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&p?.transform(m,t,null,{sync:!0})}}function D(){let e=m?C(m.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function O(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?k:x).scaleTo(vs(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function A(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?k:x).scaleBy(vs(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function j(e){p?.scaleExtent(e)}function M(e){p?.translateExtent(e)}function N(e){let t=!Pa(e)||e<0?0:e;p?.clickDistance(t)}return{update:v,destroy:y,setViewport:S,setViewportConstrained:b,getViewport:D,scaleTo:O,scaleBy:A,setScaleExtent:j,setTranslateExtent:M,syncViewport:T,setClickDistance:N}}var Ds;(function(e){e.Line=`line`,e.Handle=`handle`})(Ds||={});function Os({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function ks(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function As(e,t){return Math.max(0,t-e)}function js(e,t){return Math.max(0,e-t)}function Ms(e,t,n){return Math.max(0,t-e,e-n)}function Ns(e,t){return e?!t:t}function Ps(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Ms(E,h,g),j=Ms(D,_,v);if(o){let e=0,t=0;c&&w<0?e=As(y+w+O,o[0][0]):!c&&w>0&&(e=js(y+E+O,o[1][0])),l&&T<0?t=As(b+T+k,o[0][1]):!l&&T>0&&(t=js(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=js(y+w,s[0][0]):!c&&w<0&&(e=As(y+E,s[1][0])),l&&T>0?t=js(b+T,s[0][1]):!l&&T<0&&(t=As(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Ms(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?js(b+k+E/C,o[1][1])*C:As(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?As(b+E/C,s[1][1])*C:js(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Ms(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?js(y+D*C+O,o[1][0])/C:As(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?As(y+D*C,s[1][0])/C:js(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Ns(c,l)?-w:w)/C:w=(Ns(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Fs={width:0,height:0,x:0,y:0},Is={...Fs,pointerX:0,pointerY:0,aspectRatio:1};function Ls(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Rs({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=E(e),o={controlDirection:ks(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Fs},h={...Is};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:ks(e)};let g,_=null,v=[],y,b,x,S=ee().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Qa(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Wa(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Ls(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Qa(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=Ps(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=Os({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),ee={...m,direction:F};p?.(e,ee)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,ee),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var zs=e(h(),1),Bs=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Vs=e=>e?Bs(e):Bs,{useDebugValue:Hs}=I.default,{useSyncExternalStoreWithSelector:Us}=zs.default,Ws=e=>e;function Gs(e,t=Ws,n){let r=Us(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Hs(r),r}var Ks=(e,t)=>{let n=Vs(e),r=(e,r=t)=>Gs(n,e,r);return Object.assign(r,n),r},qs=(e,t)=>e?Ks(e,t):Ks;function K(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}r();var Js=(0,I.createContext)(null),Ys=Js.Provider,Xs=Zi.error001(`react`);function q(e,t){let n=(0,I.useContext)(Js);if(n===null)throw Error(Xs);return Gs(n,e,t)}function J(){let e=(0,I.useContext)(Js);if(e===null)throw Error(Xs);return(0,I.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Zs={display:`none`},Qs={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},$s=`react-flow__node-desc`,ec=`react-flow__edge-desc`,tc=`react-flow__aria-live`,nc=e=>e.ariaLiveMessage,rc=e=>e.ariaLabelConfig;function ic({rfId:e}){let t=q(nc);return(0,W.jsx)(`div`,{id:`${tc}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Qs,children:t})}function ac({rfId:e,disableKeyboardA11y:t}){let n=q(rc);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{id:`${$s}-${e}`,style:Zs,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,W.jsx)(`div`,{id:`${ec}-${e}`,style:Zs,children:n[`edge.a11yDescription.default`]}),!t&&(0,W.jsx)(ic,{rfId:e})]})}var oc=(0,I.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,W.jsx)(`div`,{className:Xi([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});oc.displayName=`Panel`;var sc=`https://reactflow.dev?utm_source=attribution`;function cc({proOptions:e,position:t=`bottom-right`}){return(0,I.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,W.jsx)(oc,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${sc}`,children:(0,W.jsx)(`a`,{href:sc,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var lc=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},uc=e=>e.id;function dc(e,t){return K(e.selectedNodes.map(uc),t.selectedNodes.map(uc))&&K(e.selectedEdges.map(uc),t.selectedEdges.map(uc))}function fc({onSelectionChange:e}){let t=J(),{selectedNodes:n,selectedEdges:r}=q(lc,dc);return(0,I.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var pc=e=>!!e.onSelectionChangeHandlers;function mc({onSelectionChange:e}){let t=q(pc);return e||t?(0,W.jsx)(fc,{onSelectionChange:e}):null}var hc=[0,0],gc={x:0,y:0,zoom:1},_c=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],vc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),yc={translateExtent:Qi,nodeOrigin:hc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function bc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=q(vc,K),l=J();(0,I.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=yc,s()}),[]);let u=(0,I.useRef)(yc);return(0,I.useEffect)(()=>{for(let s of _c){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Xa(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},_c.map(t=>e[t])),null}function xc(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Sc(e){let[t,n]=(0,I.useState)(e===`system`?null:e);return(0,I.useEffect)(()=>{if(e!==`system`){n(e);return}let t=xc(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?xc()?.matches?`dark`:`light`:t}var Cc=typeof document<`u`?document:null;function wc(e=null,t={target:Cc,actInsideInputWithModifier:!0}){let[n,r]=(0,I.useState)(!1),i=(0,I.useRef)(!1),a=(0,I.useRef)(new Set([])),[o,s]=(0,I.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
1
+ import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{C as t,D as n,O as r,T as i,_ as a,b as o,c as s,g as c,h as l,l as u,n as d,o as f,p,v as m,y as h}from"./index-DUe-MPm9.js";import{C as g,S as _,T as v,_ as y,b,i as x,n as S,r as C,t as w,v as T,w as E,x as D,y as O}from"./src-C_gRsKqw.js";import{t as k}from"./value-CHmTzbgv.js";var A=e=>()=>e;function j(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:a,x:o,y:s,dx:c,dy:l,dispatch:u}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:o,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:u}})}j.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function M(e){return!e.ctrlKey&&!e.button}function N(){return this.parentNode}function P(e,t){return t??{x:e.x,y:e.y}}function F(){return navigator.maxTouchPoints||`ontouchstart`in this}function ee(){var e=M,t=N,n=P,r=F,i={},a=v(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,x).on(`touchmove.drag`,S,b).on(`touchend.drag touchcancel.drag`,C).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=w(this,t.call(this,n,r),n,r,`mouse`);i&&(E(n.view).on(`mousemove.drag`,m,D).on(`mouseup.drag`,h,D),y(n.view),_(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(O(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){E(e.view).on(`mousemove.drag mouseup.drag`,null),T(e.view,l),O(e),i.mouse(`end`,e)}function x(n,r){if(e.call(this,n,r))for(var i=n.changedTouches,a=t.call(this,n,r),o=i.length,s=0,c;s<o;++s)(c=w(this,a,n,r,i[s].identifier,i[s]))&&(_(n),c(`start`,n,i[s]))}function S(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(O(e),a(`drag`,e,t[r]))}function C(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(_(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=g(l||r,t),p,m,h;if((h=n.call(e,new j(`beforestart`,{sourceEvent:r,target:f,identifier:c,active:o,x:d[0],y:d[1],dx:0,dy:0,dispatch:u}),s))!=null)return p=h.x-d[0]||0,m=h.y-d[1]||0,function n(r,a,l){var _=d,v;switch(r){case`start`:i[c]=n,v=o++;break;case`end`:delete i[c],--o;case`drag`:d=g(l||a,t),v=o}u.call(r,e,new j(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:v,x:d[0]+p,y:d[1]+m,dx:d[0]-_[0],dy:d[1]-_[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:A(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:A(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:A(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:A(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var I=e(r(),1);function te(e){return e.kind===`group`}var L=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,R=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,z=e=>typeof e==`string`,B=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ne=e=>B(e)&&e>0,re=e=>typeof e==`boolean`,ie=e=>t=>z(t)&&e.test(t),V=(...e)=>t=>e.includes(t),ae=e=>t=>t===null||e(t),H=e=>t=>Array.isArray(t)&&t.every(e),U=e=>t=>{if(!t||typeof t!=`object`||Array.isArray(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},oe=ie(/^[0-9a-f]{64}$/),se=ie(R),ce=ie(L),le=e=>z(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),ue=U({model_valid:V(`valid`,`invalid`,`unknown`),generated_summary:V(`fresh`,`stale`,`unknown`),section3:V(`present`,`pending`)}),de=U({id:z,from:z,to:z,label:z,evidence:U({entrypointId:z,sourceSymbol:z,sinkId:z})}),fe=e=>U({id:z,capabilityId:ce,name:z,applicability:V(`not-applicable`),rationale:z})(e)||U({id:z,capabilityId:ce,name:z,applicability:V(`required`),participants:H(U({id:z,nodeId:z})),steps:H(de),outcomes:H(U({id:z,kind:V(`success`,`error`),label:z,steps:H(de),terminal:U({participant:z,label:z})}))})(e),pe=e=>typeof e==`string`&&e.length>0&&e!==`group`,me=U({include:H(z),exclude:H(z)}),he=e=>U({id:z,kind:pe,name:z,role:V(`center`,`child`,`caller`,`callee`)})(e)||U({id:z,kind:V(`group`),role:V(`caller`,`callee`),count:ne,members:H(U({id:z,name:z}))})(e),ge=U({schema_version:V(`repo-harness.architecture-modules.v1`),commit:se,modules:H(U({id:ce,domain:z,name:z,status:z,components:B,state:ue}))}),_e=U({schema_version:V(`repo-harness.architecture-module.v1`),commit:se,module:U({id:ce,name:z,status:z,summary:z,responsibilities:H(z),notes:H(z),source:me,verification:H(z),entrypoints:H(U({id:z,path:le,symbols:H(U({name:z,sinks:H(U({id:z,path:le,symbol:z}))}))})),components:H(U({id:z,kind:pe,name:z,summary:z,source:me}))}),graph:U({center:ce,nodes:H(he),edges:H(U({source:z,target:z,intent:z,relation_kind:z,direction:V(`directed`)}))}),flows:H(fe),section3:ae(z),linked_docs:H(U({path:le,kind:V(`contract`,`plan`),status:ae(z)})),state:ue}),ve=U({schema_version:V(`repo-harness.module-review-prompt.v1`),prompt_version:z,package_version:z,repository_id:ie(/^repo_[0-9a-f]{16}$/),capability_id:ce,commit:se,mode:V(`module`,`diff`),base:ae(se),head:ae(se),worktree_dirty_paths:H(le),dirty_content_sha256:ae(oe),model_sha256:oe,doc_sha256:ae(oe),sources:H(U({path:le,sha256:oe,bytes:B,class:V(`required`,`optional`),disposition:V(`included`,`omitted`,`chunked`)})),budget:U({input_cap_bytes:ne,used_bytes:B,incomplete:re,omitted_sections:H(z)}),shard:U({index:ne,count:ne,bytes:B}),full_prompt_sha256:oe,prompt:z,digest:oe});function ye(e){if(!ge(e))throw Error(`architecture_module_index_invalid`);return e}function be(e){if(!_e(e))throw Error(`architecture_module_detail_invalid`);let t=e,n=new Set(t.graph.nodes.map(e=>e.id));if(t.graph.center!==t.module.id||!n.has(t.graph.center)||n.size!==t.graph.nodes.length||t.graph.edges.some(e=>!n.has(e.source)||!n.has(e.target))||t.graph.nodes.some(e=>te(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function xe(e){if(!ve(e))throw Error(`architecture_review_prompt_invalid`);let t=e;if(t.shard.index>t.shard.count||(t.mode===`module`?t.base!==null||t.head!==null:t.base===null||t.head===null)||t.worktree_dirty_paths.length===0!=(t.dirty_content_sha256===null))throw Error(`architecture_review_prompt_invalid`);return t}var Se=Object.defineProperty,Ce=(e,t,n)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,we=(e,t)=>{for(var n in t)Se(e,n,{get:t[n],enumerable:!0})},Te=(e,t,n)=>Ce(e,typeof t==`symbol`?t:t+``,n),Ee={};we(Ee,{Graph:()=>dt,alg:()=>ze});var De=Object.defineProperty,Oe=(e,t)=>{for(var n in t)De(e,n,{get:t[n],enumerable:!0})},ke=class{constructor(e){this._isDirected=!0,this._isMultigraph=!1,this._isCompound=!1,this._nodes={},this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={},this._nodeCount=0,this._edgeCount=0,this._defaultNodeLabelFn=()=>{},this._defaultEdgeLabelFn=()=>{},e&&(this._isDirected=`directed`in e?e.directed:!0,this._isMultigraph=`multigraph`in e&&e.multigraph,this._isCompound=`compound`in e&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[`\0`]={})}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 this._defaultNodeLabelFn=typeof e==`function`?e:()=>e,this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){return this.nodes().filter(e=>Object.keys(this._in[e]).length===0)}sinks(){return this.nodes().filter(e=>Object.keys(this._out[e]).length===0)}setNodes(e,t){return e.forEach(e=>{t===void 0?this.setNode(e):this.setNode(e,t)}),this}setNode(e,t){return e in this._nodes?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=`\0`,this._children[e]={},this._children[`\0`][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 e in this._nodes}removeNode(e){if(e in this._nodes){let t=e=>this.removeEdge(this._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(e=>{this.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(t),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(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(t===void 0)t=`\0`;else{t+=``;for(let n=t;n!==void 0;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}parent(e){if(this._isCompound){let t=this._parent[e];if(t!==`\0`)return t}}children(e=`\0`){if(this._isCompound){let t=this._children[e];if(t)return Object.keys(t)}else{if(e===`\0`)return this.nodes();if(this.hasNode(e))return[]}return[]}predecessors(e){let t=this._preds[e];if(t)return Object.keys(t)}successors(e){let t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){let t=this.predecessors(e);if(t){let n=new Set(t),r=this.successors(e);if(r)for(let e of r)n.add(e);return Array.from(n.values())}}isLeaf(e){let t;return t=this.isDirected()?this.successors(e):this.neighbors(e),(t?.length??0)===0}filterNodes(e){let t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph()),Object.entries(this._nodes).forEach(([n,r])=>{e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(e=>{t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,this.edge(e))});let n={},r=e=>{let i=this.parent(e);return!i||t.hasNode(i)?(n[e]=i,i):i in n?n[i]:r(i)};return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,r(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=typeof e==`function`?e:()=>e,this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){return e.reduce((e,n)=>(t===void 0?this.setEdge(e,n):this.setEdge(e,n,t),n)),this}setEdge(e,t,n,r){let i,a,o,s,c=!1;typeof e==`object`&&e&&`v`in e?(i=e.v,a=e.w,o=e.name,arguments.length===2&&(s=t,c=!0)):(i=e,a=t,o=r,arguments.length>2&&(s=n,c=!0)),i=``+i,a=``+a,o!==void 0&&(o=``+o);let l=Me(this._isDirected,i,a,o);if(l in this._edgeLabels)return c&&(this._edgeLabels[l]=s),this;if(o!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(i),this.setNode(a),this._edgeLabels[l]=c?s:this._defaultEdgeLabelFn(i,a,o);let u=Ne(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ae(this._preds[a],i),Ae(this._sucs[i],a),this._in[a][l]=u,this._out[i][l]=u,this._edgeCount++,this}edge(e,t,n){let r=arguments.length===1?Pe(this._isDirected,e):Me(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(e,t,n){let r=arguments.length===1?this.edge(e):this.edge(e,t,n);return typeof r!=`object`||!r?{label:r}:r}hasEdge(e,t,n){return(arguments.length===1?Pe(this._isDirected,e):Me(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Pe(this._isDirected,e):Me(this._isDirected,e,t,n),i=this._edgeObjs[r];if(i){let e=i.v,t=i.w;delete this._edgeLabels[r],delete this._edgeObjs[r],je(this._preds[t],e),je(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--}return this}inEdges(e,t){return this.isDirected()?this.filterEdges(this._in[e],e,t):this.nodeEdges(e,t)}outEdges(e,t){return this.isDirected()?this.filterEdges(this._out[e],e,t):this.nodeEdges(e,t)}nodeEdges(e,t){if(e in this._nodes)return this.filterEdges({...this._in[e],...this._out[e]},e,t)}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}filterEdges(e,t,n){if(!e)return;let r=Object.values(e);return n?r.filter(e=>e.v===t&&e.w===n||e.v===n&&e.w===t):r}};function Ae(e,t){e[t]?e[t]++:e[t]=1}function je(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Me(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}return i+``+a+``+(r===void 0?`\0`:r)}function Ne(e,t,n,r){let i=``+t,a=``+n;if(!e&&i>a){let e=i;i=a,a=e}let o={v:i,w:a};return r&&(o.name=r),o}function Pe(e,t){return Me(e,t.v,t.w,t.name)}Oe({},{read:()=>Re,write:()=>Fe});function Fe(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Ie(e),edges:Le(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Ie(e){return e.nodes().map(t=>{let n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function Le(e){return e.edges().map(t=>{let n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function Re(e){let t=new ke(e.options);return e.value!==void 0&&t.setGraph(e.value),e.nodes.forEach(e=>{t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(e=>{t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}var ze={};Oe(ze,{CycleException:()=>et,bellmanFord:()=>Ve,components:()=>Ue,dijkstra:()=>Ke,dijkstraAll:()=>Je,findCycles:()=>Xe,floydWarshall:()=>Qe,isAcyclic:()=>nt,postorder:()=>ot,preorder:()=>st,prim:()=>ct,shortestPaths:()=>lt,tarjan:()=>Ye,topsort:()=>tt});var Be=()=>1;function Ve(e,t,n,r){return He(e,String(t),n||Be,r||function(t){return e.outEdges(t)??[]})}function He(e,t,n,r){let i={},a,o=0,s=e.nodes(),c=function(e){let t=i[e.v],r=i[e.w];if(!t||!r)return;let o=n(e);t.distance+o<r.distance&&(i[e.w]={distance:t.distance+o,predecessor:e.v},a=!0)},l=function(){s.forEach(function(e){r(e).forEach(function(t){let n=t.v===e?t.v:t.w,r=n===t.v?t.w:t.v;c({v:n,w:r})})})};s.forEach(function(e){i[e]={distance:e===t?0:1/0,predecessor:``}});let u=s.length;for(let e=1;e<u&&(a=!1,o++,l(),a);e++);if(o===u-1&&(a=!1,l(),a))throw Error(`The graph contains a negative weight cycle`);return i}function Ue(e){let t={},n=[],r;function i(n){var a,o;n in t||(t[n]=!0,r.push(n),(a=e.successors(n))==null||a.forEach(i),(o=e.predecessors(n))==null||o.forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}var We=class{constructor(){this._arr=[],this._keyIndices={}}size(){return this._arr.length}keys(){return this._arr.map(e=>e.key)}has(e){return e in this._keyIndices}priority(e){let t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){let n=this._keyIndices,r=String(e);if(!(r in n)){let e=this._arr,i=e.length;return n[r]=i,e.push({key:r,priority:t}),this._decrease(i),!0}return!1}removeMin(){if(this.size()===0)throw Error(`Queue underflow`);this._swap(0,this._arr.length-1);let e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){let n=this._keyIndices[e];if(n===void 0)throw Error(`Key not found: ${e}`);let r=this._arr[n].priority;if(t>r)throw Error(`New priority is greater than current priority. Key: ${e} Old: ${r} New: ${t}`);this._arr[n].priority=t,this._decrease(n)}_heapify(e){let t=this._arr,n=2*e,r=n+1,i=e;n<t.length&&(i=t[n].priority<t[i].priority?n:i,r<t.length&&(i=t[r].priority<t[i].priority?r:i),i!==e&&(this._swap(e,i),this._heapify(i)))}_decrease(e){let t=this._arr,n=t[e].priority,r;for(;e!==0&&(r=e>>1,!(t[r].priority<n));)this._swap(e,r),e=r}_swap(e,t){let n=this._arr,r=this._keyIndices,i=n[e],a=n[t];n[e]=a,n[t]=i,r[a.key]=e,r[i.key]=t}},Ge=()=>1;function Ke(e,t,n,r){return qe(e,String(t),n||Ge,r||function(t){return e.outEdges(t)??[]})}function qe(e,t,n,r){let i={},a=new We,o,s,c=function(e){let t=e.v===o?e.w:e.v,r=i[t];if(!r)return;let c=n(e),l=s.distance+c;if(c<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+c);l<r.distance&&(r.distance=l,r.predecessor=o,a.decrease(t,l))};for(e.nodes().forEach(function(e){let n=e===t?0:1/0;i[e]={distance:n,predecessor:``},a.add(e,n)});a.size()>0;){o=a.removeMin();let e=i[o];if(!e||e.distance===1/0)break;s=e,r(o).forEach(c)}return i}function Je(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=Ke(e,i,t,n),r},{})}function Ye(e){let t=0,n=[],r={},i=[];function a(o){var s;let c=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),(s=e.successors(o))==null||s.forEach(function(e){if(e in r){let t=r[e];t!=null&&t.onStack&&(c.lowlink=Math.min(c.lowlink,t.index))}else{a(e);let t=r[e];t&&(c.lowlink=Math.min(c.lowlink,t.lowlink))}}),c.lowlink===c.index){let e=[],t;do{t=n.pop();let i=r[t];i&&(i.onStack=!1),e.push(t)}while(o!==t);i.push(e)}}return e.nodes().forEach(function(e){e in r||a(e)}),i}function Xe(e){return Ye(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var Ze=()=>1;function Qe(e,t,n){return $e(e,t||Ze,n||function(t){return e.outEdges(t)??[]})}function $e(e,t,n){let r={},i=e.nodes();return i.forEach(function(e){let a={};r[e]=a,a[e]={distance:0,predecessor:``},i.forEach(function(t){e!==t&&(a[t]={distance:1/0,predecessor:``})}),n(e).forEach(function(n){let r=n.v===e?n.w:n.v,i=t(n);a[r]={distance:i,predecessor:e}})}),i.forEach(function(e){let t=r[e];t&&i.forEach(function(n){let a=r[n];a&&i.forEach(function(n){let r=a[e],i=t[n],o=a[n];if(r&&i&&o){let e=r.distance+i.distance;e<o.distance&&(o.distance=e,o.predecessor=i.predecessor)}})})}),r}var et=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function tt(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new et;a in t||(n[a]=!0,t[a]=!0,(o=e.predecessors(a))==null||o.forEach(i),delete n[a],r.push(a))}if(e.sinks().forEach(i),Object.keys(t).length!==e.nodeCount())throw new et;return r}function nt(e){try{tt(e)}catch(e){if(e instanceof et)return!1;throw e}return!0}function rt(e,t,n,r,i){Array.isArray(t)||(t=[t]);let a=(t=>(e.isDirected()?e.successors(t):e.neighbors(t))??[]),o={};return t.forEach(function(t){if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);i=it(e,t,n===`post`,o,a,r,i)}),i}function it(e,t,n,r,i,a,o){return t in r||(r[t]=!0,n||(o=a(o,t)),i(t).forEach(function(t){o=it(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function at(e,t,n){return rt(e,t,n,function(e,t){return e.push(t),e},[])}function ot(e,t){return at(e,t,`post`)}function st(e,t){return at(e,t,`pre`)}function ct(e,t){var n;let r=new ke,i={},a=new We,o;function s(e){let n=e.v===o?e.w:e.v,r=a.priority(n);if(r!==void 0){let s=t(e);s<r&&(i[n]=o,a.decrease(n,s))}}if(e.nodeCount()===0)return r;e.nodes().forEach(function(e){a.add(e,1/0),r.setNode(e)});let c=e.nodes()[0];c!==void 0&&a.decrease(c,0);let l=!1;for(;a.size()>0;){if(o=a.removeMin(),o in i)r.setEdge(o,i[o]);else{if(l)throw Error(`Input graph is not connected: `+e);l=!0}(n=e.nodeEdges(o))==null||n.forEach(s)}return r}function lt(e,t,n,r){return ut(e,t,n,r??(t=>e.outEdges(t)??[]))}function ut(e,t,n,r){if(n===void 0)return Ke(e,t,n,r);let i=!1,a=e.nodes();for(let o=0;o<a.length;o++){let s=a[o];if(s===void 0)continue;let c=r(s);for(let e=0;e<c.length;e++){let t=c[e];if(!t)continue;let r=t.v===s?t.v:t.w;n({v:r,w:r===t.v?t.w:t.v})<0&&(i=!0)}if(i)return Ve(e,t,n,r)}return Ke(e,t,n,r)}var dt=ke;function ft(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Dt(r);return n.dummy=t,e.setNode(i,n),i}function pt(e){let t=new dt().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function mt(e){let t=new dt({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function ht(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return i===0||Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function gt(e){let t=Ot(Ct(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i]||(t[i]=[]),t[i][r.order]=n)}),t}function _t(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=St(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function vt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=St(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function yt(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),ft(e,`border`,i,t)}function bt(e,t=xt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var xt=65535;function St(e,t){return t.length>xt?e(...bt(t).map(t=>e(...t))):e(...t)}function Ct(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return St(Math.max,t)}function wt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Tt(e,t){return t()}var Et=0;function Dt(e){return e+(``+ ++Et)}function Ot(e,t,n=1){t??(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);let i=[];for(let t=e;r(t);t+=n)i.push(t);return i}function kt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function At(e,t){let n;return n=typeof t==`string`?e=>e[t]:t,Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function jt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Mt=`\0`;function Nt(e,t,n){if(!(e&&t&&n&&t.dummy===`edge`&&n.dummy===`edge`&&t.edgeObj&&n.edgeObj&&e[t.edgeObj.v]&&e[n.edgeObj.v]&&e[t.edgeObj.w]&&e[n.edgeObj.w]))return 0;let r=!0;t.edgeObj.w===n.edgeObj.w&&(r=!1);let i=r?e[t.edgeObj.v]?.rank??NaN:e[t.edgeObj.w]?.rank??NaN,a=Object.entries(e).find(e=>e[1].edgeObj?.v===t.edgeObj.v&&e[1].edgeObj?.w===t.edgeObj.w&&e[1].rank===i),o=Object.entries(e).find(e=>e[1].edgeObj?.v===n.edgeObj.v&&e[1].edgeObj?.w===n.edgeObj.w&&e[1].rank===i);if(!a||!o)return 0;let s=a[1].order??NaN,c=o[1].order??NaN;return isNaN(s-c)?0:s-c}var Pt=class{constructor(){Te(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Ft(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Ft(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,It)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Ft(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function It(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Lt=Pt,Rt=()=>1;function zt(e,t){if(e.nodeCount()<=1)return[];let n=Ht(e,t||Rt);return Bt(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function Bt(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)Vt(e,t,n,o);for(;o=i.dequeue();)Vt(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i]?.dequeue(),o){r=r.concat(Vt(e,t,n,o,!0)||[]);break}}}return r}function Vt(e,t,n,r,i){let a=[],o=i?a:void 0;return(e.inEdges(r.v)||[]).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,Ut(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,Ut(t,n,o)}),e.removeNode(r.v),o}function Ht(e,t){let n=new dt,r=0,i=0;e.nodes().forEach(e=>{n.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let a=n.edge(e.v,e.w)||0,o=t(e),s=a+o;n.setEdge(e.v,e.w,s);let c=n.node(e.v),l=n.node(e.w);i=Math.max(i,c.out+=o),r=Math.max(r,l.in+=o)});let a=Wt(i+r+3).map(()=>new Lt),o=r+1;return n.nodes().forEach(e=>{Ut(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function Ut(e,t,n){var r,i,a;n.out?n.in?(a=e[n.out-n.in+t])==null||a.enqueue(n):(i=e[e.length-1])==null||i.enqueue(n):(r=e[0])==null||r.enqueue(n)}function Wt(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function Gt(e,t){(e.graph().acyclicer===`greedy`?zt(e,n(e)):Kt(e,t??null)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,Dt(`rev`))});function n(e){return t=>e.edge(t).weight}}function Kt(e,t){let n=[],r={},i={};function a(t){Object.hasOwn(i,t)||(i[t]=!0,r[t]=!0,e.outEdges(t).forEach(e=>{Object.hasOwn(r,e.w)?n.push(e):a(e.w)}),delete r[t])}function o(a){var s;Object.hasOwn(i,a)||(i[a]=!0,r[a]=!0,(s=e.outEdges(a))==null||s.forEach(i=>{Object.hasOwn(r,i.w)||t.node(a)?.rank>t.node(i.w)?.rank&&Jt(e,i.w,i)?n.push(i):o(i.w)}),delete r[a])}let s=a;return t&&typeof t.node==`function`&&(s=o),e.sources().forEach(s),e.nodes().forEach(s),n}function qt(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}function Jt(e,t,n){let r=new Set;function i(t){if(e.sources().includes(t))return!0;r.add(t);for(let a of e.inEdges(t)??[])if((a.v!==n.v||a.w!==n.w)&&!r.has(a.v)&&i(a.v))return!0;return!1}return i(t)}function Yt(e){e.graph().dummyChains=[],e.edges().forEach(t=>Xt(e,t))}function Xt(e,t){let n=t.v,r=e.node(n).rank,i=t.w,a=e.node(i).rank,o=t.name,s=e.edge(t),c=s.labelRank;if(a===r+1)return;e.removeEdge(t);let l,u,d=0;for(++r;r<a;++d,++r)s.points=[],u={width:0,height:0,edgeLabel:s,edgeObj:t,rank:r},l=ft(e,`edge`,u,`_d`),r===c&&(u.width=s.width,u.height=s.height,u.dummy=`edge-label`,u.labelpos=s.labelpos),e.setEdge(n,l,{weight:s.weight},o),d===0&&e.graph().dummyChains.push(l),n=l;e.setEdge(n,i,{weight:s.weight},o)}function Zt(e){e.graph().dummyChains.forEach(t=>{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}function Qt(e){let t={};function n(r){let i=e.node(r);if(Object.hasOwn(t,r))return i.rank;t[r]=!0;let a=e.outEdges(r),o=a?a.map(t=>t==null?1/0:n(t.w)-e.edge(t).minlen):[],s=St(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function $t(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var en=tn;function tn(e){let t=new dt({directed:!1}),n=e.nodes();if(n.length===0)throw Error(`Graph must have at least one node`);let r=n[0],i=e.nodeCount();t.setNode(r,{});let a,o;for(;nn(t,e)<i&&(a=rn(t,e),a);)o=t.hasNode(a.v)?$t(e,a):-$t(e,a),an(t,e,o);return t}function nn(e,t){function n(r){let i=t.nodeEdges(r);i&&i.forEach(i=>{let a=i.v,o=r===a?i.w:a;!e.hasNode(o)&&!$t(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function rn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=$t(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function an(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:on,postorder:sn}=ze,cn=ln;ln.initLowLimValues=pn,ln.initCutValues=un,ln.calcCutValue=fn,ln.leaveEdge=hn,ln.enterEdge=gn,ln.exchangeEdges=_n;function ln(e){e=pt(e),Qt(e);let t=en(e);pn(t),un(t,e);let n,r;for(;n=hn(t);)r=gn(t,e,n),_n(t,e,n,r)}function un(e,t){let n=sn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>dn(e,t,n))}function dn(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=fn(e,t,n)}function fn(e,t,n){let r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;a||=(i=!1,t.edge(r,n)),o=a.weight;let s=t.nodeEdges(n);return s&&s.forEach(a=>{let s=a.v===n,c=s?a.w:a.v;if(c!==r){let r=s===i,l=t.edge(a).weight;if(o+=r?l:-l,yn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function pn(e,t){arguments.length<2&&(t=e.nodes()[0]),mn(e,{},1,t)}function mn(e,t,n,r,i){let a=n,o=e.node(r);t[r]=!0;let s=e.neighbors(r);return s&&s.forEach(i=>{Object.hasOwn(t,i)||(n=mn(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function hn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function gn(e,t,n){let r=n.v,i=n.w;t.hasEdge(r,i)||(r=n.w,i=n.v);let a=e.node(r),o=e.node(i),s=a,c=!1;return a.lim>o.lim&&(s=o,c=!0),t.edges().filter(t=>c===bn(e,e.node(t.v),s)&&c!==bn(e,e.node(t.w),s)).reduce((e,n)=>$t(t,n)<$t(t,e)?n:e)}function _n(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),pn(e),un(e,t),vn(e,t)}function vn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=on(e,[n]);r=r.slice(1),r.forEach(n=>{let r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function yn(e,t,n){return e.hasEdge(t,n)}function bn(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var xn=Sn;function Sn(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Tn(e);break;case`tight-tree`:wn(e);break;case`longest-path`:Cn(e);break;case`none`:break;default:Tn(e)}}var Cn=Qt;function wn(e){Qt(e),en(e)}function Tn(e){cn(e)}var En=Dn;function Dn(e){let t=kn(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=On(e,t,i.v,i.w),o=a.path,s=a.lca,c=0,l=o[c],u=!0;for(;n!==i.w;){if(r=e.node(n),u){for(;(l=o[c])!==s&&e.node(l).maxRank<r.rank;)c++;l===s&&(u=!1)}if(!u){for(;c<o.length-1&&e.node(o[c+1]).minRank<=r.rank;)c++;l=o[c]}l!==void 0&&e.setParent(n,l),n=e.successors(n)[0]}})}function On(e,t,n,r){let i=[],a=[],o=Math.min(t[n].low,t[r].low),s=Math.max(t[n].lim,t[r].lim),c;c=n;do c=e.parent(c),i.push(c);while(c&&(t[c].low>o||s>t[c].lim));let l=c,u=r;for(;(u=e.parent(u))!==l;)a.push(u);return{path:i.concat(a.reverse()),lca:l}}function kn(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children(Mt).forEach(r),t}function An(e){let t=ft(e,`root`,{},`_root`),n=Mn(e),r=Object.values(n),i=St(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Nn(e)+1;e.children(Mt).forEach(r=>{jn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function jn(e,t,n,r,i,a,o){let s=e.children(o);if(!s.length){o!==t&&e.setEdge(t,o,{weight:0,minlen:n});return}let c=yt(e,`_bt`),l=yt(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{jn(e,t,n,r,i,a,s);let u=e.node(s),d=u.borderTop?u.borderTop:s,f=u.borderBottom?u.borderBottom:s,p=u.borderTop?r:2*r,m=d===f?i-(a[o]??0)+1:1;e.setEdge(c,d,{weight:p,minlen:m,nestingEdge:!0}),e.setEdge(f,l,{weight:p,minlen:m,nestingEdge:!0})}),e.parent(o)||e.setEdge(t,c,{weight:0,minlen:i+(a[o]??0)})}function Mn(e){let t={};function n(r,i){let a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children(Mt).forEach(e=>n(e,1)),t}function Nn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Pn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Fn=In;function In(e){function t(n){let r=e.children(n),i=e.node(n);if(r.length&&r.forEach(t),i&&Object.hasOwn(i,`minRank`)){i.borderLeft=[],i.borderRight=[];for(let t=i.minRank,r=i.maxRank+1;t<r;++t)Ln(e,`borderLeft`,`_bl`,n,i,t),Ln(e,`borderRight`,`_br`,n,i,t)}}e.children(Mt).forEach(t)}function Ln(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=ft(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Rn(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&Bn(e)}function zn(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&Hn(e),(t===`lr`||t===`rl`)&&(Wn(e),Bn(e))}function Bn(e){e.nodes().forEach(t=>Vn(e.node(t))),e.edges().forEach(t=>Vn(e.edge(t)))}function Vn(e){let t=e.width;e.width=e.height,e.height=t}function Hn(e){e.nodes().forEach(t=>Un(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Un),Object.hasOwn(r,`y`)&&Un(r)})}function Un(e){e.y=-e.y}function Wn(e){e.nodes().forEach(t=>Gn(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(Gn),Object.hasOwn(r,`x`)&&Gn(r)})}function Gn(e){let t=e.x;e.x=e.y,e.y=t}function Kn(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Ot(St(Math.max,i)+1).map(()=>[]);function o(t){if(n[t])return;n[t]=!0;let r=e.node(t);a[r.rank].push(t);let i=e.successors(t);i&&[...i].sort((e,t)=>s(e,t)).forEach(o)}r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(o);function s(n,r){return Nt(t,e.node(n),e.node(r))}return a}function qn(e,t){let n=0;for(let r=1;r<t.length;++r)n+=Jn(e,t[r-1],t[r]);return n}function Jn(e,t,n){let r=jt(n,n.map((e,t)=>t)),i=t.flatMap(t=>{let n=e.outEdges(t);return n?n.map(t=>({pos:r[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos):[]}),a=1;for(;a<n.length;)a<<=1;let o=2*a-1;--a;let s=Array(o).fill(0),c=0;return i.forEach(e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;c+=e.weight*n}),c}function Yn(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(!n||!n.length)return{v:t};{let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}})}function Xn(e,t){let n={};return e.forEach((e,t)=>{let r={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight),n[e.v]=r}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(r))}),Zn(Object.values(n).filter(e=>!e.indegree))}function Zn(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&Qn(e,t)}}function r(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let i=e.pop();t.push(i),i.in.reverse().forEach(n(i)),i.out.forEach(r(i))}return t.filter(e=>!e.merged).map(e=>kt(e,[`vs`,`i`,`barycenter`,`weight`]))}function Qn(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}function $n(e,t,n,r,i){let a={},o=null,s=null,c=i;typeof t==`boolean`?(c=t,a={}):t&&(a=t,o=n??null,s=r??null);let l=wt(e,e=>Object.hasOwn(e,`barycenter`)),u=l.lhs,d=l.rhs.sort((e,t)=>t.i-e.i),f=[],p=0,m=0,h=0;u.sort(tr(s,o,!!c));for(let[e,t]of Object.entries(a)){let n=u.findIndex(t=>t.vs[0]===e);u.splice(n+1,0,t)}h=er(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=er(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function er(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function tr(e,t,n){return(r,i)=>{if(r.barycenter<i.barycenter)return-1;if(r.barycenter>i.barycenter)return 1;if(e&&(typeof r.vs[0]==`string`||typeof i.vs[0]==`string`)){let n=Nt(t,e.node(r.vs[0]),e.node(i.vs[0]));if(n!==0)return n}return n?i.i-r.i:r.i-i.i}}function nr(e,t,n,r,i){var a,o;let s=null,c=i;typeof r==`boolean`?(c=r,s=null):r!==void 0&&(s=r);let l=e.children(t),u=e.node(t),d=u?u.borderLeft:void 0,f=u?u.borderRight:void 0,p={};d&&(l=l.filter(e=>e!==d&&e!==f));let m=Yn(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=nr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&ir(t,r)}});let h=Xn(m,n);rr(h,p);let g={},_=!1;for(let t=0;t<h.length;t++)for(let n=t+1;n<h.length;n++)if(h[t]&&h[n]&&(a=h[t])!=null&&a.barycenter&&(o=h[n])!=null&&o.barycenter&&h[t]?.barycenter===h[n].barycenter){let r=h[t]?.vs[0]??``,i=h[n]?.vs[0]??``,a=e.node(r),o=e.node(i);if(a.dummy===`edge`&&o.dummy===`edge`&&a.edgeObj?.v===o.edgeObj?.v&&a.edgeObj?.w===o.edgeObj?.w){if(a.edgeLabel.reversed){g[i]=h[t],h.splice(t,1),t--;break}g[r]||(g[r]=h[n],h.splice(n,1),n--)}else _=!0}let v=$n(h,g,s,e,c);if(d&&f){v.vs=[d,v.vs,f].flat(1);let t=e.predecessors(d);if(t&&t.length){let n=e.node(t[0]),r=e.predecessors(f),i=e.node(r[0]);Object.hasOwn(v,`barycenter`)||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+n.order+i.order)/(v.weight+2),v.weight+=2}}return Object.defineProperty(v,"result",{value:v,enumerable:!1,configurable:!0,writable:!0}),Object.defineProperty(v,"usedBias",{value:_,enumerable:!1,configurable:!0,writable:!0}),v}function rr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function ir(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}function ar(e,t,n,r){r||=e.nodes();let i=or(e),a=new dt({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(t=>e.node(t));return r.forEach(r=>{let o=e.node(r),s=e.parent(r);if(o.rank===t||o.minRank<=t&&t<=o.maxRank){a.setNode(r),a.setParent(r,s||i);let c=e[n](r);c&&c.forEach(t=>{let n=t.v===r?t.w:t.v,i=a.edge(n,r),o=i===void 0?0:i.weight;a.setEdge(n,r,{weight:e.edge(t).weight+o})}),Object.hasOwn(o,`minRank`)&&a.setNode(r,{borderLeft:o.borderLeft[t],borderRight:o.borderRight[t]})}}),a}function or(e){let t;for(;e.hasNode(t=Dt(`_root`)););return t}function sr(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}function cr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,cr);return}let r=Ct(e),i=lr(e,Ot(1,r+1),`inEdges`),a=lr(e,Ot(r-1,-1,-1),`outEdges`),o=Kn(e,n);if(dr(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){ur(t%2?i:a,t%4>=2,l,n),o=gt(e);let u=qn(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}dr(e,c)}function lr(e,t,n){let r=new Map,i=(e,t)=>{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return ar(e,t,n,r.get(t)||[])})}function ur(e,t,n,r){let i=!0,a=new dt;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=nr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),sr(e,a,s.vs)})}function dr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function fr(e,t){let n={};function r(t,r){let i=0,a=0,o=t.length,s=r[r.length-1];return r.forEach((t,c)=>{let l=mr(e,t),u=l?e.node(l).order:o;(l||t===s)&&(r.slice(a,c+1).forEach(t=>{let r=e.predecessors(t);r&&r.forEach(r=>{let a=e.node(r),o=a.order;(o<i||u<o)&&!(a.dummy&&e.node(t).dummy)&&hr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function pr(e,t){let n={};function r(t){return e.node(t)?.dummy===`border`}if(!e.nodes().some(r))return n;function i(t,r,i,a,o){Ot(r,i).forEach(r=>{let i=t[r];if(i!==void 0&&e.node(i).dummy){let t=e.predecessors(i);t&&t.forEach(t=>{if(t===void 0)return;let r=e.node(t);r.dummy&&(r.order<a||r.order>o)&&hr(n,t,i)})}})}function a(t,n){let a=-1,o=-1,s=0;return n.forEach((c,l)=>{if(r(c)){let t=e.predecessors(c);if(t&&t.length){let r=t[0];if(r===void 0)return;o=e.node(r).order,i(n,s,l,a,o),s=l,a=o}}i(n,s,n.length,o,t.length)}),n}return t.length&&t.reduce(a),n}function mr(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function hr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function gr(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];return r!==void 0&&Object.hasOwn(r,n)}function _r(e,t,n,r,i){let a={},o={},s={};return t.forEach(e=>{e.forEach((e,t)=>{a[e]=e,o[e]=e,s[e]=t})}),t.forEach(t=>{let c=-1,l=-1,u=!1,d=t,f=t.findIndex(t=>i?.includes(t)||Er(t,e,i));f>0&&(d=[t[f],...t.slice(0,f),...t.slice(f+1)],u=!0),d.forEach(t=>{let d=r(t);if(d&&d.length){i!=null&&i.includes(t)&&(d=d.filter(t=>Er(t,e,i)));let r=d.sort((e,t)=>{let n=s[e],r=s[t];return(n===void 0?0:n)-(r===void 0?0:r)}),f=(r.length-1)/2;for(let e=Math.floor(f),i=Math.ceil(f);e<=i;++e){let i=r[e];if(i===void 0)continue;let d=s[i];if(d!==void 0&&o[t]===t&&c<d&&s[i]!==l&&!gr(n,t,i)){let e=a[i];e!==void 0&&(o[i]=t,o[t]=a[t]=e,c=d,u&&=(c=-1,l=s[i]??-1,!1))}}}})}),{root:a,align:o}}function vr(e,t,n,r,i=!1){let a={},o=yr(e,t,n,i),s=i?`borderLeft`:`borderRight`;function c(e,t){let n=o.nodes().slice(),r={},i=n.pop();for(;i;){if(r[i])e(i);else{r[i]=!0,n.push(i);for(let e of t(i))n.push(e)}i=n.pop()}}function l(e){let t=o.inEdges(e);t?a[e]=t.reduce((e,t)=>{let n=a[t.v]??0,r=o.edge(t);return Math.max(e,n+(r===void 0?0:r))},0):a[e]=0}function u(t){let n=o.outEdges(t),r=1/0;n&&(r=n.reduce((e,t)=>{let n=a[t.w],r=o.edge(t);return Math.min(e,(n===void 0?0:n)-(r===void 0?0:r))},1/0));let i=e.node(t);r!==1/0&&i.borderType!==s&&(a[t]=Math.max(a[t]===void 0?0:a[t],r))}function d(e){return o.predecessors(e)||[]}function f(e){return o.successors(e)||[]}return c(l,d),c(u,f),Object.keys(r).forEach(e=>{let t=n[e];t!==void 0&&(a[e]=a[t]??0)}),a}function yr(e,t,n,r){let i=new dt,a=e.graph(),o=wr(a.nodesep,a.edgesep,r);return t.forEach(t=>{let r;t.forEach(t=>{let a=n[t];if(a!==void 0){if(i.setNode(a),r!==void 0){let s=n[r];if(s!==void 0){let n=i.edge(s,a);i.setEdge(s,a,Math.max(o(e,t,r),n||0))}}r=t}})}),i}function br(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Tr(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a<t[0]&&(t=[a,n]),t},[1/0,null])[1]}function xr(e,t){let n=Object.values(t),r=St(Math.min,n),i=St(Math.max,n);[`u`,`d`].forEach(n=>{[`l`,`r`].forEach(a=>{let o=n+a,s=e[o];if(!s||s===t)return;let c=Object.values(s),l=r-St(Math.min,c);a!==`l`&&(l=i-St(Math.max,c)),l&&(e[o]=At(s,e=>e+l))})})}function Sr(e,t=void 0){let n=e.ul;return n?At(n,(n,r)=>{if(t){let n=e[t.toLowerCase()];if(n&&n[r]!==void 0)return n[r]}let i=Object.values(e).map(e=>{let t=e[r];return t===void 0?0:t}).sort((e,t)=>e-t);return((i[1]??0)+(i[2]??0))/2}):{}}function Cr(e,t){let n=gt(e),r=Object.assign(fr(e,n),pr(e,n)),i={},a;return[`u`,`d`].forEach(o=>{a=o===`u`?n:Object.values(n).reverse(),[`l`,`r`].forEach(n=>{n===`r`&&(a=a.map(e=>Object.values(e).reverse()));let s=_r(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=vr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=At(c,e=>-e)),i[o+n]=c})}),xr(i,br(e,i)),Sr(i,e.graph().align)}function wr(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2}if(l&&(c+=n?l:-l),l=void 0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2}return l&&(c+=n?l:-l),c}}function Tr(e,t){return e.node(t).width}function Er(e,t,n){if(!n)return!1;let r=t.node(e)?.edgeObj;if(!r||t.node(e).edgeLabel.reversed)return!1;let i=n.indexOf(r?.v),a=n.indexOf(r?.w);return i!==-1&&a!==-1&&i===(a+1)%n.length||i===(a-1)%n.length}function Dr(e,t){e=mt(e),Or(e),Object.entries(Cr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Or(e){let t=gt(e),n=e.graph(),r=n.ranksep,i=n.rankalign,a=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height??0;return t>r?t:r},0);t.forEach(t=>{let r=e.node(t);r.y=i===`top`?a+r.height/2:i===`bottom`?a+n-r.height/2:a+n/2}),a+=n+r})}var kr=new WeakMap;function Ar(e,t={}){return Mr(e,Tt,t),e}function jr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Mr(e,t,n){let r=e.nodes().filter(t=>e.children(t).length),i={};r.forEach(r=>{let a=e.node(r);if(a&&a.rankdir){let o=new dt({multigraph:!0,compound:!0});o.setGraph({rankdir:a.rankdir});let s=e.children(r);s.forEach(t=>{let n={...e.node(t)};o.setNode(t,n);let i=e.parent(t);i&&i!==r&&s.includes(i)&&o.setParent(t,i)});let c=new Set;e.edges().forEach(t=>{let n=jr(e,t.v,r),i=jr(e,t.w,r);if(n===t.v&&i===t.w)o.setEdge(t,{...e.edge(t)});else if(n&&i&&n!==i){let r=`${n}\0${i}`;c.has(r)||(c.add(r),o.setEdge(n,i,{...e.edge(t)}))}}),Mr(o,t,n);let l=Wr(o);Pr(l,t,n,null),Fr(o,l);let u=1/0,d=1/0,f=-1/0,p=-1/0;o.nodes().forEach(e=>{if(e===r)return;let t=o.node(e);t&&typeof t.x==`number`&&typeof t.y==`number`&&typeof t.width==`number`&&typeof t.height==`number`&&(u=Math.min(u,t.x-t.width/2),f=Math.max(f,t.x+t.width/2),d=Math.min(d,t.y-t.height/2),p=Math.max(p,t.y+t.height/2))}),isFinite(u)&&isFinite(d)&&isFinite(f)&&isFinite(p)||(u=d=0,f=p=0);let m=f-u,h=p-d;i[r]={minX:u,minY:d,maxX:f,maxY:p,width:m,height:h,offsetX:u,offsetY:d},a._dagreClusterSubgraph=o}});let a=[],o=t=>{let n=[],r=(e.children(t)||[]).filter(e=>e!==t);for(;r.length>0;){let t=r.shift();n.push(t),(e.children(t)||[]).filter(e=>e!==t).forEach(e=>r.push(e))}return n},s=new Map;r.forEach(t=>{let n=e.node(t);n&&n.rankdir&&i[t]&&s.set(t,(e.children(t)||[]).filter(e=>e!==t))});let c=new Set([...s.values()].flat()),l=new Map;s.forEach((e,t)=>{c.has(t)||l.set(t,o(t))});let u=new Set([...l.values()].flat()),d=e=>{for(let[t,n]of l)if(n.includes(e))return t;return e},f=[];e.edges().forEach(t=>{(u.has(t.v)||u.has(t.w))&&f.push({edge:t,label:e.edge(t)})});let p=new Map;u.forEach(t=>{let n=e.parent(t);p.set(t,typeof n==`string`?n:void 0)}),l.forEach((t,n)=>{let r=e.node(n),o=[];t.forEach(t=>{let n=e.node(t);n&&(o.push({id:t,node:n,parent:p.get(t)}),e.removeNode(t))});let s=f.filter(({edge:e})=>t.includes(e.v)||t.includes(e.w)),c=i[n];r&&(a.push({clusterId:n,subgraph:r._dagreClusterSubgraph,bounds:c,children:t,removedNodes:o,removedEdges:s}),r.width=c.width,r.height=c.height)});let m=new Set;f.forEach(({edge:t,label:n})=>{let r=d(t.v),i=d(t.w);if(r!==i&&e.hasNode(r)&&e.hasNode(i)){let t=`${r}\0${i}`;m.has(t)||(m.add(t),e.setEdge(r,i,{...n,width:0,height:0}))}});let h=Wr(e),g=Pr(h,t,n,kr.get(e)??null);kr.set(e,g),Fr(e,h),m.forEach(t=>{let n=t.indexOf(`\0`),r=t.slice(0,n),i=t.slice(n+1);e.hasEdge(r,i)&&e.removeEdge(r,i)}),a.forEach(({clusterId:t,subgraph:n,bounds:r,removedNodes:i,removedEdges:a})=>{let o=e.node(t),s=o?.x??0,c=o?.y??0,l=(r.minX+r.maxX)/2,u=(r.minY+r.maxY)/2;i.forEach(({id:t,node:n,parent:r})=>{e.setNode(t,n),r!==void 0&&e.setParent(t,r)}),a.forEach(({edge:t,label:n})=>{e.setEdge(t,n)}),n.nodes().forEach(r=>{if(r===t)return;let i=n.node(r),a=e.node(r);a&&i&&typeof i.x==`number`&&typeof i.y==`number`&&(a.x=s+(i.x-l),a.y=c+(i.y-u))}),Nr(e,n,s-l,c-u),delete o._dagreClusterSubgraph}),r.forEach(t=>{let n=e.node(t),r=i[t];if(n&&n.rankdir&&n._dagreClusterSubgraph&&r){let i=n._dagreClusterSubgraph,a=n.x??0,o=n.y??0,s=(r.minX+r.maxX)/2,c=(r.minY+r.maxY)/2;i.nodes().forEach(n=>{if(n===t)return;let r=i.node(n),l=e.node(n);if(l&&r&&typeof r.x==`number`&&typeof r.y==`number`){let e=r.x-s,t=r.y-c;l.x=a+e,l.y=o+t}}),Nr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function Nr(e,t,n,r){t.edges().forEach(i=>{if(!e.hasEdge(i))return;let a=t.edge(i),o=e.edge(i);o.points=a.points.map(e=>({x:e.x+n,y:e.y+r})),Object.hasOwn(a,`x`)&&(o.x=a.x+n,o.y=a.y+r)})}function Pr(e,t,n,r=null){var i,a;let o=n?.useDynamic!==!1,s=o&&(i=r?.graph)!=null?i:null,c=o&&(a=r?.rawNodes)!=null?a:null;t(` makeSpaceForEdgeLabels`,()=>Gr(e)),t(` removeSelfEdges`,()=>ei(e)),t(` acyclic`,()=>Gt(e,s)),t(` nestingGraph.run`,()=>An(e)),t(` rank`,()=>xn(mt(e))),t(` injectEdgeLabelProxies`,()=>Kr(e)),t(` removeEmptyRanks`,()=>vt(e)),t(` nestingGraph.cleanup`,()=>Pn(e)),t(` normalizeRanks`,()=>_t(e)),t(` assignRankMinMax`,()=>qr(e)),t(` removeEdgeLabelProxies`,()=>Jr(e)),t(` normalize.run`,()=>Yt(e)),t(` parentDummyChains`,()=>En(e)),t(` addBorderSegments`,()=>Fn(e)),t(` order`,()=>cr(e,n,c)),t(` insertSelfEdges`,()=>ti(e)),t(` adjustCoordinateSystem`,()=>Rn(e)),t(` position`,()=>Dr(e,n.corePath)),t(` positionSelfEdges`,()=>ni(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>$r(e)),t(` normalize.undo`,()=>Zt(e)),t(` fixupEdgeLabelCoords`,()=>Zr(e)),t(` undoCoordinateSystem`,()=>zn(e)),t(` translateGraph`,()=>Yr(e)),t(` assignNodeIntersects`,()=>Xr(e)),t(` reversePoints`,()=>Qr(e)),t(` acyclic.undo`,()=>qt(e)),{graph:e,rawNodes:l}}function Fr(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.order=i.order,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var Ir=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Lr={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Rr=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],zr=[`width`,`height`,`rank`],Br={width:0,height:0},Vr=[`minlen`,`weight`,`width`,`height`,`labeloffset`],Hr={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},Ur=[`labelpos`];function Wr(e){let t=new dt({multigraph:!0,compound:!0}),n=ii(e.graph());return t.setGraph(Object.assign({},Lr,ri(n,Ir),kt(n,Rr))),e.nodes().forEach(n=>{let r=ri(ii(e.node(n)),zr);Object.keys(Br).forEach(e=>{r[e]===void 0&&(r[e]=Br[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=ii(e.edge(n));t.setEdge(n,Object.assign({},Hr,ri(r,Vr),kt(r,Ur)))}),t}function Gr(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,(r.labelpos??`r`).toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function Kr(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);ft(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function qr(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function Jr(e){e.nodes().forEach(t=>{let n=e.node(t);if(n.dummy===`edge-proxy`){let r=n;e.edge(r.e).labelRank=n.rank,e.removeNode(t)}})}function Yr(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function Xr(e){e.edges().forEach(t=>{if(t.v===t.w)return;let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(ht(r,a)),n.points.push(ht(i,o))})}function Zr(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset}})}function Qr(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function $r(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function ei(e){e.edges().forEach(t=>{if(t.v===t.w){let n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function ti(e){gt(e).forEach(t=>{let n=0;t.forEach((t,r)=>{let i=e.node(t);typeof i.rank!=`number`&&(i.rank=0),i.order=r+n,(i.selfEdges||[]).forEach(t=>{ft(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,edgeLabel:t.label},`_se`),Array.isArray(t.label.points)&&t.label.points.length===7||(t.label.points=[{x:0,y:-10},{x:0,y:-10},{x:0,y:0},{x:0,y:10},{x:0,y:10},{x:0,y:0},{x:0,y:0}])}),delete i.selfEdges})})}function ni(e){e.nodes().forEach(t=>{let n=e.node(t),r=e=>typeof e==`number`&&isFinite(e);if(n.dummy===`selfedge`){let i=n,a=e.node(i.e.v),o=r(a?.x)?a.x:0,s=r(a?.y)?a.y:0,c=r(a?.width)?a.width:0,l=r(a?.height)?a.height:0,u=r(n.x)?n.x:o,d=r(n.y)?n.y:s,f=c/2,p=l/2;i.edgeLabel.points=[{x:u+f,y:d-p},{x:u+f,y:d-p},{x:u,y:d},{x:u-f,y:d+p},{x:u-f,y:d+p},{x:u,y:d},{x:u,y:d}],i.edgeLabel.x=u,i.edgeLabel.y=d,e.setEdge(i.e,i.edgeLabel),e.removeNode(t)}else n&&Array.isArray(n.selfEdges)&&n.selfEdges.forEach(e=>{if(!Array.isArray(e.label.points)||e.label.points.length!==7){let t=r(n.x)?n.x:0,i=r(n.y)?n.y:0,a=r(n.width)?n.width:0,o=r(n.height)?n.height:0,s=a/2,c=o/2;e.label.points=[{x:t+s,y:i-c},{x:t+s,y:i-c},{x:t,y:i},{x:t-s,y:i+c},{x:t-s,y:i+c},{x:t,y:i},{x:t,y:i}]}})})}function ri(e,t){return At(kt(e,t),Number)}function ii(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var ai=7,oi=16,si=1.5,ci=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function li(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&ci.has(r)?2:1;return Math.ceil(n*ai*(t===`title`?si:1))}var ui=12,di=e=>Math.round(e*10)/10,fi=e=>Math.round(e*100)/100,pi=(e,t)=>[fi((e[0]+t[0])/2),fi((e[1]+t[1])/2)],mi=([e,t])=>`${e} ${t}`;function hi(e){let t=e.length-1;if(t===1)return`M${mi(e[0])} L${mi(e[1])}`;let n=[`M${mi(e[0])}`,`L${mi(pi(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${mi(e[r])} ${mi(pi(e[r],e[r+1]))}`);return n.push(`L${mi(e[t])}`),n.join(` `)}var gi=16;function _i(e,t,n){return Array.from({length:gi},(r,i)=>{let a=(i+1)/gi,o=1-a;return[o*o*e[0]+2*o*a*t[0]+a*a*n[0],o*o*e[1]+2*o*a*t[1]+a*a*n[1]]})}var vi=e=>e.slice(1).map((t,n)=>[e[n],t]);function yi(e,t,n){let r=li(e,`label`);return{text:e,x:di(t[0]-r/2),y:di(t[1]-oi/2),width:r,height:oi,route:n}}function bi(e){let t=e.slice(1).map((t,n)=>Math.hypot(t[0]-e[n][0],t[1]-e[n][1])),n=t.reduce((e,t)=>e+t,0)/2;for(let[r,i]of t.entries()){if(n<=i&&i>0){let[t,a]=[e[r],e[r+1]];return[di(t[0]+(a[0]-t[0])*n/i),di(t[1]+(a[1]-t[1])*n/i)]}n-=i}return e[e.length-1]}function xi(e,t){let n=e.x+e.width/2,r=e.y+e.height/2,i=t[0]-n,a=t[1]-r;if(i===0&&a===0)return[di(n),di(e.y)];let o=Math.min(i===0?1/0:e.width/2/Math.abs(i),a===0?1/0:e.height/2/Math.abs(a));return[di(n+i*o),di(r+a*o)]}function Si(e,t,n,r){let i=t[0]-e[0],a=t[1]-e[1],o=0,s=1,c=[[-i,e[0]-(n.x-r)],[i,n.x+n.width+r-e[0]],[-a,e[1]-(n.y-r)],[a,n.y+n.height+r-e[1]]];for(let[e,t]of c){if(e===0){if(t<0)return null;continue}let n=t/e;if(e<0?o=Math.max(o,n):s=Math.min(s,n),o>s)return null}return[o,s]}function Ci(e,t,n){let r=Si(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var wi=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),Ti=e=>[[e.x-ui,e.y-ui],[e.x+e.width+ui,e.y-ui],[e.x-ui,e.y+e.height+ui],[e.x+e.width+ui,e.y+e.height+ui]],Ei=(e,t)=>e[0]>t.x+.5&&e[0]<t.x+t.width-.5&&e[1]>t.y+.5&&e[1]<t.y+t.height-.5;function Di(e,t,n){let r=[e,t,...n.flatMap(Ti).filter(e=>!n.some(t=>Ei(e,t)))],i=r.map(()=>1/0),a=r.map(()=>-1),o=r.map(()=>!1);for(i[0]=0;;){let e=-1;for(let[t,n]of i.entries())!o[t]&&n<1/0&&(e<0||n<i[e])&&(e=t);if(e<0)return null;if(e===1)break;o[e]=!0;for(let[t,s]of r.entries()){let c=i[e]+wi(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>Ci(r[e],s,t))&&(i[t]=c,a[t]=e)}}let s=[];for(let e=1;e>=0;e=a[e])s.unshift(r[e]);return s}function Oi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>Ci(n,i,e))?[n]:(Di(n,i,t)??[n,i]).slice(0,-1)})}function ki(e){let t=[];for(let n of e){let e=t.findIndex(e=>e[0]===n[0]&&e[1]===n[1]);e>=0&&(t.length=e),t.push(n)}return t}function Ai(e,t,n){let r=Math.min(n/Math.max(wi(e,t),.01),.25);return[di(e[0]+(t[0]-e[0])*r),di(e[1]+(t[1]-e[1])*r)]}function ji(e,t){let n=[...e];for(let e=0,r=8;e<6;e++,r/=2){let e=e=>e>0&&e<n.length-1&&vi([pi(n[e-1],n[e]),..._i(pi(n[e-1],n[e]),n[e],pi(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>Ci(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Ai(t,n[i-1],r),t,Ai(t,n[i+1],r)]:[t])}return n}function Mi(e,t){return ki(ji(Oi(e,t),t))}function Ni(e){let t=[...e.boxes,...e.labels,...e.routes.flatMap(e=>e.points.map(([e,t])=>({x:e,y:t,width:0,height:0})))];if(t.length===0)return{x:0,y:0,width:0,height:0};let n=Math.min(...t.map(e=>e.x)),r=Math.min(...t.map(e=>e.y));return{x:n,y:r,width:Math.max(...t.map(e=>e.x+e.width))-n,height:Math.max(...t.map(e=>e.y+e.height))-r}}function Pi(e,t,n,r=[]){let i=Ni({boxes:e,routes:t,labels:r});return{width:Math.max(0,i.x+i.width)+n,height:Math.max(0,i.y+i.height)+n}}function Fi(e,t=!0){let n=new Ee.Graph({multigraph:!0});n.setGraph({rankdir:`TB`,nodesep:e.nodesep,ranksep:e.ranksep,marginx:e.margin,marginy:e.margin});for(let t of e.nodes)n.setNode(t.id,{width:t.width,height:t.height});for(let t of e.edges)n.setEdge(t.source,t.target,{weight:t.weight},t.id);Ar(n);let r=e.nodes.map(e=>{let{x:t,y:r}=n.node(e.id);return{id:e.id,parent:null,x:di(t-e.width/2),y:di(r-e.height/2),width:e.width,height:e.height,kind:e.kind}}),i=e.edges.map(({weight:e,...i})=>{let a=n.edge(i.source,i.target,i.id).points.map(({x:e,y:t})=>[di(e),di(t)]),o=r.filter(e=>e.id!==i.source&&e.id!==i.target);return{...i,points:t?Mi(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Pi(r,i,e.margin)}}var Ii=`text{font-family:system-ui,sans-serif;font-size:12px;fill:#1F2328}.box{fill:#F2F4F7;stroke:#D3D9E0}.frame{fill:#FFFFFF;stroke:#D3D9E0}.external{fill:#FFFFFF;stroke:#D3D9E0;stroke-dasharray:6 4}.member{fill:#FFFFFF;stroke:#D3D9E0}.writer{fill:#E4F2EA;stroke:#1F8A5B}.reader{fill:#FFFFFF;stroke:#8C96A3;stroke-dasharray:4 3}.point{fill:#E8EFFB;stroke:#2D5BB8}.title{font-size:13px;font-weight:600}.detail{fill:#5B6573}.route{fill:none;stroke:#5B6573}.route.dashed{stroke-dasharray:6 4}.label-box{fill:#FFFFFF}.label{font-family:ui-monospace,monospace;font-size:11px;fill:#1F2328}`,Li={band:`.band{fill:none;stroke:none}`,selected:`.selected{stroke:#F08A3C;stroke-width:2}`,lifeline:`.lifeline{fill:#8C96A3;stroke:none}`,fragment:`.fragment{stroke-dasharray:5 4}`,terminal:`.terminal{fill:#FFFFFF}`,success:`.fragment.success{fill:#EDF7F0;stroke:#2C6A3D}.terminal.success{stroke:#2C6A3D}`,error:`.fragment.error{fill:#FBEFEF;stroke:#B42318}.terminal.error{stroke:#B42318}`},Ri=e=>e.replace(/[&<>"]/gu,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`})[e]);function zi(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${Ri(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${Ri(t)}</text>`).join(``)}function Bi(e,t){let{width:n,height:r}=e.extent,i=[];for(let[n,r]of e.boxes.entries())i.push(`<clipPath id="clip-${n}"><rect x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/></clipPath>`,`<rect class="${r.kind}" x="${r.x}" y="${r.y}" width="${r.width}" height="${r.height}" rx="10"/>`,`<g clip-path="url(#clip-${n})">${zi(r,t(r))}</g>`);for(let t of e.routes){let e=`${t.arrows.start?` marker-start="url(#arrow)"`:``}${t.arrows.end?` marker-end="url(#arrow)"`:``}`;i.push(`<path class="route${t.dashed?` dashed`:``}" stroke-width="${t.width}" d="${hi(t.points)}"${e}/>`)}for(let t of e.labels)i.push(`<rect class="label-box" x="${t.x}" y="${t.y}" width="${t.width}" height="${t.height}" rx="3"/>`,`<text class="label" x="${t.x+t.width/2}" y="${t.y+12}" text-anchor="middle">${Ri(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries(Li).filter(([e])=>a.has(e)).map(([,e])=>e).join(``);return[`<svg xmlns="http://www.w3.org/2000/svg" width="${n}" height="${r}" viewBox="0 0 ${n} ${r}">`,`<style>${Ii}${o}</style>`,`<defs><marker id="arrow" viewBox="0 0 8 8" refX="7" refY="4" markerWidth="8" markerHeight="8" orient="auto-start-reverse"><path d="M0 0L8 4L0 8z" fill="#5B6573"/></marker></defs>`,`<rect width="${n}" height="${r}" fill="#FFFFFF"/>`,...i,`</svg>`].join(`
2
+ `)}var Vi=12,Hi=12,Ui=24,Wi=64,Gi=24,Ki=`removed`,qi=new Set([`spawns`,`runs-in`,`deployed-on`,`mounts`,`reads`,`writes`,`publishes`,`subscribes`]);function Ji(e,t){let n=Math.ceil(Math.sqrt(e.length)),r=Math.ceil(e.length/n),i=Array.from({length:n},(t,r)=>Math.max(0,...e.filter((e,t)=>t%n===r).map(e=>e.width))),a=Array.from({length:r},(t,r)=>Math.max(0,...e.slice(r*n,(r+1)*n).map(e=>e.height))),o=(e,n)=>e.slice(0,n).reduce((e,n)=>e+n+t,0);return{cells:e.map((e,t)=>({x:o(i,t%n),y:o(a,Math.floor(t/n))})),width:i.reduce((e,t)=>e+t,0)+(n-1)*t,height:a.reduce((e,t)=>e+t,0)+(r-1)*t}}function Yi(e){let t=new Map;for(let n of e.nodes)n.parent!==null&&t.set(n.parent,[...t.get(n.parent)??[],n]);let n=new Map,r=new Map,i=e=>{let a=r.get(e);if(a)return a;let o=t.get(e),s={width:160,height:48};if(o){let e=Ji(o.map(e=>i(e.id)),Hi);o.forEach((t,r)=>n.set(t.id,{x:Vi+e.cells[r].x,y:36+e.cells[r].y})),s={width:Math.max(160,e.width)+24,height:36+e.height+Vi}}return r.set(e,s),s},a=new Map(e.nodes.map(e=>[e.id,e.parent])),o=e=>{let t=e;for(;a.get(t);)t=a.get(t);return t},s=new Map;for(let t of e.relations){let[e,n]=[o(t.source),o(t.target)];if(e===n)continue;let r=`${t.kind}:${e}->${n}`;s.has(r)||s.set(r,{source:e,target:n,kind:t.kind,relations:[]}),s.get(r).relations.push(t.id)}let c=e.nodes.filter(e=>e.parent===null),l=new Set([...s.values()].flatMap(e=>[e.source,e.target])),u=e=>t.has(e)?`frame`:`box`,d=Fi({nodes:c.filter(e=>l.has(e.id)).map(e=>({id:e.id,kind:u(e.id),...i(e.id)})),edges:[...s].map(([e,t])=>({id:e,source:t.source,target:t.target,kind:t.kind,arrows:{start:!1,end:!0},dashed:t.kind===Ki,width:t.kind===`relation`?1.5:2,weight:t.relations.length})),nodesep:Ui,ranksep:Wi,margin:Gi}),f=c.filter(e=>!l.has(e.id)),p=d.boxes.length===0?Gi:Math.max(...d.boxes.map(e=>e.y+e.height))+Wi,m=f.map(e=>i(e.id)),h=Ji(m,Ui).cells.map((e,t)=>({id:f[t].id,parent:null,x:Gi+e.x,y:p+e.y,...m[t],kind:u(f[t].id)})),g=new Map([...d.boxes,...h].map(e=>[e.id,e])),_=[],v=(e,r)=>{let a=n.get(e.id),o=r===null?g.get(e.id):{id:e.id,parent:r.id,x:r.x+a.x,y:r.y+a.y,...i(e.id),kind:u(e.id)};_.push(o);for(let n of t.get(e.id)??[])v(n,o)};for(let e of c)v(e,null);let y=d.routes;return{scene:{boxes:_,routes:y,labels:[],extent:Pi(_,y,Gi)},relations:new Map([...s].map(([e,t])=>[e,t.relations]))}}var W=i();function Xi(e){if(typeof e==`string`||typeof e==`number`)return``+e;let t=``;if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Xi(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var Zi={error001:(e=`react`)=>`Seems like you have not used ${e===`svelte`?`SvelteFlowProvider`:`ReactFlowProvider`} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>`It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.`,error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>`The parent container needs a width and a height to render the graph.`,error005:()=>`Only child nodes can use a parent extent.`,error006:()=>`Can't create edge. An edge needs a source and a target.`,error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e===`source`?n:r}", edge id: ${t}.`,error010:()=>`Handle: No node id found. Make sure to only use a Handle inside a custom Node.`,error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e=`react`)=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>`useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.`,error015:()=>`It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.`,error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Qi=[[-1/0,-1/0],[1/0,1/0]],$i=[`Enter`,` `,`Escape`],ea={"node.a11yDescription.default":`Press enter or space to select a node. Press delete to remove it and escape to cancel.`,"node.a11yDescription.keyboardDisabled":`Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.`,"node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":`Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.`,"controls.ariaLabel":`Control Panel`,"controls.zoomIn.ariaLabel":`Zoom In`,"controls.zoomOut.ariaLabel":`Zoom Out`,"controls.fitView.ariaLabel":`Fit View`,"controls.interactive.ariaLabel":`Toggle Interactivity`,"minimap.ariaLabel":`Mini Map`,"handle.ariaLabel":`Handle`},ta;(function(e){e.Strict=`strict`,e.Loose=`loose`})(ta||={});var na;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(na||={});var ra;(function(e){e.Partial=`partial`,e.Full=`full`})(ra||={});var ia={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},aa;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(aa||={});var oa;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(oa||={});var G;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(G||={});var sa={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},ca=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,la=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),ua=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),da=(e,t=[0,0])=>{let{width:n,height:r}=Ga(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},fa=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};let n=!1,r=e.reduce((e,r)=>{let i=typeof r==`string`,a=!t.nodeLookup&&!i?r:void 0;return t.nodeLookup&&(a=i?t.nodeLookup.get(r):ua(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ta(e,ka(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Da(r):{x:0,y:0,width:0,height:0}},pa=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(e=>{(t.filter===void 0||t.filter(e))&&(n=Ta(n,ka(e)),r=!0)}),r?Da(n):{x:0,y:0,width:0,height:0}},ma=(e,t,[n,r,i]=[0,0,1],a=!1,o=!1)=>{let s=(t.x-n)/i,c=(t.y-r)/i,l=t.width/i,u=t.height/i,d=[];for(let t of e.values()){let{measured:e,selectable:n=!0,hidden:r=!1}=t;if(o&&!n||r)continue;let i=e.width??t.width??t.initialWidth??0,f=e.height??t.height??t.initialHeight??0,{x:p,y:m}=t.internals.positionAbsolute,h=ja(s,c,l,u,p,m,i,f),g=i*f,_=a&&h>0;(!t.internals.handleBounds||_||h>=g||t.dragging)&&d.push(t)}return d},ha=(e,t)=>{let n=new Set;return e.forEach(e=>{n.add(e.id)}),t.filter(e=>n.has(e.source)||n.has(e.target))};function ga(e,t){let n=new Map,r=t?.nodes?new Set(t.nodes.map(e=>e.id)):null;return e.forEach(e=>{let i;if(t?.includeHiddenNodes){let{width:t,height:n}=Ga(e);i=t>0&&n>0}else i=!!(e.measured.width&&e.measured.height&&!e.hidden);i&&(!r||r.has(e.id))&&n.set(e.id,e)}),n}async function _a({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=Ha(pa(ga(e,o)),t,n,o?.minZoom??i,o?.maxZoom??a,o?.padding??.1);return await r.setViewport(s,{duration:o?.duration,ease:o?.ease,interpolate:o?.interpolate}),!0}function va({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:a}){let o=n.get(e),s=o.parentId?n.get(o.parentId):void 0,{x:c,y:l}=s?s.internals.positionAbsolute:{x:0,y:0},u=o.origin??r,d=o.extent||i;if(o.extent===`parent`&&!o.expandParent){if(!s)a?.(`005`,Zi.error005());else{let{width:e,height:t}=Ga(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&Wa(o.extent)&&(d=[[o.extent[0][0]+c,o.extent[0][1]+l],[o.extent[1][0]+c,o.extent[1][1]+l]]);let f=Wa(d)?xa(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,Zi.error015()),{position:{x:f.x-c+(o.measured.width??0)*u[0],y:f.y-l+(o.measured.height??0)*u[1]},positionAbsolute:f}}async function ya({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){let a=new Set(e.map(e=>e.id)),o=[];for(let e of n){if(e.deletable===!1)continue;let t=a.has(e.id),n=!t&&e.parentId&&o.find(t=>t.id===e.parentId);(t||n)&&o.push(e)}let s=new Set(t.map(e=>e.id)),c=r.filter(e=>e.deletable!==!1),l=ha(o,c);for(let e of c)s.has(e.id)&&!l.find(t=>t.id===e.id)&&l.push(e);if(!i)return{edges:l,nodes:o};let u=await i({nodes:o,edges:l});return typeof u==`boolean`?u?{edges:l,nodes:o}:{edges:[],nodes:[]}:u}var ba=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),xa=(e={x:0,y:0},t,n)=>({x:ba(e.x,t[0][0],t[1][0]-(n?.width??0)),y:ba(e.y,t[0][1],t[1][1]-(n?.height??0))});function Sa(e,t,n){let{width:r,height:i}=Ga(n),{x:a,y:o}=n.internals.positionAbsolute;return xa(e,[[a,o],[a+r,o+i]],t)}var Ca=(e,t,n)=>e<t?ba(Math.abs(e-t),1,t)/t:e>n?-ba(Math.abs(e-n),1,t)/t:0,wa=(e,t,n=15,r=40)=>[Ca(e.x,r,t.width-r)*n,Ca(e.y,r,t.height-r)*n],Ta=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Ea=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Da=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Oa=(e,t=[0,0])=>{let{x:n,y:r}=ua(e)?e.internals.positionAbsolute:da(e,t);return{x:n,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ka=(e,t=[0,0])=>{let{x:n,y:r}=ua(e)?e.internals.positionAbsolute:da(e,t);return{x:n,y:r,x2:n+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},Aa=(e,t)=>Da(Ta(Ea(e),Ea(t))),ja=(e,t,n,r,i,a,o,s)=>{let c=Math.max(0,Math.min(e+n,i+o)-Math.max(e,i)),l=Math.max(0,Math.min(t+r,a+s)-Math.max(t,a));return Math.ceil(c*l)},Ma=(e,t)=>ja(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Na=e=>Pa(e.width)&&Pa(e.height)&&Pa(e.x)&&Pa(e.y),Pa=e=>!isNaN(e)&&isFinite(e),Fa=(e,t)=>(e,t)=>{},Ia=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),La=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Ia(s,o):s},Ra=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function za(e,t){if(typeof e==`number`)return Math.floor((t-t/(1+e))*.5);if(typeof e==`string`&&e.endsWith(`px`)){let t=parseFloat(e);if(!Number.isNaN(t))return Math.floor(t)}if(typeof e==`string`&&e.endsWith(`%`)){let n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Ba(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=za(e,n),i=za(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=za(e.top??e.y??0,n),i=za(e.bottom??e.y??0,n),a=za(e.left??e.x??0,t),o=za(e.right??e.x??0,t);return{top:r,right:o,bottom:i,left:a,x:a+o,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Va(e,t,n,r,i,a){let{x:o,y:s}=Ra(e,[t,n,r]),{x:c,y:l}=Ra({x:e.x+e.width,y:e.y+e.height},[t,n,r]),u=i-c,d=a-l;return{left:Math.floor(o),top:Math.floor(s),right:Math.floor(u),bottom:Math.floor(d)}}var Ha=(e,t,n,r,i,a)=>{let o=Ba(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=ba(Math.min(s,c),r,i),u=e.x+e.width/2,d=e.y+e.height/2,f=t/2-u*l,p=n/2-d*l,m=Va(e,f,p,l,t,n),h={left:Math.min(m.left-o.left,0),top:Math.min(m.top-o.top,0),right:Math.min(m.right-o.right,0),bottom:Math.min(m.bottom-o.bottom,0)};return{x:f-h.left+h.right,y:p-h.top+h.bottom,zoom:l}},Ua=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function Wa(e){return e!=null&&e!==`parent`}function Ga(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function Ka(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function qa(e,t={width:0,height:0},n,r,i){let a={...e},o=r.get(n);if(o){let e=o.origin||i;a.x+=o.internals.positionAbsolute.x-(t.width??0)*e[0],a.y+=o.internals.positionAbsolute.y-(t.height??0)*e[1]}return a}function Ja(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function Ya(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function Xa(e){return{...ea,...e||{}}}function Za(e){return e===null?null:e?`valid`:`invalid`}function Qa(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=io(e),s=La({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Ia(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var $a=e=>({width:e.offsetWidth,height:e.offsetHeight}),eo=e=>e?.getRootNode?.()||window?.document,to=[`INPUT`,`SELECT`,`TEXTAREA`];function no(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?to.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var ro=e=>`clientX`in e,io=(e,t)=>{let n=ro(e),r=n?e.clientX:e.touches?.[0].clientX,i=n?e.clientY:e.touches?.[0].clientY;return{x:r-(t?.left??0),y:i-(t?.top??0)}},ao=(e,t,n,r,i)=>{let a=t.querySelectorAll(`.${e}`);return!a||!a.length?null:Array.from(a).map(t=>{let a=t.getBoundingClientRect();return{id:t.getAttribute(`data-handleid`),type:e,nodeId:i,position:t.getAttribute(`data-handlepos`),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...$a(t)}})};function oo({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:a,targetControlX:o,targetControlY:s}){let c=e*.125+i*.375+o*.375+n*.125,l=t*.125+a*.375+s*.375+r*.125;return[c,l,Math.abs(c-e),Math.abs(l-t)]}function so(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function co({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case G.Left:return[t-so(t-r,a),n];case G.Right:return[t+so(r-t,a),n];case G.Top:return[t,n-so(n-i,a)];case G.Bottom:return[t,n+so(i-n,a)]}}function lo({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top,curvature:o=.25}){let[s,c]=co({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=co({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=oo({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:c,targetControlX:l,targetControlY:u});return[`M${e},${t} C${s},${c} ${l},${u} ${r},${i}`,d,f,p,m]}function uo({sourceX:e,sourceY:t,targetX:n,targetY:r}){let i=Math.abs(n-e)/2,a=n<e?n+i:n-i,o=Math.abs(r-t)/2;return[a,r<t?r+o:r-o,i,o]}function fo({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:a=`basic`}){return a===`manual`?r:(i&&n?r+1e3:r)+Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0)}function po({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ta(ka(e),ka(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Ma({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Da(a))>0}var mo=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,ho=(e,t)=>t.some(t=>t.source===e.source&&t.target===e.target&&(t.sourceHandle===e.sourceHandle||!t.sourceHandle&&!e.sourceHandle)&&(t.targetHandle===e.targetHandle||!t.targetHandle&&!e.targetHandle)),go=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,Zi.error006()),t;let r=n.getEdgeId||mo,i;return i=ca(e)?{...e}:{...e,id:r(e)},ho(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function _o({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=uo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var vo={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},yo=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},bo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),xo=(e,t,n)=>e.x===t.x&&t.x===n.x&&(t.y-e.y)*(n.y-t.y)>=0||e.y===t.y&&t.y===n.y&&(t.x-e.x)*(n.x-t.x)>=0;function So({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:r=G.Top,center:i,offset:a,stepPosition:o}){let s=vo[t],c=vo[r],l={x:e.x+s.x*a,y:e.y+s.y*a},u={x:n.x+c.x*a,y:n.y+c.y*a},d=yo({source:l,sourcePosition:t,target:u}),f=d.x===0?`y`:`x`,p=d[f],m=[],h,g,_={x:0,y:0},v={x:0,y:0},[,,y,b]=uo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(s[f]*c[f]===-1){f===`x`?(h=i.x??l.x+(u.x-l.x)*o,g=i.y??(l.y+u.y)/2):(h=i.x??(l.x+u.x)/2,g=i.y??l.y+(u.y-l.y)*o);let e=[{x:h,y:l.y},{x:h,y:u.y}],t=[{x:l.x,y:g},{x:u.x,y:g}];m=s[f]===p?f===`x`?e:t:f===`x`?t:e}else{let i=[{x:l.x,y:u.y}],o=[{x:u.x,y:l.y}];if(m=f===`x`?s.x===p?o:i:s.y===p?i:o,t===r){let t=Math.abs(e[f]-n[f]);if(t<=a){let r=Math.min(a-1,a-t);s[f]===p?_[f]=(l[f]>e[f]?-1:1)*r:v[f]=(u[f]>n[f]?-1:1)*r}}if(t!==r){let e=f===`x`?`y`:`x`,t=s[f]===c[e],n=l[e]>u[e],r=l[e]<u[e];(s[f]===1&&(!t&&n||t&&r)||s[f]!==1&&(!t&&r||t&&n))&&(m=f===`x`?i:o)}let d={x:l.x+_.x,y:l.y+_.y},y={x:u.x+v.x,y:u.y+v.y};Math.max(Math.abs(d.x-m[0].x),Math.abs(y.x-m[0].x))>=Math.max(Math.abs(d.y-m[0].y),Math.abs(y.y-m[0].y))?(h=(d.x+y.x)/2,g=m[0].y):(h=m[0].x,g=(d.y+y.y)/2)}let x={x:l.x+_.x,y:l.y+_.y},S={x:u.x+v.x,y:u.y+v.y},C=[];for(let t of[e,x,...m,S,n]){let[e,n]=C.slice(-2);n&&xo(e,n,t)&&C.pop(),C.push(t)}return[C,h,g,y,b]}function Co(e,t,n,r){let i=Math.min(bo(e,t)/2,bo(t,n)/2,r),{x:a,y:o}=t;if(e.x===a&&a===n.x||e.y===o&&o===n.y)return`L${a} ${o}`;if(e.y===o){let t=e.x<n.x?-1:1,r=e.y<n.y?1:-1;return`L ${a+i*t},${o}Q ${a},${o} ${a},${o+i*r}`}let s=e.x<n.x?1:-1;return`L ${a},${o+i*(e.y<n.y?-1:1)}Q ${a},${o} ${a+i*s},${o}`}function wo({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=So({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:a,center:{x:s,y:c},offset:l,stepPosition:u}),g=`M${d[0].x} ${d[0].y}`;for(let e=1;e<d.length-1;e++)g+=Co(d[e-1],d[e],d[e+1],o);return g+=`L${d[d.length-1].x} ${d[d.length-1].y}`,[g,f,p,m,h]}function To(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Eo(e){let{sourceNode:t,targetNode:n}=e;if(!To(t)||!To(n))return null;let r=t.internals.handleBounds||Do(t.handles),i=n.internals.handleBounds||Do(n.handles),a=ko(r?.source??[],e.sourceHandle),o=ko(e.connectionMode===ta.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,Zi.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||G.Bottom,c=o?.position||G.Top,l=Oo(t,a,s),u=Oo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Do(e){if(!e)return null;let t=[],n=[];for(let r of e)r.width=r.width??1,r.height=r.height??1,r.type===`source`?t.push(r):r.type===`target`&&n.push(r);return{source:t,target:n}}function Oo(e,t,n=G.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??Ga(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case G.Top:return{x:i+o/2,y:a};case G.Right:return{x:i+o,y:a+s/2};case G.Bottom:return{x:i+o/2,y:a+s};case G.Left:return{x:i,y:a+s/2}}}function ko(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Ao(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function jo(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){let a=new Set;return e.reduce((e,o)=>([o.markerStart||r,o.markerEnd||i].forEach(r=>{if(r&&typeof r==`object`){let i=Ao(r,t);a.has(i)||(e.push({id:i,color:r.color||n,...r}),a.add(i))}}),e),[]).sort((e,t)=>e.id.localeCompare(t.id))}var Mo=1e3,No=10,Po={nodeOrigin:[0,0],nodeExtent:Qi,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Fo={...Po,checkEquality:!0};function Io(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Lo(e,t,n){let r=Io(Po,n);for(let n of e.values())if(n.parentId)Ho(n,e,t,r);else{let e=xa(da(n,r.nodeOrigin),Wa(n.extent)?n.extent:r.nodeExtent,Ga(n));n.internals.positionAbsolute=e}}function Ro(e,t){if(!e.handles)return e.measured?t?.internals.handleBounds:void 0;let n=[],r=[];for(let t of e.handles){let i={id:t.id,width:t.width??1,height:t.height??1,nodeId:e.id,x:t.x,y:t.y,position:t.position,type:t.type};t.type===`source`?n.push(i):t.type===`target`&&r.push(i)}return{source:n,target:r}}function zo(e){return e===`manual`}function Bo(e,t,n,r={}){let i=Io(Fo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!zo(i.zIndexMode)?Mo:0,c=e.length>0,l=!1;t.clear(),n.clear();for(let u of e){let e=o.get(u.id);if(i.checkEquality&&u===e?.internals.userNode)t.set(u.id,e);else{let n=xa(da(u,i.nodeOrigin),Wa(u.extent)?u.extent:i.nodeExtent,Ga(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Ro(u,e),z:Uo(u,s,i.zIndexMode),userNode:u}},t.set(u.id,e)}e.measured!==void 0&&e.measured.width!==void 0&&e.measured.height!==void 0||e.hidden||(c=!1),u.parentId&&Ho(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function Vo(e,t){if(!e.parentId)return;let n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Ho(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Io(Po,r),l=e.parentId,u=t.get(l);if(!u){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Vo(e,n),i&&!u.parentId&&u.internals.rootParentIndex===void 0&&c===`auto`&&(u.internals.rootParentIndex=++i.i,u.internals.z=u.internals.z+i.i*No),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=Wo(e,u,o,s,a&&!zo(c)?Mo:0,c),{positionAbsolute:m}=e.internals,h=d!==m.x||f!==m.y;(h||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:h?{x:d,y:f}:m,z:p}})}function Uo(e,t,n){let r=Pa(e.zIndex)?e.zIndex:0;return zo(n)?r:r+(e.selected?t:0)}function Wo(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=Ga(e),l=da(e,n),u=Wa(e.extent)?xa(l,e.extent,c):l,d=xa({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Sa(d,c,t));let f=Uo(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function Go(e,t,n,r=[0,0]){let i=[],a=new Map;for(let n of e){let e=t.get(n.parentId);if(!e)continue;let r=Aa(a.get(n.parentId)?.expandedRect??Oa(e),n.rect);a.set(n.parentId,{expandedRect:r,parent:e})}return a.size>0&&a.forEach(({expandedRect:t,parent:a},o)=>{let s=a.internals.positionAbsolute,c=Ga(a),l=a.origin??r,u=t.x<s.x?Math.round(Math.abs(s.x-t.x)):0,d=t.y<s.y?Math.round(Math.abs(s.y-t.y)):0,f=Math.max(c.width,Math.round(t.width)),p=Math.max(c.height,Math.round(t.height)),m=(f-c.width)*l[0],h=(p-c.height)*l[1];(u>0||d>0||m||h)&&(i.push({id:o,type:`position`,position:{x:a.position.x-u+m,y:a.position.y-d+h}}),n.get(o)?.forEach(t=>{e.some(e=>e.id===t.id)||i.push({id:t.id,type:`position`,position:{x:t.position.x+u,y:t.position.y+d}})})),(c.width<t.width||c.height<t.height||u||d)&&i.push({id:o,type:`dimensions`,setAttributes:!0,dimensions:{width:f+(u?l[0]*u-m:0),height:p+(d?l[1]*d-h:0)}})}),i}function Ko(e,t,n,r,i,a,o){let s=r?.querySelector(`.xyflow__viewport`),c=!1;if(!s)return{changes:[],updatedInternals:c};let l=[],u=window.getComputedStyle(s),{m22:d}=new window.DOMMatrixReadOnly(u.transform),f=[];for(let r of e.values()){let e=t.get(r.id);if(!e)continue;if(e.hidden){t.set(e.id,{...e,internals:{...e.internals,handleBounds:void 0}}),c=!0;continue}let s=$a(r.nodeElement),u=e.measured.width!==s.width||e.measured.height!==s.height;if(s.width&&s.height&&(u||!e.internals.handleBounds||r.force)){let p=r.nodeElement.getBoundingClientRect(),m=Wa(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Sa(h,s,n))}else m&&(h=xa(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:ao(`source`,r.nodeElement,p,d,e.id),target:ao(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&Ho(g,t,n,{nodeOrigin:i,zIndexMode:o}),c=!0,u&&(l.push({id:e.id,type:`dimensions`,dimensions:s}),e.expandParent&&e.parentId&&f.push({id:e.id,parentId:e.parentId,rect:Oa(g,i)}))}}if(f.length>0){let e=Go(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function qo({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:a}){if(!t||!e.x&&!e.y)return!1;let o=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,a]],r);return!!o&&(o.x!==n[0]||o.y!==n[1]||o.k!==n[2])}function Jo(e,t,n,r,i,a){let o=i,s=r.get(o)||new Map;r.set(o,s.set(n,t)),o=`${i}-${e}`;let c=r.get(o)||new Map;if(r.set(o,c.set(n,t)),a){o=`${i}-${e}-${a}`;let s=r.get(o)||new Map;r.set(o,s.set(n,t))}}function Yo(e,t,n){e.clear(),t.clear();for(let r of n){let{source:n,target:i,sourceHandle:a=null,targetHandle:o=null}=r,s={edgeId:r.id,source:n,target:i,sourceHandle:a,targetHandle:o},c=`${n}-${a}--${i}-${o}`;Jo(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),Jo(`target`,s,c,e,i,o),t.set(r.id,r)}}function Xo(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:Xo(n,t):!1}function Zo(e,t,n){let r=e;do{if(r?.matches?.(t))return!0;if(r===n)return!1;r=r?.parentElement}while(r);return!1}function Qo(e,t,n,r,i){let a=new Map;for(let[o,s]of e)if((i?s.id===r:s.selected||s.id===r)&&(i||!s.parentId||!Xo(s,e))&&(s.draggable||t&&s.draggable===void 0)){let t=e.get(o);t&&a.set(o,{id:o,position:t.position||{x:0,y:0},distance:{x:n.x-t.internals.positionAbsolute.x,y:n.y-t.internals.positionAbsolute.y},extent:t.extent,parentId:t.parentId,origin:t.origin,expandParent:t.expandParent,internals:{positionAbsolute:t.internals.positionAbsolute||{x:0,y:0}},measured:{width:t.measured.width??0,height:t.measured.height??0}})}return a}function $o({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){let i=[];for(let[e,a]of t){let t=n.get(e)?.internals.userNode;t&&i.push({...t,position:a.position,dragging:r})}if(!e)return[i[0],i];let a=n.get(e)?.internals.userNode;return[a?{...a,position:t.get(e)?.position||a.position,dragging:r}:i[0],i]}function es({dragItems:e,snapGrid:t,x:n,y:r}){let i=e.values().next().value;if(!i)return null;let a={x:n-i.distance.x,y:r-i.distance.y},o=Ia(a,t);return{x:o.x-a.x,y:o.y-a.y}}function ts({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let a={x:null,y:null},o=0,s=new Map,c=!1,l={x:0,y:0},u=null,d=!1,f=null,p=!1,m=!1,h=null;function g({noDragClassName:g,handleSelector:_,domNode:v,isSelectable:y,nodeId:b,nodeClickDistance:x=0}){f=E(v);function S({x:e,y:n}){let{nodeLookup:i,nodeExtent:o,snapGrid:c,snapToGrid:l,nodeOrigin:u,onNodeDrag:d,onSelectionDrag:f,onError:p,updateNodePositions:g}=t();a={x:e,y:n};let _=!1,v=s.size>1,y=v&&o?Ea(pa(s)):null,x=v&&l?es({dragItems:s,snapGrid:c,x:e,y:n}):null;for(let[t,r]of s){if(!i.has(t))continue;let a={x:e-r.distance.x,y:n-r.distance.y};l&&(a=x?{x:Math.round(a.x+x.x),y:Math.round(a.y+x.y)}:Ia(a,c));let s=null;if(v&&o&&!r.extent&&y){let{positionAbsolute:e}=r.internals,t=e.x-y.x+o[0][0],n=e.x+r.measured.width-y.x2+o[1][0],i=e.y-y.y+o[0][1],a=e.y+r.measured.height-y.y2+o[1][1];s=[[t,i],[n,a]]}let{position:d,positionAbsolute:f}=va({nodeId:t,nextPosition:a,nodeLookup:i,nodeExtent:s||o,nodeOrigin:u,onError:p});_=_||r.position.x!==d.x||r.position.y!==d.y,r.position=d,r.internals.positionAbsolute=f}if(m||=_,_&&(g(s,!0),h&&(r||d||!b&&f))){let[e,t]=$o({nodeId:b,dragItems:s,nodeLookup:i});r?.(h,s,e,t),d?.(h,e,t),b||f?.(h,t)}}async function C(){if(!u)return;let{transform:e,panBy:n,autoPanSpeed:r,autoPanOnNodeDrag:i}=t();if(!i){c=!1,cancelAnimationFrame(o);return}let[s,d]=wa(l,u,r);(s!==0||d!==0)&&(a.x=(a.x??0)-s/e[2],a.y=(a.y??0)-d/e[2],await n({x:s,y:d})&&S(a)),o=requestAnimationFrame(C)}function w(r){let{nodeLookup:i,multiSelectionActive:o,nodesDraggable:c,transform:l,snapGrid:f,snapToGrid:p,selectNodesOnDrag:m,onNodeDragStart:h,onSelectionDragStart:g,unselectNodesAndEdges:_}=t();d=!0;let v=!!b&&!o&&!i.get(b)?.selected;m&&y||o||!b||i.get(b)?.selected||_(),y&&m&&b&&e?.(b);let x=Qa(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=x,s=Qo(i,c,x,b,v),s.size>0&&(n||h||!b&&g)){let[e,t]=$o({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=ee().clickDistance(x).on(`start`,e=>{let{domNode:n,nodeDragThreshold:r,transform:i,snapGrid:o,snapToGrid:s}=t();u=n?.getBoundingClientRect()||null,p=!1,m=!1,h=e.sourceEvent,r===0&&w(e),a=Qa(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=io(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=Qa(e.sourceEvent,{transform:r,snapGrid:i,snapToGrid:o,containerBounds:u});if(h=e.sourceEvent,(e.sourceEvent.type===`touchmove`&&e.sourceEvent.touches.length>1||b&&!m.has(b))&&(p=!0),!p){if(!c&&n&&d&&(c=!0,C()),!d){let t=io(e.sourceEvent,u),n=t.x-l.x,r=t.y-l.y;Math.sqrt(n*n+r*r)>f&&w(e)}(a.x!==g.xSnapped||a.y!==g.ySnapped)&&s&&d&&(l=io(e.sourceEvent,u),S(g))}}).on(`end`,e=>{if(!d||p)p&&s.size>0&&t().updateNodePositions(s,!1);else if(c=!1,d=!1,cancelAnimationFrame(o),s.size>0){let{nodeLookup:n,updateNodePositions:r,onNodeDragStop:a,onSelectionDragStop:o}=t();if(m&&=(r(s,!1),!1),i||a||!b&&o){let[t,r]=$o({nodeId:b,dragItems:s,nodeLookup:n,dragging:!1});i?.(e.sourceEvent,s,t,r),a?.(e.sourceEvent,t,r),b||o?.(e.sourceEvent,r)}}}).filter(e=>{let t=e.target;return!e.button&&(!g||!Zo(t,`.${g}`,v))&&(!_||Zo(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function ns(e,t,n){let r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(let e of t.values())Ma(i,Oa(e))>0&&r.push(e);return r}var rs=250;function is(e,t,n,r){let i=[],a=1/0,o=ns(e,n,t+rs);for(let n of o){let o=[...n.internals.handleBounds?.source??[],...n.internals.handleBounds?.target??[]];for(let s of o){if(r.nodeId===s.nodeId&&r.type===s.type&&r.id===s.id)continue;let{x:o,y:c}=Oo(n,s,s.position,!0),l=Math.sqrt((o-e.x)**2+(c-e.y)**2);l>t||(l<a?(i=[{...s,x:o,y:c}],a=l):l===a&&i.push({...s,x:o,y:c}))}}if(!i.length)return null;if(i.length>1){let e=r.type===`source`?`target`:`source`;return i.find(t=>t.type===e)??i[0]}return i[0]}function as(e,t,n,r,i,a=!1){let o=r.get(e);if(!o)return null;let s=i===`strict`?o.internals.handleBounds?.[t]:[...o.internals.handleBounds?.source??[],...o.internals.handleBounds?.target??[]],c=(n?s?.find(e=>e.id===n):s?.[0])??null;return c&&a?{...c,...Oo(o,c,c.position,!0)}:c}function os(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function ss(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var cs=()=>!0;function ls(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:a,isTarget:o,domNode:s,nodeLookup:c,lib:l,autoPanOnConnect:u,flowId:d,panBy:f,cancelConnection:p,onConnectStart:m,onConnect:h,onConnectEnd:g,isValidConnection:_=cs,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=eo(e.target),E=0,D,{x:O,y:k}=io(e),A=os(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=as(i,A,r,c,t);if(!N)return;let P=io(e,j),F=!1,ee=null,I=!1,te=null;function L(){if(!u||!j)return;let[e,t]=wa(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(L)}let R={...N,nodeId:i,type:A,position:N.position},z=c.get(i),B={inProgress:!0,isValid:null,from:Oo(z,R,G.Left,!0),fromHandle:R,fromPosition:R.position,fromNode:z,to:P,toHandle:null,toPosition:sa[R.position],toNode:null,pointer:P};function ne(){M=!0,y(B),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ne();function re(e){if(!M){let{x:t,y:n}=io(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ne()}if(!x()||!R){ie(e);return}let a=b();P=io(e,j),D=is(La(P,a,!1,[1,1]),n,c,R),F||=(L(),!0);let s=us(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});te=s.handleDomNode,ee=s.connection,I=ss(!!D,s.isValid);let u=c.get(i),f=u?Oo(u,R,G.Left,!0):B.from,p={...B,from:f,isValid:I,to:s.toHandle&&I?Ra({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:I&&s.toHandle?s.toHandle.position:sa[R.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),B=p}function ie(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||te)&&ee&&I&&h?.(ee);let{inProgress:t,...n}=B,r={...n,toPosition:B.toHandle?B.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,I=!1,ee=null,te=null,T.removeEventListener(`mousemove`,re),T.removeEventListener(`mouseup`,ie),T.removeEventListener(`touchmove`,re),T.removeEventListener(`touchend`,ie)}}T.addEventListener(`mousemove`,re),T.addEventListener(`mouseup`,ie),T.addEventListener(`touchmove`,re),T.addEventListener(`touchend`,ie)}function us(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=cs,nodeLookup:u}){let d=a===`target`,f=t?o.querySelector(`.${s}-flow__handle[data-id="${c}-${t?.nodeId}-${t?.id}-${t?.type}"]`):null,{x:p,y:m}=io(e),h=o.elementFromPoint(p,m),g=h?.classList.contains(`${s}-flow__handle`)?h:f,_={handleDomNode:g,isValid:!1,connection:null,toHandle:null};if(g){let e=os(void 0,g),t=g.getAttribute(`data-nodeid`),a=g.getAttribute(`data-handleid`),o=g.classList.contains(`connectable`),s=g.classList.contains(`connectableend`);if(!t||!e)return _;let c={source:d?t:r,sourceHandle:d?a:i,target:d?r:t,targetHandle:d?i:a};_.connection=c,_.isValid=o&&s&&(n===ta.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=as(t,e,a,u,n,!0)}return _}var ds={onPointerDown:ls,isValid:us};function fs({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=E(e);function a({translateExtent:e,width:a,height:o,zoomStep:s=1,pannable:c=!0,zoomable:l=!0,inversePan:u=!1}){let d=e=>{if(e.sourceEvent.type!==`wheel`||!t)return;let r=n(),i=e.sourceEvent.ctrlKey&&Ua()?10:1,a=-e.sourceEvent.deltaY*(e.sourceEvent.deltaMode===1?.05:e.sourceEvent.deltaMode?1:.002)*s,o=r[2]*2**(a*i);t.scaleTo(o)},f=[0,0],p=w().on(`start`,e=>{(e.sourceEvent.type===`mousedown`||e.sourceEvent.type===`touchstart`)&&(f=[e.sourceEvent.clientX??e.sourceEvent.touches[0].clientX,e.sourceEvent.clientY??e.sourceEvent.touches[0].clientY])}).on(`zoom`,c?i=>{let s=n();if(i.sourceEvent.type!==`mousemove`&&i.sourceEvent.type!==`touchmove`||!t)return;let c=[i.sourceEvent.clientX??i.sourceEvent.touches[0].clientX,i.sourceEvent.clientY??i.sourceEvent.touches[0].clientY],l=[c[0]-f[0],c[1]-f[1]];f=c;let d=r()*Math.max(s[2],Math.log(s[2]))*(u?-1:1),p={x:s[0]-l[0]*d,y:s[1]-l[1]*d},m=[[0,0],[a,o]];t.setViewportConstrained({x:p.x,y:p.y,zoom:s[2]},m,e)}:null).on(`zoom.wheel`,l?d:null);i.call(p,{})}function o(){i.on(`zoom`,null)}return{update:a,destroy:o,pointer:g}}var ps=e=>({x:e.x,y:e.y,zoom:e.k}),ms=({x:e,y:t,zoom:n})=>S.translate(e,t).scale(n),hs=(e,t)=>e.target.closest(`.${t}`),gs=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),_s=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,vs=(e,t=0,n=_s,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},ys=e=>{let t=e.ctrlKey&&Ua()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function bs({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(hs(u,t))return u.ctrlKey&&u.preventDefault(),!1;u.preventDefault(),u.stopImmediatePropagation();let d=n.property(`__zoom`).k||1;if(u.ctrlKey&&o){let e=g(u),t=d*2**ys(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===na.Vertical?0:u.deltaX*f,m=i===na.Horizontal?0:u.deltaY*f;!Ua()&&u.shiftKey&&i!==na.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=ps(n.property(`__zoom`));clearTimeout(e.panScrollTimeout),e.isPanScrolling?c?.(u,h):(e.isPanScrolling=!0,s?.(u,h)),e.panScrollTimeout=setTimeout(()=>{l?.(u,h),e.isPanScrolling=!1},150)}}function xs({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=hs(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ss({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=ps(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type===`mousedown`&&t(!0),n&&n?.(r.sourceEvent,i)}}function Cs({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&gs(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,ps(a.transform))}}function ws({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&gs(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=ps(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Ts({panActivationKeyPressed:e,zoomActivationKeyPressed:t,zoomOnScroll:n,zoomOnPinch:r,panOnDrag:i,panOnScroll:a,zoomOnDoubleClick:o,userSelectionActive:s,noWheelClassName:c,noPanClassName:l,lib:u,connectionInProgress:d}){return f=>{let p=t||n,m=r&&f.ctrlKey,h=f.type===`wheel`;if(f.button===1&&f.type===`mousedown`&&(hs(f,`${u}-flow__node`)||hs(f,`${u}-flow__edge`)||hs(f,`${u}-flow__selection`)||hs(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||hs(f,c)&&h||hs(f,l)&&(!h||a&&h&&!t)||!r&&f.ctrlKey&&h)return!1;if(!r&&f.type===`touchstart`&&f.touches?.length>1)return f.preventDefault(),!1;if(!p&&!a&&!m&&h||!i&&(f.type===`mousedown`||f.type===`touchstart`)||Array.isArray(i)&&!i.includes(f.button)&&f.type===`mousedown`)return!1;let g=Array.isArray(i)&&i.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||h||e)&&g}}function Es({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:a,onPanZoomStart:o,onPanZoomEnd:s,onDraggingChange:c}){let l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},u=e.getBoundingClientRect(),d=[[0,0],[u.width,u.height]],f=typeof ResizeObserver<`u`?new ResizeObserver(e=>{let t=e[0];t?.contentRect&&(d=[[0,0],[t.contentRect.width,t.contentRect.height]])}):null;f?.observe(e);let p=w().extent(()=>d).scaleExtent([t,n]).translateExtent(r),m=E(e).call(p);b({x:i.x,y:i.y,zoom:ba(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let h=m.on(`wheel.zoom`),g=m.on(`dblclick.zoom`);p.wheelDelta(ys);async function _(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?k:x).transform(vs(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function v({noWheelClassName:e,noPanClassName:t,onPaneContextMenu:n,userSelectionActive:r,panOnScroll:i,panOnDrag:u,panOnScrollMode:d,panOnScrollSpeed:f,preventScrolling:_,zoomOnPinch:v,zoomOnScroll:y,zoomOnDoubleClick:b,panActivationKeyPressed:x=!1,zoomActivationKeyPressed:S,lib:C,onTransformChange:w,connectionInProgress:T,paneClickDistance:E,selectionOnDrag:D}){r&&!l.isZoomingOrPanning&&p.on(`zoom`,null);let O=i&&!S&&!r;p.clickDistance(D?1/0:!Pa(E)||E<0?0:E);let k=O?bs({zoomPanValues:l,noWheelClassName:e,d3Selection:m,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):xs({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:h});m.on(`wheel.zoom`,k,{passive:!1});let A=Ss({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,A);let j=Cs({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});p.on(`zoom`,j);let M=ws({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,M);let N=Ts({panActivationKeyPressed:x,zoomActivationKeyPressed:S,panOnDrag:u,zoomOnScroll:y,panOnScroll:i,zoomOnDoubleClick:b,zoomOnPinch:v,userSelectionActive:r,noPanClassName:t,noWheelClassName:e,lib:C,connectionInProgress:T});p.filter(N),b?m.on(`dblclick.zoom`,g):m.on(`dblclick.zoom`,null)}function y(){p.on(`zoom`,null),f?.disconnect()}async function b(e,t,n){let r=ms(e),i=p?.constrain()(r,t,n);return i&&await _(i),i}async function S(e,t){let n=ms(e);return await _(n,t),n}function T(e){if(m){let t=ms(e),n=m.property(`__zoom`);(n.k!==e.zoom||n.x!==e.x||n.y!==e.y)&&p?.transform(m,t,null,{sync:!0})}}function D(){let e=m?C(m.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function O(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?k:x).scaleTo(vs(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function A(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?k:x).scaleBy(vs(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function j(e){p?.scaleExtent(e)}function M(e){p?.translateExtent(e)}function N(e){let t=!Pa(e)||e<0?0:e;p?.clickDistance(t)}return{update:v,destroy:y,setViewport:S,setViewportConstrained:b,getViewport:D,scaleTo:O,scaleBy:A,setScaleExtent:j,setTranslateExtent:M,syncViewport:T,setClickDistance:N}}var Ds;(function(e){e.Line=`line`,e.Handle=`handle`})(Ds||={});function Os({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:a}){let o=e-t,s=n-r,c=[o>0?1:o<0?-1:0,s>0?1:s<0?-1:0];return o&&i&&(c[0]*=-1),s&&a&&(c[1]*=-1),c}function ks(e){return{isHorizontal:e.includes(`right`)||e.includes(`left`),isVertical:e.includes(`bottom`)||e.includes(`top`),affectsX:e.includes(`left`),affectsY:e.includes(`top`)}}function As(e,t){return Math.max(0,t-e)}function js(e,t){return Math.max(0,e-t)}function Ms(e,t,n){return Math.max(0,t-e,e-n)}function Ns(e,t){return e?!t:t}function Ps(e,t,n,r,i,a,o,s){let{affectsX:c,affectsY:l}=t,{isHorizontal:u,isVertical:d}=t,f=u&&d,{xSnapped:p,ySnapped:m}=n,{minWidth:h,maxWidth:g,minHeight:_,maxHeight:v}=r,{x:y,y:b,width:x,height:S,aspectRatio:C}=e,w=Math.floor(u?p-e.pointerX:0),T=Math.floor(d?m-e.pointerY:0),E=x+(c?-w:w),D=S+(l?-T:T),O=-a[0]*x,k=-a[1]*S,A=Ms(E,h,g),j=Ms(D,_,v);if(o){let e=0,t=0;c&&w<0?e=As(y+w+O,o[0][0]):!c&&w>0&&(e=js(y+E+O,o[1][0])),l&&T<0?t=As(b+T+k,o[0][1]):!l&&T>0&&(t=js(b+D+k,o[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(s){let e=0,t=0;c&&w>0?e=js(y+w,s[0][0]):!c&&w<0&&(e=As(y+E,s[1][0])),l&&T>0?t=js(b+T,s[0][1]):!l&&T<0&&(t=As(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Ms(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?js(b+k+E/C,o[1][1])*C:As(b+k+(c?w:-w)/C,o[0][1])*C,A=Math.max(A,e)}if(s){let e=0;e=!c&&!l||c&&!l&&f?As(b+E/C,s[1][1])*C:js(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Ms(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?js(y+D*C+O,o[1][0])/C:As(y+(l?T:-T)*C+O,o[0][0])/C,j=Math.max(j,e)}if(s){let e=0;e=!c&&!l||l&&!c&&f?As(y+D*C,s[1][0])/C:js(y+(l?T:-T)*C,s[0][0])/C,j=Math.max(j,e)}}}T+=T<0?j:-j,w+=w<0?A:-A,i&&(f?E>D*C?T=(Ns(c,l)?-w:w)/C:w=(Ns(c,l)?-T:T)*C:u?(T=w/C,l=c):(w=T*C,c=l));let M=c?y+w:y,N=l?b+T:b;return{width:x+(c?-w:w),height:S+(l?-T:T),x:a[0]*w*(c?-1:1)+M,y:a[1]*T*(l?-1:1)+N}}var Fs={width:0,height:0,x:0,y:0},Is={...Fs,pointerX:0,pointerY:0,aspectRatio:1};function Ls(e,t,n){let r=t.position.x+e.position.x,i=t.position.y+e.position.y,a=e.measured.width??0,o=e.measured.height??0,s=n[0]*a,c=n[1]*o;return[[r-s,i-c],[r+a-s,i+o-c]]}function Rs({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=E(e),o={controlDirection:ks(`bottom-right`),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function s({controlPosition:e,boundaries:s,keepAspectRatio:c,resizeDirection:l,onResizeStart:u,onResize:d,onResizeEnd:f,shouldResize:p}){let m={...Fs},h={...Is};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:ks(e)};let g,_=null,v=[],y,b,x,S=ee().on(`start`,e=>{let{nodeLookup:r,transform:i,snapGrid:a,snapToGrid:o,nodeOrigin:s,paneDomNode:c}=n();if(g=r.get(t),!g)return;_=c?.getBoundingClientRect()??null;let{xSnapped:l,ySnapped:d}=Qa(e.sourceEvent,{transform:i,snapGrid:a,snapToGrid:o,containerBounds:_});m={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},h={...m,pointerX:l,pointerY:d,aspectRatio:m.width/m.height},y=void 0,b=Wa(g.extent)?g.extent:void 0,g.parentId&&(g.extent===`parent`||g.expandParent)&&(y=r.get(g.parentId)),y&&g.extent===`parent`&&(b=[[0,0],[y.measured.width,y.measured.height]]),v=[],x=void 0;for(let[e,n]of r)if(n.parentId===t&&(v.push({id:e,position:{...n.position},extent:n.extent}),n.extent===`parent`||n.expandParent)){let e=Ls(n,g,n.origin??s);x=x?[[Math.min(e[0][0],x[0][0]),Math.min(e[0][1],x[0][1])],[Math.max(e[1][0],x[1][0]),Math.max(e[1][1],x[1][1])]]:e}u?.(e,{...m})}).on(`drag`,e=>{let{transform:t,snapGrid:i,snapToGrid:a,nodeOrigin:s}=n(),c=Qa(e.sourceEvent,{transform:t,snapGrid:i,snapToGrid:a,containerBounds:_}),l=[];if(!g)return;let{x:u,y:f,width:S,height:C}=m,w={},T=g.origin??s,{width:E,height:D,x:O,y:k}=Ps(h,o.controlDirection,c,o.boundaries,o.keepAspectRatio,T,b,x),A=E!==S,j=D!==C,M=O!==u&&A,N=k!==f&&j;if(!M&&!N&&!A&&!j)return;let P={prevValues:{...m},startX:h.x,startY:h.y,childNodes:v.map(e=>({...e,position:{...e.position}}))};if((M||N||T[0]===1||T[1]===1)&&(w.x=M?O:m.x,w.y=N?k:m.y,m.x=w.x,m.y=w.y,v.length>0)){let e=O-u,t=k-f;for(let n of v)n.position={x:n.position.x-e+T[0]*(E-S),y:n.position.y-t+T[1]*(D-C)},l.push(n)}if((A||j)&&(w.width=A&&(!o.resizeDirection||o.resizeDirection===`horizontal`)?E:m.width,w.height=j&&(!o.resizeDirection||o.resizeDirection===`vertical`)?D:m.height,m.width=w.width,m.height=w.height),y&&g.expandParent){let e=T[0]*(w.width??0);w.x&&w.x<e&&(m.x=e,h.x-=w.x-e);let t=T[1]*(w.height??0);w.y&&w.y<t&&(m.y=t,h.y-=w.y-t)}let F=Os({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),ee={...m,direction:F};p?.(e,ee)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,ee),r(w,l))}).on(`end`,e=>{f?.(e,{...m}),i?.({...m})});a.call(S)}function c(){a.on(`.drag`,null)}return{update:s,destroy:c}}var zs=e(t(),1),Bs=e=>{let t,n=new Set,r=(e,r)=>{let i=typeof e==`function`?e(t):e;if(!Object.is(i,t)){let e=t;t=r??(typeof i!=`object`||!i)?i:Object.assign({},t,i),n.forEach(n=>n(t,e))}},i=()=>t,a={setState:r,getState:i,getInitialState:()=>o,subscribe:e=>(n.add(e),()=>n.delete(e)),destroy:()=>{n.clear()}},o=t=e(r,i,a);return a},Vs=e=>e?Bs(e):Bs,{useDebugValue:Hs}=I.default,{useSyncExternalStoreWithSelector:Us}=zs.default,Ws=e=>e;function Gs(e,t=Ws,n){let r=Us(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Hs(r),r}var Ks=(e,t)=>{let n=Vs(e),r=(e,r=t)=>Gs(n,e,r);return Object.assign(r,n),r},qs=(e,t)=>e?Ks(e,t):Ks;function K(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}n();var Js=(0,I.createContext)(null),Ys=Js.Provider,Xs=Zi.error001(`react`);function q(e,t){let n=(0,I.useContext)(Js);if(n===null)throw Error(Xs);return Gs(n,e,t)}function J(){let e=(0,I.useContext)(Js);if(e===null)throw Error(Xs);return(0,I.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var Zs={display:`none`},Qs={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},$s=`react-flow__node-desc`,ec=`react-flow__edge-desc`,tc=`react-flow__aria-live`,nc=e=>e.ariaLiveMessage,rc=e=>e.ariaLabelConfig;function ic({rfId:e}){let t=q(nc);return(0,W.jsx)(`div`,{id:`${tc}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:Qs,children:t})}function ac({rfId:e,disableKeyboardA11y:t}){let n=q(rc);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{id:`${$s}-${e}`,style:Zs,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,W.jsx)(`div`,{id:`${ec}-${e}`,style:Zs,children:n[`edge.a11yDescription.default`]}),!t&&(0,W.jsx)(ic,{rfId:e})]})}var oc=(0,I.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,W.jsx)(`div`,{className:Xi([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});oc.displayName=`Panel`;var sc=`https://reactflow.dev?utm_source=attribution`;function cc({proOptions:e,position:t=`bottom-right`}){return(0,I.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,W.jsx)(oc,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${sc}`,children:(0,W.jsx)(`a`,{href:sc,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var lc=e=>{let t=[],n=[];for(let[,n]of e.nodeLookup)n.selected&&t.push(n.internals.userNode);for(let[,t]of e.edgeLookup)t.selected&&n.push(t);return{selectedNodes:t,selectedEdges:n}},uc=e=>e.id;function dc(e,t){return K(e.selectedNodes.map(uc),t.selectedNodes.map(uc))&&K(e.selectedEdges.map(uc),t.selectedEdges.map(uc))}function fc({onSelectionChange:e}){let t=J(),{selectedNodes:n,selectedEdges:r}=q(lc,dc);return(0,I.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var pc=e=>!!e.onSelectionChangeHandlers;function mc({onSelectionChange:e}){let t=q(pc);return e||t?(0,W.jsx)(fc,{onSelectionChange:e}):null}var hc=[0,0],gc={x:0,y:0,zoom:1},_c=[...`nodes.edges.defaultNodes.defaultEdges.onConnect.onConnectStart.onConnectEnd.onClickConnectStart.onClickConnectEnd.nodesDraggable.autoPanOnNodeFocus.nodesConnectable.nodesFocusable.edgesFocusable.edgesReconnectable.elevateNodesOnSelect.elevateEdgesOnSelect.minZoom.maxZoom.nodeExtent.onNodesChange.onEdgesChange.elementsSelectable.connectionMode.snapGrid.snapToGrid.translateExtent.connectOnClick.defaultEdgeOptions.fitView.fitViewOptions.onNodesDelete.onEdgesDelete.onDelete.onNodeDrag.onNodeDragStart.onNodeDragStop.onSelectionDrag.onSelectionDragStart.onSelectionDragStop.onMoveStart.onMove.onMoveEnd.noPanClassName.nodeOrigin.autoPanOnConnect.autoPanOnNodeDrag.onError.connectionRadius.isValidConnection.selectNodesOnDrag.nodeDragThreshold.connectionDragThreshold.onBeforeDelete.debug.autoPanSpeed.ariaLabelConfig.zIndexMode`.split(`.`),`rfId`],vc=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),yc={translateExtent:Qi,nodeOrigin:hc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function bc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=q(vc,K),l=J();(0,I.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=yc,s()}),[]);let u=(0,I.useRef)(yc);return(0,I.useEffect)(()=>{for(let s of _c){let c=e[s];c!==u.current[s]&&e[s]!==void 0&&(s===`nodes`?t(c):s===`edges`?n(c):s===`minZoom`?r(c):s===`maxZoom`?i(c):s===`translateExtent`?a(c):s===`nodeExtent`?o(c):s===`ariaLabelConfig`?l.setState({ariaLabelConfig:Xa(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},_c.map(t=>e[t])),null}function xc(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Sc(e){let[t,n]=(0,I.useState)(e===`system`?null:e);return(0,I.useEffect)(()=>{if(e!==`system`){n(e);return}let t=xc(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?xc()?.matches?`dark`:`light`:t}var Cc=typeof document<`u`?document:null;function wc(e=null,t={target:Cc,actInsideInputWithModifier:!0}){let[n,r]=(0,I.useState)(!1),i=(0,I.useRef)(!1),a=(0,I.useRef)(new Set([])),[o,s]=(0,I.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
3
3
  `).replace(`
4
4
 
5
5
  `,`
6
6
  +`).split(`
7
7
  `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,I.useEffect)(()=>{let n=t?.target??Cc,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&no(e))return!1;let n=Ec(e.code,s);if(a.current.add(e[n]),Tc(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=Ec(e.code,s);Tc(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function Tc(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Ec(e,t){return t.includes(e)?`code`:`key`}var Dc=()=>{let e=J();return(0,I.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),!0):!1},getViewport:()=>{let[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Ha(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return La(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=Ra(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Oc(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)kc(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function kc(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes===`width`)&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes===`height`)&&(t.height=e.dimensions.height))),typeof e.resizing==`boolean`&&(t.resizing=e.resizing)}}function Ac(e,t){return Oc(e,t)}function jc(e,t){return Oc(e,t)}function Mc(e,t){return{id:e,type:`select`,selected:t}}function Nc(e,t=new Set){let n=[];for(let[r,i]of e){let e=t.has(r);(i.selected!==void 0||e)&&i.selected!==e&&n.push(Mc(i.id,e))}return n}function Pc({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Fc(e){return{id:e.id,type:`remove`}}var Ic=Fa(`React Flow`,`https://reactflow.dev/`);function Lc(e,t,n={}){return go(e,t,{...n,onError:n.onError??Ic})}var Rc=e=>la(e),zc=e=>ca(e);function Bc(e){return(0,I.forwardRef)(e)}var Vc=typeof window<`u`?I.useLayoutEffect:I.useEffect;function Hc(e){let[t,n]=(0,I.useState)(BigInt(0)),[r]=(0,I.useState)(()=>Uc(()=>n(e=>e+BigInt(1))));return Vc(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Uc(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Wc=(0,I.createContext)(null);function Gc({children:e}){let t=J(),n=Hc((0,I.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Pc({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=Hc((0,I.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Pc({items:s,lookup:o}))},[])),i=(0,I.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,W.jsx)(Wc.Provider,{value:i,children:e})}function Kc(){let e=(0,I.useContext)(Wc);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var qc=e=>!!e.panZoom;function Jc(){let e=Dc(),t=J(),n=Kc(),r=q(qc),i=(0,I.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=Rc(e)?e:n.get(e.id),a=i.parentId?qa(i.position,i.measured,i.parentId,n,r):i.position;return Oa({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height},i.parentId?void 0:r)},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Rc(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&zc(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await ya({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Fc);o?.(f),c(e)}if(m){let e=d.map(Fc);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Na(e),o=i?e:a(e),s=r!==void 0;if(!o)return[];let{nodeOrigin:c}=t.getState();return(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let l=Oa(s?r:a,c),u=Ma(l,o);return n&&u>0||u>=l.width*l.height||u>=o.width*o.height})},isNodeIntersecting:(e,t,n=!0)=>{let r=Na(e)?e:a(e);if(!r)return!1;let i=Ma(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return fa(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??Ya();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,I.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Yc=e=>e.selected,Xc=typeof window<`u`?window:void 0;function Zc({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=J(),{deleteElements:r}=Jc(),i=wc(e,{actInsideInputWithModifier:!1}),a=wc(t,{target:Xc});(0,I.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Yc),edges:e.filter(Yc)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,I.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Qc(e){let t=J();(0,I.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=$a(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,Zi.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t.disconnect()}}},[])}var $c={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},el=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function tl({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=na.Free,zoomOnDoubleClick:s=!0,panOnDrag:c=!0,defaultViewport:l,translateExtent:u,minZoom:d,maxZoom:f,zoomActivationKeyCode:p,preventScrolling:m=!0,children:h,noWheelClassName:g,noPanClassName:_,onViewportChange:v,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=J(),C=(0,I.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=q(el,K),D=wc(p),O=(0,I.useRef)();Qc(C);let k=(0,I.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,I.useEffect)(()=>{if(C.current){O.current=Es({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:l,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,I.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:i,panOnScrollSpeed:a,panOnScrollMode:o,zoomOnDoubleClick:s,panOnDrag:c,zoomActivationKeyPressed:D,preventScrolling:m,noPanClassName:_,userSelectionActive:w,noWheelClassName:g,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,c,D,m,_,w,g,T,k,E,x,b]),(0,W.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:$c,children:h})}var nl=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function rl(){let{userSelectionActive:e,userSelectionRect:t}=q(nl,K);return e&&t?(0,W.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var il=(e,t)=>n=>{n.target===t.current&&e?.(n)},al=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function ol({isSelecting:e,selectionKeyPressed:t,selectionMode:n=ra.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,I.useRef)(0),_=J(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=q(al,K),C=y&&(e||v),w=(0,I.useRef)(null),T=(0,I.useRef)(),E=(0,I.useRef)(new Set),D=(0,I.useRef)(new Set),O=(0,I.useRef)(!1),k=(0,I.useRef)(!1),A=(0,I.useRef)({x:0,y:0}),j=(0,I.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}let{connectionClickStartHandle:t,connection:n,onClickConnectEnd:r,resetSelectedElements:i}=_.getState();if(t){let t=structuredClone(n);delete t.inProgress,t.toPosition=t.toHandle?t.toHandle.position:null,r?.(e.nativeEvent,t),_.setState({connectionClickStartHandle:null})}l?.(e),i(),_.setState({nodesSelectionActive:!1})},N=e=>{Array.isArray(r)&&r?.includes(2)?e.preventDefault():u?.(e)},P=d?e=>d(e):void 0,F=e=>{k.current&&=(e.stopPropagation(),!1)},ee=n=>{if(n.pointerType===`touch`&&r!==!1&&!t)return;let{domNode:i,transform:a}=_.getState();if(T.current=i?.getBoundingClientRect(),!T.current)return;let s=n.target===w.current;if(!s&&n.target.closest(`.nokey`)||!e||!(o&&s||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:c,y:l}=io(n.nativeEvent,T.current),u=La({x:c,y:l},a);_.setState({userSelectionRect:{width:0,height:0,startX:u.x,startY:u.y,x:c,y:l}}),s||(n.stopPropagation(),n.preventDefault())};function te(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=Ra(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(ma(a,m,i,n===ra.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}Ja(h,E.current)||c(Nc(a,E.current)),Ja(g,D.current)||l(Nc(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!i||!T.current)return;let[e,t]=wa(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(L);return}let{x:t,y:n}=A.current;te(t,n),g.current=requestAnimationFrame(L)})}let R=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,I.useEffect)(()=>()=>R(),[]);let z=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=io(e.nativeEvent,T.current);A.current={x:o,y:c};let l=Ra({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(L(),!0),te(o,c)},B=e=>{C?e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),R()):e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0)},ne=e=>{e.target?.releasePointerCapture?.(e.pointerId),R()},re=r===!0||Array.isArray(r)&&r.includes(0);return(0,W.jsxs)(`div`,{className:Xi([`react-flow__pane`,{draggable:re,dragging:b,selection:e}]),onClick:C?void 0:il(M,w),onContextMenu:il(N,w),onWheel:il(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?z:p,onPointerUp:B,onPointerCancel:C?ne:void 0,onPointerDownCapture:C?ee:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:$c,children:[h,(0,W.jsx)(rl,{})]})}function sl({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);l?(t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])):c?.(`012`,Zi.error012(e))}function cl({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=J(),[c,l]=(0,I.useState)(!1),u=(0,I.useRef)();return(0,I.useEffect)(()=>{if(!t)return u.current=ts({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{sl({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,I.useEffect)(()=>{!t&&e.current&&u.current&&u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var ll=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function ul(){let e=J();return(0,I.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=ll(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Ia(t,i));let{position:a,positionAbsolute:s}=va({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var dl=(0,I.createContext)(null),fl=dl.Provider;dl.Consumer;var pl=()=>(0,I.useContext)(dl),ml=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),hl=(0,I.createContext)(null);function gl({children:e}){let t=q(ml,K);return(0,W.jsx)(hl.Provider,{value:t,children:e})}function _l(){let e=(0,I.useContext)(hl);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var vl={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},yl=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return vl;let u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===ta.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function bl({type:e=`source`,position:t=G.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=J(),_=pl(),{connectOnClick:v,noPanClassName:y,rfId:b}=_l(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=q(yl(_,m,e),K);_||g.getState().onError?.(`010`,Zi.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(Lc(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=ro(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();ds.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,W.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:Xi([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=eo(t.target),h=n||c,{connection:v,isValid:y}=ds.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var xl=(0,I.memo)(Bc(bl));function Sl({data:e,isConnectable:t,sourcePosition:n=G.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[e?.label,(0,W.jsx)(xl,{type:`source`,position:n,isConnectable:t})]})}function Cl({data:e,isConnectable:t,targetPosition:n=G.Top,sourcePosition:r=G.Bottom}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(xl,{type:`target`,position:n,isConnectable:t}),e?.label,(0,W.jsx)(xl,{type:`source`,position:r,isConnectable:t})]})}function wl(){return null}function Tl({data:e,isConnectable:t,targetPosition:n=G.Top}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(xl,{type:`target`,position:n,isConnectable:t}),e?.label]})}var El={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Dl={input:Sl,default:Cl,output:Tl,group:wl};function Ol(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var kl=e=>{let{width:t,height:n,x:r,y:i}=pa(e.nodeLookup,{filter:e=>!!e.selected});return{width:Pa(t)?t:null,height:Pa(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Al({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=J(),{width:i,height:a,transformString:o,userSelectionActive:s}=q(kl,K),c=ul(),l=(0,I.useRef)(null);(0,I.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(cl({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,W.jsx)(`div`,{className:Xi([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,W.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(El,e.key)&&(e.preventDefault(),c({direction:El[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var jl=typeof window<`u`?window:void 0,Ml=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Nl({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:F,isControlledViewport:ee}){let{nodesSelectionActive:I,userSelectionActive:te}=q(Ml,K),L=wc(l,{target:jl}),R=wc(h,{target:jl}),z=R||w,B=R||b,ne=u&&z!==!0,re=L||te||ne;return Zc({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,W.jsx)(tl,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:B,panActivationKeyPressed:R,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!L&&z,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:ee,paneClickDistance:s,selectionOnDrag:ne,children:(0,W.jsxs)(ol,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:z,autoPanOnSelection:T,isSelecting:!!re,selectionMode:d,selectionKeyPressed:L,paneClickDistance:s,selectionOnDrag:ne,children:[e,I&&(0,W.jsx)(Al,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Nl.displayName=`FlowRenderer`;var Pl=(0,I.memo)(Nl),Fl=e=>t=>e?ma(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Il(e){return q((0,I.useCallback)(Fl(e),[e]),K)}var Ll=e=>e.updateNodeInternals;function Rl(){let e=q(Ll),[t]=(0,I.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,I.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function zl({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=J(),a=(0,I.useRef)(null),o=(0,I.useRef)(null),s=(0,I.useRef)(e.sourcePosition),c=(0,I.useRef)(e.targetPosition),l=(0,I.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,I.useEffect)(()=>{!a.current||e.hidden||u&&o.current===a.current||(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,I.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,I.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Bl({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=q(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},K),S=y.type||`default`,C=g?.[S]||Dl[S];C===void 0&&(v?.(`003`,Zi.error003(S)),S=`default`,C=g?.default||Dl.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=J(),k=Ka(y),A=zl({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=cl({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=ul();if(y.hidden)return null;let N=Ga(y),P=Ol(y),F=T||w||t||n||r||i,ee=n?e=>n(e,{...b.userNode}):void 0,I=r?e=>r(e,{...b.userNode}):void 0,te=i?e=>i(e,{...b.userNode}):void 0,L=a?e=>a(e,{...b.userNode}):void 0,R=o?e=>o(e,{...b.userNode}):void 0,z=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&sl({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},B=t=>{if(!(no(t.nativeEvent)||m)){if($i.includes(t.key)&&T){let n=t.key===`Escape`;sl({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(El,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:El[t.key],factor:t.shiftKey?4:1})}}},ne=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(ma(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,W.jsx)(`div`,{className:Xi([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:F?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:ee,onMouseMove:I,onMouseLeave:te,onContextMenu:L,onClick:z,onDoubleClick:R,onKeyDown:D?B:void 0,tabIndex:D?0:void 0,onFocus:D?ne:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${$s}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,W.jsx)(fl,{value:e,children:(0,W.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var Vl=(0,I.memo)(Bl),Hl=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ul(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=q(Hl,K),a=Il(e.onlyRenderVisibleElements),o=Rl();return(0,W.jsx)(`div`,{className:`react-flow__nodes`,style:$c,children:a.map(a=>(0,W.jsx)(Vl,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Ul.displayName=`NodeRenderer`;var Wl=(0,I.memo)(Ul);function Gl(e){return q((0,I.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&po({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),K)}var Kl=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,W.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},ql=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,W.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},Jl={[oa.Arrow]:Kl,[oa.ArrowClosed]:ql};function Yl(e){let t=J();return(0,I.useMemo)(()=>Object.prototype.hasOwnProperty.call(Jl,e)?Jl[e]:(t.getState().onError?.(`009`,Zi.error009(e)),null),[e])}var Xl=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Yl(t);return c?(0,W.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,W.jsx)(c,{color:n,strokeWidth:o})}):null},Zl=({defaultColor:e,rfId:t})=>{let n=q(e=>e.edges),r=q(e=>e.defaultEdgeOptions),i=(0,I.useMemo)(()=>jo(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,W.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,W.jsx)(`defs`,{children:i.map(e=>(0,W.jsx)(Xl,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Zl.displayName=`MarkerDefinitions`;var Ql=(0,I.memo)(Zl);function $l({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,I.useState)({x:1,y:0,width:0,height:0}),p=Xi([`react-flow__edge-textwrapper`,l]),m=(0,I.useRef)(null);return(0,I.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,W.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,W.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,W.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}$l.displayName=`EdgeText`;var eu=(0,I.memo)($l);function tu({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`path`,{...u,d:e,fill:`none`,className:Xi([`react-flow__edge-path`,u.className])}),l?(0,W.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Pa(t)&&Pa(n)?(0,W.jsx)(eu,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function nu({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===G.Left||e===G.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function ru({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top}){let[o,s]=nu({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=nu({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=oo({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function iu(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=ru({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,W.jsx)(tu,{id:x,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var au=iu({isInternal:!1}),ou=iu({isInternal:!0});au.displayName=`SimpleBezierEdge`,ou.displayName=`SimpleBezierEdgeInternal`;function su(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=G.Bottom,targetPosition:m=G.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=wo({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition}),S=e.isInternal?void 0:t;return(0,W.jsx)(tu,{id:S,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var cu=su({isInternal:!1}),lu=su({isInternal:!0});cu.displayName=`SmoothStepEdge`,lu.displayName=`SmoothStepEdgeInternal`;function uu(e){return(0,I.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,W.jsx)(cu,{...n,id:r,pathOptions:(0,I.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var du=uu({isInternal:!1}),fu=uu({isInternal:!0});du.displayName=`StepEdge`,fu.displayName=`StepEdgeInternal`;function pu(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=_o({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,W.jsx)(tu,{id:y,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var mu=pu({isInternal:!1}),hu=pu({isInternal:!0});mu.displayName=`StraightEdge`,hu.displayName=`StraightEdgeInternal`;function gu(e){return(0,I.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=G.Bottom,targetPosition:s=G.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=lo({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,W.jsx)(tu,{id:S,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var _u=gu({isInternal:!1}),vu=gu({isInternal:!0});_u.displayName=`BezierEdge`,vu.displayName=`BezierEdgeInternal`;var yu={default:vu,straight:hu,step:fu,smoothstep:lu,simplebezier:ou},bu={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},xu=(e,t,n)=>n===G.Left?e-t:n===G.Right?e+t:e,Su=(e,t,n)=>n===G.Top?e-t:n===G.Bottom?e+t:e,Cu=`react-flow__edgeupdater`;function wu({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,W.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:Xi([Cu,`${Cu}-${s}`]),cx:xu(t,r,e),cy:Su(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Tu({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=J(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;ds.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,W.jsxs)(W.Fragment,{children:[(e===!0||e===`source`)&&(0,W.jsx)(wu,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,W.jsx)(wu,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Eu({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:v}){let y=q(t=>t.edgeLookup.get(e)),b=q(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||yu[x];S===void 0&&(_?.(`011`,Zi.error011(x)),x=`default`,S=h?.default||yu.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,I.useRef)(null),[D,O]=(0,I.useState)(!1),[k,A]=(0,I.useState)(!1),j=J(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:ee,sourcePosition:te,targetPosition:L}=q((0,I.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return bu;let i=Eo({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=fo({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||bu,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),K),R=(0,I.useMemo)(()=>y.markerStart?`url('#${Ao(y.markerStart,m)}')`:void 0,[y.markerStart,m]),z=(0,I.useMemo)(()=>y.markerEnd?`url('#${Ao(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||ee===null)return null;let B=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},ne=a?e=>{a(e,{...y})}:void 0,re=o?e=>{o(e,{...y})}:void 0,ie=s?e=>{s(e,{...y})}:void 0,V=c?e=>{c(e,{...y})}:void 0,ae=l?e=>{l(e,{...y})}:void 0;return(0,W.jsx)(`svg`,{style:{zIndex:M},children:(0,W.jsxs)(`g`,{className:Xi([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:B,onDoubleClick:ne,onContextMenu:re,onMouseEnter:ie,onMouseMove:V,onMouseLeave:ae,onKeyDown:C?t=>{if(!v&&$i.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${ec}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,W.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:F,targetY:ee,sourcePosition:te,targetPosition:L,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:R,markerEnd:z,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,W.jsx)(Tu,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:ee,sourcePosition:te,targetPosition:L,setUpdateHover:O,setReconnecting:A})]})})}var Du=(0,I.memo)(Eu),Ou=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ku({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=q(Ou,K),b=Gl(t);return(0,W.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,W.jsx)(Ql,{defaultColor:e,rfId:n}),b.map(e=>(0,W.jsx)(Du,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}ku.displayName=`EdgeRenderer`;var Au=(0,I.memo)(ku),ju=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function Mu({children:e}){let t=J(),n=(0,I.useRef)(null),[r]=(0,I.useState)(()=>t.getState().transform);return Vc(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=ju(r)))};return r(),t.subscribe(r)},[t]),(0,W.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:ju(r)},children:e})}function Nu(e){let t=Jc(),n=(0,I.useRef)(!1);(0,I.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Pu=e=>e.panZoom?.syncViewport;function Fu(e){let t=q(Pu),n=J();return(0,I.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Iu(e){return e.connection.inProgress?{...e.connection,to:La(e.connection.to,e.transform)}:{...e.connection}}function Lu(e){return e?t=>e(Iu(t)):Iu}function Ru(e){return q(Lu(e),K)}var zu=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Bu({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=q(zu,K);return a&&i&&c?(0,W.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,W.jsx)(`g`,{className:Xi([`react-flow__connection`,Za(s)]),children:(0,W.jsx)(Vu,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Vu=({style:e,type:t=aa.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Ru();if(!i)return;if(n)return(0,W.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Za(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case aa.Bezier:[m]=lo(h);break;case aa.SimpleBezier:[m]=ru(h);break;case aa.Step:[m]=wo({...h,borderRadius:0});break;case aa.SmoothStep:[m]=wo(h);break;default:[m]=_o(h)}return(0,W.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Vu.displayName=`ConnectionLine`;var Hu={};function Uu(e=Hu){(0,I.useRef)(e),J(),(0,I.useEffect)(()=>{},[e])}function Wu(){J(),(0,I.useRef)(!1),(0,I.useEffect)(()=>{},[])}function Gu({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:P,panOnScroll:F,panOnScrollSpeed:ee,panOnScrollMode:I,zoomOnDoubleClick:te,panOnDrag:L,autoPanOnSelection:R,onPaneClick:z,onPaneMouseEnter:B,onPaneMouseMove:ne,onPaneMouseLeave:re,onPaneScroll:ie,onPaneContextMenu:V,paneClickDistance:ae,nodeClickDistance:H,onEdgeContextMenu:U,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:le,onReconnect:ue,onReconnectStart:de,onReconnectEnd:fe,noDragClassName:pe,noWheelClassName:me,noPanClassName:he,disableKeyboardA11y:ge,nodeExtent:_e,rfId:ve,viewport:ye,onViewportChange:be,nodesDraggable:xe}){return Uu(e),Uu(t),Wu(),Nu(n),Fu(ye),(0,W.jsx)(Pl,{onPaneClick:z,onPaneMouseEnter:B,onPaneMouseMove:ne,onPaneMouseLeave:re,onPaneContextMenu:V,onPaneScroll:ie,paneClickDistance:ae,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:P,zoomOnDoubleClick:te,panOnScroll:F,panOnScrollSpeed:ee,panOnScrollMode:I,panOnDrag:L,autoPanOnSelection:R,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:pe,noWheelClassName:me,noPanClassName:he,disableKeyboardA11y:ge,onViewportChange:be,isControlledViewport:!!ye,children:(0,W.jsxs)(Mu,{children:[(0,W.jsx)(Au,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:ue,onReconnectStart:de,onReconnectEnd:fe,onlyRenderVisibleElements:T,onEdgeContextMenu:U,onEdgeMouseEnter:oe,onEdgeMouseMove:se,onEdgeMouseLeave:ce,reconnectRadius:le,defaultMarkerColor:M,noPanClassName:he,disableKeyboardA11y:ge,rfId:ve}),(0,W.jsx)(Bu,{style:h,type:m,component:g,containerStyle:_}),(0,W.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,W.jsx)(Wl,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:H,onlyRenderVisibleElements:T,noPanClassName:he,noDragClassName:pe,disableKeyboardA11y:ge,nodeExtent:_e,rfId:ve,nodesDraggable:xe}),(0,W.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Gu.displayName=`GraphView`;var Ku=(0,I.memo)(Gu),qu=Fa(`React Flow`,`https://reactflow.dev/`),Ju=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??Qi;Yo(h,g,_);let{nodesInitialized:x}=Bo(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Ha(pa(p,{filter:e=>!(!e.width&&!e.initialWidth||!e.height&&!e.initialHeight)}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Qi,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ta.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...ia},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:qu,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:ea,zIndexMode:f,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},Yu=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>qs((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await _a({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Ju({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,fitViewQueued:o,zIndexMode:s,nodesSelectionActive:c}=m(),{nodesInitialized:l,hasSelectedNodes:u}=Bo(e,t,n,{nodeOrigin:r,nodeExtent:i,elevateNodesOnSelect:a,checkEquality:!0,zIndexMode:s}),d=c&&u;o&&l?(h(),p({nodes:e,nodesInitialized:l,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:d})):p({nodes:e,nodesInitialized:l,nodesSelectionActive:d})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Yo(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=Ko(e,n,r,i,a,o,l);d&&(Lo(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=Oo(e,o.fromHandle,G.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=Go(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Ac(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(jc(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?i(e.map(e=>Mc(e,!0))):(i(Nc(r,new Set([...e]))),a(Nc(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?a(e.map(e=>Mc(e,!0))):(a(Nc(n,new Set([...e]))),i(Nc(r,new Set)))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s)e.selected&&l.push(Mc(e.id,!1));let u=[];for(let e of c)e.selected&&u.push(Mc(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Mc(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Mc(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();(e[0][0]!==o[0][0]||e[0][1]!==o[0][1]||e[1][0]!==o[1][0]||e[1][1]!==o[1][1])&&(Bo(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return qo({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return!1;let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0},cancelConnection:()=>{p({connection:{...ia}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Ju()})}},Object.is);function Xu({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,I.useState)(()=>Yu({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,W.jsx)(Ys,{value:m,children:(0,W.jsx)(Gc,{children:(0,W.jsx)(gl,{children:p})})})}function Zu({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,I.useContext)(Js)?(0,W.jsx)(W.Fragment,{children:e}):(0,W.jsx)(Xu,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var Qu={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function $u({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onBeforeDelete:ee,connectionMode:te,connectionLineType:L=aa.Bezier,connectionLineStyle:R,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:ne=`Backspace`,selectionKeyCode:re=`Shift`,selectionOnDrag:ie=!1,selectionMode:V=ra.Full,panActivationKeyCode:ae=`Space`,multiSelectionKeyCode:H=Ua()?`Meta`:`Control`,zoomActivationKeyCode:U=Ua()?`Meta`:`Control`,snapToGrid:oe,snapGrid:se,onlyRenderVisibleElements:ce=!1,selectNodesOnDrag:le,nodesDraggable:ue,autoPanOnNodeFocus:de,nodesConnectable:fe,nodesFocusable:pe,nodeOrigin:me=hc,edgesFocusable:he,edgesReconnectable:ge,elementsSelectable:_e=!0,defaultViewport:ve=gc,minZoom:ye=.5,maxZoom:be=2,translateExtent:xe=Qi,preventScrolling:Se=!0,nodeExtent:Ce,defaultMarkerColor:we=`#b1b1b7`,zoomOnScroll:Te=!0,zoomOnPinch:Ee=!0,panOnScroll:De=!1,panOnScrollSpeed:Oe=.5,panOnScrollMode:ke=na.Free,zoomOnDoubleClick:Ae=!0,panOnDrag:je=!0,onPaneClick:Me,onPaneMouseEnter:Ne,onPaneMouseMove:Pe,onPaneMouseLeave:Fe,onPaneScroll:Ie,onPaneContextMenu:Le,paneClickDistance:Re=1,nodeClickDistance:ze=0,children:Be,onReconnect:Ve,onReconnectStart:He,onReconnectEnd:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,reconnectRadius:Ye=10,onNodesChange:Xe,onEdgesChange:Ze,noDragClassName:Qe=`nodrag`,noWheelClassName:$e=`nowheel`,noPanClassName:et=`nopan`,fitView:tt,fitViewOptions:nt,connectOnClick:rt,attributionPosition:it,proOptions:at,defaultEdgeOptions:ot,elevateNodesOnSelect:st=!0,elevateEdgesOnSelect:ct=!1,disableKeyboardA11y:lt=!1,autoPanOnConnect:ut,autoPanOnNodeDrag:dt,autoPanOnSelection:ft=!0,autoPanSpeed:pt,connectionRadius:mt,isValidConnection:ht,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=Sc(Tt),Pt=(0,I.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,W.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...Qu},ref:jt,className:Xi([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,W.jsxs)(Zu,{nodes:e,edges:t,width:Ct,height:wt,fitView:tt,fitViewOptions:nt,minZoom:ye,maxZoom:be,nodeOrigin:me,nodeExtent:Ce,zIndexMode:kt,children:[(0,W.jsx)(bc,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:ue,autoPanOnNodeFocus:de,nodesConnectable:fe,nodesFocusable:pe,edgesFocusable:he,edgesReconnectable:ge,elementsSelectable:_e,elevateNodesOnSelect:st,elevateEdgesOnSelect:ct,minZoom:ye,maxZoom:be,nodeExtent:Ce,onNodesChange:Xe,onEdgesChange:Ze,snapToGrid:oe,snapGrid:se,connectionMode:te,translateExtent:xe,connectOnClick:rt,defaultEdgeOptions:ot,fitView:tt,fitViewOptions:nt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:et,nodeOrigin:me,rfId:Mt,autoPanOnConnect:ut,autoPanOnNodeDrag:dt,autoPanSpeed:pt,onError:gt,connectionRadius:mt,isValidConnection:ht,selectNodesOnDrag:le,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:ee,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,W.jsx)(Ku,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:L,connectionLineStyle:R,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:re,selectionOnDrag:ie,selectionMode:V,deleteKeyCode:ne,multiSelectionKeyCode:H,panActivationKeyCode:ae,zoomActivationKeyCode:U,onlyRenderVisibleElements:ce,defaultViewport:ve,translateExtent:xe,minZoom:ye,maxZoom:be,preventScrolling:Se,zoomOnScroll:Te,zoomOnPinch:Ee,zoomOnDoubleClick:Ae,panOnScroll:De,panOnScrollSpeed:Oe,panOnScrollMode:ke,panOnDrag:je,autoPanOnSelection:ft,onPaneClick:Me,onPaneMouseEnter:Ne,onPaneMouseMove:Pe,onPaneMouseLeave:Fe,onPaneScroll:Ie,onPaneContextMenu:Le,paneClickDistance:Re,nodeClickDistance:ze,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ve,onReconnectStart:He,onReconnectEnd:Ue,onEdgeContextMenu:We,onEdgeDoubleClick:Ge,onEdgeMouseEnter:Ke,onEdgeMouseMove:qe,onEdgeMouseLeave:Je,reconnectRadius:Ye,defaultMarkerColor:we,noDragClassName:Qe,noWheelClassName:$e,noPanClassName:et,rfId:Mt,disableKeyboardA11y:lt,nodeExtent:Ce,viewport:xt,onViewportChange:St,nodesDraggable:ue}),(0,W.jsx)(mc,{onSelectionChange:k}),Be,(0,W.jsx)(cc,{proOptions:at,position:it}),(0,W.jsx)(ac,{rfId:Mt,disableKeyboardA11y:lt})]})})}var ed=Bc($u),td=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function nd(){return q(td,K)}Zi.error014();function rd({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,W.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:Xi([`react-flow__background-pattern`,n,r])})}function id({radius:e,className:t}){return(0,W.jsx)(`circle`,{cx:e,cy:e,r:e,className:Xi([`react-flow__background-pattern`,`dots`,t])})}var ad;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(ad||={});var od={[ad.Dots]:1,[ad.Lines]:1,[ad.Cross]:6},sd=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function cd({id:e,variant:t=ad.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,I.useRef)(null),{transform:f,patternId:p}=q(sd,K),m=r||od[t],h=t===ad.Dots,g=t===ad.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]+x[0]/2,b[1]*f[2]+x[1]/2],C=`${p}${e||``}`;return(0,W.jsxs)(`svg`,{className:Xi([`react-flow__background`,l]),style:{...c,...$c,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,W.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,W.jsx)(id,{radius:y/2,className:u}):(0,W.jsx)(rd,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,W.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}cd.displayName=`Background`;var ld=(0,I.memo)(cd);function ud(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,W.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function dd(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,W.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function fd(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,W.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function pd(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function md(){return(0,W.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,W.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function hd({children:e,className:t,...n}){return(0,W.jsx)(`button`,{type:`button`,className:Xi([`react-flow__controls-button`,t]),...n,children:e})}var gd=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function _d({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=J(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=q(gd,K),{zoomIn:y,zoomOut:b,fitView:x}=Jc();return(0,W.jsxs)(oc,{className:Xi([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(hd,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,W.jsx)(ud,{})}),(0,W.jsx)(hd,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,W.jsx)(dd,{})})]}),n&&(0,W.jsx)(hd,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,W.jsx)(fd,{})}),r&&(0,W.jsx)(hd,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,W.jsx)(md,{}):(0,W.jsx)(pd,{})}),u]})}_d.displayName=`Controls`,(0,I.memo)(_d);function vd({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,W.jsx)(`rect`,{className:Xi([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var yd=(0,I.memo)(vd),bd=e=>e.nodes.map(e=>e.id),xd=e=>e instanceof Function?e:()=>e;function Sd({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=yd,onClick:o}){let s=q(bd,K),c=xd(t),l=xd(e),u=xd(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,W.jsx)(W.Fragment,{children:s.map(e=>(0,W.jsx)(wd,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Cd({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=q(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=Ga(r);return{node:r,x:i,y:a,width:o,height:s}},K);return!l||l.hidden||!Ka(l)?null:(0,W.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var wd=(0,I.memo)(Cd),Td=(0,I.memo)(Sd),Ed=200,Dd=150,Od=e=>!e.hidden,kd=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},n=!1;for(let t of e.nodeLookup.values())if(!t.hidden){n=!0;break}return{viewBB:t,boundingRect:n?Aa(pa(e.nodeLookup,{filter:Od}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Ad=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,jd=(e,t)=>Ad(e.viewBB,t.viewBB)&&Ad(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,Md=`react-flow__minimap-desc`;function Nd({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:v,zoomStep:y=1,offsetScale:b=5}){let x=J(),S=(0,I.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=q(kd,jd),j=e?.width??Ed,M=e?.height??Dd,N=C.width/j,P=C.height/M,F=Math.max(N,P),ee=F*j,te=F*M,L=b*F,R=C.x-(ee-C.width)/2-L,z=C.y-(te-C.height)/2-L,B=ee+L*2,ne=te+L*2,re=`${Md}-${E}`,ie=(0,I.useRef)(0),V=(0,I.useRef)();ie.current=F,(0,I.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return V.current=fs({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>ie.current}),()=>{V.current?.destroy()}},[w]),(0,I.useEffect)(()=>{V.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ae=p?e=>{let[t,n]=V.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,H=(0,I.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),U=m?H:void 0,oe=_??A[`minimap.ariaLabel`];return(0,W.jsx)(oc,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*F:void 0,"--xy-minimap-node-background-color-props":typeof r==`string`?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n==`string`?n:void 0,"--xy-minimap-node-stroke-width-props":typeof o==`number`?o:void 0},className:Xi([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,W.jsxs)(`svg`,{width:j,height:M,viewBox:`${R} ${z} ${B} ${ne}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":re,ref:S,onClick:ae,children:[oe&&(0,W.jsx)(`title`,{id:re,children:oe}),(0,W.jsx)(Td,{onClick:U,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,W.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${R-L},${z-L}h${B+L*2}v${ne+L*2}h${-B-L*2}z
8
- M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Nd.displayName=`MiniMap`,(0,I.memo)(Nd);var Pd=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Fd={[Ds.Line]:`right`,[Ds.Handle]:`bottom-right`};function Id({nodeId:e,position:t,variant:n=Ds.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=pl(),y=typeof e==`string`?e:v,b=J(),x=(0,I.useRef)(null),S=n===Ds.Handle,C=q((0,I.useCallback)(Pd(S&&p),[S,p]),K),w=(0,I.useRef)(null),T=t??Fd[n];(0,I.useEffect)(()=>{if(x.current&&y)return w.current||=Rs({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Go([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...qa({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,W.jsx)(`div`,{className:Xi([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,I.memo)(Id);var Ld=`repo-harness.architecture-map.v7`,Rd=[`architecture_map_pending`,`registry_unavailable`,`repository_not_found`,`model_unavailable`,`architecture_map_invalid`,`architecture_map_failed`,`architecture_map_timeout`,`architecture_map_process_failed`],zd=[`model_worktree_dirty`,`checkout_changed`,`ownership_unavailable`,`git_read_failed`],Bd=[`model_worktree_dirty`,`checkout_changed`,`code_facts_worktree_dirty`,`code_facts_unavailable`,`code_facts_incomplete`,`code_facts_other_commit`,`dependencies_unavailable`],Vd=[`git_read_failed`,`history_starts_today`,`archctx_failed`,`path_not_public`],Hd=[...Bd,`archctx_failed`],Ud=[...a,`projection_missing`,`projection_invalid`,`tests_model_mismatch`],Wd=[`model_worktree_dirty`,`checkout_changed`,`git_read_failed`,`dev_activity_pending`,`dev_activity_unavailable`],Gd=[`head_missing`,...u,`archctx_failed`,`path_not_public`],Kd=[`model_layers_undeclared`],qd=[...Hd,`model_layers_undeclared`,`layer_direction_undeclared`,`layer_endpoint_unclassified`],Jd={debt:[`debt`,`--json`],flows:[`flows`,`check`,`--no-sync`,`--json`],anchors:[`docs`,`anchors`,`--json`],dependencies:[`deps`,`--json`],layer_direction:[`constraints`,`check`,`--json`]};function Yd(e){return[`archctx`,...Jd[e]].join(` `)}var Xd=[`unowned-path`,`ambiguous-owner`,`stale-anchor`,`state-machine-rule`,`state-machine-stale`],Zd=[`host`,`container`,`pod`,`kubernetes`,`pid`,`mount`,`net`,`user`],Qd=/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/u,$d=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function ef(e,t){return typeof e!=`string`||!Qd.test(e)||t!=null&&(typeof t!=`string`||!$d.test(t))?null:{state:`unavailable`,reason:`archctx_error`,code:e,reason_code:t??null}}function tf(e){let t=e=>m(e)?e:null,n=t(t(e)?.error)?.code;if(n===`archctx_error`){let n=t(t(e)?.archctx);return n===null?null:ef(n.code,n.reason_code)}return Rd.includes(n)?{state:`unavailable`,reason:n}:null}function nf(e){return`${e.entrypoint}\0${e.source_symbol}\0${e.sink}`}function rf(e){return e.applicability===`required`?[...e.steps.map(e=>({outcome:null,step:e})),...e.outcomes.flatMap(e=>e.steps.map(t=>({outcome:e.id,step:t})))]:[]}var af=e=>typeof e==`string`,of=e=>typeof e==`string`&&e.length>0&&e.length<=4096,sf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,cf=e=>sf(e)&&e>0,Y=e=>t=>af(t)&&e.test(t),lf=(...e)=>t=>e.includes(t),X=e=>t=>t===null||e(t),Z=e=>t=>Array.isArray(t)&&t.every(e),Q=e=>t=>{if(!m(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},uf=/^([a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)+$/u,df=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/u,ff=/^[a-z][a-z0-9-]{0,63}$/u,$=Y(uf),pf=e=>t=>e(t)&&s(t),mf=pf(Y(/^[^\r\n]{1,4096}$/u)),hf=Q({id:$,kind:Y(ff),name:pf(of),status:Y(ff),layer:X(Y(df)),parent:X($),summary:pf(af),domain:X(Y(df)),namespace:X(Q({type:lf(...Zd)})),mount:X(Q({source:X(pf(of)),target:X(pf(of)),mode:lf(`ro`,`rw`),order:sf}))}),gf=Q({id:$,kind:Y(ff),source:$,target:$,intent:pf(af),protocol:X(mf)}),_f=Q({id:$,files:cf,lines:sf}),vf=Q({source:$,target:$,imports:cf}),yf=e=>Q({state:lf(`unavailable`),reason:lf(...e)}),bf=(e,t)=>n=>Q({state:lf(`ok`),...e})(n)||yf(t)(n),xf=e=>Q({state:lf(`unavailable`),reason:lf(`archctx_error`),code:Y(Qd),reason_code:X(Y($d))})(e),Sf=Y(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u),Cf=/^(?![/.-])(?!.*\.\.)(?!.*@\{)(?!.*\/[/.])(?!.*[/.]$)(?!.*\.lock(?:\/|$))[^\x00-\x20\x7f~^:?*[\\]{1,255}$/u,wf=/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u,Tf=Y(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/u),Ef=Z($),Df=e=>Z(Y(df))(e)&&e.length>0,Of=e=>af(e)&&i(e),kf=(...e)=>t=>e.some(e=>e(t)),Af=Z(Y($d)),jf=Y(/^[a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/u),Mf=lf(!0,!1),Nf=e=>({paths:Z(Q({path:e,added:X(sf),deleted:X(sf),owners:Ef,reason_codes:Af})),unowned_paths:Z(e),nodes:Z(Q({id:$,files:cf})),dependents:Z(Q({id:$,touched:$,relations:Ef})),dependency_coverage:lf(`complete`,`partial`),flow_steps:Q({status:lf(`known`,`unknown`),reason_codes:Af,items:X(Z(Q({flow:$,step:jf,outcome:X(jf),reason_codes:Af})))}),truncated:Q({paths:Mf,nodes:Mf,relations:Mf,flow_steps:Mf,dependents:Mf,model:Mf})}),Pf=Q({kind:lf(`nodes`,`relations`,`flows`),id:$,change:lf(`added`,`removed`,`changed`),fields:Z(Y(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/u))}),Ff=Q({sha:Sf,subject:pf(Y(/^[^\r\n]{0,4096}$/u)),nodes:Ef}),If=e=>kf(bf({since:Tf,base:Sf,commits:Z(Ff),model:Z(Pf),...Nf(e)},Vd),xf),Lf=e=>kf(bf(Nf(e),Gd),xf),Rf=If(Of),zf=Lf(Of),Bf={entrypoint:jf,source_symbol:mf,sink:jf},Vf=Q({id:jf,from:jf,to:jf,label:pf(of),evidence:Q(Bf)}),Hf=kf(Q({id:$,capability:$,name:pf(of),applicability:lf(`required`),participants:Z(Q({id:jf,node:$})),steps:Z(Vf),outcomes:Z(Q({id:jf,kind:lf(`success`,`error`),label:pf(of),steps:Z(Vf),terminal:Q({participant:jf,label:pf(of)})}))}),Q({id:$,capability:$,name:pf(of),applicability:lf(`not-applicable`),rationale:pf(of)})),Uf=Q({...Bf,node:$,source_path:X(Of),sink_path:X(Of),sink_symbol:mf}),Wf=e=>Z(Q({kind:Y($d),origin:lf(`document`,`node-summary`,`node-responsibility`),path:X(Of),line:X(cf),citation:pf(of)}))(e)&&e.length>0,Gf=Q({debt:bf({items:Z(Q({kind:lf(...Xd),nodes:Ef,paths:Z(Of)}))},Hd),flows:kf(bf({selectors:sf,proven:sf,unproven:sf,used_unproven:sf,unprovable:Z(Q({id:$,diagnostics:sf})),evidence:Z(Q({...Bf,status:Y($d),call_sites:Z(Q({path:Of,line:X(cf)}))}))},Hd),xf),anchors:bf({citations:sf,nodes:Z(Q({id:$,findings:Wf}))},Hd),dependencies:bf({edges:Z(vf)},Hd),layer_direction:kf(bf({imports:sf,edges:Z(Q({source:$,target:$,source_layer:Y(df),target_layer:Y(df),imports:cf}))},qd),xf)}),Kf=Q({state:lf(`ok`),items:Z(Q({id:mf,title:mf,status:X(mf),decided_at:X(mf),applies_to:Ef,supersedes:Z(mf),path:Of}))}),qf=bf({run:Q({id:cf,head_sha:Sf,created_at:Tf}),results:lf(`ok`,`junit_missing`,`junit_invalid`),capabilities:Z(Q({id:$,files:cf,passed:sf,failed:sf,skipped:sf,no_result:sf}))},Ud),Jf=Y(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9]\d*$/u),Yf=bf({observed_at:Tf,pull_requests:Z(Q({number:cf,title:pf(of),url:Jf,head_sha:X(Sf),impact:zf}))},Wd),Xf=Q({schema_version:lf(Ld),repository_id:Y(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u),commit:Sf,head_ref:X(Y(Cf)),archctx_version:Y(wf),collected_at:Tf,nodes:Z(hf),relations:Z(gf),flows:Z(Hf),flow_evidence:Z(Uf),sizes:bf({nodes:Z(_f)},zd),dependencies:bf({edges:Z(vf)},Bd),layer_order:bf({layers:Df},Kd),layers:Q({changes:Rf,violations:Gf,pull_requests:Yf,tests:qf,decisions:Kf})});function Zf(e){return new Set(e).size===e.length}function Qf(e,t){let n=new Set(t);return e.every(e=>e.layer===null||n.has(e.layer))}function $f(e,t){let n=new Set;for(let r=e;r!==null;r=t.get(r)?.parent??null){if(n.has(r))return!1;n.add(r)}return!0}var ep=(e,t,n)=>`${e}\0${t??``}\0${n}`;function tp(e,t,n){return{nodes:new Set(e.map(e=>e.id)),relations:new Set(t.map(e=>e.id)),flows:new Set(n.map(e=>e.id)),steps:new Set(n.flatMap(e=>rf(e).map(({outcome:t,step:n})=>ep(e.id,t,n.id))))}}function np(e,t){let n=new Set(e.flows.flatMap(e=>rf(e).map(({step:e})=>nf(e.evidence)))),r=new Set(e.flow_evidence.map(nf)),i=e=>Zf(e.map(nf))&&e.every(e=>n.has(nf(e))),{flows:a}=e.layers.violations;return Zf(e.flows.map(e=>e.id))&&e.flows.every(e=>{if(t.get(e.capability)?.kind!==`capability`)return!1;if(e.applicability!==`required`)return!0;let n=new Set(e.participants.map(e=>e.id)),r=e=>Zf(e.map(e=>e.id))&&e.every(e=>n.has(e.from)&&n.has(e.to));return e.participants.length>0&&e.steps.length>0&&n.size===e.participants.length&&e.participants.every(e=>t.has(e.node))&&r(e.steps)&&Zf(e.outcomes.map(e=>e.id))&&e.outcomes.every(e=>r(e.steps)&&n.has(e.terminal.participant))})&&i(e.flow_evidence)&&e.flow_evidence.every(e=>t.has(e.node))&&(a.state!==`ok`||i(a.evidence)&&a.evidence.every(e=>r.has(nf(e))))}function rp(e,t,n){let r=e.paths.filter(e=>e.owners.length===0).map(e=>e.path),{flow_steps:i}=e;return Zf(e.paths.map(e=>e.path))&&e.paths.every(e=>Zf(e.owners)&&e.owners.every(n))&&r.length===e.unowned_paths.length&&r.every((t,n)=>t===e.unowned_paths[n])&&Zf(e.nodes.map(e=>e.id))&&e.nodes.every(e=>n(e.id))&&e.dependents.every(e=>t.nodes.has(e.id)&&n(e.touched)&&e.relations.length>0&&e.relations.every(e=>t.relations.has(e)))&&(i.status===`known`?i.reason_codes.length===0&&i.items!==null:i.reason_codes.length>0)&&(i.items??[]).every(e=>t.steps.has(ep(e.flow,e.outcome,e.step)))}function ip(e,t,n=Of){if(!(n===Of?Rf:If(n))(e))return!1;let r=e;if(r.state!==`ok`)return!0;let i=new Set(r.model.filter(e=>e.kind===`nodes`&&e.change===`removed`).map(e=>e.id)),a=(e,t)=>r.model.filter(t=>t.kind===e).every(e=>e.change===`removed`!==t.has(e.id)),o=e=>t.nodes.has(e)||i.has(e);return Zf(r.model.map(e=>`${e.kind}\0${e.id}`))&&a(`nodes`,t.nodes)&&a(`relations`,t.relations)&&a(`flows`,t.flows)&&Zf(r.commits.map(e=>e.sha))&&r.commits.every(e=>Zf(e.nodes)&&e.nodes.every(o))&&rp(r,t,o)}function ap(e,t,n=Of){if(!(n===Of?zf:Lf(n))(e))return!1;let r=e;return r.state!==`ok`||rp(r,t,e=>t.nodes.has(e))}function op(e,t){let n=e.layers.violations.layer_direction;if(n.state!==`ok`)return!0;if(e.layer_order.state!==`ok`)return!1;let r=new Map(e.layer_order.layers.map((e,t)=>[e,t]));return Zf(n.edges.map(e=>`${e.source}\0${e.target}`))&&n.edges.every(e=>t.get(e.source)?.layer===e.source_layer&&t.get(e.target)?.layer===e.target_layer&&(r.get(e.target_layer)??1/0)<(r.get(e.source_layer)??-1/0))}function sp(e){if(!Xf(e))throw Error(`architecture_map_invalid`);let t=e,n=new Map(t.nodes.map(e=>[e.id,e])),r=new Set(t.relations.map(e=>e.id)),i=tp(t.nodes,t.relations,t.flows),a=e=>n.get(e)?.kind===`capability`,o=(e,t=e=>n.has(e))=>Zf(e)&&e.every(t),s=e=>Zf(e.map(e=>`${e.source}\0${e.target}`))&&e.every(e=>e.source!==e.target&&a(e.source)&&a(e.target)),{violations:c,pull_requests:l,tests:u,decisions:d}=t.layers;if(n.size!==t.nodes.length||r.size!==t.relations.length||t.nodes.some(e=>e.domain!==null!=(e.kind===`capability`)||e.namespace!==null!=(e.kind===`namespace`)||e.mount!==null!=(e.kind===`mount`))||t.nodes.some(e=>e.parent!==null&&!n.has(e.parent))||t.nodes.some(e=>!$f(e.id,n))||t.relations.some(e=>!n.has(e.source)||!n.has(e.target))||t.layer_order.state===`ok`&&(!Zf(t.layer_order.layers)||!Qf(t.nodes,t.layer_order.layers))||t.sizes.state===`ok`&&!o(t.sizes.nodes.map(e=>e.id))||t.dependencies.state===`ok`&&!s(t.dependencies.edges)||!ip(t.layers.changes,i)||c.debt.state===`ok`&&c.debt.items.some(e=>!o(e.nodes)||!Zf(e.paths))||c.flows.state===`ok`&&!o(c.flows.unprovable.map(e=>e.id),a)||c.anchors.state===`ok`&&!o(c.anchors.nodes.map(e=>e.id))||c.dependencies.state===`ok`&&!s(c.dependencies.edges)||!op(t,n)||!np(t,n)||l.state===`ok`&&(!Zf(l.pull_requests.map(e=>String(e.number)))||l.pull_requests.some(e=>!ap(e.impact,i)||(e.impact.state===`ok`?e.head_sha===null:e.head_sha===null!=(e.impact.reason===`head_missing`))))||u.state===`ok`&&(!o(u.capabilities.map(e=>e.id),a)||u.capabilities.some(e=>e.files!==e.passed+e.failed+e.skipped+e.no_result))||!Zf(d.items.map(e=>e.id))||d.items.some(e=>!o(e.applies_to)))throw Error(`architecture_map_invalid`);return t}var cp=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`],lp={available:!1,marks:new Map,lit:new Set,edges:[]};function up(e,t){let n=new Map(e.nodes.map(e=>[e.id,e.parent])),r=new Set;for(let e of t)if(n.has(e))for(let t=e;t!==null&&!r.has(t);t=n.get(t))r.add(t);return r}function dp(e){return e.reason_code===null?e.code:`${e.code} ${e.reason_code}`}function fp(e){let{debt:t,flows:n,anchors:r,dependencies:i,layer_direction:a}=e.layers.violations,o=new Map,s=(e,t)=>o.set(e,(o.get(e)??0)+t);if(t.state===`ok`)for(let e of t.items)for(let t of e.nodes)s(t,1);if(n.state===`ok`)for(let e of n.unprovable)s(e.id,1);if(r.state===`ok`)for(let e of r.nodes)s(e.id,e.findings.length);if(i.state===`ok`)for(let e of i.edges)s(e.source,1);if(a.state===`ok`)for(let e of a.edges)s(e.source,1);return o}function pp(e){let{debt:t,flows:n,anchors:r,dependencies:i,layer_direction:a}=e.layers.violations;return(t.state===`ok`?t.items.length:0)+(n.state===`ok`?n.unprovable.length:0)+(r.state===`ok`?r.nodes.reduce((e,t)=>e+t.findings.length,0):0)+(i.state===`ok`?i.edges.length:0)+(a.state===`ok`?a.edges.length:0)}function mp(e,t){return e.paths.filter(e=>e.owners.some(e=>t.has(e))).length}function hp(e){let{pull_requests:t}=e.layers;return t.state===`ok`?t.pull_requests.find(e=>e.impact.state===`ok`)?.number??null:null}function gp(e,t){let n=0,r=0,i=0;for(let a of e.paths)a.owners.includes(t)&&(a.added===null||a.deleted===null?i+=1:(n+=a.added,r+=a.deleted));return{added:n,deleted:r,unknown:i}}function _p(e,t){return e.dependents.filter(e=>e.id===t).map(e=>e.touched)}function vp(e){return[`paths`,`nodes`,`relations`,`flow_steps`,`dependents`,`model`].filter(t=>e[t])}function yp(e,t){let n=new Map(e.nodes.map(e=>[e.id,{tone:`change`,label:t(e)}]));for(let t of e.dependents)n.has(t.id)||n.set(t.id,{tone:`muted`,label:`↳`});return n}function bp(e){return e.failed>0?`danger`:e.passed>0&&e.passed+e.skipped===e.files?`success`:`muted`}function xp(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map;for(let r of e.nodes)for(let e=r;e!==void 0;e=e.parent===null?void 0:t.get(e.parent))if(e.kind===`capability`){n.set(r.id,e.id);break}return n}var Sp={available:!1,marks:new Map,edges:[]};function Cp(e,t,n=null){let r=xp(e),i=(e,t=[])=>({available:e.size>0,marks:e,edges:t}),a=(e,t)=>{let n=new Map;for(let[i,a]of e){let e=r.get(i);e!==void 0&&n.set(e,{tone:t,count:(n.get(e)?.count??0)+a,atLeast:!1})}return n},o=(e,t)=>{for(let n of t.dependents){let t=r.get(n.id);t!==void 0&&!e.has(t)&&e.set(t,{tone:`muted`,count:null,atLeast:!1})}return e};if(t===`changes`){let{changes:t}=e.layers;if(t.state!==`ok`)return Sp;let n=a(t.commits.flatMap(e=>[...new Set(e.nodes.flatMap(e=>r.get(e)??[]))].map(e=>[e,1])),`change`);return i(o(new Map(t.nodes.flatMap(e=>r.get(e.id)??[]).map(e=>[e,{tone:`change`,count:n.get(e)?.count??0,atLeast:t.truncated.paths}])),t))}let s=e=>e.flatMap(e=>[...new Set(e.ids.flatMap(e=>r.get(e)??[]))].map(t=>[t,e.count]));if(t===`violations`){let{debt:t,flows:n,anchors:o,dependencies:c,layer_direction:l}=e.layers.violations;if(Object.values(e.layers.violations).every(e=>e.state!==`ok`))return Sp;let u=c.state===`ok`?c.edges.filter(e=>r.get(e.source)===e.source&&r.get(e.target)===e.target):[];return i(a(s([...t.state===`ok`?t.items.map(e=>({ids:e.nodes,count:1})):[],...n.state===`ok`?n.unprovable.map(e=>({ids:[e.id],count:1})):[],...o.state===`ok`?o.nodes.map(e=>({ids:[e.id],count:e.findings.length})):[],...c.state===`ok`?c.edges.map(e=>({ids:[e.source],count:1})):[],...l.state===`ok`?l.edges.map(e=>({ids:[e.source],count:1})):[]]),`danger`),u)}if(t===`tests`){let{tests:t}=e.layers;return t.state===`ok`?i(new Map(t.capabilities.map(e=>[e.id,{tone:bp(e),count:null,atLeast:!1}]))):Sp}if(t===`pull_requests`){let{pull_requests:t}=e.layers,a=t.state===`ok`?t.pull_requests.find(e=>e.number===n)?.impact:void 0;if(a?.state!==`ok`)return Sp;let s=new Map;for(let e of a.paths)for(let t of new Set(e.owners.flatMap(e=>r.get(e)??[])))s.set(t,(s.get(t)??0)+1);return i(o(new Map(a.nodes.flatMap(e=>r.get(e.id)??[]).map(e=>[e,{tone:`change`,count:s.get(e)??0,atLeast:a.truncated.paths}])),a))}return i(a(s(e.layers.decisions.items.map(e=>({ids:e.applies_to,count:1}))),`muted`))}function wp(e,t,n=null){let r=(t,n=[])=>{let r=up(e,t.keys());return{available:r.size>0,marks:t,lit:r,edges:n}};if(t===`changes`){let{changes:t}=e.layers;return t.state===`ok`?r(yp(t,e=>{let n=gp(t,e.id);return`+${n.added} −${n.deleted}${n.unknown>0?` ?`:``}`})):lp}if(t===`violations`){if(Object.values(e.layers.violations).every(e=>e.state!==`ok`))return lp;let{dependencies:t}=e.layers.violations;return r(new Map([...fp(e)].map(([e,t])=>[e,{tone:`danger`,label:String(t)}])),t.state===`ok`?t.edges:[])}if(t===`tests`){let{tests:t}=e.layers;return t.state===`ok`?r(new Map(t.capabilities.map(e=>[e.id,{tone:bp(e),label:`${e.passed}/${e.files}`}]))):lp}if(t===`pull_requests`){let{pull_requests:t}=e.layers,i=t.state===`ok`?t.pull_requests.find(e=>e.number===n)?.impact:void 0;return i?.state===`ok`?r(yp(i,e=>String(e.files))):lp}let i=new Map;for(let t of e.layers.decisions.items)for(let e of t.applies_to)i.set(e,(i.get(e)??0)+1);return r(new Map([...i].map(([e,t])=>[e,{tone:`muted`,label:String(t)}])))}var Tp=.85,Ep=24,Dp=120;function Op(e,t){let n=Math.min((t.width-48)/e.width,(t.height-Ep-Dp)/e.height);if(!(t.width>0)||!(t.height>0)||n<Tp)return{x:Ep-e.x*Tp,y:Ep-e.y*Tp,zoom:Tp};let r=Math.min(n,1);return{x:(t.width-e.width*r)/2-e.x*r,y:Ep+(t.height-Ep-Dp-e.height*r)/2-e.y*r,zoom:r}}function kp({content:e}){let t=J(),n=Jc(),r=q(e=>e.panZoom!==null&&e.width>0&&e.height>0),i=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{if(!r||i.current)return;i.current=!0;let{width:a,height:o}=t.getState();n.setViewport(Op(e,{width:a,height:o}))},[r,e,n,t]),null}function Ap(e,t,n,r=!1){return`${r?`≥`:``}${e(t===1?`architecture.unit.${n}One`:`architecture.unit.${n}`,{count:t})}`}function jp({part:e,reason:t,code:n,children:r}){return(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":e,"data-reason":t,"data-code":n,children:r})}function Mp({part:e,reason:t,children:n}){return(0,W.jsx)(`div`,{className:`architecture-map__note`,"data-note":e,"data-reason":t,children:n})}function Np({mark:e}){return e===null?null:(0,W.jsx)(`span`,{className:`architecture-map__mark mono-value`,"data-tone":e.tone,children:e.label})}function Pp({bounds:e,t}){let n=Jc(),{zoom:r}=nd();return(0,W.jsxs)(`div`,{className:`architecture-map__zoom`,role:`group`,"aria-label":t(`architecture.map.zoom`),children:[(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomOut`),onClick:()=>{n.zoomOut()},children:`−`}),(0,W.jsxs)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomReset`),className:`mono-value`,onClick:()=>{n.zoomTo(1)},children:[Math.round(r*100),`%`]}),(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomIn`),onClick:()=>{n.zoomIn()},children:`+`}),(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.fitLabel`),onClick:()=>{e?n.fitBounds(e,{padding:.1}):n.fitView()},children:t(`architecture.map.fit`)})]})}function Fp({part:e,t}){let n=Yd(e);return(0,W.jsxs)(`div`,{className:`copy-value architecture-map__command`,children:[(0,W.jsx)(`code`,{"data-fix-command":e,children:n}),(0,W.jsx)(p,{label:t(`architecture.inspector.command`),value:n,t})]})}function Ip(e,t){return e.sizes.state===`ok`?e.sizes.nodes.find(e=>e.id===t)??null:null}function Lp(e){return Jd[e].filter(e=>!e.startsWith(`--`)).join(` `)}function Rp(e,t,n,r){let{debt:i,flows:a,anchors:o,dependencies:s,layer_direction:c}=e.layers.violations,l=[];if(i.state===`ok`&&i.items.forEach((e,n)=>{e.nodes.some(e=>t.has(e))&&l.push({key:`debt-${n}`,text:r(`architecture.layer.debt.${e.kind}`),paths:e.paths,part:`debt`})}),a.state===`ok`){for(let e of a.unprovable.filter(e=>t.has(e.id)))l.push({key:`flows-${e.id}`,text:r(`architecture.layer.node.flows`,{count:e.diagnostics}),part:`flows`});let n=new Map(a.evidence.map(e=>[nf(e),e.status]));for(let i of e.flows.filter(e=>t.has(e.capability)))rf(i).forEach(({outcome:e,step:t},a)=>{let o=n.get(nf(t.evidence));o!==void 0&&o!==`proven`&&l.push({key:`flow-step-${i.id}-${e??``}-${t.id}`,part:`flows`,text:r(`architecture.layer.node.flow_step`,{flow:i.name,step:a+1,label:t.label,status:o})})})}if(o.state===`ok`)for(let e of o.nodes.filter(e=>t.has(e.id)))e.findings.forEach((t,n)=>l.push({key:`anchors-${e.id}-${n}`,part:`anchors`,text:r(`architecture.layer.node.anchor`,{origin:r(`architecture.layer.anchor.${t.origin}`),citation:t.citation,kind:t.kind}),paths:t.path===null?void 0:[t.line===null?t.path:`${t.path}:${t.line}`]}));if(s.state===`ok`)for(let e of s.edges.filter(e=>t.has(e.source)))l.push({key:`undeclared-${e.source}-${e.target}`,text:r(`architecture.layer.node.undeclared`,{name:n.get(e.target)??e.target,count:e.imports}),part:`dependencies`});if(c.state===`ok`)for(let e of c.edges.filter(e=>t.has(e.source)))l.push({key:`layer-${e.source}-${e.target}`,part:`layer_direction`,text:r(`architecture.layer.node.layer_direction`,{name:n.get(e.target)??e.target,count:e.imports,from:e.source_layer,to:e.target_layer})});return l}function zp({facts:e,layer:t,source:n=!1}){return(0,W.jsx)(`ul`,{"data-layer-facts":t,children:e.map(e=>(0,W.jsxs)(`li`,{children:[e.text,e.paths?.length?(0,W.jsx)(`ul`,{children:e.paths.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e})},e))}):null,n&&e.part!==void 0&&(0,W.jsx)(`span`,{className:`architecture-map__source mono-value`,"data-fact-source":e.part,children:Lp(e.part)})]},e.key))})}function Bp({map:e,layer:t,pullRequest:n,nodeId:r,names:i,t:a}){if(t===`violations`)return null;let o=[],{changes:s,pull_requests:c,tests:l,decisions:u}=e.layers,d=(e,t)=>{let n=e.nodes.find(e=>e.id===r);n&&o.push({key:`impact`,text:t(n.files),paths:e.paths.filter(e=>e.owners.includes(r)).map(e=>e.path)});let s=_p(e,r);s.length>0&&o.push({key:`dependent`,text:a(`architecture.layer.node.dependent`,{names:s.map(e=>i.get(e)??e).join(`, `)})})};if(t===`changes`&&s.state===`ok`){let e=gp(s,r);d(s,t=>a(`architecture.layer.node.changes`,{files:Ap(a,t,`file`),added:e.added,deleted:e.deleted})+(e.unknown>0?` ${a(`architecture.layer.node.lines_unknown`,{count:e.unknown})}`:``))}let f=c.state===`ok`?c.pull_requests.find(e=>e.number===n)?.impact:void 0;if(t===`pull_requests`&&f?.state===`ok`&&d(f,e=>a(`architecture.layer.node.pull_request`,{files:Ap(a,e,`file`),number:n})),t===`tests`&&l.state===`ok`){let e=l.capabilities.find(e=>e.id===r);e&&o.push({key:`tests`,text:a(`architecture.layer.node.tests`,{files:e.files,passed:e.passed,failed:e.failed,skipped:e.skipped,noResult:e.no_result})})}if(t===`decisions`)for(let e of u.items.filter(e=>e.applies_to.includes(r)))o.push({key:`decision-${e.id}`,text:e.status===null?e.title:a(`architecture.layer.node.decision`,{title:e.title,status:e.status}),paths:[e.path]});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:a(`architecture.layer.${t}`)}),o.length?(0,W.jsx)(zp,{facts:o,layer:t}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.layer.node.none`)})]})}function Vp({map:e,nodeId:t,t:n}){let{pull_requests:r}=e.layers;if(r.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-related-prs-gap":r.reason,children:n(`architecture.layer.pull_requests.${r.reason}`)});let i=r.pull_requests.flatMap(e=>{if(e.impact.state!==`ok`)return[];let r=e.impact.nodes.find(e=>e.id===t)?.files;return r===void 0?_p(e.impact,t).length>0?[{pr:e,text:n(`architecture.inspector.pr.depends`)}]:[]:[{pr:e,text:n(`architecture.inspector.pr.changes`,{files:Ap(n,r,`file`)})}]});return i.length?(0,W.jsx)(`ul`,{"data-related-prs":!0,children:i.map(({pr:e,text:t})=>(0,W.jsxs)(`li`,{"data-pull-request-number":e.number,children:[(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title,` · `,t]},e.number))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)})}function Hp({facts:e,source:t=!1,t:n}){let r=[...new Set(e.flatMap(e=>e.part?[e.part]:[]))];return(0,W.jsxs)(W.Fragment,{children:[e.length?(0,W.jsx)(zp,{facts:e,layer:`violations`,source:t}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)}),r.map(e=>(0,W.jsx)(Fp,{part:e,t:n},e))]})}function Up({map:e,layer:t,pullRequest:n,nodeId:r,onModule:i,t:a,children:o}){let s=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),c=e.nodes.find(e=>e.id===r);if(c===void 0)return null;let l=Ip(e,r);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{children:c.name}),(0,W.jsx)(`code`,{className:`architecture-map__id`,children:c.id}),(0,W.jsx)(`p`,{children:c.summary}),(0,W.jsxs)(`dl`,{className:`detail-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.kind`)}),(0,W.jsx)(`dd`,{children:c.kind})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.layer`)}),(0,W.jsx)(`dd`,{children:c.layer??a(`architecture.none`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.status`)}),(0,W.jsx)(`dd`,{children:c.status})]}),e.sizes.state===`ok`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.size`)}),(0,W.jsx)(`dd`,{"data-node-size":!0,children:l===null?a(`architecture.map.noSize`):a(`architecture.map.sizeValue`,{lines:l.lines,files:l.files})})]})]}),c.kind===`capability`&&(0,W.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(c.id),children:a(`architecture.map.open`)}),o,(0,W.jsx)(Bp,{map:e,layer:t,pullRequest:n,nodeId:c.id,names:s,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.inspector.pullRequests`)}),(0,W.jsx)(Vp,{map:e,nodeId:c.id,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),(0,W.jsx)(Hp,{facts:Rp(e,new Set([c.id]),s,a),t:a}),(0,W.jsx)(Wp,{map:e,nodeId:c.id,names:s,t:a})]})}function Wp({map:e,nodeId:t,names:n,t:r}){let i=e.dependencies.state===`ok`?e.dependencies.edges:[],a=a=>e.relations.filter(e=>(a===`out`?e.source:e.target)===t).map(e=>{let t=a===`out`?e.target:e.source,o=i.find(t=>t.source===e.source&&t.target===e.target)?.imports;return(0,W.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,W.jsx)(`code`,{children:e.kind}),` `,n.get(t),o!==void 0&&(0,W.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:o})]})]},e.id)}),o=a(`out`),s=a(`in`);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.map.outgoing`,{count:o.length})}),o.length?(0,W.jsx)(`ul`,{children:o}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}),(0,W.jsx)(`h4`,{children:r(`architecture.map.incoming`,{count:s.length})}),s.length?(0,W.jsx)(`ul`,{children:s}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)})]})}var Gp={route:(0,I.memo)(function({data:e,markerStart:t,markerEnd:n,style:r}){let{route:i,label:a}=e;return(0,W.jsx)(tu,{path:hi(i.points),markerStart:t,markerEnd:n,style:r,label:a?.text,labelX:a===null?void 0:a.x+a.width/2,labelY:a===null?void 0:a.y+a.height/2,labelBgPadding:[4,2]})})};function Kp(){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(xl,{type:`target`,position:G.Top,isConnectable:!1}),(0,W.jsx)(xl,{type:`source`,position:G.Bottom,isConnectable:!1})]})}var qp=e=>[{type:`target`,position:G.Top,x:e.width/2,y:0,width:1,height:1},{type:`source`,position:G.Bottom,x:e.width/2,y:e.height,width:1,height:1}];function Jp(e,t,n){let r=URL.createObjectURL(new Blob([Bi(t,n)],{type:`image/svg+xml`})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}var Yp=()=>null;function Xp({scene:e,nodeTypes:t,view:n,selected:r,emphasis:i=r,routeLabel:a,routeSelection:o=Yp,onSelect:s,legend:c,t:l}){let u=(0,I.useMemo)(()=>new Map(e.boxes.map(e=>[e.id,n(e)])),[e,n]),d=(0,I.useMemo)(()=>Ni(e),[e]),f=(0,I.useMemo)(()=>{let t=new Map(e.boxes.map(e=>[e.id,e]));return e.boxes.map(e=>{let n=e.parent===null?null:t.get(e.parent),i=u.get(e.id);return{id:e.id,type:i.type,data:i.data,ariaLabel:i.ariaLabel,position:{x:e.x-(n?.x??0),y:e.y-(n?.y??0)},width:e.width,height:e.height,handles:qp(e),...n?{parentId:n.id}:{},draggable:!1,connectable:!1,selected:i.selection!==null&&i.selection===r,...i.selection===null?{selectable:!1,focusable:!1}:{}}})},[e,u,r]),p=(0,I.useMemo)(()=>{let t=new Map(e.labels.filter(e=>e.route!==null).map(e=>[e.route,e]));return e.routes.map(e=>{let n=o(e),s=n!==null&&n===r,c=s||i!==null&&(e.source===i||e.target===i),l={type:oa.ArrowClosed,width:14,height:14,color:c?`var(--rh-accent)`:`var(--text-color-kumo-subtle)`};return{id:e.id,type:`route`,source:e.source,target:e.target,className:`architecture-map__edge architecture-map__edge--${e.kind}${c?` is-active`:r===null?``:` is-dim`}`,style:{strokeWidth:e.width,...e.dashed?{strokeDasharray:`6 4`}:{}},...e.arrows.start?{markerStart:l}:{},...e.arrows.end?{markerEnd:l}:{},data:{route:e,label:t.get(e.id)??null},selectable:n!==null,focusable:n!==null,selected:s,zIndex:c?2:1,...a?{ariaLabel:a(e)}:{}}})},[e,r,i,a,o]),m=(0,I.useRef)(r);m.current=r;let h=(0,I.useMemo)(()=>new Map(e.routes.map(e=>[e.id,e])),[e]),g=(0,I.useCallback)((e,t)=>{let n=e.filter(e=>e.type===`select`),r=n.find(e=>e.selected),i=r?t(r.id):n.some(e=>t(e.id)===m.current)?null:void 0;i!==void 0&&(m.current=i,s(i))},[s]),_=(0,I.useCallback)(e=>g(e,e=>u.get(e).selection),[g,u]),v=(0,I.useCallback)(e=>g(e,e=>o(h.get(e))),[g,h,o]);return(0,W.jsxs)(ed,{nodes:f,edges:p,nodeTypes:t,edgeTypes:Gp,onNodesChange:_,onEdgesChange:v,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.05,maxZoom:2,attributionPosition:`top-right`,children:[(0,W.jsx)(kp,{content:d}),(0,W.jsx)(ld,{variant:ad.Dots,gap:20,size:1.5,color:`var(--rh-diagram-dot)`}),(0,W.jsx)(oc,{position:`bottom-left`,children:(0,W.jsx)(`dl`,{className:`architecture-map__legend`,"aria-label":l(`architecture.map.legend`),children:c.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.swatch}),(0,W.jsx)(`dd`,{children:e.text})]},e.key))})}),(0,W.jsx)(oc,{position:`bottom-right`,children:(0,W.jsx)(Pp,{bounds:d,t:l})})]})}function Zp({label:e,...t}){return(0,W.jsx)(`div`,{className:`architecture-map__canvas`,"aria-label":e,role:`region`,children:(0,W.jsx)(Xu,{children:(0,W.jsx)(Xp,{...t})})})}var Qp=25,$p=e=>`domain:${e}`,em=e=>`${e.source}->${e.target}`;function tm(e){let t=new Set([...e.added,...e.removed,...e.renamed].flatMap(e=>e.kind===`capability`?[e.id]:[]));return new Set([...e.added,...e.removed,...e.renamed].flatMap(e=>e.kind!==`capability`&&e.capability!==null&&!t.has(e.capability)?[e.capability]:[]))}function nm(e,t){let{delta:n}=t,r=e.find(e=>e.rev===n.baseRev),i=new Map((r?.nodes??[]).map(e=>[e.id,e])),a=n.removed.flatMap(e=>e.kind===`capability`&&i.has(e.id)?[i.get(e.id)]:[]),o=[...t.nodes,...a],s=[...new Set(o.flatMap(e=>e.domain===null?[]:[e.domain]))],c=new Map;for(let e of n.added)e.kind===`capability`&&c.set(e.id,`added`);for(let e of n.removed)e.kind===`capability`&&c.set(e.id,`removed`);for(let e of n.renamed)e.kind===`capability`&&c.set(e.id,`renamed`);for(let e of tm(n))c.set(e,`inside`);let l=new Set(o.map(e=>e.id)),u=n.edgesChanged.removed.filter(e=>l.has(e.source)&&l.has(e.target));return{input:{nodes:[...s.map(e=>({id:$p(e),kind:`domain`,name:e,parent:null})),...o.map(e=>({id:e.id,kind:`capability`,name:e.name,parent:e.domain===null?null:$p(e.domain)}))],relations:[...t.edges,...u].map(e=>({id:em(e),kind:`relation`,source:e.source,target:e.target}))},nodes:c,renamed:new Map(n.renamed.filter(e=>e.kind===`capability`).map(e=>[e.id,{from:e.from,to:e.to}])),edges:new Map([...n.edgesChanged.added.map(e=>[em(e),`added`]),...u.map(e=>[em(e),`removed`])]),capabilities:new Map(o.map(e=>[e.id,e]))}}function rm(e,t){let{baseRev:n}=t.delta;if(n===null)return 0;let r=e.findIndex(e=>e.rev===n);return r===-1?null:e.indexOf(t)-r-1}var im=e=>e instanceof Error&&/^[a-z][a-z0-9_]{0,63}$/u.test(e.message)?e.message:`unavailable`;function am(e,t,n){let r={path:e,timeline:null,error:null,more:{loading:!1,error:null}},[i,a]=(0,I.useState)(r),o=(0,I.useRef)(null),s=(0,I.useCallback)(async n=>{let i=t=>{o.current?.path!==e&&(o.current=null),a(n=>n.path===e?{...n,error:t}:{...r,error:t})};try{let r=await t(`${e}?offset=0&limit=1`,o.current?.path===e?o.current.etag:null,n);if(n.aborted)return!1;if(r===null)return a(e=>e.error===null?e:{...e,error:null}),!0;if(`state`in r)return i(r.reason),l(r);let s=r.body,c=Math.max(0,s.total-Qp),u=s;if(s.total>1){let r=await t(`${e}?offset=${c}&limit=${Qp}&ref=${s.head}`,null,n);if(n.aborted)return!1;if(`state`in r)return i(r.reason),l(r);u=r.body}return o.current=r.etag===null?null:{path:e,etag:r.etag},a({path:e,timeline:{head:s.head,total:s.total,start:c,milestones:u.milestones},error:null,more:{loading:!1,error:null}}),!0}catch(e){return n.aborted||i(im(e)),!1}},[e,t]),u=c(s,JSON.stringify([e,n])),d=i.path===e?i:r,f=(0,I.useCallback)(()=>{let n=d.timeline;if(n===null||d.more.loading||n.start===0)return;let r=Math.max(0,n.start-Qp),i=t=>t.path===e&&t.timeline?.head===n.head&&t.timeline.start===n.start,o=e=>a(t=>i(t)?{...t,more:{loading:!1,error:e}}:t);a(e=>i(e)?{...e,more:{loading:!0,error:null}}:e),t(`${e}?offset=${r}&limit=${n.start-r}&ref=${n.head}`,null,new AbortController().signal).then(e=>{if(e!==null&&`state`in e){o(e.reason);return}let t=e.body;a(e=>i(e)?{...e,timeline:{...n,start:r,milestones:[...t.milestones,...n.milestones]},more:{loading:!1,error:null}}:e)},e=>o(im(e)))},[e,t,d]);return{...d,loadMore:f,retry:u}}var om={added:`+`,removed:`−`,renamed:`~`,inside:`•`},sm=e=>e.slice(0,7),cm={box:(0,I.memo)(function({id:e,data:t,selected:n}){let{name:r,diff:i,from:a,quiet:o}=t;return(0,W.jsxs)(`div`,{className:`architecture-history__node`,title:e,"data-node-id":e,"data-diff":i??void 0,"data-quiet":o||void 0,"data-selected":n||void 0,children:[(0,W.jsx)(Kp,{}),(0,W.jsx)(`b`,{className:`architecture-history__mark`,"aria-hidden":`true`,children:i&&om[i]}),(0,W.jsxs)(`span`,{className:`architecture-history__name`,children:[(0,W.jsx)(`span`,{children:r}),a!==null&&(0,W.jsx)(`s`,{className:`architecture-history__from`,children:a})]})]})}),group:(0,I.memo)(function({id:e,data:t}){return(0,W.jsxs)(`div`,{className:`architecture-history__group`,"data-node-id":e,children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`span`,{children:[t.name,` · `,t.count]})]})})};function lm(e,t){if(e.delta.baseRev===null)return{nodes:new Map,edges:new Map,touched:new Set};let n=new Set(t.nodes.keys());for(let e of t.input.relations)t.edges.has(e.id)&&(n.add(e.source),n.add(e.target));return{nodes:t.nodes,edges:t.edges,touched:n}}function um(e,t){return{nodes:e.input.nodes,relations:e.input.relations.map(e=>({...e,kind:t.get(e.id)??`relation`}))}}var dm=[`removed`,`added`,`renamed`,`inside`];function fm(e,t){for(let n of dm)for(let[r,i]of e.nodes)if(i===n&&t.capabilities.has(r))return r;return t.capabilities.keys().next().value??null}function pm(e,t,n){let{baseRev:r}=e.delta;if(r===null)return n(`architecture.history.caption.first`,{rev:sm(e.rev)});let i={base:sm(r),rev:sm(e.rev)};return t===null?n(`architectureHistory.caption.unread`,i):t>0?n(`architectureHistory.caption.skipped`,{...i,count:t}):`${i.base} → ${i.rev}`}function mm(e){return[...[`added`,`removed`,`renamed`,`inside`].map(t=>({key:t,swatch:(0,W.jsx)(`i`,{className:`architecture-history__swatch`,"data-diff":t}),text:e(`architecture.history.diff.${t}`)})),...[`added`,`removed`].map(t=>({key:`edge-${t}`,swatch:(0,W.jsx)(`i`,{className:`architecture-history__line`,"data-diff":t}),text:e(`architecture.history.edge.${t}`)}))]}function hm({milestone:e,shape:t,marks:n,skipped:r,selected:i,onSelect:a,t:o}){let[s,c]=(0,I.useState)(!1),l=e.delta.baseRev!==null,u=l&&s,d=(0,I.useMemo)(()=>Yi(um(t,n.edges)),[t,n]),f=(0,I.useMemo)(()=>new Map(t.input.nodes.map(e=>[e.id,e])),[t]),p=(0,I.useMemo)(()=>{let e=new Map;for(let n of t.input.nodes)n.parent!==null&&e.set(n.parent,(e.get(n.parent)??0)+1);return e},[t]),m=(0,I.useCallback)(e=>{let r=f.get(e.id);if(e.kind===`frame`)return{type:`group`,ariaLabel:`${r.kind} ${r.name}`,selection:null,data:{name:r.name,count:p.get(r.id)??0}};let i=n.nodes.get(r.id)??null;return{type:`box`,selection:r.id,ariaLabel:`${r.kind} ${r.name}${i?` (${o(`architecture.history.diff.${i}`)})`:``}`,data:{name:r.name,diff:i,from:i===`renamed`?t.renamed.get(r.id).from:null,quiet:u&&!n.touched.has(r.id)}}},[f,p,n,t,u,o]),h=(0,I.useCallback)(e=>{let t=[o(`architecture.modules.route.relation`,{source:f.get(e.source).name,target:f.get(e.target).name}),`${d.relations.get(e.id).length} ${o(`architecture.history.count.relations`)}`];return(e.kind===`relation`?t:[...t,o(`architecture.history.edge.${e.kind}`)]).join(` · `)},[f,d,o]),g=(0,I.useMemo)(()=>mm(o),[o]);return(0,W.jsxs)(`div`,{className:`architecture-history__stage`,"data-focus":u||void 0,children:[(0,W.jsxs)(`div`,{className:`architecture-history__bar`,children:[(0,W.jsx)(`p`,{className:`architecture-history__caption`,"data-base-rev":e.delta.baseRev??``,children:pm(e,r,o)}),(0,W.jsxs)(`label`,{className:`architecture-history__focus`,children:[(0,W.jsx)(`button`,{type:`button`,role:`switch`,className:`architecture-history__switch`,"aria-checked":u,disabled:!l,onClick:()=>c(!s)}),o(`architecture.history.focus`)]})]}),(0,W.jsx)(Zp,{label:o(`architecture.history.map`),scene:d.scene,nodeTypes:cm,view:m,selected:i,emphasis:null,routeLabel:h,onSelect:a,legend:g,t:o})]})}function gm({github:e,rev:t}){return e===null?(0,W.jsx)(`code`,{children:sm(t)}):(0,W.jsxs)(`a`,{href:`https://github.com/${e}/commit/${t}`,target:`_blank`,rel:`noreferrer`,children:[(0,W.jsx)(`code`,{children:sm(t)}),` ↗`]})}function _m({milestone:e,skipped:t,t:n}){if(e.error)return(0,W.jsx)(`span`,{className:`architecture-history__chips`,children:(0,W.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`error`,children:e.error.code})});let{delta:r}=e;if(r.baseRev===null)return(0,W.jsx)(`span`,{className:`architecture-history__chips`,children:(0,W.jsx)(`span`,{className:`architecture-history__chip`,children:n(`architecture.history.chip.first`)})});let i=r.edgesChanged.added.length+r.edgesChanged.removed.length,a=tm(r).size;return(0,W.jsxs)(`span`,{className:`architecture-history__chips`,children:[r.added.length>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`added`,children:[`+`,r.added.length]}),r.removed.length>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`removed`,children:[`−`,r.removed.length]}),r.renamed.length>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`renamed`,children:[`~`,r.renamed.length]}),a>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`inside`,title:n(`architecture.history.diff.inside`),children:[`•`,a]}),i>0&&(0,W.jsx)(`span`,{className:`architecture-history__chip`,children:n(`architecture.history.chip.relations`,{added:r.edgesChanged.added.length,removed:r.edgesChanged.removed.length})}),t!==null&&t>0&&(0,W.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`gap`,children:n(`architecture.history.chip.gap`,{count:t,rev:sm(r.baseRev)})})]})}function vm({timeline:e,selected:t,onSelect:n,more:r,onMore:i,t:a}){let{milestones:o}=e,s=(0,I.useMemo)(()=>[...o].reverse(),[o]),c=(0,I.useRef)(null),l=e=>{let t=s[Math.min(s.length-1,Math.max(0,e))];n(t.rev),c.current?.querySelector(`[data-milestone-rev="${t.rev}"]`)?.scrollIntoView({block:`nearest`})};return(0,W.jsxs)(`nav`,{className:`architecture-history__timeline`,"aria-label":a(`architecture.history.timeline`),children:[e.total===0&&(0,W.jsx)(`p`,{className:`architecture-history__empty`,children:a(`architecture.history.empty`)}),(0,W.jsx)(`ol`,{ref:c,role:`listbox`,tabIndex:0,"aria-label":a(`architecture.history.timeline`),"aria-activedescendant":`history-milestone-${t}`,onKeyDown:e=>{let n=s.findIndex(e=>e.rev===t),r={ArrowDown:n+1,ArrowUp:n-1,Home:0,End:s.length-1}[e.key];r!==void 0&&s.length!==0&&(e.preventDefault(),l(r))},children:s.map(e=>(0,W.jsxs)(`li`,{id:`history-milestone-${e.rev}`,role:`option`,"aria-selected":e.rev===t,"data-milestone-rev":e.rev,"data-state":e.error?`error`:`ok`,onClick:()=>n(e.rev),children:[(0,W.jsxs)(`span`,{className:`architecture-history__top`,children:[(0,W.jsx)(`code`,{children:sm(e.rev)}),(0,W.jsx)(`time`,{dateTime:e.date,title:e.date,children:e.date.slice(5,10)})]}),(0,W.jsx)(`span`,{className:`architecture-history__subject`,title:e.subject,children:e.subject}),(0,W.jsx)(_m,{milestone:e,skipped:e.error?0:rm(o,e),t:a})]},e.rev))}),e.start>0&&(0,W.jsx)(`button`,{type:`button`,className:`architecture-history__load`,disabled:r.loading,onClick:i,children:a(`architectureHistory.more`,{count:Math.min(Qp,e.start),head:sm(e.head)})}),r.error!==null&&(0,W.jsx)(`p`,{className:`architecture-history__callout`,"data-tone":`error`,role:`alert`,"data-error-code":r.error,children:a(`architecture.history.moreFailed`,{code:r.error})})]})}function ym(e,t,n,r,i){let{baseRev:a}=t.delta;if(a===null)return i(`architectureHistory.what.first`);let o=n.nodes.get(e);return o===`renamed`?i(`architectureHistory.what.renamed`,r.renamed.get(e)):o===`removed`?i(`architectureHistory.what.removed`,{rev:sm(a)}):i(o===void 0?`architectureHistory.what.same`:`architectureHistory.what.${o}`)}function bm(e,t){let{delta:n}=e;if(n.baseRev===null)return[];let r=e=>e.source===t||e.target===t;return[...n.edgesChanged.added.filter(r).map(e=>({edge:e,diff:`added`})),...n.edgesChanged.removed.filter(r).map(e=>({edge:e,diff:`removed`}))]}function xm({milestone:e,shape:t,marks:n,skipped:r,selected:i,github:a,t:o}){let s=o(`architectureHistory.node`);if(e.error)return(0,W.jsx)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,children:(0,W.jsxs)(`p`,{className:`architecture-history__callout`,"data-tone":`error`,"data-gap":`milestone`,"data-code":e.error.code,children:[o(`architecture.history.error`),` `,(0,W.jsx)(`code`,{children:e.error.code}),e.error.path&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`br`,{}),(0,W.jsx)(`code`,{children:e.error.path})]})]})});let{baseRev:c}=e.delta,l=i===null?null:t.capabilities.get(i),u=l===null?[]:bm(e,l.id),d=e=>{let n=t.capabilities.get(e);return n===void 0?(0,W.jsx)(`code`,{children:e}):n.name};return(0,W.jsxs)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,"data-node-id":l?.id,children:[l!==null&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`header`,{children:[(0,W.jsx)(`p`,{className:`architecture-history__eyebrow`,children:l.domain??`—`}),(0,W.jsx)(`h3`,{children:l.name}),(0,W.jsx)(`code`,{children:l.id})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h4`,{children:o(`architectureHistory.milestone`)}),(0,W.jsx)(`p`,{"data-diff":n.nodes.get(l.id),children:ym(l.id,e,n,t,o)})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h4`,{children:o(`architectureHistory.relations`)}),u.length===0?(0,W.jsx)(`p`,{className:`architecture-history__quiet`,children:o(`architectureHistory.none`)}):(0,W.jsx)(`ul`,{children:u.map(({edge:e,diff:t})=>(0,W.jsxs)(`li`,{"data-diff":t,children:[(0,W.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":t,children:t===`added`?`+`:`−`}),(0,W.jsxs)(`span`,{children:[d(e.source),` → `,d(e.target)]})]},`${t}:${em(e)}`))})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h4`,{children:o(`architecture.history.base`)}),c===null?(0,W.jsx)(`p`,{className:`architecture-history__quiet`,"data-base-rev":``,children:o(`architecture.history.first`)}):(0,W.jsxs)(`p`,{"data-base-rev":c,children:[(0,W.jsx)(gm,{github:a,rev:c}),r!==null&&r>0&&(0,W.jsxs)(`span`,{className:`architecture-history__quiet`,"data-gap":`skipped`,"data-count":r,children:[` `,o(`architectureHistory.base.skipped`,{count:r})]})]})]})]})}function Sm({path:e,github:t,read:n,refreshGeneration:r,selection:i,select:a,onSummary:o,t:s}){let c=am(e,n,r),[l,u]=(0,I.useState)(null),{timeline:f}=c,p=(0,I.useMemo)(()=>f?.milestones??[],[f]),m=p.find(e=>e.rev===l)??p.at(-1)??null,h=m===null||m.error?null:m,g=(0,I.useMemo)(()=>h===null?null:nm(p,h),[p,h]),_=(0,I.useMemo)(()=>h===null||g===null?null:lm(h,g),[h,g]),v=h===null?0:rm(p,h),y=h!==null&&i?.scope===h.rev?i:null,b=g===null||_===null?null:y===null?fm(_,g):y.id!==null&&g.capabilities.has(y.id)?y.id:null,x=h?.rev??``,S=(0,I.useCallback)(e=>a({view:`history`,scope:x,id:e}),[a,x]),C=e=>{u(e),a({view:`history`,scope:``,id:null})},w=f?.head??null,T=f?.total??0;return(0,I.useEffect)(()=>{o(w===null?null:{head:w,read:p.length,total:T})},[w,p.length,T,o]),(0,I.useEffect)(()=>()=>o(null),[o]),f===null?c.error===`history_shallow_repository`?(0,W.jsxs)(`section`,{className:`architecture-history__whole-error`,role:`alert`,"data-error-code":c.error,children:[(0,W.jsx)(`code`,{children:`history-shallow-repository`}),(0,W.jsx)(`p`,{children:s(`architecture.history.shallow`)}),(0,W.jsx)(d,{command:`git fetch --unshallow`,t:s})]}):c.error===null?(0,W.jsx)(`p`,{role:`status`,children:s(`architecture.history.loading`)}):(0,W.jsx)(`p`,{className:`architecture-notice`,role:`alert`,"data-error-code":c.error,children:s(`architecture.failed`,{code:c.error})}):(0,W.jsxs)(`div`,{className:`architecture-history`,children:[c.error!==null&&(0,W.jsxs)(`div`,{className:`architecture-history__banner`,role:`alert`,"data-error-code":c.error,children:[(0,W.jsx)(`span`,{children:s(`architecture.refreshFailed`,{code:c.error})}),(0,W.jsx)(`button`,{type:`button`,onClick:c.retry,children:s(`architecture.history.retry`)})]}),(0,W.jsx)(`div`,{className:`architecture-history__body`,"data-stale":c.error!==null||void 0,children:m===null?(0,W.jsx)(`p`,{className:`architecture-history__empty`,children:s(`architecture.history.empty`)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vm,{timeline:f,selected:m.rev,onSelect:C,more:c.more,onMore:c.loadMore,t:s}),m.error?(0,W.jsxs)(`section`,{className:`architecture-history__canvas`,"aria-label":s(`architecture.history.map`),children:[(0,W.jsx)(`p`,{className:`architecture-history__caption`,children:s(`architectureHistory.caption.error`,{rev:sm(m.rev)})}),(0,W.jsxs)(`div`,{className:`architecture-history__canvas-error`,children:[(0,W.jsx)(`code`,{children:m.error.code}),m.error.path&&(0,W.jsx)(`p`,{children:(0,W.jsx)(`code`,{children:m.error.path})})]})]}):(0,W.jsx)(hm,{milestone:m,shape:g,marks:_,skipped:v,selected:b,onSelect:S,t:s},m.rev),(0,W.jsx)(xm,{milestone:m,shape:g,marks:_,skipped:v,selected:b,github:t,t:s})]})})]})}var Cm=40,wm=96,Tm=12,Em=24,Dm=e=>`label:${e}`,Om=(e,t)=>(t.lines??0)-(e.lines??0)||e.node.name.localeCompare(t.node.name);function km(e,t){let n=new Map(e.sizes.state===`ok`?e.sizes.nodes.map(e=>[e.id,e]):[]),r=new Map;for(let t of e.nodes)t.parent!==null&&r.set(t.parent,[...r.get(t.parent)??[],t.id]);let i=(t,i)=>e.sizes.state===`ok`?(n.get(t)?.[i]??0)-(r.get(t)??[]).reduce((e,t)=>e+(n.get(t)?.[i]??0),0):null,a=new Map(e.nodes.map(e=>[e.id,e.layer])),o=new Map;for(let t of e.relations){let e=a.get(t.source),n=a.get(t.target);if(e==null||n==null||e===n)continue;let r=qi.has(t.kind),i=`${e}\n${n}\n${r}`,s=o.get(i)??{source:e,target:n,dashed:r,relations:[],protocols:[]};s.relations.push(t.id),t.protocol!==null&&!s.protocols.includes(t.protocol)&&s.protocols.push(t.protocol),o.set(i,s)}let s=new Map(t.map((e,t)=>[e,t])),c=(e,t)=>[...o.values()].filter(n=>(t===`right`?n.source:n.target)===e).sort((e,n)=>s.get(t===`right`?e.target:e.source)-s.get(t===`right`?n.target:n.source)||Number(e.dashed)-Number(n.dashed)),l=e=>Tm*(1+Math.max(0,...t.map(t=>c(t,e).length))),u=120+l(`left`),d=u+656,f=t.map((t,n)=>{let r=e.nodes.filter(e=>e.layer===t).map(e=>({node:e,files:i(e.id,`files`),lines:i(e.id,`lines`)})).sort(Om),a=t=>e.sizes.state===`ok`?r.reduce((e,n)=>e+n[t],0):null;return{layer:t,index:n,members:r,files:a(`files`),lines:a(`lines`),x:u,y:Em+n*96,width:656,height:56}}),p=new Map(f.map(e=>[e.layer,e])),m=e=>e===null||!p.has(e)?[]:[`right`,`left`].flatMap(t=>{let n=c(e,t),r=t===`right`?d:u,i=t===`right`?Tm:-12,a=(e,t,n)=>e.y+e.height*(t+1)/(n+1),o=n.map(e=>t===`right`?e.target:e.source);return n.map((s,c)=>{let l=o[c],u=a(p.get(e),c,n.length),d=a(p.get(l),o.slice(0,c).filter(e=>e===l).length,o.filter(e=>e===l).length),f=r+i*(c+1),[m,h]=t===`right`?[u,d]:[d,u],g={id:`lane:${s.source}->${s.target}:${s.dashed?`runtime`:`code`}`,source:s.source,target:s.target,points:[[r,m],[f,m],[f,h],[r,h]],arrows:{start:!1,end:!0},kind:`lane`,dashed:s.dashed,width:1.5};return{...s,side:t,route:g}})}),h=f.flatMap(e=>[{id:Dm(e.layer),parent:null,x:Em,y:e.y,width:wm,height:e.height,kind:`band`},{id:e.layer,parent:null,x:e.x,y:e.y,width:e.width,height:e.height,kind:e.members.length===0?`external`:`box`}]),g={width:d+l(`right`)+Em,height:48+t.length*56+Math.max(0,t.length-1)*Cm};return{bands:f,lanes:m,scene:e=>({boxes:h.map(t=>t.id===e?{...t,kind:`${t.kind} selected`}:t),routes:m(e).map(e=>e.route),labels:[],extent:g})}}var Am=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e).toLowerCase(),jm=7,Mm=e=>`L${e.index} ${e.layer}`,Nm=e=>e.members.map(e=>e.node.name).join(` · `),Pm={label:(0,I.memo)(function({data:e}){return(0,W.jsx)(`span`,{className:`architecture-layermap__band`,children:Mm(e.band)})}),layer:(0,I.memo)(function({data:e,selected:t}){let{band:n,t:r}=e;return(0,W.jsxs)(`div`,{className:`architecture-layermap__box`,"data-layer-box":n.layer,"data-selected":t||void 0,"data-empty":n.members.length===0||void 0,children:[(0,W.jsx)(Kp,{}),(0,W.jsx)(`strong`,{children:n.layer}),(0,W.jsx)(`span`,{className:`architecture-layermap__members`,title:Nm(n),children:n.members.length===0?r(`architecture.layers.empty`):Nm(n)}),n.lines!==null&&(0,W.jsx)(`span`,{className:`architecture-layermap__lines mono-value`,children:Am(n.lines)})]})})};function Fm(e,t){return[{key:`code`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.layers.legend.runtime`)},...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,W.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k`}),text:t(`architecture.layers.legend.lines`)}]:[]]}function Im(e){return t=>{let n=e.get(t.id);return t.id===n.layer?[n.layer,[...n.lines===null?[]:[Am(n.lines)],Nm(n)].filter(Boolean).join(` · `)]:[Mm(n)]}}function Lm({band:e,t}){let n=e.members.filter(e=>e.lines>0);if(n.length===0)return(0,W.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.map.noSize`)});let r=n.slice(0,jm),i=n.slice(jm),a=[...r.map(e=>({key:e.node.id,name:e.node.name,lines:e.lines})),...i.length>0?[{key:`rest`,name:t(`architecture.layers.rest`,{count:i.length}),lines:i.reduce((e,t)=>e+t.lines,0)}]:[]],o=Math.max(...a.map(e=>e.lines));return(0,W.jsx)(`ul`,{className:`architecture-layermap__sizes`,"data-layer-sizes":!0,children:a.map(e=>(0,W.jsxs)(`li`,{"data-size-row":e.key,children:[(0,W.jsx)(`span`,{className:`architecture-layermap__size-name`,title:e.name,children:e.name}),(0,W.jsx)(`span`,{className:`architecture-layermap__bar`,children:(0,W.jsx)(`span`,{style:{width:`${Math.round(e.lines/o*100)}%`}})}),(0,W.jsx)(`span`,{className:`mono-value`,children:Am(e.lines)})]},e.key))})}function Rm({map:e,layer:t,t:n}){let r=e.layers.violations.layer_direction;if(r.state===`unavailable`){let e=r.reason===`archctx_error`?n(`architecture.layer.reason.archctx_error`,{code:dp(r)}):n(`architecture.layer.reason.${r.reason}`);return(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`layer_direction`,"data-reason":r.reason,children:n(`architecture.layer.violations.gap`,{part:n(`architecture.layer.violations.layer_direction.label`),reason:e})})}let i=new Map;for(let e of r.edges){if(e.source_layer!==t&&e.target_layer!==t)continue;let n=`${e.source_layer}\n${e.target_layer}`,r=i.get(n)??{source:e.source_layer,target:e.target_layer,imports:0};i.set(n,{...r,imports:r.imports+e.imports})}return(0,W.jsxs)(W.Fragment,{children:[i.size===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.layers.violations.none`)}):(0,W.jsx)(`ul`,{className:`architecture-layermap__pairs`,"data-layer-violations":!0,children:[...i.values()].map(e=>(0,W.jsxs)(`li`,{"data-pair":`${e.source}->${e.target}`,children:[(0,W.jsxs)(`span`,{children:[e.source,` → `,e.target]}),(0,W.jsx)(`span`,{className:`mono-value`,children:e.imports}),(0,W.jsx)(`span`,{className:`architecture-layermap__verdict`,children:n(`architecture.layers.violation`)})]},`${e.source}-${e.target}`))}),(0,W.jsx)(`p`,{className:`detail-quiet`,"data-layer-checked":!0,children:n(`architecture.layers.checked`,{imports:r.imports})})]})}var zm=e=>[`${e.source} → ${e.target}`,...e.protocols].join(` · `);function Bm({lanes:e,t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:t(`architecture.modules.relations`,{count:e.length})}),e.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.none`)}):(0,W.jsx)(`ul`,{"data-layer-lanes":!0,children:e.map(e=>{let n=e.side===`right`?`out`:`in`;return(0,W.jsxs)(`li`,{"data-lane":e.route.id,"data-direction":n,children:[(0,W.jsx)(`span`,{className:`architecture-map__swatch${e.dashed?` architecture-map__swatch--dashed`:``}`,role:`img`,"aria-label":t(e.dashed?`architecture.layers.legend.runtime`:`architecture.map.legend.code`)}),` `,(0,W.jsx)(`span`,{className:`mono-value`,children:t(`architecture.modules.direction.${n}`)}),` `,n===`out`?e.target:e.source,e.protocols.length>0&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`code`,{children:e.protocols.join(` · `)})]})]},e.route.id)})})]})}function Vm({map:e,band:t,lanes:n,t:r}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,W.jsxs)(`span`,{className:`architecture-modules__eyebrow`,children:[`L`,t.index]}),(0,W.jsx)(`h3`,{children:t.layer}),t.files!==null&&(0,W.jsx)(`span`,{className:`detail-quiet`,"data-layer-size":!0,children:r(`architecture.map.sizeValue`,{lines:t.lines,files:t.files})})]}),(0,W.jsx)(Bm,{lanes:n,t:r}),e.sizes.state===`ok`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.layers.size`)}),(0,W.jsx)(Lm,{band:t,t:r})]}),(0,W.jsx)(`h4`,{children:r(`architecture.layer.violations.layer_direction.label`)}),(0,W.jsx)(Rm,{map:e,layer:t.layer,t:r}),(0,W.jsxs)(`details`,{className:`architecture-layermap__nodes`,children:[(0,W.jsx)(`summary`,{children:r(`architecture.layers.members`,{count:t.members.length})}),(0,W.jsx)(`ul`,{children:t.members.map(e=>(0,W.jsxs)(`li`,{"data-member":e.node.id,children:[e.node.name,` `,(0,W.jsx)(`span`,{className:`detail-quiet`,children:e.node.kind})]},e.node.id))})]})]})}function Hm({map:e,t}){return e.sizes.state===`unavailable`?(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`sizes`,"data-reason":e.sizes.reason,children:t(`architecture.map.sizes.${e.sizes.reason}`)}):null}function Um({map:e,order:t,selected:n,onSelect:r,t:i}){let a=(0,I.useMemo)(()=>km(e,t),[e,t]),o=a.bands.find(e=>e.layer===n)??null,s=o?.layer??null,c=(0,I.useMemo)(()=>a.scene(s),[a,s]),l=(0,I.useMemo)(()=>a.lanes(s),[a,s]),u=e.nodes.filter(e=>e.layer===null).length,d=(0,I.useMemo)(()=>new Map(a.bands.flatMap(e=>[[Dm(e.layer),e],[e.layer,e]])),[a]),f=(0,I.useCallback)(e=>{let t=d.get(e.id);return e.id===t.layer?{type:`layer`,ariaLabel:Mm(t),selection:t.layer,data:{band:t,t:i}}:{type:`label`,ariaLabel:Mm(t),selection:null,data:{band:t}}},[d,i]),p=(0,I.useCallback)(e=>zm(l.find(t=>t.route.id===e.id)),[l]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`architecture-lens`,children:(0,W.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,W.jsx)(`span`,{"data-layers-provenance":!0,children:i(`architecture.layers.provenance`,{version:e.archctx_version})}),(0,W.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-layers-export":!0,onClick:()=>Jp(`layers-${e.commit.slice(0,7)}.svg`,c,Im(d)),children:i(`architecture.layers.export`)})]})}),(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`layers`,"data-layer-count":a.bands.length,"data-lane-count":l.length,children:[(0,W.jsx)(Zp,{label:i(`architecture.layers.label`),scene:c,nodeTypes:Pm,view:f,selected:s,routeLabel:p,onSelect:r,legend:Fm(e,i),t:i}),(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":i(`architecture.layers.inspector`),"data-layer-id":s??void 0,children:[(0,W.jsx)(Hm,{map:e,t:i}),u>0&&(0,W.jsx)(Mp,{part:`layers.unlayered`,reason:`node_layer_undeclared`,children:i(`architecture.layers.unlayered`,{count:u})}),o===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.layers.pick`)}):(0,W.jsx)(Vm,{map:e,band:o,lanes:l,t:i})]})]})]})}function Wm({map:e,selectedId:t,onSelect:n,t:r}){let i=e.layer_order;return i.state===`unavailable`?(0,W.jsx)(`div`,{className:`architecture-map`,"data-view":`layers`,children:(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`layer_order`,"data-reason":i.reason,children:r(`architecture.layers.${i.reason}`)})}):(0,W.jsx)(Um,{map:e,order:i.layers,selected:t,onSelect:n,t:r},e.commit)}var Gm=200,Km=64,qm=8,Jm=12,Ym=30,Xm=26,Zm=16,Qm=72,$m=24,eh=1,th=e=>`domain:${e}`,nh=e=>24+7*e.length,rh=(e,t)=>Math.round((1+5*Math.sqrt(e/t))*100)/100,ih=e=>e===1?1:e<=4?2:3;function ah(e){let t=new Map;for(let n of e.nodes)n.kind===`capability`&&t.set(n.domain,[...t.get(n.domain)??[],n]);let n=[...t.keys()].sort((e,n)=>t.get(n).length-t.get(e).length||e.localeCompare(n)),r=e.nodes.filter(e=>e.kind===`external-system`),i=new Map([...t].flatMap(([e,t])=>t.map(t=>[t.id,e]))),a=new Map;if(e.dependencies.state===`ok`)for(let t of e.dependencies.edges){let[e,n]=[i.get(t.source),i.get(t.target)];if(e===void 0||n===void 0||e===n)continue;let r=`${e}\n${n}`;a.set(r,(a.get(r)??0)+t.imports)}let o=[...a].map(([e,t])=>{let[n,r]=e.split(`
8
+ M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Nd.displayName=`MiniMap`,(0,I.memo)(Nd);var Pd=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Fd={[Ds.Line]:`right`,[Ds.Handle]:`bottom-right`};function Id({nodeId:e,position:t,variant:n=Ds.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let v=pl(),y=typeof e==`string`?e:v,b=J(),x=(0,I.useRef)(null),S=n===Ds.Handle,C=q((0,I.useCallback)(Pd(S&&p),[S,p]),K),w=(0,I.useRef)(null),T=t??Fd[n];(0,I.useEffect)(()=>{if(x.current&&y)return w.current||=Rs({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Go([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...qa({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]);let E=T.split(`-`);return(0,W.jsx)(`div`,{className:Xi([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,I.memo)(Id);var Ld=`repo-harness.architecture-map.v7`,Rd=[`architecture_map_pending`,`registry_unavailable`,`repository_not_found`,`model_unavailable`,`architecture_map_invalid`,`architecture_map_failed`,`architecture_map_timeout`,`architecture_map_process_failed`],zd=[`model_worktree_dirty`,`checkout_changed`,`ownership_unavailable`,`git_read_failed`],Bd=[`model_worktree_dirty`,`checkout_changed`,`code_facts_worktree_dirty`,`code_facts_unavailable`,`code_facts_incomplete`,`code_facts_other_commit`,`dependencies_unavailable`],Vd=[`git_read_failed`,`history_starts_today`,`archctx_failed`,`path_not_public`],Hd=[...Bd,`archctx_failed`],Ud=[...f,`projection_missing`,`projection_invalid`,`tests_model_mismatch`],Wd=[`model_worktree_dirty`,`checkout_changed`,`git_read_failed`,`dev_activity_pending`,`dev_activity_unavailable`],Gd=[`head_missing`,...d,`archctx_failed`,`path_not_public`],Kd=[`model_layers_undeclared`],qd=[...Hd,`model_layers_undeclared`,`layer_direction_undeclared`,`layer_endpoint_unclassified`],Jd={debt:[`debt`,`--json`],flows:[`flows`,`check`,`--no-sync`,`--json`],anchors:[`docs`,`anchors`,`--json`],dependencies:[`deps`,`--json`],layer_direction:[`constraints`,`check`,`--json`]};function Yd(e){return[`archctx`,...Jd[e]].join(` `)}var Xd=[`unowned-path`,`ambiguous-owner`,`stale-anchor`,`state-machine-rule`,`state-machine-stale`],Zd=[`host`,`container`,`pod`,`kubernetes`,`pid`,`mount`,`net`,`user`],Qd=/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/u,$d=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function ef(e,t){return typeof e!=`string`||!Qd.test(e)||t!=null&&(typeof t!=`string`||!$d.test(t))?null:{state:`unavailable`,reason:`archctx_error`,code:e,reason_code:t??null}}function tf(e){let t=e=>o(e)?e:null,n=t(t(e)?.error)?.code;if(n===`archctx_error`){let n=t(t(e)?.archctx);return n===null?null:ef(n.code,n.reason_code)}return Rd.includes(n)?{state:`unavailable`,reason:n}:null}function nf(e){return`${e.entrypoint}\0${e.source_symbol}\0${e.sink}`}function rf(e){return e.applicability===`required`?[...e.steps.map(e=>({outcome:null,step:e})),...e.outcomes.flatMap(e=>e.steps.map(t=>({outcome:e.id,step:t})))]:[]}var af=e=>typeof e==`string`,of=e=>typeof e==`string`&&e.length>0&&e.length<=4096,sf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,cf=e=>sf(e)&&e>0,Y=e=>t=>af(t)&&e.test(t),lf=(...e)=>t=>e.includes(t),X=e=>t=>t===null||e(t),Z=e=>t=>Array.isArray(t)&&t.every(e),Q=e=>t=>{if(!o(t))return!1;let n=t;return Object.keys(n).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(n,e)&&t(n[e]))},uf=/^([a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)+$/u,df=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/u,ff=/^[a-z][a-z0-9-]{0,63}$/u,$=Y(uf),pf=e=>t=>e(t)&&m(t),mf=pf(Y(/^[^\r\n]{1,4096}$/u)),hf=Q({id:$,kind:Y(ff),name:pf(of),status:Y(ff),layer:X(Y(df)),parent:X($),summary:pf(af),domain:X(Y(df)),namespace:X(Q({type:lf(...Zd)})),mount:X(Q({source:X(pf(of)),target:X(pf(of)),mode:lf(`ro`,`rw`),order:sf}))}),gf=Q({id:$,kind:Y(ff),source:$,target:$,intent:pf(af),protocol:X(mf)}),_f=Q({id:$,files:cf,lines:sf}),vf=Q({source:$,target:$,imports:cf}),yf=e=>Q({state:lf(`unavailable`),reason:lf(...e)}),bf=(e,t)=>n=>Q({state:lf(`ok`),...e})(n)||yf(t)(n),xf=e=>Q({state:lf(`unavailable`),reason:lf(`archctx_error`),code:Y(Qd),reason_code:X(Y($d))})(e),Sf=Y(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u),Cf=/^(?![/.-])(?!.*\.\.)(?!.*@\{)(?!.*\/[/.])(?!.*[/.]$)(?!.*\.lock(?:\/|$))[^\x00-\x20\x7f~^:?*[\\]{1,255}$/u,wf=/^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/u,Tf=Y(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/u),Ef=Z($),Df=e=>Z(Y(df))(e)&&e.length>0,Of=e=>af(e)&&h(e),kf=(...e)=>t=>e.some(e=>e(t)),Af=Z(Y($d)),jf=Y(/^[a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/u),Mf=lf(!0,!1),Nf=e=>({paths:Z(Q({path:e,added:X(sf),deleted:X(sf),owners:Ef,reason_codes:Af})),unowned_paths:Z(e),nodes:Z(Q({id:$,files:cf})),dependents:Z(Q({id:$,touched:$,relations:Ef})),dependency_coverage:lf(`complete`,`partial`),flow_steps:Q({status:lf(`known`,`unknown`),reason_codes:Af,items:X(Z(Q({flow:$,step:jf,outcome:X(jf),reason_codes:Af})))}),truncated:Q({paths:Mf,nodes:Mf,relations:Mf,flow_steps:Mf,dependents:Mf,model:Mf})}),Pf=Q({kind:lf(`nodes`,`relations`,`flows`),id:$,change:lf(`added`,`removed`,`changed`),fields:Z(Y(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/u))}),Ff=Q({sha:Sf,subject:pf(Y(/^[^\r\n]{0,4096}$/u)),nodes:Ef}),If=e=>kf(bf({since:Tf,base:Sf,commits:Z(Ff),model:Z(Pf),...Nf(e)},Vd),xf),Lf=e=>kf(bf(Nf(e),Gd),xf),Rf=If(Of),zf=Lf(Of),Bf={entrypoint:jf,source_symbol:mf,sink:jf},Vf=Q({id:jf,from:jf,to:jf,label:pf(of),evidence:Q(Bf)}),Hf=kf(Q({id:$,capability:$,name:pf(of),applicability:lf(`required`),participants:Z(Q({id:jf,node:$})),steps:Z(Vf),outcomes:Z(Q({id:jf,kind:lf(`success`,`error`),label:pf(of),steps:Z(Vf),terminal:Q({participant:jf,label:pf(of)})}))}),Q({id:$,capability:$,name:pf(of),applicability:lf(`not-applicable`),rationale:pf(of)})),Uf=Q({...Bf,node:$,source_path:X(Of),sink_path:X(Of),sink_symbol:mf}),Wf=e=>Z(Q({kind:Y($d),origin:lf(`document`,`node-summary`,`node-responsibility`),path:X(Of),line:X(cf),citation:pf(of)}))(e)&&e.length>0,Gf=Q({debt:bf({items:Z(Q({kind:lf(...Xd),nodes:Ef,paths:Z(Of)}))},Hd),flows:kf(bf({selectors:sf,proven:sf,unproven:sf,used_unproven:sf,unprovable:Z(Q({id:$,diagnostics:sf})),evidence:Z(Q({...Bf,status:Y($d),call_sites:Z(Q({path:Of,line:X(cf)}))}))},Hd),xf),anchors:bf({citations:sf,nodes:Z(Q({id:$,findings:Wf}))},Hd),dependencies:bf({edges:Z(vf)},Hd),layer_direction:kf(bf({imports:sf,edges:Z(Q({source:$,target:$,source_layer:Y(df),target_layer:Y(df),imports:cf}))},qd),xf)}),Kf=Q({state:lf(`ok`),items:Z(Q({id:mf,title:mf,status:X(mf),decided_at:X(mf),applies_to:Ef,supersedes:Z(mf),path:Of}))}),qf=bf({run:Q({id:cf,head_sha:Sf,created_at:Tf}),results:lf(`ok`,`junit_missing`,`junit_invalid`),capabilities:Z(Q({id:$,files:cf,passed:sf,failed:sf,skipped:sf,no_result:sf}))},Ud),Jf=Y(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9]\d*$/u),Yf=bf({observed_at:Tf,pull_requests:Z(Q({number:cf,title:pf(of),url:Jf,head_sha:X(Sf),impact:zf}))},Wd),Xf=Q({schema_version:lf(Ld),repository_id:Y(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u),commit:Sf,head_ref:X(Y(Cf)),archctx_version:Y(wf),collected_at:Tf,nodes:Z(hf),relations:Z(gf),flows:Z(Hf),flow_evidence:Z(Uf),sizes:bf({nodes:Z(_f)},zd),dependencies:bf({edges:Z(vf)},Bd),layer_order:bf({layers:Df},Kd),layers:Q({changes:Rf,violations:Gf,pull_requests:Yf,tests:qf,decisions:Kf})});function Zf(e){return new Set(e).size===e.length}function Qf(e,t){let n=new Set(t);return e.every(e=>e.layer===null||n.has(e.layer))}function $f(e,t){let n=new Set;for(let r=e;r!==null;r=t.get(r)?.parent??null){if(n.has(r))return!1;n.add(r)}return!0}var ep=(e,t,n)=>`${e}\0${t??``}\0${n}`;function tp(e,t,n){return{nodes:new Set(e.map(e=>e.id)),relations:new Set(t.map(e=>e.id)),flows:new Set(n.map(e=>e.id)),steps:new Set(n.flatMap(e=>rf(e).map(({outcome:t,step:n})=>ep(e.id,t,n.id))))}}function np(e,t){let n=new Set(e.flows.flatMap(e=>rf(e).map(({step:e})=>nf(e.evidence)))),r=new Set(e.flow_evidence.map(nf)),i=e=>Zf(e.map(nf))&&e.every(e=>n.has(nf(e))),{flows:a}=e.layers.violations;return Zf(e.flows.map(e=>e.id))&&e.flows.every(e=>{if(t.get(e.capability)?.kind!==`capability`)return!1;if(e.applicability!==`required`)return!0;let n=new Set(e.participants.map(e=>e.id)),r=e=>Zf(e.map(e=>e.id))&&e.every(e=>n.has(e.from)&&n.has(e.to));return e.participants.length>0&&e.steps.length>0&&n.size===e.participants.length&&e.participants.every(e=>t.has(e.node))&&r(e.steps)&&Zf(e.outcomes.map(e=>e.id))&&e.outcomes.every(e=>r(e.steps)&&n.has(e.terminal.participant))})&&i(e.flow_evidence)&&e.flow_evidence.every(e=>t.has(e.node))&&(a.state!==`ok`||i(a.evidence)&&a.evidence.every(e=>r.has(nf(e))))}function rp(e,t,n){let r=e.paths.filter(e=>e.owners.length===0).map(e=>e.path),{flow_steps:i}=e;return Zf(e.paths.map(e=>e.path))&&e.paths.every(e=>Zf(e.owners)&&e.owners.every(n))&&r.length===e.unowned_paths.length&&r.every((t,n)=>t===e.unowned_paths[n])&&Zf(e.nodes.map(e=>e.id))&&e.nodes.every(e=>n(e.id))&&e.dependents.every(e=>t.nodes.has(e.id)&&n(e.touched)&&e.relations.length>0&&e.relations.every(e=>t.relations.has(e)))&&(i.status===`known`?i.reason_codes.length===0&&i.items!==null:i.reason_codes.length>0)&&(i.items??[]).every(e=>t.steps.has(ep(e.flow,e.outcome,e.step)))}function ip(e,t,n=Of){if(!(n===Of?Rf:If(n))(e))return!1;let r=e;if(r.state!==`ok`)return!0;let i=new Set(r.model.filter(e=>e.kind===`nodes`&&e.change===`removed`).map(e=>e.id)),a=(e,t)=>r.model.filter(t=>t.kind===e).every(e=>e.change===`removed`!==t.has(e.id)),o=e=>t.nodes.has(e)||i.has(e);return Zf(r.model.map(e=>`${e.kind}\0${e.id}`))&&a(`nodes`,t.nodes)&&a(`relations`,t.relations)&&a(`flows`,t.flows)&&Zf(r.commits.map(e=>e.sha))&&r.commits.every(e=>Zf(e.nodes)&&e.nodes.every(o))&&rp(r,t,o)}function ap(e,t,n=Of){if(!(n===Of?zf:Lf(n))(e))return!1;let r=e;return r.state!==`ok`||rp(r,t,e=>t.nodes.has(e))}function op(e,t){let n=e.layers.violations.layer_direction;if(n.state!==`ok`)return!0;if(e.layer_order.state!==`ok`)return!1;let r=new Map(e.layer_order.layers.map((e,t)=>[e,t]));return Zf(n.edges.map(e=>`${e.source}\0${e.target}`))&&n.edges.every(e=>t.get(e.source)?.layer===e.source_layer&&t.get(e.target)?.layer===e.target_layer&&(r.get(e.target_layer)??1/0)<(r.get(e.source_layer)??-1/0))}function sp(e){if(!Xf(e))throw Error(`architecture_map_invalid`);let t=e,n=new Map(t.nodes.map(e=>[e.id,e])),r=new Set(t.relations.map(e=>e.id)),i=tp(t.nodes,t.relations,t.flows),a=e=>n.get(e)?.kind===`capability`,o=(e,t=e=>n.has(e))=>Zf(e)&&e.every(t),s=e=>Zf(e.map(e=>`${e.source}\0${e.target}`))&&e.every(e=>e.source!==e.target&&a(e.source)&&a(e.target)),{violations:c,pull_requests:l,tests:u,decisions:d}=t.layers;if(n.size!==t.nodes.length||r.size!==t.relations.length||t.nodes.some(e=>e.domain!==null!=(e.kind===`capability`)||e.namespace!==null!=(e.kind===`namespace`)||e.mount!==null!=(e.kind===`mount`))||t.nodes.some(e=>e.parent!==null&&!n.has(e.parent))||t.nodes.some(e=>!$f(e.id,n))||t.relations.some(e=>!n.has(e.source)||!n.has(e.target))||t.layer_order.state===`ok`&&(!Zf(t.layer_order.layers)||!Qf(t.nodes,t.layer_order.layers))||t.sizes.state===`ok`&&!o(t.sizes.nodes.map(e=>e.id))||t.dependencies.state===`ok`&&!s(t.dependencies.edges)||!ip(t.layers.changes,i)||c.debt.state===`ok`&&c.debt.items.some(e=>!o(e.nodes)||!Zf(e.paths))||c.flows.state===`ok`&&!o(c.flows.unprovable.map(e=>e.id),a)||c.anchors.state===`ok`&&!o(c.anchors.nodes.map(e=>e.id))||c.dependencies.state===`ok`&&!s(c.dependencies.edges)||!op(t,n)||!np(t,n)||l.state===`ok`&&(!Zf(l.pull_requests.map(e=>String(e.number)))||l.pull_requests.some(e=>!ap(e.impact,i)||(e.impact.state===`ok`?e.head_sha===null:e.head_sha===null!=(e.impact.reason===`head_missing`))))||u.state===`ok`&&(!o(u.capabilities.map(e=>e.id),a)||u.capabilities.some(e=>e.files!==e.passed+e.failed+e.skipped+e.no_result))||!Zf(d.items.map(e=>e.id))||d.items.some(e=>!o(e.applies_to)))throw Error(`architecture_map_invalid`);return t}var cp=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`],lp={available:!1,marks:new Map,lit:new Set,edges:[]};function up(e,t){let n=new Map(e.nodes.map(e=>[e.id,e.parent])),r=new Set;for(let e of t)if(n.has(e))for(let t=e;t!==null&&!r.has(t);t=n.get(t))r.add(t);return r}function dp(e){return e.reason_code===null?e.code:`${e.code} ${e.reason_code}`}function fp(e){let{debt:t,flows:n,anchors:r,dependencies:i,layer_direction:a}=e.layers.violations,o=new Map,s=(e,t)=>o.set(e,(o.get(e)??0)+t);if(t.state===`ok`)for(let e of t.items)for(let t of e.nodes)s(t,1);if(n.state===`ok`)for(let e of n.unprovable)s(e.id,1);if(r.state===`ok`)for(let e of r.nodes)s(e.id,e.findings.length);if(i.state===`ok`)for(let e of i.edges)s(e.source,1);if(a.state===`ok`)for(let e of a.edges)s(e.source,1);return o}function pp(e){let{debt:t,flows:n,anchors:r,dependencies:i,layer_direction:a}=e.layers.violations;return(t.state===`ok`?t.items.length:0)+(n.state===`ok`?n.unprovable.length:0)+(r.state===`ok`?r.nodes.reduce((e,t)=>e+t.findings.length,0):0)+(i.state===`ok`?i.edges.length:0)+(a.state===`ok`?a.edges.length:0)}function mp(e,t){return e.paths.filter(e=>e.owners.some(e=>t.has(e))).length}function hp(e){let{pull_requests:t}=e.layers;return t.state===`ok`?t.pull_requests.find(e=>e.impact.state===`ok`)?.number??null:null}function gp(e,t){let n=0,r=0,i=0;for(let a of e.paths)a.owners.includes(t)&&(a.added===null||a.deleted===null?i+=1:(n+=a.added,r+=a.deleted));return{added:n,deleted:r,unknown:i}}function _p(e,t){return e.dependents.filter(e=>e.id===t).map(e=>e.touched)}function vp(e){return[`paths`,`nodes`,`relations`,`flow_steps`,`dependents`,`model`].filter(t=>e[t])}function yp(e,t){let n=new Map(e.nodes.map(e=>[e.id,{tone:`change`,label:t(e)}]));for(let t of e.dependents)n.has(t.id)||n.set(t.id,{tone:`muted`,label:`↳`});return n}function bp(e){return e.failed>0?`danger`:e.passed>0&&e.passed+e.skipped===e.files?`success`:`muted`}function xp(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map;for(let r of e.nodes)for(let e=r;e!==void 0;e=e.parent===null?void 0:t.get(e.parent))if(e.kind===`capability`){n.set(r.id,e.id);break}return n}var Sp={available:!1,marks:new Map,edges:[]};function Cp(e,t,n=null){let r=xp(e),i=(e,t=[])=>({available:e.size>0,marks:e,edges:t}),a=(e,t)=>{let n=new Map;for(let[i,a]of e){let e=r.get(i);e!==void 0&&n.set(e,{tone:t,count:(n.get(e)?.count??0)+a,atLeast:!1})}return n},o=(e,t)=>{for(let n of t.dependents){let t=r.get(n.id);t!==void 0&&!e.has(t)&&e.set(t,{tone:`muted`,count:null,atLeast:!1})}return e};if(t===`changes`){let{changes:t}=e.layers;if(t.state!==`ok`)return Sp;let n=a(t.commits.flatMap(e=>[...new Set(e.nodes.flatMap(e=>r.get(e)??[]))].map(e=>[e,1])),`change`);return i(o(new Map(t.nodes.flatMap(e=>r.get(e.id)??[]).map(e=>[e,{tone:`change`,count:n.get(e)?.count??0,atLeast:t.truncated.paths}])),t))}let s=e=>e.flatMap(e=>[...new Set(e.ids.flatMap(e=>r.get(e)??[]))].map(t=>[t,e.count]));if(t===`violations`){let{debt:t,flows:n,anchors:o,dependencies:c,layer_direction:l}=e.layers.violations;if(Object.values(e.layers.violations).every(e=>e.state!==`ok`))return Sp;let u=c.state===`ok`?c.edges.filter(e=>r.get(e.source)===e.source&&r.get(e.target)===e.target):[];return i(a(s([...t.state===`ok`?t.items.map(e=>({ids:e.nodes,count:1})):[],...n.state===`ok`?n.unprovable.map(e=>({ids:[e.id],count:1})):[],...o.state===`ok`?o.nodes.map(e=>({ids:[e.id],count:e.findings.length})):[],...c.state===`ok`?c.edges.map(e=>({ids:[e.source],count:1})):[],...l.state===`ok`?l.edges.map(e=>({ids:[e.source],count:1})):[]]),`danger`),u)}if(t===`tests`){let{tests:t}=e.layers;return t.state===`ok`?i(new Map(t.capabilities.map(e=>[e.id,{tone:bp(e),count:null,atLeast:!1}]))):Sp}if(t===`pull_requests`){let{pull_requests:t}=e.layers,a=t.state===`ok`?t.pull_requests.find(e=>e.number===n)?.impact:void 0;if(a?.state!==`ok`)return Sp;let s=new Map;for(let e of a.paths)for(let t of new Set(e.owners.flatMap(e=>r.get(e)??[])))s.set(t,(s.get(t)??0)+1);return i(o(new Map(a.nodes.flatMap(e=>r.get(e.id)??[]).map(e=>[e,{tone:`change`,count:s.get(e)??0,atLeast:a.truncated.paths}])),a))}return i(a(s(e.layers.decisions.items.map(e=>({ids:e.applies_to,count:1}))),`muted`))}function wp(e,t,n=null){let r=(t,n=[])=>{let r=up(e,t.keys());return{available:r.size>0,marks:t,lit:r,edges:n}};if(t===`changes`){let{changes:t}=e.layers;return t.state===`ok`?r(yp(t,e=>{let n=gp(t,e.id);return`+${n.added} −${n.deleted}${n.unknown>0?` ?`:``}`})):lp}if(t===`violations`){if(Object.values(e.layers.violations).every(e=>e.state!==`ok`))return lp;let{dependencies:t}=e.layers.violations;return r(new Map([...fp(e)].map(([e,t])=>[e,{tone:`danger`,label:String(t)}])),t.state===`ok`?t.edges:[])}if(t===`tests`){let{tests:t}=e.layers;return t.state===`ok`?r(new Map(t.capabilities.map(e=>[e.id,{tone:bp(e),label:`${e.passed}/${e.files}`}]))):lp}if(t===`pull_requests`){let{pull_requests:t}=e.layers,i=t.state===`ok`?t.pull_requests.find(e=>e.number===n)?.impact:void 0;return i?.state===`ok`?r(yp(i,e=>String(e.files))):lp}let i=new Map;for(let t of e.layers.decisions.items)for(let e of t.applies_to)i.set(e,(i.get(e)??0)+1);return r(new Map([...i].map(([e,t])=>[e,{tone:`muted`,label:String(t)}])))}var Tp=.85,Ep=24,Dp=120;function Op(e,t){let n=Math.min((t.width-48)/e.width,(t.height-Ep-Dp)/e.height);if(!(t.width>0)||!(t.height>0)||n<Tp)return{x:Ep-e.x*Tp,y:Ep-e.y*Tp,zoom:Tp};let r=Math.min(n,1);return{x:(t.width-e.width*r)/2-e.x*r,y:Ep+(t.height-Ep-Dp-e.height*r)/2-e.y*r,zoom:r}}function kp({content:e}){let t=J(),n=Jc(),r=q(e=>e.panZoom!==null&&e.width>0&&e.height>0),i=(0,I.useRef)(!1);return(0,I.useEffect)(()=>{if(!r||i.current)return;i.current=!0;let{width:a,height:o}=t.getState();n.setViewport(Op(e,{width:a,height:o}))},[r,e,n,t]),null}function Ap(e,t,n,r=!1){return`${r?`≥`:``}${e(t===1?`architecture.unit.${n}One`:`architecture.unit.${n}`,{count:t})}`}function jp({part:e,reason:t,code:n,children:r}){return(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":e,"data-reason":t,"data-code":n,children:r})}function Mp({part:e,reason:t,children:n}){return(0,W.jsx)(`div`,{className:`architecture-map__note`,"data-note":e,"data-reason":t,children:n})}function Np({mark:e}){return e===null?null:(0,W.jsx)(`span`,{className:`architecture-map__mark mono-value`,"data-tone":e.tone,children:e.label})}function Pp({bounds:e,t}){let n=Jc(),{zoom:r}=nd();return(0,W.jsxs)(`div`,{className:`architecture-map__zoom`,role:`group`,"aria-label":t(`architecture.map.zoom`),children:[(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomOut`),onClick:()=>{n.zoomOut()},children:`−`}),(0,W.jsxs)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomReset`),className:`mono-value`,onClick:()=>{n.zoomTo(1)},children:[Math.round(r*100),`%`]}),(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomIn`),onClick:()=>{n.zoomIn()},children:`+`}),(0,W.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.fitLabel`),onClick:()=>{e?n.fitBounds(e,{padding:.1}):n.fitView()},children:t(`architecture.map.fit`)})]})}function Fp({part:e,t}){let n=Yd(e);return(0,W.jsxs)(`div`,{className:`copy-value architecture-map__command`,children:[(0,W.jsx)(`code`,{"data-fix-command":e,children:n}),(0,W.jsx)(u,{label:t(`architecture.inspector.command`),value:n,t})]})}function Ip(e,t){return e.sizes.state===`ok`?e.sizes.nodes.find(e=>e.id===t)??null:null}function Lp(e){return Jd[e].filter(e=>!e.startsWith(`--`)).join(` `)}function Rp(e,t,n,r){let{debt:i,flows:a,anchors:o,dependencies:s,layer_direction:c}=e.layers.violations,l=[];if(i.state===`ok`&&i.items.forEach((e,n)=>{e.nodes.some(e=>t.has(e))&&l.push({key:`debt-${n}`,text:r(`architecture.layer.debt.${e.kind}`),paths:e.paths,part:`debt`})}),a.state===`ok`){for(let e of a.unprovable.filter(e=>t.has(e.id)))l.push({key:`flows-${e.id}`,text:r(`architecture.layer.node.flows`,{count:e.diagnostics}),part:`flows`});let n=new Map(a.evidence.map(e=>[nf(e),e.status]));for(let i of e.flows.filter(e=>t.has(e.capability)))rf(i).forEach(({outcome:e,step:t},a)=>{let o=n.get(nf(t.evidence));o!==void 0&&o!==`proven`&&l.push({key:`flow-step-${i.id}-${e??``}-${t.id}`,part:`flows`,text:r(`architecture.layer.node.flow_step`,{flow:i.name,step:a+1,label:t.label,status:o})})})}if(o.state===`ok`)for(let e of o.nodes.filter(e=>t.has(e.id)))e.findings.forEach((t,n)=>l.push({key:`anchors-${e.id}-${n}`,part:`anchors`,text:r(`architecture.layer.node.anchor`,{origin:r(`architecture.layer.anchor.${t.origin}`),citation:t.citation,kind:t.kind}),paths:t.path===null?void 0:[t.line===null?t.path:`${t.path}:${t.line}`]}));if(s.state===`ok`)for(let e of s.edges.filter(e=>t.has(e.source)))l.push({key:`undeclared-${e.source}-${e.target}`,text:r(`architecture.layer.node.undeclared`,{name:n.get(e.target)??e.target,count:e.imports}),part:`dependencies`});if(c.state===`ok`)for(let e of c.edges.filter(e=>t.has(e.source)))l.push({key:`layer-${e.source}-${e.target}`,part:`layer_direction`,text:r(`architecture.layer.node.layer_direction`,{name:n.get(e.target)??e.target,count:e.imports,from:e.source_layer,to:e.target_layer})});return l}function zp({facts:e,layer:t,source:n=!1}){return(0,W.jsx)(`ul`,{"data-layer-facts":t,children:e.map(e=>(0,W.jsxs)(`li`,{children:[e.text,e.paths?.length?(0,W.jsx)(`ul`,{children:e.paths.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e})},e))}):null,n&&e.part!==void 0&&(0,W.jsx)(`span`,{className:`architecture-map__source mono-value`,"data-fact-source":e.part,children:Lp(e.part)})]},e.key))})}function Bp({map:e,layer:t,pullRequest:n,nodeId:r,names:i,t:a}){if(t===`violations`)return null;let o=[],{changes:s,pull_requests:c,tests:l,decisions:u}=e.layers,d=(e,t)=>{let n=e.nodes.find(e=>e.id===r);n&&o.push({key:`impact`,text:t(n.files),paths:e.paths.filter(e=>e.owners.includes(r)).map(e=>e.path)});let s=_p(e,r);s.length>0&&o.push({key:`dependent`,text:a(`architecture.layer.node.dependent`,{names:s.map(e=>i.get(e)??e).join(`, `)})})};if(t===`changes`&&s.state===`ok`){let e=gp(s,r);d(s,t=>a(`architecture.layer.node.changes`,{files:Ap(a,t,`file`),added:e.added,deleted:e.deleted})+(e.unknown>0?` ${a(`architecture.layer.node.lines_unknown`,{count:e.unknown})}`:``))}let f=c.state===`ok`?c.pull_requests.find(e=>e.number===n)?.impact:void 0;if(t===`pull_requests`&&f?.state===`ok`&&d(f,e=>a(`architecture.layer.node.pull_request`,{files:Ap(a,e,`file`),number:n})),t===`tests`&&l.state===`ok`){let e=l.capabilities.find(e=>e.id===r);e&&o.push({key:`tests`,text:a(`architecture.layer.node.tests`,{files:e.files,passed:e.passed,failed:e.failed,skipped:e.skipped,noResult:e.no_result})})}if(t===`decisions`)for(let e of u.items.filter(e=>e.applies_to.includes(r)))o.push({key:`decision-${e.id}`,text:e.status===null?e.title:a(`architecture.layer.node.decision`,{title:e.title,status:e.status}),paths:[e.path]});return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:a(`architecture.layer.${t}`)}),o.length?(0,W.jsx)(zp,{facts:o,layer:t}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.layer.node.none`)})]})}function Vp({map:e,nodeId:t,t:n}){let{pull_requests:r}=e.layers;if(r.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-related-prs-gap":r.reason,children:n(`architecture.layer.pull_requests.${r.reason}`)});let i=r.pull_requests.flatMap(e=>{if(e.impact.state!==`ok`)return[];let r=e.impact.nodes.find(e=>e.id===t)?.files;return r===void 0?_p(e.impact,t).length>0?[{pr:e,text:n(`architecture.inspector.pr.depends`)}]:[]:[{pr:e,text:n(`architecture.inspector.pr.changes`,{files:Ap(n,r,`file`)})}]});return i.length?(0,W.jsx)(`ul`,{"data-related-prs":!0,children:i.map(({pr:e,text:t})=>(0,W.jsxs)(`li`,{"data-pull-request-number":e.number,children:[(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title,` · `,t]},e.number))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)})}function Hp({facts:e,source:t=!1,t:n}){let r=[...new Set(e.flatMap(e=>e.part?[e.part]:[]))];return(0,W.jsxs)(W.Fragment,{children:[e.length?(0,W.jsx)(zp,{facts:e,layer:`violations`,source:t}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)}),r.map(e=>(0,W.jsx)(Fp,{part:e,t:n},e))]})}function Up({map:e,layer:t,pullRequest:n,nodeId:r,onModule:i,t:a,children:o}){let s=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),c=e.nodes.find(e=>e.id===r);if(c===void 0)return null;let l=Ip(e,r);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h3`,{children:c.name}),(0,W.jsx)(`code`,{className:`architecture-map__id`,children:c.id}),(0,W.jsx)(`p`,{children:c.summary}),(0,W.jsxs)(`dl`,{className:`detail-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.kind`)}),(0,W.jsx)(`dd`,{children:c.kind})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.layer`)}),(0,W.jsx)(`dd`,{children:c.layer??a(`architecture.none`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.status`)}),(0,W.jsx)(`dd`,{children:c.status})]}),e.sizes.state===`ok`&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:a(`architecture.map.size`)}),(0,W.jsx)(`dd`,{"data-node-size":!0,children:l===null?a(`architecture.map.noSize`):a(`architecture.map.sizeValue`,{lines:l.lines,files:l.files})})]})]}),c.kind===`capability`&&(0,W.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(c.id),children:a(`architecture.map.open`)}),o,(0,W.jsx)(Bp,{map:e,layer:t,pullRequest:n,nodeId:c.id,names:s,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.inspector.pullRequests`)}),(0,W.jsx)(Vp,{map:e,nodeId:c.id,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),(0,W.jsx)(Hp,{facts:Rp(e,new Set([c.id]),s,a),t:a}),(0,W.jsx)(Wp,{map:e,nodeId:c.id,names:s,t:a})]})}function Wp({map:e,nodeId:t,names:n,t:r}){let i=e.dependencies.state===`ok`?e.dependencies.edges:[],a=a=>e.relations.filter(e=>(a===`out`?e.source:e.target)===t).map(e=>{let t=a===`out`?e.target:e.source,o=i.find(t=>t.source===e.source&&t.target===e.target)?.imports;return(0,W.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,W.jsx)(`code`,{children:e.kind}),` `,n.get(t),o!==void 0&&(0,W.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:o})]})]},e.id)}),o=a(`out`),s=a(`in`);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.map.outgoing`,{count:o.length})}),o.length?(0,W.jsx)(`ul`,{children:o}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}),(0,W.jsx)(`h4`,{children:r(`architecture.map.incoming`,{count:s.length})}),s.length?(0,W.jsx)(`ul`,{children:s}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)})]})}var Gp={route:(0,I.memo)(function({data:e,markerStart:t,markerEnd:n,style:r}){let{route:i,label:a}=e;return(0,W.jsx)(tu,{path:hi(i.points),markerStart:t,markerEnd:n,style:r,label:a?.text,labelX:a===null?void 0:a.x+a.width/2,labelY:a===null?void 0:a.y+a.height/2,labelBgPadding:[4,2]})})};function Kp(){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(xl,{type:`target`,position:G.Top,isConnectable:!1}),(0,W.jsx)(xl,{type:`source`,position:G.Bottom,isConnectable:!1})]})}var qp=e=>[{type:`target`,position:G.Top,x:e.width/2,y:0,width:1,height:1},{type:`source`,position:G.Bottom,x:e.width/2,y:e.height,width:1,height:1}];function Jp(e,t,n){let r=URL.createObjectURL(new Blob([Bi(t,n)],{type:`image/svg+xml`})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}var Yp=()=>null;function Xp({scene:e,nodeTypes:t,view:n,selected:r,emphasis:i=r,routeLabel:a,routeSelection:o=Yp,onSelect:s,legend:c,t:l}){let u=(0,I.useMemo)(()=>new Map(e.boxes.map(e=>[e.id,n(e)])),[e,n]),d=(0,I.useMemo)(()=>Ni(e),[e]),f=(0,I.useMemo)(()=>{let t=new Map(e.boxes.map(e=>[e.id,e]));return e.boxes.map(e=>{let n=e.parent===null?null:t.get(e.parent),i=u.get(e.id);return{id:e.id,type:i.type,data:i.data,ariaLabel:i.ariaLabel,position:{x:e.x-(n?.x??0),y:e.y-(n?.y??0)},width:e.width,height:e.height,handles:qp(e),...n?{parentId:n.id}:{},draggable:!1,connectable:!1,selected:i.selection!==null&&i.selection===r,...i.selection===null?{selectable:!1,focusable:!1}:{}}})},[e,u,r]),p=(0,I.useMemo)(()=>{let t=new Map(e.labels.filter(e=>e.route!==null).map(e=>[e.route,e]));return e.routes.map(e=>{let n=o(e),s=n!==null&&n===r,c=s||i!==null&&(e.source===i||e.target===i),l={type:oa.ArrowClosed,width:14,height:14,color:c?`var(--rh-accent)`:`var(--text-color-kumo-subtle)`};return{id:e.id,type:`route`,source:e.source,target:e.target,className:`architecture-map__edge architecture-map__edge--${e.kind}${c?` is-active`:r===null?``:` is-dim`}`,style:{strokeWidth:e.width,...e.dashed?{strokeDasharray:`6 4`}:{}},...e.arrows.start?{markerStart:l}:{},...e.arrows.end?{markerEnd:l}:{},data:{route:e,label:t.get(e.id)??null},selectable:n!==null,focusable:n!==null,selected:s,zIndex:c?2:1,...a?{ariaLabel:a(e)}:{}}})},[e,r,i,a,o]),m=(0,I.useRef)(r);m.current=r;let h=(0,I.useMemo)(()=>new Map(e.routes.map(e=>[e.id,e])),[e]),g=(0,I.useCallback)((e,t)=>{let n=e.filter(e=>e.type===`select`),r=n.find(e=>e.selected),i=r?t(r.id):n.some(e=>t(e.id)===m.current)?null:void 0;i!==void 0&&(m.current=i,s(i))},[s]),_=(0,I.useCallback)(e=>g(e,e=>u.get(e).selection),[g,u]),v=(0,I.useCallback)(e=>g(e,e=>o(h.get(e))),[g,h,o]);return(0,W.jsxs)(ed,{nodes:f,edges:p,nodeTypes:t,edgeTypes:Gp,onNodesChange:_,onEdgesChange:v,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.05,maxZoom:2,attributionPosition:`top-right`,children:[(0,W.jsx)(kp,{content:d}),(0,W.jsx)(ld,{variant:ad.Dots,gap:20,size:1.5,color:`var(--rh-diagram-dot)`}),(0,W.jsx)(oc,{position:`bottom-left`,children:(0,W.jsx)(`dl`,{className:`architecture-map__legend`,"aria-label":l(`architecture.map.legend`),children:c.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.swatch}),(0,W.jsx)(`dd`,{children:e.text})]},e.key))})}),(0,W.jsx)(oc,{position:`bottom-right`,children:(0,W.jsx)(Pp,{bounds:d,t:l})})]})}function Zp({label:e,...t}){return(0,W.jsx)(`div`,{className:`architecture-map__canvas`,"aria-label":e,role:`region`,children:(0,W.jsx)(Xu,{children:(0,W.jsx)(Xp,{...t})})})}var Qp=25,$p=e=>`domain:${e}`,em=e=>`${e.source}->${e.target}`;function tm(e){let t=new Set([...e.added,...e.removed,...e.renamed].flatMap(e=>e.kind===`capability`?[e.id]:[]));return new Set([...e.added,...e.removed,...e.renamed].flatMap(e=>e.kind!==`capability`&&e.capability!==null&&!t.has(e.capability)?[e.capability]:[]))}function nm(e,t){let{delta:n}=t,r=e.find(e=>e.rev===n.baseRev),i=new Map((r?.nodes??[]).map(e=>[e.id,e])),a=n.removed.flatMap(e=>e.kind===`capability`&&i.has(e.id)?[i.get(e.id)]:[]),o=[...t.nodes,...a],s=[...new Set(o.flatMap(e=>e.domain===null?[]:[e.domain]))],c=new Map;for(let e of n.added)e.kind===`capability`&&c.set(e.id,`added`);for(let e of n.removed)e.kind===`capability`&&c.set(e.id,`removed`);for(let e of n.renamed)e.kind===`capability`&&c.set(e.id,`renamed`);for(let e of tm(n))c.set(e,`inside`);let l=new Set(o.map(e=>e.id)),u=n.edgesChanged.removed.filter(e=>l.has(e.source)&&l.has(e.target));return{input:{nodes:[...s.map(e=>({id:$p(e),kind:`domain`,name:e,parent:null})),...o.map(e=>({id:e.id,kind:`capability`,name:e.name,parent:e.domain===null?null:$p(e.domain)}))],relations:[...t.edges,...u].map(e=>({id:em(e),kind:`relation`,source:e.source,target:e.target}))},nodes:c,renamed:new Map(n.renamed.filter(e=>e.kind===`capability`).map(e=>[e.id,{from:e.from,to:e.to}])),edges:new Map([...n.edgesChanged.added.map(e=>[em(e),`added`]),...u.map(e=>[em(e),`removed`])]),capabilities:new Map(o.map(e=>[e.id,e]))}}function rm(e,t){let{baseRev:n}=t.delta;if(n===null)return 0;let r=e.findIndex(e=>e.rev===n);return r===-1?null:e.indexOf(t)-r-1}var im=e=>e instanceof Error&&/^[a-z][a-z0-9_]{0,63}$/u.test(e.message)?e.message:`unavailable`;function am(e,t,n){let r={path:e,timeline:null,error:null,more:{loading:!1,error:null}},[i,o]=(0,I.useState)(r),s=(0,I.useRef)(null),l=(0,I.useCallback)(async n=>{let i=t=>{s.current?.path!==e&&(s.current=null),o(n=>n.path===e?{...n,error:t}:{...r,error:t})};try{let r=await t(`${e}?offset=0&limit=1`,s.current?.path===e?s.current.etag:null,n);if(n.aborted)return!1;if(r===null)return o(e=>e.error===null?e:{...e,error:null}),!0;if(`state`in r)return i(r.reason),c(r);let a=r.body,l=Math.max(0,a.total-Qp),u=a;if(a.total>1){let r=await t(`${e}?offset=${l}&limit=${Qp}&ref=${a.head}`,null,n);if(n.aborted)return!1;if(`state`in r)return i(r.reason),c(r);u=r.body}return s.current=r.etag===null?null:{path:e,etag:r.etag},o({path:e,timeline:{head:a.head,total:a.total,start:l,milestones:u.milestones},error:null,more:{loading:!1,error:null}}),!0}catch(e){return n.aborted||i(im(e)),!1}},[e,t]),u=a(l,JSON.stringify([e,n])),d=i.path===e?i:r,f=(0,I.useCallback)(()=>{let n=d.timeline;if(n===null||d.more.loading||n.start===0)return;let r=Math.max(0,n.start-Qp),i=t=>t.path===e&&t.timeline?.head===n.head&&t.timeline.start===n.start,a=e=>o(t=>i(t)?{...t,more:{loading:!1,error:e}}:t);o(e=>i(e)?{...e,more:{loading:!0,error:null}}:e),t(`${e}?offset=${r}&limit=${n.start-r}&ref=${n.head}`,null,new AbortController().signal).then(e=>{if(e!==null&&`state`in e){a(e.reason);return}let t=e.body;o(e=>i(e)?{...e,timeline:{...n,start:r,milestones:[...t.milestones,...n.milestones]},more:{loading:!1,error:null}}:e)},e=>a(im(e)))},[e,t,d]);return{...d,loadMore:f,retry:u}}var om={added:`+`,removed:`−`,renamed:`~`,inside:`•`},sm=e=>e.slice(0,7),cm={box:(0,I.memo)(function({id:e,data:t,selected:n}){let{name:r,diff:i,from:a,quiet:o}=t;return(0,W.jsxs)(`div`,{className:`architecture-history__node`,title:e,"data-node-id":e,"data-diff":i??void 0,"data-quiet":o||void 0,"data-selected":n||void 0,children:[(0,W.jsx)(Kp,{}),(0,W.jsx)(`b`,{className:`architecture-history__mark`,"aria-hidden":`true`,children:i&&om[i]}),(0,W.jsxs)(`span`,{className:`architecture-history__name`,children:[(0,W.jsx)(`span`,{children:r}),a!==null&&(0,W.jsx)(`s`,{className:`architecture-history__from`,children:a})]})]})}),group:(0,I.memo)(function({id:e,data:t}){return(0,W.jsxs)(`div`,{className:`architecture-history__group`,"data-node-id":e,children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`span`,{children:[t.name,` · `,t.count]})]})})};function lm(e,t){if(e.delta.baseRev===null)return{nodes:new Map,edges:new Map,touched:new Set};let n=new Set(t.nodes.keys());for(let e of t.input.relations)t.edges.has(e.id)&&(n.add(e.source),n.add(e.target));return{nodes:t.nodes,edges:t.edges,touched:n}}function um(e,t){return{nodes:e.input.nodes,relations:e.input.relations.map(e=>({...e,kind:t.get(e.id)??`relation`}))}}var dm=[`removed`,`added`,`renamed`,`inside`];function fm(e,t){for(let n of dm)for(let[r,i]of e.nodes)if(i===n&&t.capabilities.has(r))return r;return t.capabilities.keys().next().value??null}function pm(e,t,n){let{baseRev:r}=e.delta;if(r===null)return n(`architecture.history.caption.first`,{rev:sm(e.rev)});let i={base:sm(r),rev:sm(e.rev)};return t===null?n(`architectureHistory.caption.unread`,i):t>0?n(`architectureHistory.caption.skipped`,{...i,count:t}):`${i.base} → ${i.rev}`}function mm(e){return[...[`added`,`removed`,`renamed`,`inside`].map(t=>({key:t,swatch:(0,W.jsx)(`i`,{className:`architecture-history__swatch`,"data-diff":t}),text:e(`architecture.history.diff.${t}`)})),...[`added`,`removed`].map(t=>({key:`edge-${t}`,swatch:(0,W.jsx)(`i`,{className:`architecture-history__line`,"data-diff":t}),text:e(`architecture.history.edge.${t}`)}))]}function hm({milestone:e,shape:t,marks:n,skipped:r,selected:i,onSelect:a,t:o}){let[s,c]=(0,I.useState)(!1),l=e.delta.baseRev!==null,u=l&&s,d=(0,I.useMemo)(()=>Yi(um(t,n.edges)),[t,n]),f=(0,I.useMemo)(()=>new Map(t.input.nodes.map(e=>[e.id,e])),[t]),p=(0,I.useMemo)(()=>{let e=new Map;for(let n of t.input.nodes)n.parent!==null&&e.set(n.parent,(e.get(n.parent)??0)+1);return e},[t]),m=(0,I.useCallback)(e=>{let r=f.get(e.id);if(e.kind===`frame`)return{type:`group`,ariaLabel:`${r.kind} ${r.name}`,selection:null,data:{name:r.name,count:p.get(r.id)??0}};let i=n.nodes.get(r.id)??null;return{type:`box`,selection:r.id,ariaLabel:`${r.kind} ${r.name}${i?` (${o(`architecture.history.diff.${i}`)})`:``}`,data:{name:r.name,diff:i,from:i===`renamed`?t.renamed.get(r.id).from:null,quiet:u&&!n.touched.has(r.id)}}},[f,p,n,t,u,o]),h=(0,I.useCallback)(e=>{let t=[o(`architecture.modules.route.relation`,{source:f.get(e.source).name,target:f.get(e.target).name}),`${d.relations.get(e.id).length} ${o(`architecture.history.count.relations`)}`];return(e.kind===`relation`?t:[...t,o(`architecture.history.edge.${e.kind}`)]).join(` · `)},[f,d,o]),g=(0,I.useMemo)(()=>mm(o),[o]);return(0,W.jsxs)(`div`,{className:`architecture-history__stage`,"data-focus":u||void 0,children:[(0,W.jsxs)(`div`,{className:`architecture-history__bar`,children:[(0,W.jsx)(`p`,{className:`architecture-history__caption`,"data-base-rev":e.delta.baseRev??``,children:pm(e,r,o)}),(0,W.jsxs)(`label`,{className:`architecture-history__focus`,children:[(0,W.jsx)(`button`,{type:`button`,role:`switch`,className:`architecture-history__switch`,"aria-checked":u,disabled:!l,onClick:()=>c(!s)}),o(`architecture.history.focus`)]})]}),(0,W.jsx)(Zp,{label:o(`architecture.history.map`),scene:d.scene,nodeTypes:cm,view:m,selected:i,emphasis:null,routeLabel:h,onSelect:a,legend:g,t:o})]})}function gm({github:e,rev:t}){return e===null?(0,W.jsx)(`code`,{children:sm(t)}):(0,W.jsxs)(`a`,{href:`https://github.com/${e}/commit/${t}`,target:`_blank`,rel:`noreferrer`,children:[(0,W.jsx)(`code`,{children:sm(t)}),` ↗`]})}function _m({milestone:e,skipped:t,t:n}){if(e.error)return(0,W.jsx)(`span`,{className:`architecture-history__chips`,children:(0,W.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`error`,children:e.error.code})});let{delta:r}=e;if(r.baseRev===null)return(0,W.jsx)(`span`,{className:`architecture-history__chips`,children:(0,W.jsx)(`span`,{className:`architecture-history__chip`,children:n(`architecture.history.chip.first`)})});let i=r.edgesChanged.added.length+r.edgesChanged.removed.length,a=tm(r).size;return(0,W.jsxs)(`span`,{className:`architecture-history__chips`,children:[r.added.length>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`added`,children:[`+`,r.added.length]}),r.removed.length>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`removed`,children:[`−`,r.removed.length]}),r.renamed.length>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`renamed`,children:[`~`,r.renamed.length]}),a>0&&(0,W.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`inside`,title:n(`architecture.history.diff.inside`),children:[`•`,a]}),i>0&&(0,W.jsx)(`span`,{className:`architecture-history__chip`,children:n(`architecture.history.chip.relations`,{added:r.edgesChanged.added.length,removed:r.edgesChanged.removed.length})}),t!==null&&t>0&&(0,W.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`gap`,children:n(`architecture.history.chip.gap`,{count:t,rev:sm(r.baseRev)})})]})}function vm({timeline:e,selected:t,onSelect:n,more:r,onMore:i,t:a}){let{milestones:o}=e,s=(0,I.useMemo)(()=>[...o].reverse(),[o]),c=(0,I.useRef)(null),l=e=>{let t=s[Math.min(s.length-1,Math.max(0,e))];n(t.rev),c.current?.querySelector(`[data-milestone-rev="${t.rev}"]`)?.scrollIntoView({block:`nearest`})};return(0,W.jsxs)(`nav`,{className:`architecture-history__timeline`,"aria-label":a(`architecture.history.timeline`),children:[e.total===0&&(0,W.jsx)(`p`,{className:`architecture-history__empty`,children:a(`architecture.history.empty`)}),(0,W.jsx)(`ol`,{ref:c,role:`listbox`,tabIndex:0,"aria-label":a(`architecture.history.timeline`),"aria-activedescendant":`history-milestone-${t}`,onKeyDown:e=>{let n=s.findIndex(e=>e.rev===t),r={ArrowDown:n+1,ArrowUp:n-1,Home:0,End:s.length-1}[e.key];r!==void 0&&s.length!==0&&(e.preventDefault(),l(r))},children:s.map(e=>(0,W.jsxs)(`li`,{id:`history-milestone-${e.rev}`,role:`option`,"aria-selected":e.rev===t,"data-milestone-rev":e.rev,"data-state":e.error?`error`:`ok`,onClick:()=>n(e.rev),children:[(0,W.jsxs)(`span`,{className:`architecture-history__top`,children:[(0,W.jsx)(`code`,{children:sm(e.rev)}),(0,W.jsx)(`time`,{dateTime:e.date,title:e.date,children:e.date.slice(5,10)})]}),(0,W.jsx)(`span`,{className:`architecture-history__subject`,title:e.subject,children:e.subject}),(0,W.jsx)(_m,{milestone:e,skipped:e.error?0:rm(o,e),t:a})]},e.rev))}),e.start>0&&(0,W.jsx)(`button`,{type:`button`,className:`architecture-history__load`,disabled:r.loading,onClick:i,children:a(`architectureHistory.more`,{count:Math.min(Qp,e.start),head:sm(e.head)})}),r.error!==null&&(0,W.jsx)(`p`,{className:`architecture-history__callout`,"data-tone":`error`,role:`alert`,"data-error-code":r.error,children:a(`architecture.history.moreFailed`,{code:r.error})})]})}function ym(e,t,n,r,i){let{baseRev:a}=t.delta;if(a===null)return i(`architectureHistory.what.first`);let o=n.nodes.get(e);return o===`renamed`?i(`architectureHistory.what.renamed`,r.renamed.get(e)):o===`removed`?i(`architectureHistory.what.removed`,{rev:sm(a)}):i(o===void 0?`architectureHistory.what.same`:`architectureHistory.what.${o}`)}function bm(e,t){let{delta:n}=e;if(n.baseRev===null)return[];let r=e=>e.source===t||e.target===t;return[...n.edgesChanged.added.filter(r).map(e=>({edge:e,diff:`added`})),...n.edgesChanged.removed.filter(r).map(e=>({edge:e,diff:`removed`}))]}function xm({milestone:e,shape:t,marks:n,skipped:r,selected:i,github:a,t:o}){let s=o(`architectureHistory.node`);if(e.error)return(0,W.jsx)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,children:(0,W.jsxs)(`p`,{className:`architecture-history__callout`,"data-tone":`error`,"data-gap":`milestone`,"data-code":e.error.code,children:[o(`architecture.history.error`),` `,(0,W.jsx)(`code`,{children:e.error.code}),e.error.path&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`br`,{}),(0,W.jsx)(`code`,{children:e.error.path})]})]})});let{baseRev:c}=e.delta,l=i===null?null:t.capabilities.get(i),u=l===null?[]:bm(e,l.id),d=e=>{let n=t.capabilities.get(e);return n===void 0?(0,W.jsx)(`code`,{children:e}):n.name};return(0,W.jsxs)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,"data-node-id":l?.id,children:[l!==null&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`header`,{children:[(0,W.jsx)(`p`,{className:`architecture-history__eyebrow`,children:l.domain??`—`}),(0,W.jsx)(`h3`,{children:l.name}),(0,W.jsx)(`code`,{children:l.id})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h4`,{children:o(`architectureHistory.milestone`)}),(0,W.jsx)(`p`,{"data-diff":n.nodes.get(l.id),children:ym(l.id,e,n,t,o)})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h4`,{children:o(`architectureHistory.relations`)}),u.length===0?(0,W.jsx)(`p`,{className:`architecture-history__quiet`,children:o(`architectureHistory.none`)}):(0,W.jsx)(`ul`,{children:u.map(({edge:e,diff:t})=>(0,W.jsxs)(`li`,{"data-diff":t,children:[(0,W.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":t,children:t===`added`?`+`:`−`}),(0,W.jsxs)(`span`,{children:[d(e.source),` → `,d(e.target)]})]},`${t}:${em(e)}`))})]})]}),(0,W.jsxs)(`section`,{children:[(0,W.jsx)(`h4`,{children:o(`architecture.history.base`)}),c===null?(0,W.jsx)(`p`,{className:`architecture-history__quiet`,"data-base-rev":``,children:o(`architecture.history.first`)}):(0,W.jsxs)(`p`,{"data-base-rev":c,children:[(0,W.jsx)(gm,{github:a,rev:c}),r!==null&&r>0&&(0,W.jsxs)(`span`,{className:`architecture-history__quiet`,"data-gap":`skipped`,"data-count":r,children:[` `,o(`architectureHistory.base.skipped`,{count:r})]})]})]})]})}function Sm({path:e,github:t,read:n,refreshGeneration:r,selection:i,select:a,onSummary:o,t:c}){let l=am(e,n,r),[u,d]=(0,I.useState)(null),{timeline:f}=l,p=(0,I.useMemo)(()=>f?.milestones??[],[f]),m=p.find(e=>e.rev===u)??p.at(-1)??null,h=m===null||m.error?null:m,g=(0,I.useMemo)(()=>h===null?null:nm(p,h),[p,h]),_=(0,I.useMemo)(()=>h===null||g===null?null:lm(h,g),[h,g]),v=h===null?0:rm(p,h),y=h!==null&&i?.scope===h.rev?i:null,b=g===null||_===null?null:y===null?fm(_,g):y.id!==null&&g.capabilities.has(y.id)?y.id:null,x=h?.rev??``,S=(0,I.useCallback)(e=>a({view:`history`,scope:x,id:e}),[a,x]),C=e=>{d(e),a({view:`history`,scope:``,id:null})},w=f?.head??null,T=f?.total??0;return(0,I.useEffect)(()=>{o(w===null?null:{head:w,read:p.length,total:T})},[w,p.length,T,o]),(0,I.useEffect)(()=>()=>o(null),[o]),f===null?l.error===`history_shallow_repository`?(0,W.jsxs)(`section`,{className:`architecture-history__whole-error`,role:`alert`,"data-error-code":l.error,children:[(0,W.jsx)(`code`,{children:`history-shallow-repository`}),(0,W.jsx)(`p`,{children:c(`architecture.history.shallow`)}),(0,W.jsx)(s,{command:`git fetch --unshallow`,t:c})]}):l.error===null?(0,W.jsx)(`p`,{role:`status`,children:c(`architecture.history.loading`)}):(0,W.jsx)(`p`,{className:`architecture-notice`,role:`alert`,"data-error-code":l.error,children:c(`architecture.failed`,{code:l.error})}):(0,W.jsxs)(`div`,{className:`architecture-history`,children:[l.error!==null&&(0,W.jsxs)(`div`,{className:`architecture-history__banner`,role:`alert`,"data-error-code":l.error,children:[(0,W.jsx)(`span`,{children:c(`architecture.refreshFailed`,{code:l.error})}),(0,W.jsx)(`button`,{type:`button`,onClick:l.retry,children:c(`architecture.history.retry`)})]}),(0,W.jsx)(`div`,{className:`architecture-history__body`,"data-stale":l.error!==null||void 0,children:m===null?(0,W.jsx)(`p`,{className:`architecture-history__empty`,children:c(`architecture.history.empty`)}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(vm,{timeline:f,selected:m.rev,onSelect:C,more:l.more,onMore:l.loadMore,t:c}),m.error?(0,W.jsxs)(`section`,{className:`architecture-history__canvas`,"aria-label":c(`architecture.history.map`),children:[(0,W.jsx)(`p`,{className:`architecture-history__caption`,children:c(`architectureHistory.caption.error`,{rev:sm(m.rev)})}),(0,W.jsxs)(`div`,{className:`architecture-history__canvas-error`,children:[(0,W.jsx)(`code`,{children:m.error.code}),m.error.path&&(0,W.jsx)(`p`,{children:(0,W.jsx)(`code`,{children:m.error.path})})]})]}):(0,W.jsx)(hm,{milestone:m,shape:g,marks:_,skipped:v,selected:b,onSelect:S,t:c},m.rev),(0,W.jsx)(xm,{milestone:m,shape:g,marks:_,skipped:v,selected:b,github:t,t:c})]})})]})}var Cm=40,wm=96,Tm=12,Em=24,Dm=e=>`label:${e}`,Om=(e,t)=>(t.lines??0)-(e.lines??0)||e.node.name.localeCompare(t.node.name);function km(e,t){let n=new Map(e.sizes.state===`ok`?e.sizes.nodes.map(e=>[e.id,e]):[]),r=new Map;for(let t of e.nodes)t.parent!==null&&r.set(t.parent,[...r.get(t.parent)??[],t.id]);let i=(t,i)=>e.sizes.state===`ok`?(n.get(t)?.[i]??0)-(r.get(t)??[]).reduce((e,t)=>e+(n.get(t)?.[i]??0),0):null,a=new Map(e.nodes.map(e=>[e.id,e.layer])),o=new Map;for(let t of e.relations){let e=a.get(t.source),n=a.get(t.target);if(e==null||n==null||e===n)continue;let r=qi.has(t.kind),i=`${e}\n${n}\n${r}`,s=o.get(i)??{source:e,target:n,dashed:r,relations:[],protocols:[]};s.relations.push(t.id),t.protocol!==null&&!s.protocols.includes(t.protocol)&&s.protocols.push(t.protocol),o.set(i,s)}let s=new Map(t.map((e,t)=>[e,t])),c=(e,t)=>[...o.values()].filter(n=>(t===`right`?n.source:n.target)===e).sort((e,n)=>s.get(t===`right`?e.target:e.source)-s.get(t===`right`?n.target:n.source)||Number(e.dashed)-Number(n.dashed)),l=e=>Tm*(1+Math.max(0,...t.map(t=>c(t,e).length))),u=120+l(`left`),d=u+656,f=t.map((t,n)=>{let r=e.nodes.filter(e=>e.layer===t).map(e=>({node:e,files:i(e.id,`files`),lines:i(e.id,`lines`)})).sort(Om),a=t=>e.sizes.state===`ok`?r.reduce((e,n)=>e+n[t],0):null;return{layer:t,index:n,members:r,files:a(`files`),lines:a(`lines`),x:u,y:Em+n*96,width:656,height:56}}),p=new Map(f.map(e=>[e.layer,e])),m=e=>e===null||!p.has(e)?[]:[`right`,`left`].flatMap(t=>{let n=c(e,t),r=t===`right`?d:u,i=t===`right`?Tm:-12,a=(e,t,n)=>e.y+e.height*(t+1)/(n+1),o=n.map(e=>t===`right`?e.target:e.source);return n.map((s,c)=>{let l=o[c],u=a(p.get(e),c,n.length),d=a(p.get(l),o.slice(0,c).filter(e=>e===l).length,o.filter(e=>e===l).length),f=r+i*(c+1),[m,h]=t===`right`?[u,d]:[d,u],g={id:`lane:${s.source}->${s.target}:${s.dashed?`runtime`:`code`}`,source:s.source,target:s.target,points:[[r,m],[f,m],[f,h],[r,h]],arrows:{start:!1,end:!0},kind:`lane`,dashed:s.dashed,width:1.5};return{...s,side:t,route:g}})}),h=f.flatMap(e=>[{id:Dm(e.layer),parent:null,x:Em,y:e.y,width:wm,height:e.height,kind:`band`},{id:e.layer,parent:null,x:e.x,y:e.y,width:e.width,height:e.height,kind:e.members.length===0?`external`:`box`}]),g={width:d+l(`right`)+Em,height:48+t.length*56+Math.max(0,t.length-1)*Cm};return{bands:f,lanes:m,scene:e=>({boxes:h.map(t=>t.id===e?{...t,kind:`${t.kind} selected`}:t),routes:m(e).map(e=>e.route),labels:[],extent:g})}}var Am=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e).toLowerCase(),jm=7,Mm=e=>`L${e.index} ${e.layer}`,Nm=e=>e.members.map(e=>e.node.name).join(` · `),Pm={label:(0,I.memo)(function({data:e}){return(0,W.jsx)(`span`,{className:`architecture-layermap__band`,children:Mm(e.band)})}),layer:(0,I.memo)(function({data:e,selected:t}){let{band:n,t:r}=e;return(0,W.jsxs)(`div`,{className:`architecture-layermap__box`,"data-layer-box":n.layer,"data-selected":t||void 0,"data-empty":n.members.length===0||void 0,children:[(0,W.jsx)(Kp,{}),(0,W.jsx)(`strong`,{children:n.layer}),(0,W.jsx)(`span`,{className:`architecture-layermap__members`,title:Nm(n),children:n.members.length===0?r(`architecture.layers.empty`):Nm(n)}),n.lines!==null&&(0,W.jsx)(`span`,{className:`architecture-layermap__lines mono-value`,children:Am(n.lines)})]})})};function Fm(e,t){return[{key:`code`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.layers.legend.runtime`)},...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,W.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k`}),text:t(`architecture.layers.legend.lines`)}]:[]]}function Im(e){return t=>{let n=e.get(t.id);return t.id===n.layer?[n.layer,[...n.lines===null?[]:[Am(n.lines)],Nm(n)].filter(Boolean).join(` · `)]:[Mm(n)]}}function Lm({band:e,t}){let n=e.members.filter(e=>e.lines>0);if(n.length===0)return(0,W.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.map.noSize`)});let r=n.slice(0,jm),i=n.slice(jm),a=[...r.map(e=>({key:e.node.id,name:e.node.name,lines:e.lines})),...i.length>0?[{key:`rest`,name:t(`architecture.layers.rest`,{count:i.length}),lines:i.reduce((e,t)=>e+t.lines,0)}]:[]],o=Math.max(...a.map(e=>e.lines));return(0,W.jsx)(`ul`,{className:`architecture-layermap__sizes`,"data-layer-sizes":!0,children:a.map(e=>(0,W.jsxs)(`li`,{"data-size-row":e.key,children:[(0,W.jsx)(`span`,{className:`architecture-layermap__size-name`,title:e.name,children:e.name}),(0,W.jsx)(`span`,{className:`architecture-layermap__bar`,children:(0,W.jsx)(`span`,{style:{width:`${Math.round(e.lines/o*100)}%`}})}),(0,W.jsx)(`span`,{className:`mono-value`,children:Am(e.lines)})]},e.key))})}function Rm({map:e,layer:t,t:n}){let r=e.layers.violations.layer_direction;if(r.state===`unavailable`){let e=r.reason===`archctx_error`?n(`architecture.layer.reason.archctx_error`,{code:dp(r)}):n(`architecture.layer.reason.${r.reason}`);return(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`layer_direction`,"data-reason":r.reason,children:n(`architecture.layer.violations.gap`,{part:n(`architecture.layer.violations.layer_direction.label`),reason:e})})}let i=new Map;for(let e of r.edges){if(e.source_layer!==t&&e.target_layer!==t)continue;let n=`${e.source_layer}\n${e.target_layer}`,r=i.get(n)??{source:e.source_layer,target:e.target_layer,imports:0};i.set(n,{...r,imports:r.imports+e.imports})}return(0,W.jsxs)(W.Fragment,{children:[i.size===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.layers.violations.none`)}):(0,W.jsx)(`ul`,{className:`architecture-layermap__pairs`,"data-layer-violations":!0,children:[...i.values()].map(e=>(0,W.jsxs)(`li`,{"data-pair":`${e.source}->${e.target}`,children:[(0,W.jsxs)(`span`,{children:[e.source,` → `,e.target]}),(0,W.jsx)(`span`,{className:`mono-value`,children:e.imports}),(0,W.jsx)(`span`,{className:`architecture-layermap__verdict`,children:n(`architecture.layers.violation`)})]},`${e.source}-${e.target}`))}),(0,W.jsx)(`p`,{className:`detail-quiet`,"data-layer-checked":!0,children:n(`architecture.layers.checked`,{imports:r.imports})})]})}var zm=e=>[`${e.source} → ${e.target}`,...e.protocols].join(` · `);function Bm({lanes:e,t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:t(`architecture.modules.relations`,{count:e.length})}),e.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.none`)}):(0,W.jsx)(`ul`,{"data-layer-lanes":!0,children:e.map(e=>{let n=e.side===`right`?`out`:`in`;return(0,W.jsxs)(`li`,{"data-lane":e.route.id,"data-direction":n,children:[(0,W.jsx)(`span`,{className:`architecture-map__swatch${e.dashed?` architecture-map__swatch--dashed`:``}`,role:`img`,"aria-label":t(e.dashed?`architecture.layers.legend.runtime`:`architecture.map.legend.code`)}),` `,(0,W.jsx)(`span`,{className:`mono-value`,children:t(`architecture.modules.direction.${n}`)}),` `,n===`out`?e.target:e.source,e.protocols.length>0&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`code`,{children:e.protocols.join(` · `)})]})]},e.route.id)})})]})}function Vm({map:e,band:t,lanes:n,t:r}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,W.jsxs)(`span`,{className:`architecture-modules__eyebrow`,children:[`L`,t.index]}),(0,W.jsx)(`h3`,{children:t.layer}),t.files!==null&&(0,W.jsx)(`span`,{className:`detail-quiet`,"data-layer-size":!0,children:r(`architecture.map.sizeValue`,{lines:t.lines,files:t.files})})]}),(0,W.jsx)(Bm,{lanes:n,t:r}),e.sizes.state===`ok`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.layers.size`)}),(0,W.jsx)(Lm,{band:t,t:r})]}),(0,W.jsx)(`h4`,{children:r(`architecture.layer.violations.layer_direction.label`)}),(0,W.jsx)(Rm,{map:e,layer:t.layer,t:r}),(0,W.jsxs)(`details`,{className:`architecture-layermap__nodes`,children:[(0,W.jsx)(`summary`,{children:r(`architecture.layers.members`,{count:t.members.length})}),(0,W.jsx)(`ul`,{children:t.members.map(e=>(0,W.jsxs)(`li`,{"data-member":e.node.id,children:[e.node.name,` `,(0,W.jsx)(`span`,{className:`detail-quiet`,children:e.node.kind})]},e.node.id))})]})]})}function Hm({map:e,t}){return e.sizes.state===`unavailable`?(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`sizes`,"data-reason":e.sizes.reason,children:t(`architecture.map.sizes.${e.sizes.reason}`)}):null}function Um({map:e,order:t,selected:n,onSelect:r,t:i}){let a=(0,I.useMemo)(()=>km(e,t),[e,t]),o=a.bands.find(e=>e.layer===n)??null,s=o?.layer??null,c=(0,I.useMemo)(()=>a.scene(s),[a,s]),l=(0,I.useMemo)(()=>a.lanes(s),[a,s]),u=e.nodes.filter(e=>e.layer===null).length,d=(0,I.useMemo)(()=>new Map(a.bands.flatMap(e=>[[Dm(e.layer),e],[e.layer,e]])),[a]),f=(0,I.useCallback)(e=>{let t=d.get(e.id);return e.id===t.layer?{type:`layer`,ariaLabel:Mm(t),selection:t.layer,data:{band:t,t:i}}:{type:`label`,ariaLabel:Mm(t),selection:null,data:{band:t}}},[d,i]),p=(0,I.useCallback)(e=>zm(l.find(t=>t.route.id===e.id)),[l]);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{className:`architecture-lens`,children:(0,W.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,W.jsx)(`span`,{"data-layers-provenance":!0,children:i(`architecture.layers.provenance`,{version:e.archctx_version})}),(0,W.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-layers-export":!0,onClick:()=>Jp(`layers-${e.commit.slice(0,7)}.svg`,c,Im(d)),children:i(`architecture.layers.export`)})]})}),(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`layers`,"data-layer-count":a.bands.length,"data-lane-count":l.length,children:[(0,W.jsx)(Zp,{label:i(`architecture.layers.label`),scene:c,nodeTypes:Pm,view:f,selected:s,routeLabel:p,onSelect:r,legend:Fm(e,i),t:i}),(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":i(`architecture.layers.inspector`),"data-layer-id":s??void 0,children:[(0,W.jsx)(Hm,{map:e,t:i}),u>0&&(0,W.jsx)(Mp,{part:`layers.unlayered`,reason:`node_layer_undeclared`,children:i(`architecture.layers.unlayered`,{count:u})}),o===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.layers.pick`)}):(0,W.jsx)(Vm,{map:e,band:o,lanes:l,t:i})]})]})]})}function Wm({map:e,selectedId:t,onSelect:n,t:r}){let i=e.layer_order;return i.state===`unavailable`?(0,W.jsx)(`div`,{className:`architecture-map`,"data-view":`layers`,children:(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`layer_order`,"data-reason":i.reason,children:r(`architecture.layers.${i.reason}`)})}):(0,W.jsx)(Um,{map:e,order:i.layers,selected:t,onSelect:n,t:r},e.commit)}var Gm=200,Km=64,qm=8,Jm=12,Ym=30,Xm=26,Zm=16,Qm=72,$m=24,eh=1,th=e=>`domain:${e}`,nh=e=>24+7*e.length,rh=(e,t)=>Math.round((1+5*Math.sqrt(e/t))*100)/100,ih=e=>e===1?1:e<=4?2:3;function ah(e){let t=new Map;for(let n of e.nodes)n.kind===`capability`&&t.set(n.domain,[...t.get(n.domain)??[],n]);let n=[...t.keys()].sort((e,n)=>t.get(n).length-t.get(e).length||e.localeCompare(n)),r=e.nodes.filter(e=>e.kind===`external-system`),i=new Map([...t].flatMap(([e,t])=>t.map(t=>[t.id,e]))),a=new Map;if(e.dependencies.state===`ok`)for(let t of e.dependencies.edges){let[e,n]=[i.get(t.source),i.get(t.target)];if(e===void 0||n===void 0||e===n)continue;let r=`${e}\n${n}`;a.set(r,(a.get(r)??0)+t.imports)}let o=[...a].map(([e,t])=>{let[n,r]=e.split(`
9
9
  `);return{id:`imports:${n}->${r}`,source:n,target:r,imports:t}}),s=Math.max(1,...a.values()),c=xp(e),l=new Set(r.map(e=>e.id)),u=e=>{let t=c.get(e);return t===void 0?l.has(e)?e:null:th(i.get(t))},d=new Set;for(let t of e.relations){let[e,n]=[u(t.source),u(t.target)];e!==null&&n!==null&&e!==n&&(l.has(e)||l.has(n))&&d.add(`${e}\n${n}`)}let f=e=>{let n=t.get(e).length,r=ih(n),i=Math.ceil(n/r);return{width:r*Gm+(r-1)*qm+24,height:Ym+i*Km+(i-1)*qm+Jm}},p=(e,t,n,r,i)=>({id:e,source:t,target:n,arrows:{start:!1,end:!0},kind:r,dashed:!1,width:i}),m=Fi({nodes:n.map(e=>({id:th(e),kind:`frame`,...f(e)})),edges:o.map(e=>({...p(e.id,th(e.source),th(e.target),`imports`,rh(e.imports,s)),weight:e.imports})),nodesep:48,ranksep:72,margin:$m}),h=Math.max(0,...m.boxes.map(e=>e.x+e.width)),g=[],_=$m,v=Math.max(0,...m.boxes.map(e=>e.y+e.height))+Qm;for(let e of r){let t=nh(e.name);_>$m&&_+t>h&&(_=$m,v+=50),g.push({id:e.id,parent:null,x:_,y:v,width:t,height:Xm,kind:`external`}),_+=t+Zm}let y=[...m.boxes,...g],b=new Map(y.map(e=>[e.id,e])),x=e=>[e.x+e.width/2,e.y+e.height/2],S=[...d].map(e=>{let[t,n]=e.split(`
10
- `),[r,i]=[b.get(t),b.get(n)],a=Mi([xi(r,x(i)),xi(i,x(r))],y.filter(e=>e!==r&&e!==i));return{...p(`relation:${t}->${n}`,t,n,`relation`,eh),points:a}}),C=[...m.routes,...S],w=n.flatMap(e=>{let n=b.get(th(e)),r=ih(t.get(e).length);return t.get(e).map((e,t)=>({id:e.id,parent:n.id,kind:`box`,width:Gm,height:Km,x:n.x+Jm+t%r*208,y:n.y+Ym+Math.floor(t/r)*72}))}),T=y.flatMap(e=>[e,...w.filter(t=>t.parent===e.id)]);return{domains:n,capabilities:n.flatMap(e=>t.get(e)),externals:r,edges:o,scene:{boxes:T,routes:C,labels:[],extent:Pi(T,C,$m)}}}function oh(e,t){let n=new Map(e.capabilities.map(e=>[e.id,e.domain])),r=new Set,i=new Map,a=(e,t)=>i.set(e,i.has(e)&&i.get(e)!==t?`both`:t);for(let e of t){let[t,i]=[n.get(e.source),n.get(e.target)];t===i?(a(e.source,`out`),a(e.target,`in`)):r.add(`imports:${t}->${i}`)}return{scene:r.size===0?e.scene:{...e.scene,routes:e.scene.routes.map(e=>r.has(e.id)?{...e,kind:`undeclared`,dashed:!0}:e)},cards:i}}var sh={in:`←`,out:`→`,both:`⇄`};function ch({kind:e,state:t,t:n}){let r=n(`architecture.modules.${e}.${t}`);return(0,W.jsx)(`span`,{className:`architecture-modules__badge mono-value`,"data-badge":e,"data-state":t,role:`img`,"aria-label":r,title:r,children:sh[t]})}var lh=(0,I.memo)(function({data:e}){return(0,W.jsxs)(`div`,{className:`architecture-modules__domain`,"data-domain":e.domain,children:[(0,W.jsx)(Kp,{}),(0,W.jsx)(`b`,{children:e.domain})]})}),uh=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`];function dh(e){let t=Cp(e,`changes`).marks,n=Cp(e,`violations`).marks,r=Cp(e,`decisions`).marks,{pull_requests:i,tests:a}=e.layers,o=(i.state===`ok`?i.pull_requests:[]).map(t=>({number:t.number,marks:Cp(e,`pull_requests`,t.number).marks})),s=new Map((a.state===`ok`?a.capabilities:[]).map(e=>[e.id,e]));return new Map(e.nodes.filter(e=>e.kind===`capability`).map(e=>[e.id,{changes:t.get(e.id),violations:n.get(e.id)?.count??0,pullRequests:o.filter(t=>t.marks.get(e.id)?.tone===`change`).map(e=>e.number),tests:s.get(e.id),decisions:r.get(e.id)?.count??0}]))}function fh(e,t,n,r={}){return e(n===1?`architecture.modules.hover.${t}One`:`architecture.modules.hover.${t}`,{count:n,...r})}function ph(e,t){let{changes:n,violations:r,pullRequests:i,tests:a,decisions:o}=e,s=n?.count??0,c=n?.atLeast?`+`:``;return[{layer:`changes`,tone:null,value:n===void 0?null:n.count===null?`↳`:s>0?`${s}${c}`:null,words:n===void 0?null:n.count===null?t(`architecture.modules.hover.dependent`):s>0?fh(t,`changes`,s):null},{layer:`violations`,tone:`danger`,value:r>0?String(r):null,words:r>0?fh(t,`violations`,r):null},{layer:`pull_requests`,tone:`info`,value:i.length>0?String(i.length):null,words:i.length>0?fh(t,`pull_requests`,i.length,{list:i.map(e=>`#${e}`).join(`, `)}):null},{layer:`tests`,tone:a!==void 0&&a.failed>0?`danger`:null,value:a===void 0?null:a.failed>0?`${a.failed}✕`:a.no_result>0?`?`:null,words:a===void 0?null:t(`architecture.layer.node.tests`,{files:a.files,passed:a.passed,failed:a.failed,skipped:a.skipped,noResult:a.no_result})},{layer:`decisions`,tone:null,value:o>0?String(o):null,words:o>0?fh(t,`decisions`,o):null}]}var mh={domain:lh,module:(0,I.memo)(function({data:e,selected:t}){let{node:n,size:r,layer:i,slots:a,neighbour:o,undeclared:s,dimmed:c,t:l}=e,u=a.find(e=>e.layer===i&&e.value!==null)?.tone??void 0,d=a.flatMap(e=>e.words??[]).join(` · `);return(0,W.jsxs)(`div`,{className:`architecture-modules__box`,title:d||void 0,"data-selected":t||void 0,"data-layer":i,"data-alert":u,"data-neighbour":o??void 0,"data-undeclared":s??void 0,"data-dimmed":c||void 0,"data-deprecated":n.status===`deprecated`||void 0,children:[(0,W.jsxs)(`span`,{className:`architecture-modules__name`,children:[(0,W.jsx)(`strong`,{children:n.name}),n.status===`deprecated`&&(0,W.jsx)(`span`,{className:`architecture-modules__status`,children:l(`architecture.modules.deprecated`)}),o!==null&&(0,W.jsx)(ch,{kind:`neighbour`,state:o,t:l}),s!==null&&(0,W.jsx)(ch,{kind:`undeclared`,state:s,t:l})]}),(0,W.jsx)(`span`,{className:`architecture-modules__size mono-value`,children:r===null?``:`${Am(r.lines)} · ${Am(r.files)}`}),(0,W.jsx)(`span`,{className:`architecture-modules__slots`,children:a.map(e=>(0,W.jsx)(`span`,{className:`architecture-modules__slot mono-value`,"data-slot":e.layer,"data-active":e.layer===i||void 0,"data-tone":e.layer===i&&e.value!==null?e.tone??void 0:void 0,children:e.value},e.layer))})]})}),external:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-modules__external`,"data-selected":t||void 0,"data-neighbour":e.neighbour??void 0,"data-dimmed":e.dimmed||void 0,children:[(0,W.jsx)(Kp,{}),e.node.name,e.neighbour!==null&&(0,W.jsx)(ch,{kind:`neighbour`,state:e.neighbour,t:e.t})]})})},hh=(e,t)=>[`out`,`in`,`both`].map(n=>({key:`${e}-${n}`,swatch:(0,W.jsx)(`span`,{className:`architecture-modules__badge mono-value`,"data-badge":e,"data-state":n,"aria-hidden":`true`,children:sh[n]}),text:t(`architecture.modules.legend.${e}.${n}`)}));function gh(e,t){return[...e.routes?[{key:`undeclared`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--undeclared`}),text:t(`architecture.layer.legend.undeclared`)}]:[],...e.selection?hh(`neighbour`,t):[],...e.cards?hh(`undeclared`,t):[]]}function _h({entries:e,t}){return e.length===0?null:(0,W.jsx)(`dl`,{className:`architecture-modules__states`,"aria-label":t(`architecture.map.legend`),"data-narrow-legend":!0,children:e.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.swatch}),(0,W.jsx)(`dd`,{children:e.text})]},e.key))})}function vh(e,t,n,r,i){return[...t.edges.length>0?[{key:`width`,swatch:(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),text:i(`architecture.modules.legend.width`)}]:[],...gh(n,i),...t.externals.length>0?[{key:`external`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:i(`architecture.map.legend.external`)}]:[],...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,W.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k · 4`}),text:i(`architecture.modules.legend.lines`)}]:[],{key:`slots`,swatch:(0,W.jsx)(`span`,{className:`architecture-modules__key mono-value`,children:uh.map(e=>(0,W.jsx)(`span`,{"data-active":e===r||void 0,children:i(`architecture.modules.slot.${e}`)},e))}),text:``}]}function yh(e,t){let n=xp(e),r=e=>n.get(e)??e,i=new Map(e.dependencies.state===`ok`?e.dependencies.edges.map(e=>[`${e.source}\n${e.target}`,e.imports]):[]);return e.relations.flatMap(e=>{let[n,a]=[r(e.source),r(e.target)],o=n===t?`out`:a===t?`in`:null;return o===null?[]:[{id:e.id,direction:o,other:o===`out`?e.target:e.source,holder:o===`out`?a:n,kind:e.kind,imports:n===a?null:i.get(`${n}\n${a}`)??null}]})}function bh(e,t,n){let r=xp(e),i=new Set([...t.capabilities,...t.externals].map(e=>e.id)),a=e=>r.get(e)??e,o=new Map;for(let t of e.relations){let[e,r]=[a(t.source),a(t.target)],s=e===r?null:e===n?`out`:r===n?`in`:null,c=s===`out`?r:e;s!==null&&i.has(c)&&o.set(c,o.has(c)&&o.get(c)!==s?`both`:s)}return o}function xh({selected:e,relations:t,names:n,t:r}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.modules.relations`,{count:t.length})}),t.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}):(0,W.jsx)(`ul`,{"data-card-relations":!0,children:t.map(t=>(0,W.jsxs)(`li`,{"data-relation-id":t.id,"data-direction":t.direction,children:[(0,W.jsx)(`span`,{className:`mono-value`,children:r(`architecture.modules.direction.${t.direction}`)}),` `,n.get(t.other),t.holder!==t.other&&t.holder!==e&&(0,W.jsxs)(W.Fragment,{children:[` (`,n.get(t.holder),`)`]}),` · `,(0,W.jsx)(`code`,{children:t.kind}),t.imports!==null&&(0,W.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:t.imports})]})]},t.id))})]})}function Sh({map:e,ids:t,t:n}){let{changes:r}=e.layers;if(r.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`changes`,children:r.reason===`archctx_error`?n(`architecture.layer.changes.archctx_error`,{code:dp(r)}):n(`architecture.layer.changes.${r.reason}`)});let i=r.commits.filter(e=>e.nodes.some(e=>t.has(e)));return i.length?(0,W.jsx)(`ul`,{"data-module-commits":!0,children:i.map(e=>(0,W.jsxs)(`li`,{"data-commit":e.sha,children:[(0,W.jsx)(`code`,{children:e.sha.slice(0,7)}),` `,e.subject]},e.sha))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.changes.none`)})}function Ch({map:e,pullRequest:t,ids:n,capability:r,t:i}){let{pull_requests:a}=e.layers;if(a.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`pull_requests`,children:i(`architecture.layer.pull_requests.${a.reason}`)});let o=a.pull_requests.find(e=>e.number===t);if(o===void 0)return(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.inspector.none`)});let{impact:s}=o;if(s.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`pull_request`,children:s.reason===`archctx_error`?i(`architecture.layer.pull_requests.pr.archctx_error`,{code:dp(s)}):i(`architecture.layer.pull_requests.pr.${s.reason}`)});let c=new Map(e.nodes.map(e=>[e.id,e.name])),l=xp(e),u=[],d=mp(s,n);d>0&&u.push({key:`files`,text:i(`architecture.modules.impact.files`,{files:Ap(i,d,`file`,s.truncated.paths)})});let f=[...n].flatMap(e=>_p(s,e)).filter(e=>!n.has(e));f.length>0&&u.push({key:`targets`,text:i(`architecture.layer.node.dependent`,{names:[...new Set(f)].map(e=>c.get(e)??e).join(`, `)})});let p=new Map(e.flows.map(e=>[e.id,e]));for(let e of s.flow_steps.items??[]){let t=p.get(e.flow);if(t===void 0||t.applicability!==`required`)continue;let r=rf(t),a=r.findIndex(t=>t.outcome===e.outcome&&t.step.id===e.step),o=new Map(t.participants.map(e=>[e.id,e.node])),s=r[a]?.step;s!==void 0&&[s.from,s.to].some(e=>n.has(o.get(e)))&&u.push({key:`step-${e.flow}-${e.outcome??``}-${e.step}`,text:i(`architecture.modules.impact.step`,{flow:t.name,step:a+1})})}let m=[...new Set(s.dependents.filter(e=>n.has(e.touched)).flatMap(e=>l.get(e.id)??[]))].filter(e=>e!==r);return m.length>0&&u.push({key:`downstream`,text:i(`architecture.modules.impact.downstream`,{count:m.length,names:m.map(e=>c.get(e)??e).join(`, `)})}),u.length?(0,W.jsx)(`ul`,{"data-module-impact":o.number,children:u.map(e=>(0,W.jsx)(`li`,{children:e.text},e.key))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.modules.impact.none`,{number:o.number})})}function wh({map:e,capability:t,t:n}){let{tests:r}=e.layers;if(r.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`tests`,children:n(`architecture.layer.tests.${r.reason}`)});let i=r.capabilities.find(e=>e.id===t);return i===void 0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.tests.none`)}):(0,W.jsx)(`p`,{"data-module-tests":!0,children:n(`architecture.layer.node.tests`,{files:i.files,passed:i.passed,failed:i.failed,skipped:i.skipped,noResult:i.no_result})})}function Th({map:e,pullRequest:t,node:n,relations:r,onModule:i,t:a}){let o=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),s=(0,I.useMemo)(()=>{let t=xp(e);return new Set(e.nodes.flatMap(e=>t.get(e.id)===n.id?[e.id]:[]))},[e,n.id]),c=Ip(e,n.id),l=Rp(e,s,o,a),u=[...new Set(l.flatMap(e=>e.part??[]))],d=e.layers.decisions.items.filter(e=>e.applies_to.some(e=>s.has(e)));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,W.jsx)(`span`,{className:`architecture-modules__eyebrow`,"data-module-domain":!0,children:n.domain}),(0,W.jsx)(`h3`,{children:n.name}),(0,W.jsxs)(`span`,{className:`architecture-map__id mono-value`,children:[n.id,e.sizes.state===`ok`&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`span`,{"data-node-size":!0,children:c===null?a(`architecture.map.noSize`):a(`architecture.map.sizeValue`,{lines:c.lines,files:c.files})})]})]})]}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.changes`)}),(0,W.jsx)(Sh,{map:e,ids:s,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),l.length?(0,W.jsx)(zp,{facts:l,layer:`violations`,source:!0}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),(0,W.jsx)(`h4`,{children:t===null?a(`architecture.layer.pull_requests`):a(`architecture.modules.impact.title`,{number:t})}),(0,W.jsx)(Ch,{map:e,pullRequest:t,ids:s,capability:n.id,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.tests`)}),(0,W.jsx)(wh,{map:e,capability:n.id,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.decisions`)}),d.length?(0,W.jsx)(`ul`,{"data-module-decisions":!0,children:d.map(e=>(0,W.jsxs)(`li`,{children:[e.status===null?e.title:a(`architecture.layer.node.decision`,{title:e.title,status:e.status}),` · `,(0,W.jsx)(`code`,{children:e.path})]},e.id))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),u.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:a(`architecture.modules.fix`)}),u.map(e=>(0,W.jsx)(Fp,{part:e,t:a},e))]}),(0,W.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(n.id),children:a(`architecture.map.open`)}),(0,W.jsx)(xh,{selected:n.id,relations:r,names:o,t:a})]})}function Eh({map:e,layer:t,pullRequest:n,selectedId:r,onSelect:i,side:a,onModule:o,t:s}){let c=(0,I.useMemo)(()=>ah(e),[e]),l=(0,I.useMemo)(()=>Cp(e,t,n),[e,t,n]),{scene:u,cards:d}=(0,I.useMemo)(()=>oh(c,l.edges),[c,l]),f=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e]),p=(0,I.useMemo)(()=>new Map(e.sizes.state===`ok`?e.sizes.nodes.map(e=>[e.id,{lines:e.lines,files:e.files}]):[]),[e]),m=(0,I.useMemo)(()=>dh(e),[e]),h=(0,I.useMemo)(()=>new Map(c.edges.map(e=>[e.id,e.imports])),[c]),g=r===null?null:f.get(r)??null,_=(0,I.useMemo)(()=>g===null?[]:yh(e,g.id),[e,g]),v=(0,I.useMemo)(()=>g===null?new Map:bh(e,c,g.id),[e,c,g]),y=(0,I.useCallback)(e=>{if(e.parent===null&&e.kind===`frame`){let t=e.id.slice(th(``).length);return{type:`domain`,ariaLabel:t,selection:null,data:{domain:t}}}let n=f.get(e.id),i=v.get(n.id)??null,a=r!==null&&n.id!==r&&i===null,o=d.get(n.id)??null,c=[`${n.kind} ${n.name}`,...i===null?[]:[s(`architecture.modules.neighbour.${i}`)],...o===null?[]:[s(`architecture.modules.undeclared.${o}`)]].join(` · `);return n.kind===`external-system`?{type:`external`,ariaLabel:c,selection:n.id,data:{node:n,neighbour:i,dimmed:a,t:s}}:{type:`module`,ariaLabel:c,selection:n.id,data:{node:n,size:p.get(n.id)??null,layer:t,slots:ph(m.get(n.id),s),neighbour:i,undeclared:o,dimmed:a,t:s}}},[f,v,d,r,p,m,t,s]),b={routes:u!==c.scene,cards:d.size>0,selection:v.size>0},x=g===null?null:g.kind===`capability`?th(g.domain):g.id,S=(0,I.useCallback)(e=>{let t=e=>e.startsWith(th(``))?e.slice(th(``).length):f.get(e)?.name??e,n={source:t(e.source),target:t(e.target)};return e.kind===`relation`?s(`architecture.modules.route.relation`,n):e.kind===`undeclared`?s(`architecture.modules.route.undeclared`,n):s(`architecture.modules.route.imports`,{...n,count:h.get(e.id)})},[f,h,s]);return(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`modules`,"data-node-count":e.nodes.length,"data-relation-count":e.relations.length,"data-edge-count":c.edges.length,"data-layer":t,children:[(0,W.jsx)(Zp,{label:s(`architecture.map.label`),scene:u,nodeTypes:mh,view:y,selected:r,emphasis:x,routeLabel:S,onSelect:i,legend:vh(e,c,b,t,s),t:s}),(0,W.jsx)(_h,{entries:gh(b,s),t:s}),(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":s(`architecture.map.inspector`),"data-node-id":g?.id,children:[a,g===null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.pick`)}),(0,W.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.counts`,{nodes:Ap(s,e.nodes.length,`node`),relations:Ap(s,e.relations.length,`relation`)})})]}):g.kind===`capability`?(0,W.jsx)(Th,{map:e,pullRequest:n,node:g,relations:_,onModule:o,t:s}):(0,W.jsx)(Up,{map:e,layer:t,pullRequest:n,nodeId:g.id,onModule:o,t:s})]})]})}function Dh(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map;for(let r of e.relations)r.kind===`deployed-on`&&t.get(r.target)?.kind===`process`&&n.set(r.source,(n.get(r.source)??new Set).add(r.target));let r=new Map;return e=>{let i=r.get(e);if(i)return i;let a=t.get(e)?.kind,o={kind:`unknown`,reason:`deployment_undeclared`};if(a===`process`)o={kind:`process`,process:e};else if(a===`external-system`)o={kind:`external`};else for(let r=e;r!==null;r=t.get(r)?.parent??null){let e=n.get(r);if(e!==void 0){o=e.size===1?{kind:`process`,process:[...e][0]}:{kind:`unknown`,reason:`deployment_ambiguous`};break}}return r.set(e,o),o}}var Oh=16,kh=24,Ah=8,jh=16,Mh=196,Nh=44,Ph=24,Fh=12,Ih=52,Lh=4,Rh=16,zh=28,Bh=12,Vh=28,Hh=24;function Uh(e){return e.kind===`process`?`process:${e.process}`:e.kind===`external`?`external`:`unknown:${e.reason}`}var Wh=e=>`participant:${e}`,Gh=(e,t)=>`message:${e??``}:${t}`,Kh=e=>e===0?`alt`:`else`,qh=(e,t)=>t===null?e.label:`${e.label} · ${t}`,Jh=e=>li(e,`title`)+24;function Yh(e,t,n,r){let i=[],a=new Map;for(let n of e.participants){let e=t(n.node),r=Uh(e);a.has(r)||(i.push(r),a.set(r,{placement:e,participants:[]})),a.get(r).participants.push(n)}let o=i.flatMap(e=>a.get(e).participants.map(t=>({participant:t,key:e,header:Math.max(Mh,Jh(r.participant(t)))}))),s=new Map(o.map((e,t)=>[e.participant.id,t])),c=o.slice(1).map((e,t)=>o[t].header/2+e.header/2+Ph),l=Ah+o[0].header/2,u=(e,t)=>{e<0?l=Math.max(l,t):e<c.length&&(c[e]=Math.max(c[e],t))},d=[...e.steps,...e.outcomes.flatMap(e=>e.steps)];for(let e of d){let t=s.get(e.from),r=s.get(e.to),i=li(qh(e,n.status(e)),`label`);t===r?u(t,Hh+i+24):u(t<r?t:t-1,i+24)}for(let t of e.outcomes){let e=s.get(t.terminal.participant),n=Jh(t.terminal.label)/2+Fh;u(e-1,n),u(e,n)}let f=[],p=new Map;for(let[e,t]of o.entries()){let n=o[e-1],i=n===void 0?Oh+l:f[e-1]+c[e-1];n!==void 0&&n.key!==t.key&&(i=Math.max(i,p.get(n.key).right+jh+Ah+t.header/2)),f.push(i);let s=p.get(t.key)?.left??i-t.header/2-Ah;p.set(t.key,{left:s,right:Math.max(i+t.header/2+Ah,s+Jh(r.process(a.get(t.key).placement)))})}let m=e=>f[s.get(e)],h=[],g=new Map,_=new Map,v=(e,t,n)=>{h.push(e),g.set(e.id,t),n!==null&&_.set(e.id,n)},y=[],b=[],x=126;for(let t of e.steps)y.push({outcome:null,step:t,y:x}),x+=Ih;for(let[t,n]of e.outcomes.entries()){let e=x-Ih/2+Bh;x=e+zh+Ih/2+Rh/2;for(let e of n.steps)y.push({outcome:n.id,step:e,y:x}),x+=Ih;b.push({outcome:n,index:t,top:e,terminal:x}),x+=Ih}let S=x-Ih/2;for(let e of i){let{placement:t,participants:n}=a.get(e),{left:i,right:c}=p.get(e),l=`box:${e}`;v({id:l,parent:null,x:i,y:Oh,width:c-i,height:76,kind:t.kind===`process`?`box`:`external`},{kind:`process`,placement:t},r.process(t));for(let e of n){let t=Wh(e.id),n=o[s.get(e.id)].header;v({id:t,parent:l,x:m(e.id)-n/2,y:40,width:n,height:Nh,kind:`member`},{kind:`participant`,participant:e},r.participant(e)),v({id:`lifeline:${e.id}`,parent:t,x:m(e.id)-.5,y:84,width:1,height:S-Oh-kh-Nh,kind:`lifeline`},{kind:`lifeline`},null)}}for(let{outcome:e,index:t,top:n,terminal:r}of b){let i=[e.terminal.participant,...e.steps.flatMap(e=>[e.from,e.to])].map(m),a=Math.min(...i)-Mh/2,o=Math.max(...i)+Mh/2,s=`${Kh(t)} ${e.label}`;v({id:`fragment:${e.id}`,parent:null,x:a,y:n,width:Math.max(o-a,Jh(s)),height:zh,kind:`fragment ${e.kind}`},{kind:`fragment`,outcome:e,index:t},s);let c=Jh(e.terminal.label);v({id:`terminal:${e.id}`,parent:null,x:m(e.terminal.participant)-c/2,y:r-Vh/2,width:c,height:Vh,kind:`terminal ${e.kind}`},{kind:`terminal`,outcome:e},e.terminal.label)}let C=[],w=[],T=new Map;for(let{outcome:e,step:t,y:r}of y){let i=Gh(e,t.id),a=m(t.from),o=m(t.to),l=n.tone(e,t),u=n.status(t),d=qh(t,l===`danger`?u:null),f=a===o,p=o>a?.5:-.5,h=f?[[a+.5,r-8],[a+Hh,r-8],[a+Hh,r+8],[a+.5,r+8]]:[[a+p,r],[o-p,r]],g=f?[a+Hh+Fh+li(d,`label`)/2,r]:[(a+(o>a?a+c[s.get(t.from)]:a-c[s.get(t.from)-1]))/2,r-Lh-Rh/2];C.push({id:i,source:`lifeline:${t.from}`,target:`lifeline:${t.to}`,points:h,arrows:{start:!1,end:!0},kind:l===null?`message`:`message-${l}`,dashed:!1,width:1.5}),w.push(yi(d,g,i)),T.set(i,{outcome:e,step:t,tone:l,status:u})}return{scene:{boxes:h,routes:C,labels:w,extent:Pi(h,C,Oh,w)},parts:g,messages:T,lines:e=>_.has(e.id)?[_.get(e.id)]:[]}}var Xh=(e,t,n)=>`${e}\0${t??``}\0${n}`;function Zh(e,t,n){let{changes:r,pull_requests:i}=e.layers,a=t===`changes`?r.state===`ok`?r:null:t===`pull_requests`&&i.state===`ok`?i.pull_requests.find(e=>e.number===n)?.impact??null:null;return a===null||a.state===`unavailable`?new Set:new Set((a.flow_steps.items??[]).map(e=>Xh(e.flow,e.outcome,e.step)))}function Qh(e){let{flows:t}=e.layers.violations;return t.state===`ok`?new Map(t.evidence.map(e=>[nf(e),e.status])):null}function $h(e,t,n,r,i,a){if(t.has(Xh(r,i,a.id)))return`change`;let o=n?.get(nf(a.evidence));return e===`violations`&&o!==void 0&&o!==`proven`?`danger`:null}function eg(e,t,n,r){return new Set(e.flows.filter(e=>rf(e).some(({outcome:i,step:a})=>$h(t,n,r,e.id,i,a)!==null)).map(e=>e.id))}function tg(e,t,n,r){let i=e.flows.filter(e=>e.applicability===`required`),a=eg(e,t,n,r);return(i.find(e=>a.has(e.id))??i[0]??e.flows[0])?.id??null}var ng={box:(0,I.memo)(function({data:e}){return(0,W.jsx)(`div`,{className:`architecture-sequence__box`,"data-placement":e.placement.kind,"data-reason":e.reason??void 0,title:e.reason??void 0,children:(0,W.jsx)(`span`,{children:e.title})})}),fragment:(0,I.memo)(function({data:e}){return(0,W.jsxs)(`div`,{className:`architecture-sequence__fragment`,"data-kind":e.kind,title:e.label,children:[(0,W.jsx)(`span`,{className:`mono-value`,children:Kh(e.index)}),` `,e.label]})}),header:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__box architecture-sequence__header`,"data-kind":e.kind,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,children:[(0,W.jsx)(`strong`,{className:`architecture-sequence__name`,children:e.name}),e.mark!==null&&(0,W.jsx)(`span`,{className:`architecture-sequence__header-mark`,children:(0,W.jsx)(Np,{mark:e.mark})})]})}),lifeline:(0,I.memo)(function(){return(0,W.jsx)(`div`,{className:`architecture-sequence__lifeline`,children:(0,W.jsx)(Kp,{})})}),terminal:(0,I.memo)(function({data:e}){return(0,W.jsx)(`div`,{className:`architecture-sequence__terminal`,"data-kind":e.kind,title:e.label,children:e.label})})};function rg(e,t,n){return e.kind===`process`?t.get(e.process)??e.process:e.kind===`external`?n(`architecture.sequence.external`):n(`architecture.runtime.${e.reason}`)}function ig({evidence:e,t}){if(e===void 0)return(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`evidence`,"data-reason":`selector_undeclared`,children:t(`architecture.sequence.evidence.undeclared`)});let n=e=>e===null?(0,W.jsx)(`span`,{"data-path-withheld":!0,children:t(`architecture.sequence.evidence.withheld`)}):(0,W.jsx)(`code`,{children:e});return(0,W.jsxs)(`ul`,{className:`architecture-sequence__code`,"data-step-evidence":!0,children:[(0,W.jsxs)(`li`,{children:[n(e.source_path),` `,(0,W.jsx)(`code`,{children:e.source_symbol})]}),(0,W.jsxs)(`li`,{children:[`→ `,n(e.sink_path),` `,(0,W.jsx)(`code`,{children:e.sink_symbol})]})]})}function ag({map:e,flow:t,outcome:n,step:r,t:i}){let a=new Map(e.nodes.map(e=>[e.id,e.name])),o=new Map(t.participants.map(e=>[e.id,e.node])),s=o.get(r.from),c=o.get(r.to),l=nf(r.evidence),u=e.flow_evidence.find(e=>nf(e)===l),{flows:d}=e.layers.violations,f=d.state===`ok`?d.evidence.find(e=>nf(e)===l)??null:null,p=f?.status??null,m=e.dependencies.state===`ok`?e.dependencies.edges:[],h=e.relations.filter(e=>e.source===s&&e.target===c||e.source===c&&e.target===s),{changes:g,pull_requests:_}=e.layers,v=e=>(e??[]).some(e=>e.flow===t.id&&e.outcome===n&&e.step===r.id),y=g.state===`ok`&&v(g.flow_steps.items),b=_.state===`ok`?_.pull_requests.filter(e=>e.impact.state===`ok`&&v(e.impact.flow_steps.items)):[],x=t=>{let n=Ip(e,t);return e.sizes.state===`ok`?n===null?i(`architecture.map.noSize`):i(`architecture.map.sizeValue`,{lines:n.lines,files:n.files}):null};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:i(`architecture.sequence.selected`)}),(0,W.jsxs)(`h3`,{"data-step-title":!0,children:[a.get(s),` → `,a.get(c)]}),(0,W.jsx)(`p`,{children:r.label}),(0,W.jsxs)(`code`,{className:`architecture-map__id`,children:[t.id,` · `,n??i(`architecture.sequence.main`),` · `,r.id]}),(0,W.jsx)(`dl`,{className:`detail-list`,children:[s,c].map((e,t)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:i(t===0?`architecture.sequence.from`:`architecture.sequence.to`)}),(0,W.jsxs)(`dd`,{children:[a.get(e),x(e)!==null&&(0,W.jsxs)(`span`,{className:`detail-quiet`,"data-node-size":!0,children:[` · `,x(e)]})]})]},t))}),(0,W.jsx)(`h4`,{children:i(`architecture.sequence.evidence`)}),(0,W.jsx)(ig,{evidence:u,t:i}),(0,W.jsx)(`h4`,{children:i(`architecture.sequence.proof`)}),d.state===`ok`?(0,W.jsx)(`p`,{"data-step-proof":p??`missing`,children:p===null?i(`architecture.sequence.proof.missing`):i(p===`proven`?`architecture.sequence.proof.proven`:`architecture.sequence.proof.unproven`,{status:p})}):(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`proof`,"data-reason":d.reason,"data-code":d.reason===`archctx_error`?dp(d):void 0,children:d.reason===`archctx_error`?i(`architecture.layer.reason.archctx_error`,{code:dp(d)}):i(`architecture.layer.reason.${d.reason}`)}),f!==null&&f.call_sites.length>0&&(0,W.jsx)(`ul`,{className:`architecture-sequence__code`,"data-call-sites":!0,"aria-label":i(`architecture.sequence.callSites`),children:f.call_sites.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e.line===null?e.path:`${e.path}:${e.line}`})},`${e.path}:${e.line??``}`))}),p!==`proven`&&(0,W.jsx)(Fp,{part:`flows`,t:i}),(0,W.jsx)(`h4`,{children:i(`architecture.inspector.pullRequests`)}),y&&(0,W.jsx)(`p`,{"data-step-today":!0,children:i(`architecture.sequence.today`)}),b.length?(0,W.jsx)(`ul`,{"data-related-prs":!0,children:b.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title]},e.number))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:_.state===`unavailable`?i(`architecture.layer.pull_requests.${_.reason}`):i(`architecture.inspector.none`)}),(0,W.jsx)(`h4`,{children:i(`architecture.sequence.relations`,{count:h.length})}),h.length?(0,W.jsx)(`ul`,{children:h.map(e=>{let t=m.find(t=>t.source===e.source&&t.target===e.target)?.imports;return(0,W.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,W.jsx)(`code`,{children:e.kind}),` `,a.get(e.source),` → `,a.get(e.target),t!==void 0&&(0,W.jsxs)(`span`,{className:`mono-value`,children:[` · `,i(`architecture.map.imports`,{count:t})]})]},e.id)})}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.none`)})]})}function og(e){return[{key:`process`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--box`}),text:e(`architecture.sequence.legend.process`)},{key:`external`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:e(`architecture.sequence.legend.external`)},{key:`success`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--success`}),text:e(`architecture.sequence.legend.success`)},{key:`error`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--danger`}),text:e(`architecture.sequence.legend.error`)}]}function sg(e,t,n,r,i){let a=Zh(e,n,r),o=Qh(e),s=new Map(e.nodes.map(e=>[e.id,e.name]));return Yh(t,Dh(e),{tone:(e,r)=>$h(n,a,o,t.id,e,r),status:e=>{let t=o?.get(nf(e.evidence));return t===void 0||t===`proven`?null:t}},{process:e=>cg(e,s,i),participant:e=>s.get(e.node)})}function cg(e,t,n){return e.kind===`unknown`?n(`architecture.sequence.unknown`):rg(e,t,n)}function lg({map:e,layout:t,layer:n,pullRequest:r,selected:i,onSelect:a,t:o}){let s=(0,I.useMemo)(()=>wp(e,n,r),[e,n,r]),c=(0,I.useCallback)(n=>{let r=new Map(e.nodes.map(e=>[e.id,e.name])),i=t.parts.get(n.id);if(i.kind===`participant`){let t=e.nodes.find(e=>e.id===i.participant.node),r=t?.name??i.participant.node;return{type:`header`,ariaLabel:`${t?.kind} ${r}`,selection:n.id,data:{name:r,kind:t?.kind??``,mark:s.marks.get(i.participant.node)??null,quiet:s.available&&!s.lit.has(i.participant.node)}}}if(i.kind===`process`){let e=cg(i.placement,r,o);return{type:`box`,ariaLabel:e,selection:null,data:{placement:i.placement,title:e,reason:i.placement.kind===`unknown`?o(`architecture.runtime.${i.placement.reason}`):null}}}return i.kind===`fragment`?{type:`fragment`,ariaLabel:`${Kh(i.index)} ${i.outcome.label}`,selection:null,data:{kind:i.outcome.kind,index:i.index,label:i.outcome.label}}:i.kind===`terminal`?{type:`terminal`,ariaLabel:i.outcome.terminal.label,selection:null,data:{kind:i.outcome.kind,label:i.outcome.terminal.label}}:{type:`lifeline`,ariaLabel:``,selection:null,data:{}}},[e,t,s,o]),l=(0,I.useCallback)(e=>t.scene.labels.find(t=>t.route===e.id).text,[t]),u=(0,I.useCallback)(e=>e.id,[]),d=i!==null&&t.parts.get(i)?.kind===`participant`?`lifeline:${i.slice(12)}`:null;return(0,W.jsx)(Zp,{label:o(`architecture.sequence.label`),scene:t.scene,nodeTypes:ng,view:c,selected:i,emphasis:d,routeLabel:l,routeSelection:u,onSelect:a,legend:og(o),t:o})}function ug({map:e,flow:t,layout:n,layer:r,pullRequest:i,selected:a,lead:o,onModule:s,t:c}){let l=t.applicability===`required`?t:null,u=a===null?null:n?.messages.get(a)??null,d=a===null?null:n?.parts.get(a)??null,f=d?.kind===`participant`?d.participant.node:null,p=f===null?null:{node:f,place:Dh(e)(f)};return(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":c(`architecture.sequence.inspector`),"data-node-id":f??void 0,"data-step-id":u?`${u.outcome??``}:${u.step.id}`:void 0,children:[o,l!==null&&(u?(0,W.jsx)(ag,{map:e,flow:l,outcome:u.outcome,step:u.step,t:c}):p===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.sequence.pick`)}):(0,W.jsx)(Up,{map:e,layer:r,pullRequest:i,nodeId:p.node,onModule:s,t:c,children:(0,W.jsx)(`p`,{"data-runtime":p.place.kind,children:c(`architecture.sequence.runsIn`,{place:rg(p.place,new Map(e.nodes.map(e=>[e.id,e.name])),c)})})}))]})}var dg={violations:`imports_on_module_map`,tests:`tests_by_capability`,decisions:`decisions_by_node`};function fg(e,t,n,r,i){let a=i!==null&&e.flows.some(e=>e.id===i)?i:tg(e,t,n,r);return e.flows.find(e=>e.id===a)}function pg({map:e,layer:t,pullRequest:n,flowId:r,t:i}){let a=(0,I.useMemo)(()=>Zh(e,t,n),[e,t,n]),o=(0,I.useMemo)(()=>Qh(e),[e]),s=(0,I.useMemo)(()=>{let t=new Set(e.flow_evidence.map(e=>nf(e))),n=e.flows.flatMap(e=>rf(e));return{flows:e.flows.length,steps:n.length,evidenced:n.filter(({step:e})=>t.has(nf(e.evidence))).length}},[e]);if(e.flows.length===0)return null;let c=fg(e,t,a,o,r);return(0,W.jsxs)(`div`,{className:`architecture-lens__tools`,children:[(0,W.jsx)(`span`,{"data-sequence-summary":!0,children:i(`architecture.sequence.summary`,s)}),(0,W.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-sequence-export":!0,disabled:c.applicability!==`required`,onClick:()=>{if(c.applicability!==`required`)return;let r=sg(e,c,t,n,i);Jp(`${c.id}.svg`,r.scene,r.lines)},children:i(`architecture.sequence.export`)})]})}function mg({map:e,flowId:t,lit:n,onFlow:r,t:i}){return(0,W.jsxs)(`div`,{className:`architecture-sequence__flows`,role:`group`,"aria-labelledby":`architecture-sequence-flows`,children:[(0,W.jsx)(`h4`,{id:`architecture-sequence-flows`,children:i(`architecture.sequence.flows`)}),(0,W.jsx)(`div`,{className:`architecture-sequence__flow-list`,children:e.flows.map((e,a)=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===t,"data-flow-id":e.id,"data-lit":n.has(e.id)||void 0,title:`${e.name} · ${e.id}`,onClick:()=>r(e.id),children:[(0,W.jsx)(`span`,{className:`mono-value`,children:a+1}),(0,W.jsx)(`span`,{className:`architecture-sequence__flow-name`,children:e.name}),n.has(e.id)&&(0,W.jsx)(`span`,{className:`architecture-sequence__lit`,"aria-label":i(`architecture.sequence.lit`)})]},e.id))})]})}function hg({map:e,layer:t,pullRequest:n,flowId:r,onFlow:i,selection:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,I.useMemo)(()=>Zh(e,t,n),[e,t,n]),d=(0,I.useMemo)(()=>Qh(e),[e]),f=(0,I.useMemo)(()=>eg(e,t,u,d),[e,t,u,d]),p=e.flows.length===0?null:fg(e,t,u,d,r),m=(0,I.useMemo)(()=>p?.applicability===`required`?sg(e,p,t,n,l):null,[e,p,t,n,l]),h=p?.id??``,g=(0,I.useCallback)(e=>o(h,e),[h,o]);if(p===null)return(0,W.jsxs)(`div`,{className:`architecture-map`,children:[(0,W.jsx)(Mp,{part:`sequence.flows`,reason:`flows_undeclared`,children:l(`architecture.sequence.none`)}),(0,W.jsx)(`aside`,{className:`architecture-map__inspector`,"aria-label":l(`architecture.sequence.inspector`),children:s})]});let _=dg[t],v=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(mg,{map:e,flowId:p.id,lit:f,onFlow:i,t:l}),s,_&&(0,W.jsx)(Mp,{part:`sequence.${t}`,reason:_,children:l(`architecture.sequence.note.${_}`)})]}),y=a?.scope===p.id?a.id:null;return(0,W.jsx)(`div`,{className:`architecture-sequence`,children:(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`sequence`,"data-flow":p.id,"data-layer":t,children:[p.applicability===`not-applicable`?(0,W.jsx)(Mp,{part:`sequence.not_applicable`,reason:`flow_not_applicable`,children:l(`architecture.flow.notApplicable`,{rationale:p.rationale})}):(0,W.jsx)(lg,{map:e,layout:m,layer:t,pullRequest:n,selected:y,onSelect:g,t:l},p.id),(0,W.jsx)(ug,{map:e,flow:p,layout:m,layer:t,pullRequest:n,selected:y,lead:v,onModule:c,t:l})]})})}var gg=[`process`,`namespace`,`mount`],_g=new Set([`namespace`,`process`,`mount`,`external-system`]),vg=220,yg=72,bg=32,xg=16,Sg=12,Cg=72,wg=320,Tg=24,Eg=1.5,Dg=new Set([`runs-in`,`deployed-on`,`mounts`]),Og=(e,t)=>`${e}/${t}`,kg=(e,t)=>e(t.source)&&e(t.target);function Ag(e,t,n,r,i=!0){let a=new Set(r?[]:e.nodes.filter(e=>e.status===`deprecated`).map(e=>e.id)),o=e=>!a.has(e);return n===`process`?Fg(e,t,o,i):n===`namespace`?Bg(e,o,i):Vg(e,o)}function jg(e){let t=Dh(e),n=[`namespace`,`process`,`mount`],r=n.map(n=>Ag(e,t,n,!0).boxes.filter(e=>e.node.kind!==`external-system`).length),i=[2,1].map(e=>r.findIndex(t=>t>=e)).find(e=>e>=0);return i===void 0?`namespace`:n[i]}function Mg(e,t){let n=new Map(e.nodes.map(e=>[e.id,e.kind]));return e.relations.find(e=>e.kind===`runs-in`&&e.source===t&&n.get(e.target)===`namespace`)?.target??null}function Ng(e,t,n,r,i){return{id:e,source:t,target:n,kind:r,dashed:i,relations:[],protocols:[]}}function Pg(e,t){return{...e,relations:[...e.relations,t.id],protocols:t.protocol===null||e.protocols.includes(t.protocol)?e.protocols:[...e.protocols,t.protocol]}}function Fg(e,t,n,r){let i=new Map(e.nodes.map(e=>[e.id,e])),a=e.nodes.filter(e=>(e.kind===`process`||e.kind===`external-system`)&&n(e.id)),o=e=>{let t=i.get(e)?.kind;return t===`process`||t===`external-system`},s=new Map;for(let t of e.relations)t.kind===`deployed-on`&&kg(n,t)&&i.get(t.target)?.kind===`process`&&!_g.has(i.get(t.source).kind)&&s.set(t.target,[...s.get(t.target)??[],i.get(t.source)]);let c=e=>{if(o(e))return e;let n=t(e);return n.kind===`process`?n.process:null},l=new Map,u=[];for(let t of e.relations){if(Dg.has(t.kind)||!kg(n,t)||[t.source,t.target].some(e=>{let t=i.get(e).kind;return t===`namespace`||t===`mount`}))continue;let e=c(t.source),r=c(t.target);if(e!==null&&!n(e)||r!==null&&!n(r))continue;if(e===null||r===null){(e!==null||r!==null)&&u.push(t.id);continue}if(e===r)continue;let a=qi.has(t.kind),s=o(t.source)&&o(t.target)?t.kind:a?`io`:`code`,d=`${e}\n${r}\n${s}`;l.set(d,Pg(l.get(d)??Ng(`topology:${d}`,e,r,s,a),t))}let d=e=>{let t=s.get(e.id)?.length??0;return 44+t*26+(t>0?8:0)},f=Fi({nodes:a.map(e=>({id:e.id,width:vg,height:d(e),kind:Ig(e,null)})),edges:[...l.values()].map(e=>({...Lg(e),weight:e.relations.length})),nodesep:32,ranksep:72,margin:Tg},r),p=a.map(e=>({node:e,members:s.get(e.id)??[],group:!1,tone:null}));return{base:`process`,boxes:p,edges:[...l.values()],unplaced:u,scene:Rg(p,f.boxes,f.routes,[...l.values()])}}var Ig=(e,t)=>t??(e.kind===`namespace`?`frame`:e.kind===`external-system`?`external`:`box`),Lg=e=>({id:e.id,source:e.source,target:e.target,arrows:{start:!1,end:!0},kind:e.kind,dashed:e.dashed,width:Eg});function Rg(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=e.flatMap(e=>{let t=i.get(e.node.id);return[t,...e.members.map((n,r)=>({id:Og(e.node.id,n.id),parent:t.id,x:t.x+12,y:t.y+44+r*26,width:t.width-24,height:22,kind:`member`}))]}),o=new Map(n.map(e=>[e.id,e.points]));return{boxes:a,routes:n,labels:r.filter(e=>e.protocols.length>0).map(e=>yi(e.protocols.join(` · `),bi(o.get(e.id)),e.id)),extent:Pi(a,n,Tg)}}var zg=(e,t)=>e.mount.order-t.mount.order;function Bg(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=e=>r.get(e).kind,a=e.nodes.filter(e=>(e.kind===`namespace`||e.kind===`mount`)&&t(e.id)),o=e=>{let n=e;for(;n!==null&&i(n)===`namespace`&&!t(n);)n=r.get(n).parent;return n!==null&&i(n)===`namespace`?n:null},s=new Map;for(let e of a){let t=e.kind===`namespace`?o(e.parent):null;t!==null&&s.set(e.id,t)}for(let n of e.relations){if(n.kind!==`mounts`||i(n.target)!==`mount`||!t(n.target))continue;let r=o(i(n.source)===`namespace`?n.source:i(n.source)===`process`?Mg(e,n.source):null);r!==null&&s.set(n.target,r)}let c=new Map;for(let n of e.relations)i(n.target)===`mount`&&kg(t,n)&&(n.kind===`writes`?c.set(n.target,`writer`):n.kind===`reads`&&c.get(n.target)!==`writer`&&c.set(n.target,`reader`));let l=e=>{let n=i(e);return(n===`namespace`||n===`mount`)&&t(e)},u=new Map;for(let t of e.relations){if(Dg.has(t.kind)||!l(t.source)||!l(t.target)||t.source===t.target)continue;let e=`${t.source}\n${t.target}\n${t.kind}`;u.set(e,Pg(u.get(e)??Ng(`topology:${e}`,t.source,t.target,t.kind,qi.has(t.kind)),t))}let d=e=>[...a.filter(t=>t.kind===`mount`&&s.get(t.id)===e).sort(zg),...a.filter(t=>t.kind===`namespace`&&s.get(t.id)===e)],f=[],p=[],m=(e,t,n)=>{let r=s.get(e.id)??null;if(e.kind===`mount`){let i={node:e,members:[],group:!1,tone:c.get(e.id)??`point`},a={id:e.id,parent:r,x:t,y:n,width:vg,height:yg,kind:Ig(e,i.tone)};return f.push(i),p.push(a),a}let i=f.length,a=d(e.id),o=n+bg+xg,l=vg;for(let e of a){let n=m(e,t+xg,o);o=n.y+n.height+Sg,l=Math.max(l,n.width)}let u=a.length===0?74:o-Sg+xg-n,h={id:e.id,parent:r,x:t,y:n,width:l+32,height:u,kind:`frame`};return f.splice(i,0,{node:e,members:[],group:a.length>0,tone:null}),p.splice(i,0,h),h},h=d(void 0).map(e=>m(e,0,0)),g=e=>{let t=e;for(;s.has(t);)t=s.get(t);return t},_=[...u.values()].filter(e=>g(e.source)!==g(e.target)),v=Fi({nodes:h.map(e=>({id:e.id,width:e.width,height:e.height,kind:e.kind})),edges:_.map(e=>({...Lg(e),source:g(e.source),target:g(e.target),weight:e.relations.length})),nodesep:Cg,ranksep:72,margin:Tg},n),y=new Map(v.boxes.map(e=>[e.id,e])),b=new Map(p.map(e=>{let t=y.get(g(e.id));return[e.id,{...e,x:e.x+t.x,y:e.y+t.y}]})),x=e=>[e.x+e.width/2,e.y+e.height/2],S=new Map(v.routes.map(e=>[e.id,e])),C=e=>{let t=[e];for(;s.has(t[t.length-1]);)t.push(s.get(t[t.length-1]));return t},w=[...u.values()].map(e=>{let[t,r]=[b.get(e.source),b.get(e.target)],i=S.get(e.id),a=i===void 0?[xi(t,x(r)),xi(r,x(t))]:[...i.points];i!==void 0&&i.source!==e.source&&a.unshift(xi(t,a[0])),i!==void 0&&i.target!==e.target&&a.push(xi(r,a[a.length-1]));let o=new Set([...C(e.source),...C(e.target)]);return{...Lg(e),points:n?Mi(a,[...b.values()].filter(e=>!o.has(e.id))):a}});return{base:`namespace`,boxes:f,edges:[...u.values()],unplaced:[],scene:Rg(f,[...b.values()],w,[...u.values()])}}function Vg(e,t){let n=new Map(e.nodes.map(e=>[e.id,e])),r=new Map;for(let i of e.relations)i.kind===`mounts`&&kg(t,i)&&n.get(i.target)?.kind===`mount`&&r.set(i.source,[...r.get(i.source)??[],n.get(i.target)]);let i=e.nodes.filter(e=>r.has(e.id)).map(e=>({node:e,members:[...r.get(e.id)].sort(zg),group:!1,tone:null}));return{base:`mount`,boxes:i,edges:[],unplaced:[],scene:Rg(i,i.map((e,t)=>({id:e.node.id,parent:null,x:Tg+t*352,y:Tg,width:wg,height:44+e.members.length*26+8,kind:Ig(e.node,null)})),[],[])}}var Hg=e=>e.status===`deprecated`||void 0,Ug={box:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__group architecture-topology__box`,"data-kind":e.node.kind,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.node.name}),(0,W.jsx)(Np,{mark:e.mark})]}),(0,W.jsx)(`span`,{className:`architecture-map__meta`,children:e.detail})]})]})}),namespace:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__group architecture-topology__namespace`,"data-kind":`namespace`,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.node.name}),(0,W.jsx)(Np,{mark:e.mark})]}),(0,W.jsx)(`span`,{className:`architecture-map__meta mono-value`,children:e.detail})]}),e.empty!==null&&(0,W.jsx)(`p`,{className:`architecture-topology__empty`,"data-namespace-empty":!0,children:e.empty})]})}),mount:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__box architecture-topology__mount`,"data-kind":`mount`,"data-mount-tone":e.tone??void 0,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.node.name}),(0,W.jsx)(Np,{mark:e.mark})]}),(0,W.jsx)(`span`,{className:`architecture-topology__summary`,title:e.node.summary,children:e.node.summary})]})}),member:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsx)(`div`,{className:`architecture-map__box architecture-topology__member`,"data-kind":e.node.kind,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.detail}),(0,W.jsx)(Np,{mark:e.mark})]})})})},Wg=(e,t)=>e??t(`architecture.topology.masked`);function Gg(e,t){let{order:n,source:r,target:i,mode:a}=e.mount;return t(`architecture.topology.mountRow`,{order:n,source:Wg(r,t),target:Wg(i,t),mode:a})}function Kg(e,t){return e.members.length>0?t(e.members[0].kind===`mount`?`architecture.topology.mounts`:`architecture.topology.deployed`,{count:e.members.length}):e.node.kind===`namespace`?e.node.namespace.type:e.node.kind}var qg=(e,t)=>e.kind===`mount`?Gg(e,t):e.name,Jg=e=>new Map(e.boxes.flatMap(e=>[[e.node.id,{box:e,member:null}],...e.members.map(t=>[Og(e.node.id,t.id),{box:e,member:t}])]));function Yg(e,t){let n=Jg(e);return e=>{let{box:r,member:i}=n.get(e.id);return i===null?[r.node.name,Kg(r,t)]:[qg(i,t)]}}function Xg(e,t){return e===`process`?[{key:`code`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.topology.legend.runtime`)},{key:`external`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:t(`architecture.map.legend.external`)}]:(e===`namespace`?[`writer`,`reader`,`point`]:[`point`]).map(e=>({key:e,swatch:(0,W.jsx)(`span`,{className:`architecture-topology__swatch`,"data-mount-tone":e}),text:t(`architecture.topology.legend.${e}`)}))}var Zg=(e,t,n)=>Ag(e,Dh(e),t,n);function Qg({map:e,base:t,onBase:n,legacy:r,onLegacy:i,t:a}){let o=(0,I.useMemo)(()=>Zg(e,t,!0),[e,t]),s=o.boxes.flatMap(e=>[e.node,...e.members]).filter(e=>e.status===`deprecated`).length;return(0,W.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,W.jsx)(`span`,{className:`architecture-topology__bases`,role:`group`,"aria-label":a(`architecture.topology.base`),children:gg.map(e=>(0,W.jsx)(`button`,{type:`button`,"data-topology-base":e,"aria-pressed":e===t,onClick:()=>n(e),children:a(`architecture.topology.base.${e}`)},e))}),(0,W.jsxs)(`button`,{type:`button`,className:`architecture-lens__export architecture-topology__legacy`,"data-topology-legacy":!0,"aria-pressed":r,disabled:s===0,title:s===0?a(`architecture.topology.legacyNone`):void 0,onClick:()=>i(!r),children:[(0,W.jsx)(`span`,{className:`architecture-topology__switch`,"aria-hidden":`true`}),a(`architecture.topology.legacy`),(0,W.jsx)(`span`,{className:`mono-value`,children:s})]}),(0,W.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-topology-export":!0,disabled:o.boxes.length===0,onClick:()=>{let n=Zg(e,t,r);Jp(`topology-${t}-${e.commit.slice(0,7)}.svg`,n.scene,Yg(n,a))},children:a(`architecture.topology.export`)})]})}function $g({map:e,nodeId:t,names:n,t:r}){let i=e.relations.filter(e=>e.kind===`writes`&&e.target===t);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.topology.writers`)}),i.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,"data-writers":`none`,children:r(`architecture.topology.noWriter`)}):(0,W.jsx)(`ul`,{"data-writers":!0,children:i.map(e=>(0,W.jsx)(`li`,{children:n.get(e.source)},e.id))})]})}function e_({map:e,layout:t,layer:n,pullRequest:r,selectedId:i,onSelect:a,side:o,onModule:s,t:c}){let l=(0,I.useMemo)(()=>Dh(e),[e]),u=(0,I.useMemo)(()=>wp(e,n,r),[e,n,r]),d=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),f=(0,I.useMemo)(()=>new Map(t.boxes.map(e=>[e.node.id,e])),[t]),p=(0,I.useMemo)(()=>Jg(t),[t]),m=(0,I.useMemo)(()=>{let n=new Map(t.scene.boxes.map(e=>[e.id,e.parent])),r=new Map(t.boxes.flatMap(e=>e.members.map(t=>[t.id,e.node.id]))),i=t=>{if(f.has(t))return t;if(r.has(t))return r.get(t);let n=l(t);return n.kind===`process`?f.has(n.process)?n.process:Mg(e,n.process):null},a=new Set;for(let e of u.lit)for(let t=i(e);t!==null&&!a.has(t);t=n.get(t)??null)a.add(t);return a},[t,u,l,f,e]),h=(0,I.useCallback)(e=>{let{box:n,member:r}=p.get(e.id);return r===null?{type:t.base===`namespace`?n.node.kind===`namespace`?`namespace`:`mount`:`box`,ariaLabel:`${n.node.kind} ${n.node.name}`,selection:n.node.id,data:{node:n.node,mark:u.marks.get(n.node.id)??null,quiet:u.available&&!m.has(n.node.id),detail:Kg(n,c),tone:n.tone,empty:t.base===`namespace`&&n.node.kind===`namespace`&&!n.group?c(`architecture.topology.noMount`):null}}:{type:`member`,ariaLabel:`${r.kind} ${r.name}`,selection:r.id,data:{node:r,mark:u.marks.get(r.id)??null,quiet:u.available&&!u.lit.has(r.id),detail:qg(r,c),tone:null,empty:null}}},[p,u,m,t,c]),g=i===null?null:e.nodes.find(e=>e.id===i),_=i===null?null:f.get(i)??null,v=g===null||_g.has(g.kind)?null:l(g.id),y=g?.kind===`process`?Mg(e,g.id):null,b=g?.kind===`mount`?e.relations.find(e=>e.kind===`mounts`&&e.target===g.id)?.source??null:null;return(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`topology`,"data-base":t.base,"data-node-count":t.boxes.length,"data-edge-count":t.edges.length,"data-layer":n,children:[(0,W.jsx)(Zp,{label:c(`architecture.topology.label`),scene:t.scene,nodeTypes:Ug,view:h,selected:i,onSelect:a,legend:Xg(t.base,c),t:c}),(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":c(`architecture.map.inspector`),"data-node-id":i??void 0,children:[o,g===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.map.pick`)}):(0,W.jsxs)(Up,{map:e,layer:n,pullRequest:r,nodeId:g.id,onModule:s,t:c,children:[y!==null&&(0,W.jsx)(`p`,{"data-runs-in":y,children:c(`architecture.topology.in`,{name:d.get(y)})}),v?.kind===`process`&&(0,W.jsx)(`p`,{"data-runtime":`process`,children:c(`architecture.sequence.runsIn`,{place:d.get(v.process)})}),g.kind===`namespace`&&(0,W.jsx)(`dl`,{className:`detail-list`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.type`)}),(0,W.jsx)(`dd`,{"data-namespace-type":!0,children:g.namespace.type})]})}),g.kind===`mount`&&(0,W.jsxs)(`dl`,{className:`detail-list`,"data-mount-fields":!0,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.order`)}),(0,W.jsx)(`dd`,{className:`mono-value`,children:g.mount.order})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.path`)}),(0,W.jsxs)(`dd`,{className:`mono-value`,children:[Wg(g.mount.source,c),` → `,Wg(g.mount.target,c)]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.mode`)}),(0,W.jsx)(`dd`,{className:`mono-value`,children:g.mount.mode})]}),b!==null&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.mounter`)}),(0,W.jsx)(`dd`,{children:d.get(b)})]})]}),(g.kind===`namespace`||g.kind===`mount`)&&(0,W.jsx)($g,{map:e,nodeId:g.id,names:d,t:c}),g.kind===`process`&&_!==null&&_.members.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:c(`architecture.topology.deployed`,{count:_.members.length})}),(0,W.jsx)(`ul`,{"data-deployed":!0,children:_.members.map(t=>{let n=Ip(e,t.id);return(0,W.jsxs)(`li`,{children:[t.name,n&&(0,W.jsxs)(`span`,{className:`detail-quiet`,children:[` · `,c(`architecture.map.sizeValue`,{lines:n.lines,files:n.files})]})]},t.id)})})]})]})]})]})}var t_={process:{part:`topology.processes`,reason:`process_undeclared`},namespace:{part:`topology.namespaces`,reason:`namespace_undeclared`},mount:{part:`topology.mounts`,reason:`mount_undeclared`}};function n_({map:e,layer:t,pullRequest:n,base:r,legacy:i,selectedId:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,I.useMemo)(()=>Dh(e),[e]),d=(0,I.useMemo)(()=>Ag(e,u,r,i),[e,u,r,i]),f=(0,I.useMemo)(()=>wp(e,t,n),[e,t,n]),p=e.nodes.some(e=>e.kind===`process`||e.kind===`namespace`||e.kind===`mount`)?d.boxes.some(e=>e.node.kind!==`external-system`)?null:{...t_[r],text:l(`architecture.topology.none.${r}`)}:{part:`topology.empty`,reason:`topology_undeclared`,text:l(`architecture.topology.none`)};if(p!==null)return(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`topology`,"data-base":r,children:[(0,W.jsx)(Mp,{part:p.part,reason:p.reason,children:p.text}),(0,W.jsx)(`aside`,{className:`architecture-map__inspector`,"aria-label":l(`architecture.map.inspector`),children:s})]});let m=new Map(e.nodes.map(e=>[e.id,e.name])),h=new Map(e.relations.map(e=>[e.id,e])),g=new Set(d.boxes.flatMap(e=>[e.node.id,...e.members.map(e=>e.id)])),_=r===`process`?[...f.marks.keys()].filter(e=>!g.has(e)&&u(e).kind===`unknown`):[];return(0,W.jsxs)(`div`,{className:`architecture-topology`,children:[t===`violations`&&(0,W.jsx)(Mp,{part:`topology.violations`,reason:`imports_on_module_map`,children:l(`architecture.sequence.note.imports_on_module_map`)}),_.length>0&&(0,W.jsx)(Mp,{part:`topology.unplaced_marks`,reason:`deployment_undeclared`,children:l(`architecture.topology.hidden`,{count:_.length})}),d.unplaced.length>0&&(0,W.jsx)(Mp,{part:`topology.unplaced`,reason:`deployment_undeclared`,children:(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:l(`architecture.topology.unplaced`,{count:d.unplaced.length})}),(0,W.jsx)(`ul`,{children:d.unplaced.map(e=>{let t=h.get(e);return(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:t.kind}),` `,m.get(t.source),` → `,m.get(t.target)]},e)})})]})}),(0,W.jsx)(e_,{map:e,layout:d,layer:t,pullRequest:n,selectedId:a,onSelect:o,side:s,onModule:c,t:l},`${e.commit}:${r}:${i}`)]})}async function r_(e,t){let n=await f(`/api/v1/repositories/${encodeURIComponent(e)}/architecture/map`,t);if(n.state===`unreachable`)return{state:`unavailable`,reason:`unreachable`};let{body:r}=n;if(!n.ok)return tf(r)??{state:`unavailable`,reason:`unreachable`};try{return{state:`ok`,map:sp(r)}}catch{return{state:`unavailable`,reason:`architecture_map_invalid`}}}function i_(e,t,n){let[r,i]=(0,I.useState)(null),a=(0,I.useCallback)(async n=>{let r=await e(t,n);return!n.aborted&&(i(e=>{let n=e?.repositoryId===t&&e.read.state===`ok`?e.read.map:null;return r.state===`ok`&&n!==null&&JSON.stringify(n)===JSON.stringify({...r.map,collected_at:n.collected_at})?e:{repositoryId:t,read:r}}),l(r))},[e,t]);return c(a,JSON.stringify([t,n])),r?.repositoryId===t?r.read:null}function a_(e,t){return t===`violations`?Object.values(e.layers.violations).some(e=>e.state===`ok`):e.layers[t].state===`ok`}function o_(e,t,n,r){if(!a_(e,t))return null;let{changes:i,pull_requests:a,tests:o,decisions:s}=e.layers,c=t=>[...Cp(e,t,n).marks.values()].filter(e=>e.tone!==`muted`).length;if(t===`changes`)return i.state===`ok`?r(`architecture.layer.count.changes`,{modules:Ap(r,c(`changes`),`module`,i.truncated.nodes),commits:Ap(r,i.commits.length,`commit`)}):null;if(t===`violations`)return String(pp(e));if(t===`pull_requests`){let e=a.state===`ok`?a.pull_requests.find(e=>e.number===n)?.impact:void 0;return n===null?null:e?.state===`ok`?r(`architecture.layer.count.pull_requests`,{number:n,modules:Ap(r,c(`pull_requests`),`module`,e.truncated.nodes)}):`#${n}`}return t===`tests`?o.state===`ok`?`${o.capabilities.length} / ${e.nodes.filter(e=>e.kind===`capability`).length}`:null:Ap(r,s.items.length,`decision`)}function s_({map:e,layer:t,pullRequest:n,onLayer:r,t:i}){return(0,W.jsx)(`div`,{className:`architecture-layers`,role:`group`,"aria-labelledby":`architecture-layers-label`,children:cp.map(a=>{let o=o_(e,a,n,i);return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":t===a,"data-layer":a,"data-state":a_(e,a)?`ok`:`unavailable`,onClick:()=>r(a),children:[i(`architecture.layer.${a}`),o!==null&&(0,W.jsx)(`span`,{className:`architecture-layers__count mono-value`,children:o})]},a)})})}function c_({part:e,impact:t,flowSteps:n,t:r}){let{flow_steps:i}=t,a=vp(t.truncated);return(0,W.jsxs)(W.Fragment,{children:[n&&(i.status===`known`?(0,W.jsx)(`p`,{"data-flow-steps":e,children:r(`architecture.layer.flow_steps.known`,{count:i.items.length})}):(0,W.jsx)(jp,{part:`${e}.flow_steps`,reason:i.reason_codes.join(` `),children:r(`architecture.layer.flow_steps.unknown`,{reasons:i.reason_codes.join(`, `)})})),n&&i.items!==null&&i.items.length>0&&(0,W.jsx)(`ul`,{"data-flow-step-list":e,children:i.items.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:e.flow}),` · `,e.step,e.reason_codes.length>0&&` · ${e.reason_codes.join(`, `)}`]},`${e.flow}:${e.outcome??``}:${e.step}`))}),a.length>0&&(0,W.jsx)(Mp,{part:`${e}.truncated`,reason:a.join(` `),children:[r(`architecture.layer.truncated`,{parts:a.map(e=>r(`architecture.layer.truncated.part.${e}`)).join(`, `)}),...a.includes(`paths`)?[r(`architecture.layer.truncated.paths`)]:[]].join(` `)})]})}function l_({map:e,view:t,layer:n,pullRequest:r,onPullRequest:i,t:a}){let{changes:o,violations:s,pull_requests:c,tests:l,decisions:u}=e.layers;if(n===`changes`){if(o.state===`unavailable`)return o.reason===`archctx_error`?(0,W.jsx)(jp,{part:`changes`,reason:o.reason,code:dp(o),children:a(`architecture.layer.changes.archctx_error`,{code:dp(o)})}):(0,W.jsx)(jp,{part:`changes`,reason:o.reason,children:a(`architecture.layer.changes.${o.reason}`)});let e=(e,t)=>o.model.filter(n=>n.kind===e&&n.change===t).length;return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`changes`,children:[(0,W.jsxs)(`p`,{children:[a(`architecture.layer.changes.summary`,{commits:Ap(a,o.commits.length,`commit`),files:Ap(a,o.paths.length,`file`,o.truncated.paths),unowned:`${o.truncated.paths?`≥`:``}${o.unowned_paths.length}`}),` `,(0,W.jsx)(`time`,{dateTime:o.since,children:new Date(o.since).toLocaleString()}),` · `,(0,W.jsx)(`code`,{children:o.base.slice(0,12)})]}),(0,W.jsx)(`p`,{children:a(`architecture.layer.changes.model`,{nodesAdded:e(`nodes`,`added`),nodesRemoved:e(`nodes`,`removed`),nodesChanged:e(`nodes`,`changed`),relationsAdded:e(`relations`,`added`),relationsRemoved:e(`relations`,`removed`),relationsChanged:e(`relations`,`changed`),flowsAdded:e(`flows`,`added`),flowsRemoved:e(`flows`,`removed`),flowsChanged:e(`flows`,`changed`)})}),(0,W.jsx)(c_,{part:`changes`,impact:o,flowSteps:t===`sequence`,t:a})]})}if(n===`violations`){let{debt:e,flows:t,anchors:n,dependencies:r,layer_direction:i}=s,o=(e,t)=>a(`architecture.layer.violations.gap`,{part:a(`architecture.layer.violations.${e}.label`),reason:t}),c=(e,t)=>t.reason===`archctx_error`?(0,W.jsx)(jp,{part:`violations.${e}`,reason:t.reason,code:dp(t),children:o(e,a(`architecture.layer.reason.archctx_error`,{code:dp(t)}))}):(0,W.jsx)(jp,{part:`violations.${e}`,reason:t.reason,children:o(e,a(`architecture.layer.reason.${t.reason}`))}),l=i.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.layer_direction`,{count:i.edges.length,imports:i.edges.reduce((e,t)=>e+t.imports,0),checked:i.imports})}):i.reason===`model_layers_undeclared`||i.reason===`layer_direction_undeclared`?(0,W.jsx)(Mp,{part:`violations.layer_direction`,reason:i.reason,children:o(`layer_direction`,a(`architecture.layer.reason.${i.reason}`))}):c(`layer_direction`,i),u=e.state===`ok`?e.items.filter(e=>e.nodes.length===0):[];return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`violations`,children:[e.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.debt`,{count:e.items.length})}):c(`debt`,e),u.length>0&&(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:a(`architecture.layer.unowned`,{count:u.length})}),(0,W.jsx)(`ul`,{children:u.flatMap(e=>e.paths.map(t=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:t}),` · `,a(`architecture.layer.debt.${e.kind}`)]},`${e.kind}:${t}`)))})]}),t.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.flows`,{proven:t.proven,selectors:t.selectors,unprovable:t.unprovable.length})}):c(`flows`,t),n.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.anchors`,{findings:n.nodes.reduce((e,t)=>e+t.findings.length,0),citations:n.citations})}):c(`anchors`,n),r.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.dependencies`,{count:r.edges.length})}):c(`dependencies`,r),l]})}if(n===`tests`){if(l.state===`unavailable`)return(0,W.jsx)(jp,{part:`tests`,reason:l.reason,children:a(`architecture.layer.tests.${l.reason}`)});let t=e.nodes.filter(e=>e.kind===`capability`).length;return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`tests`,children:[(0,W.jsxs)(`p`,{children:[a(`architecture.layer.tests.summary`,{run:l.run.id,failed:l.capabilities.filter(e=>e.failed>0).length,covered:l.capabilities.length,capabilities:t}),` `,(0,W.jsx)(`time`,{dateTime:l.run.created_at,children:new Date(l.run.created_at).toLocaleString()}),` · `,(0,W.jsx)(`code`,{children:l.run.head_sha.slice(0,12)})]}),l.results!==`ok`&&(0,W.jsx)(jp,{part:`results`,reason:l.results,children:a(`architecture.layer.tests.results.${l.results}`)})]})}if(n===`pull_requests`){if(c.state===`unavailable`)return(0,W.jsx)(jp,{part:`pull_requests`,reason:c.reason,children:a(`architecture.layer.pull_requests.${c.reason}`)});let e=c.pull_requests.find(e=>e.number===r)??null;return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`pull_requests`,children:[(0,W.jsxs)(`p`,{children:[a(`architecture.layer.pull_requests.summary`,{count:c.pull_requests.length}),` `,(0,W.jsx)(`time`,{dateTime:c.observed_at,children:new Date(c.observed_at).toLocaleString()})]}),c.pull_requests.length>0&&(0,W.jsxs)(`label`,{className:`architecture-layer-summary__pick`,children:[(0,W.jsx)(`span`,{children:a(`architecture.layer.pull_requests.pick`)}),(0,W.jsxs)(`select`,{value:e?.number??``,onChange:e=>i(Number(e.target.value)),children:[e===null&&(0,W.jsx)(`option`,{value:``,disabled:!0,children:a(`architecture.layer.pull_requests.none`)}),c.pull_requests.map(e=>(0,W.jsxs)(`option`,{value:e.number,children:[`#`,e.number,` `,e.title]},e.number))]})]}),e&&(0,W.jsxs)(`p`,{"data-pull-request":e.number,children:[(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),e.head_sha!==null&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`code`,{children:e.head_sha.slice(0,12)})]}),e.impact.state===`ok`&&(0,W.jsxs)(W.Fragment,{children:[` · `,a(`architecture.layer.pull_requests.impact`,{files:Ap(a,e.impact.paths.length,`file`,e.impact.truncated.paths),nodes:Ap(a,e.impact.nodes.length,`node`,e.impact.truncated.nodes),unowned:`${e.impact.truncated.paths?`≥`:``}${e.impact.unowned_paths.length}`})]})]}),e?.impact.state===`ok`&&(0,W.jsx)(c_,{part:`pull_request`,impact:e.impact,flowSteps:t===`sequence`,t:a}),e?.impact.state===`unavailable`&&(e.impact.reason===`archctx_error`?(0,W.jsx)(jp,{part:`pull_request`,reason:e.impact.reason,code:dp(e.impact),children:a(`architecture.layer.pull_requests.pr.archctx_error`,{code:dp(e.impact)})}):(0,W.jsx)(jp,{part:`pull_request`,reason:e.impact.reason,children:a(`architecture.layer.pull_requests.pr.${e.impact.reason}`)}))]})}let d=u.items.filter(e=>e.applies_to.length===0);return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`decisions`,children:[(0,W.jsx)(`p`,{children:a(`architecture.layer.decisions.summary`,{count:Ap(a,u.items.length,`decision`),applied:u.items.length-d.length})}),d.length>0&&(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:a(`architecture.layer.decisions.unapplied`,{count:d.length})}),(0,W.jsx)(`ul`,{children:d.map(e=>(0,W.jsxs)(`li`,{children:[e.title,` · `,(0,W.jsx)(`code`,{children:e.path})]},e.id))})]})]})}function u_({read:e,kept:t,t:n}){let r=e.reason===`archctx_error`?dp(e):void 0,i=e.reason===`architecture_map_pending`;return(0,W.jsxs)(`p`,{className:i?void 0:`architecture-notice`,role:i?`status`:`alert`,"data-error-code":e.reason,"data-code":r,children:[t&&(0,W.jsx)(`span`,{className:`block`,children:n(`architecture.map.kept`)}),(0,W.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}`,r===void 0?void 0:{code:r})}),(0,W.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}.next`)})]})}function d_({map:e,t}){return(0,W.jsxs)(W.Fragment,{children:[e.sizes.state===`unavailable`&&(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`sizes`,"data-reason":e.sizes.reason,children:t(`architecture.map.sizes.${e.sizes.reason}`)}),e.dependencies.state===`unavailable`&&(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`dependencies`,"data-reason":e.dependencies.reason,children:t(`architecture.map.dependencies.${e.dependencies.reason}`)})]})}function f_({repositoryId:e,view:t=`modules`,read:n=r_,refreshGeneration:r,selections:i,select:a,onModule:o,onSummary:s,t:c}){let l=i_(n,e,r),[u,d]=(0,I.useState)(`changes`),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(!0),b=(0,I.useRef)(null);l?.state===`ok`&&(b.current={repositoryId:e,map:l.map});let x=b.current?.repositoryId===e?b.current.map:null,S=x!==null&&x.layers.pull_requests.state===`ok`&&x.layers.pull_requests.pull_requests.some(e=>e.number===f),C=x===null?null:S?f:hp(x),w=(0,I.useMemo)(()=>x===null||t!==`topology`?`namespace`:jg(x),[x,t]),T=g??w,E=`${T}:${v}`,D=i.topology?.scope===E?i.topology.id:null,O=(0,I.useCallback)(e=>{_(e),a({view:`topology`,scope:``,id:null})},[a]),k=(0,I.useCallback)(e=>{y(e),a({view:`topology`,scope:``,id:null})},[a]),A=(0,I.useCallback)(e=>a({view:`topology`,scope:E,id:e}),[E,a]),j=(0,I.useCallback)(e=>a({view:`modules`,scope:``,id:e}),[a]),M=(0,I.useCallback)(e=>a({view:`layers`,scope:``,id:e}),[a]),N=(0,I.useCallback)((e,t)=>a({view:`sequence`,scope:e,id:t}),[a]),P=(0,I.useCallback)(e=>{h(e),a({view:`sequence`,scope:``,id:null})},[a]);(0,I.useEffect)(()=>{s(x===null?null:{commit:x.commit,collectedAt:x.collected_at,headRef:x.head_ref,archctxVersion:x.archctx_version,modules:x.nodes.filter(e=>e.kind===`capability`).length,flows:x.flows.length})},[x,s]),(0,I.useEffect)(()=>()=>s(null),[s]);let F=x&&(0,W.jsxs)(`div`,{className:`architecture-map__side`,"data-map-side":!0,children:[(0,W.jsx)(d_,{map:x,t:c}),(0,W.jsx)(l_,{map:x,view:t,layer:u,pullRequest:C,onPullRequest:p,t:c})]});return(0,W.jsxs)(`div`,{className:`architecture-map-view`,children:[l===null&&(0,W.jsx)(`p`,{role:`status`,children:c(`architecture.map.loading`)}),l?.state===`unavailable`&&(0,W.jsx)(u_,{read:l,kept:x!==null,t:c}),x&&t===`layers`&&(0,W.jsx)(Wm,{map:x,selectedId:i.layers?.id??null,onSelect:M,t:c},`${e}:${x.commit}`),x&&t!==`layers`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`architecture-lens`,children:[(0,W.jsx)(`span`,{id:`architecture-layers-label`,className:`architecture-lens__label`,children:c(`architecture.layers`)}),(0,W.jsx)(s_,{map:x,layer:u,pullRequest:C,onLayer:d,t:c}),t===`sequence`?(0,W.jsx)(pg,{map:x,layer:u,pullRequest:C,flowId:m,t:c}):t===`topology`?(0,W.jsx)(Qg,{map:x,base:T,onBase:O,legacy:v,onLegacy:k,t:c}):(0,W.jsx)(`span`,{className:`architecture-lens__hint`,children:c(`architecture.lens.hint`)})]}),t===`modules`&&(0,W.jsx)(Eh,{map:x,layer:u,pullRequest:C,selectedId:i.modules?.id??null,onSelect:j,side:F,onModule:o,t:c},`${e}:${x.commit}`),t===`sequence`&&(0,W.jsx)(hg,{map:x,layer:u,pullRequest:C,flowId:m,onFlow:P,selection:i.sequence??null,onSelect:N,side:F,onModule:o,t:c},`${e}:${x.commit}`),t===`topology`&&(0,W.jsx)(n_,{map:x,layer:u,pullRequest:C,base:T,legacy:v,selectedId:D,onSelect:A,side:F,onModule:o,t:c},`${e}:${x.commit}`)]})]})}var p_=200,m_=40,h_=52,g_=260,__=240,v_=44,y_=580,b_=780;function x_(e){return e.length>26?`${e.slice(0,25)}…`:e}function S_(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}function C_(e){let t=t=>e.nodes.filter(e=>e.role===t),n=t(`caller`),r=t(`callee`),i=e.nodes.filter(e=>e.role===`child`),a=v_+i.length*h_+(i.length?4:0),o=Math.max(n.length*h_,r.length*h_,a)+8,s=new Map,c=(e,t,n)=>{let r=(o-e.length*h_)/2+6;e.forEach((e,i)=>s.set(e.id,{x:t,y:r+i*h_,w:p_,h:m_,column:n,center:!1}))};c(n,0,0),c(r,y_,2);let l=(o-a)/2;return s.set(e.center,{x:g_,y:l,w:__,h:a,column:1,center:!0}),i.forEach((e,t)=>s.set(e.id,{x:284,y:l+v_+t*h_,w:204,h:m_,column:1,center:!1})),{boxes:s,height:o}}function w_(e){return e.center?e.y+v_/2:e.y+e.h/2}function T_(e,t){if(e.column<t.column)return[[e.x+e.w,w_(e)],[t.x,w_(t)]];if(e.column>t.column)return[[e.x,w_(e)],[t.x+t.w,w_(t)]];let n=e=>e.center?[272,e.y+v_-6]:[e.x,w_(e)],[r,i]=n(e),[a,o]=n(t);return[[r,i],[272,i],[272,o],[a,o]]}function E_(e){if(e.length===2){let[[t,n],[r,i]]=e,a=(r-t)/2;return`M${t} ${n} C${t+a} ${n} ${r-a} ${i} ${r} ${i}`}return e.map(([e,t],n)=>`${n?`L`:`M`}${e} ${t}`).join(` `)}function D_(e,t){return te(e)?t(`architecture.graph.more`,{count:e.count}):e.name}function O_({graph:e,onSelect:t,t:n}){let r=(0,I.useId)(),[i,a]=(0,I.useState)([]),{boxes:s,height:c}=C_(e),l=new Map(e.nodes.map(e=>[e.id,D_(e,n)])),u=e=>a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),d=e.nodes.filter(te).filter(e=>i.includes(e.id));return(0,W.jsxs)(`figure`,{className:`module-graph`,"aria-labelledby":`${r}-caption`,children:[(0,W.jsxs)(`figcaption`,{id:`${r}-caption`,className:`module-graph__caption`,children:[(0,W.jsx)(`span`,{children:n(`architecture.graph.callers`)}),(0,W.jsx)(`span`,{children:n(`architecture.graph.module`)}),(0,W.jsx)(`span`,{children:n(`architecture.graph.callees`)})]}),(0,W.jsxs)(`svg`,{className:`module-graph__svg`,viewBox:`0 0 ${b_} ${c}`,width:b_,height:c,role:`group`,"aria-labelledby":`${r}-caption`,children:[(0,W.jsx)(`defs`,{children:(0,W.jsx)(`marker`,{id:`${r}-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,W.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,className:`module-graph__arrow`})})}),e.nodes.map(e=>{let r=s.get(e.id);if(!r)return null;let a=D_(e,n);if(te(e)){let t=i.includes(e.id);return(0,W.jsxs)(`g`,{className:`module-graph__node module-graph__node--group`,"data-node-role":e.role,role:`button`,tabIndex:0,"aria-expanded":t,"aria-label":n(`architecture.graph.group.${e.role}`,{count:e.count}),onClick:()=>u(e.id),onKeyDown:t=>S_(t,()=>u(e.id)),children:[(0,W.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,W.jsx)(`text`,{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:`middle`,dominantBaseline:`central`,children:a})]},e.id)}let c=e.role===`caller`||e.role===`callee`?o.test(e.id):!1,l=()=>t(e.id);return(0,W.jsxs)(`g`,{className:`module-graph__node module-graph__node--${e.role}`,"data-node-id":e.id,"data-node-role":e.role,...c?{role:`button`,tabIndex:0,"aria-label":n(`architecture.graph.open`,{name:e.name}),onClick:l,onKeyDown:e=>S_(e,l)}:{},children:[(0,W.jsx)(`title`,{children:`${e.name} (${e.id})`}),(0,W.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,W.jsx)(`text`,{x:r.x+12,y:r.center?r.y+v_/2:r.y+r.h/2,dominantBaseline:`central`,children:x_(a)})]},e.id)}),e.edges.map((e,t)=>{let n=s.get(e.source),i=s.get(e.target);if(!n||!i)return null;let a=T_(n,i),o=e.direction===`directed`,[c,l]=a.length===2?[(a[0][0]+a[1][0])/2,(a[0][1]+a[1][1])/2]:[a[1][0]+4,(a[1][1]+a[2][1])/2];return(0,W.jsxs)(`g`,{className:`module-graph__edge`,"data-direction":e.direction,children:[(0,W.jsx)(`path`,{d:E_(a),...o?{markerEnd:`url(#${r}-arrow)`}:{strokeDasharray:`5 4`},children:(0,W.jsx)(`title`,{children:`${e.intent} (${e.relation_kind})`})}),!o&&(0,W.jsx)(`text`,{className:`module-graph__edge-label`,x:c,y:l-4,textAnchor:`middle`,children:e.relation_kind})]},t)})]}),d.map(e=>(0,W.jsxs)(`section`,{className:`module-graph__group`,"aria-label":n(`architecture.graph.group.${e.role}`,{count:e.count}),children:[(0,W.jsx)(`h4`,{children:n(`architecture.graph.group.${e.role}`,{count:e.count})}),(0,W.jsx)(`ul`,{children:e.members.map(e=>(0,W.jsxs)(`li`,{children:[o.test(e.id)?(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),children:e.name}):(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(`code`,{children:e.id})]},e.id))})]},e.id)),(0,W.jsx)(`ul`,{className:`module-graph__relations`,"aria-label":n(`architecture.graph.relations`),children:e.edges.map((e,t)=>(0,W.jsxs)(`li`,{"data-direction":e.direction,children:[(0,W.jsx)(`span`,{children:l.get(e.source)??e.source}),(0,W.jsx)(`span`,{children:` → `}),(0,W.jsx)(`span`,{children:l.get(e.target)??e.target}),(0,W.jsx)(`span`,{className:`module-graph__intent`,children:e.intent}),(0,W.jsx)(`code`,{children:e.relation_kind})]},t))})]})}function k_(e){let t=e?.code;return typeof t==`string`&&/^[a-z][a-z0-9_]{0,63}$/u.test(t)?t:null}async function A_(e,t,n){let r=await fetch(e,{signal:n,cache:`no-store`,headers:t===null?{}:{"If-None-Match":t}});if(r.status===304)return null;let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=k_(i);if(e===null)throw Error(`unavailable`);return{state:`unavailable`,reason:e}}return{body:i,etag:r.headers.get(`ETag`)}}function j_(e,t,n){let[r,i]=(0,I.useState)({path:null,value:null,error:null}),a=(0,I.useRef)(null),o=(0,I.useCallback)(async n=>{if(e===null)return!1;let r=t=>{a.current?.path!==e&&(a.current=null),i(n=>({path:e,value:n.path===e?n.value:null,error:t}))};try{let o=await A_(e,a.current?.path===e?a.current.etag:null,n);if(n.aborted)return!1;if(o===null)return i(e=>e.error===null?e:{...e,error:null}),!0;if(`state`in o)return r(o.reason),l(o);let s=t(o.body);return a.current=o.etag===null?null:{path:e,etag:o.etag},i({path:e,value:s,error:null}),!0}catch(e){return n.aborted||r(e instanceof Error&&/^[a-z][a-z0-9_]{0,63}$/u.test(e.message)?e.message:`unavailable`),!1}},[e,t]);return c(o,JSON.stringify([e,n]),{enabled:e!==null}),r.path===e?r:{path:e,value:null,error:null}}function M_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/modules`}function N_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/history`}function P_(e){let t=`rh module review-prompt ${e.capability_id} --shard ${e.shard.index}`;return e.mode===`diff`?`${t} --base ${e.base} --head ${e.head}`:t}function F_({read:e,loading:t,t:n}){return e.error===null?e.value===null?(0,W.jsx)(`p`,{role:`status`,children:n(t)}):null:(0,W.jsx)(`p`,{className:`architecture-notice`,role:`alert`,"data-error-code":e.error,children:n(e.value===null?`architecture.failed`:`architecture.refreshFailed`,{code:e.error})})}var I_={valid:`tone-ok`,fresh:`tone-ok`,present:`tone-ok`,invalid:`tone-danger`,stale:`tone-user`,pending:`tone-user`,unknown:`tone-unknown`};function L_({state:e,t}){return(0,W.jsx)(`ul`,{className:`module-states`,"aria-label":t(`architecture.states`),children:[`model_valid`,`generated_summary`,`section3`].map(n=>(0,W.jsxs)(`li`,{className:`operator-badge ${I_[e[n]]}`,"data-state-kind":n,"data-state-value":e[n],children:[t(`architecture.state.${n}`),`: `,(0,W.jsx)(`strong`,{children:t(`architecture.value.${e[n]}`)})]},n))})}function R_({index:e,onModule:t,t:n}){let r=new Map;for(let t of e.modules)r.set(t.domain,[...r.get(t.domain)??[],t]);return r.size===0?(0,W.jsx)(`p`,{className:`empty-inline`,children:n(`architecture.empty`)}):(0,W.jsx)(`div`,{className:`module-domains`,children:[...r].map(([e,r])=>(0,W.jsxs)(`section`,{className:`module-domain`,"data-domain":e,"aria-labelledby":`domain-${e}`,children:[(0,W.jsxs)(`h3`,{id:`domain-${e}`,children:[e,` `,(0,W.jsx)(`span`,{children:r.length})]}),(0,W.jsx)(`ul`,{children:r.map(e=>(0,W.jsxs)(`li`,{className:`module-row`,"data-module-id":e.id,children:[(0,W.jsxs)(`button`,{type:`button`,className:`module-row__open`,onClick:()=>t(e.id),children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`code`,{children:e.id})]}),(0,W.jsxs)(`span`,{className:`module-row__meta`,children:[e.status,` · `,n(`architecture.components`,{count:e.components})]}),(0,W.jsx)(L_,{state:e.state,t:n})]},e.id))})]},e))})}function z_({base:e,generation:t,t:n}){let[r,i]=(0,I.useState)(1),a=j_(`${e}/review-prompt?shard=${r}`,xe,t),o=a.value,s=o?P_(o):null;return(0,W.jsxs)(`section`,{className:`architecture-card review-prompt`,"aria-labelledby":`review-prompt-heading`,children:[(0,W.jsx)(`h3`,{id:`review-prompt-heading`,children:n(`architecture.prompt.title`)}),(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.boundary`)}),(0,W.jsx)(F_,{read:a,loading:`architecture.prompt.loading`,t:n}),o&&s&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`detail-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:n(`architecture.prompt.digest`)}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{className:`mono-value review-prompt__digest`,children:o.digest})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:n(`architecture.prompt.budget`)}),(0,W.jsx)(`dd`,{children:n(`architecture.prompt.budgetValue`,{used:o.budget.used_bytes,cap:o.budget.input_cap_bytes})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:n(`architecture.prompt.omitted`)}),(0,W.jsx)(`dd`,{children:o.budget.omitted_sections.length?o.budget.omitted_sections.join(`, `):n(`architecture.prompt.omittedNone`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:(0,W.jsx)(`label`,{htmlFor:`review-prompt-shard`,children:n(`architecture.prompt.shard`)})}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`select`,{id:`review-prompt-shard`,value:o.shard.index,onChange:e=>i(Number(e.target.value)),children:Array.from({length:o.shard.count},(e,t)=>t+1).map(e=>(0,W.jsx)(`option`,{value:e,children:n(`architecture.prompt.shardOf`,{index:e,count:o.shard.count})},e))})})]})]}),o.budget.incomplete&&(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.incomplete`,{count:o.shard.count})}),(0,W.jsxs)(`div`,{className:`copy-value review-prompt__command`,children:[(0,W.jsx)(`code`,{"data-bot-command":!0,children:s}),(0,W.jsx)(p,{label:n(`architecture.prompt.command`),value:s,t:n})]}),(0,W.jsxs)(`details`,{className:`review-prompt__text`,children:[(0,W.jsx)(`summary`,{children:n(`architecture.prompt.text`,{index:o.shard.index})}),(0,W.jsx)(`pre`,{children:o.prompt})]}),(0,W.jsx)(`div`,{className:`review-prompt__actions`,children:(0,W.jsx)(p,{label:n(`architecture.prompt.textLabel`,{index:o.shard.index}),value:o.prompt,t:n})})]})]})}function B_(e,t){let n=typeof e==`object`&&e&&!Array.isArray(e)?e[t]:void 0;return typeof n==`string`?n:null}function V_({value:e,outcome:t}){let n=B_(e,`label`)??B_(e,`id`)??JSON.stringify(e),r=t?B_(e,`kind`):[B_(e,`from`),B_(e,`to`)].every(Boolean)?`${B_(e,`from`)} → ${B_(e,`to`)}`:null;return(0,W.jsxs)(`li`,{children:[r&&(0,W.jsx)(`code`,{children:r}),` `,n]})}function H_({items:e,empty:t}){return e.length?(0,W.jsx)(`ul`,{children:e.map((e,t)=>(0,W.jsx)(`li`,{children:e},t))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:t})}function U_({detail:e,base:t,generation:n,onModule:r,t:i}){let{module:a}=e,o=i(`architecture.none`);return(0,W.jsxs)(`article`,{className:`module-page`,"aria-labelledby":`module-page-title`,children:[(0,W.jsxs)(`header`,{className:`module-page__header`,children:[(0,W.jsxs)(`p`,{className:`detail-eyebrow`,children:[a.status,` · `,(0,W.jsx)(`code`,{children:a.id})]}),(0,W.jsx)(`h2`,{id:`module-page-title`,children:a.name}),(0,W.jsx)(`p`,{children:a.summary}),(0,W.jsx)(L_,{state:e.state,t:i})]}),(0,W.jsx)(O_,{graph:e.graph,onSelect:r,t:i}),(0,W.jsxs)(`div`,{className:`module-page__grid`,children:[(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-facts-heading`,children:[(0,W.jsx)(`h3`,{id:`module-facts-heading`,children:i(`architecture.facts`)}),(0,W.jsx)(`h4`,{children:i(`architecture.responsibilities`)}),(0,W.jsx)(H_,{items:a.responsibilities,empty:o}),(0,W.jsx)(`h4`,{children:i(`architecture.entrypoints`)}),a.entrypoints?.length?(0,W.jsx)(`ul`,{className:`module-entrypoints`,children:a.entrypoints.flatMap(e=>e.symbols.map(t=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:e.path}),` `,t.name,t.sinks.map(e=>(0,W.jsxs)(`span`,{children:[` → `,(0,W.jsx)(`code`,{children:e.path}),` `,e.symbol]},e.id))]},`${e.id}:${t.name}`)))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:o}),(0,W.jsx)(`h4`,{children:i(`architecture.verification`)}),a.verification.length?(0,W.jsx)(`ul`,{children:a.verification.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e})},e))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:o})]}),(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-flows-heading`,children:[(0,W.jsx)(`h3`,{id:`module-flows-heading`,children:i(`architecture.flows`)}),e.flows.length===0&&(0,W.jsx)(`p`,{className:`detail-quiet`,children:o}),e.flows.map(e=>(0,W.jsxs)(`div`,{className:`module-flow`,children:[(0,W.jsxs)(`h4`,{children:[e.name,` `,(0,W.jsx)(`code`,{children:e.id})]}),e.applicability===`not-applicable`?(0,W.jsx)(`p`,{children:i(`architecture.flow.notApplicable`,{rationale:e.rationale})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.steps`)}),(0,W.jsx)(`ul`,{children:e.steps.map((e,t)=>(0,W.jsx)(V_,{value:e,outcome:!1},t))}),(0,W.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.outcomes`)}),(0,W.jsx)(`ul`,{children:e.outcomes.map((e,t)=>(0,W.jsx)(V_,{value:e,outcome:!0},t))})]})]},e.id))]}),(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-section3-heading`,children:[(0,W.jsx)(`h3`,{id:`module-section3-heading`,children:i(`architecture.section3`)}),e.section3===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.section3.pending`)}):(0,W.jsx)(`pre`,{className:`module-section3`,children:e.section3})]}),(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-docs-heading`,children:[(0,W.jsx)(`h3`,{id:`module-docs-heading`,children:i(`architecture.docs`)}),e.linked_docs.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.docs.none`)}):(0,W.jsx)(`ul`,{className:`module-docs`,children:e.linked_docs.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:e.path}),` `,(0,W.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.kind}),` `,(0,W.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.status??i(`architecture.value.unknown`)})]},e.path))})]}),(0,W.jsx)(z_,{base:t,generation:n,t:i},a.id)]})]})}var W_=[`map`,`layers`,`sequence`,`topology`,`modules`,`history`],G_={map:`modules`,layers:`layers`,sequence:`sequence`,topology:`topology`};function K_({view:e,counts:t,onChange:n,t:r}){return(0,W.jsx)(`div`,{className:`architecture-tabs`,role:`tablist`,"aria-label":r(`architecture.views`),children:W_.map((i,a)=>(0,W.jsxs)(`button`,{type:`button`,role:`tab`,id:`architecture-tab-${i}`,"aria-controls":`architecture-view`,"aria-selected":e===i,tabIndex:e===i?0:-1,onClick:()=>n(i),onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`&&e.key!==`Home`&&e.key!==`End`)return;let t=e.key===`Home`?0:e.key===`End`?W_.length-1:(a+(e.key===`ArrowRight`?1:W_.length-1))%W_.length;e.preventDefault(),n(W_[t]),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[t]?.focus()},children:[r(`architecture.view.${i}`),t[i]!==void 0&&(0,W.jsx)(`span`,{className:`architecture-tabs__count`,children:t[i]})]},i))})}function q_(e,t){return t.type===`select`?{...e,selections:{...e.selections,[t.select.view]:{scope:t.select.scope,id:t.select.id}}}:t.repositoryId===e.repositoryId&&t.commit===e.commit?e:{repositoryId:t.repositoryId,commit:t.commit,selections:{}}}function J_({repositoryId:e,github:t,moduleId:n,onModule:r,onSource:i,refreshGeneration:a,readMap:o,readHistory:s=A_,t:c}){let[l,u]=(0,I.useState)(`map`),[d,f]=(0,I.useReducer)(q_,{repositoryId:e,commit:null,selections:{}});d.repositoryId!==e&&f({type:`shown`,repositoryId:e,commit:null});let p=d.repositoryId===e?d.selections:{},m=(0,I.useCallback)(e=>f({type:`select`,select:e}),[]),h=M_(e),g=n===null?null:`${h}/${n}`,_=j_(n===null&&l===`modules`?h:null,ye,a),v=j_(g,be,a),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(null),T=(0,I.useCallback)(t=>{b(n=>({repositoryId:e,value:{...n?.repositoryId===e?n.value:{},...t}}))},[e]),E=(0,I.useCallback)(t=>{S(t===null?null:{commit:t.commit,collectedAt:t.collectedAt,headRef:t.headRef,archctxVersion:t.archctxVersion}),t!==null&&f({type:`shown`,repositoryId:e,commit:t.commit}),t!==null&&T({map:t.modules,sequence:t.flows})},[T,e]),D=(0,I.useCallback)(e=>{w(e),e!==null&&T({history:e.total})},[T]),O=n===null?l===`modules`?_.value?.commit:l===`history`?void 0:x?.commit:v.value?.commit,k=n===null&&l!==`modules`&&l!==`history`?x:null,A=n===null&&l===`history`?C:null;return(0,I.useEffect)(()=>{i(A??(O===void 0?null:{commit:O,map:k===null?null:{collectedAt:k.collectedAt,headRef:k.headRef,archctxVersion:k.archctxVersion}}))},[A,O,k,i]),(0,I.useEffect)(()=>()=>i(null),[i]),(0,W.jsx)(`section`,{className:`architecture-workspace`,"aria-label":c(`nav.architecture`),children:n===null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(K_,{view:l,counts:y?.repositoryId===e?y.value:{},onChange:u,t:c}),(0,W.jsx)(`div`,{id:`architecture-view`,className:`architecture-view`,role:`tabpanel`,"aria-labelledby":`architecture-tab-${l}`,children:l===`history`?(0,W.jsx)(Sm,{path:N_(e),github:t,read:s,refreshGeneration:a,selection:p.history??null,select:m,onSummary:D,t:c}):l===`modules`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(F_,{read:_,loading:`architecture.loading`,t:c}),_.value&&(0,W.jsx)(R_,{index:_.value,onModule:r,t:c})]}):(0,W.jsx)(f_,{repositoryId:e,view:G_[l],read:o,refreshGeneration:a,selections:p,select:m,onModule:r,onSummary:E,t:c})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{children:(0,W.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>r(null),children:c(`architecture.back`)})}),(0,W.jsx)(F_,{read:v,loading:`architecture.module.loading`,t:c}),v.value&&g&&(0,W.jsx)(U_,{detail:v.value,base:g,generation:a,onModule:r,t:c})]})})}export{J_ as ArchitectureWorkspace};
10
+ `),[r,i]=[b.get(t),b.get(n)],a=Mi([xi(r,x(i)),xi(i,x(r))],y.filter(e=>e!==r&&e!==i));return{...p(`relation:${t}->${n}`,t,n,`relation`,eh),points:a}}),C=[...m.routes,...S],w=n.flatMap(e=>{let n=b.get(th(e)),r=ih(t.get(e).length);return t.get(e).map((e,t)=>({id:e.id,parent:n.id,kind:`box`,width:Gm,height:Km,x:n.x+Jm+t%r*208,y:n.y+Ym+Math.floor(t/r)*72}))}),T=y.flatMap(e=>[e,...w.filter(t=>t.parent===e.id)]);return{domains:n,capabilities:n.flatMap(e=>t.get(e)),externals:r,edges:o,scene:{boxes:T,routes:C,labels:[],extent:Pi(T,C,$m)}}}function oh(e,t){let n=new Map(e.capabilities.map(e=>[e.id,e.domain])),r=new Set,i=new Map,a=(e,t)=>i.set(e,i.has(e)&&i.get(e)!==t?`both`:t);for(let e of t){let[t,i]=[n.get(e.source),n.get(e.target)];t===i?(a(e.source,`out`),a(e.target,`in`)):r.add(`imports:${t}->${i}`)}return{scene:r.size===0?e.scene:{...e.scene,routes:e.scene.routes.map(e=>r.has(e.id)?{...e,kind:`undeclared`,dashed:!0}:e)},cards:i}}var sh={in:`←`,out:`→`,both:`⇄`};function ch({kind:e,state:t,t:n}){let r=n(`architecture.modules.${e}.${t}`);return(0,W.jsx)(`span`,{className:`architecture-modules__badge mono-value`,"data-badge":e,"data-state":t,role:`img`,"aria-label":r,title:r,children:sh[t]})}var lh=(0,I.memo)(function({data:e}){return(0,W.jsxs)(`div`,{className:`architecture-modules__domain`,"data-domain":e.domain,children:[(0,W.jsx)(Kp,{}),(0,W.jsx)(`b`,{children:e.domain})]})}),uh=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`];function dh(e){let t=Cp(e,`changes`).marks,n=Cp(e,`violations`).marks,r=Cp(e,`decisions`).marks,{pull_requests:i,tests:a}=e.layers,o=(i.state===`ok`?i.pull_requests:[]).map(t=>({number:t.number,marks:Cp(e,`pull_requests`,t.number).marks})),s=new Map((a.state===`ok`?a.capabilities:[]).map(e=>[e.id,e]));return new Map(e.nodes.filter(e=>e.kind===`capability`).map(e=>[e.id,{changes:t.get(e.id),violations:n.get(e.id)?.count??0,pullRequests:o.filter(t=>t.marks.get(e.id)?.tone===`change`).map(e=>e.number),tests:s.get(e.id),decisions:r.get(e.id)?.count??0}]))}function fh(e,t,n,r={}){return e(n===1?`architecture.modules.hover.${t}One`:`architecture.modules.hover.${t}`,{count:n,...r})}function ph(e,t){let{changes:n,violations:r,pullRequests:i,tests:a,decisions:o}=e,s=n?.count??0,c=n?.atLeast?`+`:``;return[{layer:`changes`,tone:null,value:n===void 0?null:n.count===null?`↳`:s>0?`${s}${c}`:null,words:n===void 0?null:n.count===null?t(`architecture.modules.hover.dependent`):s>0?fh(t,`changes`,s):null},{layer:`violations`,tone:`danger`,value:r>0?String(r):null,words:r>0?fh(t,`violations`,r):null},{layer:`pull_requests`,tone:`info`,value:i.length>0?String(i.length):null,words:i.length>0?fh(t,`pull_requests`,i.length,{list:i.map(e=>`#${e}`).join(`, `)}):null},{layer:`tests`,tone:a!==void 0&&a.failed>0?`danger`:null,value:a===void 0?null:a.failed>0?`${a.failed}✕`:a.no_result>0?`?`:null,words:a===void 0?null:t(`architecture.layer.node.tests`,{files:a.files,passed:a.passed,failed:a.failed,skipped:a.skipped,noResult:a.no_result})},{layer:`decisions`,tone:null,value:o>0?String(o):null,words:o>0?fh(t,`decisions`,o):null}]}var mh={domain:lh,module:(0,I.memo)(function({data:e,selected:t}){let{node:n,size:r,layer:i,slots:a,neighbour:o,undeclared:s,dimmed:c,t:l}=e,u=a.find(e=>e.layer===i&&e.value!==null)?.tone??void 0,d=a.flatMap(e=>e.words??[]).join(` · `);return(0,W.jsxs)(`div`,{className:`architecture-modules__box`,title:d||void 0,"data-selected":t||void 0,"data-layer":i,"data-alert":u,"data-neighbour":o??void 0,"data-undeclared":s??void 0,"data-dimmed":c||void 0,"data-deprecated":n.status===`deprecated`||void 0,children:[(0,W.jsxs)(`span`,{className:`architecture-modules__name`,children:[(0,W.jsx)(`strong`,{children:n.name}),n.status===`deprecated`&&(0,W.jsx)(`span`,{className:`architecture-modules__status`,children:l(`architecture.modules.deprecated`)}),o!==null&&(0,W.jsx)(ch,{kind:`neighbour`,state:o,t:l}),s!==null&&(0,W.jsx)(ch,{kind:`undeclared`,state:s,t:l})]}),(0,W.jsx)(`span`,{className:`architecture-modules__size mono-value`,children:r===null?``:`${Am(r.lines)} · ${Am(r.files)}`}),(0,W.jsx)(`span`,{className:`architecture-modules__slots`,children:a.map(e=>(0,W.jsx)(`span`,{className:`architecture-modules__slot mono-value`,"data-slot":e.layer,"data-active":e.layer===i||void 0,"data-tone":e.layer===i&&e.value!==null?e.tone??void 0:void 0,children:e.value},e.layer))})]})}),external:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-modules__external`,"data-selected":t||void 0,"data-neighbour":e.neighbour??void 0,"data-dimmed":e.dimmed||void 0,children:[(0,W.jsx)(Kp,{}),e.node.name,e.neighbour!==null&&(0,W.jsx)(ch,{kind:`neighbour`,state:e.neighbour,t:e.t})]})})},hh=(e,t)=>[`out`,`in`,`both`].map(n=>({key:`${e}-${n}`,swatch:(0,W.jsx)(`span`,{className:`architecture-modules__badge mono-value`,"data-badge":e,"data-state":n,"aria-hidden":`true`,children:sh[n]}),text:t(`architecture.modules.legend.${e}.${n}`)}));function gh(e,t){return[...e.routes?[{key:`undeclared`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--undeclared`}),text:t(`architecture.layer.legend.undeclared`)}]:[],...e.selection?hh(`neighbour`,t):[],...e.cards?hh(`undeclared`,t):[]]}function _h({entries:e,t}){return e.length===0?null:(0,W.jsx)(`dl`,{className:`architecture-modules__states`,"aria-label":t(`architecture.map.legend`),"data-narrow-legend":!0,children:e.map(e=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:e.swatch}),(0,W.jsx)(`dd`,{children:e.text})]},e.key))})}function vh(e,t,n,r,i){return[...t.edges.length>0?[{key:`width`,swatch:(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),text:i(`architecture.modules.legend.width`)}]:[],...gh(n,i),...t.externals.length>0?[{key:`external`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:i(`architecture.map.legend.external`)}]:[],...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,W.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k · 4`}),text:i(`architecture.modules.legend.lines`)}]:[],{key:`slots`,swatch:(0,W.jsx)(`span`,{className:`architecture-modules__key mono-value`,children:uh.map(e=>(0,W.jsx)(`span`,{"data-active":e===r||void 0,children:i(`architecture.modules.slot.${e}`)},e))}),text:``}]}function yh(e,t){let n=xp(e),r=e=>n.get(e)??e,i=new Map(e.dependencies.state===`ok`?e.dependencies.edges.map(e=>[`${e.source}\n${e.target}`,e.imports]):[]);return e.relations.flatMap(e=>{let[n,a]=[r(e.source),r(e.target)],o=n===t?`out`:a===t?`in`:null;return o===null?[]:[{id:e.id,direction:o,other:o===`out`?e.target:e.source,holder:o===`out`?a:n,kind:e.kind,imports:n===a?null:i.get(`${n}\n${a}`)??null}]})}function bh(e,t,n){let r=xp(e),i=new Set([...t.capabilities,...t.externals].map(e=>e.id)),a=e=>r.get(e)??e,o=new Map;for(let t of e.relations){let[e,r]=[a(t.source),a(t.target)],s=e===r?null:e===n?`out`:r===n?`in`:null,c=s===`out`?r:e;s!==null&&i.has(c)&&o.set(c,o.has(c)&&o.get(c)!==s?`both`:s)}return o}function xh({selected:e,relations:t,names:n,t:r}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.modules.relations`,{count:t.length})}),t.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}):(0,W.jsx)(`ul`,{"data-card-relations":!0,children:t.map(t=>(0,W.jsxs)(`li`,{"data-relation-id":t.id,"data-direction":t.direction,children:[(0,W.jsx)(`span`,{className:`mono-value`,children:r(`architecture.modules.direction.${t.direction}`)}),` `,n.get(t.other),t.holder!==t.other&&t.holder!==e&&(0,W.jsxs)(W.Fragment,{children:[` (`,n.get(t.holder),`)`]}),` · `,(0,W.jsx)(`code`,{children:t.kind}),t.imports!==null&&(0,W.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:t.imports})]})]},t.id))})]})}function Sh({map:e,ids:t,t:n}){let{changes:r}=e.layers;if(r.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`changes`,children:r.reason===`archctx_error`?n(`architecture.layer.changes.archctx_error`,{code:dp(r)}):n(`architecture.layer.changes.${r.reason}`)});let i=r.commits.filter(e=>e.nodes.some(e=>t.has(e)));return i.length?(0,W.jsx)(`ul`,{"data-module-commits":!0,children:i.map(e=>(0,W.jsxs)(`li`,{"data-commit":e.sha,children:[(0,W.jsx)(`code`,{children:e.sha.slice(0,7)}),` `,e.subject]},e.sha))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.changes.none`)})}function Ch({map:e,pullRequest:t,ids:n,capability:r,t:i}){let{pull_requests:a}=e.layers;if(a.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`pull_requests`,children:i(`architecture.layer.pull_requests.${a.reason}`)});let o=a.pull_requests.find(e=>e.number===t);if(o===void 0)return(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.inspector.none`)});let{impact:s}=o;if(s.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`pull_request`,children:s.reason===`archctx_error`?i(`architecture.layer.pull_requests.pr.archctx_error`,{code:dp(s)}):i(`architecture.layer.pull_requests.pr.${s.reason}`)});let c=new Map(e.nodes.map(e=>[e.id,e.name])),l=xp(e),u=[],d=mp(s,n);d>0&&u.push({key:`files`,text:i(`architecture.modules.impact.files`,{files:Ap(i,d,`file`,s.truncated.paths)})});let f=[...n].flatMap(e=>_p(s,e)).filter(e=>!n.has(e));f.length>0&&u.push({key:`targets`,text:i(`architecture.layer.node.dependent`,{names:[...new Set(f)].map(e=>c.get(e)??e).join(`, `)})});let p=new Map(e.flows.map(e=>[e.id,e]));for(let e of s.flow_steps.items??[]){let t=p.get(e.flow);if(t===void 0||t.applicability!==`required`)continue;let r=rf(t),a=r.findIndex(t=>t.outcome===e.outcome&&t.step.id===e.step),o=new Map(t.participants.map(e=>[e.id,e.node])),s=r[a]?.step;s!==void 0&&[s.from,s.to].some(e=>n.has(o.get(e)))&&u.push({key:`step-${e.flow}-${e.outcome??``}-${e.step}`,text:i(`architecture.modules.impact.step`,{flow:t.name,step:a+1})})}let m=[...new Set(s.dependents.filter(e=>n.has(e.touched)).flatMap(e=>l.get(e.id)??[]))].filter(e=>e!==r);return m.length>0&&u.push({key:`downstream`,text:i(`architecture.modules.impact.downstream`,{count:m.length,names:m.map(e=>c.get(e)??e).join(`, `)})}),u.length?(0,W.jsx)(`ul`,{"data-module-impact":o.number,children:u.map(e=>(0,W.jsx)(`li`,{children:e.text},e.key))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.modules.impact.none`,{number:o.number})})}function wh({map:e,capability:t,t:n}){let{tests:r}=e.layers;if(r.state===`unavailable`)return(0,W.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`tests`,children:n(`architecture.layer.tests.${r.reason}`)});let i=r.capabilities.find(e=>e.id===t);return i===void 0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.tests.none`)}):(0,W.jsx)(`p`,{"data-module-tests":!0,children:n(`architecture.layer.node.tests`,{files:i.files,passed:i.passed,failed:i.failed,skipped:i.skipped,noResult:i.no_result})})}function Th({map:e,pullRequest:t,node:n,relations:r,onModule:i,t:a}){let o=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),s=(0,I.useMemo)(()=>{let t=xp(e);return new Set(e.nodes.flatMap(e=>t.get(e.id)===n.id?[e.id]:[]))},[e,n.id]),c=Ip(e,n.id),l=Rp(e,s,o,a),u=[...new Set(l.flatMap(e=>e.part??[]))],d=e.layers.decisions.items.filter(e=>e.applies_to.some(e=>s.has(e)));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,W.jsx)(`span`,{className:`architecture-modules__eyebrow`,"data-module-domain":!0,children:n.domain}),(0,W.jsx)(`h3`,{children:n.name}),(0,W.jsxs)(`span`,{className:`architecture-map__id mono-value`,children:[n.id,e.sizes.state===`ok`&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`span`,{"data-node-size":!0,children:c===null?a(`architecture.map.noSize`):a(`architecture.map.sizeValue`,{lines:c.lines,files:c.files})})]})]})]}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.changes`)}),(0,W.jsx)(Sh,{map:e,ids:s,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),l.length?(0,W.jsx)(zp,{facts:l,layer:`violations`,source:!0}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),(0,W.jsx)(`h4`,{children:t===null?a(`architecture.layer.pull_requests`):a(`architecture.modules.impact.title`,{number:t})}),(0,W.jsx)(Ch,{map:e,pullRequest:t,ids:s,capability:n.id,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.tests`)}),(0,W.jsx)(wh,{map:e,capability:n.id,t:a}),(0,W.jsx)(`h4`,{children:a(`architecture.layer.decisions`)}),d.length?(0,W.jsx)(`ul`,{"data-module-decisions":!0,children:d.map(e=>(0,W.jsxs)(`li`,{children:[e.status===null?e.title:a(`architecture.layer.node.decision`,{title:e.title,status:e.status}),` · `,(0,W.jsx)(`code`,{children:e.path})]},e.id))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),u.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:a(`architecture.modules.fix`)}),u.map(e=>(0,W.jsx)(Fp,{part:e,t:a},e))]}),(0,W.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(n.id),children:a(`architecture.map.open`)}),(0,W.jsx)(xh,{selected:n.id,relations:r,names:o,t:a})]})}function Eh({map:e,layer:t,pullRequest:n,selectedId:r,onSelect:i,side:a,onModule:o,t:s}){let c=(0,I.useMemo)(()=>ah(e),[e]),l=(0,I.useMemo)(()=>Cp(e,t,n),[e,t,n]),{scene:u,cards:d}=(0,I.useMemo)(()=>oh(c,l.edges),[c,l]),f=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e]),p=(0,I.useMemo)(()=>new Map(e.sizes.state===`ok`?e.sizes.nodes.map(e=>[e.id,{lines:e.lines,files:e.files}]):[]),[e]),m=(0,I.useMemo)(()=>dh(e),[e]),h=(0,I.useMemo)(()=>new Map(c.edges.map(e=>[e.id,e.imports])),[c]),g=r===null?null:f.get(r)??null,_=(0,I.useMemo)(()=>g===null?[]:yh(e,g.id),[e,g]),v=(0,I.useMemo)(()=>g===null?new Map:bh(e,c,g.id),[e,c,g]),y=(0,I.useCallback)(e=>{if(e.parent===null&&e.kind===`frame`){let t=e.id.slice(th(``).length);return{type:`domain`,ariaLabel:t,selection:null,data:{domain:t}}}let n=f.get(e.id),i=v.get(n.id)??null,a=r!==null&&n.id!==r&&i===null,o=d.get(n.id)??null,c=[`${n.kind} ${n.name}`,...i===null?[]:[s(`architecture.modules.neighbour.${i}`)],...o===null?[]:[s(`architecture.modules.undeclared.${o}`)]].join(` · `);return n.kind===`external-system`?{type:`external`,ariaLabel:c,selection:n.id,data:{node:n,neighbour:i,dimmed:a,t:s}}:{type:`module`,ariaLabel:c,selection:n.id,data:{node:n,size:p.get(n.id)??null,layer:t,slots:ph(m.get(n.id),s),neighbour:i,undeclared:o,dimmed:a,t:s}}},[f,v,d,r,p,m,t,s]),b={routes:u!==c.scene,cards:d.size>0,selection:v.size>0},x=g===null?null:g.kind===`capability`?th(g.domain):g.id,S=(0,I.useCallback)(e=>{let t=e=>e.startsWith(th(``))?e.slice(th(``).length):f.get(e)?.name??e,n={source:t(e.source),target:t(e.target)};return e.kind===`relation`?s(`architecture.modules.route.relation`,n):e.kind===`undeclared`?s(`architecture.modules.route.undeclared`,n):s(`architecture.modules.route.imports`,{...n,count:h.get(e.id)})},[f,h,s]);return(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`modules`,"data-node-count":e.nodes.length,"data-relation-count":e.relations.length,"data-edge-count":c.edges.length,"data-layer":t,children:[(0,W.jsx)(Zp,{label:s(`architecture.map.label`),scene:u,nodeTypes:mh,view:y,selected:r,emphasis:x,routeLabel:S,onSelect:i,legend:vh(e,c,b,t,s),t:s}),(0,W.jsx)(_h,{entries:gh(b,s),t:s}),(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":s(`architecture.map.inspector`),"data-node-id":g?.id,children:[a,g===null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.pick`)}),(0,W.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.counts`,{nodes:Ap(s,e.nodes.length,`node`),relations:Ap(s,e.relations.length,`relation`)})})]}):g.kind===`capability`?(0,W.jsx)(Th,{map:e,pullRequest:n,node:g,relations:_,onModule:o,t:s}):(0,W.jsx)(Up,{map:e,layer:t,pullRequest:n,nodeId:g.id,onModule:o,t:s})]})]})}function Dh(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Map;for(let r of e.relations)r.kind===`deployed-on`&&t.get(r.target)?.kind===`process`&&n.set(r.source,(n.get(r.source)??new Set).add(r.target));let r=new Map;return e=>{let i=r.get(e);if(i)return i;let a=t.get(e)?.kind,o={kind:`unknown`,reason:`deployment_undeclared`};if(a===`process`)o={kind:`process`,process:e};else if(a===`external-system`)o={kind:`external`};else for(let r=e;r!==null;r=t.get(r)?.parent??null){let e=n.get(r);if(e!==void 0){o=e.size===1?{kind:`process`,process:[...e][0]}:{kind:`unknown`,reason:`deployment_ambiguous`};break}}return r.set(e,o),o}}var Oh=16,kh=24,Ah=8,jh=16,Mh=196,Nh=44,Ph=24,Fh=12,Ih=52,Lh=4,Rh=16,zh=28,Bh=12,Vh=28,Hh=24;function Uh(e){return e.kind===`process`?`process:${e.process}`:e.kind===`external`?`external`:`unknown:${e.reason}`}var Wh=e=>`participant:${e}`,Gh=(e,t)=>`message:${e??``}:${t}`,Kh=e=>e===0?`alt`:`else`,qh=(e,t)=>t===null?e.label:`${e.label} · ${t}`,Jh=e=>li(e,`title`)+24;function Yh(e,t,n,r){let i=[],a=new Map;for(let n of e.participants){let e=t(n.node),r=Uh(e);a.has(r)||(i.push(r),a.set(r,{placement:e,participants:[]})),a.get(r).participants.push(n)}let o=i.flatMap(e=>a.get(e).participants.map(t=>({participant:t,key:e,header:Math.max(Mh,Jh(r.participant(t)))}))),s=new Map(o.map((e,t)=>[e.participant.id,t])),c=o.slice(1).map((e,t)=>o[t].header/2+e.header/2+Ph),l=Ah+o[0].header/2,u=(e,t)=>{e<0?l=Math.max(l,t):e<c.length&&(c[e]=Math.max(c[e],t))},d=[...e.steps,...e.outcomes.flatMap(e=>e.steps)];for(let e of d){let t=s.get(e.from),r=s.get(e.to),i=li(qh(e,n.status(e)),`label`);t===r?u(t,Hh+i+24):u(t<r?t:t-1,i+24)}for(let t of e.outcomes){let e=s.get(t.terminal.participant),n=Jh(t.terminal.label)/2+Fh;u(e-1,n),u(e,n)}let f=[],p=new Map;for(let[e,t]of o.entries()){let n=o[e-1],i=n===void 0?Oh+l:f[e-1]+c[e-1];n!==void 0&&n.key!==t.key&&(i=Math.max(i,p.get(n.key).right+jh+Ah+t.header/2)),f.push(i);let s=p.get(t.key)?.left??i-t.header/2-Ah;p.set(t.key,{left:s,right:Math.max(i+t.header/2+Ah,s+Jh(r.process(a.get(t.key).placement)))})}let m=e=>f[s.get(e)],h=[],g=new Map,_=new Map,v=(e,t,n)=>{h.push(e),g.set(e.id,t),n!==null&&_.set(e.id,n)},y=[],b=[],x=126;for(let t of e.steps)y.push({outcome:null,step:t,y:x}),x+=Ih;for(let[t,n]of e.outcomes.entries()){let e=x-Ih/2+Bh;x=e+zh+Ih/2+Rh/2;for(let e of n.steps)y.push({outcome:n.id,step:e,y:x}),x+=Ih;b.push({outcome:n,index:t,top:e,terminal:x}),x+=Ih}let S=x-Ih/2;for(let e of i){let{placement:t,participants:n}=a.get(e),{left:i,right:c}=p.get(e),l=`box:${e}`;v({id:l,parent:null,x:i,y:Oh,width:c-i,height:76,kind:t.kind===`process`?`box`:`external`},{kind:`process`,placement:t},r.process(t));for(let e of n){let t=Wh(e.id),n=o[s.get(e.id)].header;v({id:t,parent:l,x:m(e.id)-n/2,y:40,width:n,height:Nh,kind:`member`},{kind:`participant`,participant:e},r.participant(e)),v({id:`lifeline:${e.id}`,parent:t,x:m(e.id)-.5,y:84,width:1,height:S-Oh-kh-Nh,kind:`lifeline`},{kind:`lifeline`},null)}}for(let{outcome:e,index:t,top:n,terminal:r}of b){let i=[e.terminal.participant,...e.steps.flatMap(e=>[e.from,e.to])].map(m),a=Math.min(...i)-Mh/2,o=Math.max(...i)+Mh/2,s=`${Kh(t)} ${e.label}`;v({id:`fragment:${e.id}`,parent:null,x:a,y:n,width:Math.max(o-a,Jh(s)),height:zh,kind:`fragment ${e.kind}`},{kind:`fragment`,outcome:e,index:t},s);let c=Jh(e.terminal.label);v({id:`terminal:${e.id}`,parent:null,x:m(e.terminal.participant)-c/2,y:r-Vh/2,width:c,height:Vh,kind:`terminal ${e.kind}`},{kind:`terminal`,outcome:e},e.terminal.label)}let C=[],w=[],T=new Map;for(let{outcome:e,step:t,y:r}of y){let i=Gh(e,t.id),a=m(t.from),o=m(t.to),l=n.tone(e,t),u=n.status(t),d=qh(t,l===`danger`?u:null),f=a===o,p=o>a?.5:-.5,h=f?[[a+.5,r-8],[a+Hh,r-8],[a+Hh,r+8],[a+.5,r+8]]:[[a+p,r],[o-p,r]],g=f?[a+Hh+Fh+li(d,`label`)/2,r]:[(a+(o>a?a+c[s.get(t.from)]:a-c[s.get(t.from)-1]))/2,r-Lh-Rh/2];C.push({id:i,source:`lifeline:${t.from}`,target:`lifeline:${t.to}`,points:h,arrows:{start:!1,end:!0},kind:l===null?`message`:`message-${l}`,dashed:!1,width:1.5}),w.push(yi(d,g,i)),T.set(i,{outcome:e,step:t,tone:l,status:u})}return{scene:{boxes:h,routes:C,labels:w,extent:Pi(h,C,Oh,w)},parts:g,messages:T,lines:e=>_.has(e.id)?[_.get(e.id)]:[]}}var Xh=(e,t,n)=>`${e}\0${t??``}\0${n}`;function Zh(e,t,n){let{changes:r,pull_requests:i}=e.layers,a=t===`changes`?r.state===`ok`?r:null:t===`pull_requests`&&i.state===`ok`?i.pull_requests.find(e=>e.number===n)?.impact??null:null;return a===null||a.state===`unavailable`?new Set:new Set((a.flow_steps.items??[]).map(e=>Xh(e.flow,e.outcome,e.step)))}function Qh(e){let{flows:t}=e.layers.violations;return t.state===`ok`?new Map(t.evidence.map(e=>[nf(e),e.status])):null}function $h(e,t,n,r,i,a){if(t.has(Xh(r,i,a.id)))return`change`;let o=n?.get(nf(a.evidence));return e===`violations`&&o!==void 0&&o!==`proven`?`danger`:null}function eg(e,t,n,r){return new Set(e.flows.filter(e=>rf(e).some(({outcome:i,step:a})=>$h(t,n,r,e.id,i,a)!==null)).map(e=>e.id))}function tg(e,t,n,r){let i=e.flows.filter(e=>e.applicability===`required`),a=eg(e,t,n,r);return(i.find(e=>a.has(e.id))??i[0]??e.flows[0])?.id??null}var ng={box:(0,I.memo)(function({data:e}){return(0,W.jsx)(`div`,{className:`architecture-sequence__box`,"data-placement":e.placement.kind,"data-reason":e.reason??void 0,title:e.reason??void 0,children:(0,W.jsx)(`span`,{children:e.title})})}),fragment:(0,I.memo)(function({data:e}){return(0,W.jsxs)(`div`,{className:`architecture-sequence__fragment`,"data-kind":e.kind,title:e.label,children:[(0,W.jsx)(`span`,{className:`mono-value`,children:Kh(e.index)}),` `,e.label]})}),header:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__box architecture-sequence__header`,"data-kind":e.kind,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,children:[(0,W.jsx)(`strong`,{className:`architecture-sequence__name`,children:e.name}),e.mark!==null&&(0,W.jsx)(`span`,{className:`architecture-sequence__header-mark`,children:(0,W.jsx)(Np,{mark:e.mark})})]})}),lifeline:(0,I.memo)(function(){return(0,W.jsx)(`div`,{className:`architecture-sequence__lifeline`,children:(0,W.jsx)(Kp,{})})}),terminal:(0,I.memo)(function({data:e}){return(0,W.jsx)(`div`,{className:`architecture-sequence__terminal`,"data-kind":e.kind,title:e.label,children:e.label})})};function rg(e,t,n){return e.kind===`process`?t.get(e.process)??e.process:e.kind===`external`?n(`architecture.sequence.external`):n(`architecture.runtime.${e.reason}`)}function ig({evidence:e,t}){if(e===void 0)return(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`evidence`,"data-reason":`selector_undeclared`,children:t(`architecture.sequence.evidence.undeclared`)});let n=e=>e===null?(0,W.jsx)(`span`,{"data-path-withheld":!0,children:t(`architecture.sequence.evidence.withheld`)}):(0,W.jsx)(`code`,{children:e});return(0,W.jsxs)(`ul`,{className:`architecture-sequence__code`,"data-step-evidence":!0,children:[(0,W.jsxs)(`li`,{children:[n(e.source_path),` `,(0,W.jsx)(`code`,{children:e.source_symbol})]}),(0,W.jsxs)(`li`,{children:[`→ `,n(e.sink_path),` `,(0,W.jsx)(`code`,{children:e.sink_symbol})]})]})}function ag({map:e,flow:t,outcome:n,step:r,t:i}){let a=new Map(e.nodes.map(e=>[e.id,e.name])),o=new Map(t.participants.map(e=>[e.id,e.node])),s=o.get(r.from),c=o.get(r.to),l=nf(r.evidence),u=e.flow_evidence.find(e=>nf(e)===l),{flows:d}=e.layers.violations,f=d.state===`ok`?d.evidence.find(e=>nf(e)===l)??null:null,p=f?.status??null,m=e.dependencies.state===`ok`?e.dependencies.edges:[],h=e.relations.filter(e=>e.source===s&&e.target===c||e.source===c&&e.target===s),{changes:g,pull_requests:_}=e.layers,v=e=>(e??[]).some(e=>e.flow===t.id&&e.outcome===n&&e.step===r.id),y=g.state===`ok`&&v(g.flow_steps.items),b=_.state===`ok`?_.pull_requests.filter(e=>e.impact.state===`ok`&&v(e.impact.flow_steps.items)):[],x=t=>{let n=Ip(e,t);return e.sizes.state===`ok`?n===null?i(`architecture.map.noSize`):i(`architecture.map.sizeValue`,{lines:n.lines,files:n.files}):null};return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:i(`architecture.sequence.selected`)}),(0,W.jsxs)(`h3`,{"data-step-title":!0,children:[a.get(s),` → `,a.get(c)]}),(0,W.jsx)(`p`,{children:r.label}),(0,W.jsxs)(`code`,{className:`architecture-map__id`,children:[t.id,` · `,n??i(`architecture.sequence.main`),` · `,r.id]}),(0,W.jsx)(`dl`,{className:`detail-list`,children:[s,c].map((e,t)=>(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:i(t===0?`architecture.sequence.from`:`architecture.sequence.to`)}),(0,W.jsxs)(`dd`,{children:[a.get(e),x(e)!==null&&(0,W.jsxs)(`span`,{className:`detail-quiet`,"data-node-size":!0,children:[` · `,x(e)]})]})]},t))}),(0,W.jsx)(`h4`,{children:i(`architecture.sequence.evidence`)}),(0,W.jsx)(ig,{evidence:u,t:i}),(0,W.jsx)(`h4`,{children:i(`architecture.sequence.proof`)}),d.state===`ok`?(0,W.jsx)(`p`,{"data-step-proof":p??`missing`,children:p===null?i(`architecture.sequence.proof.missing`):i(p===`proven`?`architecture.sequence.proof.proven`:`architecture.sequence.proof.unproven`,{status:p})}):(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`proof`,"data-reason":d.reason,"data-code":d.reason===`archctx_error`?dp(d):void 0,children:d.reason===`archctx_error`?i(`architecture.layer.reason.archctx_error`,{code:dp(d)}):i(`architecture.layer.reason.${d.reason}`)}),f!==null&&f.call_sites.length>0&&(0,W.jsx)(`ul`,{className:`architecture-sequence__code`,"data-call-sites":!0,"aria-label":i(`architecture.sequence.callSites`),children:f.call_sites.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e.line===null?e.path:`${e.path}:${e.line}`})},`${e.path}:${e.line??``}`))}),p!==`proven`&&(0,W.jsx)(Fp,{part:`flows`,t:i}),(0,W.jsx)(`h4`,{children:i(`architecture.inspector.pullRequests`)}),y&&(0,W.jsx)(`p`,{"data-step-today":!0,children:i(`architecture.sequence.today`)}),b.length?(0,W.jsx)(`ul`,{"data-related-prs":!0,children:b.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title]},e.number))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:_.state===`unavailable`?i(`architecture.layer.pull_requests.${_.reason}`):i(`architecture.inspector.none`)}),(0,W.jsx)(`h4`,{children:i(`architecture.sequence.relations`,{count:h.length})}),h.length?(0,W.jsx)(`ul`,{children:h.map(e=>{let t=m.find(t=>t.source===e.source&&t.target===e.target)?.imports;return(0,W.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,W.jsx)(`code`,{children:e.kind}),` `,a.get(e.source),` → `,a.get(e.target),t!==void 0&&(0,W.jsxs)(`span`,{className:`mono-value`,children:[` · `,i(`architecture.map.imports`,{count:t})]})]},e.id)})}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.none`)})]})}function og(e){return[{key:`process`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--box`}),text:e(`architecture.sequence.legend.process`)},{key:`external`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:e(`architecture.sequence.legend.external`)},{key:`success`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--success`}),text:e(`architecture.sequence.legend.success`)},{key:`error`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--danger`}),text:e(`architecture.sequence.legend.error`)}]}function sg(e,t,n,r,i){let a=Zh(e,n,r),o=Qh(e),s=new Map(e.nodes.map(e=>[e.id,e.name]));return Yh(t,Dh(e),{tone:(e,r)=>$h(n,a,o,t.id,e,r),status:e=>{let t=o?.get(nf(e.evidence));return t===void 0||t===`proven`?null:t}},{process:e=>cg(e,s,i),participant:e=>s.get(e.node)})}function cg(e,t,n){return e.kind===`unknown`?n(`architecture.sequence.unknown`):rg(e,t,n)}function lg({map:e,layout:t,layer:n,pullRequest:r,selected:i,onSelect:a,t:o}){let s=(0,I.useMemo)(()=>wp(e,n,r),[e,n,r]),c=(0,I.useCallback)(n=>{let r=new Map(e.nodes.map(e=>[e.id,e.name])),i=t.parts.get(n.id);if(i.kind===`participant`){let t=e.nodes.find(e=>e.id===i.participant.node),r=t?.name??i.participant.node;return{type:`header`,ariaLabel:`${t?.kind} ${r}`,selection:n.id,data:{name:r,kind:t?.kind??``,mark:s.marks.get(i.participant.node)??null,quiet:s.available&&!s.lit.has(i.participant.node)}}}if(i.kind===`process`){let e=cg(i.placement,r,o);return{type:`box`,ariaLabel:e,selection:null,data:{placement:i.placement,title:e,reason:i.placement.kind===`unknown`?o(`architecture.runtime.${i.placement.reason}`):null}}}return i.kind===`fragment`?{type:`fragment`,ariaLabel:`${Kh(i.index)} ${i.outcome.label}`,selection:null,data:{kind:i.outcome.kind,index:i.index,label:i.outcome.label}}:i.kind===`terminal`?{type:`terminal`,ariaLabel:i.outcome.terminal.label,selection:null,data:{kind:i.outcome.kind,label:i.outcome.terminal.label}}:{type:`lifeline`,ariaLabel:``,selection:null,data:{}}},[e,t,s,o]),l=(0,I.useCallback)(e=>t.scene.labels.find(t=>t.route===e.id).text,[t]),u=(0,I.useCallback)(e=>e.id,[]),d=i!==null&&t.parts.get(i)?.kind===`participant`?`lifeline:${i.slice(12)}`:null;return(0,W.jsx)(Zp,{label:o(`architecture.sequence.label`),scene:t.scene,nodeTypes:ng,view:c,selected:i,emphasis:d,routeLabel:l,routeSelection:u,onSelect:a,legend:og(o),t:o})}function ug({map:e,flow:t,layout:n,layer:r,pullRequest:i,selected:a,lead:o,onModule:s,t:c}){let l=t.applicability===`required`?t:null,u=a===null?null:n?.messages.get(a)??null,d=a===null?null:n?.parts.get(a)??null,f=d?.kind===`participant`?d.participant.node:null,p=f===null?null:{node:f,place:Dh(e)(f)};return(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":c(`architecture.sequence.inspector`),"data-node-id":f??void 0,"data-step-id":u?`${u.outcome??``}:${u.step.id}`:void 0,children:[o,l!==null&&(u?(0,W.jsx)(ag,{map:e,flow:l,outcome:u.outcome,step:u.step,t:c}):p===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.sequence.pick`)}):(0,W.jsx)(Up,{map:e,layer:r,pullRequest:i,nodeId:p.node,onModule:s,t:c,children:(0,W.jsx)(`p`,{"data-runtime":p.place.kind,children:c(`architecture.sequence.runsIn`,{place:rg(p.place,new Map(e.nodes.map(e=>[e.id,e.name])),c)})})}))]})}var dg={violations:`imports_on_module_map`,tests:`tests_by_capability`,decisions:`decisions_by_node`};function fg(e,t,n,r,i){let a=i!==null&&e.flows.some(e=>e.id===i)?i:tg(e,t,n,r);return e.flows.find(e=>e.id===a)}function pg({map:e,layer:t,pullRequest:n,flowId:r,t:i}){let a=(0,I.useMemo)(()=>Zh(e,t,n),[e,t,n]),o=(0,I.useMemo)(()=>Qh(e),[e]),s=(0,I.useMemo)(()=>{let t=new Set(e.flow_evidence.map(e=>nf(e))),n=e.flows.flatMap(e=>rf(e));return{flows:e.flows.length,steps:n.length,evidenced:n.filter(({step:e})=>t.has(nf(e.evidence))).length}},[e]);if(e.flows.length===0)return null;let c=fg(e,t,a,o,r);return(0,W.jsxs)(`div`,{className:`architecture-lens__tools`,children:[(0,W.jsx)(`span`,{"data-sequence-summary":!0,children:i(`architecture.sequence.summary`,s)}),(0,W.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-sequence-export":!0,disabled:c.applicability!==`required`,onClick:()=>{if(c.applicability!==`required`)return;let r=sg(e,c,t,n,i);Jp(`${c.id}.svg`,r.scene,r.lines)},children:i(`architecture.sequence.export`)})]})}function mg({map:e,flowId:t,lit:n,onFlow:r,t:i}){return(0,W.jsxs)(`div`,{className:`architecture-sequence__flows`,role:`group`,"aria-labelledby":`architecture-sequence-flows`,children:[(0,W.jsx)(`h4`,{id:`architecture-sequence-flows`,children:i(`architecture.sequence.flows`)}),(0,W.jsx)(`div`,{className:`architecture-sequence__flow-list`,children:e.flows.map((e,a)=>(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":e.id===t,"data-flow-id":e.id,"data-lit":n.has(e.id)||void 0,title:`${e.name} · ${e.id}`,onClick:()=>r(e.id),children:[(0,W.jsx)(`span`,{className:`mono-value`,children:a+1}),(0,W.jsx)(`span`,{className:`architecture-sequence__flow-name`,children:e.name}),n.has(e.id)&&(0,W.jsx)(`span`,{className:`architecture-sequence__lit`,"aria-label":i(`architecture.sequence.lit`)})]},e.id))})]})}function hg({map:e,layer:t,pullRequest:n,flowId:r,onFlow:i,selection:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,I.useMemo)(()=>Zh(e,t,n),[e,t,n]),d=(0,I.useMemo)(()=>Qh(e),[e]),f=(0,I.useMemo)(()=>eg(e,t,u,d),[e,t,u,d]),p=e.flows.length===0?null:fg(e,t,u,d,r),m=(0,I.useMemo)(()=>p?.applicability===`required`?sg(e,p,t,n,l):null,[e,p,t,n,l]),h=p?.id??``,g=(0,I.useCallback)(e=>o(h,e),[h,o]);if(p===null)return(0,W.jsxs)(`div`,{className:`architecture-map`,children:[(0,W.jsx)(Mp,{part:`sequence.flows`,reason:`flows_undeclared`,children:l(`architecture.sequence.none`)}),(0,W.jsx)(`aside`,{className:`architecture-map__inspector`,"aria-label":l(`architecture.sequence.inspector`),children:s})]});let _=dg[t],v=(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(mg,{map:e,flowId:p.id,lit:f,onFlow:i,t:l}),s,_&&(0,W.jsx)(Mp,{part:`sequence.${t}`,reason:_,children:l(`architecture.sequence.note.${_}`)})]}),y=a?.scope===p.id?a.id:null;return(0,W.jsx)(`div`,{className:`architecture-sequence`,children:(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`sequence`,"data-flow":p.id,"data-layer":t,children:[p.applicability===`not-applicable`?(0,W.jsx)(Mp,{part:`sequence.not_applicable`,reason:`flow_not_applicable`,children:l(`architecture.flow.notApplicable`,{rationale:p.rationale})}):(0,W.jsx)(lg,{map:e,layout:m,layer:t,pullRequest:n,selected:y,onSelect:g,t:l},p.id),(0,W.jsx)(ug,{map:e,flow:p,layout:m,layer:t,pullRequest:n,selected:y,lead:v,onModule:c,t:l})]})})}var gg=[`process`,`namespace`,`mount`],_g=new Set([`namespace`,`process`,`mount`,`external-system`]),vg=220,yg=72,bg=32,xg=16,Sg=12,Cg=72,wg=320,Tg=24,Eg=1.5,Dg=new Set([`runs-in`,`deployed-on`,`mounts`]),Og=(e,t)=>`${e}/${t}`,kg=(e,t)=>e(t.source)&&e(t.target);function Ag(e,t,n,r,i=!0){let a=new Set(r?[]:e.nodes.filter(e=>e.status===`deprecated`).map(e=>e.id)),o=e=>!a.has(e);return n===`process`?Fg(e,t,o,i):n===`namespace`?Bg(e,o,i):Vg(e,o)}function jg(e){let t=Dh(e),n=[`namespace`,`process`,`mount`],r=n.map(n=>Ag(e,t,n,!0).boxes.filter(e=>e.node.kind!==`external-system`).length),i=[2,1].map(e=>r.findIndex(t=>t>=e)).find(e=>e>=0);return i===void 0?`namespace`:n[i]}function Mg(e,t){let n=new Map(e.nodes.map(e=>[e.id,e.kind]));return e.relations.find(e=>e.kind===`runs-in`&&e.source===t&&n.get(e.target)===`namespace`)?.target??null}function Ng(e,t,n,r,i){return{id:e,source:t,target:n,kind:r,dashed:i,relations:[],protocols:[]}}function Pg(e,t){return{...e,relations:[...e.relations,t.id],protocols:t.protocol===null||e.protocols.includes(t.protocol)?e.protocols:[...e.protocols,t.protocol]}}function Fg(e,t,n,r){let i=new Map(e.nodes.map(e=>[e.id,e])),a=e.nodes.filter(e=>(e.kind===`process`||e.kind===`external-system`)&&n(e.id)),o=e=>{let t=i.get(e)?.kind;return t===`process`||t===`external-system`},s=new Map;for(let t of e.relations)t.kind===`deployed-on`&&kg(n,t)&&i.get(t.target)?.kind===`process`&&!_g.has(i.get(t.source).kind)&&s.set(t.target,[...s.get(t.target)??[],i.get(t.source)]);let c=e=>{if(o(e))return e;let n=t(e);return n.kind===`process`?n.process:null},l=new Map,u=[];for(let t of e.relations){if(Dg.has(t.kind)||!kg(n,t)||[t.source,t.target].some(e=>{let t=i.get(e).kind;return t===`namespace`||t===`mount`}))continue;let e=c(t.source),r=c(t.target);if(e!==null&&!n(e)||r!==null&&!n(r))continue;if(e===null||r===null){(e!==null||r!==null)&&u.push(t.id);continue}if(e===r)continue;let a=qi.has(t.kind),s=o(t.source)&&o(t.target)?t.kind:a?`io`:`code`,d=`${e}\n${r}\n${s}`;l.set(d,Pg(l.get(d)??Ng(`topology:${d}`,e,r,s,a),t))}let d=e=>{let t=s.get(e.id)?.length??0;return 44+t*26+(t>0?8:0)},f=Fi({nodes:a.map(e=>({id:e.id,width:vg,height:d(e),kind:Ig(e,null)})),edges:[...l.values()].map(e=>({...Lg(e),weight:e.relations.length})),nodesep:32,ranksep:72,margin:Tg},r),p=a.map(e=>({node:e,members:s.get(e.id)??[],group:!1,tone:null}));return{base:`process`,boxes:p,edges:[...l.values()],unplaced:u,scene:Rg(p,f.boxes,f.routes,[...l.values()])}}var Ig=(e,t)=>t??(e.kind===`namespace`?`frame`:e.kind===`external-system`?`external`:`box`),Lg=e=>({id:e.id,source:e.source,target:e.target,arrows:{start:!1,end:!0},kind:e.kind,dashed:e.dashed,width:Eg});function Rg(e,t,n,r){let i=new Map(t.map(e=>[e.id,e])),a=e.flatMap(e=>{let t=i.get(e.node.id);return[t,...e.members.map((n,r)=>({id:Og(e.node.id,n.id),parent:t.id,x:t.x+12,y:t.y+44+r*26,width:t.width-24,height:22,kind:`member`}))]}),o=new Map(n.map(e=>[e.id,e.points]));return{boxes:a,routes:n,labels:r.filter(e=>e.protocols.length>0).map(e=>yi(e.protocols.join(` · `),bi(o.get(e.id)),e.id)),extent:Pi(a,n,Tg)}}var zg=(e,t)=>e.mount.order-t.mount.order;function Bg(e,t,n){let r=new Map(e.nodes.map(e=>[e.id,e])),i=e=>r.get(e).kind,a=e.nodes.filter(e=>(e.kind===`namespace`||e.kind===`mount`)&&t(e.id)),o=e=>{let n=e;for(;n!==null&&i(n)===`namespace`&&!t(n);)n=r.get(n).parent;return n!==null&&i(n)===`namespace`?n:null},s=new Map;for(let e of a){let t=e.kind===`namespace`?o(e.parent):null;t!==null&&s.set(e.id,t)}for(let n of e.relations){if(n.kind!==`mounts`||i(n.target)!==`mount`||!t(n.target))continue;let r=o(i(n.source)===`namespace`?n.source:i(n.source)===`process`?Mg(e,n.source):null);r!==null&&s.set(n.target,r)}let c=new Map;for(let n of e.relations)i(n.target)===`mount`&&kg(t,n)&&(n.kind===`writes`?c.set(n.target,`writer`):n.kind===`reads`&&c.get(n.target)!==`writer`&&c.set(n.target,`reader`));let l=e=>{let n=i(e);return(n===`namespace`||n===`mount`)&&t(e)},u=new Map;for(let t of e.relations){if(Dg.has(t.kind)||!l(t.source)||!l(t.target)||t.source===t.target)continue;let e=`${t.source}\n${t.target}\n${t.kind}`;u.set(e,Pg(u.get(e)??Ng(`topology:${e}`,t.source,t.target,t.kind,qi.has(t.kind)),t))}let d=e=>[...a.filter(t=>t.kind===`mount`&&s.get(t.id)===e).sort(zg),...a.filter(t=>t.kind===`namespace`&&s.get(t.id)===e)],f=[],p=[],m=(e,t,n)=>{let r=s.get(e.id)??null;if(e.kind===`mount`){let i={node:e,members:[],group:!1,tone:c.get(e.id)??`point`},a={id:e.id,parent:r,x:t,y:n,width:vg,height:yg,kind:Ig(e,i.tone)};return f.push(i),p.push(a),a}let i=f.length,a=d(e.id),o=n+bg+xg,l=vg;for(let e of a){let n=m(e,t+xg,o);o=n.y+n.height+Sg,l=Math.max(l,n.width)}let u=a.length===0?74:o-Sg+xg-n,h={id:e.id,parent:r,x:t,y:n,width:l+32,height:u,kind:`frame`};return f.splice(i,0,{node:e,members:[],group:a.length>0,tone:null}),p.splice(i,0,h),h},h=d(void 0).map(e=>m(e,0,0)),g=e=>{let t=e;for(;s.has(t);)t=s.get(t);return t},_=[...u.values()].filter(e=>g(e.source)!==g(e.target)),v=Fi({nodes:h.map(e=>({id:e.id,width:e.width,height:e.height,kind:e.kind})),edges:_.map(e=>({...Lg(e),source:g(e.source),target:g(e.target),weight:e.relations.length})),nodesep:Cg,ranksep:72,margin:Tg},n),y=new Map(v.boxes.map(e=>[e.id,e])),b=new Map(p.map(e=>{let t=y.get(g(e.id));return[e.id,{...e,x:e.x+t.x,y:e.y+t.y}]})),x=e=>[e.x+e.width/2,e.y+e.height/2],S=new Map(v.routes.map(e=>[e.id,e])),C=e=>{let t=[e];for(;s.has(t[t.length-1]);)t.push(s.get(t[t.length-1]));return t},w=[...u.values()].map(e=>{let[t,r]=[b.get(e.source),b.get(e.target)],i=S.get(e.id),a=i===void 0?[xi(t,x(r)),xi(r,x(t))]:[...i.points];i!==void 0&&i.source!==e.source&&a.unshift(xi(t,a[0])),i!==void 0&&i.target!==e.target&&a.push(xi(r,a[a.length-1]));let o=new Set([...C(e.source),...C(e.target)]);return{...Lg(e),points:n?Mi(a,[...b.values()].filter(e=>!o.has(e.id))):a}});return{base:`namespace`,boxes:f,edges:[...u.values()],unplaced:[],scene:Rg(f,[...b.values()],w,[...u.values()])}}function Vg(e,t){let n=new Map(e.nodes.map(e=>[e.id,e])),r=new Map;for(let i of e.relations)i.kind===`mounts`&&kg(t,i)&&n.get(i.target)?.kind===`mount`&&r.set(i.source,[...r.get(i.source)??[],n.get(i.target)]);let i=e.nodes.filter(e=>r.has(e.id)).map(e=>({node:e,members:[...r.get(e.id)].sort(zg),group:!1,tone:null}));return{base:`mount`,boxes:i,edges:[],unplaced:[],scene:Rg(i,i.map((e,t)=>({id:e.node.id,parent:null,x:Tg+t*352,y:Tg,width:wg,height:44+e.members.length*26+8,kind:Ig(e.node,null)})),[],[])}}var Hg=e=>e.status===`deprecated`||void 0,Ug={box:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__group architecture-topology__box`,"data-kind":e.node.kind,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.node.name}),(0,W.jsx)(Np,{mark:e.mark})]}),(0,W.jsx)(`span`,{className:`architecture-map__meta`,children:e.detail})]})]})}),namespace:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__group architecture-topology__namespace`,"data-kind":`namespace`,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.node.name}),(0,W.jsx)(Np,{mark:e.mark})]}),(0,W.jsx)(`span`,{className:`architecture-map__meta mono-value`,children:e.detail})]}),e.empty!==null&&(0,W.jsx)(`p`,{className:`architecture-topology__empty`,"data-namespace-empty":!0,children:e.empty})]})}),mount:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsxs)(`div`,{className:`architecture-map__box architecture-topology__mount`,"data-kind":`mount`,"data-mount-tone":e.tone??void 0,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:[(0,W.jsx)(Kp,{}),(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.node.name}),(0,W.jsx)(Np,{mark:e.mark})]}),(0,W.jsx)(`span`,{className:`architecture-topology__summary`,title:e.node.summary,children:e.node.summary})]})}),member:(0,I.memo)(function({data:e,selected:t}){return(0,W.jsx)(`div`,{className:`architecture-map__box architecture-topology__member`,"data-kind":e.node.kind,"data-selected":t||void 0,"data-tone":e.mark?.tone,"data-quiet":e.quiet||void 0,"data-deprecated":Hg(e.node),children:(0,W.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,W.jsx)(`strong`,{children:e.detail}),(0,W.jsx)(Np,{mark:e.mark})]})})})},Wg=(e,t)=>e??t(`architecture.topology.masked`);function Gg(e,t){let{order:n,source:r,target:i,mode:a}=e.mount;return t(`architecture.topology.mountRow`,{order:n,source:Wg(r,t),target:Wg(i,t),mode:a})}function Kg(e,t){return e.members.length>0?t(e.members[0].kind===`mount`?`architecture.topology.mounts`:`architecture.topology.deployed`,{count:e.members.length}):e.node.kind===`namespace`?e.node.namespace.type:e.node.kind}var qg=(e,t)=>e.kind===`mount`?Gg(e,t):e.name,Jg=e=>new Map(e.boxes.flatMap(e=>[[e.node.id,{box:e,member:null}],...e.members.map(t=>[Og(e.node.id,t.id),{box:e,member:t}])]));function Yg(e,t){let n=Jg(e);return e=>{let{box:r,member:i}=n.get(e.id);return i===null?[r.node.name,Kg(r,t)]:[qg(i,t)]}}function Xg(e,t){return e===`process`?[{key:`code`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.topology.legend.runtime`)},{key:`external`,swatch:(0,W.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:t(`architecture.map.legend.external`)}]:(e===`namespace`?[`writer`,`reader`,`point`]:[`point`]).map(e=>({key:e,swatch:(0,W.jsx)(`span`,{className:`architecture-topology__swatch`,"data-mount-tone":e}),text:t(`architecture.topology.legend.${e}`)}))}var Zg=(e,t,n)=>Ag(e,Dh(e),t,n);function Qg({map:e,base:t,onBase:n,legacy:r,onLegacy:i,t:a}){let o=(0,I.useMemo)(()=>Zg(e,t,!0),[e,t]),s=o.boxes.flatMap(e=>[e.node,...e.members]).filter(e=>e.status===`deprecated`).length;return(0,W.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,W.jsx)(`span`,{className:`architecture-topology__bases`,role:`group`,"aria-label":a(`architecture.topology.base`),children:gg.map(e=>(0,W.jsx)(`button`,{type:`button`,"data-topology-base":e,"aria-pressed":e===t,onClick:()=>n(e),children:a(`architecture.topology.base.${e}`)},e))}),(0,W.jsxs)(`button`,{type:`button`,className:`architecture-lens__export architecture-topology__legacy`,"data-topology-legacy":!0,"aria-pressed":r,disabled:s===0,title:s===0?a(`architecture.topology.legacyNone`):void 0,onClick:()=>i(!r),children:[(0,W.jsx)(`span`,{className:`architecture-topology__switch`,"aria-hidden":`true`}),a(`architecture.topology.legacy`),(0,W.jsx)(`span`,{className:`mono-value`,children:s})]}),(0,W.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-topology-export":!0,disabled:o.boxes.length===0,onClick:()=>{let n=Zg(e,t,r);Jp(`topology-${t}-${e.commit.slice(0,7)}.svg`,n.scene,Yg(n,a))},children:a(`architecture.topology.export`)})]})}function $g({map:e,nodeId:t,names:n,t:r}){let i=e.relations.filter(e=>e.kind===`writes`&&e.target===t);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:r(`architecture.topology.writers`)}),i.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,"data-writers":`none`,children:r(`architecture.topology.noWriter`)}):(0,W.jsx)(`ul`,{"data-writers":!0,children:i.map(e=>(0,W.jsx)(`li`,{children:n.get(e.source)},e.id))})]})}function e_({map:e,layout:t,layer:n,pullRequest:r,selectedId:i,onSelect:a,side:o,onModule:s,t:c}){let l=(0,I.useMemo)(()=>Dh(e),[e]),u=(0,I.useMemo)(()=>wp(e,n,r),[e,n,r]),d=(0,I.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),f=(0,I.useMemo)(()=>new Map(t.boxes.map(e=>[e.node.id,e])),[t]),p=(0,I.useMemo)(()=>Jg(t),[t]),m=(0,I.useMemo)(()=>{let n=new Map(t.scene.boxes.map(e=>[e.id,e.parent])),r=new Map(t.boxes.flatMap(e=>e.members.map(t=>[t.id,e.node.id]))),i=t=>{if(f.has(t))return t;if(r.has(t))return r.get(t);let n=l(t);return n.kind===`process`?f.has(n.process)?n.process:Mg(e,n.process):null},a=new Set;for(let e of u.lit)for(let t=i(e);t!==null&&!a.has(t);t=n.get(t)??null)a.add(t);return a},[t,u,l,f,e]),h=(0,I.useCallback)(e=>{let{box:n,member:r}=p.get(e.id);return r===null?{type:t.base===`namespace`?n.node.kind===`namespace`?`namespace`:`mount`:`box`,ariaLabel:`${n.node.kind} ${n.node.name}`,selection:n.node.id,data:{node:n.node,mark:u.marks.get(n.node.id)??null,quiet:u.available&&!m.has(n.node.id),detail:Kg(n,c),tone:n.tone,empty:t.base===`namespace`&&n.node.kind===`namespace`&&!n.group?c(`architecture.topology.noMount`):null}}:{type:`member`,ariaLabel:`${r.kind} ${r.name}`,selection:r.id,data:{node:r,mark:u.marks.get(r.id)??null,quiet:u.available&&!u.lit.has(r.id),detail:qg(r,c),tone:null,empty:null}}},[p,u,m,t,c]),g=i===null?null:e.nodes.find(e=>e.id===i),_=i===null?null:f.get(i)??null,v=g===null||_g.has(g.kind)?null:l(g.id),y=g?.kind===`process`?Mg(e,g.id):null,b=g?.kind===`mount`?e.relations.find(e=>e.kind===`mounts`&&e.target===g.id)?.source??null:null;return(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`topology`,"data-base":t.base,"data-node-count":t.boxes.length,"data-edge-count":t.edges.length,"data-layer":n,children:[(0,W.jsx)(Zp,{label:c(`architecture.topology.label`),scene:t.scene,nodeTypes:Ug,view:h,selected:i,onSelect:a,legend:Xg(t.base,c),t:c}),(0,W.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":c(`architecture.map.inspector`),"data-node-id":i??void 0,children:[o,g===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.map.pick`)}):(0,W.jsxs)(Up,{map:e,layer:n,pullRequest:r,nodeId:g.id,onModule:s,t:c,children:[y!==null&&(0,W.jsx)(`p`,{"data-runs-in":y,children:c(`architecture.topology.in`,{name:d.get(y)})}),v?.kind===`process`&&(0,W.jsx)(`p`,{"data-runtime":`process`,children:c(`architecture.sequence.runsIn`,{place:d.get(v.process)})}),g.kind===`namespace`&&(0,W.jsx)(`dl`,{className:`detail-list`,children:(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.type`)}),(0,W.jsx)(`dd`,{"data-namespace-type":!0,children:g.namespace.type})]})}),g.kind===`mount`&&(0,W.jsxs)(`dl`,{className:`detail-list`,"data-mount-fields":!0,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.order`)}),(0,W.jsx)(`dd`,{className:`mono-value`,children:g.mount.order})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.path`)}),(0,W.jsxs)(`dd`,{className:`mono-value`,children:[Wg(g.mount.source,c),` → `,Wg(g.mount.target,c)]})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.mode`)}),(0,W.jsx)(`dd`,{className:`mono-value`,children:g.mount.mode})]}),b!==null&&(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:c(`architecture.topology.mounter`)}),(0,W.jsx)(`dd`,{children:d.get(b)})]})]}),(g.kind===`namespace`||g.kind===`mount`)&&(0,W.jsx)($g,{map:e,nodeId:g.id,names:d,t:c}),g.kind===`process`&&_!==null&&_.members.length>0&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`h4`,{children:c(`architecture.topology.deployed`,{count:_.members.length})}),(0,W.jsx)(`ul`,{"data-deployed":!0,children:_.members.map(t=>{let n=Ip(e,t.id);return(0,W.jsxs)(`li`,{children:[t.name,n&&(0,W.jsxs)(`span`,{className:`detail-quiet`,children:[` · `,c(`architecture.map.sizeValue`,{lines:n.lines,files:n.files})]})]},t.id)})})]})]})]})]})}var t_={process:{part:`topology.processes`,reason:`process_undeclared`},namespace:{part:`topology.namespaces`,reason:`namespace_undeclared`},mount:{part:`topology.mounts`,reason:`mount_undeclared`}};function n_({map:e,layer:t,pullRequest:n,base:r,legacy:i,selectedId:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,I.useMemo)(()=>Dh(e),[e]),d=(0,I.useMemo)(()=>Ag(e,u,r,i),[e,u,r,i]),f=(0,I.useMemo)(()=>wp(e,t,n),[e,t,n]),p=e.nodes.some(e=>e.kind===`process`||e.kind===`namespace`||e.kind===`mount`)?d.boxes.some(e=>e.node.kind!==`external-system`)?null:{...t_[r],text:l(`architecture.topology.none.${r}`)}:{part:`topology.empty`,reason:`topology_undeclared`,text:l(`architecture.topology.none`)};if(p!==null)return(0,W.jsxs)(`div`,{className:`architecture-map`,"data-view":`topology`,"data-base":r,children:[(0,W.jsx)(Mp,{part:p.part,reason:p.reason,children:p.text}),(0,W.jsx)(`aside`,{className:`architecture-map__inspector`,"aria-label":l(`architecture.map.inspector`),children:s})]});let m=new Map(e.nodes.map(e=>[e.id,e.name])),h=new Map(e.relations.map(e=>[e.id,e])),g=new Set(d.boxes.flatMap(e=>[e.node.id,...e.members.map(e=>e.id)])),_=r===`process`?[...f.marks.keys()].filter(e=>!g.has(e)&&u(e).kind===`unknown`):[];return(0,W.jsxs)(`div`,{className:`architecture-topology`,children:[t===`violations`&&(0,W.jsx)(Mp,{part:`topology.violations`,reason:`imports_on_module_map`,children:l(`architecture.sequence.note.imports_on_module_map`)}),_.length>0&&(0,W.jsx)(Mp,{part:`topology.unplaced_marks`,reason:`deployment_undeclared`,children:l(`architecture.topology.hidden`,{count:_.length})}),d.unplaced.length>0&&(0,W.jsx)(Mp,{part:`topology.unplaced`,reason:`deployment_undeclared`,children:(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:l(`architecture.topology.unplaced`,{count:d.unplaced.length})}),(0,W.jsx)(`ul`,{children:d.unplaced.map(e=>{let t=h.get(e);return(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:t.kind}),` `,m.get(t.source),` → `,m.get(t.target)]},e)})})]})}),(0,W.jsx)(e_,{map:e,layout:d,layer:t,pullRequest:n,selectedId:a,onSelect:o,side:s,onModule:c,t:l},`${e.commit}:${r}:${i}`)]})}async function r_(e,t){let n=await l(`/api/v1/repositories/${encodeURIComponent(e)}/architecture/map`,t);if(n.state===`unreachable`)return{state:`unavailable`,reason:`unreachable`};let{body:r}=n;if(!n.ok)return tf(r)??{state:`unavailable`,reason:`unreachable`};try{return{state:`ok`,map:sp(r)}}catch{return{state:`unavailable`,reason:`architecture_map_invalid`}}}function i_(e,t,n){let[r,i]=(0,I.useState)(null),o=(0,I.useCallback)(async n=>{let r=await e(t,n);return!n.aborted&&(i(e=>{let n=e?.repositoryId===t&&e.read.state===`ok`?e.read.map:null;return r.state===`ok`&&n!==null&&JSON.stringify(n)===JSON.stringify({...r.map,collected_at:n.collected_at})?e:{repositoryId:t,read:r}}),c(r))},[e,t]);return a(o,JSON.stringify([t,n])),r?.repositoryId===t?r.read:null}function a_(e,t){return t===`violations`?Object.values(e.layers.violations).some(e=>e.state===`ok`):e.layers[t].state===`ok`}function o_(e,t,n,r){if(!a_(e,t))return null;let{changes:i,pull_requests:a,tests:o,decisions:s}=e.layers,c=t=>[...Cp(e,t,n).marks.values()].filter(e=>e.tone!==`muted`).length;if(t===`changes`)return i.state===`ok`?r(`architecture.layer.count.changes`,{modules:Ap(r,c(`changes`),`module`,i.truncated.nodes),commits:Ap(r,i.commits.length,`commit`)}):null;if(t===`violations`)return String(pp(e));if(t===`pull_requests`){let e=a.state===`ok`?a.pull_requests.find(e=>e.number===n)?.impact:void 0;return n===null?null:e?.state===`ok`?r(`architecture.layer.count.pull_requests`,{number:n,modules:Ap(r,c(`pull_requests`),`module`,e.truncated.nodes)}):`#${n}`}return t===`tests`?o.state===`ok`?`${o.capabilities.length} / ${e.nodes.filter(e=>e.kind===`capability`).length}`:null:Ap(r,s.items.length,`decision`)}function s_({map:e,layer:t,pullRequest:n,onLayer:r,t:i}){return(0,W.jsx)(`div`,{className:`architecture-layers`,role:`group`,"aria-labelledby":`architecture-layers-label`,children:cp.map(a=>{let o=o_(e,a,n,i);return(0,W.jsxs)(`button`,{type:`button`,"aria-pressed":t===a,"data-layer":a,"data-state":a_(e,a)?`ok`:`unavailable`,onClick:()=>r(a),children:[i(`architecture.layer.${a}`),o!==null&&(0,W.jsx)(`span`,{className:`architecture-layers__count mono-value`,children:o})]},a)})})}function c_({part:e,impact:t,flowSteps:n,t:r}){let{flow_steps:i}=t,a=vp(t.truncated);return(0,W.jsxs)(W.Fragment,{children:[n&&(i.status===`known`?(0,W.jsx)(`p`,{"data-flow-steps":e,children:r(`architecture.layer.flow_steps.known`,{count:i.items.length})}):(0,W.jsx)(jp,{part:`${e}.flow_steps`,reason:i.reason_codes.join(` `),children:r(`architecture.layer.flow_steps.unknown`,{reasons:i.reason_codes.join(`, `)})})),n&&i.items!==null&&i.items.length>0&&(0,W.jsx)(`ul`,{"data-flow-step-list":e,children:i.items.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:e.flow}),` · `,e.step,e.reason_codes.length>0&&` · ${e.reason_codes.join(`, `)}`]},`${e.flow}:${e.outcome??``}:${e.step}`))}),a.length>0&&(0,W.jsx)(Mp,{part:`${e}.truncated`,reason:a.join(` `),children:[r(`architecture.layer.truncated`,{parts:a.map(e=>r(`architecture.layer.truncated.part.${e}`)).join(`, `)}),...a.includes(`paths`)?[r(`architecture.layer.truncated.paths`)]:[]].join(` `)})]})}function l_({map:e,view:t,layer:n,pullRequest:r,onPullRequest:i,t:a}){let{changes:o,violations:s,pull_requests:c,tests:l,decisions:u}=e.layers;if(n===`changes`){if(o.state===`unavailable`)return o.reason===`archctx_error`?(0,W.jsx)(jp,{part:`changes`,reason:o.reason,code:dp(o),children:a(`architecture.layer.changes.archctx_error`,{code:dp(o)})}):(0,W.jsx)(jp,{part:`changes`,reason:o.reason,children:a(`architecture.layer.changes.${o.reason}`)});let e=(e,t)=>o.model.filter(n=>n.kind===e&&n.change===t).length;return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`changes`,children:[(0,W.jsxs)(`p`,{children:[a(`architecture.layer.changes.summary`,{commits:Ap(a,o.commits.length,`commit`),files:Ap(a,o.paths.length,`file`,o.truncated.paths),unowned:`${o.truncated.paths?`≥`:``}${o.unowned_paths.length}`}),` `,(0,W.jsx)(`time`,{dateTime:o.since,children:new Date(o.since).toLocaleString()}),` · `,(0,W.jsx)(`code`,{children:o.base.slice(0,12)})]}),(0,W.jsx)(`p`,{children:a(`architecture.layer.changes.model`,{nodesAdded:e(`nodes`,`added`),nodesRemoved:e(`nodes`,`removed`),nodesChanged:e(`nodes`,`changed`),relationsAdded:e(`relations`,`added`),relationsRemoved:e(`relations`,`removed`),relationsChanged:e(`relations`,`changed`),flowsAdded:e(`flows`,`added`),flowsRemoved:e(`flows`,`removed`),flowsChanged:e(`flows`,`changed`)})}),(0,W.jsx)(c_,{part:`changes`,impact:o,flowSteps:t===`sequence`,t:a})]})}if(n===`violations`){let{debt:e,flows:t,anchors:n,dependencies:r,layer_direction:i}=s,o=(e,t)=>a(`architecture.layer.violations.gap`,{part:a(`architecture.layer.violations.${e}.label`),reason:t}),c=(e,t)=>t.reason===`archctx_error`?(0,W.jsx)(jp,{part:`violations.${e}`,reason:t.reason,code:dp(t),children:o(e,a(`architecture.layer.reason.archctx_error`,{code:dp(t)}))}):(0,W.jsx)(jp,{part:`violations.${e}`,reason:t.reason,children:o(e,a(`architecture.layer.reason.${t.reason}`))}),l=i.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.layer_direction`,{count:i.edges.length,imports:i.edges.reduce((e,t)=>e+t.imports,0),checked:i.imports})}):i.reason===`model_layers_undeclared`||i.reason===`layer_direction_undeclared`?(0,W.jsx)(Mp,{part:`violations.layer_direction`,reason:i.reason,children:o(`layer_direction`,a(`architecture.layer.reason.${i.reason}`))}):c(`layer_direction`,i),u=e.state===`ok`?e.items.filter(e=>e.nodes.length===0):[];return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`violations`,children:[e.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.debt`,{count:e.items.length})}):c(`debt`,e),u.length>0&&(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:a(`architecture.layer.unowned`,{count:u.length})}),(0,W.jsx)(`ul`,{children:u.flatMap(e=>e.paths.map(t=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:t}),` · `,a(`architecture.layer.debt.${e.kind}`)]},`${e.kind}:${t}`)))})]}),t.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.flows`,{proven:t.proven,selectors:t.selectors,unprovable:t.unprovable.length})}):c(`flows`,t),n.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.anchors`,{findings:n.nodes.reduce((e,t)=>e+t.findings.length,0),citations:n.citations})}):c(`anchors`,n),r.state===`ok`?(0,W.jsx)(`p`,{children:a(`architecture.layer.violations.dependencies`,{count:r.edges.length})}):c(`dependencies`,r),l]})}if(n===`tests`){if(l.state===`unavailable`)return(0,W.jsx)(jp,{part:`tests`,reason:l.reason,children:a(`architecture.layer.tests.${l.reason}`)});let t=e.nodes.filter(e=>e.kind===`capability`).length;return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`tests`,children:[(0,W.jsxs)(`p`,{children:[a(`architecture.layer.tests.summary`,{run:l.run.id,failed:l.capabilities.filter(e=>e.failed>0).length,covered:l.capabilities.length,capabilities:t}),` `,(0,W.jsx)(`time`,{dateTime:l.run.created_at,children:new Date(l.run.created_at).toLocaleString()}),` · `,(0,W.jsx)(`code`,{children:l.run.head_sha.slice(0,12)})]}),l.results!==`ok`&&(0,W.jsx)(jp,{part:`results`,reason:l.results,children:a(`architecture.layer.tests.results.${l.results}`)})]})}if(n===`pull_requests`){if(c.state===`unavailable`)return(0,W.jsx)(jp,{part:`pull_requests`,reason:c.reason,children:a(`architecture.layer.pull_requests.${c.reason}`)});let e=c.pull_requests.find(e=>e.number===r)??null;return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`pull_requests`,children:[(0,W.jsxs)(`p`,{children:[a(`architecture.layer.pull_requests.summary`,{count:c.pull_requests.length}),` `,(0,W.jsx)(`time`,{dateTime:c.observed_at,children:new Date(c.observed_at).toLocaleString()})]}),c.pull_requests.length>0&&(0,W.jsxs)(`label`,{className:`architecture-layer-summary__pick`,children:[(0,W.jsx)(`span`,{children:a(`architecture.layer.pull_requests.pick`)}),(0,W.jsxs)(`select`,{value:e?.number??``,onChange:e=>i(Number(e.target.value)),children:[e===null&&(0,W.jsx)(`option`,{value:``,disabled:!0,children:a(`architecture.layer.pull_requests.none`)}),c.pull_requests.map(e=>(0,W.jsxs)(`option`,{value:e.number,children:[`#`,e.number,` `,e.title]},e.number))]})]}),e&&(0,W.jsxs)(`p`,{"data-pull-request":e.number,children:[(0,W.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),e.head_sha!==null&&(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(`code`,{children:e.head_sha.slice(0,12)})]}),e.impact.state===`ok`&&(0,W.jsxs)(W.Fragment,{children:[` · `,a(`architecture.layer.pull_requests.impact`,{files:Ap(a,e.impact.paths.length,`file`,e.impact.truncated.paths),nodes:Ap(a,e.impact.nodes.length,`node`,e.impact.truncated.nodes),unowned:`${e.impact.truncated.paths?`≥`:``}${e.impact.unowned_paths.length}`})]})]}),e?.impact.state===`ok`&&(0,W.jsx)(c_,{part:`pull_request`,impact:e.impact,flowSteps:t===`sequence`,t:a}),e?.impact.state===`unavailable`&&(e.impact.reason===`archctx_error`?(0,W.jsx)(jp,{part:`pull_request`,reason:e.impact.reason,code:dp(e.impact),children:a(`architecture.layer.pull_requests.pr.archctx_error`,{code:dp(e.impact)})}):(0,W.jsx)(jp,{part:`pull_request`,reason:e.impact.reason,children:a(`architecture.layer.pull_requests.pr.${e.impact.reason}`)}))]})}let d=u.items.filter(e=>e.applies_to.length===0);return(0,W.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`decisions`,children:[(0,W.jsx)(`p`,{children:a(`architecture.layer.decisions.summary`,{count:Ap(a,u.items.length,`decision`),applied:u.items.length-d.length})}),d.length>0&&(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{children:a(`architecture.layer.decisions.unapplied`,{count:d.length})}),(0,W.jsx)(`ul`,{children:d.map(e=>(0,W.jsxs)(`li`,{children:[e.title,` · `,(0,W.jsx)(`code`,{children:e.path})]},e.id))})]})]})}function u_({read:e,kept:t,t:n}){let r=e.reason===`archctx_error`?dp(e):void 0,i=e.reason===`architecture_map_pending`;return(0,W.jsxs)(`p`,{className:i?void 0:`architecture-notice`,role:i?`status`:`alert`,"data-error-code":e.reason,"data-code":r,children:[t&&(0,W.jsx)(`span`,{className:`block`,children:n(`architecture.map.kept`)}),(0,W.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}`,r===void 0?void 0:{code:r})}),(0,W.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}.next`)})]})}function d_({map:e,t}){return(0,W.jsxs)(W.Fragment,{children:[e.sizes.state===`unavailable`&&(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`sizes`,"data-reason":e.sizes.reason,children:t(`architecture.map.sizes.${e.sizes.reason}`)}),e.dependencies.state===`unavailable`&&(0,W.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`dependencies`,"data-reason":e.dependencies.reason,children:t(`architecture.map.dependencies.${e.dependencies.reason}`)})]})}function f_({repositoryId:e,view:t=`modules`,read:n=r_,refreshGeneration:r,selections:i,select:a,onModule:o,onSummary:s,t:c}){let l=i_(n,e,r),[u,d]=(0,I.useState)(`changes`),[f,p]=(0,I.useState)(null),[m,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(null),[v,y]=(0,I.useState)(!0),b=(0,I.useRef)(null);l?.state===`ok`&&(b.current={repositoryId:e,map:l.map});let x=b.current?.repositoryId===e?b.current.map:null,S=x!==null&&x.layers.pull_requests.state===`ok`&&x.layers.pull_requests.pull_requests.some(e=>e.number===f),C=x===null?null:S?f:hp(x),w=(0,I.useMemo)(()=>x===null||t!==`topology`?`namespace`:jg(x),[x,t]),T=g??w,E=`${T}:${v}`,D=i.topology?.scope===E?i.topology.id:null,O=(0,I.useCallback)(e=>{_(e),a({view:`topology`,scope:``,id:null})},[a]),k=(0,I.useCallback)(e=>{y(e),a({view:`topology`,scope:``,id:null})},[a]),A=(0,I.useCallback)(e=>a({view:`topology`,scope:E,id:e}),[E,a]),j=(0,I.useCallback)(e=>a({view:`modules`,scope:``,id:e}),[a]),M=(0,I.useCallback)(e=>a({view:`layers`,scope:``,id:e}),[a]),N=(0,I.useCallback)((e,t)=>a({view:`sequence`,scope:e,id:t}),[a]),P=(0,I.useCallback)(e=>{h(e),a({view:`sequence`,scope:``,id:null})},[a]);(0,I.useEffect)(()=>{s(x===null?null:{commit:x.commit,collectedAt:x.collected_at,headRef:x.head_ref,archctxVersion:x.archctx_version,modules:x.nodes.filter(e=>e.kind===`capability`).length,flows:x.flows.length})},[x,s]),(0,I.useEffect)(()=>()=>s(null),[s]);let F=x&&(0,W.jsxs)(`div`,{className:`architecture-map__side`,"data-map-side":!0,children:[(0,W.jsx)(d_,{map:x,t:c}),(0,W.jsx)(l_,{map:x,view:t,layer:u,pullRequest:C,onPullRequest:p,t:c})]});return(0,W.jsxs)(`div`,{className:`architecture-map-view`,children:[l===null&&(0,W.jsx)(`p`,{role:`status`,children:c(`architecture.map.loading`)}),l?.state===`unavailable`&&(0,W.jsx)(u_,{read:l,kept:x!==null,t:c}),x&&t===`layers`&&(0,W.jsx)(Wm,{map:x,selectedId:i.layers?.id??null,onSelect:M,t:c},`${e}:${x.commit}`),x&&t!==`layers`&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`architecture-lens`,children:[(0,W.jsx)(`span`,{id:`architecture-layers-label`,className:`architecture-lens__label`,children:c(`architecture.layers`)}),(0,W.jsx)(s_,{map:x,layer:u,pullRequest:C,onLayer:d,t:c}),t===`sequence`?(0,W.jsx)(pg,{map:x,layer:u,pullRequest:C,flowId:m,t:c}):t===`topology`?(0,W.jsx)(Qg,{map:x,base:T,onBase:O,legacy:v,onLegacy:k,t:c}):(0,W.jsx)(`span`,{className:`architecture-lens__hint`,children:c(`architecture.lens.hint`)})]}),t===`modules`&&(0,W.jsx)(Eh,{map:x,layer:u,pullRequest:C,selectedId:i.modules?.id??null,onSelect:j,side:F,onModule:o,t:c},`${e}:${x.commit}`),t===`sequence`&&(0,W.jsx)(hg,{map:x,layer:u,pullRequest:C,flowId:m,onFlow:P,selection:i.sequence??null,onSelect:N,side:F,onModule:o,t:c},`${e}:${x.commit}`),t===`topology`&&(0,W.jsx)(n_,{map:x,layer:u,pullRequest:C,base:T,legacy:v,selectedId:D,onSelect:A,side:F,onModule:o,t:c},`${e}:${x.commit}`)]})]})}var p_=200,m_=40,h_=52,g_=260,__=240,v_=44,y_=580,b_=780;function x_(e){return e.length>26?`${e.slice(0,25)}…`:e}function S_(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}function C_(e){let t=t=>e.nodes.filter(e=>e.role===t),n=t(`caller`),r=t(`callee`),i=e.nodes.filter(e=>e.role===`child`),a=v_+i.length*h_+(i.length?4:0),o=Math.max(n.length*h_,r.length*h_,a)+8,s=new Map,c=(e,t,n)=>{let r=(o-e.length*h_)/2+6;e.forEach((e,i)=>s.set(e.id,{x:t,y:r+i*h_,w:p_,h:m_,column:n,center:!1}))};c(n,0,0),c(r,y_,2);let l=(o-a)/2;return s.set(e.center,{x:g_,y:l,w:__,h:a,column:1,center:!0}),i.forEach((e,t)=>s.set(e.id,{x:284,y:l+v_+t*h_,w:204,h:m_,column:1,center:!1})),{boxes:s,height:o}}function w_(e){return e.center?e.y+v_/2:e.y+e.h/2}function T_(e,t){if(e.column<t.column)return[[e.x+e.w,w_(e)],[t.x,w_(t)]];if(e.column>t.column)return[[e.x,w_(e)],[t.x+t.w,w_(t)]];let n=e=>e.center?[272,e.y+v_-6]:[e.x,w_(e)],[r,i]=n(e),[a,o]=n(t);return[[r,i],[272,i],[272,o],[a,o]]}function E_(e){if(e.length===2){let[[t,n],[r,i]]=e,a=(r-t)/2;return`M${t} ${n} C${t+a} ${n} ${r-a} ${i} ${r} ${i}`}return e.map(([e,t],n)=>`${n?`L`:`M`}${e} ${t}`).join(` `)}function D_(e,t){return te(e)?t(`architecture.graph.more`,{count:e.count}):e.name}function O_({graph:e,onSelect:t,t:n}){let r=(0,I.useId)(),[i,a]=(0,I.useState)([]),{boxes:o,height:s}=C_(e),c=new Map(e.nodes.map(e=>[e.id,D_(e,n)])),l=e=>a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),u=e.nodes.filter(te).filter(e=>i.includes(e.id));return(0,W.jsxs)(`figure`,{className:`module-graph`,"aria-labelledby":`${r}-caption`,children:[(0,W.jsxs)(`figcaption`,{id:`${r}-caption`,className:`module-graph__caption`,children:[(0,W.jsx)(`span`,{children:n(`architecture.graph.callers`)}),(0,W.jsx)(`span`,{children:n(`architecture.graph.module`)}),(0,W.jsx)(`span`,{children:n(`architecture.graph.callees`)})]}),(0,W.jsxs)(`svg`,{className:`module-graph__svg`,viewBox:`0 0 ${b_} ${s}`,width:b_,height:s,role:`group`,"aria-labelledby":`${r}-caption`,children:[(0,W.jsx)(`defs`,{children:(0,W.jsx)(`marker`,{id:`${r}-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,W.jsx)(`path`,{d:`M0 0 L10 5 L0 10 z`,className:`module-graph__arrow`})})}),e.nodes.map(e=>{let r=o.get(e.id);if(!r)return null;let a=D_(e,n);if(te(e)){let t=i.includes(e.id);return(0,W.jsxs)(`g`,{className:`module-graph__node module-graph__node--group`,"data-node-role":e.role,role:`button`,tabIndex:0,"aria-expanded":t,"aria-label":n(`architecture.graph.group.${e.role}`,{count:e.count}),onClick:()=>l(e.id),onKeyDown:t=>S_(t,()=>l(e.id)),children:[(0,W.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,W.jsx)(`text`,{x:r.x+r.w/2,y:r.y+r.h/2,textAnchor:`middle`,dominantBaseline:`central`,children:a})]},e.id)}let s=e.role===`caller`||e.role===`callee`?p.test(e.id):!1,c=()=>t(e.id);return(0,W.jsxs)(`g`,{className:`module-graph__node module-graph__node--${e.role}`,"data-node-id":e.id,"data-node-role":e.role,...s?{role:`button`,tabIndex:0,"aria-label":n(`architecture.graph.open`,{name:e.name}),onClick:c,onKeyDown:e=>S_(e,c)}:{},children:[(0,W.jsx)(`title`,{children:`${e.name} (${e.id})`}),(0,W.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,W.jsx)(`text`,{x:r.x+12,y:r.center?r.y+v_/2:r.y+r.h/2,dominantBaseline:`central`,children:x_(a)})]},e.id)}),e.edges.map((e,t)=>{let n=o.get(e.source),i=o.get(e.target);if(!n||!i)return null;let a=T_(n,i),s=e.direction===`directed`,[c,l]=a.length===2?[(a[0][0]+a[1][0])/2,(a[0][1]+a[1][1])/2]:[a[1][0]+4,(a[1][1]+a[2][1])/2];return(0,W.jsxs)(`g`,{className:`module-graph__edge`,"data-direction":e.direction,children:[(0,W.jsx)(`path`,{d:E_(a),...s?{markerEnd:`url(#${r}-arrow)`}:{strokeDasharray:`5 4`},children:(0,W.jsx)(`title`,{children:`${e.intent} (${e.relation_kind})`})}),!s&&(0,W.jsx)(`text`,{className:`module-graph__edge-label`,x:c,y:l-4,textAnchor:`middle`,children:e.relation_kind})]},t)})]}),u.map(e=>(0,W.jsxs)(`section`,{className:`module-graph__group`,"aria-label":n(`architecture.graph.group.${e.role}`,{count:e.count}),children:[(0,W.jsx)(`h4`,{children:n(`architecture.graph.group.${e.role}`,{count:e.count})}),(0,W.jsx)(`ul`,{children:e.members.map(e=>(0,W.jsxs)(`li`,{children:[p.test(e.id)?(0,W.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),children:e.name}):(0,W.jsx)(`span`,{children:e.name}),(0,W.jsx)(`code`,{children:e.id})]},e.id))})]},e.id)),(0,W.jsx)(`ul`,{className:`module-graph__relations`,"aria-label":n(`architecture.graph.relations`),children:e.edges.map((e,t)=>(0,W.jsxs)(`li`,{"data-direction":e.direction,children:[(0,W.jsx)(`span`,{children:c.get(e.source)??e.source}),(0,W.jsx)(`span`,{children:` → `}),(0,W.jsx)(`span`,{children:c.get(e.target)??e.target}),(0,W.jsx)(`span`,{className:`module-graph__intent`,children:e.intent}),(0,W.jsx)(`code`,{children:e.relation_kind})]},t))})]})}function k_(e){let t=e?.code;return typeof t==`string`&&/^[a-z][a-z0-9_]{0,63}$/u.test(t)?t:null}async function A_(e,t,n){let r=await fetch(e,{signal:n,cache:`no-store`,headers:t===null?{}:{"If-None-Match":t}});if(r.status===304)return null;let i=null;try{i=await r.json()}catch{i=null}if(!r.ok){let e=k_(i);if(e===null)throw Error(`unavailable`);return{state:`unavailable`,reason:e}}return{body:i,etag:r.headers.get(`ETag`)}}function j_(e,t,n){let[r,i]=(0,I.useState)({path:null,value:null,error:null}),o=(0,I.useRef)(null),s=(0,I.useCallback)(async n=>{if(e===null)return!1;let r=t=>{o.current?.path!==e&&(o.current=null),i(n=>({path:e,value:n.path===e?n.value:null,error:t}))};try{let a=await A_(e,o.current?.path===e?o.current.etag:null,n);if(n.aborted)return!1;if(a===null)return i(e=>e.error===null?e:{...e,error:null}),!0;if(`state`in a)return r(a.reason),c(a);let s=t(a.body);return o.current=a.etag===null?null:{path:e,etag:a.etag},i({path:e,value:s,error:null}),!0}catch(e){return n.aborted||r(e instanceof Error&&/^[a-z][a-z0-9_]{0,63}$/u.test(e.message)?e.message:`unavailable`),!1}},[e,t]);return a(s,JSON.stringify([e,n]),{enabled:e!==null}),r.path===e?r:{path:e,value:null,error:null}}function M_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/modules`}function N_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/history`}function P_(e){let t=`rh arch module review-prompt ${e.capability_id} --shard ${e.shard.index}`;return e.mode===`diff`?`${t} --base ${e.base} --head ${e.head}`:t}function F_({read:e,loading:t,t:n}){return e.error===null?e.value===null?(0,W.jsx)(`p`,{role:`status`,children:n(t)}):null:(0,W.jsx)(`p`,{className:`architecture-notice`,role:`alert`,"data-error-code":e.error,children:n(e.value===null?`architecture.failed`:`architecture.refreshFailed`,{code:e.error})})}var I_={valid:`tone-ok`,fresh:`tone-ok`,present:`tone-ok`,invalid:`tone-danger`,stale:`tone-user`,pending:`tone-user`,unknown:`tone-unknown`};function L_({state:e,t}){return(0,W.jsx)(`ul`,{className:`module-states`,"aria-label":t(`architecture.states`),children:[`model_valid`,`generated_summary`,`section3`].map(n=>(0,W.jsxs)(`li`,{className:`operator-badge ${I_[e[n]]}`,"data-state-kind":n,"data-state-value":e[n],children:[t(`architecture.state.${n}`),`: `,(0,W.jsx)(`strong`,{children:t(`architecture.value.${e[n]}`)})]},n))})}function R_({index:e,onModule:t,t:n}){let r=new Map;for(let t of e.modules)r.set(t.domain,[...r.get(t.domain)??[],t]);return r.size===0?(0,W.jsx)(`p`,{className:`empty-inline`,children:n(`architecture.empty`)}):(0,W.jsx)(`div`,{className:`module-domains`,children:[...r].map(([e,r])=>(0,W.jsxs)(`section`,{className:`module-domain`,"data-domain":e,"aria-labelledby":`domain-${e}`,children:[(0,W.jsxs)(`h3`,{id:`domain-${e}`,children:[e,` `,(0,W.jsx)(`span`,{children:r.length})]}),(0,W.jsx)(`ul`,{children:r.map(e=>(0,W.jsxs)(`li`,{className:`module-row`,"data-module-id":e.id,children:[(0,W.jsxs)(`button`,{type:`button`,className:`module-row__open`,onClick:()=>t(e.id),children:[(0,W.jsx)(`strong`,{children:e.name}),(0,W.jsx)(`code`,{children:e.id})]}),(0,W.jsxs)(`span`,{className:`module-row__meta`,children:[e.status,` · `,n(`architecture.components`,{count:e.components})]}),(0,W.jsx)(L_,{state:e.state,t:n})]},e.id))})]},e))})}function z_({base:e,generation:t,t:n}){let[r,i]=(0,I.useState)(1),a=j_(`${e}/review-prompt?shard=${r}`,xe,t),o=a.value,s=o?P_(o):null;return(0,W.jsxs)(`section`,{className:`architecture-card review-prompt`,"aria-labelledby":`review-prompt-heading`,children:[(0,W.jsx)(`h3`,{id:`review-prompt-heading`,children:n(`architecture.prompt.title`)}),(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.boundary`)}),(0,W.jsx)(F_,{read:a,loading:`architecture.prompt.loading`,t:n}),o&&s&&(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`dl`,{className:`detail-list`,children:[(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:n(`architecture.prompt.digest`)}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`code`,{className:`mono-value review-prompt__digest`,children:o.digest})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:n(`architecture.prompt.budget`)}),(0,W.jsx)(`dd`,{children:n(`architecture.prompt.budgetValue`,{used:o.budget.used_bytes,cap:o.budget.input_cap_bytes})})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:n(`architecture.prompt.omitted`)}),(0,W.jsx)(`dd`,{children:o.budget.omitted_sections.length?o.budget.omitted_sections.join(`, `):n(`architecture.prompt.omittedNone`)})]}),(0,W.jsxs)(`div`,{children:[(0,W.jsx)(`dt`,{children:(0,W.jsx)(`label`,{htmlFor:`review-prompt-shard`,children:n(`architecture.prompt.shard`)})}),(0,W.jsx)(`dd`,{children:(0,W.jsx)(`select`,{id:`review-prompt-shard`,value:o.shard.index,onChange:e=>i(Number(e.target.value)),children:Array.from({length:o.shard.count},(e,t)=>t+1).map(e=>(0,W.jsx)(`option`,{value:e,children:n(`architecture.prompt.shardOf`,{index:e,count:o.shard.count})},e))})})]})]}),o.budget.incomplete&&(0,W.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.incomplete`,{count:o.shard.count})}),(0,W.jsxs)(`div`,{className:`copy-value review-prompt__command`,children:[(0,W.jsx)(`code`,{"data-bot-command":!0,children:s}),(0,W.jsx)(u,{label:n(`architecture.prompt.command`),value:s,t:n})]}),(0,W.jsxs)(`details`,{className:`review-prompt__text`,children:[(0,W.jsx)(`summary`,{children:n(`architecture.prompt.text`,{index:o.shard.index})}),(0,W.jsx)(`pre`,{children:o.prompt})]}),(0,W.jsx)(`div`,{className:`review-prompt__actions`,children:(0,W.jsx)(u,{label:n(`architecture.prompt.textLabel`,{index:o.shard.index}),value:o.prompt,t:n})})]})]})}function B_(e,t){let n=typeof e==`object`&&e&&!Array.isArray(e)?e[t]:void 0;return typeof n==`string`?n:null}function V_({value:e,outcome:t}){let n=B_(e,`label`)??B_(e,`id`)??JSON.stringify(e),r=t?B_(e,`kind`):[B_(e,`from`),B_(e,`to`)].every(Boolean)?`${B_(e,`from`)} → ${B_(e,`to`)}`:null;return(0,W.jsxs)(`li`,{children:[r&&(0,W.jsx)(`code`,{children:r}),` `,n]})}function H_({items:e,empty:t}){return e.length?(0,W.jsx)(`ul`,{children:e.map((e,t)=>(0,W.jsx)(`li`,{children:e},t))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:t})}function U_({detail:e,base:t,generation:n,onModule:r,t:i}){let{module:a}=e,o=i(`architecture.none`);return(0,W.jsxs)(`article`,{className:`module-page`,"aria-labelledby":`module-page-title`,children:[(0,W.jsxs)(`header`,{className:`module-page__header`,children:[(0,W.jsxs)(`p`,{className:`detail-eyebrow`,children:[a.status,` · `,(0,W.jsx)(`code`,{children:a.id})]}),(0,W.jsx)(`h2`,{id:`module-page-title`,children:a.name}),(0,W.jsx)(`p`,{children:a.summary}),(0,W.jsx)(L_,{state:e.state,t:i})]}),(0,W.jsx)(O_,{graph:e.graph,onSelect:r,t:i}),(0,W.jsxs)(`div`,{className:`module-page__grid`,children:[(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-facts-heading`,children:[(0,W.jsx)(`h3`,{id:`module-facts-heading`,children:i(`architecture.facts`)}),(0,W.jsx)(`h4`,{children:i(`architecture.responsibilities`)}),(0,W.jsx)(H_,{items:a.responsibilities,empty:o}),(0,W.jsx)(`h4`,{children:i(`architecture.entrypoints`)}),a.entrypoints?.length?(0,W.jsx)(`ul`,{className:`module-entrypoints`,children:a.entrypoints.flatMap(e=>e.symbols.map(t=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:e.path}),` `,t.name,t.sinks.map(e=>(0,W.jsxs)(`span`,{children:[` → `,(0,W.jsx)(`code`,{children:e.path}),` `,e.symbol]},e.id))]},`${e.id}:${t.name}`)))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:o}),(0,W.jsx)(`h4`,{children:i(`architecture.verification`)}),a.verification.length?(0,W.jsx)(`ul`,{children:a.verification.map(e=>(0,W.jsx)(`li`,{children:(0,W.jsx)(`code`,{children:e})},e))}):(0,W.jsx)(`p`,{className:`detail-quiet`,children:o})]}),(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-flows-heading`,children:[(0,W.jsx)(`h3`,{id:`module-flows-heading`,children:i(`architecture.flows`)}),e.flows.length===0&&(0,W.jsx)(`p`,{className:`detail-quiet`,children:o}),e.flows.map(e=>(0,W.jsxs)(`div`,{className:`module-flow`,children:[(0,W.jsxs)(`h4`,{children:[e.name,` `,(0,W.jsx)(`code`,{children:e.id})]}),e.applicability===`not-applicable`?(0,W.jsx)(`p`,{children:i(`architecture.flow.notApplicable`,{rationale:e.rationale})}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.steps`)}),(0,W.jsx)(`ul`,{children:e.steps.map((e,t)=>(0,W.jsx)(V_,{value:e,outcome:!1},t))}),(0,W.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.outcomes`)}),(0,W.jsx)(`ul`,{children:e.outcomes.map((e,t)=>(0,W.jsx)(V_,{value:e,outcome:!0},t))})]})]},e.id))]}),(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-section3-heading`,children:[(0,W.jsx)(`h3`,{id:`module-section3-heading`,children:i(`architecture.section3`)}),e.section3===null?(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.section3.pending`)}):(0,W.jsx)(`pre`,{className:`module-section3`,children:e.section3})]}),(0,W.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-docs-heading`,children:[(0,W.jsx)(`h3`,{id:`module-docs-heading`,children:i(`architecture.docs`)}),e.linked_docs.length===0?(0,W.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.docs.none`)}):(0,W.jsx)(`ul`,{className:`module-docs`,children:e.linked_docs.map(e=>(0,W.jsxs)(`li`,{children:[(0,W.jsx)(`code`,{children:e.path}),` `,(0,W.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.kind}),` `,(0,W.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.status??i(`architecture.value.unknown`)})]},e.path))})]}),(0,W.jsx)(z_,{base:t,generation:n,t:i},a.id)]})]})}var W_=[`map`,`layers`,`sequence`,`topology`,`modules`,`history`],G_={map:`modules`,layers:`layers`,sequence:`sequence`,topology:`topology`};function K_({view:e,counts:t,onChange:n,t:r}){return(0,W.jsx)(`div`,{className:`architecture-tabs`,role:`tablist`,"aria-label":r(`architecture.views`),children:W_.map((i,a)=>(0,W.jsxs)(`button`,{type:`button`,role:`tab`,id:`architecture-tab-${i}`,"aria-controls":`architecture-view`,"aria-selected":e===i,tabIndex:e===i?0:-1,onClick:()=>n(i),onKeyDown:e=>{if(e.key!==`ArrowRight`&&e.key!==`ArrowLeft`&&e.key!==`Home`&&e.key!==`End`)return;let t=e.key===`Home`?0:e.key===`End`?W_.length-1:(a+(e.key===`ArrowRight`?1:W_.length-1))%W_.length;e.preventDefault(),n(W_[t]),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[t]?.focus()},children:[r(`architecture.view.${i}`),t[i]!==void 0&&(0,W.jsx)(`span`,{className:`architecture-tabs__count`,children:t[i]})]},i))})}function q_(e,t){return t.type===`select`?{...e,selections:{...e.selections,[t.select.view]:{scope:t.select.scope,id:t.select.id}}}:t.repositoryId===e.repositoryId&&t.commit===e.commit?e:{repositoryId:t.repositoryId,commit:t.commit,selections:{}}}function J_({repositoryId:e,github:t,moduleId:n,onModule:r,onSource:i,refreshGeneration:a,readMap:o,readHistory:s=A_,t:c}){let[l,u]=(0,I.useState)(`map`),[d,f]=(0,I.useReducer)(q_,{repositoryId:e,commit:null,selections:{}});d.repositoryId!==e&&f({type:`shown`,repositoryId:e,commit:null});let p=d.repositoryId===e?d.selections:{},m=(0,I.useCallback)(e=>f({type:`select`,select:e}),[]),h=M_(e),g=n===null?null:`${h}/${n}`,_=j_(n===null&&l===`modules`?h:null,ye,a),v=j_(g,be,a),[y,b]=(0,I.useState)(null),[x,S]=(0,I.useState)(null),[C,w]=(0,I.useState)(null),T=(0,I.useCallback)(t=>{b(n=>({repositoryId:e,value:{...n?.repositoryId===e?n.value:{},...t}}))},[e]),E=(0,I.useCallback)(t=>{S(t===null?null:{commit:t.commit,collectedAt:t.collectedAt,headRef:t.headRef,archctxVersion:t.archctxVersion}),t!==null&&f({type:`shown`,repositoryId:e,commit:t.commit}),t!==null&&T({map:t.modules,sequence:t.flows})},[T,e]),D=(0,I.useCallback)(e=>{w(e),e!==null&&T({history:e.total})},[T]),O=n===null?l===`modules`?_.value?.commit:l===`history`?void 0:x?.commit:v.value?.commit,k=n===null&&l!==`modules`&&l!==`history`?x:null,A=n===null&&l===`history`?C:null;return(0,I.useEffect)(()=>{i(A??(O===void 0?null:{commit:O,map:k===null?null:{collectedAt:k.collectedAt,headRef:k.headRef,archctxVersion:k.archctxVersion}}))},[A,O,k,i]),(0,I.useEffect)(()=>()=>i(null),[i]),(0,W.jsx)(`section`,{className:`architecture-workspace`,"aria-label":c(`nav.architecture`),children:n===null?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(K_,{view:l,counts:y?.repositoryId===e?y.value:{},onChange:u,t:c}),(0,W.jsx)(`div`,{id:`architecture-view`,className:`architecture-view`,role:`tabpanel`,"aria-labelledby":`architecture-tab-${l}`,children:l===`history`?(0,W.jsx)(Sm,{path:N_(e),github:t,read:s,refreshGeneration:a,selection:p.history??null,select:m,onSummary:D,t:c}):l===`modules`?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(F_,{read:_,loading:`architecture.loading`,t:c}),_.value&&(0,W.jsx)(R_,{index:_.value,onModule:r,t:c})]}):(0,W.jsx)(f_,{repositoryId:e,view:G_[l],read:o,refreshGeneration:a,selections:p,select:m,onModule:r,onSummary:E,t:c})})]}):(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`div`,{children:(0,W.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>r(null),children:c(`architecture.back`)})}),(0,W.jsx)(F_,{read:v,loading:`architecture.module.loading`,t:c}),v.value&&g&&(0,W.jsx)(U_,{detail:v.value,base:g,generation:a,onModule:r,t:c})]})})}export{J_ as ArchitectureWorkspace};