All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.FlowDetails-7100af6f.js Maven / Gradle / Ivy

There is a newer version: 25.0.1
Show newest version
import{_ as Wa,r as x,k as Nt,B as fe,l as tt,m as hg,n as Qa,u as Le,j as p,o as Ad,p as pg,d as Ja,e as cr,f as Ld,g as se,A as st,q as yn,P as qd,F as wt,V as xe,h as _t,C as Vs,T as gg,s as mg,v as vg,w as es,x as ur,y as yg,z as bg,D as xg,E as wg,G as Et,c as _g,H as Eg,b as Sg,t as Cg}from"./index-0cda761d.js";import{u as Gs}from"./ConfirmDialog-100e6a40.js";import{V as Ng}from"./ViewHeader-ff389f8e.js";import{u as Ma}from"./useToggle-3764a2a4.js";import{B as Mg,D as Ig}from"./AuthenticationSection-4d24ccb2.js";import{N as kg}from"./NameDescription-c11e0880.js";import{M as bn,a as xn}from"./Modal-ea09312d.js";import{F as wn,A as Rg}from"./Form-4087ddae.js";import{P as Tg,L as Ag}from"./PaginatingTableToolbar-11bdf18a.js";import{u as Lg,m as qg}from"./useLocaleSort-ef2c79ac.js";import{u as Pg}from"./useUpdateEffect-22c3472b.js";import{_ as lr,k as _n,a as Pd,b as $d,c as ts,d as $g,i as dr,r as ns,e as jd,f as rs,g as Fd,h as jg,j as Fg,l as Dg,m as we,n as is,o as En,p as Dd,q as Sn,s as Cn,t as Od,u as Og,v as os,w as zd,x as zg,y as Bg,z as Bd,A as Hg,B as Hd,C as as,D as Vg,E as Vd,F as Gg,G as ss,H as Ug,I as Yg,J as Kg,K as Zg,L as Xg,M as Wg}from"./Td-d9b96677.js";import{r as Lt,a as Gd,b as Ud,c as Qg,d as Jg,e as Nn,f as em,_ as Yd,g as tm,h as Kd,i as nm,j as Zd,k as rm,l as im,P as om}from"./KeycloakDataTable-a1a2bfca.js";import{P as Xd}from"./plus-icon-4f91635d.js";import{D as Wd,a as Qd,b as Jd,c as ef,d as Ot,e as am}from"./DataListItemRow-7ca17a45.js";import{C as sm}from"./Card-d5c0a973.js";import{C as cm}from"./CardBody-8867799e.js";import{S as Ia,a as ka,b as Ra}from"./Select-68736f55.js";import{D as um}from"./DynamicComponents-fe8010c1.js";import{K as Un}from"./KeycloakTextInput-ada01047.js";import{T as tf}from"./trash-icon-d675554b.js";import{K as lm}from"./KeycloakTextArea-9049d04c.js";import{D as dm}from"./DataListControl-527542ed.js";import{s as kr}from"./data-list-7d55714c.js";import{T as fm,a as hm}from"./Text-b9444fb8.js";import{T as Us}from"./Trans-4d909f1b.js";import{T as pm,a as gm,b as Rr}from"./ToolbarContent-fee3570e.js";import{R as mm}from"./Radio-a79edd45.js";import{F as Ys}from"./Flex-a3793595.js";import{F as Ks}from"./FlexItem-742749b8.js";import"./RoutableTabs-56121a9c.js";import"./Tabs-76c5b0e3.js";import"./MenuList-7fad6760.js";import"./star-icon-2ee5dfa7.js";import"./Checkbox-3affa1d3.js";import"./check-fc57dbe1.js";import"./getAuthorizationHeaders-f2376d1a.js";import"./DraggableTable-852f161b.js";import"./resource-0803fa9b.js";import"./admin-ui-endpoint-f934fa67.js";import"./FormAccess-835af982.js";import"./copy-icon-b8d617db.js";import"./GridItem-1535d986.js";import"./TimeSelector-5680ad0f.js";import"./NumberInput-1d7f57ff.js";import"./minus-icon-21b0d1e4.js";import"./minus-circle-icon-ac3563ca.js";import"./EmptyStateBody-f9d2c033.js";import"./EmptyStateSecondaryActions-e8364506.js";import"./plus-circle-icon-fe78809e.js";import"./MultiLineInput-05f00b93.js";import"./question-circle-icon-38235421.js";import"./TableToolbar-470a2060.js";import"./grip-vertical-icon-ba7b06db.js";import"./ClientSelect-ab12f3f6.js";import"./FileUpload-2469f593.js";import"./CodeEditor-781232a0.js";import"./GroupPickerDialog-9d38b823.js";import"./ActionListItem-c859aeaf.js";import"./PasswordInput-bb06acaa.js";import"./AddRoleMappingModal-71c36ce9.js";import"./filter-icon-56a9cd24.js";const nf=e=>{var{className:t="",isExpanded:n=!1,"aria-controls":r="","aria-label":i="Details",rowid:o="",id:a,buttonProps:s}=e,u=Wa(e,["className","isExpanded","aria-controls","aria-label","rowid","id","buttonProps"]);return x.createElement("div",Object.assign({className:Nt(kr.dataListItemControl,t)},u),x.createElement("div",{className:Nt(kr.dataListToggle)},x.createElement(fe,Object.assign({id:a,variant:tt.plain,"aria-controls":r!==""&&r,"aria-label":i,"aria-labelledby":i!=="Details"?null:`${o} ${a}`,"aria-expanded":n},s),x.createElement("div",{className:Nt(kr.dataListToggleIcon)},x.createElement(hg,null)))))};nf.displayName="DataListToggle";const Mt={modifiers:{compact:"pf-m-compact",selected:"pf-m-selected",disabled:"pf-m-disabled"},themeDark:"pf-theme-dark",toggleGroup:"pf-c-toggle-group",toggleGroupButton:"pf-c-toggle-group__button",toggleGroupIcon:"pf-c-toggle-group__icon",toggleGroupItem:"pf-c-toggle-group__item",toggleGroupText:"pf-c-toggle-group__text"};var Yn;(function(e){e.icon="icon",e.text="text"})(Yn||(Yn={}));const Ta=({variant:e,children:t})=>x.createElement("span",{className:Nt(e==="icon"&&Mt.toggleGroupIcon,e==="text"&&Mt.toggleGroupText)},t);Ta.displayName="ToggleGroupItemElement";const Kn=e=>{var{text:t,icon:n,className:r,isDisabled:i=!1,isSelected:o=!1,"aria-label":a="",onChange:s=()=>{},buttonId:u=""}=e,l=Wa(e,["text","icon","className","isDisabled","isSelected","aria-label","onChange","buttonId"]);const c=d=>{s(!o,d)};return!a&&n&&!t&&console.warn("An accessible aria-label is required when using the toggle group item icon variant."),x.createElement("div",Object.assign({className:Nt(Mt.toggleGroupItem,r)},l),x.createElement("button",Object.assign({type:"button",className:Nt(Mt.toggleGroupButton,o&&Mt.modifiers.selected),"aria-pressed":o,onClick:c},a&&{"aria-label":a},i&&{disabled:!0},u&&{id:u}),n?x.createElement(Ta,{variant:Yn.icon},n):null,t?x.createElement(Ta,{variant:Yn.text},t):null))};Kn.displayName="ToggleGroupItem";const rf=e=>{var{className:t,children:n,isCompact:r=!1,areAllGroupsDisabled:i=!1,"aria-label":o}=e,a=Wa(e,["className","children","isCompact","areAllGroupsDisabled","aria-label"]);const s=x.Children.map(n,u=>u.type.name!==Kn.name?u:x.cloneElement(u,i?{isDisabled:!0}:{}));return x.createElement("div",Object.assign({className:Nt(Mt.toggleGroup,r&&Mt.modifiers.compact,t),role:"group","aria-label":o},a),s)};rf.displayName="ToggleGroup";const vm={name:"CogIcon",height:512,width:512,svgPath:"M487.4 315.7l-42.6-24.6c4.3-23.2 4.3-47 0-70.2l42.6-24.6c4.9-2.8 7.1-8.6 5.5-14-11.1-35.6-30-67.8-54.7-94.6-3.8-4.1-10-5.1-14.8-2.3L380.8 110c-17.9-15.4-38.5-27.3-60.8-35.1V25.8c0-5.6-3.9-10.5-9.4-11.7-36.7-8.2-74.3-7.8-109.2 0-5.5 1.2-9.4 6.1-9.4 11.7V75c-22.2 7.9-42.8 19.8-60.8 35.1L88.7 85.5c-4.9-2.8-11-1.9-14.8 2.3-24.7 26.7-43.6 58.9-54.7 94.6-1.7 5.4.6 11.2 5.5 14L67.3 221c-4.3 23.2-4.3 47 0 70.2l-42.6 24.6c-4.9 2.8-7.1 8.6-5.5 14 11.1 35.6 30 67.8 54.7 94.6 3.8 4.1 10 5.1 14.8 2.3l42.6-24.6c17.9 15.4 38.5 27.3 60.8 35.1v49.2c0 5.6 3.9 10.5 9.4 11.7 36.7 8.2 74.3 7.8 109.2 0 5.5-1.2 9.4-6.1 9.4-11.7v-49.2c22.2-7.9 42.8-19.8 60.8-35.1l42.6 24.6c4.9 2.8 11 1.9 14.8-2.3 24.7-26.7 43.6-58.9 54.7-94.6 1.5-5.5-.7-11.3-5.6-14.1zM256 336c-44.1 0-80-35.9-80-80s35.9-80 80-80 80 35.9 80 80-35.9 80-80 80z",yOffset:0,xOffset:0},ym=Qa(vm),bm={name:"DomainIcon",height:1024,width:1024,svgPath:"M544,511.9 C561.476067,511.948945 575.664266,525.962873 575.994253,543.371439 L576,543.9 L576,991.9 C575.951055,1009.37607 561.937127,1023.56427 544.528561,1023.89425 L544,1023.9 L352,1023.9 C334.523933,1023.85105 320.335734,1009.83713 320.005747,992.428561 L320,991.9 L320,543.9 C320.048945,526.423933 334.062873,512.235734 351.471439,511.905747 L352,511.9 L544,511.9 Z M704,576 L704,960 L640,960 L640,576 L704,576 Z M512,896 L384,896 L384,960 L512,960 L512,896 Z M960,513.1 L960,513.2 C960,665.4 884.1,799.9 768,880.9 L768,880.9 L768,799.4 C773.3,794.6 778.4,789.8 783.5,784.7 C855.624209,712.728348 896.108133,614.991161 896,513.1 L896,513.1 L960,513.1 Z M149.8,385 C100.714385,524.561202 135.973879,679.905126 240.5,784.6 C245.5,789.7 250.7,794.6 256,799.3 L256,799.3 L256,880.8 C139.9,799.8 63.9999013,665.3 63.9999013,513.1 C63.9712238,469.725105 70.236499,426.575548 82.6,385 L82.6,385 Z M512.1,704 L384,704 L384,832 L512.1,832 L512.1,704 Z M512,576 L448,576 L448,640 L512,640 L512,576 Z M864,-1.13686838e-13 C881.496381,-1.13686838e-13 895.713128,14.0417829 895.995713,31.4708215 L896,32 L896,406 C896,423.496381 881.958217,437.713128 864.529179,437.995713 L864,438 L608,438 C590.503619,438 576.286872,423.958217 576.004287,406.529179 L576,406 L576,32 C576,14.5036191 590.041783,0.286872383 607.470821,0.00428708574 L608,-1.13686838e-13 L864,-1.13686838e-13 Z M1024,64 L1024,384 L960,384 L960,64 L1024,64 Z M832,256 L640,256 L640,352 L832,352 L832,256 Z M224,-5.68434189e-14 C241.476067,0.0489452394 255.664266,14.0628726 255.994253,31.4714395 L256,32 L256,288 C255.951055,305.476067 241.937127,319.664266 224.528561,319.994253 L224,320 L32,320 C14.5239331,319.951055 0.335734448,305.937127 0.00574685353,288.528561 L0,288 L0,32 C0.0489452394,14.5239331 14.0628726,0.335734448 31.4714395,0.00574685353 L32,-5.68434189e-14 L224,-5.68434189e-14 Z M192,192 L64,192 L64,256 L192,256 L192,192 Z M512,65 L512,129 C460.642759,128.90985 409.795141,139.181409 362.5,159.2 C347.917219,165.399771 333.724426,172.47947 320,180.4 L320,180.4 L320,108.2 C380.012207,79.7623165 445.590913,65.0071076 512,65 L512,65 Z M832,64 L736,64 L736,160 L832,160 L832,64 Z M192,64 L128,64 L128,128 L192,128 L192,64 Z",yOffset:0,xOffset:0},xm=Qa(bm),wm={name:"TableIcon",height:512,width:512,svgPath:"M464 32H48C21.49 32 0 53.49 0 80v352c0 26.51 21.49 48 48 48h416c26.51 0 48-21.49 48-48V80c0-26.51-21.49-48-48-48zM224 416H64v-96h160v96zm0-160H64v-96h160v96zm224 160H288v-96h160v96zm0-160H288v-96h160v96z",yOffset:0,xOffset:0},_m=Qa(wm),Em="_icon_1gmts_2",Sm={icon:Em},Cm=()=>{const{t:e}=Le("authentication");return p.jsx(Ad,{icon:p.jsx(pg,{className:Sm.icon}),children:e("buildIn")})},Nm=({flow:e,toggleDialog:t})=>{const{t:n}=Le("authentication"),{addAlert:r,addError:i}=Ja(),o=cr({mode:"onChange"}),{reset:a,handleSubmit:s}=o;x.useEffect(()=>a(e),[e]);const u=async l=>{try{await se.authenticationManagement.updateFlow({flowId:e.id},{...e,...l}),r(n("updateFlowSuccess"),st.success)}catch(c){i("authentication:updateFlowError",c)}t()};return p.jsx(bn,{title:n("editFlow"),onClose:t,variant:xn.small,actions:[p.jsx(fe,{"data-testid":"confirm",type:"submit",form:"edit-flow-form",children:n("edit")},"confirm"),p.jsx(fe,{"data-testid":"cancel",variant:tt.link,onClick:()=>t(),children:n("common:cancel")},"cancel")],isOpen:!0,children:p.jsx(Ld,{...o,children:p.jsx(wn,{id:"edit-flow-form",onSubmit:s(u),isHorizontal:!0,children:p.jsx(kg,{})})})})},Mm=({list:e,setValue:t})=>p.jsx(qd,{variant:"light",className:"pf-u-py-lg",children:p.jsx(wn,{isHorizontal:!0,children:e?.map(n=>p.jsx(mm,{id:n.id,name:"provider",label:n.displayName,"data-testid":n.id,description:n.description,onChange:()=>{t(n)}},n.id))})}),cs=({name:e,type:t,onSelect:n})=>{const{t:r}=Le("authentication"),[i,o]=x.useState(),[a,s]=x.useState(),[u,l]=x.useState(10),[c,d]=x.useState(0),[f,h]=x.useState(""),m=Lg();yn(async()=>{switch(t){case"client":return se.authenticationManagement.getClientAuthenticatorProviders();case"form":return se.authenticationManagement.getFormActionProviders();case"condition":return(await se.authenticationManagement.getAuthenticatorProviders()).filter(Xa);case"basic":default:return(await se.authenticationManagement.getAuthenticatorProviders()).filter(y=>!Xa(y))}},v=>s(v),[]);const g=x.useMemo(()=>m(a??[],qg("displayName")).filter(v=>v.displayName?.includes(f)||v.description?.includes(f)).slice(c,c+u+1),[a,f,c,u]);return p.jsx(bn,{variant:xn.medium,isOpen:!0,title:r("addStepTo",{name:e}),onClose:()=>n(),actions:[p.jsx(fe,{id:"modal-add","data-testid":"modal-add",onClick:()=>n(i),children:r("common:add")},"add"),p.jsx(fe,{"data-testid":"cancel",id:"modal-cancel",variant:tt.link,onClick:()=>{n()},children:r("common:cancel")},"cancel")],children:a&&p.jsx(Tg,{count:g.length||0,first:c,max:u,onNextClick:d,onPreviousClick:d,onPerPageSelect:(v,y)=>{d(v),l(y)},inputGroupName:"search",inputGroupPlaceholder:r("common:search"),inputGroupOnEnter:h,children:p.jsx(Mm,{list:g.slice(0,u),setValue:o})})})},Zs=["basic-flow","form-flow"],us=({name:e,onConfirm:t,onCancel:n})=>{const{t:r}=Le("authentication"),{register:i,control:o,setValue:a,handleSubmit:s,formState:{errors:u}}=cr(),[l,c]=x.useState(!1),[d,f]=x.useState(!1),[h,m]=x.useState();return yn(()=>se.authenticationManagement.getFormProviders(),m,[]),x.useEffect(()=>{h?.length===1&&a("provider",h[0].id)},[h]),p.jsx(bn,{variant:xn.medium,title:r("addStepTo",{name:e}),onClose:n,actions:[p.jsx(fe,{"data-testid":"modal-add",type:"submit",form:"sub-flow-form",children:r("common:add")},"add"),p.jsx(fe,{"data-testid":"cancel",variant:tt.link,onClick:n,children:r("common:cancel")},"cancel")],isOpen:!0,children:p.jsxs(wn,{id:"sub-flow-form",onSubmit:s(t),isHorizontal:!0,children:[p.jsx(wt,{label:r("common:name"),fieldId:"name",helperTextInvalid:r("common:required"),validated:u.name?xe.error:xe.default,labelIcon:p.jsx(_t,{helpText:r("authentication-help:name"),fieldLabelId:"name"}),isRequired:!0,children:p.jsx(Un,{id:"name","data-testid":"name",validated:u.name?xe.error:xe.default,...i("name",{required:!0})})}),p.jsx(wt,{label:r("common:description"),fieldId:"description",labelIcon:p.jsx(_t,{helpText:r("authentication-help:description"),fieldLabelId:"description"}),children:p.jsx(Un,{id:"description","data-testid":"description",...i("description")})}),p.jsx(wt,{label:r("flowType"),fieldId:"flowType",labelIcon:p.jsx(_t,{helpText:r("authentication-help:flowType"),fieldLabelId:"authentication:flowType"}),children:p.jsx(Vs,{name:"type",defaultValue:Zs[0],control:o,render:({field:g})=>p.jsx(Ia,{menuAppendTo:"parent",toggleId:"flowType",onToggle:c,onSelect:(v,y)=>{g.onChange(y.toString()),c(!1)},selections:r(`flow-type.${g.value}`),variant:ka.single,isOpen:l,children:Zs.map(v=>p.jsx(Ra,{value:v,selected:v===g.value,children:r(`flow-type.${v}`)},v))})})}),h&&h.length>1&&p.jsx(wt,{label:r("flowType"),labelIcon:p.jsx(_t,{helpText:r("authentication-help:flowType"),fieldLabelId:"authentication:flowType"}),fieldId:"flowType",children:p.jsx(Vs,{name:"provider",defaultValue:"",control:o,render:({field:g})=>p.jsx(Ia,{menuAppendTo:"parent",toggleId:"provider",onToggle:f,onSelect:(v,y)=>{g.onChange(y.toString()),f(!1)},selections:g.value,variant:ka.single,isOpen:d,children:h.map(v=>p.jsx(Ra,{value:v.id,selected:v.displayName===g.value,children:v.displayName},v.id))})})})]})})};const Im=["addExecution","addSubFlow"],km=({flow:e,onAddExecution:t,onAddFlow:n})=>{const{t:r}=Le("authentication"),[i,o]=x.useState();return p.jsxs(p.Fragment,{children:[i==="addExecution"&&p.jsx(cs,{name:e.alias,type:e.providerId==="client-flow"?"client":"basic",onSelect:a=>{a&&t(a),o(void 0)}}),i==="addSubFlow"&&p.jsx(us,{name:e.alias,onCancel:()=>o(void 0),onConfirm:a=>{n(a),o(void 0)}}),p.jsx(Ag,{message:r("emptyExecution"),instructions:r("emptyExecutionInstructions")}),p.jsx("div",{className:"keycloak__empty-execution-state__block",children:Im.map(a=>p.jsxs(Ys,{className:"keycloak__empty-execution-state__help",children:[p.jsxs(Ks,{flex:{default:"flex_1"},children:[p.jsx(gg,{headingLevel:"h2",size:mg.md,children:r(`${a}Title`)}),p.jsx("p",{children:r(`authentication-help:${a}`)})]}),p.jsx(Ys,{alignSelf:{default:"alignSelfCenter"},children:p.jsx(Ks,{children:p.jsx(fe,{"data-testid":a,variant:"tertiary",onClick:()=>o(a),children:r(a)})})})]},a))})]})};function ve(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n{let t;const n=new Set,r=(u,l)=>{const c=typeof u=="function"?u(t):u;if(!Object.is(c,t)){const d=t;t=l??typeof c!="object"?c:Object.assign({},t,c),n.forEach(f=>f(t,d))}},i=()=>t,s={setState:r,getState:i,subscribe:u=>(n.add(u),()=>n.delete(u)),destroy:()=>{({BASE_URL:"./",MODE:"production",DEV:!1,PROD:!0,SSR:!1}&&"production")!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}};return t=e(r,i,s),s},Rm=e=>e?Xs(e):Xs;var of={exports:{}},af={},sf={exports:{}},cf={};/**
 * @license React
 * use-sync-external-store-shim.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var Gt=x;function Tm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Am=typeof Object.is=="function"?Object.is:Tm,Lm=Gt.useState,qm=Gt.useEffect,Pm=Gt.useLayoutEffect,$m=Gt.useDebugValue;function jm(e,t){var n=t(),r=Lm({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return Pm(function(){i.value=n,i.getSnapshot=t,Tr(i)&&o({inst:i})},[e,n,t]),qm(function(){return Tr(i)&&o({inst:i}),e(function(){Tr(i)&&o({inst:i})})},[e]),$m(n),n}function Tr(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Am(e,n)}catch{return!0}}function Fm(e,t){return t()}var Dm=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?Fm:jm;cf.useSyncExternalStore=Gt.useSyncExternalStore!==void 0?Gt.useSyncExternalStore:Dm;sf.exports=cf;var Om=sf.exports;/**
 * @license React
 * use-sync-external-store-shim/with-selector.production.min.js
 *
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * This source code is licensed under the MIT license found in the
 * LICENSE file in the root directory of this source tree.
 */var fr=x,zm=Om;function Bm(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Hm=typeof Object.is=="function"?Object.is:Bm,Vm=zm.useSyncExternalStore,Gm=fr.useRef,Um=fr.useEffect,Ym=fr.useMemo,Km=fr.useDebugValue;af.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=Gm(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=Ym(function(){function u(h){if(!l){if(l=!0,c=h,h=r(h),i!==void 0&&a.hasValue){var m=a.value;if(i(m,h))return d=m}return d=h}if(m=d,Hm(c,h))return m;var g=r(h);return i!==void 0&&i(m,g)?m:(c=h,d=g)}var l=!1,c,d,f=n===void 0?null:n;return[function(){return u(t())},f===null?void 0:function(){return u(f())}]},[t,n,r,i]);var s=Vm(e,o[0],o[1]);return Um(function(){a.hasValue=!0,a.value=s},[s]),Km(s),s};of.exports=af;var Zm=of.exports;const Xm=vg(Zm),{useSyncExternalStoreWithSelector:Wm}=Xm;function Qm(e,t=e.getState,n){const r=Wm(e.subscribe,e.getState,e.getServerState||e.getState,t,n);return x.useDebugValue(r),r}function he(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,i]of e)if(!Object.is(i,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(let r=0;r{}};function hr(){for(var e=0,t=arguments.length,n={},r;e=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Bn.prototype=hr.prototype={constructor:Bn,on:function(e,t){var n=this._,r=ev(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o0)for(var n=new Array(i),r=0,i,o;r=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),Qs.hasOwnProperty(t)?{space:Qs[t],local:e}:e}function nv(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Aa&&t.documentElement.namespaceURI===Aa?t.createElement(e):t.createElementNS(n,e)}}function rv(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function uf(e){var t=pr(e);return(t.local?rv:nv)(t)}function iv(){}function ls(e){return e==null?iv:function(){return this.querySelector(e)}}function ov(e){typeof e!="function"&&(e=ls(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i=C&&(C=E+1);!(k=v[C])&&++C=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function Rv(e){e||(e=Tv);function t(d,f){return d&&f?e(d.__data__,f.__data__):!d-!f}for(var n=this._groups,r=n.length,i=new Array(r),o=0;ot?1:e>=t?0:NaN}function Av(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Lv(){return Array.from(this)}function qv(){for(var e=this._groups,t=0,n=e.length;t1?this.each((t==null?Gv:typeof t=="function"?Yv:Uv)(e,t,n??"")):Ut(this.node(),e)}function Ut(e,t){return e.style.getPropertyValue(t)||pf(e).getComputedStyle(e,null).getPropertyValue(t)}function Zv(e){return function(){delete this[e]}}function Xv(e,t){return function(){this[e]=t}}function Wv(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Qv(e,t){return arguments.length>1?this.each((t==null?Zv:typeof t=="function"?Wv:Xv)(e,t)):this.node()[e]}function gf(e){return e.trim().split(/^|\s+/)}function ds(e){return e.classList||new mf(e)}function mf(e){this._node=e,this._names=gf(e.getAttribute("class")||"")}mf.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function vf(e,t){for(var n=ds(e),r=-1,i=t.length;++r=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function N0(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n()=>e;function La(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:s,dx:u,dy:l,dispatch:c}){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:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:c}})}La.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function $0(e){return!e.ctrlKey&&!e.button}function j0(){return this.parentNode}function F0(e,t){return t??{x:e.x,y:e.y}}function D0(){return navigator.maxTouchPoints||"ontouchstart"in this}function O0(){var e=$0,t=j0,n=F0,r=D0,i={},o=hr("start","drag","end"),a=0,s,u,l,c,d=0;function f(w){w.on("mousedown.drag",h).filter(r).on("touchstart.drag",v).on("touchmove.drag",y,P0).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(w,k){if(!(c||!e.call(this,w,k))){var N=C(this,t.call(this,w,k),w,k,"mouse");N&&(Te(w.view).on("mousemove.drag",m,dn).on("mouseup.drag",g,dn),wf(w.view),Ar(w),l=!1,s=w.clientX,u=w.clientY,N("start",w))}}function m(w){if(zt(w),!l){var k=w.clientX-s,N=w.clientY-u;l=k*k+N*N>d}i.mouse("drag",w)}function g(w){Te(w.view).on("mousemove.drag mouseup.drag",null),_f(w.view,l),zt(w),i.mouse("end",w)}function v(w,k){if(e.call(this,w,k)){var N=w.changedTouches,A=t.call(this,w,k),P=N.length,q,B;for(q=0;q>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?An(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?An(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=B0.exec(e))?new Se(t[1],t[2],t[3],1):(t=H0.exec(e))?new Se(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=V0.exec(e))?An(t[1],t[2],t[3],t[4]):(t=G0.exec(e))?An(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=U0.exec(e))?oc(t[1],t[2]/100,t[3]/100,1):(t=Y0.exec(e))?oc(t[1],t[2]/100,t[3]/100,t[4]):Js.hasOwnProperty(e)?nc(Js[e]):e==="transparent"?new Se(NaN,NaN,NaN,0):null}function nc(e){return new Se(e>>16&255,e>>8&255,e&255,1)}function An(e,t,n,r){return r<=0&&(e=t=n=NaN),new Se(e,t,n,r)}function X0(e){return e instanceof In||(e=pn(e)),e?(e=e.rgb(),new Se(e.r,e.g,e.b,e.opacity)):new Se}function qa(e,t,n,r){return arguments.length===1?X0(e):new Se(e,t,n,r??1)}function Se(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}fs(Se,qa,Ef(In,{brighter(e){return e=e==null?Xn:Math.pow(Xn,e),new Se(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?fn:Math.pow(fn,e),new Se(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Se(It(this.r),It(this.g),It(this.b),Wn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:rc,formatHex:rc,formatHex8:W0,formatRgb:ic,toString:ic}));function rc(){return`#${St(this.r)}${St(this.g)}${St(this.b)}`}function W0(){return`#${St(this.r)}${St(this.g)}${St(this.b)}${St((isNaN(this.opacity)?1:this.opacity)*255)}`}function ic(){const e=Wn(this.opacity);return`${e===1?"rgb(":"rgba("}${It(this.r)}, ${It(this.g)}, ${It(this.b)}${e===1?")":`, ${e})`}`}function Wn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function It(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function St(e){return e=It(e),(e<16?"0":"")+e.toString(16)}function oc(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new je(e,t,n,r)}function Sf(e){if(e instanceof je)return new je(e.h,e.s,e.l,e.opacity);if(e instanceof In||(e=pn(e)),!e)return new je;if(e instanceof je)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,s=o-i,u=(o+i)/2;return s?(t===o?a=(n-r)/s+(n0&&u<1?0:a,new je(a,s,u,e.opacity)}function Q0(e,t,n,r){return arguments.length===1?Sf(e):new je(e,t,n,r??1)}function je(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}fs(je,Q0,Ef(In,{brighter(e){return e=e==null?Xn:Math.pow(Xn,e),new je(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?fn:Math.pow(fn,e),new je(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,i=2*n-r;return new Se(Lr(e>=240?e-240:e+120,i,r),Lr(e,i,r),Lr(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new je(ac(this.h),Ln(this.s),Ln(this.l),Wn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=Wn(this.opacity);return`${e===1?"hsl(":"hsla("}${ac(this.h)}, ${Ln(this.s)*100}%, ${Ln(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ac(e){return e=(e||0)%360,e<0?e+360:e}function Ln(e){return Math.max(0,Math.min(1,e||0))}function Lr(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Cf=e=>()=>e;function J0(e,t){return function(n){return e+n*t}}function ey(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function ty(e){return(e=+e)==1?Nf:function(t,n){return n-t?ey(t,n,e):Cf(isNaN(t)?n:t)}}function Nf(e,t){var n=t-e;return n?J0(e,n):Cf(isNaN(e)?t:e)}const sc=function e(t){var n=ty(t);function r(i,o){var a=n((i=qa(i)).r,(o=qa(o)).r),s=n(i.g,o.g),u=n(i.b,o.b),l=Nf(i.opacity,o.opacity);return function(c){return i.r=a(c),i.g=s(c),i.b=u(c),i.opacity=l(c),i+""}}return r.gamma=e,r}(1);function ct(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Pa=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,qr=new RegExp(Pa.source,"g");function ny(e){return function(){return e}}function ry(e){return function(t){return e(t)+""}}function iy(e,t){var n=Pa.lastIndex=qr.lastIndex=0,r,i,o,a=-1,s=[],u=[];for(e=e+"",t=t+"";(r=Pa.exec(e))&&(i=qr.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),s[a]?s[a]+=o:s[++a]=o),(r=r[0])===(i=i[0])?s[a]?s[a]+=i:s[++a]=i:(s[++a]=null,u.push({i:a,x:ct(r,i)})),n=qr.lastIndex;return n180?c+=360:c-l>180&&(l+=360),f.push({i:d.push(i(d)+"rotate(",null,r)-2,x:ct(l,c)})):c&&d.push(i(d)+"rotate("+c+r)}function s(l,c,d,f){l!==c?f.push({i:d.push(i(d)+"skewX(",null,r)-2,x:ct(l,c)}):c&&d.push(i(d)+"skewX("+c+r)}function u(l,c,d,f,h,m){if(l!==d||c!==f){var g=h.push(i(h)+"scale(",null,",",null,")");m.push({i:g-4,x:ct(l,d)},{i:g-2,x:ct(c,f)})}else(d!==1||f!==1)&&h.push(i(h)+"scale("+d+","+f+")")}return function(l,c){var d=[],f=[];return l=e(l),c=e(c),o(l.translateX,l.translateY,c.translateX,c.translateY,d,f),a(l.rotate,c.rotate,d,f),s(l.skewX,c.skewX,d,f),u(l.scaleX,l.scaleY,c.scaleX,c.scaleY,d,f),l=c=null,function(h){for(var m=-1,g=f.length,v;++m=0&&e._call.call(void 0,t),e=e._next;--Yt}function lc(){Tt=(Jn=gn.now())+gr,Yt=on=0;try{py()}finally{Yt=0,my(),Tt=0}}function gy(){var e=gn.now(),t=e-Jn;t>kf&&(gr-=t,Jn=e)}function my(){for(var e,t=Qn,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Qn=n);an=e,ja(r)}function ja(e){if(!Yt){on&&(on=clearTimeout(on));var t=e-Tt;t>24?(e<1/0&&(on=setTimeout(lc,e-gn.now()-gr)),Jt&&(Jt=clearInterval(Jt))):(Jt||(Jn=gn.now(),Jt=setInterval(gy,kf)),Yt=1,Rf(lc))}}function dc(e,t,n){var r=new er;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var vy=hr("start","end","cancel","interrupt"),yy=[],Af=0,fc=1,Fa=2,Hn=3,hc=4,Da=5,Vn=6;function mr(e,t,n,r,i,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;by(e,n,{name:t,index:r,group:i,on:vy,tween:yy,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Af})}function ps(e,t){var n=De(e,t);if(n.state>Af)throw new Error("too late; already scheduled");return n}function Ye(e,t){var n=De(e,t);if(n.state>Hn)throw new Error("too late; already running");return n}function De(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function by(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=Tf(o,0,n.time);function o(l){n.state=fc,n.timer.restart(a,n.delay,n.time),n.delay<=l&&a(l-n.delay)}function a(l){var c,d,f,h;if(n.state!==fc)return u();for(c in r)if(h=r[c],h.name===n.name){if(h.state===Hn)return dc(a);h.state===hc?(h.state=Vn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[c]):+cFa&&r.state=0&&(t=t.slice(0,n)),!t||t==="start"})}function Zy(e,t,n){var r,i,o=Ky(t)?ps:Ye;return function(){var a=o(this,e),s=a.on;s!==r&&(i=(r=s).copy()).on(t,n),a.on=i}}function Xy(e,t){var n=this._id;return arguments.length<2?De(this.node(),n).on.on(e):this.each(Zy(n,e,t))}function Wy(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Qy(){return this.on("end.remove",Wy(this._id))}function Jy(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ls(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a()=>e;function Sb(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function We(e,t,n){this.k=e,this.x=t,this.y=n}We.prototype={constructor:We,scale:function(e){return e===1?this:new We(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new We(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var et=new We(1,0,0);We.prototype;function Pr(e){e.stopImmediatePropagation()}function en(e){e.preventDefault(),e.stopImmediatePropagation()}function Cb(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Nb(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function pc(){return this.__zoom||et}function Mb(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Ib(){return navigator.maxTouchPoints||"ontouchstart"in this}function kb(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function $f(){var e=Cb,t=Nb,n=kb,r=Mb,i=Ib,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],s=250,u=fy,l=hr("start","zoom","end"),c,d,f,h=500,m=150,g=0,v=10;function y(b){b.property("__zoom",pc).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",B).filter(i).on("touchstart.zoom",F).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(b,M,S,_){var I=b.selection?b.selection():b;I.property("__zoom",pc),b!==I?k(b,M,S,_):I.interrupt().each(function(){N(this,arguments).event(_).start().zoom(null,typeof M=="function"?M.apply(this,arguments):M).end()})},y.scaleBy=function(b,M,S,_){y.scaleTo(b,function(){var I=this.__zoom.k,T=typeof M=="function"?M.apply(this,arguments):M;return I*T},S,_)},y.scaleTo=function(b,M,S,_){y.transform(b,function(){var I=t.apply(this,arguments),T=this.__zoom,L=S==null?w(I):typeof S=="function"?S.apply(this,arguments):S,z=T.invert(L),V=typeof M=="function"?M.apply(this,arguments):M;return n(C(E(T,V),L,z),I,a)},S,_)},y.translateBy=function(b,M,S,_){y.transform(b,function(){return n(this.__zoom.translate(typeof M=="function"?M.apply(this,arguments):M,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),a)},null,_)},y.translateTo=function(b,M,S,_,I){y.transform(b,function(){var T=t.apply(this,arguments),L=this.__zoom,z=_==null?w(T):typeof _=="function"?_.apply(this,arguments):_;return n(et.translate(z[0],z[1]).scale(L.k).translate(typeof M=="function"?-M.apply(this,arguments):-M,typeof S=="function"?-S.apply(this,arguments):-S),T,a)},_,I)};function E(b,M){return M=Math.max(o[0],Math.min(o[1],M)),M===b.k?b:new We(M,b.x,b.y)}function C(b,M,S){var _=M[0]-S[0]*b.k,I=M[1]-S[1]*b.k;return _===b.x&&I===b.y?b:new We(b.k,_,I)}function w(b){return[(+b[0][0]+ +b[1][0])/2,(+b[0][1]+ +b[1][1])/2]}function k(b,M,S,_){b.on("start.zoom",function(){N(this,arguments).event(_).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(_).end()}).tween("zoom",function(){var I=this,T=arguments,L=N(I,T).event(_),z=t.apply(I,T),V=S==null?w(z):typeof S=="function"?S.apply(I,T):S,Y=Math.max(z[1][0]-z[0][0],z[1][1]-z[0][1]),G=I.__zoom,X=typeof M=="function"?M.apply(I,T):M,Q=u(G.invert(V).concat(Y/G.k),X.invert(V).concat(Y/X.k));return function(ee){if(ee===1)ee=X;else{var D=Q(ee),H=Y/D[2];ee=new We(H,V[0]-D[0]*H,V[1]-D[1]*H)}L.zoom(null,ee)}})}function N(b,M,S){return!S&&b.__zooming||new A(b,M)}function A(b,M){this.that=b,this.args=M,this.active=0,this.sourceEvent=null,this.extent=t.apply(b,M),this.taps=0}A.prototype={event:function(b){return b&&(this.sourceEvent=b),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(b,M){return this.mouse&&b!=="mouse"&&(this.mouse[1]=M.invert(this.mouse[0])),this.touch0&&b!=="touch"&&(this.touch0[1]=M.invert(this.touch0[0])),this.touch1&&b!=="touch"&&(this.touch1[1]=M.invert(this.touch1[0])),this.that.__zoom=M,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(b){var M=Te(this.that).datum();l.call(b,this.that,new Sb(b,{sourceEvent:this.sourceEvent,target:y,type:b,transform:this.that.__zoom,dispatch:l}),M)}};function P(b,...M){if(!e.apply(this,arguments))return;var S=N(this,M).event(b),_=this.__zoom,I=Math.max(o[0],Math.min(o[1],_.k*Math.pow(2,r.apply(this,arguments)))),T=$e(b);if(S.wheel)(S.mouse[0][0]!==T[0]||S.mouse[0][1]!==T[1])&&(S.mouse[1]=_.invert(S.mouse[0]=T)),clearTimeout(S.wheel);else{if(_.k===I)return;S.mouse=[T,_.invert(T)],Gn(this),S.start()}en(b),S.wheel=setTimeout(L,m),S.zoom("mouse",n(C(E(_,I),S.mouse[0],S.mouse[1]),S.extent,a));function L(){S.wheel=null,S.end()}}function q(b,...M){if(f||!e.apply(this,arguments))return;var S=b.currentTarget,_=N(this,M,!0).event(b),I=Te(b.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",Y,!0),T=$e(b,S),L=b.clientX,z=b.clientY;wf(b.view),Pr(b),_.mouse=[T,this.__zoom.invert(T)],Gn(this),_.start();function V(G){if(en(G),!_.moved){var X=G.clientX-L,Q=G.clientY-z;_.moved=X*X+Q*Q>g}_.event(G).zoom("mouse",n(C(_.that.__zoom,_.mouse[0]=$e(G,S),_.mouse[1]),_.extent,a))}function Y(G){I.on("mousemove.zoom mouseup.zoom",null),_f(G.view,_.moved),en(G),_.event(G).end()}}function B(b,...M){if(e.apply(this,arguments)){var S=this.__zoom,_=$e(b.changedTouches?b.changedTouches[0]:b,this),I=S.invert(_),T=S.k*(b.shiftKey?.5:2),L=n(C(E(S,T),_,I),t.apply(this,M),a);en(b),s>0?Te(this).transition().duration(s).call(k,L,_,b):Te(this).call(y.transform,L,_,b)}}function F(b,...M){if(e.apply(this,arguments)){var S=b.touches,_=S.length,I=N(this,M,b.changedTouches.length===_).event(b),T,L,z,V;for(Pr(b),L=0;L<_;++L)z=S[L],V=$e(z,this),V=[V,this.__zoom.invert(V),z.identifier],I.touch0?!I.touch1&&I.touch0[2]!==V[2]&&(I.touch1=V,I.taps=0):(I.touch0=V,T=!0,I.taps=1+!!c);c&&(c=clearTimeout(c)),T&&(I.taps<2&&(d=V[0],c=setTimeout(function(){c=null},h)),Gn(this),I.start())}}function $(b,...M){if(this.__zooming){var S=N(this,M).event(b),_=b.changedTouches,I=_.length,T,L,z,V;for(en(b),T=0;T"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.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 React Flow 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,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,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".`},jf=gt.error001();function re(e,t){const n=x.useContext(vr);if(n===null)throw new Error(jf);return Qm(n,e,t)}const pe=()=>{const e=x.useContext(vr);if(e===null)throw new Error(jf);return x.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},Tb=e=>e.userSelectionActive?"none":"all";function ms({position:e,children:t,className:n,style:r,...i}){const o=re(Tb),a=`${e}`.split("-");return p.jsx("div",{className:ve(["react-flow__panel",n,...a]),style:{...r,pointerEvents:o},...i,children:t})}function Ab({proOptions:e,position:t="bottom-right"}){return e?.hideAttribution?null:p.jsx(ms,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:p.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Lb=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:i=!0,labelBgStyle:o={},labelBgPadding:a=[2,4],labelBgBorderRadius:s=2,children:u,className:l,...c})=>{const d=x.useRef(null),[f,h]=x.useState({x:0,y:0,width:0,height:0}),m=ve(["react-flow__edge-textwrapper",l]);return x.useEffect(()=>{if(d.current){const g=d.current.getBBox();h({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),typeof n>"u"||!n?null:p.jsxs("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:m,visibility:f.width?"visible":"hidden",...c,children:[i&&p.jsx("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:s,ry:s}),p.jsx("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:d,style:r,children:n}),u]})};var qb=x.memo(Lb);const vs=e=>({width:e.offsetWidth,height:e.offsetHeight}),Kt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ys=(e={x:0,y:0},t)=>({x:Kt(e.x,t[0][0],t[1][0]),y:Kt(e.y,t[0][1],t[1][1])}),gc=(e,t,n)=>en?-Kt(Math.abs(e-n),1,50)/50:0,Ff=(e,t)=>{const n=gc(e.x,35,t.width-35)*20,r=gc(e.y,35,t.height-35)*20;return[n,r]},Df=e=>e.getRootNode?.()||window?.document,Of=(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)}),tr=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),zf=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),mc=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),Pb=(e,t)=>zf(Of(tr(e),tr(t))),Oa=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},$b=e=>Ae(e.width)&&Ae(e.height)&&Ae(e.x)&&Ae(e.y),Ae=e=>!isNaN(e)&&isFinite(e),le=Symbol.for("internals"),Bf=["Enter"," ","Escape"],jb=(e,t)=>{},Fb=e=>"nativeEvent"in e;function za(e){const n=(Fb(e)?e.nativeEvent:e).composedPath?.()?.[0]||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n?.nodeName)||n?.hasAttribute("contenteditable")||!!n?.closest(".nokey")}const Hf=e=>"clientX"in e,ht=(e,t)=>{const n=Hf(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)}},kn=({id:e,path:t,labelX:n,labelY:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l,style:c,markerEnd:d,markerStart:f,interactionWidth:h=20})=>p.jsxs(p.Fragment,{children:[p.jsx("path",{id:e,style:c,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:d,markerStart:f}),h&&p.jsx("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:h,className:"react-flow__edge-interaction"}),i&&Ae(n)&&Ae(r)?p.jsx(qb,{x:n,y:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l}):null]});kn.displayName="BaseEdge";const Db=(e,t)=>typeof t<"u"&&t?`url(#${t})`:typeof e<"u"?`url(#react-flow__${e})`:"none";function tn(e,t,n){return n===void 0?n:r=>{const i=t().edges.find(o=>o.id===e);i&&n(r,{...i})}}function Vf({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n{const[v,y,E]=Uf({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o});return p.jsx(kn,{path:v,labelX:y,labelY:E,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:m,interactionWidth:g})});bs.displayName="SimpleBezierEdge";const yc={[O.Left]:{x:-1,y:0},[O.Right]:{x:1,y:0},[O.Top]:{x:0,y:-1},[O.Bottom]:{x:0,y:1}},Ob=({source:e,sourcePosition:t=O.Bottom,target:n})=>t===O.Left||t===O.Right?e.xMath.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function zb({source:e,sourcePosition:t=O.Bottom,target:n,targetPosition:r=O.Top,center:i,offset:o}){const a=yc[t],s=yc[r],u={x:e.x+a.x*o,y:e.y+a.y*o},l={x:n.x+s.x*o,y:n.y+s.y*o},c=Ob({source:u,sourcePosition:t,target:l}),d=c.x!==0?"x":"y",f=c[d];let h=[],m,g;const[v,y,E,C]=Vf({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[d]*s[d]===-1){m=i.x||v,g=i.y||y;const k=[{x:m,y:u.y},{x:m,y:l.y}],N=[{x:u.x,y:g},{x:l.x,y:g}];a[d]===f?h=d==="x"?k:N:h=d==="x"?N:k}else{const k=[{x:u.x,y:l.y}],N=[{x:l.x,y:u.y}];if(d==="x"?h=a.x===f?N:k:h=a.y===f?k:N,t!==r){const A=d==="x"?"y":"x",P=a[d]===s[A],q=u[A]>l[A],B=u[A]{let C="";return E>0&&E{const[y,E,C]=Ba({sourceX:e,sourceY:t,sourcePosition:d,targetX:n,targetY:r,targetPosition:f,borderRadius:g?.borderRadius,offset:g?.offset});return p.jsx(kn,{path:y,labelX:E,labelY:C,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l,style:c,markerEnd:h,markerStart:m,interactionWidth:v})});yr.displayName="SmoothStepEdge";const xs=x.memo(e=>p.jsx(yr,{...e,pathOptions:x.useMemo(()=>({borderRadius:0,offset:e.pathOptions?.offset}),[e.pathOptions?.offset])}));xs.displayName="StepEdge";function Hb({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,a,s]=Vf({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,a,s]}const ws=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l,style:c,markerEnd:d,markerStart:f,interactionWidth:h})=>{const[m,g,v]=Hb({sourceX:e,sourceY:t,targetX:n,targetY:r});return p.jsx(kn,{path:m,labelX:g,labelY:v,label:i,labelStyle:o,labelShowBg:a,labelBgStyle:s,labelBgPadding:u,labelBgBorderRadius:l,style:c,markerEnd:d,markerStart:f,interactionWidth:h})});ws.displayName="StraightEdge";function $n(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function xc({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case O.Left:return[t-$n(t-r,o),n];case O.Right:return[t+$n(r-t,o),n];case O.Top:return[t,n-$n(n-i,o)];case O.Bottom:return[t,n+$n(i-n,o)]}}function _s({sourceX:e,sourceY:t,sourcePosition:n=O.Bottom,targetX:r,targetY:i,targetPosition:o=O.Top,curvature:a=.25}){const[s,u]=xc({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[l,c]=xc({pos:o,x1:r,y1:i,x2:e,y2:t,c:a}),[d,f,h,m]=Gf({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:s,sourceControlY:u,targetControlX:l,targetControlY:c});return[`M${e},${t} C${s},${u} ${l},${c} ${r},${i}`,d,f,h,m]}const rr=x.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:i=O.Bottom,targetPosition:o=O.Top,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:m,pathOptions:g,interactionWidth:v})=>{const[y,E,C]=_s({sourceX:e,sourceY:t,sourcePosition:i,targetX:n,targetY:r,targetPosition:o,curvature:g?.curvature});return p.jsx(kn,{path:y,labelX:E,labelY:C,label:a,labelStyle:s,labelShowBg:u,labelBgStyle:l,labelBgPadding:c,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:m,interactionWidth:v})});rr.displayName="BezierEdge";const Es=x.createContext(null),Vb=Es.Provider;Es.Consumer;const Gb=()=>x.useContext(Es),Ub=e=>"id"in e&&"source"in e&&"target"in e,Yb=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Ha=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,Kb=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Zb=(e,t)=>{if(!e.source||!e.target)return t;let n;return Ub(e)?n={...e}:n={...e,id:Yb(e)},Kb(n,t)?t:t.concat(n)},Yf=({x:e,y:t},[n,r,i],o,[a,s])=>{const u={x:(e-n)/i,y:(t-r)/i};return o?{x:a*Math.round(u.x/a),y:s*Math.round(u.y/s)}:u},Xb=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r}),kt=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],i={x:e.position.x-n,y:e.position.y-r};return{...i,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:i}},Ss=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const{x:o,y:a}=kt(i,t).positionAbsolute;return Of(r,tr({x:o,y:a,width:i.width||0,height:i.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return zf(n)},Kf=(e,t,[n,r,i]=[0,0,1],o=!1,a=!1,s=[0,0])=>{const u={x:(t.x-n)/i,y:(t.y-r)/i,width:t.width/i,height:t.height/i},l=[];return e.forEach(c=>{const{width:d,height:f,selectable:h=!0,hidden:m=!1}=c;if(a&&!h||m)return!1;const{positionAbsolute:g}=kt(c,s),v={x:g.x,y:g.y,width:d||0,height:f||0},y=Oa(u,v),E=typeof d>"u"||typeof f>"u"||d===null||f===null,C=o&&y>0,w=(d||0)*(f||0);(E||C||y>=w||c.dragging)&&l.push(c)}),l},Zf=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},Xf=(e,t,n,r,i,o=.1)=>{const a=t/(e.width*(1+o)),s=n/(e.height*(1+o)),u=Math.min(a,s),l=Kt(u,r,i),c=e.x+e.width/2,d=e.y+e.height/2,f=t/2-c*l,h=n/2-d*l;return[f,h,l]},xt=(e,t=0)=>e.transition().duration(t);function wc(e,t,n,r){return(t[n]||[]).reduce((i,o)=>(`${e.id}-${o.id}-${n}`!==r&&i.push({id:o.id||null,type:n,nodeId:e.id,x:(e.positionAbsolute?.x??0)+o.x+o.width/2,y:(e.positionAbsolute?.y??0)+o.y+o.height/2}),i),[])}function Wb(e,t,n,r,i,o){const{x:a,y:s}=ht(e),l=t.elementsFromPoint(a,s).find(m=>m.classList.contains("react-flow__handle"));if(l){const m=l.getAttribute("data-nodeid");if(m){const g=Cs(void 0,l),v=l.getAttribute("data-handleid"),y=o({nodeId:m,id:v,type:g});if(y)return{handle:{id:v,type:g,nodeId:m,x:n.x,y:n.y},validHandleResult:y}}}let c=[],d=1/0;if(i.forEach(m=>{const g=Math.sqrt((m.x-n.x)**2+(m.y-n.y)**2);if(g<=r){const v=o(m);g<=d&&(gm.isValid),h=c.some(({handle:m})=>m.type==="target");return c.find(({handle:m,validHandleResult:g})=>h?m.type==="target":f?g.isValid:!0)||c[0]}const Qb={source:null,target:null,sourceHandle:null,targetHandle:null},Wf=()=>({handleDomNode:null,isValid:!1,connection:Qb,endHandle:null});function Qf(e,t,n,r,i,o,a){const s=i==="target",u=a.querySelector(`.react-flow__handle[data-id="${e?.nodeId}-${e?.id}-${e?.type}"]`),l={...Wf(),handleDomNode:u};if(u){const c=Cs(void 0,u),d=u.getAttribute("data-nodeid"),f=u.getAttribute("data-handleid"),h=u.classList.contains("connectable"),m=u.classList.contains("connectableend"),g={source:s?d:n,sourceHandle:s?f:r,target:s?n:d,targetHandle:s?r:f};l.connection=g,h&&m&&(t===At.Strict?s&&c==="source"||!s&&c==="target":d!==n||f!==r)&&(l.endHandle={nodeId:d,handleId:f,type:c},l.isValid=o(g))}return l}function Jb({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((i,o)=>{if(o[le]){const{handleBounds:a}=o[le];let s=[],u=[];a&&(s=wc(o,a,"source",`${t}-${n}-${r}`),u=wc(o,a,"target",`${t}-${n}-${r}`)),i.push(...s,...u)}return i},[])}function Cs(e,t){return e||(t?.classList.contains("target")?"target":t?.classList.contains("source")?"source":null)}function $r(e){e?.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function ex(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function Jf({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:i,getState:o,setState:a,isValidConnection:s,edgeUpdaterType:u,onEdgeUpdateEnd:l}){const c=Df(e.target),{connectionMode:d,domNode:f,autoPanOnConnect:h,connectionRadius:m,onConnectStart:g,panBy:v,getNodes:y,cancelConnection:E}=o();let C=0,w;const{x:k,y:N}=ht(e),A=c?.elementFromPoint(k,N),P=Cs(u,A),q=f?.getBoundingClientRect();if(!q||!P)return;let B,F=ht(e,q),$=!1,R=null,b=!1,M=null;const S=Jb({nodes:y(),nodeId:n,handleId:t,handleType:P}),_=()=>{if(!h)return;const[L,z]=Ff(F,q);v({x:L,y:z}),C=requestAnimationFrame(_)};a({connectionPosition:F,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:P,connectionStartHandle:{nodeId:n,handleId:t,type:P},connectionEndHandle:null}),g?.(e,{nodeId:n,handleId:t,handleType:P});function I(L){const{transform:z}=o();F=ht(L,q);const{handle:V,validHandleResult:Y}=Wb(L,c,Yf(F,z,!1,[1,1]),m,S,G=>Qf(G,d,n,t,i?"target":"source",s,c));if(w=V,$||(_(),$=!0),M=Y.handleDomNode,R=Y.connection,b=Y.isValid,a({connectionPosition:w&&b?Xb({x:w.x,y:w.y},z):F,connectionStatus:ex(!!w,b),connectionEndHandle:Y.endHandle}),!w&&!b&&!M)return $r(B);R.source!==R.target&&M&&($r(B),B=M,M.classList.add("connecting","react-flow__handle-connecting"),M.classList.toggle("valid",b),M.classList.toggle("react-flow__handle-valid",b))}function T(L){(w||M)&&R&&b&&r?.(R),o().onConnectEnd?.(L),u&&l?.(L),$r(B),E(),cancelAnimationFrame(C),$=!1,b=!1,R=null,M=null,c.removeEventListener("mousemove",I),c.removeEventListener("mouseup",T),c.removeEventListener("touchmove",I),c.removeEventListener("touchend",T)}c.addEventListener("mousemove",I),c.addEventListener("mouseup",T),c.addEventListener("touchmove",I),c.addEventListener("touchend",T)}const _c=()=>!0,tx=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),nx=(e,t,n)=>r=>{const{connectionStartHandle:i,connectionEndHandle:o,connectionClickStartHandle:a}=r;return{connecting:i?.nodeId===e&&i?.handleId===t&&i?.type===n||o?.nodeId===e&&o?.handleId===t&&o?.type===n,clickConnecting:a?.nodeId===e&&a?.handleId===t&&a?.type===n}},eh=x.forwardRef(({type:e="source",position:t=O.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:a,onConnect:s,children:u,className:l,onMouseDown:c,onTouchStart:d,...f},h)=>{const m=a||null,g=e==="target",v=pe(),y=Gb(),{connectOnClick:E,noPanClassName:C}=re(tx,he),{connecting:w,clickConnecting:k}=re(nx(y,m,e),he);y||v.getState().onError?.("010",gt.error010());const N=q=>{const{defaultEdgeOptions:B,onConnect:F,hasDefaultEdges:$}=v.getState(),R={...B,...q};if($){const{edges:b,setEdges:M}=v.getState();M(Zb(R,b))}F?.(R),s?.(R)},A=q=>{if(!y)return;const B=Hf(q);i&&(B&&q.button===0||!B)&&Jf({event:q,handleId:m,nodeId:y,onConnect:N,isTarget:g,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||_c}),B?c?.(q):d?.(q)},P=q=>{const{onClickConnectStart:B,onClickConnectEnd:F,connectionClickStartHandle:$,connectionMode:R,isValidConnection:b}=v.getState();if(!y||!$&&!i)return;if(!$){B?.(q,{nodeId:y,handleId:m,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:y,type:e,handleId:m}});return}const M=Df(q.target),S=n||b||_c,{connection:_,isValid:I}=Qf({nodeId:y,id:m,type:e},R,$.nodeId,$.handleId||null,$.type,S,M);I&&N(_),F?.(q),v.setState({connectionClickStartHandle:null})};return p.jsx("div",{"data-handleid":m,"data-nodeid":y,"data-handlepos":t,"data-id":`${y}-${m}-${e}`,className:ve(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",C,l,{source:!g,target:g,connectable:r,connectablestart:i,connectableend:o,connecting:k,connectionindicator:r&&(i&&!w||o&&w)}]),onMouseDown:A,onTouchStart:A,onClick:E?P:void 0,ref:h,...f,children:u})});eh.displayName="Handle";var mt=x.memo(eh);const th=({data:e,isConnectable:t,targetPosition:n=O.Top,sourcePosition:r=O.Bottom})=>p.jsxs(p.Fragment,{children:[p.jsx(mt,{type:"target",position:n,isConnectable:t}),e?.label,p.jsx(mt,{type:"source",position:r,isConnectable:t})]});th.displayName="DefaultNode";var Va=x.memo(th);const nh=({data:e,isConnectable:t,sourcePosition:n=O.Bottom})=>p.jsxs(p.Fragment,{children:[e?.label,p.jsx(mt,{type:"source",position:n,isConnectable:t})]});nh.displayName="InputNode";var rh=x.memo(nh);const ih=({data:e,isConnectable:t,targetPosition:n=O.Top})=>p.jsxs(p.Fragment,{children:[p.jsx(mt,{type:"target",position:n,isConnectable:t}),e?.label]});ih.displayName="OutputNode";var oh=x.memo(ih);const Ns=()=>null;Ns.displayName="GroupNode";const rx=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected)}),jn=e=>e.id;function ix(e,t){return he(e.selectedNodes.map(jn),t.selectedNodes.map(jn))&&he(e.selectedEdges.map(jn),t.selectedEdges.map(jn))}const ah=x.memo(({onSelectionChange:e})=>{const t=pe(),{selectedNodes:n,selectedEdges:r}=re(rx,ix);return x.useEffect(()=>{const i={nodes:n,edges:r};e?.(i),t.getState().onSelectionChange?.(i)},[n,r,e]),null});ah.displayName="SelectionListener";const ox=e=>!!e.onSelectionChange;function ax({onSelectionChange:e}){const t=re(ox);return e||t?p.jsx(ah,{onSelectionChange:e}):null}const sx=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Pt(e,t){x.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function J(e,t,n){x.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const cx=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:i,onConnectStart:o,onConnectEnd:a,onClickConnectStart:s,onClickConnectEnd:u,nodesDraggable:l,nodesConnectable:c,nodesFocusable:d,edgesFocusable:f,edgesUpdatable:h,elevateNodesOnSelect:m,minZoom:g,maxZoom:v,nodeExtent:y,onNodesChange:E,onEdgesChange:C,elementsSelectable:w,connectionMode:k,snapGrid:N,snapToGrid:A,translateExtent:P,connectOnClick:q,defaultEdgeOptions:B,fitView:F,fitViewOptions:$,onNodesDelete:R,onEdgesDelete:b,onNodeDrag:M,onNodeDragStart:S,onNodeDragStop:_,onSelectionDrag:I,onSelectionDragStart:T,onSelectionDragStop:L,noPanClassName:z,nodeOrigin:V,rfId:Y,autoPanOnConnect:G,autoPanOnNodeDrag:X,onError:Q,connectionRadius:ee,isValidConnection:D})=>{const{setNodes:H,setEdges:K,setDefaultNodesAndEdges:ne,setMinZoom:ie,setMaxZoom:de,setTranslateExtent:oe,setNodeExtent:U,reset:ce}=re(sx,he),j=pe();return x.useEffect(()=>{const ge=r?.map(ye=>({...ye,...B}));return ne(n,ge),()=>{ce()}},[]),J("defaultEdgeOptions",B,j.setState),J("connectionMode",k,j.setState),J("onConnect",i,j.setState),J("onConnectStart",o,j.setState),J("onConnectEnd",a,j.setState),J("onClickConnectStart",s,j.setState),J("onClickConnectEnd",u,j.setState),J("nodesDraggable",l,j.setState),J("nodesConnectable",c,j.setState),J("nodesFocusable",d,j.setState),J("edgesFocusable",f,j.setState),J("edgesUpdatable",h,j.setState),J("elementsSelectable",w,j.setState),J("elevateNodesOnSelect",m,j.setState),J("snapToGrid",A,j.setState),J("snapGrid",N,j.setState),J("onNodesChange",E,j.setState),J("onEdgesChange",C,j.setState),J("connectOnClick",q,j.setState),J("fitViewOnInit",F,j.setState),J("fitViewOnInitOptions",$,j.setState),J("onNodesDelete",R,j.setState),J("onEdgesDelete",b,j.setState),J("onNodeDrag",M,j.setState),J("onNodeDragStart",S,j.setState),J("onNodeDragStop",_,j.setState),J("onSelectionDrag",I,j.setState),J("onSelectionDragStart",T,j.setState),J("onSelectionDragStop",L,j.setState),J("noPanClassName",z,j.setState),J("nodeOrigin",V,j.setState),J("rfId",Y,j.setState),J("autoPanOnConnect",G,j.setState),J("autoPanOnNodeDrag",X,j.setState),J("onError",Q,j.setState),J("connectionRadius",ee,j.setState),J("isValidConnection",D,j.setState),Pt(e,H),Pt(t,K),Pt(g,ie),Pt(v,de),Pt(P,oe),Pt(y,U),null},Ec={display:"none"},ux={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},sh="react-flow__node-desc",ch="react-flow__edge-desc",lx="react-flow__aria-live",dx=e=>e.ariaLiveMessage;function fx({rfId:e}){const t=re(dx);return p.jsx("div",{id:`${lx}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:ux,children:t})}function hx({rfId:e,disableKeyboardA11y:t}){return p.jsxs(p.Fragment,{children:[p.jsxs("div",{id:`${sh}-${e}`,style:Ec,children:["Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "]}),p.jsx("div",{id:`${ch}-${e}`,style:Ec,children:"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."}),!t&&p.jsx(fx,{rfId:e})]})}const px=(e,t,n)=>n===O.Left?e-t:n===O.Right?e+t:e,gx=(e,t,n)=>n===O.Top?e-t:n===O.Bottom?e+t:e,Sc="react-flow__edgeupdater",Cc=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:a,type:s})=>p.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:a,className:ve([Sc,`${Sc}-${s}`]),cx:px(t,r,e),cy:gx(n,r,e),r,stroke:"transparent",fill:"transparent"}),mx=()=>!0;var $t=e=>{const t=({id:n,className:r,type:i,data:o,onClick:a,onEdgeDoubleClick:s,selected:u,animated:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,style:v,source:y,target:E,sourceX:C,sourceY:w,targetX:k,targetY:N,sourcePosition:A,targetPosition:P,elementsSelectable:q,hidden:B,sourceHandleId:F,targetHandleId:$,onContextMenu:R,onMouseEnter:b,onMouseMove:M,onMouseLeave:S,edgeUpdaterRadius:_,onEdgeUpdate:I,onEdgeUpdateStart:T,onEdgeUpdateEnd:L,markerEnd:z,markerStart:V,rfId:Y,ariaLabel:G,isFocusable:X,isUpdatable:Q,pathOptions:ee,interactionWidth:D})=>{const H=x.useRef(null),[K,ne]=x.useState(!1),[ie,de]=x.useState(!1),oe=pe(),U=x.useMemo(()=>`url(#${Ha(V,Y)})`,[V,Y]),ce=x.useMemo(()=>`url(#${Ha(z,Y)})`,[z,Y]);if(B)return null;const j=me=>{const{edges:Re,addSelectedEdges:Ve}=oe.getState();if(q&&(oe.setState({nodesSelectionActive:!1}),Ve([n])),a){const be=Re.find(Ee=>Ee.id===n);a(me,be)}},ge=tn(n,oe.getState,s),ye=tn(n,oe.getState,R),yt=tn(n,oe.getState,b),ze=tn(n,oe.getState,M),_e=tn(n,oe.getState,S),ue=(me,Re)=>{if(me.button!==0)return;const{edges:Ve,isValidConnection:be}=oe.getState(),Ee=Re?E:y,Xt=(Re?$:F)||null,Wt=Re?"target":"source",Cr=be||mx,Nr=Re,Qt=Ve.find(bt=>bt.id===n);de(!0),T?.(me,Qt,Wt);const Mr=bt=>{de(!1),L?.(bt,Qt,Wt)};Jf({event:me,handleId:Xt,nodeId:Ee,onConnect:bt=>I?.(Qt,bt),isTarget:Nr,getState:oe.getState,setState:oe.setState,isValidConnection:Cr,edgeUpdaterType:Wt,onEdgeUpdateEnd:Mr})},Ne=me=>ue(me,!0),Pe=me=>ue(me,!1),Be=()=>ne(!0),He=()=>ne(!1),ke=!q&&!a,Ke=me=>{if(Bf.includes(me.key)&&q){const{unselectNodesAndEdges:Re,addSelectedEdges:Ve,edges:be}=oe.getState();me.key==="Escape"?(H.current?.blur(),Re({edges:[be.find(Xt=>Xt.id===n)]})):Ve([n])}};return p.jsxs("g",{className:ve(["react-flow__edge",`react-flow__edge-${i}`,r,{selected:u,animated:l,inactive:ke,updating:K}]),onClick:j,onDoubleClick:ge,onContextMenu:ye,onMouseEnter:yt,onMouseMove:ze,onMouseLeave:_e,onKeyDown:X?Ke:void 0,tabIndex:X?0:void 0,role:X?"button":void 0,"data-testid":`rf__edge-${n}`,"aria-label":G===null?void 0:G||`Edge from ${y} to ${E}`,"aria-describedby":X?`${ch}-${Y}`:void 0,ref:H,children:[!ie&&p.jsx(e,{id:n,source:y,target:E,selected:u,animated:l,label:c,labelStyle:d,labelShowBg:f,labelBgStyle:h,labelBgPadding:m,labelBgBorderRadius:g,data:o,style:v,sourceX:C,sourceY:w,targetX:k,targetY:N,sourcePosition:A,targetPosition:P,sourceHandleId:F,targetHandleId:$,markerStart:U,markerEnd:ce,pathOptions:ee,interactionWidth:D}),Q&&p.jsxs(p.Fragment,{children:[(Q==="source"||Q===!0)&&p.jsx(Cc,{position:A,centerX:C,centerY:w,radius:_,onMouseDown:Ne,onMouseEnter:Be,onMouseOut:He,type:"source"}),(Q==="target"||Q===!0)&&p.jsx(Cc,{position:P,centerX:k,centerY:N,radius:_,onMouseDown:Pe,onMouseEnter:Be,onMouseOut:He,type:"target"})]})]})};return t.displayName="EdgeWrapper",x.memo(t)};function vx(e){const t={default:$t(e.default||rr),straight:$t(e.bezier||ws),step:$t(e.step||xs),smoothstep:$t(e.step||yr),simplebezier:$t(e.simplebezier||bs)},n={},r=Object.keys(e).filter(i=>!["default","bezier"].includes(i)).reduce((i,o)=>(i[o]=$t(e[o]||rr),i),n);return{...t,...r}}function Nc(e,t,n=null){const r=(n?.x||0)+t.x,i=(n?.y||0)+t.y,o=n?.width||t.width,a=n?.height||t.height;switch(e){case O.Top:return{x:r+o/2,y:i};case O.Right:return{x:r+o,y:i+a/2};case O.Bottom:return{x:r+o/2,y:i+a};case O.Left:return{x:r,y:i+a/2}}}function Mc(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const yx=(e,t,n,r,i,o)=>{const a=Nc(n,e,t),s=Nc(o,r,i);return{sourceX:a.x,sourceY:a.y,targetX:s.x,targetY:s.y}};function bx({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:i,targetHeight:o,width:a,height:s,transform:u}){const l={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+i),y2:Math.max(e.y+r,t.y+o)};l.x===l.x2&&(l.x2+=1),l.y===l.y2&&(l.y2+=1);const c=tr({x:(0-u[0])/u[2],y:(0-u[1])/u[2],width:a/u[2],height:s/u[2]}),d=Math.max(0,Math.min(c.x2,l.x2)-Math.max(c.x,l.x)),f=Math.max(0,Math.min(c.y2,l.y2)-Math.max(c.y,l.y));return Math.ceil(d*f)>0}function Ic(e){const t=e?.[le]?.handleBounds||null,n=t&&e?.width&&e?.height&&typeof e?.positionAbsolute?.x<"u"&&typeof e?.positionAbsolute?.y<"u";return[{x:e?.positionAbsolute?.x||0,y:e?.positionAbsolute?.y||0,width:e?.width||0,height:e?.height||0},t,!!n]}function uh(e,t){if(!e.parentNode)return!1;const n=t.get(e.parentNode);return n?n.selected?!0:uh(n,t):!1}function kc(e,t,n){let r=e;do{if(r?.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function xx(e,t,n,r){return Array.from(e.values()).filter(i=>(i.selected||i.id===r)&&(!i.parentNode||!uh(i,e))&&(i.draggable||t&&typeof i.draggable>"u")).map(i=>({id:i.id,position:i.position||{x:0,y:0},positionAbsolute:i.positionAbsolute||{x:0,y:0},distance:{x:n.x-(i.positionAbsolute?.x??0),y:n.y-(i.positionAbsolute?.y??0)},delta:{x:0,y:0},extent:i.extent,parentNode:i.parentNode,width:i.width,height:i.height}))}function wx(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function lh(e,t,n,r,i=[0,0],o){const a=wx(e,e.extent||r);let s=a;if(e.extent==="parent")if(e.parentNode&&e.width&&e.height){const c=n.get(e.parentNode),{x:d,y:f}=kt(c,i).positionAbsolute;s=c&&Ae(d)&&Ae(f)&&Ae(c.width)&&Ae(c.height)?[[d+e.width*i[0],f+e.height*i[1]],[d+c.width-e.width+e.width*i[0],f+c.height-e.height+e.height*i[1]]]:s}else o?.("005",gt.error005()),s=a;else if(e.extent&&e.parentNode){const c=n.get(e.parentNode),{x:d,y:f}=kt(c,i).positionAbsolute;s=[[e.extent[0][0]+d,e.extent[0][1]+f],[e.extent[1][0]+d,e.extent[1][1]+f]]}let u={x:0,y:0};if(e.parentNode){const c=n.get(e.parentNode);u=kt(c,i).positionAbsolute}const l=s?ys(t,s):t;return{position:{x:l.x-u.x,y:l.y-u.y},positionAbsolute:l}}function jr({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(i=>({...n.get(i.id),position:i.position,positionAbsolute:i.positionAbsolute}));return[e?r.find(i=>i.id===e):r[0],r]}const Rc=(e,t,n,r)=>{const i=t.querySelectorAll(e);if(!i||!i.length)return null;const o=Array.from(i),a=t.getBoundingClientRect(),s={x:a.width*r[0],y:a.height*r[1]};return o.map(u=>{const l=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),position:u.getAttribute("data-handlepos"),x:(l.left-a.left-s.x)/n,y:(l.top-a.top-s.y)/n,...vs(u)}})};function nn(e,t,n){return n===void 0?n:r=>{const i=t().nodeInternals.get(e);n(r,{...i})}}function Ga({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:a,nodeInternals:s}=t.getState(),u=s.get(e);t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function _x(){const e=pe();return x.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:i,snapToGrid:o}=e.getState(),a=n.touches?n.touches[0].clientX:n.clientX,s=n.touches?n.touches[0].clientY:n.clientY,u={x:(a-r[0])/r[2],y:(s-r[1])/r[2]};return{xSnapped:o?i[0]*Math.round(u.x/i[0]):u.x,ySnapped:o?i[1]*Math.round(u.y/i[1]):u.y,...u}},[])}function Fr(e){return(t,n,r)=>e?.(t,r)}function dh({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,selectNodesOnDrag:a}){const s=pe(),[u,l]=x.useState(!1),c=x.useRef([]),d=x.useRef({x:null,y:null}),f=x.useRef(0),h=x.useRef(null),m=x.useRef({x:0,y:0}),g=x.useRef(null),v=x.useRef(!1),y=_x();return x.useEffect(()=>{if(e?.current){const E=Te(e.current),C=({x:k,y:N})=>{const{nodeInternals:A,onNodeDrag:P,onSelectionDrag:q,updateNodePositions:B,nodeExtent:F,snapGrid:$,snapToGrid:R,nodeOrigin:b,onError:M}=s.getState();d.current={x:k,y:N};let S=!1;if(c.current=c.current.map(I=>{const T={x:k-I.distance.x,y:N-I.distance.y};R&&(T.x=$[0]*Math.round(T.x/$[0]),T.y=$[1]*Math.round(T.y/$[1]));const L=lh(I,T,A,F,b,M);return S=S||I.position.x!==L.position.x||I.position.y!==L.position.y,I.position=L.position,I.positionAbsolute=L.positionAbsolute,I}),!S)return;B(c.current,!0,!0),l(!0);const _=i?P:Fr(q);if(_&&g.current){const[I,T]=jr({nodeId:i,dragItems:c.current,nodeInternals:A});_(g.current,I,T)}},w=()=>{if(!h.current)return;const[k,N]=Ff(m.current,h.current);if(k!==0||N!==0){const{transform:A,panBy:P}=s.getState();d.current.x=(d.current.x??0)-k/A[2],d.current.y=(d.current.y??0)-N/A[2],P({x:k,y:N})&&C(d.current)}f.current=requestAnimationFrame(w)};if(t)E.on(".drag",null);else{const k=O0().on("start",N=>{const{nodeInternals:A,multiSelectionActive:P,domNode:q,nodesDraggable:B,unselectNodesAndEdges:F,onNodeDragStart:$,onSelectionDragStart:R}=s.getState(),b=i?$:Fr(R);!a&&!P&&i&&(A.get(i)?.selected||F()),i&&o&&a&&Ga({id:i,store:s,nodeRef:e});const M=y(N);if(d.current=M,c.current=xx(A,B,M,i),b&&c.current){const[S,_]=jr({nodeId:i,dragItems:c.current,nodeInternals:A});b(N.sourceEvent,S,_)}h.current=q?.getBoundingClientRect()||null,m.current=ht(N.sourceEvent,h.current)}).on("drag",N=>{const A=y(N),{autoPanOnNodeDrag:P}=s.getState();!v.current&&P&&(v.current=!0,w()),(d.current.x!==A.xSnapped||d.current.y!==A.ySnapped)&&c.current&&(g.current=N.sourceEvent,m.current=ht(N.sourceEvent,h.current),C(A))}).on("end",N=>{if(l(!1),v.current=!1,cancelAnimationFrame(f.current),c.current){const{updateNodePositions:A,nodeInternals:P,onNodeDragStop:q,onSelectionDragStop:B}=s.getState(),F=i?q:Fr(B);if(A(c.current,!1,!1),F){const[$,R]=jr({nodeId:i,dragItems:c.current,nodeInternals:P});F(N.sourceEvent,$,R)}}}).filter(N=>{const A=N.target;return!N.button&&(!n||!kc(A,`.${n}`,e))&&(!r||kc(A,r,e))});return E.call(k),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,s,i,a,y]),u}function fh(){const e=pe();return x.useCallback(n=>{const{nodeInternals:r,nodeExtent:i,updateNodePositions:o,getNodes:a,snapToGrid:s,snapGrid:u,onError:l,nodesDraggable:c}=e.getState(),d=a().filter(E=>E.selected&&(E.draggable||c&&typeof E.draggable>"u")),f=s?u[0]:5,h=s?u[1]:5,m=n.isShiftPressed?4:1,g=n.x*f*m,v=n.y*h*m,y=d.map(E=>{if(E.positionAbsolute){const C={x:E.positionAbsolute.x+g,y:E.positionAbsolute.y+v};s&&(C.x=u[0]*Math.round(C.x/u[0]),C.y=u[1]*Math.round(C.y/u[1]));const{positionAbsolute:w,position:k}=lh(E,C,r,i,void 0,l);E.position=k,E.positionAbsolute=w}return E});o(y,!0,!1)},[])}const Vt={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var rn=e=>{const t=({id:n,type:r,data:i,xPos:o,yPos:a,xPosOrigin:s,yPosOrigin:u,selected:l,onClick:c,onMouseEnter:d,onMouseMove:f,onMouseLeave:h,onContextMenu:m,onDoubleClick:g,style:v,className:y,isDraggable:E,isSelectable:C,isConnectable:w,isFocusable:k,selectNodesOnDrag:N,sourcePosition:A,targetPosition:P,hidden:q,resizeObserver:B,dragHandle:F,zIndex:$,isParent:R,noDragClassName:b,noPanClassName:M,initialized:S,disableKeyboardA11y:_,ariaLabel:I,rfId:T})=>{const L=pe(),z=x.useRef(null),V=x.useRef(A),Y=x.useRef(P),G=x.useRef(r),X=C||E||c||d||f||h,Q=fh(),ee=nn(n,L.getState,d),D=nn(n,L.getState,f),H=nn(n,L.getState,h),K=nn(n,L.getState,m),ne=nn(n,L.getState,g),ie=U=>{if(C&&(!N||!E)&&Ga({id:n,store:L,nodeRef:z}),c){const ce=L.getState().nodeInternals.get(n);c(U,{...ce})}},de=U=>{if(!za(U))if(Bf.includes(U.key)&&C){const ce=U.key==="Escape";Ga({id:n,store:L,unselect:ce,nodeRef:z})}else!_&&E&&l&&Object.prototype.hasOwnProperty.call(Vt,U.key)&&(L.setState({ariaLiveMessage:`Moved selected node ${U.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~a}`}),Q({x:Vt[U.key].x,y:Vt[U.key].y,isShiftPressed:U.shiftKey}))};x.useEffect(()=>{if(z.current&&!q){const U=z.current;return B?.observe(U),()=>B?.unobserve(U)}},[q]),x.useEffect(()=>{const U=G.current!==r,ce=V.current!==A,j=Y.current!==P;z.current&&(U||ce||j)&&(U&&(G.current=r),ce&&(V.current=A),j&&(Y.current=P),L.getState().updateNodeDimensions([{id:n,nodeElement:z.current,forceUpdate:!0}]))},[n,r,A,P]);const oe=dh({nodeRef:z,disabled:q||!E,noDragClassName:b,handleSelector:F,nodeId:n,isSelectable:C,selectNodesOnDrag:N});return q?null:p.jsx("div",{className:ve(["react-flow__node",`react-flow__node-${r}`,{[M]:E},y,{selected:l,selectable:C,parent:R,dragging:oe}]),ref:z,style:{zIndex:$,transform:`translate(${s}px,${u}px)`,pointerEvents:X?"all":"none",visibility:S?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ee,onMouseMove:D,onMouseLeave:H,onContextMenu:K,onClick:ie,onDoubleClick:ne,onKeyDown:k?de:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":_?void 0:`${sh}-${T}`,"aria-label":I,children:p.jsx(Vb,{value:n,children:p.jsx(e,{id:n,data:i,type:r,xPos:o,yPos:a,selected:l,isConnectable:w,sourcePosition:A,targetPosition:P,dragging:oe,dragHandle:F,zIndex:$})})})};return t.displayName="NodeWrapper",x.memo(t)};function Ex(e){const t={input:rn(e.input||rh),default:rn(e.default||Va),output:rn(e.output||oh),group:rn(e.group||Ns)},n={},r=Object.keys(e).filter(i=>!["input","default","output","group"].includes(i)).reduce((i,o)=>(i[o]=rn(e[o]||Va),i),n);return{...t,...r}}const Sx=({x:e,y:t,width:n,height:r,origin:i})=>!n||!r?{x:e,y:t}:i[0]<0||i[1]<0||i[0]>1||i[1]>1?{x:e,y:t}:{x:e-n*i[0],y:t-r*i[1]},Cx=typeof document<"u"?document:null;var vn=(e=null,t={target:Cx})=>{const[n,r]=x.useState(!1),i=x.useRef(!1),o=x.useRef(new Set([])),[a,s]=x.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(d=>typeof d=="string").map(d=>d.split("+")),c=l.reduce((d,f)=>d.concat(...f),[]);return[l,c]}return[[],[]]},[e]);return x.useEffect(()=>{if(e!==null){const u=d=>{if(i.current=d.ctrlKey||d.metaKey||d.shiftKey,!i.current&&za(d))return!1;const f=Ac(d.code,s);o.current.add(d[f]),Tc(a,o.current,!1)&&(d.preventDefault(),r(!0))},l=d=>{if(!i.current&&za(d))return!1;const f=Ac(d.code,s);Tc(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(d[f]),i.current=!1},c=()=>{o.current.clear(),r(!1)};return t?.target?.addEventListener("keydown",u),t?.target?.addEventListener("keyup",l),window.addEventListener("blur",c),()=>{t?.target?.removeEventListener("keydown",u),t?.target?.removeEventListener("keyup",l),window.removeEventListener("blur",c)}}},[e,r]),n};function Tc(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function Ac(e,t){return t.includes(e)?"code":"key"}function hh(e,t,n,r){if(!e.parentNode)return n;const i=t.get(e.parentNode),o=kt(i,r);return hh(i,t,{x:(n.x??0)+o.x,y:(n.y??0)+o.y,z:(i[le]?.z??0)>(n.z??0)?i[le]?.z??0:n.z??0},r)}function ph(e,t,n){e.forEach(r=>{if(r.parentNode&&!e.has(r.parentNode))throw new Error(`Parent node ${r.parentNode} not found`);if(r.parentNode||n?.[r.id]){const{x:i,y:o,z:a}=hh(r,e,{...r.position,z:r[le]?.z??0},t);r.positionAbsolute={x:i,y:o},r[le].z=a,n?.[r.id]&&(r[le].isParent=!0)}})}function Dr(e,t,n,r){const i=new Map,o={},a=r?1e3:0;return e.forEach(s=>{const u=(Ae(s.zIndex)?s.zIndex:0)+(s.selected?a:0),l=t.get(s.id),c={width:l?.width,height:l?.height,...s,positionAbsolute:{x:s.position.x,y:s.position.y}};s.parentNode&&(c.parentNode=s.parentNode,o[s.parentNode]=!0),Object.defineProperty(c,le,{enumerable:!1,value:{handleBounds:l?.[le]?.handleBounds,z:u}}),i.set(s.id,c)}),ph(i,n,o),i}function gh(e,t={}){const{getNodes:n,width:r,height:i,minZoom:o,maxZoom:a,d3Zoom:s,d3Selection:u,fitViewOnInitDone:l,fitViewOnInit:c,nodeOrigin:d}=e(),f=t.initial&&!l&&c;if(s&&u&&(f||!t.initial)){const m=n().filter(v=>{const y=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return t.nodes?.length?y&&t.nodes.some(E=>E.id===v.id):y}),g=m.every(v=>v.width&&v.height);if(m.length>0&&g){const v=Ss(m,d),[y,E,C]=Xf(v,r,i,t.minZoom??o,t.maxZoom??a,t.padding??.1),w=et.translate(y,E).scale(C);return typeof t.duration=="number"&&t.duration>0?s.transform(xt(u,t.duration),w):s.transform(u,w),!0}}return!1}function Nx(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[le]:r[le],selected:n.selected})}),new Map(t)}function Mx(e,t){return t.map(n=>{const r=e.find(i=>i.id===n.id);return r&&(n.selected=r.selected),n})}function Fn({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:i,edges:o,onNodesChange:a,onEdgesChange:s,hasDefaultNodes:u,hasDefaultEdges:l}=n();e?.length&&(u&&r({nodeInternals:Nx(e,i)}),a?.(e)),t?.length&&(l&&r({edges:Mx(t,o)}),s?.(t))}const jt=()=>{},Ix={zoomIn:jt,zoomOut:jt,zoomTo:jt,getZoom:()=>1,setViewport:jt,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:jt,fitBounds:jt,project:e=>e,viewportInitialized:!1},kx=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),Rx=()=>{const e=pe(),{d3Zoom:t,d3Selection:n}=re(kx,he);return x.useMemo(()=>n&&t?{zoomIn:i=>t.scaleBy(xt(n,i?.duration),1.2),zoomOut:i=>t.scaleBy(xt(n,i?.duration),1/1.2),zoomTo:(i,o)=>t.scaleTo(xt(n,o?.duration),i),getZoom:()=>e.getState().transform[2],setViewport:(i,o)=>{const[a,s,u]=e.getState().transform,l=et.translate(i.x??a,i.y??s).scale(i.zoom??u);t.transform(xt(n,o?.duration),l)},getViewport:()=>{const[i,o,a]=e.getState().transform;return{x:i,y:o,zoom:a}},fitView:i=>gh(e.getState,i),setCenter:(i,o,a)=>{const{width:s,height:u,maxZoom:l}=e.getState(),c=typeof a?.zoom<"u"?a.zoom:l,d=s/2-i*c,f=u/2-o*c,h=et.translate(d,f).scale(c);t.transform(xt(n,a?.duration),h)},fitBounds:(i,o)=>{const{width:a,height:s,minZoom:u,maxZoom:l}=e.getState(),[c,d,f]=Xf(i,a,s,u,l,o?.padding??.1),h=et.translate(c,d).scale(f);t.transform(xt(n,o?.duration),h)},project:i=>{const{transform:o,snapToGrid:a,snapGrid:s}=e.getState();return Yf(i,o,a,s)},viewportInitialized:!0}:Ix,[t,n])};function Ms(){const e=Rx(),t=pe(),n=x.useCallback(()=>t.getState().getNodes().map(g=>({...g})),[]),r=x.useCallback(g=>t.getState().nodeInternals.get(g),[]),i=x.useCallback(()=>{const{edges:g=[]}=t.getState();return g.map(v=>({...v}))},[]),o=x.useCallback(g=>{const{edges:v=[]}=t.getState();return v.find(y=>y.id===g)},[]),a=x.useCallback(g=>{const{getNodes:v,setNodes:y,hasDefaultNodes:E,onNodesChange:C}=t.getState(),w=v(),k=typeof g=="function"?g(w):g;if(E)y(k);else if(C){const N=k.length===0?w.map(A=>({type:"remove",id:A.id})):k.map(A=>({item:A,type:"reset"}));C(N)}},[]),s=x.useCallback(g=>{const{edges:v=[],setEdges:y,hasDefaultEdges:E,onEdgesChange:C}=t.getState(),w=typeof g=="function"?g(v):g;if(E)y(w);else if(C){const k=w.length===0?v.map(N=>({type:"remove",id:N.id})):w.map(N=>({item:N,type:"reset"}));C(k)}},[]),u=x.useCallback(g=>{const v=Array.isArray(g)?g:[g],{getNodes:y,setNodes:E,hasDefaultNodes:C,onNodesChange:w}=t.getState();if(C){const N=[...y(),...v];E(N)}else if(w){const k=v.map(N=>({item:N,type:"add"}));w(k)}},[]),l=x.useCallback(g=>{const v=Array.isArray(g)?g:[g],{edges:y=[],setEdges:E,hasDefaultEdges:C,onEdgesChange:w}=t.getState();if(C)E([...y,...v]);else if(w){const k=v.map(N=>({item:N,type:"add"}));w(k)}},[]),c=x.useCallback(()=>{const{getNodes:g,edges:v=[],transform:y}=t.getState(),[E,C,w]=y;return{nodes:g().map(k=>({...k})),edges:v.map(k=>({...k})),viewport:{x:E,y:C,zoom:w}}},[]),d=x.useCallback(({nodes:g,edges:v})=>{const{nodeInternals:y,getNodes:E,edges:C,hasDefaultNodes:w,hasDefaultEdges:k,onNodesDelete:N,onEdgesDelete:A,onNodesChange:P,onEdgesChange:q}=t.getState(),B=(g||[]).map(M=>M.id),F=(v||[]).map(M=>M.id),$=E().reduce((M,S)=>{const _=!B.includes(S.id)&&S.parentNode&&M.find(T=>T.id===S.parentNode);return(typeof S.deletable=="boolean"?S.deletable:!0)&&(B.includes(S.id)||_)&&M.push(S),M},[]),R=C.filter(M=>typeof M.deletable=="boolean"?M.deletable:!0),b=R.filter(M=>F.includes(M.id));if($||b){const M=Zf($,R),S=[...b,...M],_=S.reduce((I,T)=>(I.includes(T.id)||I.push(T.id),I),[]);if((k||w)&&(k&&t.setState({edges:C.filter(I=>!_.includes(I.id))}),w&&($.forEach(I=>{y.delete(I.id)}),t.setState({nodeInternals:new Map(y)}))),_.length>0&&(A?.(S),q&&q(_.map(I=>({id:I,type:"remove"})))),$.length>0&&(N?.($),P)){const I=$.map(T=>({id:T.id,type:"remove"}));P(I)}}},[]),f=x.useCallback(g=>{const v=$b(g),y=v?null:t.getState().nodeInternals.get(g.id);return[v?g:mc(y),y,v]},[]),h=x.useCallback((g,v=!0,y)=>{const[E,C,w]=f(g);return E?(y||t.getState().getNodes()).filter(k=>{if(!w&&(k.id===C.id||!k.positionAbsolute))return!1;const N=mc(k),A=Oa(N,E);return v&&A>0||A>=g.width*g.height}):[]},[]),m=x.useCallback((g,v,y=!0)=>{const[E]=f(g);if(!E)return!1;const C=Oa(E,v);return y&&C>0||C>=g.width*g.height},[]);return x.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:i,getEdge:o,setNodes:a,setEdges:s,addNodes:u,addEdges:l,toObject:c,deleteElements:d,getIntersectingNodes:h,isNodeIntersecting:m}),[e,n,r,i,o,a,s,u,l,c,d,h,m])}var Tx=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=pe(),{deleteElements:r}=Ms(),i=vn(e),o=vn(t);x.useEffect(()=>{if(i){const{edges:a,getNodes:s}=n.getState(),u=s().filter(c=>c.selected),l=a.filter(c=>c.selected);r({nodes:u,edges:l}),n.setState({nodesSelectionActive:!1})}},[i]),x.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function Ax(e){const t=pe();x.useEffect(()=>{let n;const r=()=>{if(!e.current)return;const i=vs(e.current);(i.height===0||i.width===0)&&t.getState().onError?.("004",gt.error004()),t.setState({width:i.width||500,height:i.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const Is={position:"absolute",width:"100%",height:"100%",top:0,left:0},Lx=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Or=e=>({x:e.x,y:e.y,zoom:e.k}),Ft=(e,t)=>e.target.closest(`.${t}`),Lc=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),qx=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),Px=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:i=!0,zoomOnPinch:o=!0,panOnScroll:a=!1,panOnScrollSpeed:s=.5,panOnScrollMode:u=Ht.Free,zoomOnDoubleClick:l=!0,elementsSelectable:c,panOnDrag:d=!0,defaultViewport:f,translateExtent:h,minZoom:m,maxZoom:g,zoomActivationKeyCode:v,preventScrolling:y=!0,children:E,noWheelClassName:C,noPanClassName:w})=>{const k=x.useRef(),N=pe(),A=x.useRef(!1),P=x.useRef(!1),q=x.useRef(null),B=x.useRef({x:0,y:0,zoom:0}),{d3Zoom:F,d3Selection:$,d3ZoomHandler:R,userSelectionActive:b}=re(qx,he),M=vn(v),S=x.useRef(0);return Ax(q),x.useEffect(()=>{if(q.current){const _=q.current.getBoundingClientRect(),I=$f().scaleExtent([m,g]).translateExtent(h),T=Te(q.current).call(I),L=et.translate(f.x,f.y).scale(Kt(f.zoom,m,g)),z=[[0,0],[_.width,_.height]],V=I.constrain()(L,z,h);I.transform(T,V),N.setState({d3Zoom:I,d3Selection:T,d3ZoomHandler:T.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:q.current.closest(".react-flow")})}},[]),x.useEffect(()=>{$&&F&&(a&&!M&&!b?$.on("wheel.zoom",_=>{if(Ft(_,C))return!1;_.preventDefault(),_.stopImmediatePropagation();const I=$.property("__zoom").k||1;if(_.ctrlKey&&o){const V=$e(_),Y=-_.deltaY*(_.deltaMode===1?.05:_.deltaMode?1:.002)*10,G=I*Math.pow(2,Y);F.scaleTo($,G,V);return}const T=_.deltaMode===1?20:1,L=u===Ht.Vertical?0:_.deltaX*T,z=u===Ht.Horizontal?0:_.deltaY*T;F.translateBy($,-(L/I)*s,-(z/I)*s)},{passive:!1}):typeof R<"u"&&$.on("wheel.zoom",function(_,I){if(!y||Ft(_,C))return null;_.preventDefault(),R.call(this,_,I)},{passive:!1}))},[b,a,u,$,F,R,M,o,y,C]),x.useEffect(()=>{F&&F.on("start",_=>{if(!_.sourceEvent)return null;S.current=_.sourceEvent.button;const{onViewportChangeStart:I}=N.getState();if(A.current=!0,_.sourceEvent?.type==="mousedown"&&N.setState({paneDragging:!0}),t||I){const T=Or(_.transform);B.current=T,I?.(T),t?.(_.sourceEvent,T)}})},[F,t]),x.useEffect(()=>{F&&(b&&!A.current?F.on("zoom",null):b||F.on("zoom",_=>{const{onViewportChange:I}=N.getState();if(N.setState({transform:[_.transform.x,_.transform.y,_.transform.k]}),P.current=!!(r&&Lc(d,S.current??0)),e||I){const T=Or(_.transform);I?.(T),e?.(_.sourceEvent,T)}}))},[b,F,e,d,r]),x.useEffect(()=>{F&&F.on("end",_=>{if(!_.sourceEvent)return null;const{onViewportChangeEnd:I}=N.getState();if(A.current=!1,N.setState({paneDragging:!1}),r&&Lc(d,S.current??0)&&!P.current&&r(_.sourceEvent),P.current=!1,(n||I)&&Lx(B.current,_.transform)){const T=Or(_.transform);B.current=T,clearTimeout(k.current),k.current=setTimeout(()=>{I?.(T),n?.(_.sourceEvent,T)},a?150:0)}})},[F,a,d,n,r]),x.useEffect(()=>{F&&F.filter(_=>{const I=M||i,T=o&&_.ctrlKey;if(_.button===1&&_.type==="mousedown"&&(Ft(_,"react-flow__node")||Ft(_,"react-flow__edge")))return!0;if(!d&&!I&&!a&&!l&&!o||b||!l&&_.type==="dblclick"||Ft(_,C)&&_.type==="wheel"||Ft(_,w)&&_.type!=="wheel"||!o&&_.ctrlKey&&_.type==="wheel"||!I&&!a&&!T&&_.type==="wheel"||!d&&(_.type==="mousedown"||_.type==="touchstart")||Array.isArray(d)&&!d.includes(_.button)&&(_.type==="mousedown"||_.type==="touchstart"))return!1;const L=Array.isArray(d)&&d.includes(_.button)||!_.button||_.button<=1;return(!_.ctrlKey||_.type==="wheel")&&L})},[b,F,i,o,a,l,d,c,M]),p.jsx("div",{className:"react-flow__renderer",ref:q,style:Is,children:E})},$x=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function jx(){const{userSelectionActive:e,userSelectionRect:t}=re($x,he);return e&&t?p.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function qc(e,t){const n=e.find(r=>r.id===t.parentNode);if(n){const r=t.position.x+t.width-n.width,i=t.position.y+t.height-n.height;if(r>0||i>0||t.position.x<0||t.position.y<0){if(n.style={...n.style},n.style.width=n.style.width??n.width,n.style.height=n.style.height??n.height,r>0&&(n.style.width+=r),i>0&&(n.style.height+=i),t.position.x<0){const o=Math.abs(t.position.x);n.position.x=n.position.x-o,n.style.width+=o,t.position.x=0}if(t.position.y<0){const o=Math.abs(t.position.y);n.position.y=n.position.y-o,n.style.height+=o,t.position.y=0}n.width=n.style.width,n.height=n.style.height}}}function mh(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,i)=>{const o=e.filter(s=>s.id===i.id);if(o.length===0)return r.push(i),r;const a={...i};for(const s of o)if(s)switch(s.type){case"select":{a.selected=s.selected;break}case"position":{typeof s.position<"u"&&(a.position=s.position),typeof s.positionAbsolute<"u"&&(a.positionAbsolute=s.positionAbsolute),typeof s.dragging<"u"&&(a.dragging=s.dragging),a.expandParent&&qc(r,a);break}case"dimensions":{typeof s.dimensions<"u"&&(a.width=s.dimensions.width,a.height=s.dimensions.height),typeof s.updateStyle<"u"&&(a.style={...a.style||{},...s.dimensions}),typeof s.resizing=="boolean"&&(a.resizing=s.resizing),a.expandParent&&qc(r,a);break}case"remove":return r}return r.push(a),r},n)}function vh(e,t){return mh(e,t)}function Fx(e,t){return mh(e,t)}const ut=(e,t)=>({id:e,type:"select",selected:t});function Dt(e,t){return e.reduce((n,r)=>{const i=t.includes(r.id);return!r.selected&&i?(r.selected=!0,n.push(ut(r.id,!0))):r.selected&&!i&&(r.selected=!1,n.push(ut(r.id,!1))),n},[])}const zr=(e,t)=>n=>{n.target===t.current&&e?.(n)},Dx=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),yh=x.memo(({isSelecting:e,selectionMode:t=mn.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:i,onPaneClick:o,onPaneContextMenu:a,onPaneScroll:s,onPaneMouseEnter:u,onPaneMouseMove:l,onPaneMouseLeave:c,children:d})=>{const f=x.useRef(null),h=pe(),m=x.useRef(0),g=x.useRef(0),v=x.useRef(),{userSelectionActive:y,elementsSelectable:E,dragging:C}=re(Dx,he),w=()=>{h.setState({userSelectionActive:!1,userSelectionRect:null}),m.current=0,g.current=0},k=R=>{o?.(R),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},N=R=>{if(Array.isArray(n)&&n?.includes(2)){R.preventDefault();return}a?.(R)},A=s?R=>s(R):void 0,P=R=>{const{resetSelectedElements:b,domNode:M}=h.getState();if(v.current=M?.getBoundingClientRect(),!E||!e||R.button!==0||R.target!==f.current||!v.current)return;const{x:S,y:_}=ht(R,v.current);b(),h.setState({userSelectionRect:{width:0,height:0,startX:S,startY:_,x:S,y:_}}),r?.(R)},q=R=>{const{userSelectionRect:b,nodeInternals:M,edges:S,transform:_,onNodesChange:I,onEdgesChange:T,nodeOrigin:L,getNodes:z}=h.getState();if(!e||!v.current||!b)return;h.setState({userSelectionActive:!0,nodesSelectionActive:!1});const V=ht(R,v.current),Y=b.startX??0,G=b.startY??0,X={...b,x:V.xK.id),H=ee.map(K=>K.id);if(m.current!==H.length){m.current=H.length;const K=Dt(Q,H);K.length&&I?.(K)}if(g.current!==D.length){g.current=D.length;const K=Dt(S,D);K.length&&T?.(K)}h.setState({userSelectionRect:X})},B=R=>{if(R.button!==0)return;const{userSelectionRect:b}=h.getState();!y&&b&&R.target===f.current&&k?.(R),h.setState({nodesSelectionActive:m.current>0}),w(),i?.(R)},F=R=>{y&&(h.setState({nodesSelectionActive:m.current>0}),i?.(R)),w()},$=E&&(e||y);return p.jsxs("div",{className:ve(["react-flow__pane",{dragging:C,selection:e}]),onClick:$?void 0:zr(k,f),onContextMenu:zr(N,f),onWheel:zr(A,f),onMouseEnter:$?void 0:u,onMouseDown:$?P:void 0,onMouseMove:$?q:l,onMouseUp:$?B:void 0,onMouseLeave:$?F:c,ref:f,style:Is,children:[d,p.jsx(jx,{})]})});yh.displayName="Pane";const Ox=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Ss(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function zx({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=pe(),{width:i,height:o,x:a,y:s,transformString:u,userSelectionActive:l}=re(Ox,he),c=fh(),d=x.useRef(null);if(x.useEffect(()=>{n||d.current?.focus({preventScroll:!0})},[n]),dh({nodeRef:d}),l||!i||!o)return null;const f=e?m=>{const g=r.getState().getNodes().filter(v=>v.selected);e(m,g)}:void 0,h=m=>{Object.prototype.hasOwnProperty.call(Vt,m.key)&&c({x:Vt[m.key].x,y:Vt[m.key].y,isShiftPressed:m.shiftKey})};return p.jsx("div",{className:ve(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u},children:p.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:i,height:o,top:s,left:a}})})}var Bx=x.memo(zx);const Hx=e=>e.nodesSelectionActive,bh=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,deleteKeyCode:s,onMove:u,onMoveStart:l,onMoveEnd:c,selectionKeyCode:d,selectionOnDrag:f,selectionMode:h,onSelectionStart:m,onSelectionEnd:g,multiSelectionKeyCode:v,panActivationKeyCode:y,zoomActivationKeyCode:E,elementsSelectable:C,zoomOnScroll:w,zoomOnPinch:k,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:P,zoomOnDoubleClick:q,panOnDrag:B,defaultViewport:F,translateExtent:$,minZoom:R,maxZoom:b,preventScrolling:M,onSelectionContextMenu:S,noWheelClassName:_,noPanClassName:I,disableKeyboardA11y:T})=>{const L=re(Hx),z=vn(d),Y=vn(y)||B,G=z||f&&Y!==!0;return Tx({deleteKeyCode:s,multiSelectionKeyCode:v}),p.jsx(Px,{onMove:u,onMoveStart:l,onMoveEnd:c,onPaneContextMenu:o,elementsSelectable:C,zoomOnScroll:w,zoomOnPinch:k,panOnScroll:N,panOnScrollSpeed:A,panOnScrollMode:P,zoomOnDoubleClick:q,panOnDrag:!z&&Y,defaultViewport:F,translateExtent:$,minZoom:R,maxZoom:b,zoomActivationKeyCode:E,preventScrolling:M,noWheelClassName:_,noPanClassName:I,children:p.jsxs(yh,{onSelectionStart:m,onSelectionEnd:g,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:Y,isSelecting:!!G,selectionMode:h,children:[e,L&&p.jsx(Bx,{onSelectionContextMenu:S,noPanClassName:I,disableKeyboardA11y:T})]})})};bh.displayName="FlowRenderer";var Vx=x.memo(bh);function Gx(e){return re(x.useCallback(n=>e?Kf(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}const Ux=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),xh=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,updateNodeDimensions:o,onError:a}=re(Ux,he),s=Gx(e.onlyRenderVisibleElements),u=x.useRef(),l=x.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const c=new ResizeObserver(d=>{const f=d.map(h=>({id:h.target.getAttribute("data-id"),nodeElement:h.target,forceUpdate:!0}));o(f)});return u.current=c,c},[]);return x.useEffect(()=>()=>{u?.current?.disconnect()},[]),p.jsx("div",{className:"react-flow__nodes",style:Is,children:s.map(c=>{let d=c.type||"default";e.nodeTypes[d]||(a?.("003",gt.error003(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,h=!!(c.draggable||t&&typeof c.draggable>"u"),m=!!(c.selectable||i&&typeof c.selectable>"u"),g=!!(c.connectable||n&&typeof c.connectable>"u"),v=!!(c.focusable||r&&typeof c.focusable>"u"),y=e.nodeExtent?ys(c.positionAbsolute,e.nodeExtent):c.positionAbsolute,E=y?.x??0,C=y?.y??0,w=Sx({x:E,y:C,width:c.width??0,height:c.height??0,origin:e.nodeOrigin});return p.jsx(f,{id:c.id,className:c.className,style:c.style,type:d,data:c.data,sourcePosition:c.sourcePosition||O.Bottom,targetPosition:c.targetPosition||O.Top,hidden:c.hidden,xPos:E,yPos:C,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!c.selected,isDraggable:h,isSelectable:m,isConnectable:g,isFocusable:v,resizeObserver:l,dragHandle:c.dragHandle,zIndex:c[le]?.z??0,isParent:!!c[le]?.isParent,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!c.width&&!!c.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:c.ariaLabel},c.id)})})};xh.displayName="NodeRenderer";var Yx=x.memo(xh);const Kx=[{level:0,isMaxLevel:!0,edges:[]}];function Zx(e,t,n=!1){let r=-1;const i=e.reduce((a,s)=>{const u=Ae(s.zIndex);let l=u?s.zIndex:0;if(n){const c=t.get(s.target),d=t.get(s.source),f=s.selected||c?.selected||d?.selected,h=Math.max(d?.[le]?.z||0,c?.[le]?.z||0,1e3);l=(u?s.zIndex:0)+(f?h:0)}return a[l]?a[l].push(s):a[l]=[s],r=l>r?l:r,a},{}),o=Object.entries(i).map(([a,s])=>{const u=+a;return{edges:s,level:u,isMaxLevel:u===r}});return o.length===0?Kx:o}function Xx(e,t,n){const r=re(x.useCallback(i=>e?i.edges.filter(o=>{const a=t.get(o.source),s=t.get(o.target);return a?.width&&a?.height&&s?.width&&s?.height&&bx({sourcePos:a.positionAbsolute||{x:0,y:0},targetPos:s.positionAbsolute||{x:0,y:0},sourceWidth:a.width,sourceHeight:a.height,targetWidth:s.width,targetHeight:s.height,width:i.width,height:i.height,transform:i.transform})}):i.edges,[e,t]));return Zx(r,t,n)}const Wx=({color:e="none",strokeWidth:t=1})=>p.jsx("polyline",{stroke:e,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,fill:"none",points:"-5,-4 0,0 -5,4"}),Qx=({color:e="none",strokeWidth:t=1})=>p.jsx("polyline",{stroke:e,strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:t,fill:e,points:"-5,-4 0,0 -5,4 -5,-4"}),Pc={[nr.Arrow]:Wx,[nr.ArrowClosed]:Qx};function Jx(e){const t=pe();return x.useMemo(()=>Object.prototype.hasOwnProperty.call(Pc,e)?Pc[e]:(t.getState().onError?.("009",gt.error009(e)),null),[e])}const ew=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:s="auto-start-reverse"})=>{const u=Jx(t);return u?p.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:s,refX:"0",refY:"0",children:p.jsx(u,{color:n,strokeWidth:a})}):null},tw=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((i,o)=>([o.markerStart,o.markerEnd].forEach(a=>{if(a&&typeof a=="object"){const s=Ha(a,t);r.includes(s)||(i.push({id:s,color:a.color||e,...a}),r.push(s))}}),i),[]).sort((i,o)=>i.id.localeCompare(o.id))},wh=({defaultColor:e,rfId:t})=>{const n=re(x.useCallback(tw({defaultColor:e,rfId:t}),[e,t]),(r,i)=>!(r.length!==i.length||r.some((o,a)=>o.id!==i[a].id)));return p.jsx("defs",{children:n.map(r=>p.jsx(ew,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})};wh.displayName="MarkerDefinitions";var nw=x.memo(wh);const rw=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),_h=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:i,noPanClassName:o,onEdgeUpdate:a,onEdgeContextMenu:s,onEdgeMouseEnter:u,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,edgeUpdaterRadius:f,onEdgeDoubleClick:h,onEdgeUpdateStart:m,onEdgeUpdateEnd:g,children:v})=>{const{edgesFocusable:y,edgesUpdatable:E,elementsSelectable:C,width:w,height:k,connectionMode:N,nodeInternals:A,onError:P}=re(rw,he),q=Xx(t,A,n);return w?p.jsxs(p.Fragment,{children:[q.map(({level:B,edges:F,isMaxLevel:$})=>p.jsxs("svg",{style:{zIndex:B},width:w,height:k,className:"react-flow__edges react-flow__container",children:[$&&p.jsx(nw,{defaultColor:e,rfId:r}),p.jsx("g",{children:F.map(R=>{const[b,M,S]=Ic(A.get(R.source)),[_,I,T]=Ic(A.get(R.target));if(!S||!T)return null;let L=R.type||"default";i[L]||(P?.("011",gt.error011(L)),L="default");const z=i[L]||i.default,V=N===At.Strict?I.target:(I.target??[]).concat(I.source??[]),Y=Mc(M.source,R.sourceHandle),G=Mc(V,R.targetHandle),X=Y?.position||O.Bottom,Q=G?.position||O.Top,ee=!!(R.focusable||y&&typeof R.focusable>"u"),D=typeof a<"u"&&(R.updatable||E&&typeof R.updatable>"u");if(!Y||!G)return P?.("008",gt.error008(Y,R)),null;const{sourceX:H,sourceY:K,targetX:ne,targetY:ie}=yx(b,Y,X,_,G,Q);return p.jsx(z,{id:R.id,className:ve([R.className,o]),type:L,data:R.data,selected:!!R.selected,animated:!!R.animated,hidden:!!R.hidden,label:R.label,labelStyle:R.labelStyle,labelShowBg:R.labelShowBg,labelBgStyle:R.labelBgStyle,labelBgPadding:R.labelBgPadding,labelBgBorderRadius:R.labelBgBorderRadius,style:R.style,source:R.source,target:R.target,sourceHandleId:R.sourceHandle,targetHandleId:R.targetHandle,markerEnd:R.markerEnd,markerStart:R.markerStart,sourceX:H,sourceY:K,targetX:ne,targetY:ie,sourcePosition:X,targetPosition:Q,elementsSelectable:C,onEdgeUpdate:a,onContextMenu:s,onMouseEnter:u,onMouseMove:l,onMouseLeave:c,onClick:d,edgeUpdaterRadius:f,onEdgeDoubleClick:h,onEdgeUpdateStart:m,onEdgeUpdateEnd:g,rfId:r,ariaLabel:R.ariaLabel,isFocusable:ee,isUpdatable:D,pathOptions:"pathOptions"in R?R.pathOptions:void 0,interactionWidth:R.interactionWidth},R.id)})})]},B)),v]}):null};_h.displayName="EdgeRenderer";var iw=x.memo(_h);const ow=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function aw({children:e}){const t=re(ow);return p.jsx("div",{className:"react-flow__viewport react-flow__container",style:{transform:t},children:e})}function sw(e){const t=Ms(),n=x.useRef(!1);x.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const cw={[O.Left]:O.Right,[O.Right]:O.Left,[O.Top]:O.Bottom,[O.Bottom]:O.Top},Eh=({nodeId:e,handleType:t,style:n,type:r=lt.Bezier,CustomComponent:i,connectionStatus:o})=>{const{fromNode:a,handleId:s,toX:u,toY:l,connectionMode:c}=re(x.useCallback(N=>({fromNode:N.nodeInternals.get(e),handleId:N.connectionHandleId,toX:(N.connectionPosition.x-N.transform[0])/N.transform[2],toY:(N.connectionPosition.y-N.transform[1])/N.transform[2],connectionMode:N.connectionMode}),[e]),he),d=a?.[le]?.handleBounds;let f=d?.[t];if(c===At.Loose&&(f=f||d?.[t==="source"?"target":"source"]),!a||!f)return null;const h=s?f.find(N=>N.id===s):f[0],m=h?h.x+h.width/2:(a.width??0)/2,g=h?h.y+h.height/2:a.height??0,v=(a.positionAbsolute?.x??0)+m,y=(a.positionAbsolute?.y??0)+g,E=h?.position,C=E?cw[E]:null;if(!E||!C)return null;if(i)return p.jsx(i,{connectionLineType:r,connectionLineStyle:n,fromNode:a,fromHandle:h,fromX:v,fromY:y,toX:u,toY:l,fromPosition:E,toPosition:C,connectionStatus:o});let w="";const k={sourceX:v,sourceY:y,sourcePosition:E,targetX:u,targetY:l,targetPosition:C};return r===lt.Bezier?[w]=_s(k):r===lt.Step?[w]=Ba({...k,borderRadius:0}):r===lt.SmoothStep?[w]=Ba(k):r===lt.SimpleBezier?[w]=Uf(k):w=`M${v},${y} ${u},${l}`,p.jsx("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};Eh.displayName="ConnectionLine";const uw=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function lw({containerStyle:e,style:t,type:n,component:r}){const{nodeId:i,handleType:o,nodesConnectable:a,width:s,height:u,connectionStatus:l}=re(uw,he);return!(i&&o&&s&&a)?null:p.jsx("svg",{style:e,width:s,height:u,className:"react-flow__edges react-flow__connectionline react-flow__container",children:p.jsx("g",{className:ve(["react-flow__connection",l]),children:p.jsx(Eh,{nodeId:i,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:l})})})}const Sh=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:i,onInit:o,onNodeClick:a,onEdgeClick:s,onNodeDoubleClick:u,onEdgeDoubleClick:l,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,onSelectionContextMenu:m,onSelectionStart:g,onSelectionEnd:v,connectionLineType:y,connectionLineStyle:E,connectionLineComponent:C,connectionLineContainerStyle:w,selectionKeyCode:k,selectionOnDrag:N,selectionMode:A,multiSelectionKeyCode:P,panActivationKeyCode:q,zoomActivationKeyCode:B,deleteKeyCode:F,onlyRenderVisibleElements:$,elementsSelectable:R,selectNodesOnDrag:b,defaultViewport:M,translateExtent:S,minZoom:_,maxZoom:I,preventScrolling:T,defaultMarkerColor:L,zoomOnScroll:z,zoomOnPinch:V,panOnScroll:Y,panOnScrollSpeed:G,panOnScrollMode:X,zoomOnDoubleClick:Q,panOnDrag:ee,onPaneClick:D,onPaneMouseEnter:H,onPaneMouseMove:K,onPaneMouseLeave:ne,onPaneScroll:ie,onPaneContextMenu:de,onEdgeUpdate:oe,onEdgeContextMenu:U,onEdgeMouseEnter:ce,onEdgeMouseMove:j,onEdgeMouseLeave:ge,edgeUpdaterRadius:ye,onEdgeUpdateStart:yt,onEdgeUpdateEnd:ze,noDragClassName:_e,noWheelClassName:ue,noPanClassName:Ne,elevateEdgesOnSelect:Pe,disableKeyboardA11y:Be,nodeOrigin:He,nodeExtent:ke,rfId:Ke})=>(sw(o),p.jsx(Vx,{onPaneClick:D,onPaneMouseEnter:H,onPaneMouseMove:K,onPaneMouseLeave:ne,onPaneContextMenu:de,onPaneScroll:ie,deleteKeyCode:F,selectionKeyCode:k,selectionOnDrag:N,selectionMode:A,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:P,panActivationKeyCode:q,zoomActivationKeyCode:B,elementsSelectable:R,onMove:n,onMoveStart:r,onMoveEnd:i,zoomOnScroll:z,zoomOnPinch:V,zoomOnDoubleClick:Q,panOnScroll:Y,panOnScrollSpeed:G,panOnScrollMode:X,panOnDrag:ee,defaultViewport:M,translateExtent:S,minZoom:_,maxZoom:I,onSelectionContextMenu:m,preventScrolling:T,noDragClassName:_e,noWheelClassName:ue,noPanClassName:Ne,disableKeyboardA11y:Be,children:p.jsxs(aw,{children:[p.jsx(iw,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:l,onEdgeUpdate:oe,onlyRenderVisibleElements:$,onEdgeContextMenu:U,onEdgeMouseEnter:ce,onEdgeMouseMove:j,onEdgeMouseLeave:ge,onEdgeUpdateStart:yt,onEdgeUpdateEnd:ze,edgeUpdaterRadius:ye,defaultMarkerColor:L,noPanClassName:Ne,elevateEdgesOnSelect:!!Pe,disableKeyboardA11y:Be,rfId:Ke,children:p.jsx(lw,{style:E,type:y,component:C,containerStyle:w})}),p.jsx("div",{className:"react-flow__edgelabel-renderer"}),p.jsx(Yx,{nodeTypes:e,onNodeClick:a,onNodeDoubleClick:u,onNodeMouseEnter:c,onNodeMouseMove:d,onNodeMouseLeave:f,onNodeContextMenu:h,selectNodesOnDrag:b,onlyRenderVisibleElements:$,noPanClassName:Ne,noDragClassName:_e,disableKeyboardA11y:Be,nodeOrigin:He,nodeExtent:ke,rfId:Ke})]})}));Sh.displayName="GraphView";var dw=x.memo(Sh);const Ua=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ot={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Ua,nodeExtent:Ua,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:At.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:jb,isValidConnection:void 0},fw=()=>Rm((e,t)=>({...ot,setNodes:n=>{const{nodeInternals:r,nodeOrigin:i,elevateNodesOnSelect:o}=t();e({nodeInternals:Dr(n,r,i,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(i=>({...r,...i}))})},setDefaultNodesAndEdges:(n,r)=>{const i=typeof n<"u",o=typeof r<"u",a=i?Dr(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:a,edges:o?r:[],hasDefaultNodes:i,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:i,fitViewOnInit:o,fitViewOnInitDone:a,fitViewOnInitOptions:s,domNode:u,nodeOrigin:l}=t(),c=u?.querySelector(".react-flow__viewport");if(!c)return;const d=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(d.transform),h=n.reduce((g,v)=>{const y=i.get(v.id);if(y){const E=vs(v.nodeElement);!!(E.width&&E.height&&(y.width!==E.width||y.height!==E.height||v.forceUpdate))&&(i.set(y.id,{...y,[le]:{...y[le],handleBounds:{source:Rc(".source",v.nodeElement,f,l),target:Rc(".target",v.nodeElement,f,l)}},...E}),g.push({id:y.id,type:"dimensions",dimensions:E}))}return g},[]);ph(i,l);const m=a||o&&!a&&gh(t,{initial:!0,...s});e({nodeInternals:new Map(i),fitViewOnInitDone:m}),h?.length>0&&r?.(h)},updateNodePositions:(n,r=!0,i=!1)=>{const{triggerNodeChanges:o}=t(),a=n.map(s=>{const u={id:s.id,type:"position",dragging:i};return r&&(u.positionAbsolute=s.positionAbsolute,u.position=s.position),u});o(a)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:i,hasDefaultNodes:o,nodeOrigin:a,getNodes:s,elevateNodesOnSelect:u}=t();if(n?.length){if(o){const l=vh(n,s()),c=Dr(l,i,a,u);e({nodeInternals:c})}r?.(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=t();let a,s=null;r?a=n.map(u=>ut(u,!0)):(a=Dt(o(),n),s=Dt(i,[])),Fn({changedNodes:a,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:i,getNodes:o}=t();let a,s=null;r?a=n.map(u=>ut(u,!0)):(a=Dt(i,n),s=Dt(o(),[])),Fn({changedNodes:s,changedEdges:a,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:i,getNodes:o}=t(),a=n||o(),s=r||i,u=a.map(c=>(c.selected=!1,ut(c.id,!1))),l=s.map(c=>ut(c.id,!1));Fn({changedNodes:u,changedEdges:l,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:i}=t();r?.scaleExtent([n,i]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:i}=t();r?.scaleExtent([i,n]),e({maxZoom:n})},setTranslateExtent:n=>{t().d3Zoom?.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(s=>s.selected).map(s=>ut(s.id,!1)),a=n.filter(s=>s.selected).map(s=>ut(s.id,!1));Fn({changedNodes:o,changedEdges:a,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(i=>{i.positionAbsolute=ys(i.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:i,height:o,d3Zoom:a,d3Selection:s,translateExtent:u}=t();if(!a||!s||!n.x&&!n.y)return!1;const l=et.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),c=[[0,0],[i,o]],d=a?.constrain()(l,c,u);return a.transform(s,d),r[0]!==d.x||r[1]!==d.y||r[2]!==d.k},cancelConnection:()=>e({connectionNodeId:ot.connectionNodeId,connectionHandleId:ot.connectionHandleId,connectionHandleType:ot.connectionHandleType,connectionStatus:ot.connectionStatus,connectionStartHandle:ot.connectionStartHandle,connectionEndHandle:ot.connectionEndHandle}),reset:()=>e({...ot})})),Ch=({children:e})=>{const t=x.useRef(null);return t.current||(t.current=fw()),p.jsx(Rb,{value:t.current,children:e})};Ch.displayName="ReactFlowProvider";const Nh=({children:e})=>x.useContext(vr)?p.jsx(p.Fragment,{children:e}):p.jsx(Ch,{children:e});Nh.displayName="ReactFlowWrapper";function $c(e,t){return x.useRef(null),x.useMemo(()=>t(e),[e])}const hw={input:rh,default:Va,output:oh,group:Ns},pw={default:rr,straight:ws,step:xs,smoothstep:yr,simplebezier:bs},gw=[0,0],mw=[15,15],vw={x:0,y:0,zoom:1},yw={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Mh=x.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o=hw,edgeTypes:a=pw,onNodeClick:s,onEdgeClick:u,onInit:l,onMove:c,onMoveStart:d,onMoveEnd:f,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:E,onNodeMouseMove:C,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:N,onNodeDragStart:A,onNodeDrag:P,onNodeDragStop:q,onNodesDelete:B,onEdgesDelete:F,onSelectionChange:$,onSelectionDragStart:R,onSelectionDrag:b,onSelectionDragStop:M,onSelectionContextMenu:S,onSelectionStart:_,onSelectionEnd:I,connectionMode:T=At.Strict,connectionLineType:L=lt.Bezier,connectionLineStyle:z,connectionLineComponent:V,connectionLineContainerStyle:Y,deleteKeyCode:G="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Q=!1,selectionMode:ee=mn.Full,panActivationKeyCode:D="Space",multiSelectionKeyCode:H="Meta",zoomActivationKeyCode:K="Meta",snapToGrid:ne=!1,snapGrid:ie=mw,onlyRenderVisibleElements:de=!1,selectNodesOnDrag:oe=!0,nodesDraggable:U,nodesConnectable:ce,nodesFocusable:j,nodeOrigin:ge=gw,edgesFocusable:ye,edgesUpdatable:yt,elementsSelectable:ze,defaultViewport:_e=vw,minZoom:ue=.5,maxZoom:Ne=2,translateExtent:Pe=Ua,preventScrolling:Be=!0,nodeExtent:He,defaultMarkerColor:ke="#b1b1b7",zoomOnScroll:Ke=!0,zoomOnPinch:me=!0,panOnScroll:Re=!1,panOnScrollSpeed:Ve=.5,panOnScrollMode:be=Ht.Free,zoomOnDoubleClick:Ee=!0,panOnDrag:Xt=!0,onPaneClick:Wt,onPaneMouseEnter:Cr,onPaneMouseMove:Nr,onPaneMouseLeave:Qt,onPaneScroll:Mr,onPaneContextMenu:Os,children:bt,onEdgeUpdate:$p,onEdgeContextMenu:jp,onEdgeDoubleClick:Fp,onEdgeMouseEnter:Dp,onEdgeMouseMove:Op,onEdgeMouseLeave:zp,onEdgeUpdateStart:Bp,onEdgeUpdateEnd:Hp,edgeUpdaterRadius:Vp=10,onNodesChange:Gp,onEdgesChange:Up,noDragClassName:Yp="nodrag",noWheelClassName:Kp="nowheel",noPanClassName:zs="nopan",fitView:Zp=!1,fitViewOptions:Xp,connectOnClick:Wp=!0,attributionPosition:Qp,proOptions:Jp,defaultEdgeOptions:eg,elevateNodesOnSelect:tg=!0,elevateEdgesOnSelect:ng=!1,disableKeyboardA11y:Bs=!1,autoPanOnConnect:rg=!0,autoPanOnNodeDrag:ig=!0,connectionRadius:og=20,isValidConnection:ag,onError:sg,style:cg,id:Hs,...ug},lg)=>{const dg=$c(o,Ex),fg=$c(a,vx),Ir=Hs||"1";return p.jsx("div",{...ug,style:{...cg,...yw},ref:lg,className:ve(["react-flow",i]),"data-testid":"rf__wrapper",id:Hs,children:p.jsxs(Nh,{children:[p.jsx(dw,{onInit:l,onMove:c,onMoveStart:d,onMoveEnd:f,onNodeClick:s,onEdgeClick:u,onNodeMouseEnter:E,onNodeMouseMove:C,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:N,nodeTypes:dg,edgeTypes:fg,connectionLineType:L,connectionLineStyle:z,connectionLineComponent:V,connectionLineContainerStyle:Y,selectionKeyCode:X,selectionOnDrag:Q,selectionMode:ee,deleteKeyCode:G,multiSelectionKeyCode:H,panActivationKeyCode:D,zoomActivationKeyCode:K,onlyRenderVisibleElements:de,selectNodesOnDrag:oe,defaultViewport:_e,translateExtent:Pe,minZoom:ue,maxZoom:Ne,preventScrolling:Be,zoomOnScroll:Ke,zoomOnPinch:me,zoomOnDoubleClick:Ee,panOnScroll:Re,panOnScrollSpeed:Ve,panOnScrollMode:be,panOnDrag:Xt,onPaneClick:Wt,onPaneMouseEnter:Cr,onPaneMouseMove:Nr,onPaneMouseLeave:Qt,onPaneScroll:Mr,onPaneContextMenu:Os,onSelectionContextMenu:S,onSelectionStart:_,onSelectionEnd:I,onEdgeUpdate:$p,onEdgeContextMenu:jp,onEdgeDoubleClick:Fp,onEdgeMouseEnter:Dp,onEdgeMouseMove:Op,onEdgeMouseLeave:zp,onEdgeUpdateStart:Bp,onEdgeUpdateEnd:Hp,edgeUpdaterRadius:Vp,defaultMarkerColor:ke,noDragClassName:Yp,noWheelClassName:Kp,noPanClassName:zs,elevateEdgesOnSelect:ng,rfId:Ir,disableKeyboardA11y:Bs,nodeOrigin:ge,nodeExtent:He}),p.jsx(cx,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:m,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:U,nodesConnectable:ce,nodesFocusable:j,edgesFocusable:ye,edgesUpdatable:yt,elementsSelectable:ze,elevateNodesOnSelect:tg,minZoom:ue,maxZoom:Ne,nodeExtent:He,onNodesChange:Gp,onEdgesChange:Up,snapToGrid:ne,snapGrid:ie,connectionMode:T,translateExtent:Pe,connectOnClick:Wp,defaultEdgeOptions:eg,fitView:Zp,fitViewOptions:Xp,onNodesDelete:B,onEdgesDelete:F,onNodeDragStart:A,onNodeDrag:P,onNodeDragStop:q,onSelectionDrag:b,onSelectionDragStart:R,onSelectionDragStop:M,noPanClassName:zs,nodeOrigin:ge,rfId:Ir,autoPanOnConnect:rg,autoPanOnNodeDrag:ig,onError:sg,connectionRadius:og,isValidConnection:ag}),p.jsx(ax,{onSelectionChange:$}),bt,p.jsx(Ab,{proOptions:Jp,position:Qp}),p.jsx(hx,{rfId:Ir,disableKeyboardA11y:Bs})]})})});Mh.displayName="ReactFlow";function Ih(e){return t=>{const[n,r]=x.useState(t),i=x.useCallback(o=>r(a=>e(o,a)),[]);return[n,r,i]}}const bw=Ih(vh),xw=Ih(Fx),kh=({id:e,x:t,y:n,width:r,height:i,style:o,color:a,strokeColor:s,strokeWidth:u,className:l,borderRadius:c,shapeRendering:d,onClick:f})=>{const{background:h,backgroundColor:m}=o||{},g=a||h||m;return p.jsx("rect",{className:ve(["react-flow__minimap-node",l]),x:t,y:n,rx:c,ry:c,width:r,height:i,fill:g,stroke:s,strokeWidth:u,shapeRendering:d,onClick:f?v=>f(v,e):void 0})};kh.displayName="MiniMapNode";var ww=x.memo(kh);const _w=e=>e.nodeOrigin,Ew=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Br=e=>e instanceof Function?e:()=>e;function Sw({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i=2,nodeComponent:o=ww,onClick:a}){const s=re(Ew,he),u=re(_w),l=Br(t),c=Br(e),d=Br(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return p.jsx(p.Fragment,{children:s.map(h=>{const{x:m,y:g}=kt(h,u).positionAbsolute;return p.jsx(o,{x:m,y:g,width:h.width,height:h.height,style:h.style,className:d(h),color:l(h),borderRadius:r,strokeColor:c(h),strokeWidth:i,shapeRendering:f,onClick:a,id:h.id},h.id)})})}var Cw=x.memo(Sw);const Nw=200,Mw=150,Iw=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?Pb(Ss(t,e.nodeOrigin),n):n,rfId:e.rfId}},kw="react-flow__minimap-desc";function Rh({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:a=2,nodeComponent:s,maskColor:u="rgb(240, 240, 240, 0.6)",maskStrokeColor:l="none",maskStrokeWidth:c=1,position:d="bottom-right",onClick:f,onNodeClick:h,pannable:m=!1,zoomable:g=!1,ariaLabel:v="React Flow mini map",inversePan:y=!1,zoomStep:E=10}){const C=pe(),w=x.useRef(null),{boundingRect:k,viewBB:N,rfId:A}=re(Iw,he),P=e?.width??Nw,q=e?.height??Mw,B=k.width/P,F=k.height/q,$=Math.max(B,F),R=$*P,b=$*q,M=5*$,S=k.x-(R-k.width)/2-M,_=k.y-(b-k.height)/2-M,I=R+M*2,T=b+M*2,L=`${kw}-${A}`,z=x.useRef(0);z.current=$,x.useEffect(()=>{if(w.current){const G=Te(w.current),X=D=>{const{transform:H,d3Selection:K,d3Zoom:ne}=C.getState();if(D.sourceEvent.type!=="wheel"||!K||!ne)return;const ie=-D.sourceEvent.deltaY*(D.sourceEvent.deltaMode===1?.05:D.sourceEvent.deltaMode?1:.002)*E,de=H[2]*Math.pow(2,ie);ne.scaleTo(K,de)},Q=D=>{const{transform:H,d3Selection:K,d3Zoom:ne,translateExtent:ie,width:de,height:oe}=C.getState();if(D.sourceEvent.type!=="mousemove"||!K||!ne)return;const U=z.current*Math.max(1,H[2])*(y?-1:1),ce={x:H[0]-D.sourceEvent.movementX*U,y:H[1]-D.sourceEvent.movementY*U},j=[[0,0],[de,oe]],ge=et.translate(ce.x,ce.y).scale(H[2]),ye=ne.constrain()(ge,j,ie);ne.transform(K,ye)},ee=$f().on("zoom",m?Q:null).on("zoom.wheel",g?X:null);return G.call(ee),()=>{G.on("zoom",null)}}},[m,g,y,E]);const V=f?G=>{const X=$e(G);f(G,{x:X[0],y:X[1]})}:void 0,Y=h?(G,X)=>{const Q=C.getState().nodeInternals.get(X);h(G,Q)}:void 0;return p.jsx(ms,{position:d,style:e,className:ve(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:p.jsxs("svg",{width:P,height:q,viewBox:`${S} ${_} ${I} ${T}`,role:"img","aria-labelledby":L,ref:w,onClick:V,children:[v&&p.jsx("title",{id:L,children:v}),p.jsx(Cw,{onClick:Y,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:s}),p.jsx("path",{className:"react-flow__minimap-mask",d:`M${S-M},${_-M}h${I+M*2}v${T+M*2}h${-I-M*2}z
        M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fill:u,fillRule:"evenodd",stroke:l,strokeWidth:c,pointerEvents:"none"})]})})}Rh.displayName="MiniMap";var Rw=x.memo(Rh);function Tw(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:p.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Aw(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:p.jsx("path",{d:"M0 0h32v4.2H0z"})})}function Lw(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:p.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function qw(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function Pw(){return p.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:p.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}const sn=({children:e,className:t,...n})=>p.jsx("button",{type:"button",className:ve(["react-flow__controls-button",t]),...n,children:e});sn.displayName="ControlButton";const $w=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),Th=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:s,onInteractiveChange:u,className:l,children:c,position:d="bottom-left"})=>{const f=pe(),[h,m]=x.useState(!1),{isInteractive:g,minZoomReached:v,maxZoomReached:y}=re($w,he),{zoomIn:E,zoomOut:C,fitView:w}=Ms();if(x.useEffect(()=>{m(!0)},[]),!h)return null;const k=()=>{E(),o?.()},N=()=>{C(),a?.()},A=()=>{w(i),s?.()},P=()=>{f.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),u?.(!g)};return p.jsxs(ms,{className:ve(["react-flow__controls",l]),position:d,style:e,"data-testid":"rf__controls",children:[t&&p.jsxs(p.Fragment,{children:[p.jsx(sn,{onClick:k,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:y,children:p.jsx(Tw,{})}),p.jsx(sn,{onClick:N,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v,children:p.jsx(Aw,{})})]}),n&&p.jsx(sn,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view",children:p.jsx(Lw,{})}),r&&p.jsx(sn,{className:"react-flow__controls-interactive",onClick:P,title:"toggle interactivity","aria-label":"toggle interactivity",children:g?p.jsx(Pw,{}):p.jsx(qw,{})}),c]})};Th.displayName="Controls";var jw=x.memo(Th),Fe;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Fe||(Fe={}));function Fw({color:e,dimensions:t,lineWidth:n}){return p.jsx("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function Dw({color:e,radius:t}){return p.jsx("circle",{cx:t,cy:t,r:t,fill:e})}const Ow={[Fe.Dots]:"#91919a",[Fe.Lines]:"#eee",[Fe.Cross]:"#e2e2e2"},zw={[Fe.Dots]:1,[Fe.Lines]:1,[Fe.Cross]:6},Bw=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Ah({id:e,variant:t=Fe.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=2,color:a,style:s,className:u}){const l=x.useRef(null),{transform:c,patternId:d}=re(Bw,he),f=a||Ow[t],h=r||zw[t],m=t===Fe.Dots,g=t===Fe.Cross,v=Array.isArray(n)?n:[n,n],y=[v[0]*c[2]||1,v[1]*c[2]||1],E=h*c[2],C=g?[E,E]:y,w=m?[E/o,E/o]:[C[0]/o,C[1]/o];return p.jsxs("svg",{className:ve(["react-flow__background",u]),style:{...s,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:l,"data-testid":"rf__background",children:[p.jsx("pattern",{id:d+e,x:c[0]%y[0],y:c[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`,children:m?p.jsx(Dw,{color:f,radius:E/o}):p.jsx(Fw,{dimensions:C,color:f,lineWidth:i})}),p.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${d+e})`})]})}Ah.displayName="Background";var Hw=x.memo(Ah),Hr,jc;function ks(){if(jc)return Hr;jc=1;function e(t,n){for(var r=-1,i=t==null?0:t.length;++r0&&o(c)?i>1?n(c,i-1,o,a,s):e(s,c):a||(s[s.length]=c)}return s}return ro=n,ro}var io,Qu;function Xh(){if(Qu)return io;Qu=1;function e(t,n,r,i){for(var o=t.length,a=r+(i?1:-1);i?a--:++a-1}return co=t,co}var uo,rl;function P1(){if(rl)return uo;rl=1;function e(t,n,r){for(var i=-1,o=t==null?0:t.length;++i=a){var y=l?null:i(u);if(y)return o(y);m=!1,f=r,v=new e}else v=l?[]:g;e:for(;++d1?h.setNode(m,d):h.setNode(m)}),this},i.prototype.setNode=function(c,d){return e.has(this._nodes,c)?(arguments.length>1&&(this._nodes[c]=d),this):(this._nodes[c]=arguments.length>1?d:this._defaultNodeLabelFn(c),this._isCompound&&(this._parent[c]=n,this._children[c]={},this._children[n][c]=!0),this._in[c]={},this._preds[c]={},this._out[c]={},this._sucs[c]={},++this._nodeCount,this)},i.prototype.node=function(c){return this._nodes[c]},i.prototype.hasNode=function(c){return e.has(this._nodes,c)},i.prototype.removeNode=function(c){var d=this;if(e.has(this._nodes,c)){var f=function(h){d.removeEdge(d._edgeObjs[h])};delete this._nodes[c],this._isCompound&&(this._removeFromParentsChildList(c),delete this._parent[c],e.each(this.children(c),function(h){d.setParent(h)}),delete this._children[c]),e.each(e.keys(this._in[c]),f),delete this._in[c],delete this._preds[c],e.each(e.keys(this._out[c]),f),delete this._out[c],delete this._sucs[c],--this._nodeCount}return this},i.prototype.setParent=function(c,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(d))d=n;else{d+="";for(var f=d;!e.isUndefined(f);f=this.parent(f))if(f===c)throw new Error("Setting "+d+" as parent of "+c+" would create a cycle");this.setNode(d)}return this.setNode(c),this._removeFromParentsChildList(c),this._parent[c]=d,this._children[d][c]=!0,this},i.prototype._removeFromParentsChildList=function(c){delete this._children[this._parent[c]][c]},i.prototype.parent=function(c){if(this._isCompound){var d=this._parent[c];if(d!==n)return d}},i.prototype.children=function(c){if(e.isUndefined(c)&&(c=n),this._isCompound){var d=this._children[c];if(d)return e.keys(d)}else{if(c===n)return this.nodes();if(this.hasNode(c))return[]}},i.prototype.predecessors=function(c){var d=this._preds[c];if(d)return e.keys(d)},i.prototype.successors=function(c){var d=this._sucs[c];if(d)return e.keys(d)},i.prototype.neighbors=function(c){var d=this.predecessors(c);if(d)return e.union(d,this.successors(c))},i.prototype.isLeaf=function(c){var d;return this.isDirected()?d=this.successors(c):d=this.neighbors(c),d.length===0},i.prototype.filterNodes=function(c){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;e.each(this._nodes,function(g,v){c(v)&&d.setNode(v,g)}),e.each(this._edgeObjs,function(g){d.hasNode(g.v)&&d.hasNode(g.w)&&d.setEdge(g,f.edge(g))});var h={};function m(g){var v=f.parent(g);return v===void 0||d.hasNode(v)?(h[g]=v,v):v in h?h[v]:m(v)}return this._isCompound&&e.each(d.nodes(),function(g){d.setParent(g,m(g))}),d},i.prototype.setDefaultEdgeLabel=function(c){return e.isFunction(c)||(c=e.constant(c)),this._defaultEdgeLabelFn=c,this},i.prototype.edgeCount=function(){return this._edgeCount},i.prototype.edges=function(){return e.values(this._edgeObjs)},i.prototype.setPath=function(c,d){var f=this,h=arguments;return e.reduce(c,function(m,g){return h.length>1?f.setEdge(m,g,d):f.setEdge(m,g),g}),this},i.prototype.setEdge=function(){var c,d,f,h,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(c=g.v,d=g.w,f=g.name,arguments.length===2&&(h=arguments[1],m=!0)):(c=g,d=arguments[1],f=arguments[3],arguments.length>2&&(h=arguments[2],m=!0)),c=""+c,d=""+d,e.isUndefined(f)||(f=""+f);var v=s(this._isDirected,c,d,f);if(e.has(this._edgeLabels,v))return m&&(this._edgeLabels[v]=h),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(c),this.setNode(d),this._edgeLabels[v]=m?h:this._defaultEdgeLabelFn(c,d,f);var y=u(this._isDirected,c,d,f);return c=y.v,d=y.w,Object.freeze(y),this._edgeObjs[v]=y,o(this._preds[d],c),o(this._sucs[c],d),this._in[d][v]=y,this._out[c][v]=y,this._edgeCount++,this},i.prototype.edge=function(c,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,c,d,f);return this._edgeLabels[h]},i.prototype.hasEdge=function(c,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,c,d,f);return e.has(this._edgeLabels,h)},i.prototype.removeEdge=function(c,d,f){var h=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,c,d,f),m=this._edgeObjs[h];return m&&(c=m.v,d=m.w,delete this._edgeLabels[h],delete this._edgeObjs[h],a(this._preds[d],c),a(this._sucs[c],d),delete this._in[d][h],delete this._out[c][h],this._edgeCount--),this},i.prototype.inEdges=function(c,d){var f=this._in[c];if(f){var h=e.values(f);return d?e.filter(h,function(m){return m.v===d}):h}},i.prototype.outEdges=function(c,d){var f=this._out[c];if(f){var h=e.values(f);return d?e.filter(h,function(m){return m.w===d}):h}},i.prototype.nodeEdges=function(c,d){var f=this.inEdges(c,d);if(f)return f.concat(this.outEdges(c,d))};function o(c,d){c[d]?c[d]++:c[d]=1}function a(c,d){--c[d]||delete c[d]}function s(c,d,f,h){var m=""+d,g=""+f;if(!c&&m>g){var v=m;m=g,g=v}return m+r+g+r+(e.isUndefined(h)?t:h)}function u(c,d,f,h){var m=""+d,g=""+f;if(!c&&m>g){var v=m;m=g,g=v}var y={v:m,w:g};return h&&(y.name=h),y}function l(c,d){return s(c,d.v,d.w,d.name)}return yo}var bo,fl;function z1(){return fl||(fl=1,bo="2.1.8"),bo}var xo,hl;function B1(){return hl||(hl=1,xo={Graph:Ls(),version:z1()}),xo}var wo,pl;function H1(){if(pl)return wo;pl=1;var e=qe(),t=Ls();wo={write:n,read:o};function n(a){var s={options:{directed:a.isDirected(),multigraph:a.isMultigraph(),compound:a.isCompound()},nodes:r(a),edges:i(a)};return e.isUndefined(a.graph())||(s.value=e.clone(a.graph())),s}function r(a){return e.map(a.nodes(),function(s){var u=a.node(s),l=a.parent(s),c={v:s};return e.isUndefined(u)||(c.value=u),e.isUndefined(l)||(c.parent=l),c})}function i(a){return e.map(a.edges(),function(s){var u=a.edge(s),l={v:s.v,w:s.w};return e.isUndefined(s.name)||(l.name=s.name),e.isUndefined(u)||(l.value=u),l})}function o(a){var s=new t(a.options).setGraph(a.value);return e.each(a.nodes,function(u){s.setNode(u.v,u.value),u.parent&&s.setParent(u.v,u.parent)}),e.each(a.edges,function(u){s.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),s}return wo}var _o,gl;function V1(){if(gl)return _o;gl=1;var e=qe();_o=t;function t(n){var r={},i=[],o;function a(s){e.has(r,s)||(r[s]=!0,o.push(s),e.each(n.successors(s),a),e.each(n.predecessors(s),a))}return e.each(n.nodes(),function(s){o=[],a(s),o.length&&i.push(o)}),i}return _o}var Eo,ml;function Qh(){if(ml)return Eo;ml=1;var e=qe();Eo=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var i=this._keyIndices;if(n=String(n),!e.has(i,n)){var o=this._arr,a=o.length;return i[n]=a,o.push({key:n,priority:r}),this._decrease(a),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var i=this._keyIndices[n];if(r>this._arr[i].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[i].priority+" New: "+r);this._arr[i].priority=r,this._decrease(i)},t.prototype._heapify=function(n){var r=this._arr,i=2*n,o=i+1,a=n;i>1,!(r[o].priority0&&(d=c.removeMin(),f=l[d],f.distance!==Number.POSITIVE_INFINITY);)u(d).forEach(h);return l}return So}var Co,yl;function G1(){if(yl)return Co;yl=1;var e=Jh(),t=qe();Co=n;function n(r,i,o){return t.transform(r.nodes(),function(a,s){a[s]=e(r,s,i,o)},{})}return Co}var No,bl;function ep(){if(bl)return No;bl=1;var e=qe();No=t;function t(n){var r=0,i=[],o={},a=[];function s(u){var l=o[u]={onStack:!0,lowlink:r,index:r++};if(i.push(u),n.successors(u).forEach(function(f){e.has(o,f)?o[f].onStack&&(l.lowlink=Math.min(l.lowlink,o[f].index)):(s(f),l.lowlink=Math.min(l.lowlink,o[f].lowlink))}),l.lowlink===l.index){var c=[],d;do d=i.pop(),o[d].onStack=!1,c.push(d);while(u!==d);a.push(c)}}return n.nodes().forEach(function(u){e.has(o,u)||s(u)}),a}return No}var Mo,xl;function U1(){if(xl)return Mo;xl=1;var e=qe(),t=ep();Mo=n;function n(r){return e.filter(t(r),function(i){return i.length>1||i.length===1&&r.hasEdge(i[0],i[0])})}return Mo}var Io,wl;function Y1(){if(wl)return Io;wl=1;var e=qe();Io=n;var t=e.constant(1);function n(i,o,a){return r(i,o||t,a||function(s){return i.outEdges(s)})}function r(i,o,a){var s={},u=i.nodes();return u.forEach(function(l){s[l]={},s[l][l]={distance:0},u.forEach(function(c){l!==c&&(s[l][c]={distance:Number.POSITIVE_INFINITY})}),a(l).forEach(function(c){var d=c.v===l?c.w:c.v,f=o(c);s[l][d]={distance:f,predecessor:l}})}),u.forEach(function(l){var c=s[l];u.forEach(function(d){var f=s[d];u.forEach(function(h){var m=f[l],g=c[h],v=f[h],y=m.distance+g.distance;y0;){if(l=u.removeMin(),e.has(s,l))a.setEdge(l,s[l]);else{if(d)throw new Error("Input graph is not connected: "+i);d=!0}i.nodeEdges(l).forEach(c)}return a}return qo}var Po,Il;function Q1(){return Il||(Il=1,Po={components:V1(),dijkstra:Jh(),dijkstraAll:G1(),findCycles:U1(),floydWarshall:Y1(),isAcyclic:K1(),postorder:Z1(),preorder:X1(),prim:W1(),tarjan:ep(),topsort:tp()}),Po}var $o,kl;function J1(){if(kl)return $o;kl=1;var e=B1();return $o={Graph:e.Graph,json:H1(),alg:Q1(),version:e.version},$o}var ir;if(typeof es=="function")try{ir=J1()}catch{}ir||(ir=window.graphlib);var Oe=ir,jo,Rl;function e_(){if(Rl)return jo;Rl=1;var e=qh(),t=1,n=4;function r(i){return e(i,t|n)}return jo=r,jo}var Fo,Tl;function t_(){if(Tl)return Fo;Tl=1;var e=as,t=Gg(),n=ss,r=_n,i=Object.prototype,o=i.hasOwnProperty,a=e(function(s,u){s=Object(s);var l=-1,c=u.length,d=c>2?u[2]:void 0;for(d&&n(u[0],u[1],d)&&(c=1);++l-1?u[l?o[c]:c]:void 0}}return Do=r,Do}var Oo,Ll;function r_(){if(Ll)return Oo;Ll=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Oo=t,Oo}var zo,ql;function i_(){if(ql)return zo;ql=1;var e=r_(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return zo=n,zo}var Bo,Pl;function o_(){if(Pl)return Bo;Pl=1;var e=i_(),t=En,n=Zt(),r=0/0,i=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,a=/^0o[0-7]+$/i,s=parseInt;function u(l){if(typeof l=="number")return l;if(n(l))return r;if(t(l)){var c=typeof l.valueOf=="function"?l.valueOf():l;l=t(c)?c+"":c}if(typeof l!="string")return l===0?l:+l;l=e(l);var d=o.test(l);return d||a.test(l)?s(l.slice(2),d?2:8):i.test(l)?r:+l}return Bo=u,Bo}var Ho,$l;function rp(){if($l)return Ho;$l=1;var e=o_(),t=1/0,n=17976931348623157e292;function r(i){if(!i)return i===0?i:0;if(i=e(i),i===t||i===-t){var o=i<0?-1:1;return o*n}return i===i?i:0}return Ho=r,Ho}var Vo,jl;function a_(){if(jl)return Vo;jl=1;var e=rp();function t(n){var r=e(n),i=r%1;return r===r?i?r-i:r:0}return Vo=t,Vo}var Go,Fl;function s_(){if(Fl)return Go;Fl=1;var e=Xh(),t=it(),n=a_(),r=Math.max;function i(o,a,s){var u=o==null?0:o.length;if(!u)return-1;var l=s==null?0:n(s);return l<0&&(l=r(u+l,0)),e(o,t(a,3),l)}return Go=i,Go}var Uo,Dl;function c_(){if(Dl)return Uo;Dl=1;var e=n_(),t=s_(),n=e(t);return Uo=n,Uo}var Yo,Ol;function ip(){if(Ol)return Yo;Ol=1;var e=As();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Yo=t,Yo}var Ko,zl;function u_(){if(zl)return Ko;zl=1;var e=Dd,t=Ph(),n=_n;function r(i,o){return i==null?i:e(i,t(o),n)}return Ko=r,Ko}var Zo,Bl;function l_(){if(Bl)return Zo;Bl=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Zo=e,Zo}var Xo,Hl;function d_(){if(Hl)return Xo;Hl=1;var e=Ug(),t=Rs(),n=it();function r(i,o){var a={};return o=n(o,3),t(i,function(s,u,l){e(a,u,o(s,u,l))}),a}return Xo=r,Xo}var Wo,Vl;function qs(){if(Vl)return Wo;Vl=1;var e=Zt();function t(n,r,i){for(var o=-1,a=n.length;++on}return Qo=e,Qo}var Jo,Ul;function h_(){if(Ul)return Jo;Ul=1;var e=qs(),t=f_(),n=Cn;function r(i){return i&&i.length?e(i,n,t):void 0}return Jo=r,Jo}var ea,Yl;function p_(){if(Yl)return ea;Yl=1;var e=Kg,t=Yg,n=t(function(r,i,o){e(r,i,o)});return ea=n,ea}var ta,Kl;function op(){if(Kl)return ta;Kl=1;function e(t,n){return tr||s&&u&&c&&!l&&!d||o&&u&&c||!i&&c||!a)return 1;if(!o&&!s&&!d&&n=l)return c;var d=i[o];return c*(d=="desc"?-1:1)}}return n.index-r.index}return ga=t,ga}var ma,ud;function k_(){if(ud)return ma;ud=1;var e=xr(),t=_r(),n=it(),r=Yh(),i=N_(),o=ns(),a=I_(),s=Cn,u=we();function l(c,d,f){d.length?d=e(d,function(g){return u(g)?function(v){return t(v,g.length===1?g[0]:g)}:g}):d=[s];var h=-1;d=e(d,o(n));var m=r(c,function(g,v,y){var E=e(d,function(C){return C(g)});return{criteria:E,index:++h,value:g}});return i(m,function(g,v){return a(g,v,f)})}return ma=l,ma}var va,ld;function R_(){if(ld)return va;ld=1;var e=As(),t=k_(),n=as,r=ss,i=n(function(o,a){if(o==null)return[];var s=a.length;return s>1&&r(o,a[0],a[1])?a=[]:s>2&&r(a[0],a[1],a[2])&&(a=[a[0]]),t(o,e(a,1),[])});return va=i,va}var ya,dd;function T_(){if(dd)return ya;dd=1;var e=Oh(),t=0;function n(r){var i=++t;return e(r)+i}return ya=n,ya}var ba,fd;function A_(){if(fd)return ba;fd=1;function e(t,n,r){for(var i=-1,o=t.length,a=n.length,s={};++i0;--s)if(a=t[s].dequeue(),a){r=r.concat(wa(e,t,n,a,!0));break}}}return r}function wa(e,t,n,r,i){var o=i?[]:void 0;return Qe.forEach(e.inEdges(r.v),function(a){var s=e.edge(a),u=e.node(a.v);i&&o.push({v:a.v,w:a.w}),u.out-=s,Ya(t,n,u)}),Qe.forEach(e.outEdges(r.v),function(a){var s=e.edge(a),u=a.w,l=e.node(u);l.in-=s,Ya(t,n,l)}),e.removeNode(r.v),o}function B_(e,t){var n=new $_,r=0,i=0;Qe.forEach(e.nodes(),function(s){n.setNode(s,{v:s,in:0,out:0})}),Qe.forEach(e.edges(),function(s){var u=n.edge(s.v,s.w)||0,l=t(s),c=u+l;n.setEdge(s.v,s.w,c),i=Math.max(i,n.node(s.v).out+=l),r=Math.max(r,n.node(s.w).in+=l)});var o=Qe.range(i+r+3).map(function(){return new j_}),a=r+1;return Qe.forEach(n.nodes(),function(s){Ya(o,a,n.node(s))}),{graph:n,buckets:o,zeroIdx:a}}function Ya(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}var Ct=ae,H_=F_,V_={run:G_,undo:Y_};function G_(e){var t=e.graph().acyclicer==="greedy"?H_(e,n(e)):U_(e);Ct.forEach(t,function(r){var i=e.edge(r);e.removeEdge(r),i.forwardName=r.name,i.reversed=!0,e.setEdge(r.w,r.v,i,Ct.uniqueId("rev"))});function n(r){return function(i){return r.edge(i).weight}}}function U_(e){var t=[],n={},r={};function i(o){Ct.has(r,o)||(r[o]=!0,n[o]=!0,Ct.forEach(e.outEdges(o),function(a){Ct.has(n,a.w)?t.push(a):i(a.w)}),delete n[o])}return Ct.forEach(e.nodes(),i),t}function Y_(e){Ct.forEach(e.edges(),function(t){var n=e.edge(t);if(n.reversed){e.removeEdge(t);var r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}var te=ae,sp=Oe.Graph,Ce={addDummyNode:cp,simplify:K_,asNonCompoundGraph:Z_,successorWeights:X_,predecessorWeights:W_,intersectRect:Q_,buildLayerMatrix:J_,normalizeRanks:eE,removeEmptyRanks:tE,addBorderNode:nE,maxRank:up,partition:rE,time:iE,notime:oE};function cp(e,t,n,r){var i;do i=te.uniqueId(r);while(e.hasNode(i));return n.dummy=t,e.setNode(i,n),i}function K_(e){var t=new sp().setGraph(e.graph());return te.forEach(e.nodes(),function(n){t.setNode(n,e.node(n))}),te.forEach(e.edges(),function(n){var 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 Z_(e){var t=new sp({multigraph:e.isMultigraph()}).setGraph(e.graph());return te.forEach(e.nodes(),function(n){e.children(n).length||t.setNode(n,e.node(n))}),te.forEach(e.edges(),function(n){t.setEdge(n,e.edge(n))}),t}function X_(e){var t=te.map(e.nodes(),function(n){var r={};return te.forEach(e.outEdges(n),function(i){r[i.w]=(r[i.w]||0)+e.edge(i).weight}),r});return te.zipObject(e.nodes(),t)}function W_(e){var t=te.map(e.nodes(),function(n){var r={};return te.forEach(e.inEdges(n),function(i){r[i.v]=(r[i.v]||0)+e.edge(i).weight}),r});return te.zipObject(e.nodes(),t)}function Q_(e,t){var n=e.x,r=e.y,i=t.x-n,o=t.y-r,a=e.width/2,s=e.height/2;if(!i&&!o)throw new Error("Not possible to find intersection inside of the rectangle");var u,l;return Math.abs(o)*a>Math.abs(i)*s?(o<0&&(s=-s),u=s*i/o,l=s):(i<0&&(a=-a),u=a,l=a*o/i),{x:n+u,y:r+l}}function J_(e){var t=te.map(te.range(up(e)+1),function(){return[]});return te.forEach(e.nodes(),function(n){var r=e.node(n),i=r.rank;te.isUndefined(i)||(t[i][r.order]=n)}),t}function eE(e){var t=te.min(te.map(e.nodes(),function(n){return e.node(n).rank}));te.forEach(e.nodes(),function(n){var r=e.node(n);te.has(r,"rank")&&(r.rank-=t)})}function tE(e){var t=te.min(te.map(e.nodes(),function(o){return e.node(o).rank})),n=[];te.forEach(e.nodes(),function(o){var a=e.node(o).rank-t;n[a]||(n[a]=[]),n[a].push(o)});var r=0,i=e.graph().nodeRankFactor;te.forEach(n,function(o,a){te.isUndefined(o)&&a%i!==0?--r:r&&te.forEach(o,function(s){e.node(s).rank+=r})})}function nE(e,t,n,r){var i={width:0,height:0};return arguments.length>=4&&(i.rank=n,i.order=r),cp(e,"border",i,t)}function up(e){return te.max(te.map(e.nodes(),function(t){var n=e.node(t).rank;if(!te.isUndefined(n))return n}))}function rE(e,t){var n={lhs:[],rhs:[]};return te.forEach(e,function(r){t(r)?n.lhs.push(r):n.rhs.push(r)}),n}function iE(e,t){var n=te.now();try{return t()}finally{console.log(e+" time: "+(te.now()-n)+"ms")}}function oE(e,t){return t()}var lp=ae,aE=Ce,sE={run:cE,undo:lE};function cE(e){e.graph().dummyChains=[],lp.forEach(e.edges(),function(t){uE(e,t)})}function uE(e,t){var n=t.v,r=e.node(n).rank,i=t.w,o=e.node(i).rank,a=t.name,s=e.edge(t),u=s.labelRank;if(o!==r+1){e.removeEdge(t);var l,c,d;for(d=0,++r;ra.lim&&(s=a,u=!0);var l=rt.filter(t.edges(),function(c){return u===pd(e,e.node(c.v),s)&&u!==pd(e,e.node(c.w),s)});return rt.minBy(l,function(c){return bE(t,c)})}function mp(e,t,n,r){var i=n.v,o=n.w;e.removeEdge(i,o),e.setEdge(r.v,r.w,{}),$s(e),Ps(e,t),NE(e,t)}function NE(e,t){var n=rt.find(e.nodes(),function(i){return!t.node(i).parent}),r=wE(e,n);r=r.slice(1),rt.forEach(r,function(i){var o=e.node(i).parent,a=t.edge(i,o),s=!1;a||(a=t.edge(o,i),s=!0),t.node(i).rank=t.node(o).rank+(s?a.minlen:-a.minlen)})}function ME(e,t,n){return e.hasEdge(t,n)}function pd(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}var IE=Sr,vp=IE.longestPath,kE=dp,RE=SE,TE=AE;function AE(e){switch(e.graph().ranker){case"network-simplex":gd(e);break;case"tight-tree":qE(e);break;case"longest-path":LE(e);break;default:gd(e)}}var LE=vp;function qE(e){vp(e),kE(e)}function gd(e){RE(e)}var Ka=ae,PE=$E;function $E(e){var t=FE(e);Ka.forEach(e.graph().dummyChains,function(n){for(var r=e.node(n),i=r.edgeObj,o=jE(e,t,i.v,i.w),a=o.path,s=o.lca,u=0,l=a[u],c=!0;n!==i.w;){if(r=e.node(n),c){for(;(l=a[u])!==s&&e.node(l).maxRanka||s>t[u].lim));for(l=u,u=r;(u=e.parent(u))!==l;)o.push(u);return{path:i.concat(o.reverse()),lca:l}}function FE(e){var t={},n=0;function r(i){var o=n;Ka.forEach(e.children(i),r),t[i]={low:o,lim:n++}}return Ka.forEach(e.children(),r),t}var Je=ae,Za=Ce,DE={run:OE,cleanup:HE};function OE(e){var t=Za.addDummyNode(e,"root",{},"_root"),n=zE(e),r=Je.max(Je.values(n))-1,i=2*r+1;e.graph().nestingRoot=t,Je.forEach(e.edges(),function(a){e.edge(a).minlen*=i});var o=BE(e)+1;Je.forEach(e.children(),function(a){yp(e,t,i,o,r,n,a)}),e.graph().nodeRankFactor=i}function yp(e,t,n,r,i,o,a){var s=e.children(a);if(!s.length){a!==t&&e.setEdge(t,a,{weight:0,minlen:n});return}var u=Za.addBorderNode(e,"_bt"),l=Za.addBorderNode(e,"_bb"),c=e.node(a);e.setParent(u,a),c.borderTop=u,e.setParent(l,a),c.borderBottom=l,Je.forEach(s,function(d){yp(e,t,n,r,i,o,d);var f=e.node(d),h=f.borderTop?f.borderTop:d,m=f.borderBottom?f.borderBottom:d,g=f.borderTop?r:2*r,v=h!==m?1:i-o[a]+1;e.setEdge(u,h,{weight:g,minlen:v,nestingEdge:!0}),e.setEdge(m,l,{weight:g,minlen:v,nestingEdge:!0})}),e.parent(a)||e.setEdge(t,u,{weight:0,minlen:i+o[a]})}function zE(e){var t={};function n(r,i){var o=e.children(r);o&&o.length&&Je.forEach(o,function(a){n(a,i+1)}),t[r]=i}return Je.forEach(e.children(),function(r){n(r,1)}),t}function BE(e){return Je.reduce(e.edges(),function(t,n){return t+e.edge(n).weight},0)}function HE(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,Je.forEach(e.edges(),function(n){var r=e.edge(n);r.nestingEdge&&e.removeEdge(n)})}var _a=ae,VE=Ce,GE=UE;function UE(e){function t(n){var r=e.children(n),i=e.node(n);if(r.length&&_a.forEach(r,t),_a.has(i,"minRank")){i.borderLeft=[],i.borderRight=[];for(var o=i.minRank,a=i.maxRank+1;o0;)c%2&&(d+=s[c+1]),c=c-1>>1,s[c]+=l.weight;u+=l.weight*d})),u}var yd=ae,rS=iS;function iS(e,t){return yd.map(t,function(n){var r=e.inEdges(n);if(r.length){var i=yd.reduce(r,function(o,a){var s=e.edge(a),u=e.node(a.v);return{sum:o.sum+s.weight*u.order,weight:o.weight+s.weight}},{sum:0,weight:0});return{v:n,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:n}})}var Me=ae,oS=aS;function aS(e,t){var n={};Me.forEach(e,function(i,o){var a=n[i.v]={indegree:0,in:[],out:[],vs:[i.v],i:o};Me.isUndefined(i.barycenter)||(a.barycenter=i.barycenter,a.weight=i.weight)}),Me.forEach(t.edges(),function(i){var o=n[i.v],a=n[i.w];!Me.isUndefined(o)&&!Me.isUndefined(a)&&(a.indegree++,o.out.push(n[i.w]))});var r=Me.filter(n,function(i){return!i.indegree});return sS(r)}function sS(e){var t=[];function n(o){return function(a){a.merged||(Me.isUndefined(a.barycenter)||Me.isUndefined(o.barycenter)||a.barycenter>=o.barycenter)&&cS(o,a)}}function r(o){return function(a){a.in.push(o),--a.indegree===0&&e.push(a)}}for(;e.length;){var i=e.pop();t.push(i),Me.forEach(i.in.reverse(),n(i)),Me.forEach(i.out,r(i))}return Me.map(Me.filter(t,function(o){return!o.merged}),function(o){return Me.pick(o,["vs","i","barycenter","weight"])})}function cS(e,t){var 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}var cn=ae,uS=Ce,lS=dS;function dS(e,t){var n=uS.partition(e,function(c){return cn.has(c,"barycenter")}),r=n.lhs,i=cn.sortBy(n.rhs,function(c){return-c.i}),o=[],a=0,s=0,u=0;r.sort(fS(!!t)),u=bd(o,i,u),cn.forEach(r,function(c){u+=c.vs.length,o.push(c.vs),a+=c.barycenter*c.weight,s+=c.weight,u=bd(o,i,u)});var l={vs:cn.flatten(o,!0)};return s&&(l.barycenter=a/s,l.weight=s),l}function bd(e,t,n){for(var r;t.length&&(r=cn.last(t)).i<=n;)t.pop(),e.push(r.vs),n++;return n}function fS(e){return function(t,n){return t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}}var dt=ae,hS=rS,pS=oS,gS=lS,mS=xp;function xp(e,t,n,r){var i=e.children(t),o=e.node(t),a=o?o.borderLeft:void 0,s=o?o.borderRight:void 0,u={};a&&(i=dt.filter(i,function(m){return m!==a&&m!==s}));var l=hS(e,i);dt.forEach(l,function(m){if(e.children(m.v).length){var g=xp(e,m.v,n,r);u[m.v]=g,dt.has(g,"barycenter")&&yS(m,g)}});var c=pS(l,n);vS(c,u);var d=gS(c,r);if(a&&(d.vs=dt.flatten([a,d.vs,s],!0),e.predecessors(a).length)){var f=e.node(e.predecessors(a)[0]),h=e.node(e.predecessors(s)[0]);dt.has(d,"barycenter")||(d.barycenter=0,d.weight=0),d.barycenter=(d.barycenter*d.weight+f.order+h.order)/(d.weight+2),d.weight+=2}return d}function vS(e,t){dt.forEach(e,function(n){n.vs=dt.flatten(n.vs.map(function(r){return t[r]?t[r].vs:r}),!0)})}function yS(e,t){dt.isUndefined(e.barycenter)?(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)}var un=ae,bS=Oe.Graph,xS=wS;function wS(e,t,n){var r=_S(e),i=new bS({compound:!0}).setGraph({root:r}).setDefaultNodeLabel(function(o){return e.node(o)});return un.forEach(e.nodes(),function(o){var a=e.node(o),s=e.parent(o);(a.rank===t||a.minRank<=t&&t<=a.maxRank)&&(i.setNode(o),i.setParent(o,s||r),un.forEach(e[n](o),function(u){var l=u.v===o?u.w:u.v,c=i.edge(l,o),d=un.isUndefined(c)?0:c.weight;i.setEdge(l,o,{weight:e.edge(u).weight+d})}),un.has(a,"minRank")&&i.setNode(o,{borderLeft:a.borderLeft[t],borderRight:a.borderRight[t]}))}),i}function _S(e){for(var t;e.hasNode(t=un.uniqueId("_root")););return t}var ES=ae,SS=CS;function CS(e,t,n){var r={},i;ES.forEach(n,function(o){for(var a=e.parent(o),s,u;a;){if(s=e.parent(a),s?(u=r[s],r[s]=a):(u=i,i=a),u&&u!==a){t.setEdge(u,a);return}a=s}})}var pt=ae,NS=QE,MS=eS,IS=mS,kS=xS,RS=SS,TS=Oe.Graph,xd=Ce,AS=LS;function LS(e){var t=xd.maxRank(e),n=wd(e,pt.range(1,t+1),"inEdges"),r=wd(e,pt.range(t-1,-1,-1),"outEdges"),i=NS(e);_d(e,i);for(var o=Number.POSITIVE_INFINITY,a,s=0,u=0;u<4;++s,++u){qS(s%2?n:r,s%4>=2),i=xd.buildLayerMatrix(e);var l=MS(e,i);ll)&&js(n,f,c)})})}function i(o,a){var s=-1,u,l=0;return Z.forEach(a,function(c,d){if(e.node(c).dummy==="border"){var f=e.predecessors(c);f.length&&(u=e.node(f[0]).order,r(a,l,d,s,u),l=d,s=u)}r(a,l,a.length,u,o.length)}),a}return Z.reduce(t,i),n}function FS(e,t){if(e.node(t).dummy)return Z.find(e.predecessors(t),function(n){return e.node(n).dummy})}function js(e,t,n){if(t>n){var r=t;t=n,n=r}var i=e[t];i||(e[t]=i={}),i[n]=!0}function Ep(e,t,n){if(t>n){var r=t;t=n,n=r}return Z.has(e[t],n)}function Sp(e,t,n,r){var i={},o={},a={};return Z.forEach(t,function(s){Z.forEach(s,function(u,l){i[u]=u,o[u]=u,a[u]=l})}),Z.forEach(t,function(s){var u=-1;Z.forEach(s,function(l){var c=r(l);if(c.length){c=Z.sortBy(c,function(g){return a[g]});for(var d=(c.length-1)/2,f=Math.floor(d),h=Math.ceil(d);f<=h;++f){var m=c[f];o[l]===l&&u({}));const Md=130,Id=28,T2=(e,t="LR")=>{const n=t==="LR";return ft.setGraph({rankdir:t}),e.forEach(r=>{ft.setNode(r.id,{width:Md,height:Id})}),Fs.layout(ft),e.map(r=>{const i=ft.node(r.id);return r.targetPosition=n?O.Left:O.Top,r.sourcePosition=n?O.Right:O.Bottom,r.position={x:i.x-Md/2+Math.random()/1e3,y:i.y-Id/2},r})},A2=(e,t="LR")=>(ft.setGraph({rankdir:t}),e.forEach(n=>{ft.setEdge(n.source,n.target)}),Fs.layout(ft),e),zn=33,L2=({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:o,targetPosition:a,style:s={},markerType:u,markerEndId:l,selected:c,data:{onEdgeClick:d}})=>{const[f,h,m]=_s({sourceX:t,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:a}),g=Db(u,l);return p.jsxs(p.Fragment,{children:[p.jsx("path",{id:e,style:s,className:"react-flow__edge-path",d:f,markerEnd:g}),c&&p.jsx("foreignObject",{width:zn,height:zn,x:h-zn/2,y:m-zn/2,className:"edgebutton-foreignobject",requiredExtensions:"http://www.w3.org/1999/xhtml",children:p.jsx("button",{className:"edgebutton",onClick:v=>d(v,e),children:p.jsx(Xd,{})})})]})},q2=({data:e,selected:t})=>p.jsxs(p.Fragment,{children:[p.jsx(mt,{position:O.Right,type:"source"}),p.jsx("div",{className:`react-flow__node-default keycloak__authentication__conditional_node ${t?"selected":""}`,children:p.jsx("div",{children:e.label})}),p.jsx(mt,{position:O.Left,type:"target"})]}),P2=x.memo(q2),$2=({data:{label:e},prefix:t,selected:n})=>p.jsxs(p.Fragment,{children:[p.jsx(mt,{position:O.Right,type:"source"}),p.jsx("div",{className:`react-flow__node-default keycloak__authentication__subflow_node ${n?"selected":""}`,children:p.jsxs("div",{children:[t," ",e]})}),p.jsx(mt,{position:O.Left,type:"target"})]}),Rp=x.memo($2),j2=({...e})=>p.jsx(Rp,{...e,prefix:"Start"}),F2=({...e})=>p.jsx(Rp,{...e,prefix:"End"});const Rt=(e,t)=>({id:`edge-${e}-to-${t}`,type:"buttonEdge",source:e,target:t,data:{onEdgeClick:(n,r)=>{n.stopPropagation(),alert(`hello ${r}`)}}}),Tp=e=>{let t;return e.executionList&&(t="startSubFlow"),Xa(e)&&(t="conditional"),{id:e.id,type:t,sourcePosition:O.Right,targetPosition:O.Left,data:{label:e.displayName},position:{x:0,y:0}}},D2=e=>[Tp(e)],O2=(e,t,n)=>[Rt(e.id,t.id),Rt(t.id,n.id)],z2=e=>[Tp(e)],B2=(e,t,n,r,i,o)=>{const a=[];return i?a.push(Rt(e.id,t.id)):a.push(Rt(r.id,t.id)),o&&a.push(Rt(t.id,n.id)),a},H2=e=>{const t=[];t.push({id:e.id,type:"startSubFlow",sourcePosition:O.Right,targetPosition:O.Left,data:{label:e.displayName},position:{x:0,y:0}});const n=`flow-end-${e.id}`;return t.push({id:n,type:"endSubFlow",sourcePosition:O.Right,targetPosition:O.Left,data:{label:e.displayName},position:{x:0,y:0}}),t.concat(Ap(e.executionList||[]))},V2=(e,t,n,r)=>{const i=[],o=`flow-end-${e.id}`;return i.push(Rt(r&&r.requirement!=="ALTERNATIVE"?r.id:t.id,e.id)),i.push(Rt(o,n.id)),i.concat(Lp(e,e.executionList||[],{...e,id:o}))},Ap=e=>{let t=[];for(let n=0;n{let r=[];for(let i=0;i{const[t,n]=x.useState(!1),r=x.useMemo(()=>kd(e),[]),i=x.useMemo(()=>Rd(e),[]),[o,a,s]=bw(r),[u,l,c]=xw(i);Pg(()=>{a(kd(e)),l(Rd(e))},[e]);const d=h=>h.fitView(),f=()=>{n(!t)};return p.jsxs(Mh,{nodes:o,edges:u,onNodesChange:s,onEdgesChange:c,onInit:d,nodeTypes:G2,edgeTypes:U2,onNodeClick:f,nodesConnectable:!1,children:[p.jsx(Rw,{}),p.jsx(jw,{}),p.jsx(Hw,{})]})};const K2=()=>{const{t:e}=Le("authentication");return p.jsx(Wd,{"aria-labelledby":"headerName",id:"header",children:p.jsxs(Qd,{children:[p.jsx(Jd,{className:"keycloak__authentication__header-drag-button","aria-label":e("common:disabled")}),p.jsx(ef,{className:"keycloak__authentication__header",dataListCells:[p.jsx(Ot,{id:"headerName",children:e("steps")},"step"),p.jsx(Ot,{children:e("requirement")},"requirement"),p.jsx(Ot,{},"config")]})]})})};const Z2=({id:e,title:t})=>p.jsx(sm,{"data-testid":t,className:"keycloak__authentication__title",isFlat:!0,children:p.jsx(cm,{"data-id":e,id:`title-id-${e}`,children:t})}),X2=({flow:e,onChange:t})=>{const{t:n}=Le("authentication"),[r,i]=x.useState(!1),o=e.requirementChoices.map((a,s)=>p.jsx(Ra,{value:a,children:n(`requirements.${a}`)},s));return p.jsxs(p.Fragment,{children:[e.requirementChoices&&e.requirementChoices.length>1&&p.jsx(Ia,{className:"keycloak__authentication__requirement-dropdown",variant:ka.single,onToggle:i,onSelect:(a,s)=>{e.requirement=s.toString(),t(e),i(!1)},selections:[e.requirement],isOpen:r,children:o}),(!e.requirementChoices||e.requirementChoices.length<=1)&&p.jsx(p.Fragment,{children:n(`requirements.${e.requirement}`)})]})},W2=({execution:e})=>{const{t}=Le("authentication"),{addAlert:n,addError:r}=Ja(),[i,o]=x.useState(!1),[a,s]=x.useState(),[u,l]=x.useState(),c=cr(),{register:d,setValue:f,handleSubmit:h,formState:{errors:m}}=c,g=y=>{yg(y||{},f)};yn(async()=>{const y=await se.authenticationManagement.getConfigDescription({providerId:e.providerId});let E;return e.authenticationConfig&&(E=await se.authenticationManagement.getConfig({id:e.authenticationConfig})),{configDescription:y,config:E}},({configDescription:y,config:E})=>{l(y),s(E)},[]),x.useEffect(()=>{a&&g(a)},[a]);const v=async y=>{const E=bg(y);try{if(a){const C={id:a.id,alias:a.alias,config:E.config};await se.authenticationManagement.updateConfig(C),s({...C})}else{const C={id:e.id,alias:E.alias,config:E.config},{id:w}=await se.authenticationManagement.createConfig(C);s({...C.config,id:w,alias:C.alias})}n(t("configSaveSuccess"),st.success),o(!1)}catch(C){r("authentication:configSaveError",C)}};return p.jsxs(p.Fragment,{children:[p.jsx(ur,{content:t("common:settings"),children:p.jsx(fe,{variant:"plain","aria-label":t("common:settings"),onClick:()=>o(!0),children:p.jsx(ym,{})})}),u&&p.jsx(bn,{variant:xn.small,isOpen:i,title:t("executionConfig",{name:u.name}),onClose:()=>o(!1),children:p.jsxs(wn,{id:"execution-config-form",onSubmit:h(v),children:[p.jsx(wt,{label:t("alias"),fieldId:"alias",helperTextInvalid:t("common:required"),validated:m.alias?xe.error:xe.default,isRequired:!0,labelIcon:p.jsx(_t,{helpText:t("authentication-help:alias"),fieldLabelId:"authentication:alias"}),children:p.jsx(Un,{isReadOnly:!!a,id:"alias","data-testid":"alias",validated:m.alias?xe.error:xe.default,...d("alias",{required:!0})})}),p.jsx(Ld,{...c,children:p.jsx(um,{stringify:!0,properties:u.properties||[]})}),p.jsxs(Rg,{children:[p.jsx(fe,{"data-testid":"save",variant:"primary",type:"submit",children:t("common:save")}),p.jsx(fe,{"data-testid":"cancel",variant:tt.link,onClick:()=>{o(!1)},children:t("common:cancel")}),a&&p.jsxs(fe,{className:"pf-u-ml-4xl","data-testid":"clear",variant:tt.link,onClick:async()=>{await se.authenticationManagement.delConfig({id:a.id}),s(void 0),o(!1)},children:[t("common:clear")," ",p.jsx(tf,{})]})]})]})})]})},Q2=({execution:e,onAddExecution:t,onAddFlow:n})=>{const{t:r}=Le("authentication"),[i,o]=x.useState(!1),[a,s]=x.useState(),[u,l]=x.useState();return yn(()=>se.authenticationManagement.getFlow({flowId:e.flowId}),({providerId:c})=>l(c),[]),p.jsx(ur,{content:r("common:add"),children:p.jsxs(p.Fragment,{children:[p.jsx(xg,{isPlain:!0,position:"right","data-testid":`${e.displayName}-edit-dropdown`,isOpen:i,toggle:p.jsx(wg,{onToggle:o,"aria-label":r("common:add"),children:p.jsx(Xd,{})}),dropdownItems:[p.jsx(Et,{onClick:()=>s(u==="form-flow"?"form":"basic"),children:r("addStep")},"addStep"),p.jsx(Et,{onClick:()=>s("condition"),children:r("addCondition")},"addCondition"),p.jsx(Et,{onClick:()=>s("subFlow"),children:r("addSubFlow")},"addSubFlow")],onSelect:()=>o(!1)}),a&&a!=="subFlow"&&p.jsx(cs,{name:e.displayName,type:a,onSelect:c=>{c&&t(e,c),s(void 0)}}),a==="subFlow"&&p.jsx(us,{name:e.displayName,onCancel:()=>s(void 0),onConfirm:c=>{n(e,c),s(void 0)}})]})})},J2=({execution:e,onRowChange:t})=>{const{t:n}=Le("authentication"),{register:r,reset:i,handleSubmit:o,formState:{errors:a,isValid:s}}=cr({mode:"onChange",defaultValues:e}),[u,l]=Ma();x.useEffect(()=>i(e),[e]);const c=d=>{t({...e,...d}),l()};return p.jsxs(p.Fragment,{children:[p.jsx(ur,{content:n("common:edit"),children:p.jsx(fe,{variant:"plain","data-testid":`${e.id}-edit`,"aria-label":n("common:edit"),onClick:l,children:p.jsx(om,{})})}),u&&p.jsx(bn,{title:n("editFlow"),onClose:l,variant:xn.small,actions:[p.jsx(fe,{"data-testid":"confirm",type:"submit",form:"edit-flow-form",isDisabled:!s,children:n("edit")},"confirm"),p.jsx(fe,{"data-testid":"cancel",variant:tt.link,onClick:l,children:n("common:cancel")},"cancel")],isOpen:!0,children:p.jsxs(wn,{id:"edit-flow-form",onSubmit:o(c),isHorizontal:!0,children:[p.jsx(wt,{label:n("common:name"),fieldId:"name",helperTextInvalid:n("common:required"),validated:a.displayName?xe.error:xe.default,labelIcon:p.jsx(_t,{helpText:n("authentication-help:name"),fieldLabelId:"name"}),isRequired:!0,children:p.jsx(Un,{id:"name","data-testid":"displayName",validated:a.displayName?xe.error:xe.default,...r("displayName",{required:!0}),isRequired:!0})}),p.jsx(wt,{label:n("common:description"),fieldId:"kc-description",labelIcon:p.jsx(_t,{helpText:n("authentication-help:description"),fieldLabelId:"description"}),validated:a.description?xe.error:xe.default,helperTextInvalid:a.description?.message,children:p.jsx(lm,{id:"kc-description","data-testid":"description",validated:a.description?xe.error:xe.default,...r("description",{maxLength:{value:255,message:n("common:maxLength",{length:255})}})})})]})})]})};const qp=({builtIn:e,execution:t,onRowClick:n,onRowChange:r,onAddExecution:i,onAddFlow:o,onDelete:a})=>{const{t:s}=Le("authentication"),u=!!t.executionList?.length;return p.jsxs(p.Fragment,{children:[p.jsx(Wd,{className:"keycloak__authentication__flow-item",id:t.id,isExpanded:!t.isCollapsed,"aria-labelledby":`title-id-${t.id}`,children:p.jsxs(Qd,{className:"keycloak__authentication__flow-row","aria-level":t.level+1,role:"heading","aria-labelledby":t.id,children:[p.jsx(dm,{children:p.jsx(Jd,{"aria-label":s("common-help:dragHelp")})}),u&&p.jsx(nf,{onClick:()=>n(t),isExpanded:!t.isCollapsed,id:`toggle1-${t.id}`,"aria-controls":t.executionList[0].id}),p.jsx(ef,{dataListCells:[p.jsxs(Ot,{children:[!t.authenticationFlow&&p.jsx(Z2,{id:t.id,title:t.displayName},t.id),t.authenticationFlow&&p.jsxs(p.Fragment,{children:[t.displayName," ",p.jsx("br",{})," ",p.jsx(fm,{component:hm.small,children:t.description})]})]},`${t.id}-name`),p.jsx(Ot,{children:p.jsx(X2,{flow:t,onChange:r})},`${t.id}-requirement`),p.jsxs(Ot,{children:[t.configurable&&p.jsx(W2,{execution:t}),t.authenticationFlow&&!e&&p.jsxs(p.Fragment,{children:[p.jsx(Q2,{execution:t,onAddExecution:i,onAddFlow:o}),p.jsx(J2,{execution:t,onRowChange:r})]}),!e&&p.jsx(ur,{content:s("common:delete"),children:p.jsx(fe,{variant:"plain","data-testid":`${t.displayName}-delete`,"aria-label":s("common:delete"),onClick:()=>a(t),children:p.jsx(tf,{})})})]},`${t.id}-config`)]})]})}),!t.isCollapsed&&u&&t.executionList?.map(l=>p.jsx(qp,{builtIn:e,execution:l,onRowClick:n,onRowChange:r,onAddExecution:i,onAddFlow:o,onDelete:a},l.id))]})};class Pp{oldIndex;newIndex;constructor(t,n){this.oldIndex=t,this.newIndex=n}}class Td extends Pp{parent;constructor(t,n,r){super(t,n),this.parent=r}}class Ds{list;expandableList;constructor(t){this.list=t;const n={executionList:[],isCollapsed:!1};this.transformToExpandableList(0,-1,n),this.expandableList=n.executionList}transformToExpandableList(t,n,r){for(let i=t;ii.id===t);if(!r){for(const i of n||this.expandableList)if(i.executionList&&(r=this.findExecution(t,i.executionList),r))return r}return r}getParentNodes(t){for(let n=0;nr.level&&r.level+1===t)return r}}getChange(t,n){const r=this.order(),i=n.findIndex(s=>s===t.id),o=r[r.findIndex(s=>s.id===t.id)],a=r[i];if(a.level!==o.level){if(a.level>0){const s=this.getParentNodes(a.level);return new Td(s?.executionList?.length||0,a.index,s)}return new Td(this.expandableList.length,a.index)}return new Pp(o.index,a.index)}clone(){const t=new Ds([]);return t.list=this.list,t.expandableList=this.expandableList,t}}const Xa=e=>e.displayName?.startsWith("Condition ");function cN(){const{t:e}=Le("authentication"),{realm:t}=_g(),{addAlert:n,addError:r}=Ja(),{id:i,usedBy:o,builtIn:a}=Eg(),s=Sg(),[u,l]=x.useState(0),c=()=>l(new Date().getTime()),[d,f]=x.useState(!0),[h,m]=x.useState(),[g,v]=x.useState(),[y,E]=x.useState(),[C,w]=x.useState(""),[k,N]=x.useState(),[A,P]=x.useState(),[q,B]=x.useState(),[F,$,R]=Ma(),[b,M]=x.useState(!1),[S,_]=Ma();yn(async()=>{const H=(await se.authenticationManagement.getFlows()).find(ne=>ne.id===i);if(!H)throw new Error(e("common:notFound"));const K=await se.authenticationManagement.getExecutions({flow:H.alias});return{flow:H,executions:K}},({flow:D,executions:H})=>{m(D),v(new Ds(H))},[u]);const I=async(D,H)=>{try{let K=D.id;"parent"in H&&(await se.authenticationManagement.delExecution({id:K}),K=(await se.authenticationManagement.addExecutionToFlow({flow:H.parent?.displayName||h?.alias,provider:D.providerId})).id);const ne=H.newIndex-H.oldIndex;for(let ie=0;ie0?await se.authenticationManagement.lowerPriorityExecution({id:K}):await se.authenticationManagement.raisePriorityExecution({id:K});c(),n(e("updateFlowSuccess"),st.success)}catch(K){r("authentication:updateFlowError",K)}},T=async D=>{const{executionList:H,isCollapsed:K,...ne}=D;try{await se.authenticationManagement.updateExecution({flow:h?.alias},ne),c(),n(e("updateFlowSuccess"),st.success)}catch(ie){r("authentication:updateFlowError",ie)}},L=async(D,H)=>{try{await se.authenticationManagement.addExecutionToFlow({flow:D,provider:H.id}),c(),n(e("updateFlowSuccess"),st.success)}catch(K){r("authentication:updateFlowError",K)}},z=async(D,{name:H,description:K="",type:ne,provider:ie})=>{try{await se.authenticationManagement.addFlowToFlow({flow:D,alias:H,description:K,provider:ie,type:ne}),c(),n(e("updateFlowSuccess"),st.success)}catch(de){r("authentication:updateFlowError",de)}},[V,Y]=Gs({titleKey:"authentication:deleteConfirmExecution",children:p.jsxs(Us,{i18nKey:"authentication:deleteConfirmExecutionMessage",children:[" ",p.jsx("strong",{children:{name:q?.displayName}}),"."]}),continueButtonLabel:"common:delete",continueButtonVariant:tt.danger,onConfirm:async()=>{try{await se.authenticationManagement.delExecution({id:q?.id}),n(e("deleteExecutionSuccess"),st.success),c()}catch(D){r("authentication:deleteExecutionError",D)}}}),[G,X]=Gs({titleKey:"authentication:deleteConfirmFlow",children:p.jsxs(Us,{i18nKey:"authentication:deleteConfirmFlowMessage",children:[" ",p.jsx("strong",{children:{flow:h?.alias||""}}),"."]}),continueButtonLabel:"common:delete",continueButtonVariant:tt.danger,onConfirm:async()=>{try{await se.authenticationManagement.deleteFlow({flowId:h.id}),s(Cg({realm:t})),n(e("deleteFlowSuccess"),st.success)}catch(D){r("authentication:deleteFlowError",D)}}}),Q=g?.expandableList.length!==0,ee=[...o!=="DEFAULT"?[p.jsx(Et,{"data-testid":"set-as-default",onClick:_,children:e("bindFlow")},"default")]:[],p.jsx(Et,{onClick:()=>R(!0),children:e("duplicate")},"duplicate"),...a?[]:[p.jsx(Et,{"data-testid":"edit-flow",onClick:()=>M(!0),children:e("editInfo")},"edit"),p.jsx(Et,{"data-testid":"delete-flow",onClick:()=>G(),children:e("common:delete")},"delete")]];return p.jsxs(p.Fragment,{children:[S&&p.jsx(Mg,{flowAlias:h?.alias,onClose:()=>{_(),c()}}),F&&p.jsx(Ig,{name:h?.alias,description:h?.description,toggleDialog:$,onComplete:()=>{c(),R(!1)}}),b&&p.jsx(Nm,{flow:h,toggleDialog:()=>{M(!b),c()}}),p.jsx(X,{}),p.jsx(Ng,{titleKey:h?.alias||"",badges:[{text:p.jsx(Ad,{children:e(`used.${o}`)})},a?{text:p.jsx(Cm,{}),id:"builtIn"}:{}],dropdownItems:ee}),p.jsxs(qd,{variant:"light",children:[g&&Q&&p.jsxs(p.Fragment,{children:[p.jsx(pm,{id:"toolbar",children:p.jsxs(gm,{children:[p.jsx(Rr,{children:p.jsxs(rf,{children:[p.jsx(Kn,{icon:p.jsx(_m,{}),"aria-label":e("tableView"),buttonId:"tableView",isSelected:d,onChange:()=>f(!0)}),p.jsx(Kn,{icon:p.jsx(xm,{}),"aria-label":e("diagramView"),buttonId:"diagramView",isSelected:!d,onChange:()=>f(!1)})]})}),p.jsx(Rr,{children:p.jsx(fe,{"data-testid":"addStep",variant:"secondary",onClick:()=>N(!0),children:e("addStep")})}),p.jsx(Rr,{children:p.jsx(fe,{"data-testid":"addSubFlow",variant:"secondary",onClick:()=>P(!0),children:e("addSubFlow")})})]})}),p.jsx(Y,{}),d&&p.jsxs(am,{"aria-label":e("flows"),onDragFinish:D=>{const H=D.slice(1);w(e("common:onDragFinish",{list:y?.displayName}));const K=g.getChange(y,H);I(y,K)},onDragStart:D=>{const H=g.findExecution(D);w(e("common:onDragStart",{item:H.displayName})),E(H),H.isCollapsed||(H.isCollapsed=!0,v(g.clone()))},onDragMove:()=>w(e("common:onDragMove",{item:y?.displayName})),onDragCancel:()=>w(e("common:onDragCancel")),itemOrder:["header",...g.order().map(D=>D.id)],children:[p.jsx(K2,{}),p.jsx(p.Fragment,{children:g.expandableList.map(D=>p.jsx(qp,{builtIn:!!a,execution:D,onRowClick:H=>{H.isCollapsed=!H.isCollapsed,v(g.clone())},onRowChange:T,onAddExecution:(H,K)=>L(H.displayName,K),onAddFlow:(H,K)=>z(H.displayName,K),onDelete:H=>{B(H),V()}},D.id))})]}),h&&p.jsxs(p.Fragment,{children:[k&&p.jsx(cs,{name:h.alias,type:h.providerId==="client-flow"?"client":"basic",onSelect:D=>{D&&L(h.alias,D),N(!1)}}),A&&p.jsx(us,{name:h.alias,onCancel:()=>P(!1),onConfirm:D=>{z(h.alias,D),P(!1)}})]}),p.jsx("div",{className:"pf-screen-reader","aria-live":"assertive",children:C})]}),!d&&g?.expandableList&&p.jsx(Y2,{executionList:g}),!g?.expandableList||h&&!Q&&p.jsx(km,{flow:h,onAddExecution:D=>L(h.alias,D),onAddFlow:D=>z(h.alias,D)})]})]})}export{cN as default,Xa as providerConditionFilter};
//# sourceMappingURL=FlowDetails-7100af6f.js.map




© 2015 - 2024 Weber Informatics LLC | Privacy Policy