agent-dag 1.35.22 → 1.35.24

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.
@@ -54,7 +54,7 @@ Error generating stack: `+x.message+`
54
54
  * This source code is licensed under the MIT license found in the
55
55
  * LICENSE file in the root directory of this source tree.
56
56
  */var Ww;function ij(){if(Ww)return Ad;Ww=1;var e=Na(),n=sj();function r(p,d){return p===d&&(p!==0||1/p===1/d)||p!==p&&d!==d}var i=typeof Object.is=="function"?Object.is:r,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,h=e.useDebugValue;return Ad.useSyncExternalStoreWithSelector=function(p,d,m,y,w){var N=l(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function S(O){if(!k){if(k=!0,E=O,O=y(O),w!==void 0&&_.hasValue){var A=_.value;if(w(A,O))return T=A}return T=O}if(A=T,i(E,O))return A;var U=y(O);return w!==void 0&&w(A,U)?(E=O,A):(E=O,T=U)}var k=!1,E,T,I=m===void 0?null:m;return[function(){return S(d())},I===null?void 0:function(){return S(I())}]},[d,m,y,w]);var b=o(p,N[0],N[1]);return u(function(){_.hasValue=!0,_.value=b},[b]),h(b),b},Ad}var Vw;function oj(){return Vw||(Vw=1,jd.exports=ij()),jd.exports}var aj=oj();const lj=Dv(aj),uj={},Gw=e=>{let n;const r=new Set,i=(d,m)=>{const y=typeof d=="function"?d(n):d;if(!Object.is(y,n)){const w=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),r.forEach(N=>N(n,w))}},o=()=>n,h={setState:i,getState:o,getInitialState:()=>p,subscribe:d=>(r.add(d),()=>r.delete(d)),destroy:()=>{(uj?"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."),r.clear()}},p=n=e(i,o,h);return h},cj=e=>e?Gw(e):Gw,{useDebugValue:dj}=ue,{useSyncExternalStoreWithSelector:fj}=lj,hj=e=>e;function WE(e,n=hj,r){const i=fj(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,r);return dj(i),i}const Yw=(e,n)=>{const r=cj(e),i=(o,l=n)=>WE(r,o,l);return Object.assign(i,r),i},pj=(e,n)=>e?Yw(e,n):Yw;function Nt(e,n){if(Object.is(e,n))return!0;if(typeof e!="object"||e===null||typeof n!="object"||n===null)return!1;if(e instanceof Map&&n instanceof Map){if(e.size!==n.size)return!1;for(const[i,o]of e)if(!Object.is(o,n.get(i)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(n).length)return!1;for(const i of r)if(!Object.prototype.hasOwnProperty.call(n,i)||!Object.is(e[i],n[i]))return!1;return!0}var mj={value:()=>{}};function Tu(){for(var e=0,n=arguments.length,r={},i;e<n;++e){if(!(i=arguments[e]+"")||i in r||/[\s.]/.test(i))throw new Error("illegal type: "+i);r[i]=[]}return new lu(r)}function lu(e){this._=e}function gj(e,n){return e.trim().split(/^|\s+/).map(function(r){var i="",o=r.indexOf(".");if(o>=0&&(i=r.slice(o+1),r=r.slice(0,o)),r&&!n.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:i}})}lu.prototype=Tu.prototype={constructor:lu,on:function(e,n){var r=this._,i=gj(e+"",r),o,l=-1,u=i.length;if(arguments.length<2){for(;++l<u;)if((o=(e=i[l]).type)&&(o=vj(r[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<u;)if(o=(e=i[l]).type)r[o]=Kw(r[o],e.name,n);else if(n==null)for(o in r)r[o]=Kw(r[o],e.name,null);return this},copy:function(){var e={},n=this._;for(var r in n)e[r]=n[r].slice();return new lu(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var r=new Array(o),i=0,o,l;i<o;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],i=0,o=l.length;i<o;++i)l[i].value.apply(n,r)},apply:function(e,n,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,l=i.length;o<l;++o)i[o].value.apply(n,r)}};function vj(e,n){for(var r=0,i=e.length,o;r<i;++r)if((o=e[r]).name===n)return o.value}function Kw(e,n,r){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=mj,e=e.slice(0,i).concat(e.slice(i+1));break}return r!=null&&e.push({name:n,value:r}),e}var hv="http://www.w3.org/1999/xhtml";const Xw={svg:"http://www.w3.org/2000/svg",xhtml:hv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Ru(e){var n=e+="",r=n.indexOf(":");return r>=0&&(n=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),Xw.hasOwnProperty(n)?{space:Xw[n],local:e}:e}function yj(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===hv&&n.documentElement.namespaceURI===hv?n.createElement(e):n.createElementNS(r,e)}}function wj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function VE(e){var n=Ru(e);return(n.local?wj:yj)(n)}function xj(){}function Fv(e){return e==null?xj:function(){return this.querySelector(e)}}function _j(e){typeof e!="function"&&(e=Fv(e));for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=i[o]=new Array(u),h,p,d=0;d<u;++d)(h=l[d])&&(p=e.call(h,h.__data__,d,l))&&("__data__"in h&&(p.__data__=h.__data__),c[d]=p);return new _n(i,this._parents)}function bj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Sj(){return[]}function GE(e){return e==null?Sj:function(){return this.querySelectorAll(e)}}function kj(e){return function(){return bj(e.apply(this,arguments))}}function Ej(e){typeof e=="function"?e=kj(e):e=GE(e);for(var n=this._groups,r=n.length,i=[],o=[],l=0;l<r;++l)for(var u=n[l],c=u.length,h,p=0;p<c;++p)(h=u[p])&&(i.push(e.call(h,h.__data__,p,u)),o.push(h));return new _n(i,o)}function YE(e){return function(){return this.matches(e)}}function KE(e){return function(n){return n.matches(e)}}var Nj=Array.prototype.find;function Cj(e){return function(){return Nj.call(this.children,e)}}function Tj(){return this.firstElementChild}function Rj(e){return this.select(e==null?Tj:Cj(typeof e=="function"?e:KE(e)))}var jj=Array.prototype.filter;function Aj(){return Array.from(this.children)}function Ij(e){return function(){return jj.call(this.children,e)}}function Mj(e){return this.selectAll(e==null?Aj:Ij(typeof e=="function"?e:KE(e)))}function Oj(e){typeof e!="function"&&(e=YE(e));for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=i[o]=[],h,p=0;p<u;++p)(h=l[p])&&e.call(h,h.__data__,p,l)&&c.push(h);return new _n(i,this._parents)}function XE(e){return new Array(e.length)}function Pj(){return new _n(this._enter||this._groups.map(XE),this._parents)}function pu(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}pu.prototype={constructor:pu,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,n){return this._parent.insertBefore(e,n)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function Lj(e){return function(){return e}}function $j(e,n,r,i,o,l){for(var u=0,c,h=n.length,p=l.length;u<p;++u)(c=n[u])?(c.__data__=l[u],i[u]=c):r[u]=new pu(e,l[u]);for(;u<h;++u)(c=n[u])&&(o[u]=c)}function qj(e,n,r,i,o,l,u){var c,h,p=new Map,d=n.length,m=l.length,y=new Array(d),w;for(c=0;c<d;++c)(h=n[c])&&(y[c]=w=u.call(h,h.__data__,c,n)+"",p.has(w)?o[c]=h:p.set(w,h));for(c=0;c<m;++c)w=u.call(e,l[c],c,l)+"",(h=p.get(w))?(i[c]=h,h.__data__=l[c],p.delete(w)):r[c]=new pu(e,l[c]);for(c=0;c<d;++c)(h=n[c])&&p.get(y[c])===h&&(o[c]=h)}function Dj(e){return e.__data__}function Fj(e,n){if(!arguments.length)return Array.from(this,Dj);var r=n?qj:$j,i=this._parents,o=this._groups;typeof e!="function"&&(e=Lj(e));for(var l=o.length,u=new Array(l),c=new Array(l),h=new Array(l),p=0;p<l;++p){var d=i[p],m=o[p],y=m.length,w=zj(e.call(d,d&&d.__data__,p,i)),N=w.length,_=c[p]=new Array(N),b=u[p]=new Array(N),S=h[p]=new Array(y);r(d,m,_,b,S,w,n);for(var k=0,E=0,T,I;k<N;++k)if(T=_[k]){for(k>=E&&(E=k+1);!(I=b[E])&&++E<N;);T._next=I||null}}return u=new _n(u,i),u._enter=c,u._exit=h,u}function zj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Bj(){return new _n(this._exit||this._groups.map(XE),this._parents)}function Uj(e,n,r){var i=this.enter(),o=this,l=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),r==null?l.remove():r(l),i&&o?i.merge(o).order():o}function Hj(e){for(var n=e.selection?e.selection():e,r=this._groups,i=n._groups,o=r.length,l=i.length,u=Math.min(o,l),c=new Array(o),h=0;h<u;++h)for(var p=r[h],d=i[h],m=p.length,y=c[h]=new Array(m),w,N=0;N<m;++N)(w=p[N]||d[N])&&(y[N]=w);for(;h<o;++h)c[h]=r[h];return new _n(c,this._parents)}function Wj(){for(var e=this._groups,n=-1,r=e.length;++n<r;)for(var i=e[n],o=i.length-1,l=i[o],u;--o>=0;)(u=i[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function Vj(e){e||(e=Gj);function n(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var r=this._groups,i=r.length,o=new Array(i),l=0;l<i;++l){for(var u=r[l],c=u.length,h=o[l]=new Array(c),p,d=0;d<c;++d)(p=u[d])&&(h[d]=p);h.sort(n)}return new _n(o,this._parents).order()}function Gj(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function Yj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Kj(){return Array.from(this)}function Xj(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,l=i.length;o<l;++o){var u=i[o];if(u)return u}return null}function Qj(){let e=0;for(const n of this)++e;return e}function Zj(){return!this.node()}function Jj(e){for(var n=this._groups,r=0,i=n.length;r<i;++r)for(var o=n[r],l=0,u=o.length,c;l<u;++l)(c=o[l])&&e.call(c,c.__data__,l,o);return this}function eA(e){return function(){this.removeAttribute(e)}}function tA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function nA(e,n){return function(){this.setAttribute(e,n)}}function rA(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function sA(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function iA(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,r)}}function oA(e,n){var r=Ru(e);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((n==null?r.local?tA:eA:typeof n=="function"?r.local?iA:sA:r.local?rA:nA)(r,n))}function QE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function aA(e){return function(){this.style.removeProperty(e)}}function lA(e,n,r){return function(){this.style.setProperty(e,n,r)}}function uA(e,n,r){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,r)}}function cA(e,n,r){return arguments.length>1?this.each((n==null?aA:typeof n=="function"?uA:lA)(e,n,r??"")):co(this.node(),e)}function co(e,n){return e.style.getPropertyValue(n)||QE(e).getComputedStyle(e,null).getPropertyValue(n)}function dA(e){return function(){delete this[e]}}function fA(e,n){return function(){this[e]=n}}function hA(e,n){return function(){var r=n.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function pA(e,n){return arguments.length>1?this.each((n==null?dA:typeof n=="function"?hA:fA)(e,n)):this.node()[e]}function ZE(e){return e.trim().split(/^|\s+/)}function zv(e){return e.classList||new JE(e)}function JE(e){this._node=e,this._names=ZE(e.getAttribute("class")||"")}JE.prototype={add:function(e){var n=this._names.indexOf(e);n<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var n=this._names.indexOf(e);n>=0&&(this._names.splice(n,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function eN(e,n){for(var r=zv(e),i=-1,o=n.length;++i<o;)r.add(n[i])}function tN(e,n){for(var r=zv(e),i=-1,o=n.length;++i<o;)r.remove(n[i])}function mA(e){return function(){eN(this,e)}}function gA(e){return function(){tN(this,e)}}function vA(e,n){return function(){(n.apply(this,arguments)?eN:tN)(this,e)}}function yA(e,n){var r=ZE(e+"");if(arguments.length<2){for(var i=zv(this.node()),o=-1,l=r.length;++o<l;)if(!i.contains(r[o]))return!1;return!0}return this.each((typeof n=="function"?vA:n?mA:gA)(r,n))}function wA(){this.textContent=""}function xA(e){return function(){this.textContent=e}}function _A(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function bA(e){return arguments.length?this.each(e==null?wA:(typeof e=="function"?_A:xA)(e)):this.node().textContent}function SA(){this.innerHTML=""}function kA(e){return function(){this.innerHTML=e}}function EA(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function NA(e){return arguments.length?this.each(e==null?SA:(typeof e=="function"?EA:kA)(e)):this.node().innerHTML}function CA(){this.nextSibling&&this.parentNode.appendChild(this)}function TA(){return this.each(CA)}function RA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function jA(){return this.each(RA)}function AA(e){var n=typeof e=="function"?e:VE(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function IA(){return null}function MA(e,n){var r=typeof e=="function"?e:VE(e),i=n==null?IA:typeof n=="function"?n:Fv(n);return this.select(function(){return this.insertBefore(r.apply(this,arguments),i.apply(this,arguments)||null)})}function OA(){var e=this.parentNode;e&&e.removeChild(this)}function PA(){return this.each(OA)}function LA(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function $A(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function qA(e){return this.select(e?$A:LA)}function DA(e){return arguments.length?this.property("__data__",e):this.node().__data__}function FA(e){return function(n){e.call(this,n,this.__data__)}}function zA(e){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");return i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),{type:n,name:r}})}function BA(e){return function(){var n=this.__on;if(n){for(var r=0,i=-1,o=n.length,l;r<o;++r)l=n[r],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++i]=l;++i?n.length=i:delete this.__on}}}function UA(e,n,r){return function(){var i=this.__on,o,l=FA(n);if(i){for(var u=0,c=i.length;u<c;++u)if((o=i[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=r),o.value=n;return}}this.addEventListener(e.type,l,r),o={type:e.type,name:e.name,value:n,listener:l,options:r},i?i.push(o):this.__on=[o]}}function HA(e,n,r){var i=zA(e+""),o,l=i.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var h=0,p=c.length,d;h<p;++h)for(o=0,d=c[h];o<l;++o)if((u=i[o]).type===d.type&&u.name===d.name)return d.value}return}for(c=n?UA:BA,o=0;o<l;++o)this.each(c(i[o],n,r));return this}function nN(e,n,r){var i=QE(e),o=i.CustomEvent;typeof o=="function"?o=new o(n,r):(o=i.document.createEvent("Event"),r?(o.initEvent(n,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function WA(e,n){return function(){return nN(this,e,n)}}function VA(e,n){return function(){return nN(this,e,n.apply(this,arguments))}}function GA(e,n){return this.each((typeof n=="function"?VA:WA)(e,n))}function*YA(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,l=i.length,u;o<l;++o)(u=i[o])&&(yield u)}var rN=[null];function _n(e,n){this._groups=e,this._parents=n}function Ca(){return new _n([[document.documentElement]],rN)}function KA(){return this}_n.prototype=Ca.prototype={constructor:_n,select:_j,selectAll:Ej,selectChild:Rj,selectChildren:Mj,filter:Oj,data:Fj,enter:Pj,exit:Bj,join:Uj,merge:Hj,selection:KA,order:Wj,sort:Vj,call:Yj,nodes:Kj,node:Xj,size:Qj,empty:Zj,each:Jj,attr:oA,style:cA,property:pA,classed:yA,text:bA,html:NA,raise:TA,lower:jA,append:AA,insert:MA,remove:PA,clone:qA,datum:DA,on:HA,dispatch:GA,[Symbol.iterator]:YA};function Ln(e){return typeof e=="string"?new _n([[document.querySelector(e)]],[document.documentElement]):new _n([[e]],rN)}function XA(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Zn(e,n){if(e=XA(e),n===void 0&&(n=e.currentTarget),n){var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const QA={passive:!1},ga={capture:!0,passive:!1};function Od(e){e.stopImmediatePropagation()}function oo(e){e.preventDefault(),e.stopImmediatePropagation()}function sN(e){var n=e.document.documentElement,r=Ln(e).on("dragstart.drag",oo,ga);"onselectstart"in n?r.on("selectstart.drag",oo,ga):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function iN(e,n){var r=e.document.documentElement,i=Ln(e).on("dragstart.drag",null);n&&(i.on("click.drag",oo,ga),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in r?i.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Wl=e=>()=>e;function pv(e,{sourceEvent:n,subject:r,target:i,identifier:o,active:l,x:u,y:c,dx:h,dy:p,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},subject:{value:r,enumerable:!0,configurable:!0},target:{value:i,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:h,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:d}})}pv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function ZA(e){return!e.ctrlKey&&!e.button}function JA(){return this.parentNode}function e2(e,n){return n??{x:e.x,y:e.y}}function t2(){return navigator.maxTouchPoints||"ontouchstart"in this}function n2(){var e=ZA,n=JA,r=e2,i=t2,o={},l=Tu("start","drag","end"),u=0,c,h,p,d,m=0;function y(T){T.on("mousedown.drag",w).filter(i).on("touchstart.drag",b).on("touchmove.drag",S,QA).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(T,I){if(!(d||!e.call(this,T,I))){var O=E(this,n.call(this,T,I),T,I,"mouse");O&&(Ln(T.view).on("mousemove.drag",N,ga).on("mouseup.drag",_,ga),sN(T.view),Od(T),p=!1,c=T.clientX,h=T.clientY,O("start",T))}}function N(T){if(oo(T),!p){var I=T.clientX-c,O=T.clientY-h;p=I*I+O*O>m}o.mouse("drag",T)}function _(T){Ln(T.view).on("mousemove.drag mouseup.drag",null),iN(T.view,p),oo(T),o.mouse("end",T)}function b(T,I){if(e.call(this,T,I)){var O=T.changedTouches,A=n.call(this,T,I),U=O.length,z,P;for(z=0;z<U;++z)(P=E(this,A,T,I,O[z].identifier,O[z]))&&(Od(T),P("start",T,O[z]))}}function S(T){var I=T.changedTouches,O=I.length,A,U;for(A=0;A<O;++A)(U=o[I[A].identifier])&&(oo(T),U("drag",T,I[A]))}function k(T){var I=T.changedTouches,O=I.length,A,U;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),A=0;A<O;++A)(U=o[I[A].identifier])&&(Od(T),U("end",T,I[A]))}function E(T,I,O,A,U,z){var P=l.copy(),D=Zn(z||O,I),V,B,C;if((C=r.call(T,new pv("beforestart",{sourceEvent:O,target:y,identifier:U,active:u,x:D[0],y:D[1],dx:0,dy:0,dispatch:P}),A))!=null)return V=C.x-D[0]||0,B=C.y-D[1]||0,function q(L,re,J){var W=D,Z;switch(L){case"start":o[U]=q,Z=u++;break;case"end":delete o[U],--u;case"drag":D=Zn(J||re,I),Z=u;break}P.call(L,T,new pv(L,{sourceEvent:re,subject:C,target:y,identifier:U,active:Z,x:D[0]+V,y:D[1]+B,dx:D[0]-W[0],dy:D[1]-W[1],dispatch:P}),A)}}return y.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Wl(!!T),y):e},y.container=function(T){return arguments.length?(n=typeof T=="function"?T:Wl(T),y):n},y.subject=function(T){return arguments.length?(r=typeof T=="function"?T:Wl(T),y):r},y.touchable=function(T){return arguments.length?(i=typeof T=="function"?T:Wl(!!T),y):i},y.on=function(){var T=l.on.apply(l,arguments);return T===l?y:T},y.clickDistance=function(T){return arguments.length?(m=(T=+T)*T,y):Math.sqrt(m)},y}function Bv(e,n,r){e.prototype=n.prototype=r,r.constructor=e}function oN(e,n){var r=Object.create(e.prototype);for(var i in n)r[i]=n[i];return r}function Ta(){}var va=.7,mu=1/va,ao="\\s*([+-]?\\d+)\\s*",ya="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",hr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",r2=/^#([0-9a-f]{3,8})$/,s2=new RegExp(`^rgb\\(${ao},${ao},${ao}\\)$`),i2=new RegExp(`^rgb\\(${hr},${hr},${hr}\\)$`),o2=new RegExp(`^rgba\\(${ao},${ao},${ao},${ya}\\)$`),a2=new RegExp(`^rgba\\(${hr},${hr},${hr},${ya}\\)$`),l2=new RegExp(`^hsl\\(${ya},${hr},${hr}\\)$`),u2=new RegExp(`^hsla\\(${ya},${hr},${hr},${ya}\\)$`),Qw={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};Bv(Ta,wa,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Zw,formatHex:Zw,formatHex8:c2,formatHsl:d2,formatRgb:Jw,toString:Jw});function Zw(){return this.rgb().formatHex()}function c2(){return this.rgb().formatHex8()}function d2(){return aN(this).formatHsl()}function Jw(){return this.rgb().formatRgb()}function wa(e){var n,r;return e=(e+"").trim().toLowerCase(),(n=r2.exec(e))?(r=n[1].length,n=parseInt(n[1],16),r===6?ex(n):r===3?new cn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?Vl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?Vl(n>>12&15|n>>8&240,n>>8&15|n>>4&240,n>>4&15|n&240,((n&15)<<4|n&15)/255):null):(n=s2.exec(e))?new cn(n[1],n[2],n[3],1):(n=i2.exec(e))?new cn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=o2.exec(e))?Vl(n[1],n[2],n[3],n[4]):(n=a2.exec(e))?Vl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=l2.exec(e))?rx(n[1],n[2]/100,n[3]/100,1):(n=u2.exec(e))?rx(n[1],n[2]/100,n[3]/100,n[4]):Qw.hasOwnProperty(e)?ex(Qw[e]):e==="transparent"?new cn(NaN,NaN,NaN,0):null}function ex(e){return new cn(e>>16&255,e>>8&255,e&255,1)}function Vl(e,n,r,i){return i<=0&&(e=n=r=NaN),new cn(e,n,r,i)}function f2(e){return e instanceof Ta||(e=wa(e)),e?(e=e.rgb(),new cn(e.r,e.g,e.b,e.opacity)):new cn}function mv(e,n,r,i){return arguments.length===1?f2(e):new cn(e,n,r,i??1)}function cn(e,n,r,i){this.r=+e,this.g=+n,this.b=+r,this.opacity=+i}Bv(cn,mv,oN(Ta,{brighter(e){return e=e==null?mu:Math.pow(mu,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?va:Math.pow(va,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new cn(fi(this.r),fi(this.g),fi(this.b),gu(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:tx,formatHex:tx,formatHex8:h2,formatRgb:nx,toString:nx}));function tx(){return`#${ci(this.r)}${ci(this.g)}${ci(this.b)}`}function h2(){return`#${ci(this.r)}${ci(this.g)}${ci(this.b)}${ci((isNaN(this.opacity)?1:this.opacity)*255)}`}function nx(){const e=gu(this.opacity);return`${e===1?"rgb(":"rgba("}${fi(this.r)}, ${fi(this.g)}, ${fi(this.b)}${e===1?")":`, ${e})`}`}function gu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function fi(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ci(e){return e=fi(e),(e<16?"0":"")+e.toString(16)}function rx(e,n,r,i){return i<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new Jn(e,n,r,i)}function aN(e){if(e instanceof Jn)return new Jn(e.h,e.s,e.l,e.opacity);if(e instanceof Ta||(e=wa(e)),!e)return new Jn;if(e instanceof Jn)return e;e=e.rgb();var n=e.r/255,r=e.g/255,i=e.b/255,o=Math.min(n,r,i),l=Math.max(n,r,i),u=NaN,c=l-o,h=(l+o)/2;return c?(n===l?u=(r-i)/c+(r<i)*6:r===l?u=(i-n)/c+2:u=(n-r)/c+4,c/=h<.5?l+o:2-l-o,u*=60):c=h>0&&h<1?0:u,new Jn(u,c,h,e.opacity)}function p2(e,n,r,i){return arguments.length===1?aN(e):new Jn(e,n,r,i??1)}function Jn(e,n,r,i){this.h=+e,this.s=+n,this.l=+r,this.opacity=+i}Bv(Jn,p2,oN(Ta,{brighter(e){return e=e==null?mu:Math.pow(mu,e),new Jn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?va:Math.pow(va,e),new Jn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,i=r+(r<.5?r:1-r)*n,o=2*r-i;return new cn(Pd(e>=240?e-240:e+120,o,i),Pd(e,o,i),Pd(e<120?e+240:e-120,o,i),this.opacity)},clamp(){return new Jn(sx(this.h),Gl(this.s),Gl(this.l),gu(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=gu(this.opacity);return`${e===1?"hsl(":"hsla("}${sx(this.h)}, ${Gl(this.s)*100}%, ${Gl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function sx(e){return e=(e||0)%360,e<0?e+360:e}function Gl(e){return Math.max(0,Math.min(1,e||0))}function Pd(e,n,r){return(e<60?n+(r-n)*e/60:e<180?r:e<240?n+(r-n)*(240-e)/60:n)*255}const lN=e=>()=>e;function m2(e,n){return function(r){return e+r*n}}function g2(e,n,r){return e=Math.pow(e,r),n=Math.pow(n,r)-e,r=1/r,function(i){return Math.pow(e+i*n,r)}}function v2(e){return(e=+e)==1?uN:function(n,r){return r-n?g2(n,r,e):lN(isNaN(n)?r:n)}}function uN(e,n){var r=n-e;return r?m2(e,r):lN(isNaN(e)?n:e)}const ix=(function e(n){var r=v2(n);function i(o,l){var u=r((o=mv(o)).r,(l=mv(l)).r),c=r(o.g,l.g),h=r(o.b,l.b),p=uN(o.opacity,l.opacity);return function(d){return o.r=u(d),o.g=c(d),o.b=h(d),o.opacity=p(d),o+""}}return i.gamma=e,i})(1);function Es(e,n){return e=+e,n=+n,function(r){return e*(1-r)+n*r}}var gv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ld=new RegExp(gv.source,"g");function y2(e){return function(){return e}}function w2(e){return function(n){return e(n)+""}}function x2(e,n){var r=gv.lastIndex=Ld.lastIndex=0,i,o,l,u=-1,c=[],h=[];for(e=e+"",n=n+"";(i=gv.exec(e))&&(o=Ld.exec(n));)(l=o.index)>r&&(l=n.slice(r,l),c[u]?c[u]+=l:c[++u]=l),(i=i[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,h.push({i:u,x:Es(i,o)})),r=Ld.lastIndex;return r<n.length&&(l=n.slice(r),c[u]?c[u]+=l:c[++u]=l),c.length<2?h[0]?w2(h[0].x):y2(n):(n=h.length,function(p){for(var d=0,m;d<n;++d)c[(m=h[d]).i]=m.x(p);return c.join("")})}var ox=180/Math.PI,vv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function cN(e,n,r,i,o,l){var u,c,h;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(h=e*r+n*i)&&(r-=e*h,i-=n*h),(c=Math.sqrt(r*r+i*i))&&(r/=c,i/=c,h/=c),e*i<n*r&&(e=-e,n=-n,h=-h,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*ox,skewX:Math.atan(h)*ox,scaleX:u,scaleY:c}}var Yl;function _2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?vv:cN(n.a,n.b,n.c,n.d,n.e,n.f)}function b2(e){return e==null||(Yl||(Yl=document.createElementNS("http://www.w3.org/2000/svg","g")),Yl.setAttribute("transform",e),!(e=Yl.transform.baseVal.consolidate()))?vv:(e=e.matrix,cN(e.a,e.b,e.c,e.d,e.e,e.f))}function dN(e,n,r,i){function o(p){return p.length?p.pop()+" ":""}function l(p,d,m,y,w,N){if(p!==m||d!==y){var _=w.push("translate(",null,n,null,r);N.push({i:_-4,x:Es(p,m)},{i:_-2,x:Es(d,y)})}else(m||y)&&w.push("translate("+m+n+y+r)}function u(p,d,m,y){p!==d?(p-d>180?d+=360:d-p>180&&(p+=360),y.push({i:m.push(o(m)+"rotate(",null,i)-2,x:Es(p,d)})):d&&m.push(o(m)+"rotate("+d+i)}function c(p,d,m,y){p!==d?y.push({i:m.push(o(m)+"skewX(",null,i)-2,x:Es(p,d)}):d&&m.push(o(m)+"skewX("+d+i)}function h(p,d,m,y,w,N){if(p!==m||d!==y){var _=w.push(o(w)+"scale(",null,",",null,")");N.push({i:_-4,x:Es(p,m)},{i:_-2,x:Es(d,y)})}else(m!==1||y!==1)&&w.push(o(w)+"scale("+m+","+y+")")}return function(p,d){var m=[],y=[];return p=e(p),d=e(d),l(p.translateX,p.translateY,d.translateX,d.translateY,m,y),u(p.rotate,d.rotate,m,y),c(p.skewX,d.skewX,m,y),h(p.scaleX,p.scaleY,d.scaleX,d.scaleY,m,y),p=d=null,function(w){for(var N=-1,_=y.length,b;++N<_;)m[(b=y[N]).i]=b.x(w);return m.join("")}}}var S2=dN(_2,"px, ","px)","deg)"),k2=dN(b2,", ",")",")"),E2=1e-12;function ax(e){return((e=Math.exp(e))+1/e)/2}function N2(e){return((e=Math.exp(e))-1/e)/2}function C2(e){return((e=Math.exp(2*e))-1)/(e+1)}const T2=(function e(n,r,i){function o(l,u){var c=l[0],h=l[1],p=l[2],d=u[0],m=u[1],y=u[2],w=d-c,N=m-h,_=w*w+N*N,b,S;if(_<E2)S=Math.log(y/p)/n,b=function(A){return[c+A*w,h+A*N,p*Math.exp(n*A*S)]};else{var k=Math.sqrt(_),E=(y*y-p*p+i*_)/(2*p*r*k),T=(y*y-p*p-i*_)/(2*y*r*k),I=Math.log(Math.sqrt(E*E+1)-E),O=Math.log(Math.sqrt(T*T+1)-T);S=(O-I)/n,b=function(A){var U=A*S,z=ax(I),P=p/(r*k)*(z*C2(n*U+I)-N2(I));return[c+P*w,h+P*N,p*z/ax(n*U+I)]}}return b.duration=S*1e3*n/Math.SQRT2,b}return o.rho=function(l){var u=Math.max(.001,+l),c=u*u,h=c*c;return e(u,c,h)},o})(Math.SQRT2,2,4);var fo=0,ca=0,sa=0,fN=1e3,vu,da,yu=0,pi=0,ju=0,xa=typeof performance=="object"&&performance.now?performance:Date,hN=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Uv(){return pi||(hN(R2),pi=xa.now()+ju)}function R2(){pi=0}function wu(){this._call=this._time=this._next=null}wu.prototype=pN.prototype={constructor:wu,restart:function(e,n,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?Uv():+r)+(n==null?0:+n),!this._next&&da!==this&&(da?da._next=this:vu=this,da=this),this._call=e,this._time=r,yv()},stop:function(){this._call&&(this._call=null,this._time=1/0,yv())}};function pN(e,n,r){var i=new wu;return i.restart(e,n,r),i}function j2(){Uv(),++fo;for(var e=vu,n;e;)(n=pi-e._time)>=0&&e._call.call(void 0,n),e=e._next;--fo}function lx(){pi=(yu=xa.now())+ju,fo=ca=0;try{j2()}finally{fo=0,I2(),pi=0}}function A2(){var e=xa.now(),n=e-yu;n>fN&&(ju-=n,yu=e)}function I2(){for(var e,n=vu,r,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(r=n._next,n._next=null,n=e?e._next=r:vu=r);da=e,yv(i)}function yv(e){if(!fo){ca&&(ca=clearTimeout(ca));var n=e-pi;n>24?(e<1/0&&(ca=setTimeout(lx,e-xa.now()-ju)),sa&&(sa=clearInterval(sa))):(sa||(yu=xa.now(),sa=setInterval(A2,fN)),fo=1,hN(lx))}}function ux(e,n,r){var i=new wu;return n=n==null?0:+n,i.restart(o=>{i.stop(),e(o+n)},n,r),i}var M2=Tu("start","end","cancel","interrupt"),O2=[],mN=0,cx=1,wv=2,uu=3,dx=4,xv=5,cu=6;function Au(e,n,r,i,o,l){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;P2(e,r,{name:n,index:i,group:o,on:M2,tween:O2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:mN})}function Hv(e,n){var r=nr(e,n);if(r.state>mN)throw new Error("too late; already scheduled");return r}function pr(e,n){var r=nr(e,n);if(r.state>uu)throw new Error("too late; already running");return r}function nr(e,n){var r=e.__transition;if(!r||!(r=r[n]))throw new Error("transition not found");return r}function P2(e,n,r){var i=e.__transition,o;i[n]=r,r.timer=pN(l,0,r.time);function l(p){r.state=cx,r.timer.restart(u,r.delay,r.time),r.delay<=p&&u(p-r.delay)}function u(p){var d,m,y,w;if(r.state!==cx)return h();for(d in i)if(w=i[d],w.name===r.name){if(w.state===uu)return ux(u);w.state===dx?(w.state=cu,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete i[d]):+d<n&&(w.state=cu,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete i[d])}if(ux(function(){r.state===uu&&(r.state=dx,r.timer.restart(c,r.delay,r.time),c(p))}),r.state=wv,r.on.call("start",e,e.__data__,r.index,r.group),r.state===wv){for(r.state=uu,o=new Array(y=r.tween.length),d=0,m=-1;d<y;++d)(w=r.tween[d].value.call(e,e.__data__,r.index,r.group))&&(o[++m]=w);o.length=m+1}}function c(p){for(var d=p<r.duration?r.ease.call(null,p/r.duration):(r.timer.restart(h),r.state=xv,1),m=-1,y=o.length;++m<y;)o[m].call(e,d);r.state===xv&&(r.on.call("end",e,e.__data__,r.index,r.group),h())}function h(){r.state=cu,r.timer.stop(),delete i[n];for(var p in i)return;delete e.__transition}}function du(e,n){var r=e.__transition,i,o,l=!0,u;if(r){n=n==null?null:n+"";for(u in r){if((i=r[u]).name!==n){l=!1;continue}o=i.state>wv&&i.state<xv,i.state=cu,i.timer.stop(),i.on.call(o?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete r[u]}l&&delete e.__transition}}function L2(e){return this.each(function(){du(this,e)})}function $2(e,n){var r,i;return function(){var o=pr(this,e),l=o.tween;if(l!==r){i=r=l;for(var u=0,c=i.length;u<c;++u)if(i[u].name===n){i=i.slice(),i.splice(u,1);break}}o.tween=i}}function q2(e,n,r){var i,o;if(typeof r!="function")throw new Error;return function(){var l=pr(this,e),u=l.tween;if(u!==i){o=(i=u).slice();for(var c={name:n,value:r},h=0,p=o.length;h<p;++h)if(o[h].name===n){o[h]=c;break}h===p&&o.push(c)}l.tween=o}}function D2(e,n){var r=this._id;if(e+="",arguments.length<2){for(var i=nr(this.node(),r).tween,o=0,l=i.length,u;o<l;++o)if((u=i[o]).name===e)return u.value;return null}return this.each((n==null?$2:q2)(r,e,n))}function Wv(e,n,r){var i=e._id;return e.each(function(){var o=pr(this,i);(o.value||(o.value={}))[n]=r.apply(this,arguments)}),function(o){return nr(o,i).value[n]}}function gN(e,n){var r;return(typeof n=="number"?Es:n instanceof wa?ix:(r=wa(n))?(n=r,ix):x2)(e,n)}function F2(e){return function(){this.removeAttribute(e)}}function z2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function B2(e,n,r){var i,o=r+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===i?l:l=n(i=u,r)}}function U2(e,n,r){var i,o=r+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===i?l:l=n(i=u,r)}}function H2(e,n,r){var i,o,l;return function(){var u,c=r(this),h;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),h=c+"",u===h?null:u===i&&h===o?l:(o=h,l=n(i=u,c)))}}function W2(e,n,r){var i,o,l;return function(){var u,c=r(this),h;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),h=c+"",u===h?null:u===i&&h===o?l:(o=h,l=n(i=u,c)))}}function V2(e,n){var r=Ru(e),i=r==="transform"?k2:gN;return this.attrTween(e,typeof n=="function"?(r.local?W2:H2)(r,i,Wv(this,"attr."+e,n)):n==null?(r.local?z2:F2)(r):(r.local?U2:B2)(r,i,n))}function G2(e,n){return function(r){this.setAttribute(e,n.call(this,r))}}function Y2(e,n){return function(r){this.setAttributeNS(e.space,e.local,n.call(this,r))}}function K2(e,n){var r,i;function o(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&Y2(e,l)),r}return o._value=n,o}function X2(e,n){var r,i;function o(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&G2(e,l)),r}return o._value=n,o}function Q2(e,n){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(n==null)return this.tween(r,null);if(typeof n!="function")throw new Error;var i=Ru(e);return this.tween(r,(i.local?K2:X2)(i,n))}function Z2(e,n){return function(){Hv(this,e).delay=+n.apply(this,arguments)}}function J2(e,n){return n=+n,function(){Hv(this,e).delay=n}}function eI(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?Z2:J2)(n,e)):nr(this.node(),n).delay}function tI(e,n){return function(){pr(this,e).duration=+n.apply(this,arguments)}}function nI(e,n){return n=+n,function(){pr(this,e).duration=n}}function rI(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?tI:nI)(n,e)):nr(this.node(),n).duration}function sI(e,n){if(typeof n!="function")throw new Error;return function(){pr(this,e).ease=n}}function iI(e){var n=this._id;return arguments.length?this.each(sI(n,e)):nr(this.node(),n).ease}function oI(e,n){return function(){var r=n.apply(this,arguments);if(typeof r!="function")throw new Error;pr(this,e).ease=r}}function aI(e){if(typeof e!="function")throw new Error;return this.each(oI(this._id,e))}function lI(e){typeof e!="function"&&(e=YE(e));for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=i[o]=[],h,p=0;p<u;++p)(h=l[p])&&e.call(h,h.__data__,p,l)&&c.push(h);return new Fr(i,this._parents,this._name,this._id)}function uI(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,r=e._groups,i=n.length,o=r.length,l=Math.min(i,o),u=new Array(i),c=0;c<l;++c)for(var h=n[c],p=r[c],d=h.length,m=u[c]=new Array(d),y,w=0;w<d;++w)(y=h[w]||p[w])&&(m[w]=y);for(;c<i;++c)u[c]=n[c];return new Fr(u,this._parents,this._name,this._id)}function cI(e){return(e+"").trim().split(/^|\s+/).every(function(n){var r=n.indexOf(".");return r>=0&&(n=n.slice(0,r)),!n||n==="start"})}function dI(e,n,r){var i,o,l=cI(n)?Hv:pr;return function(){var u=l(this,e),c=u.on;c!==i&&(o=(i=c).copy()).on(n,r),u.on=o}}function fI(e,n){var r=this._id;return arguments.length<2?nr(this.node(),r).on.on(e):this.each(dI(r,e,n))}function hI(e){return function(){var n=this.parentNode;for(var r in this.__transition)if(+r!==e)return;n&&n.removeChild(this)}}function pI(){return this.on("end.remove",hI(this._id))}function mI(e){var n=this._name,r=this._id;typeof e!="function"&&(e=Fv(e));for(var i=this._groups,o=i.length,l=new Array(o),u=0;u<o;++u)for(var c=i[u],h=c.length,p=l[u]=new Array(h),d,m,y=0;y<h;++y)(d=c[y])&&(m=e.call(d,d.__data__,y,c))&&("__data__"in d&&(m.__data__=d.__data__),p[y]=m,Au(p[y],n,r,y,p,nr(d,r)));return new Fr(l,this._parents,n,r)}function gI(e){var n=this._name,r=this._id;typeof e!="function"&&(e=GE(e));for(var i=this._groups,o=i.length,l=[],u=[],c=0;c<o;++c)for(var h=i[c],p=h.length,d,m=0;m<p;++m)if(d=h[m]){for(var y=e.call(d,d.__data__,m,h),w,N=nr(d,r),_=0,b=y.length;_<b;++_)(w=y[_])&&Au(w,n,r,_,y,N);l.push(y),u.push(d)}return new Fr(l,u,n,r)}var vI=Ca.prototype.constructor;function yI(){return new vI(this._groups,this._parents)}function wI(e,n){var r,i,o;return function(){var l=co(this,e),u=(this.style.removeProperty(e),co(this,e));return l===u?null:l===r&&u===i?o:o=n(r=l,i=u)}}function vN(e){return function(){this.style.removeProperty(e)}}function xI(e,n,r){var i,o=r+"",l;return function(){var u=co(this,e);return u===o?null:u===i?l:l=n(i=u,r)}}function _I(e,n,r){var i,o,l;return function(){var u=co(this,e),c=r(this),h=c+"";return c==null&&(h=c=(this.style.removeProperty(e),co(this,e))),u===h?null:u===i&&h===o?l:(o=h,l=n(i=u,c))}}function bI(e,n){var r,i,o,l="style."+n,u="end."+l,c;return function(){var h=pr(this,e),p=h.on,d=h.value[l]==null?c||(c=vN(n)):void 0;(p!==r||o!==d)&&(i=(r=p).copy()).on(u,o=d),h.on=i}}function SI(e,n,r){var i=(e+="")=="transform"?S2:gN;return n==null?this.styleTween(e,wI(e,i)).on("end.style."+e,vN(e)):typeof n=="function"?this.styleTween(e,_I(e,i,Wv(this,"style."+e,n))).each(bI(this._id,e)):this.styleTween(e,xI(e,i,n),r).on("end.style."+e,null)}function kI(e,n,r){return function(i){this.style.setProperty(e,n.call(this,i),r)}}function EI(e,n,r){var i,o;function l(){var u=n.apply(this,arguments);return u!==o&&(i=(o=u)&&kI(e,u,r)),i}return l._value=n,l}function NI(e,n,r){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,EI(e,n,r??""))}function CI(e){return function(){this.textContent=e}}function TI(e){return function(){var n=e(this);this.textContent=n??""}}function RI(e){return this.tween("text",typeof e=="function"?TI(Wv(this,"text",e)):CI(e==null?"":e+""))}function jI(e){return function(n){this.textContent=e.call(this,n)}}function AI(e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&jI(o)),n}return i._value=e,i}function II(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,AI(e))}function MI(){for(var e=this._name,n=this._id,r=yN(),i=this._groups,o=i.length,l=0;l<o;++l)for(var u=i[l],c=u.length,h,p=0;p<c;++p)if(h=u[p]){var d=nr(h,n);Au(h,e,r,p,u,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new Fr(i,this._parents,e,r)}function OI(){var e,n,r=this,i=r._id,o=r.size();return new Promise(function(l,u){var c={value:u},h={value:function(){--o===0&&l()}};r.each(function(){var p=pr(this,i),d=p.on;d!==e&&(n=(e=d).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(h)),p.on=n}),o===0&&l()})}var PI=0;function Fr(e,n,r,i){this._groups=e,this._parents=n,this._name=r,this._id=i}function yN(){return++PI}var $r=Ca.prototype;Fr.prototype={constructor:Fr,select:mI,selectAll:gI,selectChild:$r.selectChild,selectChildren:$r.selectChildren,filter:lI,merge:uI,selection:yI,transition:MI,call:$r.call,nodes:$r.nodes,node:$r.node,size:$r.size,empty:$r.empty,each:$r.each,on:fI,attr:V2,attrTween:Q2,style:SI,styleTween:NI,text:RI,textTween:II,remove:pI,tween:D2,delay:eI,duration:rI,ease:iI,easeVarying:aI,end:OI,[Symbol.iterator]:$r[Symbol.iterator]};function LI(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var $I={time:null,delay:0,duration:250,ease:LI};function qI(e,n){for(var r;!(r=e.__transition)||!(r=r[n]);)if(!(e=e.parentNode))throw new Error(`transition ${n} not found`);return r}function DI(e){var n,r;e instanceof Fr?(n=e._id,e=e._name):(n=yN(),(r=$I).time=Uv(),e=e==null?null:e+"");for(var i=this._groups,o=i.length,l=0;l<o;++l)for(var u=i[l],c=u.length,h,p=0;p<c;++p)(h=u[p])&&Au(h,e,n,p,u,r||qI(h,n));return new Fr(i,this._parents,e,n)}Ca.prototype.interrupt=L2;Ca.prototype.transition=DI;const Kl=e=>()=>e;function FI(e,{sourceEvent:n,target:r,transform:i,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function qr(e,n,r){this.k=e,this.x=n,this.y=r}qr.prototype={constructor:qr,scale:function(e){return e===1?this:new qr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new qr(this.k,this.x+this.k*e,this.y+this.k*n)},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 Dr=new qr(1,0,0);qr.prototype;function $d(e){e.stopImmediatePropagation()}function ia(e){e.preventDefault(),e.stopImmediatePropagation()}function zI(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function BI(){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 fx(){return this.__zoom||Dr}function UI(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function HI(){return navigator.maxTouchPoints||"ontouchstart"in this}function WI(e,n,r){var i=e.invertX(n[0][0])-r[0][0],o=e.invertX(n[1][0])-r[1][0],l=e.invertY(n[0][1])-r[0][1],u=e.invertY(n[1][1])-r[1][1];return e.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function wN(){var e=zI,n=BI,r=WI,i=UI,o=HI,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,h=T2,p=Tu("start","zoom","end"),d,m,y,w=500,N=150,_=0,b=10;function S(C){C.property("__zoom",fx).on("wheel.zoom",U,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",D).on("touchmove.zoom",V).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(C,q,L,re){var J=C.selection?C.selection():C;J.property("__zoom",fx),C!==J?I(C,q,L,re):J.interrupt().each(function(){O(this,arguments).event(re).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},S.scaleBy=function(C,q,L,re){S.scaleTo(C,function(){var J=this.__zoom.k,W=typeof q=="function"?q.apply(this,arguments):q;return J*W},L,re)},S.scaleTo=function(C,q,L,re){S.transform(C,function(){var J=n.apply(this,arguments),W=this.__zoom,Z=L==null?T(J):typeof L=="function"?L.apply(this,arguments):L,M=W.invert(Z),G=typeof q=="function"?q.apply(this,arguments):q;return r(E(k(W,G),Z,M),J,u)},L,re)},S.translateBy=function(C,q,L,re){S.transform(C,function(){return r(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof L=="function"?L.apply(this,arguments):L),n.apply(this,arguments),u)},null,re)},S.translateTo=function(C,q,L,re,J){S.transform(C,function(){var W=n.apply(this,arguments),Z=this.__zoom,M=re==null?T(W):typeof re=="function"?re.apply(this,arguments):re;return r(Dr.translate(M[0],M[1]).scale(Z.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof L=="function"?-L.apply(this,arguments):-L),W,u)},re,J)};function k(C,q){return q=Math.max(l[0],Math.min(l[1],q)),q===C.k?C:new qr(q,C.x,C.y)}function E(C,q,L){var re=q[0]-L[0]*C.k,J=q[1]-L[1]*C.k;return re===C.x&&J===C.y?C:new qr(C.k,re,J)}function T(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function I(C,q,L,re){C.on("start.zoom",function(){O(this,arguments).event(re).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(re).end()}).tween("zoom",function(){var J=this,W=arguments,Z=O(J,W).event(re),M=n.apply(J,W),G=L==null?T(M):typeof L=="function"?L.apply(J,W):L,K=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),$=J.__zoom,Q=typeof q=="function"?q.apply(J,W):q,ne=h($.invert(G).concat(K/$.k),Q.invert(G).concat(K/Q.k));return function(ae){if(ae===1)ae=Q;else{var fe=ne(ae),te=K/fe[2];ae=new qr(te,G[0]-fe[0]*te,G[1]-fe[1]*te)}Z.zoom(null,ae)}})}function O(C,q,L){return!L&&C.__zooming||new A(C,q)}function A(C,q){this.that=C,this.args=q,this.active=0,this.sourceEvent=null,this.extent=n.apply(C,q),this.taps=0}A.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,q){return this.mouse&&C!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var q=Ln(this.that).datum();p.call(C,this.that,new FI(C,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:p}),q)}};function U(C,...q){if(!e.apply(this,arguments))return;var L=O(this,q).event(C),re=this.__zoom,J=Math.max(l[0],Math.min(l[1],re.k*Math.pow(2,i.apply(this,arguments)))),W=Zn(C);if(L.wheel)(L.mouse[0][0]!==W[0]||L.mouse[0][1]!==W[1])&&(L.mouse[1]=re.invert(L.mouse[0]=W)),clearTimeout(L.wheel);else{if(re.k===J)return;L.mouse=[W,re.invert(W)],du(this),L.start()}ia(C),L.wheel=setTimeout(Z,N),L.zoom("mouse",r(E(k(re,J),L.mouse[0],L.mouse[1]),L.extent,u));function Z(){L.wheel=null,L.end()}}function z(C,...q){if(y||!e.apply(this,arguments))return;var L=C.currentTarget,re=O(this,q,!0).event(C),J=Ln(C.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",K,!0),W=Zn(C,L),Z=C.clientX,M=C.clientY;sN(C.view),$d(C),re.mouse=[W,this.__zoom.invert(W)],du(this),re.start();function G($){if(ia($),!re.moved){var Q=$.clientX-Z,ne=$.clientY-M;re.moved=Q*Q+ne*ne>_}re.event($).zoom("mouse",r(E(re.that.__zoom,re.mouse[0]=Zn($,L),re.mouse[1]),re.extent,u))}function K($){J.on("mousemove.zoom mouseup.zoom",null),iN($.view,re.moved),ia($),re.event($).end()}}function P(C,...q){if(e.apply(this,arguments)){var L=this.__zoom,re=Zn(C.changedTouches?C.changedTouches[0]:C,this),J=L.invert(re),W=L.k*(C.shiftKey?.5:2),Z=r(E(k(L,W),re,J),n.apply(this,q),u);ia(C),c>0?Ln(this).transition().duration(c).call(I,Z,re,C):Ln(this).call(S.transform,Z,re,C)}}function D(C,...q){if(e.apply(this,arguments)){var L=C.touches,re=L.length,J=O(this,q,C.changedTouches.length===re).event(C),W,Z,M,G;for($d(C),Z=0;Z<re;++Z)M=L[Z],G=Zn(M,this),G=[G,this.__zoom.invert(G),M.identifier],J.touch0?!J.touch1&&J.touch0[2]!==G[2]&&(J.touch1=G,J.taps=0):(J.touch0=G,W=!0,J.taps=1+!!d);d&&(d=clearTimeout(d)),W&&(J.taps<2&&(m=G[0],d=setTimeout(function(){d=null},w)),du(this),J.start())}}function V(C,...q){if(this.__zooming){var L=O(this,q).event(C),re=C.changedTouches,J=re.length,W,Z,M,G;for(ia(C),W=0;W<J;++W)Z=re[W],M=Zn(Z,this),L.touch0&&L.touch0[2]===Z.identifier?L.touch0[0]=M:L.touch1&&L.touch1[2]===Z.identifier&&(L.touch1[0]=M);if(Z=L.that.__zoom,L.touch1){var K=L.touch0[0],$=L.touch0[1],Q=L.touch1[0],ne=L.touch1[1],ae=(ae=Q[0]-K[0])*ae+(ae=Q[1]-K[1])*ae,fe=(fe=ne[0]-$[0])*fe+(fe=ne[1]-$[1])*fe;Z=k(Z,Math.sqrt(ae/fe)),M=[(K[0]+Q[0])/2,(K[1]+Q[1])/2],G=[($[0]+ne[0])/2,($[1]+ne[1])/2]}else if(L.touch0)M=L.touch0[0],G=L.touch0[1];else return;L.zoom("touch",r(E(Z,M,G),L.extent,u))}}function B(C,...q){if(this.__zooming){var L=O(this,q).event(C),re=C.changedTouches,J=re.length,W,Z;for($d(C),y&&clearTimeout(y),y=setTimeout(function(){y=null},w),W=0;W<J;++W)Z=re[W],L.touch0&&L.touch0[2]===Z.identifier?delete L.touch0:L.touch1&&L.touch1[2]===Z.identifier&&delete L.touch1;if(L.touch1&&!L.touch0&&(L.touch0=L.touch1,delete L.touch1),L.touch0)L.touch0[1]=this.__zoom.invert(L.touch0[0]);else if(L.end(),L.taps===2&&(Z=Zn(Z,this),Math.hypot(m[0]-Z[0],m[1]-Z[1])<b)){var M=Ln(this).on("dblclick.zoom");M&&M.apply(this,arguments)}}}return S.wheelDelta=function(C){return arguments.length?(i=typeof C=="function"?C:Kl(+C),S):i},S.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Kl(!!C),S):e},S.touchable=function(C){return arguments.length?(o=typeof C=="function"?C:Kl(!!C),S):o},S.extent=function(C){return arguments.length?(n=typeof C=="function"?C:Kl([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),S):n},S.scaleExtent=function(C){return arguments.length?(l[0]=+C[0],l[1]=+C[1],S):[l[0],l[1]]},S.translateExtent=function(C){return arguments.length?(u[0][0]=+C[0][0],u[1][0]=+C[1][0],u[0][1]=+C[0][1],u[1][1]=+C[1][1],S):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},S.constrain=function(C){return arguments.length?(r=C,S):r},S.duration=function(C){return arguments.length?(c=+C,S):c},S.interpolate=function(C){return arguments.length?(h=C,S):h},S.on=function(){var C=p.on.apply(p,arguments);return C===p?S:C},S.clickDistance=function(C){return arguments.length?(_=(C=+C)*C,S):Math.sqrt(_)},S.tapDistance=function(C){return arguments.length?(b=+C,S):b},S}var VI=HE();const Iu=j.createContext(null),GI=Iu.Provider,zr={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,n)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?n.targetHandle:n.sourceHandle}", edge id: ${n.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,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.`},xN=zr.error001();function Ke(e,n){const r=j.useContext(Iu);if(r===null)throw new Error(xN);return WE(r,e,n)}const Ct=()=>{const e=j.useContext(Iu);if(e===null)throw new Error(xN);return j.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},YI=e=>e.userSelectionActive?"none":"all";function Vv({position:e,children:n,className:r,style:i,...o}){const l=Ke(YI),u=`${e}`.split("-");return ue.createElement("div",{className:Ft(["react-flow__panel",r,...u]),style:{...i,pointerEvents:l},...o},n)}function KI({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:ue.createElement(Vv,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ue.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const XI=({x:e,y:n,label:r,labelStyle:i={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:h,className:p,...d})=>{const m=j.useRef(null),[y,w]=j.useState({x:0,y:0,width:0,height:0}),N=Ft(["react-flow__edge-textwrapper",p]);return j.useEffect(()=>{if(m.current){const _=m.current.getBBox();w({x:_.x,y:_.y,width:_.width,height:_.height})}},[r]),typeof r>"u"||!r?null:ue.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:N,visibility:y.width?"visible":"hidden",...d},o&&ue.createElement("rect",{width:y.width+2*u[0],x:-u[0],y:-u[1],height:y.height+2*u[1],className:"react-flow__edge-textbg",style:l,rx:c,ry:c}),ue.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:i},r),h)};var QI=j.memo(XI);const Gv=e=>({width:e.offsetWidth,height:e.offsetHeight}),ho=(e,n=0,r=1)=>Math.min(Math.max(e,n),r),Yv=(e={x:0,y:0},n)=>({x:ho(e.x,n[0][0],n[1][0]),y:ho(e.y,n[0][1],n[1][1])}),hx=(e,n,r)=>e<n?ho(Math.abs(e-n),1,50)/50:e>r?-ho(Math.abs(e-r),1,50)/50:0,_N=(e,n)=>{const r=hx(e.x,35,n.width-35)*20,i=hx(e.y,35,n.height-35)*20;return[r,i]},bN=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},SN=(e,n)=>({x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x2,n.x2),y2:Math.max(e.y2,n.y2)}),_a=({x:e,y:n,width:r,height:i})=>({x:e,y:n,x2:e+r,y2:n+i}),kN=({x:e,y:n,x2:r,y2:i})=>({x:e,y:n,width:r-e,height:i-n}),px=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),ZI=(e,n)=>kN(SN(_a(e),_a(n))),_v=(e,n)=>{const r=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),i=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(r*i)},JI=e=>$n(e.width)&&$n(e.height)&&$n(e.x)&&$n(e.y),$n=e=>!isNaN(e)&&isFinite(e),gt=Symbol.for("internals"),EN=["Enter"," ","Escape"],eM=(e,n)=>{},tM=e=>"nativeEvent"in e;function bv(e){var o,l;const n=tM(e)?e.nativeEvent:e,r=((l=(o=n.composedPath)==null?void 0:o.call(n))==null?void 0:l[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(r==null?void 0:r.nodeName)||(r==null?void 0:r.hasAttribute("contenteditable"))||!!(r!=null&&r.closest(".nokey"))}const NN=e=>"clientX"in e,Ts=(e,n)=>{var l,u;const r=NN(e),i=r?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=r?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:i-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},xu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Ra=({id:e,path:n,labelX:r,labelY:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:y,interactionWidth:w=20})=>ue.createElement(ue.Fragment,null,ue.createElement("path",{id:e,style:d,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),w&&ue.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),o&&$n(r)&&$n(i)?ue.createElement(QI,{x:r,y:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null);Ra.displayName="BaseEdge";function oa(e,n,r){return r===void 0?r:i=>{const o=n().edges.find(l=>l.id===e);o&&r(i,{...o})}}function CN({sourceX:e,sourceY:n,targetX:r,targetY:i}){const o=Math.abs(r-e)/2,l=r<e?r+o:r-o,u=Math.abs(i-n)/2,c=i<n?i+u:i-u;return[l,c,o,u]}function TN({sourceX:e,sourceY:n,targetX:r,targetY:i,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const h=e*.125+o*.375+u*.375+r*.125,p=n*.125+l*.375+c*.375+i*.125,d=Math.abs(h-e),m=Math.abs(p-n);return[h,p,d,m]}var mi;(function(e){e.Strict="strict",e.Loose="loose"})(mi||(mi={}));var di;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(di||(di={}));var ba;(function(e){e.Partial="partial",e.Full="full"})(ba||(ba={}));var Cs;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Cs||(Cs={}));var _u;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(_u||(_u={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function mx({pos:e,x1:n,y1:r,x2:i,y2:o}){return e===Ae.Left||e===Ae.Right?[.5*(n+i),r]:[n,.5*(r+o)]}function RN({sourceX:e,sourceY:n,sourcePosition:r=Ae.Bottom,targetX:i,targetY:o,targetPosition:l=Ae.Top}){const[u,c]=mx({pos:r,x1:e,y1:n,x2:i,y2:o}),[h,p]=mx({pos:l,x1:i,y1:o,x2:e,y2:n}),[d,m,y,w]=TN({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:h,targetControlY:p});return[`M${e},${n} C${u},${c} ${h},${p} ${i},${o}`,d,m,y,w]}const Kv=j.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,sourcePosition:o=Ae.Bottom,targetPosition:l=Ae.Top,label:u,labelStyle:c,labelShowBg:h,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:N,interactionWidth:_})=>{const[b,S,k]=RN({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:l});return ue.createElement(Ra,{path:b,labelX:S,labelY:k,label:u,labelStyle:c,labelShowBg:h,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:N,interactionWidth:_})});Kv.displayName="SimpleBezierEdge";const gx={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},nM=({source:e,sourcePosition:n=Ae.Bottom,target:r})=>n===Ae.Left||n===Ae.Right?e.x<r.x?{x:1,y:0}:{x:-1,y:0}:e.y<r.y?{x:0,y:1}:{x:0,y:-1},vx=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function rM({source:e,sourcePosition:n=Ae.Bottom,target:r,targetPosition:i=Ae.Top,center:o,offset:l}){const u=gx[n],c=gx[i],h={x:e.x+u.x*l,y:e.y+u.y*l},p={x:r.x+c.x*l,y:r.y+c.y*l},d=nM({source:h,sourcePosition:n,target:p}),m=d.x!==0?"x":"y",y=d[m];let w=[],N,_;const b={x:0,y:0},S={x:0,y:0},[k,E,T,I]=CN({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(u[m]*c[m]===-1){N=o.x??k,_=o.y??E;const A=[{x:N,y:h.y},{x:N,y:p.y}],U=[{x:h.x,y:_},{x:p.x,y:_}];u[m]===y?w=m==="x"?A:U:w=m==="x"?U:A}else{const A=[{x:h.x,y:p.y}],U=[{x:p.x,y:h.y}];if(m==="x"?w=u.x===y?U:A:w=u.y===y?A:U,n===i){const B=Math.abs(e[m]-r[m]);if(B<=l){const C=Math.min(l-1,l-B);u[m]===y?b[m]=(h[m]>e[m]?-1:1)*C:S[m]=(p[m]>r[m]?-1:1)*C}}if(n!==i){const B=m==="x"?"y":"x",C=u[m]===c[B],q=h[B]>p[B],L=h[B]<p[B];(u[m]===1&&(!C&&q||C&&L)||u[m]!==1&&(!C&&L||C&&q))&&(w=m==="x"?A:U)}const z={x:h.x+b.x,y:h.y+b.y},P={x:p.x+S.x,y:p.y+S.y},D=Math.max(Math.abs(z.x-w[0].x),Math.abs(P.x-w[0].x)),V=Math.max(Math.abs(z.y-w[0].y),Math.abs(P.y-w[0].y));D>=V?(N=(z.x+P.x)/2,_=w[0].y):(N=w[0].x,_=(z.y+P.y)/2)}return[[e,{x:h.x+b.x,y:h.y+b.y},...w,{x:p.x+S.x,y:p.y+S.y},r],N,_,T,I]}function sM(e,n,r,i){const o=Math.min(vx(e,n)/2,vx(n,r)/2,i),{x:l,y:u}=n;if(e.x===l&&l===r.x||e.y===u&&u===r.y)return`L${l} ${u}`;if(e.y===u){const p=e.x<r.x?-1:1,d=e.y<r.y?1:-1;return`L ${l+o*p},${u}Q ${l},${u} ${l},${u+o*d}`}const c=e.x<r.x?1:-1,h=e.y<r.y?-1:1;return`L ${l},${u+o*h}Q ${l},${u} ${l+o*c},${u}`}function Sv({sourceX:e,sourceY:n,sourcePosition:r=Ae.Bottom,targetX:i,targetY:o,targetPosition:l=Ae.Top,borderRadius:u=5,centerX:c,centerY:h,offset:p=20}){const[d,m,y,w,N]=rM({source:{x:e,y:n},sourcePosition:r,target:{x:i,y:o},targetPosition:l,center:{x:c,y:h},offset:p});return[d.reduce((b,S,k)=>{let E="";return k>0&&k<d.length-1?E=sM(d[k-1],S,d[k+1],u):E=`${k===0?"M":"L"}${S.x} ${S.y}`,b+=E,b},""),m,y,w,N]}const Mu=j.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,style:d,sourcePosition:m=Ae.Bottom,targetPosition:y=Ae.Top,markerEnd:w,markerStart:N,pathOptions:_,interactionWidth:b})=>{const[S,k,E]=Sv({sourceX:e,sourceY:n,sourcePosition:m,targetX:r,targetY:i,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return ue.createElement(Ra,{path:S,labelX:k,labelY:E,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,style:d,markerEnd:w,markerStart:N,interactionWidth:b})});Mu.displayName="SmoothStepEdge";const Xv=j.memo(e=>{var n;return ue.createElement(Mu,{...e,pathOptions:j.useMemo(()=>{var r;return{borderRadius:0,offset:(r=e.pathOptions)==null?void 0:r.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});Xv.displayName="StepEdge";function iM({sourceX:e,sourceY:n,targetX:r,targetY:i}){const[o,l,u,c]=CN({sourceX:e,sourceY:n,targetX:r,targetY:i});return[`M ${e},${n}L ${r},${i}`,o,l,u,c]}const Qv=j.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:y,interactionWidth:w})=>{const[N,_,b]=iM({sourceX:e,sourceY:n,targetX:r,targetY:i});return ue.createElement(Ra,{path:N,labelX:_,labelY:b,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:y,interactionWidth:w})});Qv.displayName="StraightEdge";function Xl(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function yx({pos:e,x1:n,y1:r,x2:i,y2:o,c:l}){switch(e){case Ae.Left:return[n-Xl(n-i,l),r];case Ae.Right:return[n+Xl(i-n,l),r];case Ae.Top:return[n,r-Xl(r-o,l)];case Ae.Bottom:return[n,r+Xl(o-r,l)]}}function jN({sourceX:e,sourceY:n,sourcePosition:r=Ae.Bottom,targetX:i,targetY:o,targetPosition:l=Ae.Top,curvature:u=.25}){const[c,h]=yx({pos:r,x1:e,y1:n,x2:i,y2:o,c:u}),[p,d]=yx({pos:l,x1:i,y1:o,x2:e,y2:n,c:u}),[m,y,w,N]=TN({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:c,sourceControlY:h,targetControlX:p,targetControlY:d});return[`M${e},${n} C${c},${h} ${p},${d} ${i},${o}`,m,y,w,N]}const bu=j.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,sourcePosition:o=Ae.Bottom,targetPosition:l=Ae.Top,label:u,labelStyle:c,labelShowBg:h,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:N,pathOptions:_,interactionWidth:b})=>{const[S,k,E]=jN({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:l,curvature:_==null?void 0:_.curvature});return ue.createElement(Ra,{path:S,labelX:k,labelY:E,label:u,labelStyle:c,labelShowBg:h,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:w,markerStart:N,interactionWidth:b})});bu.displayName="BezierEdge";const Zv=j.createContext(null),oM=Zv.Provider;Zv.Consumer;const aM=()=>j.useContext(Zv),lM=e=>"id"in e&&"source"in e&&"target"in e,uM=({source:e,sourceHandle:n,target:r,targetHandle:i})=>`reactflow__edge-${e}${n||""}-${r}${i||""}`,kv=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`,cM=(e,n)=>n.some(r=>r.source===e.source&&r.target===e.target&&(r.sourceHandle===e.sourceHandle||!r.sourceHandle&&!e.sourceHandle)&&(r.targetHandle===e.targetHandle||!r.targetHandle&&!e.targetHandle)),dM=(e,n)=>{if(!e.source||!e.target)return n;let r;return lM(e)?r={...e}:r={...e,id:uM(e)},cM(r,n)?n:n.concat(r)},Ev=({x:e,y:n},[r,i,o],l,[u,c])=>{const h={x:(e-r)/o,y:(n-i)/o};return l?{x:u*Math.round(h.x/u),y:c*Math.round(h.y/c)}:h},AN=({x:e,y:n},[r,i,o])=>({x:e*o+r,y:n*o+i}),hi=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*n[0],i=(e.height??0)*n[1],o={x:e.position.x-r,y:e.position.y-i};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-i}:o}},Ou=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((i,o)=>{const{x:l,y:u}=hi(o,n).positionAbsolute;return SN(i,_a({x:l,y:u,width:o.width||0,height:o.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return kN(r)},IN=(e,n,[r,i,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const h={x:(n.x-r)/o,y:(n.y-i)/o,width:n.width/o,height:n.height/o},p=[];return e.forEach(d=>{const{width:m,height:y,selectable:w=!0,hidden:N=!1}=d;if(u&&!w||N)return!1;const{positionAbsolute:_}=hi(d,c),b={x:_.x,y:_.y,width:m||0,height:y||0},S=_v(h,b),k=typeof m>"u"||typeof y>"u"||m===null||y===null,E=l&&S>0,T=(m||0)*(y||0);(k||E||S>=T||d.dragging)&&p.push(d)}),p},MN=(e,n)=>{const r=e.map(i=>i.id);return n.filter(i=>r.includes(i.source)||r.includes(i.target))},ON=(e,n,r,i,o,l=.1)=>{const u=n/(e.width*(1+l)),c=r/(e.height*(1+l)),h=Math.min(u,c),p=ho(h,i,o),d=e.x+e.width/2,m=e.y+e.height/2,y=n/2-d*p,w=r/2-m*p;return{x:y,y:w,zoom:p}},ui=(e,n=0)=>e.transition().duration(n);function wx(e,n,r,i){return(n[r]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${r}`!==i&&o.push({id:l.id||null,type:r,nodeId:e.id,x:(((u=e.positionAbsolute)==null?void 0:u.x)??0)+l.x+l.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+l.y+l.height/2}),o},[])}function fM(e,n,r,i,o,l){const{x:u,y:c}=Ts(e),p=n.elementsFromPoint(u,c).find(N=>N.classList.contains("react-flow__handle"));if(p){const N=p.getAttribute("data-nodeid");if(N){const _=Jv(void 0,p),b=p.getAttribute("data-handleid"),S=l({nodeId:N,id:b,type:_});if(S){const k=o.find(E=>E.nodeId===N&&E.type===_&&E.id===b);return{handle:{id:b,type:_,nodeId:N,x:(k==null?void 0:k.x)||r.x,y:(k==null?void 0:k.y)||r.y},validHandleResult:S}}}}let d=[],m=1/0;if(o.forEach(N=>{const _=Math.sqrt((N.x-r.x)**2+(N.y-r.y)**2);if(_<=i){const b=l(N);_<=m&&(_<m?d=[{handle:N,validHandleResult:b}]:_===m&&d.push({handle:N,validHandleResult:b}),m=_)}}),!d.length)return{handle:null,validHandleResult:PN()};if(d.length===1)return d[0];const y=d.some(({validHandleResult:N})=>N.isValid),w=d.some(({handle:N})=>N.type==="target");return d.find(({handle:N,validHandleResult:_})=>w?N.type==="target":y?_.isValid:!0)||d[0]}const hM={source:null,target:null,sourceHandle:null,targetHandle:null},PN=()=>({handleDomNode:null,isValid:!1,connection:hM,endHandle:null});function LN(e,n,r,i,o,l,u){const c=o==="target",h=u.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),p={...PN(),handleDomNode:h};if(h){const d=Jv(void 0,h),m=h.getAttribute("data-nodeid"),y=h.getAttribute("data-handleid"),w=h.classList.contains("connectable"),N=h.classList.contains("connectableend"),_={source:c?m:r,sourceHandle:c?y:i,target:c?r:m,targetHandle:c?i:y};p.connection=_,w&&N&&(n===mi.Strict?c&&d==="source"||!c&&d==="target":m!==r||y!==i)&&(p.endHandle={nodeId:m,handleId:y,type:d},p.isValid=l(_))}return p}function pM({nodes:e,nodeId:n,handleId:r,handleType:i}){return e.reduce((o,l)=>{if(l[gt]){const{handleBounds:u}=l[gt];let c=[],h=[];u&&(c=wx(l,u,"source",`${n}-${r}-${i}`),h=wx(l,u,"target",`${n}-${r}-${i}`)),o.push(...c,...h)}return o},[])}function Jv(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function qd(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function mM(e,n){let r=null;return n?r="valid":e&&!n&&(r="invalid"),r}function $N({event:e,handleId:n,nodeId:r,onConnect:i,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:h,onReconnectEnd:p}){const d=bN(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:w,connectionRadius:N,onConnectStart:_,panBy:b,getNodes:S,cancelConnection:k}=l();let E=0,T;const{x:I,y:O}=Ts(e),A=d==null?void 0:d.elementFromPoint(I,O),U=Jv(h,A),z=y==null?void 0:y.getBoundingClientRect();if(!z||!U)return;let P,D=Ts(e,z),V=!1,B=null,C=!1,q=null;const L=pM({nodes:S(),nodeId:r,handleId:n,handleType:U}),re=()=>{if(!w)return;const[Z,M]=_N(D,z);b({x:Z,y:M}),E=requestAnimationFrame(re)};u({connectionPosition:D,connectionStatus:null,connectionNodeId:r,connectionHandleId:n,connectionHandleType:U,connectionStartHandle:{nodeId:r,handleId:n,type:U},connectionEndHandle:null}),_==null||_(e,{nodeId:r,handleId:n,handleType:U});function J(Z){const{transform:M}=l();D=Ts(Z,z);const{handle:G,validHandleResult:K}=fM(Z,d,Ev(D,M,!1,[1,1]),N,L,$=>LN($,m,r,n,o?"target":"source",c,d));if(T=G,V||(re(),V=!0),q=K.handleDomNode,B=K.connection,C=K.isValid,u({connectionPosition:T&&C?AN({x:T.x,y:T.y},M):D,connectionStatus:mM(!!T,C),connectionEndHandle:K.endHandle}),!T&&!C&&!q)return qd(P);B.source!==B.target&&q&&(qd(P),P=q,q.classList.add("connecting","react-flow__handle-connecting"),q.classList.toggle("valid",C),q.classList.toggle("react-flow__handle-valid",C))}function W(Z){var M,G;(T||q)&&B&&C&&(i==null||i(B)),(G=(M=l()).onConnectEnd)==null||G.call(M,Z),h&&(p==null||p(Z)),qd(P),k(),cancelAnimationFrame(E),V=!1,C=!1,B=null,q=null,d.removeEventListener("mousemove",J),d.removeEventListener("mouseup",W),d.removeEventListener("touchmove",J),d.removeEventListener("touchend",W)}d.addEventListener("mousemove",J),d.addEventListener("mouseup",W),d.addEventListener("touchmove",J),d.addEventListener("touchend",W)}const xx=()=>!0,gM=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),vM=(e,n,r)=>i=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=i;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===r||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===r,clickConnecting:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===r}},qN=j.forwardRef(({type:e="source",position:n=Ae.Top,isValidConnection:r,isConnectable:i=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:h,className:p,onMouseDown:d,onTouchStart:m,...y},w)=>{var z,P;const N=u||null,_=e==="target",b=Ct(),S=aM(),{connectOnClick:k,noPanClassName:E}=Ke(gM,Nt),{connecting:T,clickConnecting:I}=Ke(vM(S,N,e),Nt);S||(P=(z=b.getState()).onError)==null||P.call(z,"010",zr.error010());const O=D=>{const{defaultEdgeOptions:V,onConnect:B,hasDefaultEdges:C}=b.getState(),q={...V,...D};if(C){const{edges:L,setEdges:re}=b.getState();re(dM(q,L))}B==null||B(q),c==null||c(q)},A=D=>{if(!S)return;const V=NN(D);o&&(V&&D.button===0||!V)&&$N({event:D,handleId:N,nodeId:S,onConnect:O,isTarget:_,getState:b.getState,setState:b.setState,isValidConnection:r||b.getState().isValidConnection||xx}),V?d==null||d(D):m==null||m(D)},U=D=>{const{onClickConnectStart:V,onClickConnectEnd:B,connectionClickStartHandle:C,connectionMode:q,isValidConnection:L}=b.getState();if(!S||!C&&!o)return;if(!C){V==null||V(D,{nodeId:S,handleId:N,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:S,type:e,handleId:N}});return}const re=bN(D.target),J=r||L||xx,{connection:W,isValid:Z}=LN({nodeId:S,id:N,type:e},q,C.nodeId,C.handleId||null,C.type,J,re);Z&&O(W),B==null||B(D),b.setState({connectionClickStartHandle:null})};return ue.createElement("div",{"data-handleid":N,"data-nodeid":S,"data-handlepos":n,"data-id":`${S}-${N}-${e}`,className:Ft(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",E,p,{source:!_,target:_,connectable:i,connectablestart:o,connectableend:l,connecting:I,connectionindicator:i&&(o&&!T||l&&T)}]),onMouseDown:A,onTouchStart:A,onClick:k?U:void 0,ref:w,...y},h)});qN.displayName="Handle";var po=j.memo(qN);const DN=({data:e,isConnectable:n,targetPosition:r=Ae.Top,sourcePosition:i=Ae.Bottom})=>ue.createElement(ue.Fragment,null,ue.createElement(po,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label,ue.createElement(po,{type:"source",position:i,isConnectable:n}));DN.displayName="DefaultNode";var Nv=j.memo(DN);const FN=({data:e,isConnectable:n,sourcePosition:r=Ae.Bottom})=>ue.createElement(ue.Fragment,null,e==null?void 0:e.label,ue.createElement(po,{type:"source",position:r,isConnectable:n}));FN.displayName="InputNode";var zN=j.memo(FN);const BN=({data:e,isConnectable:n,targetPosition:r=Ae.Top})=>ue.createElement(ue.Fragment,null,ue.createElement(po,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label);BN.displayName="OutputNode";var UN=j.memo(BN);const ey=()=>null;ey.displayName="GroupNode";const yM=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),Ql=e=>e.id;function wM(e,n){return Nt(e.selectedNodes.map(Ql),n.selectedNodes.map(Ql))&&Nt(e.selectedEdges.map(Ql),n.selectedEdges.map(Ql))}const HN=j.memo(({onSelectionChange:e})=>{const n=Ct(),{selectedNodes:r,selectedEdges:i}=Ke(yM,wM);return j.useEffect(()=>{const o={nodes:r,edges:i};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[r,i,e]),null});HN.displayName="SelectionListener";const xM=e=>!!e.onSelectionChange;function _M({onSelectionChange:e}){const n=Ke(xM);return e||n?ue.createElement(HN,{onSelectionChange:e}):null}const bM=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function Qi(e,n){j.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function $e(e,n,r){j.useEffect(()=>{typeof n<"u"&&r({[e]:n})},[n])}const SM=({nodes:e,edges:n,defaultNodes:r,defaultEdges:i,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:h,nodesDraggable:p,nodesConnectable:d,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:w,elevateNodesOnSelect:N,minZoom:_,maxZoom:b,nodeExtent:S,onNodesChange:k,onEdgesChange:E,elementsSelectable:T,connectionMode:I,snapGrid:O,snapToGrid:A,translateExtent:U,connectOnClick:z,defaultEdgeOptions:P,fitView:D,fitViewOptions:V,onNodesDelete:B,onEdgesDelete:C,onNodeDrag:q,onNodeDragStart:L,onNodeDragStop:re,onSelectionDrag:J,onSelectionDragStart:W,onSelectionDragStop:Z,noPanClassName:M,nodeOrigin:G,rfId:K,autoPanOnConnect:$,autoPanOnNodeDrag:Q,onError:ne,connectionRadius:ae,isValidConnection:fe,nodeDragThreshold:te})=>{const{setNodes:ce,setEdges:Ce,setDefaultNodesAndEdges:ve,setMinZoom:je,setMaxZoom:ye,setTranslateExtent:Ee,setNodeExtent:Ye,reset:we}=Ke(bM,Nt),_e=Ct();return j.useEffect(()=>{const Be=i==null?void 0:i.map(it=>({...it,...P}));return ve(r,Be),()=>{we()}},[]),$e("defaultEdgeOptions",P,_e.setState),$e("connectionMode",I,_e.setState),$e("onConnect",o,_e.setState),$e("onConnectStart",l,_e.setState),$e("onConnectEnd",u,_e.setState),$e("onClickConnectStart",c,_e.setState),$e("onClickConnectEnd",h,_e.setState),$e("nodesDraggable",p,_e.setState),$e("nodesConnectable",d,_e.setState),$e("nodesFocusable",m,_e.setState),$e("edgesFocusable",y,_e.setState),$e("edgesUpdatable",w,_e.setState),$e("elementsSelectable",T,_e.setState),$e("elevateNodesOnSelect",N,_e.setState),$e("snapToGrid",A,_e.setState),$e("snapGrid",O,_e.setState),$e("onNodesChange",k,_e.setState),$e("onEdgesChange",E,_e.setState),$e("connectOnClick",z,_e.setState),$e("fitViewOnInit",D,_e.setState),$e("fitViewOnInitOptions",V,_e.setState),$e("onNodesDelete",B,_e.setState),$e("onEdgesDelete",C,_e.setState),$e("onNodeDrag",q,_e.setState),$e("onNodeDragStart",L,_e.setState),$e("onNodeDragStop",re,_e.setState),$e("onSelectionDrag",J,_e.setState),$e("onSelectionDragStart",W,_e.setState),$e("onSelectionDragStop",Z,_e.setState),$e("noPanClassName",M,_e.setState),$e("nodeOrigin",G,_e.setState),$e("rfId",K,_e.setState),$e("autoPanOnConnect",$,_e.setState),$e("autoPanOnNodeDrag",Q,_e.setState),$e("onError",ne,_e.setState),$e("connectionRadius",ae,_e.setState),$e("isValidConnection",fe,_e.setState),$e("nodeDragThreshold",te,_e.setState),Qi(e,ce),Qi(n,Ce),Qi(_,je),Qi(b,ye),Qi(U,Ee),Qi(S,Ye),null},_x={display:"none"},kM={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},WN="react-flow__node-desc",VN="react-flow__edge-desc",EM="react-flow__aria-live",NM=e=>e.ariaLiveMessage;function CM({rfId:e}){const n=Ke(NM);return ue.createElement("div",{id:`${EM}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:kM},n)}function TM({rfId:e,disableKeyboardA11y:n}){return ue.createElement(ue.Fragment,null,ue.createElement("div",{id:`${WN}-${e}`,style:_x},"Press enter or space to select a node.",!n&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),ue.createElement("div",{id:`${VN}-${e}`,style:_x},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&ue.createElement(CM,{rfId:e}))}var Sa=(e=null,n={actInsideInputWithModifier:!0})=>{const[r,i]=j.useState(!1),o=j.useRef(!1),l=j.useRef(new Set([])),[u,c]=j.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),d=p.reduce((m,y)=>m.concat(...y),[]);return[p,d]}return[[],[]]},[e]);return j.useEffect(()=>{const h=typeof document<"u"?document:null,p=(n==null?void 0:n.target)||h;if(e!==null){const d=w=>{if(o.current=w.ctrlKey||w.metaKey||w.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&bv(w))return!1;const _=Sx(w.code,c);l.current.add(w[_]),bx(u,l.current,!1)&&(w.preventDefault(),i(!0))},m=w=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&bv(w))return!1;const _=Sx(w.code,c);bx(u,l.current,!0)?(i(!1),l.current.clear()):l.current.delete(w[_]),w.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),i(!1)};return p==null||p.addEventListener("keydown",d),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{p==null||p.removeEventListener("keydown",d),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,i]),r};function bx(e,n,r){return e.filter(i=>r||i.length===n.size).some(i=>i.every(o=>n.has(o)))}function Sx(e,n){return n.includes(e)?"code":"key"}function GN(e,n,r,i){var c,h;const o=e.parentNode||e.parentId;if(!o)return r;const l=n.get(o),u=hi(l,i);return GN(l,n,{x:(r.x??0)+u.x,y:(r.y??0)+u.y,z:(((c=l[gt])==null?void 0:c.z)??0)>(r.z??0)?((h=l[gt])==null?void 0:h.z)??0:r.z??0},i)}function YN(e,n,r){e.forEach(i=>{var l;const o=i.parentNode||i.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||r!=null&&r[i.id]){const{x:u,y:c,z:h}=GN(i,e,{...i.position,z:((l=i[gt])==null?void 0:l.z)??0},n);i.positionAbsolute={x:u,y:c},i[gt].z=h,r!=null&&r[i.id]&&(i[gt].isParent=!0)}})}function Dd(e,n,r,i){const o=new Map,l={},u=i?1e3:0;return e.forEach(c=>{var w;const h=($n(c.zIndex)?c.zIndex:0)+(c.selected?u:0),p=n.get(c.id),d={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},m=c.parentNode||c.parentId;m&&(l[m]=!0);const y=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==c.type;Object.defineProperty(d,gt,{enumerable:!1,value:{handleBounds:y||(w=p==null?void 0:p[gt])==null?void 0:w.handleBounds,z:h}}),o.set(c.id,d)}),YN(o,r,l),o}function KN(e,n={}){const{getNodes:r,width:i,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:h,fitViewOnInitDone:p,fitViewOnInit:d,nodeOrigin:m}=e(),y=n.initial&&!p&&d;if(c&&h&&(y||!n.initial)){const N=r().filter(b=>{var k;const S=n.includeHiddenNodes?b.width&&b.height:!b.hidden;return(k=n.nodes)!=null&&k.length?S&&n.nodes.some(E=>E.id===b.id):S}),_=N.every(b=>b.width&&b.height);if(N.length>0&&_){const b=Ou(N,m),{x:S,y:k,zoom:E}=ON(b,i,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),T=Dr.translate(S,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(ui(h,n.duration),T):c.transform(h,T),!0}}return!1}function RM(e,n){return e.forEach(r=>{const i=n.get(r.id);i&&n.set(i.id,{...i,[gt]:i[gt],selected:r.selected})}),new Map(n)}function jM(e,n){return n.map(r=>{const i=e.find(o=>o.id===r.id);return i&&(r.selected=i.selected),r})}function Zl({changedNodes:e,changedEdges:n,get:r,set:i}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:h,hasDefaultEdges:p}=r();e!=null&&e.length&&(h&&i({nodeInternals:RM(e,o)}),u==null||u(e)),n!=null&&n.length&&(p&&i({edges:jM(n,l)}),c==null||c(n))}const Zi=()=>{},AM={zoomIn:Zi,zoomOut:Zi,zoomTo:Zi,getZoom:()=>1,setViewport:Zi,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Zi,fitBounds:Zi,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},IM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),MM=()=>{const e=Ct(),{d3Zoom:n,d3Selection:r}=Ke(IM,Nt);return j.useMemo(()=>r&&n?{zoomIn:o=>n.scaleBy(ui(r,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(ui(r,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(ui(r,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,h]=e.getState().transform,p=Dr.translate(o.x??u,o.y??c).scale(o.zoom??h);n.transform(ui(r,l==null?void 0:l.duration),p)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>KN(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:h,maxZoom:p}=e.getState(),d=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:p,m=c/2-o*d,y=h/2-l*d,w=Dr.translate(m,y).scale(d);n.transform(ui(r,u==null?void 0:u.duration),w)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:h,maxZoom:p}=e.getState(),{x:d,y:m,zoom:y}=ON(o,u,c,h,p,(l==null?void 0:l.padding)??.1),w=Dr.translate(d,m).scale(y);n.transform(ui(r,l==null?void 0:l.duration),w)},project:o=>{const{transform:l,snapToGrid:u,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),Ev(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:h}=e.getState();if(!h)return o;const{x:p,y:d}=h.getBoundingClientRect(),m={x:o.x-p,y:o.y-d};return Ev(m,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:h}=u.getBoundingClientRect(),p=AN(o,l);return{x:p.x+c,y:p.y+h}},viewportInitialized:!0}:AM,[n,r])};function ja(){const e=MM(),n=Ct(),r=j.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),i=j.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=j.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(b=>({...b}))},[]),l=j.useCallback(_=>{const{edges:b=[]}=n.getState();return b.find(S=>S.id===_)},[]),u=j.useCallback(_=>{const{getNodes:b,setNodes:S,hasDefaultNodes:k,onNodesChange:E}=n.getState(),T=b(),I=typeof _=="function"?_(T):_;if(k)S(I);else if(E){const O=I.length===0?T.map(A=>({type:"remove",id:A.id})):I.map(A=>({item:A,type:"reset"}));E(O)}},[]),c=j.useCallback(_=>{const{edges:b=[],setEdges:S,hasDefaultEdges:k,onEdgesChange:E}=n.getState(),T=typeof _=="function"?_(b):_;if(k)S(T);else if(E){const I=T.length===0?b.map(O=>({type:"remove",id:O.id})):T.map(O=>({item:O,type:"reset"}));E(I)}},[]),h=j.useCallback(_=>{const b=Array.isArray(_)?_:[_],{getNodes:S,setNodes:k,hasDefaultNodes:E,onNodesChange:T}=n.getState();if(E){const O=[...S(),...b];k(O)}else if(T){const I=b.map(O=>({item:O,type:"add"}));T(I)}},[]),p=j.useCallback(_=>{const b=Array.isArray(_)?_:[_],{edges:S=[],setEdges:k,hasDefaultEdges:E,onEdgesChange:T}=n.getState();if(E)k([...S,...b]);else if(T){const I=b.map(O=>({item:O,type:"add"}));T(I)}},[]),d=j.useCallback(()=>{const{getNodes:_,edges:b=[],transform:S}=n.getState(),[k,E,T]=S;return{nodes:_().map(I=>({...I})),edges:b.map(I=>({...I})),viewport:{x:k,y:E,zoom:T}}},[]),m=j.useCallback(({nodes:_,edges:b})=>{const{nodeInternals:S,getNodes:k,edges:E,hasDefaultNodes:T,hasDefaultEdges:I,onNodesDelete:O,onEdgesDelete:A,onNodesChange:U,onEdgesChange:z}=n.getState(),P=(_||[]).map(q=>q.id),D=(b||[]).map(q=>q.id),V=k().reduce((q,L)=>{const re=L.parentNode||L.parentId,J=!P.includes(L.id)&&re&&q.find(Z=>Z.id===re);return(typeof L.deletable=="boolean"?L.deletable:!0)&&(P.includes(L.id)||J)&&q.push(L),q},[]),B=E.filter(q=>typeof q.deletable=="boolean"?q.deletable:!0),C=B.filter(q=>D.includes(q.id));if(V||C){const q=MN(V,B),L=[...C,...q],re=L.reduce((J,W)=>(J.includes(W.id)||J.push(W.id),J),[]);if((I||T)&&(I&&n.setState({edges:E.filter(J=>!re.includes(J.id))}),T&&(V.forEach(J=>{S.delete(J.id)}),n.setState({nodeInternals:new Map(S)}))),re.length>0&&(A==null||A(L),z&&z(re.map(J=>({id:J,type:"remove"})))),V.length>0&&(O==null||O(V),U)){const J=V.map(W=>({id:W.id,type:"remove"}));U(J)}}},[]),y=j.useCallback(_=>{const b=JI(_),S=b?null:n.getState().nodeInternals.get(_.id);return!b&&!S?[null,null,b]:[b?_:px(S),S,b]},[]),w=j.useCallback((_,b=!0,S)=>{const[k,E,T]=y(_);return k?(S||n.getState().getNodes()).filter(I=>{if(!T&&(I.id===E.id||!I.positionAbsolute))return!1;const O=px(I),A=_v(O,k);return b&&A>0||A>=k.width*k.height}):[]},[]),N=j.useCallback((_,b,S=!0)=>{const[k]=y(_);if(!k)return!1;const E=_v(k,b);return S&&E>0||E>=k.width*k.height},[]);return j.useMemo(()=>({...e,getNodes:r,getNode:i,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:h,addEdges:p,toObject:d,deleteElements:m,getIntersectingNodes:w,isNodeIntersecting:N}),[e,r,i,o,l,u,c,h,p,d,m,w,N])}const OM={actInsideInputWithModifier:!1};var PM=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const r=Ct(),{deleteElements:i}=ja(),o=Sa(e,OM),l=Sa(n);j.useEffect(()=>{if(o){const{edges:u,getNodes:c}=r.getState(),h=c().filter(d=>d.selected),p=u.filter(d=>d.selected);i({nodes:h,edges:p}),r.setState({nodesSelectionActive:!1})}},[o]),j.useEffect(()=>{r.setState({multiSelectionActive:l})},[l])};function LM(e){const n=Ct();j.useEffect(()=>{let r;const i=()=>{var l,u;if(!e.current)return;const o=Gv(e.current);(o.height===0||o.width===0)&&((u=(l=n.getState()).onError)==null||u.call(l,"004",zr.error004())),n.setState({width:o.width||500,height:o.height||500})};return i(),window.addEventListener("resize",i),e.current&&(r=new ResizeObserver(()=>i()),r.observe(e.current)),()=>{window.removeEventListener("resize",i),r&&e.current&&r.unobserve(e.current)}},[])}const ty={position:"absolute",width:"100%",height:"100%",top:0,left:0},$M=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,Jl=e=>({x:e.x,y:e.y,zoom:e.k}),Ji=(e,n)=>e.target.closest(`.${n}`),kx=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Ex=e=>{const n=e.ctrlKey&&xu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},qM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),DM=({onMove:e,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:i,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:h=di.Free,zoomOnDoubleClick:p=!0,elementsSelectable:d,panOnDrag:m=!0,defaultViewport:y,translateExtent:w,minZoom:N,maxZoom:_,zoomActivationKeyCode:b,preventScrolling:S=!0,children:k,noWheelClassName:E,noPanClassName:T})=>{const I=j.useRef(),O=Ct(),A=j.useRef(!1),U=j.useRef(!1),z=j.useRef(null),P=j.useRef({x:0,y:0,zoom:0}),{d3Zoom:D,d3Selection:V,d3ZoomHandler:B,userSelectionActive:C}=Ke(qM,Nt),q=Sa(b),L=j.useRef(0),re=j.useRef(!1),J=j.useRef();return LM(z),j.useEffect(()=>{if(z.current){const W=z.current.getBoundingClientRect(),Z=wN().scaleExtent([N,_]).translateExtent(w),M=Ln(z.current).call(Z),G=Dr.translate(y.x,y.y).scale(ho(y.zoom,N,_)),K=[[0,0],[W.width,W.height]],$=Z.constrain()(G,K,w);Z.transform(M,$),Z.wheelDelta(Ex),O.setState({d3Zoom:Z,d3Selection:M,d3ZoomHandler:M.on("wheel.zoom"),transform:[$.x,$.y,$.k],domNode:z.current.closest(".react-flow")})}},[]),j.useEffect(()=>{V&&D&&(u&&!q&&!C?V.on("wheel.zoom",W=>{if(Ji(W,E))return!1;W.preventDefault(),W.stopImmediatePropagation();const Z=V.property("__zoom").k||1;if(W.ctrlKey&&l){const fe=Zn(W),te=Ex(W),ce=Z*Math.pow(2,te);D.scaleTo(V,ce,fe,W);return}const M=W.deltaMode===1?20:1;let G=h===di.Vertical?0:W.deltaX*M,K=h===di.Horizontal?0:W.deltaY*M;!xu()&&W.shiftKey&&h!==di.Vertical&&(G=W.deltaY*M,K=0),D.translateBy(V,-(G/Z)*c,-(K/Z)*c,{internal:!0});const $=Jl(V.property("__zoom")),{onViewportChangeStart:Q,onViewportChange:ne,onViewportChangeEnd:ae}=O.getState();clearTimeout(J.current),re.current||(re.current=!0,n==null||n(W,$),Q==null||Q($)),re.current&&(e==null||e(W,$),ne==null||ne($),J.current=setTimeout(()=>{r==null||r(W,$),ae==null||ae($),re.current=!1},150))},{passive:!1}):typeof B<"u"&&V.on("wheel.zoom",function(W,Z){if(!S&&W.type==="wheel"&&!W.ctrlKey||Ji(W,E))return null;W.preventDefault(),B.call(this,W,Z)},{passive:!1}))},[C,u,h,V,D,B,q,l,S,E,n,e,r]),j.useEffect(()=>{D&&D.on("start",W=>{var G,K;if(!W.sourceEvent||W.sourceEvent.internal)return null;L.current=(G=W.sourceEvent)==null?void 0:G.button;const{onViewportChangeStart:Z}=O.getState(),M=Jl(W.transform);A.current=!0,P.current=M,((K=W.sourceEvent)==null?void 0:K.type)==="mousedown"&&O.setState({paneDragging:!0}),Z==null||Z(M),n==null||n(W.sourceEvent,M)})},[D,n]),j.useEffect(()=>{D&&(C&&!A.current?D.on("zoom",null):C||D.on("zoom",W=>{var M;const{onViewportChange:Z}=O.getState();if(O.setState({transform:[W.transform.x,W.transform.y,W.transform.k]}),U.current=!!(i&&kx(m,L.current??0)),(e||Z)&&!((M=W.sourceEvent)!=null&&M.internal)){const G=Jl(W.transform);Z==null||Z(G),e==null||e(W.sourceEvent,G)}}))},[C,D,e,m,i]),j.useEffect(()=>{D&&D.on("end",W=>{if(!W.sourceEvent||W.sourceEvent.internal)return null;const{onViewportChangeEnd:Z}=O.getState();if(A.current=!1,O.setState({paneDragging:!1}),i&&kx(m,L.current??0)&&!U.current&&i(W.sourceEvent),U.current=!1,(r||Z)&&$M(P.current,W.transform)){const M=Jl(W.transform);P.current=M,clearTimeout(I.current),I.current=setTimeout(()=>{Z==null||Z(M),r==null||r(W.sourceEvent,M)},u?150:0)}})},[D,u,m,r,i]),j.useEffect(()=>{D&&D.filter(W=>{const Z=q||o,M=l&&W.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&W.button===1&&W.type==="mousedown"&&(Ji(W,"react-flow__node")||Ji(W,"react-flow__edge")))return!0;if(!m&&!Z&&!u&&!p&&!l||C||!p&&W.type==="dblclick"||Ji(W,E)&&W.type==="wheel"||Ji(W,T)&&(W.type!=="wheel"||u&&W.type==="wheel"&&!q)||!l&&W.ctrlKey&&W.type==="wheel"||!Z&&!u&&!M&&W.type==="wheel"||!m&&(W.type==="mousedown"||W.type==="touchstart")||Array.isArray(m)&&!m.includes(W.button)&&W.type==="mousedown")return!1;const G=Array.isArray(m)&&m.includes(W.button)||!W.button||W.button<=1;return(!W.ctrlKey||W.type==="wheel")&&G})},[C,D,o,l,u,p,m,d,q]),ue.createElement("div",{className:"react-flow__renderer",ref:z,style:ty},k)},FM=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function zM(){const{userSelectionActive:e,userSelectionRect:n}=Ke(FM,Nt);return e&&n?ue.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:n.width,height:n.height,transform:`translate(${n.x}px, ${n.y}px)`}}):null}function Nx(e,n){const r=n.parentNode||n.parentId,i=e.find(o=>o.id===r);if(i){const o=n.position.x+n.width-i.width,l=n.position.y+n.height-i.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(i.style={...i.style},i.style.width=i.style.width??i.width,i.style.height=i.style.height??i.height,o>0&&(i.style.width+=o),l>0&&(i.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);i.position.x=i.position.x-u,i.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);i.position.y=i.position.y-u,i.style.height+=u,n.position.y=0}i.width=i.style.width,i.height=i.style.height}}}function BM(e,n){if(e.some(i=>i.type==="reset"))return e.filter(i=>i.type==="reset").map(i=>i.item);const r=e.filter(i=>i.type==="add").map(i=>i.item);return n.reduce((i,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return i.push(o),i;const u={...o};for(const c of l)if(c)switch(c.type){case"select":{u.selected=c.selected;break}case"position":{typeof c.position<"u"&&(u.position=c.position),typeof c.positionAbsolute<"u"&&(u.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(u.dragging=c.dragging),u.expandParent&&Nx(i,u);break}case"dimensions":{typeof c.dimensions<"u"&&(u.width=c.dimensions.width,u.height=c.dimensions.height),typeof c.updateStyle<"u"&&(u.style={...u.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(u.resizing=c.resizing),u.expandParent&&Nx(i,u);break}case"remove":return i}return i.push(u),i},r)}function UM(e,n){return BM(e,n)}const Ns=(e,n)=>({id:e,type:"select",selected:n});function ro(e,n){return e.reduce((r,i)=>{const o=n.includes(i.id);return!i.selected&&o?(i.selected=!0,r.push(Ns(i.id,!0))):i.selected&&!o&&(i.selected=!1,r.push(Ns(i.id,!1))),r},[])}const Fd=(e,n)=>r=>{r.target===n.current&&(e==null||e(r))},HM=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),XN=j.memo(({isSelecting:e,selectionMode:n=ba.Full,panOnDrag:r,onSelectionStart:i,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:d,children:m})=>{const y=j.useRef(null),w=Ct(),N=j.useRef(0),_=j.useRef(0),b=j.useRef(),{userSelectionActive:S,elementsSelectable:k,dragging:E}=Ke(HM,Nt),T=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},I=B=>{l==null||l(B),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},O=B=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){B.preventDefault();return}u==null||u(B)},A=c?B=>c(B):void 0,U=B=>{const{resetSelectedElements:C,domNode:q}=w.getState();if(b.current=q==null?void 0:q.getBoundingClientRect(),!k||!e||B.button!==0||B.target!==y.current||!b.current)return;const{x:L,y:re}=Ts(B,b.current);C(),w.setState({userSelectionRect:{width:0,height:0,startX:L,startY:re,x:L,y:re}}),i==null||i(B)},z=B=>{const{userSelectionRect:C,nodeInternals:q,edges:L,transform:re,onNodesChange:J,onEdgesChange:W,nodeOrigin:Z,getNodes:M}=w.getState();if(!e||!b.current||!C)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const G=Ts(B,b.current),K=C.startX??0,$=C.startY??0,Q={...C,x:G.x<K?G.x:K,y:G.y<$?G.y:$,width:Math.abs(G.x-K),height:Math.abs(G.y-$)},ne=M(),ae=IN(q,Q,re,n===ba.Partial,!0,Z),fe=MN(ae,L).map(ce=>ce.id),te=ae.map(ce=>ce.id);if(N.current!==te.length){N.current=te.length;const ce=ro(ne,te);ce.length&&(J==null||J(ce))}if(_.current!==fe.length){_.current=fe.length;const ce=ro(L,fe);ce.length&&(W==null||W(ce))}w.setState({userSelectionRect:Q})},P=B=>{if(B.button!==0)return;const{userSelectionRect:C}=w.getState();!S&&C&&B.target===y.current&&(I==null||I(B)),w.setState({nodesSelectionActive:N.current>0}),T(),o==null||o(B)},D=B=>{S&&(w.setState({nodesSelectionActive:N.current>0}),o==null||o(B)),T()},V=k&&(e||S);return ue.createElement("div",{className:Ft(["react-flow__pane",{dragging:E,selection:e}]),onClick:V?void 0:Fd(I,y),onContextMenu:Fd(O,y),onWheel:Fd(A,y),onMouseEnter:V?void 0:h,onMouseDown:V?U:void 0,onMouseMove:V?z:p,onMouseUp:V?P:void 0,onMouseLeave:V?D:d,ref:y,style:ty},m,ue.createElement(zM,null))});XN.displayName="Pane";function QN(e,n){const r=e.parentNode||e.parentId;if(!r)return!1;const i=n.get(r);return i?i.selected?!0:QN(i,n):!1}function Cx(e,n,r){let i=e;do{if(i!=null&&i.matches(n))return!0;if(i===r.current)return!1;i=i.parentElement}while(i);return!1}function WM(e,n,r,i){return Array.from(e.values()).filter(o=>(o.selected||o.id===i)&&(!o.parentNode||o.parentId||!QN(o,e))&&(o.draggable||n&&typeof o.draggable>"u")).map(o=>{var l,u;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:r.x-(((l=o.positionAbsolute)==null?void 0:l.x)??0),y:r.y-(((u=o.positionAbsolute)==null?void 0:u.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function VM(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function ZN(e,n,r,i,o=[0,0],l){const u=VM(e,e.extent||i);let c=u;const h=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(h&&e.width&&e.height){const m=r.get(h),{x:y,y:w}=hi(m,o).positionAbsolute;c=m&&$n(y)&&$n(w)&&$n(m.width)&&$n(m.height)?[[y+e.width*o[0],w+e.height*o[1]],[y+m.width-e.width+e.width*o[0],w+m.height-e.height+e.height*o[1]]]:c}else l==null||l("005",zr.error005()),c=u;else if(e.extent&&h&&e.extent!=="parent"){const m=r.get(h),{x:y,y:w}=hi(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+w],[e.extent[1][0]+y,e.extent[1][1]+w]]}let p={x:0,y:0};if(h){const m=r.get(h);p=hi(m,o).positionAbsolute}const d=c&&c!=="parent"?Yv(n,c):n;return{position:{x:d.x-p.x,y:d.y-p.y},positionAbsolute:d}}function zd({nodeId:e,dragItems:n,nodeInternals:r}){const i=n.map(o=>({...r.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?i.find(o=>o.id===e):i[0],i]}const Tx=(e,n,r,i)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*i[0],y:u.height*i[1]};return l.map(h=>{const p=h.getBoundingClientRect();return{id:h.getAttribute("data-handleid"),position:h.getAttribute("data-handlepos"),x:(p.left-u.left-c.x)/r,y:(p.top-u.top-c.y)/r,...Gv(h)}})};function aa(e,n,r){return r===void 0?r:i=>{const o=n().nodeInternals.get(e);o&&r(i,{...o})}}function Cv({id:e,store:n,unselect:r=!1,nodeRef:i}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:u,nodeInternals:c,onError:h}=n.getState(),p=c.get(e);if(!p){h==null||h("012",zr.error012(e));return}n.setState({nodesSelectionActive:!1}),p.selected?(r||p.selected&&u)&&(l({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var d;return(d=i==null?void 0:i.current)==null?void 0:d.blur()})):o([e])}function GM(){const e=Ct();return j.useCallback(({sourceEvent:r})=>{const{transform:i,snapGrid:o,snapToGrid:l}=e.getState(),u=r.touches?r.touches[0].clientX:r.clientX,c=r.touches?r.touches[0].clientY:r.clientY,h={x:(u-i[0])/i[2],y:(c-i[1])/i[2]};return{xSnapped:l?o[0]*Math.round(h.x/o[0]):h.x,ySnapped:l?o[1]*Math.round(h.y/o[1]):h.y,...h}},[])}function Bd(e){return(n,r,i)=>e==null?void 0:e(n,i)}function JN({nodeRef:e,disabled:n=!1,noDragClassName:r,handleSelector:i,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=Ct(),[h,p]=j.useState(!1),d=j.useRef([]),m=j.useRef({x:null,y:null}),y=j.useRef(0),w=j.useRef(null),N=j.useRef({x:0,y:0}),_=j.useRef(null),b=j.useRef(!1),S=j.useRef(!1),k=j.useRef(!1),E=GM();return j.useEffect(()=>{if(e!=null&&e.current){const T=Ln(e.current),I=({x:U,y:z})=>{const{nodeInternals:P,onNodeDrag:D,onSelectionDrag:V,updateNodePositions:B,nodeExtent:C,snapGrid:q,snapToGrid:L,nodeOrigin:re,onError:J}=c.getState();m.current={x:U,y:z};let W=!1,Z={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&C){const G=Ou(d.current,re);Z=_a(G)}if(d.current=d.current.map(G=>{const K={x:U-G.distance.x,y:z-G.distance.y};L&&(K.x=q[0]*Math.round(K.x/q[0]),K.y=q[1]*Math.round(K.y/q[1]));const $=[[C[0][0],C[0][1]],[C[1][0],C[1][1]]];d.current.length>1&&C&&!G.extent&&($[0][0]=G.positionAbsolute.x-Z.x+C[0][0],$[1][0]=G.positionAbsolute.x+(G.width??0)-Z.x2+C[1][0],$[0][1]=G.positionAbsolute.y-Z.y+C[0][1],$[1][1]=G.positionAbsolute.y+(G.height??0)-Z.y2+C[1][1]);const Q=ZN(G,K,P,$,re,J);return W=W||G.position.x!==Q.position.x||G.position.y!==Q.position.y,G.position=Q.position,G.positionAbsolute=Q.positionAbsolute,G}),!W)return;B(d.current,!0,!0),p(!0);const M=o?D:Bd(V);if(M&&_.current){const[G,K]=zd({nodeId:o,dragItems:d.current,nodeInternals:P});M(_.current,G,K)}},O=()=>{if(!w.current)return;const[U,z]=_N(N.current,w.current);if(U!==0||z!==0){const{transform:P,panBy:D}=c.getState();m.current.x=(m.current.x??0)-U/P[2],m.current.y=(m.current.y??0)-z/P[2],D({x:U,y:z})&&I(m.current)}y.current=requestAnimationFrame(O)},A=U=>{var re;const{nodeInternals:z,multiSelectionActive:P,nodesDraggable:D,unselectNodesAndEdges:V,onNodeDragStart:B,onSelectionDragStart:C}=c.getState();S.current=!0;const q=o?B:Bd(C);(!u||!l)&&!P&&o&&((re=z.get(o))!=null&&re.selected||V()),o&&l&&u&&Cv({id:o,store:c,nodeRef:e});const L=E(U);if(m.current=L,d.current=WM(z,D,L,o),q&&d.current){const[J,W]=zd({nodeId:o,dragItems:d.current,nodeInternals:z});q(U.sourceEvent,J,W)}};if(n)T.on(".drag",null);else{const U=n2().on("start",z=>{const{domNode:P,nodeDragThreshold:D}=c.getState();D===0&&A(z),k.current=!1;const V=E(z);m.current=V,w.current=(P==null?void 0:P.getBoundingClientRect())||null,N.current=Ts(z.sourceEvent,w.current)}).on("drag",z=>{var B,C;const P=E(z),{autoPanOnNodeDrag:D,nodeDragThreshold:V}=c.getState();if(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!b.current&&S.current&&D&&(b.current=!0,O()),!S.current){const q=P.xSnapped-(((B=m==null?void 0:m.current)==null?void 0:B.x)??0),L=P.ySnapped-(((C=m==null?void 0:m.current)==null?void 0:C.y)??0);Math.sqrt(q*q+L*L)>V&&A(z)}(m.current.x!==P.xSnapped||m.current.y!==P.ySnapped)&&d.current&&S.current&&(_.current=z.sourceEvent,N.current=Ts(z.sourceEvent,w.current),I(P))}}).on("end",z=>{if(!(!S.current||k.current)&&(p(!1),b.current=!1,S.current=!1,cancelAnimationFrame(y.current),d.current)){const{updateNodePositions:P,nodeInternals:D,onNodeDragStop:V,onSelectionDragStop:B}=c.getState(),C=o?V:Bd(B);if(P(d.current,!1,!1),C){const[q,L]=zd({nodeId:o,dragItems:d.current,nodeInternals:D});C(z.sourceEvent,q,L)}}}).filter(z=>{const P=z.target;return!z.button&&(!r||!Cx(P,`.${r}`,e))&&(!i||Cx(P,i,e))});return T.call(U),()=>{T.on(".drag",null)}}}},[e,n,r,i,l,c,o,u,E]),h}function eC(){const e=Ct();return j.useCallback(r=>{const{nodeInternals:i,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:h,onError:p,nodesDraggable:d}=e.getState(),m=u().filter(k=>k.selected&&(k.draggable||d&&typeof k.draggable>"u")),y=c?h[0]:5,w=c?h[1]:5,N=r.isShiftPressed?4:1,_=r.x*y*N,b=r.y*w*N,S=m.map(k=>{if(k.positionAbsolute){const E={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+b};c&&(E.x=h[0]*Math.round(E.x/h[0]),E.y=h[1]*Math.round(E.y/h[1]));const{positionAbsolute:T,position:I}=ZN(k,E,i,o,void 0,p);k.position=I,k.positionAbsolute=T}return k});l(S,!0,!1)},[])}const lo={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var la=e=>{const n=({id:r,type:i,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:h,selected:p,onClick:d,onMouseEnter:m,onMouseMove:y,onMouseLeave:w,onContextMenu:N,onDoubleClick:_,style:b,className:S,isDraggable:k,isSelectable:E,isConnectable:T,isFocusable:I,selectNodesOnDrag:O,sourcePosition:A,targetPosition:U,hidden:z,resizeObserver:P,dragHandle:D,zIndex:V,isParent:B,noDragClassName:C,noPanClassName:q,initialized:L,disableKeyboardA11y:re,ariaLabel:J,rfId:W,hasHandleBounds:Z})=>{const M=Ct(),G=j.useRef(null),K=j.useRef(null),$=j.useRef(A),Q=j.useRef(U),ne=j.useRef(i),ae=E||k||d||m||y||w,fe=eC(),te=aa(r,M.getState,m),ce=aa(r,M.getState,y),Ce=aa(r,M.getState,w),ve=aa(r,M.getState,N),je=aa(r,M.getState,_),ye=we=>{const{nodeDragThreshold:_e}=M.getState();if(E&&(!O||!k||_e>0)&&Cv({id:r,store:M,nodeRef:G}),d){const Be=M.getState().nodeInternals.get(r);Be&&d(we,{...Be})}},Ee=we=>{if(!bv(we)&&!re)if(EN.includes(we.key)&&E){const _e=we.key==="Escape";Cv({id:r,store:M,unselect:_e,nodeRef:G})}else k&&p&&Object.prototype.hasOwnProperty.call(lo,we.key)&&(M.setState({ariaLiveMessage:`Moved selected node ${we.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),fe({x:lo[we.key].x,y:lo[we.key].y,isShiftPressed:we.shiftKey}))};j.useEffect(()=>()=>{K.current&&(P==null||P.unobserve(K.current),K.current=null)},[]),j.useEffect(()=>{if(G.current&&!z){const we=G.current;(!L||!Z||K.current!==we)&&(K.current&&(P==null||P.unobserve(K.current)),P==null||P.observe(we),K.current=we)}},[z,L,Z]),j.useEffect(()=>{const we=ne.current!==i,_e=$.current!==A,Be=Q.current!==U;G.current&&(we||_e||Be)&&(we&&(ne.current=i),_e&&($.current=A),Be&&(Q.current=U),M.getState().updateNodeDimensions([{id:r,nodeElement:G.current,forceUpdate:!0}]))},[r,i,A,U]);const Ye=JN({nodeRef:G,disabled:z||!k,noDragClassName:C,handleSelector:D,nodeId:r,isSelectable:E,selectNodesOnDrag:O});return z?null:ue.createElement("div",{className:Ft(["react-flow__node",`react-flow__node-${i}`,{[q]:k},S,{selected:p,selectable:E,parent:B,dragging:Ye}]),ref:G,style:{zIndex:V,transform:`translate(${c}px,${h}px)`,pointerEvents:ae?"all":"none",visibility:L?"visible":"hidden",...b},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:te,onMouseMove:ce,onMouseLeave:Ce,onContextMenu:ve,onClick:ye,onDoubleClick:je,onKeyDown:I?Ee:void 0,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-describedby":re?void 0:`${WN}-${W}`,"aria-label":J},ue.createElement(oM,{value:r},ue.createElement(e,{id:r,data:o,type:i,xPos:l,yPos:u,selected:p,isConnectable:T,sourcePosition:A,targetPosition:U,dragging:Ye,dragHandle:D,zIndex:V})))};return n.displayName="NodeWrapper",j.memo(n)};const YM=e=>{const n=e.getNodes().filter(r=>r.selected);return{...Ou(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function KM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:r}){const i=Ct(),{width:o,height:l,x:u,y:c,transformString:h,userSelectionActive:p}=Ke(YM,Nt),d=eC(),m=j.useRef(null);if(j.useEffect(()=>{var N;r||(N=m.current)==null||N.focus({preventScroll:!0})},[r]),JN({nodeRef:m}),p||!o||!l)return null;const y=e?N=>{const _=i.getState().getNodes().filter(b=>b.selected);e(N,_)}:void 0,w=N=>{Object.prototype.hasOwnProperty.call(lo,N.key)&&d({x:lo[N.key].x,y:lo[N.key].y,isShiftPressed:N.shiftKey})};return ue.createElement("div",{className:Ft(["react-flow__nodesselection","react-flow__container",n]),style:{transform:h}},ue.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:r?void 0:-1,onKeyDown:r?void 0:w,style:{width:o,height:l,top:c,left:u}}))}var XM=j.memo(KM);const QM=e=>e.nodesSelectionActive,tC=({children:e,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:h,onMoveStart:p,onMoveEnd:d,selectionKeyCode:m,selectionOnDrag:y,selectionMode:w,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:b,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:I,panOnScroll:O,panOnScrollSpeed:A,panOnScrollMode:U,zoomOnDoubleClick:z,panOnDrag:P,defaultViewport:D,translateExtent:V,minZoom:B,maxZoom:C,preventScrolling:q,onSelectionContextMenu:L,noWheelClassName:re,noPanClassName:J,disableKeyboardA11y:W})=>{const Z=Ke(QM),M=Sa(m),G=Sa(S),K=G||P,$=G||O,Q=M||y&&K!==!0;return PM({deleteKeyCode:c,multiSelectionKeyCode:b}),ue.createElement(DM,{onMove:h,onMoveStart:p,onMoveEnd:d,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:T,zoomOnPinch:I,panOnScroll:$,panOnScrollSpeed:A,panOnScrollMode:U,zoomOnDoubleClick:z,panOnDrag:!M&&K,defaultViewport:D,translateExtent:V,minZoom:B,maxZoom:C,zoomActivationKeyCode:k,preventScrolling:q,noWheelClassName:re,noPanClassName:J},ue.createElement(XN,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:K,isSelecting:!!Q,selectionMode:w},e,Z&&ue.createElement(XM,{onSelectionContextMenu:L,noPanClassName:J,disableKeyboardA11y:W})))};tC.displayName="FlowRenderer";var ZM=j.memo(tC);function JM(e){return Ke(j.useCallback(r=>e?IN(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function eO(e){const n={input:la(e.input||zN),default:la(e.default||Nv),output:la(e.output||UN),group:la(e.group||ey)},r={},i=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=la(e[l]||Nv),o),r);return{...n,...i}}const tO=({x:e,y:n,width:r,height:i,origin:o})=>!r||!i?{x:e,y:n}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:n}:{x:e-r*o[0],y:n-i*o[1]},nO=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),nC=e=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:i,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Ke(nO,Nt),c=JM(e.onlyRenderVisibleElements),h=j.useRef(),p=j.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const d=new ResizeObserver(m=>{const y=m.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));l(y)});return h.current=d,d},[]);return j.useEffect(()=>()=>{var d;(d=h==null?void 0:h.current)==null||d.disconnect()},[]),ue.createElement("div",{className:"react-flow__nodes",style:ty},c.map(d=>{var I,O,A;let m=d.type||"default";e.nodeTypes[m]||(u==null||u("003",zr.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,w=!!(d.draggable||n&&typeof d.draggable>"u"),N=!!(d.selectable||o&&typeof d.selectable>"u"),_=!!(d.connectable||r&&typeof d.connectable>"u"),b=!!(d.focusable||i&&typeof d.focusable>"u"),S=e.nodeExtent?Yv(d.positionAbsolute,e.nodeExtent):d.positionAbsolute,k=(S==null?void 0:S.x)??0,E=(S==null?void 0:S.y)??0,T=tO({x:k,y:E,width:d.width??0,height:d.height??0,origin:e.nodeOrigin});return ue.createElement(y,{key:d.id,id:d.id,className:d.className,style:d.style,type:m,data:d.data,sourcePosition:d.sourcePosition||Ae.Bottom,targetPosition:d.targetPosition||Ae.Top,hidden:d.hidden,xPos:k,yPos:E,xPosOrigin:T.x,yPosOrigin:T.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!d.selected,isDraggable:w,isSelectable:N,isConnectable:_,isFocusable:b,resizeObserver:p,dragHandle:d.dragHandle,zIndex:((I=d[gt])==null?void 0:I.z)??0,isParent:!!((O=d[gt])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!d.width&&!!d.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:d.ariaLabel,hasHandleBounds:!!((A=d[gt])!=null&&A.handleBounds)})}))};nC.displayName="NodeRenderer";var rO=j.memo(nC);const sO=(e,n,r)=>r===Ae.Left?e-n:r===Ae.Right?e+n:e,iO=(e,n,r)=>r===Ae.Top?e-n:r===Ae.Bottom?e+n:e,Rx="react-flow__edgeupdater",jx=({position:e,centerX:n,centerY:r,radius:i=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>ue.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:Ft([Rx,`${Rx}-${c}`]),cx:sO(n,i,e),cy:iO(r,i,e),r:i,stroke:"transparent",fill:"transparent"}),oO=()=>!0;var eo=e=>{const n=({id:r,className:i,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:h,animated:p,label:d,labelStyle:m,labelShowBg:y,labelBgStyle:w,labelBgPadding:N,labelBgBorderRadius:_,style:b,source:S,target:k,sourceX:E,sourceY:T,targetX:I,targetY:O,sourcePosition:A,targetPosition:U,elementsSelectable:z,hidden:P,sourceHandleId:D,targetHandleId:V,onContextMenu:B,onMouseEnter:C,onMouseMove:q,onMouseLeave:L,reconnectRadius:re,onReconnect:J,onReconnectStart:W,onReconnectEnd:Z,markerEnd:M,markerStart:G,rfId:K,ariaLabel:$,isFocusable:Q,isReconnectable:ne,pathOptions:ae,interactionWidth:fe,disableKeyboardA11y:te})=>{const ce=j.useRef(null),[Ce,ve]=j.useState(!1),[je,ye]=j.useState(!1),Ee=Ct(),Ye=j.useMemo(()=>`url('#${kv(G,K)}')`,[G,K]),we=j.useMemo(()=>`url('#${kv(M,K)}')`,[M,K]);if(P)return null;const _e=et=>{var Pt;const{edges:bt,addSelectedEdges:ht,unselectNodesAndEdges:vt,multiSelectionActive:hn}=Ee.getState(),Yt=bt.find(bn=>bn.id===r);Yt&&(z&&(Ee.setState({nodesSelectionActive:!1}),Yt.selected&&hn?(vt({nodes:[],edges:[Yt]}),(Pt=ce.current)==null||Pt.blur()):ht([r])),u&&u(et,Yt))},Be=oa(r,Ee.getState,c),it=oa(r,Ee.getState,B),ft=oa(r,Ee.getState,C),Ze=oa(r,Ee.getState,q),De=oa(r,Ee.getState,L),Je=(et,bt)=>{if(et.button!==0)return;const{edges:ht,isValidConnection:vt}=Ee.getState(),hn=bt?k:S,Yt=(bt?V:D)||null,Pt=bt?"target":"source",bn=vt||oO,gr=bt,Sn=ht.find(pn=>pn.id===r);ye(!0),W==null||W(et,Sn,Pt);const Bt=pn=>{ye(!1),Z==null||Z(pn,Sn,Pt)};$N({event:et,handleId:Yt,nodeId:hn,onConnect:pn=>J==null?void 0:J(Sn,pn),isTarget:gr,getState:Ee.getState,setState:Ee.setState,isValidConnection:bn,edgeUpdaterType:Pt,onReconnectEnd:Bt})},Xe=et=>Je(et,!0),Mt=et=>Je(et,!1),lt=()=>ve(!0),Qe=()=>ve(!1),Ot=!z&&!u,zt=et=>{var bt;if(!te&&EN.includes(et.key)&&z){const{unselectNodesAndEdges:ht,addSelectedEdges:vt,edges:hn}=Ee.getState();et.key==="Escape"?((bt=ce.current)==null||bt.blur(),ht({edges:[hn.find(Pt=>Pt.id===r)]})):vt([r])}};return ue.createElement("g",{className:Ft(["react-flow__edge",`react-flow__edge-${o}`,i,{selected:h,animated:p,inactive:Ot,updating:Ce}]),onClick:_e,onDoubleClick:Be,onContextMenu:it,onMouseEnter:ft,onMouseMove:Ze,onMouseLeave:De,onKeyDown:Q?zt:void 0,tabIndex:Q?0:void 0,role:Q?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":$===null?void 0:$||`Edge from ${S} to ${k}`,"aria-describedby":Q?`${VN}-${K}`:void 0,ref:ce},!je&&ue.createElement(e,{id:r,source:S,target:k,selected:h,animated:p,label:d,labelStyle:m,labelShowBg:y,labelBgStyle:w,labelBgPadding:N,labelBgBorderRadius:_,data:l,style:b,sourceX:E,sourceY:T,targetX:I,targetY:O,sourcePosition:A,targetPosition:U,sourceHandleId:D,targetHandleId:V,markerStart:Ye,markerEnd:we,pathOptions:ae,interactionWidth:fe}),ne&&ue.createElement(ue.Fragment,null,(ne==="source"||ne===!0)&&ue.createElement(jx,{position:A,centerX:E,centerY:T,radius:re,onMouseDown:Xe,onMouseEnter:lt,onMouseOut:Qe,type:"source"}),(ne==="target"||ne===!0)&&ue.createElement(jx,{position:U,centerX:I,centerY:O,radius:re,onMouseDown:Mt,onMouseEnter:lt,onMouseOut:Qe,type:"target"})))};return n.displayName="EdgeWrapper",j.memo(n)};function aO(e){const n={default:eo(e.default||bu),straight:eo(e.bezier||Qv),step:eo(e.step||Xv),smoothstep:eo(e.step||Mu),simplebezier:eo(e.simplebezier||Kv)},r={},i=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=eo(e[l]||bu),o),r);return{...n,...i}}function Ax(e,n,r=null){const i=((r==null?void 0:r.x)||0)+n.x,o=((r==null?void 0:r.y)||0)+n.y,l=(r==null?void 0:r.width)||n.width,u=(r==null?void 0:r.height)||n.height;switch(e){case Ae.Top:return{x:i+l/2,y:o};case Ae.Right:return{x:i+l,y:o+u/2};case Ae.Bottom:return{x:i+l/2,y:o+u};case Ae.Left:return{x:i,y:o+u/2}}}function Ix(e,n){return e?e.length===1||!n?e[0]:n&&e.find(r=>r.id===n)||null:null}const lO=(e,n,r,i,o,l)=>{const u=Ax(r,e,n),c=Ax(l,i,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function uO({sourcePos:e,targetPos:n,sourceWidth:r,sourceHeight:i,targetWidth:o,targetHeight:l,width:u,height:c,transform:h}){const p={x:Math.min(e.x,n.x),y:Math.min(e.y,n.y),x2:Math.max(e.x+r,n.x+o),y2:Math.max(e.y+i,n.y+l)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const d=_a({x:(0-h[0])/h[2],y:(0-h[1])/h[2],width:u/h[2],height:c/h[2]}),m=Math.max(0,Math.min(d.x2,p.x2)-Math.max(d.x,p.x)),y=Math.max(0,Math.min(d.y2,p.y2)-Math.max(d.y,p.y));return Math.ceil(m*y)>0}function Mx(e){var i,o,l,u,c;const n=((i=e==null?void 0:e[gt])==null?void 0:i.handleBounds)||null,r=n&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},n,!!r]}const cO=[{level:0,isMaxLevel:!0,edges:[]}];function dO(e,n,r=!1){let i=-1;const o=e.reduce((u,c)=>{var d,m;const h=$n(c.zIndex);let p=h?c.zIndex:0;if(r){const y=n.get(c.target),w=n.get(c.source),N=c.selected||(y==null?void 0:y.selected)||(w==null?void 0:w.selected),_=Math.max(((d=w==null?void 0:w[gt])==null?void 0:d.z)||0,((m=y==null?void 0:y[gt])==null?void 0:m.z)||0,1e3);p=(h?c.zIndex:0)+(N?_:0)}return u[p]?u[p].push(c):u[p]=[c],i=p>i?p:i,u},{}),l=Object.entries(o).map(([u,c])=>{const h=+u;return{edges:c,level:h,isMaxLevel:h===i}});return l.length===0?cO:l}function fO(e,n,r){const i=Ke(j.useCallback(o=>e?o.edges.filter(l=>{const u=n.get(l.source),c=n.get(l.target);return(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&uO({sourcePos:u.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:u.width,sourceHeight:u.height,targetWidth:c.width,targetHeight:c.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[e,n]));return dO(i,n,r)}const hO=({color:e="none",strokeWidth:n=1})=>ue.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),pO=({color:e="none",strokeWidth:n=1})=>ue.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Ox={[_u.Arrow]:hO,[_u.ArrowClosed]:pO};function mO(e){const n=Ct();return j.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(Ox,e)?Ox[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",zr.error009(e)),null)},[e])}const gO=({id:e,type:n,color:r,width:i=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const h=mO(n);return h?ue.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},ue.createElement(h,{color:r,strokeWidth:u})):null},vO=({defaultColor:e,rfId:n})=>r=>{const i=[];return r.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=kv(u,n);i.includes(c)||(o.push({id:c,color:u.color||e,...u}),i.push(c))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))},rC=({defaultColor:e,rfId:n})=>{const r=Ke(j.useCallback(vO({defaultColor:e,rfId:n}),[e,n]),(i,o)=>!(i.length!==o.length||i.some((l,u)=>l.id!==o[u].id)));return ue.createElement("defs",null,r.map(i=>ue.createElement(gO,{id:i.id,key:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient})))};rC.displayName="MarkerDefinitions";var yO=j.memo(rC);const wO=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),sC=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:r,rfId:i,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:h,onEdgeMouseLeave:p,onEdgeClick:d,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:N,reconnectRadius:_,children:b,disableKeyboardA11y:S})=>{const{edgesFocusable:k,edgesUpdatable:E,elementsSelectable:T,width:I,height:O,connectionMode:A,nodeInternals:U,onError:z}=Ke(wO,Nt),P=fO(n,U,r);return I?ue.createElement(ue.Fragment,null,P.map(({level:D,edges:V,isMaxLevel:B})=>ue.createElement("svg",{key:D,style:{zIndex:D},width:I,height:O,className:"react-flow__edges react-flow__container"},B&&ue.createElement(yO,{defaultColor:e,rfId:i}),ue.createElement("g",null,V.map(C=>{const[q,L,re]=Mx(U.get(C.source)),[J,W,Z]=Mx(U.get(C.target));if(!re||!Z)return null;let M=C.type||"default";o[M]||(z==null||z("011",zr.error011(M)),M="default");const G=o[M]||o.default,K=A===mi.Strict?W.target:(W.target??[]).concat(W.source??[]),$=Ix(L.source,C.sourceHandle),Q=Ix(K,C.targetHandle),ne=($==null?void 0:$.position)||Ae.Bottom,ae=(Q==null?void 0:Q.position)||Ae.Top,fe=!!(C.focusable||k&&typeof C.focusable>"u"),te=C.reconnectable||C.updatable,ce=typeof y<"u"&&(te||E&&typeof te>"u");if(!$||!Q)return z==null||z("008",zr.error008($,C)),null;const{sourceX:Ce,sourceY:ve,targetX:je,targetY:ye}=lO(q,$,ne,J,Q,ae);return ue.createElement(G,{key:C.id,id:C.id,className:Ft([C.className,l]),type:M,data:C.data,selected:!!C.selected,animated:!!C.animated,hidden:!!C.hidden,label:C.label,labelStyle:C.labelStyle,labelShowBg:C.labelShowBg,labelBgStyle:C.labelBgStyle,labelBgPadding:C.labelBgPadding,labelBgBorderRadius:C.labelBgBorderRadius,style:C.style,source:C.source,target:C.target,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle,markerEnd:C.markerEnd,markerStart:C.markerStart,sourceX:Ce,sourceY:ve,targetX:je,targetY:ye,sourcePosition:ne,targetPosition:ae,elementsSelectable:T,onContextMenu:u,onMouseEnter:c,onMouseMove:h,onMouseLeave:p,onClick:d,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:N,reconnectRadius:_,rfId:i,ariaLabel:C.ariaLabel,isFocusable:fe,isReconnectable:ce,pathOptions:"pathOptions"in C?C.pathOptions:void 0,interactionWidth:C.interactionWidth,disableKeyboardA11y:S})})))),b):null};sC.displayName="EdgeRenderer";var xO=j.memo(sC);const _O=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function bO({children:e}){const n=Ke(_O);return ue.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function SO(e){const n=ja(),r=j.useRef(!1);j.useEffect(()=>{!r.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),r.current=!0)},[e,n.viewportInitialized])}const kO={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},iC=({nodeId:e,handleType:n,style:r,type:i=Cs.Bezier,CustomComponent:o,connectionStatus:l})=>{var O,A,U;const{fromNode:u,handleId:c,toX:h,toY:p,connectionMode:d}=Ke(j.useCallback(z=>({fromNode:z.nodeInternals.get(e),handleId:z.connectionHandleId,toX:(z.connectionPosition.x-z.transform[0])/z.transform[2],toY:(z.connectionPosition.y-z.transform[1])/z.transform[2],connectionMode:z.connectionMode}),[e]),Nt),m=(O=u==null?void 0:u[gt])==null?void 0:O.handleBounds;let y=m==null?void 0:m[n];if(d===mi.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!u||!y)return null;const w=c?y.find(z=>z.id===c):y[0],N=w?w.x+w.width/2:(u.width??0)/2,_=w?w.y+w.height/2:u.height??0,b=(((A=u.positionAbsolute)==null?void 0:A.x)??0)+N,S=(((U=u.positionAbsolute)==null?void 0:U.y)??0)+_,k=w==null?void 0:w.position,E=k?kO[k]:null;if(!k||!E)return null;if(o)return ue.createElement(o,{connectionLineType:i,connectionLineStyle:r,fromNode:u,fromHandle:w,fromX:b,fromY:S,toX:h,toY:p,fromPosition:k,toPosition:E,connectionStatus:l});let T="";const I={sourceX:b,sourceY:S,sourcePosition:k,targetX:h,targetY:p,targetPosition:E};return i===Cs.Bezier?[T]=jN(I):i===Cs.Step?[T]=Sv({...I,borderRadius:0}):i===Cs.SmoothStep?[T]=Sv(I):i===Cs.SimpleBezier?[T]=RN(I):T=`M${b},${S} ${h},${p}`,ue.createElement("path",{d:T,fill:"none",className:"react-flow__connection-path",style:r})};iC.displayName="ConnectionLine";const EO=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function NO({containerStyle:e,style:n,type:r,component:i}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:h,connectionStatus:p}=Ke(EO,Nt);return!(o&&l&&c&&u)?null:ue.createElement("svg",{style:e,width:c,height:h,className:"react-flow__edges react-flow__connectionline react-flow__container"},ue.createElement("g",{className:Ft(["react-flow__connection",p])},ue.createElement(iC,{nodeId:o,handleType:l,style:n,type:r,CustomComponent:i,connectionStatus:p})))}function Px(e,n){return j.useRef(null),Ct(),j.useMemo(()=>n(e),[e])}const oC=({nodeTypes:e,edgeTypes:n,onMove:r,onMoveStart:i,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:h,onEdgeDoubleClick:p,onNodeMouseEnter:d,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:b,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:E,connectionLineContainerStyle:T,selectionKeyCode:I,selectionOnDrag:O,selectionMode:A,multiSelectionKeyCode:U,panActivationKeyCode:z,zoomActivationKeyCode:P,deleteKeyCode:D,onlyRenderVisibleElements:V,elementsSelectable:B,selectNodesOnDrag:C,defaultViewport:q,translateExtent:L,minZoom:re,maxZoom:J,preventScrolling:W,defaultMarkerColor:Z,zoomOnScroll:M,zoomOnPinch:G,panOnScroll:K,panOnScrollSpeed:$,panOnScrollMode:Q,zoomOnDoubleClick:ne,panOnDrag:ae,onPaneClick:fe,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Ce,onPaneScroll:ve,onPaneContextMenu:je,onEdgeContextMenu:ye,onEdgeMouseEnter:Ee,onEdgeMouseMove:Ye,onEdgeMouseLeave:we,onReconnect:_e,onReconnectStart:Be,onReconnectEnd:it,reconnectRadius:ft,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Je,elevateEdgesOnSelect:Xe,disableKeyboardA11y:Mt,nodeOrigin:lt,nodeExtent:Qe,rfId:Ot})=>{const zt=Px(e,eO),et=Px(n,aO);return SO(l),ue.createElement(ZM,{onPaneClick:fe,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Ce,onPaneContextMenu:je,onPaneScroll:ve,deleteKeyCode:D,selectionKeyCode:I,selectionOnDrag:O,selectionMode:A,onSelectionStart:_,onSelectionEnd:b,multiSelectionKeyCode:U,panActivationKeyCode:z,zoomActivationKeyCode:P,elementsSelectable:B,onMove:r,onMoveStart:i,onMoveEnd:o,zoomOnScroll:M,zoomOnPinch:G,zoomOnDoubleClick:ne,panOnScroll:K,panOnScrollSpeed:$,panOnScrollMode:Q,panOnDrag:ae,defaultViewport:q,translateExtent:L,minZoom:re,maxZoom:J,onSelectionContextMenu:N,preventScrolling:W,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Je,disableKeyboardA11y:Mt},ue.createElement(bO,null,ue.createElement(xO,{edgeTypes:et,onEdgeClick:c,onEdgeDoubleClick:p,onlyRenderVisibleElements:V,onEdgeContextMenu:ye,onEdgeMouseEnter:Ee,onEdgeMouseMove:Ye,onEdgeMouseLeave:we,onReconnect:_e,onReconnectStart:Be,onReconnectEnd:it,reconnectRadius:ft,defaultMarkerColor:Z,noPanClassName:Je,elevateEdgesOnSelect:!!Xe,disableKeyboardA11y:Mt,rfId:Ot},ue.createElement(NO,{style:k,type:S,component:E,containerStyle:T})),ue.createElement("div",{className:"react-flow__edgelabel-renderer"}),ue.createElement(rO,{nodeTypes:zt,onNodeClick:u,onNodeDoubleClick:h,onNodeMouseEnter:d,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,selectNodesOnDrag:C,onlyRenderVisibleElements:V,noPanClassName:Je,noDragClassName:Ze,disableKeyboardA11y:Mt,nodeOrigin:lt,nodeExtent:Qe,rfId:Ot})))};oC.displayName="GraphView";var CO=j.memo(oC);const Tv=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ks={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Tv,nodeExtent:Tv,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:mi.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:eM,isValidConnection:void 0},TO=()=>pj((e,n)=>({...ks,setNodes:r=>{const{nodeInternals:i,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:Dd(r,i,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:i={}}=n();e({edges:r.map(o=>({...i,...o}))})},setDefaultNodesAndEdges:(r,i)=>{const o=typeof r<"u",l=typeof i<"u",u=o?Dd(r,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?i:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:r=>{const{onNodesChange:i,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:h,nodeOrigin:p}=n(),d=h==null?void 0:h.querySelector(".react-flow__viewport");if(!d)return;const m=window.getComputedStyle(d),{m22:y}=new window.DOMMatrixReadOnly(m.transform),w=r.reduce((_,b)=>{const S=o.get(b.id);if(S!=null&&S.hidden)o.set(S.id,{...S,[gt]:{...S[gt],handleBounds:void 0}});else if(S){const k=Gv(b.nodeElement);!!(k.width&&k.height&&(S.width!==k.width||S.height!==k.height||b.forceUpdate))&&(o.set(S.id,{...S,[gt]:{...S[gt],handleBounds:{source:Tx(".source",b.nodeElement,y,p),target:Tx(".target",b.nodeElement,y,p)}},...k}),_.push({id:S.id,type:"dimensions",dimensions:k}))}return _},[]);YN(o,p);const N=u||l&&!u&&KN(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:N}),(w==null?void 0:w.length)>0&&(i==null||i(w))},updateNodePositions:(r,i=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=r.map(c=>{const h={id:c.id,type:"position",dragging:o};return i&&(h.positionAbsolute=c.positionAbsolute,h.position=c.position),h});l(u)},triggerNodeChanges:r=>{const{onNodesChange:i,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:h}=n();if(r!=null&&r.length){if(l){const p=UM(r,c()),d=Dd(p,o,u,h);e({nodeInternals:d})}i==null||i(r)}},addSelectedNodes:r=>{const{multiSelectionActive:i,edges:o,getNodes:l}=n();let u,c=null;i?u=r.map(h=>Ns(h,!0)):(u=ro(l(),r),c=ro(o,[])),Zl({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:i,edges:o,getNodes:l}=n();let u,c=null;i?u=r.map(h=>Ns(h,!0)):(u=ro(o,r),c=ro(l(),[])),Zl({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:r,edges:i}={})=>{const{edges:o,getNodes:l}=n(),u=r||l(),c=i||o,h=u.map(d=>(d.selected=!1,Ns(d.id,!1))),p=c.map(d=>Ns(d.id,!1));Zl({changedNodes:h,changedEdges:p,get:n,set:e})},setMinZoom:r=>{const{d3Zoom:i,maxZoom:o}=n();i==null||i.scaleExtent([r,o]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:i,minZoom:o}=n();i==null||i.scaleExtent([o,r]),e({maxZoom:r})},setTranslateExtent:r=>{var i;(i=n().d3Zoom)==null||i.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:i}=n(),l=i().filter(c=>c.selected).map(c=>Ns(c.id,!1)),u=r.filter(c=>c.selected).map(c=>Ns(c.id,!1));Zl({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:r=>{const{nodeInternals:i}=n();i.forEach(o=>{o.positionAbsolute=Yv(o.position,r)}),e({nodeExtent:r,nodeInternals:new Map(i)})},panBy:r=>{const{transform:i,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:h}=n();if(!u||!c||!r.x&&!r.y)return!1;const p=Dr.translate(i[0]+r.x,i[1]+r.y).scale(i[2]),d=[[0,0],[o,l]],m=u==null?void 0:u.constrain()(p,d,h);return u.transform(c,m),i[0]!==m.x||i[1]!==m.y||i[2]!==m.k},cancelConnection:()=>e({connectionNodeId:ks.connectionNodeId,connectionHandleId:ks.connectionHandleId,connectionHandleType:ks.connectionHandleType,connectionStatus:ks.connectionStatus,connectionStartHandle:ks.connectionStartHandle,connectionEndHandle:ks.connectionEndHandle}),reset:()=>e({...ks})}),Object.is),ny=({children:e})=>{const n=j.useRef(null);return n.current||(n.current=TO()),ue.createElement(GI,{value:n.current},e)};ny.displayName="ReactFlowProvider";const aC=({children:e})=>j.useContext(Iu)?ue.createElement(ue.Fragment,null,e):ue.createElement(ny,null,e);aC.displayName="ReactFlowWrapper";const RO={input:zN,default:Nv,output:UN,group:ey},jO={default:bu,straight:Qv,step:Xv,smoothstep:Mu,simplebezier:Kv},AO=[0,0],IO=[15,15],MO={x:0,y:0,zoom:1},OO={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},lC=j.forwardRef(({nodes:e,edges:n,defaultNodes:r,defaultEdges:i,className:o,nodeTypes:l=RO,edgeTypes:u=jO,onNodeClick:c,onEdgeClick:h,onInit:p,onMove:d,onMoveStart:m,onMoveEnd:y,onConnect:w,onConnectStart:N,onConnectEnd:_,onClickConnectStart:b,onClickConnectEnd:S,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:T,onNodeContextMenu:I,onNodeDoubleClick:O,onNodeDragStart:A,onNodeDrag:U,onNodeDragStop:z,onNodesDelete:P,onEdgesDelete:D,onSelectionChange:V,onSelectionDragStart:B,onSelectionDrag:C,onSelectionDragStop:q,onSelectionContextMenu:L,onSelectionStart:re,onSelectionEnd:J,connectionMode:W=mi.Strict,connectionLineType:Z=Cs.Bezier,connectionLineStyle:M,connectionLineComponent:G,connectionLineContainerStyle:K,deleteKeyCode:$="Backspace",selectionKeyCode:Q="Shift",selectionOnDrag:ne=!1,selectionMode:ae=ba.Full,panActivationKeyCode:fe="Space",multiSelectionKeyCode:te=xu()?"Meta":"Control",zoomActivationKeyCode:ce=xu()?"Meta":"Control",snapToGrid:Ce=!1,snapGrid:ve=IO,onlyRenderVisibleElements:je=!1,selectNodesOnDrag:ye=!0,nodesDraggable:Ee,nodesConnectable:Ye,nodesFocusable:we,nodeOrigin:_e=AO,edgesFocusable:Be,edgesUpdatable:it,elementsSelectable:ft,defaultViewport:Ze=MO,minZoom:De=.5,maxZoom:Je=2,translateExtent:Xe=Tv,preventScrolling:Mt=!0,nodeExtent:lt,defaultMarkerColor:Qe="#b1b1b7",zoomOnScroll:Ot=!0,zoomOnPinch:zt=!0,panOnScroll:et=!1,panOnScrollSpeed:bt=.5,panOnScrollMode:ht=di.Free,zoomOnDoubleClick:vt=!0,panOnDrag:hn=!0,onPaneClick:Yt,onPaneMouseEnter:Pt,onPaneMouseMove:bn,onPaneMouseLeave:gr,onPaneScroll:Sn,onPaneContextMenu:Bt,children:Fn,onEdgeContextMenu:pn,onEdgeDoubleClick:vr,onEdgeMouseEnter:Hr,onEdgeMouseMove:xi,onEdgeMouseLeave:Wr,onEdgeUpdate:ut,onEdgeUpdateStart:_i,onEdgeUpdateEnd:mn,onReconnect:Is,onReconnectStart:yr,onReconnectEnd:zn,reconnectRadius:kn=10,edgeUpdaterRadius:Vr=10,onNodesChange:Gr,onEdgesChange:Yr,noDragClassName:bi="nodrag",noWheelClassName:sr="nowheel",noPanClassName:Ms="nopan",fitView:En=!1,fitViewOptions:wr,connectOnClick:Os=!0,attributionPosition:Ps,proOptions:Tt,defaultEdgeOptions:xr,elevateNodesOnSelect:_r=!0,elevateEdgesOnSelect:Kt=!1,disableKeyboardA11y:Kr=!1,autoPanOnConnect:Si=!0,autoPanOnNodeDrag:nt=!0,connectionRadius:br=20,isValidConnection:Xr,onError:Ls,style:Qr,id:Zr,nodeDragThreshold:$s,...ir},St)=>{const qs=Zr||"1";return ue.createElement("div",{...ir,style:{...Qr,...OO},ref:St,className:Ft(["react-flow",o]),"data-testid":"rf__wrapper",id:Zr},ue.createElement(aC,null,ue.createElement(CO,{onInit:p,onMove:d,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:h,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:T,onNodeContextMenu:I,onNodeDoubleClick:O,nodeTypes:l,edgeTypes:u,connectionLineType:Z,connectionLineStyle:M,connectionLineComponent:G,connectionLineContainerStyle:K,selectionKeyCode:Q,selectionOnDrag:ne,selectionMode:ae,deleteKeyCode:$,multiSelectionKeyCode:te,panActivationKeyCode:fe,zoomActivationKeyCode:ce,onlyRenderVisibleElements:je,selectNodesOnDrag:ye,defaultViewport:Ze,translateExtent:Xe,minZoom:De,maxZoom:Je,preventScrolling:Mt,zoomOnScroll:Ot,zoomOnPinch:zt,zoomOnDoubleClick:vt,panOnScroll:et,panOnScrollSpeed:bt,panOnScrollMode:ht,panOnDrag:hn,onPaneClick:Yt,onPaneMouseEnter:Pt,onPaneMouseMove:bn,onPaneMouseLeave:gr,onPaneScroll:Sn,onPaneContextMenu:Bt,onSelectionContextMenu:L,onSelectionStart:re,onSelectionEnd:J,onEdgeContextMenu:pn,onEdgeDoubleClick:vr,onEdgeMouseEnter:Hr,onEdgeMouseMove:xi,onEdgeMouseLeave:Wr,onReconnect:Is??ut,onReconnectStart:yr??_i,onReconnectEnd:zn??mn,reconnectRadius:kn??Vr,defaultMarkerColor:Qe,noDragClassName:bi,noWheelClassName:sr,noPanClassName:Ms,elevateEdgesOnSelect:Kt,rfId:qs,disableKeyboardA11y:Kr,nodeOrigin:_e,nodeExtent:lt}),ue.createElement(SM,{nodes:e,edges:n,defaultNodes:r,defaultEdges:i,onConnect:w,onConnectStart:N,onConnectEnd:_,onClickConnectStart:b,onClickConnectEnd:S,nodesDraggable:Ee,nodesConnectable:Ye,nodesFocusable:we,edgesFocusable:Be,edgesUpdatable:it,elementsSelectable:ft,elevateNodesOnSelect:_r,minZoom:De,maxZoom:Je,nodeExtent:lt,onNodesChange:Gr,onEdgesChange:Yr,snapToGrid:Ce,snapGrid:ve,connectionMode:W,translateExtent:Xe,connectOnClick:Os,defaultEdgeOptions:xr,fitView:En,fitViewOptions:wr,onNodesDelete:P,onEdgesDelete:D,onNodeDragStart:A,onNodeDrag:U,onNodeDragStop:z,onSelectionDrag:C,onSelectionDragStart:B,onSelectionDragStop:q,noPanClassName:Ms,nodeOrigin:_e,rfId:qs,autoPanOnConnect:Si,autoPanOnNodeDrag:nt,onError:Ls,connectionRadius:br,isValidConnection:Xr,nodeDragThreshold:$s}),ue.createElement(_M,{onSelectionChange:V}),Fn,ue.createElement(KI,{proOptions:Tt,position:Ps}),ue.createElement(TM,{rfId:qs,disableKeyboardA11y:Kr})))});lC.displayName="ReactFlow";const PO=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function uC(){return Ke(PO,Nt)}const cC=({id:e,x:n,y:r,width:i,height:o,style:l,color:u,strokeColor:c,strokeWidth:h,className:p,borderRadius:d,shapeRendering:m,onClick:y,selected:w})=>{const{background:N,backgroundColor:_}=l||{},b=u||N||_;return ue.createElement("rect",{className:Ft(["react-flow__minimap-node",{selected:w},p]),x:n,y:r,rx:d,ry:d,width:i,height:o,fill:b,stroke:c,strokeWidth:h,shapeRendering:m,onClick:y?S=>y(S,e):void 0})};cC.displayName="MiniMapNode";var LO=j.memo(cC);const $O=e=>e.nodeOrigin,qO=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),Ud=e=>e instanceof Function?e:()=>e;function DO({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:o=2,nodeComponent:l=LO,onClick:u}){const c=Ke(qO,Nt),h=Ke($O),p=Ud(n),d=Ud(e),m=Ud(r),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ue.createElement(ue.Fragment,null,c.map(w=>{const{x:N,y:_}=hi(w,h).positionAbsolute;return ue.createElement(l,{key:w.id,x:N,y:_,width:w.width,height:w.height,style:w.style,selected:w.selected,className:m(w),color:p(w),borderRadius:i,strokeColor:d(w),strokeWidth:o,shapeRendering:y,onClick:u,id:w.id})}))}var FO=j.memo(DO);const zO=200,BO=150,UO=e=>{const n=e.getNodes(),r={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:r,boundingRect:n.length>0?ZI(Ou(n,e.nodeOrigin),r):r,rfId:e.rfId}},HO="react-flow__minimap-desc";function dC({style:e,className:n,nodeStrokeColor:r="transparent",nodeColor:i="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:h="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:d=1,position:m="bottom-right",onClick:y,onNodeClick:w,pannable:N=!1,zoomable:_=!1,ariaLabel:b="React Flow mini map",inversePan:S=!1,zoomStep:k=10,offsetScale:E=5}){const T=Ct(),I=j.useRef(null),{boundingRect:O,viewBB:A,rfId:U}=Ke(UO,Nt),z=(e==null?void 0:e.width)??zO,P=(e==null?void 0:e.height)??BO,D=O.width/z,V=O.height/P,B=Math.max(D,V),C=B*z,q=B*P,L=E*B,re=O.x-(C-O.width)/2-L,J=O.y-(q-O.height)/2-L,W=C+L*2,Z=q+L*2,M=`${HO}-${U}`,G=j.useRef(0);G.current=B,j.useEffect(()=>{if(I.current){const Q=Ln(I.current),ne=te=>{const{transform:ce,d3Selection:Ce,d3Zoom:ve}=T.getState();if(te.sourceEvent.type!=="wheel"||!Ce||!ve)return;const je=-te.sourceEvent.deltaY*(te.sourceEvent.deltaMode===1?.05:te.sourceEvent.deltaMode?1:.002)*k,ye=ce[2]*Math.pow(2,je);ve.scaleTo(Ce,ye)},ae=te=>{const{transform:ce,d3Selection:Ce,d3Zoom:ve,translateExtent:je,width:ye,height:Ee}=T.getState();if(te.sourceEvent.type!=="mousemove"||!Ce||!ve)return;const Ye=G.current*Math.max(1,ce[2])*(S?-1:1),we={x:ce[0]-te.sourceEvent.movementX*Ye,y:ce[1]-te.sourceEvent.movementY*Ye},_e=[[0,0],[ye,Ee]],Be=Dr.translate(we.x,we.y).scale(ce[2]),it=ve.constrain()(Be,_e,je);ve.transform(Ce,it)},fe=wN().on("zoom",N?ae:null).on("zoom.wheel",_?ne:null);return Q.call(fe),()=>{Q.on("zoom",null)}}},[N,_,S,k]);const K=y?Q=>{const ne=Zn(Q);y(Q,{x:ne[0],y:ne[1]})}:void 0,$=w?(Q,ne)=>{const ae=T.getState().nodeInternals.get(ne);w(Q,ae)}:void 0;return ue.createElement(Vv,{position:m,style:e,className:Ft(["react-flow__minimap",n]),"data-testid":"rf__minimap"},ue.createElement("svg",{width:z,height:P,viewBox:`${re} ${J} ${W} ${Z}`,role:"img","aria-labelledby":M,ref:I,onClick:K},b&&ue.createElement("title",{id:M},b),ue.createElement(FO,{onClick:$,nodeColor:i,nodeStrokeColor:r,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),ue.createElement("path",{className:"react-flow__minimap-mask",d:`M${re-L},${J-L}h${W+L*2}v${Z+L*2}h${-W-L*2}z
57
- M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:h,fillRule:"evenodd",stroke:p,strokeWidth:d,pointerEvents:"none"})))}dC.displayName="MiniMap";var WO=j.memo(dC);function VO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ue.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function GO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ue.createElement("path",{d:"M0 0h32v4.2H0z"}))}function YO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ue.createElement("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 KO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.createElement("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 XO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const so=({children:e,className:n,...r})=>ue.createElement("button",{type:"button",className:Ft(["react-flow__controls-button",n]),...r},e);so.displayName="ControlButton";const QO=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),fC=({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:i=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:h,className:p,children:d,position:m="bottom-left"})=>{const y=Ct(),[w,N]=j.useState(!1),{isInteractive:_,minZoomReached:b,maxZoomReached:S}=Ke(QO,Nt),{zoomIn:k,zoomOut:E,fitView:T}=ja();if(j.useEffect(()=>{N(!0)},[]),!w)return null;const I=()=>{k(),l==null||l()},O=()=>{E(),u==null||u()},A=()=>{T(o),c==null||c()},U=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),h==null||h(!_)};return ue.createElement(Vv,{className:Ft(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},n&&ue.createElement(ue.Fragment,null,ue.createElement(so,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ue.createElement(VO,null)),ue.createElement(so,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ue.createElement(GO,null))),r&&ue.createElement(so,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},ue.createElement(YO,null)),i&&ue.createElement(so,{className:"react-flow__controls-interactive",onClick:U,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ue.createElement(XO,null):ue.createElement(KO,null)),d)};fC.displayName="Controls";var ZO=j.memo(fC),er;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(er||(er={}));function JO({color:e,dimensions:n,lineWidth:r}){return ue.createElement("path",{stroke:e,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function eP({color:e,radius:n}){return ue.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const tP={[er.Dots]:"#91919a",[er.Lines]:"#eee",[er.Cross]:"#e2e2e2"},nP={[er.Dots]:1,[er.Lines]:1,[er.Cross]:6},rP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hC({id:e,variant:n=er.Dots,gap:r=20,size:i,lineWidth:o=1,offset:l=2,color:u,style:c,className:h}){const p=j.useRef(null),{transform:d,patternId:m}=Ke(rP,Nt),y=u||tP[n],w=i||nP[n],N=n===er.Dots,_=n===er.Cross,b=Array.isArray(r)?r:[r,r],S=[b[0]*d[2]||1,b[1]*d[2]||1],k=w*d[2],E=_?[k,k]:S,T=N?[k/l,k/l]:[E[0]/l,E[1]/l];return ue.createElement("svg",{className:Ft(["react-flow__background",h]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ue.createElement("pattern",{id:m+e,x:d[0]%S[0],y:d[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},N?ue.createElement(eP,{color:y,radius:k/l}):ue.createElement(JO,{dimensions:E,color:y,lineWidth:o})),ue.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}hC.displayName="Background";var sP=j.memo(hC);function pC(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function mC(e){const n=e.cache_creation,r=n&&typeof n=="object"?n:e,i=r.ephemeral_1h_input_tokens,o=r.ephemeral_5m_input_tokens;return typeof i!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(i??0),cacheCreate5mTokens:Number(o??0)}}function gC(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.input_tokens=="number"||typeof r.output_tokens=="number"||typeof r.cache_read_input_tokens=="number"||typeof r.cache_creation_input_tokens=="number")return{inputTokens:Number(r.input_tokens??0),outputTokens:Number(r.output_tokens??0),cacheReadTokens:Number(r.cache_read_input_tokens??0),cacheCreateTokens:Number(r.cache_creation_input_tokens??0),...mC(r)};for(const i of Object.values(r)){const o=gC(i,n+1);if(o)return o}return null}function iP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens,(n.cacheCreate1hTokens!==void 0||n.cacheCreate5mTokens!==void 0)&&(e.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(n.cacheCreate1hTokens??0),e.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(n.cacheCreate5mTokens??0))}const oP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function vC(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&oP.test(r.model))return r.model;for(const i of Object.values(r)){const o=vC(i,n+1);if(o)return o}return null}function Rv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function Rs(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Lx(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function Aa(e,n){return`${e}::${n}`}function Su(e){return e.agent_type??e.subagent_type??"subagent"}function ma(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function io(e,n,r,i){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:r,lastEventAt:r,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:i,usage:pC()},e.agents.set(o,l),l)}function yC(e,n,r,i){const o=Aa(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&i.cwd&&(l.cwd=i.cwd,l.cwdBasename=Rs(i.cwd));const u=Su(i);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function $x(e,n,r){const i=n.session_id??"unknown",o=ma(n);if(o){const h=yC(e,i,o,n);if(h)return h}const l=e.activeSubagentStack.get(i),u=l&&l.length>0?l[l.length-1]:null;if(u){const h=e.agents.get(Aa(i,u));if(h)return!h.cwd&&n.cwd&&(h.cwd=n.cwd,h.cwdBasename=Rs(n.cwd)),h}const c=io(e,i,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=Rs(n.cwd)),c.label==="session"&&n.cwd&&(c.label=Rs(n.cwd)??"session"),c}function aP(e,n,r,i,o){const l=Aa(n,r),u=io(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&i.cwd&&(c.cwd=i.cwd,c.cwdBasename=Rs(i.cwd));const h=Su(i);return h&&(c.label==="subagent"||!c.label)&&(c.label=h),c}return c={id:l,sessionId:n,label:Su(i),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:i.cwd,cwdBasename:Rs(i.cwd),toolCount:0,childCount:0,usage:pC()},e.agents.set(l,c),u.childCount+=1,c}function lP(e,n,r){const i=e.activeSubagentStack.get(n)??[];i.includes(r)||(i.push(r),e.activeSubagentStack.set(n,i))}function uP(e,n,r){const i=e.activeSubagentStack.get(n);if(i){for(let o=i.length-1;o>=0;o--)if(i[o]===r){i.splice(o,1);break}i.length===0&&e.activeSubagentStack.delete(n)}}function eu(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const r=JSON.stringify(e);return r.length>n?r.slice(0,n-1)+"…":r}catch{return String(e)}}const qx=200,cP=25;function dP(e,n){const r=n.tools;if(r.length>qx){const i=r.splice(0,r.length-qx);for(const o of i)e.toolIndex.delete(o.id),e.toolOwner.delete(o.id)}for(let i=r.length-cP-1;i>=0;i--){const o=r[i];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function fP(e,n,r){const i=e.toolIndex.get(r);if(i)return i;for(let o=n.tools.length-1;o>=0;o--)if(n.tools[o].id===r)return n.tools[o];return null}const Dx=2e3;function hP(e,n,r){for(let i=e.prompts.length-1;i>=0;i--){const o=e.prompts[i];if(o.at<n-Dx)return!1;if(o.text===r&&o.at<=n+Dx)return!0}return!1}function pP(e,n,r,i){if(e.agents.size<=r)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>i&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=r)break;e.agents.delete(u.id),l++}return l>0}function mP(e,n,r,i){const o=new Map;for(const[p,d]of e.agents){let m=o.get(d.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(d.sessionId,m)),m.ids.push(p),d.state==="done"&&d.endedAt!=null?m.endedAt=Math.max(m.endedAt,d.endedAt):m.live=!0}const l=[...o.values()].filter(p=>!p.live&&p.endedAt>0&&n-p.endedAt>i).sort((p,d)=>p.endedAt-d.endedAt);let c=[...o.values()].filter(p=>!p.live).length-r;if(c<=0)return!1;let h=!1;for(const p of l){if(c<=0)break;for(const d of p.ids)e.agents.delete(d);c--,h=!0}return h}function gP(e,n,r){let i=!1;for(const o of e.agents.values()){if(o.provider==="codex")continue;const l=e.agents.get(o.sessionId),u=(l==null?void 0:l.lastEventAt)??(l==null?void 0:l.startedAt);for(const c of o.tools){const h=Math.max(c.startedAt,u??c.startedAt);c.endedAt==null&&n-h>r&&(c.endedAt=h,c.ok=!1,c.errorPreview="session ended before this call returned",e.toolIndex.delete(c.id),e.toolOwner.delete(c.id),i=!0)}}return i}const Fx=90*6e4;function vP(e,n,r){let i=!1;for(const o of e.agents.values()){if(o.kind!=="root")continue;const l=o.lastEventAt??o.startedAt;if(!(n-l<=r)){o.waiting&&(o.waiting=null,i=!0),o.state==="active"&&(o.state="done",o.endedAt=l,o.reaped=!0,i=!0);for(const u of e.agents.values())u.sessionId!==o.sessionId||u.kind==="root"||u.state!=="active"||(u.state="done",u.endedAt=l,i=!0)}}return i}function yP(e){return e==="permission_prompt"?"permission":e==="idle_prompt"?"idle":null}const wP=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved"]);function xP(e,n){let r=null;for(const i of e.toolIndex.values()){const o=i.agentId?e.agents.get(i.agentId):void 0;!o||o.sessionId!==n||(!r||i.startedAt>r.startedAt)&&(r=i)}return r==null?void 0:r.explicitSubagentId}function _P(e,n,r,i,o){const l=r==="permission"?xP(e,n):void 0;return l?{kind:r,message:i,since:o,subagentId:l}:{kind:r,message:i,since:o}}function bP(e,n,r){if(e.kind!=="permission")return!0;const i=ma(n);return i==null?!0:e.subagentId!=null&&Aa(r,i)===e.subagentId}function zx(e,n){const r=n.epoch??null;if(r!==null&&r!==e.seqEpoch)e.seqEpoch=r,e.lastSeq=0;else if(n.seq<=e.lastSeq)return e;const i=n.payload??{},o=n.receivedAt,l=i.hook_event_name??"Unknown";if(l==="__clear")return{...Rv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=i.session_id??"unknown";if(!wP.has(l)){const d=e.agents.get(u);d!=null&&d.waiting&&bP(d.waiting,i,u)&&(d.waiting=null)}const c=e.agents.get(u);if(c&&o>(c.lastEventAt??0)&&(c.lastEventAt=o,c.reaped&&(c.reaped=!1,c.state="active",c.endedAt=void 0)),typeof i.model_context_window=="number"&&i.model_context_window>0){const d=e.agents.get(u);d&&(d.contextWindow=i.model_context_window)}if(typeof i.approval_policy=="string"&&i.approval_policy){const d=e.agents.get(u);d&&(d.approvalPolicy=i.approval_policy)}if(typeof i.context_tokens=="number"&&i.context_tokens>=0){const d=e.agents.get(u);d&&(d.context={...d.context??Lx(),currentContextTokens:i.context_tokens})}if(l==="ModelObserved"){const d=typeof i.model=="string"?i.model:null;if(d){const y=e.agents.get(u);y&&(y.model=d)}const m=i.subagentModels;if(m&&typeof m=="object")for(const[y,w]of Object.entries(m)){if(typeof w!="string")continue;const N=`${u}::${y}`,_=e.agents.get(N);_&&(_.model=w)}return e}if(l==="ContextObserved"){const d=i.context??null;if(d){const m=e.agents.get(u);if(m){const y=m.context??Lx(),w=(_,b)=>typeof d[_]=="number"?d[_]:b,N=Array.isArray(d.memoryFiles)?d.memoryFiles:Array.isArray(d.claudeMdFiles)?d.claudeMdFiles:null;m.context={msgsUser:w("msgsUser",y.msgsUser),msgsAssistant:w("msgsAssistant",y.msgsAssistant),toolUses:w("toolUses",y.toolUses),toolResults:w("toolResults",y.toolResults),systemReminders:w("systemReminders",y.systemReminders),currentContextTokens:w("currentContextTokens",y.currentContextTokens),memoryFiles:N??y.memoryFiles}}}return e}if(l==="UsageObserved"){const d=i.usage??null;if(d){const m=e.agents.get(u);if(m){m.usage.inputTokens=Number(d.input_tokens??0),m.usage.outputTokens=Number(d.output_tokens??0),m.usage.cacheReadTokens=Number(d.cache_read_input_tokens??d.cached_input_tokens??0),m.usage.cacheCreateTokens=Number(d.cache_creation_input_tokens??d.cache_write_input_tokens??0);const y=mC(d);m.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,m.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof d.reasoning_output_tokens=="number"&&(m.usage.reasoningOutputTokens=Number(d.reasoning_output_tokens))}}return e}const h=$x(e,i,o);h.provider||(h.provider=i.provider==="codex"?"codex":"claude");const p=vC(i);switch(p&&(h.model=p),l){case"SessionStart":{const d=io(e,u,o,!1);d.synthetic=!1,d.state="active",d.startedAt=d.startedAt||o,!d.cwd&&i.cwd&&(d.cwd=i.cwd,d.cwdBasename=Rs(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Rs(i.cwd)??"session");break}case"UserPromptSubmit":{for(const w of e.agents.values())w.sessionId===u&&w.kind==="subagent"&&w.state==="done"&&w.exitAt==null&&w.endedAt!=null&&w.endedAt<o&&(w.exitAt=o);const d=io(e,u,o,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const m=$x(e,i,o);m.state="active",m.exitAt=void 0,m.endedAt=void 0;const y=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";y&&!hP(m,o,y)&&(m.prompts.push({at:o,text:y}),m.firstPrompt||(m.firstPrompt=eu(y,120)));break}case"PreToolUse":{const d=i.tool_use_id?fP(e,h,i.tool_use_id):null;if(d){i.tool_name&&d.name==="?"&&(d.name=i.tool_name),d.endedAt==null&&!d.trimmed&&i.tool_input!==void 0&&(d.input=i.tool_input,d.inputPreview=eu(i.tool_input));break}const m=i.tool_use_id??`${h.id}:${h.toolCount}`,y=ma(i),w={id:m,name:i.tool_name??"?",input:i.tool_input,inputPreview:eu(i.tool_input),agentId:h.id,explicitSubagentId:y?Aa(u,y):void 0,startedAt:o};h.tools.push(w),h.toolCount+=1,h.state="active",e.toolIndex.set(m,w),e.toolOwner.set(m,h.id),dP(e,h);break}case"PostToolUse":case"PostToolUseFailure":{const d=i.tool_use_id;if(!d)break;let m=e.toolIndex.get(d),y=!1;if(!m)for(const _ of e.agents.values()){const b=_.tools.find(S=>S.id===d);if(b){m=b,y=!0;break}}if(!m)break;m.endedAt=o,m.ok=l==="PostToolUse",m.trimmed||(m.response=i.tool_response),l==="PostToolUseFailure"?m.errorPreview=eu(i.tool_response):y&&(m.errorPreview=void 0);const w=gC(i.tool_response);w&&(m.usage=w),e.toolIndex.delete(d);const N=e.toolOwner.get(d)??m.agentId;if(e.toolOwner.delete(d),N&&w){const _=e.agents.get(N);_&&iP(_.usage,w)}break}case"SubagentStart":{const d=ma(i);if(!d)break;const m=aP(e,u,d,i,o);m.state="active",m.startedAt=m.startedAt||o,m.exitAt=void 0,m.endedAt=void 0;const y=Su(i);y&&(m.label=y),lP(e,u,d);break}case"SubagentStop":{const d=ma(i);if(!d)break;const m=yC(e,u,d,i);if(!m)break;m.state="done",m.endedAt=o,uP(e,u,d);break}case"Stop":case"SessionEnd":{const d=io(e,u,o,!1);d.state="done",d.endedAt=o,e.activeSubagentStack.delete(u);break}case"Notification":{const d=yP(i.notification_type);if(!d)break;const m=io(e,u,o,!1),y=typeof i.message=="string"?i.message:"",w=m.waiting;m.waiting=w&&w.kind===d&&w.message===y?{...w,since:Math.min(w.since,o)}:_P(e,u,d,y,o);break}}return e}function ry(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}const SP=Date.UTC(2026,8,1);function kP(e){return e<SP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const EP=[{match:/^claude[-_](fable|mythos)[-_]5\b/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]5\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b/i,rates:kP},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75,cacheWrite1h:30}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]sonnet[-_]4\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]haiku[-_]4[-_.]5\b/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25,cacheWrite1h:2}},{match:/^claude[-_]haiku[-_]3[-_.]5\b/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1,cacheWrite1h:1.6}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^codex[-_]mini/i,rates:{input:1.5,output:6,cacheRead:.375,cacheWrite:0}},{match:/^o1[-_]pro/i,rates:{input:150,output:600,cacheRead:150,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o3[-_]pro/i,rates:{input:20,output:80,cacheRead:20,cacheWrite:0}},{match:/^o4[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0}},{match:/^o3\b/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}}];function NP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function mo(e,n=Date.now()){if(!e)return null;for(const r of EP)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function wC(e,n){const r=Math.max(0,e.cacheCreate1hTokens??0),i=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-r-i),l=i+o,u=n.cacheWrite1h??n.cacheWrite;return{tokens5m:l,tokens1h:r,usd5m:l*n.cacheWrite/1e6,usd1h:r*u/1e6}}function xC(e,n,r=Date.now()){if(!NP(n))return e.inputTokens;const i=mo(n,r),o=((i==null?void 0:i.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-o)}function dn(e,n,r=Date.now()){const i=mo(n,r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=xC(e,n,r)*i.input/1e6,l=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,c=wC(e,i),h=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:h,total:o+l+u+h}}const Bx=2e5,CP=1e6,TP=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],RP=[{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]codex[-_]spark/i,window:128e3},{match:/^gpt[-_]5[-_.]3[-_]codex/i,window:4e5},{match:/^gpt[-_]5[-_.]2/i,window:4e5},{match:/^gpt[-_]5/i,window:4e5},{match:/^codex[-_]mini/i,window:2e5},{match:/^o\d/i,window:2e5}];function jP(e){if(!e)return Bx;for(const n of TP)if(n.test(e))return CP;for(const n of RP)if(n.match.test(e))return n.window;return Bx}function _C(e,n){return typeof e=="number"&&e>0?e:jP(n)}const fu="not priced";function qe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const n=(e*100).toFixed(e<.1?1:0);if(Number(n)<100)return`${n}¢`}return e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function ku(e,n){if(e<=0||n<10)return null;const r=e/n,i=r*60;return i>=.01?`${qe(i)}/min`:`${qe(r*3600)}/hr`}const AP=new Set(["untrusted","on-request","on-failure"]);function IP(e){return typeof e!="string"||!e?null:AP.has(e)?!0:e==="never"?!1:null}function MP(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const n=IP(e.approvalPolicy);return n===!1?null:{label:"approvals not visible",detail:`${n===!0?`This session's approval policy is "${e.approvalPolicy}", so Codex can stop and ask you to approve a command.`:"This session's approval policy has not been read yet, so it may be able to stop and ask you to approve a command."}
57
+ M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:h,fillRule:"evenodd",stroke:p,strokeWidth:d,pointerEvents:"none"})))}dC.displayName="MiniMap";var WO=j.memo(dC);function VO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ue.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function GO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ue.createElement("path",{d:"M0 0h32v4.2H0z"}))}function YO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ue.createElement("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 KO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.createElement("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 XO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ue.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const so=({children:e,className:n,...r})=>ue.createElement("button",{type:"button",className:Ft(["react-flow__controls-button",n]),...r},e);so.displayName="ControlButton";const QO=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),fC=({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:i=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:h,className:p,children:d,position:m="bottom-left"})=>{const y=Ct(),[w,N]=j.useState(!1),{isInteractive:_,minZoomReached:b,maxZoomReached:S}=Ke(QO,Nt),{zoomIn:k,zoomOut:E,fitView:T}=ja();if(j.useEffect(()=>{N(!0)},[]),!w)return null;const I=()=>{k(),l==null||l()},O=()=>{E(),u==null||u()},A=()=>{T(o),c==null||c()},U=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),h==null||h(!_)};return ue.createElement(Vv,{className:Ft(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},n&&ue.createElement(ue.Fragment,null,ue.createElement(so,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ue.createElement(VO,null)),ue.createElement(so,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ue.createElement(GO,null))),r&&ue.createElement(so,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},ue.createElement(YO,null)),i&&ue.createElement(so,{className:"react-flow__controls-interactive",onClick:U,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ue.createElement(XO,null):ue.createElement(KO,null)),d)};fC.displayName="Controls";var ZO=j.memo(fC),er;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(er||(er={}));function JO({color:e,dimensions:n,lineWidth:r}){return ue.createElement("path",{stroke:e,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function eP({color:e,radius:n}){return ue.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const tP={[er.Dots]:"#91919a",[er.Lines]:"#eee",[er.Cross]:"#e2e2e2"},nP={[er.Dots]:1,[er.Lines]:1,[er.Cross]:6},rP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function hC({id:e,variant:n=er.Dots,gap:r=20,size:i,lineWidth:o=1,offset:l=2,color:u,style:c,className:h}){const p=j.useRef(null),{transform:d,patternId:m}=Ke(rP,Nt),y=u||tP[n],w=i||nP[n],N=n===er.Dots,_=n===er.Cross,b=Array.isArray(r)?r:[r,r],S=[b[0]*d[2]||1,b[1]*d[2]||1],k=w*d[2],E=_?[k,k]:S,T=N?[k/l,k/l]:[E[0]/l,E[1]/l];return ue.createElement("svg",{className:Ft(["react-flow__background",h]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ue.createElement("pattern",{id:m+e,x:d[0]%S[0],y:d[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${T[0]},-${T[1]})`},N?ue.createElement(eP,{color:y,radius:k/l}):ue.createElement(JO,{dimensions:E,color:y,lineWidth:o})),ue.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}hC.displayName="Background";var sP=j.memo(hC);function pC(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function mC(e){const n=e.cache_creation,r=n&&typeof n=="object"?n:e,i=r.ephemeral_1h_input_tokens,o=r.ephemeral_5m_input_tokens;return typeof i!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(i??0),cacheCreate5mTokens:Number(o??0)}}function gC(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.input_tokens=="number"||typeof r.output_tokens=="number"||typeof r.cache_read_input_tokens=="number"||typeof r.cache_creation_input_tokens=="number")return{inputTokens:Number(r.input_tokens??0),outputTokens:Number(r.output_tokens??0),cacheReadTokens:Number(r.cache_read_input_tokens??0),cacheCreateTokens:Number(r.cache_creation_input_tokens??0),...mC(r)};for(const i of Object.values(r)){const o=gC(i,n+1);if(o)return o}return null}function iP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens,(n.cacheCreate1hTokens!==void 0||n.cacheCreate5mTokens!==void 0)&&(e.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(n.cacheCreate1hTokens??0),e.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(n.cacheCreate5mTokens??0))}const oP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function vC(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&oP.test(r.model))return r.model;for(const i of Object.values(r)){const o=vC(i,n+1);if(o)return o}return null}function Rv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function Rs(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Lx(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function Aa(e,n){return`${e}::${n}`}function Su(e){return e.agent_type??e.subagent_type??"subagent"}function ma(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function io(e,n,r,i){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:r,lastEventAt:r,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:i,usage:pC()},e.agents.set(o,l),l)}function yC(e,n,r,i){const o=Aa(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&i.cwd&&(l.cwd=i.cwd,l.cwdBasename=Rs(i.cwd));const u=Su(i);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function $x(e,n,r){const i=n.session_id??"unknown",o=ma(n);if(o){const h=yC(e,i,o,n);if(h)return h}const l=e.activeSubagentStack.get(i),u=l&&l.length>0?l[l.length-1]:null;if(u){const h=e.agents.get(Aa(i,u));if(h)return!h.cwd&&n.cwd&&(h.cwd=n.cwd,h.cwdBasename=Rs(n.cwd)),h}const c=io(e,i,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=Rs(n.cwd)),c.label==="session"&&n.cwd&&(c.label=Rs(n.cwd)??"session"),c}function aP(e,n,r,i,o){const l=Aa(n,r),u=io(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&i.cwd&&(c.cwd=i.cwd,c.cwdBasename=Rs(i.cwd));const h=Su(i);return h&&(c.label==="subagent"||!c.label)&&(c.label=h),c}return c={id:l,sessionId:n,label:Su(i),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:i.cwd,cwdBasename:Rs(i.cwd),toolCount:0,childCount:0,usage:pC()},e.agents.set(l,c),u.childCount+=1,c}function lP(e,n,r){const i=e.activeSubagentStack.get(n)??[];i.includes(r)||(i.push(r),e.activeSubagentStack.set(n,i))}function uP(e,n,r){const i=e.activeSubagentStack.get(n);if(i){for(let o=i.length-1;o>=0;o--)if(i[o]===r){i.splice(o,1);break}i.length===0&&e.activeSubagentStack.delete(n)}}function eu(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const r=JSON.stringify(e);return r.length>n?r.slice(0,n-1)+"…":r}catch{return String(e)}}const qx=200,cP=25;function dP(e,n){const r=n.tools;if(r.length>qx){const i=r.splice(0,r.length-qx);for(const o of i)e.toolIndex.delete(o.id),e.toolOwner.delete(o.id)}for(let i=r.length-cP-1;i>=0;i--){const o=r[i];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function fP(e,n,r){const i=e.toolIndex.get(r);if(i)return i;for(let o=n.tools.length-1;o>=0;o--)if(n.tools[o].id===r)return n.tools[o];return null}const Dx=2e3;function hP(e,n,r){for(let i=e.prompts.length-1;i>=0;i--){const o=e.prompts[i];if(o.at<n-Dx)return!1;if(o.text===r&&o.at<=n+Dx)return!0}return!1}function pP(e,n,r,i){if(e.agents.size<=r)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>i&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=r)break;e.agents.delete(u.id),l++}return l>0}function mP(e,n,r,i){const o=new Map;for(const[p,d]of e.agents){let m=o.get(d.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(d.sessionId,m)),m.ids.push(p),d.state==="done"&&d.endedAt!=null?m.endedAt=Math.max(m.endedAt,d.endedAt):m.live=!0}const l=[...o.values()].filter(p=>!p.live&&p.endedAt>0&&n-p.endedAt>i).sort((p,d)=>p.endedAt-d.endedAt);let c=[...o.values()].filter(p=>!p.live).length-r;if(c<=0)return!1;let h=!1;for(const p of l){if(c<=0)break;for(const d of p.ids)e.agents.delete(d);c--,h=!0}return h}function gP(e,n,r){let i=!1;for(const o of e.agents.values()){if(o.provider==="codex")continue;const l=e.agents.get(o.sessionId),u=(l==null?void 0:l.lastEventAt)??(l==null?void 0:l.startedAt);for(const c of o.tools){const h=Math.max(c.startedAt,u??c.startedAt);c.endedAt==null&&n-h>r&&(c.endedAt=h,c.ok=!1,c.errorPreview="session ended before this call returned",e.toolIndex.delete(c.id),e.toolOwner.delete(c.id),i=!0)}}return i}const Fx=90*6e4;function vP(e,n,r){let i=!1;for(const o of e.agents.values()){if(o.kind!=="root")continue;const l=o.lastEventAt??o.startedAt;if(!(n-l<=r)){o.waiting&&(o.waiting=null,i=!0),o.state==="active"&&(o.state="done",o.endedAt=l,o.reaped=!0,i=!0);for(const u of e.agents.values())u.sessionId!==o.sessionId||u.kind==="root"||u.state!=="active"||(u.state="done",u.endedAt=l,i=!0);e.activeSubagentStack.delete(o.sessionId)}}return i}function yP(e){return e==="permission_prompt"?"permission":e==="idle_prompt"?"idle":null}const wP=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved"]);function xP(e,n){let r=null;for(const i of e.toolIndex.values()){const o=i.agentId?e.agents.get(i.agentId):void 0;!o||o.sessionId!==n||(!r||i.startedAt>r.startedAt)&&(r=i)}return r==null?void 0:r.explicitSubagentId}function _P(e,n,r,i,o){const l=r==="permission"?xP(e,n):void 0;return l?{kind:r,message:i,since:o,subagentId:l}:{kind:r,message:i,since:o}}function bP(e,n,r){if(e.kind!=="permission")return!0;const i=ma(n);return i==null?!0:e.subagentId!=null&&Aa(r,i)===e.subagentId}function zx(e,n){const r=n.epoch??null;if(r!==null&&r!==e.seqEpoch)e.seqEpoch=r,e.lastSeq=0;else if(n.seq<=e.lastSeq)return e;const i=n.payload??{},o=n.receivedAt,l=i.hook_event_name??"Unknown";if(l==="__clear")return{...Rv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=i.session_id??"unknown";if(!wP.has(l)){const d=e.agents.get(u);d!=null&&d.waiting&&bP(d.waiting,i,u)&&(d.waiting=null)}const c=e.agents.get(u);if(c&&o>(c.lastEventAt??0)&&(c.lastEventAt=o,c.reaped&&(c.reaped=!1,c.state="active",c.endedAt=void 0)),typeof i.model_context_window=="number"&&i.model_context_window>0){const d=e.agents.get(u);d&&(d.contextWindow=i.model_context_window)}if(typeof i.approval_policy=="string"&&i.approval_policy){const d=e.agents.get(u);d&&(d.approvalPolicy=i.approval_policy)}if(typeof i.context_tokens=="number"&&i.context_tokens>=0){const d=e.agents.get(u);d&&(d.context={...d.context??Lx(),currentContextTokens:i.context_tokens})}if(l==="ModelObserved"){const d=typeof i.model=="string"?i.model:null;if(d){const y=e.agents.get(u);y&&(y.model=d)}const m=i.subagentModels;if(m&&typeof m=="object")for(const[y,w]of Object.entries(m)){if(typeof w!="string")continue;const N=`${u}::${y}`,_=e.agents.get(N);_&&(_.model=w)}return e}if(l==="ContextObserved"){const d=i.context??null;if(d){const m=e.agents.get(u);if(m){const y=m.context??Lx(),w=(_,b)=>typeof d[_]=="number"?d[_]:b,N=Array.isArray(d.memoryFiles)?d.memoryFiles:Array.isArray(d.claudeMdFiles)?d.claudeMdFiles:null;m.context={msgsUser:w("msgsUser",y.msgsUser),msgsAssistant:w("msgsAssistant",y.msgsAssistant),toolUses:w("toolUses",y.toolUses),toolResults:w("toolResults",y.toolResults),systemReminders:w("systemReminders",y.systemReminders),currentContextTokens:w("currentContextTokens",y.currentContextTokens),memoryFiles:N??y.memoryFiles}}}return e}if(l==="UsageObserved"){const d=i.usage??null;if(d){const m=e.agents.get(u);if(m){m.usage.inputTokens=Number(d.input_tokens??0),m.usage.outputTokens=Number(d.output_tokens??0),m.usage.cacheReadTokens=Number(d.cache_read_input_tokens??d.cached_input_tokens??0),m.usage.cacheCreateTokens=Number(d.cache_creation_input_tokens??d.cache_write_input_tokens??0);const y=mC(d);m.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,m.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof d.reasoning_output_tokens=="number"&&(m.usage.reasoningOutputTokens=Number(d.reasoning_output_tokens))}}return e}const h=$x(e,i,o);h.provider||(h.provider=i.provider==="codex"?"codex":"claude");const p=vC(i);switch(p&&(h.model=p),l){case"SessionStart":{const d=io(e,u,o,!1);d.synthetic=!1,d.state="active",d.startedAt=d.startedAt||o,!d.cwd&&i.cwd&&(d.cwd=i.cwd,d.cwdBasename=Rs(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Rs(i.cwd)??"session");break}case"UserPromptSubmit":{for(const w of e.agents.values())w.sessionId===u&&w.kind==="subagent"&&w.state==="done"&&w.exitAt==null&&w.endedAt!=null&&w.endedAt<o&&(w.exitAt=o);const d=io(e,u,o,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const m=$x(e,i,o);m.state="active",m.exitAt=void 0,m.endedAt=void 0;const y=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";y&&!hP(m,o,y)&&(m.prompts.push({at:o,text:y}),m.firstPrompt||(m.firstPrompt=eu(y,120)));break}case"PreToolUse":{const d=i.tool_use_id?fP(e,h,i.tool_use_id):null;if(d){i.tool_name&&d.name==="?"&&(d.name=i.tool_name),d.endedAt==null&&!d.trimmed&&i.tool_input!==void 0&&(d.input=i.tool_input,d.inputPreview=eu(i.tool_input));break}const m=i.tool_use_id??`${h.id}:${h.toolCount}`,y=ma(i),w={id:m,name:i.tool_name??"?",input:i.tool_input,inputPreview:eu(i.tool_input),agentId:h.id,explicitSubagentId:y?Aa(u,y):void 0,startedAt:o};h.tools.push(w),h.toolCount+=1,h.state="active",e.toolIndex.set(m,w),e.toolOwner.set(m,h.id),dP(e,h);break}case"PostToolUse":case"PostToolUseFailure":{const d=i.tool_use_id;if(!d)break;let m=e.toolIndex.get(d),y=!1;if(!m)for(const _ of e.agents.values()){const b=_.tools.find(S=>S.id===d);if(b){m=b,y=!0;break}}if(!m)break;m.endedAt=o,m.ok=l==="PostToolUse",m.trimmed||(m.response=i.tool_response),l==="PostToolUseFailure"?m.errorPreview=eu(i.tool_response):y&&(m.errorPreview=void 0);const w=gC(i.tool_response);w&&(m.usage=w),e.toolIndex.delete(d);const N=e.toolOwner.get(d)??m.agentId;if(e.toolOwner.delete(d),N&&w){const _=e.agents.get(N);_&&iP(_.usage,w)}break}case"SubagentStart":{const d=ma(i);if(!d)break;const m=aP(e,u,d,i,o);m.state="active",m.startedAt=m.startedAt||o,m.exitAt=void 0,m.endedAt=void 0;const y=Su(i);y&&(m.label=y),lP(e,u,d);break}case"SubagentStop":{const d=ma(i);if(!d)break;const m=yC(e,u,d,i);if(!m)break;m.state="done",m.endedAt=o,uP(e,u,d);break}case"Stop":case"SessionEnd":{const d=io(e,u,o,!1);d.state="done",d.endedAt=o,e.activeSubagentStack.delete(u);break}case"Notification":{const d=yP(i.notification_type);if(!d)break;const m=io(e,u,o,!1),y=typeof i.message=="string"?i.message:"",w=m.waiting;m.waiting=w&&w.kind===d&&w.message===y?{...w,since:Math.min(w.since,o)}:_P(e,u,d,y,o);break}}return e}function ry(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}const SP=Date.UTC(2026,8,1);function kP(e){return e<SP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const EP=[{match:/^claude[-_](fable|mythos)[-_]5\b/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]5\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b/i,rates:kP},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75,cacheWrite1h:30}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]sonnet[-_]4\b/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]haiku[-_]4[-_.]5\b/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25,cacheWrite1h:2}},{match:/^claude[-_]haiku[-_]3[-_.]5\b/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1,cacheWrite1h:1.6}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:6.25}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^codex[-_]mini/i,rates:{input:1.5,output:6,cacheRead:.375,cacheWrite:0}},{match:/^o1[-_]pro/i,rates:{input:150,output:600,cacheRead:150,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o3[-_]pro/i,rates:{input:20,output:80,cacheRead:20,cacheWrite:0}},{match:/^o4[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0}},{match:/^o3\b/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}}];function NP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function mo(e,n=Date.now()){if(!e)return null;for(const r of EP)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function wC(e,n){const r=Math.max(0,e.cacheCreate1hTokens??0),i=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-r-i),l=i+o,u=n.cacheWrite1h??n.cacheWrite;return{tokens5m:l,tokens1h:r,usd5m:l*n.cacheWrite/1e6,usd1h:r*u/1e6}}function xC(e,n,r=Date.now()){if(!NP(n))return e.inputTokens;const i=mo(n,r),o=((i==null?void 0:i.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-o)}function dn(e,n,r=Date.now()){const i=mo(n,r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=xC(e,n,r)*i.input/1e6,l=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,c=wC(e,i),h=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:h,total:o+l+u+h}}const Bx=2e5,CP=1e6,TP=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],RP=[{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]codex[-_]spark/i,window:128e3},{match:/^gpt[-_]5[-_.]3[-_]codex/i,window:4e5},{match:/^gpt[-_]5[-_.]2/i,window:4e5},{match:/^gpt[-_]5/i,window:4e5},{match:/^codex[-_]mini/i,window:2e5},{match:/^o\d/i,window:2e5}];function jP(e){if(!e)return Bx;for(const n of TP)if(n.test(e))return CP;for(const n of RP)if(n.match.test(e))return n.window;return Bx}function _C(e,n){return typeof e=="number"&&e>0?e:jP(n)}const fu="not priced";function qe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const n=(e*100).toFixed(e<.1?1:0);if(Number(n)<100)return`${n}¢`}return e<100?`$${e.toFixed(2)}`:e<1e4?`$${e.toFixed(0)}`:`$${(e/1e3).toFixed(1)}k`}function ku(e,n){if(e<=0||n<10)return null;const r=e/n,i=r*60;return i>=.01?`${qe(i)}/min`:`${qe(r*3600)}/hr`}const AP=new Set(["untrusted","on-request","on-failure"]);function IP(e){return typeof e!="string"||!e?null:AP.has(e)?!0:e==="never"?!1:null}function MP(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const n=IP(e.approvalPolicy);return n===!1?null:{label:"approvals not visible",detail:`${n===!0?`This session's approval policy is "${e.approvalPolicy}", so Codex can stop and ask you to approve a command.`:"This session's approval policy has not been read yet, so it may be able to stop and ask you to approve a command."}
58
58
 
59
59
  Codex writes no approval request to its rollout files, which are the only thing this deck can read — so when it does ask, this card, the sidebar, the topbar count, the tab title and the favicon will all stay silent. Check the terminal.`}}const OP=1;function PP(){const e=[];let n=0;function r(){let i;for(const o of e)(!i||o.layer>i.layer||o.layer===i.layer&&o.seq>i.seq)&&(i=o);return i}return{push(i,o=0){const l={dismiss:i,layer:o,seq:n++};return e.push(l),()=>{const u=e.indexOf(l);u!==-1&&e.splice(u,1)}},dismissTop(){const i=r();return i?(i.dismiss(),!0):!1},isTop(i){const o=r();return o!=null&&o.dismiss===i},depth(){return e.length}}}const Eu=PP();function LP(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Ux(e){return String(e.tagName??"").toUpperCase()==="BODY"}function $P(e,n){return!e||!e.isConnected||Ux(e)?!1:n==null||Ux(n)}const Hx="a[href], button, input, select, textarea, [tabindex]";function qP(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function DP(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const n=String(e.overflow??"").toLowerCase();return n==="auto"||n==="scroll"}function FP({count:e,index:n,shiftKey:r}){return e<=0?{kind:"hold"}:n<0||n>=e?{kind:"focus",index:r?e-1:0}:!r&&n===e-1?{kind:"focus",index:0}:r&&n===0?{kind:"focus",index:e-1}:{kind:"allow"}}function bC(e){return e.ctrlKey||e.metaKey||e.altKey}const zP=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),BP=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),UP=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function SC(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function sy(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=SC(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!zP.has(String(e.type??"text").toLowerCase())}function HP(e){if(!e)return!1;if(sy(e)||BP.has(SC(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>UP.has(r))}function kC(e){return e?Array.from(e.querySelectorAll("*")).filter(n=>{if(n.matches(Hx))return qP({disabled:n.disabled,tabIndex:n.tabIndex,rendered:n.getClientRects().length>0});const r=n.scrollHeight>n.clientHeight;return r&&DP({overflowing:r,overflow:getComputedStyle(n).overflowY,hasFocusable:n.querySelector(Hx)!=null})}):[]}function WP(e,n){const r=kC(e);if(!n||!e.contains(n)||r.includes(n))return r;const i=r.findIndex(o=>(n.compareDocumentPosition(o)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return i===-1?[...r,n]:[...r.slice(0,i),n,...r.slice(i)]}function yo(e,n={}){const{focusRef:r,layer:i}=n,o=j.useRef(null),l=j.useRef(e);l.current=e;const u=j.useRef(null);u.current===null&&(u.current=()=>l.current());const c=u.current;return j.useEffect(()=>Eu.push(c,i),[c,i]),j.useEffect(()=>{var p;const h=document.activeElement;return(p=(r==null?void 0:r.current)??kC(o.current)[0])==null||p.focus(),()=>{$P(h,document.activeElement)&&h.focus()}},[]),j.useEffect(()=>{const h=p=>{var _;if(p.key!=="Tab"||bC(p))return;const d=o.current;if(!d)return;const m=document.activeElement;if(!(m!=null&&d.contains(m))&&!Eu.isTop(c))return;const w=WP(d,m),N=FP({count:w.length,index:m?w.indexOf(m):-1,shiftKey:p.shiftKey});N.kind!=="allow"&&(p.preventDefault(),N.kind==="focus"&&((_=w[N.index])==null||_.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[c]),o}function VP(e){return e==="codex"?{subtitle:"reported by the Codex CLI — as of its most recent request",windowScope:"last request",compositionCounted:!1,compositionUncounted:"Not counted for Codex — the deck reconstructs the session from its rollout file and skips whatever was written before it attached, so a message and tool-call breakdown here would be short by an unknown amount. The window figure above is the CLI's own and is unaffected.",memoryHeading:"AGENTS.md files in scope",memoryEmpty:"No AGENTS.md files found on the path from cwd to the filesystem root, or in $CODEX_HOME."}:{subtitle:"approximation — CC's /context isn't hook-exposed",windowScope:"current turn",compositionCounted:!0,compositionUncounted:"",memoryHeading:"CLAUDE.md files in scope",memoryEmpty:"No CLAUDE.md files found on the path from cwd to ~/.claude."}}function Pn(e){return e.toLocaleString()}function GP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const YP=60;function KP(e,n=YP){if(e.length<=n)return e;const r=e.slice(e.length-(n-1)),i=r.search(/[/\\]/);return"…"+(i===-1?r:r.slice(i))}function XP({agent:e,onClose:n}){var y;const r=j.useRef(null),i=yo(n,{focusRef:r}),o=e.context,l=e.usage,u=(o==null?void 0:o.currentContextTokens)??0,c=_C(e.contextWindow,e.model),h=Math.min(100,u/c*100),p=dn(l,e.model),d=l.inputTokens+l.cacheReadTokens+l.cacheCreateTokens,m=VP(e.provider);return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{ref:i,className:"ctx-modal",onClick:w=>w.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[g.jsxs("header",{className:"ctx-modal-head",children:[g.jsxs("div",{children:[g.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),g.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),g.jsx("button",{type:"button",ref:r,className:"ctx-modal-close",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),g.jsxs("section",{className:"ctx-window-row",children:[g.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${h}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),g.jsxs("span",{children:[Pn(u)," / ",Pn(c)," tok (",m.windowScope,")"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Qn,{label:"input tokens",val:Pn(l.inputTokens)}),g.jsx(Qn,{label:"output tokens",val:Pn(l.outputTokens)}),g.jsx(Qn,{label:"cache reads",val:Pn(l.cacheReadTokens)}),g.jsx(Qn,{label:"cache writes",val:Pn(l.cacheCreateTokens)}),g.jsx(Qn,{label:"cumulative total",val:Pn(d)}),g.jsx(Qn,{label:"estimated cost",val:qe(p.total),accent:!0})]}),g.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Qn,{label:"user messages",val:Pn((o==null?void 0:o.msgsUser)??0)}),g.jsx(Qn,{label:"assistant messages",val:Pn((o==null?void 0:o.msgsAssistant)??0)}),g.jsx(Qn,{label:"tool uses",val:Pn((o==null?void 0:o.toolUses)??0)}),g.jsx(Qn,{label:"tool results",val:Pn((o==null?void 0:o.toolResults)??0)}),g.jsx(Qn,{label:"system-reminders",val:Pn((o==null?void 0:o.systemReminders)??0)})]}):g.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),g.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((y=o==null?void 0:o.memoryFiles)==null?void 0:y.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):g.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(w=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:w.path,children:KP(w.path)}),g.jsx("span",{className:"ctx-md-size",children:GP(w.bytes)})]},w.path))})]})})}function Qn({label:e,val:n,accent:r}){return g.jsxs("div",{className:`ctx-row${r?" accent":""}`,children:[g.jsx("span",{className:"ctx-row-label",children:e}),g.jsx("span",{className:"ctx-row-val",children:n})]})}function QP({currentContextTokens:e,modelId:n,contextWindow:r,size:i=26,onClick:o,title:l}){const u=_C(r,n),c=Math.min(1,e/u),h=i/2-3,p=i/2,d=2*Math.PI*h,m=d*c,y=c>.9?"var(--err)":c>.7?"var(--inflight)":"var(--accent)";return g.jsx("button",{type:"button",className:"ctx-donut",onClick:o,title:l??`context: ${e.toLocaleString()} / ${u.toLocaleString()} (${(c*100).toFixed(1)}%)`,"aria-label":"Show context breakdown",children:g.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[g.jsx("circle",{cx:p,cy:p,r:h,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:p,cy:p,r:h,stroke:y,strokeWidth:"2.5",fill:"none",strokeDasharray:`${m} ${d-m}`,strokeDashoffset:d/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),g.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function Wx(e,n){const r=mo(n);if(!r)return`model: ${n}
60
60
  no published rate in this build — the tokens are counted, the dollars are not`;const i=d=>d.toLocaleString(),o=d=>`$${d}/MTok`,l=dn(e,n),u=wC(e,r),c=u.tokens1h>0?[`cache w5m${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${qe(u.usd5m)}`,`cache w1h${i(u.tokens1h).padStart(14)} × ${o(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${qe(u.usd1h)}`]:[`cache w ${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${qe(u.usd5m)}`],h=xC(e,n),p=h===e.inputTokens?"input":"uncached";return[`model: ${n}`,`${p.padEnd(9)}${i(h).padStart(14)} × ${o(r.input).padEnd(11)} = ${qe(l.input)}`,`output ${i(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${qe(l.output)}`,`cache r ${i(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${qe(l.cacheRead)}`,...c,"─────────────────────────────────────────",`total = ${qe(l.total)}`].join(`
@@ -69,7 +69,7 @@ Claude Code turns only. The sound is a Stop hook Claude Code runs itself when a
69
69
 
70
70
  ${n.clash} sound hook${n.clash>1?"s":""} of your own in settings.json also run${n.clash>1?"":"s"} here.`:"",l=n.parked>0?`
71
71
 
72
- ${n.parked} of your own sound hook${n.parked>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${n.parked>1?"them":"it"} back.`:"";return r+i+o+l}function $T(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function N5(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${$T(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",label:"live",title:"Receiving events"}:{tone:"dead",label:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function C5(e){return e.paused?e.held<=0?{label:"Resume",title:"Nothing has arrived since you paused. Resume to follow the canvas again (Space)"}:{label:`Resume · ${e.held} held`,title:`${$T(e.held)} arrived while paused and will be applied in order when you resume (Space)`}:{label:"Pause",title:"Pause live updates — events keep arriving and are applied when you resume (Space)"}}function qT(e,n){return e!==""&&n>0}function T5(e,n,r){return e===""?{active:!1,matched:n,total:r,count:null,empty:!1,message:null,dim:!1}:{active:!0,matched:n,total:r,count:`${n} of ${r}`,empty:n===0,message:n===0?`No agents match “${e}”`:null,dim:qT(e,n)}}const R5="Search agents, tools, model…";function DT(e,n){var i,o,l,u;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(i=e.cwd)!=null&&i.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r)||e.model&&(e.model.toLowerCase().includes(r)||js(e.model).toLowerCase().includes(r))||(u=e.provider)!=null&&u.toLowerCase().startsWith(r))return!0;for(const c of e.tools)if(c.name.toLowerCase().includes(r))return!0;return!1}function Lv(e){const n=Math.max(0,Math.floor(e/1e3));return n<60?"just now":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function j5(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function A5(e,n,r){const i=new Date(e),o=Lv(n-e);return{label:j5(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function ua(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const I5={agent:ZP,sessionGroup:fL},FT="react-flow__node";function PE(e){var n,r;return!!e&&((r=(n=e.classList)==null?void 0:n.contains)==null?void 0:r.call(n,FT))===!0}function M5(e){try{const n=document.querySelector(`.${FT}[data-id="${CSS.escape(e)}"]`);n==null||n.focus({preventScroll:!0})}catch{}}const O5=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),P5=420,au=18,L5=200,$5=5*6e4,q5=6,D5=2*6e4,Ey="agent-dag.layout",Ny="agent-dag.viewport",zT="agent-dag.summariesDismissed",BT="agent-dag.sessionListOpen",UT="agent-dag.detailOpen",HT="agent-dag.usagePanelOpen",LE="agent-dag.accountsPanelOpen",$E="agent-dag.versionNoticeDismissed",qE="agent-dag.oldNameNoticeDismissed",F5=15*6e4,DE={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},FE="agent-dag.autoRestart",zE="agent-dag.bundleReloadedFor";function z5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(BT)==="1"}catch{return!1}}function B5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(BT,e?"1":"0")}catch{}}function U5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(UT)==="1"}catch{return!1}}function H5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(UT,e?"1":"0")}catch{}}function W5(){const e=OC(HT);return e===null?!0:e==="1"}function V5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(HT,e?"1":"0")}catch{}}function G5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(zT);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function BE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(zT,JSON.stringify(r))}catch{}}function Y5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Ey);if(!n)return e;const r=JSON.parse(n);if(!("v"in r)){const o=Object.entries(r).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(r.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(r.pins)?r.pins:[]}}catch{return e}}function fv(e,n){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of n)r[i]=o;window.localStorage.setItem(Ey,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function K5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ny);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function X5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ny,JSON.stringify(e))}catch{}}function UE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Ey)}catch{}try{window.localStorage.removeItem(Ny)}catch{}}}function Q5(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const d of e.agents.values())d.sessionId===n&&i.push(d);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:i.map(d=>({id:d.id,kind:d.kind,label:d.label,parentId:d.parentId,state:d.state,startedAt:d.startedAt,endedAt:d.endedAt,model:d.model,cwd:d.cwd,usage:d.usage,prompts:d.prompts,tools:d.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),h=document.createElement("a"),p=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=c,h.download=`${Gt}-${p}-${n.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const $v={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},qv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},WT=EC;function Z5(e,n){if(!n)return null;const r=new Set([n]);let i=n;for(;i;){const l=e.agents.get(i);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),i=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function J5(e,n,r,i,o,l,u,c,h,p,d,m,y,w,N,_,b,S,k){const E=[],T=[],I=new Set;if(l)for(const B of e.agents.values())S.has(B.id)&&DT(B,l)&&I.add(B.id);const O=qT(l,I.size);for(const B of e.agents.values()){if(!S.has(B.id))continue;const C=O&&!I.has(B.id),q=B.exitAt!=null,L=b!=null&&!b.has(B.id),re=[C?"rf-dim":"",q?"rf-exiting":"",L?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(B.id);if(E.push({id:B.id,type:"agent",position:{x:0,y:0},data:{...B,now:n,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),B.parentId&&S.has(B.parentId)){const W=ry(B.sessionId),Z=l&&!I.has(B.id)&&!I.has(B.parentId),M=q,G=_.size>0&&(_.has(B.id)||_.has(B.parentId)),K=b!=null&&!b.has(B.id)&&!b.has(B.parentId),$=B.state==="active"?2:1.5,Q=G?$+1.5:$,ne=Z||M?.2:K?.12:1,ae=["sess-edge",B.state==="active"?"sess-live":"sess-idle",M?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${B.parentId}->${B.id}`,source:B.parentId,target:B.id,animated:(B.state==="active"||G)&&!Z&&!M,type:"smoothstep",style:{"--session-hue":W,strokeWidth:Q,opacity:ne,transition:"var(--edge-transition)"},className:ae})}}const A=new Map;for(const B of e.agents.values())B.tools.length>0&&A.set(B.id,Math.min(4,B.tools.length));const U=`${w}#lanes:${r5(A)}`,z=E.filter(B=>p$(B.id,o,m,y));if(z.length>0||U!==N.current){if(z.length>0){const B=i5(E,T,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:A});for(const C of B)MC(C.id,m,y)&&g$(C.id,C.position,m,y);a5(E,m,o,u,new Set(z.map(C=>C.id)),A)}o5(E,m,o,u,A),N.current=U}const P=l5(E,m,o,u,c,!p||d,A);P.length>0&&h(P),ru(m,e.agents),ru(y,e.agents),ru(o,e.agents),ru(u,h$(e.agents.values()));const D=[];let V=!1;for(const B of E){let C=o.get(B.id)??m.get(B.id);C||(C=m$(B.id,m,y),V=!0),D.push({...B,position:C})}return V&&(N.current=""),{nodes:D,edges:T}}function eF(){return g.jsx(ny,{children:g.jsx(tF,{})})}function tF(){var Va,Ga,Ya,Ka;const e=ja(),n=j.useRef(Rv()),[,r]=j.useState(0),i=j.useCallback(()=>r(H=>H+1),[]),[o,l]=j.useState(()=>new Set),[u,c]=j.useState(null),[h,p]=j.useState(null),d=j.useCallback((H,Y)=>{l(oe=>{if(!Y)return new Set([H]);const de=new Set(oe);return de.has(H)?de.delete(H):de.add(H),de}),c(oe=>Y&&oe===H?oe:H)},[]),m=j.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=j.useState(null),[N,_]=j.useState(null),b=j.useCallback(H=>_(H),[]),[S,k]=j.useState(!1),E=j.useRef(G5()),[T,I]=j.useState(z5);j.useEffect(()=>{B5(T)},[T]);const[O,A]=j.useState(U5);j.useEffect(()=>{H5(O)},[O]);const[U,z]=j.useState(W5);j.useEffect(()=>{V5(U)},[U]);const[P,D]=j.useState(()=>{try{const H=window.localStorage.getItem(LE);return H===null?!0:H==="1"}catch{return!0}});j.useEffect(()=>{try{window.localStorage.setItem(LE,P?"1":"0")}catch{}},[P]);const[V,B]=j.useState(null),[C,q]=j.useState(!1),[L,re]=j.useState(0),[J,W]=j.useState(0);j.useEffect(()=>{fetch("/api/sound-hook").then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&(B(H.enabled===!0),re((H.foreign??[]).filter(Y=>Y.worksHere).length),W(typeof H.parked=="number"?H.parked:0))}).catch(()=>{})},[]);const Z=j.useCallback(async()=>{q(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!V})})).json().catch(()=>null);Y!=null&&Y.ok&&B(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(re((oe.foreign??[]).filter(de=>de.worksHere).length),W(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{q(!1)}},[V]),[M,G]=j.useState(!1),[K,$]=j.useState(null),[Q,ne]=j.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem($E)??""}catch{return""}}),[ae,fe]=j.useState(!1),te=j.useRef(0),[ce,Ce]=j.useState(!1),ve=j.useCallback((H=!1)=>{H&&(te.current=Date.now(),Ce(!0)),fetch(H?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&$(Y)}).catch(()=>{}).finally(()=>{H&&Ce(!1)})},[]),je=j.useCallback(()=>{ve(Date.now()-te.current>=F5)},[ve]);j.useEffect(()=>{ve();const H=window.setInterval(je,5*6e4),Y=()=>{document.visibilityState==="visible"&&je()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",Y)}},[ve,je]),j.useEffect(()=>{M&&ve()},[M,ve]);const ye=(K==null?void 0:K.notice)??null,[Ee,Ye]=j.useState(null),[we,_e]=j.useState(Pv);j.useEffect(()=>{let H=!1;return fetch("/api/health").then(Y=>Y.ok?Y.json():null).then(Y=>{H||(_e(w5(Y)),!(!Y||typeof Y.workspace!="string")&&Ye(Y.workspace))}).catch(()=>{}),()=>{H=!0}},[M]);const Be=j.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",ft=ye!=null&&Q!==it,Ze=j.useCallback(()=>{if(!ye)return;const H=Q===it?"":it;ne(H);try{window.localStorage.setItem($E,H)}catch{}},[ye,it,Q]),[De,Je]=j.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(qE)??""}catch{return""}}),Xe=K!=null&&K.invokedAs&&K.invokedAs!==Gt?K.invokedAs:null,Mt=Xe!=null&&De!==Xe,lt=j.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(qE,Xe)}catch{}}},[Xe]),Qe=((Va=K==null?void 0:K.upgrade)==null?void 0:Va.state)??"idle",Ot=n$(K==null?void 0:K.upgrade),zt=j.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);j.useEffect(()=>{if(Qe!=="running")return;const H=window.setInterval(ve,3e3);return()=>window.clearInterval(H)},[Qe,ve]);const et=j.useCallback(async()=>{var oe;const H=K==null?void 0:K.command;if(!H)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(H).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Y=!1}if(!Y)try{const de=document.createElement("textarea");de.value=H,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Y=document.execCommand("copy"),de.remove()}catch{Y=!1}Y&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[K==null?void 0:K.command]),bt=j.useCallback(()=>{I(H=>(H||D(!1),!H))},[]),ht=j.useCallback(()=>{D(H=>(H||I(!1),!H))},[]),[vt,hn]=j.useState(!1),[Yt,Pt]=j.useState(0),bn=j.useRef(null),[gr,Sn]=j.useState(!1),Bt=j.useRef(null),[Fn,pn]=j.useState(0),vr=j.useRef(x$()),[Hr,xi]=j.useState(!1),Wr=j.useCallback(()=>{const H=vr.current,Y=H.setPaused(!H.paused);for(const oe of Y)n.current=zx(n.current,oe);xi(H.paused)},[]),[ut,_i]=j.useState(Date.now()),[mn,Is]=j.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(FE)!=="0"}catch{return!0}}),yr=j.useCallback(()=>{Is(H=>{const Y=!H;try{window.localStorage.setItem(FE,Y?"1":"0")}catch{}return Y})},[]),[zn,kn]=j.useState(!1),[Vr,Gr]=j.useState("restart"),[Yr,bi]=j.useState(null),sr=j.useRef(!1),Ms=j.useRef(null),En=j.useRef(0),wr=j.useCallback(async H=>{if(sr.current)return;const Y=(H==null?void 0:H.upgrade)===!0;sr.current=!0,Ms.current=Ot;const oe=++En.current;Gr(Y?"npx":"restart"),kn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if(En.current===oe&&sr.current){sr.current=!1,kn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Ot]),Os=j.useRef(null);j.useEffect(()=>{let H=!1;for(const oe of n.current.agents.values())if(oe.state==="active"){H=!0;break}const Y=s$({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(K==null?void 0:K.canRestart)===!0,busy:H,idleSince:Os.current,now:ut});Os.current=Y.idleSince,Y.restart&&wr()},[mn,ye==null?void 0:ye.kind,K==null?void 0:K.canRestart,ut,wr]),j.useEffect(()=>{const H=K==null?void 0:K.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(zE)}catch{return}const de=t$({bundle:"1.35.22",running:H,pending:Y,lastTried:oe});if(de==="reload"){try{window.sessionStorage.setItem(zE,H??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1),bi(H??null);const xe=window.setTimeout(()=>bi(null),6e3);return()=>window.clearTimeout(xe)},[K==null?void 0:K.running]),j.useEffect(()=>{if(zn&&r$({asked:Ms.current,reported:Ot})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1)}},[zn,Ot]);const Ps=j.useRef(Y5()).current;j.useRef(!1);const Tt=j.useRef(new Map(Ps.positions.filter(([H])=>Ps.pins.includes(H)))),xr=j.useRef(null),_r=j.useState(()=>K5())[0],[Kt,Kr]=j.useState(""),[Si,nt]=j.useState(()=>new Set),[br,Xr]=j.useState(E$),[Ls,Qr]=j.useState(!1),Zr=j.useRef(null);j.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(PC,br)}catch{}},[br]),j.useEffect(()=>{if(!_r)return;const H=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(H)},[e,_r]);const $s=j.useRef(!0);j.useEffect(()=>{const H=new EventSource("/events"),Y=w$(i,{now:()=>Date.now(),setTimeout:(oe,de)=>window.setTimeout(oe,de),clearTimeout:oe=>window.clearTimeout(oe)});return H.addEventListener("open",()=>{G(!0),Qr(!0)}),H.addEventListener("error",()=>G(!1)),H.addEventListener("replay-end",()=>{$s.current=!1,Y.flush()}),H.addEventListener("hook",oe=>{try{const de=JSON.parse(oe.data);if(!vr.current.accept(de))return;n.current=zx(n.current,de),de.replay===!0||$s.current||Date.now()-de.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{H.close(),Y.cancel()}},[i]),j.useEffect(()=>{const H=setInterval(()=>{const Y=Date.now();_i(Y);let oe=gP(n.current,Y,Fx);vP(n.current,Y,Fx)&&(oe=!0),pP(n.current,Y,L5,$5)&&(oe=!0),mP(n.current,Y,q5,D5)&&(oe=!0),oe&&i()},250);return()=>clearInterval(H)},[i]);const ir=j.useRef(null),St=j.useRef(0),qs=420,pt=j.useCallback((H=500)=>{try{const Se=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Se||Pe.length===0)return;const Fe=Se.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const We=wt=>(wt-Fe.left-Ge.x)/Ge.zoom,ze=wt=>(wt-Fe.top-Ge.y)/Ge.zoom,Tn=Pe.map(wt=>wt.getBoundingClientRect()),Ys=Math.min(...Tn.map(wt=>We(wt.left))),Ao=Math.max(...Tn.map(wt=>We(wt.right))),Ks=Math.min(...Tn.map(wt=>ze(wt.top))),Io=Math.max(...Tn.map(wt=>ze(wt.bottom))),Xa=Ao-Ys,us=Io-Ks;if(!(Xa>0&&us>0))return;const Zt=Math.max(.2,Math.min(1,(Fe.width-160)/(Xa+qs)*.86,(Fe.height-160)/us*.86));e.setViewport({x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},{duration:H}),St.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},Mo=e.getViewport();(Math.abs(Mo.zoom-Zt)>.01||Math.abs(Mo.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},H+60)}catch{}},[e]),ko=j.useRef(""),Eo=j.useRef(null),qa=j.useRef(0),Sr=j.useCallback(()=>{qa.current=Date.now()},[]),Jr="agent-dag.autoFitDisabled",gn=j.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jr)==="1"}catch{return!1}})()),[Ds,Da]=j.useState(gn.current),Fa=j.useCallback(()=>{if(!gn.current){gn.current=!0,Da(!0);try{window.localStorage.setItem(Jr,"1")}catch{}}},[]),No=j.useCallback(()=>{gn.current=!1,Da(!1);try{window.localStorage.removeItem(Jr)}catch{}pt(400)},[e,pt]);j.useEffect(()=>{const H=setInterval(()=>{if(gn.current||Date.now()-qa.current<800)return;const Y=n.current,oe=Date.now(),de=[];for(const We of Y.agents.values())Ov(We,oe)&&de.push({id:We.id});if(de.length===0)return;const xe=e.getViewport(),Se=window.innerWidth-360,Pe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:We}of de){const ze=or.current.get(We),Tn=Tt.current.get(We)??Xt.current.get(We);if(!ze||!Tn)continue;Ge=!0;const Ys=Tn.x*xe.zoom+xe.x,Ao=Tn.y*xe.zoom+xe.y,Ks=(Tn.x+ze.width)*xe.zoom+xe.x,Io=(Tn.y+ze.height)*xe.zoom+xe.y;if(Ks>0&&Ys<Se&&Io>0&&Ao<Pe){Fe=!0;break}}Ge&&!Fe&&pt(600)},1500);return()=>clearInterval(H)},[e]);const ki=j.useRef(!1),or=j.useRef(new Map),es=j.useRef(0),ec=j.useCallback(H=>{const Y=or.current;let oe=!1;for(const de of H.nodeInternals.values()){const xe=de.width,Se=de.height;if(xe==null||Se==null)continue;const Pe=Y.get(de.id);Pe?(Math.abs(Pe.height-Se)>4||Math.abs(Pe.width-xe)>4)&&(Y.set(de.id,{width:xe,height:Se}),oe=!0):(Y.set(de.id,{width:xe,height:Se}),oe=!0)}return oe&&(es.current+=1),es.current},[]),Ei=Ke(ec),[He,za]=j.useState(0);j.useEffect(()=>{let H=0;const Y=()=>{const de=or.current;let xe=!1;for(const Se of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=Se.getAttribute("data-id");if(!Pe)continue;const Fe=Se.offsetWidth,Ge=Se.offsetHeight;if(!Fe||!Ge)continue;const We=de.get(Pe);(!We||Math.abs(We.width-Fe)>4||Math.abs(We.height-Ge)>4)&&(de.set(Pe,{width:Fe,height:Ge}),xe=!0)}xe&&za(Se=>Se+1)};if(ki.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):H=requestAnimationFrame(Y),()=>{cancelAnimationFrame(H),window.clearTimeout(oe)}});const Xt=j.useRef(new Map(Ps.positions)),Co=j.useRef(new Set),Ni=j.useRef(""),kr=j.useMemo(()=>{const H=[];for(const Y of n.current.agents.values())Ov(Y,ut)&&H.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return H.sort(),`${H.join("|")}#sv${Ei}.${He}`},[n.current,n.current.lastSeq,ut,Ei,He]),ts=j.useRef(null);j.useEffect(()=>(ts.current!=null&&window.clearTimeout(ts.current),ts.current=window.setTimeout(()=>{fv(Xt.current,Tt.current)},1500),()=>{ts.current!=null&&window.clearTimeout(ts.current)}),[kr]),j.useEffect(()=>{if(ko.current===kr)return;const H=ko.current;if(ko.current=kr,!H||gn.current)return;Date.now()-St.current>1200&&pt(400),ir.current&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{gn.current||pt(500)},280)},[kr,e,pt]);const Fs=j.useMemo(()=>{if(o.size===0)return null;const H=new Set;for(const Y of o){const oe=Z5(n.current,Y);if(oe)for(const de of oe)H.add(de)}return H.size>0?H:null},[n.current,n.current.lastSeq,o]),Nn=j.useMemo(()=>c5(n.current,ut),[n.current,n.current.lastSeq,ut]),Bn=j.useRef(null),[vn,Un]=j.useState({w:0,h:0});j.useEffect(()=>{const H=Bn.current;if(!H||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var xe;const de=(xe=oe[0])==null?void 0:xe.contentRect;de&&Un(Se=>Math.abs(Se.w-de.width)>40||Math.abs(Se.h-de.height)>40?{w:de.width,h:de.height}:Se)});return Y.observe(H),Un({w:H.clientWidth,h:H.clientHeight}),()=>Y.disconnect()},[]);const zs=j.useCallback(H=>{var oe,de;const Y=H.target;!(Y!=null&&Y.closest)||Y.closest(O5)!==H.currentTarget||(H.preventDefault(),(de=(oe=document.activeElement)==null?void 0:oe.blur)==null||de.call(oe))},[]),Bs=j.useRef(new Map),[Hn,tc]=j.useState(!1);j.useEffect(()=>{const H=window.setTimeout(()=>tc(!0),2500);return()=>window.clearTimeout(H)},[]);const[Ba,Er]=j.useState(!1),ar=j.useRef(null),[Ci,Us]=j.useState(!1),Ua=j.useCallback(()=>{ar.current&&(window.clearTimeout(ar.current),ar.current=null),Er(!1)},[]),nc=j.useCallback(H=>{H.length!==0&&queueMicrotask(()=>{Er(!0),ar.current&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>Er(!1),P5+80)})},[]);j.useEffect(()=>()=>{ar.current&&window.clearTimeout(ar.current)},[]);const ns=vn.w>0?vn.w*.92:0,rs=vn.h>0?vn.h:0,{nodes:Qt,edges:Ti}=j.useMemo(()=>J5(n.current,ut,ns,rs,Tt.current,Kt,or.current,Bs.current,nc,Hn,Ci,Xt.current,Co.current,kr,Ni,o,Fs,Nn,b),[n.current,n.current.lastSeq,ut,ns,rs,Hn,Ci,Kt,kr,o,Fs,Nn,b,Yt]),Ha=j.useMemo(()=>{const H=new Map;for(const oe of Qt){const de=oe.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=oe.width,Se=oe.height;if(xe==null||Se==null)continue;const Pe=oe.position.x,Fe=oe.position.y,Ge=Pe+xe,We=Fe+Se,ze=H.get(de.sessionId);ze?(ze.minX=Math.min(ze.minX,Pe),ze.minY=Math.min(ze.minY,Fe),ze.maxX=Math.max(ze.maxX,Ge),ze.maxY=Math.max(ze.maxY,We)):H.set(de.sessionId,{minX:Pe,minY:Fe,maxX:Ge,maxY:We})}const Y=[];for(const[oe,de]of H){const xe=de.maxX-de.minX+au*2,Se=de.maxY-de.minY+au*2;Y.push({id:`group:${oe}`,type:LT,position:{x:de.minX-au,y:de.minY-au},data:{sessionId:oe,w:xe,h:Se},width:xe,height:Se,style:{width:xe,height:Se},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Qt,ut]),rc=j.useMemo(()=>{const H=[...Ha,...Qt],Y=Bt.current;return!Y||Y.size===0?H:H.map(oe=>{const de=Y.get(oe.id);return de?{...oe,position:de}:oe})},[Ha,Qt,Fn]),Nr=j.useMemo(()=>{if(!Kt)return null;const H=new Set;for(const Y of n.current.agents.values())Nn.has(Y.id)&&DT(Y,Kt)&&H.add(Y.id);return H},[n.current,n.current.lastSeq,Kt,Nn]),Cn=j.useMemo(()=>T5(Kt,(Nr==null?void 0:Nr.size)??0,Nn.size),[Kt,Nr,Nn]),ss=j.useMemo(()=>{const H=new Set;for(const Y of n.current.agents.values())for(const oe of Y.tools)H.add(WT(oe.name));return Object.keys($v).filter(Y=>H.has(Y))},[n.current,n.current.lastSeq]);j.useEffect(()=>{if(ss.length<=1){Sn(!1);return}let H=0;const Y=()=>{const oe=bn.current;if(oe&&!document.hidden){const de=oe.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Pe=>Pe.getBoundingClientRect()),Se=f5(de,xe,8);Sn(Pe=>Pe===Se?Pe:Se)}H=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(H)},[ss.length]);const is=j.useMemo(()=>{const H=new Map;for(const oe of n.current.agents.values())for(const de of oe.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Se=xe.indexOf("__"),Pe=Se>0?xe.slice(0,Se):xe;H.set(Pe,(H.get(Pe)??0)+1)}const Y=[];for(const[oe,de]of H){let xe=5381;for(let Se=0;Se<oe.length;Se++)xe=(xe<<5)+xe^oe.charCodeAt(Se);Y.push({server:oe,count:de,hue:Math.abs(xe)%360})}return Y.sort((oe,de)=>de.count-oe.count),Y},[n.current,n.current.lastSeq]),lr=j.useCallback(H=>{nt(Y=>{const oe=new Set(Y);return oe.has(H)?oe.delete(H):oe.add(H),oe})},[]),Rt=u?n.current.agents.get(u):null,os=h?Array.from(n.current.agents.values()).flatMap(H=>H.tools).find(H=>H.id===h)??null:null,To=j.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Rv(),Tt.current.clear(),or.current.clear(),Xt.current.clear(),Ni.current="",UE(),m(),i()},[i,m]),Hs=j.useRef(S);Hs.current=S;const Ws=j.useRef(!1);Ws.current=os!=null||vt||N!=null||y!=null;const Vs=j.useCallback(H=>{const Y=o$(H,{confirmOpen:Hs.current,modalOpen:Ws.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),To())},[To]),Lt=j.useCallback(()=>{Tt.current.clear(),Xt.current.clear(),Ni.current="",UE(),i(),window.setTimeout(()=>pt(500),80)},[i,e,pt]),Cr=j.useCallback(()=>pt(500),[pt]),as=j.useRef(Qt);as.current=Qt;const ls=j.useRef(u);ls.current=u;const Ro=j.useCallback(H=>{const Y=as.current,oe=l$(Y.map(Se=>({id:Se.id,x:Se.position.x,y:Se.position.y})),ls.current,H),de=oe?Y.find(Se=>Se.id===oe):void 0;if(!de)return;const xe=PE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}St.current=Date.now(),xe&&M5(de.id)},30)},[d,e]),Ri=j.useCallback(H=>{d(H,!1),window.setTimeout(()=>{try{const Y=as.current.find(oe=>oe.id===H);Y&&e.fitView({padding:.3,duration:500,nodes:[Y]}),St.current=Date.now()}catch{}},60)},[d,e]);j.useEffect(()=>{const H=Y=>{var Fe,Ge,We;const oe=Y.target,de={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(Fe=oe==null?void 0:oe.getAttribute)==null?void 0:Fe.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const ze=LP({overlayOpen:Eu.depth()>0,typing:sy(de)});ze==="dismiss"?Eu.dismissTop():ze==="blur"?oe==null||oe.blur():(f$(de)&&(oe==null||oe.blur()),m());return}if(bC(Y))return;const xe=PE(oe)?(Ge=oe==null?void 0:oe.getAttribute)==null?void 0:Ge.call(oe,"data-id"):null,Se=xe&&as.current.some(ze=>ze.id===xe)?xe:null,Pe=c$(Y,Se);if(Pe.kind==="activate"){Y.preventDefault(),d(Pe.nodeId,Pe.additive);return}if(Pe.kind!=="node"&&!(Pe.nodeId==null&&HP(de))){if(Y.key==="/"){Y.preventDefault(),(We=Zr.current)==null||We.focus();return}Y.key===" "&&(Y.preventDefault(),Wr()),(Y.key==="c"||Y.key==="C")&&Vs("shortcut"),(Y.key==="r"||Y.key==="R")&&Lt(),(Y.key==="f"||Y.key==="F")&&Cr(),(Y.key==="l"||Y.key==="L")&&bt(),(Y.key==="h"||Y.key==="H")&&hn(ze=>!ze),(Y.key==="u"||Y.key==="U")&&z(ze=>!ze),(Y.key==="a"||Y.key==="A")&&Be.current.claude&&ht(),(Y.key==="j"||Y.key==="J")&&Ro(1),(Y.key==="k"||Y.key==="K")&&Ro(-1),(Y.key==="t"||Y.key==="T")&&Xr(ze=>ze==="dark"?"light":"dark")}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Vs,Lt,Cr,m,d,Ro,Wr]);const Tr=n.current.agents.size,Gs=new Set(Array.from(n.current.agents.values()).map(H=>H.sessionId)).size,tn=j.useMemo(()=>e3(n.current.agents.values()),[n.current,n.current.lastSeq]),jo=j.useMemo(()=>t3(n.current.agents.values()),[n.current,n.current.lastSeq]),Wa=j.useRef(null);j.useEffect(()=>{const H=N$({waiting:tn.length,running:jo}),Y=Wa.current;if(Wa.current=H,(Y==null?void 0:Y.title)!==H.title&&(document.title=H.title),(Y==null?void 0:Y.icon)!==H.icon){const oe=document.querySelector('link[rel="icon"]');oe&&(oe.href=C$[H.icon])}},[tn.length,jo]);const[sc,ic]=j.useState(""),ji=R$(tn);j.useEffect(()=>{ic(H=>j$(H,ji))},[ji]);const nn=j.useMemo(()=>{let H=0,Y=0,oe=0,de=0,xe=0,Se=0,Pe=0,Fe=0,Ge=0;for(const We of n.current.agents.values()){H+=We.usage.inputTokens,Y+=We.usage.outputTokens,oe+=We.usage.cacheReadTokens,de+=We.usage.cacheCreateTokens;const ze=dn(We.usage,We.model);xe+=ze.total,Se+=ze.input,Pe+=ze.output,Fe+=ze.cacheRead,Ge+=ze.cacheWrite}return{inT:H,outT:Y,cacheR:oe,cacheC:de,sum:H+Y,cost:{total:xe,input:Se,output:Pe,cacheRead:Fe,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),g.jsx("h1",{children:Gt}),ye?g.jsxs("button",{type:"button",className:"v stale",onClick:Ze,"aria-label":v5({...ye,open:ft}),title:ye.kind==="restart"?`Running v${ye.from}; v${ye.to} is installed on disk. Restart to pick it up.`:`Running v${ye.from}; v${ye.to} is on npm.`,children:["v",ye.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const H={running:(K==null?void 0:K.running)??"1.35.22",latest:K==null?void 0:K.latest,latestPending:K==null?void 0:K.latestPending,checkedAgo:K!=null&&K.checkedAt?Lv(ut-K.checkedAt):null,checkDisabled:K==null?void 0:K.checkDisabled,checking:ce};return g.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":g5(H),title:m5(H),children:["v",H.running]})})()]}),Rt&&(()=>{const H=dn(Rt.usage,Rt.model),Y=Math.max(0,((Rt.endedAt??ut)-Rt.startedAt)/1e3),oe=Rt.state==="active"?ku(H.total,Y):null,de=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Rt.label}`,onClick:()=>{try{const xe=Qt.find(Se=>Se.id===Rt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),St.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${Rt.state}`,children:Rt.state==="active"?"live":Rt.state}),g.jsx("span",{className:"selected-label",children:Rt.label}),H.total>0&&g.jsxs("span",{className:"selected-cost",children:[qe(H.total),oe?g.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),de>0&&g.jsxs("span",{className:"selected-extra",children:["+",de]}),g.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:xe=>{xe.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Zr,type:"text",placeholder:R5,value:Kt,onChange:H=>Kr(H.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Kr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Cn.count&&g.jsx("span",{className:`search-count${Cn.empty?" none":""}`,"aria-live":"polite",title:`${Cn.count} agents on the canvas match “${Kt}”`,children:Cn.count})]}),g.jsxs("span",{className:"status",children:[(()=>{const H=N5({connected:M,paused:Hr,held:vr.current.size});return g.jsx("span",{className:`pill ${H.tone}`,title:H.title,children:H.label})})(),g.jsxs("span",{className:"stat",title:b5(we),children:[g.jsx("span",{className:"count",children:Gs}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Tr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:S5(we),children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),nn.sum>0&&g.jsxs("span",{className:"stat",title:`in:${nn.inT.toLocaleString()} out:${nn.outT.toLocaleString()} cache-r:${nn.cacheR.toLocaleString()} cache-c:${nn.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:Dt(nn.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),is.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
72
+ ${n.parked} of your own sound hook${n.parked>1?"s were":" was"} set aside so this switch actually controls the sound. Nothing was deleted — shift-click to put ${n.parked>1?"them":"it"} back.`:"";return r+i+o+l}function $T(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function N5(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${$T(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",label:"live",title:"Receiving events"}:{tone:"dead",label:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}function C5(e){return e.paused?e.held<=0?{label:"Resume",title:"Nothing has arrived since you paused. Resume to follow the canvas again (Space)"}:{label:`Resume · ${e.held} held`,title:`${$T(e.held)} arrived while paused and will be applied in order when you resume (Space)`}:{label:"Pause",title:"Pause live updates — events keep arriving and are applied when you resume (Space)"}}function qT(e,n){return e!==""&&n>0}function T5(e,n,r){return e===""?{active:!1,matched:n,total:r,count:null,empty:!1,message:null,dim:!1}:{active:!0,matched:n,total:r,count:`${n} of ${r}`,empty:n===0,message:n===0?`No agents match “${e}”`:null,dim:qT(e,n)}}const R5="Search agents, tools, model…";function DT(e,n){var i,o,l,u;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(i=e.cwd)!=null&&i.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r)||e.model&&(e.model.toLowerCase().includes(r)||js(e.model).toLowerCase().includes(r))||(u=e.provider)!=null&&u.toLowerCase().startsWith(r))return!0;for(const c of e.tools)if(c.name.toLowerCase().includes(r))return!0;return!1}function Lv(e){const n=Math.max(0,Math.floor(e/1e3));return n<60?"just now":n<3600?`${Math.floor(n/60)}m ago`:n<86400?`${Math.floor(n/3600)}h ago`:`${Math.floor(n/86400)}d ago`}function j5(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function A5(e,n,r){const i=new Date(e),o=Lv(n-e);return{label:j5(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function ua(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const I5={agent:ZP,sessionGroup:fL},FT="react-flow__node";function PE(e){var n,r;return!!e&&((r=(n=e.classList)==null?void 0:n.contains)==null?void 0:r.call(n,FT))===!0}function M5(e){try{const n=document.querySelector(`.${FT}[data-id="${CSS.escape(e)}"]`);n==null||n.focus({preventScroll:!0})}catch{}}const O5=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),P5=420,au=18,L5=200,$5=5*6e4,q5=6,D5=2*6e4,Ey="agent-dag.layout",Ny="agent-dag.viewport",zT="agent-dag.summariesDismissed",BT="agent-dag.sessionListOpen",UT="agent-dag.detailOpen",HT="agent-dag.usagePanelOpen",LE="agent-dag.accountsPanelOpen",$E="agent-dag.versionNoticeDismissed",qE="agent-dag.oldNameNoticeDismissed",F5=15*6e4,DE={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:"},FE="agent-dag.autoRestart",zE="agent-dag.bundleReloadedFor";function z5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(BT)==="1"}catch{return!1}}function B5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(BT,e?"1":"0")}catch{}}function U5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(UT)==="1"}catch{return!1}}function H5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(UT,e?"1":"0")}catch{}}function W5(){const e=OC(HT);return e===null?!0:e==="1"}function V5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(HT,e?"1":"0")}catch{}}function G5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(zT);if(!e)return new Set;const n=JSON.parse(e);return new Set(Array.isArray(n)?n.filter(r=>typeof r=="string"):[])}catch{return new Set}}function BE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(zT,JSON.stringify(r))}catch{}}function Y5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Ey);if(!n)return e;const r=JSON.parse(n);if(!("v"in r)){const o=Object.entries(r).filter(([,l])=>l&&typeof l.x=="number"&&typeof l.y=="number");return{positions:o,pins:o.map(([l])=>l)}}return{positions:Object.entries(r.positions??{}).filter(([,o])=>o&&typeof o.x=="number"&&typeof o.y=="number"),pins:Array.isArray(r.pins)?r.pins:[]}}catch{return e}}function fv(e,n){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of n)r[i]=o;window.localStorage.setItem(Ey,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function K5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Ny);if(!e)return null;const n=JSON.parse(e);return typeof(n==null?void 0:n.x)!="number"||typeof(n==null?void 0:n.y)!="number"||typeof(n==null?void 0:n.zoom)!="number"?null:n}catch{return null}}function X5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Ny,JSON.stringify(e))}catch{}}function UE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Ey)}catch{}try{window.localStorage.removeItem(Ny)}catch{}}}function Q5(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const d of e.agents.values())d.sessionId===n&&i.push(d);const o={schemaVersion:1,exportedAt:new Date().toISOString(),sessionId:n,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:i.map(d=>({id:d.id,kind:d.kind,label:d.label,parentId:d.parentId,state:d.state,startedAt:d.startedAt,endedAt:d.endedAt,model:d.model,cwd:d.cwd,usage:d.usage,prompts:d.prompts,tools:d.tools.map(m=>({id:m.id,name:m.name,inputPreview:m.inputPreview,startedAt:m.startedAt,endedAt:m.endedAt,ok:m.ok,errorPreview:m.errorPreview,usage:m.usage}))}))},l=JSON.stringify(o,null,2),u=new Blob([l],{type:"application/json"}),c=URL.createObjectURL(u),h=document.createElement("a"),p=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");h.href=c,h.download=`${Gt}-${p}-${n.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const $v={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},qv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},WT=EC;function Z5(e,n){if(!n)return null;const r=new Set([n]);let i=n;for(;i;){const l=e.agents.get(i);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),i=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function J5(e,n,r,i,o,l,u,c,h,p,d,m,y,w,N,_,b,S,k){const E=[],T=[],I=new Set;if(l)for(const B of e.agents.values())S.has(B.id)&&DT(B,l)&&I.add(B.id);const O=qT(l,I.size);for(const B of e.agents.values()){if(!S.has(B.id))continue;const C=O&&!I.has(B.id),q=B.exitAt!=null,L=b!=null&&!b.has(B.id),re=[C?"rf-dim":"",q?"rf-exiting":"",L?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(B.id);if(E.push({id:B.id,type:"agent",position:{x:0,y:0},data:{...B,now:n,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),B.parentId&&S.has(B.parentId)){const W=ry(B.sessionId),Z=l&&!I.has(B.id)&&!I.has(B.parentId),M=q,G=_.size>0&&(_.has(B.id)||_.has(B.parentId)),K=b!=null&&!b.has(B.id)&&!b.has(B.parentId),$=B.state==="active"?2:1.5,Q=G?$+1.5:$,ne=Z||M?.2:K?.12:1,ae=["sess-edge",B.state==="active"?"sess-live":"sess-idle",M?"rf-edge-exiting":"",G?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${B.parentId}->${B.id}`,source:B.parentId,target:B.id,animated:(B.state==="active"||G)&&!Z&&!M,type:"smoothstep",style:{"--session-hue":W,strokeWidth:Q,opacity:ne,transition:"var(--edge-transition)"},className:ae})}}const A=new Map;for(const B of e.agents.values())B.tools.length>0&&A.set(B.id,Math.min(4,B.tools.length));const U=`${w}#lanes:${r5(A)}`,z=E.filter(B=>p$(B.id,o,m,y));if(z.length>0||U!==N.current){if(z.length>0){const B=i5(E,T,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:A});for(const C of B)MC(C.id,m,y)&&g$(C.id,C.position,m,y);a5(E,m,o,u,new Set(z.map(C=>C.id)),A)}o5(E,m,o,u,A),N.current=U}const P=l5(E,m,o,u,c,!p||d,A);P.length>0&&h(P),ru(m,e.agents),ru(y,e.agents),ru(o,e.agents),ru(u,h$(e.agents.values()));const D=[];let V=!1;for(const B of E){let C=o.get(B.id)??m.get(B.id);C||(C=m$(B.id,m,y),V=!0),D.push({...B,position:C})}return V&&(N.current=""),{nodes:D,edges:T}}function eF(){return g.jsx(ny,{children:g.jsx(tF,{})})}function tF(){var Va,Ga,Ya,Ka;const e=ja(),n=j.useRef(Rv()),[,r]=j.useState(0),i=j.useCallback(()=>r(H=>H+1),[]),[o,l]=j.useState(()=>new Set),[u,c]=j.useState(null),[h,p]=j.useState(null),d=j.useCallback((H,Y)=>{l(oe=>{if(!Y)return new Set([H]);const de=new Set(oe);return de.has(H)?de.delete(H):de.add(H),de}),c(oe=>Y&&oe===H?oe:H)},[]),m=j.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=j.useState(null),[N,_]=j.useState(null),b=j.useCallback(H=>_(H),[]),[S,k]=j.useState(!1),E=j.useRef(G5()),[T,I]=j.useState(z5);j.useEffect(()=>{B5(T)},[T]);const[O,A]=j.useState(U5);j.useEffect(()=>{H5(O)},[O]);const[U,z]=j.useState(W5);j.useEffect(()=>{V5(U)},[U]);const[P,D]=j.useState(()=>{try{const H=window.localStorage.getItem(LE);return H===null?!0:H==="1"}catch{return!0}});j.useEffect(()=>{try{window.localStorage.setItem(LE,P?"1":"0")}catch{}},[P]);const[V,B]=j.useState(null),[C,q]=j.useState(!1),[L,re]=j.useState(0),[J,W]=j.useState(0);j.useEffect(()=>{fetch("/api/sound-hook").then(H=>H.ok?H.json():null).then(H=>{H!=null&&H.ok&&(B(H.enabled===!0),re((H.foreign??[]).filter(Y=>Y.worksHere).length),W(typeof H.parked=="number"?H.parked:0))}).catch(()=>{})},[]);const Z=j.useCallback(async()=>{q(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!V})})).json().catch(()=>null);Y!=null&&Y.ok&&B(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(re((oe.foreign??[]).filter(de=>de.worksHere).length),W(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{q(!1)}},[V]),[M,G]=j.useState(!1),[K,$]=j.useState(null),[Q,ne]=j.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem($E)??""}catch{return""}}),[ae,fe]=j.useState(!1),te=j.useRef(0),[ce,Ce]=j.useState(!1),ve=j.useCallback((H=!1)=>{H&&(te.current=Date.now(),Ce(!0)),fetch(H?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&$(Y)}).catch(()=>{}).finally(()=>{H&&Ce(!1)})},[]),je=j.useCallback(()=>{ve(Date.now()-te.current>=F5)},[ve]);j.useEffect(()=>{ve();const H=window.setInterval(je,5*6e4),Y=()=>{document.visibilityState==="visible"&&je()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(H),document.removeEventListener("visibilitychange",Y)}},[ve,je]),j.useEffect(()=>{M&&ve()},[M,ve]);const ye=(K==null?void 0:K.notice)??null,[Ee,Ye]=j.useState(null),[we,_e]=j.useState(Pv);j.useEffect(()=>{let H=!1;return fetch("/api/health").then(Y=>Y.ok?Y.json():null).then(Y=>{H||(_e(w5(Y)),!(!Y||typeof Y.workspace!="string")&&Ye(Y.workspace))}).catch(()=>{}),()=>{H=!0}},[M]);const Be=j.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",ft=ye!=null&&Q!==it,Ze=j.useCallback(()=>{if(!ye)return;const H=Q===it?"":it;ne(H);try{window.localStorage.setItem($E,H)}catch{}},[ye,it,Q]),[De,Je]=j.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(qE)??""}catch{return""}}),Xe=K!=null&&K.invokedAs&&K.invokedAs!==Gt?K.invokedAs:null,Mt=Xe!=null&&De!==Xe,lt=j.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(qE,Xe)}catch{}}},[Xe]),Qe=((Va=K==null?void 0:K.upgrade)==null?void 0:Va.state)??"idle",Ot=n$(K==null?void 0:K.upgrade),zt=j.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);j.useEffect(()=>{if(Qe!=="running")return;const H=window.setInterval(ve,3e3);return()=>window.clearInterval(H)},[Qe,ve]);const et=j.useCallback(async()=>{var oe;const H=K==null?void 0:K.command;if(!H)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(H).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{Y=!1}if(!Y)try{const de=document.createElement("textarea");de.value=H,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),Y=document.execCommand("copy"),de.remove()}catch{Y=!1}Y&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[K==null?void 0:K.command]),bt=j.useCallback(()=>{I(H=>(H||D(!1),!H))},[]),ht=j.useCallback(()=>{D(H=>(H||I(!1),!H))},[]),[vt,hn]=j.useState(!1),[Yt,Pt]=j.useState(0),bn=j.useRef(null),[gr,Sn]=j.useState(!1),Bt=j.useRef(null),[Fn,pn]=j.useState(0),vr=j.useRef(x$()),[Hr,xi]=j.useState(!1),Wr=j.useCallback(()=>{const H=vr.current,Y=H.setPaused(!H.paused);for(const oe of Y)n.current=zx(n.current,oe);xi(H.paused)},[]),[ut,_i]=j.useState(Date.now()),[mn,Is]=j.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(FE)!=="0"}catch{return!0}}),yr=j.useCallback(()=>{Is(H=>{const Y=!H;try{window.localStorage.setItem(FE,Y?"1":"0")}catch{}return Y})},[]),[zn,kn]=j.useState(!1),[Vr,Gr]=j.useState("restart"),[Yr,bi]=j.useState(null),sr=j.useRef(!1),Ms=j.useRef(null),En=j.useRef(0),wr=j.useCallback(async H=>{if(sr.current)return;const Y=(H==null?void 0:H.upgrade)===!0;sr.current=!0,Ms.current=Ot;const oe=++En.current;Gr(Y?"npx":"restart"),kn(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if(En.current===oe&&sr.current){sr.current=!1,kn(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Ot]),Os=j.useRef(null);j.useEffect(()=>{let H=!1;for(const oe of n.current.agents.values())if(oe.state==="active"){H=!0;break}const Y=s$({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(K==null?void 0:K.canRestart)===!0,busy:H,idleSince:Os.current,now:ut});Os.current=Y.idleSince,Y.restart&&wr()},[mn,ye==null?void 0:ye.kind,K==null?void 0:K.canRestart,ut,wr]),j.useEffect(()=>{const H=K==null?void 0:K.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(zE)}catch{return}const de=t$({bundle:"1.35.24",running:H,pending:Y,lastTried:oe});if(de==="reload"){try{window.sessionStorage.setItem(zE,H??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1),bi(H??null);const xe=window.setTimeout(()=>bi(null),6e3);return()=>window.clearTimeout(xe)},[K==null?void 0:K.running]),j.useEffect(()=>{if(zn&&r$({asked:Ms.current,reported:Ot})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}sr.current=!1,kn(!1)}},[zn,Ot]);const Ps=j.useRef(Y5()).current;j.useRef(!1);const Tt=j.useRef(new Map(Ps.positions.filter(([H])=>Ps.pins.includes(H)))),xr=j.useRef(null),_r=j.useState(()=>K5())[0],[Kt,Kr]=j.useState(""),[Si,nt]=j.useState(()=>new Set),[br,Xr]=j.useState(E$),[Ls,Qr]=j.useState(!1),Zr=j.useRef(null);j.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(PC,br)}catch{}},[br]),j.useEffect(()=>{if(!_r)return;const H=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(H)},[e,_r]);const $s=j.useRef(!0);j.useEffect(()=>{const H=new EventSource("/events"),Y=w$(i,{now:()=>Date.now(),setTimeout:(oe,de)=>window.setTimeout(oe,de),clearTimeout:oe=>window.clearTimeout(oe)});return H.addEventListener("open",()=>{G(!0),Qr(!0)}),H.addEventListener("error",()=>G(!1)),H.addEventListener("replay-end",()=>{$s.current=!1,Y.flush()}),H.addEventListener("hook",oe=>{try{const de=JSON.parse(oe.data);if(!vr.current.accept(de))return;n.current=zx(n.current,de),de.replay===!0||$s.current||Date.now()-de.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{H.close(),Y.cancel()}},[i]),j.useEffect(()=>{const H=setInterval(()=>{const Y=Date.now();_i(Y);let oe=gP(n.current,Y,Fx);vP(n.current,Y,Fx)&&(oe=!0),pP(n.current,Y,L5,$5)&&(oe=!0),mP(n.current,Y,q5,D5)&&(oe=!0),oe&&i()},250);return()=>clearInterval(H)},[i]);const ir=j.useRef(null),St=j.useRef(0),qs=420,pt=j.useCallback((H=500)=>{try{const Se=document.querySelector(".canvas-wrap"),Pe=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Se||Pe.length===0)return;const Fe=Se.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const We=wt=>(wt-Fe.left-Ge.x)/Ge.zoom,ze=wt=>(wt-Fe.top-Ge.y)/Ge.zoom,Tn=Pe.map(wt=>wt.getBoundingClientRect()),Ys=Math.min(...Tn.map(wt=>We(wt.left))),Ao=Math.max(...Tn.map(wt=>We(wt.right))),Ks=Math.min(...Tn.map(wt=>ze(wt.top))),Io=Math.max(...Tn.map(wt=>ze(wt.bottom))),Xa=Ao-Ys,us=Io-Ks;if(!(Xa>0&&us>0))return;const Zt=Math.max(.2,Math.min(1,(Fe.width-160)/(Xa+qs)*.86,(Fe.height-160)/us*.86));e.setViewport({x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},{duration:H}),St.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Ys*Zt,y:Math.max(80,(Fe.height-us*Zt)/2)-Ks*Zt,zoom:Zt},Mo=e.getViewport();(Math.abs(Mo.zoom-Zt)>.01||Math.abs(Mo.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},H+60)}catch{}},[e]),ko=j.useRef(""),Eo=j.useRef(null),qa=j.useRef(0),Sr=j.useCallback(()=>{qa.current=Date.now()},[]),Jr="agent-dag.autoFitDisabled",gn=j.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Jr)==="1"}catch{return!1}})()),[Ds,Da]=j.useState(gn.current),Fa=j.useCallback(()=>{if(!gn.current){gn.current=!0,Da(!0);try{window.localStorage.setItem(Jr,"1")}catch{}}},[]),No=j.useCallback(()=>{gn.current=!1,Da(!1);try{window.localStorage.removeItem(Jr)}catch{}pt(400)},[e,pt]);j.useEffect(()=>{const H=setInterval(()=>{if(gn.current||Date.now()-qa.current<800)return;const Y=n.current,oe=Date.now(),de=[];for(const We of Y.agents.values())Ov(We,oe)&&de.push({id:We.id});if(de.length===0)return;const xe=e.getViewport(),Se=window.innerWidth-360,Pe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:We}of de){const ze=or.current.get(We),Tn=Tt.current.get(We)??Xt.current.get(We);if(!ze||!Tn)continue;Ge=!0;const Ys=Tn.x*xe.zoom+xe.x,Ao=Tn.y*xe.zoom+xe.y,Ks=(Tn.x+ze.width)*xe.zoom+xe.x,Io=(Tn.y+ze.height)*xe.zoom+xe.y;if(Ks>0&&Ys<Se&&Io>0&&Ao<Pe){Fe=!0;break}}Ge&&!Fe&&pt(600)},1500);return()=>clearInterval(H)},[e]);const ki=j.useRef(!1),or=j.useRef(new Map),es=j.useRef(0),ec=j.useCallback(H=>{const Y=or.current;let oe=!1;for(const de of H.nodeInternals.values()){const xe=de.width,Se=de.height;if(xe==null||Se==null)continue;const Pe=Y.get(de.id);Pe?(Math.abs(Pe.height-Se)>4||Math.abs(Pe.width-xe)>4)&&(Y.set(de.id,{width:xe,height:Se}),oe=!0):(Y.set(de.id,{width:xe,height:Se}),oe=!0)}return oe&&(es.current+=1),es.current},[]),Ei=Ke(ec),[He,za]=j.useState(0);j.useEffect(()=>{let H=0;const Y=()=>{const de=or.current;let xe=!1;for(const Se of document.querySelectorAll(".react-flow__node[data-id]")){const Pe=Se.getAttribute("data-id");if(!Pe)continue;const Fe=Se.offsetWidth,Ge=Se.offsetHeight;if(!Fe||!Ge)continue;const We=de.get(Pe);(!We||Math.abs(We.width-Fe)>4||Math.abs(We.height-Ge)>4)&&(de.set(Pe,{width:Fe,height:Ge}),xe=!0)}xe&&za(Se=>Se+1)};if(ki.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):H=requestAnimationFrame(Y),()=>{cancelAnimationFrame(H),window.clearTimeout(oe)}});const Xt=j.useRef(new Map(Ps.positions)),Co=j.useRef(new Set),Ni=j.useRef(""),kr=j.useMemo(()=>{const H=[];for(const Y of n.current.agents.values())Ov(Y,ut)&&H.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return H.sort(),`${H.join("|")}#sv${Ei}.${He}`},[n.current,n.current.lastSeq,ut,Ei,He]),ts=j.useRef(null);j.useEffect(()=>(ts.current!=null&&window.clearTimeout(ts.current),ts.current=window.setTimeout(()=>{fv(Xt.current,Tt.current)},1500),()=>{ts.current!=null&&window.clearTimeout(ts.current)}),[kr]),j.useEffect(()=>{if(ko.current===kr)return;const H=ko.current;if(ko.current=kr,!H||gn.current)return;Date.now()-St.current>1200&&pt(400),ir.current&&window.clearTimeout(ir.current),ir.current=window.setTimeout(()=>{gn.current||pt(500)},280)},[kr,e,pt]);const Fs=j.useMemo(()=>{if(o.size===0)return null;const H=new Set;for(const Y of o){const oe=Z5(n.current,Y);if(oe)for(const de of oe)H.add(de)}return H.size>0?H:null},[n.current,n.current.lastSeq,o]),Nn=j.useMemo(()=>c5(n.current,ut),[n.current,n.current.lastSeq,ut]),Bn=j.useRef(null),[vn,Un]=j.useState({w:0,h:0});j.useEffect(()=>{const H=Bn.current;if(!H||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var xe;const de=(xe=oe[0])==null?void 0:xe.contentRect;de&&Un(Se=>Math.abs(Se.w-de.width)>40||Math.abs(Se.h-de.height)>40?{w:de.width,h:de.height}:Se)});return Y.observe(H),Un({w:H.clientWidth,h:H.clientHeight}),()=>Y.disconnect()},[]);const zs=j.useCallback(H=>{var oe,de;const Y=H.target;!(Y!=null&&Y.closest)||Y.closest(O5)!==H.currentTarget||(H.preventDefault(),(de=(oe=document.activeElement)==null?void 0:oe.blur)==null||de.call(oe))},[]),Bs=j.useRef(new Map),[Hn,tc]=j.useState(!1);j.useEffect(()=>{const H=window.setTimeout(()=>tc(!0),2500);return()=>window.clearTimeout(H)},[]);const[Ba,Er]=j.useState(!1),ar=j.useRef(null),[Ci,Us]=j.useState(!1),Ua=j.useCallback(()=>{ar.current&&(window.clearTimeout(ar.current),ar.current=null),Er(!1)},[]),nc=j.useCallback(H=>{H.length!==0&&queueMicrotask(()=>{Er(!0),ar.current&&window.clearTimeout(ar.current),ar.current=window.setTimeout(()=>Er(!1),P5+80)})},[]);j.useEffect(()=>()=>{ar.current&&window.clearTimeout(ar.current)},[]);const ns=vn.w>0?vn.w*.92:0,rs=vn.h>0?vn.h:0,{nodes:Qt,edges:Ti}=j.useMemo(()=>J5(n.current,ut,ns,rs,Tt.current,Kt,or.current,Bs.current,nc,Hn,Ci,Xt.current,Co.current,kr,Ni,o,Fs,Nn,b),[n.current,n.current.lastSeq,ut,ns,rs,Hn,Ci,Kt,kr,o,Fs,Nn,b,Yt]),Ha=j.useMemo(()=>{const H=new Map;for(const oe of Qt){const de=oe.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=oe.width,Se=oe.height;if(xe==null||Se==null)continue;const Pe=oe.position.x,Fe=oe.position.y,Ge=Pe+xe,We=Fe+Se,ze=H.get(de.sessionId);ze?(ze.minX=Math.min(ze.minX,Pe),ze.minY=Math.min(ze.minY,Fe),ze.maxX=Math.max(ze.maxX,Ge),ze.maxY=Math.max(ze.maxY,We)):H.set(de.sessionId,{minX:Pe,minY:Fe,maxX:Ge,maxY:We})}const Y=[];for(const[oe,de]of H){const xe=de.maxX-de.minX+au*2,Se=de.maxY-de.minY+au*2;Y.push({id:`group:${oe}`,type:LT,position:{x:de.minX-au,y:de.minY-au},data:{sessionId:oe,w:xe,h:Se},width:xe,height:Se,style:{width:xe,height:Se},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Qt,ut]),rc=j.useMemo(()=>{const H=[...Ha,...Qt],Y=Bt.current;return!Y||Y.size===0?H:H.map(oe=>{const de=Y.get(oe.id);return de?{...oe,position:de}:oe})},[Ha,Qt,Fn]),Nr=j.useMemo(()=>{if(!Kt)return null;const H=new Set;for(const Y of n.current.agents.values())Nn.has(Y.id)&&DT(Y,Kt)&&H.add(Y.id);return H},[n.current,n.current.lastSeq,Kt,Nn]),Cn=j.useMemo(()=>T5(Kt,(Nr==null?void 0:Nr.size)??0,Nn.size),[Kt,Nr,Nn]),ss=j.useMemo(()=>{const H=new Set;for(const Y of n.current.agents.values())for(const oe of Y.tools)H.add(WT(oe.name));return Object.keys($v).filter(Y=>H.has(Y))},[n.current,n.current.lastSeq]);j.useEffect(()=>{if(ss.length<=1){Sn(!1);return}let H=0;const Y=()=>{const oe=bn.current;if(oe&&!document.hidden){const de=oe.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Pe=>Pe.getBoundingClientRect()),Se=f5(de,xe,8);Sn(Pe=>Pe===Se?Pe:Se)}H=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(H)},[ss.length]);const is=j.useMemo(()=>{const H=new Map;for(const oe of n.current.agents.values())for(const de of oe.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Se=xe.indexOf("__"),Pe=Se>0?xe.slice(0,Se):xe;H.set(Pe,(H.get(Pe)??0)+1)}const Y=[];for(const[oe,de]of H){let xe=5381;for(let Se=0;Se<oe.length;Se++)xe=(xe<<5)+xe^oe.charCodeAt(Se);Y.push({server:oe,count:de,hue:Math.abs(xe)%360})}return Y.sort((oe,de)=>de.count-oe.count),Y},[n.current,n.current.lastSeq]),lr=j.useCallback(H=>{nt(Y=>{const oe=new Set(Y);return oe.has(H)?oe.delete(H):oe.add(H),oe})},[]),Rt=u?n.current.agents.get(u):null,os=h?Array.from(n.current.agents.values()).flatMap(H=>H.tools).find(H=>H.id===h)??null:null,To=j.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Rv(),Tt.current.clear(),or.current.clear(),Xt.current.clear(),Ni.current="",UE(),m(),i()},[i,m]),Hs=j.useRef(S);Hs.current=S;const Ws=j.useRef(!1);Ws.current=os!=null||vt||N!=null||y!=null;const Vs=j.useCallback(H=>{const Y=o$(H,{confirmOpen:Hs.current,modalOpen:Ws.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),To())},[To]),Lt=j.useCallback(()=>{Tt.current.clear(),Xt.current.clear(),Ni.current="",UE(),i(),window.setTimeout(()=>pt(500),80)},[i,e,pt]),Cr=j.useCallback(()=>pt(500),[pt]),as=j.useRef(Qt);as.current=Qt;const ls=j.useRef(u);ls.current=u;const Ro=j.useCallback(H=>{const Y=as.current,oe=l$(Y.map(Se=>({id:Se.id,x:Se.position.x,y:Se.position.y})),ls.current,H),de=oe?Y.find(Se=>Se.id===oe):void 0;if(!de)return;const xe=PE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}St.current=Date.now(),xe&&M5(de.id)},30)},[d,e]),Ri=j.useCallback(H=>{d(H,!1),window.setTimeout(()=>{try{const Y=as.current.find(oe=>oe.id===H);Y&&e.fitView({padding:.3,duration:500,nodes:[Y]}),St.current=Date.now()}catch{}},60)},[d,e]);j.useEffect(()=>{const H=Y=>{var Fe,Ge,We;const oe=Y.target,de={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(Fe=oe==null?void 0:oe.getAttribute)==null?void 0:Fe.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const ze=LP({overlayOpen:Eu.depth()>0,typing:sy(de)});ze==="dismiss"?Eu.dismissTop():ze==="blur"?oe==null||oe.blur():(f$(de)&&(oe==null||oe.blur()),m());return}if(bC(Y))return;const xe=PE(oe)?(Ge=oe==null?void 0:oe.getAttribute)==null?void 0:Ge.call(oe,"data-id"):null,Se=xe&&as.current.some(ze=>ze.id===xe)?xe:null,Pe=c$(Y,Se);if(Pe.kind==="activate"){Y.preventDefault(),d(Pe.nodeId,Pe.additive);return}if(Pe.kind!=="node"&&!(Pe.nodeId==null&&HP(de))){if(Y.key==="/"){Y.preventDefault(),(We=Zr.current)==null||We.focus();return}Y.key===" "&&(Y.preventDefault(),Wr()),(Y.key==="c"||Y.key==="C")&&Vs("shortcut"),(Y.key==="r"||Y.key==="R")&&Lt(),(Y.key==="f"||Y.key==="F")&&Cr(),(Y.key==="l"||Y.key==="L")&&bt(),(Y.key==="h"||Y.key==="H")&&hn(ze=>!ze),(Y.key==="u"||Y.key==="U")&&z(ze=>!ze),(Y.key==="a"||Y.key==="A")&&Be.current.claude&&ht(),(Y.key==="j"||Y.key==="J")&&Ro(1),(Y.key==="k"||Y.key==="K")&&Ro(-1),(Y.key==="t"||Y.key==="T")&&Xr(ze=>ze==="dark"?"light":"dark")}};return window.addEventListener("keydown",H),()=>window.removeEventListener("keydown",H)},[Vs,Lt,Cr,m,d,Ro,Wr]);const Tr=n.current.agents.size,Gs=new Set(Array.from(n.current.agents.values()).map(H=>H.sessionId)).size,tn=j.useMemo(()=>e3(n.current.agents.values()),[n.current,n.current.lastSeq]),jo=j.useMemo(()=>t3(n.current.agents.values()),[n.current,n.current.lastSeq]),Wa=j.useRef(null);j.useEffect(()=>{const H=N$({waiting:tn.length,running:jo}),Y=Wa.current;if(Wa.current=H,(Y==null?void 0:Y.title)!==H.title&&(document.title=H.title),(Y==null?void 0:Y.icon)!==H.icon){const oe=document.querySelector('link[rel="icon"]');oe&&(oe.href=C$[H.icon])}},[tn.length,jo]);const[sc,ic]=j.useState(""),ji=R$(tn);j.useEffect(()=>{ic(H=>j$(H,ji))},[ji]);const nn=j.useMemo(()=>{let H=0,Y=0,oe=0,de=0,xe=0,Se=0,Pe=0,Fe=0,Ge=0;for(const We of n.current.agents.values()){H+=We.usage.inputTokens,Y+=We.usage.outputTokens,oe+=We.usage.cacheReadTokens,de+=We.usage.cacheCreateTokens;const ze=dn(We.usage,We.model);xe+=ze.total,Se+=ze.input,Pe+=ze.output,Fe+=ze.cacheRead,Ge+=ze.cacheWrite}return{inT:H,outT:Y,cacheR:oe,cacheC:de,sum:H+Y,cost:{total:xe,input:Se,output:Pe,cacheRead:Fe,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),g.jsx("h1",{children:Gt}),ye?g.jsxs("button",{type:"button",className:"v stale",onClick:Ze,"aria-label":v5({...ye,open:ft}),title:ye.kind==="restart"?`Running v${ye.from}; v${ye.to} is installed on disk. Restart to pick it up.`:`Running v${ye.from}; v${ye.to} is on npm.`,children:["v",ye.from,g.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const H={running:(K==null?void 0:K.running)??"1.35.24",latest:K==null?void 0:K.latest,latestPending:K==null?void 0:K.latestPending,checkedAgo:K!=null&&K.checkedAt?Lv(ut-K.checkedAt):null,checkDisabled:K==null?void 0:K.checkDisabled,checking:ce};return g.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":g5(H),title:m5(H),children:["v",H.running]})})()]}),Rt&&(()=>{const H=dn(Rt.usage,Rt.model),Y=Math.max(0,((Rt.endedAt??ut)-Rt.startedAt)/1e3),oe=Rt.state==="active"?ku(H.total,Y):null,de=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Rt.label}`,onClick:()=>{try{const xe=Qt.find(Se=>Se.id===Rt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),St.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${Rt.state}`,children:Rt.state==="active"?"live":Rt.state}),g.jsx("span",{className:"selected-label",children:Rt.label}),H.total>0&&g.jsxs("span",{className:"selected-cost",children:[qe(H.total),oe?g.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),de>0&&g.jsxs("span",{className:"selected-extra",children:["+",de]}),g.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:xe=>{xe.stopPropagation(),m()},children:"×"})]})})(),g.jsxs("div",{className:"actions",children:[g.jsxs("div",{className:"search",children:[g.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),g.jsx("input",{ref:Zr,type:"text",placeholder:R5,value:Kt,onChange:H=>Kr(H.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Kr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Cn.count&&g.jsx("span",{className:`search-count${Cn.empty?" none":""}`,"aria-live":"polite",title:`${Cn.count} agents on the canvas match “${Kt}”`,children:Cn.count})]}),g.jsxs("span",{className:"status",children:[(()=>{const H=N5({connected:M,paused:Hr,held:vr.current.size});return g.jsx("span",{className:`pill ${H.tone}`,title:H.title,children:H.label})})(),g.jsxs("span",{className:"stat",title:b5(we),children:[g.jsx("span",{className:"count",children:Gs}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Tr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:S5(we),children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),nn.sum>0&&g.jsxs("span",{className:"stat",title:`in:${nn.inT.toLocaleString()} out:${nn.outT.toLocaleString()} cache-r:${nn.cacheR.toLocaleString()} cache-c:${nn.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:Dt(nn.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),is.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
73
73
  ${is.map(H=>` ${H.server}: ${H.count} call${H.count===1?"":"s"}`).join(`
74
74
  `)}`,children:[is.slice(0,6).map(H=>g.jsx("span",{className:"mcp-dot",style:{"--mcp-hue":H.hue}},H.server)),is.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",is.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),nn.cost.total>0&&(()=>{let H=0,Y=0;for(const xe of n.current.agents.values()){if(xe.state!=="active")continue;const Se=dn(xe.usage,xe.model);H+=Se.total,Y=Math.max(Y,((xe.endedAt??ut)-xe.startedAt)/1e3)}const oe=Y>0?ku(H,Y):null,de=`input ${qe(nn.cost.input)} + output ${qe(nn.cost.output)} + cache r ${qe(nn.cost.cacheRead)} + cache w ${qe(nn.cost.cacheWrite)}${oe?`
75
75
  active burn: ${oe}`:""}`;return g.jsxs("span",{className:"stat",title:de,children:[g.jsx("span",{className:"count",children:qe(nn.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",oe?` · ${oe}`:""]})]})})()]}),g.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:sc}),tn.length>0&&g.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Ri(tn[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest:
@@ -40,7 +40,7 @@
40
40
  document.documentElement.setAttribute("data-theme", stored === "light" ? "light" : "dark");
41
41
  })();
42
42
  </script>
43
- <script type="module" crossorigin src="/assets/index-nS0lHmpq.js"></script>
43
+ <script type="module" crossorigin src="/assets/index-C6UkIHdv.js"></script>
44
44
  <link rel="stylesheet" crossorigin href="/assets/index-hLBidJXz.css">
45
45
  </head>
46
46
  <body>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agent-dag",
3
- "version": "1.35.22",
3
+ "version": "1.35.24",
4
4
  "description": "Live deck of Claude Code and Codex agents — watch tool calls, token spend and every Claude Code subagent on one calm canvas. Also available as npx ccdeck and npx agent-dag.",
5
5
  "type": "module",
6
6
  "bin": {
@@ -66,6 +66,16 @@ let persistPath = null; // absolute path to events.jsonl, or null
66
66
  // same way. A session is recorded unless we have been told someone else owns
67
67
  // it, so a lone deck — and a deck the hook is too old to flag — still writes
68
68
  // everything.
69
+ //
70
+ // THIS COVERS THE CLAUDE SIDE ONLY, and that is worth stating because reading it
71
+ // as the general answer is what produced #447. The only thing that ever fills
72
+ // the set is noteLogWriter, called from handleEventIngest — a hook POST. Codex
73
+ // events are read off the rollout files inside this process and never reach an
74
+ // HTTP handler, and Codex hooks are not installed any more, so a Codex session
75
+ // id cannot get in here and writesLogFor answers "mine" for every one of them on
76
+ // every deck. The Codex half is decided by writesCodexLog in the watcher's scan
77
+ // loop instead, and every event derived from a rollout — including the memory
78
+ // scan's ContextObserved — has to carry that verdict explicitly.
69
79
  const foreignSessions = new Set(); // session ids another deck is logging
70
80
  const MAX_FOREIGN_SESSIONS = 512; // bound: insertion order = oldest first
71
81
 
@@ -738,8 +748,27 @@ const pendingCodexMemoryReads = new Set();
738
748
  * session happened first, on a panel whose whole purpose is to say what is in
739
749
  * the window. ContextModal says so in the slot those counts would have used;
740
750
  * see codex-approval.ts for the same move on a different unanswerable question.
751
+ *
752
+ * WHY `persist` IS A PARAMETER (#447). Every other event the rollout watcher
753
+ * produces goes out through emitCodexEvent, which carries the per-batch verdict
754
+ * of writesCodexLog: several decks tailing one rollout all DRAW it, and exactly
755
+ * one of them appends it to the events.jsonl they share. This function pushed
756
+ * with no opts at all, so pushEvent fell back to writesLogFor — and that answers
757
+ * from `foreignSessions`, a set only ever filled by noteLogWriter off an
758
+ * incoming hook POST marked `?persist=0`. A Codex rollout never touches an HTTP
759
+ * handler and Codex hooks are not installed any more (installer.mjs keeps the
760
+ * provider for uninstall only), so a Codex session id can never appear in that
761
+ * set and every deck answered "yes, mine" for this one event. The caller already
762
+ * holds the verdict for the whole batch, so it is threaded in rather than
763
+ * re-derived: recomputing it here would cost a second directory listing and
764
+ * could disagree with the roots and tool calls the same batch just emitted.
765
+ *
766
+ * Omitting the argument keeps the old behaviour — write. That is the same
767
+ * fail-safe writesCodexLog itself takes when a deck cannot find its own
768
+ * discovery record: a line written twice is recoverable, a deck that quietly
769
+ * records nothing is not.
741
770
  */
742
- function maybeResolveCodexMemory(sid, cwd) {
771
+ function maybeResolveCodexMemory(sid, cwd, persist) {
743
772
  if (!sid || !cwd) return;
744
773
  if (pendingCodexMemoryReads.has(sid)) return;
745
774
  const now = Date.now();
@@ -754,12 +783,16 @@ function maybeResolveCodexMemory(sid, cwd) {
754
783
  // would only ever overwrite a real one with nothing. A repo that grows its
755
784
  // first AGENTS.md mid-session is picked up by the next throttled pass.
756
785
  if (!memoryFiles.length) return;
786
+ // `persist` false means another deck tailing this same rollout was elected
787
+ // to record it. The event is still buffered and broadcast from here, so
788
+ // every deck's context modal lists the AGENTS.md files — it is only the
789
+ // second copy on disk that is dropped, exactly as emitCodexEvent does it.
757
790
  pushEvent({
758
791
  hook_event_name: "ContextObserved",
759
792
  session_id: sid,
760
793
  provider: "codex",
761
794
  context: { memoryFiles },
762
- }, "internal");
795
+ }, "internal", { persist });
763
796
  })
764
797
  .catch(() => {})
765
798
  .finally(() => pendingCodexMemoryReads.delete(sid));
@@ -1452,7 +1485,13 @@ async function codexScanOnce(firstRun) {
1452
1485
  // existing so a session the deck has decided not to draw does not cost a
1453
1486
  // directory walk, and repeated rather than done once at root creation so
1454
1487
  // an AGENTS.md written after the session started is still found (#399).
1455
- if (state.rootEmitted) maybeResolveCodexMemory(state.sid, state.cwd);
1488
+ //
1489
+ // Carries the same `persist` verdict as every emit in the loop above, and
1490
+ // for the same reason: this is one more event about this batch of appended
1491
+ // lines, and a batch whose roots and tool calls went to one deck's log
1492
+ // while its memory list went to every deck's is the split the election
1493
+ // exists to prevent (#447).
1494
+ if (state.rootEmitted) maybeResolveCodexMemory(state.sid, state.cwd, persist);
1456
1495
  }
1457
1496
 
1458
1497
  // Rollout files fall out of the newest-2-days listing and never come back,