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.
- package/README.md +1 -1
- package/package.json +1 -1
- package/spec-cli/bin/spex.mjs +13 -10
- package/spec-cli/hooks/dispatch.sh +28 -40
- package/spec-cli/hooks/harness.sh +43 -7
- package/spec-cli/src/board.ts +2 -1
- package/spec-cli/src/boardCache.ts +27 -1
- package/spec-cli/src/boardStream.ts +5 -4
- package/spec-cli/src/cli.ts +93 -20
- package/spec-cli/src/commit-surgery.ts +81 -0
- package/spec-cli/src/contract-filter.ts +156 -0
- package/spec-cli/src/doctor.ts +11 -5
- package/spec-cli/src/git.ts +18 -4
- package/spec-cli/src/guide.ts +94 -38
- package/spec-cli/src/harness-select.ts +2 -2
- package/spec-cli/src/harness.ts +22 -8
- package/spec-cli/src/help.ts +28 -16
- package/spec-cli/src/index.ts +9 -6
- package/spec-cli/src/init.ts +17 -10
- package/spec-cli/src/issues.ts +7 -5
- package/spec-cli/src/layout.ts +31 -13
- package/spec-cli/src/lint.ts +19 -0
- package/spec-cli/src/localIssues.ts +16 -4
- package/spec-cli/src/materialize.ts +214 -144
- package/spec-cli/src/mentions.ts +5 -3
- package/spec-cli/src/plugin-harness.ts +10 -9
- package/spec-cli/src/ranker.ts +25 -8
- package/spec-cli/src/runtime-guard.ts +44 -0
- package/spec-cli/src/search.bench.mjs +15 -5
- package/spec-cli/src/sessions.ts +96 -22
- package/spec-cli/src/specs.ts +38 -18
- package/spec-cli/src/supervise.ts +2 -2
- package/spec-cli/src/tsx-bin.ts +6 -8
- package/spec-cli/src/uninstall.ts +18 -19
- package/spec-cli/src/worktree-sources.ts +52 -13
- package/spec-cli/templates/hooks/post-checkout +22 -0
- package/spec-cli/templates/hooks/post-merge +15 -9
- package/spec-cli/templates/hooks/pre-commit +10 -0
- package/spec-cli/templates/spec/project/.config/core/stop-gate/spec.md +1 -1
- package/spec-cli/templates/spec/project/.config/core/stop-gate/stop-gate.sh +26 -8
- package/spec-cli/templates/spec/project/.config/distill/digest.mjs +136 -0
- package/spec-cli/templates/spec/project/.config/distill/spec.md +74 -0
- package/spec-dashboard/dist/assets/Dashboard-BlRRsxE7.js +27 -0
- package/spec-dashboard/dist/assets/EvalsPage-BzVE38-Z.js +2 -0
- package/spec-dashboard/dist/assets/{FoldToggle-B5leylLf.js → FoldToggle-DFuLVOeu.js} +1 -1
- package/spec-dashboard/dist/assets/IssuesPage-CzDaazhe.js +1 -0
- package/spec-dashboard/dist/assets/{MobileApp-RHNECU6x.js → MobileApp-CXQrQCNp.js} +1 -1
- package/spec-dashboard/dist/assets/{SessionInterface-YLD6IOmC.js → SessionInterface-D1pUBl6q.js} +8 -8
- package/spec-dashboard/dist/assets/SessionWindow-Y25Bwg1e.js +9 -0
- package/spec-dashboard/dist/assets/{Settings-ZnOwskMZ.js → Settings-R610Vbzd.js} +1 -1
- package/spec-dashboard/dist/assets/{index-BdRQfrkR.js → index-BO0Zuweu.js} +2 -2
- package/spec-dashboard/dist/assets/index-uGs9v_9o.css +1 -0
- package/spec-dashboard/dist/index.html +2 -2
- package/spec-forge/src/cli.ts +2 -2
- package/spec-forge/src/drivers/gitlab.ts +168 -0
- package/spec-forge/src/drivers.ts +80 -2
- package/spec-forge/src/resident.ts +10 -5
- package/spec-yatsu/src/cli.ts +37 -16
- package/spec-yatsu/src/evaltab.ts +6 -3
- package/spec-yatsu/src/filing.ts +13 -8
- package/spec-yatsu/src/freshness.ts +97 -22
- package/spec-yatsu/src/proof.ts +14 -3
- package/spec-yatsu/src/scenariofresh.ts +38 -11
- package/spec-yatsu/src/yatsu.ts +52 -28
- package/spec-dashboard/dist/assets/Dashboard-Dlg78cbC.js +0 -27
- package/spec-dashboard/dist/assets/EvalsPage-CDxc1-in.js +0 -3
- package/spec-dashboard/dist/assets/IssuesPage-C2yFXiO-.js +0 -1
- package/spec-dashboard/dist/assets/SessionWindow-CmKtpNUX.js +0 -9
- package/spec-dashboard/dist/assets/index-DEc5Ru3l.css +0 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/SessionInterface-D1pUBl6q.js","assets/index-BO0Zuweu.js","assets/index-uGs9v_9o.css","assets/SessionWindow-Y25Bwg1e.js","assets/EvalsPage-BzVE38-Z.js","assets/FoldToggle-DFuLVOeu.js","assets/SessionInterface-DYP7pi_n.css","assets/IssuesPage-CzDaazhe.js","assets/Settings-R610Vbzd.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as b,g as Za,R as Qa,j as g,u as Xe,a as Ja,l as ec,_ as An,X as tc,Y as nc}from"./index-BO0Zuweu.js";import{S as ot,G as wo,a as rc,l as hr,A as sc,b as oc,c as gr,s as Ir,d as jr,e as ic,I as is,T as vo,f as bo,g as ac,h as cc,i as lc,j as uc,k as dc,m as fc,n as hc,u as gc,o as ke,p as pc,q as mc,r as yc,L as xc,N as wc}from"./SessionWindow-Y25Bwg1e.js";function he(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=he(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var vc={value:()=>{}};function $n(){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 bc(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=$n.prototype={constructor:gn,on:function(e,t){var n=this._,r=bc(e+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o<i;)if((s=(e=r[o]).type)&&(s=_c(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]=as(n[s],e.name,t);else if(t==null)for(s in n)n[s]=as(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 _c(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function as(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=vc,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var pr="http://www.w3.org/1999/xhtml";const cs={svg:"http://www.w3.org/2000/svg",xhtml:pr,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function In(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),cs.hasOwnProperty(t)?{space:cs[t],local:e}:e}function Ec(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===pr&&t.documentElement.namespaceURI===pr?t.createElement(e):t.createElementNS(n,e)}}function Nc(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function _o(e){var t=In(e);return(t.local?Nc:Ec)(t)}function Sc(){}function Pr(e){return e==null?Sc:function(){return this.querySelector(e)}}function kc(e){typeof e!="function"&&(e=Pr(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 Ee(r,this._parents)}function Mc(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Cc(){return[]}function Eo(e){return e==null?Cc:function(){return this.querySelectorAll(e)}}function Ac(e){return function(){return Mc(e.apply(this,arguments))}}function $c(e){typeof e=="function"?e=Ac(e):e=Eo(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 Ee(r,s)}function No(e){return function(){return this.matches(e)}}function So(e){return function(t){return t.matches(e)}}var Ic=Array.prototype.find;function jc(e){return function(){return Ic.call(this.children,e)}}function Pc(){return this.firstElementChild}function Dc(e){return this.select(e==null?Pc:jc(typeof e=="function"?e:So(e)))}var Tc=Array.prototype.filter;function Rc(){return Array.from(this.children)}function Lc(e){return function(){return Tc.call(this.children,e)}}function zc(e){return this.selectAll(e==null?Rc:Lc(typeof e=="function"?e:So(e)))}function Hc(e){typeof e!="function"&&(e=No(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 Ee(r,this._parents)}function ko(e){return new Array(e.length)}function Oc(){return new Ee(this._enter||this._groups.map(ko),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 Bc(e){return function(){return e}}function Vc(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 Fc(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 Wc(e){return e.__data__}function Yc(e,t){if(!arguments.length)return Array.from(this,Wc);var n=t?Fc:Vc,r=this._parents,s=this._groups;typeof e!="function"&&(e=Bc(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=Xc(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 Ee(i,r),i._enter=a,i._exit=c,i}function Xc(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Kc(){return new Ee(this._exit||this._groups.map(ko),this._parents)}function qc(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 Gc(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 Ee(a,this._parents)}function Uc(){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 Zc(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 Ee(s,this._parents).order()}function Qc(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Jc(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function el(){return Array.from(this)}function tl(){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 nl(){let e=0;for(const t of this)++e;return e}function rl(){return!this.node()}function sl(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 ol(e){return function(){this.removeAttribute(e)}}function il(e){return function(){this.removeAttributeNS(e.space,e.local)}}function al(e,t){return function(){this.setAttribute(e,t)}}function cl(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ll(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function ul(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 dl(e,t){var n=In(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?il:ol:typeof t=="function"?n.local?ul:ll:n.local?cl:al)(n,t))}function Mo(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function fl(e){return function(){this.style.removeProperty(e)}}function hl(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gl(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function pl(e,t,n){return arguments.length>1?this.each((t==null?fl:typeof t=="function"?gl:hl)(e,t,n??"")):wt(this.node(),e)}function wt(e,t){return e.style.getPropertyValue(t)||Mo(e).getComputedStyle(e,null).getPropertyValue(t)}function ml(e){return function(){delete this[e]}}function yl(e,t){return function(){this[e]=t}}function xl(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function wl(e,t){return arguments.length>1?this.each((t==null?ml:typeof t=="function"?xl:yl)(e,t)):this.node()[e]}function Co(e){return e.trim().split(/^|\s+/)}function Dr(e){return e.classList||new Ao(e)}function Ao(e){this._node=e,this._names=Co(e.getAttribute("class")||"")}Ao.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 $o(e,t){for(var n=Dr(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function Io(e,t){for(var n=Dr(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function vl(e){return function(){$o(this,e)}}function bl(e){return function(){Io(this,e)}}function _l(e,t){return function(){(t.apply(this,arguments)?$o:Io)(this,e)}}function El(e,t){var n=Co(e+"");if(arguments.length<2){for(var r=Dr(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?_l:t?vl:bl)(n,t))}function Nl(){this.textContent=""}function Sl(e){return function(){this.textContent=e}}function kl(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Ml(e){return arguments.length?this.each(e==null?Nl:(typeof e=="function"?kl:Sl)(e)):this.node().textContent}function Cl(){this.innerHTML=""}function Al(e){return function(){this.innerHTML=e}}function $l(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Il(e){return arguments.length?this.each(e==null?Cl:(typeof e=="function"?$l:Al)(e)):this.node().innerHTML}function jl(){this.nextSibling&&this.parentNode.appendChild(this)}function Pl(){return this.each(jl)}function Dl(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function Tl(){return this.each(Dl)}function Rl(e){var t=typeof e=="function"?e:_o(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function Ll(){return null}function zl(e,t){var n=typeof e=="function"?e:_o(e),r=t==null?Ll:typeof t=="function"?t:Pr(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function Hl(){var e=this.parentNode;e&&e.removeChild(this)}function Ol(){return this.each(Hl)}function Bl(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Vl(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function Fl(e){return this.select(e?Vl:Bl)}function Wl(e){return arguments.length?this.property("__data__",e):this.node().__data__}function Yl(e){return function(t){e.call(this,t,this.__data__)}}function Xl(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 Kl(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 ql(e,t,n){return function(){var r=this.__on,s,o=Yl(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 Gl(e,t,n){var r=Xl(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?ql:Kl,s=0;s<o;++s)this.each(a(r[s],t,n));return this}function jo(e,t,n){var r=Mo(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 Ul(e,t){return function(){return jo(this,e,t)}}function Zl(e,t){return function(){return jo(this,e,t.apply(this,arguments))}}function Ql(e,t){return this.each((typeof t=="function"?Zl:Ul)(e,t))}function*Jl(){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 Po=[null];function Ee(e,t){this._groups=e,this._parents=t}function Xt(){return new Ee([[document.documentElement]],Po)}function eu(){return this}Ee.prototype=Xt.prototype={constructor:Ee,select:kc,selectAll:$c,selectChild:Dc,selectChildren:zc,filter:Hc,data:Yc,enter:Oc,exit:Kc,join:qc,merge:Gc,selection:eu,order:Uc,sort:Zc,call:Jc,nodes:el,node:tl,size:nl,empty:rl,each:sl,attr:dl,style:pl,property:wl,classed:El,text:Ml,html:Il,raise:Pl,lower:Tl,append:Rl,insert:zl,remove:Ol,clone:Fl,datum:Wl,on:Gl,dispatch:Ql,[Symbol.iterator]:Jl};function _e(e){return typeof e=="string"?new Ee([[document.querySelector(e)]],[document.documentElement]):new Ee([[e]],Po)}function tu(e){let t;for(;t=e.sourceEvent;)e=t;return e}function $e(e,t){if(e=tu(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 nu={passive:!1},Rt={capture:!0,passive:!1};function Qn(e){e.stopImmediatePropagation()}function yt(e){e.preventDefault(),e.stopImmediatePropagation()}function Do(e){var t=e.document.documentElement,n=_e(e).on("dragstart.drag",yt,Rt);"onselectstart"in t?n.on("selectstart.drag",yt,Rt):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function To(e,t){var n=e.document.documentElement,r=_e(e).on("dragstart.drag",null);t&&(r.on("click.drag",yt,Rt),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 mr(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}})}mr.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ru(e){return!e.ctrlKey&&!e.button}function su(){return this.parentNode}function ou(e,t){return t??{x:e.x,y:e.y}}function iu(){return navigator.maxTouchPoints||"ontouchstart"in this}function Ro(){var e=ru,t=su,n=ou,r=iu,s={},o=$n("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,nu).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&&(_e(x.view).on("mousemove.drag",p,Rt).on("mouseup.drag",v,Rt),Do(x.view),Qn(x),l=!1,a=x.clientX,c=x.clientY,k("start",x))}}function p(x){if(yt(x),!l){var N=x.clientX-a,k=x.clientY-c;l=N*N+k*k>u}s.mouse("drag",x)}function v(x){_e(x.view).on("mousemove.drag mouseup.drag",null),To(x.view,l),yt(x),s.mouse("end",x)}function w(x,N){if(e.call(this,x,N)){var k=x.changedTouches,D=t.call(this,x,N),T=k.length,R,F;for(R=0;R<T;++R)(F=y(this,D,x,N,k[R].identifier,k[R]))&&(Qn(x),F("start",x,k[R]))}}function m(x){var N=x.changedTouches,k=N.length,D,T;for(D=0;D<k;++D)(T=s[N[D].identifier])&&(yt(x),T("drag",x,N[D]))}function E(x){var N=x.changedTouches,k=N.length,D,T;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),D=0;D<k;++D)(T=s[N[D].identifier])&&(Qn(x),T("end",x,N[D]))}function y(x,N,k,D,T,R){var F=o.copy(),M=$e(R||k,N),I,V,_;if((_=n.call(x,new mr("beforestart",{sourceEvent:k,target:f,identifier:T,active:i,x:M[0],y:M[1],dx:0,dy:0,dispatch:F}),D))!=null)return I=_.x-M[0]||0,V=_.y-M[1]||0,function C(S,$,L){var A=M,O;switch(S){case"start":s[T]=C,O=i++;break;case"end":delete s[T],--i;case"drag":M=$e(L||$,N),O=i;break}F.call(S,x,new mr(S,{sourceEvent:$,subject:_,target:f,identifier:T,active:O,x:M[0]+I,y:M[1]+V,dx:M[0]-A[0],dy:M[1]-A[1],dispatch:F}),D)}}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 Tr(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function Lo(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Kt(){}var Lt=.7,vn=1/Lt,xt="\\s*([+-]?\\d+)\\s*",zt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ze="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",au=/^#([0-9a-f]{3,8})$/,cu=new RegExp(`^rgb\\(${xt},${xt},${xt}\\)$`),lu=new RegExp(`^rgb\\(${ze},${ze},${ze}\\)$`),uu=new RegExp(`^rgba\\(${xt},${xt},${xt},${zt}\\)$`),du=new RegExp(`^rgba\\(${ze},${ze},${ze},${zt}\\)$`),fu=new RegExp(`^hsl\\(${zt},${ze},${ze}\\)$`),hu=new RegExp(`^hsla\\(${zt},${ze},${ze},${zt}\\)$`),ls={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};Tr(Kt,it,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:us,formatHex:us,formatHex8:gu,formatHsl:pu,formatRgb:ds,toString:ds});function us(){return this.rgb().formatHex()}function gu(){return this.rgb().formatHex8()}function pu(){return zo(this).formatHsl()}function ds(){return this.rgb().formatRgb()}function it(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=au.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?fs(t):n===3?new xe(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=cu.exec(e))?new xe(t[1],t[2],t[3],1):(t=lu.exec(e))?new xe(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=uu.exec(e))?sn(t[1],t[2],t[3],t[4]):(t=du.exec(e))?sn(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=fu.exec(e))?ps(t[1],t[2]/100,t[3]/100,1):(t=hu.exec(e))?ps(t[1],t[2]/100,t[3]/100,t[4]):ls.hasOwnProperty(e)?fs(ls[e]):e==="transparent"?new xe(NaN,NaN,NaN,0):null}function fs(e){return new xe(e>>16&255,e>>8&255,e&255,1)}function sn(e,t,n,r){return r<=0&&(e=t=n=NaN),new xe(e,t,n,r)}function mu(e){return e instanceof Kt||(e=it(e)),e?(e=e.rgb(),new xe(e.r,e.g,e.b,e.opacity)):new xe}function yr(e,t,n,r){return arguments.length===1?mu(e):new xe(e,t,n,r??1)}function xe(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Tr(xe,yr,Lo(Kt,{brighter(e){return e=e==null?vn:Math.pow(vn,e),new xe(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Lt:Math.pow(Lt,e),new xe(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new xe(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:hs,formatHex:hs,formatHex8:yu,formatRgb:gs,toString:gs}));function hs(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}`}function yu(){return`#${tt(this.r)}${tt(this.g)}${tt(this.b)}${tt((isNaN(this.opacity)?1:this.opacity)*255)}`}function gs(){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 ps(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ie(e,t,n,r)}function zo(e){if(e instanceof Ie)return new Ie(e.h,e.s,e.l,e.opacity);if(e instanceof Kt||(e=it(e)),!e)return new Ie;if(e instanceof Ie)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 Ie(i,a,c,e.opacity)}function xu(e,t,n,r){return arguments.length===1?zo(e):new Ie(e,t,n,r??1)}function Ie(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Tr(Ie,xu,Lo(Kt,{brighter(e){return e=e==null?vn:Math.pow(vn,e),new Ie(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Lt:Math.pow(Lt,e),new Ie(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 xe(Jn(e>=240?e-240:e+120,s,r),Jn(e,s,r),Jn(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ie(ms(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("}${ms(this.h)}, ${on(this.s)*100}%, ${on(this.l)*100}%${e===1?")":`, ${e})`}`}}));function ms(e){return e=(e||0)%360,e<0?e+360:e}function on(e){return Math.max(0,Math.min(1,e||0))}function Jn(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 Rr=e=>()=>e;function wu(e,t){return function(n){return e+n*t}}function vu(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 bu(e){return(e=+e)==1?Ho:function(t,n){return n-t?vu(t,n,e):Rr(isNaN(t)?n:t)}}function Ho(e,t){var n=t-e;return n?wu(e,n):Rr(isNaN(e)?t:e)}const _n=function e(t){var n=bu(t);function r(s,o){var i=n((s=yr(s)).r,(o=yr(o)).r),a=n(s.g,o.g),c=n(s.b,o.b),l=Ho(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 _u(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 Eu(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Nu(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]=Dt(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 Su(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function Le(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function ku(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]=Dt(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var xr=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,er=new RegExp(xr.source,"g");function Mu(e){return function(){return e}}function Cu(e){return function(t){return e(t)+""}}function Oo(e,t){var n=xr.lastIndex=er.lastIndex=0,r,s,o,i=-1,a=[],c=[];for(e=e+"",t=t+"";(r=xr.exec(e))&&(s=er.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:Le(r,s)})),n=er.lastIndex;return n<t.length&&(o=t.slice(n),a[i]?a[i]+=o:a[++i]=o),a.length<2?c[0]?Cu(c[0].x):Mu(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 Dt(e,t){var n=typeof t,r;return t==null||n==="boolean"?Rr(t):(n==="number"?Le:n==="string"?(r=it(t))?(t=r,_n):Oo:t instanceof it?_n:t instanceof Date?Su:Eu(t)?_u:Array.isArray(t)?Nu:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?ku:Le)(e,t)}var ys=180/Math.PI,wr={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function Bo(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)*ys,skewX:Math.atan(c)*ys,scaleX:i,scaleY:a}}var an;function Au(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?wr:Bo(t.a,t.b,t.c,t.d,t.e,t.f)}function $u(e){return e==null||(an||(an=document.createElementNS("http://www.w3.org/2000/svg","g")),an.setAttribute("transform",e),!(e=an.transform.baseVal.consolidate()))?wr:(e=e.matrix,Bo(e.a,e.b,e.c,e.d,e.e,e.f))}function Vo(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:Le(l,u)},{i:v-2,x:Le(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:Le(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:Le(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:Le(l,u)},{i:v-2,x:Le(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 Iu=Vo(Au,"px, ","px)","deg)"),ju=Vo($u,", ",")",")"),Pu=1e-12;function xs(e){return((e=Math.exp(e))+1/e)/2}function Du(e){return((e=Math.exp(e))-1/e)/2}function Tu(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<Pu)m=Math.log(f/l)/t,w=function(D){return[a+D*h,c+D*p,l*Math.exp(t*D*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(D){var T=D*m,R=xs(N),F=l/(n*E)*(R*Tu(t*T+N)-Du(N));return[a+F*h,c+F*p,l*R/xs(t*T+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 vt=0,It=0,At=0,Fo=1e3,En,jt,Nn=0,at=0,jn=0,Ht=typeof performance=="object"&&performance.now?performance:Date,Wo=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Lr(){return at||(Wo(Ru),at=Ht.now()+jn)}function Ru(){at=0}function Sn(){this._call=this._time=this._next=null}Sn.prototype=Yo.prototype={constructor:Sn,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Lr():+n)+(t==null?0:+t),!this._next&&jt!==this&&(jt?jt._next=this:En=this,jt=this),this._call=e,this._time=n,vr()},stop:function(){this._call&&(this._call=null,this._time=1/0,vr())}};function Yo(e,t,n){var r=new Sn;return r.restart(e,t,n),r}function Lu(){Lr(),++vt;for(var e=En,t;e;)(t=at-e._time)>=0&&e._call.call(void 0,t),e=e._next;--vt}function ws(){at=(Nn=Ht.now())+jn,vt=It=0;try{Lu()}finally{vt=0,Hu(),at=0}}function zu(){var e=Ht.now(),t=e-Nn;t>Fo&&(jn-=t,Nn=e)}function Hu(){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);jt=e,vr(r)}function vr(e){if(!vt){It&&(It=clearTimeout(It));var t=e-at;t>24?(e<1/0&&(It=setTimeout(ws,e-Ht.now()-jn)),At&&(At=clearInterval(At))):(At||(Nn=Ht.now(),At=setInterval(zu,Fo)),vt=1,Wo(ws))}}function vs(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 Ou=$n("start","end","cancel","interrupt"),Bu=[],Xo=0,bs=1,br=2,mn=3,_s=4,_r=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;Vu(e,n,{name:t,index:r,group:s,on:Ou,tween:Bu,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:Xo})}function zr(e,t){var n=Te(e,t);if(n.state>Xo)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 Vu(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=Yo(o,0,n.time);function o(l){n.state=bs,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!==bs)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===mn)return vs(i);h.state===_s?(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(vs(function(){n.state===mn&&(n.state=_s,n.timer.restart(a,n.delay,n.time),a(l))}),n.state=br,n.on.call("start",e,e.__data__,n.index,n.group),n.state===br){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=_r,1),u=-1,f=s.length;++u<f;)s[u].call(e,d);n.state===_r&&(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>br&&r.state<_r,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 Fu(e){return this.each(function(){xn(this,e)})}function Wu(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 Yu(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 Xu(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?Wu:Yu)(n,e,t))}function Hr(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 Ko(e,t){var n;return(typeof t=="number"?Le:t instanceof it?_n:(n=it(t))?(t=n,_n):Oo)(e,t)}function Ku(e){return function(){this.removeAttribute(e)}}function qu(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Gu(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 Uu(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 Zu(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 Ju(e,t){var n=In(e),r=n==="transform"?ju:Ko;return this.attrTween(e,typeof t=="function"?(n.local?Qu:Zu)(n,r,Hr(this,"attr."+e,t)):t==null?(n.local?qu:Ku)(n):(n.local?Uu:Gu)(n,r,t))}function ed(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function td(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function nd(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&td(e,o)),n}return s._value=t,s}function rd(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&ed(e,o)),n}return s._value=t,s}function sd(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=In(e);return this.tween(n,(r.local?nd:rd)(r,t))}function od(e,t){return function(){zr(this,e).delay=+t.apply(this,arguments)}}function id(e,t){return t=+t,function(){zr(this,e).delay=t}}function ad(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?od:id)(t,e)):Te(this.node(),t).delay}function cd(e,t){return function(){He(this,e).duration=+t.apply(this,arguments)}}function ld(e,t){return t=+t,function(){He(this,e).duration=t}}function ud(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?cd:ld)(t,e)):Te(this.node(),t).duration}function dd(e,t){if(typeof t!="function")throw new Error;return function(){He(this,e).ease=t}}function fd(e){var t=this._id;return arguments.length?this.each(dd(t,e)):Te(this.node(),t).ease}function hd(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;He(this,e).ease=n}}function gd(e){if(typeof e!="function")throw new Error;return this.each(hd(this._id,e))}function pd(e){typeof e!="function"&&(e=No(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 md(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 yd(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 xd(e,t,n){var r,s,o=yd(t)?zr:He;return function(){var i=o(this,e),a=i.on;a!==r&&(s=(r=a).copy()).on(t,n),i.on=s}}function wd(e,t){var n=this._id;return arguments.length<2?Te(this.node(),n).on.on(e):this.each(xd(n,e,t))}function vd(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function bd(){return this.on("end.remove",vd(this._id))}function _d(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Pr(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 Ed(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Eo(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 Nd=Xt.prototype.constructor;function Sd(){return new Nd(this._groups,this._parents)}function kd(e,t){var n,r,s;return function(){var o=wt(this,e),i=(this.style.removeProperty(e),wt(this,e));return o===i?null:o===n&&i===r?s:s=t(n=o,r=i)}}function qo(e){return function(){this.style.removeProperty(e)}}function Md(e,t,n){var r,s=n+"",o;return function(){var i=wt(this,e);return i===s?null:i===r?o:o=t(r=i,n)}}function Cd(e,t,n){var r,s,o;return function(){var i=wt(this,e),a=n(this),c=a+"";return a==null&&(c=a=(this.style.removeProperty(e),wt(this,e))),i===c?null:i===r&&c===s?o:(s=c,o=t(r=i,a))}}function Ad(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=qo(t)):void 0;(l!==n||s!==d)&&(r=(n=l).copy()).on(i,s=d),c.on=r}}function $d(e,t,n){var r=(e+="")=="transform"?Iu:Ko;return t==null?this.styleTween(e,kd(e,r)).on("end.style."+e,qo(e)):typeof t=="function"?this.styleTween(e,Cd(e,r,Hr(this,"style."+e,t))).each(Ad(this._id,e)):this.styleTween(e,Md(e,r,t),n).on("end.style."+e,null)}function Id(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function jd(e,t,n){var r,s;function o(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&Id(e,i,n)),r}return o._value=t,o}function Pd(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,jd(e,t,n??""))}function Dd(e){return function(){this.textContent=e}}function Td(e){return function(){var t=e(this);this.textContent=t??""}}function Rd(e){return this.tween("text",typeof e=="function"?Td(Hr(this,"text",e)):Dd(e==null?"":e+""))}function Ld(e){return function(t){this.textContent=e.call(this,t)}}function zd(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Ld(s)),t}return r._value=e,r}function Hd(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,zd(e))}function Od(){for(var e=this._name,t=this._id,n=Go(),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 Bd(){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 Vd=0;function Ye(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function Go(){return++Vd}var Fe=Xt.prototype;Ye.prototype={constructor:Ye,select:_d,selectAll:Ed,selectChild:Fe.selectChild,selectChildren:Fe.selectChildren,filter:pd,merge:md,selection:Sd,transition:Od,call:Fe.call,nodes:Fe.nodes,node:Fe.node,size:Fe.size,empty:Fe.empty,each:Fe.each,on:wd,attr:Ju,attrTween:sd,style:$d,styleTween:Pd,text:Rd,textTween:Hd,remove:bd,tween:Xu,delay:ad,duration:ud,ease:fd,easeVarying:gd,end:Bd,[Symbol.iterator]:Fe[Symbol.iterator]};function Fd(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Wd={time:null,delay:0,duration:250,ease:Fd};function Yd(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 Xd(e){var t,n;e instanceof Ye?(t=e._id,e=e._name):(t=Go(),(n=Wd).time=Lr(),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||Yd(c,t));return new Ye(r,this._parents,e,t)}Xt.prototype.interrupt=Fu;Xt.prototype.transition=Xd;const cn=e=>()=>e;function Kd(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);Uo.prototype=We.prototype;function Uo(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Dn;return e.__zoom}function tr(e){e.stopImmediatePropagation()}function $t(e){e.preventDefault(),e.stopImmediatePropagation()}function qd(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Gd(){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 Es(){return this.__zoom||Dn}function Ud(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Zd(){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 Zo(){var e=qd,t=Gd,n=Qd,r=Ud,s=Zd,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],a=250,c=pn,l=$n("start","zoom","end"),d,u,f,h=500,p=150,v=0,w=10;function m(_){_.property("__zoom",Es).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",R).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",M).on("touchmove.zoom",I).on("touchend.zoom touchcancel.zoom",V).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}m.transform=function(_,C,S,$){var L=_.selection?_.selection():_;L.property("__zoom",Es),_!==L?N(_,C,S,$):L.interrupt().each(function(){k(this,arguments).event($).start().zoom(null,typeof C=="function"?C.apply(this,arguments):C).end()})},m.scaleBy=function(_,C,S,$){m.scaleTo(_,function(){var L=this.__zoom.k,A=typeof C=="function"?C.apply(this,arguments):C;return L*A},S,$)},m.scaleTo=function(_,C,S,$){m.transform(_,function(){var L=t.apply(this,arguments),A=this.__zoom,O=S==null?x(L):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),L,i)},S,$)},m.translateBy=function(_,C,S,$){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,$)},m.translateTo=function(_,C,S,$,L){m.transform(_,function(){var A=t.apply(this,arguments),O=this.__zoom,B=$==null?x(A):typeof $=="function"?$.apply(this,arguments):$;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)},$,L)};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 $=C[0]-S[0]*_.k,L=C[1]-S[1]*_.k;return $===_.x&&L===_.y?_:new We(_.k,$,L)}function x(_){return[(+_[0][0]+ +_[1][0])/2,(+_[0][1]+ +_[1][1])/2]}function N(_,C,S,$){_.on("start.zoom",function(){k(this,arguments).event($).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event($).end()}).tween("zoom",function(){var L=this,A=arguments,O=k(L,A).event($),B=t.apply(L,A),H=S==null?x(B):typeof S=="function"?S.apply(L,A):S,Y=Math.max(B[1][0]-B[0][0],B[1][1]-B[0][1]),X=L.__zoom,ee=typeof C=="function"?C.apply(L,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=J(Z),W=Y/j[2];Z=new We(W,H[0]-j[0]*W,H[1]-j[1]*W)}O.zoom(null,Z)}})}function k(_,C,S){return!S&&_.__zooming||new D(_,C)}function D(_,C){this.that=_,this.args=C,this.active=0,this.sourceEvent=null,this.extent=t.apply(_,C),this.taps=0}D.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=_e(this.that).datum();l.call(_,this.that,new Kd(_,{sourceEvent:this.sourceEvent,target:m,transform:this.that.__zoom,dispatch:l}),C)}};function T(_,...C){if(!e.apply(this,arguments))return;var S=k(this,C).event(_),$=this.__zoom,L=Math.max(o[0],Math.min(o[1],$.k*Math.pow(2,r.apply(this,arguments)))),A=$e(_);if(S.wheel)(S.mouse[0][0]!==A[0]||S.mouse[0][1]!==A[1])&&(S.mouse[1]=$.invert(S.mouse[0]=A)),clearTimeout(S.wheel);else{if($.k===L)return;S.mouse=[A,$.invert(A)],xn(this),S.start()}$t(_),S.wheel=setTimeout(O,p),S.zoom("mouse",n(y(E($,L),S.mouse[0],S.mouse[1]),S.extent,i));function O(){S.wheel=null,S.end()}}function R(_,...C){if(f||!e.apply(this,arguments))return;var S=_.currentTarget,$=k(this,C,!0).event(_),L=_e(_.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",Y,!0),A=$e(_,S),O=_.clientX,B=_.clientY;Do(_.view),tr(_),$.mouse=[A,this.__zoom.invert(A)],xn(this),$.start();function H(X){if($t(X),!$.moved){var ee=X.clientX-O,J=X.clientY-B;$.moved=ee*ee+J*J>v}$.event(X).zoom("mouse",n(y($.that.__zoom,$.mouse[0]=$e(X,S),$.mouse[1]),$.extent,i))}function Y(X){L.on("mousemove.zoom mouseup.zoom",null),To(X.view,$.moved),$t(X),$.event(X).end()}}function F(_,...C){if(e.apply(this,arguments)){var S=this.__zoom,$=$e(_.changedTouches?_.changedTouches[0]:_,this),L=S.invert($),A=S.k*(_.shiftKey?.5:2),O=n(y(E(S,A),$,L),t.apply(this,C),i);$t(_),a>0?_e(this).transition().duration(a).call(N,O,$,_):_e(this).call(m.transform,O,$,_)}}function M(_,...C){if(e.apply(this,arguments)){var S=_.touches,$=S.length,L=k(this,C,_.changedTouches.length===$).event(_),A,O,B,H;for(tr(_),O=0;O<$;++O)B=S[O],H=$e(B,this),H=[H,this.__zoom.invert(H),B.identifier],L.touch0?!L.touch1&&L.touch0[2]!==H[2]&&(L.touch1=H,L.taps=0):(L.touch0=H,A=!0,L.taps=1+!!d);d&&(d=clearTimeout(d)),A&&(L.taps<2&&(u=H[0],d=setTimeout(function(){d=null},h)),xn(this),L.start())}}function I(_,...C){if(this.__zooming){var S=k(this,C).event(_),$=_.changedTouches,L=$.length,A,O,B,H;for($t(_),A=0;A<L;++A)O=$[A],B=$e(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=(j=J[0]-X[0])*j+(j=J[1]-X[1])*j;O=E(O,Math.sqrt(Z/j)),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(_),$=_.changedTouches,L=$.length,A,O;for(tr(_),f&&clearTimeout(f),f=setTimeout(function(){f=null},h),A=0;A<L;++A)O=$[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=$e(O,this),Math.hypot(u[0]-O[0],u[1]-O[1])<w)){var B=_e(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.`},Ot=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Qo=["Enter"," ","Escape"],Jo={"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 bt;(function(e){e.Strict="strict",e.Loose="loose"})(bt||(bt={}));var st;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(st||(st={}));var Bt;(function(e){e.Partial="partial",e.Full="full"})(Bt||(Bt={}));const ei={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 Vt;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Vt||(Vt={}));var Q;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Q||(Q={}));const Ns={[Q.Left]:Q.Right,[Q.Right]:Q.Left,[Q.Top]:Q.Bottom,[Q.Bottom]:Q.Top};function ti(e){return e===null?null:e?"valid":"invalid"}const ni=e=>"id"in e&&"source"in e&&"target"in e,Jd=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Or=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),qt=(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}},ef=(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):Or(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 Rn(n)},Gt=(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?Rn(n):{x:0,y:0,width:0,height:0}},Br=(e,t,[n,r,s]=[0,0,1],o=!1,i=!1)=>{const a={...Ct(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=Ft(a,Et(l)),w=(h??0)*(p??0),m=o&&v>0;(!l.internals.handleBounds||m||v>=w||l.dragging)&&c.push(l)}return c},tf=(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 nf(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 rf({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:o},i){if(e.size===0)return!0;const a=nf(e,i),c=Gt(a),l=Fr(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 ri({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&<(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 sf({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=tf(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 _t=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),ct=(e={x:0,y:0},t,n)=>({x:_t(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:_t(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function si(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 Ss=(e,t,n)=>e<t?_t(Math.abs(e-t),1,t)/t:e>n?-_t(Math.abs(e-n),1,t)/t:0,Vr=(e,t,n=15,r=40)=>{const s=Ss(e.x,r,t.width-r)*n,o=Ss(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)}),Er=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Rn=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Et=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Or(e)?e.internals.positionAbsolute:qt(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}=Or(e)?e.internals.positionAbsolute:qt(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)}},oi=(e,t)=>Rn(Tn(Er(e),Er(t))),Ft=(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)},ks=e=>je(e.width)&&je(e.height)&&je(e.x)&&je(e.y),je=e=>!isNaN(e)&&isFinite(e),ii=(e,t)=>(n,r)=>{},Ut=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ct=({x:e,y:t},[n,r,s],o=!1,i=[1,1])=>{const a={x:(e-n)/s,y:(t-r)/s};return o?Ut(a,i):a},Nt=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function gt(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 of(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=gt(e,n),s=gt(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=gt(e.top??e.y??0,n),s=gt(e.bottom??e.y??0,n),o=gt(e.left??e.x??0,t),i=gt(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 af(e,t,n,r,s,o){const{x:i,y:a}=Nt(e,[t,n,r]),{x:c,y:l}=Nt({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 Fr=(e,t,n,r,s,o)=>{const i=of(o,t,n),a=(t-i.x)/e.width,c=(n-i.y)/e.height,l=Math.min(a,c),d=_t(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=af(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}},Wt=()=>{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 ai(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 ci(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 Ms(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function cf(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function lf(e){return{...Jo,...e||{}}}function Tt(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:i}=Pe(e),a=Ct({x:o-((s==null?void 0:s.left)??0),y:i-((s==null?void 0:s.top)??0)},r),{x:c,y:l}=n?Ut(a,t):a;return{xSnapped:c,ySnapped:l,...a}}const Wr=e=>({width:e.offsetWidth,height:e.offsetHeight}),li=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},uf=["INPUT","SELECT","TEXTAREA"];function ui(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:uf.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const di=e=>"clientX"in e,Pe=(e,t)=>{var o,i;const n=di(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)}},Cs=(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,...Wr(i)}})};function fi({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 As({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 hi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:s,targetPosition:o=Q.Top,curvature:i=.25}){const[a,c]=As({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[l,d]=As({pos:o,x1:r,y1:s,x2:e,y2:t,c:i}),[u,f,h,p]=fi({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 gi({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 df({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 ff({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 Ft(i,Rn(o))>0}const hf=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,gf=(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)),pf=(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||hf;let s;return ni(e)?s={...e}:s={...e,id:r(e)},gf(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function pi({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,i,a]=gi({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,i,a]}const $s={[Q.Left]:{x:-1,y:0},[Q.Right]:{x:1,y:0},[Q.Top]:{x:0,y:-1},[Q.Bottom]:{x:0,y:1}},mf=({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},Is=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function yf({source:e,sourcePosition:t=Q.Bottom,target:n,targetPosition:r=Q.Top,center:s,offset:o,stepPosition:i}){const a=$s[t],c=$s[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=mf({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]=gi({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 T=[{x:v,y:l.y},{x:v,y:d.y}],R=[{x:l.x,y:w},{x:d.x,y:w}];a[f]===h?p=f==="x"?T:R:p=f==="x"?R:T}else{const T=[{x:l.x,y:d.y}],R=[{x:d.x,y:l.y}];if(f==="x"?p=a.x===h?R:T:p=a.y===h?T:R,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[_],$=l[_]<d[_];(a[f]===1&&(!C&&S||C&&$)||a[f]!==1&&(!C&&$||C&&S))&&(p=f==="x"?T:R)}const F={x:l.x+m.x,y:l.y+m.y},M={x:d.x+E.x,y:d.y+E.y},I=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));I>=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 xf(e,t,n,r){const s=Math.min(Is(e,t)/2,Is(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 Nr({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]=yf({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+=xf(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 js(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function wf(e){var u;const{sourceNode:t,targetNode:n}=e;if(!js(t)||!js(n))return null;const r=t.internals.handleBounds||Ps(t.handles),s=n.internals.handleBounds||Ps(n.handles),o=Ds((r==null?void 0:r.source)??[],e.sourceHandle),i=Ds(e.connectionMode===bt.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 Ps(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 Ds(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function Sr(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function vf(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=Sr(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 mi=1e3,bf=10,Yr={nodeOrigin:[0,0],nodeExtent:Ot,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},_f={...Yr,checkEquality:!0};function Xr(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function Ef(e,t,n){const r=Xr(Yr,n);for(const s of e.values())if(s.parentId)qr(s,e,t,r);else{const o=qt(s,r.nodeOrigin),i=lt(s.extent)?s.extent:r.nodeExtent,a=ct(o,i,Ke(s));s.internals.positionAbsolute=a}}function Nf(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 Kr(e){return e==="manual"}function kr(e,t,n,r={}){var d,u;const s=Xr(_f,r),o={i:0},i=new Map(t),a=s!=null&&s.elevateNodesOnSelect&&!Kr(s.zIndexMode)?mi: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=qt(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:Nf(f,h),z:yi(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&&qr(h,t,n,r,o),l||(l=f.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:l}}function Sf(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 qr(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:i,nodeExtent:a,zIndexMode:c}=Xr(Yr,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}Sf(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*bf),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const u=o&&!Kr(c)?mi:0,{x:f,y:h,z:p}=kf(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 yi(e,t,n){const r=je(e.zIndex)?e.zIndex:0;return Kr(n)?r:r+(e.selected?t:0)}function kf(e,t,n,r,s,o){const{x:i,y:a}=t.internals.positionAbsolute,c=Ke(e),l=qt(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=si(u,c,t));const f=yi(e,s,o),h=t.internals.z??0;return{x:u.x,y:u.y,z:h>=f?h+1:f}}function Gr(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)??Et(c),d=oi(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 Mf(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=Wr(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=si(x,v,t.get(p.parentId)):y&&(x=ct(x,y,v));const N={...p,measured:v,internals:{...p.internals,positionAbsolute:x,handleBounds:{source:Cs("source",h.nodeElement,E,u,p.id),target:Cs("target",h.nodeElement,E,u,p.id)}}};t.set(p.id,N),p.parentId&&qr(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:Et(N,s)}))}}if(f.length>0){const h=Gr(f,t,n,s);l.push(...h)}return{changes:l,updatedInternals:c}}async function Cf({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 Ts(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 xi(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}`;Ts("source",c,d,e,s,i),Ts("target",c,l,e,o,a),t.set(r.id,r)}}function wi(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:wi(n,t):!1}function Rs(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 Af(e,t,n,r){const s=new Map;for(const[o,i]of e)if((i.selected||i.id===r)&&(!i.parentId||!wi(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 nr({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 $f({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=Ut(o,t);return{x:i.x-o.x,y:i.y-o.y}}function If({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:D=0}){f=_e(x);function T({x:I,y:V}){const{nodeLookup:_,nodeExtent:C,snapGrid:S,snapToGrid:$,nodeOrigin:L,onNodeDrag:A,onSelectionDrag:O,onError:B,updateNodePositions:H}=t();o={x:I,y:V};let Y=!1;const X=a.size>1,ee=X&&C?Er(Gt(a)):null,J=X&&$?$f({dragItems:a,snapGrid:S,x:I,y:V}):null;for(const[Z,j]of a){if(!_.has(Z))continue;let W={x:I-j.distance.x,y:V-j.distance.y};$&&(W=J?{x:Math.round(W.x+J.x),y:Math.round(W.y+J.y)}:Ut(W,S));let ne=null;if(X&&C&&!j.extent&&ee){const{positionAbsolute:U}=j.internals,re=U.x-ee.x+C[0][0],ae=U.x+j.measured.width-ee.x2+C[1][0],oe=U.y-ee.y+C[0][1],ce=U.y+j.measured.height-ee.y2+C[1][1];ne=[[re,oe],[ae,ce]]}const{position:te,positionAbsolute:q}=ri({nodeId:Z,nextPosition:W,nodeLookup:_,nodeExtent:ne||C,nodeOrigin:L,onError:B});Y=Y||j.position.x!==te.x||j.position.y!==te.y,j.position=te,j.internals.positionAbsolute=q}if(p=p||Y,!!Y&&(H(a,!0),v&&(r||A||!k&&O))){const[Z,j]=nr({nodeId:k,dragItems:a,nodeLookup:_});r==null||r(v,a,Z,j),A==null||A(v,Z,j),k||O==null||O(v,j)}}async function R(){if(!d)return;const{transform:I,panBy:V,autoPanSpeed:_,autoPanOnNodeDrag:C}=t();if(!C){c=!1,cancelAnimationFrame(i);return}const[S,$]=Vr(l,d,_);(S!==0||$!==0)&&(o.x=(o.x??0)-S/I[2],o.y=(o.y??0)-$/I[2],await V({x:S,y:$})&&T(o)),i=requestAnimationFrame(R)}function F(I){var X;const{nodeLookup:V,multiSelectionActive:_,nodesDraggable:C,transform:S,snapGrid:$,snapToGrid:L,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=Tt(I.sourceEvent,{transform:S,snapGrid:$,snapToGrid:L,containerBounds:d});if(o=Y,a=Af(V,C,Y,k),a.size>0&&(n||O||!k&&B)){const[ee,J]=nr({nodeId:k,dragItems:a,nodeLookup:V});n==null||n(I.sourceEvent,a,ee,J),O==null||O(I.sourceEvent,ee,J),k||B==null||B(I.sourceEvent,J)}}const M=Ro().clickDistance(D).on("start",I=>{const{domNode:V,nodeDragThreshold:_,transform:C,snapGrid:S,snapToGrid:$}=t();d=(V==null?void 0:V.getBoundingClientRect())||null,h=!1,p=!1,v=I.sourceEvent,_===0&&F(I),o=Tt(I.sourceEvent,{transform:C,snapGrid:S,snapToGrid:$,containerBounds:d}),l=Pe(I.sourceEvent,d)}).on("drag",I=>{const{autoPanOnNodeDrag:V,transform:_,snapGrid:C,snapToGrid:S,nodeDragThreshold:$,nodeLookup:L}=t(),A=Tt(I.sourceEvent,{transform:_,snapGrid:C,snapToGrid:S,containerBounds:d});if(v=I.sourceEvent,(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1||k&&!L.has(k))&&(h=!0),!h){if(!c&&V&&u&&(c=!0,R()),!u){const O=Pe(I.sourceEvent,d),B=O.x-l.x,H=O.y-l.y;Math.sqrt(B*B+H*H)>$&&F(I)}(o.x!==A.xSnapped||o.y!==A.ySnapped)&&a&&u&&(l=Pe(I.sourceEvent,d),T(A))}}).on("end",I=>{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[$,L]=nr({nodeId:k,dragItems:a,nodeLookup:V,dragging:!1});s==null||s(I.sourceEvent,a,$,L),C==null||C(I.sourceEvent,$,L),k||S==null||S(I.sourceEvent,L)}}}).filter(I=>{const V=I.target;return!I.button&&(!E||!Rs(V,`.${E}`,x))&&(!y||Rs(V,y,x))});f.call(M)}function m(){f==null||f.on(".drag",null)}return{update:w,destroy:m}}function jf(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())Ft(s,Et(o))>0&&r.push(o);return r}const Pf=250;function Df(e,t,n,r){var a,c;let s=[],o=1/0;const i=jf(e,n,t+Pf);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 vi(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 bi(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Tf(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const _i=()=>!0;function Rf(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=_i,onReconnectEnd:E,updateConnection:y,getTransform:x,getFromHandle:N,autoPanSpeed:k,dragThreshold:D=1,handleDomNode:T}){const R=li(e.target);let F=0,M;const{x:I,y:V}=Pe(e),_=bi(o,T),C=a==null?void 0:a.getBoundingClientRect();let S=!1;if(!C||!_)return;const $=vi(s,_,r,c,t);if(!$)return;let L=Pe(e,C),A=!1,O=null,B=!1,H=null;function Y(){if(!d||!C)return;const[te,q]=Vr(L,C,k);f({x:te,y:q}),F=requestAnimationFrame(Y)}const X={...$,nodeId:s,type:_,position:$.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:L,toHandle:null,toPosition:Ns[X.position],toNode:null,pointer:L};function j(){S=!0,y(Z),p==null||p(e,{nodeId:s,handleId:r,handleType:_})}D===0&&j();function W(te){if(!S){const{x:ce,y:pe}=Pe(te),Ne=ce-I,Se=pe-V;if(!(Ne*Ne+Se*Se>D*D))return;j()}if(!N()||!X){ne(te);return}const q=x();L=Pe(te,C),M=Df(Ct(L,q,!1,[1,1]),n,c,X),A||(Y(),A=!0);const U=Ei(te,{handle:M,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:i?"target":"source",isValidConnection:m,doc:R,lib:l,flowId:u,nodeLookup:c});H=U.handleDomNode,O=U.connection,B=Tf(!!M,U.isValid);const re=c.get(s),ae=re?ut(re,X,Q.Left,!0):Z.from,oe={...Z,from:ae,isValid:B,to:U.toHandle&&B?Nt({x:U.toHandle.x,y:U.toHandle.y},q):L,toHandle:U.toHandle,toPosition:B&&U.toHandle?U.toHandle.position:Ns[X.position],toNode:U.toHandle?c.get(U.toHandle.nodeId):null,pointer:L};y(oe),Z=oe}function ne(te){if(!("touches"in te&&te.touches.length>0)){if(S){(M||H)&&O&&B&&(v==null||v(O));const{inProgress:q,...U}=Z,re={...U,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,R.removeEventListener("mousemove",W),R.removeEventListener("mouseup",ne),R.removeEventListener("touchmove",W),R.removeEventListener("touchend",ne)}}R.addEventListener("mousemove",W),R.addEventListener("mouseup",ne),R.addEventListener("touchmove",W),R.addEventListener("touchend",ne)}function Ei(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:i,lib:a,flowId:c,isValidConnection:l=_i,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=bi(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 D={source:u?y:r,sourceHandle:u?x:s,target:u?r:y,targetHandle:u?s:x};m.connection=D;const R=N&&k&&(n===bt.Strict?u&&E==="source"||!u&&E==="target":y!==r||x!==s);m.isValid=R&&l(D),m.toHandle=vi(y,E,x,d,n,!0)}return m}const Mr={onPointerDown:Rf,isValid:Ei};function Lf({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=_e(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&&Wt()?10:1,k=-y.sourceEvent.deltaY*(y.sourceEvent.deltaMode===1?.05:y.sourceEvent.deltaMode?1:.002)*d,D=x[2]*Math.pow(2,k*N);t.scaleTo(D)};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 D=r()*Math.max(x[2],Math.log(x[2]))*(h?-1:1),T={x:x[0]-k[0]*D,y:x[1]-k[1]*D},R=[[0,0],[c,l]];t.setViewportConstrained({x:T.x,y:T.y,zoom:x[2]},R,a)},E=Zo().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:$e}}const Ln=e=>({x:e.x,y:e.y,zoom:e.k}),rr=({x:e,y:t,zoom:n})=>Dn.translate(e,t).scale(n),pt=(e,t)=>e.target.closest(`.${t}`),Ni=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),zf=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,sr=(e,t=0,n=zf,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},Si=e=>{const t=e.ctrlKey&&Wt()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function Hf({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:i,onPanZoomStart:a,onPanZoom:c,onPanZoomEnd:l}){return d=>{if(pt(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=$e(d),m=Si(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;!Wt()&&d.shiftKey&&s!==st.Vertical&&(h=d.deltaY*f,p=0),r.translateBy(n,-(h/u)*o,-(p/u)*o,{internal:!0});const v=Ln(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 Of({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",i=!t&&o&&!r.ctrlKey,a=pt(r,e);if(r.ctrlKey&&o&&a&&r.preventDefault(),i||a)return null;r.preventDefault(),n.call(this,r,s)}}function Bf({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,i,a;if((o=r.sourceEvent)!=null&&o.internal)return;const s=Ln(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 Vf({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var i,a;e.usedRightMouseButton=!!(n&&Ni(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,Ln(o.transform)))}}function Ff({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&&Ni(t,e.mouseButton??0)&&!e.usedRightMouseButton&&i.sourceEvent&&o(i.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Ln(i.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(i.sourceEvent,c)},n?150:0)}}}function Wf({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"&&(pt(u,`${l}-flow__node`)||pt(u,`${l}-flow__edge`)))return!0;if(!r&&!f&&!s&&!o&&!n||i||d&&!p||pt(u,a)&&p||pt(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 Yf({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=Zo().scaleExtent([t,n]).translateExtent(r),f=_e(e).call(u);E({x:s.x,y:s.y,zoom:_t(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=f.on("wheel.zoom"),p=f.on("dblclick.zoom");u.wheelDelta(Si);async function v(M,I){return f?new Promise(V=>{u==null||u.interpolate((I==null?void 0:I.interpolate)==="linear"?Dt:pn).transform(sr(f,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>V(!0)),M)}):!1}function w({noWheelClassName:M,noPanClassName:I,onPaneContextMenu:V,userSelectionActive:_,panOnScroll:C,panOnDrag:S,panOnScrollMode:$,panOnScrollSpeed:L,preventScrolling:A,zoomOnPinch:O,zoomOnScroll:B,zoomOnDoubleClick:H,zoomActivationKeyPressed:Y,lib:X,onTransformChange:ee,connectionInProgress:J,paneClickDistance:Z,selectionOnDrag:j}){_&&!l.isZoomingOrPanning&&m();const W=C&&!Y&&!_;u.clickDistance(j?1/0:!je(Z)||Z<0?0:Z);const ne=W?Hf({zoomPanValues:l,noWheelClassName:M,d3Selection:f,d3Zoom:u,panOnScrollMode:$,panOnScrollSpeed:L,zoomOnPinch:O,onPanZoomStart:i,onPanZoom:o,onPanZoomEnd:a}):Of({noWheelClassName:M,preventScrolling:A,d3ZoomHandler:h});f.on("wheel.zoom",ne,{passive:!1});const te=Bf({zoomPanValues:l,onDraggingChange:c,onPanZoomStart:i});u.on("start",te);const q=Vf({zoomPanValues:l,panOnDrag:S,onPaneContextMenu:!!V,onPanZoom:o,onTransformChange:ee});u.on("zoom",q);const U=Ff({zoomPanValues:l,panOnDrag:S,panOnScroll:C,onPaneContextMenu:V,onPanZoomEnd:a,onDraggingChange:c});u.on("end",U);const re=Wf({zoomActivationKeyPressed:Y,panOnDrag:S,zoomOnScroll:B,panOnScroll:C,zoomOnDoubleClick:H,zoomOnPinch:O,userSelectionActive:_,noPanClassName:I,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,I,V){const _=rr(M),C=u==null?void 0:u.constrain()(_,I,V);return C&&await v(C),C}async function y(M,I){const V=rr(M);return await v(V,I),V}function x(M){if(f){const I=rr(M),V=f.property("__zoom");(V.k!==M.zoom||V.x!==M.x||V.y!==M.y)&&(u==null||u.transform(f,I,null,{sync:!0}))}}function N(){const M=f?Uo(f.node()):{x:0,y:0,k:1};return{x:M.x,y:M.y,zoom:M.k}}async function k(M,I){return f?new Promise(V=>{u==null||u.interpolate((I==null?void 0:I.interpolate)==="linear"?Dt:pn).scaleTo(sr(f,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>V(!0)),M)}):!1}async function D(M,I){return f?new Promise(V=>{u==null||u.interpolate((I==null?void 0:I.interpolate)==="linear"?Dt:pn).scaleBy(sr(f,I==null?void 0:I.duration,I==null?void 0:I.ease,()=>V(!0)),M)}):!1}function T(M){u==null||u.scaleExtent(M)}function R(M){u==null||u.translateExtent(M)}function F(M){const I=!je(M)||M<0?0:M;u==null||u.clickDistance(I)}return{update:w,destroy:m,setViewport:y,setViewportConstrained:E,getViewport:N,scaleTo:k,scaleBy:D,setScaleExtent:T,setTranslateExtent:R,syncViewport:x,setClickDistance:F}}var St;(function(e){e.Line="line",e.Handle="handle"})(St||(St={}));function Xf({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 Ls(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 zs(e,t){return e?!t:t}function Kf(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:D}=e;let T=Math.floor(d?h-e.pointerX:0),R=Math.floor(u?p-e.pointerY:0);const F=N+(c?-T:T),M=k+(l?-R:R),I=-o[0]*N,V=-o[1]*k;let _=un(F,v,w),C=un(M,m,E);if(i){let L=0,A=0;c&&T<0?L=qe(y+T+I,i[0][0]):!c&&T>0&&(L=Ge(y+F+I,i[1][0])),l&&R<0?A=qe(x+R+V,i[0][1]):!l&&R>0&&(A=Ge(x+M+V,i[1][1])),_=Math.max(_,L),C=Math.max(C,A)}if(a){let L=0,A=0;c&&T>0?L=Ge(y+T,a[0][0]):!c&&T<0&&(L=qe(y+F,a[1][0])),l&&R>0?A=Ge(x+R,a[0][1]):!l&&R<0&&(A=qe(x+M,a[1][1])),_=Math.max(_,L),C=Math.max(C,A)}if(s){if(d){const L=un(F/D,m,E)*D;if(_=Math.max(_,L),i){let A=0;!c&&!l||c&&!l&&f?A=Ge(x+V+F/D,i[1][1])*D:A=qe(x+V+(c?T:-T)/D,i[0][1])*D,_=Math.max(_,A)}if(a){let A=0;!c&&!l||c&&!l&&f?A=qe(x+F/D,a[1][1])*D:A=Ge(x+(c?T:-T)/D,a[0][1])*D,_=Math.max(_,A)}}if(u){const L=un(M*D,v,w)/D;if(C=Math.max(C,L),i){let A=0;!c&&!l||l&&!c&&f?A=Ge(y+M*D+I,i[1][0])/D:A=qe(y+(l?R:-R)*D+I,i[0][0])/D,C=Math.max(C,A)}if(a){let A=0;!c&&!l||l&&!c&&f?A=qe(y+M*D,a[1][0])/D:A=Ge(y+(l?R:-R)*D,a[0][0])/D,C=Math.max(C,A)}}}R=R+(R<0?C:-C),T=T+(T<0?_:-_),s&&(f?F>M*D?R=(zs(c,l)?-T:T)/D:T=(zs(c,l)?-R:R)*D:d?(R=T/D,l=c):(T=R*D,c=l));const S=c?y+T:y,$=l?x+R:x;return{width:N+(c?-T:T),height:k+(l?-R:R),x:o[0]*T*(c?-1:1)+S,y:o[1]*R*(l?-1:1)+$}}const ki={width:0,height:0,x:0,y:0},qf={...ki,pointerX:0,pointerY:0,aspectRatio:1};function Gf(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 Uf({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=_e(e);let i={controlDirection:Ls("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={...ki},E={...qf};i={boundaries:d,resizeDirection:f,keepAspectRatio:u,controlDirection:Ls(l)};let y,x=null,N=[],k,D,T,R=!1;const F=Ro().on("start",M=>{const{nodeLookup:I,transform:V,snapGrid:_,snapToGrid:C,nodeOrigin:S,paneDomNode:$}=n();if(y=I.get(t),!y)return;x=($==null?void 0:$.getBoundingClientRect())??null;const{xSnapped:L,ySnapped:A}=Tt(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:L,pointerY:A,aspectRatio:m.width/m.height},k=void 0,D=lt(y.extent)?y.extent:void 0,y.parentId&&(y.extent==="parent"||y.expandParent)&&(k=I.get(y.parentId)),k&&y.extent==="parent"&&(D=[[0,0],[k.measured.width,k.measured.height]]),N=[],T=void 0;for(const[O,B]of I)if(B.parentId===t&&(N.push({id:O,position:{...B.position},extent:B.extent}),B.extent==="parent"||B.expandParent)){const H=Gf(B,y,B.origin??S);T?T=[[Math.min(H[0][0],T[0][0]),Math.min(H[0][1],T[0][1])],[Math.max(H[1][0],T[1][0]),Math.max(H[1][1],T[1][1])]]:T=H}h==null||h(M,{...m})}).on("drag",M=>{const{transform:I,snapGrid:V,snapToGrid:_,nodeOrigin:C}=n(),S=Tt(M.sourceEvent,{transform:I,snapGrid:V,snapToGrid:_,containerBounds:x}),$=[];if(!y)return;const{x:L,y:A,width:O,height:B}=m,H={},Y=y.origin??C,{width:X,height:ee,x:J,y:Z}=Kf(E,i.controlDirection,S,i.boundaries,i.keepAspectRatio,Y,D,T),j=X!==O,W=ee!==B,ne=J!==L&&j,te=Z!==A&&W;if(!ne&&!te&&!j&&!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 ae=J-L,oe=Z-A;for(const ce of N)ce.position={x:ce.position.x-ae+Y[0]*(X-O),y:ce.position.y-oe+Y[1]*(ee-B)},$.push(ce)}if((j||W)&&(H.width=j&&(!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 ae=Y[0]*(H.width??0);H.x&&H.x<ae&&(m.x=ae,E.x=E.x-(H.x-ae));const oe=Y[1]*(H.height??0);H.y&&H.y<oe&&(m.y=oe,E.y=E.y-(H.y-oe))}const q=Xf({width:m.width,prevWidth:O,height:m.height,prevHeight:B,affectsX:i.controlDirection.affectsX,affectsY:i.controlDirection.affectsY}),U={...m,direction:q};(w==null?void 0:w(M,U))!==!1&&(R=!0,p==null||p(M,U),r(H,$))}).on("end",M=>{R&&(v==null||v(M,{...m}),s==null||s({...m}),R=!1)});o.call(F)}function c(){o.on(".drag",null)}return{update:a,destroy:c}}var Mi={exports:{}},Ci={},Ai={exports:{}},$i={};/**
|
|
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 kt=b;function Zf(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Qf=typeof Object.is=="function"?Object.is:Zf,Jf=kt.useState,eh=kt.useEffect,th=kt.useLayoutEffect,nh=kt.useDebugValue;function rh(e,t){var n=t(),r=Jf({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return th(function(){s.value=n,s.getSnapshot=t,or(s)&&o({inst:s})},[e,n,t]),eh(function(){return or(s)&&o({inst:s}),e(function(){or(s)&&o({inst:s})})},[e]),nh(n),n}function or(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Qf(e,n)}catch{return!0}}function sh(e,t){return t()}var oh=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?sh:rh;$i.useSyncExternalStore=kt.useSyncExternalStore!==void 0?kt.useSyncExternalStore:oh;Ai.exports=$i;var ih=Ai.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,ah=ih;function ch(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var lh=typeof Object.is=="function"?Object.is:ch,uh=ah.useSyncExternalStore,dh=zn.useRef,fh=zn.useEffect,hh=zn.useMemo,gh=zn.useDebugValue;Ci.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=dh(null);if(o.current===null){var i={hasValue:!1,value:null};o.current=i}else i=o.current;o=hh(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,lh(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=uh(e,o[0],o[1]);return fh(function(){i.hasValue=!0,i.value=a},[a]),gh(a),a};Mi.exports=Ci;var ph=Mi.exports;const mh=Za(ph),yh={},Hs=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:()=>{(yh?"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},xh=e=>e?Hs(e):Hs,{useDebugValue:wh}=Qa,{useSyncExternalStoreWithSelector:vh}=mh,bh=e=>e;function Ii(e,t=bh,n){const r=vh(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return wh(r),r}const Os=(e,t)=>{const n=xh(e),r=(s,o=t)=>Ii(n,s,o);return Object.assign(r,n),r},_h=(e,t)=>e?Os(e,t):Os;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),Eh=Hn.Provider,ji=De.error001("react");function ie(e,t){const n=b.useContext(Hn);if(n===null)throw new Error(ji);return Ii(n,e,t)}function ue(){const e=b.useContext(Hn);if(e===null)throw new Error(ji);return b.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const Bs={display:"none"},Nh={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Pi="react-flow__node-desc",Di="react-flow__edge-desc",Sh="react-flow__aria-live",kh=e=>e.ariaLiveMessage,Mh=e=>e.ariaLabelConfig;function Ch({rfId:e}){const t=ie(kh);return g.jsx("div",{id:`${Sh}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Nh,children:t})}function Ah({rfId:e,disableKeyboardA11y:t}){const n=ie(Mh);return g.jsxs(g.Fragment,{children:[g.jsx("div",{id:`${Pi}-${e}`,style:Bs,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),g.jsx("div",{id:`${Di}-${e}`,style:Bs,children:n["edge.a11yDescription.default"]}),!t&&g.jsx(Ch,{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:he(["react-flow__panel",n,...i]),style:r,ref:o,...s,children:t})});On.displayName="Panel";function $h({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 Ih=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 jh(e,t){return le(e.selectedNodes.map(dn),t.selectedNodes.map(dn))&&le(e.selectedEdges.map(dn),t.selectedEdges.map(dn))}function Ph({onSelectionChange:e}){const t=ue(),{selectedNodes:n,selectedEdges:r}=ie(Ih,jh);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 Dh=e=>!!e.onSelectionChangeHandlers;function Th({onSelectionChange:e}){const t=ie(Dh);return e||t?g.jsx(Ph,{onSelectionChange:e}):null}const Ti=[0,0],Rh={x:0,y:0,zoom:1},Lh=["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"],Vs=[...Lh,"rfId"],zh=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}),Fs={translateExtent:Ot,nodeOrigin:Ti,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function Hh(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:i,reset:a,setDefaultNodesAndEdges:c}=ie(zh,le),l=ue();b.useEffect(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=Fs,a()}),[]);const d=b.useRef(Fs);return b.useEffect(()=>{for(const u of Vs){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:lf(f)}):u==="fitView"?l.setState({fitViewQueued:f}):u==="fitViewOptions"?l.setState({fitViewOptions:f}):l.setState({[u]:f})))}d.current=e},Vs.map(u=>e[u])),null}function Ws(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function Oh(e){var r;const[t,n]=b.useState(e==="system"?null:e);return b.useEffect(()=>{if(e!=="system"){n(e);return}const s=Ws(),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=Ws())!=null&&r.matches?"dark":"light"}const Ys=typeof document<"u"?document:null;function Yt(e=null,t={target:Ys,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)??Ys,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)&&ui(h))return!1;const v=Ks(h.code,a);if(o.current.add(h[v]),Xs(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=Ks(h.code,a);Xs(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 Xs(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Ks(e,t){return t.includes(e)?"code":"key"}const Bh=()=>{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=Fr(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 Ct(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=Nt(t,n);return{x:i.x+s,y:i.y+o}}}),[])};function Ri(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)Vh(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 Vh(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 Fh(e,t){return Ri(e,t)}function Wh(e,t){return Ri(e,t)}function et(e,t){return{id:e,type:"select",selected:t}}function mt(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 qs({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 Gs(e){return{id:e.id,type:"remove"}}const Yh=ii();function Xh(e,t,n={}){return pf(e,t,{...n,onError:n.onError??Yh})}const Us=e=>Jd(e),Kh=e=>ni(e);function Li(e){return b.forwardRef(e)}const qh=typeof window<"u"?b.useLayoutEffect:b.useEffect;function Zs(e){const[t,n]=b.useState(BigInt(0)),[r]=b.useState(()=>Gh(()=>n(s=>s+BigInt(1))));return qh(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function Gh(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const zi=b.createContext(null);function Uh({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=qs({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=Zs(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(qs({items:h,lookup:f}))},[]),o=Zs(s),i=b.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return g.jsx(zi.Provider,{value:i,children:e})}function Zh(){const e=b.useContext(zi);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Qh=e=>!!e.panZoom;function Bn(){const e=Bh(),t=ue(),n=Zh(),r=ie(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=Us(u)?u:f.get(u.id),v=p.parentId?ci(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 Et(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&&Us(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&&Kh(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 sf({nodesToRemove:u,edgesToRemove:f,nodes:h,edges:p,onBeforeDelete:x}),D=k.length>0,T=N.length>0;if(D){const R=k.map(Gs);w==null||w(k),E(R)}if(T){const R=N.map(Gs);v==null||v(N),m(R)}return(T||D)&&(y==null||y({nodes:N,edges:k})),{deletedNodes:N,deletedEdges:k}},getIntersectingNodes:(u,f=!0,h)=>{const p=ks(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=Et(w?m:E),x=Ft(y,v);return f&&x>0||x>=y.width*y.height||x>=v.width*v.height}):[]},isNodeIntersecting:(u,f,h=!0)=>{const v=ks(u)?u:c(u);if(!v)return!1;const w=Ft(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 ef(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??cf();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 Qs=e=>e.selected,Jh=typeof window<"u"?window:void 0;function eg({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=ue(),{deleteElements:r}=Bn(),s=Yt(e,{actInsideInputWithModifier:!1}),o=Yt(t,{target:Jh});b.useEffect(()=>{if(s){const{edges:i,nodes:a}=n.getState();r({nodes:a.filter(Qs),edges:i.filter(Qs)}),n.setState({nodesSelectionActive:!1})}},[s]),b.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function tg(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=Wr(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},ng=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function rg({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:D,lib:T,connectionInProgress:R}=ie(ng,le),F=Yt(f),M=b.useRef();tg(k);const I=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=Yf({domNode:k.current,minZoom:d,maxZoom:u,translateExtent:l,viewport:c,onDraggingChange:S=>N.setState($=>$.paneDragging===S?$:{paneDragging:S}),onPanZoomStart:(S,$)=>{const{onViewportChangeStart:L,onMoveStart:A}=N.getState();A==null||A(S,$),L==null||L($)},onPanZoom:(S,$)=>{const{onViewportChange:L,onMove:A}=N.getState();A==null||A(S,$),L==null||L($)},onPanZoomEnd:(S,$)=>{const{onViewportChangeEnd:L,onMoveEnd:A}=N.getState();A==null||A(S,$),L==null||L($)}});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:D,noWheelClassName:v,lib:T,onTransformChange:I,connectionInProgress:R,selectionOnDrag:x,paneClickDistance:y})},[e,t,n,r,s,o,i,a,F,h,w,D,v,T,I,R,x,y]),g.jsx("div",{className:"react-flow__renderer",ref:k,style:Vn,children:p})}const sg=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function og(){const{userSelectionActive:e,userSelectionRect:t}=ie(sg,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 ir=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},ig=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function ag({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Bt.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:D}=ie(ig,le),T=y&&(e||E),R=b.useRef(null),F=b.useRef(),M=b.useRef(new Set),I=b.useRef(new Set),V=b.useRef(!1),_=b.useRef({x:0,y:0}),C=b.useRef(!1),S=j=>{if(V.current||N){V.current=!1;return}l==null||l(j),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},$=j=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){j.preventDefault();return}d==null||d(j)},L=u?j=>u(j):void 0,A=j=>{V.current&&(j.stopPropagation(),V.current=!1)},O=j=>{var ce,pe;const{domNode:W,transform:ne}=m.getState();if(F.current=W==null?void 0:W.getBoundingClientRect(),!F.current)return;const te=j.target===R.current;if(!te&&!!j.target.closest(".nokey")||!e||!(i&&te||t)||j.button!==0||!j.isPrimary)return;(pe=(ce=j.target)==null?void 0:ce.setPointerCapture)==null||pe.call(ce,j.pointerId),V.current=!1;const{x:re,y:ae}=Pe(j.nativeEvent,F.current),oe=Ct({x:re,y:ae},ne);m.setState({userSelectionRect:{width:0,height:0,startX:oe.x,startY:oe.y,x:re,y:ae}}),te||(j.stopPropagation(),j.preventDefault())};function B(j,W){const{userSelectionRect:ne}=m.getState();if(!ne)return;const{transform:te,nodeLookup:q,edgeLookup:U,connectionLookup:re,triggerNodeChanges:ae,triggerEdgeChanges:oe,defaultEdgeOptions:ce}=m.getState(),pe={x:ne.startX,y:ne.startY},{x:Ne,y:Se}=Nt(pe,te),we={startX:pe.x,startY:pe.y,x:j<Ne?j:Ne,y:W<Se?W:Se,width:Math.abs(j-Ne),height:Math.abs(W-Se)},Oe=M.current,Me=I.current;M.current=new Set(Br(q,we,te,n===Bt.Partial,!0).map(me=>me.id)),I.current=new Set;const Ce=(ce==null?void 0:ce.selectable)??!0;for(const me of M.current){const ve=re.get(me);if(ve)for(const{edgeId:be}of ve.values()){const Be=U.get(be);Be&&(Be.selectable??Ce)&&I.current.add(be)}}if(!Ms(Oe,M.current)){const me=mt(q,M.current,!0);ae(me)}if(!Ms(Me,I.current)){const me=mt(U,I.current);oe(me)}m.setState({userSelectionRect:we,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!s||!F.current)return;const[j,W]=Vr(_.current,F.current,D);k({x:j,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=j=>{const{userSelectionRect:W,transform:ne,resetSelectedElements:te}=m.getState();if(!F.current||!W)return;const{x:q,y:U}=Pe(j.nativeEvent,F.current);_.current={x:q,y:U};const re=Nt({x:W.startX,y:W.startY},ne);if(!V.current){const ae=t?0:o;if(Math.hypot(q-re.x,U-re.y)<=ae)return;te(),a==null||a(j)}V.current=!0,C.current||(H(),C.current=!0),B(q,U)},ee=j=>{var W,ne;j.button===0&&((ne=(W=j.target)==null?void 0:W.releasePointerCapture)==null||ne.call(W,j.pointerId),!E&&j.target===R.current&&m.getState().userSelectionRect&&(S==null||S(j)),m.setState({userSelectionActive:!1,userSelectionRect:null}),V.current&&(c==null||c(j),m.setState({nodesSelectionActive:M.current.size>0})),Y())},J=j=>{var W,ne;(ne=(W=j.target)==null?void 0:W.releasePointerCapture)==null||ne.call(W,j.pointerId),Y()},Z=r===!0||Array.isArray(r)&&r.includes(0);return g.jsxs("div",{className:he(["react-flow__pane",{draggable:Z,dragging:x,selection:e}]),onClick:T?void 0:ir(S,R),onContextMenu:ir($,R),onWheel:ir(L,R),onPointerEnter:T?void 0:f,onPointerMove:T?X:h,onPointerUp:T?ee:void 0,onPointerCancel:T?J:void 0,onPointerDownCapture:T?O:void 0,onClickCapture:T?A:void 0,onPointerLeave:p,ref:R,style:Vn,children:[v,g.jsx(og,{})]})}function Cr({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 Hi({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=If({getStoreItems:()=>a.getState(),onNodeMouseDown:u=>{Cr({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 cg=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Oi(){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=cg(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=Ut(E,o));const{position:y,positionAbsolute:x}=ri({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 Ur=b.createContext(null),lg=Ur.Provider;Ur.Consumer;const Bi=()=>b.useContext(Ur),ug=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),dg=(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===bt.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 fg({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=Bi(),{connectOnClick:E,noPanClassName:y,rfId:x}=ie(ug,le),{connectingFrom:N,connectingTo:k,clickConnecting:D,isPossibleEndHandle:T,connectionInProcess:R,clickConnectionInProcess:F,valid:M}=ie(dg(m,p,e),le);m||(S=(C=w.getState()).onError)==null||S.call(C,"010",De.error010());const I=$=>{const{defaultEdgeOptions:L,onConnect:A,hasDefaultEdges:O}=w.getState(),B={...L,...$};if(O){const{edges:H,setEdges:Y,onError:X}=w.getState();Y(Xh(B,H,{onError:X}))}A==null||A(B),a==null||a(B)},V=$=>{if(!m)return;const L=di($.nativeEvent);if(s&&(L&&$.button===0||!L)){const A=w.getState();Mr.onPointerDown($.nativeEvent,{handleDomNode:$.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:I,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})}L?d==null||d($):u==null||u($)},_=$=>{const{onClickConnectStart:L,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){L==null||L($.nativeEvent,{nodeId:m,handleId:p,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:m,type:e,id:p}});return}const Z=li($.target),j=n||H,{connection:W,isValid:ne}=Mr.isValid($.nativeEvent,{handle:{nodeId:m,id:p,type:e},connectionMode:B,fromNodeId:O.nodeId,fromHandleId:O.id||null,fromType:O.type,isValidConnection:j,flowId:X,doc:Z,lib:Y,nodeLookup:ee});ne&&W&&I(W);const te=structuredClone(J);delete te.inProgress,te.toPosition=te.toHandle?te.toHandle.position:null,A==null||A($,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:he(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",y,l,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:D,connectingfrom:N,connectingto:k,valid:M,connectionindicator:r&&(!R||T)&&(R||F?o:s)}]),onMouseDown:V,onTouchStart:V,onClick:E?_:void 0,ref:h,...f,children:c})}const Mt=b.memo(Li(fg));function hg({data:e,isConnectable:t,sourcePosition:n=Q.Bottom}){return g.jsxs(g.Fragment,{children:[e==null?void 0:e.label,g.jsx(Mt,{type:"source",position:n,isConnectable:t})]})}function gg({data:e,isConnectable:t,targetPosition:n=Q.Top,sourcePosition:r=Q.Bottom}){return g.jsxs(g.Fragment,{children:[g.jsx(Mt,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,g.jsx(Mt,{type:"source",position:r,isConnectable:t})]})}function pg(){return null}function mg({data:e,isConnectable:t,targetPosition:n=Q.Top}){return g.jsxs(g.Fragment,{children:[g.jsx(Mt,{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}},Js={input:hg,default:gg,output:mg,group:pg};function yg(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 xg=e=>{const{width:t,height:n,x:r,y:s}=Gt(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 wg({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=ue(),{width:s,height:o,transformString:i,userSelectionActive:a}=ie(xg,le),c=Oi(),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(Hi({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:he(["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 eo=typeof window<"u"?window:void 0,vg=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Vi({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:D,panOnDrag:T,autoPanOnSelection:R,defaultViewport:F,translateExtent:M,minZoom:I,maxZoom:V,preventScrolling:_,onSelectionContextMenu:C,noWheelClassName:S,noPanClassName:$,disableKeyboardA11y:L,onViewportChange:A,isControlledViewport:O}){const{nodesSelectionActive:B,userSelectionActive:H}=ie(vg,le),Y=Yt(l,{target:eo}),X=Yt(v,{target:eo}),ee=X||T,J=X||x,Z=d&&ee!==!0,j=Y||H||Z;return eg({deleteKeyCode:c,multiSelectionKeyCode:p}),g.jsx(rg,{onPaneContextMenu:o,elementsSelectable:m,zoomOnScroll:E,zoomOnPinch:y,panOnScroll:J,panOnScrollSpeed:N,panOnScrollMode:k,zoomOnDoubleClick:D,panOnDrag:!Y&&ee,defaultViewport:F,translateExtent:M,minZoom:I,maxZoom:V,zoomActivationKeyCode:w,preventScrolling:_,noWheelClassName:S,noPanClassName:$,onViewportChange:A,isControlledViewport:O,paneClickDistance:a,selectionOnDrag:Z,children:g.jsxs(ag,{onSelectionStart:f,onSelectionEnd:h,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:ee,autoPanOnSelection:R,isSelecting:!!j,selectionMode:u,selectionKeyPressed:Y,paneClickDistance:a,selectionOnDrag:Z,children:[e,B&&g.jsx(wg,{onSelectionContextMenu:C,noPanClassName:$,disableKeyboardA11y:L})]})})}Vi.displayName="FlowRenderer";const bg=b.memo(Vi),_g=e=>t=>e?Br(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 Eg(e){return ie(b.useCallback(_g(e),[e]),le)}const Ng=e=>e.updateNodeInternals;function Sg(){const e=ie(Ng),[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 kg({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 Mg({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}=ie(j=>{const W=j.nodeLookup.get(e),ne=j.parentLookup.has(e);return{node:W,internals:W.internals,isParent:ne}},le);let k=y.type||"default",D=(w==null?void 0:w[k])||Js[k];D===void 0&&(E==null||E("003",De.error003(k)),k="default",D=(w==null?void 0:w.default)||Js.default);const T=!!(y.draggable||a&&typeof y.draggable>"u"),R=!!(y.selectable||c&&typeof y.selectable>"u"),F=!!(y.connectable||l&&typeof y.connectable>"u"),M=!!(y.focusable||d&&typeof y.focusable>"u"),I=ue(),V=ai(y),_=kg({node:y,nodeType:k,hasDimensions:V,resizeObserver:u}),C=Hi({nodeRef:_,disabled:y.hidden||!T,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:R,nodeClickDistance:m}),S=Oi();if(y.hidden)return null;const $=Ke(y),L=yg(y),A=R||T||t||n||r||s,O=n?j=>n(j,{...x.userNode}):void 0,B=r?j=>r(j,{...x.userNode}):void 0,H=s?j=>s(j,{...x.userNode}):void 0,Y=o?j=>o(j,{...x.userNode}):void 0,X=i?j=>i(j,{...x.userNode}):void 0,ee=j=>{const{selectNodesOnDrag:W,nodeDragThreshold:ne}=I.getState();R&&(!W||!T||ne>0)&&Cr({id:e,store:I,nodeRef:_}),t&&t(j,{...x.userNode})},J=j=>{if(!(ui(j.nativeEvent)||p)){if(Qo.includes(j.key)&&R){const W=j.key==="Escape";Cr({id:e,store:I,unselect:W,nodeRef:_})}else if(T&&y.selected&&Object.prototype.hasOwnProperty.call(Mn,j.key)){j.preventDefault();const{ariaLabelConfig:W}=I.getState();I.setState({ariaLiveMessage:W["node.a11yDescription.ariaLiveMessage"]({direction:j.key.replace("Arrow","").toLowerCase(),x:~~x.positionAbsolute.x,y:~~x.positionAbsolute.y})}),S({direction:Mn[j.key],factor:j.shiftKey?4:1})}}},Z=()=>{var re;if(p||!((re=_.current)!=null&&re.matches(":focus-visible")))return;const{transform:j,width:W,height:ne,autoPanOnNodeFocus:te,setCenter:q}=I.getState();if(!te)return;Br(new Map([[e,y]]),{x:0,y:0,width:W,height:ne},j,!0).length>0||q(y.position.x+$.width/2,y.position.y+$.height/2,{zoom:j[2]})};return g.jsx("div",{className:he(["react-flow__node",`react-flow__node-${k}`,{[h]:T},y.className,{selected:y.selected,selectable:R,parent:N,draggable:T,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,...L},"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:`${Pi}-${v}`,"aria-label":y.ariaLabel,...y.domAttributes,children:g.jsx(lg,{value:e,children:g.jsx(D,{id:e,data:y.data,type:k,positionAbsoluteX:x.positionAbsolute.x,positionAbsoluteY:x.positionAbsolute.y,selected:y.selected??!1,selectable:R,draggable:T,deletable:y.deletable??!0,isConnectable:F,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:C,dragHandle:y.dragHandle,zIndex:x.z,parentId:y.parentId,...$})})})}var Cg=b.memo(Mg);const Ag=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Fi(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=ie(Ag,le),i=Eg(e.onlyRenderVisibleElements),a=Sg();return g.jsx("div",{className:"react-flow__nodes",style:Vn,children:i.map(c=>g.jsx(Cg,{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))})}Fi.displayName="NodeRenderer";const $g=b.memo(Fi);function Ig(e){return ie(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&&ff({sourceNode:o,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),le)}const jg=({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"})},Pg=({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"})},to={[Vt.Arrow]:jg,[Vt.ArrowClosed]:Pg};function Dg(e){const t=ue();return b.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(to,e)?to[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",De.error009(e)),null)},[e])}const Tg=({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=Dg(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},Wi=({defaultColor:e,rfId:t})=>{const n=ie(o=>o.edges),r=ie(o=>o.defaultEdgeOptions),s=b.useMemo(()=>vf(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(Tg,{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};Wi.displayName="MarkerDefinitions";var Rg=b.memo(Wi);function Yi({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=he(["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}Yi.displayName="EdgeText";const Lg=b.memo(Yi);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:he(["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(Lg,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:c}):null]})}function no({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 Xi({sourceX:e,sourceY:t,sourcePosition:n=Q.Bottom,targetX:r,targetY:s,targetPosition:o=Q.Top}){const[i,a]=no({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,l]=no({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,u,f,h]=fi({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 Ki(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]=Xi({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 zg=Ki({isInternal:!1}),qi=Ki({isInternal:!0});zg.displayName="SimpleBezierEdge";qi.displayName="SimpleBezierEdgeInternal";function Gi(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]=Nr({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 Ui=Gi({isInternal:!1}),Zi=Gi({isInternal:!0});Ui.displayName="SmoothStepEdge";Zi.displayName="SmoothStepEdgeInternal";function Qi(e){return b.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return g.jsx(Ui,{...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 Hg=Qi({isInternal:!1}),Ji=Qi({isInternal:!0});Hg.displayName="StepEdge";Ji.displayName="StepEdgeInternal";function ea(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]=pi({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 Og=ea({isInternal:!1}),ta=ea({isInternal:!0});Og.displayName="StraightEdge";ta.displayName="StraightEdgeInternal";function na(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]=hi({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 Bg=na({isInternal:!1}),ra=na({isInternal:!0});Bg.displayName="BezierEdge";ra.displayName="BezierEdgeInternal";const ro={default:ra,straight:ta,step:Ji,smoothstep:Zi,simplebezier:qi},so={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},Vg=(e,t,n)=>n===Q.Left?e-t:n===Q.Right?e+t:e,Fg=(e,t,n)=>n===Q.Top?e-t:n===Q.Bottom?e+t:e,oo="react-flow__edgeupdater";function io({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:he([oo,`${oo}-${a}`]),cx:Vg(t,r,e),cy:Fg(n,r,e),r,stroke:"transparent",fill:"transparent"})}function Wg({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:D,connectionMode:T,connectionRadius:R,lib:F,onConnectStart:M,cancelConnection:I,nodeLookup:V,rfId:_,panBy:C,updateConnection:S}=p.getState(),$=N.type==="target",L=(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)};Mr.onPointerDown(x.nativeEvent,{autoPanOnConnect:k,connectionMode:T,connectionRadius:R,domNode:D,handleId:N.id,nodeId:N.nodeId,nodeLookup:V,isTarget:$,edgeUpdaterType:N.type,lib:F,flowId:_,cancelConnection:I,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:L,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(io,{position:a,centerX:r,centerY:s,radius:t,onMouseDown:w,onMouseEnter:E,onMouseOut:y,type:"source"}),(e===!0||e==="target")&&g.jsx(io,{position:c,centerX:o,centerY:i,radius:t,onMouseDown:m,onMouseEnter:E,onMouseOut:y,type:"target"})]})}function Yg({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=ie(q=>q.edgeLookup.get(e));const x=ie(q=>q.defaultEdgeOptions);y=x?{...x,...y}:y;let N=y.type||"default",k=(v==null?void 0:v[N])||ro[N];k===void 0&&(m==null||m("011",De.error011(N)),N="default",k=(v==null?void 0:v.default)||ro.default);const D=!!(y.focusable||t&&typeof y.focusable>"u"),T=typeof u<"u"&&(y.reconnectable||n&&typeof y.reconnectable>"u"),R=!!(y.selectable||r&&typeof y.selectable>"u"),F=b.useRef(null),[M,I]=b.useState(!1),[V,_]=b.useState(!1),C=ue(),{zIndex:S,sourceX:$,sourceY:L,targetX:A,targetY:O,sourcePosition:B,targetPosition:H}=ie(b.useCallback(q=>{const U=q.nodeLookup.get(y.source),re=q.nodeLookup.get(y.target);if(!U||!re)return{zIndex:y.zIndex,...so};const ae=wf({id:e,sourceNode:U,targetNode:re,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:q.connectionMode,onError:m});return{zIndex:df({selected:y.selected,zIndex:y.zIndex,sourceNode:U,targetNode:re,elevateOnSelect:q.elevateEdgesOnSelect,zIndexMode:q.zIndexMode}),...ae||so}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),le),Y=b.useMemo(()=>y.markerStart?`url('#${Sr(y.markerStart,p)}')`:void 0,[y.markerStart,p]),X=b.useMemo(()=>y.markerEnd?`url('#${Sr(y.markerEnd,p)}')`:void 0,[y.markerEnd,p]);if(y.hidden||$===null||L===null||A===null||O===null)return null;const ee=q=>{var oe;const{addSelectedEdges:U,unselectNodesAndEdges:re,multiSelectionActive:ae}=C.getState();R&&(C.setState({nodesSelectionActive:!1}),y.selected&&ae?(re({nodes:[],edges:[y]}),(oe=F.current)==null||oe.blur()):U([e])),s&&s(q,y)},J=o?q=>{o(q,{...y})}:void 0,Z=i?q=>{i(q,{...y})}:void 0,j=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 U;if(!E&&Qo.includes(q.key)&&R){const{unselectNodesAndEdges:re,addSelectedEdges:ae}=C.getState();q.key==="Escape"?((U=F.current)==null||U.blur(),re({edges:[y]})):ae([e])}};return g.jsx("svg",{style:{zIndex:S},children:g.jsxs("g",{className:he(["react-flow__edge",`react-flow__edge-${N}`,y.className,w,{selected:y.selected,animated:y.animated,inactive:!R&&!s,updating:M,selectable:R}]),onClick:ee,onDoubleClick:J,onContextMenu:Z,onMouseEnter:j,onMouseMove:W,onMouseLeave:ne,onKeyDown:D?te:void 0,tabIndex:D?0:void 0,role:y.ariaRole??(D?"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":D?`${Di}-${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:R,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:$,sourceY:L,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}),T&&g.jsx(Wg,{edge:y,isReconnectable:T,reconnectRadius:d,onReconnect:u,onReconnectStart:f,onReconnectEnd:h,sourceX:$,sourceY:L,targetX:A,targetY:O,sourcePosition:B,targetPosition:H,setUpdateHover:I,setReconnecting:_})]})})}var Xg=b.memo(Yg);const Kg=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function sa({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}=ie(Kg,le),x=Ig(t);return g.jsxs("div",{className:"react-flow__edges",children:[g.jsx(Rg,{defaultColor:e,rfId:n}),x.map(N=>g.jsx(Xg,{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))]})}sa.displayName="EdgeRenderer";const qg=b.memo(sa),Gg=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Ug({children:e}){const t=ie(Gg);return g.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function Zg(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 Jg(e){const t=ie(Qg),n=ue();return b.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function ep(e){return e.connection.inProgress?{...e.connection,to:Ct(e.connection.to,e.transform)}:{...e.connection}}function tp(e){return ep}function np(e){const t=tp();return ie(t,le)}const rp=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function sp({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:i,isValid:a,inProgress:c}=ie(rp,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:he(["react-flow__connection",ti(a)]),children:g.jsx(oa,{style:t,type:n,CustomComponent:r,isValid:a})})})}const oa=({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}=np();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:ti(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]=hi(v);break;case Ue.SimpleBezier:[p]=Xi(v);break;case Ue.Step:[p]=Nr({...v,borderRadius:0});break;case Ue.SmoothStep:[p]=Nr(v);break;default:[p]=pi(v)}return g.jsx("path",{d:p,fill:"none",className:"react-flow__connection-path",style:e})};oa.displayName="ConnectionLine";const op={};function ao(e=op){b.useRef(e),ue(),b.useEffect(()=>{},[e])}function ip(){ue(),b.useRef(!1),b.useEffect(()=>{},[])}function ia({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:D,deleteKeyCode:T,onlyRenderVisibleElements:R,elementsSelectable:F,defaultViewport:M,translateExtent:I,minZoom:V,maxZoom:_,preventScrolling:C,defaultMarkerColor:S,zoomOnScroll:$,zoomOnPinch:L,panOnScroll:A,panOnScrollSpeed:O,panOnScrollMode:B,zoomOnDoubleClick:H,panOnDrag:Y,autoPanOnSelection:X,onPaneClick:ee,onPaneMouseEnter:J,onPaneMouseMove:Z,onPaneMouseLeave:j,onPaneScroll:W,onPaneContextMenu:ne,paneClickDistance:te,nodeClickDistance:q,onEdgeContextMenu:U,onEdgeMouseEnter:re,onEdgeMouseMove:ae,onEdgeMouseLeave:oe,reconnectRadius:ce,onReconnect:pe,onReconnectStart:Ne,onReconnectEnd:Se,noDragClassName:we,noWheelClassName:Oe,noPanClassName:Me,disableKeyboardA11y:Ce,nodeExtent:me,rfId:ve,viewport:be,onViewportChange:Be}){return ao(e),ao(t),ip(),Zg(n),Jg(be),g.jsx(bg,{onPaneClick:ee,onPaneMouseEnter:J,onPaneMouseMove:Z,onPaneMouseLeave:j,onPaneContextMenu:ne,onPaneScroll:W,paneClickDistance:te,deleteKeyCode:T,selectionKeyCode:E,selectionOnDrag:y,selectionMode:x,onSelectionStart:f,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:k,zoomActivationKeyCode:D,elementsSelectable:F,zoomOnScroll:$,zoomOnPinch:L,zoomOnDoubleClick:H,panOnScroll:A,panOnScrollSpeed:O,panOnScrollMode:B,panOnDrag:Y,autoPanOnSelection:X,defaultViewport:M,translateExtent:I,minZoom:V,maxZoom:_,onSelectionContextMenu:u,preventScrolling:C,noDragClassName:we,noWheelClassName:Oe,noPanClassName:Me,disableKeyboardA11y:Ce,onViewportChange:Be,isControlledViewport:!!be,children:g.jsxs(Ug,{children:[g.jsx(qg,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:i,onReconnect:pe,onReconnectStart:Ne,onReconnectEnd:Se,onlyRenderVisibleElements:R,onEdgeContextMenu:U,onEdgeMouseEnter:re,onEdgeMouseMove:ae,onEdgeMouseLeave:oe,reconnectRadius:ce,defaultMarkerColor:S,noPanClassName:Me,disableKeyboardA11y:Ce,rfId:ve}),g.jsx(sp,{style:v,type:p,component:w,containerStyle:m}),g.jsx("div",{className:"react-flow__edgelabel-renderer"}),g.jsx($g,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:a,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:d,nodeClickDistance:q,onlyRenderVisibleElements:R,noPanClassName:Me,noDragClassName:we,disableKeyboardA11y:Ce,nodeExtent:me,rfId:ve}),g.jsx("div",{className:"react-flow__viewport-portal"})]})})}ia.displayName="GraphView";const ap=b.memo(ia),cp=ii(),co=({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??Ot;xi(v,w,m);const{nodesInitialized:N}=kr(E,h,p,{nodeOrigin:y,nodeExtent:x,zIndexMode:f});let k=[0,0,1];if(i&&s&&o){const D=Gt(h,{filter:M=>!!((M.width||M.initialWidth)&&(M.height||M.initialHeight))}),{x:T,y:R,zoom:F}=Fr(D,s,o,c,l,(a==null?void 0:a.padding)??.1);k=[T,R,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:Ot,nodeExtent:x,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:bt.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:{...ei},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:cp,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:Jo,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},lp=({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})=>_h((h,p)=>{async function v(){const{nodeLookup:w,panZoom:m,fitViewOptions:E,fitViewResolver:y,width:x,height:N,minZoom:k,maxZoom:D}=p();m&&(await rf({nodes:w,width:x,height:N,panZoom:m,minZoom:k,maxZoom:D},E),y==null||y.resolve(!0),h({fitViewResolver:null}))}return{...co({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:D}=p(),{nodesInitialized:T,hasSelectedNodes:R}=kr(w,m,E,{nodeOrigin:y,nodeExtent:u,elevateNodesOnSelect:x,checkEquality:!0,zIndexMode:k}),F=D&&R;N&&T?(v(),h({nodes:w,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):h({nodes:w,nodesInitialized:T,nodesSelectionActive:F})},setEdges:w=>{const{connectionLookup:m,edgeLookup:E}=p();xi(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:D,fitViewQueued:T,zIndexMode:R}=p(),{changes:F,updatedInternals:M}=Mf(w,E,y,x,N,k,R);M&&(Ef(E,y,{nodeOrigin:N,nodeExtent:k,zIndexMode:R}),T?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(F==null?void 0:F.length)>0&&(D&&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:D,onNodesChangeMiddlewareMap:T}=p();for(const[R,F]of w){const M=x.get(R),I=!!(M!=null&&M.expandParent&&(M!=null&&M.parentId)&&(F!=null&&F.position)),V={id:R,type:"position",position:I?{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);D({...k,from:_})}I&&M.parentId&&E.push({id:R,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:R,nodeOrigin:F}=p(),M=Gr(E,x,R,F);y.push(...M)}for(const R of T.values())y=R(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=Fh(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=Wh(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(D=>et(D,!0));x(k);return}x(mt(y,new Set([...w]),!0)),N(mt(E))},addSelectedEdges:w=>{const{multiSelectionActive:m,edgeLookup:E,nodeLookup:y,triggerNodeChanges:x,triggerEdgeChanges:N}=p();if(m){const k=w.map(D=>et(D,!0));N(k);return}N(mt(E,new Set([...w]))),x(mt(y,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:m}={})=>{const{edges:E,nodes:y,nodeLookup:x,triggerNodeChanges:N,triggerEdgeChanges:k}=p(),D=w||y,T=m||E,R=[];for(const M of D){if(!M.selected)continue;const I=x.get(M.id);I&&(I.selected=!1),R.push(et(M.id,!1))}const F=[];for(const M of T)M.selected&&F.push(et(M.id,!1));N(R),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((D,T)=>T.selected?[...D,et(T.id,!1)]:D,[]),k=w.reduce((D,T)=>T.selected?[...D,et(T.id,!1)]:D,[]);E(N),y(k)},setNodeExtent:w=>{const{nodes:m,nodeLookup:E,parentLookup:y,nodeOrigin:x,elevateNodesOnSelect:N,nodeExtent:k,zIndexMode:D}=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]||(kr(m,E,y,{nodeOrigin:x,nodeExtent:w,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:D}),h({nodeExtent:w}))},panBy:w=>{const{transform:m,width:E,height:y,panZoom:x,translateExtent:N}=p();return Cf({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 D=typeof(E==null?void 0:E.zoom)<"u"?E.zoom:N;return await k.setViewport({x:y/2-w*D,y:x/2-m*D,zoom:D},{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:{...ei}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...co()})}},Object.is);function aa({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(()=>lp({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(Eh,{value:p,children:g.jsx(Uh,{children:h})})}function up({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(aa,{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 dp={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function fp({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:D,onNodeDrag:T,onNodeDragStop:R,onNodesDelete:F,onEdgesDelete:M,onDelete:I,onSelectionChange:V,onSelectionDragStart:_,onSelectionDrag:C,onSelectionDragStop:S,onSelectionContextMenu:$,onSelectionStart:L,onSelectionEnd:A,onBeforeDelete:O,connectionMode:B,connectionLineType:H=Ue.Bezier,connectionLineStyle:Y,connectionLineComponent:X,connectionLineContainerStyle:ee,deleteKeyCode:J="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:j=!1,selectionMode:W=Bt.Full,panActivationKeyCode:ne="Space",multiSelectionKeyCode:te=Wt()?"Meta":"Control",zoomActivationKeyCode:q=Wt()?"Meta":"Control",snapToGrid:U,snapGrid:re,onlyRenderVisibleElements:ae=!1,selectNodesOnDrag:oe,nodesDraggable:ce,autoPanOnNodeFocus:pe,nodesConnectable:Ne,nodesFocusable:Se,nodeOrigin:we=Ti,edgesFocusable:Oe,edgesReconnectable:Me,elementsSelectable:Ce=!0,defaultViewport:me=Rh,minZoom:ve=.5,maxZoom:be=2,translateExtent:Be=Ot,preventScrolling:Wn=!0,nodeExtent:dt,defaultMarkerColor:Re="#b1b1b7",zoomOnScroll:Zt=!0,zoomOnPinch:Qe=!0,panOnScroll:Qt=!1,panOnScrollSpeed:Jt=.5,panOnScrollMode:Je=st.Free,zoomOnDoubleClick:ft=!0,panOnDrag:ht=!0,onPaneClick:en,onPaneMouseEnter:Yn,onPaneMouseMove:Xn,onPaneMouseLeave:Kn,onPaneScroll:tn,onPaneContextMenu:qn,paneClickDistance:Gn=1,nodeClickDistance:z=0,children:K,onReconnect:G,onReconnectStart:se,onReconnectEnd:de,onEdgeContextMenu:P,onEdgeDoubleClick:ye,onEdgeMouseEnter:ge,onEdgeMouseMove:Ve,onEdgeMouseLeave:Ae,reconnectRadius:Un=10,onNodesChange:va,onEdgesChange:ba,noDragClassName:_a="nodrag",noWheelClassName:Ea="nowheel",noPanClassName:Jr="nopan",fitView:es,fitViewOptions:ts,connectOnClick:Na,attributionPosition:Sa,proOptions:ka,defaultEdgeOptions:Ma,elevateNodesOnSelect:Ca=!0,elevateEdgesOnSelect:Aa=!1,disableKeyboardA11y:ns=!1,autoPanOnConnect:$a,autoPanOnNodeDrag:Ia,autoPanOnSelection:ja=!0,autoPanSpeed:Pa,connectionRadius:Da,isValidConnection:Ta,onError:Ra,style:La,id:rs,nodeDragThreshold:za,connectionDragThreshold:Ha,viewport:Oa,onViewportChange:Ba,width:Va,height:Fa,colorMode:Wa="light",debug:Ya,onScroll:nn,ariaLabelConfig:Xa,zIndexMode:ss="basic",...Ka},qa){const Zn=rs||"1",Ga=Oh(Wa),Ua=b.useCallback(os=>{os.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),nn==null||nn(os)},[nn]);return g.jsx("div",{"data-testid":"rf__wrapper",...Ka,onScroll:Ua,style:{...La,...dp},ref:qa,className:he(["react-flow",s,Ga]),id:rs,role:"application",children:g.jsxs(up,{nodes:e,edges:t,width:Va,height:Fa,fitView:es,fitViewOptions:ts,minZoom:ve,maxZoom:be,nodeOrigin:we,nodeExtent:dt,zIndexMode:ss,children:[g.jsx(Hh,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:p,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:m,nodesDraggable:ce,autoPanOnNodeFocus:pe,nodesConnectable:Ne,nodesFocusable:Se,edgesFocusable:Oe,edgesReconnectable:Me,elementsSelectable:Ce,elevateNodesOnSelect:Ca,elevateEdgesOnSelect:Aa,minZoom:ve,maxZoom:be,nodeExtent:dt,onNodesChange:va,onEdgesChange:ba,snapToGrid:U,snapGrid:re,connectionMode:B,translateExtent:Be,connectOnClick:Na,defaultEdgeOptions:Ma,fitView:es,fitViewOptions:ts,onNodesDelete:F,onEdgesDelete:M,onDelete:I,onNodeDragStart:D,onNodeDrag:T,onNodeDragStop:R,onSelectionDrag:C,onSelectionDragStart:_,onSelectionDragStop:S,onMove:d,onMoveStart:u,onMoveEnd:f,noPanClassName:Jr,nodeOrigin:we,rfId:Zn,autoPanOnConnect:$a,autoPanOnNodeDrag:Ia,autoPanSpeed:Pa,onError:Ra,connectionRadius:Da,isValidConnection:Ta,selectNodesOnDrag:oe,nodeDragThreshold:za,connectionDragThreshold:Ha,onBeforeDelete:O,debug:Ya,ariaLabelConfig:Xa,zIndexMode:ss}),g.jsx(ap,{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:j,selectionMode:W,deleteKeyCode:J,multiSelectionKeyCode:te,panActivationKeyCode:ne,zoomActivationKeyCode:q,onlyRenderVisibleElements:ae,defaultViewport:me,translateExtent:Be,minZoom:ve,maxZoom:be,preventScrolling:Wn,zoomOnScroll:Zt,zoomOnPinch:Qe,zoomOnDoubleClick:ft,panOnScroll:Qt,panOnScrollSpeed:Jt,panOnScrollMode:Je,panOnDrag:ht,autoPanOnSelection:ja,onPaneClick:en,onPaneMouseEnter:Yn,onPaneMouseMove:Xn,onPaneMouseLeave:Kn,onPaneScroll:tn,onPaneContextMenu:qn,paneClickDistance:Gn,nodeClickDistance:z,onSelectionContextMenu:$,onSelectionStart:L,onSelectionEnd:A,onReconnect:G,onReconnectStart:se,onReconnectEnd:de,onEdgeContextMenu:P,onEdgeDoubleClick:ye,onEdgeMouseEnter:ge,onEdgeMouseMove:Ve,onEdgeMouseLeave:Ae,reconnectRadius:Un,defaultMarkerColor:Re,noDragClassName:_a,noWheelClassName:Ea,noPanClassName:Jr,rfId:Zn,disableKeyboardA11y:ns,nodeExtent:dt,viewport:Oa,onViewportChange:Ba}),g.jsx(Th,{onSelectionChange:V}),K,g.jsx($h,{proOptions:ka,position:Sa}),g.jsx(Ah,{rfId:Zn,disableKeyboardA11y:ns})]})})}var hp=Li(fp);function gp({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:he(["react-flow__background-pattern",n,r])})}function pp({radius:e,className:t}){return g.jsx("circle",{cx:e,cy:e,r:e,className:he(["react-flow__background-pattern","dots",t])})}var Ze;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ze||(Ze={}));const mp={[Ze.Dots]:1,[Ze.Lines]:1,[Ze.Cross]:6},yp=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ca({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}=ie(yp,le),p=r||mp[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],D=`${h}${e||""}`;return g.jsxs("svg",{className:he(["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:D,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(pp,{radius:y/2,className:d}):g.jsx(gp,{dimensions:N,lineWidth:s,variant:t,className:d})}),g.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${D})`})]})}ca.displayName="Background";b.memo(ca);function xp(){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 wp(){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 vp(){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 bp(){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 _p(){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:he(["react-flow__controls-button",t]),...n,children:e})}const Ep=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function la({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}=ie(Ep,le),{zoomIn:y,zoomOut:x,fitView:N}=Bn(),k=()=>{y(),o==null||o()},D=()=>{x(),i==null||i()},T=()=>{N(s),a==null||a()},R=()=>{p.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},F=f==="horizontal"?"horizontal":"vertical";return g.jsxs(On,{className:he(["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(xp,{})}),g.jsx(fn,{onClick:D,className:"react-flow__controls-zoomout",title:E["controls.zoomOut.ariaLabel"],"aria-label":E["controls.zoomOut.ariaLabel"],disabled:w,children:g.jsx(wp,{})})]}),n&&g.jsx(fn,{className:"react-flow__controls-fitview",onClick:T,title:E["controls.fitView.ariaLabel"],"aria-label":E["controls.fitView.ariaLabel"],children:g.jsx(vp,{})}),r&&g.jsx(fn,{className:"react-flow__controls-interactive",onClick:R,title:E["controls.interactive.ariaLabel"],"aria-label":E["controls.interactive.ariaLabel"],children:v?g.jsx(_p,{}):g.jsx(bp,{})}),d]})}la.displayName="Controls";b.memo(la);function Np({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:he(["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 Sp=b.memo(Np),kp=e=>e.nodes.map(t=>t.id),ar=e=>e instanceof Function?e:()=>e;function Mp({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=Sp,onClick:i}){const a=ie(kp,le),c=ar(t),l=ar(e),d=ar(n),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return g.jsx(g.Fragment,{children:a.map(f=>g.jsx(Ap,{id:f,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:i,shapeRendering:u},f))})}function Cp({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}=ie(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||!ai(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 Ap=b.memo(Cp);var $p=b.memo(Mp);const Ip=200,jp=150,Pp=e=>!e.hidden,Dp=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?oi(Gt(e.nodeLookup,{filter:Pp}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Tp="react-flow__minimap-desc";function ua({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:D,viewBB:T,rfId:R,panZoom:F,translateExtent:M,flowWidth:I,flowHeight:V,ariaLabelConfig:_}=ie(Dp,le),C=(e==null?void 0:e.width)??Ip,S=(e==null?void 0:e.height)??jp,$=D.width/C,L=D.height/S,A=Math.max($,L),O=A*C,B=A*S,H=x*A,Y=D.x-(O-D.width)/2-H,X=D.y-(B-D.height)/2-H,ee=O+H*2,J=B+H*2,Z=`${Tp}-${R}`,j=b.useRef(0),W=b.useRef();j.current=A,b.useEffect(()=>{if(k.current&&F)return W.current=Lf({domNode:k.current,panZoom:F,getTransform:()=>N.getState().transform,getViewScale:()=>j.current}),()=>{var U;(U=W.current)==null||U.destroy()}},[F]),b.useEffect(()=>{var U;(U=W.current)==null||U.update({translateExtent:M,width:I,height:V,inversePan:E,pannable:v,zoomStep:y,zoomable:w})},[v,w,E,y,M,I,V]);const ne=h?U=>{var oe;const[re,ae]=((oe=W.current)==null?void 0:oe.pointer(U))||[0,0];h(U,{x:re,y:ae})}:void 0,te=p?b.useCallback((U,re)=>{const ae=N.getState().nodeLookup.get(re).internals.userNode;p(U,ae)},[]):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:he(["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($p,{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${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}ua.displayName="MiniMap";b.memo(ua);const Rp=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Lp={[St.Line]:"right",[St.Handle]:"bottom-right"};function zp({nodeId:e,position:t,variant:n=St.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=Bi(),y=typeof e=="string"?e:E,x=ue(),N=b.useRef(null),k=n===St.Handle,D=ie(b.useCallback(Rp(k&&h),[k,h]),le),T=b.useRef(null),R=t??Lp[n];b.useEffect(()=>{if(!(!N.current||!y))return T.current||(T.current=Uf({domNode:N.current,nodeId:y,getStoreItems:()=>{const{nodeLookup:M,transform:I,snapGrid:V,snapToGrid:_,nodeOrigin:C,domNode:S}=x.getState();return{nodeLookup:M,transform:I,snapGrid:V,snapToGrid:_,nodeOrigin:C,paneDomNode:S}},onChange:(M,I)=>{const{triggerNodeChanges:V,nodeLookup:_,parentLookup:C,nodeOrigin:S}=x.getState(),$=[],L={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,...ci({x:M.x??A.position.x,y:M.y??A.position.y},{width:B,height:H},A.parentId,_,O)}},X=Gr([Y],_,C,S);$.push(...X),L.x=M.x?Math.max(O[0]*B,M.x):void 0,L.y=M.y?Math.max(O[1]*H,M.y):void 0}if(L.x!==void 0&&L.y!==void 0){const O={id:y,type:"position",position:{...L}};$.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}};$.push(B)}for(const O of I){const B={...O,type:"position"};$.push(B)}V($)},onEnd:({width:M,height:I})=>{const V={id:y,type:"dimensions",resizing:!1,dimensions:{width:M,height:I}};x.getState().triggerNodeChanges([V])}})),T.current.update({controlPosition:R,boundaries:{minWidth:a,minHeight:c,maxWidth:l,maxHeight:d},keepAspectRatio:u,resizeDirection:f,onResizeStart:v,onResize:w,onResizeEnd:m,shouldResize:p}),()=>{var M;(M=T.current)==null||M.destroy()}},[R,a,c,l,d,u,v,w,m,p]);const F=R.split("-");return g.jsx("div",{className:he(["react-flow__resize-control","nodrag",...F,n,r]),ref:N,style:{...s,scale:D,...i&&{[k?"backgroundColor":"borderColor"]:i}},children:o})}b.memo(zp);function Hp(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 Op=4,lo={isConnectable:!1,isConnectableStart:!1,isConnectableEnd:!1,style:{pointerEvents:"none"},"aria-hidden":!0};function Bp({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,Op),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(sc,{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 Vp({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 Fp({data:e,selected:t}){const n=Xe(),r=ot[e.status]||ot.pending,s=Hp(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":hr(i.seed)}:void 0,children:[g.jsx(Mt,{type:"target",position:Q.Left,...lo}),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:wo[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(Vp,{issues:e.openIssues,t:n}),g.jsx(rc,{scenarios:e.scenarios,evals:e.evals}),g.jsx(Bp,{data:e})]}),e.collapsed&&g.jsxs("span",{className:"node-expand","data-tip":n("specNode.expandable",{n:e.childCount}),children:["▸",e.childCount]}),g.jsx(Mt,{type:"source",position:Q.Right,...lo})]})}const cr=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 Wp(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 cr.push(r),()=>{const s=cr.indexOf(r);s>=0&&cr.splice(s,1)}},[e])}function Yp({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]),Wp(!!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:gr[u.status]},"aria-hidden":"true",children:oc[u.status]}),Ir(u)]},u.id))]})}let lr=null;function da(e=!0){const[t,n]=b.useState(lr),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=>{lr={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(lr)}).catch(()=>{}))},[e]),t}const Xp={pass:"✓",fail:"✗",stalePass:"✓",staleFail:"✗",empty:"○",missing:"·"};function Kp({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(bo(e,t.name)),"data-tip":r("focusPanel.openEval"),children:[g.jsx("span",{className:"fp-sc-mark","data-tip":r(`score.${t.state}`),children:Xp[t.state]}),g.jsxs("span",{className:"fp-sc-body",children:[g.jsx("span",{className:"fp-sc-name",children:t.name}),g.jsx(vo,{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 qp({node:e,onNavigateAddress:t}){var d;const n=Xe(),r=jr(e==null?void 0:e.scenarios,e==null?void 0:e.evals),s=da(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 ${ic(r)}`,children:["✓",i,"/",r.length]})]}),r.length?r.map(u=>g.jsx(Kp,{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(is,{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(is,{issue:u,onNavigateAddress:t},u.id))]}):g.jsx("div",{className:"fp-empty",children:n("focusPanel.noIssues")})]})]})}function Gp({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(ac,{icon:"x",size:13,className:"legend-close",label:t,onClick:n})]}),g.jsx("div",{className:"legend-body",children:s})]})})}const fa=[{id:"nav.up",keys:["ArrowUp","k","K"],rebind:!1,desc:"legend.board.move"},{id:"nav.down",keys:["ArrowDown","j","J"],rebind:!1,desc:"legend.board.move"},{id:"nav.parent",keys:["ArrowLeft","h","H"],rebind:!1,desc:"legend.board.parent"},{id:"nav.child",keys:["ArrowRight","l","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"}],Up={ArrowUp:"↑",ArrowDown:"↓",ArrowLeft:"←",ArrowRight:"→",Enter:"⏎",Escape:"esc"," ":"␣","-":"−"},Ar=e=>Up[e]||e,Zr="spex.keybindings.v1",Zp=Object.fromEntries(fa.map(e=>[e.id,e]));function Qp(){try{return JSON.parse(localStorage.getItem(Zr))||{}}catch{return{}}}let nt=Qp();function Qr(e){var n;const t=nt[e];return t&&t.keys||((n=Zp[e])==null?void 0:n.keys)||[]}function Um(e){return!!nt[e]}function fe(e,t){return Qr(e).includes(t)}function Zm(e,t){nt={...nt,[e]:{...nt[e],...t}},localStorage.setItem(Zr,JSON.stringify(nt))}function Qm(){nt={},localStorage.removeItem(Zr)}const Jp=new Set(["=","_","I","H","J","K","L"]),em=(()=>{const e=[];for(const t of fa){const n=Qr(t.id).filter(s=>!Jp.has(s)).map(Ar),r=e[e.length-1];r&&r.desc===t.desc?r.keys.push(...n):e.push({desc:t.desc,keys:n})}return e})(),tm=[[["←","→","h","l","⇥","1","2"],"legend.popup.switch"],[["j","k","↑","↓"],"legend.popup.scroll"],[["⇧h","⇧j","⇧k","⇧l","⇧←↑↓→"],"legend.popup.lens"],[["⏎"],"legend.popup.enter"],[["esc"],"legend.popup.esc"]],nm=["merged","active","drift","pending"],rm=["added","edited","deleted","moved"];function sm({t:e}){return g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:e("legend.secBoard")}),em.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 om({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 im({onClose:e}){const t=Xe();return g.jsxs(Gp,{title:t("legend.title"),closeLabel:t("legend.close"),onClose:e,children:[g.jsx(sm,{t}),g.jsx(om,{title:t("legend.secPopup"),rows:tm,t}),g.jsxs("section",{className:"legend-sec",children:[g.jsx("div",{className:"legend-h",children:t("legend.secStatus")}),nm.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")})]}),rm.map(n=>g.jsxs("div",{className:"legend-row",children:[g.jsx("span",{className:`ov-mark ov-${n}`,children:wo[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 am=8,cm=5,lm=2,um=1,dm=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"]),ha="\\u3400-\\u4dbf\\u4e00-\\u9fff\\uf900-\\ufaff\\u3040-\\u30ff",fm=new RegExp(`[a-z0-9]+|[${ha}]`,"g"),hm=new RegExp(`[${ha}]`);function ga(e){return hm.test(e)}function pa(e){return e.toLowerCase().match(fm)??[]}function gm(e){const t=new Set;for(const n of pa(e))(ga(n)||n.length>1&&!dm.has(n))&&t.add(n);return[...t]}function ur(e){return pa(e)}function ma(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 ya(e,t){return t.startsWith(ma(e))}function Cn(e,t){return t.startsWith(ma(e))||t.length>=3&&e.startsWith(t)}const uo=1.2,fo=.4;function ho(e,t,n){return e<=0?0:e*(uo+1)/(e+uo*(1-fo+fo*t/(n||1)))}function pm(e,t,n,r){if(t.nameWords.some(o=>ya(e,o)))return am;if(t.name.includes(e))return cm;if(t.descWords.some(o=>Cn(e,o)))return lm*ho(1,t.descWords.length,r);const s=t.bodyWords.reduce((o,i)=>o+(Cn(e,i)?1:0),0);return um*ho(s,t.bodyWords.length,n)}function mm(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=ga(l)?o.indexOf(l):o.search(new RegExp("\\b"+l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")));d>=0&&(i<0||d<i)&&(i=d)}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 ym(e,t,n={}){const r=n.limit??10,s=gm(e);if(!s.length)return[];const o=t.map(u=>{const f=u.name.toLowerCase();return{ref:u.ref,name:f,nameWords:ur(f),desc:u.desc.toLowerCase(),descWords:ur(u.desc),bodyWords:ur(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=>ya(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+=pm(h,u,a,c)*l[h];f<=0||d.push({ref:u.ref,score:Math.round(f*100)/100,snippet:mm(u.snippetText,u.desc,s)})}return d.sort((u,f)=>f.score-u.score),d.slice(0,r)}const xm={pass:"var(--green)",fail:"var(--red)",stalePass:"var(--muted)",staleFail:"var(--muted)",empty:"var(--muted)",missing:"var(--muted)"},wm=e=>(e||"").replace(/^\.spec\//,"").replace(/\/spec\.md$/,""),go=["spec","session","issue","scenario"],vm=e=>e?[e,...go.filter(t=>t!==e)]:go;function bm(e,t,n){var o,i;const r=n==null?void 0:n.bodies,s=[];for(const a of e){const c=wm(a.path);s.push({kind:"spec",key:`spec:${a.id}`,target:a.id,address:cc(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:lc(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 jr(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:bo(a.id,l.name),color:xm[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=Ir(a),l=uc(a),d=a.status||a.promptPreview||a.note||"";s.push({kind:"session",key:`session:${a.id}`,target:a.id,address:dc(a.id),color:gr[a.status]||gr.offline,title:c,sub:d,name:c||"",desc:a.status||"",body:`${a.promptPreview||a.note||""} ${l}`.trim()})}return s}function _m(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]=ym(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 Em({specs:e,sessions:t,onPick:n,onClose:r,boost:s=null}){const o=Xe(),i=da(),[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(()=>vm(s),[s]),w=b.useMemo(()=>bm(e,t,i),[e,t,i]),m=b.useMemo(()=>_m(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(vo,{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 xa(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 Nm=["merged","active","drift","pending"],Sm=[{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 km(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 jr(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(xa(t,n)):void 0,children:[i,e]})}function Mm({specs:e,focusId:t,onJump:n}){const r=Xe(),s=b.useMemo(()=>km(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}),Nm.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"}),Sm.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(fc,{state:i})},i)})]})}const Cm=["graph","sessions","evals","issues"];function po({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(hc,{name:e,size:18})})}function Am({page:e,onNav:t}){const n=Xe();return g.jsxs("nav",{className:"side-rail","aria-label":n("nav.railLabel"),children:[Cm.map(r=>g.jsx(po,{page:r,active:e===r,onNav:t,label:n(`nav.${r}`)},r)),g.jsx("div",{className:"rail-spacer"}),g.jsx(po,{page:"settings",active:e==="settings",onNav:t,label:n("nav.settings")})]})}const $m=400,Im=80,dr=7,fr=6;function jm(){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?Im:$m)},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-dr>=fr?"top":"bottom",u=d==="top"?c.top-l.height-dr:c.bottom+dr,f=Math.min(Math.max(c.left+c.width/2-l.width/2,fr),window.innerWidth-l.width-fr);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?Ja.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 Pm(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 mo(){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 $r=null;const Dm=e=>!!(e&&e.closest&&e.closest("[data-focus-overlay]")),yo=e=>!!(e&&e.isConnected&&!e.disabled&&e.getClientRects().length);typeof window<"u"&&window.addEventListener("focusin",e=>{const t=e.target;t&&t!==document.body&&!Dm(t)&&($r=t)},!0);function Tm(){requestAnimationFrame(()=>{if(yo($r)){$r.focus();return}const e=document.querySelector("[data-focus-sink]");yo(e)&&e.focus()})}function Rm(e){return e>1}function Lm(e){return{next:Ar((e("board.cycle")||[])[0]||"o"),prev:Ar((e("board.cycleRev")||[])[0]||"O")}}const zm=b.lazy(()=>An(()=>import("./SessionInterface-D1pUBl6q.js"),__vite__mapDeps([0,1,2,3,4,5,6]))),Hm=b.lazy(()=>An(()=>import("./EvalsPage-BzVE38-Z.js").then(e=>e.b),__vite__mapDeps([4,1,2,3,5]))),Om=b.lazy(()=>An(()=>import("./IssuesPage-CzDaazhe.js"),__vite__mapDeps([7,1,2,3,5]))),Bm=b.lazy(()=>An(()=>import("./Settings-R610Vbzd.js"),__vite__mapDeps([8,1,2,3]))),Vm={spec:Fp},Fm=220,Wm=46,xo=e=>Math.max(.4,Math.min(1.6,e)),Pt={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: `},wa=Object.keys(Pt),Ym=new Set(wa.map(e=>e[0]));function Xm({specs:e,sessions:t,reload:n,project:r,issuesData:s,reloadIssues:o}){const{page:i,param:a}=gc(),[c,l]=b.useState(()=>{var K;let z=null;try{z=sessionStorage.getItem("spex.focus")}catch{}return(z&&e.some(G=>G.id===z)?z:null)||((K=e.find(G=>!G.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,D]=b.useState(null),[T,R]=b.useState(null),{getViewport:F,setViewport:M}=Bn(),I=Xe(),V=b.useRef(null),_=b.useRef(0),C=b.useRef({buf:"",timer:0}),[S,$]=b.useState(!1),L=b.useRef(!1);L.current=S;const A=b.useRef({x:-1,y:-1}),O=b.useMemo(()=>mo(),[]),B=b.useMemo(()=>mo(),[]),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(()=>ec(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]),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]),U=b.useMemo(()=>x?q:ne,[x,q,ne]),re=Lm(Qr),ae=b.useCallback(z=>z?t.filter(K=>{var G;return(G=K.ops)==null?void 0:G.some(se=>se.nodeId===z.id)}):[],[t]),oe=b.useCallback(z=>{y(z),ke("sessions",z)},[]),ce=b.useCallback(z=>{y("new"),D(z),ke("sessions","new")},[]),pe=b.useCallback(z=>{pc(z,{onFocusNode:l,onOpenSession:oe})},[oe]),Ne=b.useMemo(()=>{var G;if(!T)return[];const z=e.find(se=>se.id===T.id);return(G=z==null?void 0:z.overlays)!=null&&G.length?[...new Set(z.overlays.map(se=>se.source))].map(se=>t.find(de=>de.source===se)).filter(Boolean):[]},[T,e,t]),Se=b.useCallback(z=>{pe(z.address)},[pe]);b.useLayoutEffect(()=>{i==="sessions"&&a&&a!==E&&y(a)},[i,a]),b.useEffect(()=>{i==="sessions"&&ke("sessions",E,{replace:!0})},[i,E]),b.useEffect(()=>{i!=="graph"&&(u(!1),v(!1),m(null),R(null))},[i]);const we=b.useMemo(()=>J.filter(z=>z.parent===j.id),[J,j]),Oe=j.parent?Z[j.parent]:null,Me=b.useMemo(()=>we.length?we.reduce((z,K)=>Math.abs(K.y-j.y)<Math.abs(z.y-j.y)?K:z):null,[we,j]),Ce=b.useMemo(()=>{if(Me)return Me;let z=null,K=1/0;for(const G of J){const se=G.x-j.x;if(se<=0)continue;const de=G.y-j.y,P=(se/tc)**2+(de/nc)**2;P<K&&(K=P,z=G)}return z},[Me,J,j]),me=b.useCallback(z=>{let K=null;for(const G of J){if(G.id===j.id||G.x!==j.x)continue;const se=G.y-j.y;(z==="down"?se<=0:se>=0)||(!K||Math.abs(se)<Math.abs(K.y-j.y))&&(K=G)}return K},[J,j]),ve=b.useMemo(()=>me("down"),[me]),be=b.useMemo(()=>me("up"),[me]),Be=b.useMemo(()=>J.map(z=>{const K=z.id===c||z.id===j.parent||z.parent===c||z.parent===j.parent;let G;x&&q.length?G=(z.overlays||[]).some(ge=>ge.source===x)?"ov-hot":"ov-dim":G=K?void 0:"is-far";const de=ae(z).map(ge=>({id:ge.id,status:ge.status,node:ge.node})),P=W[z.id]||0,ye={editors:de,collapsed:P>0&&!X.has(z.id),childCount:P};return{id:z.id,type:"spec",position:{x:z.x,y:z.y},data:{...z,...ye},draggable:!1,selected:z.id===c,className:G}}),[c,j.parent,x,q,J,ae,W,X]),Wn=b.useMemo(()=>{const z=J.filter(G=>G.parent).map(G=>{const se=G.id===c||G.parent===c;return{id:`${G.parent}-${G.id}`,source:G.parent,target:G.id,type:"smoothstep",style:{stroke:se?"var(--blue)":"var(--line)",strokeWidth:se?2:1},zIndex:se?1:0}}),K=[];for(const G of J){const se=(G.overlays||[]).find(P=>P.op==="moved"&&P.toParent&&Z[P.toParent]);if(!se)continue;const de=hr(se.seed);K.push({id:`move-${G.id}-${se.toParent}`,source:G.id,target:se.toParent,type:"smoothstep",animated:!0,zIndex:2,className:"move-edge",style:{stroke:de,strokeWidth:1.5,strokeDasharray:"4 4",opacity:.6},markerEnd:{type:Vt.ArrowClosed,color:de,width:14,height:14}})}return[...z,...K]},[c,J,Z]),dt=b.useCallback((z,K)=>{const G=F(),se=performance.now();cancelAnimationFrame(_.current);const de=P=>{const ye=K?Math.min(1,(P-se)/K):1,ge=1-Math.pow(1-ye,3);M({x:G.x+(z.x-G.x)*ge,y:G.y+(z.y-G.y)*ge,zoom:G.zoom+(z.zoom-G.zoom)*ge}),ye<1&&(_.current=requestAnimationFrame(de))};_.current=requestAnimationFrame(de)},[F,M]),Re=b.useCallback((z,K,G=300)=>{const se=V.current;if(!se)return;const de=K??F().zoom;dt({x:se.clientWidth/2-(z.x+Fm/2)*de,y:se.clientHeight/2-(z.y+Wm/2)*de,zoom:de},G)},[dt,F]),Zt=b.useRef(!1);b.useEffect(()=>{if(Zt.current||i!=="graph")return;Zt.current=!0;const z=requestAnimationFrame(()=>Re(j,void 0,0));return()=>cancelAnimationFrame(z)},[Re,j,i]);const Qe=b.useRef(j);Qe.current=j;const Qt=b.useRef(Re);Qt.current=Re;const Jt=b.useRef(!1),Je=b.useRef(!1),ft=b.useRef(null);b.useEffect(()=>{if(i==="graph"){if(!Jt.current){Jt.current=!0,ft.current=c;return}if(Je.current){Je.current=!1,ft.current=c;return}ft.current!==c&&(ft.current=c,Qt.current(Qe.current))}},[c,i]);const ht=d||p||!!w,en=b.useRef(ht);b.useEffect(()=>{en.current&&!ht&&Tm(),en.current=ht},[ht]),b.useEffect(()=>{const z=mc(j).map(P=>P.key),K=P=>h(ye=>{const ge=z.indexOf(ye);return z[((ge<0?0:ge)+P+z.length)%z.length]}),G=(P,ye)=>{P&&(ye.preventDefault(),ye.stopPropagation(),$(!0),l(P.id))},se=P=>O(document.querySelector(".ov-body .pane-doc, .ov-body .pane-hist, .ov-body .pane-issues, .ov-body .pane-eval, .ov-body .pane-edit"),P),de=P=>{var ye,ge;if(P.altKey&&!P.metaKey&&!P.ctrlKey){const Ae={Digit1:"graph",Digit2:"sessions",Digit3:"evals",Digit4:"issues",Digit5:"settings"}[P.code];if(Ae){P.preventDefault(),P.stopPropagation(),m(null),ke(Ae);return}if(P.code==="KeyN"){P.preventDefault(),P.stopPropagation(),m(null),y("new"),ke("sessions","new");return}if(P.code==="KeyF"){P.preventDefault(),P.stopPropagation(),m(null),ke("evals");return}}if(w){P.key==="Escape"&&(P.preventDefault(),P.stopPropagation(),m(null));return}if((P.metaKey||P.ctrlKey)&&P.key==="/"){P.preventDefault(),P.stopPropagation(),m("sessions");return}if(!(P.metaKey||P.ctrlKey||P.altKey)&&!((P.key==="Enter"||P.key===" ")&&((ge=(ye=P.target)==null?void 0:ye.closest)!=null&&ge.call(ye,"button, a[href], input, select, textarea, summary")))&&i!=="sessions"&&!(i==="evals"||i==="issues")){if(i==="settings"){fe("board.settings",P.key)&&(P.preventDefault(),P.stopPropagation(),ke("graph"));return}if(d){if(P.key==="Escape"){P.preventDefault(),u(!1);return}if(P.shiftKey){if(fe("nav.up",P.key))return G(be,P);if(fe("nav.down",P.key))return G(ve,P);if(fe("nav.parent",P.key))return G(Oe,P);if(fe("nav.child",P.key))return G(Ce,P)}if(P.key==="Tab"){P.preventDefault(),P.stopPropagation(),K(P.shiftKey?-1:1);return}if(P.key==="ArrowLeft"||P.key==="h"){P.preventDefault(),P.stopPropagation(),K(-1);return}if(P.key==="ArrowRight"||P.key==="l"){P.preventDefault(),P.stopPropagation(),K(1);return}if(/^[1-9]$/.test(P.key)&&+P.key<=z.length){P.preventDefault(),P.stopPropagation(),h(z[+P.key-1]);return}if(P.key==="j"||P.key==="k"||P.key==="ArrowDown"||P.key==="ArrowUp"){P.preventDefault(),P.stopPropagation(),se(P.key==="j"||P.key==="ArrowDown"?120:-120);return}return}if(p){if(P.key==="Escape"||P.key==="?"){P.preventDefault(),v(!1);return}if(P.key==="j"||P.key==="k"||P.key==="ArrowDown"||P.key==="ArrowUp"){P.preventDefault(),P.stopPropagation(),B(document.querySelector(".legend"),P.key==="j"||P.key==="ArrowDown"?120:-120);return}return}if(fe("board.help",P.key)){P.preventDefault(),v(!0);return}if(P.key==="Escape"&&x){P.preventDefault(),P.stopPropagation(),N(null);return}if(fe("board.settings",P.key)){P.preventDefault(),ke("settings");return}if(fe("board.search",P.key)){P.preventDefault(),P.stopPropagation(),m("board");return}if(!P.metaKey&&!P.ctrlKey&&!P.altKey&&/^[a-zA-Z]$/.test(P.key)){const Ve=C.current;if(Ve.buf||Ym.has(P.key)){clearTimeout(Ve.timer);const Ae=Ve.buf+P.key;if(Pt[Ae]){P.preventDefault(),P.stopPropagation(),C.current={buf:"",timer:0},ce(Pt[Ae](j.id));return}if(wa.some(Un=>Un.startsWith(Ae))){P.preventDefault(),P.stopPropagation(),C.current={buf:Ae,timer:setTimeout(()=>{C.current={buf:"",timer:0}},700)};return}C.current={buf:"",timer:0}}}if(fe("nav.up",P.key))return G(be,P);if(fe("nav.down",P.key))return G(ve,P);if(fe("nav.parent",P.key))return G(Oe,P);if(fe("nav.child",P.key))return G(Ce,P);if(fe("board.zoomIn",P.key))P.preventDefault(),$(!0),Re(j,xo(F().zoom*1.2),160);else if(fe("board.zoomOut",P.key))P.preventDefault(),$(!0),Re(j,xo(F().zoom/1.2),160);else if(fe("board.zoomReset",P.key))P.preventDefault(),$(!0),Re(j,.85,200);else if(fe("board.info",P.key))P.preventDefault(),u(!0);else if(fe("board.cycle",P.key)||fe("board.cycleRev",P.key)){if(P.preventDefault(),!U.length)return;$(!0);const Ve=xa(U,j.id,fe("board.cycleRev",P.key)?-1:1,Ae=>Ae.id);Ve&&l(Ve.id)}else fe("board.fresh",P.key)?(P.preventDefault(),ce(`[[${j.id}]] `)):fe("board.evals",P.key)&&(P.preventDefault(),ke("evals"))}};return window.addEventListener("keydown",de,!0),()=>window.removeEventListener("keydown",de,!0)},[d,i,p,w,x,j,U,be,ve,Ce,Oe,Re,F,oe,ce,O,B]),b.useEffect(()=>{const z=K=>{const G=A.current,se=K.clientX!==G.x||K.clientY!==G.y;G.x=K.clientX,G.y=K.clientY,se&&L.current&&$(!1)};return window.addEventListener("mousemove",z,!0),()=>window.removeEventListener("mousemove",z,!0)},[]);const Yn=b.useCallback((z,K)=>{K.id!==Qe.current.id&&(Je.current=!0),l(K.id)},[]),Xn=b.useCallback((z,K)=>{K.id!==Qe.current.id&&(Je.current=!0),l(K.id),u(!0)},[]),Kn=b.useCallback((z,K)=>{z.preventDefault(),K.id!==Qe.current.id&&(Je.current=!0),l(K.id),R({x:z.clientX,y:z.clientY,id:K.id})},[]),tn=b.useCallback((z,K=!0)=>{const G=K&&x===z.source;if(N(G?null:z.source),G)return;const se=new Set((z.ops||[]).map(P=>P.nodeId)),de=e.find(P=>se.has(P.id));de&&l(de.id)},[x,e]),[qn,Gn]=Pm("spex.fpWidth",250,{min:190,max:520,dir:-1});return g.jsxs("div",{className:S?"app kbd-mode":"app",children:[g.jsx(jm,{}),g.jsx(Am,{page:i,onNav:ke}),g.jsxs("div",{className:"app-main",children:[g.jsxs("div",{className:"page-graph",style:{"--fp-w":`${qn}px`,display:i==="graph"?void 0:"none"},children:[g.jsxs("div",{className:"graph",ref:V,children:[g.jsx(hp,{nodes:Be,edges:Wn,nodeTypes:Vm,onNodeClick:Yn,onNodeDoubleClick:Xn,onNodeContextMenu:Kn,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":I("hud.helpTitle"),children:"?"})]}),g.jsx(yc,{sessions:t,activeId:x,onPick:tn,onOpenSession:oe}),g.jsx(Mm,{specs:e,focusId:c,onJump:l}),g.jsx(Yp,{menu:T,onClose:()=>R(null),onInfo:()=>u(!0),onFresh:z=>ce(`[[${z}]] `),onNewChild:z=>ce(Pt.nn(z)),onDelete:z=>ce(Pt.dd(z)),sessions:Ne,onOpenSession:oe}),te&&g.jsxs("div",{className:"lock-hint",style:{"--ov":hr(te.id)},children:[g.jsxs("span",{className:"lock-hint-lead",children:[g.jsx(xc,{})," ",Ir(te)]}),q.length?g.jsx("span",{className:"lock-hint-body",children:Rm(q.length)?g.jsxs(g.Fragment,{children:[I("lockHint.cycleBefore"),g.jsx("kbd",{children:re.next}),I("lockHint.cycleNext"),g.jsx("span",{className:"lock-hint-sep",children:" / "}),g.jsx("kbd",{children:re.prev}),I("lockHint.cyclePrev"),I("lockHint.cycleAfter",{n:q.length})]}):I("lockHint.singleChanged")}):g.jsx("span",{className:"lock-hint-body",children:I("lockHint.empty")}),g.jsx("button",{className:"lock-hint-release",onClick:()=>N(null),"data-tip":I("lockHint.releaseTitle"),children:I("lockHint.release")})]}),p&&g.jsx(im,{onClose:()=>v(!1)})]}),g.jsx("div",{className:"pane-resizer",onMouseDown:Gn,role:"separator","aria-orientation":"vertical"}),g.jsx(qp,{node:j,onNavigateAddress:pe})]}),d&&g.jsx(wc,{node:j,pane:f,setPane:h,onClose:()=>u(!1)},j.id),g.jsx(b.Suspense,{fallback:null,children:g.jsx(zm,{sessions:t,specs:e,focusNode:j,open:i==="sessions",searchOpen:!!w,sel:E,setSel:y,seed:k,onSeedConsumed:()=>D(null),onClose:()=>ke("graph"),onPickSession:tn,onOpenSession:oe,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:I("hud.loading")}),children:g.jsx(Hm,{specs:e,sessions:t,reloadBoard:n,onOpenSession:oe})})}),i==="issues"&&g.jsx("div",{className:"page-pane page-issues",children:g.jsx(b.Suspense,{fallback:g.jsx("div",{className:"loading",children:I("hud.loading")}),children:g.jsx(Om,{specs:e,sessions:t,issuesData:s,reloadIssues:o,issueId:a,onOpenSession:oe,onFocusNode:z=>{l(z),ke("graph")}})})}),i==="settings"&&g.jsx(b.Suspense,{fallback:g.jsx("div",{className:"loading",children:I("hud.loading")}),children:g.jsx(Bm,{})}),w&&g.jsx(Em,{specs:e,sessions:t,onPick:Se,onClose:()=>m(null),boost:w==="sessions"?"session":null})]})]})}function Km(e){return g.jsx(aa,{children:g.jsx(Xm,{...e})})}const Jm=Object.freeze(Object.defineProperty({__proto__:null,default:Km},Symbol.toStringTag,{value:"Module"}));export{fa as A,Jm as D,Gp as M,Pm as a,Ar as b,Um as i,Qr as k,Qm as r,Zm as s,Wp as u};
|