@markus-global/cli 0.11.2 → 0.11.3-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/dist/commands/start.js +5 -2
  2. package/dist/commands/start.js.map +1 -1
  3. package/dist/markus.mjs +1254 -1121
  4. package/dist/web-ui/assets/{CommentInput-Cgu8208h.js → CommentInput-C-niUbUY.js} +1 -1
  5. package/dist/web-ui/assets/{ContentRenderer-rzRUDj8T.js → ContentRenderer-DxsnJJRX.js} +2 -2
  6. package/dist/web-ui/assets/{DeliverableShareModal-BvfmqTNG.js → DeliverableShareModal-DV3TiZx0.js} +1 -1
  7. package/dist/web-ui/assets/{Deliverables-DKTLnaF8.js → Deliverables-tlLsJnxZ.js} +1 -1
  8. package/dist/web-ui/assets/{Notifications-CWaO9onn.js → Notifications-4KXYRdkr.js} +1 -1
  9. package/dist/web-ui/assets/{Search-D_C5Eyed.js → Search-CPFwZv1U.js} +1 -1
  10. package/dist/web-ui/assets/{Settings-B5Ib6SFf.js → Settings-DIa-_qre.js} +6 -6
  11. package/dist/web-ui/assets/{Store-D__pfqoc.js → Store-JWjwXfTU.js} +1 -1
  12. package/dist/web-ui/assets/Team-COBxn96h.js +84 -0
  13. package/dist/web-ui/assets/{Work-BJ7kXixx.js → Work-BScJUqWL.js} +1 -1
  14. package/dist/web-ui/assets/{arc-BN0GMYN6.js → arc-DPZmpo1U.js} +1 -1
  15. package/dist/web-ui/assets/{architectureDiagram-3BPJPVTR-BP5Nnl2Y.js → architectureDiagram-3BPJPVTR-DlOs02JO.js} +1 -1
  16. package/dist/web-ui/assets/{blockDiagram-GPEHLZMM-nKHUCU_z.js → blockDiagram-GPEHLZMM-C7qsXNUe.js} +1 -1
  17. package/dist/web-ui/assets/{c4Diagram-AAUBKEIU-DoS0wcHh.js → c4Diagram-AAUBKEIU-Drwp-rtM.js} +1 -1
  18. package/dist/web-ui/assets/channel-DCChB-1T.js +1 -0
  19. package/dist/web-ui/assets/{chunk-2J33WTMH-CP54_XNl.js → chunk-2J33WTMH-VgR09Mqk.js} +1 -1
  20. package/dist/web-ui/assets/{chunk-4BX2VUAB-DMvJaJb7.js → chunk-4BX2VUAB-CuwDpBRL.js} +1 -1
  21. package/dist/web-ui/assets/{chunk-55IACEB6-DQnZgoOO.js → chunk-55IACEB6-nC7YWJ_i.js} +1 -1
  22. package/dist/web-ui/assets/{chunk-727SXJPM-B5_3LI53.js → chunk-727SXJPM-Dw6mBsRE.js} +1 -1
  23. package/dist/web-ui/assets/{chunk-AQP2D5EJ-B5Mh5bI_.js → chunk-AQP2D5EJ-CPhNJbHl.js} +1 -1
  24. package/dist/web-ui/assets/{chunk-FMBD7UC4-mjYTpuBm.js → chunk-FMBD7UC4-AyhQakG8.js} +1 -1
  25. package/dist/web-ui/assets/{chunk-ND2GUHAM-BxTrseJg.js → chunk-ND2GUHAM-DgYemv8I.js} +1 -1
  26. package/dist/web-ui/assets/{chunk-QZHKN3VN-C1do5brE.js → chunk-QZHKN3VN-CLdqxrFB.js} +1 -1
  27. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-CrNiYfSI.js +1 -0
  28. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-CrNiYfSI.js +1 -0
  29. package/dist/web-ui/assets/{cose-bilkent-S5V4N54A-DMn7aSDK.js → cose-bilkent-S5V4N54A-DrOgwDIH.js} +1 -1
  30. package/dist/web-ui/assets/{dagre-BM42HDAG-CE-tTagY.js → dagre-BM42HDAG-DhoJiA83.js} +1 -1
  31. package/dist/web-ui/assets/{diagram-2AECGRRQ-BwyvxbJa.js → diagram-2AECGRRQ-BDILSgqK.js} +1 -1
  32. package/dist/web-ui/assets/{diagram-5GNKFQAL-Nopndxl0.js → diagram-5GNKFQAL-CeXywd1i.js} +1 -1
  33. package/dist/web-ui/assets/{diagram-KO2AKTUF-CGTjHHnD.js → diagram-KO2AKTUF-Bi4RlMT0.js} +1 -1
  34. package/dist/web-ui/assets/{diagram-LMA3HP47-DhC3AqLA.js → diagram-LMA3HP47-Cw1yxk8b.js} +1 -1
  35. package/dist/web-ui/assets/{diagram-OG6HWLK6-BIuzyWJO.js → diagram-OG6HWLK6-Bl857da2.js} +1 -1
  36. package/dist/web-ui/assets/{docx-preview-ClO_djcO.js → docx-preview-CjoUhrMq.js} +1 -1
  37. package/dist/web-ui/assets/{erDiagram-TEJ5UH35-Nmfi9Wv0.js → erDiagram-TEJ5UH35-DEiaMhuV.js} +1 -1
  38. package/dist/web-ui/assets/{flowDiagram-I6XJVG4X-BVAM5QzO.js → flowDiagram-I6XJVG4X-BgKZhO0h.js} +1 -1
  39. package/dist/web-ui/assets/{ganttDiagram-6RSMTGT7-BGdTbY0A.js → ganttDiagram-6RSMTGT7-Dkx-EaS8.js} +1 -1
  40. package/dist/web-ui/assets/{gitGraphDiagram-PVQCEYII-BMfug5mp.js → gitGraphDiagram-PVQCEYII-DXaQwA0y.js} +1 -1
  41. package/dist/web-ui/assets/{index-1X1Ykov8.js → index-C_QhfMcC.js} +72 -72
  42. package/dist/web-ui/assets/index-DEN_qReg.css +1 -0
  43. package/dist/web-ui/assets/{infoDiagram-5YYISTIA-DAqSLNMU.js → infoDiagram-5YYISTIA-Dpx9IOkx.js} +1 -1
  44. package/dist/web-ui/assets/{ishikawaDiagram-YF4QCWOH-Bro4RrlG.js → ishikawaDiagram-YF4QCWOH-BWqWgitQ.js} +1 -1
  45. package/dist/web-ui/assets/{journeyDiagram-JHISSGLW-CdRHOaID.js → journeyDiagram-JHISSGLW-BBwIZ4k9.js} +1 -1
  46. package/dist/web-ui/assets/{kanban-definition-UN3LZRKU-9iLNl-rB.js → kanban-definition-UN3LZRKU-C_MRWV8R.js} +1 -1
  47. package/dist/web-ui/assets/{mermaid.core-BRHCbDDt.js → mermaid.core-BMAh3nnq.js} +5 -5
  48. package/dist/web-ui/assets/{mindmap-definition-RKZ34NQL-BLm-XQ6W.js → mindmap-definition-RKZ34NQL-B6vJQcat.js} +1 -1
  49. package/dist/web-ui/assets/{pieDiagram-4H26LBE5-ith90T5A.js → pieDiagram-4H26LBE5-BxdEttqt.js} +1 -1
  50. package/dist/web-ui/assets/{quadrantDiagram-W4KKPZXB-Cb08oHG7.js → quadrantDiagram-W4KKPZXB-gsNs2VfP.js} +1 -1
  51. package/dist/web-ui/assets/{requirementDiagram-4Y6WPE33-DzMKi4w8.js → requirementDiagram-4Y6WPE33-BSC9KvC2.js} +1 -1
  52. package/dist/web-ui/assets/{sankeyDiagram-5OEKKPKP-C0Wv4A7m.js → sankeyDiagram-5OEKKPKP-DktAZfe_.js} +1 -1
  53. package/dist/web-ui/assets/{sequenceDiagram-3UESZ5HK-C_HL9WB0.js → sequenceDiagram-3UESZ5HK-BIPt8kGU.js} +1 -1
  54. package/dist/web-ui/assets/{stateDiagram-AJRCARHV-BFfTVEYQ.js → stateDiagram-AJRCARHV-DiXmJWB0.js} +1 -1
  55. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-COOgTXIX.js +1 -0
  56. package/dist/web-ui/assets/{timeline-definition-PNZ67QCA-cyPnAADn.js → timeline-definition-PNZ67QCA-LRi7H35g.js} +1 -1
  57. package/dist/web-ui/assets/{vennDiagram-CIIHVFJN-Cb82-9OZ.js → vennDiagram-CIIHVFJN-DWQ1I022.js} +1 -1
  58. package/dist/web-ui/assets/{wardley-L42UT6IY-BTW1NXXR.js → wardley-L42UT6IY-BUb6dYqN.js} +1 -1
  59. package/dist/web-ui/assets/{wardleyDiagram-YWT4CUSO-C_F_dT6n.js → wardleyDiagram-YWT4CUSO-BYE1B3xT.js} +1 -1
  60. package/dist/web-ui/assets/{xychartDiagram-2RQKCTM6-clcfplhG.js → xychartDiagram-2RQKCTM6-D-pS2-Sa.js} +1 -1
  61. package/dist/web-ui/index.html +2 -2
  62. package/docs/README.md +93 -0
  63. package/docs/api/api.md +353 -0
  64. package/docs/architecture/agent-runtime.md +341 -0
  65. package/docs/architecture/architecture-fragility.md +184 -0
  66. package/docs/architecture/architecture.md +938 -0
  67. package/docs/architecture/cognitive-architecture.md +322 -0
  68. package/docs/architecture/concurrent-processing.md +550 -0
  69. package/docs/architecture/frontend/team-chat.md +312 -0
  70. package/docs/architecture/learning-loop.md +340 -0
  71. package/docs/architecture/llm-provider-timeouts.md +60 -0
  72. package/docs/architecture/mailbox-system.md +1635 -0
  73. package/docs/architecture/memory-system.md +533 -0
  74. package/docs/architecture/prompt-engineering.md +1377 -0
  75. package/docs/architecture/state-machines.md +665 -0
  76. package/docs/architecture/state-ownership.md +83 -0
  77. package/docs/architecture/streaming-and-reattach.md +193 -0
  78. package/docs/architecture/tool-system.md +266 -0
  79. package/docs/design/deliverable-sharing.md +238 -0
  80. package/docs/guides/coding-tools.md +765 -0
  81. package/docs/guides/community.md +104 -0
  82. package/docs/guides/development.md +179 -0
  83. package/docs/guides/guide.md +362 -0
  84. package/docs/guides/release-and-distribution.md +165 -0
  85. package/docs/guides/remote-access.md +286 -0
  86. package/docs/guides/skill-ecosystem.md +129 -0
  87. package/docs/records/agent-platform-friction-2026-10.md +98 -0
  88. package/docs/records/animation-budget-focus-vs-visibility-2026-10-08.md +110 -0
  89. package/docs/records/audit-fixes-2026-09.md +173 -0
  90. package/docs/records/branch-consolidation.md +597 -0
  91. package/docs/records/file-edit-literal-replacement-fix.md +132 -0
  92. package/docs/records/message-stop-cancel-fix-plan.md +209 -0
  93. package/docs/records/platform-hardening-2026-10.md +1365 -0
  94. package/docs/records/session-identity-plan.md +130 -0
  95. package/docs/records/settings-model-routing-first-visit-fix.md +101 -0
  96. package/docs/records/team-chat-stream-transport-vs-turn-2026-10-08.md +152 -0
  97. package/package.json +2 -1
  98. package/templates/roles/HANDBOOK.md +12 -7
  99. package/dist/web-ui/assets/Team-FFbGLcXj.js +0 -84
  100. package/dist/web-ui/assets/channel-C_kHFvaW.js +0 -1
  101. package/dist/web-ui/assets/classDiagram-4FO5ZUOK-UF2PuXCi.js +0 -1
  102. package/dist/web-ui/assets/classDiagram-v2-Q7XG4LA2-UF2PuXCi.js +0 -1
  103. package/dist/web-ui/assets/index-3PQIqBtv.css +0 -1
  104. package/dist/web-ui/assets/stateDiagram-v2-BHNVJYJU-DuO1A2q2.js +0 -1
@@ -1,4 +1,4 @@
1
- import{y as Vl,z as Wl,x as Fl,R as Yl,r as p,j as t,u as $e,l as le,B as Gl,a as yr,k as Kl,n as kt,P as He,b as Ul,c as Xl,m as Zl,d as Ls,w as mt,C as Tt,E as Or,p as zr,M as Ql,i as Jl,F as qn,q as ur,G as Qa,A as Fs,H as Ao,J as As,K as Do,L as Ds,Q as Po,U as $o,V as Bo,O as ec,W as Ja,X as ei,Y as tc}from"./index-1X1Ykov8.js";import{ContentRenderer as nc}from"./ContentRenderer-rzRUDj8T.js";import{s as ht,e as ti,f as Ys,T as vs,g as ws,t as rc}from"./transform-CpIVI4vC.js";import{i as ks}from"./value-DIujSiJ7.js";import{C as ni}from"./CommentInput-Cgu8208h.js";function sc(e){let n;for(;n=e.sourceEvent;)e=n;return e}function It(e,n){if(e=sc(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var r=s.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const oc={passive:!1},fr={capture:!0,passive:!1};function js(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function ri(e){var n=e.document.documentElement,s=ht(e).on("dragstart.drag",Yn,fr);"onselectstart"in n?s.on("selectstart.drag",Yn,fr):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function si(e,n){var s=e.document.documentElement,r=ht(e).on("dragstart.drag",null);n&&(r.on("click.drag",Yn,fr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in s?r.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const Hr=e=>()=>e;function Ps(e,{sourceEvent:n,subject:s,target:r,identifier:i,active:o,x:a,y:c,dx:l,dy:d,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:h}})}Ps.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ac(e){return!e.ctrlKey&&!e.button}function ic(){return this.parentNode}function lc(e,n){return n??{x:e.x,y:e.y}}function cc(){return navigator.maxTouchPoints||"ontouchstart"in this}function oi(){var e=ac,n=ic,s=lc,r=cc,i={},o=ti("start","drag","end"),a=0,c,l,d,h,f=0;function m(b){b.on("mousedown.drag",u).filter(r).on("touchstart.drag",C).on("touchmove.drag",v,oc).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function u(b,j){if(!(h||!e.call(this,b,j))){var k=g(this,n.call(this,b,j),b,j,"mouse");k&&(ht(b.view).on("mousemove.drag",x,fr).on("mouseup.drag",E,fr),ri(b.view),js(b),d=!1,c=b.clientX,l=b.clientY,k("start",b))}}function x(b){if(Yn(b),!d){var j=b.clientX-c,k=b.clientY-l;d=j*j+k*k>f}i.mouse("drag",b)}function E(b){ht(b.view).on("mousemove.drag mouseup.drag",null),si(b.view,d),Yn(b),i.mouse("end",b)}function C(b,j){if(e.call(this,b,j)){var k=b.changedTouches,M=n.call(this,b,j),R=k.length,D,A;for(D=0;D<R;++D)(A=g(this,M,b,j,k[D].identifier,k[D]))&&(js(b),A("start",b,k[D]))}}function v(b){var j=b.changedTouches,k=j.length,M,R;for(M=0;M<k;++M)(R=i[j[M].identifier])&&(Yn(b),R("drag",b,j[M]))}function y(b){var j=b.changedTouches,k=j.length,M,R;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),M=0;M<k;++M)(R=i[j[M].identifier])&&(js(b),R("end",b,j[M]))}function g(b,j,k,M,R,D){var A=o.copy(),T=It(D||k,j),$,z,N;if((N=s.call(b,new Ps("beforestart",{sourceEvent:k,target:m,identifier:R,active:a,x:T[0],y:T[1],dx:0,dy:0,dispatch:A}),M))!=null)return $=N.x-T[0]||0,z=N.y-T[1]||0,function O(L,_,I){var P=T,q;switch(L){case"start":i[R]=O,q=a++;break;case"end":delete i[R],--a;case"drag":T=It(I||_,j),q=a;break}A.call(L,b,new Ps(L,{sourceEvent:_,subject:N,target:m,identifier:R,active:q,x:T[0]+$,y:T[1]+z,dx:T[0]-P[0],dy:T[1]-P[1],dispatch:A}),M)}}return m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Hr(!!b),m):e},m.container=function(b){return arguments.length?(n=typeof b=="function"?b:Hr(b),m):n},m.subject=function(b){return arguments.length?(s=typeof b=="function"?b:Hr(b),m):s},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:Hr(!!b),m):r},m.on=function(){var b=o.on.apply(o,arguments);return b===o?m:b},m.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,m):Math.sqrt(f)},m}var dc=1e-12;function Oo(e){return((e=Math.exp(e))+1/e)/2}function uc(e){return((e=Math.exp(e))-1/e)/2}function fc(e){return((e=Math.exp(2*e))-1)/(e+1)}const Zr=(function e(n,s,r){function i(o,a){var c=o[0],l=o[1],d=o[2],h=a[0],f=a[1],m=a[2],u=h-c,x=f-l,E=u*u+x*x,C,v;if(E<dc)v=Math.log(m/d)/n,C=function(M){return[c+M*u,l+M*x,d*Math.exp(n*M*v)]};else{var y=Math.sqrt(E),g=(m*m-d*d+r*E)/(2*d*s*y),b=(m*m-d*d-r*E)/(2*m*s*y),j=Math.log(Math.sqrt(g*g+1)-g),k=Math.log(Math.sqrt(b*b+1)-b);v=(k-j)/n,C=function(M){var R=M*v,D=Oo(j),A=d/(s*y)*(D*fc(n*R+j)-uc(j));return[c+A*u,l+A*x,d*D/Oo(n*R+j)]}}return C.duration=v*1e3*n/Math.SQRT2,C}return i.rho=function(o){var a=Math.max(.001,+o),c=a*a,l=c*c;return e(a,c,l)},i})(Math.SQRT2,2,4),qr=e=>()=>e;function hc(e,{sourceEvent:n,target:s,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ns(e){e.stopImmediatePropagation()}function lr(e){e.preventDefault(),e.stopImmediatePropagation()}function mc(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function pc(){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 zo(){return this.__zoom||Ys}function gc(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function xc(){return navigator.maxTouchPoints||"ontouchstart"in this}function bc(e,n,s){var r=e.invertX(n[0][0])-s[0][0],i=e.invertX(n[1][0])-s[1][0],o=e.invertY(n[0][1])-s[0][1],a=e.invertY(n[1][1])-s[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function ai(){var e=mc,n=pc,s=bc,r=gc,i=xc,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],c=250,l=Zr,d=ti("start","zoom","end"),h,f,m,u=500,x=150,E=0,C=10;function v(N){N.property("__zoom",zo).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",A).filter(i).on("touchstart.zoom",T).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(N,O,L,_){var I=N.selection?N.selection():N;I.property("__zoom",zo),N!==I?j(N,O,L,_):I.interrupt().each(function(){k(this,arguments).event(_).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},v.scaleBy=function(N,O,L,_){v.scaleTo(N,function(){var I=this.__zoom.k,P=typeof O=="function"?O.apply(this,arguments):O;return I*P},L,_)},v.scaleTo=function(N,O,L,_){v.transform(N,function(){var I=n.apply(this,arguments),P=this.__zoom,q=L==null?b(I):typeof L=="function"?L.apply(this,arguments):L,Y=P.invert(q),F=typeof O=="function"?O.apply(this,arguments):O;return s(g(y(P,F),q,Y),I,a)},L,_)},v.translateBy=function(N,O,L,_){v.transform(N,function(){return s(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof L=="function"?L.apply(this,arguments):L),n.apply(this,arguments),a)},null,_)},v.translateTo=function(N,O,L,_,I){v.transform(N,function(){var P=n.apply(this,arguments),q=this.__zoom,Y=_==null?b(P):typeof _=="function"?_.apply(this,arguments):_;return s(Ys.translate(Y[0],Y[1]).scale(q.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof L=="function"?-L.apply(this,arguments):-L),P,a)},_,I)};function y(N,O){return O=Math.max(o[0],Math.min(o[1],O)),O===N.k?N:new vs(O,N.x,N.y)}function g(N,O,L){var _=O[0]-L[0]*N.k,I=O[1]-L[1]*N.k;return _===N.x&&I===N.y?N:new vs(N.k,_,I)}function b(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function j(N,O,L,_){N.on("start.zoom",function(){k(this,arguments).event(_).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(_).end()}).tween("zoom",function(){var I=this,P=arguments,q=k(I,P).event(_),Y=n.apply(I,P),F=L==null?b(Y):typeof L=="function"?L.apply(I,P):L,Q=Math.max(Y[1][0]-Y[0][0],Y[1][1]-Y[0][1]),B=I.__zoom,S=typeof O=="function"?O.apply(I,P):O,V=l(B.invert(F).concat(Q/B.k),S.invert(F).concat(Q/S.k));return function(W){if(W===1)W=S;else{var H=V(W),K=Q/H[2];W=new vs(K,F[0]-H[0]*K,F[1]-H[1]*K)}q.zoom(null,W)}})}function k(N,O,L){return!L&&N.__zooming||new M(N,O)}function M(N,O){this.that=N,this.args=O,this.active=0,this.sourceEvent=null,this.extent=n.apply(N,O),this.taps=0}M.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,O){return this.mouse&&N!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var O=ht(this.that).datum();d.call(N,this.that,new hc(N,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:d}),O)}};function R(N,...O){if(!e.apply(this,arguments))return;var L=k(this,O).event(N),_=this.__zoom,I=Math.max(o[0],Math.min(o[1],_.k*Math.pow(2,r.apply(this,arguments)))),P=It(N);if(L.wheel)(L.mouse[0][0]!==P[0]||L.mouse[0][1]!==P[1])&&(L.mouse[1]=_.invert(L.mouse[0]=P)),clearTimeout(L.wheel);else{if(_.k===I)return;L.mouse=[P,_.invert(P)],ws(this),L.start()}lr(N),L.wheel=setTimeout(q,x),L.zoom("mouse",s(g(y(_,I),L.mouse[0],L.mouse[1]),L.extent,a));function q(){L.wheel=null,L.end()}}function D(N,...O){if(m||!e.apply(this,arguments))return;var L=N.currentTarget,_=k(this,O,!0).event(N),I=ht(N.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",Q,!0),P=It(N,L),q=N.clientX,Y=N.clientY;ri(N.view),Ns(N),_.mouse=[P,this.__zoom.invert(P)],ws(this),_.start();function F(B){if(lr(B),!_.moved){var S=B.clientX-q,V=B.clientY-Y;_.moved=S*S+V*V>E}_.event(B).zoom("mouse",s(g(_.that.__zoom,_.mouse[0]=It(B,L),_.mouse[1]),_.extent,a))}function Q(B){I.on("mousemove.zoom mouseup.zoom",null),si(B.view,_.moved),lr(B),_.event(B).end()}}function A(N,...O){if(e.apply(this,arguments)){var L=this.__zoom,_=It(N.changedTouches?N.changedTouches[0]:N,this),I=L.invert(_),P=L.k*(N.shiftKey?.5:2),q=s(g(y(L,P),_,I),n.apply(this,O),a);lr(N),c>0?ht(this).transition().duration(c).call(j,q,_,N):ht(this).call(v.transform,q,_,N)}}function T(N,...O){if(e.apply(this,arguments)){var L=N.touches,_=L.length,I=k(this,O,N.changedTouches.length===_).event(N),P,q,Y,F;for(Ns(N),q=0;q<_;++q)Y=L[q],F=It(Y,this),F=[F,this.__zoom.invert(F),Y.identifier],I.touch0?!I.touch1&&I.touch0[2]!==F[2]&&(I.touch1=F,I.taps=0):(I.touch0=F,P=!0,I.taps=1+!!h);h&&(h=clearTimeout(h)),P&&(I.taps<2&&(f=F[0],h=setTimeout(function(){h=null},u)),ws(this),I.start())}}function $(N,...O){if(this.__zooming){var L=k(this,O).event(N),_=N.changedTouches,I=_.length,P,q,Y,F;for(lr(N),P=0;P<I;++P)q=_[P],Y=It(q,this),L.touch0&&L.touch0[2]===q.identifier?L.touch0[0]=Y:L.touch1&&L.touch1[2]===q.identifier&&(L.touch1[0]=Y);if(q=L.that.__zoom,L.touch1){var Q=L.touch0[0],B=L.touch0[1],S=L.touch1[0],V=L.touch1[1],W=(W=S[0]-Q[0])*W+(W=S[1]-Q[1])*W,H=(H=V[0]-B[0])*H+(H=V[1]-B[1])*H;q=y(q,Math.sqrt(W/H)),Y=[(Q[0]+S[0])/2,(Q[1]+S[1])/2],F=[(B[0]+V[0])/2,(B[1]+V[1])/2]}else if(L.touch0)Y=L.touch0[0],F=L.touch0[1];else return;L.zoom("touch",s(g(q,Y,F),L.extent,a))}}function z(N,...O){if(this.__zooming){var L=k(this,O).event(N),_=N.changedTouches,I=_.length,P,q;for(Ns(N),m&&clearTimeout(m),m=setTimeout(function(){m=null},u),P=0;P<I;++P)q=_[P],L.touch0&&L.touch0[2]===q.identifier?delete L.touch0:L.touch1&&L.touch1[2]===q.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(q=It(q,this),Math.hypot(f[0]-q[0],f[1]-q[1])<C)){var Y=ht(this).on("dblclick.zoom");Y&&Y.apply(this,arguments)}}}return v.wheelDelta=function(N){return arguments.length?(r=typeof N=="function"?N:qr(+N),v):r},v.filter=function(N){return arguments.length?(e=typeof N=="function"?N:qr(!!N),v):e},v.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:qr(!!N),v):i},v.extent=function(N){return arguments.length?(n=typeof N=="function"?N:qr([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),v):n},v.scaleExtent=function(N){return arguments.length?(o[0]=+N[0],o[1]=+N[1],v):[o[0],o[1]]},v.translateExtent=function(N){return arguments.length?(a[0][0]=+N[0][0],a[1][0]=+N[1][0],a[0][1]=+N[0][1],a[1][1]=+N[1][1],v):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},v.constrain=function(N){return arguments.length?(s=N,v):s},v.duration=function(N){return arguments.length?(c=+N,v):c},v.interpolate=function(N){return arguments.length?(l=N,v):l},v.on=function(){var N=d.on.apply(d,arguments);return N===d?v:N},v.clickDistance=function(N){return arguments.length?(E=(N=+N)*N,v):Math.sqrt(E)},v.tapDistance=function(N){return arguments.length?(C=+N,v):C},v}function Ye(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let s=0,r;s<e.length;s++)(r=Ye(e[s]))!==""&&(n+=(n&&" ")+r);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}const Wt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:s,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:r}", edge id: ${n}.`,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."},hr=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ii=["Enter"," ","Escape"],li={"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:n,y:s})=>`Moved selected node ${e}. New position, x: ${n}, y: ${s}`,"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 Gn;(function(e){e.Strict="strict",e.Loose="loose"})(Gn||(Gn={}));var Mn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Mn||(Mn={}));var mr;(function(e){e.Partial="partial",e.Full="full"})(mr||(mr={}));const ci={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var fn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(fn||(fn={}));var Kn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Kn||(Kn={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const Ho={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function di(e){return e===null?null:e?"valid":"invalid"}const ui=e=>"id"in e&&"source"in e&&"target"in e,yc=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gs=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vr=(e,n=[0,0])=>{const{width:s,height:r}=rn(e),i=e.origin??n,o=s*i[0],a=r*i[1];return{x:e.position.x-o,y:e.position.y-a}},vc=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((r,i)=>{const o=typeof i=="string";let a=!n.nodeLookup&&!o?i:void 0;n.nodeLookup&&(a=o?n.nodeLookup.get(i):Gs(i)?i:n.nodeLookup.get(i.id));const c=a?ts(a,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return is(r,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ls(s)},wr=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(n.filter===void 0||n.filter(i))&&(s=is(s,ts(i)),r=!0)}),r?ls(s):{x:0,y:0,width:0,height:0}},Ks=(e,n,[s,r,i]=[0,0,1],o=!1,a=!1)=>{const c={...jr(n,[s,r,i]),width:n.width/i,height:n.height/i},l=[];for(const d of e.values()){const{measured:h,selectable:f=!0,hidden:m=!1}=d;if(a&&!f||m)continue;const u=h.width??d.width??d.initialWidth??null,x=h.height??d.height??d.initialHeight??null,E=pr(c,Xn(d)),C=(u??0)*(x??0),v=o&&E>0;(!d.internals.handleBounds||v||E>=C||d.dragging)&&l.push(d)}return l},wc=(e,n)=>{const s=new Set;return e.forEach(r=>{s.add(r.id)}),n.filter(r=>s.has(r.source)||s.has(r.target))};function kc(e,n){const s=new Map,r=n?.nodes?new Set(n.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&(n?.includeHiddenNodes||!i.hidden)&&(!r||r.has(i.id))&&s.set(i.id,i)}),s}async function jc({nodes:e,width:n,height:s,panZoom:r,minZoom:i,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const c=kc(e,a),l=wr(c),d=Us(l,n,s,a?.minZoom??i,a?.maxZoom??o,a?.padding??.1);return await r.setViewport(d,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)}function fi({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const a=s.get(e),c=a.parentId?s.get(a.parentId):void 0,{x:l,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},h=a.origin??r;let f=a.extent||i;if(a.extent==="parent"&&!a.expandParent)if(!c)o?.("005",Wt.error005());else{const u=c.measured.width,x=c.measured.height;u&&x&&(f=[[l,d],[l+u,d+x]])}else c&&Zn(a.extent)&&(f=[[a.extent[0][0]+l,a.extent[0][1]+d],[a.extent[1][0]+l,a.extent[1][1]+d]]);const m=Zn(f)?Tn(n,f,a.measured):n;return(a.measured.width===void 0||a.measured.height===void 0)&&o?.("015",Wt.error015()),{position:{x:m.x-l+(a.measured.width??0)*h[0],y:m.y-d+(a.measured.height??0)*h[1]},positionAbsolute:m}}async function Nc({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:r,onBeforeDelete:i}){const o=new Set(e.map(m=>m.id)),a=[];for(const m of s){if(m.deletable===!1)continue;const u=o.has(m.id),x=!u&&m.parentId&&a.find(E=>E.id===m.parentId);(u||x)&&a.push(m)}const c=new Set(n.map(m=>m.id)),l=r.filter(m=>m.deletable!==!1),h=wc(a,l);for(const m of l)c.has(m.id)&&!h.find(x=>x.id===m.id)&&h.push(m);if(!i)return{edges:h,nodes:a};const f=await i({nodes:a,edges:h});return typeof f=="boolean"?f?{edges:h,nodes:a}:{edges:[],nodes:[]}:f}const Un=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),Tn=(e={x:0,y:0},n,s)=>({x:Un(e.x,n[0][0],n[1][0]-(s?.width??0)),y:Un(e.y,n[0][1],n[1][1]-(s?.height??0))});function hi(e,n,s){const{width:r,height:i}=rn(s),{x:o,y:a}=s.internals.positionAbsolute;return Tn(e,[[o,a],[o+r,a+i]],n)}const qo=(e,n,s)=>e<n?Un(Math.abs(e-n),1,n)/n:e>s?-Un(Math.abs(e-s),1,n)/n:0,mi=(e,n,s=15,r=40)=>{const i=qo(e.x,r,n.width-r)*s,o=qo(e.y,r,n.height-r)*s;return[i,o]},is=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),$s=({x:e,y:n,width:s,height:r})=>({x:e,y:n,x2:e+s,y2:n+r}),ls=({x:e,y:n,x2:s,y2:r})=>({x:e,y:n,width:s-e,height:r-n}),Xn=(e,n=[0,0])=>{const{x:s,y:r}=Gs(e)?e.internals.positionAbsolute:vr(e,n);return{x:s,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ts=(e,n=[0,0])=>{const{x:s,y:r}=Gs(e)?e.internals.positionAbsolute:vr(e,n);return{x:s,y:r,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},pi=(e,n)=>ls(is($s(e),$s(n))),pr=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),r=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*r)},Vo=e=>Rt(e.width)&&Rt(e.height)&&Rt(e.x)&&Rt(e.y),Rt=e=>!isNaN(e)&&isFinite(e),Cc=(e,n)=>{},kr=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),jr=({x:e,y:n},[s,r,i],o=!1,a=[1,1])=>{const c={x:(e-s)/i,y:(n-r)/i};return o?kr(c,a):c},ns=({x:e,y:n},[s,r,i])=>({x:e*i+s,y:n*i+r});function Hn(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(n*s*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sc(e,n,s){if(typeof e=="string"||typeof e=="number"){const r=Hn(e,s),i=Hn(e,n);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=Hn(e.top??e.y??0,s),i=Hn(e.bottom??e.y??0,s),o=Hn(e.left??e.x??0,n),a=Hn(e.right??e.x??0,n);return{top:r,right:a,bottom:i,left:o,x:o+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ec(e,n,s,r,i,o){const{x:a,y:c}=ns(e,[n,s,r]),{x:l,y:d}=ns({x:e.x+e.width,y:e.y+e.height},[n,s,r]),h=i-l,f=o-d;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(f)}}const Us=(e,n,s,r,i,o)=>{const a=Sc(o,n,s),c=(n-a.x)/e.width,l=(s-a.y)/e.height,d=Math.min(c,l),h=Un(d,r,i),f=e.x+e.width/2,m=e.y+e.height/2,u=n/2-f*h,x=s/2-m*h,E=Ec(e,u,x,h,n,s),C={left:Math.min(E.left-a.left,0),top:Math.min(E.top-a.top,0),right:Math.min(E.right-a.right,0),bottom:Math.min(E.bottom-a.bottom,0)};return{x:u-C.left+C.right,y:x-C.top+C.bottom,zoom:h}},gr=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Zn(e){return e!=null&&e!=="parent"}function rn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gi(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function xi(e,n={width:0,height:0},s,r,i){const o={...e},a=r.get(s);if(a){const c=a.origin||i;o.x+=a.internals.positionAbsolute.x-(n.width??0)*c[0],o.y+=a.internals.positionAbsolute.y-(n.height??0)*c[1]}return o}function Wo(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function Mc(){let e,n;return{promise:new Promise((r,i)=>{e=r,n=i}),resolve:e,reject:n}}function Tc(e){return{...li,...e||{}}}function cr(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:r,containerBounds:i}){const{x:o,y:a}=_t(e),c=jr({x:o-(i?.left??0),y:a-(i?.top??0)},r),{x:l,y:d}=s?kr(c,n):c;return{xSnapped:l,ySnapped:d,...c}}const Xs=e=>({width:e.offsetWidth,height:e.offsetHeight}),bi=e=>e?.getRootNode?.()||window?.document,Ic=["INPUT","SELECT","TEXTAREA"];function yi(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:Ic.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const vi=e=>"clientX"in e,_t=(e,n)=>{const s=vi(e),r=s?e.clientX:e.touches?.[0].clientX,i=s?e.clientY:e.touches?.[0].clientY;return{x:r-(n?.left??0),y:i-(n?.top??0)}},Fo=(e,n,s,r,i)=>{const o=n.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:i,position:a.getAttribute("data-handlepos"),x:(c.left-s.left)/r,y:(c.top-s.top)/r,...Xs(a)}})};function wi({sourceX:e,sourceY:n,targetX:s,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:a,targetControlY:c}){const l=e*.125+i*.375+a*.375+s*.125,d=n*.125+o*.375+c*.375+r*.125,h=Math.abs(l-e),f=Math.abs(d-n);return[l,d,h,f]}function Vr(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Yo({pos:e,x1:n,y1:s,x2:r,y2:i,c:o}){switch(e){case ve.Left:return[n-Vr(n-r,o),s];case ve.Right:return[n+Vr(r-n,o),s];case ve.Top:return[n,s-Vr(s-i,o)];case ve.Bottom:return[n,s+Vr(i-s,o)]}}function ki({sourceX:e,sourceY:n,sourcePosition:s=ve.Bottom,targetX:r,targetY:i,targetPosition:o=ve.Top,curvature:a=.25}){const[c,l]=Yo({pos:s,x1:e,y1:n,x2:r,y2:i,c:a}),[d,h]=Yo({pos:o,x1:r,y1:i,x2:e,y2:n,c:a}),[f,m,u,x]=wi({sourceX:e,sourceY:n,targetX:r,targetY:i,sourceControlX:c,sourceControlY:l,targetControlX:d,targetControlY:h});return[`M${e},${n} C${c},${l} ${d},${h} ${r},${i}`,f,m,u,x]}function ji({sourceX:e,sourceY:n,targetX:s,targetY:r}){const i=Math.abs(s-e)/2,o=s<e?s+i:s-i,a=Math.abs(r-n)/2,c=r<n?r+a:r-a;return[o,c,i,a]}function Rc({sourceNode:e,targetNode:n,selected:s=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const a=i&&s?r+1e3:r,c=Math.max(e.parentId||i&&e.selected?e.internals.z:0,n.parentId||i&&n.selected?n.internals.z:0);return a+c}function _c({sourceNode:e,targetNode:n,width:s,height:r,transform:i}){const o=is(ts(e),ts(n));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-i[0]/i[2],y:-i[1]/i[2],width:s/i[2],height:r/i[2]};return pr(a,ls(o))>0}const Lc=({source:e,sourceHandle:n,target:s,targetHandle:r})=>`xy-edge__${e}${n||""}-${s}${r||""}`,Ac=(e,n)=>n.some(s=>s.source===e.source&&s.target===e.target&&(s.sourceHandle===e.sourceHandle||!s.sourceHandle&&!e.sourceHandle)&&(s.targetHandle===e.targetHandle||!s.targetHandle&&!e.targetHandle)),Dc=(e,n,s={})=>{if(!e.source||!e.target)return n;const r=s.getEdgeId||Lc;let i;return ui(e)?i={...e}:i={...e,id:r(e)},Ac(i,n)?n:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,n.concat(i))};function Ni({sourceX:e,sourceY:n,targetX:s,targetY:r}){const[i,o,a,c]=ji({sourceX:e,sourceY:n,targetX:s,targetY:r});return[`M ${e},${n}L ${s},${r}`,i,o,a,c]}const Go={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},Pc=({source:e,sourcePosition:n=ve.Bottom,target:s})=>n===ve.Left||n===ve.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},Ko=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function $c({source:e,sourcePosition:n=ve.Bottom,target:s,targetPosition:r=ve.Top,center:i,offset:o,stepPosition:a}){const c=Go[n],l=Go[r],d={x:e.x+c.x*o,y:e.y+c.y*o},h={x:s.x+l.x*o,y:s.y+l.y*o},f=Pc({source:d,sourcePosition:n,target:h}),m=f.x!==0?"x":"y",u=f[m];let x=[],E,C;const v={x:0,y:0},y={x:0,y:0},[,,g,b]=ji({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(c[m]*l[m]===-1){m==="x"?(E=i.x??d.x+(h.x-d.x)*a,C=i.y??(d.y+h.y)/2):(E=i.x??(d.x+h.x)/2,C=i.y??d.y+(h.y-d.y)*a);const k=[{x:E,y:d.y},{x:E,y:h.y}],M=[{x:d.x,y:C},{x:h.x,y:C}];c[m]===u?x=m==="x"?k:M:x=m==="x"?M:k}else{const k=[{x:d.x,y:h.y}],M=[{x:h.x,y:d.y}];if(m==="x"?x=c.x===u?M:k:x=c.y===u?k:M,n===r){const $=Math.abs(e[m]-s[m]);if($<=o){const z=Math.min(o-1,o-$);c[m]===u?v[m]=(d[m]>e[m]?-1:1)*z:y[m]=(h[m]>s[m]?-1:1)*z}}if(n!==r){const $=m==="x"?"y":"x",z=c[m]===l[$],N=d[$]>h[$],O=d[$]<h[$];(c[m]===1&&(!z&&N||z&&O)||c[m]!==1&&(!z&&O||z&&N))&&(x=m==="x"?k:M)}const R={x:d.x+v.x,y:d.y+v.y},D={x:h.x+y.x,y:h.y+y.y},A=Math.max(Math.abs(R.x-x[0].x),Math.abs(D.x-x[0].x)),T=Math.max(Math.abs(R.y-x[0].y),Math.abs(D.y-x[0].y));A>=T?(E=(R.x+D.x)/2,C=x[0].y):(E=x[0].x,C=(R.y+D.y)/2)}return[[e,{x:d.x+v.x,y:d.y+v.y},...x,{x:h.x+y.x,y:h.y+y.y},s],E,C,g,b]}function Bc(e,n,s,r){const i=Math.min(Ko(e,n)/2,Ko(n,s)/2,r),{x:o,y:a}=n;if(e.x===o&&o===s.x||e.y===a&&a===s.y)return`L${o} ${a}`;if(e.y===a){const d=e.x<s.x?-1:1,h=e.y<s.y?1:-1;return`L ${o+i*d},${a}Q ${o},${a} ${o},${a+i*h}`}const c=e.x<s.x?1:-1,l=e.y<s.y?-1:1;return`L ${o},${a+i*l}Q ${o},${a} ${o+i*c},${a}`}function Bs({sourceX:e,sourceY:n,sourcePosition:s=ve.Bottom,targetX:r,targetY:i,targetPosition:o=ve.Top,borderRadius:a=5,centerX:c,centerY:l,offset:d=20,stepPosition:h=.5}){const[f,m,u,x,E]=$c({source:{x:e,y:n},sourcePosition:s,target:{x:r,y:i},targetPosition:o,center:{x:c,y:l},offset:d,stepPosition:h});return[f.reduce((v,y,g)=>{let b="";return g>0&&g<f.length-1?b=Bc(f[g-1],y,f[g+1],a):b=`${g===0?"M":"L"}${y.x} ${y.y}`,v+=b,v},""),m,u,x,E]}function Uo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Oc(e){const{sourceNode:n,targetNode:s}=e;if(!Uo(n)||!Uo(s))return null;const r=n.internals.handleBounds||Xo(n.handles),i=s.internals.handleBounds||Xo(s.handles),o=Zo(r?.source??[],e.sourceHandle),a=Zo(e.connectionMode===Gn.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!o||!a)return e.onError?.("008",Wt.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=o?.position||ve.Bottom,l=a?.position||ve.Top,d=In(n,o,c),h=In(s,a,l);return{sourceX:d.x,sourceY:d.y,targetX:h.x,targetY:h.y,sourcePosition:c,targetPosition:l}}function Xo(e){if(!e)return null;const n=[],s=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?n.push(r):r.type==="target"&&s.push(r);return{source:n,target:s}}function In(e,n,s=ve.Left,r=!1){const i=(n?.x??0)+e.internals.positionAbsolute.x,o=(n?.y??0)+e.internals.positionAbsolute.y,{width:a,height:c}=n??rn(e);if(r)return{x:i+a/2,y:o+c/2};switch(n?.position??s){case ve.Top:return{x:i+a/2,y:o};case ve.Right:return{x:i+a,y:o+c/2};case ve.Bottom:return{x:i+a/2,y:o+c};case ve.Left:return{x:i,y:o+c/2}}}function Zo(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function Os(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function zc(e,{id:n,defaultColor:s,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((a,c)=>([c.markerStart||r,c.markerEnd||i].forEach(l=>{if(l&&typeof l=="object"){const d=Os(l,n);o.has(d)||(a.push({id:d,color:l.color||s,...l}),o.add(d))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))}const Ci=1e3,Hc=10,Zs={nodeOrigin:[0,0],nodeExtent:hr,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},qc={...Zs,checkEquality:!0};function Qs(e,n){const s={...e};for(const r in n)n[r]!==void 0&&(s[r]=n[r]);return s}function Vc(e,n,s){const r=Qs(Zs,s);for(const i of e.values())if(i.parentId)eo(i,e,n,r);else{const o=vr(i,r.nodeOrigin),a=Zn(i.extent)?i.extent:r.nodeExtent,c=Tn(o,a,rn(i));i.internals.positionAbsolute=c}}function Wc(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?s.push(o):i.type==="target"&&r.push(o)}return{source:s,target:r}}function Js(e){return e==="manual"}function zs(e,n,s,r={}){const i=Qs(qc,r),o={i:0},a=new Map(n),c=i?.elevateNodesOnSelect&&!Js(i.zIndexMode)?Ci:0;let l=e.length>0;n.clear(),s.clear();for(const d of e){let h=a.get(d.id);if(i.checkEquality&&d===h?.internals.userNode)n.set(d.id,h);else{const f=vr(d,i.nodeOrigin),m=Zn(d.extent)?d.extent:i.nodeExtent,u=Tn(f,m,rn(d));h={...i.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:u,handleBounds:Wc(d,h),z:Si(d,c,i.zIndexMode),userNode:d}},n.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),d.parentId&&eo(h,n,s,r,o)}return l}function Fc(e,n){if(!e.parentId)return;const s=n.get(e.parentId);s?s.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function eo(e,n,s,r,i){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:c,zIndexMode:l}=Qs(Zs,r),d=e.parentId,h=n.get(d);if(!h){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Fc(e,s),i&&!h.parentId&&h.internals.rootParentIndex===void 0&&l==="auto"&&(h.internals.rootParentIndex=++i.i,h.internals.z=h.internals.z+i.i*Hc),i&&h.internals.rootParentIndex!==void 0&&(i.i=h.internals.rootParentIndex);const f=o&&!Js(l)?Ci:0,{x:m,y:u,z:x}=Yc(e,h,a,c,f,l),{positionAbsolute:E}=e.internals,C=m!==E.x||u!==E.y;(C||x!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:m,y:u}:E,z:x}})}function Si(e,n,s){const r=Rt(e.zIndex)?e.zIndex:0;return Js(s)?r:r+(e.selected?n:0)}function Yc(e,n,s,r,i,o){const{x:a,y:c}=n.internals.positionAbsolute,l=rn(e),d=vr(e,s),h=Zn(e.extent)?Tn(d,e.extent,l):d;let f=Tn({x:a+h.x,y:c+h.y},r,l);e.extent==="parent"&&(f=hi(f,l,n));const m=Si(e,i,o),u=n.internals.z??0;return{x:f.x,y:f.y,z:u>=m?u+1:m}}function to(e,n,s,r=[0,0]){const i=[],o=new Map;for(const a of e){const c=n.get(a.parentId);if(!c)continue;const l=o.get(a.parentId)?.expandedRect??Xn(c),d=pi(l,a.rect);o.set(a.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},l)=>{const d=c.internals.positionAbsolute,h=rn(c),f=c.origin??r,m=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,u=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,x=Math.max(h.width,Math.round(a.width)),E=Math.max(h.height,Math.round(a.height)),C=(x-h.width)*f[0],v=(E-h.height)*f[1];(m>0||u>0||C||v)&&(i.push({id:l,type:"position",position:{x:c.position.x-m+C,y:c.position.y-u+v}}),s.get(l)?.forEach(y=>{e.some(g=>g.id===y.id)||i.push({id:y.id,type:"position",position:{x:y.position.x+m,y:y.position.y+u}})})),(h.width<a.width||h.height<a.height||m||u)&&i.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:x+(m?f[0]*m-C:0),height:E+(u?f[1]*u-v:0)}})}),i}function Gc(e,n,s,r,i,o,a){const c=r?.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const d=[],h=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(h.transform),m=[];for(const u of e.values()){const x=n.get(u.id);if(!x)continue;if(x.hidden){n.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),l=!0;continue}const E=Xs(u.nodeElement),C=x.measured.width!==E.width||x.measured.height!==E.height;if(!!(E.width&&E.height&&(C||!x.internals.handleBounds||u.force))){const y=u.nodeElement.getBoundingClientRect(),g=Zn(x.extent)?x.extent:o;let{positionAbsolute:b}=x.internals;x.parentId&&x.extent==="parent"?b=hi(b,E,n.get(x.parentId)):g&&(b=Tn(b,g,E));const j={...x,measured:E,internals:{...x.internals,positionAbsolute:b,handleBounds:{source:Fo("source",u.nodeElement,y,f,x.id),target:Fo("target",u.nodeElement,y,f,x.id)}}};n.set(x.id,j),x.parentId&&eo(j,n,s,{nodeOrigin:i,zIndexMode:a}),l=!0,C&&(d.push({id:x.id,type:"dimensions",dimensions:E}),x.expandParent&&x.parentId&&m.push({id:x.id,parentId:x.parentId,rect:Xn(j,i)}))}}if(m.length>0){const u=to(m,n,s,i);d.push(...u)}return{changes:d,updatedInternals:l}}async function Kc({delta:e,panZoom:n,transform:s,translateExtent:r,width:i,height:o}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const a=await n.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[i,o]],r),c=!!a&&(a.x!==s[0]||a.y!==s[1]||a.k!==s[2]);return Promise.resolve(c)}function Qo(e,n,s,r,i,o){let a=i;const c=r.get(a)||new Map;r.set(a,c.set(s,n)),a=`${i}-${e}`;const l=r.get(a)||new Map;if(r.set(a,l.set(s,n)),o){a=`${i}-${e}-${o}`;const d=r.get(a)||new Map;r.set(a,d.set(s,n))}}function Ei(e,n,s){e.clear(),n.clear();for(const r of s){const{source:i,target:o,sourceHandle:a=null,targetHandle:c=null}=r,l={edgeId:r.id,source:i,target:o,sourceHandle:a,targetHandle:c},d=`${i}-${a}--${o}-${c}`,h=`${o}-${c}--${i}-${a}`;Qo("source",l,h,e,i,a),Qo("target",l,d,e,o,c),n.set(r.id,r)}}function Mi(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:Mi(s,n):!1}function Jo(e,n,s){let r=e;do{if(r?.matches?.(n))return!0;if(r===s)return!1;r=r?.parentElement}while(r);return!1}function Uc(e,n,s,r){const i=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!Mi(a,e))&&(a.draggable||n&&typeof a.draggable>"u")){const c=e.get(o);c&&i.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:s.x-c.internals.positionAbsolute.x,y:s.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return i}function Cs({nodeId:e,dragItems:n,nodeLookup:s,dragging:r=!0}){const i=[];for(const[a,c]of n){const l=s.get(a)?.internals.userNode;l&&i.push({...l,position:c.position,dragging:r})}if(!e)return[i[0],i];const o=s.get(e)?.internals.userNode;return[o?{...o,position:n.get(e)?.position||o.position,dragging:r}:i[0],i]}function Xc({dragItems:e,snapGrid:n,x:s,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:s-i.distance.x,y:r-i.distance.y},a=kr(o,n);return{x:a.x-o.x,y:a.y-o.y}}function Zc({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:r,onDragStop:i}){let o={x:null,y:null},a=0,c=new Map,l=!1,d={x:0,y:0},h=null,f=!1,m=null,u=!1,x=!1,E=null;function C({noDragClassName:y,handleSelector:g,domNode:b,isSelectable:j,nodeId:k,nodeClickDistance:M=0}){m=ht(b);function R({x:$,y:z}){const{nodeLookup:N,nodeExtent:O,snapGrid:L,snapToGrid:_,nodeOrigin:I,onNodeDrag:P,onSelectionDrag:q,onError:Y,updateNodePositions:F}=n();o={x:$,y:z};let Q=!1;const B=c.size>1,S=B&&O?$s(wr(c)):null,V=B&&_?Xc({dragItems:c,snapGrid:L,x:$,y:z}):null;for(const[W,H]of c){if(!N.has(W))continue;let K={x:$-H.distance.x,y:z-H.distance.y};_&&(K=V?{x:Math.round(K.x+V.x),y:Math.round(K.y+V.y)}:kr(K,L));let te=null;if(B&&O&&!H.extent&&S){const{positionAbsolute:J}=H.internals,Z=J.x-S.x+O[0][0],ce=J.x+H.measured.width-S.x2+O[1][0],ae=J.y-S.y+O[0][1],pe=J.y+H.measured.height-S.y2+O[1][1];te=[[Z,ae],[ce,pe]]}const{position:re,positionAbsolute:fe}=fi({nodeId:W,nextPosition:K,nodeLookup:N,nodeExtent:te||O,nodeOrigin:I,onError:Y});Q=Q||H.position.x!==re.x||H.position.y!==re.y,H.position=re,H.internals.positionAbsolute=fe}if(x=x||Q,!!Q&&(F(c,!0),E&&(r||P||!k&&q))){const[W,H]=Cs({nodeId:k,dragItems:c,nodeLookup:N});r?.(E,c,W,H),P?.(E,W,H),k||q?.(E,H)}}async function D(){if(!h)return;const{transform:$,panBy:z,autoPanSpeed:N,autoPanOnNodeDrag:O}=n();if(!O){l=!1,cancelAnimationFrame(a);return}const[L,_]=mi(d,h,N);(L!==0||_!==0)&&(o.x=(o.x??0)-L/$[2],o.y=(o.y??0)-_/$[2],await z({x:L,y:_})&&R(o)),a=requestAnimationFrame(D)}function A($){const{nodeLookup:z,multiSelectionActive:N,nodesDraggable:O,transform:L,snapGrid:_,snapToGrid:I,selectNodesOnDrag:P,onNodeDragStart:q,onSelectionDragStart:Y,unselectNodesAndEdges:F}=n();f=!0,(!P||!j)&&!N&&k&&(z.get(k)?.selected||F()),j&&P&&k&&e?.(k);const Q=cr($.sourceEvent,{transform:L,snapGrid:_,snapToGrid:I,containerBounds:h});if(o=Q,c=Uc(z,O,Q,k),c.size>0&&(s||q||!k&&Y)){const[B,S]=Cs({nodeId:k,dragItems:c,nodeLookup:z});s?.($.sourceEvent,c,B,S),q?.($.sourceEvent,B,S),k||Y?.($.sourceEvent,S)}}const T=oi().clickDistance(M).on("start",$=>{const{domNode:z,nodeDragThreshold:N,transform:O,snapGrid:L,snapToGrid:_}=n();h=z?.getBoundingClientRect()||null,u=!1,x=!1,E=$.sourceEvent,N===0&&A($),o=cr($.sourceEvent,{transform:O,snapGrid:L,snapToGrid:_,containerBounds:h}),d=_t($.sourceEvent,h)}).on("drag",$=>{const{autoPanOnNodeDrag:z,transform:N,snapGrid:O,snapToGrid:L,nodeDragThreshold:_,nodeLookup:I}=n(),P=cr($.sourceEvent,{transform:N,snapGrid:O,snapToGrid:L,containerBounds:h});if(E=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||k&&!I.has(k))&&(u=!0),!u){if(!l&&z&&f&&(l=!0,D()),!f){const q=_t($.sourceEvent,h),Y=q.x-d.x,F=q.y-d.y;Math.sqrt(Y*Y+F*F)>_&&A($)}(o.x!==P.xSnapped||o.y!==P.ySnapped)&&c&&f&&(d=_t($.sourceEvent,h),R(P))}}).on("end",$=>{if(!(!f||u)&&(l=!1,f=!1,cancelAnimationFrame(a),c.size>0)){const{nodeLookup:z,updateNodePositions:N,onNodeDragStop:O,onSelectionDragStop:L}=n();if(x&&(N(c,!1),x=!1),i||O||!k&&L){const[_,I]=Cs({nodeId:k,dragItems:c,nodeLookup:z,dragging:!1});i?.($.sourceEvent,c,_,I),O?.($.sourceEvent,_,I),k||L?.($.sourceEvent,I)}}}).filter($=>{const z=$.target;return!$.button&&(!y||!Jo(z,`.${y}`,b))&&(!g||Jo(z,g,b))});m.call(T)}function v(){m?.on(".drag",null)}return{update:C,destroy:v}}function Qc(e,n,s){const r=[],i={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const o of n.values())pr(i,Xn(o))>0&&r.push(o);return r}const Jc=250;function ed(e,n,s,r){let i=[],o=1/0;const a=Qc(e,s,n+Jc);for(const c of a){const l=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const d of l){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:h,y:f}=In(c,d,d.position,!0),m=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));m>n||(m<o?(i=[{...d,x:h,y:f}],o=m):m===o&&i.push({...d,x:h,y:f}))}}if(!i.length)return null;if(i.length>1){const c=r.type==="source"?"target":"source";return i.find(l=>l.type===c)??i[0]}return i[0]}function Ti(e,n,s,r,i,o=!1){const a=r.get(e);if(!a)return null;const c=i==="strict"?a.internals.handleBounds?.[n]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],l=(s?c?.find(d=>d.id===s):c?.[0])??null;return l&&o?{...l,...In(a,l,l.position,!0)}:l}function Ii(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function td(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const Ri=()=>!0;function nd(e,{connectionMode:n,connectionRadius:s,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:a,domNode:c,nodeLookup:l,lib:d,autoPanOnConnect:h,flowId:f,panBy:m,cancelConnection:u,onConnectStart:x,onConnect:E,onConnectEnd:C,isValidConnection:v=Ri,onReconnectEnd:y,updateConnection:g,getTransform:b,getFromHandle:j,autoPanSpeed:k,dragThreshold:M=1,handleDomNode:R}){const D=bi(e.target);let A=0,T;const{x:$,y:z}=_t(e),N=Ii(o,R),O=c?.getBoundingClientRect();let L=!1;if(!O||!N)return;const _=Ti(i,N,r,l,n);if(!_)return;let I=_t(e,O),P=!1,q=null,Y=!1,F=null;function Q(){if(!h||!O)return;const[re,fe]=mi(I,O,k);m({x:re,y:fe}),A=requestAnimationFrame(Q)}const B={..._,nodeId:i,type:N,position:_.position},S=l.get(i);let W={inProgress:!0,isValid:null,from:In(S,B,ve.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:S,to:I,toHandle:null,toPosition:Ho[B.position],toNode:null,pointer:I};function H(){L=!0,g(W),x?.(e,{nodeId:i,handleId:r,handleType:N})}M===0&&H();function K(re){if(!L){const{x:pe,y:ge}=_t(re),U=pe-$,oe=ge-z;if(!(U*U+oe*oe>M*M))return;H()}if(!j()||!B){te(re);return}const fe=b();I=_t(re,O),T=ed(jr(I,fe,!1,[1,1]),s,l,B),P||(Q(),P=!0);const J=_i(re,{handle:T,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:v,doc:D,lib:d,flowId:f,nodeLookup:l});F=J.handleDomNode,q=J.connection,Y=td(!!T,J.isValid);const Z=l.get(i),ce=Z?In(Z,B,ve.Left,!0):W.from,ae={...W,from:ce,isValid:Y,to:J.toHandle&&Y?ns({x:J.toHandle.x,y:J.toHandle.y},fe):I,toHandle:J.toHandle,toPosition:Y&&J.toHandle?J.toHandle.position:Ho[B.position],toNode:J.toHandle?l.get(J.toHandle.nodeId):null,pointer:I};g(ae),W=ae}function te(re){if(!("touches"in re&&re.touches.length>0)){if(L){(T||F)&&q&&Y&&E?.(q);const{inProgress:fe,...J}=W,Z={...J,toPosition:W.toHandle?W.toPosition:null};C?.(re,Z),o&&y?.(re,Z)}u(),cancelAnimationFrame(A),P=!1,Y=!1,q=null,F=null,D.removeEventListener("mousemove",K),D.removeEventListener("mouseup",te),D.removeEventListener("touchmove",K),D.removeEventListener("touchend",te)}}D.addEventListener("mousemove",K),D.addEventListener("mouseup",te),D.addEventListener("touchmove",K),D.addEventListener("touchend",te)}function _i(e,{handle:n,connectionMode:s,fromNodeId:r,fromHandleId:i,fromType:o,doc:a,lib:c,flowId:l,isValidConnection:d=Ri,nodeLookup:h}){const f=o==="target",m=n?a.querySelector(`.${c}-flow__handle[data-id="${l}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:u,y:x}=_t(e),E=a.elementFromPoint(u,x),C=E?.classList.contains(`${c}-flow__handle`)?E:m,v={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const y=Ii(void 0,C),g=C.getAttribute("data-nodeid"),b=C.getAttribute("data-handleid"),j=C.classList.contains("connectable"),k=C.classList.contains("connectableend");if(!g||!y)return v;const M={source:f?g:r,sourceHandle:f?b:i,target:f?r:g,targetHandle:f?i:b};v.connection=M;const D=j&&k&&(s===Gn.Strict?f&&y==="source"||!f&&y==="target":g!==r||b!==i);v.isValid=D&&d(M),v.toHandle=Ti(g,y,b,h,s,!0)}return v}const Hs={onPointerDown:nd,isValid:_i};function rd({domNode:e,panZoom:n,getTransform:s,getViewScale:r}){const i=ht(e);function o({translateExtent:c,width:l,height:d,zoomStep:h=1,pannable:f=!0,zoomable:m=!0,inversePan:u=!1}){const x=g=>{if(g.sourceEvent.type!=="wheel"||!n)return;const b=s(),j=g.sourceEvent.ctrlKey&&gr()?10:1,k=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*h,M=b[2]*Math.pow(2,k*j);n.scaleTo(M)};let E=[0,0];const C=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(E=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},v=g=>{const b=s();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!n)return;const j=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],k=[j[0]-E[0],j[1]-E[1]];E=j;const M=r()*Math.max(b[2],Math.log(b[2]))*(u?-1:1),R={x:b[0]-k[0]*M,y:b[1]-k[1]*M},D=[[0,0],[l,d]];n.setViewportConstrained({x:R.x,y:R.y,zoom:b[2]},D,c)},y=ai().on("start",C).on("zoom",f?v:null).on("zoom.wheel",m?x:null);i.call(y,{})}function a(){i.on("zoom",null)}return{update:o,destroy:a,pointer:It}}const cs=e=>({x:e.x,y:e.y,zoom:e.k}),Ss=({x:e,y:n,zoom:s})=>Ys.translate(e,n).scale(s),Vn=(e,n)=>e.target.closest(`.${n}`),Li=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),sd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Es=(e,n=0,s=sd,r=()=>{})=>{const i=typeof n=="number"&&n>0;return i||r(),i?e.transition().duration(n).ease(s).on("end",r):e},Ai=e=>{const n=e.ctrlKey&&gr()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function od({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return h=>{if(Vn(h,n))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const f=s.property("__zoom").k||1;if(h.ctrlKey&&a){const C=It(h),v=Ai(h),y=f*Math.pow(2,v);r.scaleTo(s,y,C,h);return}const m=h.deltaMode===1?20:1;let u=i===Mn.Vertical?0:h.deltaX*m,x=i===Mn.Horizontal?0:h.deltaY*m;!gr()&&h.shiftKey&&i!==Mn.Vertical&&(u=h.deltaY*m,x=0),r.translateBy(s,-(u/f)*o,-(x/f)*o,{internal:!0});const E=cs(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(h,E),e.panScrollTimeout=setTimeout(()=>{d?.(h,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c?.(h,E))}}function ad({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(r,i){const o=r.type==="wheel",a=!n&&o&&!r.ctrlKey,c=Vn(r,e);if(r.ctrlKey&&o&&c&&r.preventDefault(),a||c)return null;r.preventDefault(),s.call(this,r,i)}}function id({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return r=>{if(r.sourceEvent?.internal)return;const i=cs(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(r.sourceEvent,i)}}function ld({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:r,onPanZoom:i}){return o=>{e.usedRightMouseButton=!!(s&&Li(n,e.mouseButton??0)),o.sourceEvent?.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!o.sourceEvent?.internal&&i?.(o.sourceEvent,cs(o.transform))}}function cd({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,o&&Li(n,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const c=cs(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(a.sourceEvent,c)},s?150:0)}}}function dd({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:d,connectionInProgress:h}){return f=>{const m=e||n,u=s&&f.ctrlKey,x=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Vn(f,`${d}-flow__node`)||Vn(f,`${d}-flow__edge`)))return!0;if(!r&&!m&&!i&&!o&&!s||a||h&&!x||Vn(f,c)&&x||Vn(f,l)&&(!x||i&&x&&!e)||!s&&f.ctrlKey&&x)return!1;if(!s&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!m&&!i&&!u&&x||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const E=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||x)&&E}}function ud({domNode:e,minZoom:n,maxZoom:s,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),f=ai().scaleExtent([n,s]).translateExtent(r),m=ht(e).call(f);y({x:i.x,y:i.y,zoom:Un(i.zoom,n,s)},[[0,0],[h.width,h.height]],r);const u=m.on("wheel.zoom"),x=m.on("dblclick.zoom");f.wheelDelta(Ai);function E(T,$){return m?new Promise(z=>{f?.interpolate($?.interpolate==="linear"?ks:Zr).transform(Es(m,$?.duration,$?.ease,()=>z(!0)),T)}):Promise.resolve(!1)}function C({noWheelClassName:T,noPanClassName:$,onPaneContextMenu:z,userSelectionActive:N,panOnScroll:O,panOnDrag:L,panOnScrollMode:_,panOnScrollSpeed:I,preventScrolling:P,zoomOnPinch:q,zoomOnScroll:Y,zoomOnDoubleClick:F,zoomActivationKeyPressed:Q,lib:B,onTransformChange:S,connectionInProgress:V,paneClickDistance:W,selectionOnDrag:H}){N&&!d.isZoomingOrPanning&&v();const K=O&&!Q&&!N;f.clickDistance(H?1/0:!Rt(W)||W<0?0:W);const te=K?od({zoomPanValues:d,noWheelClassName:T,d3Selection:m,d3Zoom:f,panOnScrollMode:_,panOnScrollSpeed:I,zoomOnPinch:q,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:c}):ad({noWheelClassName:T,preventScrolling:P,d3ZoomHandler:u});if(m.on("wheel.zoom",te,{passive:!1}),!N){const fe=id({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:a});f.on("start",fe);const J=ld({zoomPanValues:d,panOnDrag:L,onPaneContextMenu:!!z,onPanZoom:o,onTransformChange:S});f.on("zoom",J);const Z=cd({zoomPanValues:d,panOnDrag:L,panOnScroll:O,onPaneContextMenu:z,onPanZoomEnd:c,onDraggingChange:l});f.on("end",Z)}const re=dd({zoomActivationKeyPressed:Q,panOnDrag:L,zoomOnScroll:Y,panOnScroll:O,zoomOnDoubleClick:F,zoomOnPinch:q,userSelectionActive:N,noPanClassName:$,noWheelClassName:T,lib:B,connectionInProgress:V});f.filter(re),F?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function v(){f.on("zoom",null)}async function y(T,$,z){const N=Ss(T),O=f?.constrain()(N,$,z);return O&&await E(O),new Promise(L=>L(O))}async function g(T,$){const z=Ss(T);return await E(z,$),new Promise(N=>N(z))}function b(T){if(m){const $=Ss(T),z=m.property("__zoom");(z.k!==T.zoom||z.x!==T.x||z.y!==T.y)&&f?.transform(m,$,null,{sync:!0})}}function j(){const T=m?rc(m.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function k(T,$){return m?new Promise(z=>{f?.interpolate($?.interpolate==="linear"?ks:Zr).scaleTo(Es(m,$?.duration,$?.ease,()=>z(!0)),T)}):Promise.resolve(!1)}function M(T,$){return m?new Promise(z=>{f?.interpolate($?.interpolate==="linear"?ks:Zr).scaleBy(Es(m,$?.duration,$?.ease,()=>z(!0)),T)}):Promise.resolve(!1)}function R(T){f?.scaleExtent(T)}function D(T){f?.translateExtent(T)}function A(T){const $=!Rt(T)||T<0?0:T;f?.clickDistance($)}return{update:C,destroy:v,setViewport:g,setViewportConstrained:y,getViewport:j,scaleTo:k,scaleBy:M,setScaleExtent:R,setTranslateExtent:D,syncViewport:b,setClickDistance:A}}var Qn;(function(e){e.Line="line",e.Handle="handle"})(Qn||(Qn={}));function fd({width:e,prevWidth:n,height:s,prevHeight:r,affectsX:i,affectsY:o}){const a=e-n,c=s-r,l=[a>0?1:a<0?-1:0,c>0?1:c<0?-1:0];return a&&i&&(l[0]=l[0]*-1),c&&o&&(l[1]=l[1]*-1),l}function ea(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:r,affectsY:i}}function dn(e,n){return Math.max(0,n-e)}function un(e,n){return Math.max(0,e-n)}function Wr(e,n,s){return Math.max(0,n-e,e-s)}function ta(e,n){return e?!n:n}function hd(e,n,s,r,i,o,a,c){let{affectsX:l,affectsY:d}=n;const{isHorizontal:h,isVertical:f}=n,m=h&&f,{xSnapped:u,ySnapped:x}=s,{minWidth:E,maxWidth:C,minHeight:v,maxHeight:y}=r,{x:g,y:b,width:j,height:k,aspectRatio:M}=e;let R=Math.floor(h?u-e.pointerX:0),D=Math.floor(f?x-e.pointerY:0);const A=j+(l?-R:R),T=k+(d?-D:D),$=-o[0]*j,z=-o[1]*k;let N=Wr(A,E,C),O=Wr(T,v,y);if(a){let I=0,P=0;l&&R<0?I=dn(g+R+$,a[0][0]):!l&&R>0&&(I=un(g+A+$,a[1][0])),d&&D<0?P=dn(b+D+z,a[0][1]):!d&&D>0&&(P=un(b+T+z,a[1][1])),N=Math.max(N,I),O=Math.max(O,P)}if(c){let I=0,P=0;l&&R>0?I=un(g+R,c[0][0]):!l&&R<0&&(I=dn(g+A,c[1][0])),d&&D>0?P=un(b+D,c[0][1]):!d&&D<0&&(P=dn(b+T,c[1][1])),N=Math.max(N,I),O=Math.max(O,P)}if(i){if(h){const I=Wr(A/M,v,y)*M;if(N=Math.max(N,I),a){let P=0;!l&&!d||l&&!d&&m?P=un(b+z+A/M,a[1][1])*M:P=dn(b+z+(l?R:-R)/M,a[0][1])*M,N=Math.max(N,P)}if(c){let P=0;!l&&!d||l&&!d&&m?P=dn(b+A/M,c[1][1])*M:P=un(b+(l?R:-R)/M,c[0][1])*M,N=Math.max(N,P)}}if(f){const I=Wr(T*M,E,C)/M;if(O=Math.max(O,I),a){let P=0;!l&&!d||d&&!l&&m?P=un(g+T*M+$,a[1][0])/M:P=dn(g+(d?D:-D)*M+$,a[0][0])/M,O=Math.max(O,P)}if(c){let P=0;!l&&!d||d&&!l&&m?P=dn(g+T*M,c[1][0])/M:P=un(g+(d?D:-D)*M,c[0][0])/M,O=Math.max(O,P)}}}D=D+(D<0?O:-O),R=R+(R<0?N:-N),i&&(m?A>T*M?D=(ta(l,d)?-R:R)/M:R=(ta(l,d)?-D:D)*M:h?(D=R/M,d=l):(R=D*M,l=d));const L=l?g+R:g,_=d?b+D:b;return{width:j+(l?-R:R),height:k+(d?-D:D),x:o[0]*R*(l?-1:1)+L,y:o[1]*D*(d?-1:1)+_}}const Di={width:0,height:0,x:0,y:0},md={...Di,pointerX:0,pointerY:0,aspectRatio:1};function pd(e){return[[0,0],[e.measured.width,e.measured.height]]}function gd(e,n,s){const r=n.position.x+e.position.x,i=n.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,c=s[0]*o,l=s[1]*a;return[[r-c,i-l],[r+o-c,i+a-l]]}function xd({domNode:e,nodeId:n,getStoreItems:s,onChange:r,onEnd:i}){const o=ht(e);let a={controlDirection:ea("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:d,boundaries:h,keepAspectRatio:f,resizeDirection:m,onResizeStart:u,onResize:x,onResizeEnd:E,shouldResize:C}){let v={...Di},y={...md};a={boundaries:h,resizeDirection:m,keepAspectRatio:f,controlDirection:ea(d)};let g,b=null,j=[],k,M,R,D=!1;const A=oi().on("start",T=>{const{nodeLookup:$,transform:z,snapGrid:N,snapToGrid:O,nodeOrigin:L,paneDomNode:_}=s();if(g=$.get(n),!g)return;b=_?.getBoundingClientRect()??null;const{xSnapped:I,ySnapped:P}=cr(T.sourceEvent,{transform:z,snapGrid:N,snapToGrid:O,containerBounds:b});v={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},y={...v,pointerX:I,pointerY:P,aspectRatio:v.width/v.height},k=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(k=$.get(g.parentId),M=k&&g.extent==="parent"?pd(k):void 0),j=[],R=void 0;for(const[q,Y]of $)if(Y.parentId===n&&(j.push({id:q,position:{...Y.position},extent:Y.extent}),Y.extent==="parent"||Y.expandParent)){const F=gd(Y,g,Y.origin??L);R?R=[[Math.min(F[0][0],R[0][0]),Math.min(F[0][1],R[0][1])],[Math.max(F[1][0],R[1][0]),Math.max(F[1][1],R[1][1])]]:R=F}u?.(T,{...v})}).on("drag",T=>{const{transform:$,snapGrid:z,snapToGrid:N,nodeOrigin:O}=s(),L=cr(T.sourceEvent,{transform:$,snapGrid:z,snapToGrid:N,containerBounds:b}),_=[];if(!g)return;const{x:I,y:P,width:q,height:Y}=v,F={},Q=g.origin??O,{width:B,height:S,x:V,y:W}=hd(y,a.controlDirection,L,a.boundaries,a.keepAspectRatio,Q,M,R),H=B!==q,K=S!==Y,te=V!==I&&H,re=W!==P&&K;if(!te&&!re&&!H&&!K)return;if((te||re||Q[0]===1||Q[1]===1)&&(F.x=te?V:v.x,F.y=re?W:v.y,v.x=F.x,v.y=F.y,j.length>0)){const ce=V-I,ae=W-P;for(const pe of j)pe.position={x:pe.position.x-ce+Q[0]*(B-q),y:pe.position.y-ae+Q[1]*(S-Y)},_.push(pe)}if((H||K)&&(F.width=H&&(!a.resizeDirection||a.resizeDirection==="horizontal")?B:v.width,F.height=K&&(!a.resizeDirection||a.resizeDirection==="vertical")?S:v.height,v.width=F.width,v.height=F.height),k&&g.expandParent){const ce=Q[0]*(F.width??0);F.x&&F.x<ce&&(v.x=ce,y.x=y.x-(F.x-ce));const ae=Q[1]*(F.height??0);F.y&&F.y<ae&&(v.y=ae,y.y=y.y-(F.y-ae))}const fe=fd({width:v.width,prevWidth:q,height:v.height,prevHeight:Y,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),J={...v,direction:fe};C?.(T,J)!==!1&&(D=!0,x?.(T,J),r(F,_))}).on("end",T=>{D&&(E?.(T,{...v}),i?.({...v}),D=!1)});o.call(A)}function l(){o.on(".drag",null)}return{update:c,destroy:l}}var Ms={exports:{}},Ts={};var na;function bd(){if(na)return Ts;na=1;var e=Vl(),n=Wl();function s(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var r=typeof Object.is=="function"?Object.is:s,i=n.useSyncExternalStore,o=e.useRef,a=e.useEffect,c=e.useMemo,l=e.useDebugValue;return Ts.useSyncExternalStoreWithSelector=function(d,h,f,m,u){var x=o(null);if(x.current===null){var E={hasValue:!1,value:null};x.current=E}else E=x.current;x=c(function(){function v(k){if(!y){if(y=!0,g=k,k=m(k),u!==void 0&&E.hasValue){var M=E.value;if(u(M,k))return b=M}return b=k}if(M=b,r(g,k))return M;var R=m(k);return u!==void 0&&u(M,R)?(g=k,M):(g=k,b=R)}var y=!1,g,b,j=f===void 0?null:f;return[function(){return v(h())},j===null?void 0:function(){return v(j())}]},[h,f,m,u]);var C=i(d,x[0],x[1]);return a(function(){E.hasValue=!0,E.value=C},[C]),l(C),C},Ts}var ra;function yd(){return ra||(ra=1,Ms.exports=bd()),Ms.exports}var vd=yd();const wd=Fl(vd),kd={},sa=e=>{let n;const s=new Set,r=(h,f)=>{const m=typeof h=="function"?h(n):h;if(!Object.is(m,n)){const u=n;n=f??(typeof m!="object"||m===null)?m:Object.assign({},n,m),s.forEach(x=>x(n,u))}},i=()=>n,l={setState:r,getState:i,getInitialState:()=>d,subscribe:h=>(s.add(h),()=>s.delete(h)),destroy:()=>{(kd?"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."),s.clear()}},d=n=e(r,i,l);return l},jd=e=>e?sa(e):sa,{useDebugValue:Nd}=Yl,{useSyncExternalStoreWithSelector:Cd}=wd,Sd=e=>e;function Pi(e,n=Sd,s){const r=Cd(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return Nd(r),r}const oa=(e,n)=>{const s=jd(e),r=(i,o=n)=>Pi(s,i,o);return Object.assign(r,s),r},Ed=(e,n)=>e?oa(e,n):oa;function qe(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[r,i]of e)if(!Object.is(i,n.get(r)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const r of e)if(!n.has(r))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const r of s)if(!Object.prototype.hasOwnProperty.call(n,r)||!Object.is(e[r],n[r]))return!1;return!0}const ds=p.createContext(null),Md=ds.Provider,$i=Wt.error001();function _e(e,n){const s=p.useContext(ds);if(s===null)throw new Error($i);return Pi(s,e,n)}function Oe(){const e=p.useContext(ds);if(e===null)throw new Error($i);return p.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const aa={display:"none"},Td={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Bi="react-flow__node-desc",Oi="react-flow__edge-desc",Id="react-flow__aria-live",Rd=e=>e.ariaLiveMessage,_d=e=>e.ariaLabelConfig;function Ld({rfId:e}){const n=_e(Rd);return t.jsx("div",{id:`${Id}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Td,children:n})}function Ad({rfId:e,disableKeyboardA11y:n}){const s=_e(_d);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Bi}-${e}`,style:aa,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${Oi}-${e}`,style:aa,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(Ld,{rfId:e})]})}const us=p.forwardRef(({position:e="top-left",children:n,className:s,style:r,...i},o)=>{const a=`${e}`.split("-");return t.jsx("div",{className:Ye(["react-flow__panel",s,...a]),style:r,ref:o,...i,children:n})});us.displayName="Panel";function Dd({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(us,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Pd=e=>{const n=[],s=[];for(const[,r]of e.nodeLookup)r.selected&&n.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&s.push(r);return{selectedNodes:n,selectedEdges:s}},Fr=e=>e.id;function $d(e,n){return qe(e.selectedNodes.map(Fr),n.selectedNodes.map(Fr))&&qe(e.selectedEdges.map(Fr),n.selectedEdges.map(Fr))}function Bd({onSelectionChange:e}){const n=Oe(),{selectedNodes:s,selectedEdges:r}=_e(Pd,$d);return p.useEffect(()=>{const i={nodes:s,edges:r};e?.(i),n.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[s,r,e]),null}const Od=e=>!!e.onSelectionChangeHandlers;function zd({onSelectionChange:e}){const n=_e(Od);return e||n?t.jsx(Bd,{onSelectionChange:e}):null}const zi=[0,0],Hd={x:0,y:0,zoom:1},qd=["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"],ia=[...qd,"rfId"],Vd=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}),la={translateExtent:hr,nodeOrigin:zi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Wd(e){const{setNodes:n,setEdges:s,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:l}=_e(Vd,qe),d=Oe();p.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{h.current=la,c()}),[]);const h=p.useRef(la);return p.useEffect(()=>{for(const f of ia){const m=e[f],u=h.current[f];m!==u&&(typeof e[f]>"u"||(f==="nodes"?n(m):f==="edges"?s(m):f==="minZoom"?r(m):f==="maxZoom"?i(m):f==="translateExtent"?o(m):f==="nodeExtent"?a(m):f==="ariaLabelConfig"?d.setState({ariaLabelConfig:Tc(m)}):f==="fitView"?d.setState({fitViewQueued:m}):f==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[f]:m})))}h.current=e},ia.map(f=>e[f])),null}function ca(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Fd(e){const[n,s]=p.useState(e==="system"?null:e);return p.useEffect(()=>{if(e!=="system"){s(e);return}const r=ca(),i=()=>s(r?.matches?"dark":"light");return i(),r?.addEventListener("change",i),()=>{r?.removeEventListener("change",i)}},[e]),n!==null?n:ca()?.matches?"dark":"light"}const da=typeof document<"u"?document:null;function xr(e=null,n={target:da,actInsideInputWithModifier:!0}){const[s,r]=p.useState(!1),i=p.useRef(!1),o=p.useRef(new Set([])),[a,c]=p.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
1
+ import{y as Vl,z as Wl,x as Fl,R as Yl,r as p,j as t,u as $e,l as le,B as Gl,a as yr,k as Kl,n as kt,P as He,b as Ul,c as Xl,m as Zl,d as Ls,w as mt,C as Tt,E as Or,p as zr,M as Ql,i as Jl,F as qn,q as ur,G as Qa,A as Fs,H as Ao,J as As,K as Do,L as Ds,Q as Po,U as $o,V as Bo,O as ec,W as Ja,X as ei,Y as tc}from"./index-C_QhfMcC.js";import{ContentRenderer as nc}from"./ContentRenderer-DxsnJJRX.js";import{s as ht,e as ti,f as Ys,T as vs,g as ws,t as rc}from"./transform-CpIVI4vC.js";import{i as ks}from"./value-DIujSiJ7.js";import{C as ni}from"./CommentInput-C-niUbUY.js";function sc(e){let n;for(;n=e.sourceEvent;)e=n;return e}function It(e,n){if(e=sc(e),n===void 0&&(n=e.currentTarget),n){var s=n.ownerSVGElement||n;if(s.createSVGPoint){var r=s.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(n.getScreenCTM().inverse()),[r.x,r.y]}if(n.getBoundingClientRect){var i=n.getBoundingClientRect();return[e.clientX-i.left-n.clientLeft,e.clientY-i.top-n.clientTop]}}return[e.pageX,e.pageY]}const oc={passive:!1},fr={capture:!0,passive:!1};function js(e){e.stopImmediatePropagation()}function Yn(e){e.preventDefault(),e.stopImmediatePropagation()}function ri(e){var n=e.document.documentElement,s=ht(e).on("dragstart.drag",Yn,fr);"onselectstart"in n?s.on("selectstart.drag",Yn,fr):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function si(e,n){var s=e.document.documentElement,r=ht(e).on("dragstart.drag",null);n&&(r.on("click.drag",Yn,fr),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in s?r.on("selectstart.drag",null):(s.style.MozUserSelect=s.__noselect,delete s.__noselect)}const Hr=e=>()=>e;function Ps(e,{sourceEvent:n,subject:s,target:r,identifier:i,active:o,x:a,y:c,dx:l,dy:d,dispatch:h}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:s,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:h}})}Ps.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ac(e){return!e.ctrlKey&&!e.button}function ic(){return this.parentNode}function lc(e,n){return n??{x:e.x,y:e.y}}function cc(){return navigator.maxTouchPoints||"ontouchstart"in this}function oi(){var e=ac,n=ic,s=lc,r=cc,i={},o=ti("start","drag","end"),a=0,c,l,d,h,f=0;function m(b){b.on("mousedown.drag",u).filter(r).on("touchstart.drag",C).on("touchmove.drag",v,oc).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function u(b,j){if(!(h||!e.call(this,b,j))){var k=g(this,n.call(this,b,j),b,j,"mouse");k&&(ht(b.view).on("mousemove.drag",x,fr).on("mouseup.drag",E,fr),ri(b.view),js(b),d=!1,c=b.clientX,l=b.clientY,k("start",b))}}function x(b){if(Yn(b),!d){var j=b.clientX-c,k=b.clientY-l;d=j*j+k*k>f}i.mouse("drag",b)}function E(b){ht(b.view).on("mousemove.drag mouseup.drag",null),si(b.view,d),Yn(b),i.mouse("end",b)}function C(b,j){if(e.call(this,b,j)){var k=b.changedTouches,M=n.call(this,b,j),R=k.length,D,A;for(D=0;D<R;++D)(A=g(this,M,b,j,k[D].identifier,k[D]))&&(js(b),A("start",b,k[D]))}}function v(b){var j=b.changedTouches,k=j.length,M,R;for(M=0;M<k;++M)(R=i[j[M].identifier])&&(Yn(b),R("drag",b,j[M]))}function y(b){var j=b.changedTouches,k=j.length,M,R;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),M=0;M<k;++M)(R=i[j[M].identifier])&&(js(b),R("end",b,j[M]))}function g(b,j,k,M,R,D){var A=o.copy(),T=It(D||k,j),$,z,N;if((N=s.call(b,new Ps("beforestart",{sourceEvent:k,target:m,identifier:R,active:a,x:T[0],y:T[1],dx:0,dy:0,dispatch:A}),M))!=null)return $=N.x-T[0]||0,z=N.y-T[1]||0,function O(L,_,I){var P=T,q;switch(L){case"start":i[R]=O,q=a++;break;case"end":delete i[R],--a;case"drag":T=It(I||_,j),q=a;break}A.call(L,b,new Ps(L,{sourceEvent:_,subject:N,target:m,identifier:R,active:q,x:T[0]+$,y:T[1]+z,dx:T[0]-P[0],dy:T[1]-P[1],dispatch:A}),M)}}return m.filter=function(b){return arguments.length?(e=typeof b=="function"?b:Hr(!!b),m):e},m.container=function(b){return arguments.length?(n=typeof b=="function"?b:Hr(b),m):n},m.subject=function(b){return arguments.length?(s=typeof b=="function"?b:Hr(b),m):s},m.touchable=function(b){return arguments.length?(r=typeof b=="function"?b:Hr(!!b),m):r},m.on=function(){var b=o.on.apply(o,arguments);return b===o?m:b},m.clickDistance=function(b){return arguments.length?(f=(b=+b)*b,m):Math.sqrt(f)},m}var dc=1e-12;function Oo(e){return((e=Math.exp(e))+1/e)/2}function uc(e){return((e=Math.exp(e))-1/e)/2}function fc(e){return((e=Math.exp(2*e))-1)/(e+1)}const Zr=(function e(n,s,r){function i(o,a){var c=o[0],l=o[1],d=o[2],h=a[0],f=a[1],m=a[2],u=h-c,x=f-l,E=u*u+x*x,C,v;if(E<dc)v=Math.log(m/d)/n,C=function(M){return[c+M*u,l+M*x,d*Math.exp(n*M*v)]};else{var y=Math.sqrt(E),g=(m*m-d*d+r*E)/(2*d*s*y),b=(m*m-d*d-r*E)/(2*m*s*y),j=Math.log(Math.sqrt(g*g+1)-g),k=Math.log(Math.sqrt(b*b+1)-b);v=(k-j)/n,C=function(M){var R=M*v,D=Oo(j),A=d/(s*y)*(D*fc(n*R+j)-uc(j));return[c+A*u,l+A*x,d*D/Oo(n*R+j)]}}return C.duration=v*1e3*n/Math.SQRT2,C}return i.rho=function(o){var a=Math.max(.001,+o),c=a*a,l=c*c;return e(a,c,l)},i})(Math.SQRT2,2,4),qr=e=>()=>e;function hc(e,{sourceEvent:n,target:s,transform:r,dispatch:i}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:s,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:i}})}function Ns(e){e.stopImmediatePropagation()}function lr(e){e.preventDefault(),e.stopImmediatePropagation()}function mc(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function pc(){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 zo(){return this.__zoom||Ys}function gc(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function xc(){return navigator.maxTouchPoints||"ontouchstart"in this}function bc(e,n,s){var r=e.invertX(n[0][0])-s[0][0],i=e.invertX(n[1][0])-s[1][0],o=e.invertY(n[0][1])-s[0][1],a=e.invertY(n[1][1])-s[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function ai(){var e=mc,n=pc,s=bc,r=gc,i=xc,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],c=250,l=Zr,d=ti("start","zoom","end"),h,f,m,u=500,x=150,E=0,C=10;function v(N){N.property("__zoom",zo).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",A).filter(i).on("touchstart.zoom",T).on("touchmove.zoom",$).on("touchend.zoom touchcancel.zoom",z).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(N,O,L,_){var I=N.selection?N.selection():N;I.property("__zoom",zo),N!==I?j(N,O,L,_):I.interrupt().each(function(){k(this,arguments).event(_).start().zoom(null,typeof O=="function"?O.apply(this,arguments):O).end()})},v.scaleBy=function(N,O,L,_){v.scaleTo(N,function(){var I=this.__zoom.k,P=typeof O=="function"?O.apply(this,arguments):O;return I*P},L,_)},v.scaleTo=function(N,O,L,_){v.transform(N,function(){var I=n.apply(this,arguments),P=this.__zoom,q=L==null?b(I):typeof L=="function"?L.apply(this,arguments):L,Y=P.invert(q),F=typeof O=="function"?O.apply(this,arguments):O;return s(g(y(P,F),q,Y),I,a)},L,_)},v.translateBy=function(N,O,L,_){v.transform(N,function(){return s(this.__zoom.translate(typeof O=="function"?O.apply(this,arguments):O,typeof L=="function"?L.apply(this,arguments):L),n.apply(this,arguments),a)},null,_)},v.translateTo=function(N,O,L,_,I){v.transform(N,function(){var P=n.apply(this,arguments),q=this.__zoom,Y=_==null?b(P):typeof _=="function"?_.apply(this,arguments):_;return s(Ys.translate(Y[0],Y[1]).scale(q.k).translate(typeof O=="function"?-O.apply(this,arguments):-O,typeof L=="function"?-L.apply(this,arguments):-L),P,a)},_,I)};function y(N,O){return O=Math.max(o[0],Math.min(o[1],O)),O===N.k?N:new vs(O,N.x,N.y)}function g(N,O,L){var _=O[0]-L[0]*N.k,I=O[1]-L[1]*N.k;return _===N.x&&I===N.y?N:new vs(N.k,_,I)}function b(N){return[(+N[0][0]+ +N[1][0])/2,(+N[0][1]+ +N[1][1])/2]}function j(N,O,L,_){N.on("start.zoom",function(){k(this,arguments).event(_).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(_).end()}).tween("zoom",function(){var I=this,P=arguments,q=k(I,P).event(_),Y=n.apply(I,P),F=L==null?b(Y):typeof L=="function"?L.apply(I,P):L,Q=Math.max(Y[1][0]-Y[0][0],Y[1][1]-Y[0][1]),B=I.__zoom,S=typeof O=="function"?O.apply(I,P):O,V=l(B.invert(F).concat(Q/B.k),S.invert(F).concat(Q/S.k));return function(W){if(W===1)W=S;else{var H=V(W),K=Q/H[2];W=new vs(K,F[0]-H[0]*K,F[1]-H[1]*K)}q.zoom(null,W)}})}function k(N,O,L){return!L&&N.__zooming||new M(N,O)}function M(N,O){this.that=N,this.args=O,this.active=0,this.sourceEvent=null,this.extent=n.apply(N,O),this.taps=0}M.prototype={event:function(N){return N&&(this.sourceEvent=N),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(N,O){return this.mouse&&N!=="mouse"&&(this.mouse[1]=O.invert(this.mouse[0])),this.touch0&&N!=="touch"&&(this.touch0[1]=O.invert(this.touch0[0])),this.touch1&&N!=="touch"&&(this.touch1[1]=O.invert(this.touch1[0])),this.that.__zoom=O,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(N){var O=ht(this.that).datum();d.call(N,this.that,new hc(N,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:d}),O)}};function R(N,...O){if(!e.apply(this,arguments))return;var L=k(this,O).event(N),_=this.__zoom,I=Math.max(o[0],Math.min(o[1],_.k*Math.pow(2,r.apply(this,arguments)))),P=It(N);if(L.wheel)(L.mouse[0][0]!==P[0]||L.mouse[0][1]!==P[1])&&(L.mouse[1]=_.invert(L.mouse[0]=P)),clearTimeout(L.wheel);else{if(_.k===I)return;L.mouse=[P,_.invert(P)],ws(this),L.start()}lr(N),L.wheel=setTimeout(q,x),L.zoom("mouse",s(g(y(_,I),L.mouse[0],L.mouse[1]),L.extent,a));function q(){L.wheel=null,L.end()}}function D(N,...O){if(m||!e.apply(this,arguments))return;var L=N.currentTarget,_=k(this,O,!0).event(N),I=ht(N.view).on("mousemove.zoom",F,!0).on("mouseup.zoom",Q,!0),P=It(N,L),q=N.clientX,Y=N.clientY;ri(N.view),Ns(N),_.mouse=[P,this.__zoom.invert(P)],ws(this),_.start();function F(B){if(lr(B),!_.moved){var S=B.clientX-q,V=B.clientY-Y;_.moved=S*S+V*V>E}_.event(B).zoom("mouse",s(g(_.that.__zoom,_.mouse[0]=It(B,L),_.mouse[1]),_.extent,a))}function Q(B){I.on("mousemove.zoom mouseup.zoom",null),si(B.view,_.moved),lr(B),_.event(B).end()}}function A(N,...O){if(e.apply(this,arguments)){var L=this.__zoom,_=It(N.changedTouches?N.changedTouches[0]:N,this),I=L.invert(_),P=L.k*(N.shiftKey?.5:2),q=s(g(y(L,P),_,I),n.apply(this,O),a);lr(N),c>0?ht(this).transition().duration(c).call(j,q,_,N):ht(this).call(v.transform,q,_,N)}}function T(N,...O){if(e.apply(this,arguments)){var L=N.touches,_=L.length,I=k(this,O,N.changedTouches.length===_).event(N),P,q,Y,F;for(Ns(N),q=0;q<_;++q)Y=L[q],F=It(Y,this),F=[F,this.__zoom.invert(F),Y.identifier],I.touch0?!I.touch1&&I.touch0[2]!==F[2]&&(I.touch1=F,I.taps=0):(I.touch0=F,P=!0,I.taps=1+!!h);h&&(h=clearTimeout(h)),P&&(I.taps<2&&(f=F[0],h=setTimeout(function(){h=null},u)),ws(this),I.start())}}function $(N,...O){if(this.__zooming){var L=k(this,O).event(N),_=N.changedTouches,I=_.length,P,q,Y,F;for(lr(N),P=0;P<I;++P)q=_[P],Y=It(q,this),L.touch0&&L.touch0[2]===q.identifier?L.touch0[0]=Y:L.touch1&&L.touch1[2]===q.identifier&&(L.touch1[0]=Y);if(q=L.that.__zoom,L.touch1){var Q=L.touch0[0],B=L.touch0[1],S=L.touch1[0],V=L.touch1[1],W=(W=S[0]-Q[0])*W+(W=S[1]-Q[1])*W,H=(H=V[0]-B[0])*H+(H=V[1]-B[1])*H;q=y(q,Math.sqrt(W/H)),Y=[(Q[0]+S[0])/2,(Q[1]+S[1])/2],F=[(B[0]+V[0])/2,(B[1]+V[1])/2]}else if(L.touch0)Y=L.touch0[0],F=L.touch0[1];else return;L.zoom("touch",s(g(q,Y,F),L.extent,a))}}function z(N,...O){if(this.__zooming){var L=k(this,O).event(N),_=N.changedTouches,I=_.length,P,q;for(Ns(N),m&&clearTimeout(m),m=setTimeout(function(){m=null},u),P=0;P<I;++P)q=_[P],L.touch0&&L.touch0[2]===q.identifier?delete L.touch0:L.touch1&&L.touch1[2]===q.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(q=It(q,this),Math.hypot(f[0]-q[0],f[1]-q[1])<C)){var Y=ht(this).on("dblclick.zoom");Y&&Y.apply(this,arguments)}}}return v.wheelDelta=function(N){return arguments.length?(r=typeof N=="function"?N:qr(+N),v):r},v.filter=function(N){return arguments.length?(e=typeof N=="function"?N:qr(!!N),v):e},v.touchable=function(N){return arguments.length?(i=typeof N=="function"?N:qr(!!N),v):i},v.extent=function(N){return arguments.length?(n=typeof N=="function"?N:qr([[+N[0][0],+N[0][1]],[+N[1][0],+N[1][1]]]),v):n},v.scaleExtent=function(N){return arguments.length?(o[0]=+N[0],o[1]=+N[1],v):[o[0],o[1]]},v.translateExtent=function(N){return arguments.length?(a[0][0]=+N[0][0],a[1][0]=+N[1][0],a[0][1]=+N[0][1],a[1][1]=+N[1][1],v):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},v.constrain=function(N){return arguments.length?(s=N,v):s},v.duration=function(N){return arguments.length?(c=+N,v):c},v.interpolate=function(N){return arguments.length?(l=N,v):l},v.on=function(){var N=d.on.apply(d,arguments);return N===d?v:N},v.clickDistance=function(N){return arguments.length?(E=(N=+N)*N,v):Math.sqrt(E)},v.tapDistance=function(N){return arguments.length?(C=+N,v):C},v}function Ye(e){if(typeof e=="string"||typeof e=="number")return""+e;let n="";if(Array.isArray(e))for(let s=0,r;s<e.length;s++)(r=Ye(e[s]))!==""&&(n+=(n&&" ")+r);else for(let s in e)e[s]&&(n+=(n&&" ")+s);return n}const Wt={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:n,sourceHandle:s,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?s:r}", edge id: ${n}.`,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."},hr=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ii=["Enter"," ","Escape"],li={"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:n,y:s})=>`Moved selected node ${e}. New position, x: ${n}, y: ${s}`,"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 Gn;(function(e){e.Strict="strict",e.Loose="loose"})(Gn||(Gn={}));var Mn;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Mn||(Mn={}));var mr;(function(e){e.Partial="partial",e.Full="full"})(mr||(mr={}));const ci={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var fn;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(fn||(fn={}));var Kn;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Kn||(Kn={}));var ve;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(ve||(ve={}));const Ho={[ve.Left]:ve.Right,[ve.Right]:ve.Left,[ve.Top]:ve.Bottom,[ve.Bottom]:ve.Top};function di(e){return e===null?null:e?"valid":"invalid"}const ui=e=>"id"in e&&"source"in e&&"target"in e,yc=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Gs=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),vr=(e,n=[0,0])=>{const{width:s,height:r}=rn(e),i=e.origin??n,o=s*i[0],a=r*i[1];return{x:e.position.x-o,y:e.position.y-a}},vc=(e,n={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const s=e.reduce((r,i)=>{const o=typeof i=="string";let a=!n.nodeLookup&&!o?i:void 0;n.nodeLookup&&(a=o?n.nodeLookup.get(i):Gs(i)?i:n.nodeLookup.get(i.id));const c=a?ts(a,n.nodeOrigin):{x:0,y:0,x2:0,y2:0};return is(r,c)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return ls(s)},wr=(e,n={})=>{let s={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(n.filter===void 0||n.filter(i))&&(s=is(s,ts(i)),r=!0)}),r?ls(s):{x:0,y:0,width:0,height:0}},Ks=(e,n,[s,r,i]=[0,0,1],o=!1,a=!1)=>{const c={...jr(n,[s,r,i]),width:n.width/i,height:n.height/i},l=[];for(const d of e.values()){const{measured:h,selectable:f=!0,hidden:m=!1}=d;if(a&&!f||m)continue;const u=h.width??d.width??d.initialWidth??null,x=h.height??d.height??d.initialHeight??null,E=pr(c,Xn(d)),C=(u??0)*(x??0),v=o&&E>0;(!d.internals.handleBounds||v||E>=C||d.dragging)&&l.push(d)}return l},wc=(e,n)=>{const s=new Set;return e.forEach(r=>{s.add(r.id)}),n.filter(r=>s.has(r.source)||s.has(r.target))};function kc(e,n){const s=new Map,r=n?.nodes?new Set(n.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&(n?.includeHiddenNodes||!i.hidden)&&(!r||r.has(i.id))&&s.set(i.id,i)}),s}async function jc({nodes:e,width:n,height:s,panZoom:r,minZoom:i,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const c=kc(e,a),l=wr(c),d=Us(l,n,s,a?.minZoom??i,a?.maxZoom??o,a?.padding??.1);return await r.setViewport(d,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),Promise.resolve(!0)}function fi({nodeId:e,nextPosition:n,nodeLookup:s,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const a=s.get(e),c=a.parentId?s.get(a.parentId):void 0,{x:l,y:d}=c?c.internals.positionAbsolute:{x:0,y:0},h=a.origin??r;let f=a.extent||i;if(a.extent==="parent"&&!a.expandParent)if(!c)o?.("005",Wt.error005());else{const u=c.measured.width,x=c.measured.height;u&&x&&(f=[[l,d],[l+u,d+x]])}else c&&Zn(a.extent)&&(f=[[a.extent[0][0]+l,a.extent[0][1]+d],[a.extent[1][0]+l,a.extent[1][1]+d]]);const m=Zn(f)?Tn(n,f,a.measured):n;return(a.measured.width===void 0||a.measured.height===void 0)&&o?.("015",Wt.error015()),{position:{x:m.x-l+(a.measured.width??0)*h[0],y:m.y-d+(a.measured.height??0)*h[1]},positionAbsolute:m}}async function Nc({nodesToRemove:e=[],edgesToRemove:n=[],nodes:s,edges:r,onBeforeDelete:i}){const o=new Set(e.map(m=>m.id)),a=[];for(const m of s){if(m.deletable===!1)continue;const u=o.has(m.id),x=!u&&m.parentId&&a.find(E=>E.id===m.parentId);(u||x)&&a.push(m)}const c=new Set(n.map(m=>m.id)),l=r.filter(m=>m.deletable!==!1),h=wc(a,l);for(const m of l)c.has(m.id)&&!h.find(x=>x.id===m.id)&&h.push(m);if(!i)return{edges:h,nodes:a};const f=await i({nodes:a,edges:h});return typeof f=="boolean"?f?{edges:h,nodes:a}:{edges:[],nodes:[]}:f}const Un=(e,n=0,s=1)=>Math.min(Math.max(e,n),s),Tn=(e={x:0,y:0},n,s)=>({x:Un(e.x,n[0][0],n[1][0]-(s?.width??0)),y:Un(e.y,n[0][1],n[1][1]-(s?.height??0))});function hi(e,n,s){const{width:r,height:i}=rn(s),{x:o,y:a}=s.internals.positionAbsolute;return Tn(e,[[o,a],[o+r,a+i]],n)}const qo=(e,n,s)=>e<n?Un(Math.abs(e-n),1,n)/n:e>s?-Un(Math.abs(e-s),1,n)/n:0,mi=(e,n,s=15,r=40)=>{const i=qo(e.x,r,n.width-r)*s,o=qo(e.y,r,n.height-r)*s;return[i,o]},is=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),$s=({x:e,y:n,width:s,height:r})=>({x:e,y:n,x2:e+s,y2:n+r}),ls=({x:e,y:n,x2:s,y2:r})=>({x:e,y:n,width:s-e,height:r-n}),Xn=(e,n=[0,0])=>{const{x:s,y:r}=Gs(e)?e.internals.positionAbsolute:vr(e,n);return{x:s,y:r,width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}},ts=(e,n=[0,0])=>{const{x:s,y:r}=Gs(e)?e.internals.positionAbsolute:vr(e,n);return{x:s,y:r,x2:s+(e.measured?.width??e.width??e.initialWidth??0),y2:r+(e.measured?.height??e.height??e.initialHeight??0)}},pi=(e,n)=>ls(is($s(e),$s(n))),pr=(e,n)=>{const s=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),r=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(s*r)},Vo=e=>Rt(e.width)&&Rt(e.height)&&Rt(e.x)&&Rt(e.y),Rt=e=>!isNaN(e)&&isFinite(e),Cc=(e,n)=>{},kr=(e,n=[1,1])=>({x:n[0]*Math.round(e.x/n[0]),y:n[1]*Math.round(e.y/n[1])}),jr=({x:e,y:n},[s,r,i],o=!1,a=[1,1])=>{const c={x:(e-s)/i,y:(n-r)/i};return o?kr(c,a):c},ns=({x:e,y:n},[s,r,i])=>({x:e*i+s,y:n*i+r});function Hn(e,n){if(typeof e=="number")return Math.floor((n-n/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(s)}if(typeof e=="string"&&e.endsWith("%")){const s=parseFloat(e);if(!Number.isNaN(s))return Math.floor(n*s*.01)}return console.error(`[React Flow] The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function Sc(e,n,s){if(typeof e=="string"||typeof e=="number"){const r=Hn(e,s),i=Hn(e,n);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=Hn(e.top??e.y??0,s),i=Hn(e.bottom??e.y??0,s),o=Hn(e.left??e.x??0,n),a=Hn(e.right??e.x??0,n);return{top:r,right:a,bottom:i,left:o,x:o+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function Ec(e,n,s,r,i,o){const{x:a,y:c}=ns(e,[n,s,r]),{x:l,y:d}=ns({x:e.x+e.width,y:e.y+e.height},[n,s,r]),h=i-l,f=o-d;return{left:Math.floor(a),top:Math.floor(c),right:Math.floor(h),bottom:Math.floor(f)}}const Us=(e,n,s,r,i,o)=>{const a=Sc(o,n,s),c=(n-a.x)/e.width,l=(s-a.y)/e.height,d=Math.min(c,l),h=Un(d,r,i),f=e.x+e.width/2,m=e.y+e.height/2,u=n/2-f*h,x=s/2-m*h,E=Ec(e,u,x,h,n,s),C={left:Math.min(E.left-a.left,0),top:Math.min(E.top-a.top,0),right:Math.min(E.right-a.right,0),bottom:Math.min(E.bottom-a.bottom,0)};return{x:u-C.left+C.right,y:x-C.top+C.bottom,zoom:h}},gr=()=>typeof navigator<"u"&&navigator?.userAgent?.indexOf("Mac")>=0;function Zn(e){return e!=null&&e!=="parent"}function rn(e){return{width:e.measured?.width??e.width??e.initialWidth??0,height:e.measured?.height??e.height??e.initialHeight??0}}function gi(e){return(e.measured?.width??e.width??e.initialWidth)!==void 0&&(e.measured?.height??e.height??e.initialHeight)!==void 0}function xi(e,n={width:0,height:0},s,r,i){const o={...e},a=r.get(s);if(a){const c=a.origin||i;o.x+=a.internals.positionAbsolute.x-(n.width??0)*c[0],o.y+=a.internals.positionAbsolute.y-(n.height??0)*c[1]}return o}function Wo(e,n){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}function Mc(){let e,n;return{promise:new Promise((r,i)=>{e=r,n=i}),resolve:e,reject:n}}function Tc(e){return{...li,...e||{}}}function cr(e,{snapGrid:n=[0,0],snapToGrid:s=!1,transform:r,containerBounds:i}){const{x:o,y:a}=_t(e),c=jr({x:o-(i?.left??0),y:a-(i?.top??0)},r),{x:l,y:d}=s?kr(c,n):c;return{xSnapped:l,ySnapped:d,...c}}const Xs=e=>({width:e.offsetWidth,height:e.offsetHeight}),bi=e=>e?.getRootNode?.()||window?.document,Ic=["INPUT","SELECT","TEXTAREA"];function yi(e){const n=e.composedPath?.()?.[0]||e.target;return n?.nodeType!==1?!1:Ic.includes(n.nodeName)||n.hasAttribute("contenteditable")||!!n.closest(".nokey")}const vi=e=>"clientX"in e,_t=(e,n)=>{const s=vi(e),r=s?e.clientX:e.touches?.[0].clientX,i=s?e.clientY:e.touches?.[0].clientY;return{x:r-(n?.left??0),y:i-(n?.top??0)}},Fo=(e,n,s,r,i)=>{const o=n.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(a=>{const c=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:i,position:a.getAttribute("data-handlepos"),x:(c.left-s.left)/r,y:(c.top-s.top)/r,...Xs(a)}})};function wi({sourceX:e,sourceY:n,targetX:s,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:a,targetControlY:c}){const l=e*.125+i*.375+a*.375+s*.125,d=n*.125+o*.375+c*.375+r*.125,h=Math.abs(l-e),f=Math.abs(d-n);return[l,d,h,f]}function Vr(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Yo({pos:e,x1:n,y1:s,x2:r,y2:i,c:o}){switch(e){case ve.Left:return[n-Vr(n-r,o),s];case ve.Right:return[n+Vr(r-n,o),s];case ve.Top:return[n,s-Vr(s-i,o)];case ve.Bottom:return[n,s+Vr(i-s,o)]}}function ki({sourceX:e,sourceY:n,sourcePosition:s=ve.Bottom,targetX:r,targetY:i,targetPosition:o=ve.Top,curvature:a=.25}){const[c,l]=Yo({pos:s,x1:e,y1:n,x2:r,y2:i,c:a}),[d,h]=Yo({pos:o,x1:r,y1:i,x2:e,y2:n,c:a}),[f,m,u,x]=wi({sourceX:e,sourceY:n,targetX:r,targetY:i,sourceControlX:c,sourceControlY:l,targetControlX:d,targetControlY:h});return[`M${e},${n} C${c},${l} ${d},${h} ${r},${i}`,f,m,u,x]}function ji({sourceX:e,sourceY:n,targetX:s,targetY:r}){const i=Math.abs(s-e)/2,o=s<e?s+i:s-i,a=Math.abs(r-n)/2,c=r<n?r+a:r-a;return[o,c,i,a]}function Rc({sourceNode:e,targetNode:n,selected:s=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const a=i&&s?r+1e3:r,c=Math.max(e.parentId||i&&e.selected?e.internals.z:0,n.parentId||i&&n.selected?n.internals.z:0);return a+c}function _c({sourceNode:e,targetNode:n,width:s,height:r,transform:i}){const o=is(ts(e),ts(n));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-i[0]/i[2],y:-i[1]/i[2],width:s/i[2],height:r/i[2]};return pr(a,ls(o))>0}const Lc=({source:e,sourceHandle:n,target:s,targetHandle:r})=>`xy-edge__${e}${n||""}-${s}${r||""}`,Ac=(e,n)=>n.some(s=>s.source===e.source&&s.target===e.target&&(s.sourceHandle===e.sourceHandle||!s.sourceHandle&&!e.sourceHandle)&&(s.targetHandle===e.targetHandle||!s.targetHandle&&!e.targetHandle)),Dc=(e,n,s={})=>{if(!e.source||!e.target)return n;const r=s.getEdgeId||Lc;let i;return ui(e)?i={...e}:i={...e,id:r(e)},Ac(i,n)?n:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,n.concat(i))};function Ni({sourceX:e,sourceY:n,targetX:s,targetY:r}){const[i,o,a,c]=ji({sourceX:e,sourceY:n,targetX:s,targetY:r});return[`M ${e},${n}L ${s},${r}`,i,o,a,c]}const Go={[ve.Left]:{x:-1,y:0},[ve.Right]:{x:1,y:0},[ve.Top]:{x:0,y:-1},[ve.Bottom]:{x:0,y:1}},Pc=({source:e,sourcePosition:n=ve.Bottom,target:s})=>n===ve.Left||n===ve.Right?e.x<s.x?{x:1,y:0}:{x:-1,y:0}:e.y<s.y?{x:0,y:1}:{x:0,y:-1},Ko=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function $c({source:e,sourcePosition:n=ve.Bottom,target:s,targetPosition:r=ve.Top,center:i,offset:o,stepPosition:a}){const c=Go[n],l=Go[r],d={x:e.x+c.x*o,y:e.y+c.y*o},h={x:s.x+l.x*o,y:s.y+l.y*o},f=Pc({source:d,sourcePosition:n,target:h}),m=f.x!==0?"x":"y",u=f[m];let x=[],E,C;const v={x:0,y:0},y={x:0,y:0},[,,g,b]=ji({sourceX:e.x,sourceY:e.y,targetX:s.x,targetY:s.y});if(c[m]*l[m]===-1){m==="x"?(E=i.x??d.x+(h.x-d.x)*a,C=i.y??(d.y+h.y)/2):(E=i.x??(d.x+h.x)/2,C=i.y??d.y+(h.y-d.y)*a);const k=[{x:E,y:d.y},{x:E,y:h.y}],M=[{x:d.x,y:C},{x:h.x,y:C}];c[m]===u?x=m==="x"?k:M:x=m==="x"?M:k}else{const k=[{x:d.x,y:h.y}],M=[{x:h.x,y:d.y}];if(m==="x"?x=c.x===u?M:k:x=c.y===u?k:M,n===r){const $=Math.abs(e[m]-s[m]);if($<=o){const z=Math.min(o-1,o-$);c[m]===u?v[m]=(d[m]>e[m]?-1:1)*z:y[m]=(h[m]>s[m]?-1:1)*z}}if(n!==r){const $=m==="x"?"y":"x",z=c[m]===l[$],N=d[$]>h[$],O=d[$]<h[$];(c[m]===1&&(!z&&N||z&&O)||c[m]!==1&&(!z&&O||z&&N))&&(x=m==="x"?k:M)}const R={x:d.x+v.x,y:d.y+v.y},D={x:h.x+y.x,y:h.y+y.y},A=Math.max(Math.abs(R.x-x[0].x),Math.abs(D.x-x[0].x)),T=Math.max(Math.abs(R.y-x[0].y),Math.abs(D.y-x[0].y));A>=T?(E=(R.x+D.x)/2,C=x[0].y):(E=x[0].x,C=(R.y+D.y)/2)}return[[e,{x:d.x+v.x,y:d.y+v.y},...x,{x:h.x+y.x,y:h.y+y.y},s],E,C,g,b]}function Bc(e,n,s,r){const i=Math.min(Ko(e,n)/2,Ko(n,s)/2,r),{x:o,y:a}=n;if(e.x===o&&o===s.x||e.y===a&&a===s.y)return`L${o} ${a}`;if(e.y===a){const d=e.x<s.x?-1:1,h=e.y<s.y?1:-1;return`L ${o+i*d},${a}Q ${o},${a} ${o},${a+i*h}`}const c=e.x<s.x?1:-1,l=e.y<s.y?-1:1;return`L ${o},${a+i*l}Q ${o},${a} ${o+i*c},${a}`}function Bs({sourceX:e,sourceY:n,sourcePosition:s=ve.Bottom,targetX:r,targetY:i,targetPosition:o=ve.Top,borderRadius:a=5,centerX:c,centerY:l,offset:d=20,stepPosition:h=.5}){const[f,m,u,x,E]=$c({source:{x:e,y:n},sourcePosition:s,target:{x:r,y:i},targetPosition:o,center:{x:c,y:l},offset:d,stepPosition:h});return[f.reduce((v,y,g)=>{let b="";return g>0&&g<f.length-1?b=Bc(f[g-1],y,f[g+1],a):b=`${g===0?"M":"L"}${y.x} ${y.y}`,v+=b,v},""),m,u,x,E]}function Uo(e){return e&&!!(e.internals.handleBounds||e.handles?.length)&&!!(e.measured.width||e.width||e.initialWidth)}function Oc(e){const{sourceNode:n,targetNode:s}=e;if(!Uo(n)||!Uo(s))return null;const r=n.internals.handleBounds||Xo(n.handles),i=s.internals.handleBounds||Xo(s.handles),o=Zo(r?.source??[],e.sourceHandle),a=Zo(e.connectionMode===Gn.Strict?i?.target??[]:(i?.target??[]).concat(i?.source??[]),e.targetHandle);if(!o||!a)return e.onError?.("008",Wt.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const c=o?.position||ve.Bottom,l=a?.position||ve.Top,d=In(n,o,c),h=In(s,a,l);return{sourceX:d.x,sourceY:d.y,targetX:h.x,targetY:h.y,sourcePosition:c,targetPosition:l}}function Xo(e){if(!e)return null;const n=[],s=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?n.push(r):r.type==="target"&&s.push(r);return{source:n,target:s}}function In(e,n,s=ve.Left,r=!1){const i=(n?.x??0)+e.internals.positionAbsolute.x,o=(n?.y??0)+e.internals.positionAbsolute.y,{width:a,height:c}=n??rn(e);if(r)return{x:i+a/2,y:o+c/2};switch(n?.position??s){case ve.Top:return{x:i+a/2,y:o};case ve.Right:return{x:i+a,y:o+c/2};case ve.Bottom:return{x:i+a/2,y:o+c};case ve.Left:return{x:i,y:o+c/2}}}function Zo(e,n){return e&&(n?e.find(s=>s.id===n):e[0])||null}function Os(e,n){return e?typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function zc(e,{id:n,defaultColor:s,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((a,c)=>([c.markerStart||r,c.markerEnd||i].forEach(l=>{if(l&&typeof l=="object"){const d=Os(l,n);o.has(d)||(a.push({id:d,color:l.color||s,...l}),o.add(d))}}),a),[]).sort((a,c)=>a.id.localeCompare(c.id))}const Ci=1e3,Hc=10,Zs={nodeOrigin:[0,0],nodeExtent:hr,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},qc={...Zs,checkEquality:!0};function Qs(e,n){const s={...e};for(const r in n)n[r]!==void 0&&(s[r]=n[r]);return s}function Vc(e,n,s){const r=Qs(Zs,s);for(const i of e.values())if(i.parentId)eo(i,e,n,r);else{const o=vr(i,r.nodeOrigin),a=Zn(i.extent)?i.extent:r.nodeExtent,c=Tn(o,a,rn(i));i.internals.positionAbsolute=c}}function Wc(e,n){if(!e.handles)return e.measured?n?.internals.handleBounds:void 0;const s=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?s.push(o):i.type==="target"&&r.push(o)}return{source:s,target:r}}function Js(e){return e==="manual"}function zs(e,n,s,r={}){const i=Qs(qc,r),o={i:0},a=new Map(n),c=i?.elevateNodesOnSelect&&!Js(i.zIndexMode)?Ci:0;let l=e.length>0;n.clear(),s.clear();for(const d of e){let h=a.get(d.id);if(i.checkEquality&&d===h?.internals.userNode)n.set(d.id,h);else{const f=vr(d,i.nodeOrigin),m=Zn(d.extent)?d.extent:i.nodeExtent,u=Tn(f,m,rn(d));h={...i.defaults,...d,measured:{width:d.measured?.width,height:d.measured?.height},internals:{positionAbsolute:u,handleBounds:Wc(d,h),z:Si(d,c,i.zIndexMode),userNode:d}},n.set(d.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(l=!1),d.parentId&&eo(h,n,s,r,o)}return l}function Fc(e,n){if(!e.parentId)return;const s=n.get(e.parentId);s?s.set(e.id,e):n.set(e.parentId,new Map([[e.id,e]]))}function eo(e,n,s,r,i){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:c,zIndexMode:l}=Qs(Zs,r),d=e.parentId,h=n.get(d);if(!h){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}Fc(e,s),i&&!h.parentId&&h.internals.rootParentIndex===void 0&&l==="auto"&&(h.internals.rootParentIndex=++i.i,h.internals.z=h.internals.z+i.i*Hc),i&&h.internals.rootParentIndex!==void 0&&(i.i=h.internals.rootParentIndex);const f=o&&!Js(l)?Ci:0,{x:m,y:u,z:x}=Yc(e,h,a,c,f,l),{positionAbsolute:E}=e.internals,C=m!==E.x||u!==E.y;(C||x!==e.internals.z)&&n.set(e.id,{...e,internals:{...e.internals,positionAbsolute:C?{x:m,y:u}:E,z:x}})}function Si(e,n,s){const r=Rt(e.zIndex)?e.zIndex:0;return Js(s)?r:r+(e.selected?n:0)}function Yc(e,n,s,r,i,o){const{x:a,y:c}=n.internals.positionAbsolute,l=rn(e),d=vr(e,s),h=Zn(e.extent)?Tn(d,e.extent,l):d;let f=Tn({x:a+h.x,y:c+h.y},r,l);e.extent==="parent"&&(f=hi(f,l,n));const m=Si(e,i,o),u=n.internals.z??0;return{x:f.x,y:f.y,z:u>=m?u+1:m}}function to(e,n,s,r=[0,0]){const i=[],o=new Map;for(const a of e){const c=n.get(a.parentId);if(!c)continue;const l=o.get(a.parentId)?.expandedRect??Xn(c),d=pi(l,a.rect);o.set(a.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},l)=>{const d=c.internals.positionAbsolute,h=rn(c),f=c.origin??r,m=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,u=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,x=Math.max(h.width,Math.round(a.width)),E=Math.max(h.height,Math.round(a.height)),C=(x-h.width)*f[0],v=(E-h.height)*f[1];(m>0||u>0||C||v)&&(i.push({id:l,type:"position",position:{x:c.position.x-m+C,y:c.position.y-u+v}}),s.get(l)?.forEach(y=>{e.some(g=>g.id===y.id)||i.push({id:y.id,type:"position",position:{x:y.position.x+m,y:y.position.y+u}})})),(h.width<a.width||h.height<a.height||m||u)&&i.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:x+(m?f[0]*m-C:0),height:E+(u?f[1]*u-v:0)}})}),i}function Gc(e,n,s,r,i,o,a){const c=r?.querySelector(".xyflow__viewport");let l=!1;if(!c)return{changes:[],updatedInternals:l};const d=[],h=window.getComputedStyle(c),{m22:f}=new window.DOMMatrixReadOnly(h.transform),m=[];for(const u of e.values()){const x=n.get(u.id);if(!x)continue;if(x.hidden){n.set(x.id,{...x,internals:{...x.internals,handleBounds:void 0}}),l=!0;continue}const E=Xs(u.nodeElement),C=x.measured.width!==E.width||x.measured.height!==E.height;if(!!(E.width&&E.height&&(C||!x.internals.handleBounds||u.force))){const y=u.nodeElement.getBoundingClientRect(),g=Zn(x.extent)?x.extent:o;let{positionAbsolute:b}=x.internals;x.parentId&&x.extent==="parent"?b=hi(b,E,n.get(x.parentId)):g&&(b=Tn(b,g,E));const j={...x,measured:E,internals:{...x.internals,positionAbsolute:b,handleBounds:{source:Fo("source",u.nodeElement,y,f,x.id),target:Fo("target",u.nodeElement,y,f,x.id)}}};n.set(x.id,j),x.parentId&&eo(j,n,s,{nodeOrigin:i,zIndexMode:a}),l=!0,C&&(d.push({id:x.id,type:"dimensions",dimensions:E}),x.expandParent&&x.parentId&&m.push({id:x.id,parentId:x.parentId,rect:Xn(j,i)}))}}if(m.length>0){const u=to(m,n,s,i);d.push(...u)}return{changes:d,updatedInternals:l}}async function Kc({delta:e,panZoom:n,transform:s,translateExtent:r,width:i,height:o}){if(!n||!e.x&&!e.y)return Promise.resolve(!1);const a=await n.setViewportConstrained({x:s[0]+e.x,y:s[1]+e.y,zoom:s[2]},[[0,0],[i,o]],r),c=!!a&&(a.x!==s[0]||a.y!==s[1]||a.k!==s[2]);return Promise.resolve(c)}function Qo(e,n,s,r,i,o){let a=i;const c=r.get(a)||new Map;r.set(a,c.set(s,n)),a=`${i}-${e}`;const l=r.get(a)||new Map;if(r.set(a,l.set(s,n)),o){a=`${i}-${e}-${o}`;const d=r.get(a)||new Map;r.set(a,d.set(s,n))}}function Ei(e,n,s){e.clear(),n.clear();for(const r of s){const{source:i,target:o,sourceHandle:a=null,targetHandle:c=null}=r,l={edgeId:r.id,source:i,target:o,sourceHandle:a,targetHandle:c},d=`${i}-${a}--${o}-${c}`,h=`${o}-${c}--${i}-${a}`;Qo("source",l,h,e,i,a),Qo("target",l,d,e,o,c),n.set(r.id,r)}}function Mi(e,n){if(!e.parentId)return!1;const s=n.get(e.parentId);return s?s.selected?!0:Mi(s,n):!1}function Jo(e,n,s){let r=e;do{if(r?.matches?.(n))return!0;if(r===s)return!1;r=r?.parentElement}while(r);return!1}function Uc(e,n,s,r){const i=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!Mi(a,e))&&(a.draggable||n&&typeof a.draggable>"u")){const c=e.get(o);c&&i.set(o,{id:o,position:c.position||{x:0,y:0},distance:{x:s.x-c.internals.positionAbsolute.x,y:s.y-c.internals.positionAbsolute.y},extent:c.extent,parentId:c.parentId,origin:c.origin,expandParent:c.expandParent,internals:{positionAbsolute:c.internals.positionAbsolute||{x:0,y:0}},measured:{width:c.measured.width??0,height:c.measured.height??0}})}return i}function Cs({nodeId:e,dragItems:n,nodeLookup:s,dragging:r=!0}){const i=[];for(const[a,c]of n){const l=s.get(a)?.internals.userNode;l&&i.push({...l,position:c.position,dragging:r})}if(!e)return[i[0],i];const o=s.get(e)?.internals.userNode;return[o?{...o,position:n.get(e)?.position||o.position,dragging:r}:i[0],i]}function Xc({dragItems:e,snapGrid:n,x:s,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:s-i.distance.x,y:r-i.distance.y},a=kr(o,n);return{x:a.x-o.x,y:a.y-o.y}}function Zc({onNodeMouseDown:e,getStoreItems:n,onDragStart:s,onDrag:r,onDragStop:i}){let o={x:null,y:null},a=0,c=new Map,l=!1,d={x:0,y:0},h=null,f=!1,m=null,u=!1,x=!1,E=null;function C({noDragClassName:y,handleSelector:g,domNode:b,isSelectable:j,nodeId:k,nodeClickDistance:M=0}){m=ht(b);function R({x:$,y:z}){const{nodeLookup:N,nodeExtent:O,snapGrid:L,snapToGrid:_,nodeOrigin:I,onNodeDrag:P,onSelectionDrag:q,onError:Y,updateNodePositions:F}=n();o={x:$,y:z};let Q=!1;const B=c.size>1,S=B&&O?$s(wr(c)):null,V=B&&_?Xc({dragItems:c,snapGrid:L,x:$,y:z}):null;for(const[W,H]of c){if(!N.has(W))continue;let K={x:$-H.distance.x,y:z-H.distance.y};_&&(K=V?{x:Math.round(K.x+V.x),y:Math.round(K.y+V.y)}:kr(K,L));let te=null;if(B&&O&&!H.extent&&S){const{positionAbsolute:J}=H.internals,Z=J.x-S.x+O[0][0],ce=J.x+H.measured.width-S.x2+O[1][0],ae=J.y-S.y+O[0][1],pe=J.y+H.measured.height-S.y2+O[1][1];te=[[Z,ae],[ce,pe]]}const{position:re,positionAbsolute:fe}=fi({nodeId:W,nextPosition:K,nodeLookup:N,nodeExtent:te||O,nodeOrigin:I,onError:Y});Q=Q||H.position.x!==re.x||H.position.y!==re.y,H.position=re,H.internals.positionAbsolute=fe}if(x=x||Q,!!Q&&(F(c,!0),E&&(r||P||!k&&q))){const[W,H]=Cs({nodeId:k,dragItems:c,nodeLookup:N});r?.(E,c,W,H),P?.(E,W,H),k||q?.(E,H)}}async function D(){if(!h)return;const{transform:$,panBy:z,autoPanSpeed:N,autoPanOnNodeDrag:O}=n();if(!O){l=!1,cancelAnimationFrame(a);return}const[L,_]=mi(d,h,N);(L!==0||_!==0)&&(o.x=(o.x??0)-L/$[2],o.y=(o.y??0)-_/$[2],await z({x:L,y:_})&&R(o)),a=requestAnimationFrame(D)}function A($){const{nodeLookup:z,multiSelectionActive:N,nodesDraggable:O,transform:L,snapGrid:_,snapToGrid:I,selectNodesOnDrag:P,onNodeDragStart:q,onSelectionDragStart:Y,unselectNodesAndEdges:F}=n();f=!0,(!P||!j)&&!N&&k&&(z.get(k)?.selected||F()),j&&P&&k&&e?.(k);const Q=cr($.sourceEvent,{transform:L,snapGrid:_,snapToGrid:I,containerBounds:h});if(o=Q,c=Uc(z,O,Q,k),c.size>0&&(s||q||!k&&Y)){const[B,S]=Cs({nodeId:k,dragItems:c,nodeLookup:z});s?.($.sourceEvent,c,B,S),q?.($.sourceEvent,B,S),k||Y?.($.sourceEvent,S)}}const T=oi().clickDistance(M).on("start",$=>{const{domNode:z,nodeDragThreshold:N,transform:O,snapGrid:L,snapToGrid:_}=n();h=z?.getBoundingClientRect()||null,u=!1,x=!1,E=$.sourceEvent,N===0&&A($),o=cr($.sourceEvent,{transform:O,snapGrid:L,snapToGrid:_,containerBounds:h}),d=_t($.sourceEvent,h)}).on("drag",$=>{const{autoPanOnNodeDrag:z,transform:N,snapGrid:O,snapToGrid:L,nodeDragThreshold:_,nodeLookup:I}=n(),P=cr($.sourceEvent,{transform:N,snapGrid:O,snapToGrid:L,containerBounds:h});if(E=$.sourceEvent,($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1||k&&!I.has(k))&&(u=!0),!u){if(!l&&z&&f&&(l=!0,D()),!f){const q=_t($.sourceEvent,h),Y=q.x-d.x,F=q.y-d.y;Math.sqrt(Y*Y+F*F)>_&&A($)}(o.x!==P.xSnapped||o.y!==P.ySnapped)&&c&&f&&(d=_t($.sourceEvent,h),R(P))}}).on("end",$=>{if(!(!f||u)&&(l=!1,f=!1,cancelAnimationFrame(a),c.size>0)){const{nodeLookup:z,updateNodePositions:N,onNodeDragStop:O,onSelectionDragStop:L}=n();if(x&&(N(c,!1),x=!1),i||O||!k&&L){const[_,I]=Cs({nodeId:k,dragItems:c,nodeLookup:z,dragging:!1});i?.($.sourceEvent,c,_,I),O?.($.sourceEvent,_,I),k||L?.($.sourceEvent,I)}}}).filter($=>{const z=$.target;return!$.button&&(!y||!Jo(z,`.${y}`,b))&&(!g||Jo(z,g,b))});m.call(T)}function v(){m?.on(".drag",null)}return{update:C,destroy:v}}function Qc(e,n,s){const r=[],i={x:e.x-s,y:e.y-s,width:s*2,height:s*2};for(const o of n.values())pr(i,Xn(o))>0&&r.push(o);return r}const Jc=250;function ed(e,n,s,r){let i=[],o=1/0;const a=Qc(e,s,n+Jc);for(const c of a){const l=[...c.internals.handleBounds?.source??[],...c.internals.handleBounds?.target??[]];for(const d of l){if(r.nodeId===d.nodeId&&r.type===d.type&&r.id===d.id)continue;const{x:h,y:f}=In(c,d,d.position,!0),m=Math.sqrt(Math.pow(h-e.x,2)+Math.pow(f-e.y,2));m>n||(m<o?(i=[{...d,x:h,y:f}],o=m):m===o&&i.push({...d,x:h,y:f}))}}if(!i.length)return null;if(i.length>1){const c=r.type==="source"?"target":"source";return i.find(l=>l.type===c)??i[0]}return i[0]}function Ti(e,n,s,r,i,o=!1){const a=r.get(e);if(!a)return null;const c=i==="strict"?a.internals.handleBounds?.[n]:[...a.internals.handleBounds?.source??[],...a.internals.handleBounds?.target??[]],l=(s?c?.find(d=>d.id===s):c?.[0])??null;return l&&o?{...l,...In(a,l,l.position,!0)}:l}function Ii(e,n){return e||(n?.classList.contains("target")?"target":n?.classList.contains("source")?"source":null)}function td(e,n){let s=null;return n?s=!0:e&&!n&&(s=!1),s}const Ri=()=>!0;function nd(e,{connectionMode:n,connectionRadius:s,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:a,domNode:c,nodeLookup:l,lib:d,autoPanOnConnect:h,flowId:f,panBy:m,cancelConnection:u,onConnectStart:x,onConnect:E,onConnectEnd:C,isValidConnection:v=Ri,onReconnectEnd:y,updateConnection:g,getTransform:b,getFromHandle:j,autoPanSpeed:k,dragThreshold:M=1,handleDomNode:R}){const D=bi(e.target);let A=0,T;const{x:$,y:z}=_t(e),N=Ii(o,R),O=c?.getBoundingClientRect();let L=!1;if(!O||!N)return;const _=Ti(i,N,r,l,n);if(!_)return;let I=_t(e,O),P=!1,q=null,Y=!1,F=null;function Q(){if(!h||!O)return;const[re,fe]=mi(I,O,k);m({x:re,y:fe}),A=requestAnimationFrame(Q)}const B={..._,nodeId:i,type:N,position:_.position},S=l.get(i);let W={inProgress:!0,isValid:null,from:In(S,B,ve.Left,!0),fromHandle:B,fromPosition:B.position,fromNode:S,to:I,toHandle:null,toPosition:Ho[B.position],toNode:null,pointer:I};function H(){L=!0,g(W),x?.(e,{nodeId:i,handleId:r,handleType:N})}M===0&&H();function K(re){if(!L){const{x:pe,y:ge}=_t(re),U=pe-$,oe=ge-z;if(!(U*U+oe*oe>M*M))return;H()}if(!j()||!B){te(re);return}const fe=b();I=_t(re,O),T=ed(jr(I,fe,!1,[1,1]),s,l,B),P||(Q(),P=!0);const J=_i(re,{handle:T,connectionMode:n,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:v,doc:D,lib:d,flowId:f,nodeLookup:l});F=J.handleDomNode,q=J.connection,Y=td(!!T,J.isValid);const Z=l.get(i),ce=Z?In(Z,B,ve.Left,!0):W.from,ae={...W,from:ce,isValid:Y,to:J.toHandle&&Y?ns({x:J.toHandle.x,y:J.toHandle.y},fe):I,toHandle:J.toHandle,toPosition:Y&&J.toHandle?J.toHandle.position:Ho[B.position],toNode:J.toHandle?l.get(J.toHandle.nodeId):null,pointer:I};g(ae),W=ae}function te(re){if(!("touches"in re&&re.touches.length>0)){if(L){(T||F)&&q&&Y&&E?.(q);const{inProgress:fe,...J}=W,Z={...J,toPosition:W.toHandle?W.toPosition:null};C?.(re,Z),o&&y?.(re,Z)}u(),cancelAnimationFrame(A),P=!1,Y=!1,q=null,F=null,D.removeEventListener("mousemove",K),D.removeEventListener("mouseup",te),D.removeEventListener("touchmove",K),D.removeEventListener("touchend",te)}}D.addEventListener("mousemove",K),D.addEventListener("mouseup",te),D.addEventListener("touchmove",K),D.addEventListener("touchend",te)}function _i(e,{handle:n,connectionMode:s,fromNodeId:r,fromHandleId:i,fromType:o,doc:a,lib:c,flowId:l,isValidConnection:d=Ri,nodeLookup:h}){const f=o==="target",m=n?a.querySelector(`.${c}-flow__handle[data-id="${l}-${n?.nodeId}-${n?.id}-${n?.type}"]`):null,{x:u,y:x}=_t(e),E=a.elementFromPoint(u,x),C=E?.classList.contains(`${c}-flow__handle`)?E:m,v={handleDomNode:C,isValid:!1,connection:null,toHandle:null};if(C){const y=Ii(void 0,C),g=C.getAttribute("data-nodeid"),b=C.getAttribute("data-handleid"),j=C.classList.contains("connectable"),k=C.classList.contains("connectableend");if(!g||!y)return v;const M={source:f?g:r,sourceHandle:f?b:i,target:f?r:g,targetHandle:f?i:b};v.connection=M;const D=j&&k&&(s===Gn.Strict?f&&y==="source"||!f&&y==="target":g!==r||b!==i);v.isValid=D&&d(M),v.toHandle=Ti(g,y,b,h,s,!0)}return v}const Hs={onPointerDown:nd,isValid:_i};function rd({domNode:e,panZoom:n,getTransform:s,getViewScale:r}){const i=ht(e);function o({translateExtent:c,width:l,height:d,zoomStep:h=1,pannable:f=!0,zoomable:m=!0,inversePan:u=!1}){const x=g=>{if(g.sourceEvent.type!=="wheel"||!n)return;const b=s(),j=g.sourceEvent.ctrlKey&&gr()?10:1,k=-g.sourceEvent.deltaY*(g.sourceEvent.deltaMode===1?.05:g.sourceEvent.deltaMode?1:.002)*h,M=b[2]*Math.pow(2,k*j);n.scaleTo(M)};let E=[0,0];const C=g=>{(g.sourceEvent.type==="mousedown"||g.sourceEvent.type==="touchstart")&&(E=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY])},v=g=>{const b=s();if(g.sourceEvent.type!=="mousemove"&&g.sourceEvent.type!=="touchmove"||!n)return;const j=[g.sourceEvent.clientX??g.sourceEvent.touches[0].clientX,g.sourceEvent.clientY??g.sourceEvent.touches[0].clientY],k=[j[0]-E[0],j[1]-E[1]];E=j;const M=r()*Math.max(b[2],Math.log(b[2]))*(u?-1:1),R={x:b[0]-k[0]*M,y:b[1]-k[1]*M},D=[[0,0],[l,d]];n.setViewportConstrained({x:R.x,y:R.y,zoom:b[2]},D,c)},y=ai().on("start",C).on("zoom",f?v:null).on("zoom.wheel",m?x:null);i.call(y,{})}function a(){i.on("zoom",null)}return{update:o,destroy:a,pointer:It}}const cs=e=>({x:e.x,y:e.y,zoom:e.k}),Ss=({x:e,y:n,zoom:s})=>Ys.translate(e,n).scale(s),Vn=(e,n)=>e.target.closest(`.${n}`),Li=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),sd=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Es=(e,n=0,s=sd,r=()=>{})=>{const i=typeof n=="number"&&n>0;return i||r(),i?e.transition().duration(n).ease(s).on("end",r):e},Ai=e=>{const n=e.ctrlKey&&gr()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n};function od({zoomPanValues:e,noWheelClassName:n,d3Selection:s,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:c,onPanZoom:l,onPanZoomEnd:d}){return h=>{if(Vn(h,n))return h.ctrlKey&&h.preventDefault(),!1;h.preventDefault(),h.stopImmediatePropagation();const f=s.property("__zoom").k||1;if(h.ctrlKey&&a){const C=It(h),v=Ai(h),y=f*Math.pow(2,v);r.scaleTo(s,y,C,h);return}const m=h.deltaMode===1?20:1;let u=i===Mn.Vertical?0:h.deltaX*m,x=i===Mn.Horizontal?0:h.deltaY*m;!gr()&&h.shiftKey&&i!==Mn.Vertical&&(u=h.deltaY*m,x=0),r.translateBy(s,-(u/f)*o,-(x/f)*o,{internal:!0});const E=cs(s.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(l?.(h,E),e.panScrollTimeout=setTimeout(()=>{d?.(h,E),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,c?.(h,E))}}function ad({noWheelClassName:e,preventScrolling:n,d3ZoomHandler:s}){return function(r,i){const o=r.type==="wheel",a=!n&&o&&!r.ctrlKey,c=Vn(r,e);if(r.ctrlKey&&o&&c&&r.preventDefault(),a||c)return null;r.preventDefault(),s.call(this,r,i)}}function id({zoomPanValues:e,onDraggingChange:n,onPanZoomStart:s}){return r=>{if(r.sourceEvent?.internal)return;const i=cs(r.transform);e.mouseButton=r.sourceEvent?.button||0,e.isZoomingOrPanning=!0,e.prevViewport=i,r.sourceEvent?.type==="mousedown"&&n(!0),s&&s?.(r.sourceEvent,i)}}function ld({zoomPanValues:e,panOnDrag:n,onPaneContextMenu:s,onTransformChange:r,onPanZoom:i}){return o=>{e.usedRightMouseButton=!!(s&&Li(n,e.mouseButton??0)),o.sourceEvent?.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!o.sourceEvent?.internal&&i?.(o.sourceEvent,cs(o.transform))}}function cd({zoomPanValues:e,panOnDrag:n,panOnScroll:s,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return a=>{if(!a.sourceEvent?.internal&&(e.isZoomingOrPanning=!1,o&&Li(n,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const c=cs(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i?.(a.sourceEvent,c)},s?150:0)}}}function dd({zoomActivationKeyPressed:e,zoomOnScroll:n,zoomOnPinch:s,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:c,noPanClassName:l,lib:d,connectionInProgress:h}){return f=>{const m=e||n,u=s&&f.ctrlKey,x=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(Vn(f,`${d}-flow__node`)||Vn(f,`${d}-flow__edge`)))return!0;if(!r&&!m&&!i&&!o&&!s||a||h&&!x||Vn(f,c)&&x||Vn(f,l)&&(!x||i&&x&&!e)||!s&&f.ctrlKey&&x)return!1;if(!s&&f.type==="touchstart"&&f.touches?.length>1)return f.preventDefault(),!1;if(!m&&!i&&!u&&x||!r&&(f.type==="mousedown"||f.type==="touchstart")||Array.isArray(r)&&!r.includes(f.button)&&f.type==="mousedown")return!1;const E=Array.isArray(r)&&r.includes(f.button)||!f.button||f.button<=1;return(!f.ctrlKey||x)&&E}}function ud({domNode:e,minZoom:n,maxZoom:s,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:c,onDraggingChange:l}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},h=e.getBoundingClientRect(),f=ai().scaleExtent([n,s]).translateExtent(r),m=ht(e).call(f);y({x:i.x,y:i.y,zoom:Un(i.zoom,n,s)},[[0,0],[h.width,h.height]],r);const u=m.on("wheel.zoom"),x=m.on("dblclick.zoom");f.wheelDelta(Ai);function E(T,$){return m?new Promise(z=>{f?.interpolate($?.interpolate==="linear"?ks:Zr).transform(Es(m,$?.duration,$?.ease,()=>z(!0)),T)}):Promise.resolve(!1)}function C({noWheelClassName:T,noPanClassName:$,onPaneContextMenu:z,userSelectionActive:N,panOnScroll:O,panOnDrag:L,panOnScrollMode:_,panOnScrollSpeed:I,preventScrolling:P,zoomOnPinch:q,zoomOnScroll:Y,zoomOnDoubleClick:F,zoomActivationKeyPressed:Q,lib:B,onTransformChange:S,connectionInProgress:V,paneClickDistance:W,selectionOnDrag:H}){N&&!d.isZoomingOrPanning&&v();const K=O&&!Q&&!N;f.clickDistance(H?1/0:!Rt(W)||W<0?0:W);const te=K?od({zoomPanValues:d,noWheelClassName:T,d3Selection:m,d3Zoom:f,panOnScrollMode:_,panOnScrollSpeed:I,zoomOnPinch:q,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:c}):ad({noWheelClassName:T,preventScrolling:P,d3ZoomHandler:u});if(m.on("wheel.zoom",te,{passive:!1}),!N){const fe=id({zoomPanValues:d,onDraggingChange:l,onPanZoomStart:a});f.on("start",fe);const J=ld({zoomPanValues:d,panOnDrag:L,onPaneContextMenu:!!z,onPanZoom:o,onTransformChange:S});f.on("zoom",J);const Z=cd({zoomPanValues:d,panOnDrag:L,panOnScroll:O,onPaneContextMenu:z,onPanZoomEnd:c,onDraggingChange:l});f.on("end",Z)}const re=dd({zoomActivationKeyPressed:Q,panOnDrag:L,zoomOnScroll:Y,panOnScroll:O,zoomOnDoubleClick:F,zoomOnPinch:q,userSelectionActive:N,noPanClassName:$,noWheelClassName:T,lib:B,connectionInProgress:V});f.filter(re),F?m.on("dblclick.zoom",x):m.on("dblclick.zoom",null)}function v(){f.on("zoom",null)}async function y(T,$,z){const N=Ss(T),O=f?.constrain()(N,$,z);return O&&await E(O),new Promise(L=>L(O))}async function g(T,$){const z=Ss(T);return await E(z,$),new Promise(N=>N(z))}function b(T){if(m){const $=Ss(T),z=m.property("__zoom");(z.k!==T.zoom||z.x!==T.x||z.y!==T.y)&&f?.transform(m,$,null,{sync:!0})}}function j(){const T=m?rc(m.node()):{x:0,y:0,k:1};return{x:T.x,y:T.y,zoom:T.k}}function k(T,$){return m?new Promise(z=>{f?.interpolate($?.interpolate==="linear"?ks:Zr).scaleTo(Es(m,$?.duration,$?.ease,()=>z(!0)),T)}):Promise.resolve(!1)}function M(T,$){return m?new Promise(z=>{f?.interpolate($?.interpolate==="linear"?ks:Zr).scaleBy(Es(m,$?.duration,$?.ease,()=>z(!0)),T)}):Promise.resolve(!1)}function R(T){f?.scaleExtent(T)}function D(T){f?.translateExtent(T)}function A(T){const $=!Rt(T)||T<0?0:T;f?.clickDistance($)}return{update:C,destroy:v,setViewport:g,setViewportConstrained:y,getViewport:j,scaleTo:k,scaleBy:M,setScaleExtent:R,setTranslateExtent:D,syncViewport:b,setClickDistance:A}}var Qn;(function(e){e.Line="line",e.Handle="handle"})(Qn||(Qn={}));function fd({width:e,prevWidth:n,height:s,prevHeight:r,affectsX:i,affectsY:o}){const a=e-n,c=s-r,l=[a>0?1:a<0?-1:0,c>0?1:c<0?-1:0];return a&&i&&(l[0]=l[0]*-1),c&&o&&(l[1]=l[1]*-1),l}function ea(e){const n=e.includes("right")||e.includes("left"),s=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:n,isVertical:s,affectsX:r,affectsY:i}}function dn(e,n){return Math.max(0,n-e)}function un(e,n){return Math.max(0,e-n)}function Wr(e,n,s){return Math.max(0,n-e,e-s)}function ta(e,n){return e?!n:n}function hd(e,n,s,r,i,o,a,c){let{affectsX:l,affectsY:d}=n;const{isHorizontal:h,isVertical:f}=n,m=h&&f,{xSnapped:u,ySnapped:x}=s,{minWidth:E,maxWidth:C,minHeight:v,maxHeight:y}=r,{x:g,y:b,width:j,height:k,aspectRatio:M}=e;let R=Math.floor(h?u-e.pointerX:0),D=Math.floor(f?x-e.pointerY:0);const A=j+(l?-R:R),T=k+(d?-D:D),$=-o[0]*j,z=-o[1]*k;let N=Wr(A,E,C),O=Wr(T,v,y);if(a){let I=0,P=0;l&&R<0?I=dn(g+R+$,a[0][0]):!l&&R>0&&(I=un(g+A+$,a[1][0])),d&&D<0?P=dn(b+D+z,a[0][1]):!d&&D>0&&(P=un(b+T+z,a[1][1])),N=Math.max(N,I),O=Math.max(O,P)}if(c){let I=0,P=0;l&&R>0?I=un(g+R,c[0][0]):!l&&R<0&&(I=dn(g+A,c[1][0])),d&&D>0?P=un(b+D,c[0][1]):!d&&D<0&&(P=dn(b+T,c[1][1])),N=Math.max(N,I),O=Math.max(O,P)}if(i){if(h){const I=Wr(A/M,v,y)*M;if(N=Math.max(N,I),a){let P=0;!l&&!d||l&&!d&&m?P=un(b+z+A/M,a[1][1])*M:P=dn(b+z+(l?R:-R)/M,a[0][1])*M,N=Math.max(N,P)}if(c){let P=0;!l&&!d||l&&!d&&m?P=dn(b+A/M,c[1][1])*M:P=un(b+(l?R:-R)/M,c[0][1])*M,N=Math.max(N,P)}}if(f){const I=Wr(T*M,E,C)/M;if(O=Math.max(O,I),a){let P=0;!l&&!d||d&&!l&&m?P=un(g+T*M+$,a[1][0])/M:P=dn(g+(d?D:-D)*M+$,a[0][0])/M,O=Math.max(O,P)}if(c){let P=0;!l&&!d||d&&!l&&m?P=dn(g+T*M,c[1][0])/M:P=un(g+(d?D:-D)*M,c[0][0])/M,O=Math.max(O,P)}}}D=D+(D<0?O:-O),R=R+(R<0?N:-N),i&&(m?A>T*M?D=(ta(l,d)?-R:R)/M:R=(ta(l,d)?-D:D)*M:h?(D=R/M,d=l):(R=D*M,l=d));const L=l?g+R:g,_=d?b+D:b;return{width:j+(l?-R:R),height:k+(d?-D:D),x:o[0]*R*(l?-1:1)+L,y:o[1]*D*(d?-1:1)+_}}const Di={width:0,height:0,x:0,y:0},md={...Di,pointerX:0,pointerY:0,aspectRatio:1};function pd(e){return[[0,0],[e.measured.width,e.measured.height]]}function gd(e,n,s){const r=n.position.x+e.position.x,i=n.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,c=s[0]*o,l=s[1]*a;return[[r-c,i-l],[r+o-c,i+a-l]]}function xd({domNode:e,nodeId:n,getStoreItems:s,onChange:r,onEnd:i}){const o=ht(e);let a={controlDirection:ea("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function c({controlPosition:d,boundaries:h,keepAspectRatio:f,resizeDirection:m,onResizeStart:u,onResize:x,onResizeEnd:E,shouldResize:C}){let v={...Di},y={...md};a={boundaries:h,resizeDirection:m,keepAspectRatio:f,controlDirection:ea(d)};let g,b=null,j=[],k,M,R,D=!1;const A=oi().on("start",T=>{const{nodeLookup:$,transform:z,snapGrid:N,snapToGrid:O,nodeOrigin:L,paneDomNode:_}=s();if(g=$.get(n),!g)return;b=_?.getBoundingClientRect()??null;const{xSnapped:I,ySnapped:P}=cr(T.sourceEvent,{transform:z,snapGrid:N,snapToGrid:O,containerBounds:b});v={width:g.measured.width??0,height:g.measured.height??0,x:g.position.x??0,y:g.position.y??0},y={...v,pointerX:I,pointerY:P,aspectRatio:v.width/v.height},k=void 0,g.parentId&&(g.extent==="parent"||g.expandParent)&&(k=$.get(g.parentId),M=k&&g.extent==="parent"?pd(k):void 0),j=[],R=void 0;for(const[q,Y]of $)if(Y.parentId===n&&(j.push({id:q,position:{...Y.position},extent:Y.extent}),Y.extent==="parent"||Y.expandParent)){const F=gd(Y,g,Y.origin??L);R?R=[[Math.min(F[0][0],R[0][0]),Math.min(F[0][1],R[0][1])],[Math.max(F[1][0],R[1][0]),Math.max(F[1][1],R[1][1])]]:R=F}u?.(T,{...v})}).on("drag",T=>{const{transform:$,snapGrid:z,snapToGrid:N,nodeOrigin:O}=s(),L=cr(T.sourceEvent,{transform:$,snapGrid:z,snapToGrid:N,containerBounds:b}),_=[];if(!g)return;const{x:I,y:P,width:q,height:Y}=v,F={},Q=g.origin??O,{width:B,height:S,x:V,y:W}=hd(y,a.controlDirection,L,a.boundaries,a.keepAspectRatio,Q,M,R),H=B!==q,K=S!==Y,te=V!==I&&H,re=W!==P&&K;if(!te&&!re&&!H&&!K)return;if((te||re||Q[0]===1||Q[1]===1)&&(F.x=te?V:v.x,F.y=re?W:v.y,v.x=F.x,v.y=F.y,j.length>0)){const ce=V-I,ae=W-P;for(const pe of j)pe.position={x:pe.position.x-ce+Q[0]*(B-q),y:pe.position.y-ae+Q[1]*(S-Y)},_.push(pe)}if((H||K)&&(F.width=H&&(!a.resizeDirection||a.resizeDirection==="horizontal")?B:v.width,F.height=K&&(!a.resizeDirection||a.resizeDirection==="vertical")?S:v.height,v.width=F.width,v.height=F.height),k&&g.expandParent){const ce=Q[0]*(F.width??0);F.x&&F.x<ce&&(v.x=ce,y.x=y.x-(F.x-ce));const ae=Q[1]*(F.height??0);F.y&&F.y<ae&&(v.y=ae,y.y=y.y-(F.y-ae))}const fe=fd({width:v.width,prevWidth:q,height:v.height,prevHeight:Y,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),J={...v,direction:fe};C?.(T,J)!==!1&&(D=!0,x?.(T,J),r(F,_))}).on("end",T=>{D&&(E?.(T,{...v}),i?.({...v}),D=!1)});o.call(A)}function l(){o.on(".drag",null)}return{update:c,destroy:l}}var Ms={exports:{}},Ts={};var na;function bd(){if(na)return Ts;na=1;var e=Vl(),n=Wl();function s(d,h){return d===h&&(d!==0||1/d===1/h)||d!==d&&h!==h}var r=typeof Object.is=="function"?Object.is:s,i=n.useSyncExternalStore,o=e.useRef,a=e.useEffect,c=e.useMemo,l=e.useDebugValue;return Ts.useSyncExternalStoreWithSelector=function(d,h,f,m,u){var x=o(null);if(x.current===null){var E={hasValue:!1,value:null};x.current=E}else E=x.current;x=c(function(){function v(k){if(!y){if(y=!0,g=k,k=m(k),u!==void 0&&E.hasValue){var M=E.value;if(u(M,k))return b=M}return b=k}if(M=b,r(g,k))return M;var R=m(k);return u!==void 0&&u(M,R)?(g=k,M):(g=k,b=R)}var y=!1,g,b,j=f===void 0?null:f;return[function(){return v(h())},j===null?void 0:function(){return v(j())}]},[h,f,m,u]);var C=i(d,x[0],x[1]);return a(function(){E.hasValue=!0,E.value=C},[C]),l(C),C},Ts}var ra;function yd(){return ra||(ra=1,Ms.exports=bd()),Ms.exports}var vd=yd();const wd=Fl(vd),kd={},sa=e=>{let n;const s=new Set,r=(h,f)=>{const m=typeof h=="function"?h(n):h;if(!Object.is(m,n)){const u=n;n=f??(typeof m!="object"||m===null)?m:Object.assign({},n,m),s.forEach(x=>x(n,u))}},i=()=>n,l={setState:r,getState:i,getInitialState:()=>d,subscribe:h=>(s.add(h),()=>s.delete(h)),destroy:()=>{(kd?"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."),s.clear()}},d=n=e(r,i,l);return l},jd=e=>e?sa(e):sa,{useDebugValue:Nd}=Yl,{useSyncExternalStoreWithSelector:Cd}=wd,Sd=e=>e;function Pi(e,n=Sd,s){const r=Cd(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,s);return Nd(r),r}const oa=(e,n)=>{const s=jd(e),r=(i,o=n)=>Pi(s,i,o);return Object.assign(r,s),r},Ed=(e,n)=>e?oa(e,n):oa;function qe(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[r,i]of e)if(!Object.is(i,n.get(r)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const r of e)if(!n.has(r))return!1;return!0}const s=Object.keys(e);if(s.length!==Object.keys(n).length)return!1;for(const r of s)if(!Object.prototype.hasOwnProperty.call(n,r)||!Object.is(e[r],n[r]))return!1;return!0}const ds=p.createContext(null),Md=ds.Provider,$i=Wt.error001();function _e(e,n){const s=p.useContext(ds);if(s===null)throw new Error($i);return Pi(s,e,n)}function Oe(){const e=p.useContext(ds);if(e===null)throw new Error($i);return p.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const aa={display:"none"},Td={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Bi="react-flow__node-desc",Oi="react-flow__edge-desc",Id="react-flow__aria-live",Rd=e=>e.ariaLiveMessage,_d=e=>e.ariaLabelConfig;function Ld({rfId:e}){const n=_e(Rd);return t.jsx("div",{id:`${Id}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Td,children:n})}function Ad({rfId:e,disableKeyboardA11y:n}){const s=_e(_d);return t.jsxs(t.Fragment,{children:[t.jsx("div",{id:`${Bi}-${e}`,style:aa,children:n?s["node.a11yDescription.default"]:s["node.a11yDescription.keyboardDisabled"]}),t.jsx("div",{id:`${Oi}-${e}`,style:aa,children:s["edge.a11yDescription.default"]}),!n&&t.jsx(Ld,{rfId:e})]})}const us=p.forwardRef(({position:e="top-left",children:n,className:s,style:r,...i},o)=>{const a=`${e}`.split("-");return t.jsx("div",{className:Ye(["react-flow__panel",s,...a]),style:r,ref:o,...i,children:n})});us.displayName="Panel";function Dd({proOptions:e,position:n="bottom-right"}){return e?.hideAttribution?null:t.jsx(us,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:t.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Pd=e=>{const n=[],s=[];for(const[,r]of e.nodeLookup)r.selected&&n.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&s.push(r);return{selectedNodes:n,selectedEdges:s}},Fr=e=>e.id;function $d(e,n){return qe(e.selectedNodes.map(Fr),n.selectedNodes.map(Fr))&&qe(e.selectedEdges.map(Fr),n.selectedEdges.map(Fr))}function Bd({onSelectionChange:e}){const n=Oe(),{selectedNodes:s,selectedEdges:r}=_e(Pd,$d);return p.useEffect(()=>{const i={nodes:s,edges:r};e?.(i),n.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[s,r,e]),null}const Od=e=>!!e.onSelectionChangeHandlers;function zd({onSelectionChange:e}){const n=_e(Od);return e||n?t.jsx(Bd,{onSelectionChange:e}):null}const zi=[0,0],Hd={x:0,y:0,zoom:1},qd=["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"],ia=[...qd,"rfId"],Vd=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}),la={translateExtent:hr,nodeOrigin:zi,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Wd(e){const{setNodes:n,setEdges:s,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:a,reset:c,setDefaultNodesAndEdges:l}=_e(Vd,qe),d=Oe();p.useEffect(()=>(l(e.defaultNodes,e.defaultEdges),()=>{h.current=la,c()}),[]);const h=p.useRef(la);return p.useEffect(()=>{for(const f of ia){const m=e[f],u=h.current[f];m!==u&&(typeof e[f]>"u"||(f==="nodes"?n(m):f==="edges"?s(m):f==="minZoom"?r(m):f==="maxZoom"?i(m):f==="translateExtent"?o(m):f==="nodeExtent"?a(m):f==="ariaLabelConfig"?d.setState({ariaLabelConfig:Tc(m)}):f==="fitView"?d.setState({fitViewQueued:m}):f==="fitViewOptions"?d.setState({fitViewOptions:m}):d.setState({[f]:m})))}h.current=e},ia.map(f=>e[f])),null}function ca(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Fd(e){const[n,s]=p.useState(e==="system"?null:e);return p.useEffect(()=>{if(e!=="system"){s(e);return}const r=ca(),i=()=>s(r?.matches?"dark":"light");return i(),r?.addEventListener("change",i),()=>{r?.removeEventListener("change",i)}},[e]),n!==null?n:ca()?.matches?"dark":"light"}const da=typeof document<"u"?document:null;function xr(e=null,n={target:da,actInsideInputWithModifier:!0}){const[s,r]=p.useState(!1),i=p.useRef(!1),o=p.useRef(new Set([])),[a,c]=p.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(f=>typeof f=="string").map(f=>f.replace("+",`
2
2
  `).replace(`
3
3
 
4
4
  `,`
@@ -1 +1 @@
1
- import{W as ln,X as an,Y as B,$ as q,a0 as Y,a1 as un,a2 as y,a3 as tn,a4 as G,a5 as _,a6 as rn,a7 as o,a8 as on,a9 as sn,aa as fn}from"./mermaid.core-BRHCbDDt.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,I,D,v,A,$,a){var O=I-l,i=D-h,n=$-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function N(l,h,I,D,v,A,$){var a=l-I,O=h-D,i=($?A:-A)/G(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,j=(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,S=(g<0?-1:1)*G(on(0,T*T*R-P*P)),W=(P*g-m*S)/R,X=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=W-j,e=X-t,r=w-j,z=p-t;return x*x+e*e>r*r+z*z&&(W=w,X=p),{cx:W,cy:X,x01:-n,y01:-d,x11:W*(v/T-1),y11:X*(v/T-1)}}function hn(){var l=cn,h=yn,I=Y(0),D=null,v=gn,A=dn,$=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,j=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(j>tn-y)a.moveTo(s*B(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*B(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=j,S=j,W=$.apply(this,arguments)/2,X=W>y&&(D?+D.apply(this,arguments):G(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(X>y){var z=sn(X/u*q(W)),H=sn(X/s*q(W));(P-=z*2)>y?(z*=t?1:-1,R+=z,T-=z):(P=0,R=T=(f+c)/2),(S-=H*2)>y?(H*=t?1:-1,m+=H,g-=H):(S=0,m=g=(f+c)/2)}var C=s*B(m),F=s*q(m),J=u*B(T),K=u*q(T);if(w>y){var L=s*B(g),M=s*q(g),Q=u*B(R),U=u*q(R),E;if(j<an)if(E=pn(C,F,Q,U,L,M,J,K)){var V=C-E[0],Z=F-E[1],k=L-E[0],b=M-E[1],nn=1/q(fn((V*k+Z*b)/(G(V*V+Z*Z)*G(k*k+b*b)))/2),en=G(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=N(Q,U,C,F,s,x,t),r=N(L,M,J,K,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(C,F),a.arc(0,0,s,m,g,!t)):a.moveTo(C,F),!(u>y)||!(P>y)?a.lineTo(J,K):p>y?(e=N(J,K,L,M,u,-p,t),r=N(C,F,Q,U,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-an/2;return[B(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Y(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Y(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:Y(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:Y(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Y(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:Y(+n),i):A},i.padAngle=function(n){return arguments.length?($=typeof n=="function"?n:Y(+n),i):$},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{W as ln,X as an,Y as B,$ as q,a0 as Y,a1 as un,a2 as y,a3 as tn,a4 as G,a5 as _,a6 as rn,a7 as o,a8 as on,a9 as sn,aa as fn}from"./mermaid.core-BMAh3nnq.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,I,D,v,A,$,a){var O=I-l,i=D-h,n=$-v,d=a-A,u=d*O-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*O,h+u*i]}function N(l,h,I,D,v,A,$){var a=l-I,O=h-D,i=($?A:-A)/G(a*a+O*O),n=i*O,d=-i*a,u=l+n,s=h+d,f=I+n,c=D+d,j=(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,S=(g<0?-1:1)*G(on(0,T*T*R-P*P)),W=(P*g-m*S)/R,X=(-P*m-g*S)/R,w=(P*g+m*S)/R,p=(-P*m+g*S)/R,x=W-j,e=X-t,r=w-j,z=p-t;return x*x+e*e>r*r+z*z&&(W=w,X=p),{cx:W,cy:X,x01:-n,y01:-d,x11:W*(v/T-1),y11:X*(v/T-1)}}function hn(){var l=cn,h=yn,I=Y(0),D=null,v=gn,A=dn,$=mn,a=null,O=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,j=rn(c-f),t=c>f;if(a||(a=n=O()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(j>tn-y)a.moveTo(s*B(f),s*q(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*B(c),u*q(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=j,S=j,W=$.apply(this,arguments)/2,X=W>y&&(D?+D.apply(this,arguments):G(u*u+s*s)),w=_(rn(s-u)/2,+I.apply(this,arguments)),p=w,x=w,e,r;if(X>y){var z=sn(X/u*q(W)),H=sn(X/s*q(W));(P-=z*2)>y?(z*=t?1:-1,R+=z,T-=z):(P=0,R=T=(f+c)/2),(S-=H*2)>y?(H*=t?1:-1,m+=H,g-=H):(S=0,m=g=(f+c)/2)}var C=s*B(m),F=s*q(m),J=u*B(T),K=u*q(T);if(w>y){var L=s*B(g),M=s*q(g),Q=u*B(R),U=u*q(R),E;if(j<an)if(E=pn(C,F,Q,U,L,M,J,K)){var V=C-E[0],Z=F-E[1],k=L-E[0],b=M-E[1],nn=1/q(fn((V*k+Z*b)/(G(V*V+Z*Z)*G(k*k+b*b)))/2),en=G(E[0]*E[0]+E[1]*E[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}S>y?x>y?(e=N(Q,U,C,F,s,x,t),r=N(L,M,J,K,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(C,F),a.arc(0,0,s,m,g,!t)):a.moveTo(C,F),!(u>y)||!(P>y)?a.lineTo(J,K):p>y?(e=N(J,K,L,M,u,-p,t),r=N(C,F,Q,U,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-an/2;return[B(d)*n,q(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:Y(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:Y(+n),i):h},i.cornerRadius=function(n){return arguments.length?(I=typeof n=="function"?n:Y(+n),i):I},i.padRadius=function(n){return arguments.length?(D=n==null?null:typeof n=="function"?n:Y(+n),i):D},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:Y(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:Y(+n),i):A},i.padAngle=function(n){return arguments.length?($=typeof n=="function"?n:Y(+n),i):$},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};