repo-harness-operator-web 0.36.1 → 0.37.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-DXm5VXGJ.js → ArchitectureWorkspace-ChGKziPI.js} +1 -1
- package/dist/assets/{DocsPage-Dzi-lwQA.js → DocsPage-hG8AizKd.js} +3 -3
- package/dist/assets/{abnfDiagram-S7VZAUFO-oWkKldsG.js → abnfDiagram-S7VZAUFO-DKaJfotT.js} +1 -1
- package/dist/assets/{architecture-WOLXFQ4H-C4iLwQsx.js → architecture-WOLXFQ4H-Bi8Ve6Ky.js} +1 -1
- package/dist/assets/{architectureDiagram-YGSQEFNW-DLhstnyT.js → architectureDiagram-YGSQEFNW-eOVp-Zdq.js} +1 -1
- package/dist/assets/{blockDiagram-APKKGZFW-CVT36L0q.js → blockDiagram-APKKGZFW-CAn24f2q.js} +1 -1
- package/dist/assets/{c4Diagram-KJ2TOQU5-tJp0zS11.js → c4Diagram-KJ2TOQU5-C1AdMzlq.js} +1 -1
- package/dist/assets/{chunk-6MUBBAK2-qP91lPlO.js → chunk-6MUBBAK2-DKMgA0jN.js} +1 -1
- package/dist/assets/{chunk-AXFCVDMN-qTmRhmoo.js → chunk-AXFCVDMN-C-fPU-DA.js} +1 -1
- package/dist/assets/{chunk-BG4553SI-Dv3MoSjh.js → chunk-BG4553SI-BGr4jQ3f.js} +1 -1
- package/dist/assets/{chunk-DQASFODM-DQW_kPFz.js → chunk-DQASFODM-Byw9q9z1.js} +1 -1
- package/dist/assets/{chunk-HFQBQIA3-F-NOiGrC.js → chunk-HFQBQIA3-CHOuNegO.js} +1 -1
- package/dist/assets/{chunk-KQLB2F66-C_sicILI.js → chunk-KQLB2F66-B5_kC-1G.js} +1 -1
- package/dist/assets/{chunk-KS47KZWR-GWfPxq_D.js → chunk-KS47KZWR-OJ2llhwv.js} +1 -1
- package/dist/assets/{chunk-LEVMRMFU-Dwv7wtQG.js → chunk-LEVMRMFU-CEAb5xyZ.js} +1 -1
- package/dist/assets/{chunk-M57EVK23-DXC0kIqQ.js → chunk-M57EVK23-BumkZo_9.js} +1 -1
- package/dist/assets/{chunk-OY52VR5R-DiYArfaB.js → chunk-OY52VR5R-CkbyPBR_.js} +1 -1
- package/dist/assets/{chunk-QB3YPZ4I-Dgi4X6no.js → chunk-QB3YPZ4I-nA24Zf0Z.js} +1 -1
- package/dist/assets/{chunk-R3KSYZAL-Duhpn409.js → chunk-R3KSYZAL-DKaGlSge.js} +1 -1
- package/dist/assets/{chunk-STOXU5M4-CuNQgHEr.js → chunk-STOXU5M4-BHqPCN0r.js} +1 -1
- package/dist/assets/{chunk-TU62E6Q5-Dbn8bidA.js → chunk-TU62E6Q5-BS4YdQdw.js} +1 -1
- package/dist/assets/{chunk-X4PVCEUW-V87IDE3L.js → chunk-X4PVCEUW-ntjmaH7q.js} +1 -1
- package/dist/assets/{classDiagram-v2-L25IHNXF-C1fTZ3wA.js → classDiagram-v2-L25IHNXF-BJYCs_Mo.js} +1 -1
- package/dist/assets/cynefin-EF2NZ3EQ-COO-UGG5.js +1 -0
- package/dist/assets/{cynefinDiagram-L36ESFBY-DvZKaR5e.js → cynefinDiagram-L36ESFBY-DwAbOteg.js} +1 -1
- package/dist/assets/{dagre-SPEB5RXH-Cha1AjV6.js → dagre-SPEB5RXH-CrhEl54J.js} +1 -1
- package/dist/assets/{diagram-3B7GL73J-C0pLb5he.js → diagram-3B7GL73J-DmQM3w1n.js} +1 -1
- package/dist/assets/{diagram-DNEMPZML-BP6-0Vrs.js → diagram-DNEMPZML-qNcVGOAf.js} +1 -1
- package/dist/assets/{diagram-L3MUGCDN-DjajPQp8.js → diagram-L3MUGCDN-DYMiuCMI.js} +1 -1
- package/dist/assets/{diagram-LA4NIPWU-BvSEjV3_.js → diagram-LA4NIPWU-vicczMzR.js} +1 -1
- package/dist/assets/{diagram-MHCOC4E2-Bpb9HC_N.js → diagram-MHCOC4E2-D_JAAhu4.js} +1 -1
- package/dist/assets/{diagram-XPFHEONP-Bf6DSJnI.js → diagram-XPFHEONP-BO_RiZyb.js} +1 -1
- package/dist/assets/{ebnfDiagram-UZSYDL2S-CjLraHZk.js → ebnfDiagram-UZSYDL2S-DDsrA9f4.js} +1 -1
- package/dist/assets/{elk-XV6XMXQE-CkxEHBId.js → elk-XV6XMXQE-DVGTNjsr.js} +1 -1
- package/dist/assets/{erDiagram-EYBAPDEH-BLp5m7S9.js → erDiagram-EYBAPDEH-CFFvzwsG.js} +1 -1
- package/dist/assets/{eventmodeling-K75KTNOO-BBhI9cbX.js → eventmodeling-K75KTNOO-CdpTiE9r.js} +1 -1
- package/dist/assets/flowDiagram-MALGAFMO-DaUiCFPn.js +1 -0
- package/dist/assets/{ganttDiagram-23REXITY-DHkr2NHi.js → ganttDiagram-23REXITY-DtEKuncI.js} +1 -1
- package/dist/assets/gitGraph-VSP46ZUC-DZswh7XC.js +1 -0
- package/dist/assets/{gitGraphDiagram-STJD7YCW-ClOXHIEJ.js → gitGraphDiagram-STJD7YCW-CcnRyNYT.js} +1 -1
- package/dist/assets/index-B86aPJ2i.js +41 -0
- package/dist/assets/info-OHQRW6UA-y4KCVA4o.js +1 -0
- package/dist/assets/{infoDiagram-KBXO4MBG-DUUVW7zA.js → infoDiagram-KBXO4MBG-C2MEjMoJ.js} +1 -1
- package/dist/assets/{ishikawaDiagram-M35NCXHK-D4MbdIm-.js → ishikawaDiagram-M35NCXHK-CS78zGgg.js} +1 -1
- package/dist/assets/{journeyDiagram-OPLOXDXO-Cn66RFrV.js → journeyDiagram-OPLOXDXO-DZ5oQ7lj.js} +1 -1
- package/dist/assets/{kanban-definition-BZKZHSQY-PhF5lMME.js → kanban-definition-BZKZHSQY-DJ5bSaKk.js} +1 -1
- package/dist/assets/{line-BdRwCs0r.js → line-BJ7LyzNm.js} +1 -1
- package/dist/assets/{mermaid-parser.core-Ci1nRpg9.js → mermaid-parser.core-CXqKnu0k.js} +3 -3
- package/dist/assets/{mermaid.core-R1StD7iM.js → mermaid.core-CEZHNGpS.js} +4 -4
- package/dist/assets/{mindmap-definition-I2QAS2VK-D-ki92JC.js → mindmap-definition-I2QAS2VK-BENGBVar.js} +1 -1
- package/dist/assets/packet-JDAUHWVQ-DlwogYT0.js +1 -0
- package/dist/assets/{pegDiagram-FD4XPPHP-D4qFEL94.js → pegDiagram-FD4XPPHP-B8b8O4J8.js} +1 -1
- package/dist/assets/pie-XZMESJXO-BVuvq8OY.js +1 -0
- package/dist/assets/{pieDiagram-J4AKIIQI-Deta8Ifv.js → pieDiagram-J4AKIIQI-Dda7nZho.js} +1 -1
- package/dist/assets/{quadrantDiagram-XTYBLID2-Cspj-h7g.js → quadrantDiagram-XTYBLID2-Bx1vii7K.js} +1 -1
- package/dist/assets/radar-ABXABTNO-DalL2yfg.js +1 -0
- package/dist/assets/railroad-I3PHUGI6-B87WPx9y.js +1 -0
- package/dist/assets/{railroad-abnf-LNEFI6M7-bSLpcz8w.js → railroad-abnf-LNEFI6M7-CWLTIPcb.js} +1 -1
- package/dist/assets/{railroad-ebnf-DWYD2UWJ-CFEt8f6s.js → railroad-ebnf-DWYD2UWJ-D51azK2O.js} +1 -1
- package/dist/assets/{railroad-peg-JR7BVNR7-CCv8LZF3.js → railroad-peg-JR7BVNR7-CVFzjXXZ.js} +1 -1
- package/dist/assets/{railroadDiagram-MRQ6NCDL-BrL1dbIF.js → railroadDiagram-MRQ6NCDL-DGiM2J9o.js} +1 -1
- package/dist/assets/{requirementDiagram-Y7LWUY3S-7zvStmjR.js → requirementDiagram-Y7LWUY3S-mEteEfPh.js} +1 -1
- package/dist/assets/{sankeyDiagram-WGJFYUXA-DEBIVIcM.js → sankeyDiagram-WGJFYUXA-BK313us6.js} +1 -1
- package/dist/assets/{sequenceDiagram-5NDRBG5M-CXBmlA6Z.js → sequenceDiagram-5NDRBG5M-D23R1fJY.js} +1 -1
- package/dist/assets/{stateDiagram-v2-FJ4FJNEA-DlE26TVS.js → stateDiagram-v2-FJ4FJNEA-DmfDq-b9.js} +1 -1
- package/dist/assets/{swimlanes-UMQ2AFYF-CqiUMkIi.js → swimlanes-UMQ2AFYF-C-gy4qyt.js} +1 -1
- package/dist/assets/swimlanesDiagram-OMPLPG4O-DdfsSQYO.js +8 -0
- package/dist/assets/{timeline-definition-SEUHKTQE-B7e4-kan.js → timeline-definition-SEUHKTQE-BniHJ9WE.js} +1 -1
- package/dist/assets/treeView-D4JQ5SDB-B-c44-td.js +1 -0
- package/dist/assets/treemap-SAJKECNS-CzHZWjs6.js +1 -0
- package/dist/assets/{usecaseDiagram-AFA6YXN4-BBl0R5-K.js → usecaseDiagram-AFA6YXN4-BWoLDNB3.js} +1 -1
- package/dist/assets/{vennDiagram-NNMJR3RB--dNLXd0M.js → vennDiagram-NNMJR3RB-BZsYBXTF.js} +1 -1
- package/dist/assets/wardley-7MLQ67FV-D_vrGPz-.js +1 -0
- package/dist/assets/{wardleyDiagram-S7YFUSEH-C0a5XrPw.js → wardleyDiagram-S7YFUSEH-GNTIubXa.js} +1 -1
- package/dist/assets/{xychartDiagram-GGNKY7IX-D6nQOp_E.js → xychartDiagram-GGNKY7IX-CA1vyNod.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
- package/dist/assets/cynefin-EF2NZ3EQ-ifoyeEUw.js +0 -1
- package/dist/assets/flowDiagram-MALGAFMO-DFsIeR4Q.js +0 -1
- package/dist/assets/gitGraph-VSP46ZUC-_BdvC7yA.js +0 -1
- package/dist/assets/index-BK2G01pV.js +0 -41
- package/dist/assets/info-OHQRW6UA-rDctUC1r.js +0 -1
- package/dist/assets/packet-JDAUHWVQ-CXgLb6RS.js +0 -1
- package/dist/assets/pie-XZMESJXO-BOh5LkmE.js +0 -1
- package/dist/assets/radar-ABXABTNO-CGhGo4lp.js +0 -1
- package/dist/assets/railroad-I3PHUGI6-Bdz3_AUc.js +0 -1
- package/dist/assets/swimlanesDiagram-OMPLPG4O-JcReCzYd.js +0 -8
- package/dist/assets/treeView-D4JQ5SDB-BKvJnHeO.js +0 -1
- package/dist/assets/treemap-SAJKECNS-BlAfSHTF.js +0 -1
- package/dist/assets/wardley-7MLQ67FV-DCN3G58W.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e}from"./rolldown-runtime-COiEfhsA.js";import{A as t,D as n,S as r,T as i,_ as a,b as o,c as s,g as c,h as l,k as u,l as d,n as f,o as p,p as m,v as h,x as g,y as _}from"./index-BK2G01pV.js";import{C as v,S as y,T as b,_ as x,b as S,i as C,n as w,r as T,t as E,v as D,w as O,x as k,y as A}from"./src-C_gRsKqw.js";import{t as j}from"./value-CHmTzbgv.js";var M=e=>()=>e;function N(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}})}N.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function P(e){return!e.ctrlKey&&!e.button}function ee(){return this.parentNode}function te(e,t){return t??{x:e.x,y:e.y}}function ne(){return navigator.maxTouchPoints||`ontouchstart`in this}function F(){var e=P,t=ee,n=te,r=ne,i={},a=b(`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`,_,S).on(`touchend.drag touchcancel.drag`,C).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=w(this,t.call(this,n,r),n,r,`mouse`);i&&(O(n.view).on(`mousemove.drag`,m,k).on(`mouseup.drag`,h,k),x(n.view),y(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(A(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){O(e.view).on(`mousemove.drag mouseup.drag`,null),D(e.view,l),A(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]))&&(y(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])&&(A(e),a(`drag`,e,t[r]))}function C(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(y(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=v(l||r,t),p,m,h;if((h=n.call(e,new N(`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=v(l||a,t),_=o}u.call(r,e,new N(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:M(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:M(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:M(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:M(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var I=e(t(),1);function L(e){return e.kind===`group`}var re=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,ie=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,ae=[`accepted`,`acknowledged`,`deferred`,`resolved`,`rejected`,`waived`],R=e=>typeof e==`string`,z=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,oe=e=>z(e)&&e>0,se=e=>typeof e==`boolean`,ce=e=>t=>R(t)&&e.test(t),B=(...e)=>t=>e.includes(t),le=e=>t=>t===null||e(t),V=e=>t=>Array.isArray(t)&&t.every(e),H=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]))},ue=e=>t=>R(t)&&t.length>0&&t.length<=e&&t===t.trim()&&!/[\x00-\x1f\x7f]/u.test(t),de=e=>!e||typeof e!=`object`||Array.isArray(e)?!1:Object.entries(e).every(([e,t])=>ue(128)(e)&&(t===null||typeof t==`number`&&Number.isFinite(t))),fe=ce(/^[0-9a-f]{64}$/),pe=ce(ie),me=ce(re),he=ce(/^recommendation\.[0-9a-f]{16}$/u),ge=ce(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/u),_e=e=>R(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),ve=H({model_valid:B(`valid`,`invalid`,`unknown`),generated_summary:B(`fresh`,`stale`,`unknown`),section3:B(`present`,`pending`)}),ye=H({id:R,from:R,to:R,label:R,evidence:H({entrypointId:R,sourceSymbol:R,sinkId:R})}),be=e=>H({id:R,capabilityId:me,name:R,applicability:B(`not-applicable`),rationale:R})(e)||H({id:R,capabilityId:me,name:R,applicability:B(`required`),participants:V(H({id:R,nodeId:R})),steps:V(ye),outcomes:V(H({id:R,kind:B(`success`,`error`),label:R,steps:V(ye),terminal:H({participant:R,label:R})}))})(e),xe=e=>typeof e==`string`&&e.length>0&&e!==`group`,Se=H({include:V(R),exclude:V(R)}),Ce=e=>H({id:R,kind:xe,name:R,role:B(`center`,`child`,`caller`,`callee`)})(e)||H({id:R,kind:B(`group`),role:B(`caller`,`callee`),count:oe,members:V(H({id:R,name:R}))})(e),we=H({schema_version:B(`repo-harness.architecture-modules.v1`),commit:pe,modules:V(H({id:me,domain:R,name:R,status:R,components:z,state:ve}))}),Te=H({schema_version:B(`repo-harness.architecture-module.v1`),commit:pe,module:H({id:me,name:R,status:R,summary:R,responsibilities:V(R),notes:V(R),source:Se,verification:V(R),entrypoints:V(H({id:R,path:_e,symbols:V(H({name:R,sinks:V(H({id:R,path:_e,symbol:R}))}))})),components:V(H({id:R,kind:xe,name:R,summary:R,source:Se}))}),graph:H({center:me,nodes:V(Ce),edges:V(H({source:R,target:R,intent:R,relation_kind:R,direction:B(`directed`)}))}),flows:V(be),section3:le(R),linked_docs:V(H({path:_e,kind:B(`contract`,`plan`),status:le(R)})),state:ve}),Ee=H({schema_version:B(`repo-harness.module-review-prompt.v1`),prompt_version:R,package_version:R,repository_id:ce(/^repo_[0-9a-f]{16}$/),capability_id:me,commit:pe,mode:B(`module`,`diff`),base:le(pe),head:le(pe),worktree_dirty_paths:V(_e),dirty_content_sha256:le(fe),model_sha256:fe,doc_sha256:le(fe),sources:V(H({path:_e,sha256:fe,bytes:z,class:B(`required`,`optional`),disposition:B(`included`,`omitted`,`chunked`)})),budget:H({input_cap_bytes:oe,used_bytes:z,incomplete:se,omitted_sections:V(R)}),shard:H({index:oe,count:oe,bytes:z}),full_prompt_sha256:fe,prompt:R,digest:fe}),De=H({accepted:z,acknowledged:z,deferred:z,resolved:z,rejected:z,waived:z}),Oe=H({recommendation_id:he,category:B(`structural_observation`,`refactor_proposal`),kind:le(B(..._)),subject:ue(512),affected_node_ids:V(ue(256)),status:B(...h),metrics:le(de),reason:ue(1024),decided_at:ge,head_sha:pe,cli_verify_command:ue(128)}),ke=H({schema_version:B(`repo-harness.architecture-refactor.v1`),adopted:se,counts:De,decisions:V(Oe)});function Ae(e){return`rh arch refactor verify ${e} --json`}function je(e,t){let n=ae.indexOf(e.status)-ae.indexOf(t.status);return n===0?e.recommendation_id<t.recommendation_id?-1:+(e.recommendation_id>t.recommendation_id):n}function Me(e){if(!we(e))throw Error(`architecture_module_index_invalid`);return e}function Ne(e){if(!Te(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=>L(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function Pe(e){if(!Ee(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 Fe(e){if(!ke(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!==Ae(r.recommendation_id)||r.affected_node_ids.some((e,t)=>t>0&&e<=r.affected_node_ids[t-1])||e>0&&je(t.decisions[e-1],r)>=0)throw Error(`architecture_refactor_decisions_invalid`)}for(let e of ae)if(t.counts[e]!==t.decisions.filter(t=>t.status===e).length)throw Error(`architecture_refactor_decisions_invalid`);return t}var Ie=Object.defineProperty,Le=(e,t,n)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Re=(e,t)=>{for(var n in t)Ie(e,n,{get:t[n],enumerable:!0})},ze=(e,t,n)=>Le(e,typeof t==`symbol`?t:t+``,n),Be={};Re(Be,{Graph:()=>Tt,alg:()=>$e});var Ve=Object.defineProperty,He=(e,t)=>{for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},Ue=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=Ke(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=qe(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,We(this._preds[a],i),We(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?Je(this._isDirected,e):Ke(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?Je(this._isDirected,e):Ke(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Je(this._isDirected,e):Ke(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],Ge(this._preds[t],e),Ge(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 We(e,t){e[t]?e[t]++:e[t]=1}function Ge(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Ke(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 qe(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 Je(e,t){return Ke(e,t.v,t.w,t.name)}He({},{read:()=>Qe,write:()=>Ye});function Ye(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Xe(e),edges:Ze(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Xe(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 Ze(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 Qe(e){let t=new Ue(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 $e={};He($e,{CycleException:()=>mt,bellmanFord:()=>tt,components:()=>rt,dijkstra:()=>ot,dijkstraAll:()=>ct,findCycles:()=>ut,floydWarshall:()=>ft,isAcyclic:()=>gt,postorder:()=>bt,preorder:()=>xt,prim:()=>St,shortestPaths:()=>Ct,tarjan:()=>lt,topsort:()=>ht});var et=()=>1;function tt(e,t,n,r){return nt(e,String(t),n||et,r||function(t){return e.outEdges(t)??[]})}function nt(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 rt(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 it=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}},at=()=>1;function ot(e,t,n,r){return st(e,String(t),n||at,r||function(t){return e.outEdges(t)??[]})}function st(e,t,n,r){let i={},a=new it,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 ct(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ot(e,i,t,n),r},{})}function lt(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 ut(e){return lt(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var dt=()=>1;function ft(e,t,n){return pt(e,t||dt,n||function(t){return e.outEdges(t)??[]})}function pt(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 mt=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function ht(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new mt;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 mt;return r}function gt(e){try{ht(e)}catch(e){if(e instanceof mt)return!1;throw e}return!0}function _t(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=vt(e,t,n===`post`,o,a,r,i)}),i}function vt(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=vt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function yt(e,t,n){return _t(e,t,n,function(e,t){return e.push(t),e},[])}function bt(e,t){return yt(e,t,`post`)}function xt(e,t){return yt(e,t,`pre`)}function St(e,t){var n;let r=new Ue,i={},a=new it,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 Ct(e,t,n,r){return wt(e,t,n,r??(t=>e.outEdges(t)??[]))}function wt(e,t,n,r){if(n===void 0)return ot(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 tt(e,t,n,r)}return ot(e,t,n,r)}var Tt=Ue;function Et(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Vt(r);return n.dummy=t,e.setNode(i,n),i}function Dt(e){let t=new Tt().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 Ot(e){let t=new Tt({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 kt(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 At(e){let t=Ht(Lt(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 jt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=It(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Mt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=It(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 Nt(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Et(e,`border`,i,t)}function Pt(e,t=Ft){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Ft=65535;function It(e,t){return t.length>Ft?e(...Pt(t).map(t=>e(...t))):e(...t)}function Lt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return It(Math.max,t)}function Rt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function zt(e,t){return t()}var Bt=0;function Vt(e){return e+(``+ ++Bt)}function Ht(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 Ut(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Wt(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 Gt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Kt=`\0`;function qt(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 Jt=class{constructor(){ze(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Yt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Yt(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,Xt)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Yt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Xt(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Zt=Jt,Qt=()=>1;function $t(e,t){if(e.nodeCount()<=1)return[];let n=nn(e,t||Qt);return en(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function en(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)tn(e,t,n,o);for(;o=i.dequeue();)tn(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(tn(e,t,n,o,!0)||[]);break}}}return r}function tn(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,rn(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,rn(t,n,o)}),e.removeNode(r.v),o}function nn(e,t){let n=new Tt,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=an(i+r+3).map(()=>new Zt),o=r+1;return n.nodes().forEach(e=>{rn(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function rn(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 an(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function on(e,t){(e.graph().acyclicer===`greedy`?$t(e,n(e)):sn(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,Vt(`rev`))});function n(e){return t=>e.edge(t).weight}}function sn(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&&ln(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 cn(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 ln(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 un(e){e.graph().dummyChains=[],e.edges().forEach(t=>dn(e,t))}function dn(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=Et(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 fn(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 pn(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=It(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function mn(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var hn=gn;function gn(e){let t=new Tt({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(;_n(t,e)<i&&(a=vn(t,e),a);)o=t.hasNode(a.v)?mn(e,a):-mn(e,a),yn(t,e,o);return t}function _n(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)&&!mn(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function vn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=mn(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function yn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:bn,postorder:xn}=$e,Sn=Cn;Cn.initLowLimValues=Dn,Cn.initCutValues=wn,Cn.calcCutValue=En,Cn.leaveEdge=kn,Cn.enterEdge=An,Cn.exchangeEdges=jn;function Cn(e){e=Dt(e),pn(e);let t=hn(e);Dn(t),wn(t,e);let n,r;for(;n=kn(t);)r=An(t,e,n),jn(t,e,n,r)}function wn(e,t){let n=xn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Tn(e,t,n))}function Tn(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=En(e,t,n)}function En(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,Nn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Dn(e,t){arguments.length<2&&(t=e.nodes()[0]),On(e,{},1,t)}function On(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=On(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function kn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function An(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===Pn(e,e.node(t.v),s)&&c!==Pn(e,e.node(t.w),s)).reduce((e,n)=>mn(t,n)<mn(t,e)?n:e)}function jn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Dn(e),wn(e,t),Mn(e,t)}function Mn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=bn(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 Nn(e,t,n){return e.hasEdge(t,n)}function Pn(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Fn=In;function In(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:zn(e);break;case`tight-tree`:Rn(e);break;case`longest-path`:Ln(e);break;case`none`:break;default:zn(e)}}var Ln=pn;function Rn(e){pn(e),hn(e)}function zn(e){Sn(e)}var Bn=Vn;function Vn(e){let t=Un(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Hn(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 Hn(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 Un(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(Kt).forEach(r),t}function Wn(e){let t=Et(e,`root`,{},`_root`),n=Kn(e),r=Object.values(n),i=It(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=qn(e)+1;e.children(Kt).forEach(r=>{Gn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function Gn(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=Nt(e,`_bt`),l=Nt(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{Gn(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 Kn(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(Kt).forEach(e=>n(e,1)),t}function qn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Jn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Yn=Xn;function Xn(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)Zn(e,`borderLeft`,`_bl`,n,i,t),Zn(e,`borderRight`,`_br`,n,i,t)}}e.children(Kt).forEach(t)}function Zn(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Et(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Qn(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&er(e)}function $n(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&nr(e),(t===`lr`||t===`rl`)&&(ir(e),er(e))}function er(e){e.nodes().forEach(t=>tr(e.node(t))),e.edges().forEach(t=>tr(e.edge(t)))}function tr(e){let t=e.width;e.width=e.height,e.height=t}function nr(e){e.nodes().forEach(t=>rr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(rr),Object.hasOwn(r,`y`)&&rr(r)})}function rr(e){e.y=-e.y}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,`x`)&&ar(r)})}function ar(e){let t=e.x;e.x=e.y,e.y=t}function or(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Ht(It(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 qt(t,e.node(n),e.node(r))}return a}function sr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=cr(e,t[r-1],t[r]);return n}function cr(e,t,n){let r=Gt(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 lr(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 ur(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))}),dr(Object.values(n).filter(e=>!e.indegree))}function dr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&fr(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=>Ut(e,[`vs`,`i`,`barycenter`,`weight`]))}function fr(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 pr(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=Rt(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(hr(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=mr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=mr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function mr(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 hr(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=qt(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 gr(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=lr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=gr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&vr(t,r)}});let h=ur(m,n);_r(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=pr(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 _r(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function vr(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 yr(e,t,n,r){r||=e.nodes();let i=br(e),a=new Tt({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 br(e){let t;for(;e.hasNode(t=Vt(`_root`)););return t}function xr(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 Sr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Sr);return}let r=Lt(e),i=Cr(e,Ht(1,r+1),`inEdges`),a=Cr(e,Ht(r-1,-1,-1),`outEdges`),o=or(e,n);if(Tr(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){wr(t%2?i:a,t%4>=2,l,n),o=At(e);let u=sr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Tr(e,c)}function Cr(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 yr(e,t,n,r.get(t)||[])})}function wr(e,t,n,r){let i=!0,a=new Tt;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=gr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),xr(e,a,s.vs)})}function Tr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Er(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=Or(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)&&kr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Dr(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){Ht(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)&&kr(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 Or(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function kr(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 Ar(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 jr(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)||Br(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=>Br(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&&!Ar(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 Mr(e,t,n,r,i=!1){let a={},o=Nr(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 Nr(e,t,n,r){let i=new Tt,a=e.graph(),o=Rr(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 Pr(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=zr(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 Fr(e,t){let n=Object.values(t),r=It(Math.min,n),i=It(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-It(Math.min,c);a!==`l`&&(l=i-It(Math.max,c)),l&&(e[o]=Wt(s,e=>e+l))})})}function Ir(e,t=void 0){let n=e.ul;return n?Wt(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 Lr(e,t){let n=At(e),r=Object.assign(Er(e,n),Dr(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=jr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Mr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Wt(c,e=>-e)),i[o+n]=c})}),Fr(i,Pr(e,i)),Ir(i,e.graph().align)}function Rr(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 zr(e,t){return e.node(t).width}function Br(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 Vr(e,t){e=Ot(e),Hr(e),Object.entries(Lr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Hr(e){let t=At(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 Ur=new WeakMap;function Wr(e,t={}){return Kr(e,zt,t),e}function Gr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Kr(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 Tt({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=Gr(e,t.v,r),i=Gr(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)}))}}),Kr(o,t,n);let l=ii(o);Jr(l,t,n,null),Yr(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=ii(e),g=Jr(h,t,n,Ur.get(e)??null);Ur.set(e,g),Yr(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))}),qr(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}}),qr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function qr(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 Jr(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`,()=>ai(e)),t(` removeSelfEdges`,()=>mi(e)),t(` acyclic`,()=>on(e,s)),t(` nestingGraph.run`,()=>Wn(e)),t(` rank`,()=>Fn(Ot(e))),t(` injectEdgeLabelProxies`,()=>oi(e)),t(` removeEmptyRanks`,()=>Mt(e)),t(` nestingGraph.cleanup`,()=>Jn(e)),t(` normalizeRanks`,()=>jt(e)),t(` assignRankMinMax`,()=>si(e)),t(` removeEdgeLabelProxies`,()=>ci(e)),t(` normalize.run`,()=>un(e)),t(` parentDummyChains`,()=>Bn(e)),t(` addBorderSegments`,()=>Yn(e)),t(` order`,()=>Sr(e,n,c)),t(` insertSelfEdges`,()=>hi(e)),t(` adjustCoordinateSystem`,()=>Qn(e)),t(` position`,()=>Vr(e,n.corePath)),t(` positionSelfEdges`,()=>gi(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>pi(e)),t(` normalize.undo`,()=>fn(e)),t(` fixupEdgeLabelCoords`,()=>di(e)),t(` undoCoordinateSystem`,()=>$n(e)),t(` translateGraph`,()=>li(e)),t(` assignNodeIntersects`,()=>ui(e)),t(` reversePoints`,()=>fi(e)),t(` acyclic.undo`,()=>cn(e)),{graph:e,rawNodes:l}}function Yr(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 Xr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Zr={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Qr=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],$r=[`width`,`height`,`rank`],ei={width:0,height:0},ti=[`minlen`,`weight`,`width`,`height`,`labeloffset`],ni={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},ri=[`labelpos`];function ii(e){let t=new Tt({multigraph:!0,compound:!0}),n=vi(e.graph());return t.setGraph(Object.assign({},Zr,_i(n,Xr),Ut(n,Qr))),e.nodes().forEach(n=>{let r=_i(vi(e.node(n)),$r);Object.keys(ei).forEach(e=>{r[e]===void 0&&(r[e]=ei[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=vi(e.edge(n));t.setEdge(n,Object.assign({},ni,_i(r,ti),Ut(r,ri)))}),t}function ai(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 oi(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Et(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function si(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 ci(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 li(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 ui(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(kt(r,a)),n.points.push(kt(i,o))})}function di(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 fi(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function pi(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 mi(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 hi(e){At(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=>{Et(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 gi(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 _i(e,t){return Wt(Ut(e,t),Number)}function vi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var yi=7,bi=16,xi=1.5,Si=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function Ci(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&Si.has(r)?2:1;return Math.ceil(n*yi*(t===`title`?xi:1))}var wi=12,Ti=e=>Math.round(e*10)/10,Ei=e=>Math.round(e*100)/100,Di=(e,t)=>[Ei((e[0]+t[0])/2),Ei((e[1]+t[1])/2)],Oi=([e,t])=>`${e} ${t}`;function ki(e){let t=e.length-1;if(t===1)return`M${Oi(e[0])} L${Oi(e[1])}`;let n=[`M${Oi(e[0])}`,`L${Oi(Di(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${Oi(e[r])} ${Oi(Di(e[r],e[r+1]))}`);return n.push(`L${Oi(e[t])}`),n.join(` `)}var Ai=16;function ji(e,t,n){return Array.from({length:Ai},(r,i)=>{let a=(i+1)/Ai,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 Mi=e=>e.slice(1).map((t,n)=>[e[n],t]);function Ni(e,t,n){let r=Ci(e,`label`);return{text:e,x:Ti(t[0]-r/2),y:Ti(t[1]-bi/2),width:r,height:bi,route:n}}function Pi(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[Ti(t[0]+(a[0]-t[0])*n/i),Ti(t[1]+(a[1]-t[1])*n/i)]}n-=i}return e[e.length-1]}function Fi(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[Ti(n),Ti(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[Ti(n+i*o),Ti(r+a*o)]}function Ii(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 Li(e,t,n){let r=Ii(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var Ri=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),zi=e=>[[e.x-wi,e.y-wi],[e.x+e.width+wi,e.y-wi],[e.x-wi,e.y+e.height+wi],[e.x+e.width+wi,e.y+e.height+wi]],Bi=(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 Vi(e,t,n){let r=[e,t,...n.flatMap(zi).filter(e=>!n.some(t=>Bi(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]+Ri(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>Li(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 Hi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>Li(n,i,e))?[n]:(Vi(n,i,t)??[n,i]).slice(0,-1)})}function Ui(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 Wi(e,t,n){let r=Math.min(n/Math.max(Ri(e,t),.01),.25);return[Ti(e[0]+(t[0]-e[0])*r),Ti(e[1]+(t[1]-e[1])*r)]}function Gi(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&&Mi([Di(n[e-1],n[e]),...ji(Di(n[e-1],n[e]),n[e],Di(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>Li(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Wi(t,n[i-1],r),t,Wi(t,n[i+1],r)]:[t])}return n}function Ki(e,t){return Ui(Gi(Hi(e,t),t))}function qi(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 Ji(e,t,n,r=[]){let i=qi({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 Yi(e,t=!0){let n=new Be.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);Wr(n);let r=e.nodes.map(e=>{let{x:t,y:r}=n.node(e.id);return{id:e.id,parent:null,x:Ti(t-e.width/2),y:Ti(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})=>[Ti(e),Ti(t)]),o=r.filter(e=>e.id!==i.source&&e.id!==i.target);return{...i,points:t?Ki(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Ji(r,i,e.margin)}}var Xi=`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}`,Zi={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}`},Qi=e=>e.replace(/[&<>"]/gu,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]);function $i(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${Qi(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${Qi(t)}</text>`).join(``)}function ea(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})">${$i(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="${ki(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">${Qi(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries(Zi).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>${Xi}${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,D as n,S as r,T as i,_ as a,b as o,c as s,g as c,h as l,k as u,l as d,n as f,o as p,p as m,v as h,x as g,y as _}from"./index-B86aPJ2i.js";import{C as v,S as y,T as b,_ as x,b as S,i as C,n as w,r as T,t as E,v as D,w as O,x as k,y as A}from"./src-C_gRsKqw.js";import{t as j}from"./value-CHmTzbgv.js";var M=e=>()=>e;function N(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}})}N.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function P(e){return!e.ctrlKey&&!e.button}function ee(){return this.parentNode}function te(e,t){return t??{x:e.x,y:e.y}}function ne(){return navigator.maxTouchPoints||`ontouchstart`in this}function F(){var e=P,t=ee,n=te,r=ne,i={},a=b(`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`,_,S).on(`touchend.drag touchcancel.drag`,C).style(`touch-action`,`none`).style(`-webkit-tap-highlight-color`,`rgba(0,0,0,0)`)}function p(n,r){if(!u&&e.call(this,n,r)){var i=w(this,t.call(this,n,r),n,r,`mouse`);i&&(O(n.view).on(`mousemove.drag`,m,k).on(`mouseup.drag`,h,k),x(n.view),y(n),l=!1,s=n.clientX,c=n.clientY,i(`start`,n))}}function m(e){if(A(e),!l){var t=e.clientX-s,n=e.clientY-c;l=t*t+n*n>d}i.mouse(`drag`,e)}function h(e){O(e.view).on(`mousemove.drag mouseup.drag`,null),D(e.view,l),A(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]))&&(y(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])&&(A(e),a(`drag`,e,t[r]))}function C(e){var t=e.changedTouches,n=t.length,r,a;for(u&&clearTimeout(u),u=setTimeout(function(){u=null},500),r=0;r<n;++r)(a=i[t[r].identifier])&&(y(e),a(`end`,e,t[r]))}function w(e,t,r,s,c,l){var u=a.copy(),d=v(l||r,t),p,m,h;if((h=n.call(e,new N(`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=v(l||a,t),_=o}u.call(r,e,new N(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:M(!!t),f):e},f.container=function(e){return arguments.length?(t=typeof e==`function`?e:M(e),f):t},f.subject=function(e){return arguments.length?(n=typeof e==`function`?e:M(e),f):n},f.touchable=function(e){return arguments.length?(r=typeof e==`function`?e:M(!!e),f):r},f.on=function(){var e=a.on.apply(a,arguments);return e===a?f:e},f.clickDistance=function(e){return arguments.length?(d=(e=+e)*e,f):Math.sqrt(d)},f}var I=e(t(),1);function L(e){return e.kind===`group`}var re=/^capability\.[a-z0-9-]+(\.[a-z0-9-]+)+$/,ie=/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/,ae=[`accepted`,`acknowledged`,`deferred`,`resolved`,`rejected`,`waived`],R=e=>typeof e==`string`,z=e=>typeof e==`number`&&Number.isSafeInteger(e)&&e>=0,oe=e=>z(e)&&e>0,se=e=>typeof e==`boolean`,ce=e=>t=>R(t)&&e.test(t),B=(...e)=>t=>e.includes(t),le=e=>t=>t===null||e(t),V=e=>t=>Array.isArray(t)&&t.every(e),H=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]))},ue=e=>t=>R(t)&&t.length>0&&t.length<=e&&t===t.trim()&&!/[\x00-\x1f\x7f]/u.test(t),de=e=>!e||typeof e!=`object`||Array.isArray(e)?!1:Object.entries(e).every(([e,t])=>ue(128)(e)&&(t===null||typeof t==`number`&&Number.isFinite(t))),fe=ce(/^[0-9a-f]{64}$/),pe=ce(ie),me=ce(re),he=ce(/^recommendation\.[0-9a-f]{16}$/u),ge=ce(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{1,9})?(?:Z|[+-]\d{2}:\d{2})$/u),_e=e=>R(e)&&!e.startsWith(`/`)&&!/^[A-Za-z]:/.test(e)&&!/[\\\x00-\x1f\x7f]/.test(e)&&e.split(`/`).every(e=>e!==``&&e!==`.`&&e!==`..`),ve=H({model_valid:B(`valid`,`invalid`,`unknown`),generated_summary:B(`fresh`,`stale`,`unknown`),section3:B(`present`,`pending`)}),ye=H({id:R,from:R,to:R,label:R,evidence:H({entrypointId:R,sourceSymbol:R,sinkId:R})}),be=e=>H({id:R,capabilityId:me,name:R,applicability:B(`not-applicable`),rationale:R})(e)||H({id:R,capabilityId:me,name:R,applicability:B(`required`),participants:V(H({id:R,nodeId:R})),steps:V(ye),outcomes:V(H({id:R,kind:B(`success`,`error`),label:R,steps:V(ye),terminal:H({participant:R,label:R})}))})(e),xe=e=>typeof e==`string`&&e.length>0&&e!==`group`,Se=H({include:V(R),exclude:V(R)}),Ce=e=>H({id:R,kind:xe,name:R,role:B(`center`,`child`,`caller`,`callee`)})(e)||H({id:R,kind:B(`group`),role:B(`caller`,`callee`),count:oe,members:V(H({id:R,name:R}))})(e),we=H({schema_version:B(`repo-harness.architecture-modules.v1`),commit:pe,modules:V(H({id:me,domain:R,name:R,status:R,components:z,state:ve}))}),Te=H({schema_version:B(`repo-harness.architecture-module.v1`),commit:pe,module:H({id:me,name:R,status:R,summary:R,responsibilities:V(R),notes:V(R),source:Se,verification:V(R),entrypoints:V(H({id:R,path:_e,symbols:V(H({name:R,sinks:V(H({id:R,path:_e,symbol:R}))}))})),components:V(H({id:R,kind:xe,name:R,summary:R,source:Se}))}),graph:H({center:me,nodes:V(Ce),edges:V(H({source:R,target:R,intent:R,relation_kind:R,direction:B(`directed`)}))}),flows:V(be),section3:le(R),linked_docs:V(H({path:_e,kind:B(`contract`,`plan`),status:le(R)})),state:ve}),Ee=H({schema_version:B(`repo-harness.module-review-prompt.v1`),prompt_version:R,package_version:R,repository_id:ce(/^repo_[0-9a-f]{16}$/),capability_id:me,commit:pe,mode:B(`module`,`diff`),base:le(pe),head:le(pe),worktree_dirty_paths:V(_e),dirty_content_sha256:le(fe),model_sha256:fe,doc_sha256:le(fe),sources:V(H({path:_e,sha256:fe,bytes:z,class:B(`required`,`optional`),disposition:B(`included`,`omitted`,`chunked`)})),budget:H({input_cap_bytes:oe,used_bytes:z,incomplete:se,omitted_sections:V(R)}),shard:H({index:oe,count:oe,bytes:z}),full_prompt_sha256:fe,prompt:R,digest:fe}),De=H({accepted:z,acknowledged:z,deferred:z,resolved:z,rejected:z,waived:z}),Oe=H({recommendation_id:he,category:B(`structural_observation`,`refactor_proposal`),kind:le(B(..._)),subject:ue(512),affected_node_ids:V(ue(256)),status:B(...h),metrics:le(de),reason:ue(1024),decided_at:ge,head_sha:pe,cli_verify_command:ue(128)}),ke=H({schema_version:B(`repo-harness.architecture-refactor.v1`),adopted:se,counts:De,decisions:V(Oe)});function Ae(e){return`rh arch refactor verify ${e} --json`}function je(e,t){let n=ae.indexOf(e.status)-ae.indexOf(t.status);return n===0?e.recommendation_id<t.recommendation_id?-1:+(e.recommendation_id>t.recommendation_id):n}function Me(e){if(!we(e))throw Error(`architecture_module_index_invalid`);return e}function Ne(e){if(!Te(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=>L(e)&&e.count!==e.members.length))throw Error(`architecture_module_detail_invalid`);return t}function Pe(e){if(!Ee(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 Fe(e){if(!ke(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!==Ae(r.recommendation_id)||r.affected_node_ids.some((e,t)=>t>0&&e<=r.affected_node_ids[t-1])||e>0&&je(t.decisions[e-1],r)>=0)throw Error(`architecture_refactor_decisions_invalid`)}for(let e of ae)if(t.counts[e]!==t.decisions.filter(t=>t.status===e).length)throw Error(`architecture_refactor_decisions_invalid`);return t}var Ie=Object.defineProperty,Le=(e,t,n)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Re=(e,t)=>{for(var n in t)Ie(e,n,{get:t[n],enumerable:!0})},ze=(e,t,n)=>Le(e,typeof t==`symbol`?t:t+``,n),Be={};Re(Be,{Graph:()=>Tt,alg:()=>$e});var Ve=Object.defineProperty,He=(e,t)=>{for(var n in t)Ve(e,n,{get:t[n],enumerable:!0})},Ue=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=Ke(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=qe(this._isDirected,i,a,o);return i=u.v,a=u.w,Object.freeze(u),this._edgeObjs[l]=u,We(this._preds[a],i),We(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?Je(this._isDirected,e):Ke(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?Je(this._isDirected,e):Ke(this._isDirected,e,t,n))in this._edgeLabels}removeEdge(e,t,n){let r=arguments.length===1?Je(this._isDirected,e):Ke(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],Ge(this._preds[t],e),Ge(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 We(e,t){e[t]?e[t]++:e[t]=1}function Ge(e,t){e[t]!==void 0&&!--e[t]&&delete e[t]}function Ke(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 qe(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 Je(e,t){return Ke(e,t.v,t.w,t.name)}He({},{read:()=>Qe,write:()=>Ye});function Ye(e){let t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:Xe(e),edges:Ze(e)},n=e.graph();return n!==void 0&&(t.value=structuredClone(n)),t}function Xe(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 Ze(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 Qe(e){let t=new Ue(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 $e={};He($e,{CycleException:()=>mt,bellmanFord:()=>tt,components:()=>rt,dijkstra:()=>ot,dijkstraAll:()=>ct,findCycles:()=>ut,floydWarshall:()=>ft,isAcyclic:()=>gt,postorder:()=>bt,preorder:()=>xt,prim:()=>St,shortestPaths:()=>Ct,tarjan:()=>lt,topsort:()=>ht});var et=()=>1;function tt(e,t,n,r){return nt(e,String(t),n||et,r||function(t){return e.outEdges(t)??[]})}function nt(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 rt(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 it=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}},at=()=>1;function ot(e,t,n,r){return st(e,String(t),n||at,r||function(t){return e.outEdges(t)??[]})}function st(e,t,n,r){let i={},a=new it,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 ct(e,t,n){return e.nodes().reduce(function(r,i){return r[i]=ot(e,i,t,n),r},{})}function lt(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 ut(e){return lt(e).filter(function(t){let n=t[0];return n?t.length>1||t.length===1&&(e.outEdges(n,n)??[]).length>0:!1})}var dt=()=>1;function ft(e,t,n){return pt(e,t||dt,n||function(t){return e.outEdges(t)??[]})}function pt(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 mt=class extends Error{constructor(e){super(e),this.name=`CycleException`}};function ht(e){let t={},n={},r=[];function i(a){var o;if(a in n)throw new mt;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 mt;return r}function gt(e){try{ht(e)}catch(e){if(e instanceof mt)return!1;throw e}return!0}function _t(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=vt(e,t,n===`post`,o,a,r,i)}),i}function vt(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=vt(e,t,n,r,i,a,o)}),n&&(o=a(o,t))),o}function yt(e,t,n){return _t(e,t,n,function(e,t){return e.push(t),e},[])}function bt(e,t){return yt(e,t,`post`)}function xt(e,t){return yt(e,t,`pre`)}function St(e,t){var n;let r=new Ue,i={},a=new it,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 Ct(e,t,n,r){return wt(e,t,n,r??(t=>e.outEdges(t)??[]))}function wt(e,t,n,r){if(n===void 0)return ot(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 tt(e,t,n,r)}return ot(e,t,n,r)}var Tt=Ue;function Et(e,t,n,r){let i=r;for(;e.hasNode(i);)i=Vt(r);return n.dummy=t,e.setNode(i,n),i}function Dt(e){let t=new Tt().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 Ot(e){let t=new Tt({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 kt(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 At(e){let t=Ht(Lt(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 jt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=It(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function Mt(e){let t=e.nodes().map(t=>e.node(t).rank).filter(e=>e!==void 0),n=It(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 Nt(e,t,n,r){let i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),Et(e,`border`,i,t)}function Pt(e,t=Ft){let n=[];for(let r=0;r<e.length;r+=t){let i=e.slice(r,r+t);n.push(i)}return n}var Ft=65535;function It(e,t){return t.length>Ft?e(...Pt(t).map(t=>e(...t))):e(...t)}function Lt(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return It(Math.max,t)}function Rt(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function zt(e,t){return t()}var Bt=0;function Vt(e){return e+(``+ ++Bt)}function Ht(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 Ut(e,t){let n={};for(let r of t)e[r]!==void 0&&(n[r]=e[r]);return n}function Wt(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 Gt(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}var Kt=`\0`;function qt(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 Jt=class{constructor(){ze(this,`_sentinel`);let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return Yt(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&Yt(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,Xt)),n=n._prev;return`[`+e.join(`, `)+`]`}};function Yt(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function Xt(e,t){if(e!==`_next`&&e!==`_prev`)return t}var Zt=Jt,Qt=()=>1;function $t(e,t){if(e.nodeCount()<=1)return[];let n=nn(e,t||Qt);return en(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w)||[])}function en(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)tn(e,t,n,o);for(;o=i.dequeue();)tn(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(tn(e,t,n,o,!0)||[]);break}}}return r}function tn(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,rn(t,n,s)}),(e.outEdges(r.v)||[]).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,rn(t,n,o)}),e.removeNode(r.v),o}function nn(e,t){let n=new Tt,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=an(i+r+3).map(()=>new Zt),o=r+1;return n.nodes().forEach(e=>{rn(a,o,n.node(e))}),{graph:n,buckets:a,zeroIdx:o}}function rn(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 an(e){let t=[];for(let n=0;n<e;n++)t.push(n);return t}function on(e,t){(e.graph().acyclicer===`greedy`?$t(e,n(e)):sn(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,Vt(`rev`))});function n(e){return t=>e.edge(t).weight}}function sn(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&&ln(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 cn(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 ln(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 un(e){e.graph().dummyChains=[],e.edges().forEach(t=>dn(e,t))}function dn(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=Et(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 fn(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 pn(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=It(Math.min,o);return s===1/0&&(s=0),i.rank=s}e.sources().forEach(n)}function mn(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}var hn=gn;function gn(e){let t=new Tt({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(;_n(t,e)<i&&(a=vn(t,e),a);)o=t.hasNode(a.v)?mn(e,a):-mn(e,a),yn(t,e,o);return t}function _n(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)&&!mn(t,i)&&(e.setNode(o,{}),e.setEdge(r,o,{}),n(o))})}return e.nodes().forEach(n),e.nodeCount()}function vn(e,t){return t.edges().reduce((n,r)=>{let i=1/0;return e.hasNode(r.v)!==e.hasNode(r.w)&&(i=mn(t,r)),i<n[0]?[i,r]:n},[1/0,null])[1]}function yn(e,t,n){e.nodes().forEach(e=>t.node(e).rank+=n)}var{preorder:bn,postorder:xn}=$e,Sn=Cn;Cn.initLowLimValues=Dn,Cn.initCutValues=wn,Cn.calcCutValue=En,Cn.leaveEdge=kn,Cn.enterEdge=An,Cn.exchangeEdges=jn;function Cn(e){e=Dt(e),pn(e);let t=hn(e);Dn(t),wn(t,e);let n,r;for(;n=kn(t);)r=An(t,e,n),jn(t,e,n,r)}function wn(e,t){let n=xn(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>Tn(e,t,n))}function Tn(e,t,n){let r=e.node(n).parent,i=e.edge(n,r);i.cutvalue=En(e,t,n)}function En(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,Nn(e,n,c)){let t=e.edge(n,c).cutvalue;o+=r?-t:t}}}),o}function Dn(e,t){arguments.length<2&&(t=e.nodes()[0]),On(e,{},1,t)}function On(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=On(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function kn(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function An(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===Pn(e,e.node(t.v),s)&&c!==Pn(e,e.node(t.w),s)).reduce((e,n)=>mn(t,n)<mn(t,e)?n:e)}function jn(e,t,n,r){let i=n.v,a=n.w;e.removeEdge(i,a),e.setEdge(r.v,r.w,{}),Dn(e),wn(e,t),Mn(e,t)}function Mn(e,t){let n=e.nodes().find(t=>!e.node(t).parent);if(!n)return;let r=bn(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 Nn(e,t,n){return e.hasEdge(t,n)}function Pn(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var Fn=In;function In(e){let t=e.graph().ranker;if(typeof t==`function`)return t(e);switch(t){case`network-simplex`:zn(e);break;case`tight-tree`:Rn(e);break;case`longest-path`:Ln(e);break;case`none`:break;default:zn(e)}}var Ln=pn;function Rn(e){pn(e),hn(e)}function zn(e){Sn(e)}var Bn=Vn;function Vn(e){let t=Un(e),n=e.graph();Array.isArray(n.dummyChains)&&n.dummyChains.forEach(n=>{let r=e.node(n),i=r.edgeObj,a=Hn(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 Hn(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 Un(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(Kt).forEach(r),t}function Wn(e){let t=Et(e,`root`,{},`_root`),n=Kn(e),r=Object.values(n),i=It(Math.max,r)-1,a=2*i+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=a);let o=qn(e)+1;e.children(Kt).forEach(r=>{Gn(e,t,a,o,i,n,r)}),e.graph().nodeRankFactor=a}function Gn(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=Nt(e,`_bt`),l=Nt(e,`_bb`),u=e.node(o);e.setParent(c,o),u.borderTop=c,e.setParent(l,o),u.borderBottom=l,s.forEach(s=>{Gn(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 Kn(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(Kt).forEach(e=>n(e,1)),t}function qn(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function Jn(e){let t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}var Yn=Xn;function Xn(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)Zn(e,`borderLeft`,`_bl`,n,i,t),Zn(e,`borderRight`,`_br`,n,i,t)}}e.children(Kt).forEach(t)}function Zn(e,t,n,r,i,a){let o={width:0,height:0,rank:a,borderType:t},s=i[t][a-1],c=Et(e,`border`,o,n);i[t][a]=c,e.setParent(c,r),s&&e.setEdge(s,c,{weight:1})}function Qn(e){let t=e.graph().rankdir?.toLowerCase();(t===`lr`||t===`rl`)&&er(e)}function $n(e){let t=e.graph().rankdir?.toLowerCase();(t===`bt`||t===`rl`)&&nr(e),(t===`lr`||t===`rl`)&&(ir(e),er(e))}function er(e){e.nodes().forEach(t=>tr(e.node(t))),e.edges().forEach(t=>tr(e.edge(t)))}function tr(e){let t=e.width;e.width=e.height,e.height=t}function nr(e){e.nodes().forEach(t=>rr(e.node(t))),e.edges().forEach(t=>{var n;let r=e.edge(t);(n=r.points)==null||n.forEach(rr),Object.hasOwn(r,`y`)&&rr(r)})}function rr(e){e.y=-e.y}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,`x`)&&ar(r)})}function ar(e){let t=e.x;e.x=e.y,e.y=t}function or(e,t=null){let n={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=Ht(It(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 qt(t,e.node(n),e.node(r))}return a}function sr(e,t){let n=0;for(let r=1;r<t.length;++r)n+=cr(e,t[r-1],t[r]);return n}function cr(e,t,n){let r=Gt(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 lr(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 ur(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))}),dr(Object.values(n).filter(e=>!e.indegree))}function dr(e){let t=[];function n(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&fr(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=>Ut(e,[`vs`,`i`,`barycenter`,`weight`]))}function fr(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 pr(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=Rt(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(hr(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=mr(f,d,h),u.forEach(e=>{h+=e.vs.length,f.push(e.vs),p+=e.barycenter*e.weight,m+=e.weight,h=mr(f,d,h)});let g={vs:f.flat(1)};return m&&(g.barycenter=p/m,g.weight=m),g}function mr(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 hr(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=qt(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 gr(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=lr(e,l);m.forEach(t=>{if(e.children(t.v).length){let{result:r}=gr(e,t.v,n,s,c);p[t.v]=r,Object.hasOwn(r,`barycenter`)&&vr(t,r)}});let h=ur(m,n);_r(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=pr(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 _r(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function vr(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 yr(e,t,n,r){r||=e.nodes();let i=br(e),a=new Tt({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 br(e){let t;for(;e.hasNode(t=Vt(`_root`)););return t}function xr(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 Sr(e,t={},n=null){if(typeof t.customOrder==`function`){t.customOrder(e,Sr);return}let r=Lt(e),i=Cr(e,Ht(1,r+1),`inEdges`),a=Cr(e,Ht(r-1,-1,-1),`outEdges`),o=or(e,n);if(Tr(e,o),t.disableOptimalOrderHeuristic)return;let s=1/0,c,l=t.constraints||[];for(let t=0,r=0;r<4;++t,++r){wr(t%2?i:a,t%4>=2,l,n),o=At(e);let u=sr(e,o);u<s?(r=0,c=Object.assign({},o),s=u):u===s&&(c=structuredClone(o))}Tr(e,c)}function Cr(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 yr(e,t,n,r.get(t)||[])})}function wr(e,t,n,r){let i=!0,a=new Tt;e.forEach(function(e){n.forEach(e=>a.setEdge(e.left,e.right));let o=e.graph().root,{result:s,usedBias:c}=gr(e,o,a,r,i);t&&c&&(i=!i),s.vs.forEach((t,n)=>e.node(t).order=n),xr(e,a,s.vs)})}function Tr(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}function Er(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=Or(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)&&kr(n,r,t)})}),a=c+1,i=u)}),r}return t.length&&t.reduce(r),n}function Dr(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){Ht(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)&&kr(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 Or(e,t){if(e.node(t).dummy){let n=e.predecessors(t);if(n)return n.find(t=>e.node(t).dummy)}}function kr(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 Ar(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 jr(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)||Br(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=>Br(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&&!Ar(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 Mr(e,t,n,r,i=!1){let a={},o=Nr(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 Nr(e,t,n,r){let i=new Tt,a=e.graph(),o=Rr(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 Pr(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=zr(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 Fr(e,t){let n=Object.values(t),r=It(Math.min,n),i=It(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-It(Math.min,c);a!==`l`&&(l=i-It(Math.max,c)),l&&(e[o]=Wt(s,e=>e+l))})})}function Ir(e,t=void 0){let n=e.ul;return n?Wt(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 Lr(e,t){let n=At(e),r=Object.assign(Er(e,n),Dr(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=jr(e,a,r,t=>(o===`u`?e.predecessors(t):e.successors(t))||[],t),c=Mr(e,a,s.root,s.align,n===`r`);n===`r`&&(c=Wt(c,e=>-e)),i[o+n]=c})}),Fr(i,Pr(e,i)),Ir(i,e.graph().align)}function Rr(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 zr(e,t){return e.node(t).width}function Br(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 Vr(e,t){e=Ot(e),Hr(e),Object.entries(Lr(e,t)).forEach(([t,n])=>e.node(t).x=n)}function Hr(e){let t=At(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 Ur=new WeakMap;function Wr(e,t={}){return Kr(e,zt,t),e}function Gr(e,t,n){let r=t;for(;r!==void 0;){let t=e.parent(r);if(t===n)return r;r=t}}function Kr(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 Tt({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=Gr(e,t.v,r),i=Gr(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)}))}}),Kr(o,t,n);let l=ii(o);Jr(l,t,n,null),Yr(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=ii(e),g=Jr(h,t,n,Ur.get(e)??null);Ur.set(e,g),Yr(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))}),qr(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}}),qr(e,i,a-s,o-c),delete n._dagreClusterSubgraph}})}function qr(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 Jr(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`,()=>ai(e)),t(` removeSelfEdges`,()=>mi(e)),t(` acyclic`,()=>on(e,s)),t(` nestingGraph.run`,()=>Wn(e)),t(` rank`,()=>Fn(Ot(e))),t(` injectEdgeLabelProxies`,()=>oi(e)),t(` removeEmptyRanks`,()=>Mt(e)),t(` nestingGraph.cleanup`,()=>Jn(e)),t(` normalizeRanks`,()=>jt(e)),t(` assignRankMinMax`,()=>si(e)),t(` removeEdgeLabelProxies`,()=>ci(e)),t(` normalize.run`,()=>un(e)),t(` parentDummyChains`,()=>Bn(e)),t(` addBorderSegments`,()=>Yn(e)),t(` order`,()=>Sr(e,n,c)),t(` insertSelfEdges`,()=>hi(e)),t(` adjustCoordinateSystem`,()=>Qn(e)),t(` position`,()=>Vr(e,n.corePath)),t(` positionSelfEdges`,()=>gi(e));let l=JSON.parse(JSON.stringify(e._nodes));return t(` removeBorderNodes`,()=>pi(e)),t(` normalize.undo`,()=>fn(e)),t(` fixupEdgeLabelCoords`,()=>di(e)),t(` undoCoordinateSystem`,()=>$n(e)),t(` translateGraph`,()=>li(e)),t(` assignNodeIntersects`,()=>ui(e)),t(` reversePoints`,()=>fi(e)),t(` acyclic.undo`,()=>cn(e)),{graph:e,rawNodes:l}}function Yr(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 Xr=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],Zr={ranksep:50,edgesep:20,nodesep:50,rankdir:`TB`,rankalign:`center`},Qr=[`acyclicer`,`ranker`,`rankdir`,`align`,`rankalign`],$r=[`width`,`height`,`rank`],ei={width:0,height:0},ti=[`minlen`,`weight`,`width`,`height`,`labeloffset`],ni={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},ri=[`labelpos`];function ii(e){let t=new Tt({multigraph:!0,compound:!0}),n=vi(e.graph());return t.setGraph(Object.assign({},Zr,_i(n,Xr),Ut(n,Qr))),e.nodes().forEach(n=>{let r=_i(vi(e.node(n)),$r);Object.keys(ei).forEach(e=>{r[e]===void 0&&(r[e]=ei[e])}),t.setNode(n,r);let i=e.parent(n);i!==void 0&&t.setParent(n,i)}),e.edges().forEach(n=>{let r=vi(e.edge(n));t.setEdge(n,Object.assign({},ni,_i(r,ti),Ut(r,ri)))}),t}function ai(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 oi(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v);Et(e,`edge-proxy`,{rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t},`_ep`)}})}function si(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 ci(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 li(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 ui(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(kt(r,a)),n.points.push(kt(i,o))})}function di(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 fi(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function pi(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 mi(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 hi(e){At(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=>{Et(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 gi(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 _i(e,t){return Wt(Ut(e,t),Number)}function vi(e){let t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}var yi=7,bi=16,xi=1.5,Si=new Set([`M`,`W`,`m`,`w`,`@`,`%`]);function Ci(e,t){let n=0;for(let r of e)n+=r.charCodeAt(0)>=128||t===`title`&&Si.has(r)?2:1;return Math.ceil(n*yi*(t===`title`?xi:1))}var wi=12,Ti=e=>Math.round(e*10)/10,Ei=e=>Math.round(e*100)/100,Di=(e,t)=>[Ei((e[0]+t[0])/2),Ei((e[1]+t[1])/2)],Oi=([e,t])=>`${e} ${t}`;function ki(e){let t=e.length-1;if(t===1)return`M${Oi(e[0])} L${Oi(e[1])}`;let n=[`M${Oi(e[0])}`,`L${Oi(Di(e[0],e[1]))}`];for(let r=1;r<t;r++)n.push(`Q${Oi(e[r])} ${Oi(Di(e[r],e[r+1]))}`);return n.push(`L${Oi(e[t])}`),n.join(` `)}var Ai=16;function ji(e,t,n){return Array.from({length:Ai},(r,i)=>{let a=(i+1)/Ai,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 Mi=e=>e.slice(1).map((t,n)=>[e[n],t]);function Ni(e,t,n){let r=Ci(e,`label`);return{text:e,x:Ti(t[0]-r/2),y:Ti(t[1]-bi/2),width:r,height:bi,route:n}}function Pi(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[Ti(t[0]+(a[0]-t[0])*n/i),Ti(t[1]+(a[1]-t[1])*n/i)]}n-=i}return e[e.length-1]}function Fi(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[Ti(n),Ti(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[Ti(n+i*o),Ti(r+a*o)]}function Ii(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 Li(e,t,n){let r=Ii(e,t,n,-.5);return r!==null&&(r[1]-r[0])*Math.hypot(t[0]-e[0],t[1]-e[1])>.01}var Ri=(e,t)=>Math.hypot(e[0]-t[0],e[1]-t[1]),zi=e=>[[e.x-wi,e.y-wi],[e.x+e.width+wi,e.y-wi],[e.x-wi,e.y+e.height+wi],[e.x+e.width+wi,e.y+e.height+wi]],Bi=(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 Vi(e,t,n){let r=[e,t,...n.flatMap(zi).filter(e=>!n.some(t=>Bi(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]+Ri(r[e],s);!o[t]&&c<i[t]&&!n.some(t=>Li(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 Hi(e,t){return e.flatMap((n,r)=>{let i=e[r+1];return i===void 0||!t.some(e=>Li(n,i,e))?[n]:(Vi(n,i,t)??[n,i]).slice(0,-1)})}function Ui(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 Wi(e,t,n){let r=Math.min(n/Math.max(Ri(e,t),.01),.25);return[Ti(e[0]+(t[0]-e[0])*r),Ti(e[1]+(t[1]-e[1])*r)]}function Gi(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&&Mi([Di(n[e-1],n[e]),...ji(Di(n[e-1],n[e]),n[e],Di(n[e],n[e+1]))]).some(([e,n])=>t.some(t=>Li(e,n,t)));if(!n.some((t,n)=>e(n)))break;n=n.flatMap((t,i)=>e(i)?[Wi(t,n[i-1],r),t,Wi(t,n[i+1],r)]:[t])}return n}function Ki(e,t){return Ui(Gi(Hi(e,t),t))}function qi(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 Ji(e,t,n,r=[]){let i=qi({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 Yi(e,t=!0){let n=new Be.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);Wr(n);let r=e.nodes.map(e=>{let{x:t,y:r}=n.node(e.id);return{id:e.id,parent:null,x:Ti(t-e.width/2),y:Ti(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})=>[Ti(e),Ti(t)]),o=r.filter(e=>e.id!==i.source&&e.id!==i.target);return{...i,points:t?Ki(a,o):a}});return{boxes:r,routes:i,labels:[],extent:Ji(r,i,e.margin)}}var Xi=`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}`,Zi={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}`},Qi=e=>e.replace(/[&<>"]/gu,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`})[e]);function $i(e,t){return e.height<32?t.length===0?``:`<text class="title" x="${e.x+8}" y="${e.y+e.height/2+4}">${Qi(t[0])}</text>`:t.map((t,n)=>`<text class="${n===0?`title`:`detail`}" x="${e.x+12}" y="${e.y+20+n*16}">${Qi(t)}</text>`).join(``)}function ea(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})">${$i(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="${ki(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">${Qi(t.text)}</text>`);let a=new Set(e.boxes.flatMap(e=>e.kind.split(` `))),o=Object.entries(Zi).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>${Xi}${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 ta=12,na=12,ra=24,ia=64,aa=24,oa=`removed`,sa=new Set([`spawns`,`runs-in`,`deployed-on`,`mounts`,`reads`,`writes`,`publishes`,`subscribes`]);function ca(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 la(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=ca(o.map(e=>i(e.id)),na);o.forEach((t,r)=>n.set(t.id,{x:ta+e.cells[r].x,y:36+e.cells[r].y})),s={width:Math.max(160,e.width)+24,height:36+e.height+ta}}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=Yi({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===oa,width:t.kind===`relation`?1.5:2,weight:t.relations.length})),nodesep:ra,ranksep:ia,margin:aa}),f=c.filter(e=>!l.has(e.id)),p=d.boxes.length===0?aa:Math.max(...d.boxes.map(e=>e.y+e.height))+ia,m=f.map(e=>i(e.id)),h=ca(m,ra).cells.map((e,t)=>({id:f[t].id,parent:null,x:aa+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:Ji(_,y,aa)},relations:new Map([...s].map(([e,t])=>[e,t.relations]))}}var U=n();function W(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=W(e[n]))!==``&&(t+=(t&&` `)+r);else for(let n in e)e[n]&&(t+=(t&&` `)+n);return t}var ua={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.`},da=[[-1/0,-1/0],[1/0,1/0]],fa=[`Enter`,` `,`Escape`],pa={"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`},ma;(function(e){e.Strict=`strict`,e.Loose=`loose`})(ma||={});var ha;(function(e){e.Free=`free`,e.Vertical=`vertical`,e.Horizontal=`horizontal`})(ha||={});var ga;(function(e){e.Partial=`partial`,e.Full=`full`})(ga||={});var _a={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null},va;(function(e){e.Bezier=`default`,e.Straight=`straight`,e.Step=`step`,e.SmoothStep=`smoothstep`,e.SimpleBezier=`simplebezier`})(va||={});var ya;(function(e){e.Arrow=`arrow`,e.ArrowClosed=`arrowclosed`})(ya||={});var G;(function(e){e.Left=`left`,e.Top=`top`,e.Right=`right`,e.Bottom=`bottom`})(G||={});var ba={[G.Left]:G.Right,[G.Right]:G.Left,[G.Top]:G.Bottom,[G.Bottom]:G.Top},xa=e=>!!e&&typeof e==`object`&&`id`in e&&`source`in e&&`target`in e,Sa=e=>!!e&&typeof e==`object`&&`id`in e&&`position`in e&&!(`source`in e)&&!(`target`in e),Ca=e=>!!e&&typeof e==`object`&&`id`in e&&`internals`in e&&!(`source`in e)&&!(`target`in e),wa=(e,t=[0,0])=>{let{width:n,height:r}=io(e),i=e.origin??t,a=n*i[0],o=r*i[1];return{x:e.position.x-a,y:e.position.y-o}},Ta=(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):Ca(r)?r:t.nodeLookup.get(r.id)),a?(n=!0,Ra(e,Ha(a,t.nodeOrigin))):e},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return n?Ba(r):{x:0,y:0,width:0,height:0}},Ea=(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=Ra(n,Ha(e)),r=!0)}),r?Ba(n):{x:0,y:0,width:0,height:0}},Da=(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=Wa(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},Oa=(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 ka(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}=io(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 Aa({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:a},o){if(e.size===0)return!0;let s=to(Ea(ka(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 ja({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`,ua.error005());else{let{width:e,height:t}=io(s);e&&t&&(d=[[c,l],[c+e,l+t]])}}else s&&ro(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=ro(d)?Pa(t,d,o.measured):t;return(o.measured.width===void 0||o.measured.height===void 0)&&a?.(`015`,ua.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 Ma({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=Oa(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 Na=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Pa=(e={x:0,y:0},t,n)=>({x:Na(e.x,t[0][0],t[1][0]-(n?.width??0)),y:Na(e.y,t[0][1],t[1][1]-(n?.height??0))});function Fa(e,t,n){let{width:r,height:i}=io(n),{x:a,y:o}=n.internals.positionAbsolute;return Pa(e,[[a,o],[a+r,o+i]],t)}var Ia=(e,t,n)=>e<t?Na(Math.abs(e-t),1,t)/t:e>n?-Na(Math.abs(e-n),1,t)/t:0,La=(e,t,n=15,r=40)=>[Ia(e.x,r,t.width-r)*n,Ia(e.y,r,t.height-r)*n],Ra=(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)}),za=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ba=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Va=(e,t=[0,0])=>{let{x:n,y:r}=Ca(e)?e.internals.positionAbsolute:wa(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}},Ha=(e,t=[0,0])=>{let{x:n,y:r}=Ca(e)?e.internals.positionAbsolute:wa(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)}},Ua=(e,t)=>Ba(Ra(za(e),za(t))),Wa=(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)},Ga=(e,t)=>Wa(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),Ka=e=>qa(e.width)&&qa(e.height)&&qa(e.x)&&qa(e.y),qa=e=>!isNaN(e)&&isFinite(e),Ja=(e,t)=>(e,t)=>{},Ya=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Xa=({x:e,y:t},[n,r,i],a=!1,o=[1,1])=>{let s={x:(e-n)/i,y:(t-r)/i};return a?Ya(s,o):s},Za=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Qa(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 $a(e,t,n){if(typeof e==`string`||typeof e==`number`){let r=Qa(e,n),i=Qa(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e==`object`){let r=Qa(e.top??e.y??0,n),i=Qa(e.bottom??e.y??0,n),a=Qa(e.left??e.x??0,t),o=Qa(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 eo(e,t,n,r,i,a){let{x:o,y:s}=Za(e,[t,n,r]),{x:c,y:l}=Za({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 to=(e,t,n,r,i,a)=>{let o=$a(a,t,n),s=(t-o.x)/e.width,c=(n-o.y)/e.height,l=Na(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=eo(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}},no=()=>typeof navigator<`u`&&navigator?.userAgent?.indexOf(`Mac`)>=0;function ro(e){return e!=null&&e!==`parent`}function io(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function ao(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function oo(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 so(e,t){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}function co(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function lo(e){return{...pa,...e||{}}}function uo(e){return e===null?null:e?`valid`:`invalid`}function fo(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){let{x:a,y:o}=vo(e),s=Xa({x:a-(i?.left??0),y:o-(i?.top??0)},r),{x:c,y:l}=n?Ya(s,t):s;return{xSnapped:c,ySnapped:l,...s}}var po=e=>({width:e.offsetWidth,height:e.offsetHeight}),mo=e=>e?.getRootNode?.()||window?.document,ho=[`INPUT`,`SELECT`,`TEXTAREA`];function go(e){let t=e.composedPath?.()?.[0]||e.target;return t?.nodeType===1?ho.includes(t.nodeName)||t.hasAttribute(`contenteditable`)||!!t.closest(`.nokey`):!1}var _o=e=>`clientX`in e,vo=(e,t)=>{let n=_o(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)}},yo=(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,...po(t)}})};function bo({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 xo(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function So({pos:e,x1:t,y1:n,x2:r,y2:i,c:a}){switch(e){case G.Left:return[t-xo(t-r,a),n];case G.Right:return[t+xo(r-t,a),n];case G.Top:return[t,n-xo(n-i,a)];case G.Bottom:return[t,n+xo(i-n,a)]}}function Co({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top,curvature:o=.25}){let[s,c]=So({pos:n,x1:e,y1:t,x2:r,y2:i,c:o}),[l,u]=So({pos:a,x1:r,y1:i,x2:e,y2:t,c:o}),[d,f,p,m]=bo({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 wo({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 To({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 Eo({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){let a=Ra(Ha(e),Ha(t));return a.x===a.x2&&(a.x2+=1),a.y===a.y2&&(a.y2+=1),Ga({x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]},Ba(a))>0}var Do=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||``}-${n}${r||``}`,Oo=(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)),ko=(e,t,n={})=>{if(!e.source||!e.target)return n.onError?.(`006`,ua.error006()),t;let r=n.getEdgeId||Do,i;return i=xa(e)?{...e}:{...e,id:r(e)},Oo(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function Ao({sourceX:e,sourceY:t,targetX:n,targetY:r}){let[i,a,o,s]=wo({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,a,o,s]}var jo={[G.Left]:{x:-1,y:0},[G.Right]:{x:1,y:0},[G.Top]:{x:0,y:-1},[G.Bottom]:{x:0,y:1}},Mo=({source:e,sourcePosition:t=G.Bottom,target:n})=>t===G.Left||t===G.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},No=(e,t)=>Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2),Po=(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 Fo({source:e,sourcePosition:t=G.Bottom,target:n,targetPosition:r=G.Top,center:i,offset:a,stepPosition:o}){let s=jo[t],c=jo[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=Mo({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]=wo({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&&Po(e,n,t)&&C.pop(),C.push(t)}return[C,h,g,y,b]}function Io(e,t,n,r){let i=Math.min(No(e,t)/2,No(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 Lo({sourceX:e,sourceY:t,sourcePosition:n=G.Bottom,targetX:r,targetY:i,targetPosition:a=G.Top,borderRadius:o=5,centerX:s,centerY:c,offset:l=20,stepPosition:u=.5}){let[d,f,p,m,h]=Fo({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+=Io(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 Ro(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function zo(e){let{sourceNode:t,targetNode:n}=e;if(!Ro(t)||!Ro(n))return null;let r=t.internals.handleBounds||Bo(t.handles),i=n.internals.handleBounds||Bo(n.handles),a=Ho(r?.source??[],e.sourceHandle),o=Ho(e.connectionMode===ma.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!a||!o)return e.onError?.(`008`,ua.error008(a?`target`:`source`,{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;let s=a?.position||G.Bottom,c=o?.position||G.Top,l=Vo(t,a,s),u=Vo(n,o,c);return{sourceX:l.x,sourceY:l.y,targetX:u.x,targetY:u.y,sourcePosition:s,targetPosition:c}}function Bo(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 Vo(e,t,n=G.Left,r=!1){let i=(t?.x??0)+e.internals.positionAbsolute.x,a=(t?.y??0)+e.internals.positionAbsolute.y,{width:o,height:s}=t??io(e);if(r)return{x:i+o/2,y:a+s/2};switch(t?.position??n){case G.Top:return{x:i+o/2,y:a};case G.Right:return{x:i+o,y:a+s/2};case G.Bottom:return{x:i+o/2,y:a+s};case G.Left:return{x:i,y:a+s/2}}}function Ho(e,t){return e&&(t?e.find(e=>e.id===t):e[0])||null}function Uo(e,t){return e?typeof e==`string`?e:`${t?`${t}__`:``}${Object.keys(e).sort().map(t=>`${t}=${e[t]}`).join(`&`)}`:``}function Wo(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=Uo(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 Go=1e3,Ko=10,qo={nodeOrigin:[0,0],nodeExtent:da,elevateNodesOnSelect:!0,zIndexMode:`basic`,defaults:{}},Jo={...qo,checkEquality:!0};function Yo(e,t){let n={...e};for(let e in t)t[e]!==void 0&&(n[e]=t[e]);return n}function Xo(e,t,n){let r=Yo(qo,n);for(let n of e.values())if(n.parentId)ts(n,e,t,r);else{let e=Pa(wa(n,r.nodeOrigin),ro(n.extent)?n.extent:r.nodeExtent,io(n));n.internals.positionAbsolute=e}}function Zo(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 Qo(e){return e===`manual`}function $o(e,t,n,r={}){let i=Yo(Jo,r),a={i:0},o=new Map(t),s=i?.elevateNodesOnSelect&&!Qo(i.zIndexMode)?Go: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=Pa(wa(u,i.nodeOrigin),ro(u.extent)?u.extent:i.nodeExtent,io(u));e={...i.defaults,...u,measured:{width:u.measured?.width,height:u.measured?.height},internals:{positionAbsolute:n,handleBounds:Zo(u,e),z:ns(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&&ts(e,t,n,r,a),l||=u.selected??!1}return{nodesInitialized:c,hasSelectedNodes:l}}function es(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 ts(e,t,n,r,i){let{elevateNodesOnSelect:a,nodeOrigin:o,nodeExtent:s,zIndexMode:c}=Yo(qo,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}es(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*Ko),i&&u.internals.rootParentIndex!==void 0&&(i.i=u.internals.rootParentIndex);let{x:d,y:f,z:p}=rs(e,u,o,s,a&&!Qo(c)?Go: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 ns(e,t,n){let r=qa(e.zIndex)?e.zIndex:0;return Qo(n)?r:r+(e.selected?t:0)}function rs(e,t,n,r,i,a){let{x:o,y:s}=t.internals.positionAbsolute,c=io(e),l=wa(e,n),u=ro(e.extent)?Pa(l,e.extent,c):l,d=Pa({x:o+u.x,y:s+u.y},r,c);e.extent===`parent`&&(d=Fa(d,c,t));let f=ns(e,i,a),p=t.internals.z??0;return{x:d.x,y:d.y,z:p>=f?p+1:f}}function is(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=Ua(a.get(n.parentId)?.expandedRect??Va(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=io(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 as(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=po(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=ro(e.extent)?e.extent:a,{positionAbsolute:h}=e.internals;if(e.parentId&&e.extent===`parent`){let n=t.get(e.parentId);n&&(h=Fa(h,s,n))}else m&&(h=Pa(h,m,s));let g={...e,measured:s,internals:{...e.internals,positionAbsolute:h,handleBounds:{source:yo(`source`,r.nodeElement,p,d,e.id),target:yo(`target`,r.nodeElement,p,d,e.id)}}};t.set(e.id,g),e.parentId&&ts(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:Va(g,i)}))}}if(f.length>0){let e=is(f,t,n,i);l.push(...e)}return{changes:l,updatedInternals:c}}async function os({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 ss(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 cs(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}`;ss(`source`,s,`${i}-${o}--${n}-${a}`,e,n,a),ss(`target`,s,c,e,i,o),t.set(r.id,r)}}function ls(e,t){if(!e.parentId)return!1;let n=t.get(e.parentId);return n?n.selected?!0:ls(n,t):!1}function us(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 ds(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||!ls(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 fs({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 ps({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=Ya(a,t);return{x:o.x-a.x,y:o.y-a.y}}function ms({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=O(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?za(Ea(s)):null,x=v&&l?ps({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)}:Ya(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}=ja({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]=fs({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]=La(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=fo(r.sourceEvent,{transform:l,snapGrid:f,snapToGrid:p,containerBounds:u});if(a=x,s=ds(i,c,x,b,v),s.size>0&&(n||h||!b&&g)){let[e,t]=fs({nodeId:b,dragItems:s,nodeLookup:i});n?.(r.sourceEvent,s,e,t),h?.(r.sourceEvent,e,t),b||g?.(r.sourceEvent,t)}}let T=F().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=fo(e.sourceEvent,{transform:i,snapGrid:o,snapToGrid:s,containerBounds:u}),l=vo(e.sourceEvent,u)}).on(`drag`,e=>{let{autoPanOnNodeDrag:n,transform:r,snapGrid:i,snapToGrid:o,nodeDragThreshold:f,nodeLookup:m}=t(),g=fo(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=vo(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=vo(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]=fs({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||!us(t,`.${g}`,v))&&(!_||us(t,_,v))});f.call(T)}function _(){f?.on(`.drag`,null)}return{update:g,destroy:_}}function hs(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())Ga(i,Va(e))>0&&r.push(e);return r}var gs=250;function _s(e,t,n,r){let i=[],a=1/0,o=hs(e,n,t+gs);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}=Vo(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 vs(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,...Vo(o,c,c.position,!0)}:c}function ys(e,t){return e||(t?.classList.contains(`target`)?`target`:t?.classList.contains(`source`)?`source`:null)}function bs(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}var xs=()=>!0;function Ss(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:_=xs,onReconnectEnd:v,updateConnection:y,getTransform:b,getFromHandle:x,autoPanSpeed:S,dragThreshold:C=1,handleDomNode:w}){let T=mo(e.target),E=0,D,{x:O,y:k}=vo(e),A=ys(a,w),j=s?.getBoundingClientRect(),M=!1;if(!j||!A)return;let N=vs(i,A,r,c,t);if(!N)return;let P=vo(e,j),ee=!1,te=null,ne=!1,F=null;function I(){if(!u||!j)return;let[e,t]=La(P,j,S);f({x:e,y:t}),E=requestAnimationFrame(I)}let L={...N,nodeId:i,type:A,position:N.position},re=c.get(i),ie={inProgress:!0,isValid:null,from:Vo(re,L,G.Left,!0),fromHandle:L,fromPosition:L.position,fromNode:re,to:P,toHandle:null,toPosition:ba[L.position],toNode:null,pointer:P};function ae(){M=!0,y(ie),m?.(e,{nodeId:i,handleId:r,handleType:A})}C===0&&ae();function R(e){if(!M){let{x:t,y:n}=vo(e),r=t-O,i=n-k;if(!(r*r+i*i>C*C))return;ae()}if(!x()||!L){z(e);return}let a=b();P=vo(e,j),D=_s(Xa(P,a,!1,[1,1]),n,c,L),ee||=(I(),!0);let s=Cs(e,{handle:D,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:o?`target`:`source`,isValidConnection:_,doc:T,lib:l,flowId:d,nodeLookup:c});F=s.handleDomNode,te=s.connection,ne=bs(!!D,s.isValid);let u=c.get(i),f=u?Vo(u,L,G.Left,!0):ie.from,p={...ie,from:f,isValid:ne,to:s.toHandle&&ne?Za({x:s.toHandle.x,y:s.toHandle.y},a):P,toHandle:s.toHandle,toPosition:ne&&s.toHandle?s.toHandle.position:ba[L.position],toNode:s.toHandle?c.get(s.toHandle.nodeId):null,pointer:P};y(p),ie=p}function z(e){if(!(`touches`in e&&e.touches.length>0)){if(M){(D||F)&&te&&ne&&h?.(te);let{inProgress:t,...n}=ie,r={...n,toPosition:ie.toHandle?ie.toPosition:null};g?.(e,r),a&&v?.(e,r)}p(),cancelAnimationFrame(E),ee=!1,ne=!1,te=null,F=null,T.removeEventListener(`mousemove`,R),T.removeEventListener(`mouseup`,z),T.removeEventListener(`touchmove`,R),T.removeEventListener(`touchend`,z)}}T.addEventListener(`mousemove`,R),T.addEventListener(`mouseup`,z),T.addEventListener(`touchmove`,R),T.addEventListener(`touchend`,z)}function Cs(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:a,doc:o,lib:s,flowId:c,isValidConnection:l=xs,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}=vo(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=ys(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===ma.Strict?d&&e===`source`||!d&&e===`target`:t!==r||a!==i)&&l(c),_.toHandle=vs(t,e,a,u,n,!0)}return _}var ws={onPointerDown:Ss,isValid:Cs};function Ts({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){let i=O(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&&no()?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=E().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:v}}var Es=e=>({x:e.x,y:e.y,zoom:e.k}),Ds=({x:e,y:t,zoom:n})=>w.translate(e,t).scale(n),Os=(e,t)=>e.target.closest(`.${t}`),ks=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),As=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,js=(e,t=0,n=As,r=()=>{})=>{let i=typeof t==`number`&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on(`end`,r):e},Ms=e=>{let t=e.ctrlKey&&no()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Ns({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:a,zoomOnPinch:o,onPanZoomStart:s,onPanZoom:c,onPanZoomEnd:l}){return u=>{if(Os(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=v(u),t=d*2**Ms(u);r.scaleTo(n,t,e,u);return}let f=u.deltaMode===1?20:1,p=i===ha.Vertical?0:u.deltaX*f,m=i===ha.Horizontal?0:u.deltaY*f;!no()&&u.shiftKey&&i!==ha.Vertical&&(p=u.deltaY*f,m=0),r.translateBy(n,-(p/d)*a,-(m/d)*a,{internal:!0});let h=Es(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 Ps({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){let a=r.type===`wheel`,o=!t&&a&&!r.ctrlKey,s=Os(r,e);if(r.ctrlKey&&a&&s&&r.preventDefault(),o||s)return null;r.preventDefault(),n.call(this,r,i)}}function Fs({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{if(r.sourceEvent?.internal)return;let i=Es(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 Is({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return a=>{e.usedRightMouseButton=!!(n&&ks(t,e.mouseButton??0)),a.sourceEvent?.sync||r([a.transform.x,a.transform.y,a.transform.k]),i&&!a.sourceEvent?.internal&&i?.(a.sourceEvent,Es(a.transform))}}function Ls({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:a}){return o=>{if(!o.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,a&&ks(t,e.mouseButton??0)&&!e.usedRightMouseButton&&o.sourceEvent&&a(o.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){let t=Es(o.transform);e.prevViewport=t,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(o.sourceEvent,t)},n?150:0)}}}function Rs({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`&&(Os(f,`${u}-flow__node`)||Os(f,`${u}-flow__edge`)||Os(f,`${u}-flow__selection`)||Os(f,`${u}-flow__nodesselection`)))return!0;if(!i&&!p&&!a&&!o&&!r||s||d&&!h||Os(f,c)&&h||Os(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 zs({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=E().extent(()=>d).scaleExtent([t,n]).translateExtent(r),m=O(e).call(p);b({x:i.x,y:i.y,zoom:Na(i.zoom,t,n)},[[0,0],[u.width,u.height]],r);let h=m.on(`wheel.zoom`),g=m.on(`dblclick.zoom`);p.wheelDelta(Ms);async function _(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?j:C).transform(js(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:!qa(E)||E<0?0:E);let k=O?Ns({zoomPanValues:l,noWheelClassName:e,d3Selection:m,d3Zoom:p,panOnScrollMode:d,panOnScrollSpeed:f,zoomOnPinch:v,onPanZoomStart:o,onPanZoom:a,onPanZoomEnd:s}):Ps({noWheelClassName:e,preventScrolling:_,d3ZoomHandler:h});m.on(`wheel.zoom`,k,{passive:!1});let A=Fs({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:o});p.on(`start`,A);let j=Is({zoomPanValues:l,panOnDrag:u,onPaneContextMenu:!!n,onPanZoom:a,onTransformChange:w});p.on(`zoom`,j);let M=Ls({zoomPanValues:l,panOnDrag:u,panOnScroll:i,onPaneContextMenu:n,onPanZoomEnd:s,onDraggingChange:c});p.on(`end`,M);let N=Rs({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=Ds(e),i=p?.constrain()(r,t,n);return i&&await _(i),i}async function x(e,t){let n=Ds(e);return await _(n,t),n}function S(e){if(m){let t=Ds(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 w(){let e=m?T(m.node()):{x:0,y:0,k:1};return{x:e.x,y:e.y,zoom:e.k}}async function D(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?j:C).scaleTo(js(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}async function k(e,t){return m?new Promise(n=>{p?.interpolate(t?.interpolate===`linear`?j:C).scaleBy(js(m,t?.duration,t?.ease,()=>n(!0)),e)}):!1}function A(e){p?.scaleExtent(e)}function M(e){p?.translateExtent(e)}function N(e){let t=!qa(e)||e<0?0:e;p?.clickDistance(t)}return{update:v,destroy:y,setViewport:x,setViewportConstrained:b,getViewport:w,scaleTo:D,scaleBy:k,setScaleExtent:A,setTranslateExtent:M,syncViewport:S,setClickDistance:N}}var Bs;(function(e){e.Line=`line`,e.Handle=`handle`})(Bs||={});function Vs({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 Hs(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 Us(e,t){return Math.max(0,t-e)}function Ws(e,t){return Math.max(0,e-t)}function Gs(e,t,n){return Math.max(0,t-e,e-n)}function Ks(e,t){return e?!t:t}function qs(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=Gs(E,h,g),j=Gs(D,_,v);if(o){let e=0,t=0;c&&w<0?e=Us(y+w+O,o[0][0]):!c&&w>0&&(e=Ws(y+E+O,o[1][0])),l&&T<0?t=Us(b+T+k,o[0][1]):!l&&T>0&&(t=Ws(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=Ws(y+w,s[0][0]):!c&&w<0&&(e=Us(y+E,s[1][0])),l&&T>0?t=Ws(b+T,s[0][1]):!l&&T<0&&(t=Us(b+D,s[1][1])),A=Math.max(A,e),j=Math.max(j,t)}if(i){if(u){let e=Gs(E/C,_,v)*C;if(A=Math.max(A,e),o){let e=0;e=!c&&!l||c&&!l&&f?Ws(b+k+E/C,o[1][1])*C:Us(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?Us(b+E/C,s[1][1])*C:Ws(b+(c?w:-w)/C,s[0][1])*C,A=Math.max(A,e)}}if(d){let e=Gs(D*C,h,g)/C;if(j=Math.max(j,e),o){let e=0;e=!c&&!l||l&&!c&&f?Ws(y+D*C+O,o[1][0])/C:Us(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?Us(y+D*C,s[1][0])/C:Ws(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=(Ks(c,l)?-w:w)/C:w=(Ks(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 Js={width:0,height:0,x:0,y:0},Ys={...Js,pointerX:0,pointerY:0,aspectRatio:1};function Xs(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 Zs({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){let a=O(e),o={controlDirection:Hs(`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={...Js},h={...Ys};o={boundaries:s,resizeDirection:l,keepAspectRatio:c,controlDirection:Hs(e)};let g,_=null,v=[],y,b,x,S=F().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}=fo(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=ro(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=Xs(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=fo(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}=qs(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 ee=Vs({width:m.width,prevWidth:S,height:m.height,prevHeight:C,affectsX:o.controlDirection.affectsX,affectsY:o.controlDirection.affectsY}),te={...m,direction:ee};p?.(e,te)===!1?(m=P.prevValues,h.x=P.startX,h.y=P.startY,v.forEach((e,t)=>{e.position=P.childNodes[t].position})):(d?.(e,te),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 Qs=e(i(),1),$s=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},ec=e=>e?$s(e):$s,{useDebugValue:tc}=I.default,{useSyncExternalStoreWithSelector:nc}=Qs.default,rc=e=>e;function ic(e,t=rc,n){let r=nc(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return tc(r),r}var ac=(e,t)=>{let n=ec(e),r=(e,r=t)=>ic(n,e,r);return Object.assign(r,n),r},oc=(e,t)=>e?ac(e,t):ac;function K(e,t){if(Object.is(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(let[n,r]of e)if(!Object.is(r,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(let n of e)if(!t.has(n))return!1;return!0}let n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}u();var sc=(0,I.createContext)(null),cc=sc.Provider,lc=ua.error001(`react`);function q(e,t){let n=(0,I.useContext)(sc);if(n===null)throw Error(lc);return ic(n,e,t)}function J(){let e=(0,I.useContext)(sc);if(e===null)throw Error(lc);return(0,I.useMemo)(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}var uc={display:`none`},dc={position:`absolute`,width:1,height:1,margin:-1,border:0,padding:0,overflow:`hidden`,clip:`rect(0px, 0px, 0px, 0px)`,clipPath:`inset(100%)`},fc=`react-flow__node-desc`,pc=`react-flow__edge-desc`,mc=`react-flow__aria-live`,hc=e=>e.ariaLiveMessage,gc=e=>e.ariaLabelConfig;function _c({rfId:e}){let t=q(hc);return(0,U.jsx)(`div`,{id:`${mc}-${e}`,"aria-live":`assertive`,"aria-atomic":`true`,style:dc,children:t})}function vc({rfId:e,disableKeyboardA11y:t}){let n=q(gc);return(0,U.jsxs)(U.Fragment,{children:[(0,U.jsx)(`div`,{id:`${fc}-${e}`,style:uc,children:t?n[`node.a11yDescription.default`]:n[`node.a11yDescription.keyboardDisabled`]}),(0,U.jsx)(`div`,{id:`${pc}-${e}`,style:uc,children:n[`edge.a11yDescription.default`]}),!t&&(0,U.jsx)(_c,{rfId:e})]})}var yc=(0,I.forwardRef)(({position:e=`top-left`,children:t,className:n,style:r,...i},a)=>{let o=`${e}`.split(`-`);return(0,U.jsx)(`div`,{className:W([`react-flow__panel`,n,...o]),style:r,ref:a,...i,children:t})});yc.displayName=`Panel`;var bc=`https://reactflow.dev?utm_source=attribution`;function xc({proOptions:e,position:t=`bottom-right`}){return(0,I.useEffect)(()=>{},[]),e?.hideAttribution?null:(0,U.jsx)(yc,{position:t,className:`react-flow__attribution`,"data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${bc}`,children:(0,U.jsx)(`a`,{href:bc,target:`_blank`,rel:`noopener noreferrer`,"aria-label":`React Flow attribution`,children:`React Flow`})})}var Sc=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}},Cc=e=>e.id;function wc(e,t){return K(e.selectedNodes.map(Cc),t.selectedNodes.map(Cc))&&K(e.selectedEdges.map(Cc),t.selectedEdges.map(Cc))}function Tc({onSelectionChange:e}){let t=J(),{selectedNodes:n,selectedEdges:r}=q(Sc,wc);return(0,I.useEffect)(()=>{let i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChangeHandlers.forEach(e=>e(i))},[n,r,e]),null}var Ec=e=>!!e.onSelectionChangeHandlers;function Dc({onSelectionChange:e}){let t=q(Ec);return e||t?(0,U.jsx)(Tc,{onSelectionChange:e}):null}var Oc=[0,0],kc={x:0,y:0,zoom:1},Ac=[...`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`],jc=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}),Mc={translateExtent:da,nodeOrigin:Oc,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:`nopan`,rfId:`1`};function Nc(e){let{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:a,setNodeExtent:o,reset:s,setDefaultNodesAndEdges:c}=q(jc,K),l=J();(0,I.useEffect)(()=>(c(e.defaultNodes,e.defaultEdges),()=>{u.current=Mc,s()}),[]);let u=(0,I.useRef)(Mc);return(0,I.useEffect)(()=>{for(let s of Ac){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:lo(c)}):s===`fitView`?l.setState({fitViewQueued:c}):s===`fitViewOptions`?l.setState({fitViewOptions:c}):l.setState({[s]:c}))}u.current=e},Ac.map(t=>e[t])),null}function Pc(){return typeof window>`u`||!window.matchMedia?null:window.matchMedia(`(prefers-color-scheme: dark)`)}function Fc(e){let[t,n]=(0,I.useState)(e===`system`?null:e);return(0,I.useEffect)(()=>{if(e!==`system`){n(e);return}let t=Pc(),r=()=>n(t?.matches?`dark`:`light`);return r(),t?.addEventListener(`change`,r),()=>{t?.removeEventListener(`change`,r)}},[e]),t===null?Pc()?.matches?`dark`:`light`:t}var Ic=typeof document<`u`?document:null;function Lc(e=null,t={target:Ic,actInsideInputWithModifier:!0}){let[n,r]=(0,I.useState)(!1),i=(0,I.useRef)(!1),a=(0,I.useRef)(new Set([])),[o,s]=(0,I.useMemo)(()=>{if(e!==null){let t=(Array.isArray(e)?e:[e]).filter(e=>typeof e==`string`).map(e=>e.replace(/\+/g,`
|
|
3
3
|
`).replace(`
|
|
4
4
|
|