@actalk/inkos-studio 1.6.1 → 1.6.3-canary.52.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/server.d.ts.map +1 -1
- package/dist/api/server.js +163 -3
- package/dist/api/server.js.map +1 -1
- package/dist/assets/{FilmWizard-DEDrqO5H.js → FilmWizard-C_1W4acq.js} +1 -1
- package/dist/assets/{FlowView-DUBkKiff.js → FlowView-DvrwPvo2.js} +1 -1
- package/dist/assets/{_baseUniq-DYxaUtZI.js → _baseUniq-B-ZYRDWx.js} +1 -1
- package/dist/assets/{arc-CHuRYqSh.js → arc-Ciw3FGtr.js} +1 -1
- package/dist/assets/{architectureDiagram-Q4EWVU46-BRVULDTV.js → architectureDiagram-Q4EWVU46-mC_rz2X6.js} +1 -1
- package/dist/assets/{blockDiagram-DXYQGD6D-DKQr_EU5.js → blockDiagram-DXYQGD6D-D_GMBRzY.js} +1 -1
- package/dist/assets/{c4Diagram-AHTNJAMY-6OA3wnaj.js → c4Diagram-AHTNJAMY-CvmmAOg5.js} +1 -1
- package/dist/assets/channel-F10GB4f_.js +1 -0
- package/dist/assets/{chunk-4BX2VUAB-RPzgJJNb.js → chunk-4BX2VUAB-BPr0k8sP.js} +1 -1
- package/dist/assets/{chunk-4TB4RGXK-C4RNzHuu.js → chunk-4TB4RGXK-D-Y1Qj_T.js} +1 -1
- package/dist/assets/{chunk-55IACEB6-D7M7RO-J.js → chunk-55IACEB6-Bug_ufgD.js} +1 -1
- package/dist/assets/{chunk-EDXVE4YY-DZY9MFLO.js → chunk-EDXVE4YY-C7tD8L3k.js} +1 -1
- package/dist/assets/{chunk-FMBD7UC4-QMoMGo7W.js → chunk-FMBD7UC4-BU7HNA1K.js} +1 -1
- package/dist/assets/{chunk-OYMX7WX6-CQWjKnzn.js → chunk-OYMX7WX6-DQ_CIv08.js} +1 -1
- package/dist/assets/{chunk-QZHKN3VN-D16FUhg8.js → chunk-QZHKN3VN-HODyXosI.js} +1 -1
- package/dist/assets/{chunk-YZCP3GAM-CqRHihc7.js → chunk-YZCP3GAM-7Y8K_8MD.js} +1 -1
- package/dist/assets/classDiagram-6PBFFD2Q-BqBb7BDW.js +1 -0
- package/dist/assets/classDiagram-v2-HSJHXN6E-BqBb7BDW.js +1 -0
- package/dist/assets/clone-DOQmcAsj.js +1 -0
- package/dist/assets/{cose-bilkent-S5V4N54A-bfoOQLsv.js → cose-bilkent-S5V4N54A-D2kYbpZy.js} +1 -1
- package/dist/assets/{dagre-KV5264BT-BCyLituE.js → dagre-KV5264BT-BlyZQ0n0.js} +1 -1
- package/dist/assets/{diagram-5BDNPKRD-CPkN139r.js → diagram-5BDNPKRD-C3lJ6ObZ.js} +1 -1
- package/dist/assets/{diagram-G4DWMVQ6-DFLt39fl.js → diagram-G4DWMVQ6-hx-WGqJX.js} +1 -1
- package/dist/assets/{diagram-MMDJMWI5-DYYmrlVW.js → diagram-MMDJMWI5-CdI5Z_ZJ.js} +1 -1
- package/dist/assets/{diagram-TYMM5635-BZ3Pv-hE.js → diagram-TYMM5635-BmtYRsNe.js} +1 -1
- package/dist/assets/{erDiagram-SMLLAGMA-CAKauIJm.js → erDiagram-SMLLAGMA-DPokxoLy.js} +1 -1
- package/dist/assets/{flowDiagram-DWJPFMVM-KB2eEgGe.js → flowDiagram-DWJPFMVM-DFnf6GAZ.js} +1 -1
- package/dist/assets/{ganttDiagram-T4ZO3ILL-JMol99Z2.js → ganttDiagram-T4ZO3ILL-ymFoiBFD.js} +1 -1
- package/dist/assets/{gitGraphDiagram-UUTBAWPF-Bj2wACW5.js → gitGraphDiagram-UUTBAWPF-BOAZqylM.js} +1 -1
- package/dist/assets/{graph-mzOZJsmK.js → graph-BMumGBmN.js} +1 -1
- package/dist/assets/{highlighted-body-OFNGDK62-C5zsRw66.js → highlighted-body-OFNGDK62-DRX5PypI.js} +1 -1
- package/dist/assets/index-BZMnkfN7.css +1 -0
- package/dist/assets/{index-BXxzots5.js → index-MiIZL4f3.js} +291 -280
- package/dist/assets/{infoDiagram-42DDH7IO-DJiZjg4e.js → infoDiagram-42DDH7IO-D0iCgAlu.js} +1 -1
- package/dist/assets/{ishikawaDiagram-UXIWVN3A-D3C3S2GG.js → ishikawaDiagram-UXIWVN3A-WtqHTEzb.js} +1 -1
- package/dist/assets/{journeyDiagram-VCZTEJTY-oox1ioYZ.js → journeyDiagram-VCZTEJTY-DUlKzcQ-.js} +1 -1
- package/dist/assets/{kanban-definition-6JOO6SKY-DmK_6JO5.js → kanban-definition-6JOO6SKY-COYae0oO.js} +1 -1
- package/dist/assets/{layout-BU0zwXna.js → layout-Et_h2gsr.js} +1 -1
- package/dist/assets/{linear-BTTy9rEg.js → linear-DY_vot7D.js} +1 -1
- package/dist/assets/{min-CxsTU35L.js → min-CImNjYIc.js} +1 -1
- package/dist/assets/{mindmap-definition-QFDTVHPH-B9yvRvsY.js → mindmap-definition-QFDTVHPH-zOJ7uKnl.js} +1 -1
- package/dist/assets/{pieDiagram-DEJITSTG-BRDyhVEN.js → pieDiagram-DEJITSTG-BftexWKs.js} +1 -1
- package/dist/assets/{quadrantDiagram-34T5L4WZ-CHuq8duY.js → quadrantDiagram-34T5L4WZ-CHmM6MYD.js} +1 -1
- package/dist/assets/{requirementDiagram-MS252O5E-CPZMaTta.js → requirementDiagram-MS252O5E-eMzrziUe.js} +1 -1
- package/dist/assets/{sankeyDiagram-XADWPNL6-ukpqhioK.js → sankeyDiagram-XADWPNL6-B-Bgmxmu.js} +1 -1
- package/dist/assets/{sequenceDiagram-FGHM5R23-_HE4wLAQ.js → sequenceDiagram-FGHM5R23-cFT-__W_.js} +1 -1
- package/dist/assets/{stateDiagram-FHFEXIEX-CzvbU_vB.js → stateDiagram-FHFEXIEX-CVnHwqCo.js} +1 -1
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-nhhJvKGq.js +1 -0
- package/dist/assets/{timeline-definition-GMOUNBTQ-CjOUyryC.js → timeline-definition-GMOUNBTQ-CKbNRuf9.js} +1 -1
- package/dist/assets/{value-BRre6T9m.js → value-IOfiG7E7.js} +1 -1
- package/dist/assets/{vennDiagram-DHZGUBPP-ByHmBMvF.js → vennDiagram-DHZGUBPP-BDoxftwQ.js} +1 -1
- package/dist/assets/{wardley-RL74JXVD-BJB7tkWD.js → wardley-RL74JXVD-5TXAieIJ.js} +1 -1
- package/dist/assets/{wardleyDiagram-NUSXRM2D-CPNSDUV6.js → wardleyDiagram-NUSXRM2D-CFpD2tIy.js} +1 -1
- package/dist/assets/{xychartDiagram-5P7HB3ND-BPC25pDH.js → xychartDiagram-5P7HB3ND-cP5C2vcw.js} +1 -1
- package/dist/index.html +2 -2
- package/package.json +2 -2
- package/dist/assets/channel-CbescFQS.js +0 -1
- package/dist/assets/classDiagram-6PBFFD2Q-BbJjgfyw.js +0 -1
- package/dist/assets/classDiagram-v2-HSJHXN6E-BbJjgfyw.js +0 -1
- package/dist/assets/clone-D07SvwIC.js +0 -1
- package/dist/assets/index-Pc31QmUJ.css +0 -1
- package/dist/assets/stateDiagram-v2-QKLJ7IA2-Zuwgf5Ss.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{aH as N,j as e,aI as P,r as h,aJ as B,aK as U,aL as T,aM as S,aN as z,aO as L}from"./index-
|
|
1
|
+
import{aH as N,j as e,aI as P,r as h,aJ as B,aK as U,aL as T,aM as S,aN as z,aO as L}from"./index-MiIZL4f3.js";import W from"./FlowView-DvrwPvo2.js";import"./value-IOfiG7E7.js";function _({projectId:t,theme:s}){const r=P(),n=encodeURIComponent(t),d=N(`/projects/${n}/export/json`)??"#",a=N(`/projects/${n}/export/ink`)??"#",l=N(`/projects/${n}/export/html`)??"#";return e.jsxs("div",{className:"border border-border bg-card rounded p-3","data-testid":"export-bar",children:[e.jsx("div",{className:`text-sm font-medium mb-2 ${r.muted}`,children:"导出 / 交付"}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("a",{href:d,download:!0,"data-testid":"export-json",className:`inline-flex items-center rounded px-3 py-1.5 text-sm font-medium no-underline ${r.btnSecondary}`,children:"导出 JSON"}),e.jsx("a",{href:a,download:!0,"data-testid":"export-ink",className:`inline-flex items-center rounded px-3 py-1.5 text-sm font-medium no-underline ${r.btnSecondary}`,children:"导出 Ink"}),e.jsx("a",{href:l,download:!0,"data-testid":"export-html",className:`inline-flex items-center rounded px-3 py-1.5 text-sm font-medium no-underline ${r.btnSecondary}`,children:"导出可玩网页(HTML)"})]})]})}const H=["world","scale","structure","workshop","validate"];function $(t){var x,y;const s=!!((y=(x=t.worldAnchor)==null?void 0:x.storyCore)!=null&&y.trim()),r=t.characters.length>0,n=s&&r?"done":s?"partial":"empty",d="empty",a=t.nodes.some(i=>i.type==="start"),l=t.nodes.some(i=>i.type==="ending"),f=t.nodes.some(i=>i.choices.length>0),p=a&&l&&f?"done":t.nodes.length>0?"partial":"empty",u=t.nodes.filter(i=>i.type!=="ending"),c=u.filter(i=>{var v,b;return!!((v=i.sceneDesc)!=null&&v.trim())||(((b=i.dialogue)==null?void 0:b.length)??0)>0}),w=u.length===0?"empty":c.length===u.length?"done":c.length>0?"partial":"empty",m=t.nodes.length>0&&t.endings.length>0?"partial":"empty";return{world:n,scale:d,structure:p,workshop:w,validate:m}}function V(t,s,r){const n=$(t),d=a=>{const l=s==null?void 0:s[a];return typeof l=="number"&&l<r&&n[a]!=="empty"};return{world:d("world"),scale:d("scale"),structure:d("structure"),workshop:d("workshop"),validate:d("validate")}}const D={world:"世界",scale:"规模",structure:"结构",workshop:"逐节点",validate:"校验"},F={world:"chat",scale:"scale",structure:"flow",workshop:"tree",validate:"validate"},G={world:[{key:"chat",label:"对话"},{key:"anchor",label:"世界锚点"}],scale:[],structure:[{key:"flow",label:"流程图"},{key:"tree",label:"树"}],workshop:[{key:"tree",label:"树"},{key:"chat",label:"对话"}],validate:[]},O={world:"empty",scale:"empty",structure:"empty",workshop:"empty",validate:"empty"},R={world:!1,scale:!1,structure:!1,workshop:!1,validate:!1};function I({graph:t,c:s}){if(!(t!=null&&t.worldAnchor))return e.jsx("div",{className:`p-6 text-sm ${s.muted}`,children:"暂无世界锚点。请先切换到「对话」,请 AI 帮您设定世界观和角色。"});const{worldAnchor:r}=t;return e.jsxs("div",{className:"p-4 space-y-3 text-sm","data-testid":"film-world",children:[e.jsxs("div",{children:[e.jsx("div",{className:`text-xs font-medium mb-1 ${s.muted}`,children:"故事核心"}),e.jsx("div",{className:"text-foreground",children:r.storyCore||"—"})]}),e.jsxs("div",{className:"flex gap-6",children:[e.jsxs("div",{children:[e.jsx("div",{className:`text-xs font-medium mb-1 ${s.muted}`,children:"主题"}),e.jsx("div",{children:r.theme||"—"})]}),e.jsxs("div",{children:[e.jsx("div",{className:`text-xs font-medium mb-1 ${s.muted}`,children:"题材"}),e.jsx("div",{children:r.genre||"—"})]}),r.durationMinutes>0&&e.jsxs("div",{children:[e.jsx("div",{className:`text-xs font-medium mb-1 ${s.muted}`,children:"时长"}),e.jsxs("div",{children:[r.durationMinutes," 分钟"]})]})]}),r.worldRules&&e.jsxs("div",{children:[e.jsx("div",{className:`text-xs font-medium mb-1 ${s.muted}`,children:"世界规则"}),e.jsx("div",{className:"whitespace-pre-wrap",children:r.worldRules})]}),t.characters.length>0&&e.jsxs("div",{children:[e.jsx("div",{className:`text-xs font-medium mb-2 ${s.muted}`,children:"主要角色"}),e.jsx("ul",{className:"space-y-2",children:t.characters.map(n=>e.jsxs("li",{className:"flex items-start gap-2",children:[e.jsx("span",{className:`shrink-0 text-xs px-1.5 py-0.5 rounded border border-border ${s.muted}`,children:n.role}),e.jsxs("span",{children:[e.jsx("span",{className:"font-medium text-foreground",children:n.name}),n.motivation&&e.jsx("span",{className:` ml-2 ${s.muted}`,children:n.motivation})]})]},n.id))})]})]})}function J({c:t}){return e.jsx("div",{className:`p-6 text-sm ${t.muted}`,"data-testid":"film-scale-placeholder",children:"规模配置(P2 功能)— 在此设定节点数量目标、分支深度、多结局数量等参数。"})}function Q({projectId:t,nav:s,theme:r,t:n,sse:d}){const a=P(),[l,f]=h.useState("world"),[p,u]=h.useState({...F}),[c,w]=h.useState(!1),{data:m,refetch:x}=B(`/projects/${t}/story-graph`);h.useEffect(()=>{x()},[l,x]);const y=h.useCallback(o=>{if(o.event!=="agent:complete")return;const j=o.data;(j==null?void 0:j.activeBookId)===t&&x()},[t,x]);U(d.messages,y);const i=h.useMemo(()=>m?$(m):O,[m]),v=h.useMemo(()=>m?V(m,void 0,0):R,[m]),b=p[l],k=G[l];function E(o){w(!1),f(o)}function A(o){u({...p,[l]:o})}function C(){w(o=>!o)}return e.jsxs("div",{"data-testid":"film-wizard",className:"flex flex-col h-screen bg-background text-foreground",children:[e.jsxs("div",{className:"flex items-center justify-between border-b border-border px-4 py-2 shrink-0 gap-3",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("button",{type:"button","data-testid":"wizard-exit",onClick:s.toDashboard,className:a.link,children:"← 互动影游"}),e.jsx("div",{className:"flex items-center gap-1 flex-wrap",children:H.map((o,j)=>{const M=l===o&&!c,g=i[o];return e.jsxs("button",{type:"button","data-testid":`wizard-step-${o}`,onClick:()=>E(o),className:["relative flex items-center gap-1.5 rounded-md px-3 py-1.5 text-sm font-medium transition-all",M?a.btnPrimary:a.btnSecondary].join(" "),children:[v[o]&&e.jsx("span",{className:"absolute -top-1 -right-1 h-2 w-2 rounded-full bg-destructive"}),e.jsx("span",{className:["flex h-5 w-5 shrink-0 items-center justify-center rounded-full border text-[11px] font-semibold tabular-nums",g==="done"?"border-current bg-current/25":g==="partial"?"border-current/80":"border-current/40 opacity-70"].join(" "),children:j+1}),e.jsx("span",{children:D[o]})]},o)})})]}),e.jsx("button",{type:"button","data-testid":"wizard-preview",onClick:C,className:["shrink-0 flex items-center gap-1 rounded-md px-3 py-1.5 text-sm font-medium",c?a.btnPrimary:a.btnSecondary].join(" "),children:"试玩"})]}),!c&&k.length>0&&e.jsx("div",{className:"flex items-center gap-1 border-b border-border px-4 py-1.5 shrink-0",children:k.map(o=>e.jsx("button",{type:"button","data-testid":`wizard-subview-${o.key}`,onClick:()=>A(o.key),className:["rounded px-3 py-1 text-sm font-medium transition-colors",b===o.key?a.btnPrimary:a.btnSecondary].join(" "),children:o.label},o.key))}),e.jsx("div",{className:"flex-1 min-h-0 overflow-auto",children:e.jsx(Y,{showPreview:c,phase:l,subView:b,projectId:t,nav:s,theme:r,t:n,sse:d,graph:m,c:a})})]})}function Y({showPreview:t,phase:s,subView:r,projectId:n,nav:d,theme:a,t:l,sse:f,graph:p,c:u}){const c="mx-auto w-full max-w-4xl px-6 py-6";return t?e.jsx("div",{className:c,children:e.jsx(T,{projectId:n,nav:d,theme:a,t:l,embedded:!0})}):s==="world"&&r==="chat"?e.jsx("div",{className:"h-full relative overflow-hidden",children:e.jsx(S,{activeBookId:n,mode:"interactive-film-authoring",nav:d,theme:a,t:l,sse:f})}):s==="world"&&r==="anchor"?e.jsx(I,{graph:p,c:u}):s==="scale"?e.jsx(J,{c:u}):s==="structure"&&r==="flow"?e.jsx(W,{projectId:n,nav:d,theme:a,t:l,embedded:!0}):s==="structure"&&r==="tree"||s==="workshop"&&r==="tree"?e.jsx("div",{className:c,children:e.jsx(z,{projectId:n,nav:d,theme:a,t:l,embedded:!0})}):s==="workshop"&&r==="chat"?e.jsx("div",{className:"h-full relative overflow-hidden",children:e.jsx(S,{activeBookId:n,mode:"interactive-film-authoring",nav:d,theme:a,t:l,sse:f})}):s==="validate"?e.jsxs("div",{className:`${c} space-y-4`,children:[e.jsx(L,{projectId:n,theme:a}),e.jsx(_,{projectId:n,theme:a})]}):null}export{Q as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as ae,bp as Zn,bq as Ht,br as vt,bs as Et,bt as yr,bu as xr,bv as wr,r as z,j as C,aJ as br,aI as vr,bw as Er}from"./index-BXxzots5.js";import{i as St}from"./value-BRre6T9m.js";function Sr(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ue(e,t){if(e=Sr(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Nr={passive:!1},Ye={capture:!0,passive:!1};function Nt(e){e.stopImmediatePropagation()}function De(e){e.preventDefault(),e.stopImmediatePropagation()}function Kn(e){var t=e.document.documentElement,n=ae(e).on("dragstart.drag",De,Ye);"onselectstart"in t?n.on("selectstart.drag",De,Ye):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Un(e,t){var n=e.document.documentElement,o=ae(e).on("dragstart.drag",null);t&&(o.on("click.drag",De,Ye),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const tt=e=>()=>e;function _t(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:r,x:i,y:a,dx:d,dy:u,dispatch:h}){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:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:h}})}_t.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Mr(e){return!e.ctrlKey&&!e.button}function Cr(){return this.parentNode}function Ir(e,t){return t??{x:e.x,y:e.y}}function kr(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qn(){var e=Mr,t=Cr,n=Ir,o=kr,s={},r=Zn("start","drag","end"),i=0,a,d,u,h,c=0;function l(x){x.on("mousedown.drag",m).filter(o).on("touchstart.drag",y).on("touchmove.drag",g,Nr).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(x,k){if(!(h||!e.call(this,x,k))){var S=f(this,t.call(this,x,k),x,k,"mouse");S&&(ae(x.view).on("mousemove.drag",p,Ye).on("mouseup.drag",b,Ye),Kn(x.view),Nt(x),u=!1,a=x.clientX,d=x.clientY,S("start",x))}}function p(x){if(De(x),!u){var k=x.clientX-a,S=x.clientY-d;u=k*k+S*S>c}s.mouse("drag",x)}function b(x){ae(x.view).on("mousemove.drag mouseup.drag",null),Un(x.view,u),De(x),s.mouse("end",x)}function y(x,k){if(e.call(this,x,k)){var S=x.changedTouches,_=t.call(this,x,k),A=S.length,T,V;for(T=0;T<A;++T)(V=f(this,_,x,k,S[T].identifier,S[T]))&&(Nt(x),V("start",x,S[T]))}}function g(x){var k=x.changedTouches,S=k.length,_,A;for(_=0;_<S;++_)(A=s[k[_].identifier])&&(De(x),A("drag",x,k[_]))}function v(x){var k=x.changedTouches,S=k.length,_,A;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),_=0;_<S;++_)(A=s[k[_].identifier])&&(Nt(x),A("end",x,k[_]))}function f(x,k,S,_,A,T){var V=r.copy(),I=ue(T||S,k),D,B,w;if((w=n.call(x,new _t("beforestart",{sourceEvent:S,target:l,identifier:A,active:i,x:I[0],y:I[1],dx:0,dy:0,dispatch:V}),_))!=null)return D=w.x-I[0]||0,B=w.y-I[1]||0,function $(N,E,P){var M=I,L;switch(N){case"start":s[A]=$,L=i++;break;case"end":delete s[A],--i;case"drag":I=ue(P||E,k),L=i;break}V.call(N,x,new _t(N,{sourceEvent:E,subject:w,target:l,identifier:A,active:L,x:I[0]+D,y:I[1]+B,dx:I[0]-M[0],dy:I[1]-M[1],dispatch:V}),_)}}return l.filter=function(x){return arguments.length?(e=typeof x=="function"?x:tt(!!x),l):e},l.container=function(x){return arguments.length?(t=typeof x=="function"?x:tt(x),l):t},l.subject=function(x){return arguments.length?(n=typeof x=="function"?x:tt(x),l):n},l.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:tt(!!x),l):o},l.on=function(){var x=r.on.apply(r,arguments);return x===r?l:x},l.clickDistance=function(x){return arguments.length?(c=(x=+x)*x,l):Math.sqrt(c)},l}var Pr=1e-12;function sn(e){return((e=Math.exp(e))+1/e)/2}function $r(e){return((e=Math.exp(e))-1/e)/2}function _r(e){return((e=Math.exp(2*e))-1)/(e+1)}const at=(function e(t,n,o){function s(r,i){var a=r[0],d=r[1],u=r[2],h=i[0],c=i[1],l=i[2],m=h-a,p=c-d,b=m*m+p*p,y,g;if(b<Pr)g=Math.log(l/u)/t,y=function(_){return[a+_*m,d+_*p,u*Math.exp(t*_*g)]};else{var v=Math.sqrt(b),f=(l*l-u*u+o*b)/(2*u*n*v),x=(l*l-u*u-o*b)/(2*l*n*v),k=Math.log(Math.sqrt(f*f+1)-f),S=Math.log(Math.sqrt(x*x+1)-x);g=(S-k)/t,y=function(_){var A=_*g,T=sn(k),V=u/(n*v)*(T*_r(t*A+k)-$r(k));return[a+V*m,d+V*p,u*T/sn(t*A+k)]}}return y.duration=g*1e3*t/Math.SQRT2,y}return s.rho=function(r){var i=Math.max(.001,+r),a=i*i,d=a*a;return e(i,a,d)},s})(Math.SQRT2,2,4),nt=e=>()=>e;function Ar(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){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:o,enumerable:!0,configurable:!0},_:{value:s}})}function Mt(e){e.stopImmediatePropagation()}function Fe(e){e.preventDefault(),e.stopImmediatePropagation()}function zr(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Tr(){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 rn(){return this.__zoom||Ht}function Dr(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Lr(){return navigator.maxTouchPoints||"ontouchstart"in this}function jr(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i))}function Jn(){var e=zr,t=Tr,n=jr,o=Dr,s=Lr,r=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,d=at,u=Zn("start","zoom","end"),h,c,l,m=500,p=150,b=0,y=10;function g(w){w.property("__zoom",rn).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",V).filter(s).on("touchstart.zoom",I).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(w,$,N,E){var P=w.selection?w.selection():w;P.property("__zoom",rn),w!==P?k(w,$,N,E):P.interrupt().each(function(){S(this,arguments).event(E).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},g.scaleBy=function(w,$,N,E){g.scaleTo(w,function(){var P=this.__zoom.k,M=typeof $=="function"?$.apply(this,arguments):$;return P*M},N,E)},g.scaleTo=function(w,$,N,E){g.transform(w,function(){var P=t.apply(this,arguments),M=this.__zoom,L=N==null?x(P):typeof N=="function"?N.apply(this,arguments):N,j=M.invert(L),H=typeof $=="function"?$.apply(this,arguments):$;return n(f(v(M,H),L,j),P,i)},N,E)},g.translateBy=function(w,$,N,E){g.transform(w,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),i)},null,E)},g.translateTo=function(w,$,N,E,P){g.transform(w,function(){var M=t.apply(this,arguments),L=this.__zoom,j=E==null?x(M):typeof E=="function"?E.apply(this,arguments):E;return n(Ht.translate(j[0],j[1]).scale(L.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof N=="function"?-N.apply(this,arguments):-N),M,i)},E,P)};function v(w,$){return $=Math.max(r[0],Math.min(r[1],$)),$===w.k?w:new vt($,w.x,w.y)}function f(w,$,N){var E=$[0]-N[0]*w.k,P=$[1]-N[1]*w.k;return E===w.x&&P===w.y?w:new vt(w.k,E,P)}function x(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,$,N,E){w.on("start.zoom",function(){S(this,arguments).event(E).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(E).end()}).tween("zoom",function(){var P=this,M=arguments,L=S(P,M).event(E),j=t.apply(P,M),H=N==null?x(j):typeof N=="function"?N.apply(P,M):N,O=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),Y=P.__zoom,Z=typeof $=="function"?$.apply(P,M):$,Q=d(Y.invert(H).concat(O/Y.k),Z.invert(H).concat(O/Z.k));return function(q){if(q===1)q=Z;else{var R=Q(q),F=O/R[2];q=new vt(F,H[0]-R[0]*F,H[1]-R[1]*F)}L.zoom(null,q)}})}function S(w,$,N){return!N&&w.__zooming||new _(w,$)}function _(w,$){this.that=w,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(w,$),this.taps=0}_.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,$){return this.mouse&&w!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var $=ae(this.that).datum();u.call(w,this.that,new Ar(w,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),$)}};function A(w,...$){if(!e.apply(this,arguments))return;var N=S(this,$).event(w),E=this.__zoom,P=Math.max(r[0],Math.min(r[1],E.k*Math.pow(2,o.apply(this,arguments)))),M=ue(w);if(N.wheel)(N.mouse[0][0]!==M[0]||N.mouse[0][1]!==M[1])&&(N.mouse[1]=E.invert(N.mouse[0]=M)),clearTimeout(N.wheel);else{if(E.k===P)return;N.mouse=[M,E.invert(M)],Et(this),N.start()}Fe(w),N.wheel=setTimeout(L,p),N.zoom("mouse",n(f(v(E,P),N.mouse[0],N.mouse[1]),N.extent,i));function L(){N.wheel=null,N.end()}}function T(w,...$){if(l||!e.apply(this,arguments))return;var N=w.currentTarget,E=S(this,$,!0).event(w),P=ae(w.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",O,!0),M=ue(w,N),L=w.clientX,j=w.clientY;Kn(w.view),Mt(w),E.mouse=[M,this.__zoom.invert(M)],Et(this),E.start();function H(Y){if(Fe(Y),!E.moved){var Z=Y.clientX-L,Q=Y.clientY-j;E.moved=Z*Z+Q*Q>b}E.event(Y).zoom("mouse",n(f(E.that.__zoom,E.mouse[0]=ue(Y,N),E.mouse[1]),E.extent,i))}function O(Y){P.on("mousemove.zoom mouseup.zoom",null),Un(Y.view,E.moved),Fe(Y),E.event(Y).end()}}function V(w,...$){if(e.apply(this,arguments)){var N=this.__zoom,E=ue(w.changedTouches?w.changedTouches[0]:w,this),P=N.invert(E),M=N.k*(w.shiftKey?.5:2),L=n(f(v(N,M),E,P),t.apply(this,$),i);Fe(w),a>0?ae(this).transition().duration(a).call(k,L,E,w):ae(this).call(g.transform,L,E,w)}}function I(w,...$){if(e.apply(this,arguments)){var N=w.touches,E=N.length,P=S(this,$,w.changedTouches.length===E).event(w),M,L,j,H;for(Mt(w),L=0;L<E;++L)j=N[L],H=ue(j,this),H=[H,this.__zoom.invert(H),j.identifier],P.touch0?!P.touch1&&P.touch0[2]!==H[2]&&(P.touch1=H,P.taps=0):(P.touch0=H,M=!0,P.taps=1+!!h);h&&(h=clearTimeout(h)),M&&(P.taps<2&&(c=H[0],h=setTimeout(function(){h=null},m)),Et(this),P.start())}}function D(w,...$){if(this.__zooming){var N=S(this,$).event(w),E=w.changedTouches,P=E.length,M,L,j,H;for(Fe(w),M=0;M<P;++M)L=E[M],j=ue(L,this),N.touch0&&N.touch0[2]===L.identifier?N.touch0[0]=j:N.touch1&&N.touch1[2]===L.identifier&&(N.touch1[0]=j);if(L=N.that.__zoom,N.touch1){var O=N.touch0[0],Y=N.touch0[1],Z=N.touch1[0],Q=N.touch1[1],q=(q=Z[0]-O[0])*q+(q=Z[1]-O[1])*q,R=(R=Q[0]-Y[0])*R+(R=Q[1]-Y[1])*R;L=v(L,Math.sqrt(q/R)),j=[(O[0]+Z[0])/2,(O[1]+Z[1])/2],H=[(Y[0]+Q[0])/2,(Y[1]+Q[1])/2]}else if(N.touch0)j=N.touch0[0],H=N.touch0[1];else return;N.zoom("touch",n(f(L,j,H),N.extent,i))}}function B(w,...$){if(this.__zooming){var N=S(this,$).event(w),E=w.changedTouches,P=E.length,M,L;for(Mt(w),l&&clearTimeout(l),l=setTimeout(function(){l=null},m),M=0;M<P;++M)L=E[M],N.touch0&&N.touch0[2]===L.identifier?delete N.touch0:N.touch1&&N.touch1[2]===L.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(L=ue(L,this),Math.hypot(c[0]-L[0],c[1]-L[1])<y)){var j=ae(this).on("dblclick.zoom");j&&j.apply(this,arguments)}}}return g.wheelDelta=function(w){return arguments.length?(o=typeof w=="function"?w:nt(+w),g):o},g.filter=function(w){return arguments.length?(e=typeof w=="function"?w:nt(!!w),g):e},g.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:nt(!!w),g):s},g.extent=function(w){return arguments.length?(t=typeof w=="function"?w:nt([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),g):t},g.scaleExtent=function(w){return arguments.length?(r[0]=+w[0],r[1]=+w[1],g):[r[0],r[1]]},g.translateExtent=function(w){return arguments.length?(i[0][0]=+w[0][0],i[1][0]=+w[1][0],i[0][1]=+w[0][1],i[1][1]=+w[1][1],g):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},g.constrain=function(w){return arguments.length?(n=w,g):n},g.duration=function(w){return arguments.length?(a=+w,g):a},g.interpolate=function(w){return arguments.length?(d=w,g):d},g.on=function(){var w=u.on.apply(u,arguments);return w===u?g:w},g.clickDistance=function(w){return arguments.length?(b=(w=+w)*w,g):Math.sqrt(b)},g.tapDistance=function(w){return arguments.length?(y=+w,g):y},g}function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ie(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const he={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Xe=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eo=["Enter"," ","Escape"],to={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Le;(function(e){e.Strict="strict",e.Loose="loose"})(Le||(Le={}));var ke;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ke||(ke={}));var We;(function(e){e.Partial="partial",e.Full="full"})(We||(We={}));const no={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ee;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ee||(Ee={}));var ct;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ct||(ct={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const an={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function oo(e){return e===null?null:e?"valid":"invalid"}const so=e=>"id"in e&&"source"in e&&"target"in e,Hr=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Rt=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ke=(e,t=[0,0])=>{const{width:n,height:o}=we(e),s=e.origin??t,r=n*s[0],i=o*s[1];return{x:e.position.x-r,y:e.position.y-i}},Rr=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const r=typeof s=="string";let i=!t.nodeLookup&&!r?s:void 0;t.nodeLookup&&(i=r?t.nodeLookup.get(s):Rt(s)?s:t.nodeLookup.get(s.id));const a=i?lt(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ft(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ht(n)},Ue=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=ft(n,lt(s)),o=!0)}),o?ht(n):{x:0,y:0,width:0,height:0}},Bt=(e,t,[n,o,s]=[0,0,1],r=!1,i=!1)=>{const a=(t.x-n)/s,d=(t.y-o)/s,u=t.width/s,h=t.height/s,c=[];for(const l of e.values()){const{measured:m,selectable:p=!0,hidden:b=!1}=l;if(i&&!p||b)continue;const y=m.width??l.width??l.initialWidth??0,g=m.height??l.height??l.initialHeight??0,{x:v,y:f}=l.internals.positionAbsolute,x=co(a,d,u,h,v,f,y,g),k=y*g,S=r&&x>0;(!l.internals.handleBounds||S||x>=k||l.dragging)&&c.push(l)}return c},Br=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Vr(e,t){const n=new Map,o=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function Fr({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:r},i){if(e.size===0)return!0;const a=Vr(e,i),d=Ue(a),u=Ft(d,t,n,(i==null?void 0:i.minZoom)??s,(i==null?void 0:i.maxZoom)??r,(i==null?void 0:i.padding)??.1);return await o.setViewport(u,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0}function ro({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:r}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:d,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},h=i.origin??o;let c=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!a)r==null||r("005",he.error005());else{const m=a.measured.width,p=a.measured.height;m&&p&&(c=[[d,u],[d+m,u+p]])}else a&&$e(i.extent)&&(c=[[i.extent[0][0]+d,i.extent[0][1]+u],[i.extent[1][0]+d,i.extent[1][1]+u]]);const l=$e(c)?Pe(t,c,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(r==null||r("015",he.error015())),{position:{x:l.x-d+(i.measured.width??0)*h[0],y:l.y-u+(i.measured.height??0)*h[1]},positionAbsolute:l}}async function Or({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const r=new Set(e.map(l=>l.id)),i=[];for(const l of n){if(l.deletable===!1)continue;const m=r.has(l.id),p=!m&&l.parentId&&i.find(b=>b.id===l.parentId);(m||p)&&i.push(l)}const a=new Set(t.map(l=>l.id)),d=o.filter(l=>l.deletable!==!1),h=Br(i,d);for(const l of d)a.has(l.id)&&!h.find(p=>p.id===l.id)&&h.push(l);if(!s)return{edges:h,nodes:i};const c=await s({nodes:i,edges:h});return typeof c=="boolean"?c?{edges:h,nodes:i}:{edges:[],nodes:[]}:c}const je=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Pe=(e={x:0,y:0},t,n)=>({x:je(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:je(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function io(e,t,n){const{width:o,height:s}=we(n),{x:r,y:i}=n.internals.positionAbsolute;return Pe(e,[[r,i],[r+o,i+s]],t)}const cn=(e,t,n)=>e<t?je(Math.abs(e-t),1,t)/t:e>n?-je(Math.abs(e-n),1,t)/t:0,Vt=(e,t,n=15,o=40)=>{const s=cn(e.x,o,t.width-o)*n,r=cn(e.y,o,t.height-o)*n;return[s,r]},ft=(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)}),At=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),ht=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ge=(e,t=[0,0])=>{var s,r;const{x:n,y:o}=Rt(e)?e.internals.positionAbsolute:Ke(e,t);return{x:n,y:o,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}},lt=(e,t=[0,0])=>{var s,r;const{x:n,y:o}=Rt(e)?e.internals.positionAbsolute:Ke(e,t);return{x:n,y:o,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:o+(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0)}},ao=(e,t)=>ht(ft(At(e),At(t))),co=(e,t,n,o,s,r,i,a)=>{const d=Math.max(0,Math.min(e+n,s+i)-Math.max(e,s)),u=Math.max(0,Math.min(t+o,r+a)-Math.max(t,r));return Math.ceil(d*u)},ut=(e,t)=>co(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),ln=e=>de(e.width)&&de(e.height)&&de(e.x)&&de(e.y),de=e=>!isNaN(e)&&isFinite(e),lo=(e,t)=>(n,o)=>{},Qe=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Je=({x:e,y:t},[n,o,s],r=!1,i=[1,1])=>{const a={x:(e-n)/s,y:(t-o)/s};return r?Qe(a,i):a},He=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function Ae(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Yr(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Ae(e,n),s=Ae(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=Ae(e.top??e.y??0,n),s=Ae(e.bottom??e.y??0,n),r=Ae(e.left??e.x??0,t),i=Ae(e.right??e.x??0,t);return{top:o,right:i,bottom:s,left:r,x:r+i,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Xr(e,t,n,o,s,r){const{x:i,y:a}=He(e,[t,n,o]),{x:d,y:u}=He({x:e.x+e.width,y:e.y+e.height},[t,n,o]),h=s-d,c=r-u;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(h),bottom:Math.floor(c)}}const Ft=(e,t,n,o,s,r)=>{const i=Yr(r,t,n),a=(t-i.x)/e.width,d=(n-i.y)/e.height,u=Math.min(a,d),h=je(u,o,s),c=e.x+e.width/2,l=e.y+e.height/2,m=t/2-c*h,p=n/2-l*h,b=Xr(e,m,p,h,t,n),y={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:m-y.left+y.right,y:p-y.top+y.bottom,zoom:h}},qe=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function $e(e){return e!=null&&e!=="parent"}function we(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function uo(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function fo(e,t={width:0,height:0},n,o,s){const r={...e},i=o.get(n);if(i){const a=i.origin||s;r.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],r.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return r}function un(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Wr(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function Gr(e){return{...to,...e||{}}}function Oe(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:r,y:i}=fe(e),a=Je({x:r-((s==null?void 0:s.left)??0),y:i-((s==null?void 0:s.top)??0)},o),{x:d,y:u}=n?Qe(a,t):a;return{xSnapped:d,ySnapped:u,...a}}const Ot=e=>({width:e.offsetWidth,height:e.offsetHeight}),ho=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},qr=["INPUT","SELECT","TEXTAREA"];function go(e){var o,s;const t=((s=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:qr.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const po=e=>"clientX"in e,fe=(e,t)=>{var r,i;const n=po(e),o=n?e.clientX:(r=e.touches)==null?void 0:r[0].clientX,s=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},dn=(e,t,n,o,s)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...Ot(i)}})};function mo({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:r,targetControlX:i,targetControlY:a}){const d=e*.125+s*.375+i*.375+n*.125,u=t*.125+r*.375+a*.375+o*.125,h=Math.abs(d-e),c=Math.abs(u-t);return[d,u,h,c]}function ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fn({pos:e,x1:t,y1:n,x2:o,y2:s,c:r}){switch(e){case W.Left:return[t-ot(t-o,r),n];case W.Right:return[t+ot(o-t,r),n];case W.Top:return[t,n-ot(n-s,r)];case W.Bottom:return[t,n+ot(s-n,r)]}}function yo({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:s,targetPosition:r=W.Top,curvature:i=.25}){const[a,d]=fn({pos:n,x1:e,y1:t,x2:o,y2:s,c:i}),[u,h]=fn({pos:r,x1:o,y1:s,x2:e,y2:t,c:i}),[c,l,m,p]=mo({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:a,sourceControlY:d,targetControlX:u,targetControlY:h});return[`M${e},${t} C${a},${d} ${u},${h} ${o},${s}`,c,l,m,p]}function xo({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,r=n<e?n+s:n-s,i=Math.abs(o-t)/2,a=o<t?o+i:o-i;return[r,a,s,i]}function Zr({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:r="basic"}){if(r==="manual")return o;const i=s&&n?o+1e3:o,a=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+a}function Kr({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const r=ft(lt(e),lt(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return ut(i,ht(r))>0}const Ur=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Qr=(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)),Jr=(e,t,n={})=>{var r;if(!e.source||!e.target)return(r=n.onError)==null||r.call(n,"006",he.error006()),t;const o=n.getEdgeId||Ur;let s;return so(e)?s={...e}:s={...e,id:o(e)},Qr(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function wo({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,r,i,a]=xo({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,r,i,a]}const hn={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},ei=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},gn=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ti({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:o=W.Top,center:s,offset:r,stepPosition:i}){const a=hn[t],d=hn[o],u={x:e.x+a.x*r,y:e.y+a.y*r},h={x:n.x+d.x*r,y:n.y+d.y*r},c=ei({source:u,sourcePosition:t,target:h}),l=c.x!==0?"x":"y",m=c[l];let p=[],b,y;const g={x:0,y:0},v={x:0,y:0},[,,f,x]=xo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[l]*d[l]===-1){l==="x"?(b=s.x??u.x+(h.x-u.x)*i,y=s.y??(u.y+h.y)/2):(b=s.x??(u.x+h.x)/2,y=s.y??u.y+(h.y-u.y)*i);const A=[{x:b,y:u.y},{x:b,y:h.y}],T=[{x:u.x,y},{x:h.x,y}];a[l]===m?p=l==="x"?A:T:p=l==="x"?T:A}else{const A=[{x:u.x,y:h.y}],T=[{x:h.x,y:u.y}];if(l==="x"?p=a.x===m?T:A:p=a.y===m?A:T,t===o){const w=Math.abs(e[l]-n[l]);if(w<=r){const $=Math.min(r-1,r-w);a[l]===m?g[l]=(u[l]>e[l]?-1:1)*$:v[l]=(h[l]>n[l]?-1:1)*$}}if(t!==o){const w=l==="x"?"y":"x",$=a[l]===d[w],N=u[w]>h[w],E=u[w]<h[w];(a[l]===1&&(!$&&N||$&&E)||a[l]!==1&&(!$&&E||$&&N))&&(p=l==="x"?A:T)}const V={x:u.x+g.x,y:u.y+g.y},I={x:h.x+v.x,y:h.y+v.y},D=Math.max(Math.abs(V.x-p[0].x),Math.abs(I.x-p[0].x)),B=Math.max(Math.abs(V.y-p[0].y),Math.abs(I.y-p[0].y));D>=B?(b=(V.x+I.x)/2,y=p[0].y):(b=p[0].x,y=(V.y+I.y)/2)}const k={x:u.x+g.x,y:u.y+g.y},S={x:h.x+v.x,y:h.y+v.y};return[[e,...k.x!==p[0].x||k.y!==p[0].y?[k]:[],...p,...S.x!==p[p.length-1].x||S.y!==p[p.length-1].y?[S]:[],n],b,y,f,x]}function ni(e,t,n,o){const s=Math.min(gn(e,t)/2,gn(t,n)/2,o),{x:r,y:i}=t;if(e.x===r&&r===n.x||e.y===i&&i===n.y)return`L${r} ${i}`;if(e.y===i){const u=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${r+s*u},${i}Q ${r},${i} ${r},${i+s*h}`}const a=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${r},${i+s*d}Q ${r},${i} ${r+s*a},${i}`}function zt({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:s,targetPosition:r=W.Top,borderRadius:i=5,centerX:a,centerY:d,offset:u=20,stepPosition:h=.5}){const[c,l,m,p,b]=ti({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:r,center:{x:a,y:d},offset:u,stepPosition:h});let y=`M${c[0].x} ${c[0].y}`;for(let g=1;g<c.length-1;g++)y+=ni(c[g-1],c[g],c[g+1],i);return y+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[y,l,m,p,b]}function pn(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function oi(e){var c;const{sourceNode:t,targetNode:n}=e;if(!pn(t)||!pn(n))return null;const o=t.internals.handleBounds||mn(t.handles),s=n.internals.handleBounds||mn(n.handles),r=yn((o==null?void 0:o.source)??[],e.sourceHandle),i=yn(e.connectionMode===Le.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!r||!i)return(c=e.onError)==null||c.call(e,"008",he.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(r==null?void 0:r.position)||W.Bottom,d=(i==null?void 0:i.position)||W.Top,u=_e(t,r,a),h=_e(n,i,d);return{sourceX:u.x,sourceY:u.y,targetX:h.x,targetY:h.y,sourcePosition:a,targetPosition:d}}function mn(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function _e(e,t,n=W.Left,o=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,r=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??we(e);if(o)return{x:s+i/2,y:r+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:s+i/2,y:r};case W.Right:return{x:s+i,y:r+a/2};case W.Bottom:return{x:s+i/2,y:r+a};case W.Left:return{x:s,y:r+a/2}}}function yn(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Tt(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function si(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const r=new Set;return e.reduce((i,a)=>([a.markerStart||o,a.markerEnd||s].forEach(d=>{if(d&&typeof d=="object"){const u=Tt(d,t);r.has(u)||(i.push({id:u,color:d.color||n,...d}),r.add(u))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const bo=1e3,ri=10,Yt={nodeOrigin:[0,0],nodeExtent:Xe,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ii={...Yt,checkEquality:!0};function Xt(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function ai(e,t,n){const o=Xt(Yt,n);for(const s of e.values())if(s.parentId)Gt(s,e,t,o);else{const r=Ke(s,o.nodeOrigin),i=$e(s.extent)?s.extent:o.nodeExtent,a=Pe(r,i,we(s));s.internals.positionAbsolute=a}}function ci(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const r={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(r):s.type==="target"&&o.push(r)}return{source:n,target:o}}function Wt(e){return e==="manual"}function Dt(e,t,n,o={}){var h,c;const s=Xt(ii,o),r={i:0},i=new Map(t),a=s!=null&&s.elevateNodesOnSelect&&!Wt(s.zIndexMode)?bo:0;let d=e.length>0,u=!1;t.clear(),n.clear();for(const l of e){let m=i.get(l.id);if(s.checkEquality&&l===(m==null?void 0:m.internals.userNode))t.set(l.id,m);else{const p=Ke(l,s.nodeOrigin),b=$e(l.extent)?l.extent:s.nodeExtent,y=Pe(p,b,we(l));m={...s.defaults,...l,measured:{width:(h=l.measured)==null?void 0:h.width,height:(c=l.measured)==null?void 0:c.height},internals:{positionAbsolute:y,handleBounds:ci(l,m),z:vo(l,a,s.zIndexMode),userNode:l}},t.set(l.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(d=!1),l.parentId&&Gt(m,t,n,o,r),u||(u=l.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:u}}function li(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Gt(e,t,n,o,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:a,zIndexMode:d}=Xt(Yt,o),u=e.parentId,h=t.get(u);if(!h){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}li(e,n),s&&!h.parentId&&h.internals.rootParentIndex===void 0&&d==="auto"&&(h.internals.rootParentIndex=++s.i,h.internals.z=h.internals.z+s.i*ri),s&&h.internals.rootParentIndex!==void 0&&(s.i=h.internals.rootParentIndex);const c=r&&!Wt(d)?bo:0,{x:l,y:m,z:p}=ui(e,h,i,a,c,d),{positionAbsolute:b}=e.internals,y=l!==b.x||m!==b.y;(y||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:l,y:m}:b,z:p}})}function vo(e,t,n){const o=de(e.zIndex)?e.zIndex:0;return Wt(n)?o:o+(e.selected?t:0)}function ui(e,t,n,o,s,r){const{x:i,y:a}=t.internals.positionAbsolute,d=we(e),u=Ke(e,n),h=$e(e.extent)?Pe(u,e.extent,d):u;let c=Pe({x:i+h.x,y:a+h.y},o,d);e.extent==="parent"&&(c=io(c,d,t));const l=vo(e,s,r),m=t.internals.z??0;return{x:c.x,y:c.y,z:m>=l?m+1:l}}function qt(e,t,n,o=[0,0]){var i;const s=[],r=new Map;for(const a of e){const d=t.get(a.parentId);if(!d)continue;const u=((i=r.get(a.parentId))==null?void 0:i.expandedRect)??Ge(d),h=ao(u,a.rect);r.set(a.parentId,{expandedRect:h,parent:d})}return r.size>0&&r.forEach(({expandedRect:a,parent:d},u)=>{var f;const h=d.internals.positionAbsolute,c=we(d),l=d.origin??o,m=a.x<h.x?Math.round(Math.abs(h.x-a.x)):0,p=a.y<h.y?Math.round(Math.abs(h.y-a.y)):0,b=Math.max(c.width,Math.round(a.width)),y=Math.max(c.height,Math.round(a.height)),g=(b-c.width)*l[0],v=(y-c.height)*l[1];(m>0||p>0||g||v)&&(s.push({id:u,type:"position",position:{x:d.position.x-m+g,y:d.position.y-p+v}}),(f=n.get(u))==null||f.forEach(x=>{e.some(k=>k.id===x.id)||s.push({id:x.id,type:"position",position:{x:x.position.x+m,y:x.position.y+p}})})),(c.width<a.width||c.height<a.height||m||p)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:b+(m?l[0]*m-g:0),height:y+(p?l[1]*p-v:0)}})}),s}function di(e,t,n,o,s,r,i){const a=o==null?void 0:o.querySelector(".xyflow__viewport");let d=!1;if(!a)return{changes:[],updatedInternals:d};const u=[],h=window.getComputedStyle(a),{m22:c}=new window.DOMMatrixReadOnly(h.transform),l=[];for(const m of e.values()){const p=t.get(m.id);if(!p)continue;if(p.hidden){t.set(p.id,{...p,internals:{...p.internals,handleBounds:void 0}}),d=!0;continue}const b=Ot(m.nodeElement),y=p.measured.width!==b.width||p.measured.height!==b.height;if(!!(b.width&&b.height&&(y||!p.internals.handleBounds||m.force))){const v=m.nodeElement.getBoundingClientRect(),f=$e(p.extent)?p.extent:r;let{positionAbsolute:x}=p.internals;p.parentId&&p.extent==="parent"?x=io(x,b,t.get(p.parentId)):f&&(x=Pe(x,f,b));const k={...p,measured:b,internals:{...p.internals,positionAbsolute:x,handleBounds:{source:dn("source",m.nodeElement,v,c,p.id),target:dn("target",m.nodeElement,v,c,p.id)}}};t.set(p.id,k),p.parentId&&Gt(k,t,n,{nodeOrigin:s,zIndexMode:i}),d=!0,y&&(u.push({id:p.id,type:"dimensions",dimensions:b}),p.expandParent&&p.parentId&&l.push({id:p.id,parentId:p.parentId,rect:Ge(k,s)}))}}if(l.length>0){const m=qt(l,t,n,s);u.push(...m)}return{changes:u,updatedInternals:d}}async function fi({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:r}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,r]],o);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function xn(e,t,n,o,s,r){let i=s;const a=o.get(i)||new Map;o.set(i,a.set(n,t)),i=`${s}-${e}`;const d=o.get(i)||new Map;if(o.set(i,d.set(n,t)),r){i=`${s}-${e}-${r}`;const u=o.get(i)||new Map;o.set(i,u.set(n,t))}}function Eo(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:r,sourceHandle:i=null,targetHandle:a=null}=o,d={edgeId:o.id,source:s,target:r,sourceHandle:i,targetHandle:a},u=`${s}-${i}--${r}-${a}`,h=`${r}-${a}--${s}-${i}`;xn("source",d,h,e,s,i),xn("target",d,u,e,r,a),t.set(o.id,o)}}function So(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:So(n,t):!1}function wn(e,t,n){var s;let o=e;do{if((s=o==null?void 0:o.matches)!=null&&s.call(o,t))return!0;if(o===n)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function hi(e,t,n,o){const s=new Map;for(const[r,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!So(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(r);a&&s.set(r,{id:r,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return s}function Ct({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){var i,a,d;const s=[];for(const[u,h]of t){const c=(i=n.get(u))==null?void 0:i.internals.userNode;c&&s.push({...c,position:h.position,dragging:o})}if(!e)return[s[0],s];const r=(a=n.get(e))==null?void 0:a.internals.userNode;return[r?{...r,position:((d=t.get(e))==null?void 0:d.position)||r.position,dragging:o}:s[0],s]}function gi({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const r={x:n-s.distance.x,y:o-s.distance.y},i=Qe(r,t);return{x:i.x-r.x,y:i.y-r.y}}function pi({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let r={x:null,y:null},i=0,a=new Map,d=!1,u={x:0,y:0},h=null,c=!1,l=null,m=!1,p=!1,b=null;function y({noDragClassName:v,handleSelector:f,domNode:x,isSelectable:k,nodeId:S,nodeClickDistance:_=0}){l=ae(x);function A({x:D,y:B}){const{nodeLookup:w,nodeExtent:$,snapGrid:N,snapToGrid:E,nodeOrigin:P,onNodeDrag:M,onSelectionDrag:L,onError:j,updateNodePositions:H}=t();r={x:D,y:B};let O=!1;const Y=a.size>1,Z=Y&&$?At(Ue(a)):null,Q=Y&&E?gi({dragItems:a,snapGrid:N,x:D,y:B}):null;for(const[q,R]of a){if(!w.has(q))continue;let F={x:D-R.distance.x,y:B-R.distance.y};E&&(F=Q?{x:Math.round(F.x+Q.x),y:Math.round(F.y+Q.y)}:Qe(F,N));let U=null;if(Y&&$&&!R.extent&&Z){const{positionAbsolute:X}=R.internals,J=X.x-Z.x+$[0][0],te=X.x+R.measured.width-Z.x2+$[1][0],ne=X.y-Z.y+$[0][1],re=X.y+R.measured.height-Z.y2+$[1][1];U=[[J,ne],[te,re]]}const{position:K,positionAbsolute:G}=ro({nodeId:q,nextPosition:F,nodeLookup:w,nodeExtent:U||$,nodeOrigin:P,onError:j});O=O||R.position.x!==K.x||R.position.y!==K.y,R.position=K,R.internals.positionAbsolute=G}if(p=p||O,!!O&&(H(a,!0),b&&(o||M||!S&&L))){const[q,R]=Ct({nodeId:S,dragItems:a,nodeLookup:w});o==null||o(b,a,q,R),M==null||M(b,q,R),S||L==null||L(b,R)}}async function T(){if(!h)return;const{transform:D,panBy:B,autoPanSpeed:w,autoPanOnNodeDrag:$}=t();if(!$){d=!1,cancelAnimationFrame(i);return}const[N,E]=Vt(u,h,w);(N!==0||E!==0)&&(r.x=(r.x??0)-N/D[2],r.y=(r.y??0)-E/D[2],await B({x:N,y:E})&&A(r)),i=requestAnimationFrame(T)}function V(D){var Y;const{nodeLookup:B,multiSelectionActive:w,nodesDraggable:$,transform:N,snapGrid:E,snapToGrid:P,selectNodesOnDrag:M,onNodeDragStart:L,onSelectionDragStart:j,unselectNodesAndEdges:H}=t();c=!0,(!M||!k)&&!w&&S&&((Y=B.get(S))!=null&&Y.selected||H()),k&&M&&S&&(e==null||e(S));const O=Oe(D.sourceEvent,{transform:N,snapGrid:E,snapToGrid:P,containerBounds:h});if(r=O,a=hi(B,$,O,S),a.size>0&&(n||L||!S&&j)){const[Z,Q]=Ct({nodeId:S,dragItems:a,nodeLookup:B});n==null||n(D.sourceEvent,a,Z,Q),L==null||L(D.sourceEvent,Z,Q),S||j==null||j(D.sourceEvent,Q)}}const I=Qn().clickDistance(_).on("start",D=>{const{domNode:B,nodeDragThreshold:w,transform:$,snapGrid:N,snapToGrid:E}=t();h=(B==null?void 0:B.getBoundingClientRect())||null,m=!1,p=!1,b=D.sourceEvent,w===0&&V(D),r=Oe(D.sourceEvent,{transform:$,snapGrid:N,snapToGrid:E,containerBounds:h}),u=fe(D.sourceEvent,h)}).on("drag",D=>{const{autoPanOnNodeDrag:B,transform:w,snapGrid:$,snapToGrid:N,nodeDragThreshold:E,nodeLookup:P}=t(),M=Oe(D.sourceEvent,{transform:w,snapGrid:$,snapToGrid:N,containerBounds:h});if(b=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||S&&!P.has(S))&&(m=!0),!m){if(!d&&B&&c&&(d=!0,T()),!c){const L=fe(D.sourceEvent,h),j=L.x-u.x,H=L.y-u.y;Math.sqrt(j*j+H*H)>E&&V(D)}(r.x!==M.xSnapped||r.y!==M.ySnapped)&&a&&c&&(u=fe(D.sourceEvent,h),A(M))}}).on("end",D=>{if(!c||m){m&&a.size>0&&t().updateNodePositions(a,!1);return}if(d=!1,c=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:B,updateNodePositions:w,onNodeDragStop:$,onSelectionDragStop:N}=t();if(p&&(w(a,!1),p=!1),s||$||!S&&N){const[E,P]=Ct({nodeId:S,dragItems:a,nodeLookup:B,dragging:!1});s==null||s(D.sourceEvent,a,E,P),$==null||$(D.sourceEvent,E,P),S||N==null||N(D.sourceEvent,P)}}}).filter(D=>{const B=D.target;return!D.button&&(!v||!wn(B,`.${v}`,x))&&(!f||wn(B,f,x))});l.call(I)}function g(){l==null||l.on(".drag",null)}return{update:y,destroy:g}}function mi(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())ut(s,Ge(r))>0&&o.push(r);return o}const yi=250;function xi(e,t,n,o){var a,d;let s=[],r=1/0;const i=mi(e,n,t+yi);for(const u of i){const h=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((d=u.internals.handleBounds)==null?void 0:d.target)??[]];for(const c of h){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:l,y:m}=_e(u,c,c.position,!0),p=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(m-e.y,2));p>t||(p<r?(s=[{...c,x:l,y:m}],r=p):p===r&&s.push({...c,x:l,y:m}))}}if(!s.length)return null;if(s.length>1){const u=o.type==="source"?"target":"source";return s.find(h=>h.type===u)??s[0]}return s[0]}function No(e,t,n,o,s,r=!1){var u,h,c;const i=o.get(e);if(!i)return null;const a=s==="strict"?(u=i.internals.handleBounds)==null?void 0:u[t]:[...((h=i.internals.handleBounds)==null?void 0:h.source)??[],...((c=i.internals.handleBounds)==null?void 0:c.target)??[]],d=(n?a==null?void 0:a.find(l=>l.id===n):a==null?void 0:a[0])??null;return d&&r?{...d,..._e(i,d,d.position,!0)}:d}function Mo(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function wi(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Co=()=>!0;function bi(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:r,isTarget:i,domNode:a,nodeLookup:d,lib:u,autoPanOnConnect:h,flowId:c,panBy:l,cancelConnection:m,onConnectStart:p,onConnect:b,onConnectEnd:y,isValidConnection:g=Co,onReconnectEnd:v,updateConnection:f,getTransform:x,getFromHandle:k,autoPanSpeed:S,dragThreshold:_=1,handleDomNode:A}){const T=ho(e.target);let V=0,I;const{x:D,y:B}=fe(e),w=Mo(r,A),$=a==null?void 0:a.getBoundingClientRect();let N=!1;if(!$||!w)return;const E=No(s,w,o,d,t);if(!E)return;let P=fe(e,$),M=!1,L=null,j=!1,H=null;function O(){if(!h||!$)return;const[K,G]=Vt(P,$,S);l({x:K,y:G}),V=requestAnimationFrame(O)}const Y={...E,nodeId:s,type:w,position:E.position},Z=d.get(s);let q={inProgress:!0,isValid:null,from:_e(Z,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Z,to:P,toHandle:null,toPosition:an[Y.position],toNode:null,pointer:P};function R(){N=!0,f(q),p==null||p(e,{nodeId:s,handleId:o,handleType:w})}_===0&&R();function F(K){if(!N){const{x:re,y:ce}=fe(K),ge=re-D,pe=ce-B;if(!(ge*ge+pe*pe>_*_))return;R()}if(!k()||!Y){U(K);return}const G=x();P=fe(K,$),I=xi(Je(P,G,!1,[1,1]),n,d,Y),M||(O(),M=!0);const X=Io(K,{handle:I,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:i?"target":"source",isValidConnection:g,doc:T,lib:u,flowId:c,nodeLookup:d});H=X.handleDomNode,L=X.connection,j=wi(!!I,X.isValid);const J=d.get(s),te=J?_e(J,Y,W.Left,!0):q.from,ne={...q,from:te,isValid:j,to:X.toHandle&&j?He({x:X.toHandle.x,y:X.toHandle.y},G):P,toHandle:X.toHandle,toPosition:j&&X.toHandle?X.toHandle.position:an[Y.position],toNode:X.toHandle?d.get(X.toHandle.nodeId):null,pointer:P};f(ne),q=ne}function U(K){if(!("touches"in K&&K.touches.length>0)){if(N){(I||H)&&L&&j&&(b==null||b(L));const{inProgress:G,...X}=q,J={...X,toPosition:q.toHandle?q.toPosition:null};y==null||y(K,J),r&&(v==null||v(K,J))}m(),cancelAnimationFrame(V),M=!1,j=!1,L=null,H=null,T.removeEventListener("mousemove",F),T.removeEventListener("mouseup",U),T.removeEventListener("touchmove",F),T.removeEventListener("touchend",U)}}T.addEventListener("mousemove",F),T.addEventListener("mouseup",U),T.addEventListener("touchmove",F),T.addEventListener("touchend",U)}function Io(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:r,doc:i,lib:a,flowId:d,isValidConnection:u=Co,nodeLookup:h}){const c=r==="target",l=t?i.querySelector(`.${a}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:p}=fe(e),b=i.elementFromPoint(m,p),y=b!=null&&b.classList.contains(`${a}-flow__handle`)?b:l,g={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const v=Mo(void 0,y),f=y.getAttribute("data-nodeid"),x=y.getAttribute("data-handleid"),k=y.classList.contains("connectable"),S=y.classList.contains("connectableend");if(!f||!v)return g;const _={source:c?f:o,sourceHandle:c?x:s,target:c?o:f,targetHandle:c?s:x};g.connection=_;const T=k&&S&&(n===Le.Strict?c&&v==="source"||!c&&v==="target":f!==o||x!==s);g.isValid=T&&u(_),g.toHandle=No(f,v,x,h,n,!0)}return g}const Lt={onPointerDown:bi,isValid:Io};function vi({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=ae(e);function r({translateExtent:a,width:d,height:u,zoomStep:h=1,pannable:c=!0,zoomable:l=!0,inversePan:m=!1}){const p=f=>{if(f.sourceEvent.type!=="wheel"||!t)return;const x=n(),k=f.sourceEvent.ctrlKey&&qe()?10:1,S=-f.sourceEvent.deltaY*(f.sourceEvent.deltaMode===1?.05:f.sourceEvent.deltaMode?1:.002)*h,_=x[2]*Math.pow(2,S*k);t.scaleTo(_)};let b=[0,0];const y=f=>{(f.sourceEvent.type==="mousedown"||f.sourceEvent.type==="touchstart")&&(b=[f.sourceEvent.clientX??f.sourceEvent.touches[0].clientX,f.sourceEvent.clientY??f.sourceEvent.touches[0].clientY])},g=f=>{const x=n();if(f.sourceEvent.type!=="mousemove"&&f.sourceEvent.type!=="touchmove"||!t)return;const k=[f.sourceEvent.clientX??f.sourceEvent.touches[0].clientX,f.sourceEvent.clientY??f.sourceEvent.touches[0].clientY],S=[k[0]-b[0],k[1]-b[1]];b=k;const _=o()*Math.max(x[2],Math.log(x[2]))*(m?-1:1),A={x:x[0]-S[0]*_,y:x[1]-S[1]*_},T=[[0,0],[d,u]];t.setViewportConstrained({x:A.x,y:A.y,zoom:x[2]},T,a)},v=Jn().on("start",y).on("zoom",c?g:null).on("zoom.wheel",l?p:null);s.call(v,{})}function i(){s.on("zoom",null)}return{update:r,destroy:i,pointer:ue}}const gt=e=>({x:e.x,y:e.y,zoom:e.k}),It=({x:e,y:t,zoom:n})=>Ht.translate(e,t).scale(n),ze=(e,t)=>e.target.closest(`.${t}`),ko=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ei=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kt=(e,t=0,n=Ei,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},Po=e=>{const t=e.ctrlKey&&qe()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Si({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:r,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:d,onPanZoomEnd:u}){return h=>{if(ze(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(h.ctrlKey&&i){const y=ue(h),g=Po(h),v=c*Math.pow(2,g);o.scaleTo(n,v,y,h);return}const l=h.deltaMode===1?20:1;let m=s===ke.Vertical?0:h.deltaX*l,p=s===ke.Horizontal?0:h.deltaY*l;!qe()&&h.shiftKey&&s!==ke.Vertical&&(m=h.deltaY*l,p=0),o.translateBy(n,-(m/c)*r,-(p/c)*r,{internal:!0});const b=gt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(h,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(h,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(h,b))}}function Ni({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const r=o.type==="wheel",i=!t&&r&&!o.ctrlKey,a=ze(o,e);if(o.ctrlKey&&r&&a&&o.preventDefault(),i||a)return null;o.preventDefault(),n.call(this,o,s)}}function Mi({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{var r,i,a;if((r=o.sourceEvent)!=null&&r.internal)return;const s=gt(o.transform);e.mouseButton=((i=o.sourceEvent)==null?void 0:i.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((a=o.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(o.sourceEvent,s))}}function Ci({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return r=>{var i,a;e.usedRightMouseButton=!!(n&&ko(t,e.mouseButton??0)),(i=r.sourceEvent)!=null&&i.sync||o([r.transform.x,r.transform.y,r.transform.k]),s&&!((a=r.sourceEvent)!=null&&a.internal)&&(s==null||s(r.sourceEvent,gt(r.transform)))}}function Ii({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:r}){return i=>{var a;if(!((a=i.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,r&&ko(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&r(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const d=gt(i.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(i.sourceEvent,d)},n?150:0)}}}function ki({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:r,userSelectionActive:i,noWheelClassName:a,noPanClassName:d,lib:u,connectionInProgress:h}){return c=>{var y;const l=e||t,m=n&&c.ctrlKey,p=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(ze(c,`${u}-flow__node`)||ze(c,`${u}-flow__edge`)))return!0;if(!o&&!l&&!s&&!r&&!n||i||h&&!p||ze(c,a)&&p||ze(c,d)&&(!p||s&&p&&!e)||!n&&c.ctrlKey&&p)return!1;if(!n&&c.type==="touchstart"&&((y=c.touches)==null?void 0:y.length)>1)return c.preventDefault(),!1;if(!l&&!s&&!m&&p||!o&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(o)&&!o.includes(c.button)&&c.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||p)&&b}}function Pi({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:r,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),c=Jn().scaleExtent([t,n]).translateExtent(o),l=ae(e).call(c);v({x:s.x,y:s.y,zoom:je(s.zoom,t,n)},[[0,0],[h.width,h.height]],o);const m=l.on("wheel.zoom"),p=l.on("dblclick.zoom");c.wheelDelta(Po);async function b(I,D){return l?new Promise(B=>{c==null||c.interpolate((D==null?void 0:D.interpolate)==="linear"?St:at).transform(kt(l,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>B(!0)),I)}):!1}function y({noWheelClassName:I,noPanClassName:D,onPaneContextMenu:B,userSelectionActive:w,panOnScroll:$,panOnDrag:N,panOnScrollMode:E,panOnScrollSpeed:P,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:j,zoomOnDoubleClick:H,zoomActivationKeyPressed:O,lib:Y,onTransformChange:Z,connectionInProgress:Q,paneClickDistance:q,selectionOnDrag:R}){w&&!u.isZoomingOrPanning&&g();const F=$&&!O&&!w;c.clickDistance(R?1/0:!de(q)||q<0?0:q);const U=F?Si({zoomPanValues:u,noWheelClassName:I,d3Selection:l,d3Zoom:c,panOnScrollMode:E,panOnScrollSpeed:P,zoomOnPinch:L,onPanZoomStart:i,onPanZoom:r,onPanZoomEnd:a}):Ni({noWheelClassName:I,preventScrolling:M,d3ZoomHandler:m});l.on("wheel.zoom",U,{passive:!1});const K=Mi({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:i});c.on("start",K);const G=Ci({zoomPanValues:u,panOnDrag:N,onPaneContextMenu:!!B,onPanZoom:r,onTransformChange:Z});c.on("zoom",G);const X=Ii({zoomPanValues:u,panOnDrag:N,panOnScroll:$,onPaneContextMenu:B,onPanZoomEnd:a,onDraggingChange:d});c.on("end",X);const J=ki({zoomActivationKeyPressed:O,panOnDrag:N,zoomOnScroll:j,panOnScroll:$,zoomOnDoubleClick:H,zoomOnPinch:L,userSelectionActive:w,noPanClassName:D,noWheelClassName:I,lib:Y,connectionInProgress:Q});c.filter(J),H?l.on("dblclick.zoom",p):l.on("dblclick.zoom",null)}function g(){c.on("zoom",null)}async function v(I,D,B){const w=It(I),$=c==null?void 0:c.constrain()(w,D,B);return $&&await b($),$}async function f(I,D){const B=It(I);return await b(B,D),B}function x(I){if(l){const D=It(I),B=l.property("__zoom");(B.k!==I.zoom||B.x!==I.x||B.y!==I.y)&&(c==null||c.transform(l,D,null,{sync:!0}))}}function k(){const I=l?yr(l.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}async function S(I,D){return l?new Promise(B=>{c==null||c.interpolate((D==null?void 0:D.interpolate)==="linear"?St:at).scaleTo(kt(l,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>B(!0)),I)}):!1}async function _(I,D){return l?new Promise(B=>{c==null||c.interpolate((D==null?void 0:D.interpolate)==="linear"?St:at).scaleBy(kt(l,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>B(!0)),I)}):!1}function A(I){c==null||c.scaleExtent(I)}function T(I){c==null||c.translateExtent(I)}function V(I){const D=!de(I)||I<0?0:I;c==null||c.clickDistance(D)}return{update:y,destroy:g,setViewport:f,setViewportConstrained:v,getViewport:k,scaleTo:S,scaleBy:_,setScaleExtent:A,setTranslateExtent:T,syncViewport:x,setClickDistance:V}}var Re;(function(e){e.Line="line",e.Handle="handle"})(Re||(Re={}));function $i({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:r}){const i=e-t,a=n-o,d=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&s&&(d[0]=d[0]*-1),a&&r&&(d[1]=d[1]*-1),d}function bn(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function be(e,t){return Math.max(0,t-e)}function ve(e,t){return Math.max(0,e-t)}function st(e,t,n){return Math.max(0,t-e,e-n)}function vn(e,t){return e?!t:t}function _i(e,t,n,o,s,r,i,a){let{affectsX:d,affectsY:u}=t;const{isHorizontal:h,isVertical:c}=t,l=h&&c,{xSnapped:m,ySnapped:p}=n,{minWidth:b,maxWidth:y,minHeight:g,maxHeight:v}=o,{x:f,y:x,width:k,height:S,aspectRatio:_}=e;let A=Math.floor(h?m-e.pointerX:0),T=Math.floor(c?p-e.pointerY:0);const V=k+(d?-A:A),I=S+(u?-T:T),D=-r[0]*k,B=-r[1]*S;let w=st(V,b,y),$=st(I,g,v);if(i){let P=0,M=0;d&&A<0?P=be(f+A+D,i[0][0]):!d&&A>0&&(P=ve(f+V+D,i[1][0])),u&&T<0?M=be(x+T+B,i[0][1]):!u&&T>0&&(M=ve(x+I+B,i[1][1])),w=Math.max(w,P),$=Math.max($,M)}if(a){let P=0,M=0;d&&A>0?P=ve(f+A,a[0][0]):!d&&A<0&&(P=be(f+V,a[1][0])),u&&T>0?M=ve(x+T,a[0][1]):!u&&T<0&&(M=be(x+I,a[1][1])),w=Math.max(w,P),$=Math.max($,M)}if(s){if(h){const P=st(V/_,g,v)*_;if(w=Math.max(w,P),i){let M=0;!d&&!u||d&&!u&&l?M=ve(x+B+V/_,i[1][1])*_:M=be(x+B+(d?A:-A)/_,i[0][1])*_,w=Math.max(w,M)}if(a){let M=0;!d&&!u||d&&!u&&l?M=be(x+V/_,a[1][1])*_:M=ve(x+(d?A:-A)/_,a[0][1])*_,w=Math.max(w,M)}}if(c){const P=st(I*_,b,y)/_;if($=Math.max($,P),i){let M=0;!d&&!u||u&&!d&&l?M=ve(f+I*_+D,i[1][0])/_:M=be(f+(u?T:-T)*_+D,i[0][0])/_,$=Math.max($,M)}if(a){let M=0;!d&&!u||u&&!d&&l?M=be(f+I*_,a[1][0])/_:M=ve(f+(u?T:-T)*_,a[0][0])/_,$=Math.max($,M)}}}T=T+(T<0?$:-$),A=A+(A<0?w:-w),s&&(l?V>I*_?T=(vn(d,u)?-A:A)/_:A=(vn(d,u)?-T:T)*_:h?(T=A/_,u=d):(A=T*_,d=u));const N=d?f+A:f,E=u?x+T:x;return{width:k+(d?-A:A),height:S+(u?-T:T),x:r[0]*A*(d?-1:1)+N,y:r[1]*T*(u?-1:1)+E}}const $o={width:0,height:0,x:0,y:0},Ai={...$o,pointerX:0,pointerY:0,aspectRatio:1};function zi(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,r=e.measured.width??0,i=e.measured.height??0,a=n[0]*r,d=n[1]*i;return[[o-a,s-d],[o+r-a,s+i-d]]}function Ti({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const r=ae(e);let i={controlDirection:bn("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:h,keepAspectRatio:c,resizeDirection:l,onResizeStart:m,onResize:p,onResizeEnd:b,shouldResize:y}){let g={...$o},v={...Ai};i={boundaries:h,resizeDirection:l,keepAspectRatio:c,controlDirection:bn(u)};let f,x=null,k=[],S,_,A,T=!1;const V=Qn().on("start",I=>{const{nodeLookup:D,transform:B,snapGrid:w,snapToGrid:$,nodeOrigin:N,paneDomNode:E}=n();if(f=D.get(t),!f)return;x=(E==null?void 0:E.getBoundingClientRect())??null;const{xSnapped:P,ySnapped:M}=Oe(I.sourceEvent,{transform:B,snapGrid:w,snapToGrid:$,containerBounds:x});g={width:f.measured.width??0,height:f.measured.height??0,x:f.position.x??0,y:f.position.y??0},v={...g,pointerX:P,pointerY:M,aspectRatio:g.width/g.height},S=void 0,_=$e(f.extent)?f.extent:void 0,f.parentId&&(f.extent==="parent"||f.expandParent)&&(S=D.get(f.parentId)),S&&f.extent==="parent"&&(_=[[0,0],[S.measured.width,S.measured.height]]),k=[],A=void 0;for(const[L,j]of D)if(j.parentId===t&&(k.push({id:L,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const H=zi(j,f,j.origin??N);A?A=[[Math.min(H[0][0],A[0][0]),Math.min(H[0][1],A[0][1])],[Math.max(H[1][0],A[1][0]),Math.max(H[1][1],A[1][1])]]:A=H}m==null||m(I,{...g})}).on("drag",I=>{const{transform:D,snapGrid:B,snapToGrid:w,nodeOrigin:$}=n(),N=Oe(I.sourceEvent,{transform:D,snapGrid:B,snapToGrid:w,containerBounds:x}),E=[];if(!f)return;const{x:P,y:M,width:L,height:j}=g,H={},O=f.origin??$,{width:Y,height:Z,x:Q,y:q}=_i(v,i.controlDirection,N,i.boundaries,i.keepAspectRatio,O,_,A),R=Y!==L,F=Z!==j,U=Q!==P&&R,K=q!==M&&F;if(!U&&!K&&!R&&!F)return;if((U||K||O[0]===1||O[1]===1)&&(H.x=U?Q:g.x,H.y=K?q:g.y,g.x=H.x,g.y=H.y,k.length>0)){const te=Q-P,ne=q-M;for(const re of k)re.position={x:re.position.x-te+O[0]*(Y-L),y:re.position.y-ne+O[1]*(Z-j)},E.push(re)}if((R||F)&&(H.width=R&&(!i.resizeDirection||i.resizeDirection==="horizontal")?Y:g.width,H.height=F&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:g.height,g.width=H.width,g.height=H.height),S&&f.expandParent){const te=O[0]*(H.width??0);H.x&&H.x<te&&(g.x=te,v.x=v.x-(H.x-te));const ne=O[1]*(H.height??0);H.y&&H.y<ne&&(g.y=ne,v.y=v.y-(H.y-ne))}const G=$i({width:g.width,prevWidth:L,height:g.height,prevHeight:j,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),X={...g,direction:G};(y==null?void 0:y(I,X))!==!1&&(T=!0,p==null||p(I,X),o(H,E))}).on("end",I=>{T&&(b==null||b(I,{...g}),s==null||s({...g}),T=!1)});r.call(V)}function d(){r.on(".drag",null)}return{update:a,destroy:d}}const Di={},En=e=>{let t;const n=new Set,o=(h,c)=>{const l=typeof h=="function"?h(t):h;if(!Object.is(l,t)){const m=t;t=c??(typeof l!="object"||l===null)?l:Object.assign({},t,l),n.forEach(p=>p(t,m))}},s=()=>t,d={setState:o,getState:s,getInitialState:()=>u,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Di?"production":void 0)!=="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()}},u=t=e(o,s,d);return d},Li=e=>e?En(e):En,{useDebugValue:ji}=wr,{useSyncExternalStoreWithSelector:Hi}=xr,Ri=e=>e;function _o(e,t=Ri,n){const o=Hi(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ji(o),o}const Sn=(e,t)=>{const n=Li(e),o=(s,r=t)=>_o(n,s,r);return Object.assign(o,n),o},Bi=(e,t)=>e?Sn(e,t):Sn;function oe(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[o,s]of e)if(!Object.is(s,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const pt=z.createContext(null),Vi=pt.Provider,Ao=he.error001("react");function ee(e,t){const n=z.useContext(pt);if(n===null)throw new Error(Ao);return _o(n,e,t)}function se(){const e=z.useContext(pt);if(e===null)throw new Error(Ao);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Nn={display:"none"},Fi={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},zo="react-flow__node-desc",To="react-flow__edge-desc",Oi="react-flow__aria-live",Yi=e=>e.ariaLiveMessage,Xi=e=>e.ariaLabelConfig;function Wi({rfId:e}){const t=ee(Yi);return C.jsx("div",{id:`${Oi}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Fi,children:t})}function Gi({rfId:e,disableKeyboardA11y:t}){const n=ee(Xi);return C.jsxs(C.Fragment,{children:[C.jsx("div",{id:`${zo}-${e}`,style:Nn,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),C.jsx("div",{id:`${To}-${e}`,style:Nn,children:n["edge.a11yDescription.default"]}),!t&&C.jsx(Wi,{rfId:e})]})}const mt=z.forwardRef(({position:e="top-left",children:t,className:n,style:o,...s},r)=>{const i=`${e}`.split("-");return C.jsx("div",{className:ie(["react-flow__panel",n,...i]),style:o,ref:r,...s,children:t})});mt.displayName="Panel";const Mn="https://reactflow.dev?utm_source=attribution";function qi({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:C.jsx(mt,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Mn}`,children:C.jsx("a",{href:Mn,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Zi=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},rt=e=>e.id;function Ki(e,t){return oe(e.selectedNodes.map(rt),t.selectedNodes.map(rt))&&oe(e.selectedEdges.map(rt),t.selectedEdges.map(rt))}function Ui({onSelectionChange:e}){const t=se(),{selectedNodes:n,selectedEdges:o}=ee(Zi,Ki);return z.useEffect(()=>{const s={nodes:n,edges:o};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(r=>r(s))},[n,o,e]),null}const Qi=e=>!!e.onSelectionChangeHandlers;function Ji({onSelectionChange:e}){const t=ee(Qi);return e||t?C.jsx(Ui,{onSelectionChange:e}):null}const Do=[0,0],ea={x:0,y:0,zoom:1},ta=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Cn=[...ta,"rfId"],na=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),In={translateExtent:Xe,nodeOrigin:Do,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function oa(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:r,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:d}=ee(na,oe),u=se();z.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{h.current=In,a()}),[]);const h=z.useRef(In);return z.useEffect(()=>{for(const c of Cn){const l=e[c],m=h.current[c];l!==m&&(typeof e[c]>"u"||(c==="nodes"?t(l):c==="edges"?n(l):c==="minZoom"?o(l):c==="maxZoom"?s(l):c==="translateExtent"?r(l):c==="nodeExtent"?i(l):c==="ariaLabelConfig"?u.setState({ariaLabelConfig:Gr(l)}):c==="fitView"?u.setState({fitViewQueued:l}):c==="fitViewOptions"?u.setState({fitViewOptions:l}):u.setState({[c]:l})))}h.current=e},Cn.map(c=>e[c])),null}function kn(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function sa(e){var o;const[t,n]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){n(e);return}const s=kn(),r=()=>n(s!=null&&s.matches?"dark":"light");return r(),s==null||s.addEventListener("change",r),()=>{s==null||s.removeEventListener("change",r)}},[e]),t!==null?t:(o=kn())!=null&&o.matches?"dark":"light"}const Pn=typeof document<"u"?document:null;function Ze(e=null,t={target:Pn,actInsideInputWithModifier:!0}){const[n,o]=z.useState(!1),s=z.useRef(!1),r=z.useRef(new Set([])),[i,a]=z.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",`
|
|
1
|
+
import{d as ae,bp as Zn,bq as Ht,br as vt,bs as Et,bt as yr,bu as xr,bv as wr,r as z,j as C,aJ as br,aI as vr,bw as Er}from"./index-MiIZL4f3.js";import{i as St}from"./value-IOfiG7E7.js";function Sr(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ue(e,t){if(e=Sr(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,o=o.matrixTransform(t.getScreenCTM().inverse()),[o.x,o.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Nr={passive:!1},Ye={capture:!0,passive:!1};function Nt(e){e.stopImmediatePropagation()}function De(e){e.preventDefault(),e.stopImmediatePropagation()}function Kn(e){var t=e.document.documentElement,n=ae(e).on("dragstart.drag",De,Ye);"onselectstart"in t?n.on("selectstart.drag",De,Ye):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function Un(e,t){var n=e.document.documentElement,o=ae(e).on("dragstart.drag",null);t&&(o.on("click.drag",De,Ye),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const tt=e=>()=>e;function _t(e,{sourceEvent:t,subject:n,target:o,identifier:s,active:r,x:i,y:a,dx:d,dy:u,dispatch:h}){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:o,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:r,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:h}})}_t.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Mr(e){return!e.ctrlKey&&!e.button}function Cr(){return this.parentNode}function Ir(e,t){return t??{x:e.x,y:e.y}}function kr(){return navigator.maxTouchPoints||"ontouchstart"in this}function Qn(){var e=Mr,t=Cr,n=Ir,o=kr,s={},r=Zn("start","drag","end"),i=0,a,d,u,h,c=0;function l(x){x.on("mousedown.drag",m).filter(o).on("touchstart.drag",y).on("touchmove.drag",g,Nr).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(x,k){if(!(h||!e.call(this,x,k))){var S=f(this,t.call(this,x,k),x,k,"mouse");S&&(ae(x.view).on("mousemove.drag",p,Ye).on("mouseup.drag",b,Ye),Kn(x.view),Nt(x),u=!1,a=x.clientX,d=x.clientY,S("start",x))}}function p(x){if(De(x),!u){var k=x.clientX-a,S=x.clientY-d;u=k*k+S*S>c}s.mouse("drag",x)}function b(x){ae(x.view).on("mousemove.drag mouseup.drag",null),Un(x.view,u),De(x),s.mouse("end",x)}function y(x,k){if(e.call(this,x,k)){var S=x.changedTouches,_=t.call(this,x,k),A=S.length,T,V;for(T=0;T<A;++T)(V=f(this,_,x,k,S[T].identifier,S[T]))&&(Nt(x),V("start",x,S[T]))}}function g(x){var k=x.changedTouches,S=k.length,_,A;for(_=0;_<S;++_)(A=s[k[_].identifier])&&(De(x),A("drag",x,k[_]))}function v(x){var k=x.changedTouches,S=k.length,_,A;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),_=0;_<S;++_)(A=s[k[_].identifier])&&(Nt(x),A("end",x,k[_]))}function f(x,k,S,_,A,T){var V=r.copy(),I=ue(T||S,k),D,B,w;if((w=n.call(x,new _t("beforestart",{sourceEvent:S,target:l,identifier:A,active:i,x:I[0],y:I[1],dx:0,dy:0,dispatch:V}),_))!=null)return D=w.x-I[0]||0,B=w.y-I[1]||0,function $(N,E,P){var M=I,L;switch(N){case"start":s[A]=$,L=i++;break;case"end":delete s[A],--i;case"drag":I=ue(P||E,k),L=i;break}V.call(N,x,new _t(N,{sourceEvent:E,subject:w,target:l,identifier:A,active:L,x:I[0]+D,y:I[1]+B,dx:I[0]-M[0],dy:I[1]-M[1],dispatch:V}),_)}}return l.filter=function(x){return arguments.length?(e=typeof x=="function"?x:tt(!!x),l):e},l.container=function(x){return arguments.length?(t=typeof x=="function"?x:tt(x),l):t},l.subject=function(x){return arguments.length?(n=typeof x=="function"?x:tt(x),l):n},l.touchable=function(x){return arguments.length?(o=typeof x=="function"?x:tt(!!x),l):o},l.on=function(){var x=r.on.apply(r,arguments);return x===r?l:x},l.clickDistance=function(x){return arguments.length?(c=(x=+x)*x,l):Math.sqrt(c)},l}var Pr=1e-12;function sn(e){return((e=Math.exp(e))+1/e)/2}function $r(e){return((e=Math.exp(e))-1/e)/2}function _r(e){return((e=Math.exp(2*e))-1)/(e+1)}const at=(function e(t,n,o){function s(r,i){var a=r[0],d=r[1],u=r[2],h=i[0],c=i[1],l=i[2],m=h-a,p=c-d,b=m*m+p*p,y,g;if(b<Pr)g=Math.log(l/u)/t,y=function(_){return[a+_*m,d+_*p,u*Math.exp(t*_*g)]};else{var v=Math.sqrt(b),f=(l*l-u*u+o*b)/(2*u*n*v),x=(l*l-u*u-o*b)/(2*l*n*v),k=Math.log(Math.sqrt(f*f+1)-f),S=Math.log(Math.sqrt(x*x+1)-x);g=(S-k)/t,y=function(_){var A=_*g,T=sn(k),V=u/(n*v)*(T*_r(t*A+k)-$r(k));return[a+V*m,d+V*p,u*T/sn(t*A+k)]}}return y.duration=g*1e3*t/Math.SQRT2,y}return s.rho=function(r){var i=Math.max(.001,+r),a=i*i,d=a*a;return e(i,a,d)},s})(Math.SQRT2,2,4),nt=e=>()=>e;function Ar(e,{sourceEvent:t,target:n,transform:o,dispatch:s}){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:o,enumerable:!0,configurable:!0},_:{value:s}})}function Mt(e){e.stopImmediatePropagation()}function Fe(e){e.preventDefault(),e.stopImmediatePropagation()}function zr(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Tr(){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 rn(){return this.__zoom||Ht}function Dr(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Lr(){return navigator.maxTouchPoints||"ontouchstart"in this}function jr(e,t,n){var o=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],r=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>o?(o+s)/2:Math.min(0,o)||Math.max(0,s),i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i))}function Jn(){var e=zr,t=Tr,n=jr,o=Dr,s=Lr,r=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,d=at,u=Zn("start","zoom","end"),h,c,l,m=500,p=150,b=0,y=10;function g(w){w.property("__zoom",rn).on("wheel.zoom",A,{passive:!1}).on("mousedown.zoom",T).on("dblclick.zoom",V).filter(s).on("touchstart.zoom",I).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(w,$,N,E){var P=w.selection?w.selection():w;P.property("__zoom",rn),w!==P?k(w,$,N,E):P.interrupt().each(function(){S(this,arguments).event(E).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},g.scaleBy=function(w,$,N,E){g.scaleTo(w,function(){var P=this.__zoom.k,M=typeof $=="function"?$.apply(this,arguments):$;return P*M},N,E)},g.scaleTo=function(w,$,N,E){g.transform(w,function(){var P=t.apply(this,arguments),M=this.__zoom,L=N==null?x(P):typeof N=="function"?N.apply(this,arguments):N,j=M.invert(L),H=typeof $=="function"?$.apply(this,arguments):$;return n(f(v(M,H),L,j),P,i)},N,E)},g.translateBy=function(w,$,N,E){g.transform(w,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof N=="function"?N.apply(this,arguments):N),t.apply(this,arguments),i)},null,E)},g.translateTo=function(w,$,N,E,P){g.transform(w,function(){var M=t.apply(this,arguments),L=this.__zoom,j=E==null?x(M):typeof E=="function"?E.apply(this,arguments):E;return n(Ht.translate(j[0],j[1]).scale(L.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof N=="function"?-N.apply(this,arguments):-N),M,i)},E,P)};function v(w,$){return $=Math.max(r[0],Math.min(r[1],$)),$===w.k?w:new vt($,w.x,w.y)}function f(w,$,N){var E=$[0]-N[0]*w.k,P=$[1]-N[1]*w.k;return E===w.x&&P===w.y?w:new vt(w.k,E,P)}function x(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,$,N,E){w.on("start.zoom",function(){S(this,arguments).event(E).start()}).on("interrupt.zoom end.zoom",function(){S(this,arguments).event(E).end()}).tween("zoom",function(){var P=this,M=arguments,L=S(P,M).event(E),j=t.apply(P,M),H=N==null?x(j):typeof N=="function"?N.apply(P,M):N,O=Math.max(j[1][0]-j[0][0],j[1][1]-j[0][1]),Y=P.__zoom,Z=typeof $=="function"?$.apply(P,M):$,Q=d(Y.invert(H).concat(O/Y.k),Z.invert(H).concat(O/Z.k));return function(q){if(q===1)q=Z;else{var R=Q(q),F=O/R[2];q=new vt(F,H[0]-R[0]*F,H[1]-R[1]*F)}L.zoom(null,q)}})}function S(w,$,N){return!N&&w.__zooming||new _(w,$)}function _(w,$){this.that=w,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(w,$),this.taps=0}_.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,$){return this.mouse&&w!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var $=ae(this.that).datum();u.call(w,this.that,new Ar(w,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),$)}};function A(w,...$){if(!e.apply(this,arguments))return;var N=S(this,$).event(w),E=this.__zoom,P=Math.max(r[0],Math.min(r[1],E.k*Math.pow(2,o.apply(this,arguments)))),M=ue(w);if(N.wheel)(N.mouse[0][0]!==M[0]||N.mouse[0][1]!==M[1])&&(N.mouse[1]=E.invert(N.mouse[0]=M)),clearTimeout(N.wheel);else{if(E.k===P)return;N.mouse=[M,E.invert(M)],Et(this),N.start()}Fe(w),N.wheel=setTimeout(L,p),N.zoom("mouse",n(f(v(E,P),N.mouse[0],N.mouse[1]),N.extent,i));function L(){N.wheel=null,N.end()}}function T(w,...$){if(l||!e.apply(this,arguments))return;var N=w.currentTarget,E=S(this,$,!0).event(w),P=ae(w.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",O,!0),M=ue(w,N),L=w.clientX,j=w.clientY;Kn(w.view),Mt(w),E.mouse=[M,this.__zoom.invert(M)],Et(this),E.start();function H(Y){if(Fe(Y),!E.moved){var Z=Y.clientX-L,Q=Y.clientY-j;E.moved=Z*Z+Q*Q>b}E.event(Y).zoom("mouse",n(f(E.that.__zoom,E.mouse[0]=ue(Y,N),E.mouse[1]),E.extent,i))}function O(Y){P.on("mousemove.zoom mouseup.zoom",null),Un(Y.view,E.moved),Fe(Y),E.event(Y).end()}}function V(w,...$){if(e.apply(this,arguments)){var N=this.__zoom,E=ue(w.changedTouches?w.changedTouches[0]:w,this),P=N.invert(E),M=N.k*(w.shiftKey?.5:2),L=n(f(v(N,M),E,P),t.apply(this,$),i);Fe(w),a>0?ae(this).transition().duration(a).call(k,L,E,w):ae(this).call(g.transform,L,E,w)}}function I(w,...$){if(e.apply(this,arguments)){var N=w.touches,E=N.length,P=S(this,$,w.changedTouches.length===E).event(w),M,L,j,H;for(Mt(w),L=0;L<E;++L)j=N[L],H=ue(j,this),H=[H,this.__zoom.invert(H),j.identifier],P.touch0?!P.touch1&&P.touch0[2]!==H[2]&&(P.touch1=H,P.taps=0):(P.touch0=H,M=!0,P.taps=1+!!h);h&&(h=clearTimeout(h)),M&&(P.taps<2&&(c=H[0],h=setTimeout(function(){h=null},m)),Et(this),P.start())}}function D(w,...$){if(this.__zooming){var N=S(this,$).event(w),E=w.changedTouches,P=E.length,M,L,j,H;for(Fe(w),M=0;M<P;++M)L=E[M],j=ue(L,this),N.touch0&&N.touch0[2]===L.identifier?N.touch0[0]=j:N.touch1&&N.touch1[2]===L.identifier&&(N.touch1[0]=j);if(L=N.that.__zoom,N.touch1){var O=N.touch0[0],Y=N.touch0[1],Z=N.touch1[0],Q=N.touch1[1],q=(q=Z[0]-O[0])*q+(q=Z[1]-O[1])*q,R=(R=Q[0]-Y[0])*R+(R=Q[1]-Y[1])*R;L=v(L,Math.sqrt(q/R)),j=[(O[0]+Z[0])/2,(O[1]+Z[1])/2],H=[(Y[0]+Q[0])/2,(Y[1]+Q[1])/2]}else if(N.touch0)j=N.touch0[0],H=N.touch0[1];else return;N.zoom("touch",n(f(L,j,H),N.extent,i))}}function B(w,...$){if(this.__zooming){var N=S(this,$).event(w),E=w.changedTouches,P=E.length,M,L;for(Mt(w),l&&clearTimeout(l),l=setTimeout(function(){l=null},m),M=0;M<P;++M)L=E[M],N.touch0&&N.touch0[2]===L.identifier?delete N.touch0:N.touch1&&N.touch1[2]===L.identifier&&delete N.touch1;if(N.touch1&&!N.touch0&&(N.touch0=N.touch1,delete N.touch1),N.touch0)N.touch0[1]=this.__zoom.invert(N.touch0[0]);else if(N.end(),N.taps===2&&(L=ue(L,this),Math.hypot(c[0]-L[0],c[1]-L[1])<y)){var j=ae(this).on("dblclick.zoom");j&&j.apply(this,arguments)}}}return g.wheelDelta=function(w){return arguments.length?(o=typeof w=="function"?w:nt(+w),g):o},g.filter=function(w){return arguments.length?(e=typeof w=="function"?w:nt(!!w),g):e},g.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:nt(!!w),g):s},g.extent=function(w){return arguments.length?(t=typeof w=="function"?w:nt([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),g):t},g.scaleExtent=function(w){return arguments.length?(r[0]=+w[0],r[1]=+w[1],g):[r[0],r[1]]},g.translateExtent=function(w){return arguments.length?(i[0][0]=+w[0][0],i[1][0]=+w[1][0],i[0][1]=+w[0][1],i[1][1]=+w[1][1],g):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},g.constrain=function(w){return arguments.length?(n=w,g):n},g.duration=function(w){return arguments.length?(a=+w,g):a},g.interpolate=function(w){return arguments.length?(d=w,g):d},g.on=function(){var w=u.on.apply(u,arguments);return w===u?g:w},g.clickDistance=function(w){return arguments.length?(b=(w=+w)*w,g):Math.sqrt(b)},g.tapDistance=function(w){return arguments.length?(y=+w,g):y},g}function ie(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,o;n<e.length;n++)(o=ie(e[n]))!==""&&(t+=(t&&" ")+o);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const he={error001:(e="react")=>`Seems like you have not used ${e==="svelte"?"SvelteFlowProvider":"ReactFlowProvider"} as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:o})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:o}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Xe=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],eo=["Enter"," ","Escape"],to={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var Le;(function(e){e.Strict="strict",e.Loose="loose"})(Le||(Le={}));var ke;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ke||(ke={}));var We;(function(e){e.Partial="partial",e.Full="full"})(We||(We={}));const no={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ee;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ee||(Ee={}));var ct;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ct||(ct={}));var W;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(W||(W={}));const an={[W.Left]:W.Right,[W.Right]:W.Left,[W.Top]:W.Bottom,[W.Bottom]:W.Top};function oo(e){return e===null?null:e?"valid":"invalid"}const so=e=>"id"in e&&"source"in e&&"target"in e,Hr=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Rt=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Ke=(e,t=[0,0])=>{const{width:n,height:o}=we(e),s=e.origin??t,r=n*s[0],i=o*s[1];return{x:e.position.x-r,y:e.position.y-i}},Rr=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((o,s)=>{const r=typeof s=="string";let i=!t.nodeLookup&&!r?s:void 0;t.nodeLookup&&(i=r?t.nodeLookup.get(s):Rt(s)?s:t.nodeLookup.get(s.id));const a=i?lt(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return ft(o,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ht(n)},Ue=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},o=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=ft(n,lt(s)),o=!0)}),o?ht(n):{x:0,y:0,width:0,height:0}},Bt=(e,t,[n,o,s]=[0,0,1],r=!1,i=!1)=>{const a=(t.x-n)/s,d=(t.y-o)/s,u=t.width/s,h=t.height/s,c=[];for(const l of e.values()){const{measured:m,selectable:p=!0,hidden:b=!1}=l;if(i&&!p||b)continue;const y=m.width??l.width??l.initialWidth??0,g=m.height??l.height??l.initialHeight??0,{x:v,y:f}=l.internals.positionAbsolute,x=co(a,d,u,h,v,f,y,g),k=y*g,S=r&&x>0;(!l.internals.handleBounds||S||x>=k||l.dragging)&&c.push(l)}return c},Br=(e,t)=>{const n=new Set;return e.forEach(o=>{n.add(o.id)}),t.filter(o=>n.has(o.source)||n.has(o.target))};function Vr(e,t){const n=new Map,o=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!o||o.has(s.id))&&n.set(s.id,s)}),n}async function Fr({nodes:e,width:t,height:n,panZoom:o,minZoom:s,maxZoom:r},i){if(e.size===0)return!0;const a=Vr(e,i),d=Ue(a),u=Ft(d,t,n,(i==null?void 0:i.minZoom)??s,(i==null?void 0:i.maxZoom)??r,(i==null?void 0:i.padding)??.1);return await o.setViewport(u,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0}function ro({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:o=[0,0],nodeExtent:s,onError:r}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:d,y:u}=a?a.internals.positionAbsolute:{x:0,y:0},h=i.origin??o;let c=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!a)r==null||r("005",he.error005());else{const m=a.measured.width,p=a.measured.height;m&&p&&(c=[[d,u],[d+m,u+p]])}else a&&$e(i.extent)&&(c=[[i.extent[0][0]+d,i.extent[0][1]+u],[i.extent[1][0]+d,i.extent[1][1]+u]]);const l=$e(c)?Pe(t,c,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(r==null||r("015",he.error015())),{position:{x:l.x-d+(i.measured.width??0)*h[0],y:l.y-u+(i.measured.height??0)*h[1]},positionAbsolute:l}}async function Or({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:o,onBeforeDelete:s}){const r=new Set(e.map(l=>l.id)),i=[];for(const l of n){if(l.deletable===!1)continue;const m=r.has(l.id),p=!m&&l.parentId&&i.find(b=>b.id===l.parentId);(m||p)&&i.push(l)}const a=new Set(t.map(l=>l.id)),d=o.filter(l=>l.deletable!==!1),h=Br(i,d);for(const l of d)a.has(l.id)&&!h.find(p=>p.id===l.id)&&h.push(l);if(!s)return{edges:h,nodes:i};const c=await s({nodes:i,edges:h});return typeof c=="boolean"?c?{edges:h,nodes:i}:{edges:[],nodes:[]}:c}const je=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Pe=(e={x:0,y:0},t,n)=>({x:je(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:je(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function io(e,t,n){const{width:o,height:s}=we(n),{x:r,y:i}=n.internals.positionAbsolute;return Pe(e,[[r,i],[r+o,i+s]],t)}const cn=(e,t,n)=>e<t?je(Math.abs(e-t),1,t)/t:e>n?-je(Math.abs(e-n),1,t)/t:0,Vt=(e,t,n=15,o=40)=>{const s=cn(e.x,o,t.width-o)*n,r=cn(e.y,o,t.height-o)*n;return[s,r]},ft=(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)}),At=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),ht=({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}),Ge=(e,t=[0,0])=>{var s,r;const{x:n,y:o}=Rt(e)?e.internals.positionAbsolute:Ke(e,t);return{x:n,y:o,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0}},lt=(e,t=[0,0])=>{var s,r;const{x:n,y:o}=Rt(e)?e.internals.positionAbsolute:Ke(e,t);return{x:n,y:o,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:o+(((r=e.measured)==null?void 0:r.height)??e.height??e.initialHeight??0)}},ao=(e,t)=>ht(ft(At(e),At(t))),co=(e,t,n,o,s,r,i,a)=>{const d=Math.max(0,Math.min(e+n,s+i)-Math.max(e,s)),u=Math.max(0,Math.min(t+o,r+a)-Math.max(t,r));return Math.ceil(d*u)},ut=(e,t)=>co(e.x,e.y,e.width,e.height,t.x,t.y,t.width,t.height),ln=e=>de(e.width)&&de(e.height)&&de(e.x)&&de(e.y),de=e=>!isNaN(e)&&isFinite(e),lo=(e,t)=>(n,o)=>{},Qe=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Je=({x:e,y:t},[n,o,s],r=!1,i=[1,1])=>{const a={x:(e-n)/s,y:(t-o)/s};return r?Qe(a,i):a},He=({x:e,y:t},[n,o,s])=>({x:e*s+n,y:t*s+o});function Ae(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Yr(e,t,n){if(typeof e=="string"||typeof e=="number"){const o=Ae(e,n),s=Ae(e,t);return{top:o,right:s,bottom:o,left:s,x:s*2,y:o*2}}if(typeof e=="object"){const o=Ae(e.top??e.y??0,n),s=Ae(e.bottom??e.y??0,n),r=Ae(e.left??e.x??0,t),i=Ae(e.right??e.x??0,t);return{top:o,right:i,bottom:s,left:r,x:r+i,y:o+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Xr(e,t,n,o,s,r){const{x:i,y:a}=He(e,[t,n,o]),{x:d,y:u}=He({x:e.x+e.width,y:e.y+e.height},[t,n,o]),h=s-d,c=r-u;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(h),bottom:Math.floor(c)}}const Ft=(e,t,n,o,s,r)=>{const i=Yr(r,t,n),a=(t-i.x)/e.width,d=(n-i.y)/e.height,u=Math.min(a,d),h=je(u,o,s),c=e.x+e.width/2,l=e.y+e.height/2,m=t/2-c*h,p=n/2-l*h,b=Xr(e,m,p,h,t,n),y={left:Math.min(b.left-i.left,0),top:Math.min(b.top-i.top,0),right:Math.min(b.right-i.right,0),bottom:Math.min(b.bottom-i.bottom,0)};return{x:m-y.left+y.right,y:p-y.top+y.bottom,zoom:h}},qe=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function $e(e){return e!=null&&e!=="parent"}function we(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function uo(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function fo(e,t={width:0,height:0},n,o,s){const r={...e},i=o.get(n);if(i){const a=i.origin||s;r.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],r.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return r}function un(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function Wr(){let e,t;return{promise:new Promise((o,s)=>{e=o,t=s}),resolve:e,reject:t}}function Gr(e){return{...to,...e||{}}}function Oe(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:o,containerBounds:s}){const{x:r,y:i}=fe(e),a=Je({x:r-((s==null?void 0:s.left)??0),y:i-((s==null?void 0:s.top)??0)},o),{x:d,y:u}=n?Qe(a,t):a;return{xSnapped:d,ySnapped:u,...a}}const Ot=e=>({width:e.offsetWidth,height:e.offsetHeight}),ho=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},qr=["INPUT","SELECT","TEXTAREA"];function go(e){var o,s;const t=((s=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:qr.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const po=e=>"clientX"in e,fe=(e,t)=>{var r,i;const n=po(e),o=n?e.clientX:(r=e.touches)==null?void 0:r[0].clientX,s=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:o-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},dn=(e,t,n,o,s)=>{const r=t.querySelectorAll(`.${e}`);return!r||!r.length?null:Array.from(r).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/o,y:(a.top-n.top)/o,...Ot(i)}})};function mo({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:r,targetControlX:i,targetControlY:a}){const d=e*.125+s*.375+i*.375+n*.125,u=t*.125+r*.375+a*.375+o*.125,h=Math.abs(d-e),c=Math.abs(u-t);return[d,u,h,c]}function ot(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fn({pos:e,x1:t,y1:n,x2:o,y2:s,c:r}){switch(e){case W.Left:return[t-ot(t-o,r),n];case W.Right:return[t+ot(o-t,r),n];case W.Top:return[t,n-ot(n-s,r)];case W.Bottom:return[t,n+ot(s-n,r)]}}function yo({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:s,targetPosition:r=W.Top,curvature:i=.25}){const[a,d]=fn({pos:n,x1:e,y1:t,x2:o,y2:s,c:i}),[u,h]=fn({pos:r,x1:o,y1:s,x2:e,y2:t,c:i}),[c,l,m,p]=mo({sourceX:e,sourceY:t,targetX:o,targetY:s,sourceControlX:a,sourceControlY:d,targetControlX:u,targetControlY:h});return[`M${e},${t} C${a},${d} ${u},${h} ${o},${s}`,c,l,m,p]}function xo({sourceX:e,sourceY:t,targetX:n,targetY:o}){const s=Math.abs(n-e)/2,r=n<e?n+s:n-s,i=Math.abs(o-t)/2,a=o<t?o+i:o-i;return[r,a,s,i]}function Zr({sourceNode:e,targetNode:t,selected:n=!1,zIndex:o=0,elevateOnSelect:s=!1,zIndexMode:r="basic"}){if(r==="manual")return o;const i=s&&n?o+1e3:o,a=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+a}function Kr({sourceNode:e,targetNode:t,width:n,height:o,transform:s}){const r=ft(lt(e),lt(t));r.x===r.x2&&(r.x2+=1),r.y===r.y2&&(r.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:o/s[2]};return ut(i,ht(r))>0}const Ur=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`xy-edge__${e}${t||""}-${n}${o||""}`,Qr=(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)),Jr=(e,t,n={})=>{var r;if(!e.source||!e.target)return(r=n.onError)==null||r.call(n,"006",he.error006()),t;const o=n.getEdgeId||Ur;let s;return so(e)?s={...e}:s={...e,id:o(e)},Qr(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function wo({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[s,r,i,a]=xo({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,s,r,i,a]}const hn={[W.Left]:{x:-1,y:0},[W.Right]:{x:1,y:0},[W.Top]:{x:0,y:-1},[W.Bottom]:{x:0,y:1}},ei=({source:e,sourcePosition:t=W.Bottom,target:n})=>t===W.Left||t===W.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},gn=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function ti({source:e,sourcePosition:t=W.Bottom,target:n,targetPosition:o=W.Top,center:s,offset:r,stepPosition:i}){const a=hn[t],d=hn[o],u={x:e.x+a.x*r,y:e.y+a.y*r},h={x:n.x+d.x*r,y:n.y+d.y*r},c=ei({source:u,sourcePosition:t,target:h}),l=c.x!==0?"x":"y",m=c[l];let p=[],b,y;const g={x:0,y:0},v={x:0,y:0},[,,f,x]=xo({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[l]*d[l]===-1){l==="x"?(b=s.x??u.x+(h.x-u.x)*i,y=s.y??(u.y+h.y)/2):(b=s.x??(u.x+h.x)/2,y=s.y??u.y+(h.y-u.y)*i);const A=[{x:b,y:u.y},{x:b,y:h.y}],T=[{x:u.x,y},{x:h.x,y}];a[l]===m?p=l==="x"?A:T:p=l==="x"?T:A}else{const A=[{x:u.x,y:h.y}],T=[{x:h.x,y:u.y}];if(l==="x"?p=a.x===m?T:A:p=a.y===m?A:T,t===o){const w=Math.abs(e[l]-n[l]);if(w<=r){const $=Math.min(r-1,r-w);a[l]===m?g[l]=(u[l]>e[l]?-1:1)*$:v[l]=(h[l]>n[l]?-1:1)*$}}if(t!==o){const w=l==="x"?"y":"x",$=a[l]===d[w],N=u[w]>h[w],E=u[w]<h[w];(a[l]===1&&(!$&&N||$&&E)||a[l]!==1&&(!$&&E||$&&N))&&(p=l==="x"?A:T)}const V={x:u.x+g.x,y:u.y+g.y},I={x:h.x+v.x,y:h.y+v.y},D=Math.max(Math.abs(V.x-p[0].x),Math.abs(I.x-p[0].x)),B=Math.max(Math.abs(V.y-p[0].y),Math.abs(I.y-p[0].y));D>=B?(b=(V.x+I.x)/2,y=p[0].y):(b=p[0].x,y=(V.y+I.y)/2)}const k={x:u.x+g.x,y:u.y+g.y},S={x:h.x+v.x,y:h.y+v.y};return[[e,...k.x!==p[0].x||k.y!==p[0].y?[k]:[],...p,...S.x!==p[p.length-1].x||S.y!==p[p.length-1].y?[S]:[],n],b,y,f,x]}function ni(e,t,n,o){const s=Math.min(gn(e,t)/2,gn(t,n)/2,o),{x:r,y:i}=t;if(e.x===r&&r===n.x||e.y===i&&i===n.y)return`L${r} ${i}`;if(e.y===i){const u=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${r+s*u},${i}Q ${r},${i} ${r},${i+s*h}`}const a=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${r},${i+s*d}Q ${r},${i} ${r+s*a},${i}`}function zt({sourceX:e,sourceY:t,sourcePosition:n=W.Bottom,targetX:o,targetY:s,targetPosition:r=W.Top,borderRadius:i=5,centerX:a,centerY:d,offset:u=20,stepPosition:h=.5}){const[c,l,m,p,b]=ti({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:s},targetPosition:r,center:{x:a,y:d},offset:u,stepPosition:h});let y=`M${c[0].x} ${c[0].y}`;for(let g=1;g<c.length-1;g++)y+=ni(c[g-1],c[g],c[g+1],i);return y+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[y,l,m,p,b]}function pn(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function oi(e){var c;const{sourceNode:t,targetNode:n}=e;if(!pn(t)||!pn(n))return null;const o=t.internals.handleBounds||mn(t.handles),s=n.internals.handleBounds||mn(n.handles),r=yn((o==null?void 0:o.source)??[],e.sourceHandle),i=yn(e.connectionMode===Le.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!r||!i)return(c=e.onError)==null||c.call(e,"008",he.error008(r?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(r==null?void 0:r.position)||W.Bottom,d=(i==null?void 0:i.position)||W.Top,u=_e(t,r,a),h=_e(n,i,d);return{sourceX:u.x,sourceY:u.y,targetX:h.x,targetY:h.y,sourcePosition:a,targetPosition:d}}function mn(e){if(!e)return null;const t=[],n=[];for(const o of e)o.width=o.width??1,o.height=o.height??1,o.type==="source"?t.push(o):o.type==="target"&&n.push(o);return{source:t,target:n}}function _e(e,t,n=W.Left,o=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,r=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??we(e);if(o)return{x:s+i/2,y:r+a/2};switch((t==null?void 0:t.position)??n){case W.Top:return{x:s+i/2,y:r};case W.Right:return{x:s+i,y:r+a/2};case W.Bottom:return{x:s+i/2,y:r+a};case W.Left:return{x:s,y:r+a/2}}}function yn(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Tt(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(o=>`${o}=${e[o]}`).join("&")}`:""}function si(e,{id:t,defaultColor:n,defaultMarkerStart:o,defaultMarkerEnd:s}){const r=new Set;return e.reduce((i,a)=>([a.markerStart||o,a.markerEnd||s].forEach(d=>{if(d&&typeof d=="object"){const u=Tt(d,t);r.has(u)||(i.push({id:u,color:d.color||n,...d}),r.add(u))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const bo=1e3,ri=10,Yt={nodeOrigin:[0,0],nodeExtent:Xe,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},ii={...Yt,checkEquality:!0};function Xt(e,t){const n={...e};for(const o in t)t[o]!==void 0&&(n[o]=t[o]);return n}function ai(e,t,n){const o=Xt(Yt,n);for(const s of e.values())if(s.parentId)Gt(s,e,t,o);else{const r=Ke(s,o.nodeOrigin),i=$e(s.extent)?s.extent:o.nodeExtent,a=Pe(r,i,we(s));s.internals.positionAbsolute=a}}function ci(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],o=[];for(const s of e.handles){const r={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(r):s.type==="target"&&o.push(r)}return{source:n,target:o}}function Wt(e){return e==="manual"}function Dt(e,t,n,o={}){var h,c;const s=Xt(ii,o),r={i:0},i=new Map(t),a=s!=null&&s.elevateNodesOnSelect&&!Wt(s.zIndexMode)?bo:0;let d=e.length>0,u=!1;t.clear(),n.clear();for(const l of e){let m=i.get(l.id);if(s.checkEquality&&l===(m==null?void 0:m.internals.userNode))t.set(l.id,m);else{const p=Ke(l,s.nodeOrigin),b=$e(l.extent)?l.extent:s.nodeExtent,y=Pe(p,b,we(l));m={...s.defaults,...l,measured:{width:(h=l.measured)==null?void 0:h.width,height:(c=l.measured)==null?void 0:c.height},internals:{positionAbsolute:y,handleBounds:ci(l,m),z:vo(l,a,s.zIndexMode),userNode:l}},t.set(l.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(d=!1),l.parentId&&Gt(m,t,n,o,r),u||(u=l.selected??!1)}return{nodesInitialized:d,hasSelectedNodes:u}}function li(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Gt(e,t,n,o,s){const{elevateNodesOnSelect:r,nodeOrigin:i,nodeExtent:a,zIndexMode:d}=Xt(Yt,o),u=e.parentId,h=t.get(u);if(!h){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}li(e,n),s&&!h.parentId&&h.internals.rootParentIndex===void 0&&d==="auto"&&(h.internals.rootParentIndex=++s.i,h.internals.z=h.internals.z+s.i*ri),s&&h.internals.rootParentIndex!==void 0&&(s.i=h.internals.rootParentIndex);const c=r&&!Wt(d)?bo:0,{x:l,y:m,z:p}=ui(e,h,i,a,c,d),{positionAbsolute:b}=e.internals,y=l!==b.x||m!==b.y;(y||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:y?{x:l,y:m}:b,z:p}})}function vo(e,t,n){const o=de(e.zIndex)?e.zIndex:0;return Wt(n)?o:o+(e.selected?t:0)}function ui(e,t,n,o,s,r){const{x:i,y:a}=t.internals.positionAbsolute,d=we(e),u=Ke(e,n),h=$e(e.extent)?Pe(u,e.extent,d):u;let c=Pe({x:i+h.x,y:a+h.y},o,d);e.extent==="parent"&&(c=io(c,d,t));const l=vo(e,s,r),m=t.internals.z??0;return{x:c.x,y:c.y,z:m>=l?m+1:l}}function qt(e,t,n,o=[0,0]){var i;const s=[],r=new Map;for(const a of e){const d=t.get(a.parentId);if(!d)continue;const u=((i=r.get(a.parentId))==null?void 0:i.expandedRect)??Ge(d),h=ao(u,a.rect);r.set(a.parentId,{expandedRect:h,parent:d})}return r.size>0&&r.forEach(({expandedRect:a,parent:d},u)=>{var f;const h=d.internals.positionAbsolute,c=we(d),l=d.origin??o,m=a.x<h.x?Math.round(Math.abs(h.x-a.x)):0,p=a.y<h.y?Math.round(Math.abs(h.y-a.y)):0,b=Math.max(c.width,Math.round(a.width)),y=Math.max(c.height,Math.round(a.height)),g=(b-c.width)*l[0],v=(y-c.height)*l[1];(m>0||p>0||g||v)&&(s.push({id:u,type:"position",position:{x:d.position.x-m+g,y:d.position.y-p+v}}),(f=n.get(u))==null||f.forEach(x=>{e.some(k=>k.id===x.id)||s.push({id:x.id,type:"position",position:{x:x.position.x+m,y:x.position.y+p}})})),(c.width<a.width||c.height<a.height||m||p)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:b+(m?l[0]*m-g:0),height:y+(p?l[1]*p-v:0)}})}),s}function di(e,t,n,o,s,r,i){const a=o==null?void 0:o.querySelector(".xyflow__viewport");let d=!1;if(!a)return{changes:[],updatedInternals:d};const u=[],h=window.getComputedStyle(a),{m22:c}=new window.DOMMatrixReadOnly(h.transform),l=[];for(const m of e.values()){const p=t.get(m.id);if(!p)continue;if(p.hidden){t.set(p.id,{...p,internals:{...p.internals,handleBounds:void 0}}),d=!0;continue}const b=Ot(m.nodeElement),y=p.measured.width!==b.width||p.measured.height!==b.height;if(!!(b.width&&b.height&&(y||!p.internals.handleBounds||m.force))){const v=m.nodeElement.getBoundingClientRect(),f=$e(p.extent)?p.extent:r;let{positionAbsolute:x}=p.internals;p.parentId&&p.extent==="parent"?x=io(x,b,t.get(p.parentId)):f&&(x=Pe(x,f,b));const k={...p,measured:b,internals:{...p.internals,positionAbsolute:x,handleBounds:{source:dn("source",m.nodeElement,v,c,p.id),target:dn("target",m.nodeElement,v,c,p.id)}}};t.set(p.id,k),p.parentId&&Gt(k,t,n,{nodeOrigin:s,zIndexMode:i}),d=!0,y&&(u.push({id:p.id,type:"dimensions",dimensions:b}),p.expandParent&&p.parentId&&l.push({id:p.id,parentId:p.parentId,rect:Ge(k,s)}))}}if(l.length>0){const m=qt(l,t,n,s);u.push(...m)}return{changes:u,updatedInternals:d}}async function fi({delta:e,panZoom:t,transform:n,translateExtent:o,width:s,height:r}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,r]],o);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function xn(e,t,n,o,s,r){let i=s;const a=o.get(i)||new Map;o.set(i,a.set(n,t)),i=`${s}-${e}`;const d=o.get(i)||new Map;if(o.set(i,d.set(n,t)),r){i=`${s}-${e}-${r}`;const u=o.get(i)||new Map;o.set(i,u.set(n,t))}}function Eo(e,t,n){e.clear(),t.clear();for(const o of n){const{source:s,target:r,sourceHandle:i=null,targetHandle:a=null}=o,d={edgeId:o.id,source:s,target:r,sourceHandle:i,targetHandle:a},u=`${s}-${i}--${r}-${a}`,h=`${r}-${a}--${s}-${i}`;xn("source",d,h,e,s,i),xn("target",d,u,e,r,a),t.set(o.id,o)}}function So(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:So(n,t):!1}function wn(e,t,n){var s;let o=e;do{if((s=o==null?void 0:o.matches)!=null&&s.call(o,t))return!0;if(o===n)return!1;o=o==null?void 0:o.parentElement}while(o);return!1}function hi(e,t,n,o){const s=new Map;for(const[r,i]of e)if((i.selected||i.id===o)&&(!i.parentId||!So(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(r);a&&s.set(r,{id:r,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return s}function Ct({nodeId:e,dragItems:t,nodeLookup:n,dragging:o=!0}){var i,a,d;const s=[];for(const[u,h]of t){const c=(i=n.get(u))==null?void 0:i.internals.userNode;c&&s.push({...c,position:h.position,dragging:o})}if(!e)return[s[0],s];const r=(a=n.get(e))==null?void 0:a.internals.userNode;return[r?{...r,position:((d=t.get(e))==null?void 0:d.position)||r.position,dragging:o}:s[0],s]}function gi({dragItems:e,snapGrid:t,x:n,y:o}){const s=e.values().next().value;if(!s)return null;const r={x:n-s.distance.x,y:o-s.distance.y},i=Qe(r,t);return{x:i.x-r.x,y:i.y-r.y}}function pi({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:o,onDragStop:s}){let r={x:null,y:null},i=0,a=new Map,d=!1,u={x:0,y:0},h=null,c=!1,l=null,m=!1,p=!1,b=null;function y({noDragClassName:v,handleSelector:f,domNode:x,isSelectable:k,nodeId:S,nodeClickDistance:_=0}){l=ae(x);function A({x:D,y:B}){const{nodeLookup:w,nodeExtent:$,snapGrid:N,snapToGrid:E,nodeOrigin:P,onNodeDrag:M,onSelectionDrag:L,onError:j,updateNodePositions:H}=t();r={x:D,y:B};let O=!1;const Y=a.size>1,Z=Y&&$?At(Ue(a)):null,Q=Y&&E?gi({dragItems:a,snapGrid:N,x:D,y:B}):null;for(const[q,R]of a){if(!w.has(q))continue;let F={x:D-R.distance.x,y:B-R.distance.y};E&&(F=Q?{x:Math.round(F.x+Q.x),y:Math.round(F.y+Q.y)}:Qe(F,N));let U=null;if(Y&&$&&!R.extent&&Z){const{positionAbsolute:X}=R.internals,J=X.x-Z.x+$[0][0],te=X.x+R.measured.width-Z.x2+$[1][0],ne=X.y-Z.y+$[0][1],re=X.y+R.measured.height-Z.y2+$[1][1];U=[[J,ne],[te,re]]}const{position:K,positionAbsolute:G}=ro({nodeId:q,nextPosition:F,nodeLookup:w,nodeExtent:U||$,nodeOrigin:P,onError:j});O=O||R.position.x!==K.x||R.position.y!==K.y,R.position=K,R.internals.positionAbsolute=G}if(p=p||O,!!O&&(H(a,!0),b&&(o||M||!S&&L))){const[q,R]=Ct({nodeId:S,dragItems:a,nodeLookup:w});o==null||o(b,a,q,R),M==null||M(b,q,R),S||L==null||L(b,R)}}async function T(){if(!h)return;const{transform:D,panBy:B,autoPanSpeed:w,autoPanOnNodeDrag:$}=t();if(!$){d=!1,cancelAnimationFrame(i);return}const[N,E]=Vt(u,h,w);(N!==0||E!==0)&&(r.x=(r.x??0)-N/D[2],r.y=(r.y??0)-E/D[2],await B({x:N,y:E})&&A(r)),i=requestAnimationFrame(T)}function V(D){var Y;const{nodeLookup:B,multiSelectionActive:w,nodesDraggable:$,transform:N,snapGrid:E,snapToGrid:P,selectNodesOnDrag:M,onNodeDragStart:L,onSelectionDragStart:j,unselectNodesAndEdges:H}=t();c=!0,(!M||!k)&&!w&&S&&((Y=B.get(S))!=null&&Y.selected||H()),k&&M&&S&&(e==null||e(S));const O=Oe(D.sourceEvent,{transform:N,snapGrid:E,snapToGrid:P,containerBounds:h});if(r=O,a=hi(B,$,O,S),a.size>0&&(n||L||!S&&j)){const[Z,Q]=Ct({nodeId:S,dragItems:a,nodeLookup:B});n==null||n(D.sourceEvent,a,Z,Q),L==null||L(D.sourceEvent,Z,Q),S||j==null||j(D.sourceEvent,Q)}}const I=Qn().clickDistance(_).on("start",D=>{const{domNode:B,nodeDragThreshold:w,transform:$,snapGrid:N,snapToGrid:E}=t();h=(B==null?void 0:B.getBoundingClientRect())||null,m=!1,p=!1,b=D.sourceEvent,w===0&&V(D),r=Oe(D.sourceEvent,{transform:$,snapGrid:N,snapToGrid:E,containerBounds:h}),u=fe(D.sourceEvent,h)}).on("drag",D=>{const{autoPanOnNodeDrag:B,transform:w,snapGrid:$,snapToGrid:N,nodeDragThreshold:E,nodeLookup:P}=t(),M=Oe(D.sourceEvent,{transform:w,snapGrid:$,snapToGrid:N,containerBounds:h});if(b=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||S&&!P.has(S))&&(m=!0),!m){if(!d&&B&&c&&(d=!0,T()),!c){const L=fe(D.sourceEvent,h),j=L.x-u.x,H=L.y-u.y;Math.sqrt(j*j+H*H)>E&&V(D)}(r.x!==M.xSnapped||r.y!==M.ySnapped)&&a&&c&&(u=fe(D.sourceEvent,h),A(M))}}).on("end",D=>{if(!c||m){m&&a.size>0&&t().updateNodePositions(a,!1);return}if(d=!1,c=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:B,updateNodePositions:w,onNodeDragStop:$,onSelectionDragStop:N}=t();if(p&&(w(a,!1),p=!1),s||$||!S&&N){const[E,P]=Ct({nodeId:S,dragItems:a,nodeLookup:B,dragging:!1});s==null||s(D.sourceEvent,a,E,P),$==null||$(D.sourceEvent,E,P),S||N==null||N(D.sourceEvent,P)}}}).filter(D=>{const B=D.target;return!D.button&&(!v||!wn(B,`.${v}`,x))&&(!f||wn(B,f,x))});l.call(I)}function g(){l==null||l.on(".drag",null)}return{update:y,destroy:g}}function mi(e,t,n){const o=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const r of t.values())ut(s,Ge(r))>0&&o.push(r);return o}const yi=250;function xi(e,t,n,o){var a,d;let s=[],r=1/0;const i=mi(e,n,t+yi);for(const u of i){const h=[...((a=u.internals.handleBounds)==null?void 0:a.source)??[],...((d=u.internals.handleBounds)==null?void 0:d.target)??[]];for(const c of h){if(o.nodeId===c.nodeId&&o.type===c.type&&o.id===c.id)continue;const{x:l,y:m}=_e(u,c,c.position,!0),p=Math.sqrt(Math.pow(l-e.x,2)+Math.pow(m-e.y,2));p>t||(p<r?(s=[{...c,x:l,y:m}],r=p):p===r&&s.push({...c,x:l,y:m}))}}if(!s.length)return null;if(s.length>1){const u=o.type==="source"?"target":"source";return s.find(h=>h.type===u)??s[0]}return s[0]}function No(e,t,n,o,s,r=!1){var u,h,c;const i=o.get(e);if(!i)return null;const a=s==="strict"?(u=i.internals.handleBounds)==null?void 0:u[t]:[...((h=i.internals.handleBounds)==null?void 0:h.source)??[],...((c=i.internals.handleBounds)==null?void 0:c.target)??[]],d=(n?a==null?void 0:a.find(l=>l.id===n):a==null?void 0:a[0])??null;return d&&r?{...d,..._e(i,d,d.position,!0)}:d}function Mo(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function wi(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const Co=()=>!0;function bi(e,{connectionMode:t,connectionRadius:n,handleId:o,nodeId:s,edgeUpdaterType:r,isTarget:i,domNode:a,nodeLookup:d,lib:u,autoPanOnConnect:h,flowId:c,panBy:l,cancelConnection:m,onConnectStart:p,onConnect:b,onConnectEnd:y,isValidConnection:g=Co,onReconnectEnd:v,updateConnection:f,getTransform:x,getFromHandle:k,autoPanSpeed:S,dragThreshold:_=1,handleDomNode:A}){const T=ho(e.target);let V=0,I;const{x:D,y:B}=fe(e),w=Mo(r,A),$=a==null?void 0:a.getBoundingClientRect();let N=!1;if(!$||!w)return;const E=No(s,w,o,d,t);if(!E)return;let P=fe(e,$),M=!1,L=null,j=!1,H=null;function O(){if(!h||!$)return;const[K,G]=Vt(P,$,S);l({x:K,y:G}),V=requestAnimationFrame(O)}const Y={...E,nodeId:s,type:w,position:E.position},Z=d.get(s);let q={inProgress:!0,isValid:null,from:_e(Z,Y,W.Left,!0),fromHandle:Y,fromPosition:Y.position,fromNode:Z,to:P,toHandle:null,toPosition:an[Y.position],toNode:null,pointer:P};function R(){N=!0,f(q),p==null||p(e,{nodeId:s,handleId:o,handleType:w})}_===0&&R();function F(K){if(!N){const{x:re,y:ce}=fe(K),ge=re-D,pe=ce-B;if(!(ge*ge+pe*pe>_*_))return;R()}if(!k()||!Y){U(K);return}const G=x();P=fe(K,$),I=xi(Je(P,G,!1,[1,1]),n,d,Y),M||(O(),M=!0);const X=Io(K,{handle:I,connectionMode:t,fromNodeId:s,fromHandleId:o,fromType:i?"target":"source",isValidConnection:g,doc:T,lib:u,flowId:c,nodeLookup:d});H=X.handleDomNode,L=X.connection,j=wi(!!I,X.isValid);const J=d.get(s),te=J?_e(J,Y,W.Left,!0):q.from,ne={...q,from:te,isValid:j,to:X.toHandle&&j?He({x:X.toHandle.x,y:X.toHandle.y},G):P,toHandle:X.toHandle,toPosition:j&&X.toHandle?X.toHandle.position:an[Y.position],toNode:X.toHandle?d.get(X.toHandle.nodeId):null,pointer:P};f(ne),q=ne}function U(K){if(!("touches"in K&&K.touches.length>0)){if(N){(I||H)&&L&&j&&(b==null||b(L));const{inProgress:G,...X}=q,J={...X,toPosition:q.toHandle?q.toPosition:null};y==null||y(K,J),r&&(v==null||v(K,J))}m(),cancelAnimationFrame(V),M=!1,j=!1,L=null,H=null,T.removeEventListener("mousemove",F),T.removeEventListener("mouseup",U),T.removeEventListener("touchmove",F),T.removeEventListener("touchend",U)}}T.addEventListener("mousemove",F),T.addEventListener("mouseup",U),T.addEventListener("touchmove",F),T.addEventListener("touchend",U)}function Io(e,{handle:t,connectionMode:n,fromNodeId:o,fromHandleId:s,fromType:r,doc:i,lib:a,flowId:d,isValidConnection:u=Co,nodeLookup:h}){const c=r==="target",l=t?i.querySelector(`.${a}-flow__handle[data-id="${d}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:p}=fe(e),b=i.elementFromPoint(m,p),y=b!=null&&b.classList.contains(`${a}-flow__handle`)?b:l,g={handleDomNode:y,isValid:!1,connection:null,toHandle:null};if(y){const v=Mo(void 0,y),f=y.getAttribute("data-nodeid"),x=y.getAttribute("data-handleid"),k=y.classList.contains("connectable"),S=y.classList.contains("connectableend");if(!f||!v)return g;const _={source:c?f:o,sourceHandle:c?x:s,target:c?o:f,targetHandle:c?s:x};g.connection=_;const T=k&&S&&(n===Le.Strict?c&&v==="source"||!c&&v==="target":f!==o||x!==s);g.isValid=T&&u(_),g.toHandle=No(f,v,x,h,n,!0)}return g}const Lt={onPointerDown:bi,isValid:Io};function vi({domNode:e,panZoom:t,getTransform:n,getViewScale:o}){const s=ae(e);function r({translateExtent:a,width:d,height:u,zoomStep:h=1,pannable:c=!0,zoomable:l=!0,inversePan:m=!1}){const p=f=>{if(f.sourceEvent.type!=="wheel"||!t)return;const x=n(),k=f.sourceEvent.ctrlKey&&qe()?10:1,S=-f.sourceEvent.deltaY*(f.sourceEvent.deltaMode===1?.05:f.sourceEvent.deltaMode?1:.002)*h,_=x[2]*Math.pow(2,S*k);t.scaleTo(_)};let b=[0,0];const y=f=>{(f.sourceEvent.type==="mousedown"||f.sourceEvent.type==="touchstart")&&(b=[f.sourceEvent.clientX??f.sourceEvent.touches[0].clientX,f.sourceEvent.clientY??f.sourceEvent.touches[0].clientY])},g=f=>{const x=n();if(f.sourceEvent.type!=="mousemove"&&f.sourceEvent.type!=="touchmove"||!t)return;const k=[f.sourceEvent.clientX??f.sourceEvent.touches[0].clientX,f.sourceEvent.clientY??f.sourceEvent.touches[0].clientY],S=[k[0]-b[0],k[1]-b[1]];b=k;const _=o()*Math.max(x[2],Math.log(x[2]))*(m?-1:1),A={x:x[0]-S[0]*_,y:x[1]-S[1]*_},T=[[0,0],[d,u]];t.setViewportConstrained({x:A.x,y:A.y,zoom:x[2]},T,a)},v=Jn().on("start",y).on("zoom",c?g:null).on("zoom.wheel",l?p:null);s.call(v,{})}function i(){s.on("zoom",null)}return{update:r,destroy:i,pointer:ue}}const gt=e=>({x:e.x,y:e.y,zoom:e.k}),It=({x:e,y:t,zoom:n})=>Ht.translate(e,t).scale(n),ze=(e,t)=>e.target.closest(`.${t}`),ko=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Ei=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,kt=(e,t=0,n=Ei,o=()=>{})=>{const s=typeof t=="number"&&t>0;return s||o(),s?e.transition().duration(t).ease(n).on("end",o):e},Po=e=>{const t=e.ctrlKey&&qe()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Si({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:o,panOnScrollMode:s,panOnScrollSpeed:r,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:d,onPanZoomEnd:u}){return h=>{if(ze(h,t))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(h.ctrlKey&&i){const y=ue(h),g=Po(h),v=c*Math.pow(2,g);o.scaleTo(n,v,y,h);return}const l=h.deltaMode===1?20:1;let m=s===ke.Vertical?0:h.deltaX*l,p=s===ke.Horizontal?0:h.deltaY*l;!qe()&&h.shiftKey&&s!==ke.Vertical&&(m=h.deltaY*l,p=0),o.translateBy(n,-(m/c)*r,-(p/c)*r,{internal:!0});const b=gt(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(d==null||d(h,b),e.panScrollTimeout=setTimeout(()=>{u==null||u(h,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(h,b))}}function Ni({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(o,s){const r=o.type==="wheel",i=!t&&r&&!o.ctrlKey,a=ze(o,e);if(o.ctrlKey&&r&&a&&o.preventDefault(),i||a)return null;o.preventDefault(),n.call(this,o,s)}}function Mi({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return o=>{var r,i,a;if((r=o.sourceEvent)!=null&&r.internal)return;const s=gt(o.transform);e.mouseButton=((i=o.sourceEvent)==null?void 0:i.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((a=o.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(o.sourceEvent,s))}}function Ci({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:o,onPanZoom:s}){return r=>{var i,a;e.usedRightMouseButton=!!(n&&ko(t,e.mouseButton??0)),(i=r.sourceEvent)!=null&&i.sync||o([r.transform.x,r.transform.y,r.transform.k]),s&&!((a=r.sourceEvent)!=null&&a.internal)&&(s==null||s(r.sourceEvent,gt(r.transform)))}}function Ii({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:o,onPanZoomEnd:s,onPaneContextMenu:r}){return i=>{var a;if(!((a=i.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,r&&ko(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&r(i.sourceEvent),e.usedRightMouseButton=!1,o(!1),s)){const d=gt(i.transform);e.prevViewport=d,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(i.sourceEvent,d)},n?150:0)}}}function ki({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:o,panOnScroll:s,zoomOnDoubleClick:r,userSelectionActive:i,noWheelClassName:a,noPanClassName:d,lib:u,connectionInProgress:h}){return c=>{var y;const l=e||t,m=n&&c.ctrlKey,p=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(ze(c,`${u}-flow__node`)||ze(c,`${u}-flow__edge`)))return!0;if(!o&&!l&&!s&&!r&&!n||i||h&&!p||ze(c,a)&&p||ze(c,d)&&(!p||s&&p&&!e)||!n&&c.ctrlKey&&p)return!1;if(!n&&c.type==="touchstart"&&((y=c.touches)==null?void 0:y.length)>1)return c.preventDefault(),!1;if(!l&&!s&&!m&&p||!o&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(o)&&!o.includes(c.button)&&c.type==="mousedown")return!1;const b=Array.isArray(o)&&o.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||p)&&b}}function Pi({domNode:e,minZoom:t,maxZoom:n,translateExtent:o,viewport:s,onPanZoom:r,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:d}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),c=Jn().scaleExtent([t,n]).translateExtent(o),l=ae(e).call(c);v({x:s.x,y:s.y,zoom:je(s.zoom,t,n)},[[0,0],[h.width,h.height]],o);const m=l.on("wheel.zoom"),p=l.on("dblclick.zoom");c.wheelDelta(Po);async function b(I,D){return l?new Promise(B=>{c==null||c.interpolate((D==null?void 0:D.interpolate)==="linear"?St:at).transform(kt(l,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>B(!0)),I)}):!1}function y({noWheelClassName:I,noPanClassName:D,onPaneContextMenu:B,userSelectionActive:w,panOnScroll:$,panOnDrag:N,panOnScrollMode:E,panOnScrollSpeed:P,preventScrolling:M,zoomOnPinch:L,zoomOnScroll:j,zoomOnDoubleClick:H,zoomActivationKeyPressed:O,lib:Y,onTransformChange:Z,connectionInProgress:Q,paneClickDistance:q,selectionOnDrag:R}){w&&!u.isZoomingOrPanning&&g();const F=$&&!O&&!w;c.clickDistance(R?1/0:!de(q)||q<0?0:q);const U=F?Si({zoomPanValues:u,noWheelClassName:I,d3Selection:l,d3Zoom:c,panOnScrollMode:E,panOnScrollSpeed:P,zoomOnPinch:L,onPanZoomStart:i,onPanZoom:r,onPanZoomEnd:a}):Ni({noWheelClassName:I,preventScrolling:M,d3ZoomHandler:m});l.on("wheel.zoom",U,{passive:!1});const K=Mi({zoomPanValues:u,onDraggingChange:d,onPanZoomStart:i});c.on("start",K);const G=Ci({zoomPanValues:u,panOnDrag:N,onPaneContextMenu:!!B,onPanZoom:r,onTransformChange:Z});c.on("zoom",G);const X=Ii({zoomPanValues:u,panOnDrag:N,panOnScroll:$,onPaneContextMenu:B,onPanZoomEnd:a,onDraggingChange:d});c.on("end",X);const J=ki({zoomActivationKeyPressed:O,panOnDrag:N,zoomOnScroll:j,panOnScroll:$,zoomOnDoubleClick:H,zoomOnPinch:L,userSelectionActive:w,noPanClassName:D,noWheelClassName:I,lib:Y,connectionInProgress:Q});c.filter(J),H?l.on("dblclick.zoom",p):l.on("dblclick.zoom",null)}function g(){c.on("zoom",null)}async function v(I,D,B){const w=It(I),$=c==null?void 0:c.constrain()(w,D,B);return $&&await b($),$}async function f(I,D){const B=It(I);return await b(B,D),B}function x(I){if(l){const D=It(I),B=l.property("__zoom");(B.k!==I.zoom||B.x!==I.x||B.y!==I.y)&&(c==null||c.transform(l,D,null,{sync:!0}))}}function k(){const I=l?yr(l.node()):{x:0,y:0,k:1};return{x:I.x,y:I.y,zoom:I.k}}async function S(I,D){return l?new Promise(B=>{c==null||c.interpolate((D==null?void 0:D.interpolate)==="linear"?St:at).scaleTo(kt(l,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>B(!0)),I)}):!1}async function _(I,D){return l?new Promise(B=>{c==null||c.interpolate((D==null?void 0:D.interpolate)==="linear"?St:at).scaleBy(kt(l,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>B(!0)),I)}):!1}function A(I){c==null||c.scaleExtent(I)}function T(I){c==null||c.translateExtent(I)}function V(I){const D=!de(I)||I<0?0:I;c==null||c.clickDistance(D)}return{update:y,destroy:g,setViewport:f,setViewportConstrained:v,getViewport:k,scaleTo:S,scaleBy:_,setScaleExtent:A,setTranslateExtent:T,syncViewport:x,setClickDistance:V}}var Re;(function(e){e.Line="line",e.Handle="handle"})(Re||(Re={}));function $i({width:e,prevWidth:t,height:n,prevHeight:o,affectsX:s,affectsY:r}){const i=e-t,a=n-o,d=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&s&&(d[0]=d[0]*-1),a&&r&&(d[1]=d[1]*-1),d}function bn(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),o=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:o,affectsY:s}}function be(e,t){return Math.max(0,t-e)}function ve(e,t){return Math.max(0,e-t)}function st(e,t,n){return Math.max(0,t-e,e-n)}function vn(e,t){return e?!t:t}function _i(e,t,n,o,s,r,i,a){let{affectsX:d,affectsY:u}=t;const{isHorizontal:h,isVertical:c}=t,l=h&&c,{xSnapped:m,ySnapped:p}=n,{minWidth:b,maxWidth:y,minHeight:g,maxHeight:v}=o,{x:f,y:x,width:k,height:S,aspectRatio:_}=e;let A=Math.floor(h?m-e.pointerX:0),T=Math.floor(c?p-e.pointerY:0);const V=k+(d?-A:A),I=S+(u?-T:T),D=-r[0]*k,B=-r[1]*S;let w=st(V,b,y),$=st(I,g,v);if(i){let P=0,M=0;d&&A<0?P=be(f+A+D,i[0][0]):!d&&A>0&&(P=ve(f+V+D,i[1][0])),u&&T<0?M=be(x+T+B,i[0][1]):!u&&T>0&&(M=ve(x+I+B,i[1][1])),w=Math.max(w,P),$=Math.max($,M)}if(a){let P=0,M=0;d&&A>0?P=ve(f+A,a[0][0]):!d&&A<0&&(P=be(f+V,a[1][0])),u&&T>0?M=ve(x+T,a[0][1]):!u&&T<0&&(M=be(x+I,a[1][1])),w=Math.max(w,P),$=Math.max($,M)}if(s){if(h){const P=st(V/_,g,v)*_;if(w=Math.max(w,P),i){let M=0;!d&&!u||d&&!u&&l?M=ve(x+B+V/_,i[1][1])*_:M=be(x+B+(d?A:-A)/_,i[0][1])*_,w=Math.max(w,M)}if(a){let M=0;!d&&!u||d&&!u&&l?M=be(x+V/_,a[1][1])*_:M=ve(x+(d?A:-A)/_,a[0][1])*_,w=Math.max(w,M)}}if(c){const P=st(I*_,b,y)/_;if($=Math.max($,P),i){let M=0;!d&&!u||u&&!d&&l?M=ve(f+I*_+D,i[1][0])/_:M=be(f+(u?T:-T)*_+D,i[0][0])/_,$=Math.max($,M)}if(a){let M=0;!d&&!u||u&&!d&&l?M=be(f+I*_,a[1][0])/_:M=ve(f+(u?T:-T)*_,a[0][0])/_,$=Math.max($,M)}}}T=T+(T<0?$:-$),A=A+(A<0?w:-w),s&&(l?V>I*_?T=(vn(d,u)?-A:A)/_:A=(vn(d,u)?-T:T)*_:h?(T=A/_,u=d):(A=T*_,d=u));const N=d?f+A:f,E=u?x+T:x;return{width:k+(d?-A:A),height:S+(u?-T:T),x:r[0]*A*(d?-1:1)+N,y:r[1]*T*(u?-1:1)+E}}const $o={width:0,height:0,x:0,y:0},Ai={...$o,pointerX:0,pointerY:0,aspectRatio:1};function zi(e,t,n){const o=t.position.x+e.position.x,s=t.position.y+e.position.y,r=e.measured.width??0,i=e.measured.height??0,a=n[0]*r,d=n[1]*i;return[[o-a,s-d],[o+r-a,s+i-d]]}function Ti({domNode:e,nodeId:t,getStoreItems:n,onChange:o,onEnd:s}){const r=ae(e);let i={controlDirection:bn("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:u,boundaries:h,keepAspectRatio:c,resizeDirection:l,onResizeStart:m,onResize:p,onResizeEnd:b,shouldResize:y}){let g={...$o},v={...Ai};i={boundaries:h,resizeDirection:l,keepAspectRatio:c,controlDirection:bn(u)};let f,x=null,k=[],S,_,A,T=!1;const V=Qn().on("start",I=>{const{nodeLookup:D,transform:B,snapGrid:w,snapToGrid:$,nodeOrigin:N,paneDomNode:E}=n();if(f=D.get(t),!f)return;x=(E==null?void 0:E.getBoundingClientRect())??null;const{xSnapped:P,ySnapped:M}=Oe(I.sourceEvent,{transform:B,snapGrid:w,snapToGrid:$,containerBounds:x});g={width:f.measured.width??0,height:f.measured.height??0,x:f.position.x??0,y:f.position.y??0},v={...g,pointerX:P,pointerY:M,aspectRatio:g.width/g.height},S=void 0,_=$e(f.extent)?f.extent:void 0,f.parentId&&(f.extent==="parent"||f.expandParent)&&(S=D.get(f.parentId)),S&&f.extent==="parent"&&(_=[[0,0],[S.measured.width,S.measured.height]]),k=[],A=void 0;for(const[L,j]of D)if(j.parentId===t&&(k.push({id:L,position:{...j.position},extent:j.extent}),j.extent==="parent"||j.expandParent)){const H=zi(j,f,j.origin??N);A?A=[[Math.min(H[0][0],A[0][0]),Math.min(H[0][1],A[0][1])],[Math.max(H[1][0],A[1][0]),Math.max(H[1][1],A[1][1])]]:A=H}m==null||m(I,{...g})}).on("drag",I=>{const{transform:D,snapGrid:B,snapToGrid:w,nodeOrigin:$}=n(),N=Oe(I.sourceEvent,{transform:D,snapGrid:B,snapToGrid:w,containerBounds:x}),E=[];if(!f)return;const{x:P,y:M,width:L,height:j}=g,H={},O=f.origin??$,{width:Y,height:Z,x:Q,y:q}=_i(v,i.controlDirection,N,i.boundaries,i.keepAspectRatio,O,_,A),R=Y!==L,F=Z!==j,U=Q!==P&&R,K=q!==M&&F;if(!U&&!K&&!R&&!F)return;if((U||K||O[0]===1||O[1]===1)&&(H.x=U?Q:g.x,H.y=K?q:g.y,g.x=H.x,g.y=H.y,k.length>0)){const te=Q-P,ne=q-M;for(const re of k)re.position={x:re.position.x-te+O[0]*(Y-L),y:re.position.y-ne+O[1]*(Z-j)},E.push(re)}if((R||F)&&(H.width=R&&(!i.resizeDirection||i.resizeDirection==="horizontal")?Y:g.width,H.height=F&&(!i.resizeDirection||i.resizeDirection==="vertical")?Z:g.height,g.width=H.width,g.height=H.height),S&&f.expandParent){const te=O[0]*(H.width??0);H.x&&H.x<te&&(g.x=te,v.x=v.x-(H.x-te));const ne=O[1]*(H.height??0);H.y&&H.y<ne&&(g.y=ne,v.y=v.y-(H.y-ne))}const G=$i({width:g.width,prevWidth:L,height:g.height,prevHeight:j,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),X={...g,direction:G};(y==null?void 0:y(I,X))!==!1&&(T=!0,p==null||p(I,X),o(H,E))}).on("end",I=>{T&&(b==null||b(I,{...g}),s==null||s({...g}),T=!1)});r.call(V)}function d(){r.on(".drag",null)}return{update:a,destroy:d}}const Di={},En=e=>{let t;const n=new Set,o=(h,c)=>{const l=typeof h=="function"?h(t):h;if(!Object.is(l,t)){const m=t;t=c??(typeof l!="object"||l===null)?l:Object.assign({},t,l),n.forEach(p=>p(t,m))}},s=()=>t,d={setState:o,getState:s,getInitialState:()=>u,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(Di?"production":void 0)!=="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()}},u=t=e(o,s,d);return d},Li=e=>e?En(e):En,{useDebugValue:ji}=wr,{useSyncExternalStoreWithSelector:Hi}=xr,Ri=e=>e;function _o(e,t=Ri,n){const o=Hi(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ji(o),o}const Sn=(e,t)=>{const n=Li(e),o=(s,r=t)=>_o(n,s,r);return Object.assign(o,n),o},Bi=(e,t)=>e?Sn(e,t):Sn;function oe(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[o,s]of e)if(!Object.is(s,t.get(o)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const o of e)if(!t.has(o))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}const pt=z.createContext(null),Vi=pt.Provider,Ao=he.error001("react");function ee(e,t){const n=z.useContext(pt);if(n===null)throw new Error(Ao);return _o(n,e,t)}function se(){const e=z.useContext(pt);if(e===null)throw new Error(Ao);return z.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Nn={display:"none"},Fi={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},zo="react-flow__node-desc",To="react-flow__edge-desc",Oi="react-flow__aria-live",Yi=e=>e.ariaLiveMessage,Xi=e=>e.ariaLabelConfig;function Wi({rfId:e}){const t=ee(Yi);return C.jsx("div",{id:`${Oi}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Fi,children:t})}function Gi({rfId:e,disableKeyboardA11y:t}){const n=ee(Xi);return C.jsxs(C.Fragment,{children:[C.jsx("div",{id:`${zo}-${e}`,style:Nn,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),C.jsx("div",{id:`${To}-${e}`,style:Nn,children:n["edge.a11yDescription.default"]}),!t&&C.jsx(Wi,{rfId:e})]})}const mt=z.forwardRef(({position:e="top-left",children:t,className:n,style:o,...s},r)=>{const i=`${e}`.split("-");return C.jsx("div",{className:ie(["react-flow__panel",n,...i]),style:o,ref:r,...s,children:t})});mt.displayName="Panel";const Mn="https://reactflow.dev?utm_source=attribution";function qi({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:C.jsx(mt,{position:t,className:"react-flow__attribution","data-message":`Please only hide this attribution when you are subscribed to React Flow Pro: ${Mn}`,children:C.jsx("a",{href:Mn,target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Zi=e=>{const t=[],n=[];for(const[,o]of e.nodeLookup)o.selected&&t.push(o.internals.userNode);for(const[,o]of e.edgeLookup)o.selected&&n.push(o);return{selectedNodes:t,selectedEdges:n}},rt=e=>e.id;function Ki(e,t){return oe(e.selectedNodes.map(rt),t.selectedNodes.map(rt))&&oe(e.selectedEdges.map(rt),t.selectedEdges.map(rt))}function Ui({onSelectionChange:e}){const t=se(),{selectedNodes:n,selectedEdges:o}=ee(Zi,Ki);return z.useEffect(()=>{const s={nodes:n,edges:o};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(r=>r(s))},[n,o,e]),null}const Qi=e=>!!e.onSelectionChangeHandlers;function Ji({onSelectionChange:e}){const t=ee(Qi);return e||t?C.jsx(Ui,{onSelectionChange:e}):null}const Do=[0,0],ea={x:0,y:0,zoom:1},ta=["nodes","edges","defaultNodes","defaultEdges","onConnect","onConnectStart","onConnectEnd","onClickConnectStart","onClickConnectEnd","nodesDraggable","autoPanOnNodeFocus","nodesConnectable","nodesFocusable","edgesFocusable","edgesReconnectable","elevateNodesOnSelect","elevateEdgesOnSelect","minZoom","maxZoom","nodeExtent","onNodesChange","onEdgesChange","elementsSelectable","connectionMode","snapGrid","snapToGrid","translateExtent","connectOnClick","defaultEdgeOptions","fitView","fitViewOptions","onNodesDelete","onEdgesDelete","onDelete","onNodeDrag","onNodeDragStart","onNodeDragStop","onSelectionDrag","onSelectionDragStart","onSelectionDragStop","onMoveStart","onMove","onMoveEnd","noPanClassName","nodeOrigin","autoPanOnConnect","autoPanOnNodeDrag","onError","connectionRadius","isValidConnection","selectNodesOnDrag","nodeDragThreshold","connectionDragThreshold","onBeforeDelete","debug","autoPanSpeed","ariaLabelConfig","zIndexMode"],Cn=[...ta,"rfId"],na=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),In={translateExtent:Xe,nodeOrigin:Do,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function oa(e){const{setNodes:t,setEdges:n,setMinZoom:o,setMaxZoom:s,setTranslateExtent:r,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:d}=ee(na,oe),u=se();z.useEffect(()=>(d(e.defaultNodes,e.defaultEdges),()=>{h.current=In,a()}),[]);const h=z.useRef(In);return z.useEffect(()=>{for(const c of Cn){const l=e[c],m=h.current[c];l!==m&&(typeof e[c]>"u"||(c==="nodes"?t(l):c==="edges"?n(l):c==="minZoom"?o(l):c==="maxZoom"?s(l):c==="translateExtent"?r(l):c==="nodeExtent"?i(l):c==="ariaLabelConfig"?u.setState({ariaLabelConfig:Gr(l)}):c==="fitView"?u.setState({fitViewQueued:l}):c==="fitViewOptions"?u.setState({fitViewOptions:l}):u.setState({[c]:l})))}h.current=e},Cn.map(c=>e[c])),null}function kn(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function sa(e){var o;const[t,n]=z.useState(e==="system"?null:e);return z.useEffect(()=>{if(e!=="system"){n(e);return}const s=kn(),r=()=>n(s!=null&&s.matches?"dark":"light");return r(),s==null||s.addEventListener("change",r),()=>{s==null||s.removeEventListener("change",r)}},[e]),t!==null?t:(o=kn())!=null&&o.matches?"dark":"light"}const Pn=typeof document<"u"?document:null;function Ze(e=null,t={target:Pn,actInsideInputWithModifier:!0}){const[n,o]=z.useState(!1),s=z.useRef(!1),r=z.useRef(new Set([])),[i,a]=z.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",`
|
|
2
2
|
`).replace(`
|
|
3
3
|
|
|
4
4
|
`,`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b9 as L,bH as ln,aZ as A,b7 as P,aY as W,bI as gn,bJ as dn,bK as hn,bL as z,bM as pn,bN as An,bO as N,ba as m,bf as K,bi as T,bP as _n,bd as on,bQ as wn,bR as On,a_ as V,bS as bn,bT as I}from"./index-
|
|
1
|
+
import{b9 as L,bH as ln,aZ as A,b7 as P,aY as W,bI as gn,bJ as dn,bK as hn,bL as z,bM as pn,bN as An,bO as N,ba as m,bf as K,bi as T,bP as _n,bd as on,bQ as wn,bR as On,a_ as V,bS as bn,bT as I}from"./index-MiIZL4f3.js";var Pn="[object Symbol]";function x(n){return typeof n=="symbol"||L(n)&&ln(n)==Pn}function vn(n,r){for(var e=-1,i=n==null?0:n.length,f=Array(i);++e<i;)f[e]=r(n[e],e,n);return f}var U=P?P.prototype:void 0,B=U?U.toString:void 0;function k(n){if(typeof n=="string")return n;if(A(n))return vn(n,k)+"";if(x(n))return B?B.call(n):"";var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function yn(){}function En(n,r){for(var e=-1,i=n==null?0:n.length;++e<i&&r(n[e],e,n)!==!1;);return n}function cn(n,r,e,i){for(var f=n.length,t=e+-1;++t<f;)if(r(n[t],t,n))return t;return-1}function Tn(n){return n!==n}function Rn(n,r,e){for(var i=e-1,f=n.length;++i<f;)if(n[i]===r)return i;return-1}function In(n,r,e){return r===r?Rn(n,r,e):cn(n,Tn,e)}function Sn(n,r){var e=n==null?0:n.length;return!!e&&In(n,r,0)>-1}function M(n){return W(n)?gn(n):dn(n)}var Ln=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,xn=/^\w*$/;function $(n,r){if(A(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||x(n)?!0:xn.test(n)||!Ln.test(n)||r!=null&&n in Object(r)}var Mn=500;function $n(n){var r=hn(n,function(i){return e.size===Mn&&e.clear(),i}),e=r.cache;return r}var Cn=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Dn=/\\(\\)?/g,Fn=$n(function(n){var r=[];return n.charCodeAt(0)===46&&r.push(""),n.replace(Cn,function(e,i,f,t){r.push(f?t.replace(Dn,"$1"):i||e)}),r});function Gn(n){return n==null?"":k(n)}function j(n,r){return A(n)?n:$(n,r)?[n]:Fn(Gn(n))}function R(n){if(typeof n=="string"||x(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}function nn(n,r){r=j(r,n);for(var e=0,i=r.length;n!=null&&e<i;)n=n[R(r[e++])];return e&&e==i?n:void 0}function Nn(n,r,e){var i=n==null?void 0:nn(n,r);return i===void 0?e:i}function rn(n,r){for(var e=-1,i=r.length,f=n.length;++e<i;)n[f+e]=r[e];return n}var H=P?P.isConcatSpreadable:void 0;function mn(n){return A(n)||z(n)||!!(H&&n&&n[H])}function Hr(n,r,e,i,f){var t=-1,s=n.length;for(e||(e=mn),f||(f=[]);++t<s;){var u=n[t];e(u)?rn(f,u):i||(f[f.length]=u)}return f}function Kn(n,r,e,i){var f=-1,t=n==null?0:n.length;for(i&&t&&(e=n[++f]);++f<t;)e=r(e,n[f],f,n);return e}function en(n,r){for(var e=-1,i=n==null?0:n.length,f=0,t=[];++e<i;){var s=n[e];r(s,e,n)&&(t[f++]=s)}return t}function Un(){return[]}var Bn=Object.prototype,Hn=Bn.propertyIsEnumerable,Z=Object.getOwnPropertySymbols,Zn=Z?function(n){return n==null?[]:(n=Object(n),en(Z(n),function(r){return Hn.call(n,r)}))}:Un;function qn(n,r,e){var i=r(n);return A(n)?i:rn(i,e(n))}function q(n){return qn(n,M,Zn)}var Yn="__lodash_hash_undefined__";function Jn(n){return this.__data__.set(n,Yn),this}function Qn(n){return this.__data__.has(n)}function v(n){var r=-1,e=n==null?0:n.length;for(this.__data__=new pn;++r<e;)this.add(n[r])}v.prototype.add=v.prototype.push=Jn;v.prototype.has=Qn;function Xn(n,r){for(var e=-1,i=n==null?0:n.length;++e<i;)if(r(n[e],e,n))return!0;return!1}function tn(n,r){return n.has(r)}var Wn=1,zn=2;function fn(n,r,e,i,f,t){var s=e&Wn,u=n.length,a=r.length;if(u!=a&&!(s&&a>u))return!1;var h=t.get(n),g=t.get(r);if(h&&g)return h==r&&g==n;var l=-1,d=!0,o=e&zn?new v:void 0;for(t.set(n,r),t.set(r,n);++l<u;){var p=n[l],_=r[l];if(i)var w=s?i(_,p,l,r,n,t):i(p,_,l,n,r,t);if(w!==void 0){if(w)continue;d=!1;break}if(o){if(!Xn(r,function(O,b){if(!tn(o,b)&&(p===O||f(p,O,e,i,t)))return o.push(b)})){d=!1;break}}else if(!(p===_||f(p,_,e,i,t))){d=!1;break}}return t.delete(n),t.delete(r),d}function Vn(n){var r=-1,e=Array(n.size);return n.forEach(function(i,f){e[++r]=[f,i]}),e}function C(n){var r=-1,e=Array(n.size);return n.forEach(function(i){e[++r]=i}),e}var kn=1,jn=2,nr="[object Boolean]",rr="[object Date]",er="[object Error]",ir="[object Map]",tr="[object Number]",fr="[object RegExp]",sr="[object Set]",ur="[object String]",ar="[object Symbol]",lr="[object ArrayBuffer]",gr="[object DataView]",Y=P?P.prototype:void 0,S=Y?Y.valueOf:void 0;function dr(n,r,e,i,f,t,s){switch(e){case gr:if(n.byteLength!=r.byteLength||n.byteOffset!=r.byteOffset)return!1;n=n.buffer,r=r.buffer;case lr:return!(n.byteLength!=r.byteLength||!t(new N(n),new N(r)));case nr:case rr:case tr:return An(+n,+r);case er:return n.name==r.name&&n.message==r.message;case fr:case ur:return n==r+"";case ir:var u=Vn;case sr:var a=i&kn;if(u||(u=C),n.size!=r.size&&!a)return!1;var h=s.get(n);if(h)return h==r;i|=jn,s.set(n,r);var g=fn(u(n),u(r),i,f,t,s);return s.delete(n),g;case ar:if(S)return S.call(n)==S.call(r)}return!1}var hr=1,pr=Object.prototype,Ar=pr.hasOwnProperty;function _r(n,r,e,i,f,t){var s=e&hr,u=q(n),a=u.length,h=q(r),g=h.length;if(a!=g&&!s)return!1;for(var l=a;l--;){var d=u[l];if(!(s?d in r:Ar.call(r,d)))return!1}var o=t.get(n),p=t.get(r);if(o&&p)return o==r&&p==n;var _=!0;t.set(n,r),t.set(r,n);for(var w=s;++l<a;){d=u[l];var O=n[d],b=r[d];if(i)var G=s?i(b,O,d,r,n,t):i(O,b,d,n,r,t);if(!(G===void 0?O===b||f(O,b,e,i,t):G)){_=!1;break}w||(w=d=="constructor")}if(_&&!w){var y=n.constructor,E=r.constructor;y!=E&&"constructor"in n&&"constructor"in r&&!(typeof y=="function"&&y instanceof y&&typeof E=="function"&&E instanceof E)&&(_=!1)}return t.delete(n),t.delete(r),_}var or=1,J="[object Arguments]",Q="[object Array]",c="[object Object]",wr=Object.prototype,X=wr.hasOwnProperty;function Or(n,r,e,i,f,t){var s=A(n),u=A(r),a=s?Q:m(n),h=u?Q:m(r);a=a==J?c:a,h=h==J?c:h;var g=a==c,l=h==c,d=a==h;if(d&&K(n)){if(!K(r))return!1;s=!0,g=!1}if(d&&!g)return t||(t=new T),s||_n(n)?fn(n,r,e,i,f,t):dr(n,r,a,e,i,f,t);if(!(e&or)){var o=g&&X.call(n,"__wrapped__"),p=l&&X.call(r,"__wrapped__");if(o||p){var _=o?n.value():n,w=p?r.value():r;return t||(t=new T),f(_,w,e,i,t)}}return d?(t||(t=new T),_r(n,r,e,i,f,t)):!1}function D(n,r,e,i,f){return n===r?!0:n==null||r==null||!L(n)&&!L(r)?n!==n&&r!==r:Or(n,r,e,i,D,f)}var br=1,Pr=2;function vr(n,r,e,i){var f=e.length,t=f;if(n==null)return!t;for(n=Object(n);f--;){var s=e[f];if(s[2]?s[1]!==n[s[0]]:!(s[0]in n))return!1}for(;++f<t;){s=e[f];var u=s[0],a=n[u],h=s[1];if(s[2]){if(a===void 0&&!(u in n))return!1}else{var g=new T,l;if(!(l===void 0?D(h,a,br|Pr,i,g):l))return!1}}return!0}function sn(n){return n===n&&!on(n)}function yr(n){for(var r=M(n),e=r.length;e--;){var i=r[e],f=n[i];r[e]=[i,f,sn(f)]}return r}function un(n,r){return function(e){return e==null?!1:e[n]===r&&(r!==void 0||n in Object(e))}}function Er(n){var r=yr(n);return r.length==1&&r[0][2]?un(r[0][0],r[0][1]):function(e){return e===n||vr(e,n,r)}}function cr(n,r){return n!=null&&r in Object(n)}function Tr(n,r,e){r=j(r,n);for(var i=-1,f=r.length,t=!1;++i<f;){var s=R(r[i]);if(!(t=n!=null&&e(n,s)))break;n=n[s]}return t||++i!=f?t:(f=n==null?0:n.length,!!f&&wn(f)&&On(s,f)&&(A(n)||z(n)))}function Rr(n,r){return n!=null&&Tr(n,r,cr)}var Ir=1,Sr=2;function Lr(n,r){return $(n)&&sn(r)?un(R(n),r):function(e){var i=Nn(e,n);return i===void 0&&i===r?Rr(e,n):D(r,i,Ir|Sr)}}function xr(n){return function(r){return r==null?void 0:r[n]}}function Mr(n){return function(r){return nn(r,n)}}function $r(n){return $(n)?xr(R(n)):Mr(n)}function an(n){return typeof n=="function"?n:n==null?V:typeof n=="object"?A(n)?Lr(n[0],n[1]):Er(n):$r(n)}function Cr(n,r){return n&&bn(n,r,M)}function Dr(n,r){return function(e,i){if(e==null)return e;if(!W(e))return n(e,i);for(var f=e.length,t=-1,s=Object(e);++t<f&&i(s[t],t,s)!==!1;);return e}}var F=Dr(Cr);function Fr(n){return typeof n=="function"?n:V}function Zr(n,r){var e=A(n)?En:F;return e(n,Fr(r))}function Gr(n,r){var e=[];return F(n,function(i,f,t){r(i,f,t)&&e.push(i)}),e}function qr(n,r){var e=A(n)?en:Gr;return e(n,an(r))}function Nr(n,r,e,i,f){return f(n,function(t,s,u){e=i?(i=!1,t):r(e,t,s,u)}),e}function Yr(n,r,e){var i=A(n)?Kn:Nr,f=arguments.length<3;return i(n,an(r),e,f,F)}var mr=1/0,Kr=I&&1/C(new I([,-0]))[1]==mr?function(n){return new I(n)}:yn,Ur=200;function Jr(n,r,e){var i=-1,f=Sn,t=n.length,s=!0,u=[],a=u;if(t>=Ur){var h=r?null:Kr(n);if(h)return C(h);s=!1,f=tn,a=new v}else a=r?[]:u;n:for(;++i<t;){var g=n[i],l=r?r(g):g;if(g=g!==0?g:0,s&&l===l){for(var d=a.length;d--;)if(a[d]===l)continue n;r&&a.push(l),u.push(g)}else f(a,l,e)||(a!==u&&a.push(l),u.push(g))}return u}export{F as a,Hr as b,an as c,vn as d,rn as e,qn as f,Zn as g,En as h,x as i,q as j,M as k,Jr as l,qr as m,Zr as n,cn as o,Fr as p,Cr as q,Yr as r,Un as s,Tr as t,j as u,R as v,nn as w,Rr as x,Gn as y};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Q as ln,S as an,T as y,V as tn,W as $,X as S,Y as _,Z as un,$ as rn,a0 as B,a1 as o,a2 as W,a3 as sn,a4 as on,a5 as fn}from"./index-
|
|
1
|
+
import{Q as ln,S as an,T as y,V as tn,W as $,X as S,Y as _,Z as un,$ as rn,a0 as B,a1 as o,a2 as W,a3 as sn,a4 as on,a5 as fn}from"./index-MiIZL4f3.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,X,a){var I=E-l,i=q-h,n=X-v,d=a-A,u=d*I-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function K(l,h,E,q,v,A,X){var a=l-E,I=h-q,i=(X?A:-A)/B(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,Y=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,O=(g<0?-1:1)*B(fn(0,T*T*R-P*P)),Q=(P*g-m*O)/R,V=(-P*m-g*O)/R,w=(P*g+m*O)/R,p=(-P*m+g*O)/R,x=Q-Y,e=V-t,r=w-Y,Z=p-t;return x*x+e*e>r*r+Z*Z&&(Q=w,V=p),{cx:Q,cy:V,x01:-n,y01:-d,x11:Q*(v/T-1),y11:V*(v/T-1)}}function hn(){var l=cn,h=yn,E=W(0),q=null,v=gn,A=dn,X=mn,a=null,I=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-an,c=A.apply(this,arguments)-an,Y=un(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(Y>tn-y)a.moveTo(s*$(f),s*S(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*$(c),u*S(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=Y,O=Y,Q=X.apply(this,arguments)/2,V=Q>y&&(q?+q.apply(this,arguments):B(u*u+s*s)),w=_(un(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(V>y){var Z=sn(V/u*S(Q)),C=sn(V/s*S(Q));(P-=Z*2)>y?(Z*=t?1:-1,R+=Z,T-=Z):(P=0,R=T=(f+c)/2),(O-=C*2)>y?(C*=t?1:-1,m+=C,g-=C):(O=0,m=g=(f+c)/2)}var j=s*$(m),z=s*S(m),F=u*$(T),G=u*S(T);if(w>y){var H=s*$(g),J=s*S(g),L=u*$(R),M=u*S(R),D;if(Y<rn)if(D=pn(j,z,L,M,H,J,F,G)){var N=j-D[0],U=z-D[1],k=H-D[0],b=J-D[1],nn=1/S(on((N*k+U*b)/(B(N*N+U*U)*B(k*k+b*b)))/2),en=B(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>y?x>y?(e=K(L,M,j,z,s,x,t),r=K(H,J,F,G,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(j,z),a.arc(0,0,s,m,g,!t)):a.moveTo(j,z),!(u>y)||!(P>y)?a.lineTo(F,G):p>y?(e=K(F,G,H,J,u,-p,t),r=K(j,z,L,M,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-rn/2;return[$(d)*n,S(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:W(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:W(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:W(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:W(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:W(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:W(+n),i):A},i.padAngle=function(n){return arguments.length?(X=typeof n=="function"?n:W(+n),i):X},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
|