spexcode 0.2.4 → 0.2.6

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 (69) hide show
  1. package/README.md +1 -1
  2. package/package.json +1 -1
  3. package/spec-cli/bin/spex.mjs +13 -10
  4. package/spec-cli/hooks/dispatch.sh +28 -40
  5. package/spec-cli/hooks/harness.sh +43 -7
  6. package/spec-cli/src/board.ts +2 -1
  7. package/spec-cli/src/boardCache.ts +27 -1
  8. package/spec-cli/src/boardStream.ts +5 -4
  9. package/spec-cli/src/cli.ts +93 -20
  10. package/spec-cli/src/commit-surgery.ts +81 -0
  11. package/spec-cli/src/contract-filter.ts +156 -0
  12. package/spec-cli/src/doctor.ts +11 -5
  13. package/spec-cli/src/git.ts +18 -4
  14. package/spec-cli/src/guide.ts +94 -38
  15. package/spec-cli/src/harness-select.ts +2 -2
  16. package/spec-cli/src/harness.ts +22 -8
  17. package/spec-cli/src/help.ts +28 -16
  18. package/spec-cli/src/index.ts +9 -6
  19. package/spec-cli/src/init.ts +17 -10
  20. package/spec-cli/src/issues.ts +7 -5
  21. package/spec-cli/src/layout.ts +31 -13
  22. package/spec-cli/src/lint.ts +19 -0
  23. package/spec-cli/src/localIssues.ts +16 -4
  24. package/spec-cli/src/materialize.ts +214 -144
  25. package/spec-cli/src/mentions.ts +5 -3
  26. package/spec-cli/src/plugin-harness.ts +10 -9
  27. package/spec-cli/src/ranker.ts +25 -8
  28. package/spec-cli/src/runtime-guard.ts +44 -0
  29. package/spec-cli/src/search.bench.mjs +15 -5
  30. package/spec-cli/src/sessions.ts +96 -22
  31. package/spec-cli/src/specs.ts +38 -18
  32. package/spec-cli/src/supervise.ts +2 -2
  33. package/spec-cli/src/tsx-bin.ts +6 -8
  34. package/spec-cli/src/uninstall.ts +18 -19
  35. package/spec-cli/src/worktree-sources.ts +52 -13
  36. package/spec-cli/templates/hooks/post-checkout +22 -0
  37. package/spec-cli/templates/hooks/post-merge +15 -9
  38. package/spec-cli/templates/hooks/pre-commit +10 -0
  39. package/spec-cli/templates/spec/project/.config/core/stop-gate/spec.md +1 -1
  40. package/spec-cli/templates/spec/project/.config/core/stop-gate/stop-gate.sh +26 -8
  41. package/spec-cli/templates/spec/project/.config/distill/digest.mjs +136 -0
  42. package/spec-cli/templates/spec/project/.config/distill/spec.md +74 -0
  43. package/spec-dashboard/dist/assets/Dashboard-BlRRsxE7.js +27 -0
  44. package/spec-dashboard/dist/assets/EvalsPage-BzVE38-Z.js +2 -0
  45. package/spec-dashboard/dist/assets/{FoldToggle-B5leylLf.js → FoldToggle-DFuLVOeu.js} +1 -1
  46. package/spec-dashboard/dist/assets/IssuesPage-CzDaazhe.js +1 -0
  47. package/spec-dashboard/dist/assets/{MobileApp-RHNECU6x.js → MobileApp-CXQrQCNp.js} +1 -1
  48. package/spec-dashboard/dist/assets/{SessionInterface-YLD6IOmC.js → SessionInterface-D1pUBl6q.js} +8 -8
  49. package/spec-dashboard/dist/assets/SessionWindow-Y25Bwg1e.js +9 -0
  50. package/spec-dashboard/dist/assets/{Settings-ZnOwskMZ.js → Settings-R610Vbzd.js} +1 -1
  51. package/spec-dashboard/dist/assets/{index-BdRQfrkR.js → index-BO0Zuweu.js} +2 -2
  52. package/spec-dashboard/dist/assets/index-uGs9v_9o.css +1 -0
  53. package/spec-dashboard/dist/index.html +2 -2
  54. package/spec-forge/src/cli.ts +2 -2
  55. package/spec-forge/src/drivers/gitlab.ts +168 -0
  56. package/spec-forge/src/drivers.ts +80 -2
  57. package/spec-forge/src/resident.ts +10 -5
  58. package/spec-yatsu/src/cli.ts +37 -16
  59. package/spec-yatsu/src/evaltab.ts +6 -3
  60. package/spec-yatsu/src/filing.ts +13 -8
  61. package/spec-yatsu/src/freshness.ts +97 -22
  62. package/spec-yatsu/src/proof.ts +14 -3
  63. package/spec-yatsu/src/scenariofresh.ts +38 -11
  64. package/spec-yatsu/src/yatsu.ts +52 -28
  65. package/spec-dashboard/dist/assets/Dashboard-Dlg78cbC.js +0 -27
  66. package/spec-dashboard/dist/assets/EvalsPage-CDxc1-in.js +0 -3
  67. package/spec-dashboard/dist/assets/IssuesPage-C2yFXiO-.js +0 -1
  68. package/spec-dashboard/dist/assets/SessionWindow-CmKtpNUX.js +0 -9
  69. package/spec-dashboard/dist/assets/index-DEc5Ru3l.css +0 -1
@@ -1,27 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionInterface-YLD6IOmC.js","assets/index-BdRQfrkR.js","assets/index-DEc5Ru3l.css","assets/SessionWindow-CmKtpNUX.js","assets/EvalsPage-CDxc1-in.js","assets/FoldToggle-B5leylLf.js","assets/SessionInterface-DYP7pi_n.css","assets/IssuesPage-C2yFXiO-.js","assets/Settings-ZnOwskMZ.js"])))=>i.map(i=>d[i]);
2
- import{r as b,g as Ka,R as qa,j as g,u as Xe,a as Ga,l as Ua,_ as An,X as Za,Y as Qa}from"./index-BdRQfrkR.js";import{S as ot,G as mo,a as Ja,l as fr,A as ec,b as tc,c as hr,s as Ar,d as Ir,e as nc,I as rs,T as yo,f as xo,g as rc,h as sc,i as oc,j as ic,k as ac,m as cc,n as lc,u as uc,o as Me,p as dc,q as fc,r as hc,L as gc,N as pc}from"./SessionWindow-CmKtpNUX.js";function fe(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=fe(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var mc={value:()=>{}};function In(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new gn(n)}function gn(e){this._=e}function yc(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}gn.prototype=In.prototype={constructor:gn,on:function(e,t){var n=this._,r=yc(e+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o<i;)if((s=(e=r[o]).type)&&(s=xc(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<i;)if(s=(e=r[o]).type)n[s]=ss(n[s],e.name,t);else if(t==null)for(s in n)n[s]=ss(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new gn(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function xc(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function ss(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=mc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var gr="http://www.w3.org/1999/xhtml";const os={svg:"http://www.w3.org/2000/svg",xhtml:gr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function $n(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),os.hasOwnProperty(t)?{space:os[t],local:e}:e}function wc(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===gr&&t.documentElement.namespaceURI===gr?t.createElement(e):t.createElementNS(n,e)}}function vc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function wo(e){var t=$n(e);return(t.local?vc:wc)(t)}function bc(){}function $r(e){return e==null?bc:function(){return this.querySelector(e)}}function _c(e){typeof e!="function"&&(e=$r(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],i=o.length,a=r[s]=new Array(i),c,l,d=0;d<i;++d)(c=o[d])&&(l=e.call(c,c.__data__,d,o))&&("__data__"in c&&(l.__data__=c.__data__),a[d]=l);return new be(r,this._parents)}function Ec(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Nc(){return[]}function vo(e){return e==null?Nc:function(){return this.querySelectorAll(e)}}function Sc(e){return function(){return Ec(e.apply(this,arguments))}}function kc(e){typeof e=="function"?e=Sc(e):e=vo(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var i=t[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&(r.push(e.call(c,c.__data__,l,i)),s.push(c));return new be(r,s)}function bo(e){return function(){return this.matches(e)}}function _o(e){return function(t){return t.matches(e)}}var Mc=Array.prototype.find;function Cc(e){return function(){return Mc.call(this.children,e)}}function Ac(){return this.firstElementChild}function Ic(e){return this.select(e==null?Ac:Cc(typeof e=="function"?e:_o(e)))}var $c=Array.prototype.filter;function jc(){return Array.from(this.children)}function Pc(e){return function(){return $c.call(this.children,e)}}function Dc(e){return this.selectAll(e==null?jc:Pc(typeof e=="function"?e:_o(e)))}function Tc(e){typeof e!="function"&&(e=bo(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&e.call(c,c.__data__,l,o)&&a.push(c);return new be(r,this._parents)}function Eo(e){return new Array(e.length)}function Lc(){return new be(this._enter||this._groups.map(Eo),this._parents)}function wn(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}wn.prototype={constructor:wn,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Rc(e){return function(){return e}}function zc(e,t,n,r,s,o){for(var i=0,a,c=t.length,l=o.length;i<l;++i)(a=t[i])?(a.__data__=o[i],r[i]=a):n[i]=new wn(e,o[i]);for(;i<c;++i)(a=t[i])&&(s[i]=a)}function Hc(e,t,n,r,s,o,i){var a,c,l=new Map,d=t.length,u=o.length,f=new Array(d),h;for(a=0;a<d;++a)(c=t[a])&&(f[a]=h=i.call(c,c.__data__,a,t)+"",l.has(h)?s[a]=c:l.set(h,c));for(a=0;a<u;++a)h=i.call(e,o[a],a,o)+"",(c=l.get(h))?(r[a]=c,c.__data__=o[a],l.delete(h)):n[a]=new wn(e,o[a]);for(a=0;a<d;++a)(c=t[a])&&l.get(f[a])===c&&(s[a]=c)}function Oc(e){return e.__data__}function Bc(e,t){if(!arguments.length)return Array.from(this,Oc);var n=t?Hc:zc,r=this._parents,s=this._groups;typeof e!="function"&&(e=Rc(e));for(var o=s.length,i=new Array(o),a=new Array(o),c=new Array(o),l=0;l<o;++l){var d=r[l],u=s[l],f=u.length,h=Vc(e.call(d,d&&d.__data__,l,r)),p=h.length,v=a[l]=new Array(p),w=i[l]=new Array(p),m=c[l]=new Array(f);n(d,u,v,w,m,h,t);for(var E=0,y=0,x,N;E<p;++E)if(x=v[E]){for(E>=y&&(y=E+1);!(N=w[y])&&++y<p;);x._next=N||null}}return i=new be(i,r),i._enter=a,i._exit=c,i}function Vc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Fc(){return new be(this._exit||this._groups.map(Eo),this._parents)}function Wc(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function Yc(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,i=Math.min(s,o),a=new Array(s),c=0;c<i;++c)for(var l=n[c],d=r[c],u=l.length,f=a[c]=new Array(u),h,p=0;p<u;++p)(h=l[p]||d[p])&&(f[p]=h);for(;c<s;++c)a[c]=n[c];return new be(a,this._parents)}function Xc(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],i;--s>=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function Kc(e){e||(e=qc);function t(u,f){return u&&f?e(u.__data__,f.__data__):!u-!f}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var i=n[o],a=i.length,c=s[o]=new Array(a),l,d=0;d<a;++d)(l=i[d])&&(c[d]=l);c.sort(t)}return new be(s,this._parents).order()}function qc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Gc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Uc(){return Array.from(this)}function Zc(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var i=r[s];if(i)return i}return null}function Qc(){let e=0;for(const t of this)++e;return e}function Jc(){return!this.node()}function el(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,i=s.length,a;o<i;++o)(a=s[o])&&e.call(a,a.__data__,o,s);return this}function tl(e){return function(){this.removeAttribute(e)}}function nl(e){return function(){this.removeAttributeNS(e.space,e.local)}}function rl(e,t){return function(){this.setAttribute(e,t)}}function sl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ol(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function il(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function al(e,t){var n=$n(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?nl:tl:typeof t=="function"?n.local?il:ol:n.local?sl:rl)(n,t))}function No(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function cl(e){return function(){this.style.removeProperty(e)}}function ll(e,t,n){return function(){this.style.setProperty(e,t,n)}}function ul(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function dl(e,t,n){return arguments.length>1?this.each((t==null?cl:typeof t=="function"?ul:ll)(e,t,n??"")):xt(this.node(),e)}function xt(e,t){return e.style.getPropertyValue(t)||No(e).getComputedStyle(e,null).getPropertyValue(t)}function fl(e){return function(){delete this[e]}}function hl(e,t){return function(){this[e]=t}}function gl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function pl(e,t){return arguments.length>1?this.each((t==null?fl:typeof t=="function"?gl:hl)(e,t)):this.node()[e]}function So(e){return e.trim().split(/^|\s+/)}function jr(e){return e.classList||new ko(e)}function ko(e){this._node=e,this._names=So(e.getAttribute("class")||"")}ko.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function Mo(e,t){for(var n=jr(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function Co(e,t){for(var n=jr(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function ml(e){return function(){Mo(this,e)}}function yl(e){return function(){Co(this,e)}}function xl(e,t){return function(){(t.apply(this,arguments)?Mo:Co)(this,e)}}function wl(e,t){var n=So(e+"");if(arguments.length<2){for(var r=jr(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?xl:t?ml:yl)(n,t))}function vl(){this.textContent=""}function bl(e){return function(){this.textContent=e}}function _l(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function El(e){return arguments.length?this.each(e==null?vl:(typeof e=="function"?_l:bl)(e)):this.node().textContent}function Nl(){this.innerHTML=""}function Sl(e){return function(){this.innerHTML=e}}function kl(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Ml(e){return arguments.length?this.each(e==null?Nl:(typeof e=="function"?kl:Sl)(e)):this.node().innerHTML}function Cl(){this.nextSibling&&this.parentNode.appendChild(this)}function Al(){return this.each(Cl)}function Il(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function $l(){return this.each(Il)}function jl(e){var t=typeof e=="function"?e:wo(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Pl(){return null}function Dl(e,t){var n=typeof e=="function"?e:wo(e),r=t==null?Pl:typeof t=="function"?t:$r(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Tl(){var e=this.parentNode;e&&e.removeChild(this)}function Ll(){return this.each(Tl)}function Rl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function zl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Hl(e){return this.select(e?zl:Rl)}function Ol(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Bl(e){return function(t){e.call(this,t,this.__data__)}}function Vl(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function Fl(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function Wl(e,t,n){return function(){var r=this.__on,s,o=Bl(t);if(r){for(var i=0,a=r.length;i<a;++i)if((s=r[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function Yl(e,t,n){var r=Vl(e+""),s,o=r.length,i;if(arguments.length<2){var a=this.node().__on;if(a){for(var c=0,l=a.length,d;c<l;++c)for(s=0,d=a[c];s<o;++s)if((i=r[s]).type===d.type&&i.name===d.name)return d.value}return}for(a=t?Wl:Fl,s=0;s<o;++s)this.each(a(r[s],t,n));return this}function Ao(e,t,n){var r=No(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function Xl(e,t){return function(){return Ao(this,e,t)}}function Kl(e,t){return function(){return Ao(this,e,t.apply(this,arguments))}}function ql(e,t){return this.each((typeof t=="function"?Kl:Xl)(e,t))}function*Gl(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,i;s<o;++s)(i=r[s])&&(yield i)}var Io=[null];function be(e,t){this._groups=e,this._parents=t}function Yt(){return new be([[document.documentElement]],Io)}function Ul(){return this}be.prototype=Yt.prototype={constructor:be,select:_c,selectAll:kc,selectChild:Ic,selectChildren:Dc,filter:Tc,data:Bc,enter:Lc,exit:Fc,join:Wc,merge:Yc,selection:Ul,order:Xc,sort:Kc,call:Gc,nodes:Uc,node:Zc,size:Qc,empty:Jc,each:el,attr:al,style:dl,property:pl,classed:wl,text:El,html:Ml,raise:Al,lower:$l,append:jl,insert:Dl,remove:Ll,clone:Hl,datum:Ol,on:Yl,dispatch:ql,[Symbol.iterator]:Gl};function ve(e){return typeof e=="string"?new be([[document.querySelector(e)]],[document.documentElement]):new be([[e]],Io)}function Zl(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Ie(e,t){if(e=Zl(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const Ql={passive:!1},Tt={capture:!0,passive:!1};function Zn(e){e.stopImmediatePropagation()}function mt(e){e.preventDefault(),e.stopImmediatePropagation()}function $o(e){var t=e.document.documentElement,n=ve(e).on("dragstart.drag",mt,Tt);"onselectstart"in t?n.on("selectstart.drag",mt,Tt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function jo(e,t){var n=e.document.documentElement,r=ve(e).on("dragstart.drag",null);t&&(r.on("click.drag",mt,Tt),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const rn=e=>()=>e;function pr(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:i,y:a,dx:c,dy:l,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:l,enumerable:!0,configurable:!0},_:{value:d}})}pr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function Jl(e){return!e.ctrlKey&&!e.button}function eu(){return this.parentNode}function tu(e,t){return t??{x:e.x,y:e.y}}function nu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Po(){var e=Jl,t=eu,n=tu,r=nu,s={},o=In("start","drag","end"),i=0,a,c,l,d,u=0;function f(x){x.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).on("touchmove.drag",m,Ql).on("touchend.drag touchcancel.drag",E).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function h(x,N){if(!(d||!e.call(this,x,N))){var k=y(this,t.call(this,x,N),x,N,"mouse");k&&(ve(x.view).on("mousemove.drag",p,Tt).on("mouseup.drag",v,Tt),$o(x.view),Zn(x),l=!1,a=x.clientX,c=x.clientY,k("start",x))}}function p(x){if(mt(x),!l){var N=x.clientX-a,k=x.clientY-c;l=N*N+k*k>u}s.mouse("drag",x)}function v(x){ve(x.view).on("mousemove.drag mouseup.drag",null),jo(x.view,l),mt(x),s.mouse("end",x)}function w(x,N){if(e.call(this,x,N)){var k=x.changedTouches,P=t.call(this,x,N),D=k.length,L,F;for(L=0;L<D;++L)(F=y(this,P,x,N,k[L].identifier,k[L]))&&(Zn(x),F("start",x,k[L]))}}function m(x){var N=x.changedTouches,k=N.length,P,D;for(P=0;P<k;++P)(D=s[N[P].identifier])&&(mt(x),D("drag",x,N[P]))}function E(x){var N=x.changedTouches,k=N.length,P,D;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),P=0;P<k;++P)(D=s[N[P].identifier])&&(Zn(x),D("end",x,N[P]))}function y(x,N,k,P,D,L){var F=o.copy(),M=Ie(L||k,N),j,V,_;if((_=n.call(x,new pr("beforestart",{sourceEvent:k,target:f,identifier:D,active:i,x:M[0],y:M[1],dx:0,dy:0,dispatch:F}),P))!=null)return j=_.x-M[0]||0,V=_.y-M[1]||0,function C(S,I,R){var A=M,O;switch(S){case"start":s[D]=C,O=i++;break;case"end":delete s[D],--i;case"drag":M=Ie(R||I,N),O=i;break}F.call(S,x,new pr(S,{sourceEvent:I,subject:_,target:f,identifier:D,active:O,x:M[0]+j,y:M[1]+V,dx:M[0]-A[0],dy:M[1]-A[1],dispatch:F}),P)}}return f.filter=function(x){return arguments.length?(e=typeof x=="function"?x:rn(!!x),f):e},f.container=function(x){return arguments.length?(t=typeof x=="function"?x:rn(x),f):t},f.subject=function(x){return arguments.length?(n=typeof x=="function"?x:rn(x),f):n},f.touchable=function(x){return arguments.length?(r=typeof x=="function"?x:rn(!!x),f):r},f.on=function(){var x=o.on.apply(o,arguments);return x===o?f:x},f.clickDistance=function(x){return arguments.length?(u=(x=+x)*x,f):Math.sqrt(u)},f}function Pr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Do(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Xt(){}var Lt=.7,vn=1/Lt,yt="\\s*([+-]?\\d+)\\s*",Rt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ru=/^#([0-9a-f]{3,8})$/,su=new RegExp(`^rgb\\(${yt},${yt},${yt}\\)$`),ou=new RegExp(`^rgb\\(${ze},${ze},${ze}\\)$`),iu=new RegExp(`^rgba\\(${yt},${yt},${yt},${Rt}\\)$`),au=new RegExp(`^rgba\\(${ze},${ze},${ze},${Rt}\\)$`),cu=new RegExp(`^hsl\\(${Rt},${ze},${ze}\\)$`),lu=new RegExp(`^hsla\\(${Rt},${ze},${ze},${Rt}\\)$`),is={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Pr(Xt,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:as,formatHex:as,formatHex8:uu,formatHsl:du,formatRgb:cs,toString:cs});function as(){return this.rgb().formatHex()}function uu(){return this.rgb().formatHex8()}function du(){return To(this).formatHsl()}function cs(){return this.rgb().formatRgb()}function it(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=ru.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ls(t):n===3?new we(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?sn(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?sn(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=su.exec(e))?new we(t[1],t[2],t[3],1):(t=ou.exec(e))?new we(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=iu.exec(e))?sn(t[1],t[2],t[3],t[4]):(t=au.exec(e))?sn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=cu.exec(e))?fs(t[1],t[2]/100,t[3]/100,1):(t=lu.exec(e))?fs(t[1],t[2]/100,t[3]/100,t[4]):is.hasOwnProperty(e)?ls(is[e]):e==="transparent"?new we(NaN,NaN,NaN,0):null}function ls(e){return new we(e>>16&255,e>>8&255,e&255,1)}function sn(e,t,n,r){return r<=0&&(e=t=n=NaN),new we(e,t,n,r)}function fu(e){return e instanceof Xt||(e=it(e)),e?(e=e.rgb(),new we(e.r,e.g,e.b,e.opacity)):new we}function mr(e,t,n,r){return arguments.length===1?fu(e):new we(e,t,n,r??1)}function we(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Pr(we,mr,Do(Xt,{brighter(e){return e=e==null?vn:Math.pow(vn,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lt:Math.pow(Lt,e),new we(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new we(rt(this.r),rt(this.g),rt(this.b),bn(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:us,formatHex:us,formatHex8:hu,formatRgb:ds,toString:ds}));function us(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}`}function hu(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}${tt((isNaN(this.opacity)?1:this.opacity)*255)}`}function ds(){const e=bn(this.opacity);return`${e===1?"rgb(":"rgba("}${rt(this.r)}, ${rt(this.g)}, ${rt(this.b)}${e===1?")":`, ${e})`}`}function bn(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function rt(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function tt(e){return e=rt(e),(e<16?"0":"")+e.toString(16)}function fs(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new $e(e,t,n,r)}function To(e){if(e instanceof $e)return new $e(e.h,e.s,e.l,e.opacity);if(e instanceof Xt||(e=it(e)),!e)return new $e;if(e instanceof $e)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),i=NaN,a=o-s,c=(o+s)/2;return a?(t===o?i=(n-r)/a+(n<r)*6:n===o?i=(r-t)/a+2:i=(t-n)/a+4,a/=c<.5?o+s:2-o-s,i*=60):a=c>0&&c<1?0:i,new $e(i,a,c,e.opacity)}function gu(e,t,n,r){return arguments.length===1?To(e):new $e(e,t,n,r??1)}function $e(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Pr($e,gu,Do(Xt,{brighter(e){return e=e==null?vn:Math.pow(vn,e),new $e(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lt:Math.pow(Lt,e),new $e(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new we(Qn(e>=240?e-240:e+120,s,r),Qn(e,s,r),Qn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new $e(hs(this.h),on(this.s),on(this.l),bn(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=bn(this.opacity);return`${e===1?"hsl(":"hsla("}${hs(this.h)}, ${on(this.s)*100}%, ${on(this.l)*100}%${e===1?")":`, ${e})`}`}}));function hs(e){return e=(e||0)%360,e<0?e+360:e}function on(e){return Math.max(0,Math.min(1,e||0))}function Qn(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const Dr=e=>()=>e;function pu(e,t){return function(n){return e+n*t}}function mu(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function yu(e){return(e=+e)==1?Lo:function(t,n){return n-t?mu(t,n,e):Dr(isNaN(t)?n:t)}}function Lo(e,t){var n=t-e;return n?pu(e,n):Dr(isNaN(e)?t:e)}const _n=function e(t){var n=yu(t);function r(s,o){var i=n((s=mr(s)).r,(o=mr(o)).r),a=n(s.g,o.g),c=n(s.b,o.b),l=Lo(s.opacity,o.opacity);return function(d){return s.r=i(d),s.g=a(d),s.b=c(d),s.opacity=l(d),s+""}}return r.gamma=e,r}(1);function xu(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(o){for(s=0;s<n;++s)r[s]=e[s]*(1-o)+t[s]*o;return r}}function wu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function vu(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),o=new Array(n),i;for(i=0;i<r;++i)s[i]=Pt(e[i],t[i]);for(;i<n;++i)o[i]=t[i];return function(a){for(i=0;i<r;++i)o[i]=s[i](a);return o}}function bu(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Re(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function _u(e,t){var n={},r={},s;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(s in t)s in e?n[s]=Pt(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var yr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Jn=new RegExp(yr.source,"g");function Eu(e){return function(){return e}}function Nu(e){return function(t){return e(t)+""}}function Ro(e,t){var n=yr.lastIndex=Jn.lastIndex=0,r,s,o,i=-1,a=[],c=[];for(e=e+"",t=t+"";(r=yr.exec(e))&&(s=Jn.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),a[i]?a[i]+=o:a[++i]=o),(r=r[0])===(s=s[0])?a[i]?a[i]+=s:a[++i]=s:(a[++i]=null,c.push({i,x:Re(r,s)})),n=Jn.lastIndex;return n<t.length&&(o=t.slice(n),a[i]?a[i]+=o:a[++i]=o),a.length<2?c[0]?Nu(c[0].x):Eu(t):(t=c.length,function(l){for(var d=0,u;d<t;++d)a[(u=c[d]).i]=u.x(l);return a.join("")})}function Pt(e,t){var n=typeof t,r;return t==null||n==="boolean"?Dr(t):(n==="number"?Re:n==="string"?(r=it(t))?(t=r,_n):Ro:t instanceof it?_n:t instanceof Date?bu:wu(t)?xu:Array.isArray(t)?vu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?_u:Re)(e,t)}var gs=180/Math.PI,xr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function zo(e,t,n,r,s,o){var i,a,c;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(a=Math.sqrt(n*n+r*r))&&(n/=a,r/=a,c/=a),e*r<t*n&&(e=-e,t=-t,c=-c,i=-i),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*gs,skewX:Math.atan(c)*gs,scaleX:i,scaleY:a}}var an;function Su(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?xr:zo(t.a,t.b,t.c,t.d,t.e,t.f)}function ku(e){return e==null||(an||(an=document.createElementNS("http://www.w3.org/2000/svg","g")),an.setAttribute("transform",e),!(e=an.transform.baseVal.consolidate()))?xr:(e=e.matrix,zo(e.a,e.b,e.c,e.d,e.e,e.f))}function Ho(e,t,n,r){function s(l){return l.length?l.pop()+" ":""}function o(l,d,u,f,h,p){if(l!==u||d!==f){var v=h.push("translate(",null,t,null,n);p.push({i:v-4,x:Re(l,u)},{i:v-2,x:Re(d,f)})}else(u||f)&&h.push("translate("+u+t+f+n)}function i(l,d,u,f){l!==d?(l-d>180?d+=360:d-l>180&&(l+=360),f.push({i:u.push(s(u)+"rotate(",null,r)-2,x:Re(l,d)})):d&&u.push(s(u)+"rotate("+d+r)}function a(l,d,u,f){l!==d?f.push({i:u.push(s(u)+"skewX(",null,r)-2,x:Re(l,d)}):d&&u.push(s(u)+"skewX("+d+r)}function c(l,d,u,f,h,p){if(l!==u||d!==f){var v=h.push(s(h)+"scale(",null,",",null,")");p.push({i:v-4,x:Re(l,u)},{i:v-2,x:Re(d,f)})}else(u!==1||f!==1)&&h.push(s(h)+"scale("+u+","+f+")")}return function(l,d){var u=[],f=[];return l=e(l),d=e(d),o(l.translateX,l.translateY,d.translateX,d.translateY,u,f),i(l.rotate,d.rotate,u,f),a(l.skewX,d.skewX,u,f),c(l.scaleX,l.scaleY,d.scaleX,d.scaleY,u,f),l=d=null,function(h){for(var p=-1,v=f.length,w;++p<v;)u[(w=f[p]).i]=w.x(h);return u.join("")}}}var Mu=Ho(Su,"px, ","px)","deg)"),Cu=Ho(ku,", ",")",")"),Au=1e-12;function ps(e){return((e=Math.exp(e))+1/e)/2}function Iu(e){return((e=Math.exp(e))-1/e)/2}function $u(e){return((e=Math.exp(2*e))-1)/(e+1)}const pn=function e(t,n,r){function s(o,i){var a=o[0],c=o[1],l=o[2],d=i[0],u=i[1],f=i[2],h=d-a,p=u-c,v=h*h+p*p,w,m;if(v<Au)m=Math.log(f/l)/t,w=function(P){return[a+P*h,c+P*p,l*Math.exp(t*P*m)]};else{var E=Math.sqrt(v),y=(f*f-l*l+r*v)/(2*l*n*E),x=(f*f-l*l-r*v)/(2*f*n*E),N=Math.log(Math.sqrt(y*y+1)-y),k=Math.log(Math.sqrt(x*x+1)-x);m=(k-N)/t,w=function(P){var D=P*m,L=ps(N),F=l/(n*E)*(L*$u(t*D+N)-Iu(N));return[a+F*h,c+F*p,l*L/ps(t*D+N)]}}return w.duration=m*1e3*t/Math.SQRT2,w}return s.rho=function(o){var i=Math.max(.001,+o),a=i*i,c=a*a;return e(i,a,c)},s}(Math.SQRT2,2,4);var wt=0,It=0,Ct=0,Oo=1e3,En,$t,Nn=0,at=0,jn=0,zt=typeof performance=="object"&&performance.now?performance:Date,Bo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Tr(){return at||(Bo(ju),at=zt.now()+jn)}function ju(){at=0}function Sn(){this._call=this._time=this._next=null}Sn.prototype=Vo.prototype={constructor:Sn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Tr():+n)+(t==null?0:+t),!this._next&&$t!==this&&($t?$t._next=this:En=this,$t=this),this._call=e,this._time=n,wr()},stop:function(){this._call&&(this._call=null,this._time=1/0,wr())}};function Vo(e,t,n){var r=new Sn;return r.restart(e,t,n),r}function Pu(){Tr(),++wt;for(var e=En,t;e;)(t=at-e._time)>=0&&e._call.call(void 0,t),e=e._next;--wt}function ms(){at=(Nn=zt.now())+jn,wt=It=0;try{Pu()}finally{wt=0,Tu(),at=0}}function Du(){var e=zt.now(),t=e-Nn;t>Oo&&(jn-=t,Nn=e)}function Tu(){for(var e,t=En,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:En=n);$t=e,wr(r)}function wr(e){if(!wt){It&&(It=clearTimeout(It));var t=e-at;t>24?(e<1/0&&(It=setTimeout(ms,e-zt.now()-jn)),Ct&&(Ct=clearInterval(Ct))):(Ct||(Nn=zt.now(),Ct=setInterval(Du,Oo)),wt=1,Bo(ms))}}function ys(e,t,n){var r=new Sn;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var Lu=In("start","end","cancel","interrupt"),Ru=[],Fo=0,xs=1,vr=2,mn=3,ws=4,br=5,yn=6;function Pn(e,t,n,r,s,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;zu(e,n,{name:t,index:r,group:s,on:Lu,tween:Ru,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Fo})}function Lr(e,t){var n=Te(e,t);if(n.state>Fo)throw new Error("too late; already scheduled");return n}function He(e,t){var n=Te(e,t);if(n.state>mn)throw new Error("too late; already running");return n}function Te(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function zu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Vo(o,0,n.time);function o(l){n.state=xs,n.timer.restart(i,n.delay,n.time),n.delay<=l&&i(l-n.delay)}function i(l){var d,u,f,h;if(n.state!==xs)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===mn)return ys(i);h.state===ws?(h.state=yn,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=yn,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(ys(function(){n.state===mn&&(n.state=ws,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=vr,n.on.call("start",e,e.__data__,n.index,n.group),n.state===vr){for(n.state=mn,s=new Array(f=n.tween.length),d=0,u=-1;d<f;++d)(h=n.tween[d].value.call(e,e.__data__,n.index,n.group))&&(s[++u]=h);s.length=u+1}}function a(l){for(var d=l<n.duration?n.ease.call(null,l/n.duration):(n.timer.restart(c),n.state=br,1),u=-1,f=s.length;++u<f;)s[u].call(e,d);n.state===br&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=yn,n.timer.stop(),delete r[t];for(var l in r)return;delete e.__transition}}function xn(e,t){var n=e.__transition,r,s,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){o=!1;continue}s=r.state>vr&&r.state<br,r.state=yn,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}o&&delete e.__transition}}function Hu(e){return this.each(function(){xn(this,e)})}function Ou(e,t){var n,r;return function(){var s=He(this,e),o=s.tween;if(o!==n){r=n=o;for(var i=0,a=r.length;i<a;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function Bu(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=He(this,e),i=o.tween;if(i!==r){s=(r=i).slice();for(var a={name:t,value:n},c=0,l=s.length;c<l;++c)if(s[c].name===t){s[c]=a;break}c===l&&s.push(a)}o.tween=s}}function Vu(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Te(this.node(),n).tween,s=0,o=r.length,i;s<o;++s)if((i=r[s]).name===e)return i.value;return null}return this.each((t==null?Ou:Bu)(n,e,t))}function Rr(e,t,n){var r=e._id;return e.each(function(){var s=He(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Te(s,r).value[t]}}function Wo(e,t){var n;return(typeof t=="number"?Re:t instanceof it?_n:(n=it(t))?(t=n,_n):Ro)(e,t)}function Fu(e){return function(){this.removeAttribute(e)}}function Wu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Yu(e,t,n){var r,s=n+"",o;return function(){var i=this.getAttribute(e);return i===s?null:i===r?o:o=t(r=i,n)}}function Xu(e,t,n){var r,s=n+"",o;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===r?o:o=t(r=i,n)}}function Ku(e,t,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttribute(e):(i=this.getAttribute(e),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=t(r=i,a)))}}function qu(e,t,n){var r,s,o;return function(){var i,a=n(this),c;return a==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),c=a+"",i===c?null:i===r&&c===s?o:(s=c,o=t(r=i,a)))}}function Gu(e,t){var n=$n(e),r=n==="transform"?Cu:Wo;return this.attrTween(e,typeof t=="function"?(n.local?qu:Ku)(n,r,Rr(this,"attr."+e,t)):t==null?(n.local?Wu:Fu)(n):(n.local?Xu:Yu)(n,r,t))}function Uu(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function Zu(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function Qu(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Zu(e,o)),n}return s._value=t,s}function Ju(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&Uu(e,o)),n}return s._value=t,s}function ed(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=$n(e);return this.tween(n,(r.local?Qu:Ju)(r,t))}function td(e,t){return function(){Lr(this,e).delay=+t.apply(this,arguments)}}function nd(e,t){return t=+t,function(){Lr(this,e).delay=t}}function rd(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?td:nd)(t,e)):Te(this.node(),t).delay}function sd(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function od(e,t){return t=+t,function(){He(this,e).duration=t}}function id(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?sd:od)(t,e)):Te(this.node(),t).duration}function ad(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function cd(e){var t=this._id;return arguments.length?this.each(ad(t,e)):Te(this.node(),t).ease}function ld(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;He(this,e).ease=n}}function ud(e){if(typeof e!="function")throw new Error;return this.each(ld(this._id,e))}function dd(e){typeof e!="function"&&(e=bo(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],i=o.length,a=r[s]=[],c,l=0;l<i;++l)(c=o[l])&&e.call(c,c.__data__,l,o)&&a.push(c);return new Ye(r,this._parents,this._name,this._id)}function fd(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),i=new Array(r),a=0;a<o;++a)for(var c=t[a],l=n[a],d=c.length,u=i[a]=new Array(d),f,h=0;h<d;++h)(f=c[h]||l[h])&&(u[h]=f);for(;a<r;++a)i[a]=t[a];return new Ye(i,this._parents,this._name,this._id)}function hd(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function gd(e,t,n){var r,s,o=hd(t)?Lr:He;return function(){var i=o(this,e),a=i.on;a!==r&&(s=(r=a).copy()).on(t,n),i.on=s}}function pd(e,t){var n=this._id;return arguments.length<2?Te(this.node(),n).on.on(e):this.each(gd(n,e,t))}function md(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function yd(){return this.on("end.remove",md(this._id))}function xd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$r(e));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i<s;++i)for(var a=r[i],c=a.length,l=o[i]=new Array(c),d,u,f=0;f<c;++f)(d=a[f])&&(u=e.call(d,d.__data__,f,a))&&("__data__"in d&&(u.__data__=d.__data__),l[f]=u,Pn(l[f],t,n,f,l,Te(d,n)));return new Ye(o,this._parents,t,n)}function wd(e){var t=this._name,n=this._id;typeof e!="function"&&(e=vo(e));for(var r=this._groups,s=r.length,o=[],i=[],a=0;a<s;++a)for(var c=r[a],l=c.length,d,u=0;u<l;++u)if(d=c[u]){for(var f=e.call(d,d.__data__,u,c),h,p=Te(d,n),v=0,w=f.length;v<w;++v)(h=f[v])&&Pn(h,t,n,v,f,p);o.push(f),i.push(d)}return new Ye(o,i,t,n)}var vd=Yt.prototype.constructor;function bd(){return new vd(this._groups,this._parents)}function _d(e,t){var n,r,s;return function(){var o=xt(this,e),i=(this.style.removeProperty(e),xt(this,e));return o===i?null:o===n&&i===r?s:s=t(n=o,r=i)}}function Yo(e){return function(){this.style.removeProperty(e)}}function Ed(e,t,n){var r,s=n+"",o;return function(){var i=xt(this,e);return i===s?null:i===r?o:o=t(r=i,n)}}function Nd(e,t,n){var r,s,o;return function(){var i=xt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),xt(this,e))),i===c?null:i===r&&c===s?o:(s=c,o=t(r=i,a))}}function Sd(e,t){var n,r,s,o="style."+t,i="end."+o,a;return function(){var c=He(this,e),l=c.on,d=c.value[o]==null?a||(a=Yo(t)):void 0;(l!==n||s!==d)&&(r=(n=l).copy()).on(i,s=d),c.on=r}}function kd(e,t,n){var r=(e+="")=="transform"?Mu:Wo;return t==null?this.styleTween(e,_d(e,r)).on("end.style."+e,Yo(e)):typeof t=="function"?this.styleTween(e,Nd(e,r,Rr(this,"style."+e,t))).each(Sd(this._id,e)):this.styleTween(e,Ed(e,r,t),n).on("end.style."+e,null)}function Md(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Cd(e,t,n){var r,s;function o(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&Md(e,i,n)),r}return o._value=t,o}function Ad(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,Cd(e,t,n??""))}function Id(e){return function(){this.textContent=e}}function $d(e){return function(){var t=e(this);this.textContent=t??""}}function jd(e){return this.tween("text",typeof e=="function"?$d(Rr(this,"text",e)):Id(e==null?"":e+""))}function Pd(e){return function(t){this.textContent=e.call(this,t)}}function Dd(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Pd(s)),t}return r._value=e,r}function Td(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,Dd(e))}function Ld(){for(var e=this._name,t=this._id,n=Xo(),r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)if(c=i[l]){var d=Te(c,t);Pn(c,e,n,l,i,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Ye(r,this._parents,e,n)}function Rd(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,i){var a={value:i},c={value:function(){--s===0&&o()}};n.each(function(){var l=He(this,r),d=l.on;d!==e&&(t=(e=d).copy(),t._.cancel.push(a),t._.interrupt.push(a),t._.end.push(c)),l.on=t}),s===0&&o()})}var zd=0;function Ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Xo(){return++zd}var Fe=Yt.prototype;Ye.prototype={constructor:Ye,select:xd,selectAll:wd,selectChild:Fe.selectChild,selectChildren:Fe.selectChildren,filter:dd,merge:fd,selection:bd,transition:Ld,call:Fe.call,nodes:Fe.nodes,node:Fe.node,size:Fe.size,empty:Fe.empty,each:Fe.each,on:pd,attr:Gu,attrTween:ed,style:kd,styleTween:Ad,text:jd,textTween:Td,remove:yd,tween:Vu,delay:rd,duration:id,ease:cd,easeVarying:ud,end:Rd,[Symbol.iterator]:Fe[Symbol.iterator]};function Hd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Od={time:null,delay:0,duration:250,ease:Hd};function Bd(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function Vd(e){var t,n;e instanceof Ye?(t=e._id,e=e._name):(t=Xo(),(n=Od).time=Tr(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],a=i.length,c,l=0;l<a;++l)(c=i[l])&&Pn(c,e,t,l,i,n||Bd(c,t));return new Ye(r,this._parents,e,t)}Yt.prototype.interrupt=Hu;Yt.prototype.transition=Vd;const cn=e=>()=>e;function Fd(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function We(e,t,n){this.k=e,this.x=t,this.y=n}We.prototype={constructor:We,scale:function(e){return e===1?this:new We(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new We(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var Dn=new We(1,0,0);Ko.prototype=We.prototype;function Ko(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Dn;return e.__zoom}function er(e){e.stopImmediatePropagation()}function At(e){e.preventDefault(),e.stopImmediatePropagation()}function Wd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Yd(){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 vs(){return this.__zoom||Dn}function Xd(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Kd(){return navigator.maxTouchPoints||"ontouchstart"in this}function qd(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function qo(){var e=Wd,t=Yd,n=qd,r=Xd,s=Kd,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=pn,l=In("start","zoom","end"),d,u,f,h=500,p=150,v=0,w=10;function m(_){_.property("__zoom",vs).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",j).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(_,C,S,I){var R=_.selection?_.selection():_;R.property("__zoom",vs),_!==R?N(_,C,S,I):R.interrupt().each(function(){k(this,arguments).event(I).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},m.scaleBy=function(_,C,S,I){m.scaleTo(_,function(){var R=this.__zoom.k,A=typeof C=="function"?C.apply(this,arguments):C;return R*A},S,I)},m.scaleTo=function(_,C,S,I){m.transform(_,function(){var R=t.apply(this,arguments),A=this.__zoom,O=S==null?x(R):typeof S=="function"?S.apply(this,arguments):S,B=A.invert(O),H=typeof C=="function"?C.apply(this,arguments):C;return n(y(E(A,H),O,B),R,i)},S,I)},m.translateBy=function(_,C,S,I){m.transform(_,function(){return n(this.__zoom.translate(typeof C=="function"?C.apply(this,arguments):C,typeof S=="function"?S.apply(this,arguments):S),t.apply(this,arguments),i)},null,I)},m.translateTo=function(_,C,S,I,R){m.transform(_,function(){var A=t.apply(this,arguments),O=this.__zoom,B=I==null?x(A):typeof I=="function"?I.apply(this,arguments):I;return n(Dn.translate(B[0],B[1]).scale(O.k).translate(typeof C=="function"?-C.apply(this,arguments):-C,typeof S=="function"?-S.apply(this,arguments):-S),A,i)},I,R)};function E(_,C){return C=Math.max(o[0],Math.min(o[1],C)),C===_.k?_:new We(C,_.x,_.y)}function y(_,C,S){var I=C[0]-S[0]*_.k,R=C[1]-S[1]*_.k;return I===_.x&&R===_.y?_:new We(_.k,I,R)}function x(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function N(_,C,S,I){_.on("start.zoom",function(){k(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(I).end()}).tween("zoom",function(){var R=this,A=arguments,O=k(R,A).event(I),B=t.apply(R,A),H=S==null?x(B):typeof S=="function"?S.apply(R,A):S,Y=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),X=R.__zoom,ee=typeof C=="function"?C.apply(R,A):C,J=c(X.invert(H).concat(Y/X.k),ee.invert(H).concat(Y/ee.k));return function(Z){if(Z===1)Z=ee;else{var $=J(Z),W=Y/$[2];Z=new We(W,H[0]-$[0]*W,H[1]-$[1]*W)}O.zoom(null,Z)}})}function k(_,C,S){return!S&&_.__zooming||new P(_,C)}function P(_,C){this.that=_,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,C),this.taps=0}P.prototype={event:function(_){return _&&(this.sourceEvent=_),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(_,C){return this.mouse&&_!=="mouse"&&(this.mouse[1]=C.invert(this.mouse[0])),this.touch0&&_!=="touch"&&(this.touch0[1]=C.invert(this.touch0[0])),this.touch1&&_!=="touch"&&(this.touch1[1]=C.invert(this.touch1[0])),this.that.__zoom=C,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(_){var C=ve(this.that).datum();l.call(_,this.that,new Fd(_,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),C)}};function D(_,...C){if(!e.apply(this,arguments))return;var S=k(this,C).event(_),I=this.__zoom,R=Math.max(o[0],Math.min(o[1],I.k*Math.pow(2,r.apply(this,arguments)))),A=Ie(_);if(S.wheel)(S.mouse[0][0]!==A[0]||S.mouse[0][1]!==A[1])&&(S.mouse[1]=I.invert(S.mouse[0]=A)),clearTimeout(S.wheel);else{if(I.k===R)return;S.mouse=[A,I.invert(A)],xn(this),S.start()}At(_),S.wheel=setTimeout(O,p),S.zoom("mouse",n(y(E(I,R),S.mouse[0],S.mouse[1]),S.extent,i));function O(){S.wheel=null,S.end()}}function L(_,...C){if(f||!e.apply(this,arguments))return;var S=_.currentTarget,I=k(this,C,!0).event(_),R=ve(_.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",Y,!0),A=Ie(_,S),O=_.clientX,B=_.clientY;$o(_.view),er(_),I.mouse=[A,this.__zoom.invert(A)],xn(this),I.start();function H(X){if(At(X),!I.moved){var ee=X.clientX-O,J=X.clientY-B;I.moved=ee*ee+J*J>v}I.event(X).zoom("mouse",n(y(I.that.__zoom,I.mouse[0]=Ie(X,S),I.mouse[1]),I.extent,i))}function Y(X){R.on("mousemove.zoom mouseup.zoom",null),jo(X.view,I.moved),At(X),I.event(X).end()}}function F(_,...C){if(e.apply(this,arguments)){var S=this.__zoom,I=Ie(_.changedTouches?_.changedTouches[0]:_,this),R=S.invert(I),A=S.k*(_.shiftKey?.5:2),O=n(y(E(S,A),I,R),t.apply(this,C),i);At(_),a>0?ve(this).transition().duration(a).call(N,O,I,_):ve(this).call(m.transform,O,I,_)}}function M(_,...C){if(e.apply(this,arguments)){var S=_.touches,I=S.length,R=k(this,C,_.changedTouches.length===I).event(_),A,O,B,H;for(er(_),O=0;O<I;++O)B=S[O],H=Ie(B,this),H=[H,this.__zoom.invert(H),B.identifier],R.touch0?!R.touch1&&R.touch0[2]!==H[2]&&(R.touch1=H,R.taps=0):(R.touch0=H,A=!0,R.taps=1+!!d);d&&(d=clearTimeout(d)),A&&(R.taps<2&&(u=H[0],d=setTimeout(function(){d=null},h)),xn(this),R.start())}}function j(_,...C){if(this.__zooming){var S=k(this,C).event(_),I=_.changedTouches,R=I.length,A,O,B,H;for(At(_),A=0;A<R;++A)O=I[A],B=Ie(O,this),S.touch0&&S.touch0[2]===O.identifier?S.touch0[0]=B:S.touch1&&S.touch1[2]===O.identifier&&(S.touch1[0]=B);if(O=S.that.__zoom,S.touch1){var Y=S.touch0[0],X=S.touch0[1],ee=S.touch1[0],J=S.touch1[1],Z=(Z=ee[0]-Y[0])*Z+(Z=ee[1]-Y[1])*Z,$=($=J[0]-X[0])*$+($=J[1]-X[1])*$;O=E(O,Math.sqrt(Z/$)),B=[(Y[0]+ee[0])/2,(Y[1]+ee[1])/2],H=[(X[0]+J[0])/2,(X[1]+J[1])/2]}else if(S.touch0)B=S.touch0[0],H=S.touch0[1];else return;S.zoom("touch",n(y(O,B,H),S.extent,i))}}function V(_,...C){if(this.__zooming){var S=k(this,C).event(_),I=_.changedTouches,R=I.length,A,O;for(er(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),A=0;A<R;++A)O=I[A],S.touch0&&S.touch0[2]===O.identifier?delete S.touch0:S.touch1&&S.touch1[2]===O.identifier&&delete S.touch1;if(S.touch1&&!S.touch0&&(S.touch0=S.touch1,delete S.touch1),S.touch0)S.touch0[1]=this.__zoom.invert(S.touch0[0]);else if(S.end(),S.taps===2&&(O=Ie(O,this),Math.hypot(u[0]-O[0],u[1]-O[1])<w)){var B=ve(this).on("dblclick.zoom");B&&B.apply(this,arguments)}}}return m.wheelDelta=function(_){return arguments.length?(r=typeof _=="function"?_:cn(+_),m):r},m.filter=function(_){return arguments.length?(e=typeof _=="function"?_:cn(!!_),m):e},m.touchable=function(_){return arguments.length?(s=typeof _=="function"?_:cn(!!_),m):s},m.extent=function(_){return arguments.length?(t=typeof _=="function"?_:cn([[+_[0][0],+_[0][1]],[+_[1][0],+_[1][1]]]),m):t},m.scaleExtent=function(_){return arguments.length?(o[0]=+_[0],o[1]=+_[1],m):[o[0],o[1]]},m.translateExtent=function(_){return arguments.length?(i[0][0]=+_[0][0],i[1][0]=+_[1][0],i[0][1]=+_[0][1],i[1][1]=+_[1][1],m):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},m.constrain=function(_){return arguments.length?(n=_,m):n},m.duration=function(_){return arguments.length?(a=+_,m):a},m.interpolate=function(_){return arguments.length?(c=_,m):c},m.on=function(){var _=l.on.apply(l,arguments);return _===l?m:_},m.clickDistance=function(_){return arguments.length?(v=(_=+_)*_,m):Math.sqrt(v)},m.tapDistance=function(_){return arguments.length?(w=+_,m):w},m}const De={error001:(e="react")=>`Seems like you have not used zustand provider as an ancestor. Help: https://${e}flow.dev/error#001`,error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,{id:t,sourceHandle:n,targetHandle:r})=>`Couldn't create edge for ${e} handle id: "${e==="source"?n:r}", edge id: ${t}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,error013:(e="react")=>`It seems that you haven't loaded the styles. Please import '@xyflow/${e}/dist/style.css' or base.css to make sure everything is working properly.`,error014:()=>"useNodeConnections: No node ID found. Call useNodeConnections inside a custom Node or provide a node ID.",error015:()=>"It seems that you are trying to drag a node that is not initialized. Please use onNodesChange as explained in the docs.",error016:e=>`Edge with id "${e}" does not exist, it may have been removed. This can happen when an edge is deleted before the "onEdgeClick" handler is called.`},Ht=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Go=["Enter"," ","Escape"],Uo={"node.a11yDescription.default":"Press enter or space to select a node. Press delete to remove it and escape to cancel.","node.a11yDescription.keyboardDisabled":"Press enter or space to select a node. You can then use the arrow keys to move the node around. Press delete to remove it and escape to cancel.","node.a11yDescription.ariaLiveMessage":({direction:e,x:t,y:n})=>`Moved selected node ${e}. New position, x: ${t}, y: ${n}`,"edge.a11yDescription.default":"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel.","controls.ariaLabel":"Control Panel","controls.zoomIn.ariaLabel":"Zoom In","controls.zoomOut.ariaLabel":"Zoom Out","controls.fitView.ariaLabel":"Fit View","controls.interactive.ariaLabel":"Toggle Interactivity","minimap.ariaLabel":"Mini Map","handle.ariaLabel":"Handle"};var vt;(function(e){e.Strict="strict",e.Loose="loose"})(vt||(vt={}));var st;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(st||(st={}));var Ot;(function(e){e.Partial="partial",e.Full="full"})(Ot||(Ot={}));const Zo={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Ue;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ue||(Ue={}));var Bt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Bt||(Bt={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const bs={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function Qo(e){return e===null?null:e?"valid":"invalid"}const Jo=e=>"id"in e&&"source"in e&&"target"in e,Gd=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),zr=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Kt=(e,t=[0,0])=>{const{width:n,height:r}=Ke(e),s=e.origin??t,o=n*s[0],i=r*s[1];return{x:e.position.x-o,y:e.position.y-i}},Ud=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const o=typeof s=="string";let i=!t.nodeLookup&&!o?s:void 0;t.nodeLookup&&(i=o?t.nodeLookup.get(s):zr(s)?s:t.nodeLookup.get(s.id));const a=i?kn(i,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Tn(r,a)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ln(n)},qt=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(s=>{(t.filter===void 0||t.filter(s))&&(n=Tn(n,kn(s)),r=!0)}),r?Ln(n):{x:0,y:0,width:0,height:0}},Hr=(e,t,[n,r,s]=[0,0,1],o=!1,i=!1)=>{const a={...Mt(t,[n,r,s]),width:t.width/s,height:t.height/s},c=[];for(const l of e.values()){const{measured:d,selectable:u=!0,hidden:f=!1}=l;if(i&&!u||f)continue;const h=d.width??l.width??l.initialWidth??null,p=d.height??l.height??l.initialHeight??null,v=Vt(a,_t(l)),w=(h??0)*(p??0),m=o&&v>0;(!l.internals.handleBounds||m||v>=w||l.dragging)&&c.push(l)}return c},Zd=(e,t)=>{const n=new Set;return e.forEach(r=>{n.add(r.id)}),t.filter(r=>n.has(r.source)||n.has(r.target))};function Qd(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(s=>s.id)):null;return e.forEach(s=>{s.measured.width&&s.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!s.hidden)&&(!r||r.has(s.id))&&n.set(s.id,s)}),n}async function Jd({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},i){if(e.size===0)return!0;const a=Qd(e,i),c=qt(a),l=Br(c,t,n,(i==null?void 0:i.minZoom)??s,(i==null?void 0:i.maxZoom)??o,(i==null?void 0:i.padding)??.1);return await r.setViewport(l,{duration:i==null?void 0:i.duration,ease:i==null?void 0:i.ease,interpolate:i==null?void 0:i.interpolate}),!0}function ei({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:o}){const i=n.get(e),a=i.parentId?n.get(i.parentId):void 0,{x:c,y:l}=a?a.internals.positionAbsolute:{x:0,y:0},d=i.origin??r;let u=i.extent||s;if(i.extent==="parent"&&!i.expandParent)if(!a)o==null||o("005",De.error005());else{const h=a.measured.width,p=a.measured.height;h&&p&&(u=[[c,l],[c+h,l+p]])}else a&&lt(i.extent)&&(u=[[i.extent[0][0]+c,i.extent[0][1]+l],[i.extent[1][0]+c,i.extent[1][1]+l]]);const f=lt(u)?ct(t,u,i.measured):t;return(i.measured.width===void 0||i.measured.height===void 0)&&(o==null||o("015",De.error015())),{position:{x:f.x-c+(i.measured.width??0)*d[0],y:f.y-l+(i.measured.height??0)*d[1]},positionAbsolute:f}}async function ef({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const o=new Set(e.map(f=>f.id)),i=[];for(const f of n){if(f.deletable===!1)continue;const h=o.has(f.id),p=!h&&f.parentId&&i.find(v=>v.id===f.parentId);(h||p)&&i.push(f)}const a=new Set(t.map(f=>f.id)),c=r.filter(f=>f.deletable!==!1),d=Zd(i,c);for(const f of c)a.has(f.id)&&!d.find(p=>p.id===f.id)&&d.push(f);if(!s)return{edges:d,nodes:i};const u=await s({nodes:i,edges:d});return typeof u=="boolean"?u?{edges:d,nodes:i}:{edges:[],nodes:[]}:u}const bt=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ct=(e={x:0,y:0},t,n)=>({x:bt(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:bt(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function ti(e,t,n){const{width:r,height:s}=Ke(n),{x:o,y:i}=n.internals.positionAbsolute;return ct(e,[[o,i],[o+r,i+s]],t)}const _s=(e,t,n)=>e<t?bt(Math.abs(e-t),1,t)/t:e>n?-bt(Math.abs(e-n),1,t)/t:0,Or=(e,t,n=15,r=40)=>{const s=_s(e.x,r,t.width-r)*n,o=_s(e.y,r,t.height-r)*n;return[s,o]},Tn=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),_r=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ln=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_t=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=zr(e)?e.internals.positionAbsolute:Kt(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},kn=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=zr(e)?e.internals.positionAbsolute:Kt(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},ni=(e,t)=>Ln(Tn(_r(e),_r(t))),Vt=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},Es=e=>je(e.width)&&je(e.height)&&je(e.x)&&je(e.y),je=e=>!isNaN(e)&&isFinite(e),ri=(e,t)=>(n,r)=>{},Gt=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Mt=({x:e,y:t},[n,r,s],o=!1,i=[1,1])=>{const a={x:(e-n)/s,y:(t-r)/s};return o?Gt(a,i):a},Et=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function ht(e,t){if(typeof e=="number")return Math.floor((t-t/(1+e))*.5);if(typeof e=="string"&&e.endsWith("px")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(n)}if(typeof e=="string"&&e.endsWith("%")){const n=parseFloat(e);if(!Number.isNaN(n))return Math.floor(t*n*.01)}return console.error(`The padding value "${e}" is invalid. Please provide a number or a string with a valid unit (px or %).`),0}function tf(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=ht(e,n),s=ht(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=ht(e.top??e.y??0,n),s=ht(e.bottom??e.y??0,n),o=ht(e.left??e.x??0,t),i=ht(e.right??e.x??0,t);return{top:r,right:i,bottom:s,left:o,x:o+i,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function nf(e,t,n,r,s,o){const{x:i,y:a}=Et(e,[t,n,r]),{x:c,y:l}=Et({x:e.x+e.width,y:e.y+e.height},[t,n,r]),d=s-c,u=o-l;return{left:Math.floor(i),top:Math.floor(a),right:Math.floor(d),bottom:Math.floor(u)}}const Br=(e,t,n,r,s,o)=>{const i=tf(o,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c),d=bt(l,r,s),u=e.x+e.width/2,f=e.y+e.height/2,h=t/2-u*d,p=n/2-f*d,v=nf(e,h,p,d,t,n),w={left:Math.min(v.left-i.left,0),top:Math.min(v.top-i.top,0),right:Math.min(v.right-i.right,0),bottom:Math.min(v.bottom-i.bottom,0)};return{x:h-w.left+w.right,y:p-w.top+w.bottom,zoom:d}},Ft=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function lt(e){return e!=null&&e!=="parent"}function Ke(e){var t,n;return{width:((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth??0,height:((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight??0}}function si(e){var t,n;return(((t=e.measured)==null?void 0:t.width)??e.width??e.initialWidth)!==void 0&&(((n=e.measured)==null?void 0:n.height)??e.height??e.initialHeight)!==void 0}function oi(e,t={width:0,height:0},n,r,s){const o={...e},i=r.get(n);if(i){const a=i.origin||s;o.x+=i.internals.positionAbsolute.x-(t.width??0)*a[0],o.y+=i.internals.positionAbsolute.y-(t.height??0)*a[1]}return o}function Ns(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function rf(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function sf(e){return{...Uo,...e||{}}}function Dt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:i}=Pe(e),a=Mt({x:o-((s==null?void 0:s.left)??0),y:i-((s==null?void 0:s.top)??0)},r),{x:c,y:l}=n?Gt(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Vr=e=>({width:e.offsetWidth,height:e.offsetHeight}),ii=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},of=["INPUT","SELECT","TEXTAREA"];function ai(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:of.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const ci=e=>"clientX"in e,Pe=(e,t)=>{var o,i;const n=ci(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},Ss=(e,t,n,r,s)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(i=>{const a=i.getBoundingClientRect();return{id:i.getAttribute("data-handleid"),type:e,nodeId:s,position:i.getAttribute("data-handlepos"),x:(a.left-n.left)/r,y:(a.top-n.top)/r,...Vr(i)}})};function li({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:i,targetControlY:a}){const c=e*.125+s*.375+i*.375+n*.125,l=t*.125+o*.375+a*.375+r*.125,d=Math.abs(c-e),u=Math.abs(l-t);return[c,l,d,u]}function ln(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function ks({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Q.Left:return[t-ln(t-r,o),n];case Q.Right:return[t+ln(r-t,o),n];case Q.Top:return[t,n-ln(n-s,o)];case Q.Bottom:return[t,n+ln(s-n,o)]}}function ui({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:s,targetPosition:o=Q.Top,curvature:i=.25}){const[a,c]=ks({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[l,d]=ks({pos:o,x1:r,y1:s,x2:e,y2:t,c:i}),[u,f,h,p]=li({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:c,targetControlX:l,targetControlY:d});return[`M${e},${t} C${a},${c} ${l},${d} ${r},${s}`,u,f,h,p]}function di({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,i=Math.abs(r-t)/2,a=r<t?r+i:r-i;return[o,a,s,i]}function af({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const i=s&&n?r+1e3:r,a=Math.max(e.parentId||s&&e.selected?e.internals.z:0,t.parentId||s&&t.selected?t.internals.z:0);return i+a}function cf({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=Tn(kn(e),kn(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const i={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return Vt(i,Ln(o))>0}const lf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,uf=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),df=(e,t,n={})=>{var o;if(!e.source||!e.target)return(o=n.onError)==null||o.call(n,"006",De.error006()),t;const r=n.getEdgeId||lf;let s;return Jo(e)?s={...e}:s={...e,id:r(e)},uf(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function fi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,i,a]=di({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,i,a]}const Ms={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},ff=({source:e,sourcePosition:t=Q.Bottom,target:n})=>t===Q.Left||t===Q.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},Cs=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function hf({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:s,offset:o,stepPosition:i}){const a=Ms[t],c=Ms[r],l={x:e.x+a.x*o,y:e.y+a.y*o},d={x:n.x+c.x*o,y:n.y+c.y*o},u=ff({source:l,sourcePosition:t,target:d}),f=u.x!==0?"x":"y",h=u[f];let p=[],v,w;const m={x:0,y:0},E={x:0,y:0},[,,y,x]=di({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(a[f]*c[f]===-1){f==="x"?(v=s.x??l.x+(d.x-l.x)*i,w=s.y??(l.y+d.y)/2):(v=s.x??(l.x+d.x)/2,w=s.y??l.y+(d.y-l.y)*i);const D=[{x:v,y:l.y},{x:v,y:d.y}],L=[{x:l.x,y:w},{x:d.x,y:w}];a[f]===h?p=f==="x"?D:L:p=f==="x"?L:D}else{const D=[{x:l.x,y:d.y}],L=[{x:d.x,y:l.y}];if(f==="x"?p=a.x===h?L:D:p=a.y===h?D:L,t===r){const _=Math.abs(e[f]-n[f]);if(_<=o){const C=Math.min(o-1,o-_);a[f]===h?m[f]=(l[f]>e[f]?-1:1)*C:E[f]=(d[f]>n[f]?-1:1)*C}}if(t!==r){const _=f==="x"?"y":"x",C=a[f]===c[_],S=l[_]>d[_],I=l[_]<d[_];(a[f]===1&&(!C&&S||C&&I)||a[f]!==1&&(!C&&I||C&&S))&&(p=f==="x"?D:L)}const F={x:l.x+m.x,y:l.y+m.y},M={x:d.x+E.x,y:d.y+E.y},j=Math.max(Math.abs(F.x-p[0].x),Math.abs(M.x-p[0].x)),V=Math.max(Math.abs(F.y-p[0].y),Math.abs(M.y-p[0].y));j>=V?(v=(F.x+M.x)/2,w=p[0].y):(v=p[0].x,w=(F.y+M.y)/2)}const N={x:l.x+m.x,y:l.y+m.y},k={x:d.x+E.x,y:d.y+E.y};return[[e,...N.x!==p[0].x||N.y!==p[0].y?[N]:[],...p,...k.x!==p[p.length-1].x||k.y!==p[p.length-1].y?[k]:[],n],v,w,y,x]}function gf(e,t,n,r){const s=Math.min(Cs(e,t)/2,Cs(t,n)/2,r),{x:o,y:i}=t;if(e.x===o&&o===n.x||e.y===i&&i===n.y)return`L${o} ${i}`;if(e.y===i){const l=e.x<n.x?-1:1,d=e.y<n.y?1:-1;return`L ${o+s*l},${i}Q ${o},${i} ${o},${i+s*d}`}const a=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${i+s*c}Q ${o},${i} ${o+s*a},${i}`}function Er({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:s,targetPosition:o=Q.Top,borderRadius:i=5,centerX:a,centerY:c,offset:l=20,stepPosition:d=.5}){const[u,f,h,p,v]=hf({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:a,y:c},offset:l,stepPosition:d});let w=`M${u[0].x} ${u[0].y}`;for(let m=1;m<u.length-1;m++)w+=gf(u[m-1],u[m],u[m+1],i);return w+=`L${u[u.length-1].x} ${u[u.length-1].y}`,[w,f,h,p,v]}function As(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function pf(e){var u;const{sourceNode:t,targetNode:n}=e;if(!As(t)||!As(n))return null;const r=t.internals.handleBounds||Is(t.handles),s=n.internals.handleBounds||Is(n.handles),o=$s((r==null?void 0:r.source)??[],e.sourceHandle),i=$s(e.connectionMode===vt.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!o||!i)return(u=e.onError)==null||u.call(e,"008",De.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const a=(o==null?void 0:o.position)||Q.Bottom,c=(i==null?void 0:i.position)||Q.Top,l=ut(t,o,a),d=ut(n,i,c);return{sourceX:l.x,sourceY:l.y,targetX:d.x,targetY:d.y,sourcePosition:a,targetPosition:c}}function Is(e){if(!e)return null;const t=[],n=[];for(const r of e)r.width=r.width??1,r.height=r.height??1,r.type==="source"?t.push(r):r.type==="target"&&n.push(r);return{source:t,target:n}}function ut(e,t,n=Q.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:i,height:a}=t??Ke(e);if(r)return{x:s+i/2,y:o+a/2};switch((t==null?void 0:t.position)??n){case Q.Top:return{x:s+i/2,y:o};case Q.Right:return{x:s+i,y:o+a/2};case Q.Bottom:return{x:s+i/2,y:o+a};case Q.Left:return{x:s,y:o+a/2}}}function $s(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Nr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function mf(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const o=new Set;return e.reduce((i,a)=>([a.markerStart||r,a.markerEnd||s].forEach(c=>{if(c&&typeof c=="object"){const l=Nr(c,t);o.has(l)||(i.push({id:l,color:c.color||n,...c}),o.add(l))}}),i),[]).sort((i,a)=>i.id.localeCompare(a.id))}const hi=1e3,yf=10,Fr={nodeOrigin:[0,0],nodeExtent:Ht,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},xf={...Fr,checkEquality:!0};function Wr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function wf(e,t,n){const r=Wr(Fr,n);for(const s of e.values())if(s.parentId)Xr(s,e,t,r);else{const o=Kt(s,r.nodeOrigin),i=lt(s.extent)?s.extent:r.nodeExtent,a=ct(o,i,Ke(s));s.internals.positionAbsolute=a}}function vf(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const s of e.handles){const o={id:s.id,width:s.width??1,height:s.height??1,nodeId:e.id,x:s.x,y:s.y,position:s.position,type:s.type};s.type==="source"?n.push(o):s.type==="target"&&r.push(o)}return{source:n,target:r}}function Yr(e){return e==="manual"}function Sr(e,t,n,r={}){var d,u;const s=Wr(xf,r),o={i:0},i=new Map(t),a=s!=null&&s.elevateNodesOnSelect&&!Yr(s.zIndexMode)?hi:0;let c=e.length>0,l=!1;t.clear(),n.clear();for(const f of e){let h=i.get(f.id);if(s.checkEquality&&f===(h==null?void 0:h.internals.userNode))t.set(f.id,h);else{const p=Kt(f,s.nodeOrigin),v=lt(f.extent)?f.extent:s.nodeExtent,w=ct(p,v,Ke(f));h={...s.defaults,...f,measured:{width:(d=f.measured)==null?void 0:d.width,height:(u=f.measured)==null?void 0:u.height},internals:{positionAbsolute:w,handleBounds:vf(f,h),z:gi(f,a,s.zIndexMode),userNode:f}},t.set(f.id,h)}(h.measured===void 0||h.measured.width===void 0||h.measured.height===void 0)&&!h.hidden&&(c=!1),f.parentId&&Xr(h,t,n,r,o),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function bf(e,t){if(!e.parentId)return;const n=t.get(e.parentId);n?n.set(e.id,e):t.set(e.parentId,new Map([[e.id,e]]))}function Xr(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=Wr(Fr,r),l=e.parentId,d=t.get(l);if(!d){console.warn(`Parent node ${l} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}bf(e,n),s&&!d.parentId&&d.internals.rootParentIndex===void 0&&c==="auto"&&(d.internals.rootParentIndex=++s.i,d.internals.z=d.internals.z+s.i*yf),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const u=o&&!Yr(c)?hi:0,{x:f,y:h,z:p}=_f(e,d,i,a,u,c),{positionAbsolute:v}=e.internals,w=f!==v.x||h!==v.y;(w||p!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:f,y:h}:v,z:p}})}function gi(e,t,n){const r=je(e.zIndex)?e.zIndex:0;return Yr(n)?r:r+(e.selected?t:0)}function _f(e,t,n,r,s,o){const{x:i,y:a}=t.internals.positionAbsolute,c=Ke(e),l=Kt(e,n),d=lt(e.extent)?ct(l,e.extent,c):l;let u=ct({x:i+d.x,y:a+d.y},r,c);e.extent==="parent"&&(u=ti(u,c,t));const f=gi(e,s,o),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function Kr(e,t,n,r=[0,0]){var i;const s=[],o=new Map;for(const a of e){const c=t.get(a.parentId);if(!c)continue;const l=((i=o.get(a.parentId))==null?void 0:i.expandedRect)??_t(c),d=ni(l,a.rect);o.set(a.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:a,parent:c},l)=>{var y;const d=c.internals.positionAbsolute,u=Ke(c),f=c.origin??r,h=a.x<d.x?Math.round(Math.abs(d.x-a.x)):0,p=a.y<d.y?Math.round(Math.abs(d.y-a.y)):0,v=Math.max(u.width,Math.round(a.width)),w=Math.max(u.height,Math.round(a.height)),m=(v-u.width)*f[0],E=(w-u.height)*f[1];(h>0||p>0||m||E)&&(s.push({id:l,type:"position",position:{x:c.position.x-h+m,y:c.position.y-p+E}}),(y=n.get(l))==null||y.forEach(x=>{e.some(N=>N.id===x.id)||s.push({id:x.id,type:"position",position:{x:x.position.x+h,y:x.position.y+p}})})),(u.width<a.width||u.height<a.height||h||p)&&s.push({id:l,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?f[0]*h-m:0),height:w+(p?f[1]*p-E:0)}})}),s}function Ef(e,t,n,r,s,o,i){const a=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!a)return{changes:[],updatedInternals:c};const l=[],d=window.getComputedStyle(a),{m22:u}=new window.DOMMatrixReadOnly(d.transform),f=[];for(const h of e.values()){const p=t.get(h.id);if(!p)continue;if(p.hidden){t.set(p.id,{...p,internals:{...p.internals,handleBounds:void 0}}),c=!0;continue}const v=Vr(h.nodeElement),w=p.measured.width!==v.width||p.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!p.internals.handleBounds||h.force))){const E=h.nodeElement.getBoundingClientRect(),y=lt(p.extent)?p.extent:o;let{positionAbsolute:x}=p.internals;p.parentId&&p.extent==="parent"?x=ti(x,v,t.get(p.parentId)):y&&(x=ct(x,y,v));const N={...p,measured:v,internals:{...p.internals,positionAbsolute:x,handleBounds:{source:Ss("source",h.nodeElement,E,u,p.id),target:Ss("target",h.nodeElement,E,u,p.id)}}};t.set(p.id,N),p.parentId&&Xr(N,t,n,{nodeOrigin:s,zIndexMode:i}),c=!0,w&&(l.push({id:p.id,type:"dimensions",dimensions:v}),p.expandParent&&p.parentId&&f.push({id:p.id,parentId:p.parentId,rect:_t(N,s)}))}}if(f.length>0){const h=Kr(f,t,n,s);l.push(...h)}return{changes:l,updatedInternals:c}}async function Nf({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:o}){if(!t||!e.x&&!e.y)return!1;const i=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[s,o]],r);return!!i&&(i.x!==n[0]||i.y!==n[1]||i.k!==n[2])}function js(e,t,n,r,s,o){let i=s;const a=r.get(i)||new Map;r.set(i,a.set(n,t)),i=`${s}-${e}`;const c=r.get(i)||new Map;if(r.set(i,c.set(n,t)),o){i=`${s}-${e}-${o}`;const l=r.get(i)||new Map;r.set(i,l.set(n,t))}}function pi(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:o,sourceHandle:i=null,targetHandle:a=null}=r,c={edgeId:r.id,source:s,target:o,sourceHandle:i,targetHandle:a},l=`${s}-${i}--${o}-${a}`,d=`${o}-${a}--${s}-${i}`;js("source",c,d,e,s,i),js("target",c,l,e,o,a),t.set(r.id,r)}}function mi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:mi(n,t):!1}function Ps(e,t,n){var s;let r=e;do{if((s=r==null?void 0:r.matches)!=null&&s.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function Sf(e,t,n,r){const s=new Map;for(const[o,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!mi(i,e))&&(i.draggable||t&&typeof i.draggable>"u")){const a=e.get(o);a&&s.set(o,{id:o,position:a.position||{x:0,y:0},distance:{x:n.x-a.internals.positionAbsolute.x,y:n.y-a.internals.positionAbsolute.y},extent:a.extent,parentId:a.parentId,origin:a.origin,expandParent:a.expandParent,internals:{positionAbsolute:a.internals.positionAbsolute||{x:0,y:0}},measured:{width:a.measured.width??0,height:a.measured.height??0}})}return s}function tr({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var i,a,c;const s=[];for(const[l,d]of t){const u=(i=n.get(l))==null?void 0:i.internals.userNode;u&&s.push({...u,position:d.position,dragging:r})}if(!e)return[s[0],s];const o=(a=n.get(e))==null?void 0:a.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:r}:s[0],s]}function kf({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const o={x:n-s.distance.x,y:r-s.distance.y},i=Gt(o,t);return{x:i.x-o.x,y:i.y-o.y}}function Mf({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},i=0,a=new Map,c=!1,l={x:0,y:0},d=null,u=!1,f=null,h=!1,p=!1,v=null;function w({noDragClassName:E,handleSelector:y,domNode:x,isSelectable:N,nodeId:k,nodeClickDistance:P=0}){f=ve(x);function D({x:j,y:V}){const{nodeLookup:_,nodeExtent:C,snapGrid:S,snapToGrid:I,nodeOrigin:R,onNodeDrag:A,onSelectionDrag:O,onError:B,updateNodePositions:H}=t();o={x:j,y:V};let Y=!1;const X=a.size>1,ee=X&&C?_r(qt(a)):null,J=X&&I?kf({dragItems:a,snapGrid:S,x:j,y:V}):null;for(const[Z,$]of a){if(!_.has(Z))continue;let W={x:j-$.distance.x,y:V-$.distance.y};I&&(W=J?{x:Math.round(W.x+J.x),y:Math.round(W.y+J.y)}:Gt(W,S));let ne=null;if(X&&C&&!$.extent&&ee){const{positionAbsolute:G}=$.internals,re=G.x-ee.x+C[0][0],se=G.x+$.measured.width-ee.x2+C[1][0],ie=G.y-ee.y+C[0][1],ce=G.y+$.measured.height-ee.y2+C[1][1];ne=[[re,ie],[se,ce]]}const{position:te,positionAbsolute:q}=ei({nodeId:Z,nextPosition:W,nodeLookup:_,nodeExtent:ne||C,nodeOrigin:R,onError:B});Y=Y||$.position.x!==te.x||$.position.y!==te.y,$.position=te,$.internals.positionAbsolute=q}if(p=p||Y,!!Y&&(H(a,!0),v&&(r||A||!k&&O))){const[Z,$]=tr({nodeId:k,dragItems:a,nodeLookup:_});r==null||r(v,a,Z,$),A==null||A(v,Z,$),k||O==null||O(v,$)}}async function L(){if(!d)return;const{transform:j,panBy:V,autoPanSpeed:_,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(i);return}const[S,I]=Or(l,d,_);(S!==0||I!==0)&&(o.x=(o.x??0)-S/j[2],o.y=(o.y??0)-I/j[2],await V({x:S,y:I})&&D(o)),i=requestAnimationFrame(L)}function F(j){var X;const{nodeLookup:V,multiSelectionActive:_,nodesDraggable:C,transform:S,snapGrid:I,snapToGrid:R,selectNodesOnDrag:A,onNodeDragStart:O,onSelectionDragStart:B,unselectNodesAndEdges:H}=t();u=!0,(!A||!N)&&!_&&k&&((X=V.get(k))!=null&&X.selected||H()),N&&A&&k&&(e==null||e(k));const Y=Dt(j.sourceEvent,{transform:S,snapGrid:I,snapToGrid:R,containerBounds:d});if(o=Y,a=Sf(V,C,Y,k),a.size>0&&(n||O||!k&&B)){const[ee,J]=tr({nodeId:k,dragItems:a,nodeLookup:V});n==null||n(j.sourceEvent,a,ee,J),O==null||O(j.sourceEvent,ee,J),k||B==null||B(j.sourceEvent,J)}}const M=Po().clickDistance(P).on("start",j=>{const{domNode:V,nodeDragThreshold:_,transform:C,snapGrid:S,snapToGrid:I}=t();d=(V==null?void 0:V.getBoundingClientRect())||null,h=!1,p=!1,v=j.sourceEvent,_===0&&F(j),o=Dt(j.sourceEvent,{transform:C,snapGrid:S,snapToGrid:I,containerBounds:d}),l=Pe(j.sourceEvent,d)}).on("drag",j=>{const{autoPanOnNodeDrag:V,transform:_,snapGrid:C,snapToGrid:S,nodeDragThreshold:I,nodeLookup:R}=t(),A=Dt(j.sourceEvent,{transform:_,snapGrid:C,snapToGrid:S,containerBounds:d});if(v=j.sourceEvent,(j.sourceEvent.type==="touchmove"&&j.sourceEvent.touches.length>1||k&&!R.has(k))&&(h=!0),!h){if(!c&&V&&u&&(c=!0,L()),!u){const O=Pe(j.sourceEvent,d),B=O.x-l.x,H=O.y-l.y;Math.sqrt(B*B+H*H)>I&&F(j)}(o.x!==A.xSnapped||o.y!==A.ySnapped)&&a&&u&&(l=Pe(j.sourceEvent,d),D(A))}}).on("end",j=>{if(!u||h){h&&a.size>0&&t().updateNodePositions(a,!1);return}if(c=!1,u=!1,cancelAnimationFrame(i),a.size>0){const{nodeLookup:V,updateNodePositions:_,onNodeDragStop:C,onSelectionDragStop:S}=t();if(p&&(_(a,!1),p=!1),s||C||!k&&S){const[I,R]=tr({nodeId:k,dragItems:a,nodeLookup:V,dragging:!1});s==null||s(j.sourceEvent,a,I,R),C==null||C(j.sourceEvent,I,R),k||S==null||S(j.sourceEvent,R)}}}).filter(j=>{const V=j.target;return!j.button&&(!E||!Ps(V,`.${E}`,x))&&(!y||Ps(V,y,x))});f.call(M)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function Cf(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())Vt(s,_t(o))>0&&r.push(o);return r}const Af=250;function If(e,t,n,r){var a,c;let s=[],o=1/0;const i=Cf(e,n,t+Af);for(const l of i){const d=[...((a=l.internals.handleBounds)==null?void 0:a.source)??[],...((c=l.internals.handleBounds)==null?void 0:c.target)??[]];for(const u of d){if(r.nodeId===u.nodeId&&r.type===u.type&&r.id===u.id)continue;const{x:f,y:h}=ut(l,u,u.position,!0),p=Math.sqrt(Math.pow(f-e.x,2)+Math.pow(h-e.y,2));p>t||(p<o?(s=[{...u,x:f,y:h}],o=p):p===o&&s.push({...u,x:f,y:h}))}}if(!s.length)return null;if(s.length>1){const l=r.type==="source"?"target":"source";return s.find(d=>d.type===l)??s[0]}return s[0]}function yi(e,t,n,r,s,o=!1){var l,d,u;const i=r.get(e);if(!i)return null;const a=s==="strict"?(l=i.internals.handleBounds)==null?void 0:l[t]:[...((d=i.internals.handleBounds)==null?void 0:d.source)??[],...((u=i.internals.handleBounds)==null?void 0:u.target)??[]],c=(n?a==null?void 0:a.find(f=>f.id===n):a==null?void 0:a[0])??null;return c&&o?{...c,...ut(i,c,c.position,!0)}:c}function xi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function $f(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const wi=()=>!0;function jf(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:o,isTarget:i,domNode:a,nodeLookup:c,lib:l,autoPanOnConnect:d,flowId:u,panBy:f,cancelConnection:h,onConnectStart:p,onConnect:v,onConnectEnd:w,isValidConnection:m=wi,onReconnectEnd:E,updateConnection:y,getTransform:x,getFromHandle:N,autoPanSpeed:k,dragThreshold:P=1,handleDomNode:D}){const L=ii(e.target);let F=0,M;const{x:j,y:V}=Pe(e),_=xi(o,D),C=a==null?void 0:a.getBoundingClientRect();let S=!1;if(!C||!_)return;const I=yi(s,_,r,c,t);if(!I)return;let R=Pe(e,C),A=!1,O=null,B=!1,H=null;function Y(){if(!d||!C)return;const[te,q]=Or(R,C,k);f({x:te,y:q}),F=requestAnimationFrame(Y)}const X={...I,nodeId:s,type:_,position:I.position},ee=c.get(s);let Z={inProgress:!0,isValid:null,from:ut(ee,X,Q.Left,!0),fromHandle:X,fromPosition:X.position,fromNode:ee,to:R,toHandle:null,toPosition:bs[X.position],toNode:null,pointer:R};function $(){S=!0,y(Z),p==null||p(e,{nodeId:s,handleId:r,handleType:_})}P===0&&$();function W(te){if(!S){const{x:ce,y:me}=Pe(te),_e=ce-j,ye=me-V;if(!(_e*_e+ye*ye>P*P))return;$()}if(!N()||!X){ne(te);return}const q=x();R=Pe(te,C),M=If(Mt(R,q,!1,[1,1]),n,c,X),A||(Y(),A=!0);const G=vi(te,{handle:M,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:m,doc:L,lib:l,flowId:u,nodeLookup:c});H=G.handleDomNode,O=G.connection,B=$f(!!M,G.isValid);const re=c.get(s),se=re?ut(re,X,Q.Left,!0):Z.from,ie={...Z,from:se,isValid:B,to:G.toHandle&&B?Et({x:G.toHandle.x,y:G.toHandle.y},q):R,toHandle:G.toHandle,toPosition:B&&G.toHandle?G.toHandle.position:bs[X.position],toNode:G.toHandle?c.get(G.toHandle.nodeId):null,pointer:R};y(ie),Z=ie}function ne(te){if(!("touches"in te&&te.touches.length>0)){if(S){(M||H)&&O&&B&&(v==null||v(O));const{inProgress:q,...G}=Z,re={...G,toPosition:Z.toHandle?Z.toPosition:null};w==null||w(te,re),o&&(E==null||E(te,re))}h(),cancelAnimationFrame(F),A=!1,B=!1,O=null,H=null,L.removeEventListener("mousemove",W),L.removeEventListener("mouseup",ne),L.removeEventListener("touchmove",W),L.removeEventListener("touchend",ne)}}L.addEventListener("mousemove",W),L.addEventListener("mouseup",ne),L.addEventListener("touchmove",W),L.addEventListener("touchend",ne)}function vi(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:i,lib:a,flowId:c,isValidConnection:l=wi,nodeLookup:d}){const u=o==="target",f=t?i.querySelector(`.${a}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:h,y:p}=Pe(e),v=i.elementFromPoint(h,p),w=v!=null&&v.classList.contains(`${a}-flow__handle`)?v:f,m={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const E=xi(void 0,w),y=w.getAttribute("data-nodeid"),x=w.getAttribute("data-handleid"),N=w.classList.contains("connectable"),k=w.classList.contains("connectableend");if(!y||!E)return m;const P={source:u?y:r,sourceHandle:u?x:s,target:u?r:y,targetHandle:u?s:x};m.connection=P;const L=N&&k&&(n===vt.Strict?u&&E==="source"||!u&&E==="target":y!==r||x!==s);m.isValid=L&&l(P),m.toHandle=yi(y,E,x,d,n,!0)}return m}const kr={onPointerDown:jf,isValid:vi};function Pf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=ve(e);function o({translateExtent:a,width:c,height:l,zoomStep:d=1,pannable:u=!0,zoomable:f=!0,inversePan:h=!1}){const p=y=>{if(y.sourceEvent.type!=="wheel"||!t)return;const x=n(),N=y.sourceEvent.ctrlKey&&Ft()?10:1,k=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*d,P=x[2]*Math.pow(2,k*N);t.scaleTo(P)};let v=[0,0];const w=y=>{(y.sourceEvent.type==="mousedown"||y.sourceEvent.type==="touchstart")&&(v=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY])},m=y=>{const x=n();if(y.sourceEvent.type!=="mousemove"&&y.sourceEvent.type!=="touchmove"||!t)return;const N=[y.sourceEvent.clientX??y.sourceEvent.touches[0].clientX,y.sourceEvent.clientY??y.sourceEvent.touches[0].clientY],k=[N[0]-v[0],N[1]-v[1]];v=N;const P=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),D={x:x[0]-k[0]*P,y:x[1]-k[1]*P},L=[[0,0],[c,l]];t.setViewportConstrained({x:D.x,y:D.y,zoom:x[2]},L,a)},E=qo().on("start",w).on("zoom",u?m:null).on("zoom.wheel",f?p:null);s.call(E,{})}function i(){s.on("zoom",null)}return{update:o,destroy:i,pointer:Ie}}const Rn=e=>({x:e.x,y:e.y,zoom:e.k}),nr=({x:e,y:t,zoom:n})=>Dn.translate(e,t).scale(n),gt=(e,t)=>e.target.closest(`.${t}`),bi=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Df=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,rr=(e,t=0,n=Df,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},_i=e=>{const t=e.ctrlKey&&Ft()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Tf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(gt(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const u=n.property("__zoom").k||1;if(d.ctrlKey&&i){const w=Ie(d),m=_i(d),E=u*Math.pow(2,m);r.scaleTo(n,E,w,d);return}const f=d.deltaMode===1?20:1;let h=s===st.Vertical?0:d.deltaX*f,p=s===st.Horizontal?0:d.deltaY*f;!Ft()&&d.shiftKey&&s!==st.Vertical&&(h=d.deltaY*f,p=0),r.translateBy(n,-(h/u)*o,-(p/u)*o,{internal:!0});const v=Rn(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(d,v),e.panScrollTimeout=setTimeout(()=>{l==null||l(d,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,a==null||a(d,v))}}function Lf({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",i=!t&&o&&!r.ctrlKey,a=gt(r,e);if(r.ctrlKey&&o&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,s)}}function Rf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,i,a;if((o=r.sourceEvent)!=null&&o.internal)return;const s=Rn(r.transform);e.mouseButton=((i=r.sourceEvent)==null?void 0:i.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=s,((a=r.sourceEvent)==null?void 0:a.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,s))}}function zf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var i,a;e.usedRightMouseButton=!!(n&&bi(t,e.mouseButton??0)),(i=o.sourceEvent)!=null&&i.sync||r([o.transform.x,o.transform.y,o.transform.k]),s&&!((a=o.sourceEvent)!=null&&a.internal)&&(s==null||s(o.sourceEvent,Rn(o.transform)))}}function Hf({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:o}){return i=>{var a;if(!((a=i.sourceEvent)!=null&&a.internal)&&(e.isZoomingOrPanning=!1,o&&bi(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&o(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Rn(i.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(i.sourceEvent,c)},n?150:0)}}}function Of({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:o,userSelectionActive:i,noWheelClassName:a,noPanClassName:c,lib:l,connectionInProgress:d}){return u=>{var w;const f=e||t,h=n&&u.ctrlKey,p=u.type==="wheel";if(u.button===1&&u.type==="mousedown"&&(gt(u,`${l}-flow__node`)||gt(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!s&&!o&&!n||i||d&&!p||gt(u,a)&&p||gt(u,c)&&(!p||s&&p&&!e)||!n&&u.ctrlKey&&p)return!1;if(!n&&u.type==="touchstart"&&((w=u.touches)==null?void 0:w.length)>1)return u.preventDefault(),!1;if(!f&&!s&&!h&&p||!r&&(u.type==="mousedown"||u.type==="touchstart")||Array.isArray(r)&&!r.includes(u.button)&&u.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(u.button)||!u.button||u.button<=1;return(!u.ctrlKey||p)&&v}}function Bf({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:o,onPanZoomStart:i,onPanZoomEnd:a,onDraggingChange:c}){const l={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},d=e.getBoundingClientRect(),u=qo().scaleExtent([t,n]).translateExtent(r),f=ve(e).call(u);E({x:s.x,y:s.y,zoom:bt(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),p=f.on("dblclick.zoom");u.wheelDelta(_i);async function v(M,j){return f?new Promise(V=>{u==null||u.interpolate((j==null?void 0:j.interpolate)==="linear"?Pt:pn).transform(rr(f,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>V(!0)),M)}):!1}function w({noWheelClassName:M,noPanClassName:j,onPaneContextMenu:V,userSelectionActive:_,panOnScroll:C,panOnDrag:S,panOnScrollMode:I,panOnScrollSpeed:R,preventScrolling:A,zoomOnPinch:O,zoomOnScroll:B,zoomOnDoubleClick:H,zoomActivationKeyPressed:Y,lib:X,onTransformChange:ee,connectionInProgress:J,paneClickDistance:Z,selectionOnDrag:$}){_&&!l.isZoomingOrPanning&&m();const W=C&&!Y&&!_;u.clickDistance($?1/0:!je(Z)||Z<0?0:Z);const ne=W?Tf({zoomPanValues:l,noWheelClassName:M,d3Selection:f,d3Zoom:u,panOnScrollMode:I,panOnScrollSpeed:R,zoomOnPinch:O,onPanZoomStart:i,onPanZoom:o,onPanZoomEnd:a}):Lf({noWheelClassName:M,preventScrolling:A,d3ZoomHandler:h});f.on("wheel.zoom",ne,{passive:!1});const te=Rf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});u.on("start",te);const q=zf({zoomPanValues:l,panOnDrag:S,onPaneContextMenu:!!V,onPanZoom:o,onTransformChange:ee});u.on("zoom",q);const G=Hf({zoomPanValues:l,panOnDrag:S,panOnScroll:C,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:c});u.on("end",G);const re=Of({zoomActivationKeyPressed:Y,panOnDrag:S,zoomOnScroll:B,panOnScroll:C,zoomOnDoubleClick:H,zoomOnPinch:O,userSelectionActive:_,noPanClassName:j,noWheelClassName:M,lib:X,connectionInProgress:J});u.filter(re),H?f.on("dblclick.zoom",p):f.on("dblclick.zoom",null)}function m(){u.on("zoom",null)}async function E(M,j,V){const _=nr(M),C=u==null?void 0:u.constrain()(_,j,V);return C&&await v(C),C}async function y(M,j){const V=nr(M);return await v(V,j),V}function x(M){if(f){const j=nr(M),V=f.property("__zoom");(V.k!==M.zoom||V.x!==M.x||V.y!==M.y)&&(u==null||u.transform(f,j,null,{sync:!0}))}}function N(){const M=f?Ko(f.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function k(M,j){return f?new Promise(V=>{u==null||u.interpolate((j==null?void 0:j.interpolate)==="linear"?Pt:pn).scaleTo(rr(f,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>V(!0)),M)}):!1}async function P(M,j){return f?new Promise(V=>{u==null||u.interpolate((j==null?void 0:j.interpolate)==="linear"?Pt:pn).scaleBy(rr(f,j==null?void 0:j.duration,j==null?void 0:j.ease,()=>V(!0)),M)}):!1}function D(M){u==null||u.scaleExtent(M)}function L(M){u==null||u.translateExtent(M)}function F(M){const j=!je(M)||M<0?0:M;u==null||u.clickDistance(j)}return{update:w,destroy:m,setViewport:y,setViewportConstrained:E,getViewport:N,scaleTo:k,scaleBy:P,setScaleExtent:D,setTranslateExtent:L,syncViewport:x,setClickDistance:F}}var Nt;(function(e){e.Line="line",e.Handle="handle"})(Nt||(Nt={}));function Vf({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:o}){const i=e-t,a=n-r,c=[i>0?1:i<0?-1:0,a>0?1:a<0?-1:0];return i&&s&&(c[0]=c[0]*-1),a&&o&&(c[1]=c[1]*-1),c}function Ds(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function qe(e,t){return Math.max(0,t-e)}function Ge(e,t){return Math.max(0,e-t)}function un(e,t,n){return Math.max(0,t-e,e-n)}function Ts(e,t){return e?!t:t}function Ff(e,t,n,r,s,o,i,a){let{affectsX:c,affectsY:l}=t;const{isHorizontal:d,isVertical:u}=t,f=d&&u,{xSnapped:h,ySnapped:p}=n,{minWidth:v,maxWidth:w,minHeight:m,maxHeight:E}=r,{x:y,y:x,width:N,height:k,aspectRatio:P}=e;let D=Math.floor(d?h-e.pointerX:0),L=Math.floor(u?p-e.pointerY:0);const F=N+(c?-D:D),M=k+(l?-L:L),j=-o[0]*N,V=-o[1]*k;let _=un(F,v,w),C=un(M,m,E);if(i){let R=0,A=0;c&&D<0?R=qe(y+D+j,i[0][0]):!c&&D>0&&(R=Ge(y+F+j,i[1][0])),l&&L<0?A=qe(x+L+V,i[0][1]):!l&&L>0&&(A=Ge(x+M+V,i[1][1])),_=Math.max(_,R),C=Math.max(C,A)}if(a){let R=0,A=0;c&&D>0?R=Ge(y+D,a[0][0]):!c&&D<0&&(R=qe(y+F,a[1][0])),l&&L>0?A=Ge(x+L,a[0][1]):!l&&L<0&&(A=qe(x+M,a[1][1])),_=Math.max(_,R),C=Math.max(C,A)}if(s){if(d){const R=un(F/P,m,E)*P;if(_=Math.max(_,R),i){let A=0;!c&&!l||c&&!l&&f?A=Ge(x+V+F/P,i[1][1])*P:A=qe(x+V+(c?D:-D)/P,i[0][1])*P,_=Math.max(_,A)}if(a){let A=0;!c&&!l||c&&!l&&f?A=qe(x+F/P,a[1][1])*P:A=Ge(x+(c?D:-D)/P,a[0][1])*P,_=Math.max(_,A)}}if(u){const R=un(M*P,v,w)/P;if(C=Math.max(C,R),i){let A=0;!c&&!l||l&&!c&&f?A=Ge(y+M*P+j,i[1][0])/P:A=qe(y+(l?L:-L)*P+j,i[0][0])/P,C=Math.max(C,A)}if(a){let A=0;!c&&!l||l&&!c&&f?A=qe(y+M*P,a[1][0])/P:A=Ge(y+(l?L:-L)*P,a[0][0])/P,C=Math.max(C,A)}}}L=L+(L<0?C:-C),D=D+(D<0?_:-_),s&&(f?F>M*P?L=(Ts(c,l)?-D:D)/P:D=(Ts(c,l)?-L:L)*P:d?(L=D/P,l=c):(D=L*P,c=l));const S=c?y+D:y,I=l?x+L:x;return{width:N+(c?-D:D),height:k+(l?-L:L),x:o[0]*D*(c?-1:1)+S,y:o[1]*L*(l?-1:1)+I}}const Ei={width:0,height:0,x:0,y:0},Wf={...Ei,pointerX:0,pointerY:0,aspectRatio:1};function Yf(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,o=e.measured.width??0,i=e.measured.height??0,a=n[0]*o,c=n[1]*i;return[[r-a,s-c],[r+o-a,s+i-c]]}function Xf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=ve(e);let i={controlDirection:Ds("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function a({controlPosition:l,boundaries:d,keepAspectRatio:u,resizeDirection:f,onResizeStart:h,onResize:p,onResizeEnd:v,shouldResize:w}){let m={...Ei},E={...Wf};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Ds(l)};let y,x=null,N=[],k,P,D,L=!1;const F=Po().on("start",M=>{const{nodeLookup:j,transform:V,snapGrid:_,snapToGrid:C,nodeOrigin:S,paneDomNode:I}=n();if(y=j.get(t),!y)return;x=(I==null?void 0:I.getBoundingClientRect())??null;const{xSnapped:R,ySnapped:A}=Dt(M.sourceEvent,{transform:V,snapGrid:_,snapToGrid:C,containerBounds:x});m={width:y.measured.width??0,height:y.measured.height??0,x:y.position.x??0,y:y.position.y??0},E={...m,pointerX:R,pointerY:A,aspectRatio:m.width/m.height},k=void 0,P=lt(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(k=j.get(y.parentId)),k&&y.extent==="parent"&&(P=[[0,0],[k.measured.width,k.measured.height]]),N=[],D=void 0;for(const[O,B]of j)if(B.parentId===t&&(N.push({id:O,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const H=Yf(B,y,B.origin??S);D?D=[[Math.min(H[0][0],D[0][0]),Math.min(H[0][1],D[0][1])],[Math.max(H[1][0],D[1][0]),Math.max(H[1][1],D[1][1])]]:D=H}h==null||h(M,{...m})}).on("drag",M=>{const{transform:j,snapGrid:V,snapToGrid:_,nodeOrigin:C}=n(),S=Dt(M.sourceEvent,{transform:j,snapGrid:V,snapToGrid:_,containerBounds:x}),I=[];if(!y)return;const{x:R,y:A,width:O,height:B}=m,H={},Y=y.origin??C,{width:X,height:ee,x:J,y:Z}=Ff(E,i.controlDirection,S,i.boundaries,i.keepAspectRatio,Y,P,D),$=X!==O,W=ee!==B,ne=J!==R&&$,te=Z!==A&&W;if(!ne&&!te&&!$&&!W)return;if((ne||te||Y[0]===1||Y[1]===1)&&(H.x=ne?J:m.x,H.y=te?Z:m.y,m.x=H.x,m.y=H.y,N.length>0)){const se=J-R,ie=Z-A;for(const ce of N)ce.position={x:ce.position.x-se+Y[0]*(X-O),y:ce.position.y-ie+Y[1]*(ee-B)},I.push(ce)}if(($||W)&&(H.width=$&&(!i.resizeDirection||i.resizeDirection==="horizontal")?X:m.width,H.height=W&&(!i.resizeDirection||i.resizeDirection==="vertical")?ee:m.height,m.width=H.width,m.height=H.height),k&&y.expandParent){const se=Y[0]*(H.width??0);H.x&&H.x<se&&(m.x=se,E.x=E.x-(H.x-se));const ie=Y[1]*(H.height??0);H.y&&H.y<ie&&(m.y=ie,E.y=E.y-(H.y-ie))}const q=Vf({width:m.width,prevWidth:O,height:m.height,prevHeight:B,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),G={...m,direction:q};(w==null?void 0:w(M,G))!==!1&&(L=!0,p==null||p(M,G),r(H,I))}).on("end",M=>{L&&(v==null||v(M,{...m}),s==null||s({...m}),L=!1)});o.call(F)}function c(){o.on(".drag",null)}return{update:a,destroy:c}}var Ni={exports:{}},Si={},ki={exports:{}},Mi={};/**
3
- * @license React
4
- * use-sync-external-store-shim.production.js
5
- *
6
- * Copyright (c) Meta Platforms, Inc. and affiliates.
7
- *
8
- * This source code is licensed under the MIT license found in the
9
- * LICENSE file in the root directory of this source tree.
10
- */var St=b;function Kf(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var qf=typeof Object.is=="function"?Object.is:Kf,Gf=St.useState,Uf=St.useEffect,Zf=St.useLayoutEffect,Qf=St.useDebugValue;function Jf(e,t){var n=t(),r=Gf({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return Zf(function(){s.value=n,s.getSnapshot=t,sr(s)&&o({inst:s})},[e,n,t]),Uf(function(){return sr(s)&&o({inst:s}),e(function(){sr(s)&&o({inst:s})})},[e]),Qf(n),n}function sr(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!qf(e,n)}catch{return!0}}function eh(e,t){return t()}var th=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?eh:Jf;Mi.useSyncExternalStore=St.useSyncExternalStore!==void 0?St.useSyncExternalStore:th;ki.exports=Mi;var nh=ki.exports;/**
11
- * @license React
12
- * use-sync-external-store-shim/with-selector.production.js
13
- *
14
- * Copyright (c) Meta Platforms, Inc. and affiliates.
15
- *
16
- * This source code is licensed under the MIT license found in the
17
- * LICENSE file in the root directory of this source tree.
18
- */var zn=b,rh=nh;function sh(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var oh=typeof Object.is=="function"?Object.is:sh,ih=rh.useSyncExternalStore,ah=zn.useRef,ch=zn.useEffect,lh=zn.useMemo,uh=zn.useDebugValue;Si.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=ah(null);if(o.current===null){var i={hasValue:!1,value:null};o.current=i}else i=o.current;o=lh(function(){function c(h){if(!l){if(l=!0,d=h,h=r(h),s!==void 0&&i.hasValue){var p=i.value;if(s(p,h))return u=p}return u=h}if(p=u,oh(d,h))return p;var v=r(h);return s!==void 0&&s(p,v)?(d=h,p):(d=h,u=v)}var l=!1,d,u,f=n===void 0?null:n;return[function(){return c(t())},f===null?void 0:function(){return c(f())}]},[t,n,r,s]);var a=ih(e,o[0],o[1]);return ch(function(){i.hasValue=!0,i.value=a},[a]),uh(a),a};Ni.exports=Si;var dh=Ni.exports;const fh=Ka(dh),hh={},Ls=e=>{let t;const n=new Set,r=(d,u)=>{const f=typeof d=="function"?d(t):d;if(!Object.is(f,t)){const h=t;t=u??(typeof f!="object"||f===null)?f:Object.assign({},t,f),n.forEach(p=>p(t,h))}},s=()=>t,c={setState:r,getState:s,getInitialState:()=>l,subscribe:d=>(n.add(d),()=>n.delete(d)),destroy:()=>{(hh?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},l=t=e(r,s,c);return c},gh=e=>e?Ls(e):Ls,{useDebugValue:ph}=qa,{useSyncExternalStoreWithSelector:mh}=fh,yh=e=>e;function Ci(e,t=yh,n){const r=mh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return ph(r),r}const Rs=(e,t)=>{const n=gh(e),r=(s,o=t)=>Ci(n,s,o);return Object.assign(r,n),r},xh=(e,t)=>e?Rs(e,t):Rs;function le(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}const Hn=b.createContext(null),wh=Hn.Provider,Ai=De.error001("react");function ae(e,t){const n=b.useContext(Hn);if(n===null)throw new Error(Ai);return Ci(n,e,t)}function ue(){const e=b.useContext(Hn);if(e===null)throw new Error(Ai);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const zs={display:"none"},vh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Ii="react-flow__node-desc",$i="react-flow__edge-desc",bh="react-flow__aria-live",_h=e=>e.ariaLiveMessage,Eh=e=>e.ariaLabelConfig;function Nh({rfId:e}){const t=ae(_h);return g.jsx("div",{id:`${bh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:vh,children:t})}function Sh({rfId:e,disableKeyboardA11y:t}){const n=ae(Eh);return g.jsxs(g.Fragment,{children:[g.jsx("div",{id:`${Ii}-${e}`,style:zs,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),g.jsx("div",{id:`${$i}-${e}`,style:zs,children:n["edge.a11yDescription.default"]}),!t&&g.jsx(Nh,{rfId:e})]})}const On=b.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const i=`${e}`.split("-");return g.jsx("div",{className:fe(["react-flow__panel",n,...i]),style:r,ref:o,...s,children:t})});On.displayName="Panel";function kh({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:g.jsx(On,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:g.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const Mh=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},dn=e=>e.id;function Ch(e,t){return le(e.selectedNodes.map(dn),t.selectedNodes.map(dn))&&le(e.selectedEdges.map(dn),t.selectedEdges.map(dn))}function Ah({onSelectionChange:e}){const t=ue(),{selectedNodes:n,selectedEdges:r}=ae(Mh,Ch);return b.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(o=>o(s))},[n,r,e]),null}const Ih=e=>!!e.onSelectionChangeHandlers;function $h({onSelectionChange:e}){const t=ae(Ih);return e||t?g.jsx(Ah,{onSelectionChange:e}):null}const ji=[0,0],jh={x:0,y:0,zoom:1},Ph=["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"],Hs=[...Ph,"rfId"],Dh=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}),Os={translateExtent:Ht,nodeOrigin:ji,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Th(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:c}=ae(Dh,le),l=ue();b.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Os,a()}),[]);const d=b.useRef(Os);return b.useEffect(()=>{for(const u of Hs){const f=e[u],h=d.current[u];f!==h&&(typeof e[u]>"u"||(u==="nodes"?t(f):u==="edges"?n(f):u==="minZoom"?r(f):u==="maxZoom"?s(f):u==="translateExtent"?o(f):u==="nodeExtent"?i(f):u==="ariaLabelConfig"?l.setState({ariaLabelConfig:sf(f)}):u==="fitView"?l.setState({fitViewQueued:f}):u==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[u]:f})))}d.current=e},Hs.map(u=>e[u])),null}function Bs(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Lh(e){var r;const[t,n]=b.useState(e==="system"?null:e);return b.useEffect(()=>{if(e!=="system"){n(e);return}const s=Bs(),o=()=>n(s!=null&&s.matches?"dark":"light");return o(),s==null||s.addEventListener("change",o),()=>{s==null||s.removeEventListener("change",o)}},[e]),t!==null?t:(r=Bs())!=null&&r.matches?"dark":"light"}const Vs=typeof document<"u"?document:null;function Wt(e=null,t={target:Vs,actInsideInputWithModifier:!0}){const[n,r]=b.useState(!1),s=b.useRef(!1),o=b.useRef(new Set([])),[i,a]=b.useMemo(()=>{if(e!==null){const l=(Array.isArray(e)?e:[e]).filter(u=>typeof u=="string").map(u=>u.replace("+",`
19
- `).replace(`
20
-
21
- `,`
22
- +`).split(`
23
- `)),d=l.reduce((u,f)=>u.concat(...f),[]);return[l,d]}return[[],[]]},[e]);return b.useEffect(()=>{const c=(t==null?void 0:t.target)??Vs,l=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var w,m;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!l)&&ai(h))return!1;const v=Ws(h.code,a);if(o.current.add(h[v]),Fs(i,o.current,!1)){const E=((m=(w=h.composedPath)==null?void 0:w.call(h))==null?void 0:m[0])||h.target,y=(E==null?void 0:E.nodeName)==="BUTTON"||(E==null?void 0:E.nodeName)==="A";t.preventDefault!==!1&&(s.current||!y)&&h.preventDefault(),r(!0)}},u=h=>{const p=Ws(h.code,a);Fs(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(h[p]),h.key==="Meta"&&o.current.clear(),s.current=!1},f=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",d),c==null||c.addEventListener("keyup",u),window.addEventListener("blur",f),window.addEventListener("contextmenu",f),()=>{c==null||c.removeEventListener("keydown",d),c==null||c.removeEventListener("keyup",u),window.removeEventListener("blur",f),window.removeEventListener("contextmenu",f)}}},[e,r]),n}function Fs(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Ws(e,t){return t.includes(e)?"code":"key"}const Rh=()=>{const e=ue();return b.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,o],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??o},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:s,minZoom:o,maxZoom:i,panZoom:a}=e.getState(),c=Br(t,r,s,o,i,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:s,snapToGrid:o,domNode:i}=e.getState();if(!i)return t;const{x:a,y:c}=i.getBoundingClientRect(),l={x:t.x-a,y:t.y-c},d=n.snapGrid??s,u=n.snapToGrid??o;return Mt(l,r,u,d)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:o}=r.getBoundingClientRect(),i=Et(t,n);return{x:i.x+s,y:i.y+o}}}),[])};function Pi(e,t){const n=[],r=new Map,s=[];for(const o of e)if(o.type==="add"){s.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const i=r.get(o.id);i?i.push(o):r.set(o.id,[o])}for(const o of t){const i=r.get(o.id);if(!i){n.push(o);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const a={...o};for(const c of i)zh(c,a);n.push(a)}return s.length&&s.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function zh(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function Hh(e,t){return Pi(e,t)}function Oh(e,t){return Pi(e,t)}function et(e,t){return{id:e,type:"select",selected:t}}function pt(e,t=new Set,n=!1){const r=[];for(const[s,o]of e){const i=t.has(s);!(o.selected===void 0&&!i)&&o.selected!==i&&(n&&(o.selected=i),r.push(et(o.id,i)))}return r}function Ys({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,i]of e.entries()){const a=t.get(i.id),c=((s=a==null?void 0:a.internals)==null?void 0:s.userNode)??a;c!==void 0&&c!==i&&n.push({id:i.id,item:i,type:"replace"}),c===void 0&&n.push({item:i,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function Xs(e){return{id:e.id,type:"remove"}}const Bh=ri();function Vh(e,t,n={}){return df(e,t,{...n,onError:n.onError??Bh})}const Ks=e=>Gd(e),Fh=e=>Jo(e);function Di(e){return b.forwardRef(e)}const Wh=typeof window<"u"?b.useLayoutEffect:b.useEffect;function qs(e){const[t,n]=b.useState(BigInt(0)),[r]=b.useState(()=>Yh(()=>n(s=>s+BigInt(1))));return Wh(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function Yh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Ti=b.createContext(null);function Xh({children:e}){const t=ue(),n=b.useCallback(a=>{const{nodes:c=[],setNodes:l,hasDefaultNodes:d,onNodesChange:u,nodeLookup:f,fitViewQueued:h,onNodesChangeMiddlewareMap:p}=t.getState();let v=c;for(const m of a)v=typeof m=="function"?m(v):m;let w=Ys({items:v,lookup:f});for(const m of p.values())w=m(w);d&&l(v),w.length>0?u==null||u(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:m,nodes:E,setNodes:y}=t.getState();m&&y(E)})},[]),r=qs(n),s=b.useCallback(a=>{const{edges:c=[],setEdges:l,hasDefaultEdges:d,onEdgesChange:u,edgeLookup:f}=t.getState();let h=c;for(const p of a)h=typeof p=="function"?p(h):p;d?l(h):u&&u(Ys({items:h,lookup:f}))},[]),o=qs(s),i=b.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return g.jsx(Ti.Provider,{value:i,children:e})}function Kh(){const e=b.useContext(Ti);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const qh=e=>!!e.panZoom;function Bn(){const e=Rh(),t=ue(),n=Kh(),r=ae(qh),s=b.useMemo(()=>{const o=u=>t.getState().nodeLookup.get(u),i=u=>{n.nodeQueue.push(u)},a=u=>{n.edgeQueue.push(u)},c=u=>{var m,E;const{nodeLookup:f,nodeOrigin:h}=t.getState(),p=Ks(u)?u:f.get(u.id),v=p.parentId?oi(p.position,p.measured,p.parentId,f,h):p.position,w={...p,position:v,width:((m=p.measured)==null?void 0:m.width)??p.width,height:((E=p.measured)==null?void 0:E.height)??p.height};return _t(w)},l=(u,f,h={replace:!1})=>{i(p=>p.map(v=>{if(v.id===u){const w=typeof f=="function"?f(v):f;return h.replace&&Ks(w)?w:{...v,...w}}return v}))},d=(u,f,h={replace:!1})=>{a(p=>p.map(v=>{if(v.id===u){const w=typeof f=="function"?f(v):f;return h.replace&&Fh(w)?w:{...v,...w}}return v}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>{var f;return(f=o(u))==null?void 0:f.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:u=[]}=t.getState();return u.map(f=>({...f}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:i,setEdges:a,addNodes:u=>{const f=Array.isArray(u)?u:[u];n.nodeQueue.push(h=>[...h,...f])},addEdges:u=>{const f=Array.isArray(u)?u:[u];n.edgeQueue.push(h=>[...h,...f])},toObject:()=>{const{nodes:u=[],edges:f=[],transform:h}=t.getState(),[p,v,w]=h;return{nodes:u.map(m=>({...m})),edges:f.map(m=>({...m})),viewport:{x:p,y:v,zoom:w}}},deleteElements:async({nodes:u=[],edges:f=[]})=>{const{nodes:h,edges:p,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:m,triggerEdgeChanges:E,onDelete:y,onBeforeDelete:x}=t.getState(),{nodes:N,edges:k}=await ef({nodesToRemove:u,edgesToRemove:f,nodes:h,edges:p,onBeforeDelete:x}),P=k.length>0,D=N.length>0;if(P){const L=k.map(Xs);w==null||w(k),E(L)}if(D){const L=N.map(Xs);v==null||v(N),m(L)}return(D||P)&&(y==null||y({nodes:N,edges:k})),{deletedNodes:N,deletedEdges:k}},getIntersectingNodes:(u,f=!0,h)=>{const p=Es(u),v=p?u:c(u),w=h!==void 0;return v?(h||t.getState().nodes).filter(m=>{const E=t.getState().nodeLookup.get(m.id);if(E&&!p&&(m.id===u.id||!E.internals.positionAbsolute))return!1;const y=_t(w?m:E),x=Vt(y,v);return f&&x>0||x>=y.width*y.height||x>=v.width*v.height}):[]},isNodeIntersecting:(u,f,h=!0)=>{const v=Es(u)?u:c(u);if(!v)return!1;const w=Vt(v,f);return h&&w>0||w>=f.width*f.height||w>=v.width*v.height},updateNode:l,updateNodeData:(u,f,h={replace:!1})=>{l(u,p=>{const v=typeof f=="function"?f(p):f;return h.replace?{...p,data:v}:{...p,data:{...p.data,...v}}},h)},updateEdge:d,updateEdgeData:(u,f,h={replace:!1})=>{d(u,p=>{const v=typeof f=="function"?f(p):f;return h.replace?{...p,data:v}:{...p,data:{...p.data,...v}}},h)},getNodesBounds:u=>{const{nodeLookup:f,nodeOrigin:h}=t.getState();return Ud(u,{nodeLookup:f,nodeOrigin:h})},getHandleConnections:({type:u,id:f,nodeId:h})=>{var p;return Array.from(((p=t.getState().connectionLookup.get(`${h}-${u}${f?`-${f}`:""}`))==null?void 0:p.values())??[])},getNodeConnections:({type:u,handleId:f,nodeId:h})=>{var p;return Array.from(((p=t.getState().connectionLookup.get(`${h}${u?f?`-${u}-${f}`:`-${u}`:""}`))==null?void 0:p.values())??[])},fitView:async u=>{const f=t.getState().fitViewResolver??rf();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:f}),n.nodeQueue.push(h=>[...h]),f.promise}}},[]);return b.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const Gs=e=>e.selected,Gh=typeof window<"u"?window:void 0;function Uh({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ue(),{deleteElements:r}=Bn(),s=Wt(e,{actInsideInputWithModifier:!1}),o=Wt(t,{target:Gh});b.useEffect(()=>{if(s){const{edges:i,nodes:a}=n.getState();r({nodes:a.filter(Gs),edges:i.filter(Gs)}),n.setState({nodesSelectionActive:!1})}},[s]),b.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function Zh(e){const t=ue();b.useEffect(()=>{const n=()=>{var s,o,i,a;if(!e.current||!(((o=(s=e.current).checkVisibility)==null?void 0:o.call(s))??!0))return!1;const r=Vr(e.current);(r.height===0||r.width===0)&&((a=(i=t.getState()).onError)==null||a.call(i,"004",De.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Vn={position:"absolute",width:"100%",height:"100%",top:0,left:0},Qh=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Jh({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=st.Free,zoomOnDoubleClick:i=!0,panOnDrag:a=!0,defaultViewport:c,translateExtent:l,minZoom:d,maxZoom:u,zoomActivationKeyCode:f,preventScrolling:h=!0,children:p,noWheelClassName:v,noPanClassName:w,onViewportChange:m,isControlledViewport:E,paneClickDistance:y,selectionOnDrag:x}){const N=ue(),k=b.useRef(null),{userSelectionActive:P,lib:D,connectionInProgress:L}=ae(Qh,le),F=Wt(f),M=b.useRef();Zh(k);const j=b.useCallback(V=>{m==null||m({x:V[0],y:V[1],zoom:V[2]}),E||N.setState({transform:V})},[m,E]);return b.useEffect(()=>{if(k.current){M.current=Bf({domNode:k.current,minZoom:d,maxZoom:u,translateExtent:l,viewport:c,onDraggingChange:S=>N.setState(I=>I.paneDragging===S?I:{paneDragging:S}),onPanZoomStart:(S,I)=>{const{onViewportChangeStart:R,onMoveStart:A}=N.getState();A==null||A(S,I),R==null||R(I)},onPanZoom:(S,I)=>{const{onViewportChange:R,onMove:A}=N.getState();A==null||A(S,I),R==null||R(I)},onPanZoomEnd:(S,I)=>{const{onViewportChangeEnd:R,onMoveEnd:A}=N.getState();A==null||A(S,I),R==null||R(I)}});const{x:V,y:_,zoom:C}=M.current.getViewport();return N.setState({panZoom:M.current,transform:[V,_,C],domNode:k.current.closest(".react-flow")}),()=>{var S;(S=M.current)==null||S.destroy()}}},[]),b.useEffect(()=>{var V;(V=M.current)==null||V.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:i,panOnDrag:a,zoomActivationKeyPressed:F,preventScrolling:h,noPanClassName:w,userSelectionActive:P,noWheelClassName:v,lib:D,onTransformChange:j,connectionInProgress:L,selectionOnDrag:x,paneClickDistance:y})},[e,t,n,r,s,o,i,a,F,h,w,P,v,D,j,L,x,y]),g.jsx("div",{className:"react-flow__renderer",ref:k,style:Vn,children:p})}const eg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function tg(){const{userSelectionActive:e,userSelectionRect:t}=ae(eg,le);return e&&t?g.jsx("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}const or=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},ng=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function rg({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Ot.Full,panOnDrag:r,autoPanOnSelection:s,paneClickDistance:o,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:d,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:h,onPaneMouseLeave:p,children:v}){const w=b.useRef(0),m=ue(),{userSelectionActive:E,elementsSelectable:y,dragging:x,connectionInProgress:N,panBy:k,autoPanSpeed:P}=ae(ng,le),D=y&&(e||E),L=b.useRef(null),F=b.useRef(),M=b.useRef(new Set),j=b.useRef(new Set),V=b.useRef(!1),_=b.useRef({x:0,y:0}),C=b.useRef(!1),S=$=>{if(V.current||N){V.current=!1;return}l==null||l($),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},I=$=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){$.preventDefault();return}d==null||d($)},R=u?$=>u($):void 0,A=$=>{V.current&&($.stopPropagation(),V.current=!1)},O=$=>{var ce,me;const{domNode:W,transform:ne}=m.getState();if(F.current=W==null?void 0:W.getBoundingClientRect(),!F.current)return;const te=$.target===L.current;if(!te&&!!$.target.closest(".nokey")||!e||!(i&&te||t)||$.button!==0||!$.isPrimary)return;(me=(ce=$.target)==null?void 0:ce.setPointerCapture)==null||me.call(ce,$.pointerId),V.current=!1;const{x:re,y:se}=Pe($.nativeEvent,F.current),ie=Mt({x:re,y:se},ne);m.setState({userSelectionRect:{width:0,height:0,startX:ie.x,startY:ie.y,x:re,y:se}}),te||($.stopPropagation(),$.preventDefault())};function B($,W){const{userSelectionRect:ne}=m.getState();if(!ne)return;const{transform:te,nodeLookup:q,edgeLookup:G,connectionLookup:re,triggerNodeChanges:se,triggerEdgeChanges:ie,defaultEdgeOptions:ce}=m.getState(),me={x:ne.startX,y:ne.startY},{x:_e,y:ye}=Et(me,te),Ee={startX:me.x,startY:me.y,x:$<_e?$:_e,y:W<ye?W:ye,width:Math.abs($-_e),height:Math.abs(W-ye)},Oe=M.current,Le=j.current;M.current=new Set(Hr(q,Ee,te,n===Ot.Partial,!0).map(xe=>xe.id)),j.current=new Set;const Ne=(ce==null?void 0:ce.selectable)??!0;for(const xe of M.current){const Se=re.get(xe);if(Se)for(const{edgeId:Ce}of Se.values()){const Be=G.get(Ce);Be&&(Be.selectable??Ne)&&j.current.add(Ce)}}if(!Ns(Oe,M.current)){const xe=pt(q,M.current,!0);se(xe)}if(!Ns(Le,j.current)){const xe=pt(G,j.current);ie(xe)}m.setState({userSelectionRect:Ee,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!s||!F.current)return;const[$,W]=Or(_.current,F.current,P);k({x:$,y:W}).then(ne=>{if(!V.current||!ne){w.current=requestAnimationFrame(H);return}const{x:te,y:q}=_.current;B(te,q),w.current=requestAnimationFrame(H)})}const Y=()=>{cancelAnimationFrame(w.current),w.current=0,C.current=!1};b.useEffect(()=>()=>Y(),[]);const X=$=>{const{userSelectionRect:W,transform:ne,resetSelectedElements:te}=m.getState();if(!F.current||!W)return;const{x:q,y:G}=Pe($.nativeEvent,F.current);_.current={x:q,y:G};const re=Et({x:W.startX,y:W.startY},ne);if(!V.current){const se=t?0:o;if(Math.hypot(q-re.x,G-re.y)<=se)return;te(),a==null||a($)}V.current=!0,C.current||(H(),C.current=!0),B(q,G)},ee=$=>{var W,ne;$.button===0&&((ne=(W=$.target)==null?void 0:W.releasePointerCapture)==null||ne.call(W,$.pointerId),!E&&$.target===L.current&&m.getState().userSelectionRect&&(S==null||S($)),m.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c($),m.setState({nodesSelectionActive:M.current.size>0})),Y())},J=$=>{var W,ne;(ne=(W=$.target)==null?void 0:W.releasePointerCapture)==null||ne.call(W,$.pointerId),Y()},Z=r===!0||Array.isArray(r)&&r.includes(0);return g.jsxs("div",{className:fe(["react-flow__pane",{draggable:Z,dragging:x,selection:e}]),onClick:D?void 0:or(S,L),onContextMenu:or(I,L),onWheel:or(R,L),onPointerEnter:D?void 0:f,onPointerMove:D?X:h,onPointerUp:D?ee:void 0,onPointerCancel:D?J:void 0,onPointerDownCapture:D?O:void 0,onClickCapture:D?A:void 0,onPointerLeave:p,ref:L,style:Vn,children:[v,g.jsx(tg,{})]})}function Mr({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeLookup:a,onError:c}=t.getState(),l=a.get(e);if(!l){c==null||c("012",De.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&i)&&(o({nodes:[l],edges:[]}),requestAnimationFrame(()=>{var d;return(d=r==null?void 0:r.current)==null?void 0:d.blur()})):s([e])}function Li({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:i}){const a=ue(),[c,l]=b.useState(!1),d=b.useRef();return b.useEffect(()=>{d.current=Mf({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Mr({id:u,store:a,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),b.useEffect(()=>{if(!(t||!e.current||!d.current))return d.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:s,nodeClickDistance:i}),()=>{var u;(u=d.current)==null||u.destroy()}},[n,r,t,o,e,s,i]),c}const sg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Ri(){const e=ue();return b.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:o,nodesDraggable:i,onError:a,updateNodePositions:c,nodeLookup:l,nodeOrigin:d}=e.getState(),u=new Map,f=sg(i),h=s?o[0]:5,p=s?o[1]:5,v=n.direction.x*h*n.factor,w=n.direction.y*p*n.factor;for(const[,m]of l){if(!f(m))continue;let E={x:m.internals.positionAbsolute.x+v,y:m.internals.positionAbsolute.y+w};s&&(E=Gt(E,o));const{position:y,positionAbsolute:x}=ei({nodeId:m.id,nextPosition:E,nodeLookup:l,nodeExtent:r,nodeOrigin:d,onError:a});m.position=y,m.internals.positionAbsolute=x,u.set(m.id,m)}c(u)},[])}const qr=b.createContext(null),og=qr.Provider;qr.Consumer;const zi=()=>b.useContext(qr),ig=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),ag=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:o,connection:i}=r,{fromHandle:a,toHandle:c,isValid:l}=i,d=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:d,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:o===vt.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!s,valid:d&&l}};function cg({type:e="source",position:t=Q.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:a,children:c,className:l,onMouseDown:d,onTouchStart:u,...f},h){var C,S;const p=i||null,v=e==="target",w=ue(),m=zi(),{connectOnClick:E,noPanClassName:y,rfId:x}=ae(ig,le),{connectingFrom:N,connectingTo:k,clickConnecting:P,isPossibleEndHandle:D,connectionInProcess:L,clickConnectionInProcess:F,valid:M}=ae(ag(m,p,e),le);m||(S=(C=w.getState()).onError)==null||S.call(C,"010",De.error010());const j=I=>{const{defaultEdgeOptions:R,onConnect:A,hasDefaultEdges:O}=w.getState(),B={...R,...I};if(O){const{edges:H,setEdges:Y,onError:X}=w.getState();Y(Vh(B,H,{onError:X}))}A==null||A(B),a==null||a(B)},V=I=>{if(!m)return;const R=ci(I.nativeEvent);if(s&&(R&&I.button===0||!R)){const A=w.getState();kr.onPointerDown(I.nativeEvent,{handleDomNode:I.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:v,handleId:p,nodeId:m,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...O)=>{var B,H;return(H=(B=w.getState()).onConnectEnd)==null?void 0:H.call(B,...O)},updateConnection:A.updateConnection,onConnect:j,isValidConnection:n||((...O)=>{var B,H;return((H=(B=w.getState()).isValidConnection)==null?void 0:H.call(B,...O))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}R?d==null||d(I):u==null||u(I)},_=I=>{const{onClickConnectStart:R,onClickConnectEnd:A,connectionClickStartHandle:O,connectionMode:B,isValidConnection:H,lib:Y,rfId:X,nodeLookup:ee,connection:J}=w.getState();if(!m||!O&&!s)return;if(!O){R==null||R(I.nativeEvent,{nodeId:m,handleId:p,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:m,type:e,id:p}});return}const Z=ii(I.target),$=n||H,{connection:W,isValid:ne}=kr.isValid(I.nativeEvent,{handle:{nodeId:m,id:p,type:e},connectionMode:B,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:$,flowId:X,doc:Z,lib:Y,nodeLookup:ee});ne&&W&&j(W);const te=structuredClone(J);delete te.inProgress,te.toPosition=te.toHandle?te.toHandle.position:null,A==null||A(I,te),w.setState({connectionClickStartHandle:null})};return g.jsx("div",{"data-handleid":p,"data-nodeid":m,"data-handlepos":t,"data-id":`${x}-${m}-${p}-${e}`,className:fe(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,l,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:P,connectingfrom:N,connectingto:k,valid:M,connectionindicator:r&&(!L||D)&&(L||F?o:s)}]),onMouseDown:V,onTouchStart:V,onClick:E?_:void 0,ref:h,...f,children:c})}const kt=b.memo(Di(cg));function lg({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return g.jsxs(g.Fragment,{children:[e==null?void 0:e.label,g.jsx(kt,{type:"source",position:n,isConnectable:t})]})}function ug({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return g.jsxs(g.Fragment,{children:[g.jsx(kt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,g.jsx(kt,{type:"source",position:r,isConnectable:t})]})}function dg(){return null}function fg({data:e,isConnectable:t,targetPosition:n=Q.Top}){return g.jsxs(g.Fragment,{children:[g.jsx(kt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Mn={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Us={input:lg,default:ug,output:fg,group:dg};function hg(e){var t,n,r,s;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((s=e.style)==null?void 0:s.height)}}const gg=e=>{const{width:t,height:n,x:r,y:s}=qt(e.nodeLookup,{filter:o=>!!o.selected});return{width:je(t)?t:null,height:je(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${s}px)`}};function pg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=ue(),{width:s,height:o,transformString:i,userSelectionActive:a}=ae(gg,le),c=Ri(),l=b.useRef(null);b.useEffect(()=>{var h;n||(h=l.current)==null||h.focus({preventScroll:!0})},[n]);const d=!a&&s!==null&&o!==null;if(Li({nodeRef:l,disabled:!d}),!d)return null;const u=e?h=>{const p=r.getState().nodes.filter(v=>v.selected);e(h,p)}:void 0,f=h=>{Object.prototype.hasOwnProperty.call(Mn,h.key)&&(h.preventDefault(),c({direction:Mn[h.key],factor:h.shiftKey?4:1}))};return g.jsx("div",{className:fe(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:g.jsx("div",{ref:l,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:n?void 0:-1,onKeyDown:n?void 0:f,style:{width:s,height:o}})})}const Zs=typeof window<"u"?window:void 0,mg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Hi({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,paneClickDistance:a,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:d,selectionMode:u,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:p,panActivationKeyCode:v,zoomActivationKeyCode:w,elementsSelectable:m,zoomOnScroll:E,zoomOnPinch:y,panOnScroll:x,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:P,panOnDrag:D,autoPanOnSelection:L,defaultViewport:F,translateExtent:M,minZoom:j,maxZoom:V,preventScrolling:_,onSelectionContextMenu:C,noWheelClassName:S,noPanClassName:I,disableKeyboardA11y:R,onViewportChange:A,isControlledViewport:O}){const{nodesSelectionActive:B,userSelectionActive:H}=ae(mg,le),Y=Wt(l,{target:Zs}),X=Wt(v,{target:Zs}),ee=X||D,J=X||x,Z=d&&ee!==!0,$=Y||H||Z;return Uh({deleteKeyCode:c,multiSelectionKeyCode:p}),g.jsx(Jh,{onPaneContextMenu:o,elementsSelectable:m,zoomOnScroll:E,zoomOnPinch:y,panOnScroll:J,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:P,panOnDrag:!Y&&ee,defaultViewport:F,translateExtent:M,minZoom:j,maxZoom:V,zoomActivationKeyCode:w,preventScrolling:_,noWheelClassName:S,noPanClassName:I,onViewportChange:A,isControlledViewport:O,paneClickDistance:a,selectionOnDrag:Z,children:g.jsxs(rg,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:ee,autoPanOnSelection:L,isSelecting:!!$,selectionMode:u,selectionKeyPressed:Y,paneClickDistance:a,selectionOnDrag:Z,children:[e,B&&g.jsx(pg,{onSelectionContextMenu:C,noPanClassName:I,disableKeyboardA11y:R})]})})}Hi.displayName="FlowRenderer";const yg=b.memo(Hi),xg=e=>t=>e?Hr(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function wg(e){return ae(b.useCallback(xg(e),[e]),le)}const vg=e=>e.updateNodeInternals;function bg(){const e=ae(vg),[t]=b.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const o=s.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:s.target,force:!0})}),e(r)}));return b.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function _g({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=ue(),o=b.useRef(null),i=b.useRef(null),a=b.useRef(e.sourcePosition),c=b.useRef(e.targetPosition),l=b.useRef(t),d=n&&!!e.internals.handleBounds;return b.useEffect(()=>{o.current&&!e.hidden&&(!d||i.current!==o.current)&&(i.current&&(r==null||r.unobserve(i.current)),r==null||r.observe(o.current),i.current=o.current)},[d,e.hidden]),b.useEffect(()=>()=>{i.current&&(r==null||r.unobserve(i.current),i.current=null)},[]),b.useEffect(()=>{if(o.current){const u=l.current!==t,f=a.current!==e.sourcePosition,h=c.current!==e.targetPosition;(u||f||h)&&(l.current=t,a.current=e.sourcePosition,c.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function Eg({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:o,onDoubleClick:i,nodesDraggable:a,elementsSelectable:c,nodesConnectable:l,nodesFocusable:d,resizeObserver:u,noDragClassName:f,noPanClassName:h,disableKeyboardA11y:p,rfId:v,nodeTypes:w,nodeClickDistance:m,onError:E}){const{node:y,internals:x,isParent:N}=ae($=>{const W=$.nodeLookup.get(e),ne=$.parentLookup.has(e);return{node:W,internals:W.internals,isParent:ne}},le);let k=y.type||"default",P=(w==null?void 0:w[k])||Us[k];P===void 0&&(E==null||E("003",De.error003(k)),k="default",P=(w==null?void 0:w.default)||Us.default);const D=!!(y.draggable||a&&typeof y.draggable>"u"),L=!!(y.selectable||c&&typeof y.selectable>"u"),F=!!(y.connectable||l&&typeof y.connectable>"u"),M=!!(y.focusable||d&&typeof y.focusable>"u"),j=ue(),V=si(y),_=_g({node:y,nodeType:k,hasDimensions:V,resizeObserver:u}),C=Li({nodeRef:_,disabled:y.hidden||!D,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:L,nodeClickDistance:m}),S=Ri();if(y.hidden)return null;const I=Ke(y),R=hg(y),A=L||D||t||n||r||s,O=n?$=>n($,{...x.userNode}):void 0,B=r?$=>r($,{...x.userNode}):void 0,H=s?$=>s($,{...x.userNode}):void 0,Y=o?$=>o($,{...x.userNode}):void 0,X=i?$=>i($,{...x.userNode}):void 0,ee=$=>{const{selectNodesOnDrag:W,nodeDragThreshold:ne}=j.getState();L&&(!W||!D||ne>0)&&Mr({id:e,store:j,nodeRef:_}),t&&t($,{...x.userNode})},J=$=>{if(!(ai($.nativeEvent)||p)){if(Go.includes($.key)&&L){const W=$.key==="Escape";Mr({id:e,store:j,unselect:W,nodeRef:_})}else if(D&&y.selected&&Object.prototype.hasOwnProperty.call(Mn,$.key)){$.preventDefault();const{ariaLabelConfig:W}=j.getState();j.setState({ariaLiveMessage:W["node.a11yDescription.ariaLiveMessage"]({direction:$.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),S({direction:Mn[$.key],factor:$.shiftKey?4:1})}}},Z=()=>{var re;if(p||!((re=_.current)!=null&&re.matches(":focus-visible")))return;const{transform:$,width:W,height:ne,autoPanOnNodeFocus:te,setCenter:q}=j.getState();if(!te)return;Hr(new Map([[e,y]]),{x:0,y:0,width:W,height:ne},$,!0).length>0||q(y.position.x+I.width/2,y.position.y+I.height/2,{zoom:$[2]})};return g.jsx("div",{className:fe(["react-flow__node",`react-flow__node-${k}`,{[h]:D},y.className,{selected:y.selected,selectable:L,parent:N,draggable:D,dragging:C}]),ref:_,style:{zIndex:x.z,transform:`translate(${x.positionAbsolute.x}px,${x.positionAbsolute.y}px)`,pointerEvents:A?"all":"none",visibility:V?"visible":"hidden",...y.style,...R},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:O,onMouseMove:B,onMouseLeave:H,onContextMenu:Y,onClick:ee,onDoubleClick:X,onKeyDown:M?J:void 0,tabIndex:M?0:void 0,onFocus:M?Z:void 0,role:y.ariaRole??(M?"group":void 0),"aria-roledescription":"node","aria-describedby":p?void 0:`${Ii}-${v}`,"aria-label":y.ariaLabel,...y.domAttributes,children:g.jsx(og,{value:e,children:g.jsx(P,{id:e,data:y.data,type:k,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:y.selected??!1,selectable:L,draggable:D,deletable:y.deletable??!0,isConnectable:F,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:C,dragHandle:y.dragHandle,zIndex:x.z,parentId:y.parentId,...I})})})}var Ng=b.memo(Eg);const Sg=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Oi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=ae(Sg,le),i=wg(e.onlyRenderVisibleElements),a=bg();return g.jsx("div",{className:"react-flow__nodes",style:Vn,children:i.map(c=>g.jsx(Ng,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:a,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}Oi.displayName="NodeRenderer";const kg=b.memo(Oi);function Mg(e){return ae(b.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const o=n.nodeLookup.get(s.source),i=n.nodeLookup.get(s.target);o&&i&&cf({sourceNode:o,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),le)}const Cg=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return g.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},Ag=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return g.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},Qs={[Bt.Arrow]:Cg,[Bt.ArrowClosed]:Ag};function Ig(e){const t=ue();return b.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(Qs,e)?Qs[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",De.error009(e)),null)},[e])}const $g=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const c=Ig(t);return c?g.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:a,refX:"0",refY:"0",children:g.jsx(c,{color:n,strokeWidth:i})}):null},Bi=({defaultColor:e,rfId:t})=>{const n=ae(o=>o.edges),r=ae(o=>o.defaultEdgeOptions),s=b.useMemo(()=>mf(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return s.length?g.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:g.jsx("defs",{children:s.map(o=>g.jsx($g,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};Bi.displayName="MarkerDefinitions";var jg=b.memo(Bi);function Vi({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:o,labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:c,className:l,...d}){const[u,f]=b.useState({x:1,y:0,width:0,height:0}),h=fe(["react-flow__edge-textwrapper",l]),p=b.useRef(null);return b.useEffect(()=>{if(p.current){const v=p.current.getBBox();f({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?g.jsxs("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:h,visibility:u.width?"visible":"hidden",...d,children:[s&&g.jsx("rect",{width:u.width+2*i[0],x:-i[0],y:-i[1],height:u.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:a,ry:a}),g.jsx("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:p,style:r,children:n}),c]}):null}Vi.displayName="EdgeText";const Pg=b.memo(Vi);function Fn({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:c,interactionWidth:l=20,...d}){return g.jsxs(g.Fragment,{children:[g.jsx("path",{...d,d:e,fill:"none",className:fe(["react-flow__edge-path",d.className])}),l?g.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:l,className:"react-flow__edge-interaction"}):null,r&&je(t)&&je(n)?g.jsx(Pg,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function Js({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Q.Left||e===Q.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function Fi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:s,targetPosition:o=Q.Top}){const[i,a]=Js({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,l]=Js({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,u,f,h]=li({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:a,targetControlX:c,targetControlY:l});return[`M${e},${t} C${i},${a} ${c},${l} ${r},${s}`,d,u,f,h]}function Wi(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:i,targetPosition:a,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:v,markerStart:w,interactionWidth:m})=>{const[E,y,x]=Fi({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:o,targetPosition:a}),N=e.isInternal?void 0:t;return g.jsx(Fn,{id:N,path:E,labelX:y,labelY:x,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:v,markerStart:w,interactionWidth:m})})}const Dg=Wi({isInternal:!1}),Yi=Wi({isInternal:!0});Dg.displayName="SimpleBezierEdge";Yi.displayName="SimpleBezierEdgeInternal";function Xi(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,sourcePosition:h=Q.Bottom,targetPosition:p=Q.Top,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:E})=>{const[y,x,N]=Er({sourceX:n,sourceY:r,sourcePosition:h,targetX:s,targetY:o,targetPosition:p,borderRadius:m==null?void 0:m.borderRadius,offset:m==null?void 0:m.offset,stepPosition:m==null?void 0:m.stepPosition}),k=e.isInternal?void 0:t;return g.jsx(Fn,{id:k,path:y,labelX:x,labelY:N,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:v,markerStart:w,interactionWidth:E})})}const Ki=Xi({isInternal:!1}),qi=Xi({isInternal:!0});Ki.displayName="SmoothStepEdge";qi.displayName="SmoothStepEdgeInternal";function Gi(e){return b.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return g.jsx(Ki,{...n,id:r,pathOptions:b.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const Tg=Gi({isInternal:!1}),Ui=Gi({isInternal:!0});Tg.displayName="StepEdge";Ui.displayName="StepEdgeInternal";function Zi(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:p,interactionWidth:v})=>{const[w,m,E]=fi({sourceX:n,sourceY:r,targetX:s,targetY:o}),y=e.isInternal?void 0:t;return g.jsx(Fn,{id:y,path:w,labelX:m,labelY:E,label:i,labelStyle:a,labelShowBg:c,labelBgStyle:l,labelBgPadding:d,labelBgBorderRadius:u,style:f,markerEnd:h,markerStart:p,interactionWidth:v})})}const Lg=Zi({isInternal:!1}),Qi=Zi({isInternal:!0});Lg.displayName="StraightEdge";Qi.displayName="StraightEdgeInternal";function Ji(e){return b.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:o,sourcePosition:i=Q.Bottom,targetPosition:a=Q.Top,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:v,markerStart:w,pathOptions:m,interactionWidth:E})=>{const[y,x,N]=ui({sourceX:n,sourceY:r,sourcePosition:i,targetX:s,targetY:o,targetPosition:a,curvature:m==null?void 0:m.curvature}),k=e.isInternal?void 0:t;return g.jsx(Fn,{id:k,path:y,labelX:x,labelY:N,label:c,labelStyle:l,labelShowBg:d,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:h,style:p,markerEnd:v,markerStart:w,interactionWidth:E})})}const Rg=Ji({isInternal:!1}),ea=Ji({isInternal:!0});Rg.displayName="BezierEdge";ea.displayName="BezierEdgeInternal";const eo={default:ea,straight:Qi,step:Ui,smoothstep:qi,simplebezier:Yi},to={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},zg=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,Hg=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,no="react-flow__edgeupdater";function ro({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:a}){return g.jsx("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:fe([no,`${no}-${a}`]),cx:zg(t,r,e),cy:Hg(n,r,e),r,stroke:"transparent",fill:"transparent"})}function Og({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:o,targetY:i,sourcePosition:a,targetPosition:c,onReconnect:l,onReconnectStart:d,onReconnectEnd:u,setReconnecting:f,setUpdateHover:h}){const p=ue(),v=(x,N)=>{if(x.button!==0)return;const{autoPanOnConnect:k,domNode:P,connectionMode:D,connectionRadius:L,lib:F,onConnectStart:M,cancelConnection:j,nodeLookup:V,rfId:_,panBy:C,updateConnection:S}=p.getState(),I=N.type==="target",R=(B,H)=>{f(!1),u==null||u(B,n,N.type,H)},A=B=>l==null?void 0:l(n,B),O=(B,H)=>{f(!0),d==null||d(x,n,N.type),M==null||M(B,H)};kr.onPointerDown(x.nativeEvent,{autoPanOnConnect:k,connectionMode:D,connectionRadius:L,domNode:P,handleId:N.id,nodeId:N.nodeId,nodeLookup:V,isTarget:I,edgeUpdaterType:N.type,lib:F,flowId:_,cancelConnection:j,panBy:C,isValidConnection:(...B)=>{var H,Y;return((Y=(H=p.getState()).isValidConnection)==null?void 0:Y.call(H,...B))??!0},onConnect:A,onConnectStart:O,onConnectEnd:(...B)=>{var H,Y;return(Y=(H=p.getState()).onConnectEnd)==null?void 0:Y.call(H,...B)},onReconnectEnd:R,updateConnection:S,getTransform:()=>p.getState().transform,getFromHandle:()=>p.getState().connection.fromHandle,dragThreshold:p.getState().connectionDragThreshold,handleDomNode:x.currentTarget})},w=x=>v(x,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),m=x=>v(x,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),E=()=>h(!0),y=()=>h(!1);return g.jsxs(g.Fragment,{children:[(e===!0||e==="source")&&g.jsx(ro,{position:a,centerX:r,centerY:s,radius:t,onMouseDown:w,onMouseEnter:E,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&g.jsx(ro,{position:c,centerX:o,centerY:i,radius:t,onMouseDown:m,onMouseEnter:E,onMouseOut:y,type:"target"})]})}function Bg({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:o,onContextMenu:i,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,rfId:p,edgeTypes:v,noPanClassName:w,onError:m,disableKeyboardA11y:E}){let y=ae(q=>q.edgeLookup.get(e));const x=ae(q=>q.defaultEdgeOptions);y=x?{...x,...y}:y;let N=y.type||"default",k=(v==null?void 0:v[N])||eo[N];k===void 0&&(m==null||m("011",De.error011(N)),N="default",k=(v==null?void 0:v.default)||eo.default);const P=!!(y.focusable||t&&typeof y.focusable>"u"),D=typeof u<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),L=!!(y.selectable||r&&typeof y.selectable>"u"),F=b.useRef(null),[M,j]=b.useState(!1),[V,_]=b.useState(!1),C=ue(),{zIndex:S,sourceX:I,sourceY:R,targetX:A,targetY:O,sourcePosition:B,targetPosition:H}=ae(b.useCallback(q=>{const G=q.nodeLookup.get(y.source),re=q.nodeLookup.get(y.target);if(!G||!re)return{zIndex:y.zIndex,...to};const se=pf({id:e,sourceNode:G,targetNode:re,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:q.connectionMode,onError:m});return{zIndex:af({selected:y.selected,zIndex:y.zIndex,sourceNode:G,targetNode:re,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...se||to}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),le),Y=b.useMemo(()=>y.markerStart?`url('#${Nr(y.markerStart,p)}')`:void 0,[y.markerStart,p]),X=b.useMemo(()=>y.markerEnd?`url('#${Nr(y.markerEnd,p)}')`:void 0,[y.markerEnd,p]);if(y.hidden||I===null||R===null||A===null||O===null)return null;const ee=q=>{var ie;const{addSelectedEdges:G,unselectNodesAndEdges:re,multiSelectionActive:se}=C.getState();L&&(C.setState({nodesSelectionActive:!1}),y.selected&&se?(re({nodes:[],edges:[y]}),(ie=F.current)==null||ie.blur()):G([e])),s&&s(q,y)},J=o?q=>{o(q,{...y})}:void 0,Z=i?q=>{i(q,{...y})}:void 0,$=a?q=>{a(q,{...y})}:void 0,W=c?q=>{c(q,{...y})}:void 0,ne=l?q=>{l(q,{...y})}:void 0,te=q=>{var G;if(!E&&Go.includes(q.key)&&L){const{unselectNodesAndEdges:re,addSelectedEdges:se}=C.getState();q.key==="Escape"?((G=F.current)==null||G.blur(),re({edges:[y]})):se([e])}};return g.jsx("svg",{style:{zIndex:S},children:g.jsxs("g",{className:fe(["react-flow__edge",`react-flow__edge-${N}`,y.className,w,{selected:y.selected,animated:y.animated,inactive:!L&&!s,updating:M,selectable:L}]),onClick:ee,onDoubleClick:J,onContextMenu:Z,onMouseEnter:$,onMouseMove:W,onMouseLeave:ne,onKeyDown:P?te:void 0,tabIndex:P?0:void 0,role:y.ariaRole??(P?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":P?`${$i}-${p}`:void 0,ref:F,...y.domAttributes,children:[!V&&g.jsx(k,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:L,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:I,sourceY:R,targetX:A,targetY:O,sourcePosition:B,targetPosition:H,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:Y,markerEnd:X,pathOptions:"pathOptions"in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),D&&g.jsx(Og,{edge:y,isReconnectable:D,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,sourceX:I,sourceY:R,targetX:A,targetY:O,sourcePosition:B,targetPosition:H,setUpdateHover:j,setReconnecting:_})]})})}var Vg=b.memo(Bg);const Fg=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function ta({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:o,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:d,reconnectRadius:u,onEdgeDoubleClick:f,onReconnectStart:h,onReconnectEnd:p,disableKeyboardA11y:v}){const{edgesFocusable:w,edgesReconnectable:m,elementsSelectable:E,onError:y}=ae(Fg,le),x=Mg(t);return g.jsxs("div",{className:"react-flow__edges",children:[g.jsx(jg,{defaultColor:e,rfId:n}),x.map(N=>g.jsx(Vg,{id:N,edgesFocusable:w,edgesReconnectable:m,elementsSelectable:E,noPanClassName:s,onReconnect:o,onContextMenu:i,onMouseEnter:a,onMouseMove:c,onMouseLeave:l,onClick:d,reconnectRadius:u,onDoubleClick:f,onReconnectStart:h,onReconnectEnd:p,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:v},N))]})}ta.displayName="EdgeRenderer";const Wg=b.memo(ta),Yg=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Xg({children:e}){const t=ae(Yg);return g.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Kg(e){const t=Bn(),n=b.useRef(!1);b.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const qg=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function Gg(e){const t=ae(qg),n=ue();return b.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Ug(e){return e.connection.inProgress?{...e.connection,to:Mt(e.connection.to,e.transform)}:{...e.connection}}function Zg(e){return Ug}function Qg(e){const t=Zg();return ae(t,le)}const Jg=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function ep({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:i,isValid:a,inProgress:c}=ae(Jg,le);return!(o&&s&&c)?null:g.jsx("svg",{style:e,width:o,height:i,className:"react-flow__connectionline react-flow__container",children:g.jsx("g",{className:fe(["react-flow__connection",Qo(a)]),children:g.jsx(na,{style:t,type:n,CustomComponent:r,isValid:a})})})}const na=({style:e,type:t=Ue.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:o,fromNode:i,fromHandle:a,fromPosition:c,to:l,toNode:d,toHandle:u,toPosition:f,pointer:h}=Qg();if(!s)return;if(n)return g.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:a,fromX:o.x,fromY:o.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:Qo(r),toNode:d,toHandle:u,pointer:h});let p="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Ue.Bezier:[p]=ui(v);break;case Ue.SimpleBezier:[p]=Fi(v);break;case Ue.Step:[p]=Er({...v,borderRadius:0});break;case Ue.SmoothStep:[p]=Er(v);break;default:[p]=fi(v)}return g.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};na.displayName="ConnectionLine";const tp={};function so(e=tp){b.useRef(e),ue(),b.useEffect(()=>{},[e])}function np(){ue(),b.useRef(!1),b.useEffect(()=>{},[])}function ra({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:o,onEdgeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,onSelectionContextMenu:u,onSelectionStart:f,onSelectionEnd:h,connectionLineType:p,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:m,selectionKeyCode:E,selectionOnDrag:y,selectionMode:x,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:P,deleteKeyCode:D,onlyRenderVisibleElements:L,elementsSelectable:F,defaultViewport:M,translateExtent:j,minZoom:V,maxZoom:_,preventScrolling:C,defaultMarkerColor:S,zoomOnScroll:I,zoomOnPinch:R,panOnScroll:A,panOnScrollSpeed:O,panOnScrollMode:B,zoomOnDoubleClick:H,panOnDrag:Y,autoPanOnSelection:X,onPaneClick:ee,onPaneMouseEnter:J,onPaneMouseMove:Z,onPaneMouseLeave:$,onPaneScroll:W,onPaneContextMenu:ne,paneClickDistance:te,nodeClickDistance:q,onEdgeContextMenu:G,onEdgeMouseEnter:re,onEdgeMouseMove:se,onEdgeMouseLeave:ie,reconnectRadius:ce,onReconnect:me,onReconnectStart:_e,onReconnectEnd:ye,noDragClassName:Ee,noWheelClassName:Oe,noPanClassName:Le,disableKeyboardA11y:Ne,nodeExtent:xe,rfId:Se,viewport:Ce,onViewportChange:Be}){return so(e),so(t),np(),Kg(n),Gg(Ce),g.jsx(yg,{onPaneClick:ee,onPaneMouseEnter:J,onPaneMouseMove:Z,onPaneMouseLeave:$,onPaneContextMenu:ne,onPaneScroll:W,paneClickDistance:te,deleteKeyCode:D,selectionKeyCode:E,selectionOnDrag:y,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:P,elementsSelectable:F,zoomOnScroll:I,zoomOnPinch:R,zoomOnDoubleClick:H,panOnScroll:A,panOnScrollSpeed:O,panOnScrollMode:B,panOnDrag:Y,autoPanOnSelection:X,defaultViewport:M,translateExtent:j,minZoom:V,maxZoom:_,onSelectionContextMenu:u,preventScrolling:C,noDragClassName:Ee,noWheelClassName:Oe,noPanClassName:Le,disableKeyboardA11y:Ne,onViewportChange:Be,isControlledViewport:!!Ce,children:g.jsxs(Xg,{children:[g.jsx(Wg,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:me,onReconnectStart:_e,onReconnectEnd:ye,onlyRenderVisibleElements:L,onEdgeContextMenu:G,onEdgeMouseEnter:re,onEdgeMouseMove:se,onEdgeMouseLeave:ie,reconnectRadius:ce,defaultMarkerColor:S,noPanClassName:Le,disableKeyboardA11y:Ne,rfId:Se}),g.jsx(ep,{style:v,type:p,component:w,containerStyle:m}),g.jsx("div",{className:"react-flow__edgelabel-renderer"}),g.jsx(kg,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,nodeClickDistance:q,onlyRenderVisibleElements:L,noPanClassName:Le,noDragClassName:Ee,disableKeyboardA11y:Ne,nodeExtent:xe,rfId:Se}),g.jsx("div",{className:"react-flow__viewport-portal"})]})})}ra.displayName="GraphView";const rp=b.memo(ra),sp=ri(),oo=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:i,fitViewOptions:a,minZoom:c=.5,maxZoom:l=2,nodeOrigin:d,nodeExtent:u,zIndexMode:f="basic"}={})=>{const h=new Map,p=new Map,v=new Map,w=new Map,m=r??t??[],E=n??e??[],y=d??[0,0],x=u??Ht;pi(v,w,m);const{nodesInitialized:N}=Sr(E,h,p,{nodeOrigin:y,nodeExtent:x,zIndexMode:f});let k=[0,0,1];if(i&&s&&o){const P=qt(h,{filter:M=>!!((M.width||M.initialWidth)&&(M.height||M.initialHeight))}),{x:D,y:L,zoom:F}=Br(P,s,o,c,l,(a==null?void 0:a.padding)??.1);k=[D,L,F]}return{rfId:"1",width:s??0,height:o??0,transform:k,nodes:E,nodesInitialized:N,nodeLookup:h,parentLookup:p,edges:m,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Ht,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:vt.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:y,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:i??!1,fitViewOptions:a,fitViewResolver:null,connection:{...Zo},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:sp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Uo,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},op=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:i,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:d,nodeExtent:u,zIndexMode:f})=>xh((h,p)=>{async function v(){const{nodeLookup:w,panZoom:m,fitViewOptions:E,fitViewResolver:y,width:x,height:N,minZoom:k,maxZoom:P}=p();m&&(await Jd({nodes:w,width:x,height:N,panZoom:m,minZoom:k,maxZoom:P},E),y==null||y.resolve(!0),h({fitViewResolver:null}))}return{...oo({nodes:e,edges:t,width:s,height:o,fitView:i,fitViewOptions:a,minZoom:c,maxZoom:l,nodeOrigin:d,nodeExtent:u,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:w=>{const{nodeLookup:m,parentLookup:E,nodeOrigin:y,elevateNodesOnSelect:x,fitViewQueued:N,zIndexMode:k,nodesSelectionActive:P}=p(),{nodesInitialized:D,hasSelectedNodes:L}=Sr(w,m,E,{nodeOrigin:y,nodeExtent:u,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:k}),F=P&&L;N&&D?(v(),h({nodes:w,nodesInitialized:D,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):h({nodes:w,nodesInitialized:D,nodesSelectionActive:F})},setEdges:w=>{const{connectionLookup:m,edgeLookup:E}=p();pi(m,E,w),h({edges:w})},setDefaultNodesAndEdges:(w,m)=>{if(w){const{setNodes:E}=p();E(w),h({hasDefaultNodes:!0})}if(m){const{setEdges:E}=p();E(m),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:m,nodeLookup:E,parentLookup:y,domNode:x,nodeOrigin:N,nodeExtent:k,debug:P,fitViewQueued:D,zIndexMode:L}=p(),{changes:F,updatedInternals:M}=Ef(w,E,y,x,N,k,L);M&&(wf(E,y,{nodeOrigin:N,nodeExtent:k,zIndexMode:L}),D?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(F==null?void 0:F.length)>0&&(P&&console.log("React Flow: trigger node changes",F),m==null||m(F)))},updateNodePositions:(w,m=!1)=>{const E=[];let y=[];const{nodeLookup:x,triggerNodeChanges:N,connection:k,updateConnection:P,onNodesChangeMiddlewareMap:D}=p();for(const[L,F]of w){const M=x.get(L),j=!!(M!=null&&M.expandParent&&(M!=null&&M.parentId)&&(F!=null&&F.position)),V={id:L,type:"position",position:j?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:m};if(M&&k.inProgress&&k.fromNode.id===M.id){const _=ut(M,k.fromHandle,Q.Left,!0);P({...k,from:_})}j&&M.parentId&&E.push({id:L,parentId:M.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),y.push(V)}if(E.length>0){const{parentLookup:L,nodeOrigin:F}=p(),M=Kr(E,x,L,F);y.push(...M)}for(const L of D.values())y=L(y);N(y)},triggerNodeChanges:w=>{const{onNodesChange:m,setNodes:E,nodes:y,hasDefaultNodes:x,debug:N}=p();if(w!=null&&w.length){if(x){const k=Hh(w,y);E(k)}N&&console.log("React Flow: trigger node changes",w),m==null||m(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:m,setEdges:E,edges:y,hasDefaultEdges:x,debug:N}=p();if(w!=null&&w.length){if(x){const k=Oh(w,y);E(k)}N&&console.log("React Flow: trigger edge changes",w),m==null||m(w)}},addSelectedNodes:w=>{const{multiSelectionActive:m,edgeLookup:E,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:N}=p();if(m){const k=w.map(P=>et(P,!0));x(k);return}x(pt(y,new Set([...w]),!0)),N(pt(E))},addSelectedEdges:w=>{const{multiSelectionActive:m,edgeLookup:E,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:N}=p();if(m){const k=w.map(P=>et(P,!0));N(k);return}N(pt(E,new Set([...w]))),x(pt(y,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:m}={})=>{const{edges:E,nodes:y,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:k}=p(),P=w||y,D=m||E,L=[];for(const M of P){if(!M.selected)continue;const j=x.get(M.id);j&&(j.selected=!1),L.push(et(M.id,!1))}const F=[];for(const M of D)M.selected&&F.push(et(M.id,!1));N(L),k(F)},setMinZoom:w=>{const{panZoom:m,maxZoom:E}=p();m==null||m.setScaleExtent([w,E]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:m,minZoom:E}=p();m==null||m.setScaleExtent([E,w]),h({maxZoom:w})},setTranslateExtent:w=>{var m;(m=p().panZoom)==null||m.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:m,triggerNodeChanges:E,triggerEdgeChanges:y,elementsSelectable:x}=p();if(!x)return;const N=m.reduce((P,D)=>D.selected?[...P,et(D.id,!1)]:P,[]),k=w.reduce((P,D)=>D.selected?[...P,et(D.id,!1)]:P,[]);E(N),y(k)},setNodeExtent:w=>{const{nodes:m,nodeLookup:E,parentLookup:y,nodeOrigin:x,elevateNodesOnSelect:N,nodeExtent:k,zIndexMode:P}=p();w[0][0]===k[0][0]&&w[0][1]===k[0][1]&&w[1][0]===k[1][0]&&w[1][1]===k[1][1]||(Sr(m,E,y,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:P}),h({nodeExtent:w}))},panBy:w=>{const{transform:m,width:E,height:y,panZoom:x,translateExtent:N}=p();return Nf({delta:w,panZoom:x,transform:m,translateExtent:N,width:E,height:y})},setCenter:async(w,m,E)=>{const{width:y,height:x,maxZoom:N,panZoom:k}=p();if(!k)return!1;const P=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:N;return await k.setViewport({x:y/2-w*P,y:x/2-m*P,zoom:P},{duration:E==null?void 0:E.duration,ease:E==null?void 0:E.ease,interpolate:E==null?void 0:E.interpolate}),!0},cancelConnection:()=>{h({connection:{...Zo}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...oo()})}},Object.is);function sa({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:o,initialMinZoom:i,initialMaxZoom:a,initialFitViewOptions:c,fitView:l,nodeOrigin:d,nodeExtent:u,zIndexMode:f,children:h}){const[p]=b.useState(()=>op({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:o,fitView:l,minZoom:i,maxZoom:a,fitViewOptions:c,nodeOrigin:d,nodeExtent:u,zIndexMode:f}));return g.jsx(wh,{value:p,children:g.jsx(Xh,{children:h})})}function ip({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:o,height:i,fitView:a,fitViewOptions:c,minZoom:l,maxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h}){return b.useContext(Hn)?g.jsx(g.Fragment,{children:e}):g.jsx(sa,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:o,initialHeight:i,fitView:a,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:d,nodeOrigin:u,nodeExtent:f,zIndexMode:h,children:e})}const ap={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function cp({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o,edgeTypes:i,onNodeClick:a,onEdgeClick:c,onInit:l,onMove:d,onMoveStart:u,onMoveEnd:f,onConnect:h,onConnectStart:p,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,onNodeMouseEnter:E,onNodeMouseMove:y,onNodeMouseLeave:x,onNodeContextMenu:N,onNodeDoubleClick:k,onNodeDragStart:P,onNodeDrag:D,onNodeDragStop:L,onNodesDelete:F,onEdgesDelete:M,onDelete:j,onSelectionChange:V,onSelectionDragStart:_,onSelectionDrag:C,onSelectionDragStop:S,onSelectionContextMenu:I,onSelectionStart:R,onSelectionEnd:A,onBeforeDelete:O,connectionMode:B,connectionLineType:H=Ue.Bezier,connectionLineStyle:Y,connectionLineComponent:X,connectionLineContainerStyle:ee,deleteKeyCode:J="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:$=!1,selectionMode:W=Ot.Full,panActivationKeyCode:ne="Space",multiSelectionKeyCode:te=Ft()?"Meta":"Control",zoomActivationKeyCode:q=Ft()?"Meta":"Control",snapToGrid:G,snapGrid:re,onlyRenderVisibleElements:se=!1,selectNodesOnDrag:ie,nodesDraggable:ce,autoPanOnNodeFocus:me,nodesConnectable:_e,nodesFocusable:ye,nodeOrigin:Ee=ji,edgesFocusable:Oe,edgesReconnectable:Le,elementsSelectable:Ne=!0,defaultViewport:xe=jh,minZoom:Se=.5,maxZoom:Ce=2,translateExtent:Be=Ht,preventScrolling:Ut=!0,nodeExtent:ke,defaultMarkerColor:Zt="#b1b1b7",zoomOnScroll:Qe=!0,zoomOnPinch:Qt=!0,panOnScroll:Jt=!1,panOnScrollSpeed:Je=.5,panOnScrollMode:dt=st.Free,zoomOnDoubleClick:ft=!0,panOnDrag:en=!0,onPaneClick:Wn,onPaneMouseEnter:Yn,onPaneMouseMove:Xn,onPaneMouseLeave:tn,onPaneScroll:Kn,onPaneContextMenu:qn,paneClickDistance:z=1,nodeClickDistance:K=0,children:U,onReconnect:oe,onReconnectStart:de,onReconnectEnd:T,onEdgeContextMenu:pe,onEdgeDoubleClick:he,onEdgeMouseEnter:Ve,onEdgeMouseMove:Ae,onEdgeMouseLeave:Gn,reconnectRadius:pa=10,onNodesChange:ma,onEdgesChange:ya,noDragClassName:xa="nodrag",noWheelClassName:wa="nowheel",noPanClassName:Ur="nopan",fitView:Zr,fitViewOptions:Qr,connectOnClick:va,attributionPosition:ba,proOptions:_a,defaultEdgeOptions:Ea,elevateNodesOnSelect:Na=!0,elevateEdgesOnSelect:Sa=!1,disableKeyboardA11y:Jr=!1,autoPanOnConnect:ka,autoPanOnNodeDrag:Ma,autoPanOnSelection:Ca=!0,autoPanSpeed:Aa,connectionRadius:Ia,isValidConnection:$a,onError:ja,style:Pa,id:es,nodeDragThreshold:Da,connectionDragThreshold:Ta,viewport:La,onViewportChange:Ra,width:za,height:Ha,colorMode:Oa="light",debug:Ba,onScroll:nn,ariaLabelConfig:Va,zIndexMode:ts="basic",...Fa},Wa){const Un=es||"1",Ya=Lh(Oa),Xa=b.useCallback(ns=>{ns.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),nn==null||nn(ns)},[nn]);return g.jsx("div",{"data-testid":"rf__wrapper",...Fa,onScroll:Xa,style:{...Pa,...ap},ref:Wa,className:fe(["react-flow",s,Ya]),id:es,role:"application",children:g.jsxs(ip,{nodes:e,edges:t,width:za,height:Ha,fitView:Zr,fitViewOptions:Qr,minZoom:Se,maxZoom:Ce,nodeOrigin:Ee,nodeExtent:ke,zIndexMode:ts,children:[g.jsx(Th,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:p,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,nodesDraggable:ce,autoPanOnNodeFocus:me,nodesConnectable:_e,nodesFocusable:ye,edgesFocusable:Oe,edgesReconnectable:Le,elementsSelectable:Ne,elevateNodesOnSelect:Na,elevateEdgesOnSelect:Sa,minZoom:Se,maxZoom:Ce,nodeExtent:ke,onNodesChange:ma,onEdgesChange:ya,snapToGrid:G,snapGrid:re,connectionMode:B,translateExtent:Be,connectOnClick:va,defaultEdgeOptions:Ea,fitView:Zr,fitViewOptions:Qr,onNodesDelete:F,onEdgesDelete:M,onDelete:j,onNodeDragStart:P,onNodeDrag:D,onNodeDragStop:L,onSelectionDrag:C,onSelectionDragStart:_,onSelectionDragStop:S,onMove:d,onMoveStart:u,onMoveEnd:f,noPanClassName:Ur,nodeOrigin:Ee,rfId:Un,autoPanOnConnect:ka,autoPanOnNodeDrag:Ma,autoPanSpeed:Aa,onError:ja,connectionRadius:Ia,isValidConnection:$a,selectNodesOnDrag:ie,nodeDragThreshold:Da,connectionDragThreshold:Ta,onBeforeDelete:O,debug:Ba,ariaLabelConfig:Va,zIndexMode:ts}),g.jsx(rp,{onInit:l,onNodeClick:a,onEdgeClick:c,onNodeMouseEnter:E,onNodeMouseMove:y,onNodeMouseLeave:x,onNodeContextMenu:N,onNodeDoubleClick:k,nodeTypes:o,edgeTypes:i,connectionLineType:H,connectionLineStyle:Y,connectionLineComponent:X,connectionLineContainerStyle:ee,selectionKeyCode:Z,selectionOnDrag:$,selectionMode:W,deleteKeyCode:J,multiSelectionKeyCode:te,panActivationKeyCode:ne,zoomActivationKeyCode:q,onlyRenderVisibleElements:se,defaultViewport:xe,translateExtent:Be,minZoom:Se,maxZoom:Ce,preventScrolling:Ut,zoomOnScroll:Qe,zoomOnPinch:Qt,zoomOnDoubleClick:ft,panOnScroll:Jt,panOnScrollSpeed:Je,panOnScrollMode:dt,panOnDrag:en,autoPanOnSelection:Ca,onPaneClick:Wn,onPaneMouseEnter:Yn,onPaneMouseMove:Xn,onPaneMouseLeave:tn,onPaneScroll:Kn,onPaneContextMenu:qn,paneClickDistance:z,nodeClickDistance:K,onSelectionContextMenu:I,onSelectionStart:R,onSelectionEnd:A,onReconnect:oe,onReconnectStart:de,onReconnectEnd:T,onEdgeContextMenu:pe,onEdgeDoubleClick:he,onEdgeMouseEnter:Ve,onEdgeMouseMove:Ae,onEdgeMouseLeave:Gn,reconnectRadius:pa,defaultMarkerColor:Zt,noDragClassName:xa,noWheelClassName:wa,noPanClassName:Ur,rfId:Un,disableKeyboardA11y:Jr,nodeExtent:ke,viewport:La,onViewportChange:Ra}),g.jsx($h,{onSelectionChange:V}),U,g.jsx(kh,{proOptions:_a,position:ba}),g.jsx(Sh,{rfId:Un,disableKeyboardA11y:Jr})]})})}var lp=Di(cp);function up({dimensions:e,lineWidth:t,variant:n,className:r}){return g.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:fe(["react-flow__background-pattern",n,r])})}function dp({radius:e,className:t}){return g.jsx("circle",{cx:e,cy:e,r:e,className:fe(["react-flow__background-pattern","dots",t])})}var Ze;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ze||(Ze={}));const fp={[Ze.Dots]:1,[Ze.Lines]:1,[Ze.Cross]:6},hp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function oa({id:e,variant:t=Ze.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=0,color:i,bgColor:a,style:c,className:l,patternClassName:d}){const u=b.useRef(null),{transform:f,patternId:h}=ae(hp,le),p=r||fp[t],v=t===Ze.Dots,w=t===Ze.Cross,m=Array.isArray(n)?n:[n,n],E=[m[0]*f[2]||1,m[1]*f[2]||1],y=p*f[2],x=Array.isArray(o)?o:[o,o],N=w?[y,y]:E,k=[x[0]*f[2]||1+N[0]/2,x[1]*f[2]||1+N[1]/2],P=`${h}${e||""}`;return g.jsxs("svg",{className:fe(["react-flow__background",l]),style:{...c,...Vn,"--xy-background-color-props":a,"--xy-background-pattern-color-props":i},ref:u,"data-testid":"rf__background",children:[g.jsx("pattern",{id:P,x:f[0]%E[0],y:f[1]%E[1],width:E[0],height:E[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:v?g.jsx(dp,{radius:y/2,className:d}):g.jsx(up,{dimensions:N,lineWidth:s,variant:t,className:d})}),g.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}oa.displayName="Background";b.memo(oa);function gp(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:g.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function pp(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:g.jsx("path",{d:"M0 0h32v4.2H0z"})})}function mp(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:g.jsx("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function yp(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function xp(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.jsx("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function fn({children:e,className:t,...n}){return g.jsx("button",{type:"button",className:fe(["react-flow__controls-button",t]),...n,children:e})}const wp=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ia({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:i,onFitView:a,onInteractiveChange:c,className:l,children:d,position:u="bottom-left",orientation:f="vertical","aria-label":h}){const p=ue(),{isInteractive:v,minZoomReached:w,maxZoomReached:m,ariaLabelConfig:E}=ae(wp,le),{zoomIn:y,zoomOut:x,fitView:N}=Bn(),k=()=>{y(),o==null||o()},P=()=>{x(),i==null||i()},D=()=>{N(s),a==null||a()},L=()=>{p.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},F=f==="horizontal"?"horizontal":"vertical";return g.jsxs(On,{className:fe(["react-flow__controls",F,l]),position:u,style:e,"data-testid":"rf__controls","aria-label":h??E["controls.ariaLabel"],children:[t&&g.jsxs(g.Fragment,{children:[g.jsx(fn,{onClick:k,className:"react-flow__controls-zoomin",title:E["controls.zoomIn.ariaLabel"],"aria-label":E["controls.zoomIn.ariaLabel"],disabled:m,children:g.jsx(gp,{})}),g.jsx(fn,{onClick:P,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:w,children:g.jsx(pp,{})})]}),n&&g.jsx(fn,{className:"react-flow__controls-fitview",onClick:D,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:g.jsx(mp,{})}),r&&g.jsx(fn,{className:"react-flow__controls-interactive",onClick:L,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:v?g.jsx(xp,{}):g.jsx(yp,{})}),d]})}ia.displayName="Controls";b.memo(ia);function vp({id:e,x:t,y:n,width:r,height:s,style:o,color:i,strokeColor:a,strokeWidth:c,className:l,borderRadius:d,shapeRendering:u,selected:f,onClick:h}){const{background:p,backgroundColor:v}=o||{},w=i||p||v;return g.jsx("rect",{className:fe(["react-flow__minimap-node",{selected:f},l]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:w,stroke:a,strokeWidth:c},shapeRendering:u,onClick:h?m=>h(m,e):void 0})}const bp=b.memo(vp),_p=e=>e.nodes.map(t=>t.id),ir=e=>e instanceof Function?e:()=>e;function Ep({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=bp,onClick:i}){const a=ae(_p,le),c=ir(t),l=ir(e),d=ir(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return g.jsx(g.Fragment,{children:a.map(f=>g.jsx(Sp,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:i,shapeRendering:u},f))})}function Np({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:o,shapeRendering:i,NodeComponent:a,onClick:c}){const{node:l,x:d,y:u,width:f,height:h}=ae(p=>{const v=p.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:m,y:E}=v.internals.positionAbsolute,{width:y,height:x}=Ke(w);return{node:w,x:m,y:E,width:y,height:x}},le);return!l||l.hidden||!si(l)?null:g.jsx(a,{x:d,y:u,width:f,height:h,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:s,strokeColor:n(l),strokeWidth:o,shapeRendering:i,onClick:c,id:l.id})}const Sp=b.memo(Np);var kp=b.memo(Ep);const Mp=200,Cp=150,Ap=e=>!e.hidden,Ip=e=>{const t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?ni(qt(e.nodeLookup,{filter:Ap}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},$p="react-flow__minimap-desc";function aa({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:i,nodeComponent:a,bgColor:c,maskColor:l,maskStrokeColor:d,maskStrokeWidth:u,position:f="bottom-right",onClick:h,onNodeClick:p,pannable:v=!1,zoomable:w=!1,ariaLabel:m,inversePan:E,zoomStep:y=1,offsetScale:x=5}){const N=ue(),k=b.useRef(null),{boundingRect:P,viewBB:D,rfId:L,panZoom:F,translateExtent:M,flowWidth:j,flowHeight:V,ariaLabelConfig:_}=ae(Ip,le),C=(e==null?void 0:e.width)??Mp,S=(e==null?void 0:e.height)??Cp,I=P.width/C,R=P.height/S,A=Math.max(I,R),O=A*C,B=A*S,H=x*A,Y=P.x-(O-P.width)/2-H,X=P.y-(B-P.height)/2-H,ee=O+H*2,J=B+H*2,Z=`${$p}-${L}`,$=b.useRef(0),W=b.useRef();$.current=A,b.useEffect(()=>{if(k.current&&F)return W.current=Pf({domNode:k.current,panZoom:F,getTransform:()=>N.getState().transform,getViewScale:()=>$.current}),()=>{var G;(G=W.current)==null||G.destroy()}},[F]),b.useEffect(()=>{var G;(G=W.current)==null||G.update({translateExtent:M,width:j,height:V,inversePan:E,pannable:v,zoomStep:y,zoomable:w})},[v,w,E,y,M,j,V]);const ne=h?G=>{var ie;const[re,se]=((ie=W.current)==null?void 0:ie.pointer(G))||[0,0];h(G,{x:re,y:se})}:void 0,te=p?b.useCallback((G,re)=>{const se=N.getState().nodeLookup.get(re).internals.userNode;p(G,se)},[]):void 0,q=m??_["minimap.ariaLabel"];return g.jsx(On,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*A:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:fe(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:g.jsxs("svg",{width:C,height:S,viewBox:`${Y} ${X} ${ee} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":Z,ref:k,onClick:ne,children:[q&&g.jsx("title",{id:Z,children:q}),g.jsx(kp,{onClick:te,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:a}),g.jsx("path",{className:"react-flow__minimap-mask",d:`M${Y-H},${X-H}h${ee+H*2}v${J+H*2}h${-ee-H*2}z
24
- M${D.x},${D.y}h${D.width}v${D.height}h${-D.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}aa.displayName="MiniMap";b.memo(aa);const jp=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Pp={[Nt.Line]:"right",[Nt.Handle]:"bottom-right"};function Dp({nodeId:e,position:t,variant:n=Nt.Handle,className:r,style:s=void 0,children:o,color:i,minWidth:a=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:d=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:f,autoScale:h=!0,shouldResize:p,onResizeStart:v,onResize:w,onResizeEnd:m}){const E=zi(),y=typeof e=="string"?e:E,x=ue(),N=b.useRef(null),k=n===Nt.Handle,P=ae(b.useCallback(jp(k&&h),[k,h]),le),D=b.useRef(null),L=t??Pp[n];b.useEffect(()=>{if(!(!N.current||!y))return D.current||(D.current=Xf({domNode:N.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:M,transform:j,snapGrid:V,snapToGrid:_,nodeOrigin:C,domNode:S}=x.getState();return{nodeLookup:M,transform:j,snapGrid:V,snapToGrid:_,nodeOrigin:C,paneDomNode:S}},onChange:(M,j)=>{const{triggerNodeChanges:V,nodeLookup:_,parentLookup:C,nodeOrigin:S}=x.getState(),I=[],R={x:M.x,y:M.y},A=_.get(y);if(A&&A.expandParent&&A.parentId){const O=A.origin??S,B=M.width??A.measured.width??0,H=M.height??A.measured.height??0,Y={id:A.id,parentId:A.parentId,rect:{width:B,height:H,...oi({x:M.x??A.position.x,y:M.y??A.position.y},{width:B,height:H},A.parentId,_,O)}},X=Kr([Y],_,C,S);I.push(...X),R.x=M.x?Math.max(O[0]*B,M.x):void 0,R.y=M.y?Math.max(O[1]*H,M.y):void 0}if(R.x!==void 0&&R.y!==void 0){const O={id:y,type:"position",position:{...R}};I.push(O)}if(M.width!==void 0&&M.height!==void 0){const B={id:y,type:"dimensions",resizing:!0,setAttributes:f?f==="horizontal"?"width":"height":!0,dimensions:{width:M.width,height:M.height}};I.push(B)}for(const O of j){const B={...O,type:"position"};I.push(B)}V(I)},onEnd:({width:M,height:j})=>{const V={id:y,type:"dimensions",resizing:!1,dimensions:{width:M,height:j}};x.getState().triggerNodeChanges([V])}})),D.current.update({controlPosition:L,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:m,shouldResize:p}),()=>{var M;(M=D.current)==null||M.destroy()}},[L,a,c,l,d,u,v,w,m,p]);const F=L.split("-");return g.jsx("div",{className:fe(["react-flow__resize-control","nodrag",...F,n,r]),ref:N,style:{...s,scale:P,...i&&{[k?"backgroundColor":"borderColor"]:i}},children:o})}b.memo(Dp);function Tp(e,t){if(!e)return null;const n=Date.parse(e);if(Number.isNaN(n))return null;const r=Math.max(0,(Date.now()-n)/1e3);if(r<45)return t("time.justNow");const s=r/60,o=s/60,i=o/24;return s<45?t("time.minutes",{n:Math.round(s)}):o<22?t("time.hours",{n:Math.round(o)}):i<7?t("time.days",{n:Math.round(i)}):t("time.weeks",{n:Math.round(i/7)})}const Lp=4,io={isConnectable:!1,isConnectableStart:!1,isConnectableEnd:!1,style:{pointerEvents:"none"},"aria-hidden":!0};function Rp({data:e}){const t=Xe(),n=[...new Map((e.editors||[]).map(o=>[o.id,o])).values()];if(n.length===0)return null;const r=n.slice(0,Lp),s=n.length-r.length;return g.jsxs("span",{className:"node-editors","data-tip":t("specNode.liveEditors",{n:n.length}),children:[r.map(o=>g.jsx(ec,{seed:o.id,status:o.status,title:t("specNode.editorTitle",{node:o.node||t("common.session"),status:t(`status.${o.status}`),id:o.id.slice(0,8)})},o.id)),s>0&&g.jsxs("span",{className:"av-more","data-tip":t("specNode.more",{n:s}),children:["+",s]})]})}function zp({issues:e,t}){return!e||e.length===0?null:g.jsxs("span",{className:"issue-badge","data-tip":t("specNode.openIssues",{n:e.length}),children:["◆",e.length]})}function Hp({data:e,selected:t}){const n=Xe(),r=ot[e.status]||ot.pending,s=Tp(e.lastEdited,n),o=e.overlays||[],i=o[0],a=o.some(u=>u.op==="deleted"),c=i&&!i.committed,l=[...new Set(o.map(u=>u.op))],d=["spec-node",e.status,t?"focused":"",e.ghost?"ghost":"",a?"deleted":"",o.length?"has-overlay":"",c?"ov-dirty":""].filter(Boolean).join(" ");return g.jsxs("div",{className:d,style:i?{"--ov":fr(i.seed)}:void 0,children:[g.jsx(kt,{type:"target",position:Q.Left,...io}),g.jsxs("div",{className:"node-row1",children:[g.jsx("span",{className:"node-dot",style:{background:r.color},children:e.status==="active"&&g.jsx("span",{className:"pulse",style:{background:r.color}})}),g.jsx("span",{className:"node-title",children:e.title}),l.length>0?g.jsx("span",{className:"ov-marks","data-tip":o.map(u=>n("specNode.opTitle",{op:n(`legend.opRows.${u.op}`),label:u.label,uncommitted:!u.committed})).join(`
25
- `),children:l.map(u=>g.jsx("span",{className:`ov-mark ov-${u}`,children:mo[u]},u))}):s?g.jsx("span",{className:"node-ago",children:s}):null]}),g.jsxs("div",{className:"node-row2",children:[g.jsx("span",{className:"node-ver",children:e.version?`v${e.version}`:""}),e.drift>0&&g.jsxs("span",{className:"drift-badge","data-tip":(e.driftFiles||[]).map(u=>`${u.file}: ${n("specNode.driftAhead",{n:u.behind})}`).join(`
26
- `),children:["⚠",e.drift]}),g.jsx(zp,{issues:e.openIssues,t:n}),g.jsx(Ja,{scenarios:e.scenarios,evals:e.evals}),g.jsx(Rp,{data:e})]}),e.collapsed&&g.jsxs("span",{className:"node-expand","data-tip":n("specNode.expandable",{n:e.childCount}),children:["▸",e.childCount]}),g.jsx(kt,{type:"source",position:Q.Right,...io})]})}const ar=typeof window<"u"?window.__escStack||(window.__escStack=[]):[];typeof window<"u"&&!window.__escStackBound&&(window.__escStackBound=!0,window.addEventListener("keydown",e=>{const t=window.__escStack;e.key!=="Escape"||!t||t.length===0||(e.preventDefault(),e.stopImmediatePropagation(),t[t.length-1].close())},!0));function Op(e,t){const n=b.useRef(t);n.current=t,b.useEffect(()=>{if(!e)return;const r={close:()=>{var s;return(s=n.current)==null?void 0:s.call(n)}};return ar.push(r),()=>{const s=ar.indexOf(r);s>=0&&ar.splice(s,1)}},[e])}function Bp({menu:e,onClose:t,onInfo:n,onFresh:r,onNewChild:s,onDelete:o,sessions:i=[],onOpenSession:a}){const c=Xe();if(b.useEffect(()=>{if(e)return window.addEventListener("click",t),window.addEventListener("contextmenu",t,!0),()=>{window.removeEventListener("click",t),window.removeEventListener("contextmenu",t,!0)}},[e,t]),Op(!!e,t),!e)return null;const l=u=>f=>{f.stopPropagation(),t(),u(e.id)},d=u=>f=>{f.stopPropagation(),t(),a==null||a(u)};return g.jsxs("div",{className:"sess-menu",style:{left:e.x,top:e.y},onClick:u=>u.stopPropagation(),children:[g.jsx("button",{className:"sess-menu-item",onClick:l(n),children:c("nodeMenu.info")}),g.jsx("button",{className:"sess-menu-item",onClick:l(r),children:c("nodeMenu.newSession")}),g.jsx("button",{className:"sess-menu-item",onClick:l(s),children:c("nodeMenu.newChild")}),g.jsx("button",{className:"sess-menu-item danger",onClick:l(o),children:c("nodeMenu.del")}),i.length>0&&g.jsx("div",{className:"sess-menu-sep"}),i.map(u=>g.jsxs("button",{className:"sess-menu-item sess-menu-sess",onClick:d(u.id),children:[g.jsx("span",{className:"sess-glyph",style:{color:hr[u.status]},"aria-hidden":"true",children:tc[u.status]}),Ar(u)]},u.id))]})}let cr=null;function ca(e=!0){const[t,n]=b.useState(cr),r=b.useRef(!1);return b.useEffect(()=>{!e||r.current||(r.current=!0,fetch("/api/specs/lite").then(s=>s.ok?s.json():[]).then(s=>{cr={bodies:Object.fromEntries((s||[]).map(o=>[o.id,o.body||""])),scenarios:Object.fromEntries((s||[]).filter(o=>{var i;return(i=o.scenarios)==null?void 0:i.length}).map(o=>[o.id,Object.fromEntries(o.scenarios.map(i=>[i.name,i]))]))},n(cr)}).catch(()=>{}))},[e]),t}const Vp={pass:"✓",fail:"✗",stalePass:"✓",staleFail:"✗",empty:"○",missing:"·"};function Fp({nodeId:e,s:t,prose:n,t:r,onNavigateAddress:s}){const o=(n==null?void 0:n.expected)??t.expected,i=(n==null?void 0:n.code)??t.code;return g.jsxs("button",{type:"button",className:`fp-scenario ${t.state}`,onClick:()=>s==null?void 0:s(xo(e,t.name)),"data-tip":r("focusPanel.openEval"),children:[g.jsx("span",{className:"fp-sc-mark","data-tip":r(`score.${t.state}`),children:Vp[t.state]}),g.jsxs("span",{className:"fp-sc-body",children:[g.jsx("span",{className:"fp-sc-name",children:t.name}),g.jsx(yo,{tags:t.tags}),o&&g.jsx("span",{className:"fp-sc-expected",children:o}),(i==null?void 0:i.length)>0&&g.jsx("span",{className:"fp-sc-code",children:r("focusPanel.tracks",{files:i.join(", ")})})]})]})}function Wp({node:e,onNavigateAddress:t}){var d;const n=Xe(),r=Ir(e==null?void 0:e.scenarios,e==null?void 0:e.evals),s=ca(r.length>0),o=e?(d=s==null?void 0:s.scenarios)==null?void 0:d[e.id]:null,i=r.filter(u=>u.state==="pass").length,a=(e==null?void 0:e.issues)||[],c=a.filter(u=>u.status==="open"),l=a.filter(u=>u.status!=="open");return g.jsxs("aside",{className:"focus-panel",children:[g.jsxs("div",{className:"fp-head",children:[g.jsx("span",{className:"fp-title",children:e?e.title:n("focusPanel.noFocus")}),(e==null?void 0:e.desc)&&g.jsx("span",{className:"fp-desc","data-tip":e.desc,children:e.desc})]}),g.jsxs("section",{className:"fp-sec",children:[g.jsxs("div",{className:"fp-sec-head",children:[g.jsx("span",{children:n("focusPanel.scenarios")}),r.length>0&&g.jsxs("span",{className:`fp-count ${nc(r)}`,children:["✓",i,"/",r.length]})]}),r.length?r.map(u=>g.jsx(Fp,{nodeId:e.id,s:u,prose:o==null?void 0:o[u.name],t:n,onNavigateAddress:t},u.name)):g.jsx("div",{className:"fp-empty",children:n("focusPanel.noScenarios")})]}),g.jsxs("section",{className:"fp-sec",children:[g.jsxs("div",{className:"fp-sec-head",children:[g.jsx("span",{children:n("focusPanel.issues")}),a.length>0&&g.jsxs("span",{className:"fp-issue-counts",children:[c.length>0&&g.jsx("span",{className:"issue-state st-open",children:n("focusPanel.open",{n:c.length})}),l.length>0&&g.jsx("span",{className:"issue-state st-closed",children:n("focusPanel.closed",{n:l.length})})]})]}),a.length?g.jsxs(g.Fragment,{children:[c.map(u=>g.jsx(rs,{issue:u,onNavigateAddress:t},u.id)),l.length>0&&g.jsx("div",{className:"issue-group-head closed",children:n("focusPanel.closed",{n:l.length})}),l.map(u=>g.jsx(rs,{issue:u,onNavigateAddress:t},u.id))]}):g.jsx("div",{className:"fp-empty",children:n("focusPanel.noIssues")})]})]})}function Yp({title:e,closeLabel:t,onClose:n,className:r,children:s}){return g.jsx("div",{className:"legend-backdrop","data-focus-overlay":!0,onClick:n,children:g.jsxs("div",{className:r?`legend ${r}`:"legend",role:"dialog","aria-modal":"true","aria-label":e,onClick:o=>o.stopPropagation(),children:[g.jsxs("div",{className:"legend-head",children:[g.jsx("span",{className:"legend-title",children:e}),g.jsx(rc,{icon:"x",size:13,className:"legend-close",label:t,onClick:n})]}),g.jsx("div",{className:"legend-body",children:s})]})})}const la=[{id:"nav.up",keys:["ArrowUp","k"],rebind:!1,desc:"legend.board.move"},{id:"nav.down",keys:["ArrowDown","j"],rebind:!1,desc:"legend.board.move"},{id:"nav.parent",keys:["ArrowLeft","h"],rebind:!1,desc:"legend.board.parent"},{id:"nav.child",keys:["ArrowRight","l"],rebind:!1,desc:"legend.board.child"},{id:"board.zoomIn",keys:["+","="],rebind:!0,desc:"legend.board.zoom"},{id:"board.zoomOut",keys:["-","_"],rebind:!0,desc:"legend.board.zoom"},{id:"board.zoomReset",keys:["0"],rebind:!0,desc:"legend.board.zoom"},{id:"board.info",keys:["i","I","Enter"],rebind:!0,desc:"legend.board.info"},{id:"board.search",keys:["/"],rebind:!0,desc:"legend.board.search"},{id:"board.cycle",keys:["o"],rebind:!0,desc:"legend.board.overlayCycle"},{id:"board.cycleRev",keys:["O"],rebind:!0,desc:"legend.board.overlayCycle"},{id:"board.fresh",keys:["["],rebind:!0,desc:"legend.board.fresh"},{id:"board.evals",keys:["f"],rebind:!0,desc:"legend.board.evals"},{id:"board.newChild",keys:["n"],rebind:!1,desc:"legend.board.newChild"},{id:"board.del",keys:["d"],rebind:!1,desc:"legend.board.del"},{id:"board.settings",keys:[","],rebind:!0,desc:"legend.board.settings"},{id:"board.help",keys:["?"],rebind:!0,desc:"legend.board.help"}],Xp={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Enter:"⏎",Escape:"esc"," ":"␣","-":"−"},Kp=e=>Xp[e]||e,Gr="spex.keybindings.v1",qp=Object.fromEntries(la.map(e=>[e.id,e]));function Gp(){try{return JSON.parse(localStorage.getItem(Gr))||{}}catch{return{}}}let nt=Gp();function ua(e){var n;const t=nt[e];return t&&t.keys||((n=qp[e])==null?void 0:n.keys)||[]}function Fm(e){return!!nt[e]}function ge(e,t){return ua(e).includes(t)}function Wm(e,t){nt={...nt,[e]:{...nt[e],...t}},localStorage.setItem(Gr,JSON.stringify(nt))}function Ym(){nt={},localStorage.removeItem(Gr)}const Up=new Set(["=","_","I"]),Zp=(()=>{const e=[];for(const t of la){const n=ua(t.id).filter(s=>!Up.has(s)).map(Kp),r=e[e.length-1];r&&r.desc===t.desc?r.keys.push(...n):e.push({desc:t.desc,keys:n})}return e})(),Qp=[[["←","→","h","l","⇥","1","2"],"legend.popup.switch"],[["j","k","↑","↓"],"legend.popup.scroll"],[["⏎"],"legend.popup.enter"],[["esc"],"legend.popup.esc"]],Jp=["merged","active","drift","pending"],em=["added","edited","deleted","moved"];function tm({t:e}){return g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:e("legend.secBoard")}),Zp.map(t=>g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"keymap-keys",children:t.keys.map((n,r)=>g.jsx("kbd",{children:n},r))}),g.jsx("span",{className:"legend-desc",children:e(t.desc)})]},t.desc))]})}function nm({title:e,rows:t,t:n}){return g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:e}),t.map(([r,s])=>g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"keymap-keys",children:r.map((o,i)=>g.jsx("kbd",{children:o},i))}),g.jsx("span",{className:"legend-desc",children:n(s)})]},s))]})}function rm({onClose:e}){const t=Xe();return g.jsxs(Yp,{title:t("legend.title"),closeLabel:t("legend.close"),onClose:e,children:[g.jsx(tm,{t}),g.jsx(nm,{title:t("legend.secPopup"),rows:Qp,t}),g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:t("legend.secStatus")}),Jp.map(n=>g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"node-dot",style:{background:ot[n].color},children:n==="active"&&g.jsx("span",{className:"pulse",style:{background:ot[n].color}})}),g.jsx("span",{className:"legend-name",children:t(`status.${n}`)}),g.jsx("span",{className:"legend-desc",children:t(`legend.statusRows.${n}`)})]},n))]}),g.jsxs("section",{className:"legend-sec",children:[g.jsxs("div",{className:"legend-h",children:[t("legend.secOp")," ",g.jsx("span",{className:"legend-sub",children:t("legend.secOpSub")})]}),em.map(n=>g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:`ov-mark ov-${n}`,children:mo[n]}),g.jsx("span",{className:"legend-desc",children:t(`legend.opRows.${n}`)})]},n))]}),g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:t("legend.secBadges")}),g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"drift-badge",children:"⚠N"}),g.jsx("span",{className:"legend-desc",children:t("legend.badgeDrift")})]}),g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"legend-glyph legend-ver",children:"vN"}),g.jsx("span",{className:"legend-desc",children:t("legend.badgeVer")})]})]}),g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:t("legend.secRing")}),g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"legend-ring ring-dashed"}),g.jsx("span",{className:"legend-desc",children:t("legend.ringDashed")})]}),g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"legend-ring ring-solid"}),g.jsx("span",{className:"legend-desc",children:t("legend.ringSolid")})]}),g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:"legend-ring ring-ghost"}),g.jsx("span",{className:"legend-desc",children:t("legend.ringGhost")})]})]})]})}const sm=8,om=5,im=3,am=1,cm=new Set(["the","a","an","and","or","of","to","in","on","is","it","its","as","at","by","for","how","does","do","what","which","that","this","these","those","with","from","into","are","be","can","just","them","they","their","so","if","not","no","but","vs","us","we","you"]);function lm(e){const t=new Set;for(const n of e.toLowerCase().split(/[^a-z0-9]+/))n.length>1&&!cm.has(n)&&t.add(n);return[...t]}function lr(e){return e.toLowerCase().split(/[^a-z0-9]+/).filter(Boolean)}function da(e){let t=e;return t.length>=4&&t.endsWith("s")&&!t.endsWith("ss")&&(t=t.slice(0,-1)),t.length>=5&&t.endsWith("e")&&(t=t.slice(0,-1)),t}function fa(e,t){return t.startsWith(da(e))}function Cn(e,t){return t.startsWith(da(e))||t.length>=3&&e.startsWith(t)}const ao=1.2,co=.4;function lo(e,t,n){return e<=0?0:e*(ao+1)/(e+ao*(1-co+co*t/(n||1)))}function um(e,t,n,r){if(t.nameWords.some(o=>fa(e,o)))return sm;if(t.name.includes(e))return om;if(t.descWords.some(o=>Cn(e,o)))return im*lo(1,t.descWords.length,r);const s=t.bodyWords.reduce((o,i)=>o+(Cn(e,i)?1:0),0);return am*lo(s,t.bodyWords.length,n)}function dm(e,t,n,r=140){const s=e.replace(/\s+/g," ").trim(),o=s.toLowerCase();let i=-1;for(const l of n){const d=o.match(new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")));d&&d.index!==void 0&&(i<0||d.index<i)&&(i=d.index)}if(i<0){const l=(t||s).replace(/\s+/g," ").trim();return l.length>r?l.slice(0,r).trimEnd()+"…":l}const a=Math.max(0,i-Math.floor(r/3));let c=s.slice(a,a+r).trim();return a>0&&(c="…"+c),a+r<s.length&&(c=c+"…"),c}function fm(e,t,n={}){const r=n.limit??10,s=lm(e);if(!s.length)return[];const o=t.map(u=>{const f=u.name.toLowerCase();return{ref:u.ref,name:f,nameWords:lr(f),desc:u.desc.toLowerCase(),descWords:lr(u.desc),bodyWords:lr(u.body),snippetText:`${u.desc}
27
- ${u.body}`}}),i=o.length,a=o.reduce((u,f)=>u+f.bodyWords.length,0)/(i||1),c=o.reduce((u,f)=>u+f.descWords.length,0)/(i||1),l={};for(const u of s){let f=0;for(const h of o)(h.nameWords.some(p=>fa(u,p))||h.descWords.some(p=>Cn(u,p))||h.bodyWords.some(p=>Cn(u,p)))&&f++;l[u]=f>0?Math.log(i/f):0}const d=[];for(const u of o){let f=0;for(const h of s)f+=um(h,u,a,c)*l[h];f<=0||d.push({ref:u.ref,score:Math.round(f*100)/100,snippet:dm(u.snippetText,u.desc,s)})}return d.sort((u,f)=>f.score-u.score),d.slice(0,r)}const hm={pass:"var(--green)",fail:"var(--red)",stalePass:"var(--muted)",staleFail:"var(--muted)",empty:"var(--muted)",missing:"var(--muted)"},gm=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,""),uo=["spec","session","issue","scenario"],pm=e=>e?[e,...uo.filter(t=>t!==e)]:uo;function mm(e,t,n){var o,i;const r=n==null?void 0:n.bodies,s=[];for(const a of e){const c=gm(a.path);s.push({kind:"spec",key:`spec:${a.id}`,target:a.id,address:sc(a.id),color:(ot[a.status]||ot.pending).color,title:a.title||a.id,sub:c,name:`${a.title||a.id} ${a.id}`,desc:a.desc||"",body:(r==null?void 0:r[a.id])??a.body??""});for(const l of a.issues||[]){const d=l.status==="open";s.push({kind:"issue",key:`issue:${a.id}:${l.id}`,target:l.id,nodeId:a.id,address:oc(l.id),color:d?"var(--green)":"var(--muted)",title:l.concern,sub:`${l.id} · ${c}`,name:l.concern||"",desc:l.id,body:""})}for(const l of Ir(a.scenarios,a.evals)){const d=(i=(o=n==null?void 0:n.scenarios)==null?void 0:o[a.id])==null?void 0:i[l.name];s.push({kind:"scenario",key:`scenario:${a.id}:${l.name}`,target:l.name,nodeId:a.id,address:xo(a.id,l.name),color:hm[l.state]||"var(--cyan)",title:l.name,sub:c,tags:l.tags,name:l.name||"",desc:"",body:d?`${d.description||""} ${d.expected||""}`.trim():l.expected||""})}}for(const a of t){const c=Ar(a),l=ic(a),d=a.status||a.promptPreview||a.note||"";s.push({kind:"session",key:`session:${a.id}`,target:a.id,address:ac(a.id),color:hr[a.status]||hr.offline,title:c,sub:d,name:c||"",desc:a.status||"",body:`${a.promptPreview||a.note||""} ${l}`.trim()})}return s}function ym(e,t,n){const r=Object.fromEntries(n.map((a,c)=>[a,c])),s=(a,c)=>r[a.kind]-r[c.kind]||a.name.length-c.name.length||a.key.localeCompare(c.key);if(!t.trim())return e.slice().sort(s).slice(0,15);const o={};for(const a of n){const c=e.filter(l=>l.kind===a).sort((l,d)=>l.name.length-d.name.length||l.key.localeCompare(d.key));o[a]=fm(t,c.map(l=>({ref:l,name:l.name,desc:l.desc,body:l.body})),{limit:15}).map(l=>l.ref)}const i=[];for(let a=0;i.length<15;a++){let c=!1;for(const l of n)o[l][a]&&i.length<15&&(i.push(o[l][a]),c=!0);if(!c)break}return i}function xm({specs:e,sessions:t,onPick:n,onClose:r,boost:s=null}){const o=Xe(),i=ca(),[a,c]=b.useState(""),[l,d]=b.useState("");b.useEffect(()=>{if(!a.trim()){d(a);return}const x=setTimeout(()=>d(a),120);return()=>clearTimeout(x)},[a]);const[u,f]=b.useState(0),h=b.useRef(null),p=b.useRef(null),v=b.useMemo(()=>pm(s),[s]),w=b.useMemo(()=>mm(e,t,i),[e,t,i]),m=b.useMemo(()=>ym(w,l,v),[w,l,v]);b.useEffect(()=>{var x;(x=h.current)==null||x.focus()},[]),b.useEffect(()=>{f(0)},[a]),b.useEffect(()=>{var x,N;(N=(x=p.current)==null?void 0:x.querySelector(".search-item.on"))==null||N.scrollIntoView({block:"nearest"})},[u,m]);const E=x=>{x&&(n(x),r())},y=x=>{x.key==="ArrowDown"?(x.preventDefault(),f(N=>Math.min(m.length-1,N+1))):x.key==="ArrowUp"?(x.preventDefault(),f(N=>Math.max(0,N-1))):x.key==="Enter"?(x.preventDefault(),E(m[u])):x.key==="Escape"&&(x.preventDefault(),r())};return g.jsx("div",{className:"search-backdrop","data-focus-overlay":!0,onClick:r,children:g.jsxs("div",{className:"search-panel",role:"dialog","aria-modal":"true","aria-label":o("search.title"),onClick:x=>x.stopPropagation(),children:[g.jsxs("div",{className:"search-bar",children:[g.jsx("span",{className:"search-icon",children:"⌕"}),g.jsx("input",{ref:h,className:"search-input",value:a,placeholder:o("search.placeholder"),onChange:x=>c(x.target.value),onKeyDown:y})]}),g.jsxs("ul",{className:"search-results",ref:p,children:[m.length===0&&g.jsx("li",{className:"search-empty",children:o("search.empty")}),m.map((x,N)=>g.jsxs("li",{className:`search-item${N===u?" on":""}`,onMouseEnter:()=>f(N),onClick:()=>E(x),children:[g.jsx("span",{className:"node-dot",style:{background:x.color}}),g.jsx("span",{className:`search-kind k-${x.kind}`,children:o(`search.kind.${x.kind}`)}),g.jsx("span",{className:"search-title",children:x.title||x.target}),g.jsx(yo,{tags:x.tags}),g.jsx("span",{className:"search-path",children:x.sub})]},x.key))]}),g.jsx("div",{className:"search-foot",children:o("search.hint")})]})})}function ha(e,t,n=1,r=s=>s){if(!e.length)return null;const s=e.findIndex(o=>r(o)===t);return s===-1?n>0?e[0]:e[e.length-1]:e[(s+n+e.length)%e.length]}const wm=["merged","active","drift","pending"],vm=[{state:"pass",always:!0,titleKey:"scorePass"},{state:"fail",always:!0,titleKey:"scoreFail"},{state:"stalePass",always:!1,titleKey:"scoreStalePass"},{state:"staleFail",always:!1,titleKey:"scoreStaleFail"},{state:"empty",always:!1,titleKey:"scoreEmpty"}];function bm(e){const t={merged:[],active:[],drift:[],pending:[]},n=[],r=[],s=new Set,o={pass:0,fail:0,stalePass:0,staleFail:0,empty:0},i={pass:[],fail:[],stalePass:[],staleFail:[],empty:[]};for(const a of e){t[a.status]&&t[a.status].push(a.id),a.drift>0&&n.push(a.id);const c=a.openIssues||[];if(c.length){r.push(a.id);for(const d of c)s.add(d.id)}const l=new Set;for(const d of Ir(a.scenarios,a.evals)){const u=d.state==="missing"?"empty":d.state;o[u]!==void 0&&(o[u]++,l.has(u)||(l.add(u),i[u].push(a.id)))}}return{total:e.length,status:t,driftIds:n,issueIds:r,issueCount:s.size,scoreCount:o,scoreNodes:i}}function hn({count:e,ids:t,focusId:n,onJump:r,title:s,cls:o="",children:i}){const a=t.length>0;return g.jsxs("button",{type:"button",className:`bstat ${o}`.trim(),disabled:!a,"data-tip":s,"aria-label":s,onClick:a?()=>r(ha(t,n)):void 0,children:[i,e]})}function _m({specs:e,focusId:t,onJump:n}){const r=Xe(),s=b.useMemo(()=>bm(e),[e]),o=i=>i&&(n==null?void 0:n(i));return g.jsxs("div",{className:"board-stats",role:"group","aria-label":r("stats.aria"),children:[g.jsx("span",{className:"bstat-total","data-tip":r("stats.totalTitle",{n:s.total}),children:s.total}),wm.map(i=>g.jsx(hn,{count:s.status[i].length,ids:s.status[i],focusId:t,onJump:o,title:r("stats.statusTitle",{n:s.status[i].length,status:r(`status.${i}`)}),children:g.jsx("span",{className:"bstat-dot",style:{background:ot[i].color}})},i)),g.jsx("span",{className:"bstat-sep"}),g.jsx(hn,{count:s.driftIds.length,ids:s.driftIds,focusId:t,onJump:o,cls:"bstat-drift",title:r("stats.driftTitle",{n:s.driftIds.length}),children:"⚠"}),g.jsx(hn,{count:s.issueCount,ids:s.issueIds,focusId:t,onJump:o,cls:"bstat-issue",title:r("stats.issueTitle",{n:s.issueCount}),children:"◆"}),g.jsx("span",{className:"bstat-sep"}),vm.map(({state:i,always:a,titleKey:c})=>{const l=s.scoreCount[i],d=s.scoreNodes[i];return!l&&!a?null:g.jsx(hn,{count:l,ids:d,focusId:t,onJump:o,title:r(`stats.${c}`,{n:l}),children:g.jsx(cc,{state:i})},i)})]})}const Em=["graph","sessions","evals","issues"];function fo({page:e,active:t,onNav:n,label:r}){return g.jsx("button",{type:"button",className:t?"rail-btn on":"rail-btn","data-tip":r,"aria-label":r,"aria-current":t?"page":void 0,onClick:()=>n(e),children:g.jsx(lc,{name:e,size:18})})}function Nm({page:e,onNav:t}){const n=Xe();return g.jsxs("nav",{className:"side-rail","aria-label":n("nav.railLabel"),children:[Em.map(r=>g.jsx(fo,{page:r,active:e===r,onNav:t,label:n(`nav.${r}`)},r)),g.jsx("div",{className:"rail-spacer"}),g.jsx(fo,{page:"settings",active:e==="settings",onNav:t,label:n("nav.settings")})]})}const Sm=400,km=80,ur=7,dr=6;function Mm(){const[e,t]=b.useState(null),n=b.useRef(null),r=b.useRef(0),s=b.useRef(null),o=b.useRef(null),i=b.useRef(!1);return b.useEffect(()=>{const a=()=>{r.current&&(clearTimeout(r.current),r.current=0)},c=()=>{a(),s.current=null,o.current&&(o.current.getAttribute("aria-describedby")==="ui-tip"&&o.current.removeAttribute("aria-describedby"),o.current=null),t(w=>(w&&(i.current=!0,setTimeout(()=>{s.current||(i.current=!1)},300)),null))},l=w=>{const m=w.getAttribute("data-tip");!m||!w.isConnected||(s.current=w,w.getAttribute("aria-describedby")||(w.setAttribute("aria-describedby","ui-tip"),o.current=w),t({text:m,anchor:w}))},d=(w,m)=>{s.current!==w&&(a(),s.current=w,r.current=setTimeout(()=>{r.current=0,l(w)},m))},u=w=>{var E,y;const m=(y=(E=w.target).closest)==null?void 0:y.call(E,"[data-tip]");m&&d(m,i.current?km:Sm)},f=w=>{var E,y;const m=(y=(E=w.target).closest)==null?void 0:y.call(E,"[data-tip]");!m||m!==s.current||m.contains(w.relatedTarget)||c()},h=w=>{var y,x;const m=(x=(y=w.target).closest)==null?void 0:x.call(y,"[data-tip]");if(!m)return;let E=!0;try{E=m.matches(":focus-visible")}catch{}E&&(a(),l(m))},p=w=>{var E,y;const m=(y=(E=w.target).closest)==null?void 0:y.call(E,"[data-tip]");m&&m===s.current&&c()},v=w=>{w.key==="Escape"&&c()};return document.addEventListener("pointerover",u,!0),document.addEventListener("pointerout",f,!0),document.addEventListener("focusin",h,!0),document.addEventListener("focusout",p,!0),document.addEventListener("keydown",v,!0),document.addEventListener("pointerdown",c,!0),window.addEventListener("scroll",c,!0),window.addEventListener("resize",c),()=>{a(),document.removeEventListener("pointerover",u,!0),document.removeEventListener("pointerout",f,!0),document.removeEventListener("focusin",h,!0),document.removeEventListener("focusout",p,!0),document.removeEventListener("keydown",v,!0),document.removeEventListener("pointerdown",c,!0),window.removeEventListener("scroll",c,!0),window.removeEventListener("resize",c)}},[]),b.useEffect(()=>{const a=n.current;if(!e||!a)return;if(!e.anchor.isConnected){t(null);return}const c=e.anchor.getBoundingClientRect(),l=a.getBoundingClientRect(),d=c.top-l.height-ur>=dr?"top":"bottom",u=d==="top"?c.top-l.height-ur:c.bottom+ur,f=Math.min(Math.max(c.left+c.width/2-l.width/2,dr),window.innerWidth-l.width-dr);a.dataset.place=d,a.style.top=`${Math.round(u)}px`,a.style.left=`${Math.round(f)}px`;const h=a.querySelector(".ui-tip-arrow");h&&(h.style.left=`${Math.round(Math.min(Math.max(c.left+c.width/2-f,10),l.width-10))-4}px`);const p=requestAnimationFrame(()=>a.classList.add("show"));return()=>cancelAnimationFrame(p)},[e]),e?Ga.createPortal(g.jsxs("div",{id:"ui-tip",role:"tooltip",ref:n,className:"ui-tip",children:[e.text,g.jsx("span",{className:"ui-tip-arrow","aria-hidden":"true"})]}),document.body):null}function Cm(e,t,{min:n,max:r,dir:s=1}={}){const[o,i]=b.useState(()=>{try{const l=parseInt(localStorage.getItem(e),10);if(Number.isFinite(l))return Math.max(n,Math.min(r,l))}catch{}return t}),a=b.useRef(null),c=b.useCallback(l=>{l.preventDefault(),a.current={x:l.clientX,w:o};const d=f=>{const h=a.current;if(!h)return;const p=Math.max(n,Math.min(r,h.w+(f.clientX-h.x)*s));i(p)},u=()=>{a.current=null,window.removeEventListener("mousemove",d),window.removeEventListener("mouseup",u),document.body.classList.remove("is-resizing"),i(f=>{try{localStorage.setItem(e,String(Math.round(f)))}catch{}return f})};window.addEventListener("mousemove",d),window.addEventListener("mouseup",u),document.body.classList.add("is-resizing")},[e,o,n,r,s]);return[o,c]}function ho(){let e=0,t=null,n=null,r=null;return function(o,i){if(!o)return;const a=r!=null&&Math.abs(o.scrollTop-r)>1;(o!==n||a)&&(n=o,t=null,r=null);const c=o.scrollHeight-o.clientHeight,l=t??o.scrollTop;t=Math.max(0,Math.min(c,l+i)),cancelAnimationFrame(e);const d=()=>{if(r!=null&&Math.abs(o.scrollTop-r)>1){cancelAnimationFrame(e),t=null,r=null;return}const u=t-o.scrollTop;if(Math.abs(u)<.5){o.scrollTop=t,r=o.scrollTop;return}o.scrollTop+=u*.2,r=o.scrollTop,e=requestAnimationFrame(d)};e=requestAnimationFrame(d)}}let Cr=null;const Am=e=>!!(e&&e.closest&&e.closest("[data-focus-overlay]")),go=e=>!!(e&&e.isConnected&&!e.disabled&&e.getClientRects().length);typeof window<"u"&&window.addEventListener("focusin",e=>{const t=e.target;t&&t!==document.body&&!Am(t)&&(Cr=t)},!0);function Im(){requestAnimationFrame(()=>{if(go(Cr)){Cr.focus();return}const e=document.querySelector("[data-focus-sink]");go(e)&&e.focus()})}const $m=b.lazy(()=>An(()=>import("./SessionInterface-YLD6IOmC.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),jm=b.lazy(()=>An(()=>import("./EvalsPage-CDxc1-in.js").then(e=>e.b),__vite__mapDeps([4,1,2,3,5]))),Pm=b.lazy(()=>An(()=>import("./IssuesPage-C2yFXiO-.js"),__vite__mapDeps([7,1,2,3,5]))),Dm=b.lazy(()=>An(()=>import("./Settings-ZnOwskMZ.js"),__vite__mapDeps([8,1,2,3]))),Tm={spec:Hp},Lm=220,Rm=46,po=e=>Math.max(.4,Math.min(1.6,e)),jt={nn:e=>`Create a new spec node under [[${e}]] — choose a kebab-case id, write its spec.md at contract altitude with a code: list, implement it, then propose merge. What it should be: `,dd:e=>`Delete the [[${e}]] spec node — remove its dir, repoint or fold its governed code, fix any [[…]] refs, recover its intent from git history, then propose merge. Why: `},ga=Object.keys(jt),zm=new Set(ga.map(e=>e[0]));function Hm({specs:e,sessions:t,reload:n,project:r,issuesData:s,reloadIssues:o}){const{page:i,param:a}=uc(),[c,l]=b.useState(()=>{var K;let z=null;try{z=sessionStorage.getItem("spex.focus")}catch{}return(z&&e.some(U=>U.id===z)?z:null)||((K=e.find(U=>!U.parent))==null?void 0:K.id)});b.useEffect(()=>{try{c&&sessionStorage.setItem("spex.focus",c)}catch{}},[c]);const[d,u]=b.useState(!1),[f,h]=b.useState("spec"),[p,v]=b.useState(!1),[w,m]=b.useState(null),[E,y]=b.useState("new"),[x,N]=b.useState(null),[k,P]=b.useState(null),[D,L]=b.useState(null),{getViewport:F,setViewport:M}=Bn(),j=Xe(),V=b.useRef(null),_=b.useRef(0),C=b.useRef({buf:"",timer:0}),[S,I]=b.useState(!1),R=b.useRef(!1);R.current=S;const A=b.useRef({x:-1,y:-1}),O=b.useMemo(()=>ho(),[]),B=b.useMemo(()=>ho(),[]),H=b.useMemo(()=>Object.fromEntries(e.map(z=>[z.id,z])),[e]),Y=H[c]||e.find(z=>!z.parent)||e[0],X=b.useMemo(()=>{const z=new Set;for(let K=Y;K;K=K.parent?H[K.parent]:null)z.add(K.id);return z},[Y,H]),ee=b.useMemo(()=>Ua(e,X),[e,X]),J=b.useMemo(()=>e.filter(z=>ee[z.id]).map(z=>({...z,...ee[z.id]})),[e,ee]),Z=b.useMemo(()=>Object.fromEntries(J.map(z=>[z.id,z])),[J]),$=Z[Y.id],W=b.useMemo(()=>{const z={};return e.forEach(K=>{K.parent&&(z[K.parent]=(z[K.parent]||0)+1)}),z},[e]),ne=b.useMemo(()=>e.filter(z=>{var K;return(K=z.overlays)==null?void 0:K.length}),[e]),te=b.useMemo(()=>x?t.find(z=>z.source===x):null,[t,x]),q=b.useMemo(()=>x?e.filter(z=>(z.overlays||[]).some(K=>K.source===x)):[],[e,x]),G=b.useMemo(()=>x?q:ne,[x,q,ne]),re=b.useCallback(z=>z?t.filter(K=>{var U;return(U=K.ops)==null?void 0:U.some(oe=>oe.nodeId===z.id)}):[],[t]),se=b.useCallback(z=>{y(z),Me("sessions",z)},[]),ie=b.useCallback(z=>{y("new"),P(z),Me("sessions","new")},[]),ce=b.useCallback(z=>{dc(z,{onFocusNode:l,onOpenSession:se})},[se]),me=b.useMemo(()=>{var U;if(!D)return[];const z=e.find(oe=>oe.id===D.id);return(U=z==null?void 0:z.overlays)!=null&&U.length?[...new Set(z.overlays.map(oe=>oe.source))].map(oe=>t.find(de=>de.source===oe)).filter(Boolean):[]},[D,e,t]),_e=b.useCallback(z=>{ce(z.address)},[ce]);b.useLayoutEffect(()=>{i==="sessions"&&a&&a!==E&&y(a)},[i,a]),b.useEffect(()=>{i==="sessions"&&Me("sessions",E,{replace:!0})},[i,E]),b.useEffect(()=>{i!=="graph"&&(u(!1),v(!1),m(null),L(null))},[i]);const ye=b.useMemo(()=>J.filter(z=>z.parent===$.id),[J,$]),Ee=$.parent?Z[$.parent]:null,Oe=b.useMemo(()=>ye.length?ye.reduce((z,K)=>Math.abs(K.y-$.y)<Math.abs(z.y-$.y)?K:z):null,[ye,$]),Le=b.useMemo(()=>{if(Oe)return Oe;let z=null,K=1/0;for(const U of J){const oe=U.x-$.x;if(oe<=0)continue;const de=U.y-$.y,T=(oe/Za)**2+(de/Qa)**2;T<K&&(K=T,z=U)}return z},[Oe,J,$]),Ne=b.useCallback(z=>{let K=null;for(const U of J){if(U.id===$.id||U.x!==$.x)continue;const oe=U.y-$.y;(z==="down"?oe<=0:oe>=0)||(!K||Math.abs(oe)<Math.abs(K.y-$.y))&&(K=U)}return K},[J,$]),xe=b.useMemo(()=>Ne("down"),[Ne]),Se=b.useMemo(()=>Ne("up"),[Ne]),Ce=b.useMemo(()=>J.map(z=>{const K=z.id===c||z.id===$.parent||z.parent===c||z.parent===$.parent;let U;x&&q.length?U=(z.overlays||[]).some(he=>he.source===x)?"ov-hot":"ov-dim":U=K?void 0:"is-far";const de=re(z).map(he=>({id:he.id,status:he.status,node:he.node})),T=W[z.id]||0,pe={editors:de,collapsed:T>0&&!X.has(z.id),childCount:T};return{id:z.id,type:"spec",position:{x:z.x,y:z.y},data:{...z,...pe},draggable:!1,selected:z.id===c,className:U}}),[c,$.parent,x,q,J,re,W,X]),Be=b.useMemo(()=>{const z=J.filter(U=>U.parent).map(U=>{const oe=U.id===c||U.parent===c;return{id:`${U.parent}-${U.id}`,source:U.parent,target:U.id,type:"smoothstep",style:{stroke:oe?"var(--blue)":"var(--line)",strokeWidth:oe?2:1},zIndex:oe?1:0}}),K=[];for(const U of J){const oe=(U.overlays||[]).find(T=>T.op==="moved"&&T.toParent&&Z[T.toParent]);if(!oe)continue;const de=fr(oe.seed);K.push({id:`move-${U.id}-${oe.toParent}`,source:U.id,target:oe.toParent,type:"smoothstep",animated:!0,zIndex:2,className:"move-edge",style:{stroke:de,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6},markerEnd:{type:Bt.ArrowClosed,color:de,width:14,height:14}})}return[...z,...K]},[c,J,Z]),Ut=b.useCallback((z,K)=>{const U=F(),oe=performance.now();cancelAnimationFrame(_.current);const de=T=>{const pe=K?Math.min(1,(T-oe)/K):1,he=1-Math.pow(1-pe,3);M({x:U.x+(z.x-U.x)*he,y:U.y+(z.y-U.y)*he,zoom:U.zoom+(z.zoom-U.zoom)*he}),pe<1&&(_.current=requestAnimationFrame(de))};_.current=requestAnimationFrame(de)},[F,M]),ke=b.useCallback((z,K,U=300)=>{const oe=V.current;if(!oe)return;const de=K??F().zoom;Ut({x:oe.clientWidth/2-(z.x+Lm/2)*de,y:oe.clientHeight/2-(z.y+Rm/2)*de,zoom:de},U)},[Ut,F]),Zt=b.useRef(!1);b.useEffect(()=>{if(Zt.current||i!=="graph")return;Zt.current=!0;const z=requestAnimationFrame(()=>ke($,void 0,0));return()=>cancelAnimationFrame(z)},[ke,$,i]);const Qe=b.useRef($);Qe.current=$;const Qt=b.useRef(ke);Qt.current=ke;const Jt=b.useRef(!1),Je=b.useRef(!1),dt=b.useRef(null);b.useEffect(()=>{if(i==="graph"){if(!Jt.current){Jt.current=!0,dt.current=c;return}if(Je.current){Je.current=!1,dt.current=c;return}dt.current!==c&&(dt.current=c,Qt.current(Qe.current))}},[c,i]);const ft=d||p||!!w,en=b.useRef(ft);b.useEffect(()=>{en.current&&!ft&&Im(),en.current=ft},[ft]),b.useEffect(()=>{const z=fc($).map(T=>T.key),K=T=>h(pe=>{const he=z.indexOf(pe);return z[((he<0?0:he)+T+z.length)%z.length]}),U=(T,pe)=>{T&&(pe.preventDefault(),pe.stopPropagation(),I(!0),l(T.id))},oe=T=>O(document.querySelector(".ov-body .pane-doc, .ov-body .pane-hist, .ov-body .pane-issues, .ov-body .pane-eval, .ov-body .pane-edit"),T),de=T=>{var pe,he;if(T.altKey&&!T.metaKey&&!T.ctrlKey){const Ae={Digit1:"graph",Digit2:"sessions",Digit3:"evals",Digit4:"issues",Digit5:"settings"}[T.code];if(Ae){T.preventDefault(),T.stopPropagation(),m(null),Me(Ae);return}if(T.code==="KeyN"){T.preventDefault(),T.stopPropagation(),m(null),y("new"),Me("sessions","new");return}if(T.code==="KeyF"){T.preventDefault(),T.stopPropagation(),m(null),Me("evals");return}}if(w){T.key==="Escape"&&(T.preventDefault(),T.stopPropagation(),m(null));return}if((T.metaKey||T.ctrlKey)&&T.key==="/"){T.preventDefault(),T.stopPropagation(),m("sessions");return}if(!(T.metaKey||T.ctrlKey||T.altKey)&&!((T.key==="Enter"||T.key===" ")&&((he=(pe=T.target)==null?void 0:pe.closest)!=null&&he.call(pe,"button, a[href], input, select, textarea, summary")))&&i!=="sessions"&&!(i==="evals"||i==="issues")){if(i==="settings"){ge("board.settings",T.key)&&(T.preventDefault(),T.stopPropagation(),Me("graph"));return}if(d){if(T.key==="Escape"){T.preventDefault(),u(!1);return}if(T.key==="Tab"){T.preventDefault(),T.stopPropagation(),K(T.shiftKey?-1:1);return}if(T.key==="ArrowLeft"||T.key==="h"){T.preventDefault(),T.stopPropagation(),K(-1);return}if(T.key==="ArrowRight"||T.key==="l"){T.preventDefault(),T.stopPropagation(),K(1);return}if(/^[1-9]$/.test(T.key)&&+T.key<=z.length){T.preventDefault(),T.stopPropagation(),h(z[+T.key-1]);return}if(T.key==="j"||T.key==="k"||T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault(),T.stopPropagation(),oe(T.key==="j"||T.key==="ArrowDown"?120:-120);return}return}if(p){if(T.key==="Escape"||T.key==="?"){T.preventDefault(),v(!1);return}if(T.key==="j"||T.key==="k"||T.key==="ArrowDown"||T.key==="ArrowUp"){T.preventDefault(),T.stopPropagation(),B(document.querySelector(".legend"),T.key==="j"||T.key==="ArrowDown"?120:-120);return}return}if(ge("board.help",T.key)){T.preventDefault(),v(!0);return}if(T.key==="Escape"&&x){T.preventDefault(),T.stopPropagation(),N(null);return}if(ge("board.settings",T.key)){T.preventDefault(),Me("settings");return}if(ge("board.search",T.key)){T.preventDefault(),T.stopPropagation(),m("board");return}if(!T.metaKey&&!T.ctrlKey&&!T.altKey&&/^[a-zA-Z]$/.test(T.key)){const Ve=C.current;if(Ve.buf||zm.has(T.key)){clearTimeout(Ve.timer);const Ae=Ve.buf+T.key;if(jt[Ae]){T.preventDefault(),T.stopPropagation(),C.current={buf:"",timer:0},ie(jt[Ae]($.id));return}if(ga.some(Gn=>Gn.startsWith(Ae))){T.preventDefault(),T.stopPropagation(),C.current={buf:Ae,timer:setTimeout(()=>{C.current={buf:"",timer:0}},700)};return}C.current={buf:"",timer:0}}}if(ge("nav.up",T.key))return U(Se,T);if(ge("nav.down",T.key))return U(xe,T);if(ge("nav.parent",T.key))return U(Ee,T);if(ge("nav.child",T.key))return U(Le,T);if(ge("board.zoomIn",T.key))T.preventDefault(),I(!0),ke($,po(F().zoom*1.2),160);else if(ge("board.zoomOut",T.key))T.preventDefault(),I(!0),ke($,po(F().zoom/1.2),160);else if(ge("board.zoomReset",T.key))T.preventDefault(),I(!0),ke($,.85,200);else if(ge("board.info",T.key))T.preventDefault(),u(!0);else if(ge("board.cycle",T.key)||ge("board.cycleRev",T.key)){if(T.preventDefault(),!G.length)return;I(!0);const Ve=ha(G,$.id,ge("board.cycleRev",T.key)?-1:1,Ae=>Ae.id);Ve&&l(Ve.id)}else ge("board.fresh",T.key)?(T.preventDefault(),ie(`[[${$.id}]] `)):ge("board.evals",T.key)&&(T.preventDefault(),Me("evals"))}};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[d,i,p,w,x,$,G,Se,xe,Le,Ee,ke,F,se,ie,O,B]),b.useEffect(()=>{const z=K=>{const U=A.current,oe=K.clientX!==U.x||K.clientY!==U.y;U.x=K.clientX,U.y=K.clientY,oe&&R.current&&I(!1)};return window.addEventListener("mousemove",z,!0),()=>window.removeEventListener("mousemove",z,!0)},[]);const Wn=b.useCallback((z,K)=>{K.id!==Qe.current.id&&(Je.current=!0),l(K.id)},[]),Yn=b.useCallback((z,K)=>{K.id!==Qe.current.id&&(Je.current=!0),l(K.id),u(!0)},[]),Xn=b.useCallback((z,K)=>{z.preventDefault(),K.id!==Qe.current.id&&(Je.current=!0),l(K.id),L({x:z.clientX,y:z.clientY,id:K.id})},[]),tn=b.useCallback((z,K=!0)=>{const U=K&&x===z.source;if(N(U?null:z.source),U)return;const oe=new Set((z.ops||[]).map(T=>T.nodeId)),de=e.find(T=>oe.has(T.id));de&&l(de.id)},[x,e]),[Kn,qn]=Cm("spex.fpWidth",250,{min:190,max:520,dir:-1});return g.jsxs("div",{className:S?"app kbd-mode":"app",children:[g.jsx(Mm,{}),g.jsx(Nm,{page:i,onNav:Me}),g.jsxs("div",{className:"app-main",children:[g.jsxs("div",{className:"page-graph",style:{"--fp-w":`${Kn}px`,display:i==="graph"?void 0:"none"},children:[g.jsxs("div",{className:"graph",ref:V,children:[g.jsx(lp,{nodes:Ce,edges:Be,nodeTypes:Tm,onNodeClick:Wn,onNodeDoubleClick:Yn,onNodeContextMenu:Xn,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesFocusable:!1,disableKeyboardA11y:!0,defaultViewport:{x:0,y:0,zoom:.85},minZoom:.4,maxZoom:1.6,proOptions:{hideAttribution:!0}}),g.jsxs("div",{className:"hud",children:[g.jsxs("span",{className:"brand",children:["$ ",r||"spec-dashboard"]}),g.jsx("button",{className:"hud-help",onClick:()=>v(z=>!z),"data-tip":j("hud.helpTitle"),children:"?"})]}),g.jsx(hc,{sessions:t,activeId:x,onPick:tn,onOpenSession:se}),g.jsx(_m,{specs:e,focusId:c,onJump:l}),g.jsx(Bp,{menu:D,onClose:()=>L(null),onInfo:()=>u(!0),onFresh:z=>ie(`[[${z}]] `),onNewChild:z=>ie(jt.nn(z)),onDelete:z=>ie(jt.dd(z)),sessions:me,onOpenSession:se}),te&&g.jsxs("div",{className:"lock-hint",style:{"--ov":fr(te.id)},children:[g.jsxs("span",{className:"lock-hint-lead",children:[g.jsx(gc,{})," ",Ar(te)]}),q.length?g.jsxs("span",{className:"lock-hint-body",children:[j("lockHint.cycleBefore"),g.jsx("kbd",{children:"o"}),g.jsx("kbd",{children:"O"}),j("lockHint.cycleAfter",{n:q.length})]}):g.jsx("span",{className:"lock-hint-body",children:j("lockHint.empty")}),g.jsx("button",{className:"lock-hint-release",onClick:()=>N(null),"data-tip":j("lockHint.releaseTitle"),children:j("lockHint.release")})]}),p&&g.jsx(rm,{onClose:()=>v(!1)})]}),g.jsx("div",{className:"pane-resizer",onMouseDown:qn,role:"separator","aria-orientation":"vertical"}),g.jsx(Wp,{node:$,onNavigateAddress:ce})]}),d&&g.jsx(pc,{node:$,pane:f,setPane:h,onClose:()=>u(!1)},$.id),g.jsx(b.Suspense,{fallback:null,children:g.jsx($m,{sessions:t,specs:e,focusNode:$,open:i==="sessions",searchOpen:!!w,sel:E,setSel:y,seed:k,onSeedConsumed:()=>P(null),onClose:()=>Me("graph"),onPickSession:tn,onOpenSession:se,onOpenSearch:()=>m("sessions"),reload:n})}),i==="evals"&&g.jsx("div",{className:"page-pane page-evals",children:g.jsx(b.Suspense,{fallback:g.jsx("div",{className:"loading",children:j("hud.loading")}),children:g.jsx(jm,{specs:e,sessions:t,reloadBoard:n,onOpenSession:se})})}),i==="issues"&&g.jsx("div",{className:"page-pane page-issues",children:g.jsx(b.Suspense,{fallback:g.jsx("div",{className:"loading",children:j("hud.loading")}),children:g.jsx(Pm,{specs:e,sessions:t,issuesData:s,reloadIssues:o,issueId:a,onOpenSession:se,onFocusNode:z=>{l(z),Me("graph")}})})}),i==="settings"&&g.jsx(b.Suspense,{fallback:g.jsx("div",{className:"loading",children:j("hud.loading")}),children:g.jsx(Dm,{})}),w&&g.jsx(xm,{specs:e,sessions:t,onPick:_e,onClose:()=>m(null),boost:w==="sessions"?"session":null})]})]})}function Om(e){return g.jsx(sa,{children:g.jsx(Hm,{...e})})}const Xm=Object.freeze(Object.defineProperty({__proto__:null,default:Om},Symbol.toStringTag,{value:"Module"}));export{la as A,Xm as D,Yp as M,Cm as a,Kp as b,Fm as i,ua as k,Ym as r,Wm as s,Op as u};