repo-harness-operator-web 0.37.4 → 0.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ArchitectureWorkspace-C08Cz9I0.js → ArchitectureWorkspace-DwYcXNar.js} +3 -3
- package/dist/assets/{DocsPage-vqQNdYJU.js → DocsPage-D3mGkuaa.js} +3 -3
- package/dist/assets/{abnfDiagram-S7VZAUFO-DBEIBD2p.js → abnfDiagram-S7VZAUFO-C_D7PMBr.js} +1 -1
- package/dist/assets/{architecture-WOLXFQ4H-BaorlmPK.js → architecture-WOLXFQ4H-BrckpEDe.js} +1 -1
- package/dist/assets/{architectureDiagram-YGSQEFNW-C8ZvW9UE.js → architectureDiagram-YGSQEFNW-Bfpn5b35.js} +1 -1
- package/dist/assets/{blockDiagram-APKKGZFW-CjekUXF3.js → blockDiagram-APKKGZFW-PwPU306U.js} +1 -1
- package/dist/assets/{c4Diagram-KJ2TOQU5-BWM85FBu.js → c4Diagram-KJ2TOQU5-DpA8lx9q.js} +1 -1
- package/dist/assets/{chunk-6MUBBAK2-IrJ-CERh.js → chunk-6MUBBAK2-oTuVksv8.js} +1 -1
- package/dist/assets/{chunk-AXFCVDMN-DDV9QrlB.js → chunk-AXFCVDMN-Bg-W-7iw.js} +1 -1
- package/dist/assets/{chunk-BG4553SI-DXWrTBgV.js → chunk-BG4553SI-B8pTqwcT.js} +1 -1
- package/dist/assets/{chunk-DQASFODM-DIA1vn3s.js → chunk-DQASFODM-BKAJI2G3.js} +1 -1
- package/dist/assets/{chunk-HFQBQIA3-DouiOssD.js → chunk-HFQBQIA3--gB9-sPx.js} +1 -1
- package/dist/assets/{chunk-KQLB2F66-Bvri8Z1N.js → chunk-KQLB2F66-CXWBEtX8.js} +1 -1
- package/dist/assets/{chunk-KS47KZWR-CpUTW3ZG.js → chunk-KS47KZWR-ngyF6MAV.js} +1 -1
- package/dist/assets/{chunk-LEVMRMFU-D6tTo6Ec.js → chunk-LEVMRMFU-0iOB1h_L.js} +1 -1
- package/dist/assets/{chunk-M57EVK23-DdoE6qSV.js → chunk-M57EVK23-D400tf6N.js} +1 -1
- package/dist/assets/{chunk-OY52VR5R-CaLuWnnA.js → chunk-OY52VR5R-5dm9FiEx.js} +1 -1
- package/dist/assets/{chunk-QB3YPZ4I-AtSR54RF.js → chunk-QB3YPZ4I-EyNzpLdg.js} +1 -1
- package/dist/assets/{chunk-R3KSYZAL-DzrDNr1R.js → chunk-R3KSYZAL-PgCM06md.js} +1 -1
- package/dist/assets/{chunk-STOXU5M4-CdxbtmlW.js → chunk-STOXU5M4-DdDDKUyK.js} +1 -1
- package/dist/assets/{chunk-TU62E6Q5-DaoPquj8.js → chunk-TU62E6Q5-CBvGKtAZ.js} +1 -1
- package/dist/assets/{chunk-X4PVCEUW-Bk0BE3ro.js → chunk-X4PVCEUW-C4hrOD66.js} +1 -1
- package/dist/assets/{classDiagram-v2-L25IHNXF-BHfkHpFL.js → classDiagram-v2-L25IHNXF-uUS4EgD_.js} +1 -1
- package/dist/assets/cynefin-EF2NZ3EQ-BDLhN8yn.js +1 -0
- package/dist/assets/{cynefinDiagram-L36ESFBY-D6fA-0UO.js → cynefinDiagram-L36ESFBY-ChrLkbxU.js} +1 -1
- package/dist/assets/{dagre-SPEB5RXH-DYO1eB5s.js → dagre-SPEB5RXH-BzORIw_N.js} +1 -1
- package/dist/assets/{diagram-3B7GL73J-BOS3SlQY.js → diagram-3B7GL73J-BsDphbnF.js} +1 -1
- package/dist/assets/{diagram-DNEMPZML-NaI0VGQ2.js → diagram-DNEMPZML-C8Ihyoz2.js} +1 -1
- package/dist/assets/{diagram-L3MUGCDN-BnrZCRT5.js → diagram-L3MUGCDN-DLY-fI81.js} +1 -1
- package/dist/assets/{diagram-LA4NIPWU-Bwa1nY-M.js → diagram-LA4NIPWU-B7CKD51B.js} +1 -1
- package/dist/assets/{diagram-MHCOC4E2-Dk_C1N9q.js → diagram-MHCOC4E2-__VlEqOJ.js} +1 -1
- package/dist/assets/{diagram-XPFHEONP-D5jODu4f.js → diagram-XPFHEONP-CKUB95fr.js} +1 -1
- package/dist/assets/{ebnfDiagram-UZSYDL2S-DdIebCF2.js → ebnfDiagram-UZSYDL2S-D6D2WUGb.js} +1 -1
- package/dist/assets/{elk-XV6XMXQE-BbnnCyre.js → elk-XV6XMXQE-BVGaf7QD.js} +1 -1
- package/dist/assets/{erDiagram-EYBAPDEH-CH2nCqC1.js → erDiagram-EYBAPDEH-Cls6dnTe.js} +1 -1
- package/dist/assets/{eventmodeling-K75KTNOO-m5iysAx8.js → eventmodeling-K75KTNOO-CBMmTJte.js} +1 -1
- package/dist/assets/flowDiagram-MALGAFMO-Djslx3E5.js +1 -0
- package/dist/assets/{ganttDiagram-23REXITY-vBHEp_iE.js → ganttDiagram-23REXITY-DA7t0PHc.js} +1 -1
- package/dist/assets/gitGraph-VSP46ZUC-D4tvRJcQ.js +1 -0
- package/dist/assets/{gitGraphDiagram-STJD7YCW-fkcRaAYb.js → gitGraphDiagram-STJD7YCW-CPaA623C.js} +1 -1
- package/dist/assets/index-CGL3FY4V.css +1 -0
- package/dist/assets/index-MzH6C6xf.js +41 -0
- package/dist/assets/info-OHQRW6UA-Y-3eTqHS.js +1 -0
- package/dist/assets/{infoDiagram-KBXO4MBG-Cjr_tHho.js → infoDiagram-KBXO4MBG-BFyj_S64.js} +1 -1
- package/dist/assets/{ishikawaDiagram-M35NCXHK-DYuTJ9yl.js → ishikawaDiagram-M35NCXHK--rsObY3d.js} +1 -1
- package/dist/assets/{journeyDiagram-OPLOXDXO-BLOuZjUy.js → journeyDiagram-OPLOXDXO-6rDRWmOt.js} +1 -1
- package/dist/assets/{kanban-definition-BZKZHSQY-D9RIROyu.js → kanban-definition-BZKZHSQY-BLIZmmnA.js} +1 -1
- package/dist/assets/{line-DaeU9Jky.js → line-N9kZb7gs.js} +1 -1
- package/dist/assets/{mermaid-parser.core-sDSQcEXe.js → mermaid-parser.core-CuaxSj2k.js} +3 -3
- package/dist/assets/{mermaid.core-DXZlQakD.js → mermaid.core-DDsoGIP7.js} +4 -4
- package/dist/assets/{mindmap-definition-I2QAS2VK-CPmp_YEx.js → mindmap-definition-I2QAS2VK-RIZcARRF.js} +1 -1
- package/dist/assets/packet-JDAUHWVQ-CQAb8g0k.js +1 -0
- package/dist/assets/{pegDiagram-FD4XPPHP-EMo5cruW.js → pegDiagram-FD4XPPHP-CxfkNWQ7.js} +1 -1
- package/dist/assets/pie-XZMESJXO-VXh7osV3.js +1 -0
- package/dist/assets/{pieDiagram-J4AKIIQI-pk-dfaD7.js → pieDiagram-J4AKIIQI-CprnmNbe.js} +1 -1
- package/dist/assets/{quadrantDiagram-XTYBLID2-DW4jCNOA.js → quadrantDiagram-XTYBLID2-PTqL2ek4.js} +1 -1
- package/dist/assets/radar-ABXABTNO-B4YIx0GU.js +1 -0
- package/dist/assets/railroad-I3PHUGI6-C-0rV13h.js +1 -0
- package/dist/assets/{railroad-abnf-LNEFI6M7-O29fviJ5.js → railroad-abnf-LNEFI6M7-z9EpBBjJ.js} +1 -1
- package/dist/assets/{railroad-ebnf-DWYD2UWJ-BIdxdiO1.js → railroad-ebnf-DWYD2UWJ-BbLuE-ss.js} +1 -1
- package/dist/assets/{railroad-peg-JR7BVNR7-Dh339z7-.js → railroad-peg-JR7BVNR7-CAHCSZUz.js} +1 -1
- package/dist/assets/{railroadDiagram-MRQ6NCDL-DCAgrcwT.js → railroadDiagram-MRQ6NCDL-BfH4nAjd.js} +1 -1
- package/dist/assets/{requirementDiagram-Y7LWUY3S-fwr7AMzB.js → requirementDiagram-Y7LWUY3S-CvIJ2THD.js} +1 -1
- package/dist/assets/{sankeyDiagram-WGJFYUXA-CyHjbYTX.js → sankeyDiagram-WGJFYUXA-Dn0lNNo0.js} +1 -1
- package/dist/assets/{sequenceDiagram-5NDRBG5M-2T1UvBgp.js → sequenceDiagram-5NDRBG5M-Cd80VnKA.js} +1 -1
- package/dist/assets/{stateDiagram-v2-FJ4FJNEA-Fgi-LXC1.js → stateDiagram-v2-FJ4FJNEA-OOVeFWiV.js} +1 -1
- package/dist/assets/{swimlanes-UMQ2AFYF-Dn8RMd0d.js → swimlanes-UMQ2AFYF-7D0i7Rrg.js} +1 -1
- package/dist/assets/swimlanesDiagram-OMPLPG4O-BqM-D12r.js +8 -0
- package/dist/assets/{timeline-definition-SEUHKTQE-CJC2LMdE.js → timeline-definition-SEUHKTQE-Bd-lNn06.js} +1 -1
- package/dist/assets/treeView-D4JQ5SDB-K3BXb4UC.js +1 -0
- package/dist/assets/treemap-SAJKECNS-ul51eE0X.js +1 -0
- package/dist/assets/{usecaseDiagram-AFA6YXN4-q_8TzeDd.js → usecaseDiagram-AFA6YXN4-DS_3pApn.js} +1 -1
- package/dist/assets/{vennDiagram-NNMJR3RB-9tbgzSHf.js → vennDiagram-NNMJR3RB-Ddo08CPM.js} +1 -1
- package/dist/assets/wardley-7MLQ67FV-CF1nNV_p.js +1 -0
- package/dist/assets/{wardleyDiagram-S7YFUSEH-Bj4zD6JF.js → wardleyDiagram-S7YFUSEH-B4OnQ-03.js} +1 -1
- package/dist/assets/{xychartDiagram-GGNKY7IX-Dn1yGw5C.js → xychartDiagram-GGNKY7IX-DA1f8IsD.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +1 -1
- package/dist/assets/cynefin-EF2NZ3EQ-D99nlQ4o.js +0 -1
- package/dist/assets/flowDiagram-MALGAFMO-CedxZedm.js +0 -1
- package/dist/assets/gitGraph-VSP46ZUC-DzzGTHrr.js +0 -1
- package/dist/assets/index-D8L3EgDU.css +0 -1
- package/dist/assets/index-NYT5wXhs.js +0 -41
- package/dist/assets/info-OHQRW6UA-DCCEPRXW.js +0 -1
- package/dist/assets/packet-JDAUHWVQ-BcG0_kef.js +0 -1
- package/dist/assets/pie-XZMESJXO-l9rDKPIV.js +0 -1
- package/dist/assets/radar-ABXABTNO-CF7N9ZyT.js +0 -1
- package/dist/assets/railroad-I3PHUGI6-iIuT2BRt.js +0 -1
- package/dist/assets/swimlanesDiagram-OMPLPG4O-CPNl06QX.js +0 -8
- package/dist/assets/treeView-D4JQ5SDB-Cev-3e5I.js +0 -1
- package/dist/assets/treemap-SAJKECNS-DERE_DGE.js +0 -1
- package/dist/assets/wardley-7MLQ67FV-XWlFrBZM.js +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,C as n,E as r,O as i,S as a,_ as o,b as s,c,g as l,h as u,j as d,l as f,n as p,o as m,p as h,v as g,x as _,y as v}from"./index-NYT5wXhs.js";import{C as y,S as b,T as x,_ as S,b as C,i as w,n as T,r as E,t as D,v as O,w as k,x as A,y as j}from"./src-C_gRsKqw.js";import{t as M}from"./value-CHmTzbgv.js";var N=e=>()=>e;function P(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}})}P.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function F(e){return!e.ctrlKey&&!e.button}function ee(){return this.parentNode}function te(e,t){return t??{x:e.x,y:e.y}}function I(){return navigator.maxTouchPoints||`ontouchstart`in this}function ne(){var e=F,t=ee,n=te,r=I,i={},a=x(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,C).on(`touchend.drag touchcancel.drag`,v).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&&(k(n.view).on(`mousemove.drag`,m,A).on(`mouseup.drag`,h,A),S(n.view),b(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(j(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){k(e.view).on(`mousemove.drag mouseup.drag`,null),O(e.view,l),j(e),i.mouse(`end`,e)}function g(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]))&&(b(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(j(e),a(`drag`,e,t[r]))}function v(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])&&(b(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=y(l||r,t),p,m,h;if((h=n.call(e,new P(`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 g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=y(l||a,t),_=o}u.call(r,e,new P(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:N(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:N(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:N(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:N(!!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 L=e(d(),1);function re(e){return e.kind===`group`}var ie=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,ae=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,oe=[`accepted`,`acknowledged`,`deferred`,`resolved`,`rejected`,`waived`],R=e=>typeof e==`string`,se=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ce=e=>se(e)&&e>0,le=e=>typeof e==`boolean`,ue=e=>t=>R(t)&&e.test(t),z=(...e)=>t=>e.includes(t),de=e=>t=>t===null||e(t),B=e=>t=>Array.isArray(t)&&t.every(e),V=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]))},fe=e=>t=>R(t)&&t.length>0&&t.length<=e&&t===t.trim()&&!/[\x00-\x1f\x7f]/u.test(t),pe=e=>!e||typeof e!=`object`||Array.isArray(e)?!1:Object.entries(e).every(([e,t])=>fe(128)(e)&&(t===null||typeof t==`number`&&Number.isFinite(t))),me=ue(/^[0-9a-f]{64}$/),he=ue(ae),ge=ue(ie),_e=ue(/^recommendation\.[0-9a-f]{16}$/u),ve=ue(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/u),ye=e=>R(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),be=V({model_valid:z(`valid`,`invalid`,`unknown`),generated_summary:z(`fresh`,`stale`,`unknown`),section3:z(`present`,`pending`)}),xe=V({id:R,from:R,to:R,label:R,evidence:V({entrypointId:R,sourceSymbol:R,sinkId:R})}),Se=e=>V({id:R,capabilityId:ge,name:R,applicability:z(`not-applicable`),rationale:R})(e)||V({id:R,capabilityId:ge,name:R,applicability:z(`required`),participants:B(V({id:R,nodeId:R})),steps:B(xe),outcomes:B(V({id:R,kind:z(`success`,`error`),label:R,steps:B(xe),terminal:V({participant:R,label:R})}))})(e),Ce=e=>typeof e==`string`&&e.length>0&&e!==`group`,we=V({include:B(R),exclude:B(R)}),Te=e=>V({id:R,kind:Ce,name:R,role:z(`center`,`child`,`caller`,`callee`)})(e)||V({id:R,kind:z(`group`),role:z(`caller`,`callee`),count:ce,members:B(V({id:R,name:R}))})(e),Ee=V({schema_version:z(`repo-harness.architecture-modules.v1`),commit:he,modules:B(V({id:ge,domain:R,name:R,status:R,components:se,state:be}))}),De=V({schema_version:z(`repo-harness.architecture-module.v1`),commit:he,module:V({id:ge,name:R,status:R,summary:R,responsibilities:B(R),notes:B(R),source:we,verification:B(R),entrypoints:B(V({id:R,path:ye,symbols:B(V({name:R,sinks:B(V({id:R,path:ye,symbol:R}))}))})),components:B(V({id:R,kind:Ce,name:R,summary:R,source:we}))}),graph:V({center:ge,nodes:B(Te),edges:B(V({source:R,target:R,intent:R,relation_kind:R,direction:z(`directed`)}))}),flows:B(Se),section3:de(R),linked_docs:B(V({path:ye,kind:z(`contract`,`plan`),status:de(R)})),state:be}),Oe=V({schema_version:z(`repo-harness.module-review-prompt.v1`),prompt_version:R,package_version:R,repository_id:ue(/^repo_[0-9a-f]{16}$/),capability_id:ge,commit:he,mode:z(`module`,`diff`),base:de(he),head:de(he),worktree_dirty_paths:B(ye),dirty_content_sha256:de(me),model_sha256:me,doc_sha256:de(me),sources:B(V({path:ye,sha256:me,bytes:se,class:z(`required`,`optional`),disposition:z(`included`,`omitted`,`chunked`)})),budget:V({input_cap_bytes:ce,used_bytes:se,incomplete:le,omitted_sections:B(R)}),shard:V({index:ce,count:ce,bytes:se}),full_prompt_sha256:me,prompt:R,digest:me}),ke=V({accepted:se,acknowledged:se,deferred:se,resolved:se,rejected:se,waived:se}),Ae=V({recommendation_id:_e,category:z(`structural_observation`,`refactor_proposal`),kind:de(z(...g)),subject:fe(512),affected_node_ids:B(fe(256)),status:z(...v),metrics:de(pe),reason:fe(1024),decided_at:ve,head_sha:he,cli_verify_command:fe(128)}),je=V({schema_version:z(`repo-harness.architecture-refactor.v1`),adopted:le,counts:ke,decisions:B(Ae)});function Me(e){return`rh arch refactor verify ${e} --json`}function Ne(e,t){let n=oe.indexOf(e.status)-oe.indexOf(t.status);return n===0?e.recommendation_id<t.recommendation_id?-1:+(e.recommendation_id>t.recommendation_id):n}function Pe(e){if(!Ee(e))throw Error(`architecture_module_index_invalid`);return e}function Fe(e){if(!De(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=>re(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function Ie(e){if(!Oe(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}function Le(e){if(!je(e))throw Error(`architecture_refactor_decisions_invalid`);let t=e;if(!t.adopted&&t.decisions.length>0)throw Error(`architecture_refactor_decisions_invalid`);let n=new Set;for(let e=0;e<t.decisions.length;e++){let r=t.decisions[e];if(n.has(r.recommendation_id)||(n.add(r.recommendation_id),r.category===`structural_observation`!=(r.kind!==null))||r.cli_verify_command!==Me(r.recommendation_id)||r.affected_node_ids.some((e,t)=>t>0&&e<=r.affected_node_ids[t-1])||e>0&&Ne(t.decisions[e-1],r)>=0)throw Error(`architecture_refactor_decisions_invalid`)}for(let e of oe)if(t.counts[e]!==t.decisions.filter(t=>t.status===e).length)throw Error(`architecture_refactor_decisions_invalid`);return t}var Re=Object.defineProperty,ze=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Be=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},Ve=(e,t,n)=>ze(e,typeof t==`symbol`?t:t+``,n),He={};Be(He,{Graph:()=>Dt,alg:()=>tt});var Ue=Object.defineProperty,We=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Ge=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=Je(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=Ye(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ke(this._preds[a],i),Ke(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?Xe(this._isDirected,e):Je(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?Xe(this._isDirected,e):Je(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Xe(this._isDirected,e):Je(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],qe(this._preds[t],e),qe(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 Ke(e,t){e[t]?e[t]++:e[t]=1}function qe(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Je(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 Ye(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 Xe(e,t){return Je(e,t.v,t.w,t.name)}We({},{read:()=>et,write:()=>Ze});function Ze(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Qe(e),edges:$e(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Qe(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 $e(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 et(e){let t=new Ge(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 tt={};We(tt,{CycleException:()=>gt,bellmanFord:()=>rt,components:()=>at,dijkstra:()=>ct,dijkstraAll:()=>ut,findCycles:()=>ft,floydWarshall:()=>mt,isAcyclic:()=>vt,postorder:()=>St,preorder:()=>Ct,prim:()=>wt,shortestPaths:()=>Tt,tarjan:()=>dt,topsort:()=>_t});var nt=()=>1;function rt(e,t,n,r){return it(e,String(t),n||nt,r||function(t){return e.outEdges(t)??[]})}function it(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 at(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 ot=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}},st=()=>1;function ct(e,t,n,r){return lt(e,String(t),n||st,r||function(t){return e.outEdges(t)??[]})}function lt(e,t,n,r){let i={},a=new ot,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 ut(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ct(e,i,t,n),r},{})}function dt(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 ft(e){return dt(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var pt=()=>1;function mt(e,t,n){return ht(e,t||pt,n||function(t){return e.outEdges(t)??[]})}function ht(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 gt=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function _t(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new gt;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 gt;return r}function vt(e){try{_t(e)}catch(e){if(e instanceof gt)return!1;throw e}return!0}function yt(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=bt(e,t,n===`post`,o,a,r,i)}),i}function bt(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=bt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function xt(e,t,n){return yt(e,t,n,function(e,t){return e.push(t),e},[])}function St(e,t){return xt(e,t,`post`)}function Ct(e,t){return xt(e,t,`pre`)}function wt(e,t){var n;let r=new Ge,i={},a=new ot,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 Tt(e,t,n,r){return Et(e,t,n,r??(t=>e.outEdges(t)??[]))}function Et(e,t,n,r){if(n===void 0)return ct(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 rt(e,t,n,r)}return ct(e,t,n,r)}var Dt=Ge;function Ot(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ut(r);return n.dummy=t,e.setNode(i,n),i}function kt(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 At(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 jt(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 Mt(e){let t=Wt(zt(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 Nt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Rt(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Pt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Rt(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 Ft(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Ot(e,`border`,i,t)}function It(e,t=Lt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Lt=65535;function Rt(e,t){return t.length>Lt?e(...It(t).map(t=>e(...t))):e(...t)}function zt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Rt(Math.max,t)}function Bt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Vt(e,t){return t()}var Ht=0;function Ut(e){return e+(``+ ++Ht)}function Wt(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 Gt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Kt(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 qt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Jt=`\0`;function Yt(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 Xt=class{constructor(){Ve(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Zt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Zt(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,Qt)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Zt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Qt(e,t){if(e!==`_next`&&e!==`_prev`)return t}var $t=Xt,en=()=>1;function tn(e,t){if(e.nodeCount()<=1)return[];let n=an(e,t||en);return nn(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function nn(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)rn(e,t,n,o);for(;o=i.dequeue();)rn(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(rn(e,t,n,o,!0)||[]);break}}}return r}function rn(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,on(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,on(t,n,o)}),e.removeNode(r.v),o}function an(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=sn(i+r+3).map(()=>new $t),o=r+1;return n.nodes().forEach(e=>{on(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function on(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 sn(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function cn(e,t){(e.graph().acyclicer===`greedy`?tn(e,n(e)):ln(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,Ut(`rev`))});function n(e){return t=>e.edge(t).weight}}function ln(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&&dn(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 un(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 dn(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 fn(e){e.graph().dummyChains=[],e.edges().forEach(t=>pn(e,t))}function pn(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=Ot(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 mn(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 hn(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=Rt(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function gn(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var _n=vn;function vn(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(;yn(t,e)<i&&(a=bn(t,e),a);)o=t.hasNode(a.v)?gn(e,a):-gn(e,a),xn(t,e,o);return t}function yn(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)&&!gn(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function bn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=gn(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function xn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Sn,postorder:Cn}=tt,wn=Tn;Tn.initLowLimValues=kn,Tn.initCutValues=En,Tn.calcCutValue=On,Tn.leaveEdge=jn,Tn.enterEdge=Mn,Tn.exchangeEdges=Nn;function Tn(e){e=kt(e),hn(e);let t=_n(e);kn(t),En(t,e);let n,r;for(;n=jn(t);)r=Mn(t,e,n),Nn(t,e,n,r)}function En(e,t){let n=Cn(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=On(e,t,n)}function On(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,Fn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function kn(e,t){arguments.length<2&&(t=e.nodes()[0]),An(e,{},1,t)}function An(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=An(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function jn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Mn(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===In(e,e.node(t.v),s)&&c!==In(e,e.node(t.w),s)).reduce((e,n)=>gn(t,n)<gn(t,e)?n:e)}function Nn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),kn(e),En(e,t),Pn(e,t)}function Pn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Sn(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 Fn(e,t,n){return e.hasEdge(t,n)}function In(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Ln=Rn;function Rn(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Vn(e);break;case`tight-tree`:Bn(e);break;case`longest-path`:zn(e);break;case`none`:break;default:Vn(e)}}var zn=hn;function Bn(e){hn(e),_n(e)}function Vn(e){wn(e)}var Hn=Un;function Un(e){let t=Gn(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Wn(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 Wn(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 Gn(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(Jt).forEach(r),t}function Kn(e){let t=Ot(e,`root`,{},`_root`),n=Jn(e),r=Object.values(n),i=Rt(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Yn(e)+1;e.children(Jt).forEach(r=>{qn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function qn(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=Ft(e,`_bt`),l=Ft(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{qn(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 Jn(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(Jt).forEach(e=>n(e,1)),t}function Yn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Xn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Zn=Qn;function Qn(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)$n(e,`borderLeft`,`_bl`,n,i,t),$n(e,`borderRight`,`_br`,n,i,t)}}e.children(Jt).forEach(t)}function $n(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Ot(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function er(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&nr(e)}function tr(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&ir(e),(t===`lr`||t===`rl`)&&(or(e),nr(e))}function nr(e){e.nodes().forEach(t=>rr(e.node(t))),e.edges().forEach(t=>rr(e.edge(t)))}function rr(e){let t=e.width;e.width=e.height,e.height=t}function ir(e){e.nodes().forEach(t=>ar(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ar),Object.hasOwn(r,`y`)&&ar(r)})}function ar(e){e.y=-e.y}function or(e){e.nodes().forEach(t=>sr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(sr),Object.hasOwn(r,`x`)&&sr(r)})}function sr(e){let t=e.x;e.x=e.y,e.y=t}function cr(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Wt(Rt(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 Yt(t,e.node(n),e.node(r))}return a}function lr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=ur(e,t[r-1],t[r]);return n}function ur(e,t,n){let r=qt(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 dr(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 fr(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))}),pr(Object.values(n).filter(e=>!e.indegree))}function pr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&mr(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=>Gt(e,[`vs`,`i`,`barycenter`,`weight`]))}function mr(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 hr(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=Bt(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(_r(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=gr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=gr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function gr(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 _r(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=Yt(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 vr(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=dr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=vr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&br(t,r)}});let h=fr(m,n);yr(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=hr(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 yr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function br(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 xr(e,t,n,r){r||=e.nodes();let i=Sr(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 Sr(e){let t;for(;e.hasNode(t=Ut(`_root`)););return t}function Cr(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 wr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,wr);return}let r=zt(e),i=Tr(e,Wt(1,r+1),`inEdges`),a=Tr(e,Wt(r-1,-1,-1),`outEdges`),o=cr(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){Er(t%2?i:a,t%4>=2,l,n),o=Mt(e);let u=lr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Dr(e,c)}function Tr(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 xr(e,t,n,r.get(t)||[])})}function Er(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}=vr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Cr(e,a,s.vs)})}function Dr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Or(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=Ar(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)&&jr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function kr(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){Wt(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)&&jr(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 Ar(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function jr(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 Mr(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 Nr(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)||Hr(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=>Hr(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&&!Mr(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 Pr(e,t,n,r,i=!1){let a={},o=Fr(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 Fr(e,t,n,r){let i=new Dt,a=e.graph(),o=Br(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 Ir(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Vr(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 Lr(e,t){let n=Object.values(t),r=Rt(Math.min,n),i=Rt(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-Rt(Math.min,c);a!==`l`&&(l=i-Rt(Math.max,c)),l&&(e[o]=Kt(s,e=>e+l))})})}function Rr(e,t=void 0){let n=e.ul;return n?Kt(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 zr(e,t){let n=Mt(e),r=Object.assign(Or(e,n),kr(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=Nr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Pr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Kt(c,e=>-e)),i[o+n]=c})}),Lr(i,Ir(e,i)),Rr(i,e.graph().align)}function Br(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 Vr(e,t){return e.node(t).width}function Hr(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 Ur(e,t){e=At(e),Wr(e),Object.entries(zr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Wr(e){let t=Mt(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 Gr=new WeakMap;function Kr(e,t={}){return Jr(e,Vt,t),e}function qr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Jr(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=qr(e,t.v,r),i=qr(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)}))}}),Jr(o,t,n);let l=oi(o);Xr(l,t,n,null),Zr(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=oi(e),g=Xr(h,t,n,Gr.get(e)??null);Gr.set(e,g),Zr(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))}),Yr(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}}),Yr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function Yr(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 Xr(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`,()=>si(e)),t(` removeSelfEdges`,()=>gi(e)),t(` acyclic`,()=>cn(e,s)),t(` nestingGraph.run`,()=>Kn(e)),t(` rank`,()=>Ln(At(e))),t(` injectEdgeLabelProxies`,()=>ci(e)),t(` removeEmptyRanks`,()=>Pt(e)),t(` nestingGraph.cleanup`,()=>Xn(e)),t(` normalizeRanks`,()=>Nt(e)),t(` assignRankMinMax`,()=>li(e)),t(` removeEdgeLabelProxies`,()=>ui(e)),t(` normalize.run`,()=>fn(e)),t(` parentDummyChains`,()=>Hn(e)),t(` addBorderSegments`,()=>Zn(e)),t(` order`,()=>wr(e,n,c)),t(` insertSelfEdges`,()=>_i(e)),t(` adjustCoordinateSystem`,()=>er(e)),t(` position`,()=>Ur(e,n.corePath)),t(` positionSelfEdges`,()=>vi(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>hi(e)),t(` normalize.undo`,()=>mn(e)),t(` fixupEdgeLabelCoords`,()=>pi(e)),t(` undoCoordinateSystem`,()=>tr(e)),t(` translateGraph`,()=>di(e)),t(` assignNodeIntersects`,()=>fi(e)),t(` reversePoints`,()=>mi(e)),t(` acyclic.undo`,()=>un(e)),{graph:e,rawNodes:l}}function Zr(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 Qr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],$r={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ei=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],ti=[`width`,`height`,`rank`],ni={width:0,height:0},ri=[`minlen`,`weight`,`width`,`height`,`labeloffset`],ii={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},ai=[`labelpos`];function oi(e){let t=new Dt({multigraph:!0,compound:!0}),n=bi(e.graph());return t.setGraph(Object.assign({},$r,yi(n,Qr),Gt(n,ei))),e.nodes().forEach(n=>{let r=yi(bi(e.node(n)),ti);Object.keys(ni).forEach(e=>{r[e]===void 0&&(r[e]=ni[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=bi(e.edge(n));t.setEdge(n,Object.assign({},ii,yi(r,ri),Gt(r,ai)))}),t}function si(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 ci(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Ot(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function li(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 ui(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 di(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 fi(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(jt(r,a)),n.points.push(jt(i,o))})}function pi(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 mi(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function hi(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 gi(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 _i(e){Mt(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=>{Ot(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 vi(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 yi(e,t){return Kt(Gt(e,t),Number)}function bi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var xi=7,Si=16,Ci=1.5,wi=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function Ti(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&wi.has(r)?2:1;return Math.ceil(n*xi*(t===`title`?Ci:1))}var Ei=12,Di=e=>Math.round(e*10)/10,Oi=e=>Math.round(e*100)/100,ki=(e,t)=>[Oi((e[0]+t[0])/2),Oi((e[1]+t[1])/2)],Ai=([e,t])=>`${e} ${t}`;function ji(e){let t=e.length-1;if(t===1)return`M${Ai(e[0])} L${Ai(e[1])}`;let n=[`M${Ai(e[0])}`,`L${Ai(ki(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${Ai(e[r])} ${Ai(ki(e[r],e[r+1]))}`);return n.push(`L${Ai(e[t])}`),n.join(` `)}var Mi=16;function Ni(e,t,n){return Array.from({length:Mi},(r,i)=>{let a=(i+1)/Mi,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 Pi=e=>e.slice(1).map((t,n)=>[e[n],t]);function Fi(e,t,n){let r=Ti(e,`label`);return{text:e,x:Di(t[0]-r/2),y:Di(t[1]-Si/2),width:r,height:Si,route:n}}function Ii(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 Li(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 Ri(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 zi(e,t,n){let r=Ri(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var Bi=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),Vi=e=>[[e.x-Ei,e.y-Ei],[e.x+e.width+Ei,e.y-Ei],[e.x-Ei,e.y+e.height+Ei],[e.x+e.width+Ei,e.y+e.height+Ei]],Hi=(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 Ui(e,t,n){let r=[e,t,...n.flatMap(Vi).filter(e=>!n.some(t=>Hi(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]+Bi(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>zi(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 Wi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>zi(n,i,e))?[n]:(Ui(n,i,t)??[n,i]).slice(0,-1)})}function Gi(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 Ki(e,t,n){let r=Math.min(n/Math.max(Bi(e,t),.01),.25);return[Di(e[0]+(t[0]-e[0])*r),Di(e[1]+(t[1]-e[1])*r)]}function qi(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&&Pi([ki(n[e-1],n[e]),...Ni(ki(n[e-1],n[e]),n[e],ki(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>zi(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Ki(t,n[i-1],r),t,Ki(t,n[i+1],r)]:[t])}return n}function Ji(e,t){return Gi(qi(Wi(e,t),t))}function Yi(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 Xi(e,t,n,r=[]){let i=Yi({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 Zi(e,t=!0){let n=new He.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);Kr(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?Ji(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Xi(r,i,e.margin)}}var Qi=`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}`,$i={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}`},ea=e=>e.replace(/[&<>"]/gu,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]);function ta(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${ea(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${ea(t)}</text>`).join(``)}function na(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})">${ta(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="${ji(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">${ea(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries($i).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>${Qi}${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(`
|
|
1
|
+
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,C as n,E as r,O as i,S as a,_ as o,b as s,c,g as l,h as u,j as d,l as f,n as p,o as m,p as h,v as g,x as _,y as v}from"./index-MzH6C6xf.js";import{C as y,S as b,T as x,_ as S,b as C,i as w,n as T,r as E,t as D,v as O,w as k,x as A,y as j}from"./src-C_gRsKqw.js";import{t as M}from"./value-CHmTzbgv.js";var N=e=>()=>e;function P(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}})}P.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function F(e){return!e.ctrlKey&&!e.button}function ee(){return this.parentNode}function te(e,t){return t??{x:e.x,y:e.y}}function I(){return navigator.maxTouchPoints||`ontouchstart`in this}function ne(){var e=F,t=ee,n=te,r=I,i={},a=x(`start`,`drag`,`end`),o=0,s,c,l,u,d=0;function f(e){e.on(`mousedown.drag`,p).filter(r).on(`touchstart.drag`,g).on(`touchmove.drag`,_,C).on(`touchend.drag touchcancel.drag`,v).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&&(k(n.view).on(`mousemove.drag`,m,A).on(`mouseup.drag`,h,A),S(n.view),b(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(j(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){k(e.view).on(`mousemove.drag mouseup.drag`,null),O(e.view,l),j(e),i.mouse(`end`,e)}function g(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]))&&(b(n),c(`start`,n,i[s]))}function _(e){for(var t=e.changedTouches,n=t.length,r=0,a;r<n;++r)(a=i[t[r].identifier])&&(j(e),a(`drag`,e,t[r]))}function v(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])&&(b(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=y(l||r,t),p,m,h;if((h=n.call(e,new P(`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 g=d,_;switch(r){case`start`:i[c]=n,_=o++;break;case`end`:delete i[c],--o;case`drag`:d=y(l||a,t),_=o}u.call(r,e,new P(r,{sourceEvent:a,subject:h,target:f,identifier:c,active:_,x:d[0]+p,y:d[1]+m,dx:d[0]-g[0],dy:d[1]-g[1],dispatch:u}),s)}}return f.filter=function(t){return arguments.length?(e=typeof t==`function`?t:N(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:N(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:N(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:N(!!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 L=e(d(),1);function re(e){return e.kind===`group`}var ie=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,ae=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,oe=[`accepted`,`acknowledged`,`deferred`,`resolved`,`rejected`,`waived`],R=e=>typeof e==`string`,se=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,ce=e=>se(e)&&e>0,le=e=>typeof e==`boolean`,ue=e=>t=>R(t)&&e.test(t),z=(...e)=>t=>e.includes(t),de=e=>t=>t===null||e(t),B=e=>t=>Array.isArray(t)&&t.every(e),V=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]))},fe=e=>t=>R(t)&&t.length>0&&t.length<=e&&t===t.trim()&&!/[\x00-\x1f\x7f]/u.test(t),pe=e=>!e||typeof e!=`object`||Array.isArray(e)?!1:Object.entries(e).every(([e,t])=>fe(128)(e)&&(t===null||typeof t==`number`&&Number.isFinite(t))),me=ue(/^[0-9a-f]{64}$/),he=ue(ae),ge=ue(ie),_e=ue(/^recommendation\.[0-9a-f]{16}$/u),ve=ue(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/u),ye=e=>R(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),be=V({model_valid:z(`valid`,`invalid`,`unknown`),generated_summary:z(`fresh`,`stale`,`unknown`),section3:z(`present`,`pending`)}),xe=V({id:R,from:R,to:R,label:R,evidence:V({entrypointId:R,sourceSymbol:R,sinkId:R})}),Se=e=>V({id:R,capabilityId:ge,name:R,applicability:z(`not-applicable`),rationale:R})(e)||V({id:R,capabilityId:ge,name:R,applicability:z(`required`),participants:B(V({id:R,nodeId:R})),steps:B(xe),outcomes:B(V({id:R,kind:z(`success`,`error`),label:R,steps:B(xe),terminal:V({participant:R,label:R})}))})(e),Ce=e=>typeof e==`string`&&e.length>0&&e!==`group`,we=V({include:B(R),exclude:B(R)}),Te=e=>V({id:R,kind:Ce,name:R,role:z(`center`,`child`,`caller`,`callee`)})(e)||V({id:R,kind:z(`group`),role:z(`caller`,`callee`),count:ce,members:B(V({id:R,name:R}))})(e),Ee=V({schema_version:z(`repo-harness.architecture-modules.v1`),commit:he,modules:B(V({id:ge,domain:R,name:R,status:R,components:se,state:be}))}),De=V({schema_version:z(`repo-harness.architecture-module.v1`),commit:he,module:V({id:ge,name:R,status:R,summary:R,responsibilities:B(R),notes:B(R),source:we,verification:B(R),entrypoints:B(V({id:R,path:ye,symbols:B(V({name:R,sinks:B(V({id:R,path:ye,symbol:R}))}))})),components:B(V({id:R,kind:Ce,name:R,summary:R,source:we}))}),graph:V({center:ge,nodes:B(Te),edges:B(V({source:R,target:R,intent:R,relation_kind:R,direction:z(`directed`)}))}),flows:B(Se),section3:de(R),linked_docs:B(V({path:ye,kind:z(`contract`,`plan`),status:de(R)})),state:be}),Oe=V({schema_version:z(`repo-harness.module-review-prompt.v1`),prompt_version:R,package_version:R,repository_id:ue(/^repo_[0-9a-f]{16}$/),capability_id:ge,commit:he,mode:z(`module`,`diff`),base:de(he),head:de(he),worktree_dirty_paths:B(ye),dirty_content_sha256:de(me),model_sha256:me,doc_sha256:de(me),sources:B(V({path:ye,sha256:me,bytes:se,class:z(`required`,`optional`),disposition:z(`included`,`omitted`,`chunked`)})),budget:V({input_cap_bytes:ce,used_bytes:se,incomplete:le,omitted_sections:B(R)}),shard:V({index:ce,count:ce,bytes:se}),full_prompt_sha256:me,prompt:R,digest:me}),ke=V({accepted:se,acknowledged:se,deferred:se,resolved:se,rejected:se,waived:se}),Ae=V({recommendation_id:_e,category:z(`structural_observation`,`refactor_proposal`),kind:de(z(...g)),subject:fe(512),affected_node_ids:B(fe(256)),status:z(...v),metrics:de(pe),reason:fe(1024),decided_at:ve,head_sha:he,cli_verify_command:fe(128)}),je=V({schema_version:z(`repo-harness.architecture-refactor.v1`),adopted:le,counts:ke,decisions:B(Ae)});function Me(e){return`rh arch refactor verify ${e} --json`}function Ne(e,t){let n=oe.indexOf(e.status)-oe.indexOf(t.status);return n===0?e.recommendation_id<t.recommendation_id?-1:+(e.recommendation_id>t.recommendation_id):n}function Pe(e){if(!Ee(e))throw Error(`architecture_module_index_invalid`);return e}function Fe(e){if(!De(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=>re(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function Ie(e){if(!Oe(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}function Le(e){if(!je(e))throw Error(`architecture_refactor_decisions_invalid`);let t=e;if(!t.adopted&&t.decisions.length>0)throw Error(`architecture_refactor_decisions_invalid`);let n=new Set;for(let e=0;e<t.decisions.length;e++){let r=t.decisions[e];if(n.has(r.recommendation_id)||(n.add(r.recommendation_id),r.category===`structural_observation`!=(r.kind!==null))||r.cli_verify_command!==Me(r.recommendation_id)||r.affected_node_ids.some((e,t)=>t>0&&e<=r.affected_node_ids[t-1])||e>0&&Ne(t.decisions[e-1],r)>=0)throw Error(`architecture_refactor_decisions_invalid`)}for(let e of oe)if(t.counts[e]!==t.decisions.filter(t=>t.status===e).length)throw Error(`architecture_refactor_decisions_invalid`);return t}var Re=Object.defineProperty,ze=(e,t,n)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Be=(e,t)=>{for(var n in t)Re(e,n,{get:t[n],enumerable:!0})},Ve=(e,t,n)=>ze(e,typeof t==`symbol`?t:t+``,n),He={};Be(He,{Graph:()=>Dt,alg:()=>tt});var Ue=Object.defineProperty,We=(e,t)=>{for(var n in t)Ue(e,n,{get:t[n],enumerable:!0})},Ge=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=Je(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=Ye(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,Ke(this._preds[a],i),Ke(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?Xe(this._isDirected,e):Je(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?Xe(this._isDirected,e):Je(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Xe(this._isDirected,e):Je(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],qe(this._preds[t],e),qe(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 Ke(e,t){e[t]?e[t]++:e[t]=1}function qe(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Je(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 Ye(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 Xe(e,t){return Je(e,t.v,t.w,t.name)}We({},{read:()=>et,write:()=>Ze});function Ze(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Qe(e),edges:$e(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Qe(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 $e(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 et(e){let t=new Ge(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 tt={};We(tt,{CycleException:()=>gt,bellmanFord:()=>rt,components:()=>at,dijkstra:()=>ct,dijkstraAll:()=>ut,findCycles:()=>ft,floydWarshall:()=>mt,isAcyclic:()=>vt,postorder:()=>St,preorder:()=>Ct,prim:()=>wt,shortestPaths:()=>Tt,tarjan:()=>dt,topsort:()=>_t});var nt=()=>1;function rt(e,t,n,r){return it(e,String(t),n||nt,r||function(t){return e.outEdges(t)??[]})}function it(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 at(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 ot=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}},st=()=>1;function ct(e,t,n,r){return lt(e,String(t),n||st,r||function(t){return e.outEdges(t)??[]})}function lt(e,t,n,r){let i={},a=new ot,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 ut(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ct(e,i,t,n),r},{})}function dt(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 ft(e){return dt(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var pt=()=>1;function mt(e,t,n){return ht(e,t||pt,n||function(t){return e.outEdges(t)??[]})}function ht(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 gt=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function _t(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new gt;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 gt;return r}function vt(e){try{_t(e)}catch(e){if(e instanceof gt)return!1;throw e}return!0}function yt(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=bt(e,t,n===`post`,o,a,r,i)}),i}function bt(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=bt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function xt(e,t,n){return yt(e,t,n,function(e,t){return e.push(t),e},[])}function St(e,t){return xt(e,t,`post`)}function Ct(e,t){return xt(e,t,`pre`)}function wt(e,t){var n;let r=new Ge,i={},a=new ot,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 Tt(e,t,n,r){return Et(e,t,n,r??(t=>e.outEdges(t)??[]))}function Et(e,t,n,r){if(n===void 0)return ct(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 rt(e,t,n,r)}return ct(e,t,n,r)}var Dt=Ge;function Ot(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Ut(r);return n.dummy=t,e.setNode(i,n),i}function kt(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 At(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 jt(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 Mt(e){let t=Wt(zt(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 Nt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=Rt(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Pt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=Rt(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 Ft(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Ot(e,`border`,i,t)}function It(e,t=Lt){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Lt=65535;function Rt(e,t){return t.length>Lt?e(...It(t).map(t=>e(...t))):e(...t)}function zt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return Rt(Math.max,t)}function Bt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function Vt(e,t){return t()}var Ht=0;function Ut(e){return e+(``+ ++Ht)}function Wt(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 Gt(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Kt(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 qt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Jt=`\0`;function Yt(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 Xt=class{constructor(){Ve(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Zt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Zt(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,Qt)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Zt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Qt(e,t){if(e!==`_next`&&e!==`_prev`)return t}var $t=Xt,en=()=>1;function tn(e,t){if(e.nodeCount()<=1)return[];let n=an(e,t||en);return nn(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function nn(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)rn(e,t,n,o);for(;o=i.dequeue();)rn(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(rn(e,t,n,o,!0)||[]);break}}}return r}function rn(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,on(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,on(t,n,o)}),e.removeNode(r.v),o}function an(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=sn(i+r+3).map(()=>new $t),o=r+1;return n.nodes().forEach(e=>{on(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function on(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 sn(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function cn(e,t){(e.graph().acyclicer===`greedy`?tn(e,n(e)):ln(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,Ut(`rev`))});function n(e){return t=>e.edge(t).weight}}function ln(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&&dn(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 un(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 dn(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 fn(e){e.graph().dummyChains=[],e.edges().forEach(t=>pn(e,t))}function pn(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=Ot(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 mn(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 hn(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=Rt(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function gn(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var _n=vn;function vn(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(;yn(t,e)<i&&(a=bn(t,e),a);)o=t.hasNode(a.v)?gn(e,a):-gn(e,a),xn(t,e,o);return t}function yn(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)&&!gn(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function bn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=gn(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function xn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:Sn,postorder:Cn}=tt,wn=Tn;Tn.initLowLimValues=kn,Tn.initCutValues=En,Tn.calcCutValue=On,Tn.leaveEdge=jn,Tn.enterEdge=Mn,Tn.exchangeEdges=Nn;function Tn(e){e=kt(e),hn(e);let t=_n(e);kn(t),En(t,e);let n,r;for(;n=jn(t);)r=Mn(t,e,n),Nn(t,e,n,r)}function En(e,t){let n=Cn(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=On(e,t,n)}function On(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,Fn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function kn(e,t){arguments.length<2&&(t=e.nodes()[0]),An(e,{},1,t)}function An(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=An(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function jn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function Mn(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===In(e,e.node(t.v),s)&&c!==In(e,e.node(t.w),s)).reduce((e,n)=>gn(t,n)<gn(t,e)?n:e)}function Nn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),kn(e),En(e,t),Pn(e,t)}function Pn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=Sn(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 Fn(e,t,n){return e.hasEdge(t,n)}function In(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Ln=Rn;function Rn(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:Vn(e);break;case`tight-tree`:Bn(e);break;case`longest-path`:zn(e);break;case`none`:break;default:Vn(e)}}var zn=hn;function Bn(e){hn(e),_n(e)}function Vn(e){wn(e)}var Hn=Un;function Un(e){let t=Gn(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Wn(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 Wn(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 Gn(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(Jt).forEach(r),t}function Kn(e){let t=Ot(e,`root`,{},`_root`),n=Jn(e),r=Object.values(n),i=Rt(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=Yn(e)+1;e.children(Jt).forEach(r=>{qn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function qn(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=Ft(e,`_bt`),l=Ft(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{qn(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 Jn(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(Jt).forEach(e=>n(e,1)),t}function Yn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Xn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Zn=Qn;function Qn(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)$n(e,`borderLeft`,`_bl`,n,i,t),$n(e,`borderRight`,`_br`,n,i,t)}}e.children(Jt).forEach(t)}function $n(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Ot(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function er(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&nr(e)}function tr(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&ir(e),(t===`lr`||t===`rl`)&&(or(e),nr(e))}function nr(e){e.nodes().forEach(t=>rr(e.node(t))),e.edges().forEach(t=>rr(e.edge(t)))}function rr(e){let t=e.width;e.width=e.height,e.height=t}function ir(e){e.nodes().forEach(t=>ar(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(ar),Object.hasOwn(r,`y`)&&ar(r)})}function ar(e){e.y=-e.y}function or(e){e.nodes().forEach(t=>sr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(sr),Object.hasOwn(r,`x`)&&sr(r)})}function sr(e){let t=e.x;e.x=e.y,e.y=t}function cr(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Wt(Rt(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 Yt(t,e.node(n),e.node(r))}return a}function lr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=ur(e,t[r-1],t[r]);return n}function ur(e,t,n){let r=qt(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 dr(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 fr(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))}),pr(Object.values(n).filter(e=>!e.indegree))}function pr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&mr(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=>Gt(e,[`vs`,`i`,`barycenter`,`weight`]))}function mr(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 hr(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=Bt(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(_r(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=gr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=gr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function gr(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 _r(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=Yt(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 vr(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=dr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=vr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&br(t,r)}});let h=fr(m,n);yr(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=hr(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 yr(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function br(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 xr(e,t,n,r){r||=e.nodes();let i=Sr(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 Sr(e){let t;for(;e.hasNode(t=Ut(`_root`)););return t}function Cr(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 wr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,wr);return}let r=zt(e),i=Tr(e,Wt(1,r+1),`inEdges`),a=Tr(e,Wt(r-1,-1,-1),`outEdges`),o=cr(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){Er(t%2?i:a,t%4>=2,l,n),o=Mt(e);let u=lr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Dr(e,c)}function Tr(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 xr(e,t,n,r.get(t)||[])})}function Er(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}=vr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),Cr(e,a,s.vs)})}function Dr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Or(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=Ar(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)&&jr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function kr(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){Wt(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)&&jr(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 Ar(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function jr(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 Mr(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 Nr(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)||Hr(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=>Hr(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&&!Mr(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 Pr(e,t,n,r,i=!1){let a={},o=Fr(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 Fr(e,t,n,r){let i=new Dt,a=e.graph(),o=Br(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 Ir(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=Vr(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 Lr(e,t){let n=Object.values(t),r=Rt(Math.min,n),i=Rt(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-Rt(Math.min,c);a!==`l`&&(l=i-Rt(Math.max,c)),l&&(e[o]=Kt(s,e=>e+l))})})}function Rr(e,t=void 0){let n=e.ul;return n?Kt(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 zr(e,t){let n=Mt(e),r=Object.assign(Or(e,n),kr(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=Nr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Pr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Kt(c,e=>-e)),i[o+n]=c})}),Lr(i,Ir(e,i)),Rr(i,e.graph().align)}function Br(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 Vr(e,t){return e.node(t).width}function Hr(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 Ur(e,t){e=At(e),Wr(e),Object.entries(zr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Wr(e){let t=Mt(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 Gr=new WeakMap;function Kr(e,t={}){return Jr(e,Vt,t),e}function qr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Jr(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=qr(e,t.v,r),i=qr(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)}))}}),Jr(o,t,n);let l=oi(o);Xr(l,t,n,null),Zr(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=oi(e),g=Xr(h,t,n,Gr.get(e)??null);Gr.set(e,g),Zr(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))}),Yr(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}}),Yr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function Yr(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 Xr(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`,()=>si(e)),t(` removeSelfEdges`,()=>gi(e)),t(` acyclic`,()=>cn(e,s)),t(` nestingGraph.run`,()=>Kn(e)),t(` rank`,()=>Ln(At(e))),t(` injectEdgeLabelProxies`,()=>ci(e)),t(` removeEmptyRanks`,()=>Pt(e)),t(` nestingGraph.cleanup`,()=>Xn(e)),t(` normalizeRanks`,()=>Nt(e)),t(` assignRankMinMax`,()=>li(e)),t(` removeEdgeLabelProxies`,()=>ui(e)),t(` normalize.run`,()=>fn(e)),t(` parentDummyChains`,()=>Hn(e)),t(` addBorderSegments`,()=>Zn(e)),t(` order`,()=>wr(e,n,c)),t(` insertSelfEdges`,()=>_i(e)),t(` adjustCoordinateSystem`,()=>er(e)),t(` position`,()=>Ur(e,n.corePath)),t(` positionSelfEdges`,()=>vi(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>hi(e)),t(` normalize.undo`,()=>mn(e)),t(` fixupEdgeLabelCoords`,()=>pi(e)),t(` undoCoordinateSystem`,()=>tr(e)),t(` translateGraph`,()=>di(e)),t(` assignNodeIntersects`,()=>fi(e)),t(` reversePoints`,()=>mi(e)),t(` acyclic.undo`,()=>un(e)),{graph:e,rawNodes:l}}function Zr(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 Qr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],$r={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},ei=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],ti=[`width`,`height`,`rank`],ni={width:0,height:0},ri=[`minlen`,`weight`,`width`,`height`,`labeloffset`],ii={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},ai=[`labelpos`];function oi(e){let t=new Dt({multigraph:!0,compound:!0}),n=bi(e.graph());return t.setGraph(Object.assign({},$r,yi(n,Qr),Gt(n,ei))),e.nodes().forEach(n=>{let r=yi(bi(e.node(n)),ti);Object.keys(ni).forEach(e=>{r[e]===void 0&&(r[e]=ni[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=bi(e.edge(n));t.setEdge(n,Object.assign({},ii,yi(r,ri),Gt(r,ai)))}),t}function si(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 ci(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Ot(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function li(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 ui(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 di(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 fi(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(jt(r,a)),n.points.push(jt(i,o))})}function pi(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 mi(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function hi(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 gi(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 _i(e){Mt(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=>{Ot(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 vi(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 yi(e,t){return Kt(Gt(e,t),Number)}function bi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var xi=7,Si=16,Ci=1.5,wi=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function Ti(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&wi.has(r)?2:1;return Math.ceil(n*xi*(t===`title`?Ci:1))}var Ei=12,Di=e=>Math.round(e*10)/10,Oi=e=>Math.round(e*100)/100,ki=(e,t)=>[Oi((e[0]+t[0])/2),Oi((e[1]+t[1])/2)],Ai=([e,t])=>`${e} ${t}`;function ji(e){let t=e.length-1;if(t===1)return`M${Ai(e[0])} L${Ai(e[1])}`;let n=[`M${Ai(e[0])}`,`L${Ai(ki(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${Ai(e[r])} ${Ai(ki(e[r],e[r+1]))}`);return n.push(`L${Ai(e[t])}`),n.join(` `)}var Mi=16;function Ni(e,t,n){return Array.from({length:Mi},(r,i)=>{let a=(i+1)/Mi,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 Pi=e=>e.slice(1).map((t,n)=>[e[n],t]);function Fi(e,t,n){let r=Ti(e,`label`);return{text:e,x:Di(t[0]-r/2),y:Di(t[1]-Si/2),width:r,height:Si,route:n}}function Ii(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 Li(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 Ri(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 zi(e,t,n){let r=Ri(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var Bi=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),Vi=e=>[[e.x-Ei,e.y-Ei],[e.x+e.width+Ei,e.y-Ei],[e.x-Ei,e.y+e.height+Ei],[e.x+e.width+Ei,e.y+e.height+Ei]],Hi=(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 Ui(e,t,n){let r=[e,t,...n.flatMap(Vi).filter(e=>!n.some(t=>Hi(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]+Bi(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>zi(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 Wi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>zi(n,i,e))?[n]:(Ui(n,i,t)??[n,i]).slice(0,-1)})}function Gi(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 Ki(e,t,n){let r=Math.min(n/Math.max(Bi(e,t),.01),.25);return[Di(e[0]+(t[0]-e[0])*r),Di(e[1]+(t[1]-e[1])*r)]}function qi(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&&Pi([ki(n[e-1],n[e]),...Ni(ki(n[e-1],n[e]),n[e],ki(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>zi(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Ki(t,n[i-1],r),t,Ki(t,n[i+1],r)]:[t])}return n}function Ji(e,t){return Gi(qi(Wi(e,t),t))}function Yi(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 Xi(e,t,n,r=[]){let i=Yi({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 Zi(e,t=!0){let n=new He.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);Kr(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?Ji(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Xi(r,i,e.margin)}}var Qi=`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}`,$i={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}`},ea=e=>e.replace(/[&<>"]/gu,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]);function ta(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${ea(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${ea(t)}</text>`).join(``)}function na(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})">${ta(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="${ji(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">${ea(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries($i).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>${Qi}${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
2
|
`)}var ra=12,ia=12,aa=24,oa=64,sa=24,ca=`removed`,la=new Set([`spawns`,`runs-in`,`deployed-on`,`mounts`,`reads`,`writes`,`publishes`,`subscribes`]);function ua(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 da(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=ua(o.map(e=>i(e.id)),ia);o.forEach((t,r)=>n.set(t.id,{x:ra+e.cells[r].x,y:36+e.cells[r].y})),s={width:Math.max(160,e.width)+24,height:36+e.height+ra}}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=Zi({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===ca,width:t.kind===`relation`?1.5:2,weight:t.relations.length})),nodesep:aa,ranksep:oa,margin:sa}),f=c.filter(e=>!l.has(e.id)),p=d.boxes.length===0?sa:Math.max(...d.boxes.map(e=>e.y+e.height))+oa,m=f.map(e=>i(e.id)),h=ua(m,aa).cells.map((e,t)=>({id:f[t].id,parent:null,x:sa+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:Xi(_,y,sa)},relations:new Map([...s].map(([e,t])=>[e,t.relations]))}}var H=i();function U(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=U(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var fa={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.`},pa=[[-1/0,-1/0],[1/0,1/0]],ma=[`Enter`,` `,`Escape`],ha={"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`},ga;(function(e){e.Strict=`strict`,e.Loose=`loose`})(ga||={});var _a;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(_a||={});var va;(function(e){e.Partial=`partial`,e.Full=`full`})(va||={});var ya={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},ba;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(ba||={});var xa;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(xa||={});var W;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(W||={});var Sa={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top},Ca=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,wa=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Ta=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),Ea=(e,t=[0,0])=>{let{width:n,height:r}=oo(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Da=(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):Ta(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ba(e,Wa(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Ha(r):{x:0,y:0,width:0,height:0}},Oa=(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=Ba(n,Wa(e)),r=!0)}),r?Ha(n):{x:0,y:0,width:0,height:0}},ka=(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=Ka(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},Aa=(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 ja(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}=oo(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 Ma({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=ro(Oa(ja(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 Na({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`,fa.error005());else{let{width:e,height:t}=oo(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&ao(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=ao(d)?Ia(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,fa.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 Pa({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=Aa(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 Fa=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ia=(e={x:0,y:0},t,n)=>({x:Fa(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Fa(e.y,t[0][1],t[1][1]-(n?.height??0))});function La(e,t,n){let{width:r,height:i}=oo(n),{x:a,y:o}=n.internals.positionAbsolute;return Ia(e,[[a,o],[a+r,o+i]],t)}var Ra=(e,t,n)=>e<t?Fa(Math.abs(e-t),1,t)/t:e>n?-Fa(Math.abs(e-n),1,t)/t:0,za=(e,t,n=15,r=40)=>[Ra(e.x,r,t.width-r)*n,Ra(e.y,r,t.height-r)*n],Ba=(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)}),Va=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ha=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Ua=(e,t=[0,0])=>{let{x:n,y:r}=Ta(e)?e.internals.positionAbsolute:Ea(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}},Wa=(e,t=[0,0])=>{let{x:n,y:r}=Ta(e)?e.internals.positionAbsolute:Ea(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)}},Ga=(e,t)=>Ha(Ba(Va(e),Va(t))),Ka=(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)},qa=(e,t)=>Ka(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ja=e=>Ya(e.width)&&Ya(e.height)&&Ya(e.x)&&Ya(e.y),Ya=e=>!isNaN(e)&&isFinite(e),Xa=(e,t)=>(e,t)=>{},Za=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Qa=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Za(s,o):s},$a=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function eo(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 to(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=eo(e,n),i=eo(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=eo(e.top??e.y??0,n),i=eo(e.bottom??e.y??0,n),a=eo(e.left??e.x??0,t),o=eo(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 no(e,t,n,r,i,a){let{x:o,y:s}=$a(e,[t,n,r]),{x:c,y:l}=$a({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 ro=(e,t,n,r,i,a)=>{let o=to(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Fa(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=no(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}},io=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function ao(e){return e!=null&&e!==`parent`}function oo(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function so(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function co(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 lo(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function uo(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function fo(e){return{...ha,...e||{}}}function po(e){return e===null?null:e?`valid`:`invalid`}function mo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=bo(e),s=Qa({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Za(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var ho=e=>({width:e.offsetWidth,height:e.offsetHeight}),go=e=>e?.getRootNode?.()||window?.document,_o=[`INPUT`,`SELECT`,`TEXTAREA`];function vo(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?_o.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var yo=e=>`clientX`in e,bo=(e,t)=>{let n=yo(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)}},xo=(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,...ho(t)}})};function So({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 Co(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function wo({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case W.Left:return[t-Co(t-r,a),n];case W.Right:return[t+Co(r-t,a),n];case W.Top:return[t,n-Co(n-i,a)];case W.Bottom:return[t,n+Co(i-n,a)]}}function To({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,curvature:o=.25}){let[s,c]=wo({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=wo({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=So({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 Eo({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 Do({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 Oo({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ba(Wa(e),Wa(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),qa({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Ha(a))>0}var ko=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Ao=(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)),jo=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,fa.error006()),t;let r=n.getEdgeId||ko,i;return i=Ca(e)?{...e}:{...e,id:r(e)},Ao(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Mo({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=Eo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var No={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},Po=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.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},Fo=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Io=(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 Lo({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:r=W.Top,center:i,offset:a,stepPosition:o}){let s=No[t],c=No[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=Po({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]=Eo({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&&Io(e,n,t)&&C.pop(),C.push(t)}return[C,h,g,y,b]}function Ro(e,t,n,r){let i=Math.min(Fo(e,t)/2,Fo(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 zo({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Lo({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+=Ro(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 Bo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Vo(e){let{sourceNode:t,targetNode:n}=e;if(!Bo(t)||!Bo(n))return null;let r=t.internals.handleBounds||Ho(t.handles),i=n.internals.handleBounds||Ho(n.handles),a=Wo(r?.source??[],e.sourceHandle),o=Wo(e.connectionMode===ga.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,fa.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||W.Bottom,c=o?.position||W.Top,l=Uo(t,a,s),u=Uo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Ho(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 Uo(e,t,n=W.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??oo(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case W.Top:return{x:i+o/2,y:a};case W.Right:return{x:i+o,y:a+s/2};case W.Bottom:return{x:i+o/2,y:a+s};case W.Left:return{x:i,y:a+s/2}}}function Wo(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Go(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Ko(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=Go(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 qo=1e3,Jo=10,Yo={nodeOrigin:[0,0],nodeExtent:pa,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Xo={...Yo,checkEquality:!0};function Zo(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Qo(e,t,n){let r=Zo(Yo,n);for(let n of e.values())if(n.parentId)rs(n,e,t,r);else{let e=Ia(Ea(n,r.nodeOrigin),ao(n.extent)?n.extent:r.nodeExtent,oo(n));n.internals.positionAbsolute=e}}function $o(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 es(e){return e===`manual`}function ts(e,t,n,r={}){let i=Zo(Xo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!es(i.zIndexMode)?qo: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=Ia(Ea(u,i.nodeOrigin),ao(u.extent)?u.extent:i.nodeExtent,oo(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:$o(u,e),z:is(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&&rs(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function ns(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 rs(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Zo(Yo,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}ns(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*Jo),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=as(e,u,o,s,a&&!es(c)?qo: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 is(e,t,n){let r=Ya(e.zIndex)?e.zIndex:0;return es(n)?r:r+(e.selected?t:0)}function as(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=oo(e),l=Ea(e,n),u=ao(e.extent)?Ia(l,e.extent,c):l,d=Ia({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=La(d,c,t));let f=is(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function os(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=Ga(a.get(n.parentId)?.expandedRect??Ua(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=oo(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 ss(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=ho(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=ao(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=La(h,s,n))}else m&&(h=Ia(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:xo(`source`,r.nodeElement,p,d,e.id),target:xo(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&rs(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:Ua(g,i)}))}}if(f.length>0){let e=os(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function cs({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 ls(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 us(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}`;ls(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),ls(`target`,s,c,e,i,o),t.set(r.id,r)}}function ds(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ds(n,t):!1}function fs(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 ps(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||!ds(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 ms({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 hs({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=Za(a,t);return{x:o.x-a.x,y:o.y-a.y}}function gs({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=k(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?Va(Oa(s)):null,x=v&&l?hs({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)}:Za(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}=Na({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]=ms({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]=za(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=mo(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=x,s=ps(i,c,x,b,v),s.size>0&&(n||h||!b&&g)){let[e,t]=ms({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=ne().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=mo(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=bo(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=mo(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=bo(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=bo(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]=ms({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||!fs(t,`.${g}`,v))&&(!_||fs(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function _s(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())qa(i,Ua(e))>0&&r.push(e);return r}var vs=250;function ys(e,t,n,r){let i=[],a=1/0,o=_s(e,n,t+vs);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}=Uo(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 bs(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,...Uo(o,c,c.position,!0)}:c}function xs(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 ws(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=go(e.target),E=0,D,{x:O,y:k}=bo(e),A=xs(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=bs(i,A,r,c,t);if(!N)return;let P=bo(e,j),F=!1,ee=null,te=!1,I=null;function ne(){if(!u||!j)return;let[e,t]=za(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(ne)}let L={...N,nodeId:i,type:A,position:N.position},re=c.get(i),ie={inProgress:!0,isValid:null,from:Uo(re,L,W.Left,!0),fromHandle:L,fromPosition:L.position,fromNode:re,to:P,toHandle:null,toPosition:Sa[L.position],toNode:null,pointer:P};function ae(){M=!0,y(ie),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ae();function oe(e){if(!M){let{x:t,y:n}=bo(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ae()}if(!x()||!L){R(e);return}let a=b();P=bo(e,j),D=ys(Qa(P,a,!1,[1,1]),n,c,L),F||=(ne(),!0);let s=Ts(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});I=s.handleDomNode,ee=s.connection,te=Ss(!!D,s.isValid);let u=c.get(i),f=u?Uo(u,L,W.Left,!0):ie.from,p={...ie,from:f,isValid:te,to:s.toHandle&&te?$a({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:te&&s.toHandle?s.toHandle.position:Sa[L.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ie=p}function R(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||I)&&ee&&te&&h?.(ee);let{inProgress:t,...n}=ie,r={...n,toPosition:ie.toHandle?ie.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),F=!1,te=!1,ee=null,I=null,T.removeEventListener(`mousemove`,oe),T.removeEventListener(`mouseup`,R),T.removeEventListener(`touchmove`,oe),T.removeEventListener(`touchend`,R)}}T.addEventListener(`mousemove`,oe),T.addEventListener(`mouseup`,R),T.addEventListener(`touchmove`,oe),T.addEventListener(`touchend`,R)}function Ts(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}=bo(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=xs(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===ga.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=bs(t,e,a,u,n,!0)}return _}var Es={onPointerDown:ws,isValid:Ts};function Ds({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=k(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&&io()?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=D().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:y}}var Os=e=>({x:e.x,y:e.y,zoom:e.k}),ks=({x:e,y:t,zoom:n})=>T.translate(e,t).scale(n),As=(e,t)=>e.target.closest(`.${t}`),js=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ms=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Ns=(e,t=0,n=Ms,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Ps=e=>{let t=e.ctrlKey&&io()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Fs({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(As(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=y(u),t=d*2**Ps(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===_a.Vertical?0:u.deltaX*f,m=i===_a.Horizontal?0:u.deltaY*f;!io()&&u.shiftKey&&i!==_a.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=Os(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 Is({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=As(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Ls({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=Os(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 Rs({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&js(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,Os(a.transform))}}function zs({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&js(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=Os(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Bs({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`&&(As(f,`${u}-flow__node`)||As(f,`${u}-flow__edge`)||As(f,`${u}-flow__selection`)||As(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||As(f,c)&&h||As(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 Vs({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=D().extent(()=>d).scaleExtent([t,n]).translateExtent(r),m=k(e).call(p);b({x:i.x,y:i.y,zoom:Fa(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let h=m.on(`wheel.zoom`),g=m.on(`dblclick.zoom`);p.wheelDelta(Ps);async function _(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?M:w).transform(Ns(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:!Ya(E)||E<0?0:E);let k=O?Fs({zoomPanValues:l,noWheelClassName:e,d3Selection:m,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Is({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:h});m.on(`wheel.zoom`,k,{passive:!1});let A=Ls({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,A);let j=Rs({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});p.on(`zoom`,j);let M=zs({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,M);let N=Bs({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=ks(e),i=p?.constrain()(r,t,n);return i&&await _(i),i}async function x(e,t){let n=ks(e);return await _(n,t),n}function S(e){if(m){let t=ks(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 C(){let e=m?E(m.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function T(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?M:w).scaleTo(Ns(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function O(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?M:w).scaleBy(Ns(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){p?.scaleExtent(e)}function j(e){p?.translateExtent(e)}function N(e){let t=!Ya(e)||e<0?0:e;p?.clickDistance(t)}return{update:v,destroy:y,setViewport:x,setViewportConstrained:b,getViewport:C,scaleTo:T,scaleBy:O,setScaleExtent:A,setTranslateExtent:j,syncViewport:S,setClickDistance:N}}var Hs;(function(e){e.Line=`line`,e.Handle=`handle`})(Hs||={});function Us({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 Ws(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 Gs(e,t){return Math.max(0,t-e)}function Ks(e,t){return Math.max(0,e-t)}function qs(e,t,n){return Math.max(0,t-e,e-n)}function Js(e,t){return e?!t:t}function Ys(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=qs(E,h,g),j=qs(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Gs(y+w+O,o[0][0]):!c&&w>0&&(e=Ks(y+E+O,o[1][0])),l&&T<0?t=Gs(b+T+k,o[0][1]):!l&&T>0&&(t=Ks(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=Ks(y+w,s[0][0]):!c&&w<0&&(e=Gs(y+E,s[1][0])),l&&T>0?t=Ks(b+T,s[0][1]):!l&&T<0&&(t=Gs(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=qs(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Ks(b+k+E/C,o[1][1])*C:Gs(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?Gs(b+E/C,s[1][1])*C:Ks(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=qs(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Ks(y+D*C+O,o[1][0])/C:Gs(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?Gs(y+D*C,s[1][0])/C:Ks(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=(Js(c,l)?-w:w)/C:w=(Js(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 Xs={width:0,height:0,x:0,y:0},Zs={...Xs,pointerX:0,pointerY:0,aspectRatio:1};function Qs(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 $s({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=k(e),o={controlDirection:Ws(`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={...Xs},h={...Zs};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Ws(e)};let g,_=null,v=[],y,b,x,S=ne().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}=mo(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=ao(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=Qs(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=mo(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}=Ys(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=Us({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 ec=e(r(),1),tc=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},nc=e=>e?tc(e):tc,{useDebugValue:rc}=L.default,{useSyncExternalStoreWithSelector:ic}=ec.default,ac=e=>e;function oc(e,t=ac,n){let r=ic(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return rc(r),r}var sc=(e,t)=>{let n=nc(e),r=(e,r=t)=>oc(n,e,r);return Object.assign(r,n),r},cc=(e,t)=>e?sc(e,t):sc;function G(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}t();var lc=(0,L.createContext)(null),uc=lc.Provider,dc=fa.error001(`react`);function K(e,t){let n=(0,L.useContext)(lc);if(n===null)throw Error(dc);return oc(n,e,t)}function q(){let e=(0,L.useContext)(lc);if(e===null)throw Error(dc);return(0,L.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var fc={display:`none`},pc={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},mc=`react-flow__node-desc`,hc=`react-flow__edge-desc`,gc=`react-flow__aria-live`,_c=e=>e.ariaLiveMessage,vc=e=>e.ariaLabelConfig;function yc({rfId:e}){let t=K(_c);return(0,H.jsx)(`div`,{id:`${gc}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:pc,children:t})}function bc({rfId:e,disableKeyboardA11y:t}){let n=K(vc);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{id:`${mc}-${e}`,style:fc,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,H.jsx)(`div`,{id:`${hc}-${e}`,style:fc,children:n[`edge.a11yDescription.default`]}),!t&&(0,H.jsx)(yc,{rfId:e})]})}var xc=(0,L.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,H.jsx)(`div`,{className:U([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});xc.displayName=`Panel`;var Sc=`https://reactflow.dev?utm_source=attribution`;function Cc({proOptions:e,position:t=`bottom-right`}){return(0,L.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,H.jsx)(xc,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Sc}`,children:(0,H.jsx)(`a`,{href:Sc,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var wc=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}},Tc=e=>e.id;function Ec(e,t){return G(e.selectedNodes.map(Tc),t.selectedNodes.map(Tc))&&G(e.selectedEdges.map(Tc),t.selectedEdges.map(Tc))}function Dc({onSelectionChange:e}){let t=q(),{selectedNodes:n,selectedEdges:r}=K(wc,Ec);return(0,L.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Oc=e=>!!e.onSelectionChangeHandlers;function kc({onSelectionChange:e}){let t=K(Oc);return e||t?(0,H.jsx)(Dc,{onSelectionChange:e}):null}var Ac=[0,0],jc={x:0,y:0,zoom:1},Mc=[...`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`],Nc=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}),Pc={translateExtent:pa,nodeOrigin:Ac,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Fc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=K(Nc,G),l=q();(0,L.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Pc,s()}),[]);let u=(0,L.useRef)(Pc);return(0,L.useEffect)(()=>{for(let s of Mc){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:fo(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Mc.map(t=>e[t])),null}function Ic(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Lc(e){let[t,n]=(0,L.useState)(e===`system`?null:e);return(0,L.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Ic(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Ic()?.matches?`dark`:`light`:t}var Rc=typeof document<`u`?document:null;function zc(e=null,t={target:Rc,actInsideInputWithModifier:!0}){let[n,r]=(0,L.useState)(!1),i=(0,L.useRef)(!1),a=(0,L.useRef)(new Set([])),[o,s]=(0,L.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,L.useEffect)(()=>{let n=t?.target??Rc,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)&&vo(e))return!1;let n=Vc(e.code,s);if(a.current.add(e[n]),Bc(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=Vc(e.code,s);Bc(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 Bc(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function Vc(e,t){return t.includes(e)?`code`:`key`}var Hc=()=>{let e=q();return(0,L.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=ro(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 Qa(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=$a(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function Uc(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)Wc(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 Wc(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 Gc(e,t){return Uc(e,t)}function Kc(e,t){return Uc(e,t)}function qc(e,t){return{id:e,type:`select`,selected:t}}function Jc(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(qc(i.id,e))}return n}function Yc({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 Xc(e){return{id:e.id,type:`remove`}}var Zc=Xa(`React Flow`,`https://reactflow.dev/`);function Qc(e,t,n={}){return jo(e,t,{...n,onError:n.onError??Zc})}var $c=e=>wa(e),el=e=>Ca(e);function tl(e){return(0,L.forwardRef)(e)}var nl=typeof window<`u`?L.useLayoutEffect:L.useEffect;function rl(e){let[t,n]=(0,L.useState)(BigInt(0)),[r]=(0,L.useState)(()=>il(()=>n(e=>e+BigInt(1))));return nl(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function il(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var al=(0,L.createContext)(null);function ol({children:e}){let t=q(),n=rl((0,L.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=Yc({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=rl((0,L.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(Yc({items:s,lookup:o}))},[])),i=(0,L.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,H.jsx)(al.Provider,{value:i,children:e})}function sl(){let e=(0,L.useContext)(al);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var cl=e=>!!e.panZoom;function ll(){let e=Hc(),t=q(),n=sl(),r=K(cl),i=(0,L.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=$c(e)?e:n.get(e.id),a=i.parentId?co(i.position,i.measured,i.parentId,n,r):i.position;return Ua({...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&&$c(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&&el(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 Pa({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Xc);o?.(f),c(e)}if(m){let e=d.map(Xc);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=Ja(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=Ua(s?r:a,c),u=qa(l,o);return n&&u>0||u>=l.width*l.height||u>=o.width*o.height})},isNodeIntersecting:(e,t,n=!0)=>{let r=Ja(e)?e:a(e);if(!r)return!1;let i=qa(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 Da(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??uo();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,L.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var ul=e=>e.selected,dl=typeof window<`u`?window:void 0;function fl({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=q(),{deleteElements:r}=ll(),i=zc(e,{actInsideInputWithModifier:!1}),a=zc(t,{target:dl});(0,L.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(ul),edges:e.filter(ul)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,L.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function pl(e){let t=q();(0,L.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=ho(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,fa.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 ml={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},hl=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function gl({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:i,panOnScrollSpeed:a=.5,panOnScrollMode:o=_a.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=q(),C=(0,L.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=K(hl,G),D=zc(p),O=(0,L.useRef)();pl(C);let k=(0,L.useCallback)(e=>{v?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[v,y]);return(0,L.useEffect)(()=>{if(C.current){O.current=Vs({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,L.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,H.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:ml,children:h})}var _l=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function vl(){let{userSelectionActive:e,userSelectionRect:t}=K(_l,G);return e&&t?(0,H.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 yl=(e,t)=>n=>{n.target===t.current&&e?.(n)},bl=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function xl({isSelecting:e,selectionKeyPressed:t,selectionMode:n=va.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,L.useRef)(0),_=q(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=K(bl,G),C=y&&(e||v),w=(0,L.useRef)(null),T=(0,L.useRef)(),E=(0,L.useRef)(new Set),D=(0,L.useRef)(new Set),O=(0,L.useRef)(!1),k=(0,L.useRef)(!1),A=(0,L.useRef)({x:0,y:0}),j=(0,L.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}=bo(n.nativeEvent,T.current),u=Qa({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}=$a(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(ka(a,m,i,n===va.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)}}lo(h,E.current)||c(Jc(a,E.current)),lo(g,D.current)||l(Jc(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function I(){if(!i||!T.current)return;let[e,t]=za(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(I);return}let{x:t,y:n}=A.current;te(t,n),g.current=requestAnimationFrame(I)})}let ne=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};(0,L.useEffect)(()=>()=>ne(),[]);let re=e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=bo(e.nativeEvent,T.current);A.current={x:o,y:c};let l=$a({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||=(I(),!0),te(o,c)},ie=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})),ne()):e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0)},ae=e=>{e.target?.releasePointerCapture?.(e.pointerId),ne()},oe=r===!0||Array.isArray(r)&&r.includes(0);return(0,H.jsxs)(`div`,{className:U([`react-flow__pane`,{draggable:oe,dragging:b,selection:e}]),onClick:C?void 0:yl(M,w),onContextMenu:yl(N,w),onWheel:yl(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?re:p,onPointerUp:ie,onPointerCancel:C?ae:void 0,onPointerDownCapture:C?ee:void 0,onClickCapture:C?F:void 0,onPointerLeave:m,ref:w,style:ml,children:[h,(0,H.jsx)(vl,{})]})}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`,fa.error012(e))}function Cl({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=q(),[c,l]=(0,L.useState)(!1),u=(0,L.useRef)();return(0,L.useEffect)(()=>{if(!t)return u.current=gs({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,L.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 wl=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function Tl(){let e=q();return(0,L.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=wl(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=Za(t,i));let{position:a,positionAbsolute:s}=Na({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 El=(0,L.createContext)(null),Dl=El.Provider;El.Consumer;var Ol=()=>(0,L.useContext)(El),kl=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Al=(0,L.createContext)(null);function jl({children:e}){let t=K(kl,G);return(0,H.jsx)(Al.Provider,{value:t,children:e})}function Ml(){let e=(0,L.useContext)(Al);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var Nl={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},Pl=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return Nl;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===ga.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function Fl({type:e=`source`,position:t=W.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=q(),_=Ol(),{connectOnClick:v,noPanClassName:y,rfId:b}=Ml(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=K(Pl(_,m,e),G);_||g.getState().onError?.(`010`,fa.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(Qc(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=yo(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();Es.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,H.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:U([`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=go(t.target),h=n||c,{connection:v,isValid:y}=Es.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 Il=(0,L.memo)(tl(Fl));function Ll({data:e,isConnectable:t,sourcePosition:n=W.Bottom}){return(0,H.jsxs)(H.Fragment,{children:[e?.label,(0,H.jsx)(Il,{type:`source`,position:n,isConnectable:t})]})}function Rl({data:e,isConnectable:t,targetPosition:n=W.Top,sourcePosition:r=W.Bottom}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Il,{type:`target`,position:n,isConnectable:t}),e?.label,(0,H.jsx)(Il,{type:`source`,position:r,isConnectable:t})]})}function zl(){return null}function Bl({data:e,isConnectable:t,targetPosition:n=W.Top}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Il,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Vl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Hl={input:Ll,default:Rl,output:Bl,group:zl};function Ul(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 Wl=e=>{let{width:t,height:n,x:r,y:i}=Oa(e.nodeLookup,{filter:e=>!!e.selected});return{width:Ya(t)?t:null,height:Ya(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 Gl({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=q(),{width:i,height:a,transformString:o,userSelectionActive:s}=K(Wl,G),c=Tl(),l=(0,L.useRef)(null);(0,L.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,H.jsx)(`div`,{className:U([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,H.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(Vl,e.key)&&(e.preventDefault(),c({direction:Vl[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Kl=typeof window<`u`?window:void 0,ql=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Jl({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:te,userSelectionActive:I}=K(ql,G),ne=zc(l,{target:Kl}),L=zc(h,{target:Kl}),re=L||w,ie=L||b,ae=u&&re!==!0,oe=ne||I||ae;return fl({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,H.jsx)(gl,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ie,panActivationKeyPressed:L,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!ne&&re,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:F,isControlledViewport:ee,paneClickDistance:s,selectionOnDrag:ae,children:(0,H.jsxs)(xl,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:re,autoPanOnSelection:T,isSelecting:!!oe,selectionMode:d,selectionKeyPressed:ne,paneClickDistance:s,selectionOnDrag:ae,children:[e,te&&(0,H.jsx)(Gl,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Jl.displayName=`FlowRenderer`;var Yl=(0,L.memo)(Jl),Xl=e=>t=>e?ka(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 Zl(e){return K((0,L.useCallback)(Xl(e),[e]),G)}var Ql=e=>e.updateNodeInternals;function $l(){let e=K(Ql),[t]=(0,L.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,L.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function eu({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=q(),a=(0,L.useRef)(null),o=(0,L.useRef)(null),s=(0,L.useRef)(e.sourcePosition),c=(0,L.useRef)(e.targetPosition),l=(0,L.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,L.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,L.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,L.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 tu({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}=K(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},G),S=y.type||`default`,C=g?.[S]||Hl[S];C===void 0&&(v?.(`003`,fa.error003(S)),S=`default`,C=g?.default||Hl.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=q(),k=so(y),A=eu({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=Tl();if(y.hidden)return null;let N=oo(y),P=Ul(y),F=T||w||t||n||r||i,ee=n?e=>n(e,{...b.userNode}):void 0,te=r?e=>r(e,{...b.userNode}):void 0,I=i?e=>i(e,{...b.userNode}):void 0,ne=a?e=>a(e,{...b.userNode}):void 0,L=o?e=>o(e,{...b.userNode}):void 0,re=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})},ie=t=>{if(!(vo(t.nativeEvent)||m)){if(ma.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(Vl,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:Vl[t.key],factor:t.shiftKey?4:1})}}},ae=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(ka(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,H.jsx)(`div`,{className:U([`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:te,onMouseLeave:I,onContextMenu:ne,onClick:re,onDoubleClick:L,onKeyDown:D?ie:void 0,tabIndex:D?0:void 0,onFocus:D?ae:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${mc}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,H.jsx)(Dl,{value:e,children:(0,H.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 nu=(0,L.memo)(tu),ru=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function iu(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=K(ru,G),a=Zl(e.onlyRenderVisibleElements),o=$l();return(0,H.jsx)(`div`,{className:`react-flow__nodes`,style:ml,children:a.map(a=>(0,H.jsx)(nu,{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))})}iu.displayName=`NodeRenderer`;var au=(0,L.memo)(iu);function ou(e){return K((0,L.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&&Oo({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),G)}var su=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e}};return(0,H.jsx)(`polyline`,{className:`arrow`,style:n,strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`})},cu=({color:e=`none`,strokeWidth:t=1})=>{let n={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,H.jsx)(`polyline`,{className:`arrowclosed`,style:n,strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`})},lu={[xa.Arrow]:su,[xa.ArrowClosed]:cu};function uu(e){let t=q();return(0,L.useMemo)(()=>Object.prototype.hasOwnProperty.call(lu,e)?lu[e]:(t.getState().onError?.(`009`,fa.error009(e)),null),[e])}var du=({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=uu(t);return c?(0,H.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,H.jsx)(c,{color:n,strokeWidth:o})}):null},fu=({defaultColor:e,rfId:t})=>{let n=K(e=>e.edges),r=K(e=>e.defaultEdgeOptions),i=(0,L.useMemo)(()=>Ko(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,H.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,H.jsx)(`defs`,{children:i.map(e=>(0,H.jsx)(du,{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};fu.displayName=`MarkerDefinitions`;var pu=(0,L.memo)(fu);function mu({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,L.useState)({x:1,y:0,width:0,height:0}),p=U([`react-flow__edge-textwrapper`,l]),m=(0,L.useRef)(null);return(0,L.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,H.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,H.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,H.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}mu.displayName=`EdgeText`;var hu=(0,L.memo)(mu);function gu({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{...u,d:e,fill:`none`,className:U([`react-flow__edge-path`,u.className])}),l?(0,H.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Ya(t)&&Ya(n)?(0,H.jsx)(hu,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function _u({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===W.Left||e===W.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function vu({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:r,targetY:i,targetPosition:a=W.Top}){let[o,s]=_u({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=_u({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=So({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 yu(e){return(0,L.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]=vu({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s}),x=e.isInternal?void 0:t;return(0,H.jsx)(gu,{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 bu=yu({isInternal:!1}),xu=yu({isInternal:!0});bu.displayName=`SimpleBezierEdge`,xu.displayName=`SimpleBezierEdgeInternal`;function Su(e){return(0,L.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=W.Bottom,targetPosition:m=W.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=zo({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,H.jsx)(gu,{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}),wu=Su({isInternal:!0});Cu.displayName=`SmoothStepEdge`,wu.displayName=`SmoothStepEdgeInternal`;function Tu(e){return(0,L.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,H.jsx)(Cu,{...n,id:r,pathOptions:(0,L.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Eu=Tu({isInternal:!1}),Du=Tu({isInternal:!0});Eu.displayName=`StepEdge`,Du.displayName=`StepEdgeInternal`;function Ou(e){return(0,L.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]=Mo({sourceX:n,sourceY:r,targetX:i,targetY:a}),y=e.isInternal?void 0:t;return(0,H.jsx)(gu,{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 ku=Ou({isInternal:!1}),Au=Ou({isInternal:!0});ku.displayName=`StraightEdge`,Au.displayName=`StraightEdgeInternal`;function ju(e){return(0,L.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=W.Bottom,targetPosition:s=W.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]=To({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature}),S=e.isInternal?void 0:t;return(0,H.jsx)(gu,{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 Mu=ju({isInternal:!1}),Nu=ju({isInternal:!0});Mu.displayName=`BezierEdge`,Nu.displayName=`BezierEdgeInternal`;var Pu={default:Nu,straight:Au,step:Du,smoothstep:wu,simplebezier:xu},Fu={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},Iu=(e,t,n)=>n===W.Left?e-t:n===W.Right?e+t:e,Lu=(e,t,n)=>n===W.Top?e-t:n===W.Bottom?e+t:e,Ru=`react-flow__edgeupdater`;function zu({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,H.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:U([Ru,`${Ru}-${s}`]),cx:Iu(t,r,e),cy:Lu(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function Bu({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=q(),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`;Es.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,H.jsxs)(H.Fragment,{children:[(e===!0||e===`source`)&&(0,H.jsx)(zu,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,H.jsx)(zu,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function Vu({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=K(t=>t.edgeLookup.get(e)),b=K(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||Pu[x];S===void 0&&(_?.(`011`,fa.error011(x)),x=`default`,S=h?.default||Pu.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,L.useRef)(null),[D,O]=(0,L.useState)(!1),[k,A]=(0,L.useState)(!1),j=q(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:F,targetY:ee,sourcePosition:te,targetPosition:I}=K((0,L.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return Fu;let i=Vo({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=Do({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||Fu,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex,_]),G),ne=(0,L.useMemo)(()=>y.markerStart?`url('#${Go(y.markerStart,m)}')`:void 0,[y.markerStart,m]),re=(0,L.useMemo)(()=>y.markerEnd?`url('#${Go(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||F===null||ee===null)return null;let ie=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)},ae=a?e=>{a(e,{...y})}:void 0,oe=o?e=>{o(e,{...y})}:void 0,R=s?e=>{s(e,{...y})}:void 0,se=c?e=>{c(e,{...y})}:void 0,ce=l?e=>{l(e,{...y})}:void 0;return(0,H.jsx)(`svg`,{style:{zIndex:M},children:(0,H.jsxs)(`g`,{className:U([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:ie,onDoubleClick:ae,onContextMenu:oe,onMouseEnter:R,onMouseMove:se,onMouseLeave:ce,onKeyDown:C?t=>{if(!v&&ma.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?`${hc}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,H.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:I,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:ne,markerEnd:re,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,H.jsx)(Bu,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:F,targetY:ee,sourcePosition:te,targetPosition:I,setUpdateHover:O,setReconnecting:A})]})})}var Hu=(0,L.memo)(Vu),Uu=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function Wu({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}=K(Uu,G),b=ou(t);return(0,H.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,H.jsx)(pu,{defaultColor:e,rfId:n}),b.map(e=>(0,H.jsx)(Hu,{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))]})}Wu.displayName=`EdgeRenderer`;var Gu=(0,L.memo)(Wu),Ku=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function qu({children:e}){let t=q(),n=(0,L.useRef)(null),[r]=(0,L.useState)(()=>t.getState().transform);return nl(()=>{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=Ku(r)))};return r(),t.subscribe(r)},[t]),(0,H.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:Ku(r)},children:e})}function Ju(e){let t=ll(),n=(0,L.useRef)(!1);(0,L.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var Yu=e=>e.panZoom?.syncViewport;function Xu(e){let t=K(Yu),n=q();return(0,L.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Zu(e){return e.connection.inProgress?{...e.connection,to:Qa(e.connection.to,e.transform)}:{...e.connection}}function Qu(e){return e?t=>e(Zu(t)):Zu}function $u(e){return K(Qu(e),G)}var ed=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function td({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=K(ed,G);return a&&i&&c?(0,H.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,H.jsx)(`g`,{className:U([`react-flow__connection`,po(s)]),children:(0,H.jsx)(nd,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var nd=({style:e,type:t=ba.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}=$u();if(!i)return;if(n)return(0,H.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:po(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 ba.Bezier:[m]=To(h);break;case ba.SimpleBezier:[m]=vu(h);break;case ba.Step:[m]=zo({...h,borderRadius:0});break;case ba.SmoothStep:[m]=zo(h);break;default:[m]=Mo(h)}return(0,H.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};nd.displayName=`ConnectionLine`;var rd={};function id(e=rd){(0,L.useRef)(e),q(),(0,L.useEffect)(()=>{},[e])}function ad(){q(),(0,L.useRef)(!1),(0,L.useEffect)(()=>{},[])}function od({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:te,zoomOnDoubleClick:I,panOnDrag:ne,autoPanOnSelection:L,onPaneClick:re,onPaneMouseEnter:ie,onPaneMouseMove:ae,onPaneMouseLeave:oe,onPaneScroll:R,onPaneContextMenu:se,paneClickDistance:ce,nodeClickDistance:le,onEdgeContextMenu:ue,onEdgeMouseEnter:z,onEdgeMouseMove:de,onEdgeMouseLeave:B,reconnectRadius:V,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,viewport:xe,onViewportChange:Se,nodesDraggable:Ce}){return id(e),id(t),ad(),Ju(n),Xu(xe),(0,H.jsx)(Yl,{onPaneClick:re,onPaneMouseEnter:ie,onPaneMouseMove:ae,onPaneMouseLeave:oe,onPaneContextMenu:se,onPaneScroll:R,paneClickDistance:ce,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:I,panOnScroll:F,panOnScrollSpeed:ee,panOnScrollMode:te,panOnDrag:ne,autoPanOnSelection:L,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:he,noWheelClassName:ge,noPanClassName:_e,disableKeyboardA11y:ve,onViewportChange:Se,isControlledViewport:!!xe,children:(0,H.jsxs)(qu,{children:[(0,H.jsx)(Gu,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:fe,onReconnectStart:pe,onReconnectEnd:me,onlyRenderVisibleElements:T,onEdgeContextMenu:ue,onEdgeMouseEnter:z,onEdgeMouseMove:de,onEdgeMouseLeave:B,reconnectRadius:V,defaultMarkerColor:M,noPanClassName:_e,disableKeyboardA11y:ve,rfId:be}),(0,H.jsx)(td,{style:h,type:m,component:g,containerStyle:_}),(0,H.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,H.jsx)(au,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:le,onlyRenderVisibleElements:T,noPanClassName:_e,noDragClassName:he,disableKeyboardA11y:ve,nodeExtent:ye,rfId:be,nodesDraggable:Ce}),(0,H.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}od.displayName=`GraphView`;var sd=(0,L.memo)(od),cd=Xa(`React Flow`,`https://reactflow.dev/`),ld=({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??pa;us(h,g,_);let{nodesInitialized:x}=ts(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=ro(Oa(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:pa,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:ga.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:{...ya},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:cd,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:ha,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}},ud=({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})=>cc((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 Ma({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...ld({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}=ts(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();us(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}=ss(e,n,r,i,a,o,l);d&&(Qo(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=Uo(e,o.fromHandle,W.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=os(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(Gc(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(Kc(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=>qc(e,!0))):(i(Jc(r,new Set([...e]))),a(Jc(n)))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();t?a(e.map(e=>qc(e,!0))):(a(Jc(n,new Set([...e]))),i(Jc(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(qc(e.id,!1));let u=[];for(let e of c)e.selected&&u.push(qc(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,qc(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,qc(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])&&(ts(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 cs({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:{...ya}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...ld()})}},Object.is);function dd({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,L.useState)(()=>ud({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,H.jsx)(uc,{value:m,children:(0,H.jsx)(ol,{children:(0,H.jsx)(jl,{children:p})})})}function fd({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,L.useContext)(lc)?(0,H.jsx)(H.Fragment,{children:e}):(0,H.jsx)(dd,{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 pd={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function md({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:I=ba.Bezier,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ie,deleteKeyCode:ae=`Backspace`,selectionKeyCode:oe=`Shift`,selectionOnDrag:R=!1,selectionMode:se=va.Full,panActivationKeyCode:ce=`Space`,multiSelectionKeyCode:le=io()?`Meta`:`Control`,zoomActivationKeyCode:ue=io()?`Meta`:`Control`,snapToGrid:z,snapGrid:de,onlyRenderVisibleElements:B=!1,selectNodesOnDrag:V,nodesDraggable:fe,autoPanOnNodeFocus:pe,nodesConnectable:me,nodesFocusable:he,nodeOrigin:ge=Ac,edgesFocusable:_e,edgesReconnectable:ve,elementsSelectable:ye=!0,defaultViewport:be=jc,minZoom:xe=.5,maxZoom:Se=2,translateExtent:Ce=pa,preventScrolling:we=!0,nodeExtent:Te,defaultMarkerColor:Ee=`#b1b1b7`,zoomOnScroll:De=!0,zoomOnPinch:Oe=!0,panOnScroll:ke=!1,panOnScrollSpeed:Ae=.5,panOnScrollMode:je=_a.Free,zoomOnDoubleClick:Me=!0,panOnDrag:Ne=!0,onPaneClick:Pe,onPaneMouseEnter:Fe,onPaneMouseMove:Ie,onPaneMouseLeave:Le,onPaneScroll:Re,onPaneContextMenu:ze,paneClickDistance:Be=1,nodeClickDistance:Ve=0,children:He,onReconnect:Ue,onReconnectStart:We,onReconnectEnd:Ge,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze=10,onNodesChange:Qe,onEdgesChange:$e,noDragClassName:et=`nodrag`,noWheelClassName:tt=`nowheel`,noPanClassName:nt=`nopan`,fitView:rt,fitViewOptions:it,connectOnClick:at,attributionPosition:ot,proOptions:st,defaultEdgeOptions:ct,elevateNodesOnSelect:lt=!0,elevateEdgesOnSelect:ut=!1,disableKeyboardA11y:dt=!1,autoPanOnConnect:ft,autoPanOnNodeDrag:pt,autoPanOnSelection:mt=!0,autoPanSpeed:ht,connectionRadius:gt,isValidConnection:_t,onError:vt,style:yt,id:bt,nodeDragThreshold:xt,connectionDragThreshold:St,viewport:Ct,onViewportChange:wt,width:Tt,height:Et,colorMode:Dt=`light`,debug:Ot,onScroll:kt,ariaLabelConfig:At,zIndexMode:jt=`basic`,...Mt},Nt){let Pt=bt||`1`,Ft=Lc(Dt),It=(0,L.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),kt?.(e)},[kt]);return(0,H.jsx)(`div`,{"data-testid":`rf__wrapper`,...Mt,onScroll:It,style:{...yt,...pd},ref:Nt,className:U([`react-flow`,i,Ft]),id:bt,role:`application`,children:(0,H.jsxs)(fd,{nodes:e,edges:t,width:Tt,height:Et,fitView:rt,fitViewOptions:it,minZoom:xe,maxZoom:Se,nodeOrigin:ge,nodeExtent:Te,zIndexMode:jt,children:[(0,H.jsx)(Fc,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:fe,autoPanOnNodeFocus:pe,nodesConnectable:me,nodesFocusable:he,edgesFocusable:_e,edgesReconnectable:ve,elementsSelectable:ye,elevateNodesOnSelect:lt,elevateEdgesOnSelect:ut,minZoom:xe,maxZoom:Se,nodeExtent:Te,onNodesChange:Qe,onEdgesChange:$e,snapToGrid:z,snapGrid:de,connectionMode:te,translateExtent:Ce,connectOnClick:at,defaultEdgeOptions:ct,fitView:rt,fitViewOptions:it,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:nt,nodeOrigin:ge,rfId:Pt,autoPanOnConnect:ft,autoPanOnNodeDrag:pt,autoPanSpeed:ht,onError:vt,connectionRadius:gt,isValidConnection:_t,selectNodesOnDrag:V,nodeDragThreshold:xt,connectionDragThreshold:St,onBeforeDelete:ee,debug:Ot,ariaLabelConfig:At,zIndexMode:jt}),(0,H.jsx)(sd,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:I,connectionLineStyle:ne,connectionLineComponent:re,connectionLineContainerStyle:ie,selectionKeyCode:oe,selectionOnDrag:R,selectionMode:se,deleteKeyCode:ae,multiSelectionKeyCode:le,panActivationKeyCode:ce,zoomActivationKeyCode:ue,onlyRenderVisibleElements:B,defaultViewport:be,translateExtent:Ce,minZoom:xe,maxZoom:Se,preventScrolling:we,zoomOnScroll:De,zoomOnPinch:Oe,zoomOnDoubleClick:Me,panOnScroll:ke,panOnScrollSpeed:Ae,panOnScrollMode:je,panOnDrag:Ne,autoPanOnSelection:mt,onPaneClick:Pe,onPaneMouseEnter:Fe,onPaneMouseMove:Ie,onPaneMouseLeave:Le,onPaneScroll:Re,onPaneContextMenu:ze,paneClickDistance:Be,nodeClickDistance:Ve,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:F,onReconnect:Ue,onReconnectStart:We,onReconnectEnd:Ge,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze,defaultMarkerColor:Ee,noDragClassName:et,noWheelClassName:tt,noPanClassName:nt,rfId:Pt,disableKeyboardA11y:dt,nodeExtent:Te,viewport:Ct,onViewportChange:wt,nodesDraggable:fe}),(0,H.jsx)(kc,{onSelectionChange:k}),He,(0,H.jsx)(Cc,{proOptions:st,position:ot}),(0,H.jsx)(bc,{rfId:Pt,disableKeyboardA11y:dt})]})})}var hd=tl(md),gd=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function _d(){return K(gd,G)}fa.error014();function vd({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,H.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:U([`react-flow__background-pattern`,n,r])})}function yd({radius:e,className:t}){return(0,H.jsx)(`circle`,{cx:e,cy:e,r:e,className:U([`react-flow__background-pattern`,`dots`,t])})}var bd;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(bd||={});var xd={[bd.Dots]:1,[bd.Lines]:1,[bd.Cross]:6},Sd=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Cd({id:e,variant:t=bd.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,L.useRef)(null),{transform:f,patternId:p}=K(Sd,G),m=r||xd[t],h=t===bd.Dots,g=t===bd.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,H.jsxs)(`svg`,{className:U([`react-flow__background`,l]),style:{...c,...ml,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,H.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,H.jsx)(yd,{radius:y/2,className:u}):(0,H.jsx)(vd,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,H.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}Cd.displayName=`Background`;var wd=(0,L.memo)(Cd);function Td(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,H.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function Ed(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,H.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function Dd(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,H.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 Od(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,H.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 kd(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,H.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 Ad({children:e,className:t,...n}){return(0,H.jsx)(`button`,{type:`button`,className:U([`react-flow__controls-button`,t]),...n,children:e})}var jd=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function Md({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=q(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=K(jd,G),{zoomIn:y,zoomOut:b,fitView:x}=ll();return(0,H.jsxs)(xc,{className:U([`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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Ad,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,H.jsx)(Td,{})}),(0,H.jsx)(Ad,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,H.jsx)(Ed,{})})]}),n&&(0,H.jsx)(Ad,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,H.jsx)(Dd,{})}),r&&(0,H.jsx)(Ad,{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,H.jsx)(kd,{}):(0,H.jsx)(Od,{})}),u]})}Md.displayName=`Controls`,(0,L.memo)(Md);function Nd({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,H.jsx)(`rect`,{className:U([`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 Pd=(0,L.memo)(Nd),Fd=e=>e.nodes.map(e=>e.id),Id=e=>e instanceof Function?e:()=>e;function Ld({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=Pd,onClick:o}){let s=K(Fd,G),c=Id(t),l=Id(e),u=Id(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,H.jsx)(H.Fragment,{children:s.map(e=>(0,H.jsx)(zd,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function Rd({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}=K(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}=oo(r);return{node:r,x:i,y:a,width:o,height:s}},G);return!l||l.hidden||!so(l)?null:(0,H.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 zd=(0,L.memo)(Rd),Bd=(0,L.memo)(Ld),Vd=200,Hd=150,Ud=e=>!e.hidden,Wd=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?Ga(Oa(e.nodeLookup,{filter:Ud}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Gd=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,Kd=(e,t)=>Gd(e.viewBB,t.viewBB)&&Gd(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,qd=`react-flow__minimap-desc`;function Jd({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=q(),S=(0,L.useRef)(null),{boundingRect:C,panZoom:w,viewBB:T,rfId:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=K(Wd,Kd),j=e?.width??Vd,M=e?.height??Hd,N=C.width/j,P=C.height/M,F=Math.max(N,P),ee=F*j,te=F*M,I=b*F,ne=C.x-(ee-C.width)/2-I,re=C.y-(te-C.height)/2-I,ie=ee+I*2,ae=te+I*2,oe=`${qd}-${E}`,R=(0,L.useRef)(0),se=(0,L.useRef)();R.current=F,(0,L.useEffect)(()=>{let e=x.getState().panZoom;if(S.current&&e)return se.current=Ds({domNode:S.current,panZoom:e,getTransform:()=>x.getState().transform,getViewScale:()=>R.current}),()=>{se.current?.destroy()}},[w]),(0,L.useEffect)(()=>{se.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let ce=p?e=>{let[t,n]=se.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,le=(0,L.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m?.(e,n)},[m]),ue=m?le:void 0,z=_??A[`minimap.ariaLabel`];return(0,H.jsx)(xc,{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:U([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,H.jsxs)(`svg`,{width:j,height:M,viewBox:`${ne} ${re} ${ie} ${ae}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":oe,ref:S,onClick:ce,children:[z&&(0,H.jsx)(`title`,{id:oe,children:z}),(0,H.jsx)(Bd,{onClick:ue,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,H.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ne-I},${re-I}h${ie+I*2}v${ae+I*2}h${-ie-I*2}z
|
|
8
|
-
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}Jd.displayName=`MiniMap`,(0,L.memo)(Jd);var Yd=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Xd={[Hs.Line]:`right`,[Hs.Handle]:`bottom-right`};function Zd({nodeId:e,position:t,variant:n=Hs.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=Ol(),y=typeof e==`string`?e:v,b=q(),x=(0,L.useRef)(null),S=n===Hs.Handle,C=K((0,L.useCallback)(Yd(S&&p),[S,p]),G),w=(0,L.useRef)(null),T=t??Xd[n];(0,L.useEffect)(()=>{if(x.current&&y)return w.current||=$s({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=os([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...co({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,H.jsx)(`div`,{className:U([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,L.memo)(Zd);var Qd=`repo-harness.architecture-map.v7`,$d=[`architecture_map_pending`,`registry_unavailable`,`repository_not_found`,`model_unavailable`,`architecture_map_invalid`,`architecture_map_failed`,`architecture_map_timeout`,`architecture_map_process_failed`],ef=[`model_worktree_dirty`,`checkout_changed`,`ownership_unavailable`,`git_read_failed`],tf=[`model_worktree_dirty`,`checkout_changed`,`code_facts_worktree_dirty`,`code_facts_unavailable`,`code_facts_incomplete`,`code_facts_other_commit`,`dependencies_unavailable`],nf=[`git_read_failed`,`history_starts_today`,`archctx_failed`,`path_not_public`],rf=[...tf,`archctx_failed`],af=[...m,`projection_missing`,`projection_invalid`,`tests_model_mismatch`],of=[`model_worktree_dirty`,`checkout_changed`,`git_read_failed`,`dev_activity_pending`,`dev_activity_unavailable`],sf=[`head_missing`,...p,`archctx_failed`,...s,`path_not_public`],cf=[`model_layers_undeclared`],lf=[...rf,`model_layers_undeclared`,`layer_direction_undeclared`,`layer_endpoint_unclassified`],uf={debt:[`debt`,`--json`],flows:[`flows`,`check`,`--no-sync`,`--json`],anchors:[`docs`,`anchors`,`--json`],dependencies:[`deps`,`--json`],layer_direction:[`constraints`,`check`,`--json`]};function df(e){return[`rh`,`arch`,...uf[e]].join(` `)}var ff=[`unowned-path`,`ambiguous-owner`,`stale-anchor`,`state-machine-rule`,`state-machine-stale`],pf=[`host`,`container`,`pod`,`kubernetes`,`pid`,`mount`,`net`,`user`],mf=/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/u,hf=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function gf(e,t){return typeof e!=`string`||!mf.test(e)||t!=null&&(typeof t!=`string`||!hf.test(t))?null:{state:`unavailable`,reason:`archctx_error`,code:e,reason_code:t??null}}function _f(e){return`${e.entrypoint}\0${e.source_symbol}\0${e.sink}`}function vf(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 yf=e=>typeof e==`string`,bf=e=>typeof e==`string`&&e.length>0&&e.length<=4096,xf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,Sf=e=>xf(e)&&e>0,J=e=>t=>yf(t)&&e.test(t),Y=(...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(!n(t))return!1;let r=t;return Object.keys(r).length===Object.keys(e).length&&Object.entries(e).every(([e,t])=>Object.hasOwn(r,e)&&t(r[e]))},Cf=/^([a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)+$/u,wf=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/u,Tf=/^[a-z][a-z0-9-]{0,63}$/u,$=J(Cf),Ef=e=>t=>e(t)&&_(t),Df=Ef(J(/^[^\r\n]{1,4096}$/u)),Of=Q({id:$,kind:J(Tf),name:Ef(bf),status:J(Tf),layer:X(J(wf)),parent:X($),summary:Ef(yf),domain:X(J(wf)),namespace:X(Q({type:Y(...pf)})),mount:X(Q({source:X(Ef(bf)),target:X(Ef(bf)),mode:Y(`ro`,`rw`),order:xf}))}),kf=Q({id:$,kind:J(Tf),source:$,target:$,intent:Ef(yf),protocol:X(Df)}),Af=Q({id:$,files:Sf,lines:xf}),jf=Q({source:$,target:$,imports:Sf}),Mf=e=>Q({state:Y(`unavailable`),reason:Y(...e)}),Nf=(e,t)=>n=>Q({state:Y(`ok`),...e})(n)||Mf(t)(n),Pf=e=>Q({state:Y(`unavailable`),reason:Y(`archctx_error`),code:J(mf),reason_code:X(J(hf))})(e),Ff=J(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u),If=/^(?![/.-])(?!.*\.\.)(?!.*@\{)(?!.*\/[/.])(?!.*[/.]$)(?!.*\.lock(?:\/|$))[^\x00-\x20\x7f~^:?*[\\]{1,255}$/u,Lf=/^(?: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,Rf=J(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/u),zf=Z($),Bf=e=>Z(J(wf))(e)&&e.length>0,Vf=e=>yf(e)&&a(e),Hf=(...e)=>t=>e.some(e=>e(t)),Uf=Z(J(hf)),Wf=J(/^[a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/u),Gf=Y(!0,!1),Kf=e=>({paths:Z(Q({path:e,added:X(xf),deleted:X(xf),owners:zf,reason_codes:Uf})),unowned_paths:Z(e),nodes:Z(Q({id:$,files:Sf})),dependents:Z(Q({id:$,touched:$,relations:zf})),dependency_coverage:Y(`complete`,`partial`),flow_steps:Q({status:Y(`known`,`unknown`),reason_codes:Uf,items:X(Z(Q({flow:$,step:Wf,outcome:X(Wf),reason_codes:Uf})))}),truncated:Q({paths:Gf,nodes:Gf,relations:Gf,flow_steps:Gf,dependents:Gf,model:Gf})}),qf=Q({kind:Y(`nodes`,`relations`,`flows`),id:$,change:Y(`added`,`removed`,`changed`),fields:Z(J(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/u))}),Jf=Q({sha:Ff,subject:Ef(J(/^[^\r\n]{0,4096}$/u)),nodes:zf}),Yf=e=>Hf(Nf({since:Rf,base:Ff,commits:Z(Jf),model:Z(qf),...Kf(e)},nf),Pf),Xf=e=>Hf(Nf(Kf(e),sf),Pf),Zf=Yf(Vf),Qf=Xf(Vf),$f={entrypoint:Wf,source_symbol:Df,sink:Wf},ep=Q({id:Wf,from:Wf,to:Wf,label:Ef(bf),evidence:Q($f)}),tp=Hf(Q({id:$,capability:$,name:Ef(bf),applicability:Y(`required`),participants:Z(Q({id:Wf,node:$})),steps:Z(ep),outcomes:Z(Q({id:Wf,kind:Y(`success`,`error`),label:Ef(bf),steps:Z(ep),terminal:Q({participant:Wf,label:Ef(bf)})}))}),Q({id:$,capability:$,name:Ef(bf),applicability:Y(`not-applicable`),rationale:Ef(bf)})),np=Q({...$f,node:$,source_path:X(Vf),sink_path:X(Vf),sink_symbol:Df}),rp=e=>Z(Q({kind:J(hf),origin:Y(`document`,`node-summary`,`node-responsibility`),path:X(Vf),line:X(Sf),citation:Ef(bf)}))(e)&&e.length>0,ip={severity:Df,message:Df,action:Df},ap=Q({debt:Nf({items:Z(e=>{if(!n(e))return!1;let t=e,r=[`kind`,`nodes`,`paths`];return r.every(e=>Object.hasOwn(t,e))&&Y(...ff)(t.kind)&&zf(t.nodes)&&Z(Vf)(t.paths)&&Object.keys(t).every(e=>r.includes(e)||Object.hasOwn(ip,e)&&ip[e](t[e]))})},rf),flows:Hf(Nf({selectors:xf,proven:xf,unproven:xf,used_unproven:xf,unprovable:Z(Q({id:$,diagnostics:xf})),evidence:Z(Q({...$f,status:J(hf),call_sites:Z(Q({path:Vf,line:X(Sf)}))}))},rf),Pf),anchors:Nf({citations:xf,nodes:Z(Q({id:$,findings:rp}))},rf),dependencies:Nf({edges:Z(jf)},rf),layer_direction:Hf(Nf({imports:xf,edges:Z(Q({source:$,target:$,source_layer:J(wf),target_layer:J(wf),imports:Sf}))},lf),Pf)}),op=Q({state:Y(`ok`),items:Z(Q({id:Df,title:Df,status:X(Df),decided_at:X(Df),applies_to:zf,supersedes:Z(Df),path:Vf}))}),sp=Nf({run:Q({id:Sf,head_sha:Ff,created_at:Rf}),results:Y(`ok`,`junit_missing`,`junit_invalid`),capabilities:Z(Q({id:$,files:Sf,passed:xf,failed:xf,skipped:xf,no_result:xf}))},af),cp=J(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9]\d*$/u),lp=Nf({observed_at:Rf,pull_requests:Z(Q({number:Sf,title:Ef(bf),url:cp,head_sha:X(Ff),impact:Qf}))},of),up=Q({schema_version:Y(Qd),repository_id:J(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u),commit:Ff,head_ref:X(J(If)),archctx_version:J(Lf),collected_at:Rf,nodes:Z(Of),relations:Z(kf),flows:Z(tp),flow_evidence:Z(np),sizes:Nf({nodes:Z(Af)},ef),dependencies:Nf({edges:Z(jf)},tf),layer_order:Nf({layers:Bf},cf),layers:Q({changes:Zf,violations:ap,pull_requests:lp,tests:sp,decisions:op})});function dp(e){return new Set(e).size===e.length}function fp(e,t){let n=new Set(t);return e.every(e=>e.layer===null||n.has(e.layer))}function pp(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 mp=(e,t,n)=>`${e}\0${t??``}\0${n}`;function hp(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=>vf(e).map(({outcome:t,step:n})=>mp(e.id,t,n.id))))}}function gp(e,t){let n=new Set(e.flows.flatMap(e=>vf(e).map(({step:e})=>_f(e.evidence)))),r=new Set(e.flow_evidence.map(_f)),i=e=>dp(e.map(_f))&&e.every(e=>n.has(_f(e))),{flows:a}=e.layers.violations;return dp(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=>dp(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)&&dp(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(_f(e))))}function _p(e,t,n){let r=e.paths.filter(e=>e.owners.length===0).map(e=>e.path),{flow_steps:i}=e;return dp(e.paths.map(e=>e.path))&&e.paths.every(e=>dp(e.owners)&&e.owners.every(n))&&r.length===e.unowned_paths.length&&r.every((t,n)=>t===e.unowned_paths[n])&&dp(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(mp(e.flow,e.outcome,e.step)))}function vp(e,t,n=Vf){if(!(n===Vf?Zf:Yf(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 dp(r.model.map(e=>`${e.kind}\0${e.id}`))&&a(`nodes`,t.nodes)&&a(`relations`,t.relations)&&a(`flows`,t.flows)&&dp(r.commits.map(e=>e.sha))&&r.commits.every(e=>dp(e.nodes)&&e.nodes.every(o))&&_p(r,t,o)}function yp(e,t,n=Vf){if(!(n===Vf?Qf:Xf(n))(e))return!1;let r=e;return r.state!==`ok`||_p(r,t,e=>t.nodes.has(e))}function bp(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 dp(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 xp(e){if(!up(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=hp(t.nodes,t.relations,t.flows),a=e=>n.get(e)?.kind===`capability`,o=(e,t=e=>n.has(e))=>dp(e)&&e.every(t),s=e=>dp(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=>!pp(e.id,n))||t.relations.some(e=>!n.has(e.source)||!n.has(e.target))||t.layer_order.state===`ok`&&(!dp(t.layer_order.layers)||!fp(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)||!vp(t.layers.changes,i)||c.debt.state===`ok`&&c.debt.items.some(e=>!o(e.nodes)||!dp(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)||!bp(t,n)||!gp(t,n)||l.state===`ok`&&(!dp(l.pull_requests.map(e=>String(e.number)))||l.pull_requests.some(e=>!yp(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))||!dp(d.items.map(e=>e.id))||d.items.some(e=>!o(e.applies_to)))throw Error(`architecture_map_invalid`);return t}function Sp(e){let t=e=>n(e)?e:null,r=t(t(e)?.error)?.code;if(r===`archctx_error`){let n=t(t(e)?.archctx);return n===null?null:gf(n.code,n.reason_code)}return $d.includes(r)?{state:`unavailable`,reason:r}:null}var Cp=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`],wp={available:!1,marks:new Map,lit:new Set,edges:[]};function Tp(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 Ep(e){return e.reason_code===null?e.code:`${e.code} ${e.reason_code}`}function Dp(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 Op(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 kp(e,t){return e.paths.filter(e=>e.owners.some(e=>t.has(e))).length}function Ap(e){let{pull_requests:t}=e.layers;return t.state===`ok`?t.pull_requests.find(e=>e.impact.state===`ok`)?.number??null:null}function jp(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 Mp(e,t){return e.dependents.filter(e=>e.id===t).map(e=>e.touched)}function Np(e){return[`paths`,`nodes`,`relations`,`flow_steps`,`dependents`,`model`].filter(t=>e[t])}function Pp(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 Fp(e){return e.failed>0?`danger`:e.passed>0&&e.passed+e.skipped===e.files?`success`:`muted`}function Ip(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 Lp={available:!1,marks:new Map,edges:[]};function Rp(e,t,n=null){let r=Ip(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 Lp;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 Lp;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:Fp(e),count:null,atLeast:!1}]))):Lp}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 Lp;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 zp(e,t,n=null){let r=(t,n=[])=>{let r=Tp(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(Pp(t,e=>{let n=jp(t,e.id);return`+${n.added} −${n.deleted}${n.unknown>0?` ?`:``}`})):wp}if(t===`violations`){if(Object.values(e.layers.violations).every(e=>e.state!==`ok`))return wp;let{dependencies:t}=e.layers.violations;return r(new Map([...Dp(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:Fp(e),label:`${e.passed}/${e.files}`}]))):wp}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(Pp(i,e=>String(e.files))):wp}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 Bp=.85,Vp=24,Hp=120;function Up(e,t){let n=Math.min((t.width-48)/e.width,(t.height-Vp-Hp)/e.height);if(!(t.width>0)||!(t.height>0)||n<Bp)return{x:Vp-e.x*Bp,y:Vp-e.y*Bp,zoom:Bp};let r=Math.min(n,1);return{x:(t.width-e.width*r)/2-e.x*r,y:Vp+(t.height-Vp-Hp-e.height*r)/2-e.y*r,zoom:r}}function Wp({content:e}){let t=q(),n=ll(),r=K(e=>e.panZoom!==null&&e.width>0&&e.height>0),i=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{if(!r||i.current)return;i.current=!0;let{width:a,height:o}=t.getState();n.setViewport(Up(e,{width:a,height:o}))},[r,e,n,t]),null}function Gp(e,t,n,r=!1){return`${r?`≥`:``}${e(t===1?`architecture.unit.${n}One`:`architecture.unit.${n}`,{count:t})}`}function Kp({part:e,reason:t,code:n,children:r}){return(0,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":e,"data-reason":t,"data-code":n,children:r})}function qp({part:e,reason:t,children:n}){return(0,H.jsx)(`div`,{className:`architecture-map__note`,"data-note":e,"data-reason":t,children:n})}function Jp({mark:e}){return e===null?null:(0,H.jsx)(`span`,{className:`architecture-map__mark mono-value`,"data-tone":e.tone,children:e.label})}function Yp({bounds:e,t}){let n=ll(),{zoom:r}=_d();return(0,H.jsxs)(`div`,{className:`architecture-map__zoom`,role:`group`,"aria-label":t(`architecture.map.zoom`),children:[(0,H.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomOut`),onClick:()=>{n.zoomOut()},children:`−`}),(0,H.jsxs)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomReset`),className:`mono-value`,onClick:()=>{n.zoomTo(1)},children:[Math.round(r*100),`%`]}),(0,H.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomIn`),onClick:()=>{n.zoomIn()},children:`+`}),(0,H.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 Xp({part:e,t}){let n=df(e);return(0,H.jsxs)(`div`,{className:`copy-value architecture-map__command`,children:[(0,H.jsx)(`code`,{"data-fix-command":e,children:n}),(0,H.jsx)(f,{label:t(`architecture.inspector.command`),value:n,t})]})}function Zp(e,t){return e.sizes.state===`ok`?e.sizes.nodes.find(e=>e.id===t)??null:null}function Qp(e){return uf[e].filter(e=>!e.startsWith(`--`)).join(` `)}function $p(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)=>{if(!e.nodes.some(e=>t.has(e)))return;let i=e.severity?`[${e.severity}] ${r(`architecture.layer.debt.${e.kind}`)}`:r(`architecture.layer.debt.${e.kind}`),a=e.message?`${i} — ${e.message}`:i;l.push({key:`debt-${n}`,text:a,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=>[_f(e),e.status]));for(let i of e.flows.filter(e=>t.has(e.capability)))vf(i).forEach(({outcome:e,step:t},a)=>{let o=n.get(_f(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 em({facts:e,layer:t,source:n=!1}){return(0,H.jsx)(`ul`,{"data-layer-facts":t,children:e.map(e=>(0,H.jsxs)(`li`,{children:[e.text,e.paths?.length?(0,H.jsx)(`ul`,{children:e.paths.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))}):null,n&&e.part!==void 0&&(0,H.jsx)(`span`,{className:`architecture-map__source mono-value`,"data-fact-source":e.part,children:Qp(e.part)})]},e.key))})}function tm({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=Mp(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=jp(s,r);d(s,t=>a(`architecture.layer.node.changes`,{files:Gp(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:Gp(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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:a(`architecture.layer.${t}`)}),o.length?(0,H.jsx)(em,{facts:o,layer:t}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.layer.node.none`)})]})}function nm({map:e,nodeId:t,t:n}){let{pull_requests:r}=e.layers;if(r.state===`unavailable`)return(0,H.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?Mp(e.impact,t).length>0?[{pr:e,text:n(`architecture.inspector.pr.depends`)}]:[]:[{pr:e,text:n(`architecture.inspector.pr.changes`,{files:Gp(n,r,`file`)})}]});return i.length?(0,H.jsx)(`ul`,{"data-related-prs":!0,children:i.map(({pr:e,text:t})=>(0,H.jsxs)(`li`,{"data-pull-request-number":e.number,children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title,` · `,t]},e.number))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)})}function rm({facts:e,source:t=!1,t:n}){let r=[...new Set(e.flatMap(e=>e.part?[e.part]:[]))];return(0,H.jsxs)(H.Fragment,{children:[e.length?(0,H.jsx)(em,{facts:e,layer:`violations`,source:t}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)}),r.map(e=>(0,H.jsx)(Xp,{part:e,t:n},e))]})}function im({map:e,layer:t,pullRequest:n,nodeId:r,onModule:i,t:a,children:o}){let s=(0,L.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=Zp(e,r);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h3`,{children:c.name}),(0,H.jsx)(`code`,{className:`architecture-map__id`,children:c.id}),(0,H.jsx)(`p`,{children:c.summary}),(0,H.jsxs)(`dl`,{className:`detail-list`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.kind`)}),(0,H.jsx)(`dd`,{children:c.kind})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.layer`)}),(0,H.jsx)(`dd`,{children:c.layer??a(`architecture.none`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.status`)}),(0,H.jsx)(`dd`,{children:c.status})]}),e.sizes.state===`ok`&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.size`)}),(0,H.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,H.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(c.id),children:a(`architecture.map.open`)}),o,(0,H.jsx)(tm,{map:e,layer:t,pullRequest:n,nodeId:c.id,names:s,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.inspector.pullRequests`)}),(0,H.jsx)(nm,{map:e,nodeId:c.id,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),(0,H.jsx)(rm,{facts:$p(e,new Set([c.id]),s,a),t:a}),(0,H.jsx)(am,{map:e,nodeId:c.id,names:s,t:a})]})}function am({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,H.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,H.jsx)(`code`,{children:e.kind}),` `,n.get(t),o!==void 0&&(0,H.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:o})]})]},e.id)}),o=a(`out`),s=a(`in`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.map.outgoing`,{count:o.length})}),o.length?(0,H.jsx)(`ul`,{children:o}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}),(0,H.jsx)(`h4`,{children:r(`architecture.map.incoming`,{count:s.length})}),s.length?(0,H.jsx)(`ul`,{children:s}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)})]})}var om={route:(0,L.memo)(function({data:e,markerStart:t,markerEnd:n,style:r}){let{route:i,label:a}=e;return(0,H.jsx)(gu,{path:ji(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 sm(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Il,{type:`target`,position:W.Top,isConnectable:!1}),(0,H.jsx)(Il,{type:`source`,position:W.Bottom,isConnectable:!1})]})}var cm=e=>[{type:`target`,position:W.Top,x:e.width/2,y:0,width:1,height:1},{type:`source`,position:W.Bottom,x:e.width/2,y:e.height,width:1,height:1}];function lm(e,t,n){let r=URL.createObjectURL(new Blob([na(t,n)],{type:`image/svg+xml`})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}var um=()=>null;function dm({scene:e,nodeTypes:t,view:n,selected:r,emphasis:i=r,routeLabel:a,routeSelection:o=um,onSelect:s,legend:c,t:l}){let u=(0,L.useMemo)(()=>new Map(e.boxes.map(e=>[e.id,n(e)])),[e,n]),d=(0,L.useMemo)(()=>Yi(e),[e]),f=(0,L.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:cm(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,L.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:xa.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,L.useRef)(r);m.current=r;let h=(0,L.useMemo)(()=>new Map(e.routes.map(e=>[e.id,e])),[e]),g=(0,L.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,L.useCallback)(e=>g(e,e=>u.get(e).selection),[g,u]),v=(0,L.useCallback)(e=>g(e,e=>o(h.get(e))),[g,h,o]);return(0,H.jsxs)(hd,{nodes:f,edges:p,nodeTypes:t,edgeTypes:om,onNodesChange:_,onEdgesChange:v,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.05,maxZoom:2,attributionPosition:`top-right`,children:[(0,H.jsx)(Wp,{content:d}),(0,H.jsx)(wd,{variant:bd.Dots,gap:20,size:1.5,color:`var(--rh-diagram-dot)`}),(0,H.jsx)(xc,{position:`bottom-left`,children:(0,H.jsx)(`dl`,{className:`architecture-map__legend`,"aria-label":l(`architecture.map.legend`),children:c.map(e=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:e.swatch}),(0,H.jsx)(`dd`,{children:e.text})]},e.key))})}),(0,H.jsx)(xc,{position:`bottom-right`,children:(0,H.jsx)(Yp,{bounds:d,t:l})})]})}function fm({label:e,...t}){return(0,H.jsx)(`div`,{className:`architecture-map__canvas`,"aria-label":e,role:`region`,children:(0,H.jsx)(dd,{children:(0,H.jsx)(dm,{...t})})})}var pm=25,mm=e=>`domain:${e}`,hm=e=>`${e.source}->${e.target}`;function gm(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 _m(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 gm(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:mm(e),kind:`domain`,name:e,parent:null})),...o.map(e=>({id:e.id,kind:`capability`,name:e.name,parent:e.domain===null?null:mm(e.domain)}))],relations:[...t.edges,...u].map(e=>({id:hm(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=>[hm(e),`added`]),...u.map(e=>[hm(e),`removed`])]),capabilities:new Map(o.map(e=>[e.id,e]))}}function vm(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 ym=e=>e instanceof Error&&/^[a-z][a-z0-9_]{0,63}$/u.test(e.message)?e.message:`unavailable`;function bm(e,t,n){let r={path:e,timeline:null,error:null,more:{loading:!1,error:null}},[i,a]=(0,L.useState)(r),s=(0,L.useRef)(null),c=(0,L.useCallback)(async n=>{let i=t=>{s.current?.path!==e&&(s.current=null),a(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 a(e=>e.error===null?e:{...e,error:null}),!0;if(`state`in r)return i(r.reason),l(r);let o=r.body,c=Math.max(0,o.total-pm),u=o;if(o.total>1){let r=await t(`${e}?offset=${c}&limit=${pm}&ref=${o.head}`,null,n);if(n.aborted)return!1;if(`state`in r)return i(r.reason),l(r);u=r.body}return s.current=r.etag===null?null:{path:e,etag:r.etag},a({path:e,timeline:{head:o.head,total:o.total,start:c,milestones:u.milestones},error:null,more:{loading:!1,error:null}}),!0}catch(e){return n.aborted||i(ym(e)),!1}},[e,t]),u=o(c,JSON.stringify([e,n])),d=i.path===e?i:r,f=(0,L.useCallback)(()=>{let n=d.timeline;if(n===null||d.more.loading||n.start===0)return;let r=Math.max(0,n.start-pm),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(ym(e)))},[e,t,d]);return{...d,loadMore:f,retry:u}}var xm={added:`+`,removed:`−`,renamed:`~`,inside:`•`},Sm=e=>e.slice(0,7),Cm={box:(0,L.memo)(function({id:e,data:t,selected:n}){let{name:r,diff:i,from:a,quiet:o}=t;return(0,H.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,H.jsx)(sm,{}),(0,H.jsx)(`b`,{className:`architecture-history__mark`,"aria-hidden":`true`,children:i&&xm[i]}),(0,H.jsxs)(`span`,{className:`architecture-history__name`,children:[(0,H.jsx)(`span`,{children:r}),a!==null&&(0,H.jsx)(`s`,{className:`architecture-history__from`,children:a})]})]})}),group:(0,L.memo)(function({id:e,data:t}){return(0,H.jsxs)(`div`,{className:`architecture-history__group`,"data-node-id":e,children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`span`,{children:[t.name,` · `,t.count]})]})})};function wm(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 Tm(e,t){return{nodes:e.input.nodes,relations:e.input.relations.map(e=>({...e,kind:t.get(e.id)??`relation`}))}}var Em=[`removed`,`added`,`renamed`,`inside`];function Dm(e,t){for(let n of Em)for(let[r,i]of e.nodes)if(i===n&&t.capabilities.has(r))return r;return t.capabilities.keys().next().value??null}function Om(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 km(e){return[...[`added`,`removed`,`renamed`,`inside`].map(t=>({key:t,swatch:(0,H.jsx)(`i`,{className:`architecture-history__swatch`,"data-diff":t}),text:e(`architecture.history.diff.${t}`)})),...[`added`,`removed`].map(t=>({key:`edge-${t}`,swatch:(0,H.jsx)(`i`,{className:`architecture-history__line`,"data-diff":t}),text:e(`architecture.history.edge.${t}`)}))]}function Am({milestone:e,shape:t,marks:n,skipped:r,selected:i,onSelect:a,t:o}){let[s,c]=(0,L.useState)(!1),l=e.delta.baseRev!==null,u=l&&s,d=(0,L.useMemo)(()=>da(Tm(t,n.edges)),[t,n]),f=(0,L.useMemo)(()=>new Map(t.input.nodes.map(e=>[e.id,e])),[t]),p=(0,L.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,L.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,L.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,L.useMemo)(()=>km(o),[o]);return(0,H.jsxs)(`div`,{className:`architecture-history__stage`,"data-focus":u||void 0,children:[(0,H.jsxs)(`div`,{className:`architecture-history__bar`,children:[(0,H.jsx)(`p`,{className:`architecture-history__caption`,"data-base-rev":e.delta.baseRev??``,children:Om(e,r,o)}),(0,H.jsxs)(`label`,{className:`architecture-history__focus`,children:[(0,H.jsx)(`button`,{type:`button`,role:`switch`,className:`architecture-history__switch`,"aria-checked":u,disabled:!l,onClick:()=>c(!s)}),o(`architecture.history.focus`)]})]}),(0,H.jsx)(fm,{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 jm({github:e,rev:t}){return e===null?(0,H.jsx)(`code`,{children:Sm(t)}):(0,H.jsxs)(`a`,{href:`https://github.com/${e}/commit/${t}`,target:`_blank`,rel:`noreferrer`,children:[(0,H.jsx)(`code`,{children:Sm(t)}),` ↗`]})}function Mm({milestone:e,skipped:t,t:n}){if(e.error)return(0,H.jsx)(`span`,{className:`architecture-history__chips`,children:(0,H.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`error`,children:e.error.code})});let{delta:r}=e;if(r.baseRev===null)return(0,H.jsx)(`span`,{className:`architecture-history__chips`,children:(0,H.jsx)(`span`,{className:`architecture-history__chip`,children:n(`architecture.history.chip.first`)})});let i=r.edgesChanged.added.length+r.edgesChanged.removed.length,a=gm(r).size;return(0,H.jsxs)(`span`,{className:`architecture-history__chips`,children:[r.added.length>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`added`,children:[`+`,r.added.length]}),r.removed.length>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`removed`,children:[`−`,r.removed.length]}),r.renamed.length>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`renamed`,children:[`~`,r.renamed.length]}),a>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`inside`,title:n(`architecture.history.diff.inside`),children:[`•`,a]}),i>0&&(0,H.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,H.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`gap`,children:n(`architecture.history.chip.gap`,{count:t,rev:Sm(r.baseRev)})})]})}function Nm({timeline:e,selected:t,onSelect:n,more:r,onMore:i,t:a}){let{milestones:o}=e,s=(0,L.useMemo)(()=>[...o].reverse(),[o]),c=(0,L.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,H.jsxs)(`nav`,{className:`architecture-history__timeline`,"aria-label":a(`architecture.history.timeline`),children:[e.total===0&&(0,H.jsx)(`p`,{className:`architecture-history__empty`,children:a(`architecture.history.empty`)}),(0,H.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,H.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,H.jsxs)(`span`,{className:`architecture-history__top`,children:[(0,H.jsx)(`code`,{children:Sm(e.rev)}),(0,H.jsx)(`time`,{dateTime:e.date,title:e.date,children:e.date.slice(5,10)})]}),(0,H.jsx)(`span`,{className:`architecture-history__subject`,title:e.subject,children:e.subject}),(0,H.jsx)(Mm,{milestone:e,skipped:e.error?0:vm(o,e),t:a})]},e.rev))}),e.start>0&&(0,H.jsx)(`button`,{type:`button`,className:`architecture-history__load`,disabled:r.loading,onClick:i,children:a(`architectureHistory.more`,{count:Math.min(pm,e.start),head:Sm(e.head)})}),r.error!==null&&(0,H.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 Pm(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 Fm(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 Im({milestone:e,shape:t,marks:n,skipped:r,selected:i,github:a,t:o}){let s=o(`architectureHistory.node`);if(e.error)return(0,H.jsx)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,children:(0,H.jsxs)(`p`,{className:`architecture-history__callout`,"data-tone":`error`,"data-gap":`milestone`,"data-code":e.error.code,children:[o(`architecture.history.error`),` `,(0,H.jsx)(`code`,{children:e.error.code}),e.error.path&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`br`,{}),(0,H.jsx)(`code`,{children:e.error.path})]})]})});let{baseRev:c}=e.delta,l=i===null?null:t.capabilities.get(i),u=l===null?[]:Fm(e,l.id),d=e=>{let n=t.capabilities.get(e);return n===void 0?(0,H.jsx)(`code`,{children:e}):n.name};return(0,H.jsxs)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,"data-node-id":l?.id,children:[l!==null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`header`,{children:[(0,H.jsx)(`p`,{className:`architecture-history__eyebrow`,children:l.domain??`—`}),(0,H.jsx)(`h3`,{children:l.name}),(0,H.jsx)(`code`,{children:l.id})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{children:o(`architectureHistory.milestone`)}),(0,H.jsx)(`p`,{"data-diff":n.nodes.get(l.id),children:Pm(l.id,e,n,t,o)})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{children:o(`architectureHistory.relations`)}),u.length===0?(0,H.jsx)(`p`,{className:`architecture-history__quiet`,children:o(`architectureHistory.none`)}):(0,H.jsx)(`ul`,{children:u.map(({edge:e,diff:t})=>(0,H.jsxs)(`li`,{"data-diff":t,children:[(0,H.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":t,children:t===`added`?`+`:`−`}),(0,H.jsxs)(`span`,{children:[d(e.source),` → `,d(e.target)]})]},`${t}:${hm(e)}`))})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{children:o(`architecture.history.base`)}),c===null?(0,H.jsx)(`p`,{className:`architecture-history__quiet`,"data-base-rev":``,children:o(`architecture.history.first`)}):(0,H.jsxs)(`p`,{"data-base-rev":c,children:[(0,H.jsx)(jm,{github:a,rev:c}),r!==null&&r>0&&(0,H.jsxs)(`span`,{className:`architecture-history__quiet`,"data-gap":`skipped`,"data-count":r,children:[` `,o(`architectureHistory.base.skipped`,{count:r})]})]})]})]})}function Lm({path:e,github:t,read:n,refreshGeneration:r,selection:i,select:a,onSummary:o,t:s}){let l=bm(e,n,r),[u,d]=(0,L.useState)(null),{timeline:f}=l,p=(0,L.useMemo)(()=>f?.milestones??[],[f]),m=p.find(e=>e.rev===u)??p.at(-1)??null,h=m===null||m.error?null:m,g=(0,L.useMemo)(()=>h===null?null:_m(p,h),[p,h]),_=(0,L.useMemo)(()=>h===null||g===null?null:wm(h,g),[h,g]),v=h===null?0:vm(p,h),y=h!==null&&i?.scope===h.rev?i:null,b=g===null||_===null?null:y===null?Dm(_,g):y.id!==null&&g.capabilities.has(y.id)?y.id:null,x=h?.rev??``,S=(0,L.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,L.useEffect)(()=>{o(w===null?null:{head:w,read:p.length,total:T})},[w,p.length,T,o]),(0,L.useEffect)(()=>()=>o(null),[o]),f===null?l.error===`history_shallow_repository`?(0,H.jsxs)(`section`,{className:`architecture-history__whole-error`,role:`alert`,"data-error-code":l.error,children:[(0,H.jsx)(`code`,{children:`history-shallow-repository`}),(0,H.jsx)(`p`,{children:s(`architecture.history.shallow`)}),(0,H.jsx)(c,{command:`git fetch --unshallow`,t:s})]}):l.error===null?(0,H.jsx)(`p`,{role:`status`,children:s(`architecture.history.loading`)}):(0,H.jsx)(`p`,{className:`architecture-notice`,role:`alert`,"data-error-code":l.error,children:s(`architecture.failed`,{code:l.error})}):(0,H.jsxs)(`div`,{className:`architecture-history`,children:[l.error!==null&&(0,H.jsxs)(`div`,{className:`architecture-history__banner`,role:`alert`,"data-error-code":l.error,children:[(0,H.jsx)(`span`,{children:s(`architecture.refreshFailed`,{code:l.error})}),(0,H.jsx)(`button`,{type:`button`,onClick:l.retry,children:s(`architecture.history.retry`)})]}),(0,H.jsx)(`div`,{className:`architecture-history__body`,"data-stale":l.error!==null||void 0,children:m===null?(0,H.jsx)(`p`,{className:`architecture-history__empty`,children:s(`architecture.history.empty`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Nm,{timeline:f,selected:m.rev,onSelect:C,more:l.more,onMore:l.loadMore,t:s}),m.error?(0,H.jsxs)(`section`,{className:`architecture-history__canvas`,"aria-label":s(`architecture.history.map`),children:[(0,H.jsx)(`p`,{className:`architecture-history__caption`,children:s(`architectureHistory.caption.error`,{rev:Sm(m.rev)})}),(0,H.jsxs)(`div`,{className:`architecture-history__canvas-error`,children:[(0,H.jsx)(`code`,{children:m.error.code}),m.error.path&&(0,H.jsx)(`p`,{children:(0,H.jsx)(`code`,{children:m.error.path})})]})]}):(0,H.jsx)(Am,{milestone:m,shape:g,marks:_,skipped:v,selected:b,onSelect:S,t:s},m.rev),(0,H.jsx)(Im,{milestone:m,shape:g,marks:_,skipped:v,selected:b,github:t,t:s})]})})]})}var Rm=40,zm=96,Bm=12,Vm=24,Hm=e=>`label:${e}`,Um=(e,t)=>(t.lines??0)-(e.lines??0)||e.node.name.localeCompare(t.node.name);function Wm(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=la.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=>Bm*(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(Um),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:Vm+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`?Bm:-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:Hm(e.layer),parent:null,x:Vm,y:e.y,width:zm,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`)+Vm,height:48+t.length*56+Math.max(0,t.length-1)*Rm};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 Gm=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e).toLowerCase(),Km=7,qm=e=>`L${e.index} ${e.layer}`,Jm=e=>e.members.map(e=>e.node.name).join(` · `),Ym={label:(0,L.memo)(function({data:e}){return(0,H.jsx)(`span`,{className:`architecture-layermap__band`,children:qm(e.band)})}),layer:(0,L.memo)(function({data:e,selected:t}){let{band:n,t:r}=e;return(0,H.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,H.jsx)(sm,{}),(0,H.jsx)(`strong`,{children:n.layer}),(0,H.jsx)(`span`,{className:`architecture-layermap__members`,title:Jm(n),children:n.members.length===0?r(`architecture.layers.empty`):Jm(n)}),n.lines!==null&&(0,H.jsx)(`span`,{className:`architecture-layermap__lines mono-value`,children:Gm(n.lines)})]})})};function Xm(e,t){return[{key:`code`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.layers.legend.runtime`)},...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,H.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k`}),text:t(`architecture.layers.legend.lines`)}]:[]]}function Zm(e){return t=>{let n=e.get(t.id);return t.id===n.layer?[n.layer,[...n.lines===null?[]:[Gm(n.lines)],Jm(n)].filter(Boolean).join(` · `)]:[qm(n)]}}function Qm({band:e,t}){let n=e.members.filter(e=>e.lines>0);if(n.length===0)return(0,H.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.map.noSize`)});let r=n.slice(0,Km),i=n.slice(Km),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,H.jsx)(`ul`,{className:`architecture-layermap__sizes`,"data-layer-sizes":!0,children:a.map(e=>(0,H.jsxs)(`li`,{"data-size-row":e.key,children:[(0,H.jsx)(`span`,{className:`architecture-layermap__size-name`,title:e.name,children:e.name}),(0,H.jsx)(`span`,{className:`architecture-layermap__bar`,children:(0,H.jsx)(`span`,{style:{width:`${Math.round(e.lines/o*100)}%`}})}),(0,H.jsx)(`span`,{className:`mono-value`,children:Gm(e.lines)})]},e.key))})}function $m({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:Ep(r)}):n(`architecture.layer.reason.${r.reason}`);return(0,H.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,H.jsxs)(H.Fragment,{children:[i.size===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.layers.violations.none`)}):(0,H.jsx)(`ul`,{className:`architecture-layermap__pairs`,"data-layer-violations":!0,children:[...i.values()].map(e=>(0,H.jsxs)(`li`,{"data-pair":`${e.source}->${e.target}`,children:[(0,H.jsxs)(`span`,{children:[e.source,` → `,e.target]}),(0,H.jsx)(`span`,{className:`mono-value`,children:e.imports}),(0,H.jsx)(`span`,{className:`architecture-layermap__verdict`,children:n(`architecture.layers.violation`)})]},`${e.source}-${e.target}`))}),(0,H.jsx)(`p`,{className:`detail-quiet`,"data-layer-checked":!0,children:n(`architecture.layers.checked`,{imports:r.imports})})]})}var eh=e=>[`${e.source} → ${e.target}`,...e.protocols].join(` · `);function th({lanes:e,t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:t(`architecture.modules.relations`,{count:e.length})}),e.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.none`)}):(0,H.jsx)(`ul`,{"data-layer-lanes":!0,children:e.map(e=>{let n=e.side===`right`?`out`:`in`;return(0,H.jsxs)(`li`,{"data-lane":e.route.id,"data-direction":n,children:[(0,H.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,H.jsx)(`span`,{className:`mono-value`,children:t(`architecture.modules.direction.${n}`)}),` `,n===`out`?e.target:e.source,e.protocols.length>0&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`code`,{children:e.protocols.join(` · `)})]})]},e.route.id)})})]})}function nh({map:e,band:t,lanes:n,t:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,H.jsxs)(`span`,{className:`architecture-modules__eyebrow`,children:[`L`,t.index]}),(0,H.jsx)(`h3`,{children:t.layer}),t.files!==null&&(0,H.jsx)(`span`,{className:`detail-quiet`,"data-layer-size":!0,children:r(`architecture.map.sizeValue`,{lines:t.lines,files:t.files})})]}),(0,H.jsx)(th,{lanes:n,t:r}),e.sizes.state===`ok`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.layers.size`)}),(0,H.jsx)(Qm,{band:t,t:r})]}),(0,H.jsx)(`h4`,{children:r(`architecture.layer.violations.layer_direction.label`)}),(0,H.jsx)($m,{map:e,layer:t.layer,t:r}),(0,H.jsxs)(`details`,{className:`architecture-layermap__nodes`,children:[(0,H.jsx)(`summary`,{children:r(`architecture.layers.members`,{count:t.members.length})}),(0,H.jsx)(`ul`,{children:t.members.map(e=>(0,H.jsxs)(`li`,{"data-member":e.node.id,children:[e.node.name,` `,(0,H.jsx)(`span`,{className:`detail-quiet`,children:e.node.kind})]},e.node.id))})]})]})}function rh({map:e,t}){return e.sizes.state===`unavailable`?(0,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`sizes`,"data-reason":e.sizes.reason,children:t(`architecture.map.sizes.${e.sizes.reason}`)}):null}function ih({map:e,order:t,selected:n,onSelect:r,t:i}){let a=(0,L.useMemo)(()=>Wm(e,t),[e,t]),o=a.bands.find(e=>e.layer===n)??null,s=o?.layer??null,c=(0,L.useMemo)(()=>a.scene(s),[a,s]),l=(0,L.useMemo)(()=>a.lanes(s),[a,s]),u=e.nodes.filter(e=>e.layer===null).length,d=(0,L.useMemo)(()=>new Map(a.bands.flatMap(e=>[[Hm(e.layer),e],[e.layer,e]])),[a]),f=(0,L.useCallback)(e=>{let t=d.get(e.id);return e.id===t.layer?{type:`layer`,ariaLabel:qm(t),selection:t.layer,data:{band:t,t:i}}:{type:`label`,ariaLabel:qm(t),selection:null,data:{band:t}}},[d,i]),p=(0,L.useCallback)(e=>eh(l.find(t=>t.route.id===e.id)),[l]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`architecture-lens`,children:(0,H.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,H.jsx)(`span`,{"data-layers-provenance":!0,children:i(`architecture.layers.provenance`,{version:e.archctx_version})}),(0,H.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-layers-export":!0,onClick:()=>lm(`layers-${e.commit.slice(0,7)}.svg`,c,Zm(d)),children:i(`architecture.layers.export`)})]})}),(0,H.jsxs)(`div`,{className:`architecture-map`,"data-view":`layers`,"data-layer-count":a.bands.length,"data-lane-count":l.length,children:[(0,H.jsx)(fm,{label:i(`architecture.layers.label`),scene:c,nodeTypes:Ym,view:f,selected:s,routeLabel:p,onSelect:r,legend:Xm(e,i),t:i}),(0,H.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":i(`architecture.layers.inspector`),"data-layer-id":s??void 0,children:[(0,H.jsx)(rh,{map:e,t:i}),u>0&&(0,H.jsx)(qp,{part:`layers.unlayered`,reason:`node_layer_undeclared`,children:i(`architecture.layers.unlayered`,{count:u})}),o===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.layers.pick`)}):(0,H.jsx)(nh,{map:e,band:o,lanes:l,t:i})]})]})]})}function ah({map:e,selectedId:t,onSelect:n,t:r}){let i=e.layer_order;return i.state===`unavailable`?(0,H.jsx)(`div`,{className:`architecture-map`,"data-view":`layers`,children:(0,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`layer_order`,"data-reason":i.reason,children:r(`architecture.layers.${i.reason}`)})}):(0,H.jsx)(ih,{map:e,order:i.layers,selected:t,onSelect:n,t:r},e.commit)}var oh=200,sh=64,ch=8,lh=12,uh=30,dh=26,fh=16,ph=72,mh=24,hh=1,gh=e=>`domain:${e}`,_h=e=>24+7*e.length,vh=(e,t)=>Math.round((1+5*Math.sqrt(e/t))*100)/100,yh=e=>e===1?1:e<=4?2:3;function bh(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`})]})})}Jd.displayName=`MiniMap`,(0,L.memo)(Jd);var Yd=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Xd={[Hs.Line]:`right`,[Hs.Handle]:`bottom-right`};function Zd({nodeId:e,position:t,variant:n=Hs.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=Ol(),y=typeof e==`string`?e:v,b=q(),x=(0,L.useRef)(null),S=n===Hs.Handle,C=K((0,L.useCallback)(Yd(S&&p),[S,p]),G),w=(0,L.useRef)(null),T=t??Xd[n];(0,L.useEffect)(()=>{if(x.current&&y)return w.current||=$s({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=os([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...co({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,H.jsx)(`div`,{className:U([`react-flow__resize-control`,`nodrag`,...E,n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,L.memo)(Zd);var Qd=`repo-harness.architecture-map.v7`,$d=[`architecture_map_pending`,`registry_unavailable`,`repository_not_found`,`model_unavailable`,`architecture_map_invalid`,`architecture_map_failed`,`architecture_map_timeout`,`architecture_map_process_failed`],ef=[`model_worktree_dirty`,`checkout_changed`,`ownership_unavailable`,`git_read_failed`],tf=[`model_worktree_dirty`,`checkout_changed`,`code_facts_worktree_dirty`,`code_facts_unavailable`,`code_facts_incomplete`,`code_facts_other_commit`,`dependencies_unavailable`],nf=[`model_layers_undeclared`],rf=[`host`,`container`,`pod`,`kubernetes`,`pid`,`mount`,`net`,`user`],af=/^[A-Z][A-Z0-9]*(?:_[A-Z0-9]+)+$/u,of=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/u;function sf(e,t){return typeof e!=`string`||!af.test(e)||t!=null&&(typeof t!=`string`||!of.test(t))?null:{state:`unavailable`,reason:`archctx_error`,code:e,reason_code:t??null}}function cf(e){return`${e.entrypoint}\0${e.source_symbol}\0${e.sink}`}function lf(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 uf=[`git_read_failed`,`history_starts_today`,`archctx_failed`,`path_not_public`],df=[...tf,`archctx_failed`],ff=[...m,`projection_missing`,`projection_invalid`,`tests_model_mismatch`],pf=[`model_worktree_dirty`,`checkout_changed`,`git_read_failed`,`dev_activity_pending`,`dev_activity_unavailable`],mf=[`head_missing`,...p,`archctx_failed`,...s,`path_not_public`],hf=[...df,`model_layers_undeclared`,`layer_direction_undeclared`,`layer_endpoint_unclassified`],gf={debt:[`debt`,`--json`],flows:[`flows`,`check`,`--no-sync`,`--json`],anchors:[`docs`,`anchors`,`--json`],dependencies:[`deps`,`--json`],layer_direction:[`constraints`,`check`,`--json`]};function _f(e){return[`rh`,`arch`,...gf[e]].join(` `)}var vf=[`unowned-path`,`ambiguous-owner`,`stale-anchor`,`state-machine-rule`,`state-machine-stale`],yf=e=>typeof e==`string`,bf=e=>typeof e==`string`&&e.length>0&&e.length<=4096,xf=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,Sf=e=>xf(e)&&e>0,J=e=>t=>yf(t)&&e.test(t),Y=(...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(!_(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]))},Cf=/^([a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)*::)?[a-z][a-z0-9]*(\.[a-z0-9][a-z0-9-]*)+$/u,wf=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/u,Tf=/^[a-z][a-z0-9-]{0,63}$/u,$=J(Cf),Ef=e=>t=>e(t)&&a(t),Df=Ef(J(/^[^\r\n]{1,4096}$/u)),Of=Q({id:$,kind:J(Tf),name:Ef(bf),status:J(Tf),layer:X(J(wf)),parent:X($),summary:Ef(yf),domain:X(J(wf)),namespace:X(Q({type:Y(...rf)})),mount:X(Q({source:X(Ef(bf)),target:X(Ef(bf)),mode:Y(`ro`,`rw`),order:xf}))}),kf=Q({id:$,kind:J(Tf),source:$,target:$,intent:Ef(yf),protocol:X(Df)}),Af=Q({id:$,files:Sf,lines:xf}),jf=Q({source:$,target:$,imports:Sf}),Mf=e=>Q({state:Y(`unavailable`),reason:Y(...e)}),Nf=(e,t)=>n=>Q({state:Y(`ok`),...e})(n)||Mf(t)(n),Pf=e=>Q({state:Y(`unavailable`),reason:Y(`archctx_error`),code:J(af),reason_code:X(J(of))})(e),Ff=J(/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/u),If=/^(?![/.-])(?!.*\.\.)(?!.*@\{)(?!.*\/[/.])(?!.*[/.]$)(?!.*\.lock(?:\/|$))[^\x00-\x20\x7f~^:?*[\\]{1,255}$/u,Lf=/^(?: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,Rf=J(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,3})?Z$/u),zf=Z($),Bf=e=>Z(J(wf))(e)&&e.length>0,Vf=e=>yf(e)&&n(e),Hf=(...e)=>t=>e.some(e=>e(t)),Uf=Z(J(of)),Wf=J(/^[a-z][a-z0-9-]*(?:\.[a-z0-9][a-z0-9-]*)*$/u),Gf=Y(!0,!1),Kf=e=>({paths:Z(Q({path:e,added:X(xf),deleted:X(xf),owners:zf,reason_codes:Uf})),unowned_paths:Z(e),nodes:Z(Q({id:$,files:Sf})),dependents:Z(Q({id:$,touched:$,relations:zf})),dependency_coverage:Y(`complete`,`partial`),flow_steps:Q({status:Y(`known`,`unknown`),reason_codes:Uf,items:X(Z(Q({flow:$,step:Wf,outcome:X(Wf),reason_codes:Uf})))}),truncated:Q({paths:Gf,nodes:Gf,relations:Gf,flow_steps:Gf,dependents:Gf,model:Gf})}),qf=Q({kind:Y(`nodes`,`relations`,`flows`),id:$,change:Y(`added`,`removed`,`changed`),fields:Z(J(/^[A-Za-z][A-Za-z0-9_-]{0,127}$/u))}),Jf=Q({sha:Ff,subject:Ef(J(/^[^\r\n]{0,4096}$/u)),nodes:zf}),Yf=e=>Hf(Nf({since:Rf,base:Ff,commits:Z(Jf),model:Z(qf),...Kf(e)},uf),Pf),Xf=e=>Hf(Nf(Kf(e),mf),Pf),Zf=Yf(Vf),Qf=Xf(Vf),$f={entrypoint:Wf,source_symbol:Df,sink:Wf},ep=Q({id:Wf,from:Wf,to:Wf,label:Ef(bf),evidence:Q($f)}),tp=Hf(Q({id:$,capability:$,name:Ef(bf),applicability:Y(`required`),participants:Z(Q({id:Wf,node:$})),steps:Z(ep),outcomes:Z(Q({id:Wf,kind:Y(`success`,`error`),label:Ef(bf),steps:Z(ep),terminal:Q({participant:Wf,label:Ef(bf)})}))}),Q({id:$,capability:$,name:Ef(bf),applicability:Y(`not-applicable`),rationale:Ef(bf)})),np=Q({...$f,node:$,source_path:X(Vf),sink_path:X(Vf),sink_symbol:Df}),rp=e=>Z(Q({kind:J(of),origin:Y(`document`,`node-summary`,`node-responsibility`),path:X(Vf),line:X(Sf),citation:Ef(bf)}))(e)&&e.length>0,ip={severity:Df,message:Df,action:Df},ap=Q({debt:Nf({items:Z(e=>{if(!_(e))return!1;let t=e,n=[`kind`,`nodes`,`paths`];return n.every(e=>Object.hasOwn(t,e))&&Y(...vf)(t.kind)&&zf(t.nodes)&&Z(Vf)(t.paths)&&Object.keys(t).every(e=>n.includes(e)||Object.hasOwn(ip,e)&&ip[e](t[e]))})},df),flows:Hf(Nf({selectors:xf,proven:xf,unproven:xf,used_unproven:xf,unprovable:Z(Q({id:$,diagnostics:xf})),evidence:Z(Q({...$f,status:J(of),call_sites:Z(Q({path:Vf,line:X(Sf)}))}))},df),Pf),anchors:Nf({citations:xf,nodes:Z(Q({id:$,findings:rp}))},df),dependencies:Nf({edges:Z(jf)},df),layer_direction:Hf(Nf({imports:xf,edges:Z(Q({source:$,target:$,source_layer:J(wf),target_layer:J(wf),imports:Sf}))},hf),Pf)}),op=Q({state:Y(`ok`),items:Z(Q({id:Df,title:Df,status:X(Df),decided_at:X(Df),applies_to:zf,supersedes:Z(Df),path:Vf}))}),sp=Nf({run:Q({id:Sf,head_sha:Ff,created_at:Rf}),results:Y(`ok`,`junit_missing`,`junit_invalid`),capabilities:Z(Q({id:$,files:Sf,passed:xf,failed:xf,skipped:xf,no_result:xf}))},ff),cp=J(/^https:\/\/github\.com\/[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+\/pull\/[1-9]\d*$/u),lp=Nf({observed_at:Rf,pull_requests:Z(Q({number:Sf,title:Ef(bf),url:cp,head_sha:X(Ff),impact:Qf}))},pf),up=Q({schema_version:Y(Qd),repository_id:J(/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/u),commit:Ff,head_ref:X(J(If)),archctx_version:J(Lf),collected_at:Rf,nodes:Z(Of),relations:Z(kf),flows:Z(tp),flow_evidence:Z(np),sizes:Nf({nodes:Z(Af)},ef),dependencies:Nf({edges:Z(jf)},tf),layer_order:Nf({layers:Bf},nf),layers:Q({changes:Zf,violations:ap,pull_requests:lp,tests:sp,decisions:op})});function dp(e){return new Set(e).size===e.length}function fp(e,t){let n=new Set(t);return e.every(e=>e.layer===null||n.has(e.layer))}function pp(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 mp=(e,t,n)=>`${e}\0${t??``}\0${n}`;function hp(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=>lf(e).map(({outcome:t,step:n})=>mp(e.id,t,n.id))))}}function gp(e,t){let n=new Set(e.flows.flatMap(e=>lf(e).map(({step:e})=>cf(e.evidence)))),r=new Set(e.flow_evidence.map(cf)),i=e=>dp(e.map(cf))&&e.every(e=>n.has(cf(e))),{flows:a}=e.layers.violations;return dp(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=>dp(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)&&dp(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(cf(e))))}function _p(e,t,n){let r=e.paths.filter(e=>e.owners.length===0).map(e=>e.path),{flow_steps:i}=e;return dp(e.paths.map(e=>e.path))&&e.paths.every(e=>dp(e.owners)&&e.owners.every(n))&&r.length===e.unowned_paths.length&&r.every((t,n)=>t===e.unowned_paths[n])&&dp(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(mp(e.flow,e.outcome,e.step)))}function vp(e,t,n=Vf){if(!(n===Vf?Zf:Yf(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 dp(r.model.map(e=>`${e.kind}\0${e.id}`))&&a(`nodes`,t.nodes)&&a(`relations`,t.relations)&&a(`flows`,t.flows)&&dp(r.commits.map(e=>e.sha))&&r.commits.every(e=>dp(e.nodes)&&e.nodes.every(o))&&_p(r,t,o)}function yp(e,t,n=Vf){if(!(n===Vf?Qf:Xf(n))(e))return!1;let r=e;return r.state!==`ok`||_p(r,t,e=>t.nodes.has(e))}function bp(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 dp(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 xp(e){if(!up(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=hp(t.nodes,t.relations,t.flows),a=e=>n.get(e)?.kind===`capability`,o=(e,t=e=>n.has(e))=>dp(e)&&e.every(t),s=e=>dp(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=>!pp(e.id,n))||t.relations.some(e=>!n.has(e.source)||!n.has(e.target))||t.layer_order.state===`ok`&&(!dp(t.layer_order.layers)||!fp(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)||!vp(t.layers.changes,i)||c.debt.state===`ok`&&c.debt.items.some(e=>!o(e.nodes)||!dp(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)||!bp(t,n)||!gp(t,n)||l.state===`ok`&&(!dp(l.pull_requests.map(e=>String(e.number)))||l.pull_requests.some(e=>!yp(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))||!dp(d.items.map(e=>e.id))||d.items.some(e=>!o(e.applies_to)))throw Error(`architecture_map_invalid`);return t}function Sp(e){let t=e=>_(e)?e:null,n=t(t(e)?.error)?.code;if(n===`archctx_error`){let n=t(t(e)?.archctx);return n===null?null:sf(n.code,n.reason_code)}return $d.includes(n)?{state:`unavailable`,reason:n}:null}var Cp=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`],wp={available:!1,marks:new Map,lit:new Set,edges:[]};function Tp(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 Ep(e){return e.reason_code===null?e.code:`${e.code} ${e.reason_code}`}function Dp(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 Op(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 kp(e,t){return e.paths.filter(e=>e.owners.some(e=>t.has(e))).length}function Ap(e){let{pull_requests:t}=e.layers;return t.state===`ok`?t.pull_requests.find(e=>e.impact.state===`ok`)?.number??null:null}function jp(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 Mp(e,t){return e.dependents.filter(e=>e.id===t).map(e=>e.touched)}function Np(e){return[`paths`,`nodes`,`relations`,`flow_steps`,`dependents`,`model`].filter(t=>e[t])}function Pp(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 Fp(e){return e.failed>0?`danger`:e.passed>0&&e.passed+e.skipped===e.files?`success`:`muted`}function Ip(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 Lp={available:!1,marks:new Map,edges:[]};function Rp(e,t,n=null){let r=Ip(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 Lp;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 Lp;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:Fp(e),count:null,atLeast:!1}]))):Lp}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 Lp;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 zp(e,t,n=null){let r=(t,n=[])=>{let r=Tp(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(Pp(t,e=>{let n=jp(t,e.id);return`+${n.added} −${n.deleted}${n.unknown>0?` ?`:``}`})):wp}if(t===`violations`){if(Object.values(e.layers.violations).every(e=>e.state!==`ok`))return wp;let{dependencies:t}=e.layers.violations;return r(new Map([...Dp(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:Fp(e),label:`${e.passed}/${e.files}`}]))):wp}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(Pp(i,e=>String(e.files))):wp}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 Bp=.85,Vp=24,Hp=120;function Up(e,t){let n=Math.min((t.width-48)/e.width,(t.height-Vp-Hp)/e.height);if(!(t.width>0)||!(t.height>0)||n<Bp)return{x:Vp-e.x*Bp,y:Vp-e.y*Bp,zoom:Bp};let r=Math.min(n,1);return{x:(t.width-e.width*r)/2-e.x*r,y:Vp+(t.height-Vp-Hp-e.height*r)/2-e.y*r,zoom:r}}function Wp({content:e}){let t=q(),n=ll(),r=K(e=>e.panZoom!==null&&e.width>0&&e.height>0),i=(0,L.useRef)(!1);return(0,L.useEffect)(()=>{if(!r||i.current)return;i.current=!0;let{width:a,height:o}=t.getState();n.setViewport(Up(e,{width:a,height:o}))},[r,e,n,t]),null}function Gp(e,t,n,r=!1){return`${r?`≥`:``}${e(t===1?`architecture.unit.${n}One`:`architecture.unit.${n}`,{count:t})}`}function Kp({part:e,reason:t,code:n,children:r}){return(0,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":e,"data-reason":t,"data-code":n,children:r})}function qp({part:e,reason:t,children:n}){return(0,H.jsx)(`div`,{className:`architecture-map__note`,"data-note":e,"data-reason":t,children:n})}function Jp({mark:e}){return e===null?null:(0,H.jsx)(`span`,{className:`architecture-map__mark mono-value`,"data-tone":e.tone,children:e.label})}function Yp({bounds:e,t}){let n=ll(),{zoom:r}=_d();return(0,H.jsxs)(`div`,{className:`architecture-map__zoom`,role:`group`,"aria-label":t(`architecture.map.zoom`),children:[(0,H.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomOut`),onClick:()=>{n.zoomOut()},children:`−`}),(0,H.jsxs)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomReset`),className:`mono-value`,onClick:()=>{n.zoomTo(1)},children:[Math.round(r*100),`%`]}),(0,H.jsx)(`button`,{type:`button`,"aria-label":t(`architecture.map.zoomIn`),onClick:()=>{n.zoomIn()},children:`+`}),(0,H.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 Xp({part:e,t}){let n=_f(e);return(0,H.jsxs)(`div`,{className:`copy-value architecture-map__command`,children:[(0,H.jsx)(`code`,{"data-fix-command":e,children:n}),(0,H.jsx)(f,{label:t(`architecture.inspector.command`),value:n,t})]})}function Zp(e,t){return e.sizes.state===`ok`?e.sizes.nodes.find(e=>e.id===t)??null:null}function Qp(e){return gf[e].filter(e=>!e.startsWith(`--`)).join(` `)}function $p(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)=>{if(!e.nodes.some(e=>t.has(e)))return;let i=e.severity?`[${e.severity}] ${r(`architecture.layer.debt.${e.kind}`)}`:r(`architecture.layer.debt.${e.kind}`),a=e.message?`${i} — ${e.message}`:i;l.push({key:`debt-${n}`,text:a,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=>[cf(e),e.status]));for(let i of e.flows.filter(e=>t.has(e.capability)))lf(i).forEach(({outcome:e,step:t},a)=>{let o=n.get(cf(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 em({facts:e,layer:t,source:n=!1}){return(0,H.jsx)(`ul`,{"data-layer-facts":t,children:e.map(e=>(0,H.jsxs)(`li`,{children:[e.text,e.paths?.length?(0,H.jsx)(`ul`,{children:e.paths.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))}):null,n&&e.part!==void 0&&(0,H.jsx)(`span`,{className:`architecture-map__source mono-value`,"data-fact-source":e.part,children:Qp(e.part)})]},e.key))})}function tm({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=Mp(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=jp(s,r);d(s,t=>a(`architecture.layer.node.changes`,{files:Gp(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:Gp(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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:a(`architecture.layer.${t}`)}),o.length?(0,H.jsx)(em,{facts:o,layer:t}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.layer.node.none`)})]})}function nm({map:e,nodeId:t,t:n}){let{pull_requests:r}=e.layers;if(r.state===`unavailable`)return(0,H.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?Mp(e.impact,t).length>0?[{pr:e,text:n(`architecture.inspector.pr.depends`)}]:[]:[{pr:e,text:n(`architecture.inspector.pr.changes`,{files:Gp(n,r,`file`)})}]});return i.length?(0,H.jsx)(`ul`,{"data-related-prs":!0,children:i.map(({pr:e,text:t})=>(0,H.jsxs)(`li`,{"data-pull-request-number":e.number,children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title,` · `,t]},e.number))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)})}function rm({facts:e,source:t=!1,t:n}){let r=[...new Set(e.flatMap(e=>e.part?[e.part]:[]))];return(0,H.jsxs)(H.Fragment,{children:[e.length?(0,H.jsx)(em,{facts:e,layer:`violations`,source:t}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.inspector.none`)}),r.map(e=>(0,H.jsx)(Xp,{part:e,t:n},e))]})}function im({map:e,layer:t,pullRequest:n,nodeId:r,onModule:i,t:a,children:o}){let s=(0,L.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=Zp(e,r);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h3`,{children:c.name}),(0,H.jsx)(`code`,{className:`architecture-map__id`,children:c.id}),(0,H.jsx)(`p`,{children:c.summary}),(0,H.jsxs)(`dl`,{className:`detail-list`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.kind`)}),(0,H.jsx)(`dd`,{children:c.kind})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.layer`)}),(0,H.jsx)(`dd`,{children:c.layer??a(`architecture.none`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.status`)}),(0,H.jsx)(`dd`,{children:c.status})]}),e.sizes.state===`ok`&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:a(`architecture.map.size`)}),(0,H.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,H.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(c.id),children:a(`architecture.map.open`)}),o,(0,H.jsx)(tm,{map:e,layer:t,pullRequest:n,nodeId:c.id,names:s,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.inspector.pullRequests`)}),(0,H.jsx)(nm,{map:e,nodeId:c.id,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),(0,H.jsx)(rm,{facts:$p(e,new Set([c.id]),s,a),t:a}),(0,H.jsx)(am,{map:e,nodeId:c.id,names:s,t:a})]})}function am({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,H.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,H.jsx)(`code`,{children:e.kind}),` `,n.get(t),o!==void 0&&(0,H.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:o})]})]},e.id)}),o=a(`out`),s=a(`in`);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.map.outgoing`,{count:o.length})}),o.length?(0,H.jsx)(`ul`,{children:o}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}),(0,H.jsx)(`h4`,{children:r(`architecture.map.incoming`,{count:s.length})}),s.length?(0,H.jsx)(`ul`,{children:s}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)})]})}var om={route:(0,L.memo)(function({data:e,markerStart:t,markerEnd:n,style:r}){let{route:i,label:a}=e;return(0,H.jsx)(gu,{path:ji(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 sm(){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Il,{type:`target`,position:W.Top,isConnectable:!1}),(0,H.jsx)(Il,{type:`source`,position:W.Bottom,isConnectable:!1})]})}var cm=e=>[{type:`target`,position:W.Top,x:e.width/2,y:0,width:1,height:1},{type:`source`,position:W.Bottom,x:e.width/2,y:e.height,width:1,height:1}];function lm(e,t,n){let r=URL.createObjectURL(new Blob([na(t,n)],{type:`image/svg+xml`})),i=document.createElement(`a`);i.href=r,i.download=e,i.click(),setTimeout(()=>URL.revokeObjectURL(r),0)}var um=()=>null;function dm({scene:e,nodeTypes:t,view:n,selected:r,emphasis:i=r,routeLabel:a,routeSelection:o=um,onSelect:s,legend:c,t:l}){let u=(0,L.useMemo)(()=>new Map(e.boxes.map(e=>[e.id,n(e)])),[e,n]),d=(0,L.useMemo)(()=>Yi(e),[e]),f=(0,L.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:cm(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,L.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:xa.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,L.useRef)(r);m.current=r;let h=(0,L.useMemo)(()=>new Map(e.routes.map(e=>[e.id,e])),[e]),g=(0,L.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,L.useCallback)(e=>g(e,e=>u.get(e).selection),[g,u]),v=(0,L.useCallback)(e=>g(e,e=>o(h.get(e))),[g,h,o]);return(0,H.jsxs)(hd,{nodes:f,edges:p,nodeTypes:t,edgeTypes:om,onNodesChange:_,onEdgesChange:v,nodesDraggable:!1,nodesConnectable:!1,edgesFocusable:!1,minZoom:.05,maxZoom:2,attributionPosition:`top-right`,children:[(0,H.jsx)(Wp,{content:d}),(0,H.jsx)(wd,{variant:bd.Dots,gap:20,size:1.5,color:`var(--rh-diagram-dot)`}),(0,H.jsx)(xc,{position:`bottom-left`,children:(0,H.jsx)(`dl`,{className:`architecture-map__legend`,"aria-label":l(`architecture.map.legend`),children:c.map(e=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:e.swatch}),(0,H.jsx)(`dd`,{children:e.text})]},e.key))})}),(0,H.jsx)(xc,{position:`bottom-right`,children:(0,H.jsx)(Yp,{bounds:d,t:l})})]})}function fm({label:e,...t}){return(0,H.jsx)(`div`,{className:`architecture-map__canvas`,"aria-label":e,role:`region`,children:(0,H.jsx)(dd,{children:(0,H.jsx)(dm,{...t})})})}var pm=25,mm=e=>`domain:${e}`,hm=e=>`${e.source}->${e.target}`;function gm(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 _m(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 gm(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:mm(e),kind:`domain`,name:e,parent:null})),...o.map(e=>({id:e.id,kind:`capability`,name:e.name,parent:e.domain===null?null:mm(e.domain)}))],relations:[...t.edges,...u].map(e=>({id:hm(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=>[hm(e),`added`]),...u.map(e=>[hm(e),`removed`])]),capabilities:new Map(o.map(e=>[e.id,e]))}}function vm(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 ym=e=>e instanceof Error&&/^[a-z][a-z0-9_]{0,63}$/u.test(e.message)?e.message:`unavailable`;function bm(e,t,n){let r={path:e,timeline:null,error:null,more:{loading:!1,error:null}},[i,a]=(0,L.useState)(r),s=(0,L.useRef)(null),c=(0,L.useCallback)(async n=>{let i=t=>{s.current?.path!==e&&(s.current=null),a(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 a(e=>e.error===null?e:{...e,error:null}),!0;if(`state`in r)return i(r.reason),l(r);let o=r.body,c=Math.max(0,o.total-pm),u=o;if(o.total>1){let r=await t(`${e}?offset=${c}&limit=${pm}&ref=${o.head}`,null,n);if(n.aborted)return!1;if(`state`in r)return i(r.reason),l(r);u=r.body}return s.current=r.etag===null?null:{path:e,etag:r.etag},a({path:e,timeline:{head:o.head,total:o.total,start:c,milestones:u.milestones},error:null,more:{loading:!1,error:null}}),!0}catch(e){return n.aborted||i(ym(e)),!1}},[e,t]),u=o(c,JSON.stringify([e,n])),d=i.path===e?i:r,f=(0,L.useCallback)(()=>{let n=d.timeline;if(n===null||d.more.loading||n.start===0)return;let r=Math.max(0,n.start-pm),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(ym(e)))},[e,t,d]);return{...d,loadMore:f,retry:u}}var xm={added:`+`,removed:`−`,renamed:`~`,inside:`•`},Sm=e=>e.slice(0,7),Cm={box:(0,L.memo)(function({id:e,data:t,selected:n}){let{name:r,diff:i,from:a,quiet:o}=t;return(0,H.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,H.jsx)(sm,{}),(0,H.jsx)(`b`,{className:`architecture-history__mark`,"aria-hidden":`true`,children:i&&xm[i]}),(0,H.jsxs)(`span`,{className:`architecture-history__name`,children:[(0,H.jsx)(`span`,{children:r}),a!==null&&(0,H.jsx)(`s`,{className:`architecture-history__from`,children:a})]})]})}),group:(0,L.memo)(function({id:e,data:t}){return(0,H.jsxs)(`div`,{className:`architecture-history__group`,"data-node-id":e,children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`span`,{children:[t.name,` · `,t.count]})]})})};function wm(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 Tm(e,t){return{nodes:e.input.nodes,relations:e.input.relations.map(e=>({...e,kind:t.get(e.id)??`relation`}))}}var Em=[`removed`,`added`,`renamed`,`inside`];function Dm(e,t){for(let n of Em)for(let[r,i]of e.nodes)if(i===n&&t.capabilities.has(r))return r;return t.capabilities.keys().next().value??null}function Om(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 km(e){return[...[`added`,`removed`,`renamed`,`inside`].map(t=>({key:t,swatch:(0,H.jsx)(`i`,{className:`architecture-history__swatch`,"data-diff":t}),text:e(`architecture.history.diff.${t}`)})),...[`added`,`removed`].map(t=>({key:`edge-${t}`,swatch:(0,H.jsx)(`i`,{className:`architecture-history__line`,"data-diff":t}),text:e(`architecture.history.edge.${t}`)}))]}function Am({milestone:e,shape:t,marks:n,skipped:r,selected:i,onSelect:a,t:o}){let[s,c]=(0,L.useState)(!1),l=e.delta.baseRev!==null,u=l&&s,d=(0,L.useMemo)(()=>da(Tm(t,n.edges)),[t,n]),f=(0,L.useMemo)(()=>new Map(t.input.nodes.map(e=>[e.id,e])),[t]),p=(0,L.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,L.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,L.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,L.useMemo)(()=>km(o),[o]);return(0,H.jsxs)(`div`,{className:`architecture-history__stage`,"data-focus":u||void 0,children:[(0,H.jsxs)(`div`,{className:`architecture-history__bar`,children:[(0,H.jsx)(`p`,{className:`architecture-history__caption`,"data-base-rev":e.delta.baseRev??``,children:Om(e,r,o)}),(0,H.jsxs)(`label`,{className:`architecture-history__focus`,children:[(0,H.jsx)(`button`,{type:`button`,role:`switch`,className:`architecture-history__switch`,"aria-checked":u,disabled:!l,onClick:()=>c(!s)}),o(`architecture.history.focus`)]})]}),(0,H.jsx)(fm,{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 jm({github:e,rev:t}){return e===null?(0,H.jsx)(`code`,{children:Sm(t)}):(0,H.jsxs)(`a`,{href:`https://github.com/${e}/commit/${t}`,target:`_blank`,rel:`noreferrer`,children:[(0,H.jsx)(`code`,{children:Sm(t)}),` ↗`]})}function Mm({milestone:e,skipped:t,t:n}){if(e.error)return(0,H.jsx)(`span`,{className:`architecture-history__chips`,children:(0,H.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`error`,children:e.error.code})});let{delta:r}=e;if(r.baseRev===null)return(0,H.jsx)(`span`,{className:`architecture-history__chips`,children:(0,H.jsx)(`span`,{className:`architecture-history__chip`,children:n(`architecture.history.chip.first`)})});let i=r.edgesChanged.added.length+r.edgesChanged.removed.length,a=gm(r).size;return(0,H.jsxs)(`span`,{className:`architecture-history__chips`,children:[r.added.length>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`added`,children:[`+`,r.added.length]}),r.removed.length>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`removed`,children:[`−`,r.removed.length]}),r.renamed.length>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`renamed`,children:[`~`,r.renamed.length]}),a>0&&(0,H.jsxs)(`span`,{className:`architecture-history__chip`,"data-tone":`inside`,title:n(`architecture.history.diff.inside`),children:[`•`,a]}),i>0&&(0,H.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,H.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":`gap`,children:n(`architecture.history.chip.gap`,{count:t,rev:Sm(r.baseRev)})})]})}function Nm({timeline:e,selected:t,onSelect:n,more:r,onMore:i,t:a}){let{milestones:o}=e,s=(0,L.useMemo)(()=>[...o].reverse(),[o]),c=(0,L.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,H.jsxs)(`nav`,{className:`architecture-history__timeline`,"aria-label":a(`architecture.history.timeline`),children:[e.total===0&&(0,H.jsx)(`p`,{className:`architecture-history__empty`,children:a(`architecture.history.empty`)}),(0,H.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,H.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,H.jsxs)(`span`,{className:`architecture-history__top`,children:[(0,H.jsx)(`code`,{children:Sm(e.rev)}),(0,H.jsx)(`time`,{dateTime:e.date,title:e.date,children:e.date.slice(5,10)})]}),(0,H.jsx)(`span`,{className:`architecture-history__subject`,title:e.subject,children:e.subject}),(0,H.jsx)(Mm,{milestone:e,skipped:e.error?0:vm(o,e),t:a})]},e.rev))}),e.start>0&&(0,H.jsx)(`button`,{type:`button`,className:`architecture-history__load`,disabled:r.loading,onClick:i,children:a(`architectureHistory.more`,{count:Math.min(pm,e.start),head:Sm(e.head)})}),r.error!==null&&(0,H.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 Pm(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 Fm(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 Im({milestone:e,shape:t,marks:n,skipped:r,selected:i,github:a,t:o}){let s=o(`architectureHistory.node`);if(e.error)return(0,H.jsx)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,children:(0,H.jsxs)(`p`,{className:`architecture-history__callout`,"data-tone":`error`,"data-gap":`milestone`,"data-code":e.error.code,children:[o(`architecture.history.error`),` `,(0,H.jsx)(`code`,{children:e.error.code}),e.error.path&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`br`,{}),(0,H.jsx)(`code`,{children:e.error.path})]})]})});let{baseRev:c}=e.delta,l=i===null?null:t.capabilities.get(i),u=l===null?[]:Fm(e,l.id),d=e=>{let n=t.capabilities.get(e);return n===void 0?(0,H.jsx)(`code`,{children:e}):n.name};return(0,H.jsxs)(`aside`,{className:`architecture-history__inspector`,"aria-label":s,"data-milestone-rev":e.rev,"data-node-id":l?.id,children:[l!==null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`header`,{children:[(0,H.jsx)(`p`,{className:`architecture-history__eyebrow`,children:l.domain??`—`}),(0,H.jsx)(`h3`,{children:l.name}),(0,H.jsx)(`code`,{children:l.id})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{children:o(`architectureHistory.milestone`)}),(0,H.jsx)(`p`,{"data-diff":n.nodes.get(l.id),children:Pm(l.id,e,n,t,o)})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{children:o(`architectureHistory.relations`)}),u.length===0?(0,H.jsx)(`p`,{className:`architecture-history__quiet`,children:o(`architectureHistory.none`)}):(0,H.jsx)(`ul`,{children:u.map(({edge:e,diff:t})=>(0,H.jsxs)(`li`,{"data-diff":t,children:[(0,H.jsx)(`span`,{className:`architecture-history__chip`,"data-tone":t,children:t===`added`?`+`:`−`}),(0,H.jsxs)(`span`,{children:[d(e.source),` → `,d(e.target)]})]},`${t}:${hm(e)}`))})]})]}),(0,H.jsxs)(`section`,{children:[(0,H.jsx)(`h4`,{children:o(`architecture.history.base`)}),c===null?(0,H.jsx)(`p`,{className:`architecture-history__quiet`,"data-base-rev":``,children:o(`architecture.history.first`)}):(0,H.jsxs)(`p`,{"data-base-rev":c,children:[(0,H.jsx)(jm,{github:a,rev:c}),r!==null&&r>0&&(0,H.jsxs)(`span`,{className:`architecture-history__quiet`,"data-gap":`skipped`,"data-count":r,children:[` `,o(`architectureHistory.base.skipped`,{count:r})]})]})]})]})}function Lm({path:e,github:t,read:n,refreshGeneration:r,selection:i,select:a,onSummary:o,t:s}){let l=bm(e,n,r),[u,d]=(0,L.useState)(null),{timeline:f}=l,p=(0,L.useMemo)(()=>f?.milestones??[],[f]),m=p.find(e=>e.rev===u)??p.at(-1)??null,h=m===null||m.error?null:m,g=(0,L.useMemo)(()=>h===null?null:_m(p,h),[p,h]),_=(0,L.useMemo)(()=>h===null||g===null?null:wm(h,g),[h,g]),v=h===null?0:vm(p,h),y=h!==null&&i?.scope===h.rev?i:null,b=g===null||_===null?null:y===null?Dm(_,g):y.id!==null&&g.capabilities.has(y.id)?y.id:null,x=h?.rev??``,S=(0,L.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,L.useEffect)(()=>{o(w===null?null:{head:w,read:p.length,total:T})},[w,p.length,T,o]),(0,L.useEffect)(()=>()=>o(null),[o]),f===null?l.error===`history_shallow_repository`?(0,H.jsxs)(`section`,{className:`architecture-history__whole-error`,role:`alert`,"data-error-code":l.error,children:[(0,H.jsx)(`code`,{children:`history-shallow-repository`}),(0,H.jsx)(`p`,{children:s(`architecture.history.shallow`)}),(0,H.jsx)(c,{command:`git fetch --unshallow`,t:s})]}):l.error===null?(0,H.jsx)(`p`,{role:`status`,children:s(`architecture.history.loading`)}):(0,H.jsx)(`p`,{className:`architecture-notice`,role:`alert`,"data-error-code":l.error,children:s(`architecture.failed`,{code:l.error})}):(0,H.jsxs)(`div`,{className:`architecture-history`,children:[l.error!==null&&(0,H.jsxs)(`div`,{className:`architecture-history__banner`,role:`alert`,"data-error-code":l.error,children:[(0,H.jsx)(`span`,{children:s(`architecture.refreshFailed`,{code:l.error})}),(0,H.jsx)(`button`,{type:`button`,onClick:l.retry,children:s(`architecture.history.retry`)})]}),(0,H.jsx)(`div`,{className:`architecture-history__body`,"data-stale":l.error!==null||void 0,children:m===null?(0,H.jsx)(`p`,{className:`architecture-history__empty`,children:s(`architecture.history.empty`)}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Nm,{timeline:f,selected:m.rev,onSelect:C,more:l.more,onMore:l.loadMore,t:s}),m.error?(0,H.jsxs)(`section`,{className:`architecture-history__canvas`,"aria-label":s(`architecture.history.map`),children:[(0,H.jsx)(`p`,{className:`architecture-history__caption`,children:s(`architectureHistory.caption.error`,{rev:Sm(m.rev)})}),(0,H.jsxs)(`div`,{className:`architecture-history__canvas-error`,children:[(0,H.jsx)(`code`,{children:m.error.code}),m.error.path&&(0,H.jsx)(`p`,{children:(0,H.jsx)(`code`,{children:m.error.path})})]})]}):(0,H.jsx)(Am,{milestone:m,shape:g,marks:_,skipped:v,selected:b,onSelect:S,t:s},m.rev),(0,H.jsx)(Im,{milestone:m,shape:g,marks:_,skipped:v,selected:b,github:t,t:s})]})})]})}var Rm=40,zm=96,Bm=12,Vm=24,Hm=e=>`label:${e}`,Um=(e,t)=>(t.lines??0)-(e.lines??0)||e.node.name.localeCompare(t.node.name);function Wm(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=la.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=>Bm*(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(Um),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:Vm+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`?Bm:-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:Hm(e.layer),parent:null,x:Vm,y:e.y,width:zm,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`)+Vm,height:48+t.length*56+Math.max(0,t.length-1)*Rm};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 Gm=e=>new Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(e).toLowerCase(),Km=7,qm=e=>`L${e.index} ${e.layer}`,Jm=e=>e.members.map(e=>e.node.name).join(` · `),Ym={label:(0,L.memo)(function({data:e}){return(0,H.jsx)(`span`,{className:`architecture-layermap__band`,children:qm(e.band)})}),layer:(0,L.memo)(function({data:e,selected:t}){let{band:n,t:r}=e;return(0,H.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,H.jsx)(sm,{}),(0,H.jsx)(`strong`,{children:n.layer}),(0,H.jsx)(`span`,{className:`architecture-layermap__members`,title:Jm(n),children:n.members.length===0?r(`architecture.layers.empty`):Jm(n)}),n.lines!==null&&(0,H.jsx)(`span`,{className:`architecture-layermap__lines mono-value`,children:Gm(n.lines)})]})})};function Xm(e,t){return[{key:`code`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.layers.legend.runtime`)},...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,H.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k`}),text:t(`architecture.layers.legend.lines`)}]:[]]}function Zm(e){return t=>{let n=e.get(t.id);return t.id===n.layer?[n.layer,[...n.lines===null?[]:[Gm(n.lines)],Jm(n)].filter(Boolean).join(` · `)]:[qm(n)]}}function Qm({band:e,t}){let n=e.members.filter(e=>e.lines>0);if(n.length===0)return(0,H.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.map.noSize`)});let r=n.slice(0,Km),i=n.slice(Km),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,H.jsx)(`ul`,{className:`architecture-layermap__sizes`,"data-layer-sizes":!0,children:a.map(e=>(0,H.jsxs)(`li`,{"data-size-row":e.key,children:[(0,H.jsx)(`span`,{className:`architecture-layermap__size-name`,title:e.name,children:e.name}),(0,H.jsx)(`span`,{className:`architecture-layermap__bar`,children:(0,H.jsx)(`span`,{style:{width:`${Math.round(e.lines/o*100)}%`}})}),(0,H.jsx)(`span`,{className:`mono-value`,children:Gm(e.lines)})]},e.key))})}function $m({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:Ep(r)}):n(`architecture.layer.reason.${r.reason}`);return(0,H.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,H.jsxs)(H.Fragment,{children:[i.size===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.layers.violations.none`)}):(0,H.jsx)(`ul`,{className:`architecture-layermap__pairs`,"data-layer-violations":!0,children:[...i.values()].map(e=>(0,H.jsxs)(`li`,{"data-pair":`${e.source}->${e.target}`,children:[(0,H.jsxs)(`span`,{children:[e.source,` → `,e.target]}),(0,H.jsx)(`span`,{className:`mono-value`,children:e.imports}),(0,H.jsx)(`span`,{className:`architecture-layermap__verdict`,children:n(`architecture.layers.violation`)})]},`${e.source}-${e.target}`))}),(0,H.jsx)(`p`,{className:`detail-quiet`,"data-layer-checked":!0,children:n(`architecture.layers.checked`,{imports:r.imports})})]})}var eh=e=>[`${e.source} → ${e.target}`,...e.protocols].join(` · `);function th({lanes:e,t}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:t(`architecture.modules.relations`,{count:e.length})}),e.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:t(`architecture.none`)}):(0,H.jsx)(`ul`,{"data-layer-lanes":!0,children:e.map(e=>{let n=e.side===`right`?`out`:`in`;return(0,H.jsxs)(`li`,{"data-lane":e.route.id,"data-direction":n,children:[(0,H.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,H.jsx)(`span`,{className:`mono-value`,children:t(`architecture.modules.direction.${n}`)}),` `,n===`out`?e.target:e.source,e.protocols.length>0&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`code`,{children:e.protocols.join(` · `)})]})]},e.route.id)})})]})}function nh({map:e,band:t,lanes:n,t:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,H.jsxs)(`span`,{className:`architecture-modules__eyebrow`,children:[`L`,t.index]}),(0,H.jsx)(`h3`,{children:t.layer}),t.files!==null&&(0,H.jsx)(`span`,{className:`detail-quiet`,"data-layer-size":!0,children:r(`architecture.map.sizeValue`,{lines:t.lines,files:t.files})})]}),(0,H.jsx)(th,{lanes:n,t:r}),e.sizes.state===`ok`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.layers.size`)}),(0,H.jsx)(Qm,{band:t,t:r})]}),(0,H.jsx)(`h4`,{children:r(`architecture.layer.violations.layer_direction.label`)}),(0,H.jsx)($m,{map:e,layer:t.layer,t:r}),(0,H.jsxs)(`details`,{className:`architecture-layermap__nodes`,children:[(0,H.jsx)(`summary`,{children:r(`architecture.layers.members`,{count:t.members.length})}),(0,H.jsx)(`ul`,{children:t.members.map(e=>(0,H.jsxs)(`li`,{"data-member":e.node.id,children:[e.node.name,` `,(0,H.jsx)(`span`,{className:`detail-quiet`,children:e.node.kind})]},e.node.id))})]})]})}function rh({map:e,t}){return e.sizes.state===`unavailable`?(0,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`sizes`,"data-reason":e.sizes.reason,children:t(`architecture.map.sizes.${e.sizes.reason}`)}):null}function ih({map:e,order:t,selected:n,onSelect:r,t:i}){let a=(0,L.useMemo)(()=>Wm(e,t),[e,t]),o=a.bands.find(e=>e.layer===n)??null,s=o?.layer??null,c=(0,L.useMemo)(()=>a.scene(s),[a,s]),l=(0,L.useMemo)(()=>a.lanes(s),[a,s]),u=e.nodes.filter(e=>e.layer===null).length,d=(0,L.useMemo)(()=>new Map(a.bands.flatMap(e=>[[Hm(e.layer),e],[e.layer,e]])),[a]),f=(0,L.useCallback)(e=>{let t=d.get(e.id);return e.id===t.layer?{type:`layer`,ariaLabel:qm(t),selection:t.layer,data:{band:t,t:i}}:{type:`label`,ariaLabel:qm(t),selection:null,data:{band:t}}},[d,i]),p=(0,L.useCallback)(e=>eh(l.find(t=>t.route.id===e.id)),[l]);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`architecture-lens`,children:(0,H.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,H.jsx)(`span`,{"data-layers-provenance":!0,children:i(`architecture.layers.provenance`,{version:e.archctx_version})}),(0,H.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-layers-export":!0,onClick:()=>lm(`layers-${e.commit.slice(0,7)}.svg`,c,Zm(d)),children:i(`architecture.layers.export`)})]})}),(0,H.jsxs)(`div`,{className:`architecture-map`,"data-view":`layers`,"data-layer-count":a.bands.length,"data-lane-count":l.length,children:[(0,H.jsx)(fm,{label:i(`architecture.layers.label`),scene:c,nodeTypes:Ym,view:f,selected:s,routeLabel:p,onSelect:r,legend:Xm(e,i),t:i}),(0,H.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":i(`architecture.layers.inspector`),"data-layer-id":s??void 0,children:[(0,H.jsx)(rh,{map:e,t:i}),u>0&&(0,H.jsx)(qp,{part:`layers.unlayered`,reason:`node_layer_undeclared`,children:i(`architecture.layers.unlayered`,{count:u})}),o===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.layers.pick`)}):(0,H.jsx)(nh,{map:e,band:o,lanes:l,t:i})]})]})]})}function ah({map:e,selectedId:t,onSelect:n,t:r}){let i=e.layer_order;return i.state===`unavailable`?(0,H.jsx)(`div`,{className:`architecture-map`,"data-view":`layers`,children:(0,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`layer_order`,"data-reason":i.reason,children:r(`architecture.layers.${i.reason}`)})}):(0,H.jsx)(ih,{map:e,order:i.layers,selected:t,onSelect:n,t:r},e.commit)}var oh=200,sh=64,ch=8,lh=12,uh=30,dh=26,fh=16,ph=72,mh=24,hh=1,gh=e=>`domain:${e}`,_h=e=>24+7*e.length,vh=(e,t)=>Math.round((1+5*Math.sqrt(e/t))*100)/100,yh=e=>e===1?1:e<=4?2:3;function bh(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=Ip(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:gh(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=yh(n),i=Math.ceil(n/r);return{width:r*oh+(r-1)*ch+24,height:uh+i*sh+(i-1)*ch+lh}},p=(e,t,n,r,i)=>({id:e,source:t,target:n,arrows:{start:!1,end:!0},kind:r,dashed:!1,width:i}),m=Zi({nodes:n.map(e=>({id:gh(e),kind:`frame`,...f(e)})),edges:o.map(e=>({...p(e.id,gh(e.source),gh(e.target),`imports`,vh(e.imports,s)),weight:e.imports})),nodesep:48,ranksep:72,margin:mh}),h=Math.max(0,...m.boxes.map(e=>e.x+e.width)),g=[],_=mh,v=Math.max(0,...m.boxes.map(e=>e.y+e.height))+ph;for(let e of r){let t=_h(e.name);_>mh&&_+t>h&&(_=mh,v+=50),g.push({id:e.id,parent:null,x:_,y:v,width:t,height:dh,kind:`external`}),_+=t+fh}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=Ji([Li(r,x(i)),Li(i,x(r))],y.filter(e=>e!==r&&e!==i));return{...p(`relation:${t}->${n}`,t,n,`relation`,hh),points:a}}),C=[...m.routes,...S],w=n.flatMap(e=>{let n=b.get(gh(e)),r=yh(t.get(e).length);return t.get(e).map((e,t)=>({id:e.id,parent:n.id,kind:`box`,width:oh,height:sh,x:n.x+lh+t%r*208,y:n.y+uh+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:Xi(T,C,mh)}}}function xh(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,H.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 wh=(0,L.memo)(function({data:e}){return(0,H.jsxs)(`div`,{className:`architecture-modules__domain`,"data-domain":e.domain,children:[(0,H.jsx)(sm,{}),(0,H.jsx)(`b`,{children:e.domain})]})}),Th=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`];function Eh(e){let t=Rp(e,`changes`).marks,n=Rp(e,`violations`).marks,r=Rp(e,`decisions`).marks,{pull_requests:i,tests:a}=e.layers,o=(i.state===`ok`?i.pull_requests:[]).map(t=>({number:t.number,marks:Rp(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 Dh(e,t,n,r={}){return e(n===1?`architecture.modules.hover.${t}One`:`architecture.modules.hover.${t}`,{count:n,...r})}function Oh(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?Dh(t,`changes`,s):null},{layer:`violations`,tone:`danger`,value:r>0?String(r):null,words:r>0?Dh(t,`violations`,r):null},{layer:`pull_requests`,tone:`info`,value:i.length>0?String(i.length):null,words:i.length>0?Dh(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?Dh(t,`decisions`,o):null}]}var kh={domain:wh,module:(0,L.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,H.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,H.jsxs)(`span`,{className:`architecture-modules__name`,children:[(0,H.jsx)(`strong`,{children:n.name}),n.status===`deprecated`&&(0,H.jsx)(`span`,{className:`architecture-modules__status`,children:l(`architecture.modules.deprecated`)}),o!==null&&(0,H.jsx)(Ch,{kind:`neighbour`,state:o,t:l}),s!==null&&(0,H.jsx)(Ch,{kind:`undeclared`,state:s,t:l})]}),(0,H.jsx)(`span`,{className:`architecture-modules__size mono-value`,children:r===null?``:`${Gm(r.lines)} · ${Gm(r.files)}`}),(0,H.jsx)(`span`,{className:`architecture-modules__slots`,children:a.map(e=>(0,H.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,L.memo)(function({data:e,selected:t}){return(0,H.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,H.jsx)(sm,{}),e.node.name,e.neighbour!==null&&(0,H.jsx)(Ch,{kind:`neighbour`,state:e.neighbour,t:e.t})]})})},Ah=(e,t)=>[`out`,`in`,`both`].map(n=>({key:`${e}-${n}`,swatch:(0,H.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 jh(e,t){return[...e.routes?[{key:`undeclared`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--undeclared`}),text:t(`architecture.layer.legend.undeclared`)}]:[],...e.selection?Ah(`neighbour`,t):[],...e.cards?Ah(`undeclared`,t):[]]}function Mh({entries:e,t}){return e.length===0?null:(0,H.jsx)(`dl`,{className:`architecture-modules__states`,"aria-label":t(`architecture.map.legend`),"data-narrow-legend":!0,children:e.map(e=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:e.swatch}),(0,H.jsx)(`dd`,{children:e.text})]},e.key))})}function Nh(e,t,n,r,i){return[...t.edges.length>0?[{key:`width`,swatch:(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),text:i(`architecture.modules.legend.width`)}]:[],...jh(n,i),...t.externals.length>0?[{key:`external`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:i(`architecture.map.legend.external`)}]:[],...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,H.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k · 4`}),text:i(`architecture.modules.legend.lines`)}]:[],{key:`slots`,swatch:(0,H.jsx)(`span`,{className:`architecture-modules__key mono-value`,children:Th.map(e=>(0,H.jsx)(`span`,{"data-active":e===r||void 0,children:i(`architecture.modules.slot.${e}`)},e))}),text:``}]}function Ph(e,t){let n=Ip(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 Fh(e,t,n){let r=Ip(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 Ih({selected:e,relations:t,names:n,t:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.modules.relations`,{count:t.length})}),t.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}):(0,H.jsx)(`ul`,{"data-card-relations":!0,children:t.map(t=>(0,H.jsxs)(`li`,{"data-relation-id":t.id,"data-direction":t.direction,children:[(0,H.jsx)(`span`,{className:`mono-value`,children:r(`architecture.modules.direction.${t.direction}`)}),` `,n.get(t.other),t.holder!==t.other&&t.holder!==e&&(0,H.jsxs)(H.Fragment,{children:[` (`,n.get(t.holder),`)`]}),` · `,(0,H.jsx)(`code`,{children:t.kind}),t.imports!==null&&(0,H.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:t.imports})]})]},t.id))})]})}function Lh({map:e,ids:t,t:n}){let{changes:r}=e.layers;if(r.state===`unavailable`)return(0,H.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`changes`,children:r.reason===`archctx_error`?n(`architecture.layer.changes.archctx_error`,{code:Ep(r)}):n(`architecture.layer.changes.${r.reason}`)});let i=r.commits.filter(e=>e.nodes.some(e=>t.has(e)));return i.length?(0,H.jsx)(`ul`,{"data-module-commits":!0,children:i.map(e=>(0,H.jsxs)(`li`,{"data-commit":e.sha,children:[(0,H.jsx)(`code`,{children:e.sha.slice(0,7)}),` `,e.subject]},e.sha))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.changes.none`)})}function Rh({map:e,pullRequest:t,ids:n,capability:r,t:i}){let{pull_requests:a}=e.layers;if(a.state===`unavailable`)return(0,H.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,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.inspector.none`)});let{impact:s}=o;if(s.state===`unavailable`)return(0,H.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`pull_request`,children:s.reason===`archctx_error`?i(`architecture.layer.pull_requests.pr.archctx_error`,{code:Ep(s)}):i(`architecture.layer.pull_requests.pr.${s.reason}`)});let c=new Map(e.nodes.map(e=>[e.id,e.name])),l=Ip(e),u=[],d=kp(s,n);d>0&&u.push({key:`files`,text:i(`architecture.modules.impact.files`,{files:Gp(i,d,`file`,s.truncated.paths)})});let f=[...n].flatMap(e=>Mp(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=vf(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,H.jsx)(`ul`,{"data-module-impact":o.number,children:u.map(e=>(0,H.jsx)(`li`,{children:e.text},e.key))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.modules.impact.none`,{number:o.number})})}function zh({map:e,capability:t,t:n}){let{tests:r}=e.layers;if(r.state===`unavailable`)return(0,H.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,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.tests.none`)}):(0,H.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 Bh({map:e,pullRequest:t,node:n,relations:r,onModule:i,t:a}){let o=(0,L.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),s=(0,L.useMemo)(()=>{let t=Ip(e);return new Set(e.nodes.flatMap(e=>t.get(e.id)===n.id?[e.id]:[]))},[e,n.id]),c=Zp(e,n.id),l=$p(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,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,H.jsx)(`span`,{className:`architecture-modules__eyebrow`,"data-module-domain":!0,children:n.domain}),(0,H.jsx)(`h3`,{children:n.name}),(0,H.jsxs)(`span`,{className:`architecture-map__id mono-value`,children:[n.id,e.sizes.state===`ok`&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`span`,{"data-node-size":!0,children:c===null?a(`architecture.map.noSize`):a(`architecture.map.sizeValue`,{lines:c.lines,files:c.files})})]})]})]}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.changes`)}),(0,H.jsx)(Lh,{map:e,ids:s,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),l.length?(0,H.jsx)(em,{facts:l,layer:`violations`,source:!0}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),(0,H.jsx)(`h4`,{children:t===null?a(`architecture.layer.pull_requests`):a(`architecture.modules.impact.title`,{number:t})}),(0,H.jsx)(Rh,{map:e,pullRequest:t,ids:s,capability:n.id,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.tests`)}),(0,H.jsx)(zh,{map:e,capability:n.id,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.decisions`)}),d.length?(0,H.jsx)(`ul`,{"data-module-decisions":!0,children:d.map(e=>(0,H.jsxs)(`li`,{children:[e.status===null?e.title:a(`architecture.layer.node.decision`,{title:e.title,status:e.status}),` · `,(0,H.jsx)(`code`,{children:e.path})]},e.id))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),u.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:a(`architecture.modules.fix`)}),u.map(e=>(0,H.jsx)(Xp,{part:e,t:a},e))]}),(0,H.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(n.id),children:a(`architecture.map.open`)}),(0,H.jsx)(Ih,{selected:n.id,relations:r,names:o,t:a})]})}function Vh({map:e,layer:t,pullRequest:n,selectedId:r,onSelect:i,side:a,onModule:o,t:s}){let c=(0,L.useMemo)(()=>bh(e),[e]),l=(0,L.useMemo)(()=>Rp(e,t,n),[e,t,n]),{scene:u,cards:d}=(0,L.useMemo)(()=>xh(c,l.edges),[c,l]),f=(0,L.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e]),p=(0,L.useMemo)(()=>new Map(e.sizes.state===`ok`?e.sizes.nodes.map(e=>[e.id,{lines:e.lines,files:e.files}]):[]),[e]),m=(0,L.useMemo)(()=>Eh(e),[e]),h=(0,L.useMemo)(()=>new Map(c.edges.map(e=>[e.id,e.imports])),[c]),g=r===null?null:f.get(r)??null,_=(0,L.useMemo)(()=>g===null?[]:Ph(e,g.id),[e,g]),v=(0,L.useMemo)(()=>g===null?new Map:Fh(e,c,g.id),[e,c,g]),y=(0,L.useCallback)(e=>{if(e.parent===null&&e.kind===`frame`){let t=e.id.slice(gh(``).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:Oh(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`?gh(g.domain):g.id,S=(0,L.useCallback)(e=>{let t=e=>e.startsWith(gh(``))?e.slice(gh(``).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,H.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,H.jsx)(fm,{label:s(`architecture.map.label`),scene:u,nodeTypes:kh,view:y,selected:r,emphasis:x,routeLabel:S,onSelect:i,legend:Nh(e,c,b,t,s),t:s}),(0,H.jsx)(Mh,{entries:jh(b,s),t:s}),(0,H.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":s(`architecture.map.inspector`),"data-node-id":g?.id,children:[a,g===null?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.pick`)}),(0,H.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.counts`,{nodes:Gp(s,e.nodes.length,`node`),relations:Gp(s,e.relations.length,`relation`)})})]}):g.kind===`capability`?(0,H.jsx)(Bh,{map:e,pullRequest:n,node:g,relations:_,onModule:o,t:s}):(0,H.jsx)(im,{map:e,layer:t,pullRequest:n,nodeId:g.id,onModule:o,t:s})]})]})}function Hh(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 Uh=16,Wh=24,Gh=8,Kh=16,qh=196,Jh=44,Yh=24,Xh=12,Zh=52,Qh=4,$h=16,eg=28,tg=12,ng=28,rg=24;function ig(e){return e.kind===`process`?`process:${e.process}`:e.kind===`external`?`external`:`unknown:${e.reason}`}var ag=e=>`participant:${e}`,og=(e,t)=>`message:${e??``}:${t}`,sg=e=>e===0?`alt`:`else`,cg=(e,t)=>t===null?e.label:`${e.label} · ${t}`,lg=e=>Ti(e,`title`)+24;function ug(e,t,n,r){let i=[],a=new Map;for(let n of e.participants){let e=t(n.node),r=ig(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(qh,lg(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+Yh),l=Gh+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=Ti(cg(e,n.status(e)),`label`);t===r?u(t,rg+i+24):u(t<r?t:t-1,i+24)}for(let t of e.outcomes){let e=s.get(t.terminal.participant),n=lg(t.terminal.label)/2+Xh;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?Uh+l:f[e-1]+c[e-1];n!==void 0&&n.key!==t.key&&(i=Math.max(i,p.get(n.key).right+Kh+Gh+t.header/2)),f.push(i);let s=p.get(t.key)?.left??i-t.header/2-Gh;p.set(t.key,{left:s,right:Math.max(i+t.header/2+Gh,s+lg(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+=Zh;for(let[t,n]of e.outcomes.entries()){let e=x-Zh/2+tg;x=e+eg+Zh/2+$h/2;for(let e of n.steps)y.push({outcome:n.id,step:e,y:x}),x+=Zh;b.push({outcome:n,index:t,top:e,terminal:x}),x+=Zh}let S=x-Zh/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:Uh,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=ag(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:Jh,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-Uh-Wh-Jh,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)-qh/2,o=Math.max(...i)+qh/2,s=`${sg(t)} ${e.label}`;v({id:`fragment:${e.id}`,parent:null,x:a,y:n,width:Math.max(o-a,lg(s)),height:eg,kind:`fragment ${e.kind}`},{kind:`fragment`,outcome:e,index:t},s);let c=lg(e.terminal.label);v({id:`terminal:${e.id}`,parent:null,x:m(e.terminal.participant)-c/2,y:r-ng/2,width:c,height:ng,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=og(e,t.id),a=m(t.from),o=m(t.to),l=n.tone(e,t),u=n.status(t),d=cg(t,l===`danger`?u:null),f=a===o,p=o>a?.5:-.5,h=f?[[a+.5,r-8],[a+rg,r-8],[a+rg,r+8],[a+.5,r+8]]:[[a+p,r],[o-p,r]],g=f?[a+rg+Xh+Ti(d,`label`)/2,r]:[(a+(o>a?a+c[s.get(t.from)]:a-c[s.get(t.from)-1]))/2,r-Qh-$h/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(Fi(d,g,i)),T.set(i,{outcome:e,step:t,tone:l,status:u})}return{scene:{boxes:h,routes:C,labels:w,extent:Xi(h,C,Uh,w)},parts:g,messages:T,lines:e=>_.has(e.id)?[_.get(e.id)]:[]}}var dg=(e,t,n)=>`${e}\0${t??``}\0${n}`;function fg(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=>dg(e.flow,e.outcome,e.step)))}function pg(e){let{flows:t}=e.layers.violations;return t.state===`ok`?new Map(t.evidence.map(e=>[_f(e),e.status])):null}function mg(e,t,n,r,i,a){if(t.has(dg(r,i,a.id)))return`change`;let o=n?.get(_f(a.evidence));return e===`violations`&&o!==void 0&&o!==`proven`?`danger`:null}function hg(e,t,n,r){return new Set(e.flows.filter(e=>vf(e).some(({outcome:i,step:a})=>mg(t,n,r,e.id,i,a)!==null)).map(e=>e.id))}function gg(e,t,n,r){let i=e.flows.filter(e=>e.applicability===`required`),a=hg(e,t,n,r);return(i.find(e=>a.has(e.id))??i[0]??e.flows[0])?.id??null}var _g={box:(0,L.memo)(function({data:e}){return(0,H.jsx)(`div`,{className:`architecture-sequence__box`,"data-placement":e.placement.kind,"data-reason":e.reason??void 0,title:e.reason??void 0,children:(0,H.jsx)(`span`,{children:e.title})})}),fragment:(0,L.memo)(function({data:e}){return(0,H.jsxs)(`div`,{className:`architecture-sequence__fragment`,"data-kind":e.kind,title:e.label,children:[(0,H.jsx)(`span`,{className:`mono-value`,children:sg(e.index)}),` `,e.label]})}),header:(0,L.memo)(function({data:e,selected:t}){return(0,H.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,H.jsx)(`strong`,{className:`architecture-sequence__name`,children:e.name}),e.mark!==null&&(0,H.jsx)(`span`,{className:`architecture-sequence__header-mark`,children:(0,H.jsx)(Jp,{mark:e.mark})})]})}),lifeline:(0,L.memo)(function(){return(0,H.jsx)(`div`,{className:`architecture-sequence__lifeline`,children:(0,H.jsx)(sm,{})})}),terminal:(0,L.memo)(function({data:e}){return(0,H.jsx)(`div`,{className:`architecture-sequence__terminal`,"data-kind":e.kind,title:e.label,children:e.label})})};function vg(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 yg({evidence:e,t}){if(e===void 0)return(0,H.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,H.jsx)(`span`,{"data-path-withheld":!0,children:t(`architecture.sequence.evidence.withheld`)}):(0,H.jsx)(`code`,{children:e});return(0,H.jsxs)(`ul`,{className:`architecture-sequence__code`,"data-step-evidence":!0,children:[(0,H.jsxs)(`li`,{children:[n(e.source_path),` `,(0,H.jsx)(`code`,{children:e.source_symbol})]}),(0,H.jsxs)(`li`,{children:[`→ `,n(e.sink_path),` `,(0,H.jsx)(`code`,{children:e.sink_symbol})]})]})}function bg({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=_f(r.evidence),u=e.flow_evidence.find(e=>_f(e)===l),{flows:d}=e.layers.violations,f=d.state===`ok`?d.evidence.find(e=>_f(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=Zp(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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:i(`architecture.sequence.selected`)}),(0,H.jsxs)(`h3`,{"data-step-title":!0,children:[a.get(s),` → `,a.get(c)]}),(0,H.jsx)(`p`,{children:r.label}),(0,H.jsxs)(`code`,{className:`architecture-map__id`,children:[t.id,` · `,n??i(`architecture.sequence.main`),` · `,r.id]}),(0,H.jsx)(`dl`,{className:`detail-list`,children:[s,c].map((e,t)=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:i(t===0?`architecture.sequence.from`:`architecture.sequence.to`)}),(0,H.jsxs)(`dd`,{children:[a.get(e),x(e)!==null&&(0,H.jsxs)(`span`,{className:`detail-quiet`,"data-node-size":!0,children:[` · `,x(e)]})]})]},t))}),(0,H.jsx)(`h4`,{children:i(`architecture.sequence.evidence`)}),(0,H.jsx)(yg,{evidence:u,t:i}),(0,H.jsx)(`h4`,{children:i(`architecture.sequence.proof`)}),d.state===`ok`?(0,H.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,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`proof`,"data-reason":d.reason,"data-code":d.reason===`archctx_error`?Ep(d):void 0,children:d.reason===`archctx_error`?i(`architecture.layer.reason.archctx_error`,{code:Ep(d)}):i(`architecture.layer.reason.${d.reason}`)}),f!==null&&f.call_sites.length>0&&(0,H.jsx)(`ul`,{className:`architecture-sequence__code`,"data-call-sites":!0,"aria-label":i(`architecture.sequence.callSites`),children:f.call_sites.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e.line===null?e.path:`${e.path}:${e.line}`})},`${e.path}:${e.line??``}`))}),p!==`proven`&&(0,H.jsx)(Xp,{part:`flows`,t:i}),(0,H.jsx)(`h4`,{children:i(`architecture.inspector.pullRequests`)}),y&&(0,H.jsx)(`p`,{"data-step-today":!0,children:i(`architecture.sequence.today`)}),b.length?(0,H.jsx)(`ul`,{"data-related-prs":!0,children:b.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title]},e.number))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:_.state===`unavailable`?i(`architecture.layer.pull_requests.${_.reason}`):i(`architecture.inspector.none`)}),(0,H.jsx)(`h4`,{children:i(`architecture.sequence.relations`,{count:h.length})}),h.length?(0,H.jsx)(`ul`,{children:h.map(e=>{let t=m.find(t=>t.source===e.source&&t.target===e.target)?.imports;return(0,H.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,H.jsx)(`code`,{children:e.kind}),` `,a.get(e.source),` → `,a.get(e.target),t!==void 0&&(0,H.jsxs)(`span`,{className:`mono-value`,children:[` · `,i(`architecture.map.imports`,{count:t})]})]},e.id)})}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.none`)})]})}function xg(e){return[{key:`process`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--box`}),text:e(`architecture.sequence.legend.process`)},{key:`external`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:e(`architecture.sequence.legend.external`)},{key:`success`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--success`}),text:e(`architecture.sequence.legend.success`)},{key:`error`,swatch:(0,H.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=fg(e,n,r),o=pg(e),s=new Map(e.nodes.map(e=>[e.id,e.name]));return ug(t,Hh(e),{tone:(e,r)=>mg(n,a,o,t.id,e,r),status:e=>{let t=o?.get(_f(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`):vg(e,t,n)}function wg({map:e,layout:t,layer:n,pullRequest:r,selected:i,onSelect:a,t:o}){let s=(0,L.useMemo)(()=>zp(e,n,r),[e,n,r]),c=(0,L.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:`${sg(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,L.useCallback)(e=>t.scene.labels.find(t=>t.route===e.id).text,[t]),u=(0,L.useCallback)(e=>e.id,[]),d=i!==null&&t.parts.get(i)?.kind===`participant`?`lifeline:${i.slice(12)}`:null;return(0,H.jsx)(fm,{label:o(`architecture.sequence.label`),scene:t.scene,nodeTypes:_g,view:c,selected:i,emphasis:d,routeLabel:l,routeSelection:u,onSelect:a,legend:xg(o),t:o})}function Tg({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:Hh(e)(f)};return(0,H.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,H.jsx)(bg,{map:e,flow:l,outcome:u.outcome,step:u.step,t:c}):p===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.sequence.pick`)}):(0,H.jsx)(im,{map:e,layer:r,pullRequest:i,nodeId:p.node,onModule:s,t:c,children:(0,H.jsx)(`p`,{"data-runtime":p.place.kind,children:c(`architecture.sequence.runsIn`,{place:vg(p.place,new Map(e.nodes.map(e=>[e.id,e.name])),c)})})}))]})}var Eg={violations:`imports_on_module_map`,tests:`tests_by_capability`,decisions:`decisions_by_node`};function Dg(e,t,n,r,i){let a=i!==null&&e.flows.some(e=>e.id===i)?i:gg(e,t,n,r);return e.flows.find(e=>e.id===a)}function Og({map:e,layer:t,pullRequest:n,flowId:r,t:i}){let a=(0,L.useMemo)(()=>fg(e,t,n),[e,t,n]),o=(0,L.useMemo)(()=>pg(e),[e]),s=(0,L.useMemo)(()=>{let t=new Set(e.flow_evidence.map(e=>_f(e))),n=e.flows.flatMap(e=>vf(e));return{flows:e.flows.length,steps:n.length,evidenced:n.filter(({step:e})=>t.has(_f(e.evidence))).length}},[e]);if(e.flows.length===0)return null;let c=Dg(e,t,a,o,r);return(0,H.jsxs)(`div`,{className:`architecture-lens__tools`,children:[(0,H.jsx)(`span`,{"data-sequence-summary":!0,children:i(`architecture.sequence.summary`,s)}),(0,H.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);lm(`${c.id}.svg`,r.scene,r.lines)},children:i(`architecture.sequence.export`)})]})}function kg({map:e,flowId:t,lit:n,onFlow:r,t:i}){return(0,H.jsxs)(`div`,{className:`architecture-sequence__flows`,role:`group`,"aria-labelledby":`architecture-sequence-flows`,children:[(0,H.jsx)(`h4`,{id:`architecture-sequence-flows`,children:i(`architecture.sequence.flows`)}),(0,H.jsx)(`div`,{className:`architecture-sequence__flow-list`,children:e.flows.map((e,a)=>(0,H.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,H.jsx)(`span`,{className:`mono-value`,children:a+1}),(0,H.jsx)(`span`,{className:`architecture-sequence__flow-name`,children:e.name}),n.has(e.id)&&(0,H.jsx)(`span`,{className:`architecture-sequence__lit`,"aria-label":i(`architecture.sequence.lit`)})]},e.id))})]})}function Ag({map:e,layer:t,pullRequest:n,flowId:r,onFlow:i,selection:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,L.useMemo)(()=>fg(e,t,n),[e,t,n]),d=(0,L.useMemo)(()=>pg(e),[e]),f=(0,L.useMemo)(()=>hg(e,t,u,d),[e,t,u,d]),p=e.flows.length===0?null:Dg(e,t,u,d,r),m=(0,L.useMemo)(()=>p?.applicability===`required`?Sg(e,p,t,n,l):null,[e,p,t,n,l]),h=p?.id??``,g=(0,L.useCallback)(e=>o(h,e),[h,o]);if(p===null)return(0,H.jsxs)(`div`,{className:`architecture-map`,children:[(0,H.jsx)(qp,{part:`sequence.flows`,reason:`flows_undeclared`,children:l(`architecture.sequence.none`)}),(0,H.jsx)(`aside`,{className:`architecture-map__inspector`,"aria-label":l(`architecture.sequence.inspector`),children:s})]});let _=Eg[t],v=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(kg,{map:e,flowId:p.id,lit:f,onFlow:i,t:l}),s,_&&(0,H.jsx)(qp,{part:`sequence.${t}`,reason:_,children:l(`architecture.sequence.note.${_}`)})]}),y=a?.scope===p.id?a.id:null;return(0,H.jsx)(`div`,{className:`architecture-sequence`,children:(0,H.jsxs)(`div`,{className:`architecture-map`,"data-view":`sequence`,"data-flow":p.id,"data-layer":t,children:[p.applicability===`not-applicable`?(0,H.jsx)(qp,{part:`sequence.not_applicable`,reason:`flow_not_applicable`,children:l(`architecture.flow.notApplicable`,{rationale:p.rationale})}):(0,H.jsx)(wg,{map:e,layout:m,layer:t,pullRequest:n,selected:y,onSelect:g,t:l},p.id),(0,H.jsx)(Tg,{map:e,flow:p,layout:m,layer:t,pullRequest:n,selected:y,lead:v,onModule:c,t:l})]})})}var jg=[`process`,`namespace`,`mount`],Mg=new Set([`namespace`,`process`,`mount`,`external-system`]),Ng=220,Pg=72,Fg=32,Ig=16,Lg=12,Rg=72,zg=320,Bg=24,Vg=1.5,Hg=new Set([`runs-in`,`deployed-on`,`mounts`]),Ug=(e,t)=>`${e}/${t}`,Wg=(e,t)=>e(t.source)&&e(t.target);function Gg(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`?Xg(e,t,o,i):n===`namespace`?t_(e,o,i):n_(e,o)}function Kg(e){let t=Hh(e),n=[`namespace`,`process`,`mount`],r=n.map(n=>Gg(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 qg(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 Jg(e,t,n,r,i){return{id:e,source:t,target:n,kind:r,dashed:i,relations:[],protocols:[]}}function Yg(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 Xg(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`&&Wg(n,t)&&i.get(t.target)?.kind===`process`&&!Mg.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(Hg.has(t.kind)||!Wg(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=la.has(t.kind),s=o(t.source)&&o(t.target)?t.kind:a?`io`:`code`,d=`${e}\n${r}\n${s}`;l.set(d,Yg(l.get(d)??Jg(`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=Zi({nodes:a.map(e=>({id:e.id,width:Ng,height:d(e),kind:Zg(e,null)})),edges:[...l.values()].map(e=>({...Qg(e),weight:e.relations.length})),nodesep:32,ranksep:72,margin:Bg},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:$g(p,f.boxes,f.routes,[...l.values()])}}var Zg=(e,t)=>t??(e.kind===`namespace`?`frame`:e.kind===`external-system`?`external`:`box`),Qg=e=>({id:e.id,source:e.source,target:e.target,arrows:{start:!1,end:!0},kind:e.kind,dashed:e.dashed,width:Vg});function $g(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:Ug(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=>Fi(e.protocols.join(` · `),Ii(o.get(e.id)),e.id)),extent:Xi(a,n,Bg)}}var e_=(e,t)=>e.mount.order-t.mount.order;function t_(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`?qg(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`&&Wg(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(Hg.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,Yg(u.get(e)??Jg(`topology:${e}`,t.source,t.target,t.kind,la.has(t.kind)),t))}let d=e=>[...a.filter(t=>t.kind===`mount`&&s.get(t.id)===e).sort(e_),...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:Ng,height:Pg,kind:Zg(e,i.tone)};return f.push(i),p.push(a),a}let i=f.length,a=d(e.id),o=n+Fg+Ig,l=Ng;for(let e of a){let n=m(e,t+Ig,o);o=n.y+n.height+Lg,l=Math.max(l,n.width)}let u=a.length===0?74:o-Lg+Ig-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=Zi({nodes:h.map(e=>({id:e.id,width:e.width,height:e.height,kind:e.kind})),edges:_.map(e=>({...Qg(e),source:g(e.source),target:g(e.target),weight:e.relations.length})),nodesep:Rg,ranksep:72,margin:Bg},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?[Li(t,x(r)),Li(r,x(t))]:[...i.points];i!==void 0&&i.source!==e.source&&a.unshift(Li(t,a[0])),i!==void 0&&i.target!==e.target&&a.push(Li(r,a[a.length-1]));let o=new Set([...C(e.source),...C(e.target)]);return{...Qg(e),points:n?Ji(a,[...b.values()].filter(e=>!o.has(e.id))):a}});return{base:`namespace`,boxes:f,edges:[...u.values()],unplaced:[],scene:$g(f,[...b.values()],w,[...u.values()])}}function n_(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`&&Wg(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(e_),group:!1,tone:null}));return{base:`mount`,boxes:i,edges:[],unplaced:[],scene:$g(i,i.map((e,t)=>({id:e.node.id,parent:null,x:Bg+t*352,y:Bg,width:zg,height:44+e.members.length*26+8,kind:Zg(e.node,null)})),[],[])}}var r_=e=>e.status===`deprecated`||void 0,i_={box:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.node.name}),(0,H.jsx)(Jp,{mark:e.mark})]}),(0,H.jsx)(`span`,{className:`architecture-map__meta`,children:e.detail})]})]})}),namespace:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.node.name}),(0,H.jsx)(Jp,{mark:e.mark})]}),(0,H.jsx)(`span`,{className:`architecture-map__meta mono-value`,children:e.detail})]}),e.empty!==null&&(0,H.jsx)(`p`,{className:`architecture-topology__empty`,"data-namespace-empty":!0,children:e.empty})]})}),mount:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.node.name}),(0,H.jsx)(Jp,{mark:e.mark})]}),(0,H.jsx)(`span`,{className:`architecture-topology__summary`,title:e.node.summary,children:e.node.summary})]})}),member:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.detail}),(0,H.jsx)(Jp,{mark:e.mark})]})})})},a_=(e,t)=>e??t(`architecture.topology.masked`);function o_(e,t){let{order:n,source:r,target:i,mode:a}=e.mount;return t(`architecture.topology.mountRow`,{order:n,source:a_(r,t),target:a_(i,t),mode:a})}function s_(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 c_=(e,t)=>e.kind===`mount`?o_(e,t):e.name,l_=e=>new Map(e.boxes.flatMap(e=>[[e.node.id,{box:e,member:null}],...e.members.map(t=>[Ug(e.node.id,t.id),{box:e,member:t}])]));function u_(e,t){let n=l_(e);return e=>{let{box:r,member:i}=n.get(e.id);return i===null?[r.node.name,s_(r,t)]:[c_(i,t)]}}function d_(e,t){return e===`process`?[{key:`code`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.topology.legend.runtime`)},{key:`external`,swatch:(0,H.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,H.jsx)(`span`,{className:`architecture-topology__swatch`,"data-mount-tone":e}),text:t(`architecture.topology.legend.${e}`)}))}var f_=(e,t,n)=>Gg(e,Hh(e),t,n);function p_({map:e,base:t,onBase:n,legacy:r,onLegacy:i,t:a}){let o=(0,L.useMemo)(()=>f_(e,t,!0),[e,t]),s=o.boxes.flatMap(e=>[e.node,...e.members]).filter(e=>e.status===`deprecated`).length;return(0,H.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,H.jsx)(`span`,{className:`architecture-topology__bases`,role:`group`,"aria-label":a(`architecture.topology.base`),children:jg.map(e=>(0,H.jsx)(`button`,{type:`button`,"data-topology-base":e,"aria-pressed":e===t,onClick:()=>n(e),children:a(`architecture.topology.base.${e}`)},e))}),(0,H.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,H.jsx)(`span`,{className:`architecture-topology__switch`,"aria-hidden":`true`}),a(`architecture.topology.legacy`),(0,H.jsx)(`span`,{className:`mono-value`,children:s})]}),(0,H.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-topology-export":!0,disabled:o.boxes.length===0,onClick:()=>{let n=f_(e,t,r);lm(`topology-${t}-${e.commit.slice(0,7)}.svg`,n.scene,u_(n,a))},children:a(`architecture.topology.export`)})]})}function m_({map:e,nodeId:t,names:n,t:r}){let i=e.relations.filter(e=>e.kind===`writes`&&e.target===t);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.topology.writers`)}),i.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,"data-writers":`none`,children:r(`architecture.topology.noWriter`)}):(0,H.jsx)(`ul`,{"data-writers":!0,children:i.map(e=>(0,H.jsx)(`li`,{children:n.get(e.source)},e.id))})]})}function h_({map:e,layout:t,layer:n,pullRequest:r,selectedId:i,onSelect:a,side:o,onModule:s,t:c}){let l=(0,L.useMemo)(()=>Hh(e),[e]),u=(0,L.useMemo)(()=>zp(e,n,r),[e,n,r]),d=(0,L.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),f=(0,L.useMemo)(()=>new Map(t.boxes.map(e=>[e.node.id,e])),[t]),p=(0,L.useMemo)(()=>l_(t),[t]),m=(0,L.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:qg(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,L.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:s_(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:c_(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||Mg.has(g.kind)?null:l(g.id),y=g?.kind===`process`?qg(e,g.id):null,b=g?.kind===`mount`?e.relations.find(e=>e.kind===`mounts`&&e.target===g.id)?.source??null:null;return(0,H.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,H.jsx)(fm,{label:c(`architecture.topology.label`),scene:t.scene,nodeTypes:i_,view:h,selected:i,onSelect:a,legend:d_(t.base,c),t:c}),(0,H.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":c(`architecture.map.inspector`),"data-node-id":i??void 0,children:[o,g===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.map.pick`)}):(0,H.jsxs)(im,{map:e,layer:n,pullRequest:r,nodeId:g.id,onModule:s,t:c,children:[y!==null&&(0,H.jsx)(`p`,{"data-runs-in":y,children:c(`architecture.topology.in`,{name:d.get(y)})}),v?.kind===`process`&&(0,H.jsx)(`p`,{"data-runtime":`process`,children:c(`architecture.sequence.runsIn`,{place:d.get(v.process)})}),g.kind===`namespace`&&(0,H.jsx)(`dl`,{className:`detail-list`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.type`)}),(0,H.jsx)(`dd`,{"data-namespace-type":!0,children:g.namespace.type})]})}),g.kind===`mount`&&(0,H.jsxs)(`dl`,{className:`detail-list`,"data-mount-fields":!0,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.order`)}),(0,H.jsx)(`dd`,{className:`mono-value`,children:g.mount.order})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.path`)}),(0,H.jsxs)(`dd`,{className:`mono-value`,children:[a_(g.mount.source,c),` → `,a_(g.mount.target,c)]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.mode`)}),(0,H.jsx)(`dd`,{className:`mono-value`,children:g.mount.mode})]}),b!==null&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.mounter`)}),(0,H.jsx)(`dd`,{children:d.get(b)})]})]}),(g.kind===`namespace`||g.kind===`mount`)&&(0,H.jsx)(m_,{map:e,nodeId:g.id,names:d,t:c}),g.kind===`process`&&_!==null&&_.members.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:c(`architecture.topology.deployed`,{count:_.members.length})}),(0,H.jsx)(`ul`,{"data-deployed":!0,children:_.members.map(t=>{let n=Zp(e,t.id);return(0,H.jsxs)(`li`,{children:[t.name,n&&(0,H.jsxs)(`span`,{className:`detail-quiet`,children:[` · `,c(`architecture.map.sizeValue`,{lines:n.lines,files:n.files})]})]},t.id)})})]})]})]})]})}var g_={process:{part:`topology.processes`,reason:`process_undeclared`},namespace:{part:`topology.namespaces`,reason:`namespace_undeclared`},mount:{part:`topology.mounts`,reason:`mount_undeclared`}};function __({map:e,layer:t,pullRequest:n,base:r,legacy:i,selectedId:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,L.useMemo)(()=>Hh(e),[e]),d=(0,L.useMemo)(()=>Gg(e,u,r,i),[e,u,r,i]),f=(0,L.useMemo)(()=>zp(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:{...g_[r],text:l(`architecture.topology.none.${r}`)}:{part:`topology.empty`,reason:`topology_undeclared`,text:l(`architecture.topology.none`)};if(p!==null)return(0,H.jsxs)(`div`,{className:`architecture-map`,"data-view":`topology`,"data-base":r,children:[(0,H.jsx)(qp,{part:p.part,reason:p.reason,children:p.text}),(0,H.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,H.jsxs)(`div`,{className:`architecture-topology`,children:[t===`violations`&&(0,H.jsx)(qp,{part:`topology.violations`,reason:`imports_on_module_map`,children:l(`architecture.sequence.note.imports_on_module_map`)}),_.length>0&&(0,H.jsx)(qp,{part:`topology.unplaced_marks`,reason:`deployment_undeclared`,children:l(`architecture.topology.hidden`,{count:_.length})}),d.unplaced.length>0&&(0,H.jsx)(qp,{part:`topology.unplaced`,reason:`deployment_undeclared`,children:(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:l(`architecture.topology.unplaced`,{count:d.unplaced.length})}),(0,H.jsx)(`ul`,{children:d.unplaced.map(e=>{let t=h.get(e);return(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:t.kind}),` `,m.get(t.source),` → `,m.get(t.target)]},e)})})]})}),(0,H.jsx)(h_,{map:e,layout:d,layer:t,pullRequest:n,selectedId:a,onSelect:o,side:s,onModule:c,t:l},`${e.commit}:${r}:${i}`)]})}async function v_(e,t){let n=await u(`/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 Sp(r)??{state:`unavailable`,reason:`unreachable`};try{return{state:`ok`,map:xp(r)}}catch{return{state:`unavailable`,reason:`architecture_map_invalid`}}}function y_(e,t,n){let[r,i]=(0,L.useState)(null),a=(0,L.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 o(a,JSON.stringify([t,n])),r?.repositoryId===t?r.read:null}function b_(e,t){return t===`violations`?Object.values(e.layers.violations).some(e=>e.state===`ok`):e.layers[t].state===`ok`}function x_(e,t,n,r){if(!b_(e,t))return null;let{changes:i,pull_requests:a,tests:o,decisions:s}=e.layers,c=t=>[...Rp(e,t,n).marks.values()].filter(e=>e.tone!==`muted`).length;if(t===`changes`)return i.state===`ok`?r(`architecture.layer.count.changes`,{modules:Gp(r,c(`changes`),`module`,i.truncated.nodes),commits:Gp(r,i.commits.length,`commit`)}):null;if(t===`violations`)return String(Op(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:Gp(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:Gp(r,s.items.length,`decision`)}function S_({map:e,layer:t,pullRequest:n,onLayer:r,t:i}){return(0,H.jsx)(`div`,{className:`architecture-layers`,role:`group`,"aria-labelledby":`architecture-layers-label`,children:Cp.map(a=>{let o=x_(e,a,n,i);return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":t===a,"data-layer":a,"data-state":b_(e,a)?`ok`:`unavailable`,onClick:()=>r(a),children:[i(`architecture.layer.${a}`),o!==null&&(0,H.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=Np(t.truncated);return(0,H.jsxs)(H.Fragment,{children:[n&&(i.status===`known`?(0,H.jsx)(`p`,{"data-flow-steps":e,children:r(`architecture.layer.flow_steps.known`,{count:i.items.length})}):(0,H.jsx)(Kp,{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,H.jsx)(`ul`,{"data-flow-step-list":e,children:i.items.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.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,H.jsx)(qp,{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 w_({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,H.jsx)(Kp,{part:`changes`,reason:o.reason,code:Ep(o),children:a(`architecture.layer.changes.archctx_error`,{code:Ep(o)})}):(0,H.jsx)(Kp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`changes`,children:[(0,H.jsxs)(`p`,{children:[a(`architecture.layer.changes.summary`,{commits:Gp(a,o.commits.length,`commit`),files:Gp(a,o.paths.length,`file`,o.truncated.paths),unowned:`${o.truncated.paths?`≥`:``}${o.unowned_paths.length}`}),` `,(0,H.jsx)(`time`,{dateTime:o.since,children:new Date(o.since).toLocaleString()}),` · `,(0,H.jsx)(`code`,{children:o.base.slice(0,12)})]}),(0,H.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,H.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,H.jsx)(Kp,{part:`violations.${e}`,reason:t.reason,code:Ep(t),children:o(e,a(`architecture.layer.reason.archctx_error`,{code:Ep(t)}))}):(0,H.jsx)(Kp,{part:`violations.${e}`,reason:t.reason,children:o(e,a(`architecture.layer.reason.${t.reason}`))}),l=i.state===`ok`?(0,H.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,H.jsx)(qp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`violations`,children:[e.state===`ok`?(0,H.jsx)(`p`,{children:a(`architecture.layer.violations.debt`,{count:e.items.length})}):c(`debt`,e),u.length>0&&(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:a(`architecture.layer.unowned`,{count:u.length})}),(0,H.jsx)(`ul`,{children:u.flatMap(e=>e.paths.map(t=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:t}),` · `,a(`architecture.layer.debt.${e.kind}`)]},`${e.kind}:${t}`)))})]}),t.state===`ok`?(0,H.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,H.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,H.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,H.jsx)(Kp,{part:`tests`,reason:l.reason,children:a(`architecture.layer.tests.${l.reason}`)});let t=e.nodes.filter(e=>e.kind===`capability`).length;return(0,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`tests`,children:[(0,H.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,H.jsx)(`time`,{dateTime:l.run.created_at,children:new Date(l.run.created_at).toLocaleString()}),` · `,(0,H.jsx)(`code`,{children:l.run.head_sha.slice(0,12)})]}),l.results!==`ok`&&(0,H.jsx)(Kp,{part:`results`,reason:l.results,children:a(`architecture.layer.tests.results.${l.results}`)})]})}if(n===`pull_requests`){if(c.state===`unavailable`)return(0,H.jsx)(Kp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`pull_requests`,children:[(0,H.jsxs)(`p`,{children:[a(`architecture.layer.pull_requests.summary`,{count:c.pull_requests.length}),` `,(0,H.jsx)(`time`,{dateTime:c.observed_at,children:new Date(c.observed_at).toLocaleString()})]}),c.pull_requests.length>0&&(0,H.jsxs)(`label`,{className:`architecture-layer-summary__pick`,children:[(0,H.jsx)(`span`,{children:a(`architecture.layer.pull_requests.pick`)}),(0,H.jsxs)(`select`,{value:e?.number??``,onChange:e=>i(Number(e.target.value)),children:[e===null&&(0,H.jsx)(`option`,{value:``,disabled:!0,children:a(`architecture.layer.pull_requests.none`)}),c.pull_requests.map(e=>(0,H.jsxs)(`option`,{value:e.number,children:[`#`,e.number,` `,e.title]},e.number))]})]}),e&&(0,H.jsxs)(`p`,{"data-pull-request":e.number,children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),e.head_sha!==null&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`code`,{children:e.head_sha.slice(0,12)})]}),e.impact.state===`ok`&&(0,H.jsxs)(H.Fragment,{children:[` · `,a(`architecture.layer.pull_requests.impact`,{files:Gp(a,e.impact.paths.length,`file`,e.impact.truncated.paths),nodes:Gp(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,H.jsx)(C_,{part:`pull_request`,impact:e.impact,flowSteps:t===`sequence`,t:a}),e?.impact.state===`unavailable`&&(e.impact.reason===`archctx_error`?(0,H.jsx)(Kp,{part:`pull_request`,reason:e.impact.reason,code:Ep(e.impact),children:a(`architecture.layer.pull_requests.pr.archctx_error`,{code:Ep(e.impact)})}):(0,H.jsx)(Kp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`decisions`,children:[(0,H.jsx)(`p`,{children:a(`architecture.layer.decisions.summary`,{count:Gp(a,u.items.length,`decision`),applied:u.items.length-d.length})}),d.length>0&&(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:a(`architecture.layer.decisions.unapplied`,{count:d.length})}),(0,H.jsx)(`ul`,{children:d.map(e=>(0,H.jsxs)(`li`,{children:[e.title,` · `,(0,H.jsx)(`code`,{children:e.path})]},e.id))})]})]})}function T_({read:e,kept:t,t:n}){let r=e.reason===`archctx_error`?Ep(e):void 0,i=e.reason===`architecture_map_pending`;return(0,H.jsxs)(`p`,{className:i?void 0:`architecture-notice`,role:i?`status`:`alert`,"data-error-code":e.reason,"data-code":r,children:[t&&(0,H.jsx)(`span`,{className:`block`,children:n(`architecture.map.kept`)}),(0,H.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}`,r===void 0?void 0:{code:r})}),(0,H.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}.next`)})]})}function E_({map:e,t}){return(0,H.jsxs)(H.Fragment,{children:[e.sizes.state===`unavailable`&&(0,H.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,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`dependencies`,"data-reason":e.dependencies.reason,children:t(`architecture.map.dependencies.${e.dependencies.reason}`)})]})}function D_({repositoryId:e,view:t=`modules`,read:n=v_,refreshGeneration:r,selections:i,select:a,onModule:o,onSummary:s,t:c}){let l=y_(n,e,r),[u,d]=(0,L.useState)(`changes`),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(null),[v,y]=(0,L.useState)(!0),b=(0,L.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:Ap(x),w=(0,L.useMemo)(()=>x===null||t!==`topology`?`namespace`:Kg(x),[x,t]),T=g??w,E=`${T}:${v}`,D=i.topology?.scope===E?i.topology.id:null,O=(0,L.useCallback)(e=>{_(e),a({view:`topology`,scope:``,id:null})},[a]),k=(0,L.useCallback)(e=>{y(e),a({view:`topology`,scope:``,id:null})},[a]),A=(0,L.useCallback)(e=>a({view:`topology`,scope:E,id:e}),[E,a]),j=(0,L.useCallback)(e=>a({view:`modules`,scope:``,id:e}),[a]),M=(0,L.useCallback)(e=>a({view:`layers`,scope:``,id:e}),[a]),N=(0,L.useCallback)((e,t)=>a({view:`sequence`,scope:e,id:t}),[a]),P=(0,L.useCallback)(e=>{h(e),a({view:`sequence`,scope:``,id:null})},[a]);(0,L.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,L.useEffect)(()=>()=>s(null),[s]);let F=x&&(0,H.jsxs)(`div`,{className:`architecture-map__side`,"data-map-side":!0,children:[(0,H.jsx)(E_,{map:x,t:c}),(0,H.jsx)(w_,{map:x,view:t,layer:u,pullRequest:C,onPullRequest:p,t:c})]});return(0,H.jsxs)(`div`,{className:`architecture-map-view`,children:[l===null&&(0,H.jsx)(`p`,{role:`status`,children:c(`architecture.map.loading`)}),l?.state===`unavailable`&&(0,H.jsx)(T_,{read:l,kept:x!==null,t:c}),x&&t===`layers`&&(0,H.jsx)(ah,{map:x,selectedId:i.layers?.id??null,onSelect:M,t:c},`${e}:${x.commit}`),x&&t!==`layers`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`architecture-lens`,children:[(0,H.jsx)(`span`,{id:`architecture-layers-label`,className:`architecture-lens__label`,children:c(`architecture.layers`)}),(0,H.jsx)(S_,{map:x,layer:u,pullRequest:C,onLayer:d,t:c}),t===`sequence`?(0,H.jsx)(Og,{map:x,layer:u,pullRequest:C,flowId:m,t:c}):t===`topology`?(0,H.jsx)(p_,{map:x,base:T,onBase:O,legacy:v,onLegacy:k,t:c}):(0,H.jsx)(`span`,{className:`architecture-lens__hint`,children:c(`architecture.lens.hint`)})]}),t===`modules`&&(0,H.jsx)(Vh,{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,H.jsx)(Ag,{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,H.jsx)(__,{map:x,layer:u,pullRequest:C,base:T,legacy:v,selectedId:D,onSelect:A,side:F,onModule:o,t:c},`${e}:${x.commit}`)]})]})}var O_=200,k_=40,A_=52,j_=260,M_=240,N_=44,P_=580,F_=780;function I_(e){return e.length>26?`${e.slice(0,25)}…`:e}function L_(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}function R_(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=N_+i.length*A_+(i.length?4:0),o=Math.max(n.length*A_,r.length*A_,a)+8,s=new Map,c=(e,t,n)=>{let r=(o-e.length*A_)/2+6;e.forEach((e,i)=>s.set(e.id,{x:t,y:r+i*A_,w:O_,h:k_,column:n,center:!1}))};c(n,0,0),c(r,P_,2);let l=(o-a)/2;return s.set(e.center,{x:j_,y:l,w:M_,h:a,column:1,center:!0}),i.forEach((e,t)=>s.set(e.id,{x:284,y:l+N_+t*A_,w:204,h:k_,column:1,center:!1})),{boxes:s,height:o}}function z_(e){return e.center?e.y+N_/2:e.y+e.h/2}function B_(e,t){if(e.column<t.column)return[[e.x+e.w,z_(e)],[t.x,z_(t)]];if(e.column>t.column)return[[e.x,z_(e)],[t.x+t.w,z_(t)]];let n=e=>e.center?[272,e.y+N_-6]:[e.x,z_(e)],[r,i]=n(e),[a,o]=n(t);return[[r,i],[272,i],[272,o],[a,o]]}function V_(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 H_(e,t){return re(e)?t(`architecture.graph.more`,{count:e.count}):e.name}function U_({graph:e,onSelect:t,t:n}){let r=(0,L.useId)(),[i,a]=(0,L.useState)([]),{boxes:o,height:s}=R_(e),c=new Map(e.nodes.map(e=>[e.id,H_(e,n)])),l=e=>a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),u=e.nodes.filter(re).filter(e=>i.includes(e.id));return(0,H.jsxs)(`figure`,{className:`module-graph`,"aria-labelledby":`${r}-caption`,children:[(0,H.jsxs)(`figcaption`,{id:`${r}-caption`,className:`module-graph__caption`,children:[(0,H.jsx)(`span`,{children:n(`architecture.graph.callers`)}),(0,H.jsx)(`span`,{children:n(`architecture.graph.module`)}),(0,H.jsx)(`span`,{children:n(`architecture.graph.callees`)})]}),(0,H.jsxs)(`svg`,{className:`module-graph__svg`,viewBox:`0 0 ${F_} ${s}`,width:F_,height:s,role:`group`,"aria-labelledby":`${r}-caption`,children:[(0,H.jsx)(`defs`,{children:(0,H.jsx)(`marker`,{id:`${r}-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,H.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=H_(e,n);if(re(e)){let t=i.includes(e.id);return(0,H.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=>L_(t,()=>l(e.id)),children:[(0,H.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,H.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`?h.test(e.id):!1,c=()=>t(e.id);return(0,H.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=>L_(e,c)}:{},children:[(0,H.jsx)(`title`,{children:`${e.name} (${e.id})`}),(0,H.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,H.jsx)(`text`,{x:r.x+12,y:r.center?r.y+N_/2:r.y+r.h/2,dominantBaseline:`central`,children:I_(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=B_(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,H.jsxs)(`g`,{className:`module-graph__edge`,"data-direction":e.direction,children:[(0,H.jsx)(`path`,{d:V_(a),...s?{markerEnd:`url(#${r}-arrow)`}:{strokeDasharray:`5 4`},children:(0,H.jsx)(`title`,{children:`${e.intent} (${e.relation_kind})`})}),!s&&(0,H.jsx)(`text`,{className:`module-graph__edge-label`,x:c,y:l-4,textAnchor:`middle`,children:e.relation_kind})]},t)})]}),u.map(e=>(0,H.jsxs)(`section`,{className:`module-graph__group`,"aria-label":n(`architecture.graph.group.${e.role}`,{count:e.count}),children:[(0,H.jsx)(`h4`,{children:n(`architecture.graph.group.${e.role}`,{count:e.count})}),(0,H.jsx)(`ul`,{children:e.members.map(e=>(0,H.jsxs)(`li`,{children:[h.test(e.id)?(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),children:e.name}):(0,H.jsx)(`span`,{children:e.name}),(0,H.jsx)(`code`,{children:e.id})]},e.id))})]},e.id)),(0,H.jsx)(`ul`,{className:`module-graph__relations`,"aria-label":n(`architecture.graph.relations`),children:e.edges.map((e,t)=>(0,H.jsxs)(`li`,{"data-direction":e.direction,children:[(0,H.jsx)(`span`,{children:c.get(e.source)??e.source}),(0,H.jsx)(`span`,{children:` → `}),(0,H.jsx)(`span`,{children:c.get(e.target)??e.target}),(0,H.jsx)(`span`,{className:`module-graph__intent`,children:e.intent}),(0,H.jsx)(`code`,{children:e.relation_kind})]},t))})]})}function W_(e){let t=e?.code;return typeof t==`string`&&/^[a-z][a-z0-9_]{0,63}$/u.test(t)?t:null}async function G_(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=W_(i);if(e===null)throw Error(`unavailable`);return{state:`unavailable`,reason:e}}return{body:i,etag:r.headers.get(`ETag`)}}function K_(e,t,n){let[r,i]=(0,L.useState)({path:null,value:null,error:null}),a=(0,L.useRef)(null),s=(0,L.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 G_(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 o(s,JSON.stringify([e,n]),{enabled:e!==null}),r.path===e?r:{path:e,value:null,error:null}}function q_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/modules`}function J_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/history`}function Y_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/refactor`}function X_(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 Z_({read:e,loading:t,t:n}){return e.error===null?e.value===null?(0,H.jsx)(`p`,{role:`status`,children:n(t)}):null:(0,H.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 Q_={valid:`tone-ok`,fresh:`tone-ok`,present:`tone-ok`,invalid:`tone-danger`,stale:`tone-user`,pending:`tone-user`,unknown:`tone-unknown`};function $_({state:e,t}){return(0,H.jsx)(`ul`,{className:`module-states`,"aria-label":t(`architecture.states`),children:[`model_valid`,`generated_summary`,`section3`].map(n=>(0,H.jsxs)(`li`,{className:`operator-badge ${Q_[e[n]]}`,"data-state-kind":n,"data-state-value":e[n],children:[t(`architecture.state.${n}`),`: `,(0,H.jsx)(`strong`,{children:t(`architecture.value.${e[n]}`)})]},n))})}function ev({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,H.jsx)(`p`,{className:`empty-inline`,children:n(`architecture.empty`)}):(0,H.jsx)(`div`,{className:`module-domains`,children:[...r].map(([e,r])=>(0,H.jsxs)(`section`,{className:`module-domain`,"data-domain":e,"aria-labelledby":`domain-${e}`,children:[(0,H.jsxs)(`h3`,{id:`domain-${e}`,children:[e,` `,(0,H.jsx)(`span`,{children:r.length})]}),(0,H.jsx)(`ul`,{children:r.map(e=>(0,H.jsxs)(`li`,{className:`module-row`,"data-module-id":e.id,children:[(0,H.jsxs)(`button`,{type:`button`,className:`module-row__open`,onClick:()=>t(e.id),children:[(0,H.jsx)(`strong`,{children:e.name}),(0,H.jsx)(`code`,{children:e.id})]}),(0,H.jsxs)(`span`,{className:`module-row__meta`,children:[e.status,` · `,n(`architecture.components`,{count:e.components})]}),(0,H.jsx)($_,{state:e.state,t:n})]},e.id))})]},e))})}function tv({base:e,generation:t,t:n}){let[r,i]=(0,L.useState)(1),a=K_(`${e}/review-prompt?shard=${r}`,Ie,t),o=a.value,s=o?X_(o):null;return(0,H.jsxs)(`section`,{className:`architecture-card review-prompt`,"aria-labelledby":`review-prompt-heading`,children:[(0,H.jsx)(`h3`,{id:`review-prompt-heading`,children:n(`architecture.prompt.title`)}),(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.boundary`)}),(0,H.jsx)(Z_,{read:a,loading:`architecture.prompt.loading`,t:n}),o&&s&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`dl`,{className:`detail-list`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:n(`architecture.prompt.digest`)}),(0,H.jsx)(`dd`,{children:(0,H.jsx)(`code`,{className:`mono-value review-prompt__digest`,children:o.digest})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:n(`architecture.prompt.budget`)}),(0,H.jsx)(`dd`,{children:n(`architecture.prompt.budgetValue`,{used:o.budget.used_bytes,cap:o.budget.input_cap_bytes})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:n(`architecture.prompt.omitted`)}),(0,H.jsx)(`dd`,{children:o.budget.omitted_sections.length?o.budget.omitted_sections.join(`, `):n(`architecture.prompt.omittedNone`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:(0,H.jsx)(`label`,{htmlFor:`review-prompt-shard`,children:n(`architecture.prompt.shard`)})}),(0,H.jsx)(`dd`,{children:(0,H.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,H.jsx)(`option`,{value:e,children:n(`architecture.prompt.shardOf`,{index:e,count:o.shard.count})},e))})})]})]}),o.budget.incomplete&&(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.incomplete`,{count:o.shard.count})}),(0,H.jsxs)(`div`,{className:`copy-value review-prompt__command`,children:[(0,H.jsx)(`code`,{"data-bot-command":!0,children:s}),(0,H.jsx)(f,{label:n(`architecture.prompt.command`),value:s,t:n})]}),(0,H.jsxs)(`details`,{className:`review-prompt__text`,children:[(0,H.jsx)(`summary`,{children:n(`architecture.prompt.text`,{index:o.shard.index})}),(0,H.jsx)(`pre`,{children:o.prompt})]}),(0,H.jsx)(`div`,{className:`review-prompt__actions`,children:(0,H.jsx)(f,{label:n(`architecture.prompt.textLabel`,{index:o.shard.index}),value:o.prompt,t:n})})]})]})}function nv(e,t){let n=typeof e==`object`&&e&&!Array.isArray(e)?e[t]:void 0;return typeof n==`string`?n:null}function rv({value:e,outcome:t}){let n=nv(e,`label`)??nv(e,`id`)??JSON.stringify(e),r=t?nv(e,`kind`):[nv(e,`from`),nv(e,`to`)].every(Boolean)?`${nv(e,`from`)} → ${nv(e,`to`)}`:null;return(0,H.jsxs)(`li`,{children:[r&&(0,H.jsx)(`code`,{children:r}),` `,n]})}function iv({items:e,empty:t}){return e.length?(0,H.jsx)(`ul`,{children:e.map((e,t)=>(0,H.jsx)(`li`,{children:e},t))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:t})}function av({detail:e,base:t,generation:n,onModule:r,t:i}){let{module:a}=e,o=i(`architecture.none`);return(0,H.jsxs)(`article`,{className:`module-page`,"aria-labelledby":`module-page-title`,children:[(0,H.jsxs)(`header`,{className:`module-page__header`,children:[(0,H.jsxs)(`p`,{className:`detail-eyebrow`,children:[a.status,` · `,(0,H.jsx)(`code`,{children:a.id})]}),(0,H.jsx)(`h2`,{id:`module-page-title`,children:a.name}),(0,H.jsx)(`p`,{children:a.summary}),(0,H.jsx)($_,{state:e.state,t:i})]}),(0,H.jsx)(U_,{graph:e.graph,onSelect:r,t:i}),(0,H.jsxs)(`div`,{className:`module-page__grid`,children:[(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-facts-heading`,children:[(0,H.jsx)(`h3`,{id:`module-facts-heading`,children:i(`architecture.facts`)}),(0,H.jsx)(`h4`,{children:i(`architecture.responsibilities`)}),(0,H.jsx)(iv,{items:a.responsibilities,empty:o}),(0,H.jsx)(`h4`,{children:i(`architecture.entrypoints`)}),a.entrypoints?.length?(0,H.jsx)(`ul`,{className:`module-entrypoints`,children:a.entrypoints.flatMap(e=>e.symbols.map(t=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:e.path}),` `,t.name,t.sinks.map(e=>(0,H.jsxs)(`span`,{children:[` → `,(0,H.jsx)(`code`,{children:e.path}),` `,e.symbol]},e.id))]},`${e.id}:${t.name}`)))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:o}),(0,H.jsx)(`h4`,{children:i(`architecture.verification`)}),a.verification.length?(0,H.jsx)(`ul`,{children:a.verification.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:o})]}),(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-flows-heading`,children:[(0,H.jsx)(`h3`,{id:`module-flows-heading`,children:i(`architecture.flows`)}),e.flows.length===0&&(0,H.jsx)(`p`,{className:`detail-quiet`,children:o}),e.flows.map(e=>(0,H.jsxs)(`div`,{className:`module-flow`,children:[(0,H.jsxs)(`h4`,{children:[e.name,` `,(0,H.jsx)(`code`,{children:e.id})]}),e.applicability===`not-applicable`?(0,H.jsx)(`p`,{children:i(`architecture.flow.notApplicable`,{rationale:e.rationale})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.steps`)}),(0,H.jsx)(`ul`,{children:e.steps.map((e,t)=>(0,H.jsx)(rv,{value:e,outcome:!1},t))}),(0,H.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.outcomes`)}),(0,H.jsx)(`ul`,{children:e.outcomes.map((e,t)=>(0,H.jsx)(rv,{value:e,outcome:!0},t))})]})]},e.id))]}),(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-section3-heading`,children:[(0,H.jsx)(`h3`,{id:`module-section3-heading`,children:i(`architecture.section3`)}),e.section3===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.section3.pending`)}):(0,H.jsx)(`pre`,{className:`module-section3`,children:e.section3})]}),(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-docs-heading`,children:[(0,H.jsx)(`h3`,{id:`module-docs-heading`,children:i(`architecture.docs`)}),e.linked_docs.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.docs.none`)}):(0,H.jsx)(`ul`,{className:`module-docs`,children:e.linked_docs.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:e.path}),` `,(0,H.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.kind}),` `,(0,H.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.status??i(`architecture.value.unknown`)})]},e.path))})]}),(0,H.jsx)(tv,{base:t,generation:n,t:i},a.id)]})]})}var ov=`rh arch refactor recommendations`,sv=new Set([`accepted`,`acknowledged`,`deferred`]),cv={accepted:`tone-user`,acknowledged:`tone-user`,deferred:`tone-unknown`,resolved:`tone-ok`,rejected:`tone-neutral`,waived:`tone-neutral`};function lv({value:e,onModule:t,t:n}){let r=e.counts.accepted+e.counts.acknowledged+e.counts.deferred,i=!e.adopted||e.decisions.length===0||r>0;return(0,H.jsxs)(`div`,{className:`architecture-map-view`,"data-refactor-view":!0,children:[(0,H.jsx)(`ul`,{className:`module-states`,"data-refactor-counts":!0,children:oe.map(t=>(0,H.jsxs)(`li`,{className:`operator-badge ${cv[t]}`,"data-refactor-status":t,children:[n(`architecture.refactor.status.${t}`),`: `,(0,H.jsx)(`strong`,{children:e.counts[t]})]},t))}),i&&(0,H.jsxs)(`div`,{className:`copy-value`,children:[(0,H.jsx)(`code`,{"data-refactor-command":`recommendations`,children:ov}),(0,H.jsx)(f,{label:n(`architecture.refactor.recommendationsCommand`),value:ov,t:n})]}),e.adopted?e.decisions.length===0?(0,H.jsx)(`p`,{className:`empty-inline`,"data-refactor-empty":`none`,children:n(`architecture.refactor.empty`)}):(0,H.jsx)(`ul`,{className:`module-domains`,"data-refactor-decisions":!0,children:e.decisions.map(e=>{let r=e.metrics?Object.entries(e.metrics):[];return(0,H.jsxs)(`li`,{className:`architecture-card`,"data-refactor-decision":e.recommendation_id,"data-status":e.status,children:[(0,H.jsxs)(`div`,{className:`module-states`,children:[(0,H.jsx)(`span`,{className:`operator-badge ${cv[e.status]}`,children:n(`architecture.refactor.status.${e.status}`)}),(0,H.jsx)(`code`,{children:e.kind??e.category}),(0,H.jsx)(`strong`,{children:e.subject}),(0,H.jsx)(`code`,{className:`mono-value`,children:e.recommendation_id})]}),e.affected_node_ids.length>0&&(0,H.jsx)(`div`,{className:`module-states`,"data-refactor-nodes":!0,children:e.affected_node_ids.map(e=>ie.test(e)?(0,H.jsx)(`button`,{type:`button`,className:`module-row__open`,onClick:()=>t(e),children:(0,H.jsx)(`code`,{children:e})},e):(0,H.jsx)(`code`,{children:e},e))}),r.length>0&&(0,H.jsx)(`p`,{className:`mono-value`,"data-refactor-metrics":!0,children:r.map(([e,t])=>`${e}=${t??`null`}`).join(` · `)}),(0,H.jsx)(`p`,{"data-refactor-reason":!0,children:e.reason}),(0,H.jsxs)(`p`,{className:`detail-quiet`,children:[(0,H.jsx)(`time`,{dateTime:e.decided_at,children:e.decided_at}),` · `,(0,H.jsx)(`code`,{children:e.head_sha.slice(0,7)})]}),sv.has(e.status)&&(0,H.jsxs)(`div`,{className:`copy-value`,children:[(0,H.jsx)(`code`,{"data-refactor-verify":e.recommendation_id,children:e.cli_verify_command}),(0,H.jsx)(f,{label:n(`architecture.refactor.verifyCommand`),value:e.cli_verify_command,t:n})]})]},e.recommendation_id)})}):(0,H.jsx)(`p`,{className:`empty-inline`,"data-refactor-empty":`unadopted`,children:n(`architecture.refactor.unadopted`)})]})}var uv=[`map`,`layers`,`sequence`,`topology`,`modules`,`history`,`refactor`],dv={map:`modules`,layers:`layers`,sequence:`sequence`,topology:`topology`};function fv({view:e,counts:t,onChange:n,t:r}){return(0,H.jsx)(`div`,{className:`architecture-tabs`,role:`tablist`,"aria-label":r(`architecture.views`),children:uv.map((i,a)=>(0,H.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`?uv.length-1:(a+(e.key===`ArrowRight`?1:uv.length-1))%uv.length;e.preventDefault(),n(uv[t]),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[t]?.focus()},children:[r(`architecture.view.${i}`),t[i]!==void 0&&(0,H.jsx)(`span`,{className:`architecture-tabs__count`,children:t[i]})]},i))})}function pv(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 mv({repositoryId:e,github:t,moduleId:n,onModule:r,onSource:i,refreshGeneration:a,readMap:o,readHistory:s=G_,t:c}){let[l,u]=(0,L.useState)(`map`),[d,f]=(0,L.useReducer)(pv,{repositoryId:e,commit:null,selections:{}});d.repositoryId!==e&&f({type:`shown`,repositoryId:e,commit:null});let p=d.repositoryId===e?d.selections:{},m=(0,L.useCallback)(e=>f({type:`select`,select:e}),[]),h=q_(e),g=n===null?null:`${h}/${n}`,_=K_(n===null&&l===`modules`?h:null,Pe,a),v=K_(n===null&&l===`refactor`?Y_(e):null,Le,a),y=K_(g,Fe,a),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(null),E=(0,L.useCallback)(t=>{x(n=>({repositoryId:e,value:{...n?.repositoryId===e?n.value:{},...t}}))},[e]),D=(0,L.useCallback)(t=>{C(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&&E({map:t.modules,sequence:t.flows})},[E,e]),O=(0,L.useCallback)(e=>{T(e),e!==null&&E({history:e.total})},[E]);(0,L.useEffect)(()=>{v.value!==null&&E({refactor:v.value.decisions.length})},[v.value,E]);let k=n===null?l===`modules`?_.value?.commit:l===`history`||l===`refactor`?void 0:S?.commit:y.value?.commit,A=n===null&&l!==`modules`&&l!==`history`&&l!==`refactor`?S:null,j=n===null&&l===`history`?w:null;return(0,L.useEffect)(()=>{i(j??(k===void 0?null:{commit:k,map:A===null?null:{collectedAt:A.collectedAt,headRef:A.headRef,archctxVersion:A.archctxVersion}}))},[j,k,A,i]),(0,L.useEffect)(()=>()=>i(null),[i]),(0,H.jsx)(`section`,{className:`architecture-workspace`,"aria-label":c(`nav.architecture`),children:n===null?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(fv,{view:l,counts:b?.repositoryId===e?b.value:{},onChange:u,t:c}),(0,H.jsx)(`div`,{id:`architecture-view`,className:`architecture-view`,role:`tabpanel`,"aria-labelledby":`architecture-tab-${l}`,children:l===`history`?(0,H.jsx)(Lm,{path:J_(e),github:t,read:s,refreshGeneration:a,selection:p.history??null,select:m,onSummary:O,t:c}):l===`refactor`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z_,{read:v,loading:`architecture.refactor.loading`,t:c}),v.value&&(0,H.jsx)(lv,{value:v.value,onModule:r,t:c})]}):l===`modules`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z_,{read:_,loading:`architecture.loading`,t:c}),_.value&&(0,H.jsx)(ev,{index:_.value,onModule:r,t:c})]}):(0,H.jsx)(D_,{repositoryId:e,view:dv[l],read:o,refreshGeneration:a,selections:p,select:m,onModule:r,onSummary:D,t:c})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>r(null),children:c(`architecture.back`)})}),(0,H.jsx)(Z_,{read:y,loading:`architecture.module.loading`,t:c}),y.value&&g&&(0,H.jsx)(av,{detail:y.value,base:g,generation:a,onModule:r,t:c})]})})}export{mv as ArchitectureWorkspace};
|
|
10
|
+
`),[r,i]=[b.get(t),b.get(n)],a=Ji([Li(r,x(i)),Li(i,x(r))],y.filter(e=>e!==r&&e!==i));return{...p(`relation:${t}->${n}`,t,n,`relation`,hh),points:a}}),C=[...m.routes,...S],w=n.flatMap(e=>{let n=b.get(gh(e)),r=yh(t.get(e).length);return t.get(e).map((e,t)=>({id:e.id,parent:n.id,kind:`box`,width:oh,height:sh,x:n.x+lh+t%r*208,y:n.y+uh+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:Xi(T,C,mh)}}}function xh(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,H.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 wh=(0,L.memo)(function({data:e}){return(0,H.jsxs)(`div`,{className:`architecture-modules__domain`,"data-domain":e.domain,children:[(0,H.jsx)(sm,{}),(0,H.jsx)(`b`,{children:e.domain})]})}),Th=[`changes`,`violations`,`pull_requests`,`tests`,`decisions`];function Eh(e){let t=Rp(e,`changes`).marks,n=Rp(e,`violations`).marks,r=Rp(e,`decisions`).marks,{pull_requests:i,tests:a}=e.layers,o=(i.state===`ok`?i.pull_requests:[]).map(t=>({number:t.number,marks:Rp(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 Dh(e,t,n,r={}){return e(n===1?`architecture.modules.hover.${t}One`:`architecture.modules.hover.${t}`,{count:n,...r})}function Oh(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?Dh(t,`changes`,s):null},{layer:`violations`,tone:`danger`,value:r>0?String(r):null,words:r>0?Dh(t,`violations`,r):null},{layer:`pull_requests`,tone:`info`,value:i.length>0?String(i.length):null,words:i.length>0?Dh(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?Dh(t,`decisions`,o):null}]}var kh={domain:wh,module:(0,L.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,H.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,H.jsxs)(`span`,{className:`architecture-modules__name`,children:[(0,H.jsx)(`strong`,{children:n.name}),n.status===`deprecated`&&(0,H.jsx)(`span`,{className:`architecture-modules__status`,children:l(`architecture.modules.deprecated`)}),o!==null&&(0,H.jsx)(Ch,{kind:`neighbour`,state:o,t:l}),s!==null&&(0,H.jsx)(Ch,{kind:`undeclared`,state:s,t:l})]}),(0,H.jsx)(`span`,{className:`architecture-modules__size mono-value`,children:r===null?``:`${Gm(r.lines)} · ${Gm(r.files)}`}),(0,H.jsx)(`span`,{className:`architecture-modules__slots`,children:a.map(e=>(0,H.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,L.memo)(function({data:e,selected:t}){return(0,H.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,H.jsx)(sm,{}),e.node.name,e.neighbour!==null&&(0,H.jsx)(Ch,{kind:`neighbour`,state:e.neighbour,t:e.t})]})})},Ah=(e,t)=>[`out`,`in`,`both`].map(n=>({key:`${e}-${n}`,swatch:(0,H.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 jh(e,t){return[...e.routes?[{key:`undeclared`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--undeclared`}),text:t(`architecture.layer.legend.undeclared`)}]:[],...e.selection?Ah(`neighbour`,t):[],...e.cards?Ah(`undeclared`,t):[]]}function Mh({entries:e,t}){return e.length===0?null:(0,H.jsx)(`dl`,{className:`architecture-modules__states`,"aria-label":t(`architecture.map.legend`),"data-narrow-legend":!0,children:e.map(e=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:e.swatch}),(0,H.jsx)(`dd`,{children:e.text})]},e.key))})}function Nh(e,t,n,r,i){return[...t.edges.length>0?[{key:`width`,swatch:(0,H.jsx)(`span`,{"aria-hidden":`true`,children:`→`}),text:i(`architecture.modules.legend.width`)}]:[],...jh(n,i),...t.externals.length>0?[{key:`external`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:i(`architecture.map.legend.external`)}]:[],...e.sizes.state===`ok`?[{key:`lines`,swatch:(0,H.jsx)(`span`,{className:`mono-value`,"aria-hidden":`true`,children:`1.2k · 4`}),text:i(`architecture.modules.legend.lines`)}]:[],{key:`slots`,swatch:(0,H.jsx)(`span`,{className:`architecture-modules__key mono-value`,children:Th.map(e=>(0,H.jsx)(`span`,{"data-active":e===r||void 0,children:i(`architecture.modules.slot.${e}`)},e))}),text:``}]}function Ph(e,t){let n=Ip(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 Fh(e,t,n){let r=Ip(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 Ih({selected:e,relations:t,names:n,t:r}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.modules.relations`,{count:t.length})}),t.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:r(`architecture.none`)}):(0,H.jsx)(`ul`,{"data-card-relations":!0,children:t.map(t=>(0,H.jsxs)(`li`,{"data-relation-id":t.id,"data-direction":t.direction,children:[(0,H.jsx)(`span`,{className:`mono-value`,children:r(`architecture.modules.direction.${t.direction}`)}),` `,n.get(t.other),t.holder!==t.other&&t.holder!==e&&(0,H.jsxs)(H.Fragment,{children:[` (`,n.get(t.holder),`)`]}),` · `,(0,H.jsx)(`code`,{children:t.kind}),t.imports!==null&&(0,H.jsxs)(`span`,{className:`mono-value`,children:[` · `,r(`architecture.map.imports`,{count:t.imports})]})]},t.id))})]})}function Lh({map:e,ids:t,t:n}){let{changes:r}=e.layers;if(r.state===`unavailable`)return(0,H.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`changes`,children:r.reason===`archctx_error`?n(`architecture.layer.changes.archctx_error`,{code:Ep(r)}):n(`architecture.layer.changes.${r.reason}`)});let i=r.commits.filter(e=>e.nodes.some(e=>t.has(e)));return i.length?(0,H.jsx)(`ul`,{"data-module-commits":!0,children:i.map(e=>(0,H.jsxs)(`li`,{"data-commit":e.sha,children:[(0,H.jsx)(`code`,{children:e.sha.slice(0,7)}),` `,e.subject]},e.sha))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.changes.none`)})}function Rh({map:e,pullRequest:t,ids:n,capability:r,t:i}){let{pull_requests:a}=e.layers;if(a.state===`unavailable`)return(0,H.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,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.inspector.none`)});let{impact:s}=o;if(s.state===`unavailable`)return(0,H.jsx)(`p`,{className:`detail-quiet`,"data-module-gap":`pull_request`,children:s.reason===`archctx_error`?i(`architecture.layer.pull_requests.pr.archctx_error`,{code:Ep(s)}):i(`architecture.layer.pull_requests.pr.${s.reason}`)});let c=new Map(e.nodes.map(e=>[e.id,e.name])),l=Ip(e),u=[],d=kp(s,n);d>0&&u.push({key:`files`,text:i(`architecture.modules.impact.files`,{files:Gp(i,d,`file`,s.truncated.paths)})});let f=[...n].flatMap(e=>Mp(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=lf(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,H.jsx)(`ul`,{"data-module-impact":o.number,children:u.map(e=>(0,H.jsx)(`li`,{children:e.text},e.key))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.modules.impact.none`,{number:o.number})})}function zh({map:e,capability:t,t:n}){let{tests:r}=e.layers;if(r.state===`unavailable`)return(0,H.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,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.modules.tests.none`)}):(0,H.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 Bh({map:e,pullRequest:t,node:n,relations:r,onModule:i,t:a}){let o=(0,L.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),s=(0,L.useMemo)(()=>{let t=Ip(e);return new Set(e.nodes.flatMap(e=>t.get(e.id)===n.id?[e.id]:[]))},[e,n.id]),c=Zp(e,n.id),l=$p(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,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`architecture-modules__heading`,children:[(0,H.jsx)(`span`,{className:`architecture-modules__eyebrow`,"data-module-domain":!0,children:n.domain}),(0,H.jsx)(`h3`,{children:n.name}),(0,H.jsxs)(`span`,{className:`architecture-map__id mono-value`,children:[n.id,e.sizes.state===`ok`&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`span`,{"data-node-size":!0,children:c===null?a(`architecture.map.noSize`):a(`architecture.map.sizeValue`,{lines:c.lines,files:c.files})})]})]})]}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.changes`)}),(0,H.jsx)(Lh,{map:e,ids:s,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.violations`)}),l.length?(0,H.jsx)(em,{facts:l,layer:`violations`,source:!0}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),(0,H.jsx)(`h4`,{children:t===null?a(`architecture.layer.pull_requests`):a(`architecture.modules.impact.title`,{number:t})}),(0,H.jsx)(Rh,{map:e,pullRequest:t,ids:s,capability:n.id,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.tests`)}),(0,H.jsx)(zh,{map:e,capability:n.id,t:a}),(0,H.jsx)(`h4`,{children:a(`architecture.layer.decisions`)}),d.length?(0,H.jsx)(`ul`,{"data-module-decisions":!0,children:d.map(e=>(0,H.jsxs)(`li`,{children:[e.status===null?e.title:a(`architecture.layer.node.decision`,{title:e.title,status:e.status}),` · `,(0,H.jsx)(`code`,{children:e.path})]},e.id))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:a(`architecture.inspector.none`)}),u.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:a(`architecture.modules.fix`)}),u.map(e=>(0,H.jsx)(Xp,{part:e,t:a},e))]}),(0,H.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>i(n.id),children:a(`architecture.map.open`)}),(0,H.jsx)(Ih,{selected:n.id,relations:r,names:o,t:a})]})}function Vh({map:e,layer:t,pullRequest:n,selectedId:r,onSelect:i,side:a,onModule:o,t:s}){let c=(0,L.useMemo)(()=>bh(e),[e]),l=(0,L.useMemo)(()=>Rp(e,t,n),[e,t,n]),{scene:u,cards:d}=(0,L.useMemo)(()=>xh(c,l.edges),[c,l]),f=(0,L.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e])),[e]),p=(0,L.useMemo)(()=>new Map(e.sizes.state===`ok`?e.sizes.nodes.map(e=>[e.id,{lines:e.lines,files:e.files}]):[]),[e]),m=(0,L.useMemo)(()=>Eh(e),[e]),h=(0,L.useMemo)(()=>new Map(c.edges.map(e=>[e.id,e.imports])),[c]),g=r===null?null:f.get(r)??null,_=(0,L.useMemo)(()=>g===null?[]:Ph(e,g.id),[e,g]),v=(0,L.useMemo)(()=>g===null?new Map:Fh(e,c,g.id),[e,c,g]),y=(0,L.useCallback)(e=>{if(e.parent===null&&e.kind===`frame`){let t=e.id.slice(gh(``).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:Oh(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`?gh(g.domain):g.id,S=(0,L.useCallback)(e=>{let t=e=>e.startsWith(gh(``))?e.slice(gh(``).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,H.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,H.jsx)(fm,{label:s(`architecture.map.label`),scene:u,nodeTypes:kh,view:y,selected:r,emphasis:x,routeLabel:S,onSelect:i,legend:Nh(e,c,b,t,s),t:s}),(0,H.jsx)(Mh,{entries:jh(b,s),t:s}),(0,H.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":s(`architecture.map.inspector`),"data-node-id":g?.id,children:[a,g===null?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.pick`)}),(0,H.jsx)(`p`,{className:`detail-quiet`,children:s(`architecture.map.counts`,{nodes:Gp(s,e.nodes.length,`node`),relations:Gp(s,e.relations.length,`relation`)})})]}):g.kind===`capability`?(0,H.jsx)(Bh,{map:e,pullRequest:n,node:g,relations:_,onModule:o,t:s}):(0,H.jsx)(im,{map:e,layer:t,pullRequest:n,nodeId:g.id,onModule:o,t:s})]})]})}function Hh(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 Uh=16,Wh=24,Gh=8,Kh=16,qh=196,Jh=44,Yh=24,Xh=12,Zh=52,Qh=4,$h=16,eg=28,tg=12,ng=28,rg=24;function ig(e){return e.kind===`process`?`process:${e.process}`:e.kind===`external`?`external`:`unknown:${e.reason}`}var ag=e=>`participant:${e}`,og=(e,t)=>`message:${e??``}:${t}`,sg=e=>e===0?`alt`:`else`,cg=(e,t)=>t===null?e.label:`${e.label} · ${t}`,lg=e=>Ti(e,`title`)+24;function ug(e,t,n,r){let i=[],a=new Map;for(let n of e.participants){let e=t(n.node),r=ig(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(qh,lg(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+Yh),l=Gh+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=Ti(cg(e,n.status(e)),`label`);t===r?u(t,rg+i+24):u(t<r?t:t-1,i+24)}for(let t of e.outcomes){let e=s.get(t.terminal.participant),n=lg(t.terminal.label)/2+Xh;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?Uh+l:f[e-1]+c[e-1];n!==void 0&&n.key!==t.key&&(i=Math.max(i,p.get(n.key).right+Kh+Gh+t.header/2)),f.push(i);let s=p.get(t.key)?.left??i-t.header/2-Gh;p.set(t.key,{left:s,right:Math.max(i+t.header/2+Gh,s+lg(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+=Zh;for(let[t,n]of e.outcomes.entries()){let e=x-Zh/2+tg;x=e+eg+Zh/2+$h/2;for(let e of n.steps)y.push({outcome:n.id,step:e,y:x}),x+=Zh;b.push({outcome:n,index:t,top:e,terminal:x}),x+=Zh}let S=x-Zh/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:Uh,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=ag(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:Jh,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-Uh-Wh-Jh,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)-qh/2,o=Math.max(...i)+qh/2,s=`${sg(t)} ${e.label}`;v({id:`fragment:${e.id}`,parent:null,x:a,y:n,width:Math.max(o-a,lg(s)),height:eg,kind:`fragment ${e.kind}`},{kind:`fragment`,outcome:e,index:t},s);let c=lg(e.terminal.label);v({id:`terminal:${e.id}`,parent:null,x:m(e.terminal.participant)-c/2,y:r-ng/2,width:c,height:ng,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=og(e,t.id),a=m(t.from),o=m(t.to),l=n.tone(e,t),u=n.status(t),d=cg(t,l===`danger`?u:null),f=a===o,p=o>a?.5:-.5,h=f?[[a+.5,r-8],[a+rg,r-8],[a+rg,r+8],[a+.5,r+8]]:[[a+p,r],[o-p,r]],g=f?[a+rg+Xh+Ti(d,`label`)/2,r]:[(a+(o>a?a+c[s.get(t.from)]:a-c[s.get(t.from)-1]))/2,r-Qh-$h/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(Fi(d,g,i)),T.set(i,{outcome:e,step:t,tone:l,status:u})}return{scene:{boxes:h,routes:C,labels:w,extent:Xi(h,C,Uh,w)},parts:g,messages:T,lines:e=>_.has(e.id)?[_.get(e.id)]:[]}}var dg=(e,t,n)=>`${e}\0${t??``}\0${n}`;function fg(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=>dg(e.flow,e.outcome,e.step)))}function pg(e){let{flows:t}=e.layers.violations;return t.state===`ok`?new Map(t.evidence.map(e=>[cf(e),e.status])):null}function mg(e,t,n,r,i,a){if(t.has(dg(r,i,a.id)))return`change`;let o=n?.get(cf(a.evidence));return e===`violations`&&o!==void 0&&o!==`proven`?`danger`:null}function hg(e,t,n,r){return new Set(e.flows.filter(e=>lf(e).some(({outcome:i,step:a})=>mg(t,n,r,e.id,i,a)!==null)).map(e=>e.id))}function gg(e,t,n,r){let i=e.flows.filter(e=>e.applicability===`required`),a=hg(e,t,n,r);return(i.find(e=>a.has(e.id))??i[0]??e.flows[0])?.id??null}var _g={box:(0,L.memo)(function({data:e}){return(0,H.jsx)(`div`,{className:`architecture-sequence__box`,"data-placement":e.placement.kind,"data-reason":e.reason??void 0,title:e.reason??void 0,children:(0,H.jsx)(`span`,{children:e.title})})}),fragment:(0,L.memo)(function({data:e}){return(0,H.jsxs)(`div`,{className:`architecture-sequence__fragment`,"data-kind":e.kind,title:e.label,children:[(0,H.jsx)(`span`,{className:`mono-value`,children:sg(e.index)}),` `,e.label]})}),header:(0,L.memo)(function({data:e,selected:t}){return(0,H.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,H.jsx)(`strong`,{className:`architecture-sequence__name`,children:e.name}),e.mark!==null&&(0,H.jsx)(`span`,{className:`architecture-sequence__header-mark`,children:(0,H.jsx)(Jp,{mark:e.mark})})]})}),lifeline:(0,L.memo)(function(){return(0,H.jsx)(`div`,{className:`architecture-sequence__lifeline`,children:(0,H.jsx)(sm,{})})}),terminal:(0,L.memo)(function({data:e}){return(0,H.jsx)(`div`,{className:`architecture-sequence__terminal`,"data-kind":e.kind,title:e.label,children:e.label})})};function vg(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 yg({evidence:e,t}){if(e===void 0)return(0,H.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,H.jsx)(`span`,{"data-path-withheld":!0,children:t(`architecture.sequence.evidence.withheld`)}):(0,H.jsx)(`code`,{children:e});return(0,H.jsxs)(`ul`,{className:`architecture-sequence__code`,"data-step-evidence":!0,children:[(0,H.jsxs)(`li`,{children:[n(e.source_path),` `,(0,H.jsx)(`code`,{children:e.source_symbol})]}),(0,H.jsxs)(`li`,{children:[`→ `,n(e.sink_path),` `,(0,H.jsx)(`code`,{children:e.sink_symbol})]})]})}function bg({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=cf(r.evidence),u=e.flow_evidence.find(e=>cf(e)===l),{flows:d}=e.layers.violations,f=d.state===`ok`?d.evidence.find(e=>cf(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=Zp(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,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:i(`architecture.sequence.selected`)}),(0,H.jsxs)(`h3`,{"data-step-title":!0,children:[a.get(s),` → `,a.get(c)]}),(0,H.jsx)(`p`,{children:r.label}),(0,H.jsxs)(`code`,{className:`architecture-map__id`,children:[t.id,` · `,n??i(`architecture.sequence.main`),` · `,r.id]}),(0,H.jsx)(`dl`,{className:`detail-list`,children:[s,c].map((e,t)=>(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:i(t===0?`architecture.sequence.from`:`architecture.sequence.to`)}),(0,H.jsxs)(`dd`,{children:[a.get(e),x(e)!==null&&(0,H.jsxs)(`span`,{className:`detail-quiet`,"data-node-size":!0,children:[` · `,x(e)]})]})]},t))}),(0,H.jsx)(`h4`,{children:i(`architecture.sequence.evidence`)}),(0,H.jsx)(yg,{evidence:u,t:i}),(0,H.jsx)(`h4`,{children:i(`architecture.sequence.proof`)}),d.state===`ok`?(0,H.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,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`proof`,"data-reason":d.reason,"data-code":d.reason===`archctx_error`?Ep(d):void 0,children:d.reason===`archctx_error`?i(`architecture.layer.reason.archctx_error`,{code:Ep(d)}):i(`architecture.layer.reason.${d.reason}`)}),f!==null&&f.call_sites.length>0&&(0,H.jsx)(`ul`,{className:`architecture-sequence__code`,"data-call-sites":!0,"aria-label":i(`architecture.sequence.callSites`),children:f.call_sites.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e.line===null?e.path:`${e.path}:${e.line}`})},`${e.path}:${e.line??``}`))}),p!==`proven`&&(0,H.jsx)(Xp,{part:`flows`,t:i}),(0,H.jsx)(`h4`,{children:i(`architecture.inspector.pullRequests`)}),y&&(0,H.jsx)(`p`,{"data-step-today":!0,children:i(`architecture.sequence.today`)}),b.length?(0,H.jsx)(`ul`,{"data-related-prs":!0,children:b.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),` `,e.title]},e.number))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:_.state===`unavailable`?i(`architecture.layer.pull_requests.${_.reason}`):i(`architecture.inspector.none`)}),(0,H.jsx)(`h4`,{children:i(`architecture.sequence.relations`,{count:h.length})}),h.length?(0,H.jsx)(`ul`,{children:h.map(e=>{let t=m.find(t=>t.source===e.source&&t.target===e.target)?.imports;return(0,H.jsxs)(`li`,{"data-relation-id":e.id,children:[(0,H.jsx)(`code`,{children:e.kind}),` `,a.get(e.source),` → `,a.get(e.target),t!==void 0&&(0,H.jsxs)(`span`,{className:`mono-value`,children:[` · `,i(`architecture.map.imports`,{count:t})]})]},e.id)})}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.none`)})]})}function xg(e){return[{key:`process`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--box`}),text:e(`architecture.sequence.legend.process`)},{key:`external`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--external`}),text:e(`architecture.sequence.legend.external`)},{key:`success`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--success`}),text:e(`architecture.sequence.legend.success`)},{key:`error`,swatch:(0,H.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=fg(e,n,r),o=pg(e),s=new Map(e.nodes.map(e=>[e.id,e.name]));return ug(t,Hh(e),{tone:(e,r)=>mg(n,a,o,t.id,e,r),status:e=>{let t=o?.get(cf(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`):vg(e,t,n)}function wg({map:e,layout:t,layer:n,pullRequest:r,selected:i,onSelect:a,t:o}){let s=(0,L.useMemo)(()=>zp(e,n,r),[e,n,r]),c=(0,L.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:`${sg(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,L.useCallback)(e=>t.scene.labels.find(t=>t.route===e.id).text,[t]),u=(0,L.useCallback)(e=>e.id,[]),d=i!==null&&t.parts.get(i)?.kind===`participant`?`lifeline:${i.slice(12)}`:null;return(0,H.jsx)(fm,{label:o(`architecture.sequence.label`),scene:t.scene,nodeTypes:_g,view:c,selected:i,emphasis:d,routeLabel:l,routeSelection:u,onSelect:a,legend:xg(o),t:o})}function Tg({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:Hh(e)(f)};return(0,H.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,H.jsx)(bg,{map:e,flow:l,outcome:u.outcome,step:u.step,t:c}):p===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.sequence.pick`)}):(0,H.jsx)(im,{map:e,layer:r,pullRequest:i,nodeId:p.node,onModule:s,t:c,children:(0,H.jsx)(`p`,{"data-runtime":p.place.kind,children:c(`architecture.sequence.runsIn`,{place:vg(p.place,new Map(e.nodes.map(e=>[e.id,e.name])),c)})})}))]})}var Eg={violations:`imports_on_module_map`,tests:`tests_by_capability`,decisions:`decisions_by_node`};function Dg(e,t,n,r,i){let a=i!==null&&e.flows.some(e=>e.id===i)?i:gg(e,t,n,r);return e.flows.find(e=>e.id===a)}function Og({map:e,layer:t,pullRequest:n,flowId:r,t:i}){let a=(0,L.useMemo)(()=>fg(e,t,n),[e,t,n]),o=(0,L.useMemo)(()=>pg(e),[e]),s=(0,L.useMemo)(()=>{let t=new Set(e.flow_evidence.map(e=>cf(e))),n=e.flows.flatMap(e=>lf(e));return{flows:e.flows.length,steps:n.length,evidenced:n.filter(({step:e})=>t.has(cf(e.evidence))).length}},[e]);if(e.flows.length===0)return null;let c=Dg(e,t,a,o,r);return(0,H.jsxs)(`div`,{className:`architecture-lens__tools`,children:[(0,H.jsx)(`span`,{"data-sequence-summary":!0,children:i(`architecture.sequence.summary`,s)}),(0,H.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);lm(`${c.id}.svg`,r.scene,r.lines)},children:i(`architecture.sequence.export`)})]})}function kg({map:e,flowId:t,lit:n,onFlow:r,t:i}){return(0,H.jsxs)(`div`,{className:`architecture-sequence__flows`,role:`group`,"aria-labelledby":`architecture-sequence-flows`,children:[(0,H.jsx)(`h4`,{id:`architecture-sequence-flows`,children:i(`architecture.sequence.flows`)}),(0,H.jsx)(`div`,{className:`architecture-sequence__flow-list`,children:e.flows.map((e,a)=>(0,H.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,H.jsx)(`span`,{className:`mono-value`,children:a+1}),(0,H.jsx)(`span`,{className:`architecture-sequence__flow-name`,children:e.name}),n.has(e.id)&&(0,H.jsx)(`span`,{className:`architecture-sequence__lit`,"aria-label":i(`architecture.sequence.lit`)})]},e.id))})]})}function Ag({map:e,layer:t,pullRequest:n,flowId:r,onFlow:i,selection:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,L.useMemo)(()=>fg(e,t,n),[e,t,n]),d=(0,L.useMemo)(()=>pg(e),[e]),f=(0,L.useMemo)(()=>hg(e,t,u,d),[e,t,u,d]),p=e.flows.length===0?null:Dg(e,t,u,d,r),m=(0,L.useMemo)(()=>p?.applicability===`required`?Sg(e,p,t,n,l):null,[e,p,t,n,l]),h=p?.id??``,g=(0,L.useCallback)(e=>o(h,e),[h,o]);if(p===null)return(0,H.jsxs)(`div`,{className:`architecture-map`,children:[(0,H.jsx)(qp,{part:`sequence.flows`,reason:`flows_undeclared`,children:l(`architecture.sequence.none`)}),(0,H.jsx)(`aside`,{className:`architecture-map__inspector`,"aria-label":l(`architecture.sequence.inspector`),children:s})]});let _=Eg[t],v=(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(kg,{map:e,flowId:p.id,lit:f,onFlow:i,t:l}),s,_&&(0,H.jsx)(qp,{part:`sequence.${t}`,reason:_,children:l(`architecture.sequence.note.${_}`)})]}),y=a?.scope===p.id?a.id:null;return(0,H.jsx)(`div`,{className:`architecture-sequence`,children:(0,H.jsxs)(`div`,{className:`architecture-map`,"data-view":`sequence`,"data-flow":p.id,"data-layer":t,children:[p.applicability===`not-applicable`?(0,H.jsx)(qp,{part:`sequence.not_applicable`,reason:`flow_not_applicable`,children:l(`architecture.flow.notApplicable`,{rationale:p.rationale})}):(0,H.jsx)(wg,{map:e,layout:m,layer:t,pullRequest:n,selected:y,onSelect:g,t:l},p.id),(0,H.jsx)(Tg,{map:e,flow:p,layout:m,layer:t,pullRequest:n,selected:y,lead:v,onModule:c,t:l})]})})}var jg=[`process`,`namespace`,`mount`],Mg=new Set([`namespace`,`process`,`mount`,`external-system`]),Ng=220,Pg=72,Fg=32,Ig=16,Lg=12,Rg=72,zg=320,Bg=24,Vg=1.5,Hg=new Set([`runs-in`,`deployed-on`,`mounts`]),Ug=(e,t)=>`${e}/${t}`,Wg=(e,t)=>e(t.source)&&e(t.target);function Gg(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`?Xg(e,t,o,i):n===`namespace`?t_(e,o,i):n_(e,o)}function Kg(e){let t=Hh(e),n=[`namespace`,`process`,`mount`],r=n.map(n=>Gg(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 qg(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 Jg(e,t,n,r,i){return{id:e,source:t,target:n,kind:r,dashed:i,relations:[],protocols:[]}}function Yg(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 Xg(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`&&Wg(n,t)&&i.get(t.target)?.kind===`process`&&!Mg.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(Hg.has(t.kind)||!Wg(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=la.has(t.kind),s=o(t.source)&&o(t.target)?t.kind:a?`io`:`code`,d=`${e}\n${r}\n${s}`;l.set(d,Yg(l.get(d)??Jg(`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=Zi({nodes:a.map(e=>({id:e.id,width:Ng,height:d(e),kind:Zg(e,null)})),edges:[...l.values()].map(e=>({...Qg(e),weight:e.relations.length})),nodesep:32,ranksep:72,margin:Bg},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:$g(p,f.boxes,f.routes,[...l.values()])}}var Zg=(e,t)=>t??(e.kind===`namespace`?`frame`:e.kind===`external-system`?`external`:`box`),Qg=e=>({id:e.id,source:e.source,target:e.target,arrows:{start:!1,end:!0},kind:e.kind,dashed:e.dashed,width:Vg});function $g(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:Ug(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=>Fi(e.protocols.join(` · `),Ii(o.get(e.id)),e.id)),extent:Xi(a,n,Bg)}}var e_=(e,t)=>e.mount.order-t.mount.order;function t_(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`?qg(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`&&Wg(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(Hg.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,Yg(u.get(e)??Jg(`topology:${e}`,t.source,t.target,t.kind,la.has(t.kind)),t))}let d=e=>[...a.filter(t=>t.kind===`mount`&&s.get(t.id)===e).sort(e_),...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:Ng,height:Pg,kind:Zg(e,i.tone)};return f.push(i),p.push(a),a}let i=f.length,a=d(e.id),o=n+Fg+Ig,l=Ng;for(let e of a){let n=m(e,t+Ig,o);o=n.y+n.height+Lg,l=Math.max(l,n.width)}let u=a.length===0?74:o-Lg+Ig-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=Zi({nodes:h.map(e=>({id:e.id,width:e.width,height:e.height,kind:e.kind})),edges:_.map(e=>({...Qg(e),source:g(e.source),target:g(e.target),weight:e.relations.length})),nodesep:Rg,ranksep:72,margin:Bg},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?[Li(t,x(r)),Li(r,x(t))]:[...i.points];i!==void 0&&i.source!==e.source&&a.unshift(Li(t,a[0])),i!==void 0&&i.target!==e.target&&a.push(Li(r,a[a.length-1]));let o=new Set([...C(e.source),...C(e.target)]);return{...Qg(e),points:n?Ji(a,[...b.values()].filter(e=>!o.has(e.id))):a}});return{base:`namespace`,boxes:f,edges:[...u.values()],unplaced:[],scene:$g(f,[...b.values()],w,[...u.values()])}}function n_(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`&&Wg(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(e_),group:!1,tone:null}));return{base:`mount`,boxes:i,edges:[],unplaced:[],scene:$g(i,i.map((e,t)=>({id:e.node.id,parent:null,x:Bg+t*352,y:Bg,width:zg,height:44+e.members.length*26+8,kind:Zg(e.node,null)})),[],[])}}var r_=e=>e.status===`deprecated`||void 0,i_={box:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.node.name}),(0,H.jsx)(Jp,{mark:e.mark})]}),(0,H.jsx)(`span`,{className:`architecture-map__meta`,children:e.detail})]})]})}),namespace:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`div`,{className:`architecture-map__group-title`,children:[(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.node.name}),(0,H.jsx)(Jp,{mark:e.mark})]}),(0,H.jsx)(`span`,{className:`architecture-map__meta mono-value`,children:e.detail})]}),e.empty!==null&&(0,H.jsx)(`p`,{className:`architecture-topology__empty`,"data-namespace-empty":!0,children:e.empty})]})}),mount:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:[(0,H.jsx)(sm,{}),(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.node.name}),(0,H.jsx)(Jp,{mark:e.mark})]}),(0,H.jsx)(`span`,{className:`architecture-topology__summary`,title:e.node.summary,children:e.node.summary})]})}),member:(0,L.memo)(function({data:e,selected:t}){return(0,H.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":r_(e.node),children:(0,H.jsxs)(`span`,{className:`architecture-map__title`,children:[(0,H.jsx)(`strong`,{children:e.detail}),(0,H.jsx)(Jp,{mark:e.mark})]})})})},a_=(e,t)=>e??t(`architecture.topology.masked`);function o_(e,t){let{order:n,source:r,target:i,mode:a}=e.mount;return t(`architecture.topology.mountRow`,{order:n,source:a_(r,t),target:a_(i,t),mode:a})}function s_(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 c_=(e,t)=>e.kind===`mount`?o_(e,t):e.name,l_=e=>new Map(e.boxes.flatMap(e=>[[e.node.id,{box:e,member:null}],...e.members.map(t=>[Ug(e.node.id,t.id),{box:e,member:t}])]));function u_(e,t){let n=l_(e);return e=>{let{box:r,member:i}=n.get(e.id);return i===null?[r.node.name,s_(r,t)]:[c_(i,t)]}}function d_(e,t){return e===`process`?[{key:`code`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch`}),text:t(`architecture.map.legend.code`)},{key:`runtime`,swatch:(0,H.jsx)(`span`,{className:`architecture-map__swatch architecture-map__swatch--dashed`}),text:t(`architecture.topology.legend.runtime`)},{key:`external`,swatch:(0,H.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,H.jsx)(`span`,{className:`architecture-topology__swatch`,"data-mount-tone":e}),text:t(`architecture.topology.legend.${e}`)}))}var f_=(e,t,n)=>Gg(e,Hh(e),t,n);function p_({map:e,base:t,onBase:n,legacy:r,onLegacy:i,t:a}){let o=(0,L.useMemo)(()=>f_(e,t,!0),[e,t]),s=o.boxes.flatMap(e=>[e.node,...e.members]).filter(e=>e.status===`deprecated`).length;return(0,H.jsxs)(`span`,{className:`architecture-lens__tools`,children:[(0,H.jsx)(`span`,{className:`architecture-topology__bases`,role:`group`,"aria-label":a(`architecture.topology.base`),children:jg.map(e=>(0,H.jsx)(`button`,{type:`button`,"data-topology-base":e,"aria-pressed":e===t,onClick:()=>n(e),children:a(`architecture.topology.base.${e}`)},e))}),(0,H.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,H.jsx)(`span`,{className:`architecture-topology__switch`,"aria-hidden":`true`}),a(`architecture.topology.legacy`),(0,H.jsx)(`span`,{className:`mono-value`,children:s})]}),(0,H.jsx)(`button`,{type:`button`,className:`architecture-lens__export`,"data-topology-export":!0,disabled:o.boxes.length===0,onClick:()=>{let n=f_(e,t,r);lm(`topology-${t}-${e.commit.slice(0,7)}.svg`,n.scene,u_(n,a))},children:a(`architecture.topology.export`)})]})}function m_({map:e,nodeId:t,names:n,t:r}){let i=e.relations.filter(e=>e.kind===`writes`&&e.target===t);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:r(`architecture.topology.writers`)}),i.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,"data-writers":`none`,children:r(`architecture.topology.noWriter`)}):(0,H.jsx)(`ul`,{"data-writers":!0,children:i.map(e=>(0,H.jsx)(`li`,{children:n.get(e.source)},e.id))})]})}function h_({map:e,layout:t,layer:n,pullRequest:r,selectedId:i,onSelect:a,side:o,onModule:s,t:c}){let l=(0,L.useMemo)(()=>Hh(e),[e]),u=(0,L.useMemo)(()=>zp(e,n,r),[e,n,r]),d=(0,L.useMemo)(()=>new Map(e.nodes.map(e=>[e.id,e.name])),[e]),f=(0,L.useMemo)(()=>new Map(t.boxes.map(e=>[e.node.id,e])),[t]),p=(0,L.useMemo)(()=>l_(t),[t]),m=(0,L.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:qg(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,L.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:s_(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:c_(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||Mg.has(g.kind)?null:l(g.id),y=g?.kind===`process`?qg(e,g.id):null,b=g?.kind===`mount`?e.relations.find(e=>e.kind===`mounts`&&e.target===g.id)?.source??null:null;return(0,H.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,H.jsx)(fm,{label:c(`architecture.topology.label`),scene:t.scene,nodeTypes:i_,view:h,selected:i,onSelect:a,legend:d_(t.base,c),t:c}),(0,H.jsxs)(`aside`,{className:`architecture-map__inspector`,"aria-label":c(`architecture.map.inspector`),"data-node-id":i??void 0,children:[o,g===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:c(`architecture.map.pick`)}):(0,H.jsxs)(im,{map:e,layer:n,pullRequest:r,nodeId:g.id,onModule:s,t:c,children:[y!==null&&(0,H.jsx)(`p`,{"data-runs-in":y,children:c(`architecture.topology.in`,{name:d.get(y)})}),v?.kind===`process`&&(0,H.jsx)(`p`,{"data-runtime":`process`,children:c(`architecture.sequence.runsIn`,{place:d.get(v.process)})}),g.kind===`namespace`&&(0,H.jsx)(`dl`,{className:`detail-list`,children:(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.type`)}),(0,H.jsx)(`dd`,{"data-namespace-type":!0,children:g.namespace.type})]})}),g.kind===`mount`&&(0,H.jsxs)(`dl`,{className:`detail-list`,"data-mount-fields":!0,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.order`)}),(0,H.jsx)(`dd`,{className:`mono-value`,children:g.mount.order})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.path`)}),(0,H.jsxs)(`dd`,{className:`mono-value`,children:[a_(g.mount.source,c),` → `,a_(g.mount.target,c)]})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.mode`)}),(0,H.jsx)(`dd`,{className:`mono-value`,children:g.mount.mode})]}),b!==null&&(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:c(`architecture.topology.mounter`)}),(0,H.jsx)(`dd`,{children:d.get(b)})]})]}),(g.kind===`namespace`||g.kind===`mount`)&&(0,H.jsx)(m_,{map:e,nodeId:g.id,names:d,t:c}),g.kind===`process`&&_!==null&&_.members.length>0&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`h4`,{children:c(`architecture.topology.deployed`,{count:_.members.length})}),(0,H.jsx)(`ul`,{"data-deployed":!0,children:_.members.map(t=>{let n=Zp(e,t.id);return(0,H.jsxs)(`li`,{children:[t.name,n&&(0,H.jsxs)(`span`,{className:`detail-quiet`,children:[` · `,c(`architecture.map.sizeValue`,{lines:n.lines,files:n.files})]})]},t.id)})})]})]})]})]})}var g_={process:{part:`topology.processes`,reason:`process_undeclared`},namespace:{part:`topology.namespaces`,reason:`namespace_undeclared`},mount:{part:`topology.mounts`,reason:`mount_undeclared`}};function __({map:e,layer:t,pullRequest:n,base:r,legacy:i,selectedId:a,onSelect:o,side:s,onModule:c,t:l}){let u=(0,L.useMemo)(()=>Hh(e),[e]),d=(0,L.useMemo)(()=>Gg(e,u,r,i),[e,u,r,i]),f=(0,L.useMemo)(()=>zp(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:{...g_[r],text:l(`architecture.topology.none.${r}`)}:{part:`topology.empty`,reason:`topology_undeclared`,text:l(`architecture.topology.none`)};if(p!==null)return(0,H.jsxs)(`div`,{className:`architecture-map`,"data-view":`topology`,"data-base":r,children:[(0,H.jsx)(qp,{part:p.part,reason:p.reason,children:p.text}),(0,H.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,H.jsxs)(`div`,{className:`architecture-topology`,children:[t===`violations`&&(0,H.jsx)(qp,{part:`topology.violations`,reason:`imports_on_module_map`,children:l(`architecture.sequence.note.imports_on_module_map`)}),_.length>0&&(0,H.jsx)(qp,{part:`topology.unplaced_marks`,reason:`deployment_undeclared`,children:l(`architecture.topology.hidden`,{count:_.length})}),d.unplaced.length>0&&(0,H.jsx)(qp,{part:`topology.unplaced`,reason:`deployment_undeclared`,children:(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:l(`architecture.topology.unplaced`,{count:d.unplaced.length})}),(0,H.jsx)(`ul`,{children:d.unplaced.map(e=>{let t=h.get(e);return(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:t.kind}),` `,m.get(t.source),` → `,m.get(t.target)]},e)})})]})}),(0,H.jsx)(h_,{map:e,layout:d,layer:t,pullRequest:n,selectedId:a,onSelect:o,side:s,onModule:c,t:l},`${e.commit}:${r}:${i}`)]})}async function v_(e,t){let n=await u(`/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 Sp(r)??{state:`unavailable`,reason:`unreachable`};try{return{state:`ok`,map:xp(r)}}catch{return{state:`unavailable`,reason:`architecture_map_invalid`}}}function y_(e,t,n){let[r,i]=(0,L.useState)(null),a=(0,L.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 o(a,JSON.stringify([t,n])),r?.repositoryId===t?r.read:null}function b_(e,t){return t===`violations`?Object.values(e.layers.violations).some(e=>e.state===`ok`):e.layers[t].state===`ok`}function x_(e,t,n,r){if(!b_(e,t))return null;let{changes:i,pull_requests:a,tests:o,decisions:s}=e.layers,c=t=>[...Rp(e,t,n).marks.values()].filter(e=>e.tone!==`muted`).length;if(t===`changes`)return i.state===`ok`?r(`architecture.layer.count.changes`,{modules:Gp(r,c(`changes`),`module`,i.truncated.nodes),commits:Gp(r,i.commits.length,`commit`)}):null;if(t===`violations`)return String(Op(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:Gp(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:Gp(r,s.items.length,`decision`)}function S_({map:e,layer:t,pullRequest:n,onLayer:r,t:i}){return(0,H.jsx)(`div`,{className:`architecture-layers`,role:`group`,"aria-labelledby":`architecture-layers-label`,children:Cp.map(a=>{let o=x_(e,a,n,i);return(0,H.jsxs)(`button`,{type:`button`,"aria-pressed":t===a,"data-layer":a,"data-state":b_(e,a)?`ok`:`unavailable`,onClick:()=>r(a),children:[i(`architecture.layer.${a}`),o!==null&&(0,H.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=Np(t.truncated);return(0,H.jsxs)(H.Fragment,{children:[n&&(i.status===`known`?(0,H.jsx)(`p`,{"data-flow-steps":e,children:r(`architecture.layer.flow_steps.known`,{count:i.items.length})}):(0,H.jsx)(Kp,{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,H.jsx)(`ul`,{"data-flow-step-list":e,children:i.items.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.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,H.jsx)(qp,{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 w_({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,H.jsx)(Kp,{part:`changes`,reason:o.reason,code:Ep(o),children:a(`architecture.layer.changes.archctx_error`,{code:Ep(o)})}):(0,H.jsx)(Kp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`changes`,children:[(0,H.jsxs)(`p`,{children:[a(`architecture.layer.changes.summary`,{commits:Gp(a,o.commits.length,`commit`),files:Gp(a,o.paths.length,`file`,o.truncated.paths),unowned:`${o.truncated.paths?`≥`:``}${o.unowned_paths.length}`}),` `,(0,H.jsx)(`time`,{dateTime:o.since,children:new Date(o.since).toLocaleString()}),` · `,(0,H.jsx)(`code`,{children:o.base.slice(0,12)})]}),(0,H.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,H.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,H.jsx)(Kp,{part:`violations.${e}`,reason:t.reason,code:Ep(t),children:o(e,a(`architecture.layer.reason.archctx_error`,{code:Ep(t)}))}):(0,H.jsx)(Kp,{part:`violations.${e}`,reason:t.reason,children:o(e,a(`architecture.layer.reason.${t.reason}`))}),l=i.state===`ok`?(0,H.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,H.jsx)(qp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`violations`,children:[e.state===`ok`?(0,H.jsx)(`p`,{children:a(`architecture.layer.violations.debt`,{count:e.items.length})}):c(`debt`,e),u.length>0&&(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:a(`architecture.layer.unowned`,{count:u.length})}),(0,H.jsx)(`ul`,{children:u.flatMap(e=>e.paths.map(t=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:t}),` · `,a(`architecture.layer.debt.${e.kind}`)]},`${e.kind}:${t}`)))})]}),t.state===`ok`?(0,H.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,H.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,H.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,H.jsx)(Kp,{part:`tests`,reason:l.reason,children:a(`architecture.layer.tests.${l.reason}`)});let t=e.nodes.filter(e=>e.kind===`capability`).length;return(0,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`tests`,children:[(0,H.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,H.jsx)(`time`,{dateTime:l.run.created_at,children:new Date(l.run.created_at).toLocaleString()}),` · `,(0,H.jsx)(`code`,{children:l.run.head_sha.slice(0,12)})]}),l.results!==`ok`&&(0,H.jsx)(Kp,{part:`results`,reason:l.results,children:a(`architecture.layer.tests.results.${l.results}`)})]})}if(n===`pull_requests`){if(c.state===`unavailable`)return(0,H.jsx)(Kp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`pull_requests`,children:[(0,H.jsxs)(`p`,{children:[a(`architecture.layer.pull_requests.summary`,{count:c.pull_requests.length}),` `,(0,H.jsx)(`time`,{dateTime:c.observed_at,children:new Date(c.observed_at).toLocaleString()})]}),c.pull_requests.length>0&&(0,H.jsxs)(`label`,{className:`architecture-layer-summary__pick`,children:[(0,H.jsx)(`span`,{children:a(`architecture.layer.pull_requests.pick`)}),(0,H.jsxs)(`select`,{value:e?.number??``,onChange:e=>i(Number(e.target.value)),children:[e===null&&(0,H.jsx)(`option`,{value:``,disabled:!0,children:a(`architecture.layer.pull_requests.none`)}),c.pull_requests.map(e=>(0,H.jsxs)(`option`,{value:e.number,children:[`#`,e.number,` `,e.title]},e.number))]})]}),e&&(0,H.jsxs)(`p`,{"data-pull-request":e.number,children:[(0,H.jsxs)(`a`,{href:e.url,target:`_blank`,rel:`noreferrer`,children:[`#`,e.number]}),e.head_sha!==null&&(0,H.jsxs)(H.Fragment,{children:[` · `,(0,H.jsx)(`code`,{children:e.head_sha.slice(0,12)})]}),e.impact.state===`ok`&&(0,H.jsxs)(H.Fragment,{children:[` · `,a(`architecture.layer.pull_requests.impact`,{files:Gp(a,e.impact.paths.length,`file`,e.impact.truncated.paths),nodes:Gp(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,H.jsx)(C_,{part:`pull_request`,impact:e.impact,flowSteps:t===`sequence`,t:a}),e?.impact.state===`unavailable`&&(e.impact.reason===`archctx_error`?(0,H.jsx)(Kp,{part:`pull_request`,reason:e.impact.reason,code:Ep(e.impact),children:a(`architecture.layer.pull_requests.pr.archctx_error`,{code:Ep(e.impact)})}):(0,H.jsx)(Kp,{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,H.jsxs)(`div`,{className:`architecture-layer-summary`,"data-layer-summary":`decisions`,children:[(0,H.jsx)(`p`,{children:a(`architecture.layer.decisions.summary`,{count:Gp(a,u.items.length,`decision`),applied:u.items.length-d.length})}),d.length>0&&(0,H.jsxs)(`details`,{children:[(0,H.jsx)(`summary`,{children:a(`architecture.layer.decisions.unapplied`,{count:d.length})}),(0,H.jsx)(`ul`,{children:d.map(e=>(0,H.jsxs)(`li`,{children:[e.title,` · `,(0,H.jsx)(`code`,{children:e.path})]},e.id))})]})]})}function T_({read:e,kept:t,t:n}){let r=e.reason===`archctx_error`?Ep(e):void 0,i=e.reason===`architecture_map_pending`;return(0,H.jsxs)(`p`,{className:i?void 0:`architecture-notice`,role:i?`status`:`alert`,"data-error-code":e.reason,"data-code":r,children:[t&&(0,H.jsx)(`span`,{className:`block`,children:n(`architecture.map.kept`)}),(0,H.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}`,r===void 0?void 0:{code:r})}),(0,H.jsx)(`span`,{className:`block`,children:n(`architecture.map.unavailable.${e.reason}.next`)})]})}function E_({map:e,t}){return(0,H.jsxs)(H.Fragment,{children:[e.sizes.state===`unavailable`&&(0,H.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,H.jsx)(`p`,{className:`architecture-map__gap`,"data-gap":`dependencies`,"data-reason":e.dependencies.reason,children:t(`architecture.map.dependencies.${e.dependencies.reason}`)})]})}function D_({repositoryId:e,view:t=`modules`,read:n=v_,refreshGeneration:r,selections:i,select:a,onModule:o,onSummary:s,t:c}){let l=y_(n,e,r),[u,d]=(0,L.useState)(`changes`),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(null),[v,y]=(0,L.useState)(!0),b=(0,L.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:Ap(x),w=(0,L.useMemo)(()=>x===null||t!==`topology`?`namespace`:Kg(x),[x,t]),T=g??w,E=`${T}:${v}`,D=i.topology?.scope===E?i.topology.id:null,O=(0,L.useCallback)(e=>{_(e),a({view:`topology`,scope:``,id:null})},[a]),k=(0,L.useCallback)(e=>{y(e),a({view:`topology`,scope:``,id:null})},[a]),A=(0,L.useCallback)(e=>a({view:`topology`,scope:E,id:e}),[E,a]),j=(0,L.useCallback)(e=>a({view:`modules`,scope:``,id:e}),[a]),M=(0,L.useCallback)(e=>a({view:`layers`,scope:``,id:e}),[a]),N=(0,L.useCallback)((e,t)=>a({view:`sequence`,scope:e,id:t}),[a]),P=(0,L.useCallback)(e=>{h(e),a({view:`sequence`,scope:``,id:null})},[a]);(0,L.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,L.useEffect)(()=>()=>s(null),[s]);let F=x&&(0,H.jsxs)(`div`,{className:`architecture-map__side`,"data-map-side":!0,children:[(0,H.jsx)(E_,{map:x,t:c}),(0,H.jsx)(w_,{map:x,view:t,layer:u,pullRequest:C,onPullRequest:p,t:c})]});return(0,H.jsxs)(`div`,{className:`architecture-map-view`,children:[l===null&&(0,H.jsx)(`p`,{role:`status`,children:c(`architecture.map.loading`)}),l?.state===`unavailable`&&(0,H.jsx)(T_,{read:l,kept:x!==null,t:c}),x&&t===`layers`&&(0,H.jsx)(ah,{map:x,selectedId:i.layers?.id??null,onSelect:M,t:c},`${e}:${x.commit}`),x&&t!==`layers`&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`architecture-lens`,children:[(0,H.jsx)(`span`,{id:`architecture-layers-label`,className:`architecture-lens__label`,children:c(`architecture.layers`)}),(0,H.jsx)(S_,{map:x,layer:u,pullRequest:C,onLayer:d,t:c}),t===`sequence`?(0,H.jsx)(Og,{map:x,layer:u,pullRequest:C,flowId:m,t:c}):t===`topology`?(0,H.jsx)(p_,{map:x,base:T,onBase:O,legacy:v,onLegacy:k,t:c}):(0,H.jsx)(`span`,{className:`architecture-lens__hint`,children:c(`architecture.lens.hint`)})]}),t===`modules`&&(0,H.jsx)(Vh,{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,H.jsx)(Ag,{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,H.jsx)(__,{map:x,layer:u,pullRequest:C,base:T,legacy:v,selectedId:D,onSelect:A,side:F,onModule:o,t:c},`${e}:${x.commit}`)]})]})}var O_=200,k_=40,A_=52,j_=260,M_=240,N_=44,P_=580,F_=780;function I_(e){return e.length>26?`${e.slice(0,25)}…`:e}function L_(e,t){(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t())}function R_(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=N_+i.length*A_+(i.length?4:0),o=Math.max(n.length*A_,r.length*A_,a)+8,s=new Map,c=(e,t,n)=>{let r=(o-e.length*A_)/2+6;e.forEach((e,i)=>s.set(e.id,{x:t,y:r+i*A_,w:O_,h:k_,column:n,center:!1}))};c(n,0,0),c(r,P_,2);let l=(o-a)/2;return s.set(e.center,{x:j_,y:l,w:M_,h:a,column:1,center:!0}),i.forEach((e,t)=>s.set(e.id,{x:284,y:l+N_+t*A_,w:204,h:k_,column:1,center:!1})),{boxes:s,height:o}}function z_(e){return e.center?e.y+N_/2:e.y+e.h/2}function B_(e,t){if(e.column<t.column)return[[e.x+e.w,z_(e)],[t.x,z_(t)]];if(e.column>t.column)return[[e.x,z_(e)],[t.x+t.w,z_(t)]];let n=e=>e.center?[272,e.y+N_-6]:[e.x,z_(e)],[r,i]=n(e),[a,o]=n(t);return[[r,i],[272,i],[272,o],[a,o]]}function V_(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 H_(e,t){return re(e)?t(`architecture.graph.more`,{count:e.count}):e.name}function U_({graph:e,onSelect:t,t:n}){let r=(0,L.useId)(),[i,a]=(0,L.useState)([]),{boxes:o,height:s}=R_(e),c=new Map(e.nodes.map(e=>[e.id,H_(e,n)])),l=e=>a(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),u=e.nodes.filter(re).filter(e=>i.includes(e.id));return(0,H.jsxs)(`figure`,{className:`module-graph`,"aria-labelledby":`${r}-caption`,children:[(0,H.jsxs)(`figcaption`,{id:`${r}-caption`,className:`module-graph__caption`,children:[(0,H.jsx)(`span`,{children:n(`architecture.graph.callers`)}),(0,H.jsx)(`span`,{children:n(`architecture.graph.module`)}),(0,H.jsx)(`span`,{children:n(`architecture.graph.callees`)})]}),(0,H.jsxs)(`svg`,{className:`module-graph__svg`,viewBox:`0 0 ${F_} ${s}`,width:F_,height:s,role:`group`,"aria-labelledby":`${r}-caption`,children:[(0,H.jsx)(`defs`,{children:(0,H.jsx)(`marker`,{id:`${r}-arrow`,viewBox:`0 0 10 10`,refX:`9`,refY:`5`,markerWidth:`7`,markerHeight:`7`,orient:`auto-start-reverse`,children:(0,H.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=H_(e,n);if(re(e)){let t=i.includes(e.id);return(0,H.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=>L_(t,()=>l(e.id)),children:[(0,H.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,H.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`?h.test(e.id):!1,c=()=>t(e.id);return(0,H.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=>L_(e,c)}:{},children:[(0,H.jsx)(`title`,{children:`${e.name} (${e.id})`}),(0,H.jsx)(`rect`,{x:r.x,y:r.y,width:r.w,height:r.h,rx:`8`}),(0,H.jsx)(`text`,{x:r.x+12,y:r.center?r.y+N_/2:r.y+r.h/2,dominantBaseline:`central`,children:I_(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=B_(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,H.jsxs)(`g`,{className:`module-graph__edge`,"data-direction":e.direction,children:[(0,H.jsx)(`path`,{d:V_(a),...s?{markerEnd:`url(#${r}-arrow)`}:{strokeDasharray:`5 4`},children:(0,H.jsx)(`title`,{children:`${e.intent} (${e.relation_kind})`})}),!s&&(0,H.jsx)(`text`,{className:`module-graph__edge-label`,x:c,y:l-4,textAnchor:`middle`,children:e.relation_kind})]},t)})]}),u.map(e=>(0,H.jsxs)(`section`,{className:`module-graph__group`,"aria-label":n(`architecture.graph.group.${e.role}`,{count:e.count}),children:[(0,H.jsx)(`h4`,{children:n(`architecture.graph.group.${e.role}`,{count:e.count})}),(0,H.jsx)(`ul`,{children:e.members.map(e=>(0,H.jsxs)(`li`,{children:[h.test(e.id)?(0,H.jsx)(`button`,{type:`button`,onClick:()=>t(e.id),children:e.name}):(0,H.jsx)(`span`,{children:e.name}),(0,H.jsx)(`code`,{children:e.id})]},e.id))})]},e.id)),(0,H.jsx)(`ul`,{className:`module-graph__relations`,"aria-label":n(`architecture.graph.relations`),children:e.edges.map((e,t)=>(0,H.jsxs)(`li`,{"data-direction":e.direction,children:[(0,H.jsx)(`span`,{children:c.get(e.source)??e.source}),(0,H.jsx)(`span`,{children:` → `}),(0,H.jsx)(`span`,{children:c.get(e.target)??e.target}),(0,H.jsx)(`span`,{className:`module-graph__intent`,children:e.intent}),(0,H.jsx)(`code`,{children:e.relation_kind})]},t))})]})}function W_(e){let t=e?.code;return typeof t==`string`&&/^[a-z][a-z0-9_]{0,63}$/u.test(t)?t:null}async function G_(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=W_(i);if(e===null)throw Error(`unavailable`);return{state:`unavailable`,reason:e}}return{body:i,etag:r.headers.get(`ETag`)}}function K_(e,t,n){let[r,i]=(0,L.useState)({path:null,value:null,error:null}),a=(0,L.useRef)(null),s=(0,L.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 G_(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 o(s,JSON.stringify([e,n]),{enabled:e!==null}),r.path===e?r:{path:e,value:null,error:null}}function q_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/modules`}function J_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/history`}function Y_(e){return`/api/v1/repositories/${encodeURIComponent(e)}/architecture/refactor`}function X_(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 Z_({read:e,loading:t,t:n}){return e.error===null?e.value===null?(0,H.jsx)(`p`,{role:`status`,children:n(t)}):null:(0,H.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 Q_={valid:`tone-ok`,fresh:`tone-ok`,present:`tone-ok`,invalid:`tone-danger`,stale:`tone-user`,pending:`tone-user`,unknown:`tone-unknown`};function $_({state:e,t}){return(0,H.jsx)(`ul`,{className:`module-states`,"aria-label":t(`architecture.states`),children:[`model_valid`,`generated_summary`,`section3`].map(n=>(0,H.jsxs)(`li`,{className:`operator-badge ${Q_[e[n]]}`,"data-state-kind":n,"data-state-value":e[n],children:[t(`architecture.state.${n}`),`: `,(0,H.jsx)(`strong`,{children:t(`architecture.value.${e[n]}`)})]},n))})}function ev({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,H.jsx)(`p`,{className:`empty-inline`,children:n(`architecture.empty`)}):(0,H.jsx)(`div`,{className:`module-domains`,children:[...r].map(([e,r])=>(0,H.jsxs)(`section`,{className:`module-domain`,"data-domain":e,"aria-labelledby":`domain-${e}`,children:[(0,H.jsxs)(`h3`,{id:`domain-${e}`,children:[e,` `,(0,H.jsx)(`span`,{children:r.length})]}),(0,H.jsx)(`ul`,{children:r.map(e=>(0,H.jsxs)(`li`,{className:`module-row`,"data-module-id":e.id,children:[(0,H.jsxs)(`button`,{type:`button`,className:`module-row__open`,onClick:()=>t(e.id),children:[(0,H.jsx)(`strong`,{children:e.name}),(0,H.jsx)(`code`,{children:e.id})]}),(0,H.jsxs)(`span`,{className:`module-row__meta`,children:[e.status,` · `,n(`architecture.components`,{count:e.components})]}),(0,H.jsx)($_,{state:e.state,t:n})]},e.id))})]},e))})}function tv({base:e,generation:t,t:n}){let[r,i]=(0,L.useState)(1),a=K_(`${e}/review-prompt?shard=${r}`,Ie,t),o=a.value,s=o?X_(o):null;return(0,H.jsxs)(`section`,{className:`architecture-card review-prompt`,"aria-labelledby":`review-prompt-heading`,children:[(0,H.jsx)(`h3`,{id:`review-prompt-heading`,children:n(`architecture.prompt.title`)}),(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.boundary`)}),(0,H.jsx)(Z_,{read:a,loading:`architecture.prompt.loading`,t:n}),o&&s&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`dl`,{className:`detail-list`,children:[(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:n(`architecture.prompt.digest`)}),(0,H.jsx)(`dd`,{children:(0,H.jsx)(`code`,{className:`mono-value review-prompt__digest`,children:o.digest})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:n(`architecture.prompt.budget`)}),(0,H.jsx)(`dd`,{children:n(`architecture.prompt.budgetValue`,{used:o.budget.used_bytes,cap:o.budget.input_cap_bytes})})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:n(`architecture.prompt.omitted`)}),(0,H.jsx)(`dd`,{children:o.budget.omitted_sections.length?o.budget.omitted_sections.join(`, `):n(`architecture.prompt.omittedNone`)})]}),(0,H.jsxs)(`div`,{children:[(0,H.jsx)(`dt`,{children:(0,H.jsx)(`label`,{htmlFor:`review-prompt-shard`,children:n(`architecture.prompt.shard`)})}),(0,H.jsx)(`dd`,{children:(0,H.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,H.jsx)(`option`,{value:e,children:n(`architecture.prompt.shardOf`,{index:e,count:o.shard.count})},e))})})]})]}),o.budget.incomplete&&(0,H.jsx)(`p`,{className:`detail-quiet`,children:n(`architecture.prompt.incomplete`,{count:o.shard.count})}),(0,H.jsxs)(`div`,{className:`copy-value review-prompt__command`,children:[(0,H.jsx)(`code`,{"data-bot-command":!0,children:s}),(0,H.jsx)(f,{label:n(`architecture.prompt.command`),value:s,t:n})]}),(0,H.jsxs)(`details`,{className:`review-prompt__text`,children:[(0,H.jsx)(`summary`,{children:n(`architecture.prompt.text`,{index:o.shard.index})}),(0,H.jsx)(`pre`,{children:o.prompt})]}),(0,H.jsx)(`div`,{className:`review-prompt__actions`,children:(0,H.jsx)(f,{label:n(`architecture.prompt.textLabel`,{index:o.shard.index}),value:o.prompt,t:n})})]})]})}function nv(e,t){let n=typeof e==`object`&&e&&!Array.isArray(e)?e[t]:void 0;return typeof n==`string`?n:null}function rv({value:e,outcome:t}){let n=nv(e,`label`)??nv(e,`id`)??JSON.stringify(e),r=t?nv(e,`kind`):[nv(e,`from`),nv(e,`to`)].every(Boolean)?`${nv(e,`from`)} → ${nv(e,`to`)}`:null;return(0,H.jsxs)(`li`,{children:[r&&(0,H.jsx)(`code`,{children:r}),` `,n]})}function iv({items:e,empty:t}){return e.length?(0,H.jsx)(`ul`,{children:e.map((e,t)=>(0,H.jsx)(`li`,{children:e},t))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:t})}function av({detail:e,base:t,generation:n,onModule:r,t:i}){let{module:a}=e,o=i(`architecture.none`);return(0,H.jsxs)(`article`,{className:`module-page`,"aria-labelledby":`module-page-title`,children:[(0,H.jsxs)(`header`,{className:`module-page__header`,children:[(0,H.jsxs)(`p`,{className:`detail-eyebrow`,children:[a.status,` · `,(0,H.jsx)(`code`,{children:a.id})]}),(0,H.jsx)(`h2`,{id:`module-page-title`,children:a.name}),(0,H.jsx)(`p`,{children:a.summary}),(0,H.jsx)($_,{state:e.state,t:i})]}),(0,H.jsx)(U_,{graph:e.graph,onSelect:r,t:i}),(0,H.jsxs)(`div`,{className:`module-page__grid`,children:[(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-facts-heading`,children:[(0,H.jsx)(`h3`,{id:`module-facts-heading`,children:i(`architecture.facts`)}),(0,H.jsx)(`h4`,{children:i(`architecture.responsibilities`)}),(0,H.jsx)(iv,{items:a.responsibilities,empty:o}),(0,H.jsx)(`h4`,{children:i(`architecture.entrypoints`)}),a.entrypoints?.length?(0,H.jsx)(`ul`,{className:`module-entrypoints`,children:a.entrypoints.flatMap(e=>e.symbols.map(t=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:e.path}),` `,t.name,t.sinks.map(e=>(0,H.jsxs)(`span`,{children:[` → `,(0,H.jsx)(`code`,{children:e.path}),` `,e.symbol]},e.id))]},`${e.id}:${t.name}`)))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:o}),(0,H.jsx)(`h4`,{children:i(`architecture.verification`)}),a.verification.length?(0,H.jsx)(`ul`,{children:a.verification.map(e=>(0,H.jsx)(`li`,{children:(0,H.jsx)(`code`,{children:e})},e))}):(0,H.jsx)(`p`,{className:`detail-quiet`,children:o})]}),(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-flows-heading`,children:[(0,H.jsx)(`h3`,{id:`module-flows-heading`,children:i(`architecture.flows`)}),e.flows.length===0&&(0,H.jsx)(`p`,{className:`detail-quiet`,children:o}),e.flows.map(e=>(0,H.jsxs)(`div`,{className:`module-flow`,children:[(0,H.jsxs)(`h4`,{children:[e.name,` `,(0,H.jsx)(`code`,{children:e.id})]}),e.applicability===`not-applicable`?(0,H.jsx)(`p`,{children:i(`architecture.flow.notApplicable`,{rationale:e.rationale})}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.steps`)}),(0,H.jsx)(`ul`,{children:e.steps.map((e,t)=>(0,H.jsx)(rv,{value:e,outcome:!1},t))}),(0,H.jsx)(`p`,{className:`detail-eyebrow`,children:i(`architecture.flow.outcomes`)}),(0,H.jsx)(`ul`,{children:e.outcomes.map((e,t)=>(0,H.jsx)(rv,{value:e,outcome:!0},t))})]})]},e.id))]}),(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-section3-heading`,children:[(0,H.jsx)(`h3`,{id:`module-section3-heading`,children:i(`architecture.section3`)}),e.section3===null?(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.section3.pending`)}):(0,H.jsx)(`pre`,{className:`module-section3`,children:e.section3})]}),(0,H.jsxs)(`section`,{className:`architecture-card`,"aria-labelledby":`module-docs-heading`,children:[(0,H.jsx)(`h3`,{id:`module-docs-heading`,children:i(`architecture.docs`)}),e.linked_docs.length===0?(0,H.jsx)(`p`,{className:`detail-quiet`,children:i(`architecture.docs.none`)}):(0,H.jsx)(`ul`,{className:`module-docs`,children:e.linked_docs.map(e=>(0,H.jsxs)(`li`,{children:[(0,H.jsx)(`code`,{children:e.path}),` `,(0,H.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.kind}),` `,(0,H.jsx)(`span`,{className:`operator-badge tone-neutral`,children:e.status??i(`architecture.value.unknown`)})]},e.path))})]}),(0,H.jsx)(tv,{base:t,generation:n,t:i},a.id)]})]})}var ov=`rh arch refactor recommendations`,sv=new Set([`accepted`,`acknowledged`,`deferred`]),cv={accepted:`tone-user`,acknowledged:`tone-user`,deferred:`tone-unknown`,resolved:`tone-ok`,rejected:`tone-neutral`,waived:`tone-neutral`};function lv({value:e,onModule:t,t:n}){let r=e.counts.accepted+e.counts.acknowledged+e.counts.deferred,i=!e.adopted||e.decisions.length===0||r>0;return(0,H.jsxs)(`div`,{className:`architecture-map-view`,"data-refactor-view":!0,children:[(0,H.jsx)(`ul`,{className:`module-states`,"data-refactor-counts":!0,children:oe.map(t=>(0,H.jsxs)(`li`,{className:`operator-badge ${cv[t]}`,"data-refactor-status":t,children:[n(`architecture.refactor.status.${t}`),`: `,(0,H.jsx)(`strong`,{children:e.counts[t]})]},t))}),i&&(0,H.jsxs)(`div`,{className:`copy-value`,children:[(0,H.jsx)(`code`,{"data-refactor-command":`recommendations`,children:ov}),(0,H.jsx)(f,{label:n(`architecture.refactor.recommendationsCommand`),value:ov,t:n})]}),e.adopted?e.decisions.length===0?(0,H.jsx)(`p`,{className:`empty-inline`,"data-refactor-empty":`none`,children:n(`architecture.refactor.empty`)}):(0,H.jsx)(`ul`,{className:`module-domains`,"data-refactor-decisions":!0,children:e.decisions.map(e=>{let r=e.metrics?Object.entries(e.metrics):[];return(0,H.jsxs)(`li`,{className:`architecture-card`,"data-refactor-decision":e.recommendation_id,"data-status":e.status,children:[(0,H.jsxs)(`div`,{className:`module-states`,children:[(0,H.jsx)(`span`,{className:`operator-badge ${cv[e.status]}`,children:n(`architecture.refactor.status.${e.status}`)}),(0,H.jsx)(`code`,{children:e.kind??e.category}),(0,H.jsx)(`strong`,{children:e.subject}),(0,H.jsx)(`code`,{className:`mono-value`,children:e.recommendation_id})]}),e.affected_node_ids.length>0&&(0,H.jsx)(`div`,{className:`module-states`,"data-refactor-nodes":!0,children:e.affected_node_ids.map(e=>ie.test(e)?(0,H.jsx)(`button`,{type:`button`,className:`module-row__open`,onClick:()=>t(e),children:(0,H.jsx)(`code`,{children:e})},e):(0,H.jsx)(`code`,{children:e},e))}),r.length>0&&(0,H.jsx)(`p`,{className:`mono-value`,"data-refactor-metrics":!0,children:r.map(([e,t])=>`${e}=${t??`null`}`).join(` · `)}),(0,H.jsx)(`p`,{"data-refactor-reason":!0,children:e.reason}),(0,H.jsxs)(`p`,{className:`detail-quiet`,children:[(0,H.jsx)(`time`,{dateTime:e.decided_at,children:e.decided_at}),` · `,(0,H.jsx)(`code`,{children:e.head_sha.slice(0,7)})]}),sv.has(e.status)&&(0,H.jsxs)(`div`,{className:`copy-value`,children:[(0,H.jsx)(`code`,{"data-refactor-verify":e.recommendation_id,children:e.cli_verify_command}),(0,H.jsx)(f,{label:n(`architecture.refactor.verifyCommand`),value:e.cli_verify_command,t:n})]})]},e.recommendation_id)})}):(0,H.jsx)(`p`,{className:`empty-inline`,"data-refactor-empty":`unadopted`,children:n(`architecture.refactor.unadopted`)})]})}var uv=[`map`,`layers`,`sequence`,`topology`,`modules`,`history`,`refactor`],dv={map:`modules`,layers:`layers`,sequence:`sequence`,topology:`topology`};function fv({view:e,counts:t,onChange:n,t:r}){return(0,H.jsx)(`div`,{className:`architecture-tabs`,role:`tablist`,"aria-label":r(`architecture.views`),children:uv.map((i,a)=>(0,H.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`?uv.length-1:(a+(e.key===`ArrowRight`?1:uv.length-1))%uv.length;e.preventDefault(),n(uv[t]),e.currentTarget.parentElement?.querySelectorAll(`[role="tab"]`)[t]?.focus()},children:[r(`architecture.view.${i}`),t[i]!==void 0&&(0,H.jsx)(`span`,{className:`architecture-tabs__count`,children:t[i]})]},i))})}function pv(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 mv({repositoryId:e,github:t,moduleId:n,onModule:r,onSource:i,refreshGeneration:a,readMap:o,readHistory:s=G_,t:c}){let[l,u]=(0,L.useState)(`map`),[d,f]=(0,L.useReducer)(pv,{repositoryId:e,commit:null,selections:{}});d.repositoryId!==e&&f({type:`shown`,repositoryId:e,commit:null});let p=d.repositoryId===e?d.selections:{},m=(0,L.useCallback)(e=>f({type:`select`,select:e}),[]),h=q_(e),g=n===null?null:`${h}/${n}`,_=K_(n===null&&l===`modules`?h:null,Pe,a),v=K_(n===null&&l===`refactor`?Y_(e):null,Le,a),y=K_(g,Fe,a),[b,x]=(0,L.useState)(null),[S,C]=(0,L.useState)(null),[w,T]=(0,L.useState)(null),E=(0,L.useCallback)(t=>{x(n=>({repositoryId:e,value:{...n?.repositoryId===e?n.value:{},...t}}))},[e]),D=(0,L.useCallback)(t=>{C(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&&E({map:t.modules,sequence:t.flows})},[E,e]),O=(0,L.useCallback)(e=>{T(e),e!==null&&E({history:e.total})},[E]);(0,L.useEffect)(()=>{v.value!==null&&E({refactor:v.value.decisions.length})},[v.value,E]);let k=n===null?l===`modules`?_.value?.commit:l===`history`||l===`refactor`?void 0:S?.commit:y.value?.commit,A=n===null&&l!==`modules`&&l!==`history`&&l!==`refactor`?S:null,j=n===null&&l===`history`?w:null;return(0,L.useEffect)(()=>{i(j??(k===void 0?null:{commit:k,map:A===null?null:{collectedAt:A.collectedAt,headRef:A.headRef,archctxVersion:A.archctxVersion}}))},[j,k,A,i]),(0,L.useEffect)(()=>()=>i(null),[i]),(0,H.jsx)(`section`,{className:`architecture-workspace`,"aria-label":c(`nav.architecture`),children:n===null?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(fv,{view:l,counts:b?.repositoryId===e?b.value:{},onChange:u,t:c}),(0,H.jsx)(`div`,{id:`architecture-view`,className:`architecture-view`,role:`tabpanel`,"aria-labelledby":`architecture-tab-${l}`,children:l===`history`?(0,H.jsx)(Lm,{path:J_(e),github:t,read:s,refreshGeneration:a,selection:p.history??null,select:m,onSummary:O,t:c}):l===`refactor`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z_,{read:v,loading:`architecture.refactor.loading`,t:c}),v.value&&(0,H.jsx)(lv,{value:v.value,onModule:r,t:c})]}):l===`modules`?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Z_,{read:_,loading:`architecture.loading`,t:c}),_.value&&(0,H.jsx)(ev,{index:_.value,onModule:r,t:c})]}):(0,H.jsx)(D_,{repositoryId:e,view:dv[l],read:o,refreshGeneration:a,selections:p,select:m,onModule:r,onSummary:D,t:c})})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{children:(0,H.jsx)(`button`,{type:`button`,className:`operator-button operator-button--secondary`,onClick:()=>r(null),children:c(`architecture.back`)})}),(0,H.jsx)(Z_,{read:y,loading:`architecture.module.loading`,t:c}),y.value&&g&&(0,H.jsx)(av,{detail:y.value,base:g,generation:a,onModule:r,t:c})]})})}export{mv as ArchitectureWorkspace};
|