agent-dag 1.35.2 → 1.35.4

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,13 +54,13 @@ 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 Uw;function ej(){if(Uw)return Rd;Uw=1;var e=ka(),n=JR();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 Rd.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(P){if(!k){if(k=!0,E=P,P=y(P),w!==void 0&&_.hasValue){var A=_.value;if(w(A,P))return C=A}return C=P}if(A=C,i(E,P))return A;var H=y(P);return w!==void 0&&w(A,H)?(E=P,A):(E=P,C=H)}var k=!1,E,C,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},Rd}var Hw;function tj(){return Hw||(Hw=1,Td.exports=ej()),Td.exports}var nj=tj();const rj=Lv(nj),sj={},Ww=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:()=>{(sj?"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},ij=e=>e?Ww(e):Ww,{useDebugValue:oj}=ue,{useSyncExternalStoreWithSelector:aj}=rj,lj=e=>e;function zE(e,n=lj,r){const i=aj(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,r);return oj(i),i}const Vw=(e,n)=>{const r=ij(e),i=(o,l=n)=>zE(r,o,l);return Object.assign(i,r),i},uj=(e,n)=>e?Vw(e,n):Vw;function Ct(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 cj={value:()=>{}};function Cu(){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 au(r)}function au(e){this._=e}function dj(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}})}au.prototype=Cu.prototype={constructor:au,on:function(e,n){var r=this._,i=dj(e+"",r),o,l=-1,u=i.length;if(arguments.length<2){for(;++l<u;)if((o=(e=i[l]).type)&&(o=fj(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]=Gw(r[o],e.name,n);else if(n==null)for(o in r)r[o]=Gw(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 au(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 fj(e,n){for(var r=0,i=e.length,o;r<i;++r)if((o=e[r]).name===n)return o.value}function Gw(e,n,r){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=cj,e=e.slice(0,i).concat(e.slice(i+1));break}return r!=null&&e.push({name:n,value:r}),e}var cv="http://www.w3.org/1999/xhtml";const Yw={svg:"http://www.w3.org/2000/svg",xhtml:cv,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Tu(e){var n=e+="",r=n.indexOf(":");return r>=0&&(n=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),Yw.hasOwnProperty(n)?{space:Yw[n],local:e}:e}function hj(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===cv&&n.documentElement.namespaceURI===cv?n.createElement(e):n.createElementNS(r,e)}}function pj(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function BE(e){var n=Tu(e);return(n.local?pj:hj)(n)}function mj(){}function qv(e){return e==null?mj:function(){return this.querySelector(e)}}function gj(e){typeof e!="function"&&(e=qv(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 bn(i,this._parents)}function vj(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function yj(){return[]}function UE(e){return e==null?yj:function(){return this.querySelectorAll(e)}}function wj(e){return function(){return vj(e.apply(this,arguments))}}function xj(e){typeof e=="function"?e=wj(e):e=UE(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 bn(i,o)}function HE(e){return function(){return this.matches(e)}}function WE(e){return function(n){return n.matches(e)}}var _j=Array.prototype.find;function bj(e){return function(){return _j.call(this.children,e)}}function Sj(){return this.firstElementChild}function kj(e){return this.select(e==null?Sj:bj(typeof e=="function"?e:WE(e)))}var Ej=Array.prototype.filter;function Nj(){return Array.from(this.children)}function Cj(e){return function(){return Ej.call(this.children,e)}}function Tj(e){return this.selectAll(e==null?Nj:Cj(typeof e=="function"?e:WE(e)))}function Rj(e){typeof e!="function"&&(e=HE(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 bn(i,this._parents)}function VE(e){return new Array(e.length)}function jj(){return new bn(this._enter||this._groups.map(VE),this._parents)}function hu(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}hu.prototype={constructor:hu,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 Aj(e){return function(){return e}}function Ij(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 hu(e,l[u]);for(;u<h;++u)(c=n[u])&&(o[u]=c)}function Mj(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 hu(e,l[c]);for(c=0;c<d;++c)(h=n[c])&&p.get(y[c])===h&&(o[c]=h)}function Oj(e){return e.__data__}function Pj(e,n){if(!arguments.length)return Array.from(this,Oj);var r=n?Mj:Ij,i=this._parents,o=this._groups;typeof e!="function"&&(e=Aj(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=Lj(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,C,I;k<N;++k)if(C=_[k]){for(k>=E&&(E=k+1);!(I=b[E])&&++E<N;);C._next=I||null}}return u=new bn(u,i),u._enter=c,u._exit=h,u}function Lj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function qj(){return new bn(this._exit||this._groups.map(VE),this._parents)}function $j(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 Dj(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 bn(c,this._parents)}function Fj(){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 zj(e){e||(e=Bj);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 bn(o,this._parents).order()}function Bj(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function Uj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Hj(){return Array.from(this)}function Wj(){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 Vj(){let e=0;for(const n of this)++e;return e}function Gj(){return!this.node()}function Yj(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 Kj(e){return function(){this.removeAttribute(e)}}function Xj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Qj(e,n){return function(){this.setAttribute(e,n)}}function Zj(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function Jj(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function eA(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 tA(e,n){var r=Tu(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?Xj:Kj:typeof n=="function"?r.local?eA:Jj:r.local?Zj:Qj)(r,n))}function GE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function nA(e){return function(){this.style.removeProperty(e)}}function rA(e,n,r){return function(){this.style.setProperty(e,n,r)}}function sA(e,n,r){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,r)}}function iA(e,n,r){return arguments.length>1?this.each((n==null?nA:typeof n=="function"?sA:rA)(e,n,r??"")):ao(this.node(),e)}function ao(e,n){return e.style.getPropertyValue(n)||GE(e).getComputedStyle(e,null).getPropertyValue(n)}function oA(e){return function(){delete this[e]}}function aA(e,n){return function(){this[e]=n}}function lA(e,n){return function(){var r=n.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function uA(e,n){return arguments.length>1?this.each((n==null?oA:typeof n=="function"?lA:aA)(e,n)):this.node()[e]}function YE(e){return e.trim().split(/^|\s+/)}function $v(e){return e.classList||new KE(e)}function KE(e){this._node=e,this._names=YE(e.getAttribute("class")||"")}KE.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 XE(e,n){for(var r=$v(e),i=-1,o=n.length;++i<o;)r.add(n[i])}function QE(e,n){for(var r=$v(e),i=-1,o=n.length;++i<o;)r.remove(n[i])}function cA(e){return function(){XE(this,e)}}function dA(e){return function(){QE(this,e)}}function fA(e,n){return function(){(n.apply(this,arguments)?XE:QE)(this,e)}}function hA(e,n){var r=YE(e+"");if(arguments.length<2){for(var i=$v(this.node()),o=-1,l=r.length;++o<l;)if(!i.contains(r[o]))return!1;return!0}return this.each((typeof n=="function"?fA:n?cA:dA)(r,n))}function pA(){this.textContent=""}function mA(e){return function(){this.textContent=e}}function gA(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function vA(e){return arguments.length?this.each(e==null?pA:(typeof e=="function"?gA:mA)(e)):this.node().textContent}function yA(){this.innerHTML=""}function wA(e){return function(){this.innerHTML=e}}function xA(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function _A(e){return arguments.length?this.each(e==null?yA:(typeof e=="function"?xA:wA)(e)):this.node().innerHTML}function bA(){this.nextSibling&&this.parentNode.appendChild(this)}function SA(){return this.each(bA)}function kA(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function EA(){return this.each(kA)}function NA(e){var n=typeof e=="function"?e:BE(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function CA(){return null}function TA(e,n){var r=typeof e=="function"?e:BE(e),i=n==null?CA:typeof n=="function"?n:qv(n);return this.select(function(){return this.insertBefore(r.apply(this,arguments),i.apply(this,arguments)||null)})}function RA(){var e=this.parentNode;e&&e.removeChild(this)}function jA(){return this.each(RA)}function AA(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function IA(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function MA(e){return this.select(e?IA:AA)}function OA(e){return arguments.length?this.property("__data__",e):this.node().__data__}function PA(e){return function(n){e.call(this,n,this.__data__)}}function LA(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 qA(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 $A(e,n,r){return function(){var i=this.__on,o,l=PA(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 DA(e,n,r){var i=LA(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?$A:qA,o=0;o<l;++o)this.each(c(i[o],n,r));return this}function ZE(e,n,r){var i=GE(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 FA(e,n){return function(){return ZE(this,e,n)}}function zA(e,n){return function(){return ZE(this,e,n.apply(this,arguments))}}function BA(e,n){return this.each((typeof n=="function"?zA:FA)(e,n))}function*UA(){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 JE=[null];function bn(e,n){this._groups=e,this._parents=n}function Ea(){return new bn([[document.documentElement]],JE)}function HA(){return this}bn.prototype=Ea.prototype={constructor:bn,select:gj,selectAll:xj,selectChild:kj,selectChildren:Tj,filter:Rj,data:Pj,enter:jj,exit:qj,join:$j,merge:Dj,selection:HA,order:Fj,sort:zj,call:Uj,nodes:Hj,node:Wj,size:Vj,empty:Gj,each:Yj,attr:tA,style:iA,property:uA,classed:hA,text:vA,html:_A,raise:SA,lower:EA,append:NA,insert:TA,remove:jA,clone:MA,datum:OA,on:DA,dispatch:BA,[Symbol.iterator]:UA};function Ln(e){return typeof e=="string"?new bn([[document.querySelector(e)]],[document.documentElement]):new bn([[e]],JE)}function WA(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Jn(e,n){if(e=WA(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 VA={passive:!1},pa={capture:!0,passive:!1};function Id(e){e.stopImmediatePropagation()}function ro(e){e.preventDefault(),e.stopImmediatePropagation()}function eN(e){var n=e.document.documentElement,r=Ln(e).on("dragstart.drag",ro,pa);"onselectstart"in n?r.on("selectstart.drag",ro,pa):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function tN(e,n){var r=e.document.documentElement,i=Ln(e).on("dragstart.drag",null);n&&(i.on("click.drag",ro,pa),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 Hl=e=>()=>e;function dv(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}})}dv.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function GA(e){return!e.ctrlKey&&!e.button}function YA(){return this.parentNode}function KA(e,n){return n??{x:e.x,y:e.y}}function XA(){return navigator.maxTouchPoints||"ontouchstart"in this}function QA(){var e=GA,n=YA,r=KA,i=XA,o={},l=Cu("start","drag","end"),u=0,c,h,p,d,m=0;function y(C){C.on("mousedown.drag",w).filter(i).on("touchstart.drag",b).on("touchmove.drag",S,VA).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(C,I){if(!(d||!e.call(this,C,I))){var P=E(this,n.call(this,C,I),C,I,"mouse");P&&(Ln(C.view).on("mousemove.drag",N,pa).on("mouseup.drag",_,pa),eN(C.view),Id(C),p=!1,c=C.clientX,h=C.clientY,P("start",C))}}function N(C){if(ro(C),!p){var I=C.clientX-c,P=C.clientY-h;p=I*I+P*P>m}o.mouse("drag",C)}function _(C){Ln(C.view).on("mousemove.drag mouseup.drag",null),tN(C.view,p),ro(C),o.mouse("end",C)}function b(C,I){if(e.call(this,C,I)){var P=C.changedTouches,A=n.call(this,C,I),H=P.length,z,L;for(z=0;z<H;++z)(L=E(this,A,C,I,P[z].identifier,P[z]))&&(Id(C),L("start",C,P[z]))}}function S(C){var I=C.changedTouches,P=I.length,A,H;for(A=0;A<P;++A)(H=o[I[A].identifier])&&(ro(C),H("drag",C,I[A]))}function k(C){var I=C.changedTouches,P=I.length,A,H;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),A=0;A<P;++A)(H=o[I[A].identifier])&&(Id(C),H("end",C,I[A]))}function E(C,I,P,A,H,z){var L=l.copy(),F=Jn(z||P,I),G,O,j;if((j=r.call(C,new dv("beforestart",{sourceEvent:P,target:y,identifier:H,active:u,x:F[0],y:F[1],dx:0,dy:0,dispatch:L}),A))!=null)return G=j.x-F[0]||0,O=j.y-F[1]||0,function q($,re,J){var W=F,Z;switch($){case"start":o[H]=q,Z=u++;break;case"end":delete o[H],--u;case"drag":F=Jn(J||re,I),Z=u;break}L.call($,C,new dv($,{sourceEvent:re,subject:j,target:y,identifier:H,active:Z,x:F[0]+G,y:F[1]+O,dx:F[0]-W[0],dy:F[1]-W[1],dispatch:L}),A)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Hl(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:Hl(C),y):n},y.subject=function(C){return arguments.length?(r=typeof C=="function"?C:Hl(C),y):r},y.touchable=function(C){return arguments.length?(i=typeof C=="function"?C:Hl(!!C),y):i},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function Dv(e,n,r){e.prototype=n.prototype=r,r.constructor=e}function nN(e,n){var r=Object.create(e.prototype);for(var i in n)r[i]=n[i];return r}function Na(){}var ma=.7,pu=1/ma,so="\\s*([+-]?\\d+)\\s*",ga="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",hr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",ZA=/^#([0-9a-f]{3,8})$/,JA=new RegExp(`^rgb\\(${so},${so},${so}\\)$`),e2=new RegExp(`^rgb\\(${hr},${hr},${hr}\\)$`),t2=new RegExp(`^rgba\\(${so},${so},${so},${ga}\\)$`),n2=new RegExp(`^rgba\\(${hr},${hr},${hr},${ga}\\)$`),r2=new RegExp(`^hsl\\(${ga},${hr},${hr}\\)$`),s2=new RegExp(`^hsla\\(${ga},${hr},${hr},${ga}\\)$`),Kw={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};Dv(Na,va,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Xw,formatHex:Xw,formatHex8:i2,formatHsl:o2,formatRgb:Qw,toString:Qw});function Xw(){return this.rgb().formatHex()}function i2(){return this.rgb().formatHex8()}function o2(){return rN(this).formatHsl()}function Qw(){return this.rgb().formatRgb()}function va(e){var n,r;return e=(e+"").trim().toLowerCase(),(n=ZA.exec(e))?(r=n[1].length,n=parseInt(n[1],16),r===6?Zw(n):r===3?new cn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?Wl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?Wl(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=JA.exec(e))?new cn(n[1],n[2],n[3],1):(n=e2.exec(e))?new cn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=t2.exec(e))?Wl(n[1],n[2],n[3],n[4]):(n=n2.exec(e))?Wl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=r2.exec(e))?tx(n[1],n[2]/100,n[3]/100,1):(n=s2.exec(e))?tx(n[1],n[2]/100,n[3]/100,n[4]):Kw.hasOwnProperty(e)?Zw(Kw[e]):e==="transparent"?new cn(NaN,NaN,NaN,0):null}function Zw(e){return new cn(e>>16&255,e>>8&255,e&255,1)}function Wl(e,n,r,i){return i<=0&&(e=n=r=NaN),new cn(e,n,r,i)}function a2(e){return e instanceof Na||(e=va(e)),e?(e=e.rgb(),new cn(e.r,e.g,e.b,e.opacity)):new cn}function fv(e,n,r,i){return arguments.length===1?a2(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}Dv(cn,fv,nN(Na,{brighter(e){return e=e==null?pu:Math.pow(pu,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ma:Math.pow(ma,e),new cn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new cn(ai(this.r),ai(this.g),ai(this.b),mu(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:Jw,formatHex:Jw,formatHex8:l2,formatRgb:ex,toString:ex}));function Jw(){return`#${ii(this.r)}${ii(this.g)}${ii(this.b)}`}function l2(){return`#${ii(this.r)}${ii(this.g)}${ii(this.b)}${ii((isNaN(this.opacity)?1:this.opacity)*255)}`}function ex(){const e=mu(this.opacity);return`${e===1?"rgb(":"rgba("}${ai(this.r)}, ${ai(this.g)}, ${ai(this.b)}${e===1?")":`, ${e})`}`}function mu(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function ai(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ii(e){return e=ai(e),(e<16?"0":"")+e.toString(16)}function tx(e,n,r,i){return i<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new er(e,n,r,i)}function rN(e){if(e instanceof er)return new er(e.h,e.s,e.l,e.opacity);if(e instanceof Na||(e=va(e)),!e)return new er;if(e instanceof er)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 er(u,c,h,e.opacity)}function u2(e,n,r,i){return arguments.length===1?rN(e):new er(e,n,r,i??1)}function er(e,n,r,i){this.h=+e,this.s=+n,this.l=+r,this.opacity=+i}Dv(er,u2,nN(Na,{brighter(e){return e=e==null?pu:Math.pow(pu,e),new er(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ma:Math.pow(ma,e),new er(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(Md(e>=240?e-240:e+120,o,i),Md(e,o,i),Md(e<120?e+240:e-120,o,i),this.opacity)},clamp(){return new er(nx(this.h),Vl(this.s),Vl(this.l),mu(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=mu(this.opacity);return`${e===1?"hsl(":"hsla("}${nx(this.h)}, ${Vl(this.s)*100}%, ${Vl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function nx(e){return e=(e||0)%360,e<0?e+360:e}function Vl(e){return Math.max(0,Math.min(1,e||0))}function Md(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 sN=e=>()=>e;function c2(e,n){return function(r){return e+r*n}}function d2(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 f2(e){return(e=+e)==1?iN:function(n,r){return r-n?d2(n,r,e):sN(isNaN(n)?r:n)}}function iN(e,n){var r=n-e;return r?c2(e,r):sN(isNaN(e)?n:e)}const rx=(function e(n){var r=f2(n);function i(o,l){var u=r((o=fv(o)).r,(l=fv(l)).r),c=r(o.g,l.g),h=r(o.b,l.b),p=iN(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 _s(e,n){return e=+e,n=+n,function(r){return e*(1-r)+n*r}}var hv=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Od=new RegExp(hv.source,"g");function h2(e){return function(){return e}}function p2(e){return function(n){return e(n)+""}}function m2(e,n){var r=hv.lastIndex=Od.lastIndex=0,i,o,l,u=-1,c=[],h=[];for(e=e+"",n=n+"";(i=hv.exec(e))&&(o=Od.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:_s(i,o)})),r=Od.lastIndex;return r<n.length&&(l=n.slice(r),c[u]?c[u]+=l:c[++u]=l),c.length<2?h[0]?p2(h[0].x):h2(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 sx=180/Math.PI,pv={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function oN(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)*sx,skewX:Math.atan(h)*sx,scaleX:u,scaleY:c}}var Gl;function g2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?pv:oN(n.a,n.b,n.c,n.d,n.e,n.f)}function v2(e){return e==null||(Gl||(Gl=document.createElementNS("http://www.w3.org/2000/svg","g")),Gl.setAttribute("transform",e),!(e=Gl.transform.baseVal.consolidate()))?pv:(e=e.matrix,oN(e.a,e.b,e.c,e.d,e.e,e.f))}function aN(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:_s(p,m)},{i:_-2,x:_s(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:_s(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:_s(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:_s(p,m)},{i:_-2,x:_s(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 y2=aN(g2,"px, ","px)","deg)"),w2=aN(v2,", ",")",")"),x2=1e-12;function ix(e){return((e=Math.exp(e))+1/e)/2}function _2(e){return((e=Math.exp(e))-1/e)/2}function b2(e){return((e=Math.exp(2*e))-1)/(e+1)}const S2=(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(_<x2)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),C=(y*y-p*p-i*_)/(2*y*r*k),I=Math.log(Math.sqrt(E*E+1)-E),P=Math.log(Math.sqrt(C*C+1)-C);S=(P-I)/n,b=function(A){var H=A*S,z=ix(I),L=p/(r*k)*(z*b2(n*H+I)-_2(I));return[c+L*w,h+L*N,p*z/ix(n*H+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 lo=0,la=0,na=0,lN=1e3,gu,ua,vu=0,ui=0,Ru=0,ya=typeof performance=="object"&&performance.now?performance:Date,uN=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Fv(){return ui||(uN(k2),ui=ya.now()+Ru)}function k2(){ui=0}function yu(){this._call=this._time=this._next=null}yu.prototype=cN.prototype={constructor:yu,restart:function(e,n,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?Fv():+r)+(n==null?0:+n),!this._next&&ua!==this&&(ua?ua._next=this:gu=this,ua=this),this._call=e,this._time=r,mv()},stop:function(){this._call&&(this._call=null,this._time=1/0,mv())}};function cN(e,n,r){var i=new yu;return i.restart(e,n,r),i}function E2(){Fv(),++lo;for(var e=gu,n;e;)(n=ui-e._time)>=0&&e._call.call(void 0,n),e=e._next;--lo}function ox(){ui=(vu=ya.now())+Ru,lo=la=0;try{E2()}finally{lo=0,C2(),ui=0}}function N2(){var e=ya.now(),n=e-vu;n>lN&&(Ru-=n,vu=e)}function C2(){for(var e,n=gu,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:gu=r);ua=e,mv(i)}function mv(e){if(!lo){la&&(la=clearTimeout(la));var n=e-ui;n>24?(e<1/0&&(la=setTimeout(ox,e-ya.now()-Ru)),na&&(na=clearInterval(na))):(na||(vu=ya.now(),na=setInterval(N2,lN)),lo=1,uN(ox))}}function ax(e,n,r){var i=new yu;return n=n==null?0:+n,i.restart(o=>{i.stop(),e(o+n)},n,r),i}var T2=Cu("start","end","cancel","interrupt"),R2=[],dN=0,lx=1,gv=2,lu=3,ux=4,vv=5,uu=6;function ju(e,n,r,i,o,l){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;j2(e,r,{name:n,index:i,group:o,on:T2,tween:R2,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:dN})}function zv(e,n){var r=rr(e,n);if(r.state>dN)throw new Error("too late; already scheduled");return r}function pr(e,n){var r=rr(e,n);if(r.state>lu)throw new Error("too late; already running");return r}function rr(e,n){var r=e.__transition;if(!r||!(r=r[n]))throw new Error("transition not found");return r}function j2(e,n,r){var i=e.__transition,o;i[n]=r,r.timer=cN(l,0,r.time);function l(p){r.state=lx,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!==lx)return h();for(d in i)if(w=i[d],w.name===r.name){if(w.state===lu)return ax(u);w.state===ux?(w.state=uu,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete i[d]):+d<n&&(w.state=uu,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete i[d])}if(ax(function(){r.state===lu&&(r.state=ux,r.timer.restart(c,r.delay,r.time),c(p))}),r.state=gv,r.on.call("start",e,e.__data__,r.index,r.group),r.state===gv){for(r.state=lu,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=vv,1),m=-1,y=o.length;++m<y;)o[m].call(e,d);r.state===vv&&(r.on.call("end",e,e.__data__,r.index,r.group),h())}function h(){r.state=uu,r.timer.stop(),delete i[n];for(var p in i)return;delete e.__transition}}function cu(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>gv&&i.state<vv,i.state=uu,i.timer.stop(),i.on.call(o?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete r[u]}l&&delete e.__transition}}function A2(e){return this.each(function(){cu(this,e)})}function I2(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 M2(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 O2(e,n){var r=this._id;if(e+="",arguments.length<2){for(var i=rr(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?I2:M2)(r,e,n))}function Bv(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 rr(o,i).value[n]}}function fN(e,n){var r;return(typeof n=="number"?_s:n instanceof va?rx:(r=va(n))?(n=r,rx):m2)(e,n)}function P2(e){return function(){this.removeAttribute(e)}}function L2(e){return function(){this.removeAttributeNS(e.space,e.local)}}function q2(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 $2(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 D2(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 F2(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 z2(e,n){var r=Tu(e),i=r==="transform"?w2:fN;return this.attrTween(e,typeof n=="function"?(r.local?F2:D2)(r,i,Bv(this,"attr."+e,n)):n==null?(r.local?L2:P2)(r):(r.local?$2:q2)(r,i,n))}function B2(e,n){return function(r){this.setAttribute(e,n.call(this,r))}}function U2(e,n){return function(r){this.setAttributeNS(e.space,e.local,n.call(this,r))}}function H2(e,n){var r,i;function o(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&U2(e,l)),r}return o._value=n,o}function W2(e,n){var r,i;function o(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&B2(e,l)),r}return o._value=n,o}function V2(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=Tu(e);return this.tween(r,(i.local?H2:W2)(i,n))}function G2(e,n){return function(){zv(this,e).delay=+n.apply(this,arguments)}}function Y2(e,n){return n=+n,function(){zv(this,e).delay=n}}function K2(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?G2:Y2)(n,e)):rr(this.node(),n).delay}function X2(e,n){return function(){pr(this,e).duration=+n.apply(this,arguments)}}function Q2(e,n){return n=+n,function(){pr(this,e).duration=n}}function Z2(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?X2:Q2)(n,e)):rr(this.node(),n).duration}function J2(e,n){if(typeof n!="function")throw new Error;return function(){pr(this,e).ease=n}}function eI(e){var n=this._id;return arguments.length?this.each(J2(n,e)):rr(this.node(),n).ease}function tI(e,n){return function(){var r=n.apply(this,arguments);if(typeof r!="function")throw new Error;pr(this,e).ease=r}}function nI(e){if(typeof e!="function")throw new Error;return this.each(tI(this._id,e))}function rI(e){typeof e!="function"&&(e=HE(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 zr(i,this._parents,this._name,this._id)}function sI(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 zr(u,this._parents,this._name,this._id)}function iI(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 oI(e,n,r){var i,o,l=iI(n)?zv:pr;return function(){var u=l(this,e),c=u.on;c!==i&&(o=(i=c).copy()).on(n,r),u.on=o}}function aI(e,n){var r=this._id;return arguments.length<2?rr(this.node(),r).on.on(e):this.each(oI(r,e,n))}function lI(e){return function(){var n=this.parentNode;for(var r in this.__transition)if(+r!==e)return;n&&n.removeChild(this)}}function uI(){return this.on("end.remove",lI(this._id))}function cI(e){var n=this._name,r=this._id;typeof e!="function"&&(e=qv(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,ju(p[y],n,r,y,p,rr(d,r)));return new zr(l,this._parents,n,r)}function dI(e){var n=this._name,r=this._id;typeof e!="function"&&(e=UE(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=rr(d,r),_=0,b=y.length;_<b;++_)(w=y[_])&&ju(w,n,r,_,y,N);l.push(y),u.push(d)}return new zr(l,u,n,r)}var fI=Ea.prototype.constructor;function hI(){return new fI(this._groups,this._parents)}function pI(e,n){var r,i,o;return function(){var l=ao(this,e),u=(this.style.removeProperty(e),ao(this,e));return l===u?null:l===r&&u===i?o:o=n(r=l,i=u)}}function hN(e){return function(){this.style.removeProperty(e)}}function mI(e,n,r){var i,o=r+"",l;return function(){var u=ao(this,e);return u===o?null:u===i?l:l=n(i=u,r)}}function gI(e,n,r){var i,o,l;return function(){var u=ao(this,e),c=r(this),h=c+"";return c==null&&(h=c=(this.style.removeProperty(e),ao(this,e))),u===h?null:u===i&&h===o?l:(o=h,l=n(i=u,c))}}function vI(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=hN(n)):void 0;(p!==r||o!==d)&&(i=(r=p).copy()).on(u,o=d),h.on=i}}function yI(e,n,r){var i=(e+="")=="transform"?y2:fN;return n==null?this.styleTween(e,pI(e,i)).on("end.style."+e,hN(e)):typeof n=="function"?this.styleTween(e,gI(e,i,Bv(this,"style."+e,n))).each(vI(this._id,e)):this.styleTween(e,mI(e,i,n),r).on("end.style."+e,null)}function wI(e,n,r){return function(i){this.style.setProperty(e,n.call(this,i),r)}}function xI(e,n,r){var i,o;function l(){var u=n.apply(this,arguments);return u!==o&&(i=(o=u)&&wI(e,u,r)),i}return l._value=n,l}function _I(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,xI(e,n,r??""))}function bI(e){return function(){this.textContent=e}}function SI(e){return function(){var n=e(this);this.textContent=n??""}}function kI(e){return this.tween("text",typeof e=="function"?SI(Bv(this,"text",e)):bI(e==null?"":e+""))}function EI(e){return function(n){this.textContent=e.call(this,n)}}function NI(e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&EI(o)),n}return i._value=e,i}function CI(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,NI(e))}function TI(){for(var e=this._name,n=this._id,r=pN(),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=rr(h,n);ju(h,e,r,p,u,{time:d.time+d.delay+d.duration,delay:0,duration:d.duration,ease:d.ease})}return new zr(i,this._parents,e,r)}function RI(){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 jI=0;function zr(e,n,r,i){this._groups=e,this._parents=n,this._name=r,this._id=i}function pN(){return++jI}var $r=Ea.prototype;zr.prototype={constructor:zr,select:cI,selectAll:dI,selectChild:$r.selectChild,selectChildren:$r.selectChildren,filter:rI,merge:sI,selection:hI,transition:TI,call:$r.call,nodes:$r.nodes,node:$r.node,size:$r.size,empty:$r.empty,each:$r.each,on:aI,attr:z2,attrTween:V2,style:yI,styleTween:_I,text:kI,textTween:CI,remove:uI,tween:O2,delay:K2,duration:Z2,ease:eI,easeVarying:nI,end:RI,[Symbol.iterator]:$r[Symbol.iterator]};function AI(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var II={time:null,delay:0,duration:250,ease:AI};function MI(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 OI(e){var n,r;e instanceof zr?(n=e._id,e=e._name):(n=pN(),(r=II).time=Fv(),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])&&ju(h,e,n,p,u,r||MI(h,n));return new zr(i,this._parents,e,n)}Ea.prototype.interrupt=A2;Ea.prototype.transition=OI;const Yl=e=>()=>e;function PI(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 Dr(e,n,r){this.k=e,this.x=n,this.y=r}Dr.prototype={constructor:Dr,scale:function(e){return e===1?this:new Dr(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Dr(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 Fr=new Dr(1,0,0);Dr.prototype;function Pd(e){e.stopImmediatePropagation()}function ra(e){e.preventDefault(),e.stopImmediatePropagation()}function LI(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function qI(){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 cx(){return this.__zoom||Fr}function $I(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function DI(){return navigator.maxTouchPoints||"ontouchstart"in this}function FI(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 mN(){var e=LI,n=qI,r=FI,i=$I,o=DI,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,h=S2,p=Cu("start","zoom","end"),d,m,y,w=500,N=150,_=0,b=10;function S(j){j.property("__zoom",cx).on("wheel.zoom",H,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",L).filter(o).on("touchstart.zoom",F).on("touchmove.zoom",G).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(j,q,$,re){var J=j.selection?j.selection():j;J.property("__zoom",cx),j!==J?I(j,q,$,re):J.interrupt().each(function(){P(this,arguments).event(re).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},S.scaleBy=function(j,q,$,re){S.scaleTo(j,function(){var J=this.__zoom.k,W=typeof q=="function"?q.apply(this,arguments):q;return J*W},$,re)},S.scaleTo=function(j,q,$,re){S.transform(j,function(){var J=n.apply(this,arguments),W=this.__zoom,Z=$==null?C(J):typeof $=="function"?$.apply(this,arguments):$,M=W.invert(Z),Y=typeof q=="function"?q.apply(this,arguments):q;return r(E(k(W,Y),Z,M),J,u)},$,re)},S.translateBy=function(j,q,$,re){S.transform(j,function(){return r(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof $=="function"?$.apply(this,arguments):$),n.apply(this,arguments),u)},null,re)},S.translateTo=function(j,q,$,re,J){S.transform(j,function(){var W=n.apply(this,arguments),Z=this.__zoom,M=re==null?C(W):typeof re=="function"?re.apply(this,arguments):re;return r(Fr.translate(M[0],M[1]).scale(Z.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof $=="function"?-$.apply(this,arguments):-$),W,u)},re,J)};function k(j,q){return q=Math.max(l[0],Math.min(l[1],q)),q===j.k?j:new Dr(q,j.x,j.y)}function E(j,q,$){var re=q[0]-$[0]*j.k,J=q[1]-$[1]*j.k;return re===j.x&&J===j.y?j:new Dr(j.k,re,J)}function C(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function I(j,q,$,re){j.on("start.zoom",function(){P(this,arguments).event(re).start()}).on("interrupt.zoom end.zoom",function(){P(this,arguments).event(re).end()}).tween("zoom",function(){var J=this,W=arguments,Z=P(J,W).event(re),M=n.apply(J,W),Y=$==null?C(M):typeof $=="function"?$.apply(J,W):$,U=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),B=J.__zoom,X=typeof q=="function"?q.apply(J,W):q,ne=h(B.invert(Y).concat(U/B.k),X.invert(Y).concat(U/X.k));return function(le){if(le===1)le=X;else{var fe=ne(le),te=U/fe[2];le=new Dr(te,Y[0]-fe[0]*te,Y[1]-fe[1]*te)}Z.zoom(null,le)}})}function P(j,q,$){return!$&&j.__zooming||new A(j,q)}function A(j,q){this.that=j,this.args=q,this.active=0,this.sourceEvent=null,this.extent=n.apply(j,q),this.taps=0}A.prototype={event:function(j){return j&&(this.sourceEvent=j),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(j,q){return this.mouse&&j!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&j!=="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(j){var q=Ln(this.that).datum();p.call(j,this.that,new PI(j,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:p}),q)}};function H(j,...q){if(!e.apply(this,arguments))return;var $=P(this,q).event(j),re=this.__zoom,J=Math.max(l[0],Math.min(l[1],re.k*Math.pow(2,i.apply(this,arguments)))),W=Jn(j);if($.wheel)($.mouse[0][0]!==W[0]||$.mouse[0][1]!==W[1])&&($.mouse[1]=re.invert($.mouse[0]=W)),clearTimeout($.wheel);else{if(re.k===J)return;$.mouse=[W,re.invert(W)],cu(this),$.start()}ra(j),$.wheel=setTimeout(Z,N),$.zoom("mouse",r(E(k(re,J),$.mouse[0],$.mouse[1]),$.extent,u));function Z(){$.wheel=null,$.end()}}function z(j,...q){if(y||!e.apply(this,arguments))return;var $=j.currentTarget,re=P(this,q,!0).event(j),J=Ln(j.view).on("mousemove.zoom",Y,!0).on("mouseup.zoom",U,!0),W=Jn(j,$),Z=j.clientX,M=j.clientY;eN(j.view),Pd(j),re.mouse=[W,this.__zoom.invert(W)],cu(this),re.start();function Y(B){if(ra(B),!re.moved){var X=B.clientX-Z,ne=B.clientY-M;re.moved=X*X+ne*ne>_}re.event(B).zoom("mouse",r(E(re.that.__zoom,re.mouse[0]=Jn(B,$),re.mouse[1]),re.extent,u))}function U(B){J.on("mousemove.zoom mouseup.zoom",null),tN(B.view,re.moved),ra(B),re.event(B).end()}}function L(j,...q){if(e.apply(this,arguments)){var $=this.__zoom,re=Jn(j.changedTouches?j.changedTouches[0]:j,this),J=$.invert(re),W=$.k*(j.shiftKey?.5:2),Z=r(E(k($,W),re,J),n.apply(this,q),u);ra(j),c>0?Ln(this).transition().duration(c).call(I,Z,re,j):Ln(this).call(S.transform,Z,re,j)}}function F(j,...q){if(e.apply(this,arguments)){var $=j.touches,re=$.length,J=P(this,q,j.changedTouches.length===re).event(j),W,Z,M,Y;for(Pd(j),Z=0;Z<re;++Z)M=$[Z],Y=Jn(M,this),Y=[Y,this.__zoom.invert(Y),M.identifier],J.touch0?!J.touch1&&J.touch0[2]!==Y[2]&&(J.touch1=Y,J.taps=0):(J.touch0=Y,W=!0,J.taps=1+!!d);d&&(d=clearTimeout(d)),W&&(J.taps<2&&(m=Y[0],d=setTimeout(function(){d=null},w)),cu(this),J.start())}}function G(j,...q){if(this.__zooming){var $=P(this,q).event(j),re=j.changedTouches,J=re.length,W,Z,M,Y;for(ra(j),W=0;W<J;++W)Z=re[W],M=Jn(Z,this),$.touch0&&$.touch0[2]===Z.identifier?$.touch0[0]=M:$.touch1&&$.touch1[2]===Z.identifier&&($.touch1[0]=M);if(Z=$.that.__zoom,$.touch1){var U=$.touch0[0],B=$.touch0[1],X=$.touch1[0],ne=$.touch1[1],le=(le=X[0]-U[0])*le+(le=X[1]-U[1])*le,fe=(fe=ne[0]-B[0])*fe+(fe=ne[1]-B[1])*fe;Z=k(Z,Math.sqrt(le/fe)),M=[(U[0]+X[0])/2,(U[1]+X[1])/2],Y=[(B[0]+ne[0])/2,(B[1]+ne[1])/2]}else if($.touch0)M=$.touch0[0],Y=$.touch0[1];else return;$.zoom("touch",r(E(Z,M,Y),$.extent,u))}}function O(j,...q){if(this.__zooming){var $=P(this,q).event(j),re=j.changedTouches,J=re.length,W,Z;for(Pd(j),y&&clearTimeout(y),y=setTimeout(function(){y=null},w),W=0;W<J;++W)Z=re[W],$.touch0&&$.touch0[2]===Z.identifier?delete $.touch0:$.touch1&&$.touch1[2]===Z.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(Z=Jn(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(j){return arguments.length?(i=typeof j=="function"?j:Yl(+j),S):i},S.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Yl(!!j),S):e},S.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Yl(!!j),S):o},S.extent=function(j){return arguments.length?(n=typeof j=="function"?j:Yl([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),S):n},S.scaleExtent=function(j){return arguments.length?(l[0]=+j[0],l[1]=+j[1],S):[l[0],l[1]]},S.translateExtent=function(j){return arguments.length?(u[0][0]=+j[0][0],u[1][0]=+j[1][0],u[0][1]=+j[0][1],u[1][1]=+j[1][1],S):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},S.constrain=function(j){return arguments.length?(r=j,S):r},S.duration=function(j){return arguments.length?(c=+j,S):c},S.interpolate=function(j){return arguments.length?(h=j,S):h},S.on=function(){var j=p.on.apply(p,arguments);return j===p?S:j},S.clickDistance=function(j){return arguments.length?(_=(j=+j)*j,S):Math.sqrt(_)},S.tapDistance=function(j){return arguments.length?(b=+j,S):b},S}var zI=FE();const Au=R.createContext(null),BI=Au.Provider,Br={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.`},gN=Br.error001();function Ke(e,n){const r=R.useContext(Au);if(r===null)throw new Error(gN);return zE(r,e,n)}const Tt=()=>{const e=R.useContext(Au);if(e===null)throw new Error(gN);return R.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},UI=e=>e.userSelectionActive?"none":"all";function Uv({position:e,children:n,className:r,style:i,...o}){const l=Ke(UI),u=`${e}`.split("-");return ue.createElement("div",{className:Dt(["react-flow__panel",r,...u]),style:{...i,pointerEvents:l},...o},n)}function HI({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:ue.createElement(Uv,{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 WI=({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=R.useRef(null),[y,w]=R.useState({x:0,y:0,width:0,height:0}),N=Dt(["react-flow__edge-textwrapper",p]);return R.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 VI=R.memo(WI);const Hv=e=>({width:e.offsetWidth,height:e.offsetHeight}),uo=(e,n=0,r=1)=>Math.min(Math.max(e,n),r),Wv=(e={x:0,y:0},n)=>({x:uo(e.x,n[0][0],n[1][0]),y:uo(e.y,n[0][1],n[1][1])}),dx=(e,n,r)=>e<n?uo(Math.abs(e-n),1,50)/50:e>r?-uo(Math.abs(e-r),1,50)/50:0,vN=(e,n)=>{const r=dx(e.x,35,n.width-35)*20,i=dx(e.y,35,n.height-35)*20;return[r,i]},yN=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},wN=(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)}),wa=({x:e,y:n,width:r,height:i})=>({x:e,y:n,x2:e+r,y2:n+i}),xN=({x:e,y:n,x2:r,y2:i})=>({x:e,y:n,width:r-e,height:i-n}),fx=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),GI=(e,n)=>xN(wN(wa(e),wa(n))),yv=(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)},YI=e=>qn(e.width)&&qn(e.height)&&qn(e.x)&&qn(e.y),qn=e=>!isNaN(e)&&isFinite(e),vt=Symbol.for("internals"),_N=["Enter"," ","Escape"],KI=(e,n)=>{},XI=e=>"nativeEvent"in e;function wv(e){var o,l;const n=XI(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 bN=e=>"clientX"in e,ks=(e,n)=>{var l,u;const r=bN(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)}},wu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Ca=({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&&qn(r)&&qn(i)?ue.createElement(VI,{x:r,y:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:h,labelBgBorderRadius:p}):null);Ca.displayName="BaseEdge";function sa(e,n,r){return r===void 0?r:i=>{const o=n().edges.find(l=>l.id===e);o&&r(i,{...o})}}function SN({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 kN({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 ci;(function(e){e.Strict="strict",e.Loose="loose"})(ci||(ci={}));var oi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(oi||(oi={}));var xa;(function(e){e.Partial="partial",e.Full="full"})(xa||(xa={}));var Ss;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ss||(Ss={}));var xu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(xu||(xu={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function hx({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 EN({sourceX:e,sourceY:n,sourcePosition:r=Ae.Bottom,targetX:i,targetY:o,targetPosition:l=Ae.Top}){const[u,c]=hx({pos:r,x1:e,y1:n,x2:i,y2:o}),[h,p]=hx({pos:l,x1:i,y1:o,x2:e,y2:n}),[d,m,y,w]=kN({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 Vv=R.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]=EN({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:l});return ue.createElement(Ca,{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:_})});Vv.displayName="SimpleBezierEdge";const px={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},QI=({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},mx=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function ZI({source:e,sourcePosition:n=Ae.Bottom,target:r,targetPosition:i=Ae.Top,center:o,offset:l}){const u=px[n],c=px[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=QI({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,C,I]=SN({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}],H=[{x:h.x,y:_},{x:p.x,y:_}];u[m]===y?w=m==="x"?A:H:w=m==="x"?H:A}else{const A=[{x:h.x,y:p.y}],H=[{x:p.x,y:h.y}];if(m==="x"?w=u.x===y?H:A:w=u.y===y?A:H,n===i){const O=Math.abs(e[m]-r[m]);if(O<=l){const j=Math.min(l-1,l-O);u[m]===y?b[m]=(h[m]>e[m]?-1:1)*j:S[m]=(p[m]>r[m]?-1:1)*j}}if(n!==i){const O=m==="x"?"y":"x",j=u[m]===c[O],q=h[O]>p[O],$=h[O]<p[O];(u[m]===1&&(!j&&q||j&&$)||u[m]!==1&&(!j&&$||j&&q))&&(w=m==="x"?A:H)}const z={x:h.x+b.x,y:h.y+b.y},L={x:p.x+S.x,y:p.y+S.y},F=Math.max(Math.abs(z.x-w[0].x),Math.abs(L.x-w[0].x)),G=Math.max(Math.abs(z.y-w[0].y),Math.abs(L.y-w[0].y));F>=G?(N=(z.x+L.x)/2,_=w[0].y):(N=w[0].x,_=(z.y+L.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,_,C,I]}function JI(e,n,r,i){const o=Math.min(mx(e,n)/2,mx(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 xv({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]=ZI({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=JI(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 Iu=R.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]=xv({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(Ca,{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})});Iu.displayName="SmoothStepEdge";const Gv=R.memo(e=>{var n;return ue.createElement(Iu,{...e,pathOptions:R.useMemo(()=>{var r;return{borderRadius:0,offset:(r=e.pathOptions)==null?void 0:r.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});Gv.displayName="StepEdge";function eM({sourceX:e,sourceY:n,targetX:r,targetY:i}){const[o,l,u,c]=SN({sourceX:e,sourceY:n,targetX:r,targetY:i});return[`M ${e},${n}L ${r},${i}`,o,l,u,c]}const Yv=R.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]=eM({sourceX:e,sourceY:n,targetX:r,targetY:i});return ue.createElement(Ca,{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})});Yv.displayName="StraightEdge";function Kl(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function gx({pos:e,x1:n,y1:r,x2:i,y2:o,c:l}){switch(e){case Ae.Left:return[n-Kl(n-i,l),r];case Ae.Right:return[n+Kl(i-n,l),r];case Ae.Top:return[n,r-Kl(r-o,l)];case Ae.Bottom:return[n,r+Kl(o-r,l)]}}function NN({sourceX:e,sourceY:n,sourcePosition:r=Ae.Bottom,targetX:i,targetY:o,targetPosition:l=Ae.Top,curvature:u=.25}){const[c,h]=gx({pos:r,x1:e,y1:n,x2:i,y2:o,c:u}),[p,d]=gx({pos:l,x1:i,y1:o,x2:e,y2:n,c:u}),[m,y,w,N]=kN({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 _u=R.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]=NN({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:l,curvature:_==null?void 0:_.curvature});return ue.createElement(Ca,{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})});_u.displayName="BezierEdge";const Kv=R.createContext(null),tM=Kv.Provider;Kv.Consumer;const nM=()=>R.useContext(Kv),rM=e=>"id"in e&&"source"in e&&"target"in e,sM=({source:e,sourceHandle:n,target:r,targetHandle:i})=>`reactflow__edge-${e}${n||""}-${r}${i||""}`,_v=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`,iM=(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)),oM=(e,n)=>{if(!e.source||!e.target)return n;let r;return rM(e)?r={...e}:r={...e,id:sM(e)},iM(r,n)?n:n.concat(r)},bv=({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},CN=({x:e,y:n},[r,i,o])=>({x:e*o+r,y:n*o+i}),li=(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}},Mu=(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}=li(o,n).positionAbsolute;return wN(i,wa({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 xN(r)},TN=(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:_}=li(d,c),b={x:_.x,y:_.y,width:m||0,height:y||0},S=yv(h,b),k=typeof m>"u"||typeof y>"u"||m===null||y===null,E=l&&S>0,C=(m||0)*(y||0);(k||E||S>=C||d.dragging)&&p.push(d)}),p},RN=(e,n)=>{const r=e.map(i=>i.id);return n.filter(i=>r.includes(i.source)||r.includes(i.target))},jN=(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=uo(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}},si=(e,n=0)=>e.transition().duration(n);function vx(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 aM(e,n,r,i,o,l){const{x:u,y:c}=ks(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 _=Xv(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:AN()};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 lM={source:null,target:null,sourceHandle:null,targetHandle:null},AN=()=>({handleDomNode:null,isValid:!1,connection:lM,endHandle:null});function IN(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={...AN(),handleDomNode:h};if(h){const d=Xv(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===ci.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 uM({nodes:e,nodeId:n,handleId:r,handleType:i}){return e.reduce((o,l)=>{if(l[vt]){const{handleBounds:u}=l[vt];let c=[],h=[];u&&(c=vx(l,u,"source",`${n}-${r}-${i}`),h=vx(l,u,"target",`${n}-${r}-${i}`)),o.push(...c,...h)}return o},[])}function Xv(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function Ld(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function cM(e,n){let r=null;return n?r="valid":e&&!n&&(r="invalid"),r}function MN({event:e,handleId:n,nodeId:r,onConnect:i,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:h,onReconnectEnd:p}){const d=yN(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:w,connectionRadius:N,onConnectStart:_,panBy:b,getNodes:S,cancelConnection:k}=l();let E=0,C;const{x:I,y:P}=ks(e),A=d==null?void 0:d.elementFromPoint(I,P),H=Xv(h,A),z=y==null?void 0:y.getBoundingClientRect();if(!z||!H)return;let L,F=ks(e,z),G=!1,O=null,j=!1,q=null;const $=uM({nodes:S(),nodeId:r,handleId:n,handleType:H}),re=()=>{if(!w)return;const[Z,M]=vN(F,z);b({x:Z,y:M}),E=requestAnimationFrame(re)};u({connectionPosition:F,connectionStatus:null,connectionNodeId:r,connectionHandleId:n,connectionHandleType:H,connectionStartHandle:{nodeId:r,handleId:n,type:H},connectionEndHandle:null}),_==null||_(e,{nodeId:r,handleId:n,handleType:H});function J(Z){const{transform:M}=l();F=ks(Z,z);const{handle:Y,validHandleResult:U}=aM(Z,d,bv(F,M,!1,[1,1]),N,$,B=>IN(B,m,r,n,o?"target":"source",c,d));if(C=Y,G||(re(),G=!0),q=U.handleDomNode,O=U.connection,j=U.isValid,u({connectionPosition:C&&j?CN({x:C.x,y:C.y},M):F,connectionStatus:cM(!!C,j),connectionEndHandle:U.endHandle}),!C&&!j&&!q)return Ld(L);O.source!==O.target&&q&&(Ld(L),L=q,q.classList.add("connecting","react-flow__handle-connecting"),q.classList.toggle("valid",j),q.classList.toggle("react-flow__handle-valid",j))}function W(Z){var M,Y;(C||q)&&O&&j&&(i==null||i(O)),(Y=(M=l()).onConnectEnd)==null||Y.call(M,Z),h&&(p==null||p(Z)),Ld(L),k(),cancelAnimationFrame(E),G=!1,j=!1,O=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 yx=()=>!0,dM=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),fM=(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}},ON=R.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,L;const N=u||null,_=e==="target",b=Tt(),S=nM(),{connectOnClick:k,noPanClassName:E}=Ke(dM,Ct),{connecting:C,clickConnecting:I}=Ke(fM(S,N,e),Ct);S||(L=(z=b.getState()).onError)==null||L.call(z,"010",Br.error010());const P=F=>{const{defaultEdgeOptions:G,onConnect:O,hasDefaultEdges:j}=b.getState(),q={...G,...F};if(j){const{edges:$,setEdges:re}=b.getState();re(oM(q,$))}O==null||O(q),c==null||c(q)},A=F=>{if(!S)return;const G=bN(F);o&&(G&&F.button===0||!G)&&MN({event:F,handleId:N,nodeId:S,onConnect:P,isTarget:_,getState:b.getState,setState:b.setState,isValidConnection:r||b.getState().isValidConnection||yx}),G?d==null||d(F):m==null||m(F)},H=F=>{const{onClickConnectStart:G,onClickConnectEnd:O,connectionClickStartHandle:j,connectionMode:q,isValidConnection:$}=b.getState();if(!S||!j&&!o)return;if(!j){G==null||G(F,{nodeId:S,handleId:N,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:S,type:e,handleId:N}});return}const re=yN(F.target),J=r||$||yx,{connection:W,isValid:Z}=IN({nodeId:S,id:N,type:e},q,j.nodeId,j.handleId||null,j.type,J,re);Z&&P(W),O==null||O(F),b.setState({connectionClickStartHandle:null})};return ue.createElement("div",{"data-handleid":N,"data-nodeid":S,"data-handlepos":n,"data-id":`${S}-${N}-${e}`,className:Dt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",E,p,{source:!_,target:_,connectable:i,connectablestart:o,connectableend:l,connecting:I,connectionindicator:i&&(o&&!C||l&&C)}]),onMouseDown:A,onTouchStart:A,onClick:k?H:void 0,ref:w,...y},h)});ON.displayName="Handle";var co=R.memo(ON);const PN=({data:e,isConnectable:n,targetPosition:r=Ae.Top,sourcePosition:i=Ae.Bottom})=>ue.createElement(ue.Fragment,null,ue.createElement(co,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label,ue.createElement(co,{type:"source",position:i,isConnectable:n}));PN.displayName="DefaultNode";var Sv=R.memo(PN);const LN=({data:e,isConnectable:n,sourcePosition:r=Ae.Bottom})=>ue.createElement(ue.Fragment,null,e==null?void 0:e.label,ue.createElement(co,{type:"source",position:r,isConnectable:n}));LN.displayName="InputNode";var qN=R.memo(LN);const $N=({data:e,isConnectable:n,targetPosition:r=Ae.Top})=>ue.createElement(ue.Fragment,null,ue.createElement(co,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label);$N.displayName="OutputNode";var DN=R.memo($N);const Qv=()=>null;Qv.displayName="GroupNode";const hM=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),Xl=e=>e.id;function pM(e,n){return Ct(e.selectedNodes.map(Xl),n.selectedNodes.map(Xl))&&Ct(e.selectedEdges.map(Xl),n.selectedEdges.map(Xl))}const FN=R.memo(({onSelectionChange:e})=>{const n=Tt(),{selectedNodes:r,selectedEdges:i}=Ke(hM,pM);return R.useEffect(()=>{const o={nodes:r,edges:i};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[r,i,e]),null});FN.displayName="SelectionListener";const mM=e=>!!e.onSelectionChange;function gM({onSelectionChange:e}){const n=Ke(mM);return e||n?ue.createElement(FN,{onSelectionChange:e}):null}const vM=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 Yi(e,n){R.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function qe(e,n,r){R.useEffect(()=>{typeof n<"u"&&r({[e]:n})},[n])}const yM=({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:C,connectionMode:I,snapGrid:P,snapToGrid:A,translateExtent:H,connectOnClick:z,defaultEdgeOptions:L,fitView:F,fitViewOptions:G,onNodesDelete:O,onEdgesDelete:j,onNodeDrag:q,onNodeDragStart:$,onNodeDragStop:re,onSelectionDrag:J,onSelectionDragStart:W,onSelectionDragStop:Z,noPanClassName:M,nodeOrigin:Y,rfId:U,autoPanOnConnect:B,autoPanOnNodeDrag:X,onError:ne,connectionRadius:le,isValidConnection:fe,nodeDragThreshold:te})=>{const{setNodes:ce,setEdges:Ce,setDefaultNodesAndEdges:ve,setMinZoom:je,setMaxZoom:ye,setTranslateExtent:ke,setNodeExtent:Ye,reset:we}=Ke(vM,Ct),_e=Tt();return R.useEffect(()=>{const Be=i==null?void 0:i.map(it=>({...it,...L}));return ve(r,Be),()=>{we()}},[]),qe("defaultEdgeOptions",L,_e.setState),qe("connectionMode",I,_e.setState),qe("onConnect",o,_e.setState),qe("onConnectStart",l,_e.setState),qe("onConnectEnd",u,_e.setState),qe("onClickConnectStart",c,_e.setState),qe("onClickConnectEnd",h,_e.setState),qe("nodesDraggable",p,_e.setState),qe("nodesConnectable",d,_e.setState),qe("nodesFocusable",m,_e.setState),qe("edgesFocusable",y,_e.setState),qe("edgesUpdatable",w,_e.setState),qe("elementsSelectable",C,_e.setState),qe("elevateNodesOnSelect",N,_e.setState),qe("snapToGrid",A,_e.setState),qe("snapGrid",P,_e.setState),qe("onNodesChange",k,_e.setState),qe("onEdgesChange",E,_e.setState),qe("connectOnClick",z,_e.setState),qe("fitViewOnInit",F,_e.setState),qe("fitViewOnInitOptions",G,_e.setState),qe("onNodesDelete",O,_e.setState),qe("onEdgesDelete",j,_e.setState),qe("onNodeDrag",q,_e.setState),qe("onNodeDragStart",$,_e.setState),qe("onNodeDragStop",re,_e.setState),qe("onSelectionDrag",J,_e.setState),qe("onSelectionDragStart",W,_e.setState),qe("onSelectionDragStop",Z,_e.setState),qe("noPanClassName",M,_e.setState),qe("nodeOrigin",Y,_e.setState),qe("rfId",U,_e.setState),qe("autoPanOnConnect",B,_e.setState),qe("autoPanOnNodeDrag",X,_e.setState),qe("onError",ne,_e.setState),qe("connectionRadius",le,_e.setState),qe("isValidConnection",fe,_e.setState),qe("nodeDragThreshold",te,_e.setState),Yi(e,ce),Yi(n,Ce),Yi(_,je),Yi(b,ye),Yi(H,ke),Yi(S,Ye),null},wx={display:"none"},wM={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},zN="react-flow__node-desc",BN="react-flow__edge-desc",xM="react-flow__aria-live",_M=e=>e.ariaLiveMessage;function bM({rfId:e}){const n=Ke(_M);return ue.createElement("div",{id:`${xM}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:wM},n)}function SM({rfId:e,disableKeyboardA11y:n}){return ue.createElement(ue.Fragment,null,ue.createElement("div",{id:`${zN}-${e}`,style:wx},"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:`${BN}-${e}`,style:wx},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&ue.createElement(bM,{rfId:e}))}var _a=(e=null,n={actInsideInputWithModifier:!0})=>{const[r,i]=R.useState(!1),o=R.useRef(!1),l=R.useRef(new Set([])),[u,c]=R.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 R.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)&&wv(w))return!1;const _=_x(w.code,c);l.current.add(w[_]),xx(u,l.current,!1)&&(w.preventDefault(),i(!0))},m=w=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&wv(w))return!1;const _=_x(w.code,c);xx(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 xx(e,n,r){return e.filter(i=>r||i.length===n.size).some(i=>i.every(o=>n.has(o)))}function _x(e,n){return n.includes(e)?"code":"key"}function UN(e,n,r,i){var c,h;const o=e.parentNode||e.parentId;if(!o)return r;const l=n.get(o),u=li(l,i);return UN(l,n,{x:(r.x??0)+u.x,y:(r.y??0)+u.y,z:(((c=l[vt])==null?void 0:c.z)??0)>(r.z??0)?((h=l[vt])==null?void 0:h.z)??0:r.z??0},i)}function HN(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}=UN(i,e,{...i.position,z:((l=i[vt])==null?void 0:l.z)??0},n);i.positionAbsolute={x:u,y:c},i[vt].z=h,r!=null&&r[i.id]&&(i[vt].isParent=!0)}})}function qd(e,n,r,i){const o=new Map,l={},u=i?1e3:0;return e.forEach(c=>{var w;const h=(qn(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,vt,{enumerable:!1,value:{handleBounds:y||(w=p==null?void 0:p[vt])==null?void 0:w.handleBounds,z:h}}),o.set(c.id,d)}),HN(o,r,l),o}function WN(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=Mu(N,m),{x:S,y:k,zoom:E}=jN(b,i,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),C=Fr.translate(S,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(si(h,n.duration),C):c.transform(h,C),!0}}return!1}function kM(e,n){return e.forEach(r=>{const i=n.get(r.id);i&&n.set(i.id,{...i,[vt]:i[vt],selected:r.selected})}),new Map(n)}function EM(e,n){return n.map(r=>{const i=e.find(o=>o.id===r.id);return i&&(r.selected=i.selected),r})}function Ql({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:kM(e,o)}),u==null||u(e)),n!=null&&n.length&&(p&&i({edges:EM(n,l)}),c==null||c(n))}const Ki=()=>{},NM={zoomIn:Ki,zoomOut:Ki,zoomTo:Ki,getZoom:()=>1,setViewport:Ki,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ki,fitBounds:Ki,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},CM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),TM=()=>{const e=Tt(),{d3Zoom:n,d3Selection:r}=Ke(CM,Ct);return R.useMemo(()=>r&&n?{zoomIn:o=>n.scaleBy(si(r,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(si(r,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(si(r,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,h]=e.getState().transform,p=Fr.translate(o.x??u,o.y??c).scale(o.zoom??h);n.transform(si(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=>WN(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=Fr.translate(m,y).scale(d);n.transform(si(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}=jN(o,u,c,h,p,(l==null?void 0:l.padding)??.1),w=Fr.translate(d,m).scale(y);n.transform(si(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"),bv(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 bv(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=CN(o,l);return{x:p.x+c,y:p.y+h}},viewportInitialized:!0}:NM,[n,r])};function Ta(){const e=TM(),n=Tt(),r=R.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),i=R.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=R.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(b=>({...b}))},[]),l=R.useCallback(_=>{const{edges:b=[]}=n.getState();return b.find(S=>S.id===_)},[]),u=R.useCallback(_=>{const{getNodes:b,setNodes:S,hasDefaultNodes:k,onNodesChange:E}=n.getState(),C=b(),I=typeof _=="function"?_(C):_;if(k)S(I);else if(E){const P=I.length===0?C.map(A=>({type:"remove",id:A.id})):I.map(A=>({item:A,type:"reset"}));E(P)}},[]),c=R.useCallback(_=>{const{edges:b=[],setEdges:S,hasDefaultEdges:k,onEdgesChange:E}=n.getState(),C=typeof _=="function"?_(b):_;if(k)S(C);else if(E){const I=C.length===0?b.map(P=>({type:"remove",id:P.id})):C.map(P=>({item:P,type:"reset"}));E(I)}},[]),h=R.useCallback(_=>{const b=Array.isArray(_)?_:[_],{getNodes:S,setNodes:k,hasDefaultNodes:E,onNodesChange:C}=n.getState();if(E){const P=[...S(),...b];k(P)}else if(C){const I=b.map(P=>({item:P,type:"add"}));C(I)}},[]),p=R.useCallback(_=>{const b=Array.isArray(_)?_:[_],{edges:S=[],setEdges:k,hasDefaultEdges:E,onEdgesChange:C}=n.getState();if(E)k([...S,...b]);else if(C){const I=b.map(P=>({item:P,type:"add"}));C(I)}},[]),d=R.useCallback(()=>{const{getNodes:_,edges:b=[],transform:S}=n.getState(),[k,E,C]=S;return{nodes:_().map(I=>({...I})),edges:b.map(I=>({...I})),viewport:{x:k,y:E,zoom:C}}},[]),m=R.useCallback(({nodes:_,edges:b})=>{const{nodeInternals:S,getNodes:k,edges:E,hasDefaultNodes:C,hasDefaultEdges:I,onNodesDelete:P,onEdgesDelete:A,onNodesChange:H,onEdgesChange:z}=n.getState(),L=(_||[]).map(q=>q.id),F=(b||[]).map(q=>q.id),G=k().reduce((q,$)=>{const re=$.parentNode||$.parentId,J=!L.includes($.id)&&re&&q.find(Z=>Z.id===re);return(typeof $.deletable=="boolean"?$.deletable:!0)&&(L.includes($.id)||J)&&q.push($),q},[]),O=E.filter(q=>typeof q.deletable=="boolean"?q.deletable:!0),j=O.filter(q=>F.includes(q.id));if(G||j){const q=RN(G,O),$=[...j,...q],re=$.reduce((J,W)=>(J.includes(W.id)||J.push(W.id),J),[]);if((I||C)&&(I&&n.setState({edges:E.filter(J=>!re.includes(J.id))}),C&&(G.forEach(J=>{S.delete(J.id)}),n.setState({nodeInternals:new Map(S)}))),re.length>0&&(A==null||A($),z&&z(re.map(J=>({id:J,type:"remove"})))),G.length>0&&(P==null||P(G),H)){const J=G.map(W=>({id:W.id,type:"remove"}));H(J)}}},[]),y=R.useCallback(_=>{const b=YI(_),S=b?null:n.getState().nodeInternals.get(_.id);return!b&&!S?[null,null,b]:[b?_:fx(S),S,b]},[]),w=R.useCallback((_,b=!0,S)=>{const[k,E,C]=y(_);return k?(S||n.getState().getNodes()).filter(I=>{if(!C&&(I.id===E.id||!I.positionAbsolute))return!1;const P=fx(I),A=yv(P,k);return b&&A>0||A>=k.width*k.height}):[]},[]),N=R.useCallback((_,b,S=!0)=>{const[k]=y(_);if(!k)return!1;const E=yv(k,b);return S&&E>0||E>=k.width*k.height},[]);return R.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 RM={actInsideInputWithModifier:!1};var jM=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const r=Tt(),{deleteElements:i}=Ta(),o=_a(e,RM),l=_a(n);R.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]),R.useEffect(()=>{r.setState({multiSelectionActive:l})},[l])};function AM(e){const n=Tt();R.useEffect(()=>{let r;const i=()=>{var l,u;if(!e.current)return;const o=Hv(e.current);(o.height===0||o.width===0)&&((u=(l=n.getState()).onError)==null||u.call(l,"004",Br.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 Zv={position:"absolute",width:"100%",height:"100%",top:0,left:0},IM=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,Zl=e=>({x:e.x,y:e.y,zoom:e.k}),Xi=(e,n)=>e.target.closest(`.${n}`),bx=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Sx=e=>{const n=e.ctrlKey&&wu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},MM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),OM=({onMove:e,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:i,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:h=oi.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:C})=>{const I=R.useRef(),P=Tt(),A=R.useRef(!1),H=R.useRef(!1),z=R.useRef(null),L=R.useRef({x:0,y:0,zoom:0}),{d3Zoom:F,d3Selection:G,d3ZoomHandler:O,userSelectionActive:j}=Ke(MM,Ct),q=_a(b),$=R.useRef(0),re=R.useRef(!1),J=R.useRef();return AM(z),R.useEffect(()=>{if(z.current){const W=z.current.getBoundingClientRect(),Z=mN().scaleExtent([N,_]).translateExtent(w),M=Ln(z.current).call(Z),Y=Fr.translate(y.x,y.y).scale(uo(y.zoom,N,_)),U=[[0,0],[W.width,W.height]],B=Z.constrain()(Y,U,w);Z.transform(M,B),Z.wheelDelta(Sx),P.setState({d3Zoom:Z,d3Selection:M,d3ZoomHandler:M.on("wheel.zoom"),transform:[B.x,B.y,B.k],domNode:z.current.closest(".react-flow")})}},[]),R.useEffect(()=>{G&&F&&(u&&!q&&!j?G.on("wheel.zoom",W=>{if(Xi(W,E))return!1;W.preventDefault(),W.stopImmediatePropagation();const Z=G.property("__zoom").k||1;if(W.ctrlKey&&l){const fe=Jn(W),te=Sx(W),ce=Z*Math.pow(2,te);F.scaleTo(G,ce,fe,W);return}const M=W.deltaMode===1?20:1;let Y=h===oi.Vertical?0:W.deltaX*M,U=h===oi.Horizontal?0:W.deltaY*M;!wu()&&W.shiftKey&&h!==oi.Vertical&&(Y=W.deltaY*M,U=0),F.translateBy(G,-(Y/Z)*c,-(U/Z)*c,{internal:!0});const B=Zl(G.property("__zoom")),{onViewportChangeStart:X,onViewportChange:ne,onViewportChangeEnd:le}=P.getState();clearTimeout(J.current),re.current||(re.current=!0,n==null||n(W,B),X==null||X(B)),re.current&&(e==null||e(W,B),ne==null||ne(B),J.current=setTimeout(()=>{r==null||r(W,B),le==null||le(B),re.current=!1},150))},{passive:!1}):typeof O<"u"&&G.on("wheel.zoom",function(W,Z){if(!S&&W.type==="wheel"&&!W.ctrlKey||Xi(W,E))return null;W.preventDefault(),O.call(this,W,Z)},{passive:!1}))},[j,u,h,G,F,O,q,l,S,E,n,e,r]),R.useEffect(()=>{F&&F.on("start",W=>{var Y,U;if(!W.sourceEvent||W.sourceEvent.internal)return null;$.current=(Y=W.sourceEvent)==null?void 0:Y.button;const{onViewportChangeStart:Z}=P.getState(),M=Zl(W.transform);A.current=!0,L.current=M,((U=W.sourceEvent)==null?void 0:U.type)==="mousedown"&&P.setState({paneDragging:!0}),Z==null||Z(M),n==null||n(W.sourceEvent,M)})},[F,n]),R.useEffect(()=>{F&&(j&&!A.current?F.on("zoom",null):j||F.on("zoom",W=>{var M;const{onViewportChange:Z}=P.getState();if(P.setState({transform:[W.transform.x,W.transform.y,W.transform.k]}),H.current=!!(i&&bx(m,$.current??0)),(e||Z)&&!((M=W.sourceEvent)!=null&&M.internal)){const Y=Zl(W.transform);Z==null||Z(Y),e==null||e(W.sourceEvent,Y)}}))},[j,F,e,m,i]),R.useEffect(()=>{F&&F.on("end",W=>{if(!W.sourceEvent||W.sourceEvent.internal)return null;const{onViewportChangeEnd:Z}=P.getState();if(A.current=!1,P.setState({paneDragging:!1}),i&&bx(m,$.current??0)&&!H.current&&i(W.sourceEvent),H.current=!1,(r||Z)&&IM(L.current,W.transform)){const M=Zl(W.transform);L.current=M,clearTimeout(I.current),I.current=setTimeout(()=>{Z==null||Z(M),r==null||r(W.sourceEvent,M)},u?150:0)}})},[F,u,m,r,i]),R.useEffect(()=>{F&&F.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"&&(Xi(W,"react-flow__node")||Xi(W,"react-flow__edge")))return!0;if(!m&&!Z&&!u&&!p&&!l||j||!p&&W.type==="dblclick"||Xi(W,E)&&W.type==="wheel"||Xi(W,C)&&(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 Y=Array.isArray(m)&&m.includes(W.button)||!W.button||W.button<=1;return(!W.ctrlKey||W.type==="wheel")&&Y})},[j,F,o,l,u,p,m,d,q]),ue.createElement("div",{className:"react-flow__renderer",ref:z,style:Zv},k)},PM=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function LM(){const{userSelectionActive:e,userSelectionRect:n}=Ke(PM,Ct);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 kx(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 qM(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&&kx(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&&kx(i,u);break}case"remove":return i}return i.push(u),i},r)}function $M(e,n){return qM(e,n)}const bs=(e,n)=>({id:e,type:"select",selected:n});function eo(e,n){return e.reduce((r,i)=>{const o=n.includes(i.id);return!i.selected&&o?(i.selected=!0,r.push(bs(i.id,!0))):i.selected&&!o&&(i.selected=!1,r.push(bs(i.id,!1))),r},[])}const $d=(e,n)=>r=>{r.target===n.current&&(e==null||e(r))},DM=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),VN=R.memo(({isSelecting:e,selectionMode:n=xa.Full,panOnDrag:r,onSelectionStart:i,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:h,onPaneMouseMove:p,onPaneMouseLeave:d,children:m})=>{const y=R.useRef(null),w=Tt(),N=R.useRef(0),_=R.useRef(0),b=R.useRef(),{userSelectionActive:S,elementsSelectable:k,dragging:E}=Ke(DM,Ct),C=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},I=O=>{l==null||l(O),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},P=O=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){O.preventDefault();return}u==null||u(O)},A=c?O=>c(O):void 0,H=O=>{const{resetSelectedElements:j,domNode:q}=w.getState();if(b.current=q==null?void 0:q.getBoundingClientRect(),!k||!e||O.button!==0||O.target!==y.current||!b.current)return;const{x:$,y:re}=ks(O,b.current);j(),w.setState({userSelectionRect:{width:0,height:0,startX:$,startY:re,x:$,y:re}}),i==null||i(O)},z=O=>{const{userSelectionRect:j,nodeInternals:q,edges:$,transform:re,onNodesChange:J,onEdgesChange:W,nodeOrigin:Z,getNodes:M}=w.getState();if(!e||!b.current||!j)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const Y=ks(O,b.current),U=j.startX??0,B=j.startY??0,X={...j,x:Y.x<U?Y.x:U,y:Y.y<B?Y.y:B,width:Math.abs(Y.x-U),height:Math.abs(Y.y-B)},ne=M(),le=TN(q,X,re,n===xa.Partial,!0,Z),fe=RN(le,$).map(ce=>ce.id),te=le.map(ce=>ce.id);if(N.current!==te.length){N.current=te.length;const ce=eo(ne,te);ce.length&&(J==null||J(ce))}if(_.current!==fe.length){_.current=fe.length;const ce=eo($,fe);ce.length&&(W==null||W(ce))}w.setState({userSelectionRect:X})},L=O=>{if(O.button!==0)return;const{userSelectionRect:j}=w.getState();!S&&j&&O.target===y.current&&(I==null||I(O)),w.setState({nodesSelectionActive:N.current>0}),C(),o==null||o(O)},F=O=>{S&&(w.setState({nodesSelectionActive:N.current>0}),o==null||o(O)),C()},G=k&&(e||S);return ue.createElement("div",{className:Dt(["react-flow__pane",{dragging:E,selection:e}]),onClick:G?void 0:$d(I,y),onContextMenu:$d(P,y),onWheel:$d(A,y),onMouseEnter:G?void 0:h,onMouseDown:G?H:void 0,onMouseMove:G?z:p,onMouseUp:G?L:void 0,onMouseLeave:G?F:d,ref:y,style:Zv},m,ue.createElement(LM,null))});VN.displayName="Pane";function GN(e,n){const r=e.parentNode||e.parentId;if(!r)return!1;const i=n.get(r);return i?i.selected?!0:GN(i,n):!1}function Ex(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 FM(e,n,r,i){return Array.from(e.values()).filter(o=>(o.selected||o.id===i)&&(!o.parentNode||o.parentId||!GN(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 zM(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function YN(e,n,r,i,o=[0,0],l){const u=zM(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}=li(m,o).positionAbsolute;c=m&&qn(y)&&qn(w)&&qn(m.width)&&qn(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",Br.error005()),c=u;else if(e.extent&&h&&e.extent!=="parent"){const m=r.get(h),{x:y,y:w}=li(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=li(m,o).positionAbsolute}const d=c&&c!=="parent"?Wv(n,c):n;return{position:{x:d.x-p.x,y:d.y-p.y},positionAbsolute:d}}function Dd({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 Nx=(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,...Hv(h)}})};function ia(e,n,r){return r===void 0?r:i=>{const o=n().nodeInternals.get(e);o&&r(i,{...o})}}function kv({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",Br.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 BM(){const e=Tt();return R.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 Fd(e){return(n,r,i)=>e==null?void 0:e(n,i)}function KN({nodeRef:e,disabled:n=!1,noDragClassName:r,handleSelector:i,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=Tt(),[h,p]=R.useState(!1),d=R.useRef([]),m=R.useRef({x:null,y:null}),y=R.useRef(0),w=R.useRef(null),N=R.useRef({x:0,y:0}),_=R.useRef(null),b=R.useRef(!1),S=R.useRef(!1),k=R.useRef(!1),E=BM();return R.useEffect(()=>{if(e!=null&&e.current){const C=Ln(e.current),I=({x:H,y:z})=>{const{nodeInternals:L,onNodeDrag:F,onSelectionDrag:G,updateNodePositions:O,nodeExtent:j,snapGrid:q,snapToGrid:$,nodeOrigin:re,onError:J}=c.getState();m.current={x:H,y:z};let W=!1,Z={x:0,y:0,x2:0,y2:0};if(d.current.length>1&&j){const Y=Mu(d.current,re);Z=wa(Y)}if(d.current=d.current.map(Y=>{const U={x:H-Y.distance.x,y:z-Y.distance.y};$&&(U.x=q[0]*Math.round(U.x/q[0]),U.y=q[1]*Math.round(U.y/q[1]));const B=[[j[0][0],j[0][1]],[j[1][0],j[1][1]]];d.current.length>1&&j&&!Y.extent&&(B[0][0]=Y.positionAbsolute.x-Z.x+j[0][0],B[1][0]=Y.positionAbsolute.x+(Y.width??0)-Z.x2+j[1][0],B[0][1]=Y.positionAbsolute.y-Z.y+j[0][1],B[1][1]=Y.positionAbsolute.y+(Y.height??0)-Z.y2+j[1][1]);const X=YN(Y,U,L,B,re,J);return W=W||Y.position.x!==X.position.x||Y.position.y!==X.position.y,Y.position=X.position,Y.positionAbsolute=X.positionAbsolute,Y}),!W)return;O(d.current,!0,!0),p(!0);const M=o?F:Fd(G);if(M&&_.current){const[Y,U]=Dd({nodeId:o,dragItems:d.current,nodeInternals:L});M(_.current,Y,U)}},P=()=>{if(!w.current)return;const[H,z]=vN(N.current,w.current);if(H!==0||z!==0){const{transform:L,panBy:F}=c.getState();m.current.x=(m.current.x??0)-H/L[2],m.current.y=(m.current.y??0)-z/L[2],F({x:H,y:z})&&I(m.current)}y.current=requestAnimationFrame(P)},A=H=>{var re;const{nodeInternals:z,multiSelectionActive:L,nodesDraggable:F,unselectNodesAndEdges:G,onNodeDragStart:O,onSelectionDragStart:j}=c.getState();S.current=!0;const q=o?O:Fd(j);(!u||!l)&&!L&&o&&((re=z.get(o))!=null&&re.selected||G()),o&&l&&u&&kv({id:o,store:c,nodeRef:e});const $=E(H);if(m.current=$,d.current=FM(z,F,$,o),q&&d.current){const[J,W]=Dd({nodeId:o,dragItems:d.current,nodeInternals:z});q(H.sourceEvent,J,W)}};if(n)C.on(".drag",null);else{const H=QA().on("start",z=>{const{domNode:L,nodeDragThreshold:F}=c.getState();F===0&&A(z),k.current=!1;const G=E(z);m.current=G,w.current=(L==null?void 0:L.getBoundingClientRect())||null,N.current=ks(z.sourceEvent,w.current)}).on("drag",z=>{var O,j;const L=E(z),{autoPanOnNodeDrag:F,nodeDragThreshold:G}=c.getState();if(z.sourceEvent.type==="touchmove"&&z.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!b.current&&S.current&&F&&(b.current=!0,P()),!S.current){const q=L.xSnapped-(((O=m==null?void 0:m.current)==null?void 0:O.x)??0),$=L.ySnapped-(((j=m==null?void 0:m.current)==null?void 0:j.y)??0);Math.sqrt(q*q+$*$)>G&&A(z)}(m.current.x!==L.xSnapped||m.current.y!==L.ySnapped)&&d.current&&S.current&&(_.current=z.sourceEvent,N.current=ks(z.sourceEvent,w.current),I(L))}}).on("end",z=>{if(!(!S.current||k.current)&&(p(!1),b.current=!1,S.current=!1,cancelAnimationFrame(y.current),d.current)){const{updateNodePositions:L,nodeInternals:F,onNodeDragStop:G,onSelectionDragStop:O}=c.getState(),j=o?G:Fd(O);if(L(d.current,!1,!1),j){const[q,$]=Dd({nodeId:o,dragItems:d.current,nodeInternals:F});j(z.sourceEvent,q,$)}}}).filter(z=>{const L=z.target;return!z.button&&(!r||!Ex(L,`.${r}`,e))&&(!i||Ex(L,i,e))});return C.call(H),()=>{C.on(".drag",null)}}}},[e,n,r,i,l,c,o,u,E]),h}function XN(){const e=Tt();return R.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:C,position:I}=YN(k,E,i,o,void 0,p);k.position=I,k.positionAbsolute=C}return k});l(S,!0,!1)},[])}const io={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var oa=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:C,isFocusable:I,selectNodesOnDrag:P,sourcePosition:A,targetPosition:H,hidden:z,resizeObserver:L,dragHandle:F,zIndex:G,isParent:O,noDragClassName:j,noPanClassName:q,initialized:$,disableKeyboardA11y:re,ariaLabel:J,rfId:W,hasHandleBounds:Z})=>{const M=Tt(),Y=R.useRef(null),U=R.useRef(null),B=R.useRef(A),X=R.useRef(H),ne=R.useRef(i),le=E||k||d||m||y||w,fe=XN(),te=ia(r,M.getState,m),ce=ia(r,M.getState,y),Ce=ia(r,M.getState,w),ve=ia(r,M.getState,N),je=ia(r,M.getState,_),ye=we=>{const{nodeDragThreshold:_e}=M.getState();if(E&&(!P||!k||_e>0)&&kv({id:r,store:M,nodeRef:Y}),d){const Be=M.getState().nodeInternals.get(r);Be&&d(we,{...Be})}},ke=we=>{if(!wv(we)&&!re)if(_N.includes(we.key)&&E){const _e=we.key==="Escape";kv({id:r,store:M,unselect:_e,nodeRef:Y})}else k&&p&&Object.prototype.hasOwnProperty.call(io,we.key)&&(M.setState({ariaLiveMessage:`Moved selected node ${we.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),fe({x:io[we.key].x,y:io[we.key].y,isShiftPressed:we.shiftKey}))};R.useEffect(()=>()=>{U.current&&(L==null||L.unobserve(U.current),U.current=null)},[]),R.useEffect(()=>{if(Y.current&&!z){const we=Y.current;(!$||!Z||U.current!==we)&&(U.current&&(L==null||L.unobserve(U.current)),L==null||L.observe(we),U.current=we)}},[z,$,Z]),R.useEffect(()=>{const we=ne.current!==i,_e=B.current!==A,Be=X.current!==H;Y.current&&(we||_e||Be)&&(we&&(ne.current=i),_e&&(B.current=A),Be&&(X.current=H),M.getState().updateNodeDimensions([{id:r,nodeElement:Y.current,forceUpdate:!0}]))},[r,i,A,H]);const Ye=KN({nodeRef:Y,disabled:z||!k,noDragClassName:j,handleSelector:F,nodeId:r,isSelectable:E,selectNodesOnDrag:P});return z?null:ue.createElement("div",{className:Dt(["react-flow__node",`react-flow__node-${i}`,{[q]:k},S,{selected:p,selectable:E,parent:O,dragging:Ye}]),ref:Y,style:{zIndex:G,transform:`translate(${c}px,${h}px)`,pointerEvents:le?"all":"none",visibility:$?"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?ke:void 0,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-describedby":re?void 0:`${zN}-${W}`,"aria-label":J},ue.createElement(tM,{value:r},ue.createElement(e,{id:r,data:o,type:i,xPos:l,yPos:u,selected:p,isConnectable:C,sourcePosition:A,targetPosition:H,dragging:Ye,dragHandle:F,zIndex:G})))};return n.displayName="NodeWrapper",R.memo(n)};const UM=e=>{const n=e.getNodes().filter(r=>r.selected);return{...Mu(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function HM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:r}){const i=Tt(),{width:o,height:l,x:u,y:c,transformString:h,userSelectionActive:p}=Ke(UM,Ct),d=XN(),m=R.useRef(null);if(R.useEffect(()=>{var N;r||(N=m.current)==null||N.focus({preventScroll:!0})},[r]),KN({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(io,N.key)&&d({x:io[N.key].x,y:io[N.key].y,isShiftPressed:N.shiftKey})};return ue.createElement("div",{className:Dt(["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 WM=R.memo(HM);const VM=e=>e.nodesSelectionActive,QN=({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:C,zoomOnPinch:I,panOnScroll:P,panOnScrollSpeed:A,panOnScrollMode:H,zoomOnDoubleClick:z,panOnDrag:L,defaultViewport:F,translateExtent:G,minZoom:O,maxZoom:j,preventScrolling:q,onSelectionContextMenu:$,noWheelClassName:re,noPanClassName:J,disableKeyboardA11y:W})=>{const Z=Ke(VM),M=_a(m),Y=_a(S),U=Y||L,B=Y||P,X=M||y&&U!==!0;return jM({deleteKeyCode:c,multiSelectionKeyCode:b}),ue.createElement(OM,{onMove:h,onMoveStart:p,onMoveEnd:d,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:B,panOnScrollSpeed:A,panOnScrollMode:H,zoomOnDoubleClick:z,panOnDrag:!M&&U,defaultViewport:F,translateExtent:G,minZoom:O,maxZoom:j,zoomActivationKeyCode:k,preventScrolling:q,noWheelClassName:re,noPanClassName:J},ue.createElement(VN,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:U,isSelecting:!!X,selectionMode:w},e,Z&&ue.createElement(WM,{onSelectionContextMenu:$,noPanClassName:J,disableKeyboardA11y:W})))};QN.displayName="FlowRenderer";var GM=R.memo(QN);function YM(e){return Ke(R.useCallback(r=>e?TN(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function KM(e){const n={input:oa(e.input||qN),default:oa(e.default||Sv),output:oa(e.output||DN),group:oa(e.group||Qv)},r={},i=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=oa(e[l]||Sv),o),r);return{...n,...i}}const XM=({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]},QM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),ZN=e=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:i,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Ke(QM,Ct),c=YM(e.onlyRenderVisibleElements),h=R.useRef(),p=R.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 R.useEffect(()=>()=>{var d;(d=h==null?void 0:h.current)==null||d.disconnect()},[]),ue.createElement("div",{className:"react-flow__nodes",style:Zv},c.map(d=>{var I,P,A;let m=d.type||"default";e.nodeTypes[m]||(u==null||u("003",Br.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?Wv(d.positionAbsolute,e.nodeExtent):d.positionAbsolute,k=(S==null?void 0:S.x)??0,E=(S==null?void 0:S.y)??0,C=XM({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:C.x,yPosOrigin:C.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[vt])==null?void 0:I.z)??0,isParent:!!((P=d[vt])!=null&&P.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!d.width&&!!d.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:d.ariaLabel,hasHandleBounds:!!((A=d[vt])!=null&&A.handleBounds)})}))};ZN.displayName="NodeRenderer";var ZM=R.memo(ZN);const JM=(e,n,r)=>r===Ae.Left?e-n:r===Ae.Right?e+n:e,eO=(e,n,r)=>r===Ae.Top?e-n:r===Ae.Bottom?e+n:e,Cx="react-flow__edgeupdater",Tx=({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:Dt([Cx,`${Cx}-${c}`]),cx:JM(n,i,e),cy:eO(r,i,e),r:i,stroke:"transparent",fill:"transparent"}),tO=()=>!0;var Qi=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:C,targetX:I,targetY:P,sourcePosition:A,targetPosition:H,elementsSelectable:z,hidden:L,sourceHandleId:F,targetHandleId:G,onContextMenu:O,onMouseEnter:j,onMouseMove:q,onMouseLeave:$,reconnectRadius:re,onReconnect:J,onReconnectStart:W,onReconnectEnd:Z,markerEnd:M,markerStart:Y,rfId:U,ariaLabel:B,isFocusable:X,isReconnectable:ne,pathOptions:le,interactionWidth:fe,disableKeyboardA11y:te})=>{const ce=R.useRef(null),[Ce,ve]=R.useState(!1),[je,ye]=R.useState(!1),ke=Tt(),Ye=R.useMemo(()=>`url('#${_v(Y,U)}')`,[Y,U]),we=R.useMemo(()=>`url('#${_v(M,U)}')`,[M,U]);if(L)return null;const _e=et=>{var Pt;const{edges:St,addSelectedEdges:pt,unselectNodesAndEdges:wt,multiSelectionActive:hn}=ke.getState(),Yt=St.find(Sn=>Sn.id===r);Yt&&(z&&(ke.setState({nodesSelectionActive:!1}),Yt.selected&&hn?(wt({nodes:[],edges:[Yt]}),(Pt=ce.current)==null||Pt.blur()):pt([r])),u&&u(et,Yt))},Be=sa(r,ke.getState,c),it=sa(r,ke.getState,O),yt=sa(r,ke.getState,j),Ze=sa(r,ke.getState,q),De=sa(r,ke.getState,$),Je=(et,St)=>{if(et.button!==0)return;const{edges:pt,isValidConnection:wt}=ke.getState(),hn=St?k:S,Yt=(St?G:F)||null,Pt=St?"target":"source",Sn=wt||tO,gr=St,kn=pt.find(pn=>pn.id===r);ye(!0),W==null||W(et,kn,Pt);const zt=pn=>{ye(!1),Z==null||Z(pn,kn,Pt)};MN({event:et,handleId:Yt,nodeId:hn,onConnect:pn=>J==null?void 0:J(kn,pn),isTarget:gr,getState:ke.getState,setState:ke.setState,isValidConnection:Sn,edgeUpdaterType:Pt,onReconnectEnd:zt})},Xe=et=>Je(et,!0),Mt=et=>Je(et,!1),ut=()=>ve(!0),Qe=()=>ve(!1),Ot=!z&&!u,Ft=et=>{var St;if(!te&&_N.includes(et.key)&&z){const{unselectNodesAndEdges:pt,addSelectedEdges:wt,edges:hn}=ke.getState();et.key==="Escape"?((St=ce.current)==null||St.blur(),pt({edges:[hn.find(Pt=>Pt.id===r)]})):wt([r])}};return ue.createElement("g",{className:Dt(["react-flow__edge",`react-flow__edge-${o}`,i,{selected:h,animated:p,inactive:Ot,updating:Ce}]),onClick:_e,onDoubleClick:Be,onContextMenu:it,onMouseEnter:yt,onMouseMove:Ze,onMouseLeave:De,onKeyDown:X?Ft:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":B===null?void 0:B||`Edge from ${S} to ${k}`,"aria-describedby":X?`${BN}-${U}`: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:C,targetX:I,targetY:P,sourcePosition:A,targetPosition:H,sourceHandleId:F,targetHandleId:G,markerStart:Ye,markerEnd:we,pathOptions:le,interactionWidth:fe}),ne&&ue.createElement(ue.Fragment,null,(ne==="source"||ne===!0)&&ue.createElement(Tx,{position:A,centerX:E,centerY:C,radius:re,onMouseDown:Xe,onMouseEnter:ut,onMouseOut:Qe,type:"source"}),(ne==="target"||ne===!0)&&ue.createElement(Tx,{position:H,centerX:I,centerY:P,radius:re,onMouseDown:Mt,onMouseEnter:ut,onMouseOut:Qe,type:"target"})))};return n.displayName="EdgeWrapper",R.memo(n)};function nO(e){const n={default:Qi(e.default||_u),straight:Qi(e.bezier||Yv),step:Qi(e.step||Gv),smoothstep:Qi(e.step||Iu),simplebezier:Qi(e.simplebezier||Vv)},r={},i=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Qi(e[l]||_u),o),r);return{...n,...i}}function Rx(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 jx(e,n){return e?e.length===1||!n?e[0]:n&&e.find(r=>r.id===n)||null:null}const rO=(e,n,r,i,o,l)=>{const u=Rx(r,e,n),c=Rx(l,i,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function sO({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=wa({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 Ax(e){var i,o,l,u,c;const n=((i=e==null?void 0:e[vt])==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 iO=[{level:0,isMaxLevel:!0,edges:[]}];function oO(e,n,r=!1){let i=-1;const o=e.reduce((u,c)=>{var d,m;const h=qn(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[vt])==null?void 0:d.z)||0,((m=y==null?void 0:y[vt])==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?iO:l}function aO(e,n,r){const i=Ke(R.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)&&sO({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 oO(i,n,r)}const lO=({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"}),uO=({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"}),Ix={[xu.Arrow]:lO,[xu.ArrowClosed]:uO};function cO(e){const n=Tt();return R.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(Ix,e)?Ix[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Br.error009(e)),null)},[e])}const dO=({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=cO(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},fO=({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=_v(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))},JN=({defaultColor:e,rfId:n})=>{const r=Ke(R.useCallback(fO({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(dO,{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})))};JN.displayName="MarkerDefinitions";var hO=R.memo(JN);const pO=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}),eC=({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:C,width:I,height:P,connectionMode:A,nodeInternals:H,onError:z}=Ke(pO,Ct),L=aO(n,H,r);return I?ue.createElement(ue.Fragment,null,L.map(({level:F,edges:G,isMaxLevel:O})=>ue.createElement("svg",{key:F,style:{zIndex:F},width:I,height:P,className:"react-flow__edges react-flow__container"},O&&ue.createElement(hO,{defaultColor:e,rfId:i}),ue.createElement("g",null,G.map(j=>{const[q,$,re]=Ax(H.get(j.source)),[J,W,Z]=Ax(H.get(j.target));if(!re||!Z)return null;let M=j.type||"default";o[M]||(z==null||z("011",Br.error011(M)),M="default");const Y=o[M]||o.default,U=A===ci.Strict?W.target:(W.target??[]).concat(W.source??[]),B=jx($.source,j.sourceHandle),X=jx(U,j.targetHandle),ne=(B==null?void 0:B.position)||Ae.Bottom,le=(X==null?void 0:X.position)||Ae.Top,fe=!!(j.focusable||k&&typeof j.focusable>"u"),te=j.reconnectable||j.updatable,ce=typeof y<"u"&&(te||E&&typeof te>"u");if(!B||!X)return z==null||z("008",Br.error008(B,j)),null;const{sourceX:Ce,sourceY:ve,targetX:je,targetY:ye}=rO(q,B,ne,J,X,le);return ue.createElement(Y,{key:j.id,id:j.id,className:Dt([j.className,l]),type:M,data:j.data,selected:!!j.selected,animated:!!j.animated,hidden:!!j.hidden,label:j.label,labelStyle:j.labelStyle,labelShowBg:j.labelShowBg,labelBgStyle:j.labelBgStyle,labelBgPadding:j.labelBgPadding,labelBgBorderRadius:j.labelBgBorderRadius,style:j.style,source:j.source,target:j.target,sourceHandleId:j.sourceHandle,targetHandleId:j.targetHandle,markerEnd:j.markerEnd,markerStart:j.markerStart,sourceX:Ce,sourceY:ve,targetX:je,targetY:ye,sourcePosition:ne,targetPosition:le,elementsSelectable:C,onContextMenu:u,onMouseEnter:c,onMouseMove:h,onMouseLeave:p,onClick:d,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:w,onReconnectEnd:N,reconnectRadius:_,rfId:i,ariaLabel:j.ariaLabel,isFocusable:fe,isReconnectable:ce,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth,disableKeyboardA11y:S})})))),b):null};eC.displayName="EdgeRenderer";var mO=R.memo(eC);const gO=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function vO({children:e}){const n=Ke(gO);return ue.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function yO(e){const n=Ta(),r=R.useRef(!1);R.useEffect(()=>{!r.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),r.current=!0)},[e,n.viewportInitialized])}const wO={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},tC=({nodeId:e,handleType:n,style:r,type:i=Ss.Bezier,CustomComponent:o,connectionStatus:l})=>{var P,A,H;const{fromNode:u,handleId:c,toX:h,toY:p,connectionMode:d}=Ke(R.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]),Ct),m=(P=u==null?void 0:u[vt])==null?void 0:P.handleBounds;let y=m==null?void 0:m[n];if(d===ci.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=(((H=u.positionAbsolute)==null?void 0:H.y)??0)+_,k=w==null?void 0:w.position,E=k?wO[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 C="";const I={sourceX:b,sourceY:S,sourcePosition:k,targetX:h,targetY:p,targetPosition:E};return i===Ss.Bezier?[C]=NN(I):i===Ss.Step?[C]=xv({...I,borderRadius:0}):i===Ss.SmoothStep?[C]=xv(I):i===Ss.SimpleBezier?[C]=EN(I):C=`M${b},${S} ${h},${p}`,ue.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:r})};tC.displayName="ConnectionLine";const xO=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function _O({containerStyle:e,style:n,type:r,component:i}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:h,connectionStatus:p}=Ke(xO,Ct);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:Dt(["react-flow__connection",p])},ue.createElement(tC,{nodeId:o,handleType:l,style:n,type:r,CustomComponent:i,connectionStatus:p})))}function Mx(e,n){return R.useRef(null),Tt(),R.useMemo(()=>n(e),[e])}const nC=({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:C,selectionKeyCode:I,selectionOnDrag:P,selectionMode:A,multiSelectionKeyCode:H,panActivationKeyCode:z,zoomActivationKeyCode:L,deleteKeyCode:F,onlyRenderVisibleElements:G,elementsSelectable:O,selectNodesOnDrag:j,defaultViewport:q,translateExtent:$,minZoom:re,maxZoom:J,preventScrolling:W,defaultMarkerColor:Z,zoomOnScroll:M,zoomOnPinch:Y,panOnScroll:U,panOnScrollSpeed:B,panOnScrollMode:X,zoomOnDoubleClick:ne,panOnDrag:le,onPaneClick:fe,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Ce,onPaneScroll:ve,onPaneContextMenu:je,onEdgeContextMenu:ye,onEdgeMouseEnter:ke,onEdgeMouseMove:Ye,onEdgeMouseLeave:we,onReconnect:_e,onReconnectStart:Be,onReconnectEnd:it,reconnectRadius:yt,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Je,elevateEdgesOnSelect:Xe,disableKeyboardA11y:Mt,nodeOrigin:ut,nodeExtent:Qe,rfId:Ot})=>{const Ft=Mx(e,KM),et=Mx(n,nO);return yO(l),ue.createElement(GM,{onPaneClick:fe,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:Ce,onPaneContextMenu:je,onPaneScroll:ve,deleteKeyCode:F,selectionKeyCode:I,selectionOnDrag:P,selectionMode:A,onSelectionStart:_,onSelectionEnd:b,multiSelectionKeyCode:H,panActivationKeyCode:z,zoomActivationKeyCode:L,elementsSelectable:O,onMove:r,onMoveStart:i,onMoveEnd:o,zoomOnScroll:M,zoomOnPinch:Y,zoomOnDoubleClick:ne,panOnScroll:U,panOnScrollSpeed:B,panOnScrollMode:X,panOnDrag:le,defaultViewport:q,translateExtent:$,minZoom:re,maxZoom:J,onSelectionContextMenu:N,preventScrolling:W,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Je,disableKeyboardA11y:Mt},ue.createElement(vO,null,ue.createElement(mO,{edgeTypes:et,onEdgeClick:c,onEdgeDoubleClick:p,onlyRenderVisibleElements:G,onEdgeContextMenu:ye,onEdgeMouseEnter:ke,onEdgeMouseMove:Ye,onEdgeMouseLeave:we,onReconnect:_e,onReconnectStart:Be,onReconnectEnd:it,reconnectRadius:yt,defaultMarkerColor:Z,noPanClassName:Je,elevateEdgesOnSelect:!!Xe,disableKeyboardA11y:Mt,rfId:Ot},ue.createElement(_O,{style:k,type:S,component:E,containerStyle:C})),ue.createElement("div",{className:"react-flow__edgelabel-renderer"}),ue.createElement(ZM,{nodeTypes:Ft,onNodeClick:u,onNodeDoubleClick:h,onNodeMouseEnter:d,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:w,selectNodesOnDrag:j,onlyRenderVisibleElements:G,noPanClassName:Je,noDragClassName:Ze,disableKeyboardA11y:Mt,nodeOrigin:ut,nodeExtent:Qe,rfId:Ot})))};nC.displayName="GraphView";var bO=R.memo(nC);const Ev=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],xs={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:Ev,nodeExtent:Ev,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ci.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:KI,isValidConnection:void 0},SO=()=>uj((e,n)=>({...xs,setNodes:r=>{const{nodeInternals:i,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:qd(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?qd(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,[vt]:{...S[vt],handleBounds:void 0}});else if(S){const k=Hv(b.nodeElement);!!(k.width&&k.height&&(S.width!==k.width||S.height!==k.height||b.forceUpdate))&&(o.set(S.id,{...S,[vt]:{...S[vt],handleBounds:{source:Nx(".source",b.nodeElement,y,p),target:Nx(".target",b.nodeElement,y,p)}},...k}),_.push({id:S.id,type:"dimensions",dimensions:k}))}return _},[]);HN(o,p);const N=u||l&&!u&&WN(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=$M(r,c()),d=qd(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=>bs(h,!0)):(u=eo(l(),r),c=eo(o,[])),Ql({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=>bs(h,!0)):(u=eo(o,r),c=eo(l(),[])),Ql({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,bs(d.id,!1))),p=c.map(d=>bs(d.id,!1));Ql({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=>bs(c.id,!1)),u=r.filter(c=>c.selected).map(c=>bs(c.id,!1));Ql({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:r=>{const{nodeInternals:i}=n();i.forEach(o=>{o.positionAbsolute=Wv(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=Fr.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:xs.connectionNodeId,connectionHandleId:xs.connectionHandleId,connectionHandleType:xs.connectionHandleType,connectionStatus:xs.connectionStatus,connectionStartHandle:xs.connectionStartHandle,connectionEndHandle:xs.connectionEndHandle}),reset:()=>e({...xs})}),Object.is),Jv=({children:e})=>{const n=R.useRef(null);return n.current||(n.current=SO()),ue.createElement(BI,{value:n.current},e)};Jv.displayName="ReactFlowProvider";const rC=({children:e})=>R.useContext(Au)?ue.createElement(ue.Fragment,null,e):ue.createElement(Jv,null,e);rC.displayName="ReactFlowWrapper";const kO={input:qN,default:Sv,output:DN,group:Qv},EO={default:_u,straight:Yv,step:Gv,smoothstep:Iu,simplebezier:Vv},NO=[0,0],CO=[15,15],TO={x:0,y:0,zoom:1},RO={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},sC=R.forwardRef(({nodes:e,edges:n,defaultNodes:r,defaultEdges:i,className:o,nodeTypes:l=kO,edgeTypes:u=EO,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:C,onNodeContextMenu:I,onNodeDoubleClick:P,onNodeDragStart:A,onNodeDrag:H,onNodeDragStop:z,onNodesDelete:L,onEdgesDelete:F,onSelectionChange:G,onSelectionDragStart:O,onSelectionDrag:j,onSelectionDragStop:q,onSelectionContextMenu:$,onSelectionStart:re,onSelectionEnd:J,connectionMode:W=ci.Strict,connectionLineType:Z=Ss.Bezier,connectionLineStyle:M,connectionLineComponent:Y,connectionLineContainerStyle:U,deleteKeyCode:B="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:ne=!1,selectionMode:le=xa.Full,panActivationKeyCode:fe="Space",multiSelectionKeyCode:te=wu()?"Meta":"Control",zoomActivationKeyCode:ce=wu()?"Meta":"Control",snapToGrid:Ce=!1,snapGrid:ve=CO,onlyRenderVisibleElements:je=!1,selectNodesOnDrag:ye=!0,nodesDraggable:ke,nodesConnectable:Ye,nodesFocusable:we,nodeOrigin:_e=NO,edgesFocusable:Be,edgesUpdatable:it,elementsSelectable:yt,defaultViewport:Ze=TO,minZoom:De=.5,maxZoom:Je=2,translateExtent:Xe=Ev,preventScrolling:Mt=!0,nodeExtent:ut,defaultMarkerColor:Qe="#b1b1b7",zoomOnScroll:Ot=!0,zoomOnPinch:Ft=!0,panOnScroll:et=!1,panOnScrollSpeed:St=.5,panOnScrollMode:pt=oi.Free,zoomOnDoubleClick:wt=!0,panOnDrag:hn=!0,onPaneClick:Yt,onPaneMouseEnter:Pt,onPaneMouseMove:Sn,onPaneMouseLeave:gr,onPaneScroll:kn,onPaneContextMenu:zt,children:Fn,onEdgeContextMenu:pn,onEdgeDoubleClick:vr,onEdgeMouseEnter:Wr,onEdgeMouseMove:gi,onEdgeMouseLeave:Vr,onEdgeUpdate:ct,onEdgeUpdateStart:vi,onEdgeUpdateEnd:mn,onReconnect:Cs,onReconnectStart:yr,onReconnectEnd:zn,reconnectRadius:En=10,edgeUpdaterRadius:Gr=10,onNodesChange:Yr,onEdgesChange:Kr,noDragClassName:yi="nodrag",noWheelClassName:ir="nowheel",noPanClassName:Ts="nopan",fitView:Nn=!1,fitViewOptions:wr,connectOnClick:Rs=!0,attributionPosition:js,proOptions:Rt,defaultEdgeOptions:xr,elevateNodesOnSelect:_r=!0,elevateEdgesOnSelect:Kt=!1,disableKeyboardA11y:Xr=!1,autoPanOnConnect:wi=!0,autoPanOnNodeDrag:nt=!0,connectionRadius:br=20,isValidConnection:Qr,onError:As,style:Zr,id:Jr,nodeDragThreshold:Is,...or},kt)=>{const Ms=Jr||"1";return ue.createElement("div",{...or,style:{...Zr,...RO},ref:kt,className:Dt(["react-flow",o]),"data-testid":"rf__wrapper",id:Jr},ue.createElement(rC,null,ue.createElement(bO,{onInit:p,onMove:d,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:h,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:P,nodeTypes:l,edgeTypes:u,connectionLineType:Z,connectionLineStyle:M,connectionLineComponent:Y,connectionLineContainerStyle:U,selectionKeyCode:X,selectionOnDrag:ne,selectionMode:le,deleteKeyCode:B,multiSelectionKeyCode:te,panActivationKeyCode:fe,zoomActivationKeyCode:ce,onlyRenderVisibleElements:je,selectNodesOnDrag:ye,defaultViewport:Ze,translateExtent:Xe,minZoom:De,maxZoom:Je,preventScrolling:Mt,zoomOnScroll:Ot,zoomOnPinch:Ft,zoomOnDoubleClick:wt,panOnScroll:et,panOnScrollSpeed:St,panOnScrollMode:pt,panOnDrag:hn,onPaneClick:Yt,onPaneMouseEnter:Pt,onPaneMouseMove:Sn,onPaneMouseLeave:gr,onPaneScroll:kn,onPaneContextMenu:zt,onSelectionContextMenu:$,onSelectionStart:re,onSelectionEnd:J,onEdgeContextMenu:pn,onEdgeDoubleClick:vr,onEdgeMouseEnter:Wr,onEdgeMouseMove:gi,onEdgeMouseLeave:Vr,onReconnect:Cs??ct,onReconnectStart:yr??vi,onReconnectEnd:zn??mn,reconnectRadius:En??Gr,defaultMarkerColor:Qe,noDragClassName:yi,noWheelClassName:ir,noPanClassName:Ts,elevateEdgesOnSelect:Kt,rfId:Ms,disableKeyboardA11y:Xr,nodeOrigin:_e,nodeExtent:ut}),ue.createElement(yM,{nodes:e,edges:n,defaultNodes:r,defaultEdges:i,onConnect:w,onConnectStart:N,onConnectEnd:_,onClickConnectStart:b,onClickConnectEnd:S,nodesDraggable:ke,nodesConnectable:Ye,nodesFocusable:we,edgesFocusable:Be,edgesUpdatable:it,elementsSelectable:yt,elevateNodesOnSelect:_r,minZoom:De,maxZoom:Je,nodeExtent:ut,onNodesChange:Yr,onEdgesChange:Kr,snapToGrid:Ce,snapGrid:ve,connectionMode:W,translateExtent:Xe,connectOnClick:Rs,defaultEdgeOptions:xr,fitView:Nn,fitViewOptions:wr,onNodesDelete:L,onEdgesDelete:F,onNodeDragStart:A,onNodeDrag:H,onNodeDragStop:z,onSelectionDrag:j,onSelectionDragStart:O,onSelectionDragStop:q,noPanClassName:Ts,nodeOrigin:_e,rfId:Ms,autoPanOnConnect:wi,autoPanOnNodeDrag:nt,onError:As,connectionRadius:br,isValidConnection:Qr,nodeDragThreshold:Is}),ue.createElement(gM,{onSelectionChange:G}),Fn,ue.createElement(HI,{proOptions:Rt,position:js}),ue.createElement(SM,{rfId:Ms,disableKeyboardA11y:Xr})))});sC.displayName="ReactFlow";const jO=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function iC(){return Ke(jO,Ct)}const oC=({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:Dt(["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})};oC.displayName="MiniMapNode";var AO=R.memo(oC);const IO=e=>e.nodeOrigin,MO=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),zd=e=>e instanceof Function?e:()=>e;function OO({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:o=2,nodeComponent:l=AO,onClick:u}){const c=Ke(MO,Ct),h=Ke(IO),p=zd(n),d=zd(e),m=zd(r),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ue.createElement(ue.Fragment,null,c.map(w=>{const{x:N,y:_}=li(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 PO=R.memo(OO);const LO=200,qO=150,$O=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?GI(Mu(n,e.nodeOrigin),r):r,rfId:e.rfId}},DO="react-flow__minimap-desc";function aC({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 C=Tt(),I=R.useRef(null),{boundingRect:P,viewBB:A,rfId:H}=Ke($O,Ct),z=(e==null?void 0:e.width)??LO,L=(e==null?void 0:e.height)??qO,F=P.width/z,G=P.height/L,O=Math.max(F,G),j=O*z,q=O*L,$=E*O,re=P.x-(j-P.width)/2-$,J=P.y-(q-P.height)/2-$,W=j+$*2,Z=q+$*2,M=`${DO}-${H}`,Y=R.useRef(0);Y.current=O,R.useEffect(()=>{if(I.current){const X=Ln(I.current),ne=te=>{const{transform:ce,d3Selection:Ce,d3Zoom:ve}=C.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)},le=te=>{const{transform:ce,d3Selection:Ce,d3Zoom:ve,translateExtent:je,width:ye,height:ke}=C.getState();if(te.sourceEvent.type!=="mousemove"||!Ce||!ve)return;const Ye=Y.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,ke]],Be=Fr.translate(we.x,we.y).scale(ce[2]),it=ve.constrain()(Be,_e,je);ve.transform(Ce,it)},fe=mN().on("zoom",N?le:null).on("zoom.wheel",_?ne:null);return X.call(fe),()=>{X.on("zoom",null)}}},[N,_,S,k]);const U=y?X=>{const ne=Jn(X);y(X,{x:ne[0],y:ne[1]})}:void 0,B=w?(X,ne)=>{const le=C.getState().nodeInternals.get(ne);w(X,le)}:void 0;return ue.createElement(Uv,{position:m,style:e,className:Dt(["react-flow__minimap",n]),"data-testid":"rf__minimap"},ue.createElement("svg",{width:z,height:L,viewBox:`${re} ${J} ${W} ${Z}`,role:"img","aria-labelledby":M,ref:I,onClick:U},b&&ue.createElement("title",{id:M},b),ue.createElement(PO,{onClick:B,nodeColor:i,nodeStrokeColor:r,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),ue.createElement("path",{className:"react-flow__minimap-mask",d:`M${re-$},${J-$}h${W+$*2}v${Z+$*2}h${-W-$*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"})))}aC.displayName="MiniMap";var FO=R.memo(aC);function zO(){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 BO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ue.createElement("path",{d:"M0 0h32v4.2H0z"}))}function UO(){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 HO(){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 WO(){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 to=({children:e,className:n,...r})=>ue.createElement("button",{type:"button",className:Dt(["react-flow__controls-button",n]),...r},e);to.displayName="ControlButton";const VO=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),lC=({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=Tt(),[w,N]=R.useState(!1),{isInteractive:_,minZoomReached:b,maxZoomReached:S}=Ke(VO,Ct),{zoomIn:k,zoomOut:E,fitView:C}=Ta();if(R.useEffect(()=>{N(!0)},[]),!w)return null;const I=()=>{k(),l==null||l()},P=()=>{E(),u==null||u()},A=()=>{C(o),c==null||c()},H=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),h==null||h(!_)};return ue.createElement(Uv,{className:Dt(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},n&&ue.createElement(ue.Fragment,null,ue.createElement(to,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ue.createElement(zO,null)),ue.createElement(to,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ue.createElement(BO,null))),r&&ue.createElement(to,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},ue.createElement(UO,null)),i&&ue.createElement(to,{className:"react-flow__controls-interactive",onClick:H,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ue.createElement(WO,null):ue.createElement(HO,null)),d)};lC.displayName="Controls";var GO=R.memo(lC),tr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(tr||(tr={}));function YO({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 KO({color:e,radius:n}){return ue.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const XO={[tr.Dots]:"#91919a",[tr.Lines]:"#eee",[tr.Cross]:"#e2e2e2"},QO={[tr.Dots]:1,[tr.Lines]:1,[tr.Cross]:6},ZO=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function uC({id:e,variant:n=tr.Dots,gap:r=20,size:i,lineWidth:o=1,offset:l=2,color:u,style:c,className:h}){const p=R.useRef(null),{transform:d,patternId:m}=Ke(ZO,Ct),y=u||XO[n],w=i||QO[n],N=n===tr.Dots,_=n===tr.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,C=N?[k/l,k/l]:[E[0]/l,E[1]/l];return ue.createElement("svg",{className:Dt(["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(-${C[0]},-${C[1]})`},N?ue.createElement(KO,{color:y,radius:k/l}):ue.createElement(YO,{dimensions:E,color:y,lineWidth:o})),ue.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}uC.displayName="Background";var JO=R.memo(uC);function cC(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function dC(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 fC(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),...dC(r)};for(const i of Object.values(r)){const o=fC(i,n+1);if(o)return o}return null}function eP(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 tP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function hC(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&tP.test(r.model))return r.model;for(const i of Object.values(r)){const o=hC(i,n+1);if(o)return o}return null}function Nv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function Es(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Ra(e,n){return`${e}::${n}`}function bu(e){return e.agent_type??e.subagent_type??"subagent"}function ha(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function no(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:cC()},e.agents.set(o,l),l)}function pC(e,n,r,i){const o=Ra(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&i.cwd&&(l.cwd=i.cwd,l.cwdBasename=Es(i.cwd));const u=bu(i);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function Ox(e,n,r){const i=n.session_id??"unknown",o=ha(n);if(o){const h=pC(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(Ra(i,u));if(h)return!h.cwd&&n.cwd&&(h.cwd=n.cwd,h.cwdBasename=Es(n.cwd)),h}const c=no(e,i,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=Es(n.cwd)),c.label==="session"&&n.cwd&&(c.label=Es(n.cwd)??"session"),c}function nP(e,n,r,i,o){const l=Ra(n,r),u=no(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&i.cwd&&(c.cwd=i.cwd,c.cwdBasename=Es(i.cwd));const h=bu(i);return h&&(c.label==="subagent"||!c.label)&&(c.label=h),c}return c={id:l,sessionId:n,label:bu(i),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:i.cwd,cwdBasename:Es(i.cwd),toolCount:0,childCount:0,usage:cC()},e.agents.set(l,c),u.childCount+=1,c}function rP(e,n,r){const i=e.activeSubagentStack.get(n)??[];i.includes(r)||(i.push(r),e.activeSubagentStack.set(n,i))}function sP(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 Jl(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 Px=200,iP=25;function oP(e,n){const r=n.tools;if(r.length>Px){const i=r.splice(0,r.length-Px);for(const o of i)e.toolIndex.delete(o.id),e.toolOwner.delete(o.id)}for(let i=r.length-iP-1;i>=0;i--){const o=r[i];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function aP(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 Lx=2e3;function lP(e,n,r){for(let i=e.prompts.length-1;i>=0;i--){const o=e.prompts[i];if(o.at<n-Lx)return!1;if(o.text===r&&o.at<=n+Lx)return!0}return!1}function uP(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 cP(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 dP(e,n,r){let i=!1;for(const o of e.agents.values())for(const l of o.tools)l.endedAt==null&&n-l.startedAt>r&&(l.endedAt=l.startedAt+r,l.ok=!1,l.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(l.id),e.toolOwner.delete(l.id),i=!0);return i}const fP=90*6e4;function hP(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 pP(e){return e==="permission_prompt"?"permission":e==="idle_prompt"?"idle":null}const mP=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved"]);function gP(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 vP(e,n,r,i,o){const l=r==="permission"?gP(e,n):void 0;return l?{kind:r,message:i,since:o,subagentId:l}:{kind:r,message:i,since:o}}function yP(e,n,r){if(e.kind!=="permission")return!0;const i=ha(n);return i==null?!0:e.subagentId!=null&&Ra(r,i)===e.subagentId}function qx(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{...Nv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=i.session_id??"unknown";if(!mP.has(l)){const d=e.agents.get(u);d!=null&&d.waiting&&yP(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(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);m&&(m.context={msgsUser:Number(d.msgsUser??0),msgsAssistant:Number(d.msgsAssistant??0),toolUses:Number(d.toolUses??0),toolResults:Number(d.toolResults??0),systemReminders:Number(d.systemReminders??0),currentContextTokens:Number(d.currentContextTokens??0),claudeMdFiles:Array.isArray(d.claudeMdFiles)?d.claudeMdFiles:[]})}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=dC(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=Ox(e,i,o);h.provider||(h.provider=i.provider==="codex"?"codex":"claude");const p=hC(i);switch(p&&(h.model=p),l){case"SessionStart":{const d=no(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=Es(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Es(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=no(e,u,o,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const m=Ox(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&&!lP(m,o,y)&&(m.prompts.push({at:o,text:y}),m.firstPrompt||(m.firstPrompt=Jl(y,120)));break}case"PreToolUse":{const d=i.tool_use_id?aP(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=Jl(i.tool_input));break}const m=i.tool_use_id??`${h.id}:${h.toolCount}`,y=ha(i),w={id:m,name:i.tool_name??"?",input:i.tool_input,inputPreview:Jl(i.tool_input),agentId:h.id,explicitSubagentId:y?Ra(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),oP(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=Jl(i.tool_response):y&&(m.errorPreview=void 0);const w=fC(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);_&&eP(_.usage,w)}break}case"SubagentStart":{const d=ha(i);if(!d)break;const m=nP(e,u,d,i,o);m.state="active",m.startedAt=m.startedAt||o,m.exitAt=void 0,m.endedAt=void 0;const y=bu(i);y&&(m.label=y),rP(e,u,d);break}case"SubagentStop":{const d=ha(i);if(!d)break;const m=pC(e,u,d,i);if(!m)break;m.state="done",m.endedAt=o,sP(e,u,d);break}case"Stop":case"SessionEnd":{const d=no(e,u,o,!1);d.state="done",d.endedAt=o,e.activeSubagentStack.delete(u);break}case"Notification":{const d=pP(i.notification_type);if(!d)break;const m=no(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)}:vP(e,u,d,y,o);break}}return e}function ey(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 wP=Date.UTC(2026,8,1);function xP(e){return e<wP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const _P=[{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:xP},{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 bP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function fo(e,n=Date.now()){if(!e)return null;for(const r of _P)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function mC(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 gC(e,n,r=Date.now()){if(!bP(n))return e.inputTokens;const i=fo(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=fo(n,r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=gC(e,n,r)*i.input/1e6,l=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,c=mC(e,i),h=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:h,total:o+l+u+h}}const $x=2e5,SP=1e6,kP=[/\[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],EP=[{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 NP(e){if(!e)return $x;for(const n of kP)if(n.test(e))return SP;for(const n of EP)if(n.match.test(e))return n.window;return $x}function vC(e,n){return typeof e=="number"&&e>0?e:NP(n)}const du="not priced";function ze(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 Su(e,n){if(e<=0||n<10)return null;const r=e/n,i=r*60;return i>=.01?`${ze(i)}/min`:`${ze(r*3600)}/hr`}const CP=1;function TP(){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 ku=TP();function RP(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Dx(e){return String(e.tagName??"").toUpperCase()==="BODY"}function jP(e,n){return!e||!e.isConnected||Dx(e)?!1:n==null||Dx(n)}const Fx="a[href], button, input, select, textarea, [tabindex]";function AP(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function IP(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const n=String(e.overflow??"").toLowerCase();return n==="auto"||n==="scroll"}function MP({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 yC(e){return e.ctrlKey||e.metaKey||e.altKey}const OP=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),PP=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),LP=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function wC(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function ty(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=wC(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!OP.has(String(e.type??"text").toLowerCase())}function qP(e){if(!e)return!1;if(ty(e)||PP.has(wC(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>LP.has(r))}function xC(e){return e?Array.from(e.querySelectorAll("*")).filter(n=>{if(n.matches(Fx))return AP({disabled:n.disabled,tabIndex:n.tabIndex,rendered:n.getClientRects().length>0});const r=n.scrollHeight>n.clientHeight;return r&&IP({overflowing:r,overflow:getComputedStyle(n).overflowY,hasFocusable:n.querySelector(Fx)!=null})}):[]}function $P(e,n){const r=xC(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 mo(e,n={}){const{focusRef:r,layer:i}=n,o=R.useRef(null),l=R.useRef(e);l.current=e;const u=R.useRef(null);u.current===null&&(u.current=()=>l.current());const c=u.current;return R.useEffect(()=>ku.push(c,i),[c,i]),R.useEffect(()=>{var p;const h=document.activeElement;return(p=(r==null?void 0:r.current)??xC(o.current)[0])==null||p.focus(),()=>{jP(h,document.activeElement)&&h.focus()}},[]),R.useEffect(()=>{const h=p=>{var _;if(p.key!=="Tab"||yC(p))return;const d=o.current;if(!d)return;const m=document.activeElement;if(!(m!=null&&d.contains(m))&&!ku.isTop(c))return;const w=$P(d,m),N=MP({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 Pn(e){return e.toLocaleString()}function DP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const FP=60;function zP(e,n=FP){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 BP({agent:e,onClose:n}){var m;const r=R.useRef(null),i=mo(n,{focusRef:r}),o=e.context,l=e.usage,u=(o==null?void 0:o.currentContextTokens)??0,c=vC(e.contextWindow,e.model),h=Math.min(100,u/c*100),p=dn(l,e.model),d=l.inputTokens+l.cacheReadTokens+l.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{ref:i,className:"ctx-modal",onClick:y=>y.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:"approximation — CC's /context isn't hook-exposed"})]}),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 (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Zn,{label:"input tokens",val:Pn(l.inputTokens)}),g.jsx(Zn,{label:"output tokens",val:Pn(l.outputTokens)}),g.jsx(Zn,{label:"cache reads",val:Pn(l.cacheReadTokens)}),g.jsx(Zn,{label:"cache writes",val:Pn(l.cacheCreateTokens)}),g.jsx(Zn,{label:"cumulative total",val:Pn(d)}),g.jsx(Zn,{label:"estimated cost",val:ze(p.total),accent:!0})]}),g.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Zn,{label:"user messages",val:Pn((o==null?void 0:o.msgsUser)??0)}),g.jsx(Zn,{label:"assistant messages",val:Pn((o==null?void 0:o.msgsAssistant)??0)}),g.jsx(Zn,{label:"tool uses",val:Pn((o==null?void 0:o.toolUses)??0)}),g.jsx(Zn,{label:"tool results",val:Pn((o==null?void 0:o.toolResults)??0)}),g.jsx(Zn,{label:"system-reminders",val:Pn((o==null?void 0:o.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((m=o==null?void 0:o.claudeMdFiles)==null?void 0:m.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):g.jsx("ul",{className:"ctx-md-list",children:o.claudeMdFiles.map(y=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:y.path,children:zP(y.path)}),g.jsx("span",{className:"ctx-md-size",children:DP(y.bytes)})]},y.path))})]})})}function Zn({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 UP({currentContextTokens:e,modelId:n,contextWindow:r,size:i=26,onClick:o,title:l}){const u=vC(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:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function zx(e,n){const r=fo(n);if(!r)return`model: ${n}
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"})))}aC.displayName="MiniMap";var FO=R.memo(aC);function zO(){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 BO(){return ue.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ue.createElement("path",{d:"M0 0h32v4.2H0z"}))}function UO(){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 HO(){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 WO(){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 to=({children:e,className:n,...r})=>ue.createElement("button",{type:"button",className:Dt(["react-flow__controls-button",n]),...r},e);to.displayName="ControlButton";const VO=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),lC=({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=Tt(),[w,N]=R.useState(!1),{isInteractive:_,minZoomReached:b,maxZoomReached:S}=Ke(VO,Ct),{zoomIn:k,zoomOut:E,fitView:C}=Ta();if(R.useEffect(()=>{N(!0)},[]),!w)return null;const I=()=>{k(),l==null||l()},P=()=>{E(),u==null||u()},A=()=>{C(o),c==null||c()},H=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),h==null||h(!_)};return ue.createElement(Uv,{className:Dt(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},n&&ue.createElement(ue.Fragment,null,ue.createElement(to,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ue.createElement(zO,null)),ue.createElement(to,{onClick:P,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ue.createElement(BO,null))),r&&ue.createElement(to,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},ue.createElement(UO,null)),i&&ue.createElement(to,{className:"react-flow__controls-interactive",onClick:H,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ue.createElement(WO,null):ue.createElement(HO,null)),d)};lC.displayName="Controls";var GO=R.memo(lC),tr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(tr||(tr={}));function YO({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 KO({color:e,radius:n}){return ue.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const XO={[tr.Dots]:"#91919a",[tr.Lines]:"#eee",[tr.Cross]:"#e2e2e2"},QO={[tr.Dots]:1,[tr.Lines]:1,[tr.Cross]:6},ZO=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function uC({id:e,variant:n=tr.Dots,gap:r=20,size:i,lineWidth:o=1,offset:l=2,color:u,style:c,className:h}){const p=R.useRef(null),{transform:d,patternId:m}=Ke(ZO,Ct),y=u||XO[n],w=i||QO[n],N=n===tr.Dots,_=n===tr.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,C=N?[k/l,k/l]:[E[0]/l,E[1]/l];return ue.createElement("svg",{className:Dt(["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(-${C[0]},-${C[1]})`},N?ue.createElement(KO,{color:y,radius:k/l}):ue.createElement(YO,{dimensions:E,color:y,lineWidth:o})),ue.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}uC.displayName="Background";var JO=R.memo(uC);function cC(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function dC(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 fC(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),...dC(r)};for(const i of Object.values(r)){const o=fC(i,n+1);if(o)return o}return null}function eP(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 tP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function hC(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&tP.test(r.model))return r.model;for(const i of Object.values(r)){const o=hC(i,n+1);if(o)return o}return null}function Nv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function Es(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Ra(e,n){return`${e}::${n}`}function bu(e){return e.agent_type??e.subagent_type??"subagent"}function ha(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function no(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:cC()},e.agents.set(o,l),l)}function pC(e,n,r,i){const o=Ra(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&i.cwd&&(l.cwd=i.cwd,l.cwdBasename=Es(i.cwd));const u=bu(i);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function Ox(e,n,r){const i=n.session_id??"unknown",o=ha(n);if(o){const h=pC(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(Ra(i,u));if(h)return!h.cwd&&n.cwd&&(h.cwd=n.cwd,h.cwdBasename=Es(n.cwd)),h}const c=no(e,i,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=Es(n.cwd)),c.label==="session"&&n.cwd&&(c.label=Es(n.cwd)??"session"),c}function nP(e,n,r,i,o){const l=Ra(n,r),u=no(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&i.cwd&&(c.cwd=i.cwd,c.cwdBasename=Es(i.cwd));const h=bu(i);return h&&(c.label==="subagent"||!c.label)&&(c.label=h),c}return c={id:l,sessionId:n,label:bu(i),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:i.cwd,cwdBasename:Es(i.cwd),toolCount:0,childCount:0,usage:cC()},e.agents.set(l,c),u.childCount+=1,c}function rP(e,n,r){const i=e.activeSubagentStack.get(n)??[];i.includes(r)||(i.push(r),e.activeSubagentStack.set(n,i))}function sP(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 Jl(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 Px=200,iP=25;function oP(e,n){const r=n.tools;if(r.length>Px){const i=r.splice(0,r.length-Px);for(const o of i)e.toolIndex.delete(o.id),e.toolOwner.delete(o.id)}for(let i=r.length-iP-1;i>=0;i--){const o=r[i];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function aP(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 Lx=2e3;function lP(e,n,r){for(let i=e.prompts.length-1;i>=0;i--){const o=e.prompts[i];if(o.at<n-Lx)return!1;if(o.text===r&&o.at<=n+Lx)return!0}return!1}function uP(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 cP(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 dP(e,n,r){let i=!1;for(const o of e.agents.values())if(o.provider!=="codex")for(const l of o.tools)l.endedAt==null&&n-l.startedAt>r&&(l.endedAt=l.startedAt+r,l.ok=!1,l.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(l.id),e.toolOwner.delete(l.id),i=!0);return i}const fP=90*6e4;function hP(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 pP(e){return e==="permission_prompt"?"permission":e==="idle_prompt"?"idle":null}const mP=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved"]);function gP(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 vP(e,n,r,i,o){const l=r==="permission"?gP(e,n):void 0;return l?{kind:r,message:i,since:o,subagentId:l}:{kind:r,message:i,since:o}}function yP(e,n,r){if(e.kind!=="permission")return!0;const i=ha(n);return i==null?!0:e.subagentId!=null&&Ra(r,i)===e.subagentId}function qx(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{...Nv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=i.session_id??"unknown";if(!mP.has(l)){const d=e.agents.get(u);d!=null&&d.waiting&&yP(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(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);m&&(m.context={msgsUser:Number(d.msgsUser??0),msgsAssistant:Number(d.msgsAssistant??0),toolUses:Number(d.toolUses??0),toolResults:Number(d.toolResults??0),systemReminders:Number(d.systemReminders??0),currentContextTokens:Number(d.currentContextTokens??0),claudeMdFiles:Array.isArray(d.claudeMdFiles)?d.claudeMdFiles:[]})}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=dC(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=Ox(e,i,o);h.provider||(h.provider=i.provider==="codex"?"codex":"claude");const p=hC(i);switch(p&&(h.model=p),l){case"SessionStart":{const d=no(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=Es(i.cwd)),d.label==="session"&&i.cwd&&(d.label=Es(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=no(e,u,o,!1);d.state="active",d.endedAt=void 0,d.exitAt=void 0;const m=Ox(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&&!lP(m,o,y)&&(m.prompts.push({at:o,text:y}),m.firstPrompt||(m.firstPrompt=Jl(y,120)));break}case"PreToolUse":{const d=i.tool_use_id?aP(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=Jl(i.tool_input));break}const m=i.tool_use_id??`${h.id}:${h.toolCount}`,y=ha(i),w={id:m,name:i.tool_name??"?",input:i.tool_input,inputPreview:Jl(i.tool_input),agentId:h.id,explicitSubagentId:y?Ra(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),oP(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=Jl(i.tool_response):y&&(m.errorPreview=void 0);const w=fC(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);_&&eP(_.usage,w)}break}case"SubagentStart":{const d=ha(i);if(!d)break;const m=nP(e,u,d,i,o);m.state="active",m.startedAt=m.startedAt||o,m.exitAt=void 0,m.endedAt=void 0;const y=bu(i);y&&(m.label=y),rP(e,u,d);break}case"SubagentStop":{const d=ha(i);if(!d)break;const m=pC(e,u,d,i);if(!m)break;m.state="done",m.endedAt=o,sP(e,u,d);break}case"Stop":case"SessionEnd":{const d=no(e,u,o,!1);d.state="done",d.endedAt=o,e.activeSubagentStack.delete(u);break}case"Notification":{const d=pP(i.notification_type);if(!d)break;const m=no(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)}:vP(e,u,d,y,o);break}}return e}function ey(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 wP=Date.UTC(2026,8,1);function xP(e){return e<wP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const _P=[{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:xP},{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 bP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function fo(e,n=Date.now()){if(!e)return null;for(const r of _P)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function mC(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 gC(e,n,r=Date.now()){if(!bP(n))return e.inputTokens;const i=fo(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=fo(n,r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=gC(e,n,r)*i.input/1e6,l=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,c=mC(e,i),h=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:h,total:o+l+u+h}}const $x=2e5,SP=1e6,kP=[/\[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],EP=[{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 NP(e){if(!e)return $x;for(const n of kP)if(n.test(e))return SP;for(const n of EP)if(n.match.test(e))return n.window;return $x}function vC(e,n){return typeof e=="number"&&e>0?e:NP(n)}const du="not priced";function ze(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 Su(e,n){if(e<=0||n<10)return null;const r=e/n,i=r*60;return i>=.01?`${ze(i)}/min`:`${ze(r*3600)}/hr`}const CP=1;function TP(){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 ku=TP();function RP(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Dx(e){return String(e.tagName??"").toUpperCase()==="BODY"}function jP(e,n){return!e||!e.isConnected||Dx(e)?!1:n==null||Dx(n)}const Fx="a[href], button, input, select, textarea, [tabindex]";function AP(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function IP(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const n=String(e.overflow??"").toLowerCase();return n==="auto"||n==="scroll"}function MP({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 yC(e){return e.ctrlKey||e.metaKey||e.altKey}const OP=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),PP=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),LP=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function wC(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function ty(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=wC(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!OP.has(String(e.type??"text").toLowerCase())}function qP(e){if(!e)return!1;if(ty(e)||PP.has(wC(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>LP.has(r))}function xC(e){return e?Array.from(e.querySelectorAll("*")).filter(n=>{if(n.matches(Fx))return AP({disabled:n.disabled,tabIndex:n.tabIndex,rendered:n.getClientRects().length>0});const r=n.scrollHeight>n.clientHeight;return r&&IP({overflowing:r,overflow:getComputedStyle(n).overflowY,hasFocusable:n.querySelector(Fx)!=null})}):[]}function $P(e,n){const r=xC(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 mo(e,n={}){const{focusRef:r,layer:i}=n,o=R.useRef(null),l=R.useRef(e);l.current=e;const u=R.useRef(null);u.current===null&&(u.current=()=>l.current());const c=u.current;return R.useEffect(()=>ku.push(c,i),[c,i]),R.useEffect(()=>{var p;const h=document.activeElement;return(p=(r==null?void 0:r.current)??xC(o.current)[0])==null||p.focus(),()=>{jP(h,document.activeElement)&&h.focus()}},[]),R.useEffect(()=>{const h=p=>{var _;if(p.key!=="Tab"||yC(p))return;const d=o.current;if(!d)return;const m=document.activeElement;if(!(m!=null&&d.contains(m))&&!ku.isTop(c))return;const w=$P(d,m),N=MP({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 Pn(e){return e.toLocaleString()}function DP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const FP=60;function zP(e,n=FP){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 BP({agent:e,onClose:n}){var m;const r=R.useRef(null),i=mo(n,{focusRef:r}),o=e.context,l=e.usage,u=(o==null?void 0:o.currentContextTokens)??0,c=vC(e.contextWindow,e.model),h=Math.min(100,u/c*100),p=dn(l,e.model),d=l.inputTokens+l.cacheReadTokens+l.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{ref:i,className:"ctx-modal",onClick:y=>y.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:"approximation — CC's /context isn't hook-exposed"})]}),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 (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Zn,{label:"input tokens",val:Pn(l.inputTokens)}),g.jsx(Zn,{label:"output tokens",val:Pn(l.outputTokens)}),g.jsx(Zn,{label:"cache reads",val:Pn(l.cacheReadTokens)}),g.jsx(Zn,{label:"cache writes",val:Pn(l.cacheCreateTokens)}),g.jsx(Zn,{label:"cumulative total",val:Pn(d)}),g.jsx(Zn,{label:"estimated cost",val:ze(p.total),accent:!0})]}),g.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Zn,{label:"user messages",val:Pn((o==null?void 0:o.msgsUser)??0)}),g.jsx(Zn,{label:"assistant messages",val:Pn((o==null?void 0:o.msgsAssistant)??0)}),g.jsx(Zn,{label:"tool uses",val:Pn((o==null?void 0:o.toolUses)??0)}),g.jsx(Zn,{label:"tool results",val:Pn((o==null?void 0:o.toolResults)??0)}),g.jsx(Zn,{label:"system-reminders",val:Pn((o==null?void 0:o.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((m=o==null?void 0:o.claudeMdFiles)==null?void 0:m.length)??0)===0?g.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):g.jsx("ul",{className:"ctx-md-list",children:o.claudeMdFiles.map(y=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:y.path,children:zP(y.path)}),g.jsx("span",{className:"ctx-md-size",children:DP(y.bytes)})]},y.path))})]})})}function Zn({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 UP({currentContextTokens:e,modelId:n,contextWindow:r,size:i=26,onClick:o,title:l}){const u=vC(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:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:p,y:p+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function zx(e,n){const r=fo(n);if(!r)return`model: ${n}
58
58
  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=mC(e,r),c=u.tokens1h>0?[`cache w5m${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`,`cache w1h${i(u.tokens1h).padStart(14)} × ${o(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${ze(u.usd1h)}`]:[`cache w ${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`],h=gC(e,n),p=h===e.inputTokens?"input":"uncached";return[`model: ${n}`,`${p.padEnd(9)}${i(h).padStart(14)} × ${o(r.input).padEnd(11)} = ${ze(l.input)}`,`output ${i(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${ze(l.output)}`,`cache r ${i(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${ze(l.cacheRead)}`,...c,"─────────────────────────────────────────",`total = ${ze(l.total)}`].join(`
59
59
  `)}function Cv(e,n,r){const i=(n??r)-e;if(i<1e3)return`${Math.max(0,i)}ms`;const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function HP({data:e,selected:n}){var h;const r=e.now??Date.now(),i=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(p=>!p.endedAt).length,l=ey(e.sessionId),u=((h=e.context)==null?void 0:h.currentContextTokens)??0,c=e.kind==="root"&&u>0;return g.jsxs("div",{className:i,style:{"--session-hue":l},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(co,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(WP,{state:e.state}),g.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&g.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),g.jsxs("div",{className:"head-right",children:[c&&e.onOpenContext&&g.jsx(UP,{currentContextTokens:u,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:Cv(e.startedAt,e.endedAt,r)})]})]}),g.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&g.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&g.jsx("span",{className:"model-chip",title:e.model,children:di(e.model)})]}),e.waiting&&g.jsx(GP,{waiting:e.waiting,now:r}),e.tools.length>0&&g.jsx(KP,{tools:e.tools,now:r}),g.jsxs("div",{className:"meta",children:[g.jsxs("span",{children:[g.jsx("b",{children:e.toolCount})," tools"]}),o>0&&g.jsxs("span",{className:"inflight-meta",children:[g.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&g.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[g.jsx("b",{children:YP(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{if(!fo(e.model))return e.usage.inputTokens+e.usage.outputTokens<=0?null:g.jsx("span",{className:"cost-unpriced",title:zx(e.usage,e.model),children:du});const d=dn(e.usage,e.model);if(d.total<=0)return null;const m=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),y=e.state==="active"?Su(d.total,m):null,w=zx(e.usage,e.model)+(y?`
60
60
  burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:w,children:[g.jsx("b",{children:ze(d.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(co,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function ny(e){return e==="active"?"live":e==="done"?"done":"err"}function WP({state:e}){return g.jsx("span",{className:`state-pill state-${e}`,children:ny(e)})}function Ou(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function VP(e){return e.kind==="permission"?Ou(e):"Your turn"}function GP({waiting:e,now:n}){const r=e.kind==="permission",i=Ou(e);return g.jsxs("div",{className:r?"waiting-row permission":"waiting-row idle",title:`${i}
61
61
  Blocked for ${Cv(e.since,void 0,n)} — the answer goes in the terminal, not here.`,children:[r?g.jsx("span",{className:"ap-pulse","aria-hidden":!0}):g.jsx("span",{className:"waiting-dot","aria-hidden":!0}),g.jsx("span",{className:"waiting-said",children:VP(e)}),g.jsx("b",{children:Cv(e.since,void 0,n)})]})}function YP(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function KP({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const w=n-y.startedAt;if(w<0||w>=6e4)continue;const N=23-Math.floor(w/2500);N>=0&&N<24&&(l[N]+=1,u+=1)}const c=Math.max(1,...l),h=132,p=14,d=h/24,m=c/(2500/1e3);return g.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${m.toFixed(1)}/s`,children:[g.jsx("svg",{className:"tool-spark",width:h,height:p,viewBox:`0 0 ${h} ${p}`,"aria-hidden":!0,children:l.map((y,w)=>{const N=y===0?1.5:Math.max(1.5,y/c*p),_=w===23&&y>0,S=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:w*d+.4,y:p-N,width:Math.max(.5,d-1),height:N,rx:.8,className:S},w)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function di(e){const n=e.replace(/^anthropic\./,"").replace(/[-_]\d{8}(?!\d)/,""),r=n.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(r){const l=r[1][0].toUpperCase()+r[1].slice(1).toLowerCase(),u=r[2].replace(/[-_]/g,".");return`${l} ${u}`}const i=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const o=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return o?`GPT-${o[1].replace(/[-_]/g,".")}`:e}function Bx(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function XP(e){if(e.endedAt==null)return"in-flight…";const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function QP({tool:e,onClose:n}){const r=mo(n),i=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{ref:r,className:"modal",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:`status-dot ${i}`,"aria-hidden":!0}),g.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),g.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",children:XP(e)}),g.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("section",{className:"modal-body",children:[e.trimmed&&g.jsx("div",{className:"modal-section",children:g.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),g.jsxs("div",{className:"modal-section",children:[g.jsx("h4",{children:"Input"}),g.jsx("pre",{children:Bx(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",i==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":Bx(e.response??e.errorPreview)})]})]})]})})}const eu=18,Ux=26,ZP=12;function JP(e){return e3(e.nodeInternals.values())}function e3(e){const n=new Map;for(const o of e){if(o.type!=="agent")continue;const l=o.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||o.width==null||o.height==null)continue;const u=o.position.x,c=o.position.y,h=u+o.width,p=c+o.height,d=n.get(l.sessionId);d?(d.minX=Math.min(d.minX,u),d.minY=Math.min(d.minY,c),d.maxX=Math.max(d.maxX,h),d.maxY=Math.max(d.maxY,p),l.kind==="root"&&(d.label=Hx(l)??d.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:h,maxY:p,label:Hx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const i=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${t3(o)}`:l.label;i.push({sessionId:o,label:c,x:l.minX-eu,y:l.minY-eu-Ux,w:l.maxX-l.minX+eu*2,h:l.maxY-l.minY+eu*2+Ux})}return i}function t3(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function Hx(e){if(e.kind==="root")return e.label}function n3(){const{x:e,y:n,zoom:r}=iC(),i=Ta(),o=Ke(JP,r3);if(o.length<=1)return null;const l=u=>{try{const c=i.getNodes().filter(h=>{const p=h.data;return(p==null?void 0:p.sessionId)===u});if(c.length===0)return;i.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=ey(u.sessionId),h={position:"absolute",left:u.x*r+e,top:u.y*r+n,width:u.w*r,height:u.h*r,"--session-hue":c},p={position:"absolute",left:u.x*r+e+16*r,top:(u.y-ZP)*r+n,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top","--session-hue":c};return g.jsxs(ue.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:h,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:p,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function r3(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(i.sessionId!==o.sessionId||i.label!==o.label||i.x!==o.x||i.y!==o.y||i.w!==o.w||i.h!==o.h)return!1}return!0}function s3({data:e}){return g.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const _C=600,i3=4,o3=36,Tv=16,a3=60,l3=6,Wx=220,Vx=96,u3=28,c3={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",ScheduleWakeup:"other",CronCreate:"other",CronList:"other",CronDelete:"other",Monitor:"other",PushNotification:"other",RemoteTrigger:"other",ToolSearch:"other"};function d3(e){return e.startsWith("mcp__")?"mcp":c3[e]??"other"}const f3={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",shell:"⚡",exec_command:"⚡",shell_command:"⚡",write_stdin:"💻",wait:"⏳",apply_patch:"🩹",update_plan:"📋",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡"};function Gx(e){return e.startsWith("mcp__")?"🔌":f3[e]??"✨"}const h3={git:"🐙",gh:"🐙",glab:"🐙",npm:"📦",pnpm:"📦",yarn:"📦",bun:"📦",brew:"🍺",node:"🟢",deno:"🟢",python:"🐍",python3:"🐍",py:"🐍",pip:"🐍",pip3:"🐍",uv:"🐍",ruby:"💎",bundle:"💎",gem:"💎",cargo:"🦀",rustc:"🦀",rustup:"🦀",go:"🐹",docker:"🐳","docker-compose":"🐳",podman:"🐳",kubectl:"☸️",helm:"☸️",k9s:"☸️",grep:"🔎",rg:"🔎",ag:"🔎",ack:"🔎",find:"🔍",fd:"🔍",locate:"🔍",which:"🔍",ls:"📂",dir:"📂",tree:"📂",cat:"📄",head:"📄",tail:"📄",less:"📄",more:"📄",bat:"📄",cp:"📋",mv:"✂️",rm:"🗑️",rmdir:"🗑️",mkdir:"📁",touch:"📁",sed:"✏️",awk:"✏️",tr:"✏️",curl:"🌐",wget:"🌐",http:"🌐",httpie:"🌐",ssh:"🔐",scp:"🔐",rsync:"🔐",ping:"📡",make:"🔨",cmake:"🔨",ninja:"🔨",bazel:"🔨",just:"🔨",terraform:"🏗️",ansible:"📕",pulumi:"🏗️",ps:"📊",top:"📊",htop:"📊",btm:"📊",kill:"💀",pkill:"💀",systemctl:"⚙️",service:"⚙️",tar:"🗜️",zip:"🗜️",unzip:"🗜️",gzip:"🗜️","7z":"🗜️",vim:"📝",nvim:"📝",nano:"📝",emacs:"📝",code:"📝",jq:"🪺",yq:"🪺",echo:"💬",printf:"💬",ffmpeg:"🎞️",ffprobe:"🎞️",imagemagick:"🖼️",convert:"🖼️","Get-ChildItem":"📂","Get-Content":"📄","Set-Content":"💾","Out-File":"💾","Add-Content":"💾","Set-Location":"📍","Get-Location":"📍","Get-Process":"📊","Start-Process":"▶️","Stop-Process":"💀","Invoke-WebRequest":"🌐","Invoke-RestMethod":"🌐","New-Item":"📁","Remove-Item":"🗑️","Copy-Item":"📋","Move-Item":"✂️","Test-Path":"🔍","Where-Object":"🔎","ForEach-Object":"🔁","Select-Object":"🎯","Measure-Object":"📊","Get-Service":"⚙️","Restart-Service":"⚙️","ConvertTo-Json":"🪺","ConvertFrom-Json":"🪺"};function bC(e){if(!e)return null;let n=e.trim();if(!n)return null;const r=n.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?\s+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(r)return bC(r[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const i=n.match(/^([^\s|;&<>(]+)/);if(!i)return null;let o=i[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function p3(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(r=>typeof r=="string")){const r=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const i=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(i>=0&&i+1<r.length)return r[i+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const m3=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),g3=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function v3(e,n){return g3.has(e)||e.startsWith("mcp__")?Math.max(Vx,34+n.length*7.5):Vx}function y3(e,n){if(!m3.has(e))return null;const r=p3(n);if(!r)return null;const i=bC(r);return i?{emoji:h3[i]??"⚙️",label:i,category:"shell",detail:r}:null}const w3=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Yx={ts:"🟦",tsx:"🟦",d:"🟦",js:"🟨",jsx:"🟨",mjs:"🟨",cjs:"🟨",py:"🐍",pyi:"🐍",ipynb:"📓",rs:"🦀",go:"🐹",rb:"💎",erb:"💎",java:"☕",kt:"☕",scala:"☕",gradle:"☕",cs:"🔷",fs:"🔷",php:"🐘",swift:"🦅",c:"🇨",cpp:"🇨",cc:"🇨",h:"🇨",hpp:"🇨",md:"📝",mdx:"📝",rst:"📝",json:"🪺",json5:"🪺",jsonl:"🪺",yaml:"⚙️",yml:"⚙️",toml:"⚙️",ini:"⚙️",conf:"⚙️",cfg:"⚙️",xml:"📰",html:"🌐",htm:"🌐",vue:"🌐",svelte:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sh:"⚡",bash:"⚡",zsh:"⚡",fish:"⚡",ps1:"⚡",txt:"📄",log:"📄",out:"📄",csv:"📊",tsv:"📊",xlsx:"📊",xls:"📊",pdf:"📕",png:"🖼️",jpg:"🖼️",jpeg:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",ico:"🖼️",mp4:"🎬",mov:"🎬",avi:"🎬",mkv:"🎬",webm:"🎬",mp3:"🎵",wav:"🎵",ogg:"🎵",flac:"🎵",zip:"🗜️",tar:"🗜️",gz:"🗜️",bz2:"🗜️","7z":"🗜️",xz:"🗜️",rar:"🗜️",env:"🔐",lock:"🔐",pem:"🔐",key:"🔐",crt:"🔐",sql:"🗄️",db:"🗄️",sqlite:"🗄️",parquet:"🗄️"},Kx={dockerfile:"🐳",makefile:"🔨",rakefile:"💎","package.json":"📦","pnpm-lock.yaml":"📦","yarn.lock":"📦","cargo.toml":"🦀","cargo.lock":"🦀","go.mod":"🐹","go.sum":"🐹","pyproject.toml":"🐍","requirements.txt":"🐍","readme.md":"📖",readme:"📖",license:"📜",".gitignore":"🐙",".gitattributes":"🐙",".env":"🔐",".dockerignore":"🐳"};function x3(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function _3(e){const n=e.toLowerCase();if(Kx[n])return Kx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const r=n.lastIndexOf(".");if(r>0&&r<n.length-1){const i=n.slice(r+1);if(Yx[i])return Yx[i]}return"📄"}function b3(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const i=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return i?i[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function S3(e,n){if(!w3.has(e))return null;const r=b3(e,n);if(!r)return null;const i=x3(r);return i?{emoji:e==="LS"?"📂":_3(i),label:i,category:"file",detail:r}:null}const SC={github:{emoji:"🐙",name:"GitHub"},git:{emoji:"🐙",name:"Git"},gitlab:{emoji:"🦊",name:"GitLab"},slack:{emoji:"💬",name:"Slack"},discord:{emoji:"💬",name:"Discord"},linear:{emoji:"📐",name:"Linear"},jira:{emoji:"🅹",name:"Jira"},atlassian:{emoji:"🅰️",name:"Atlassian"},notion:{emoji:"📓",name:"Notion"},asana:{emoji:"📋",name:"Asana"},intercom:{emoji:"💬",name:"Intercom"},figma:{emoji:"🎨",name:"Figma"},gmail:{emoji:"📧",name:"Gmail"},calendar:{emoji:"📅",name:"Calendar"},drive:{emoji:"☁️",name:"Drive"},zoom:{emoji:"📹",name:"Zoom"},spotify:{emoji:"🎵",name:"Spotify"},youtube:{emoji:"📺",name:"YouTube"},ccd_session:{emoji:"📡",name:"Session"},ccd_directory:{emoji:"📂",name:"Directory"},ccd_session_mgmt:{emoji:"📡",name:"Sessions"},mcp_registry:{emoji:"🧰",name:"Registry"},"computer-use":{emoji:"🖱️",name:"Computer"},"claude-in-chrome":{emoji:"🌐",name:"Chrome"},"claude-preview":{emoji:"👀",name:"Preview"},"scheduled-tasks":{emoji:"⏰",name:"Scheduler"},visualize:{emoji:"🎨",name:"Visualize"},"plugin-design-asana":{emoji:"📋",name:"Asana"},"plugin-design-atlassian":{emoji:"🅰️",name:"Atlassian"},"plugin-design-figma":{emoji:"🎨",name:"Figma"},"plugin-design-intercom":{emoji:"💬",name:"Intercom"},"plugin-design-linear":{emoji:"📐",name:"Linear"},"plugin-design-notion":{emoji:"📓",name:"Notion"},"plugin-design-slack":{emoji:"💬",name:"Slack"}};function kC(e){if(!e.startsWith("mcp__"))return null;const n=e.slice(5),r=n.indexOf("__");return r<=0?{server:n,method:""}:{server:n.slice(0,r),method:n.slice(r+2)}}function k3(e){let n=5381;for(let r=0;r<e.length;r++)n=(n<<5)+n^e.charCodeAt(r);return Math.abs(n)%360}function E3(e,n){const r=kC(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const l=SC[i.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${i} · ${o}`}}function N3(e,n){return y3(e,n)??S3(e,n)??E3(e)}const C3={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function T3(e){const n=kC(e);if(n){const i=SC[n.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:n.server,hue:k3(n.server)}}const r=C3[e];return r?{emoji:Gx(e),label:r}:{emoji:Gx(e),label:e}}function R3(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function j3(e,n,r){if(r==null)return 1;const i=n-r;return i<0?1:Math.max(0,1-i/_C)}function A3(e,n){const r=[],i=new Set;for(let o=e.length-1;o>=0&&r.length<n;o--){const l=e[o];i.has(l.id)||(i.add(l.id),r.push(l))}return r.reverse()}function I3(e,n,r,i,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>_C)continue;const h=i.get(c.id)??r.get(c.id);if(!h)continue;const p=A3(c.tools,i3);if(p.length===0)continue;const d=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??Wx,Wx),w=(m==null?void 0:m.height)??130,N=h.x,_=h.y,b=N+y,S=_+w/2;p.forEach((k,E)=>{const C=E*o3,I=N+y+a3,P=_+l3+C,A=j3(k,l,d),H=k.inputPreview??"",z=R3(k),L=A<.999,F=T3(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:F.label,emoji:F.emoji,status:z,category:d3(k.name),mcpHue:F.hue,inputPreview:H,fade:A,fading:L,worldX:I,worldY:P,anchorX:b,anchorY:S,spawnDx:b-I,spawnDy:S-(P+Tv)});const G=N3(k.name,k.input);if(G){const O=v3(k.name,F.label),j=I+O+u3,q=P,$=I+O,re=P+Tv;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:G.label,emoji:G.emoji,isSub:!0,status:z,category:G.category,inputPreview:G.detail??H,fade:A,fading:L,worldX:j,worldY:q,anchorX:$,anchorY:re,spawnDx:$-j,spawnDy:0})}})}return u}function M3({agents:e,visibleAgentIds:n,positions:r,pinned:i,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:h,onOpenTool:p}){const d=I3(e,n,r,i,o,h),m=c&&c.size>0?d.filter(y=>!c.has(y.category)):d;return g.jsx(O3,{bursts:m,dimUnmatched:l,spotlight:u,onOpenTool:p})}function O3({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:i}){const{x:o,y:l,zoom:u}=iC();return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const h=c.anchorX*u+o,p=c.anchorY*u+l,d=(c.worldX+6)*u+o,m=(c.worldY+Tv)*u+l,y=h+(d-h)*.55,w=n!=null&&!n.has(c.agentId),N=r!=null&&!r.has(c.agentId),_=c.fade*(w||N?.14:1);return g.jsx("path",{d:`M ${h} ${p} Q ${y} ${p}, ${d} ${m}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const h=c.worldX*u+o,p=c.worldY*u+l,d={left:`${h}px`,top:`${p}px`,transform:`scale(${u})`,transformOrigin:"left top","--spawn-dx":`${c.spawnDx}px`,"--spawn-dy":`${c.spawnDy}px`},m=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${m} · ${c.inputPreview}`:m,w=i!=null,N=c.mcpHue!=null?{"--mcp-hue":c.mcpHue}:{},_=n!=null&&!n.has(c.agentId),b=r!=null&&!r.has(c.agentId),S=_||b?" dim":"";return g.jsx("div",{className:"tool-burst-wrap",style:d,children:g.jsxs("div",{className:`tool-burst cat-${c.category}${c.mcpHue!=null?" mcp-hue":""} status-${c.status}${c.fading?" fading":""}${w?" clickable":""}${c.isSub?" sub":""}${S}`,style:N,title:y,onClick:w?()=>i(c.toolId):void 0,children:[g.jsx("span",{className:"tb-emoji",children:c.emoji}),g.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&g.jsx("span",{className:"tb-spin"}),c.status==="done"&&g.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&g.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function P3({state:e,sessionId:n,onClose:r}){const i=R.useMemo(()=>q3(e,n),[e,n]),o=R.useRef(null),l=mo(r,{focusRef:o});return i?g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{ref:l,className:"modal session-summary",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[g.jsxs("div",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),g.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:i.durationLabel}),g.jsx("button",{type:"button",ref:o,className:"btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),g.jsxs("div",{className:"modal-body",children:[g.jsxs("section",{className:"ss-hero",children:[g.jsxs("div",{className:"ss-hero-left",children:[g.jsx("div",{className:"ss-cost-label",children:"total spend"}),g.jsx("div",{className:"ss-cost",children:ze(i.cost.total)}),i.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:i.modelChips.map(u=>g.jsx("span",{className:"model-chip",title:u,children:di(u)},u))})]}),g.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(L3,{cost:i.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:ze(i.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:ze(i.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:ze(i.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:ze(i.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Zi,{label:"agents",value:i.agentCount}),g.jsx(Zi,{label:"subagents",value:i.subagentCount}),g.jsx(Zi,{label:"tool calls",value:i.toolCount}),g.jsx(Zi,{label:"prompts",value:i.promptCount}),g.jsx(Zi,{label:"tokens",value:i.tokensSum.toLocaleString()}),i.errCount>0&&g.jsx(Zi,{label:"errors",value:i.errCount,tone:"err"})]}),i.topTools.length>0&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Most-used tools"}),g.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([u,c])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:u}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${c/i.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:c})]},u))})]}),i.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function Zi({label:e,value:n,tone:r}){return g.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[g.jsx("div",{className:"ss-stat-value",children:n}),g.jsx("div",{className:"ss-stat-label",children:e})]})}function L3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(i)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar cost-bar-lg","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function q3(e,n){const r=e.agents.get(n);if(!r)return null;const i=[];for(const E of e.agents.values())E.sessionId===n&&i.push(E);if(i.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,h=0,p=0,d=0,m=0,y,w=1/0,N=0;for(const E of i){const C=dn(E.usage,E.model);o.input+=C.input,o.output+=C.output,o.cacheRead+=C.cacheRead,o.cacheWrite+=C.cacheWrite,o.total+=C.total,E.model&&l.add(E.model),E.kind==="subagent"&&m++,h+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),p+=E.usage.inputTokens+E.usage.outputTokens,c+=E.toolCount,w=Math.min(w,E.startedAt),N=Math.max(N,E.endedAt??Date.now());for(const I of E.tools)u.set(I.name,(u.get(I.name)??0)+1),I.ok===!1&&d++}const _=Math.max(0,N-w),b=Math.floor(_/1e3),S=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,k=Array.from(u.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:n,label:r.label||r.cwdBasename||"session",cwd:r.cwd,durationLabel:S,cost:o,modelChips:Array.from(l),agentCount:i.length,subagentCount:m,toolCount:c,promptCount:h,tokensSum:p,errCount:d,topTools:k,firstPrompt:y}}function ry(e){return(e==null?void 0:e.kind)==="permission"}function $3(e){const n=[];for(const r of e)r.kind==="root"&&ry(r.waiting)&&n.push({id:r.id,label:r.label,waiting:r.waiting});return n.sort((r,i)=>r.waiting.since-i.waiting.since)}function D3(e){const n=new Set;for(const r of e)r.state==="active"&&n.add(r.sessionId);return n.size}function Xx(e){return e.waiting?ry(e.waiting)?0:1:e.state==="active"?2:3}function F3(e,n){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,l=dn(i.usage,i.model).total,u=i.endedAt??i.startedAt;for(const c of e.agents.values()){if(c.sessionId!==i.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=dn(c.usage,c.model).total;const h=c.endedAt??c.startedAt;h>u&&(u=h)}r.push({sessionId:i.sessionId,label:i.label||i.cwdBasename||"session",cwdBasename:i.cwdBasename,state:i.state,waiting:i.waiting,modelId:i.model,toolCount:o,cost:l,startedAt:i.startedAt,lastActivity:u})}return r.sort((i,o)=>{const l=Xx(i),u=Xx(o);return l!==u?l-u:i.waiting&&o.waiting?i.waiting.since-o.waiting.since:o.lastActivity-i.lastActivity}),r}function Qx(e,n,r){const i=(n??r)-e;if(i<1e3)return"<1s";const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function z3({state:e,now:n,selectedIds:r,onSelect:i,onClose:o}){const l=R.useMemo(()=>F3(e),[e,e.lastSeq,n]),u=l.filter(h=>h.state==="active").length,c=l.filter(h=>ry(h.waiting)).length;return g.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[g.jsxs("div",{className:"sl-header",children:[g.jsxs("h3",{children:["Sessions ",g.jsx("span",{className:"sl-count",children:l.length})]}),c>0&&g.jsxs("span",{className:"sl-waiting-count",children:[c," waiting"]}),u>0&&g.jsxs("span",{className:"sl-live-count",children:[u," live"]}),g.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),g.jsxs("div",{className:"sl-rows",children:[l.length===0&&g.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(h=>{const p=r.has(h.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${h.state}${p?" selected":""}`,onClick:()=>i(h.sessionId),title:`Focus ${h.label}`,children:[g.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),g.jsx("span",{className:"vis-hidden",children:ny(h.state)}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:h.label}),h.modelId&&g.jsx("span",{className:"model-chip",title:h.modelId,children:di(h.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:ze(h.cost)})}),h.waiting?g.jsxs("span",{className:"sl-waiting",title:`${Ou(h.waiting)}
62
62
  Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`,children:["waiting ",Qx(h.waiting.since,void 0,n)]}):g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:Qx(h.startedAt,h.state==="active"?void 0:h.lastActivity,n)})]})]})]},h.sessionId)})]})]})}const en="ccdeck";function $t(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:e<1e9?`${(e/1e6).toFixed(2)}M`:`${(e/1e9).toFixed(2)}B`}function Zx(e,n){if(!e)return null;const r=n-Math.floor(e/1e3);return r<10?"just now":r<60?`${r}s ago`:r<3600?`${Math.floor(r/60)}m ago`:`${Math.floor(r/3600)}h ago`}function B3(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}const Bd="__unknown__";function U3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(i)} (${u.toFixed(0)}%)`},o)};return g.jsxs("div",{className:"cost-bar","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}function H3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/3600),o=Math.floor(r%3600/60);if(i>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return i>0?`${i}h ${o}m`:`${o}m`}function W3(e,n,r,i){const o=Math.max(0,n-i),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const h=100-e,p=l>0?e/l:0,d=p>0?h/p:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(d<o&&d<86400){const y=Math.floor(d/3600),w=Math.floor(d%3600/60);m.runsOutIn=y>0?`${y}h ${w}m`:`${w}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function ri({pct:e,label:n,reset:r,resetAt:i,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),p=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",d=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=i?H3(i,u):null,w=i&&o?W3(c,i,o,u):null;return g.jsxs("div",{className:"qb-row",children:[g.jsxs("div",{className:"qb-meta",children:[g.jsxs("span",{className:"qb-label",children:[n,l&&g.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),g.jsx("span",{className:"qb-pct",style:{color:p},children:d})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:p,opacity:c===0?.4:1}}),w&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${w.expectedPct}%`,background:w.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(w.expectedPct)}% by now`})]}),g.jsxs("div",{className:"qb-reset-row",children:[y?g.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?g.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,w&&g.jsx("span",{className:"qb-pace",style:{color:w.color},children:w.runsOutIn?`runs out in ${w.runsOutIn}`:w.label})]})]})}const V3=6e4;function G3(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(null),u=async(h=!1)=>{h&&o(!0);try{const d=await fetch(h?"/api/quota?refresh=1":"/api/quota");d.ok&&r(await d.json())}catch{}finally{h&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),l.current=window.setInterval(()=>u(!1),V3),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{quota:n,loading:i,refresh:()=>{e&&u(!0)}}}function Y3(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const EC=6e4;function K3(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(null),u=async(h=!1)=>{h&&o(!0);try{const d=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");d.ok&&r(await d.json())}catch{}finally{h&&o(!1)}};return R.useEffect(()=>{if(e)return u(!0),l.current=window.setInterval(()=>u(!1),EC),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{data:n,loading:i,refresh:()=>{e&&u(!0)}}}function X3(e){const[n,r]=R.useState(null),i=R.useRef(null),o=async()=>{try{const l=await fetch("/api/codex-usage");l.ok&&r(await l.json())}catch{}};return R.useEffect(()=>{if(e)return o(),i.current=window.setInterval(o,EC),()=>{i.current!=null&&window.clearInterval(i.current)}},[e]),{data:n}}function Q3({state:e,now:n,providers:r,onClose:i}){var F,G;const{quota:o,loading:l,refresh:u}=G3(r.claude),{data:c,loading:h,refresh:p}=K3(r.codex),{data:d}=X3(r.codex),[m,y]=R.useState(()=>Math.floor(Date.now()/1e3));R.useEffect(()=>{const O=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const{byModel:w,totalCost:N,totalTokens:_,burnRate:b}=R.useMemo(()=>{const O=new Map,j={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let q=0,$=0,re=0,J=0;for(const U of e.agents.values()){const B=U.model??Bd,X=dn(U.usage,U.model),ne=O.get(B);ne?(ne.inputTokens+=U.usage.inputTokens,ne.outputTokens+=U.usage.outputTokens,ne.cacheReadTokens+=U.usage.cacheReadTokens,ne.cacheCreateTokens+=U.usage.cacheCreateTokens,ne.cost.total+=X.total,ne.cost.input+=X.input,ne.cost.output+=X.output,ne.cost.cacheRead+=X.cacheRead,ne.cost.cacheWrite+=X.cacheWrite,ne.agentCount++):O.set(B,{model:B,inputTokens:U.usage.inputTokens,outputTokens:U.usage.outputTokens,cacheReadTokens:U.usage.cacheReadTokens,cacheCreateTokens:U.usage.cacheCreateTokens,cost:{...X},agentCount:1,priced:fo(U.model)!=null}),j.total+=X.total,j.input+=X.input,j.output+=X.output,j.cacheRead+=X.cacheRead,j.cacheWrite+=X.cacheWrite,q+=U.usage.inputTokens,$+=U.usage.outputTokens,re+=U.usage.cacheReadTokens,J+=U.usage.cacheCreateTokens}const W=Array.from(O.values()).sort((U,B)=>B.cost.total-U.cost.total||B.inputTokens+B.outputTokens-(U.inputTokens+U.outputTokens));let Z=0,M=0;for(const U of e.agents.values()){if(U.state!=="active")continue;const B=dn(U.usage,U.model);Z+=B.total,M=Math.max(M,((U.endedAt??n)-U.startedAt)/1e3)}const Y=M>0?Su(Z,M):null;return{byModel:W,totalCost:j,totalTokens:{in:q,out:$,cacheR:re,cacheC:J},burnRate:Y}},[e,e.lastSeq,n]),S=R.useMemo(()=>{const O=[],j=q=>fo(q.model)==null?q.usage.inputTokens+q.usage.outputTokens:0;for(const q of e.agents.values()){if(q.kind!=="root")continue;let $=dn(q.usage,q.model).total,re=q.usage.inputTokens,J=q.usage.outputTokens,W=j(q);for(const Z of e.agents.values())Z.sessionId!==q.sessionId||Z.kind==="root"||($+=dn(Z.usage,Z.model).total,re+=Z.usage.inputTokens,J+=Z.usage.outputTokens,W+=j(Z));O.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:$,inputTokens:re,outputTokens:J,unpricedTokens:W})}return O.sort((q,$)=>$.cost-q.cost||$.inputTokens+$.outputTokens-(q.inputTokens+q.outputTokens)).slice(0,12)},[e,e.lastSeq]),k=N.total>0,E=_.in+_.out,C=w.filter(O=>O.cost.total>0||O.inputTokens+O.outputTokens>0),I=S.filter(O=>O.cost>0||O.inputTokens+O.outputTokens>0),P=C.some(O=>!O.priced),A=l||h,H=Zx(o==null?void 0:o.fetchedAt,m),z=Zx(c==null?void 0:c.fetchedAt,m),L=()=>{u(),p()};return g.jsxs("div",{className:"usage-panel",id:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),b&&g.jsx("span",{className:"up-rate",children:b}),g.jsxs("div",{className:"up-header-right",children:[(r.claude||r.codex)&&g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:L,disabled:A,title:r.claude&&r.codex?"Refresh Claude + Codex quota":r.codex?"Refresh Codex quota":"Refresh Claude quota",children:A?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:i,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),r.claude&&g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",H&&!l&&g.jsx("span",{className:"up-section-age",title:B3(o==null?void 0:o.source),children:H})]}),o!=null&&o.ok?g.jsxs("div",{className:"up-quota-bars",children:[o.session5hPct!=null&&g.jsx(ri,{label:"5-hour window",pct:o.session5hPct,reset:o.session5hReset,resetAt:o.session5hResetAt,windowSec:o.session5hWindowSec,nowSec:m}),o.week7dPct!=null&&g.jsx(ri,{label:"7-day window",pct:o.week7dPct,reset:o.week7dReset,resetAt:o.week7dResetAt,windowSec:o.week7dWindowSec,nowSec:m}),o.weekSonnetPct!=null&&g.jsx(ri,{label:"Sonnet (7d)",pct:o.weekSonnetPct,nowSec:m}),o.weekOpusPct!=null&&g.jsx(ri,{label:"Opus (7d)",pct:o.weekOpusPct,nowSec:m})]}):(o==null?void 0:o.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsxs("span",{className:"up-quota-hint",children:["Run ",g.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),r.codex&&g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(c==null?void 0:c.ok)&&c.planLabel&&g.jsx("span",{className:"up-plan-badge",children:c.planLabel}),z&&!h&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:z})]}),c!=null&&c.ok?g.jsxs("div",{className:"up-quota-bars",children:[(F=c.windows)==null?void 0:F.map(O=>g.jsx(ri,{label:O.label,pct:O.pct,reset:O.reset??void 0,resetAt:O.resetAt??void 0,windowSec:O.windowSec??void 0,limitReached:c.limitReached&&O.pct>=100,nowSec:m},O.id)),(G=c.extraWindows)==null?void 0:G.map(O=>g.jsx(ri,{label:O.label,pct:O.pct,reset:O.reset??void 0,resetAt:O.resetAt??void 0,windowSec:O.windowSec??void 0,nowSec:m},O.id)),c.creditLimit&&g.jsx(ri,{label:`spend cap · $${Math.round(c.creditLimit.used)} of $${Math.round(c.creditLimit.limit)}`,pct:c.creditLimit.usedPct,reset:c.creditLimit.reset??void 0,resetAt:c.creditLimit.resetAt??void 0,limitReached:c.spendControlReached,nowSec:m}),c.creditsBalance&&!c.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",c.creditsBalance,c.overageReached&&" · overage limit reached"]}),c.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),c.resetCredits&&c.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${en} only reports them`,children:[c.resetCredits.availableCount," rate-limit reset",c.resetCredits.availableCount!==1?"s":""," available",c.resetCredits.nextExpiryAt&&` · expires ${new Date(c.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),c.promo&&g.jsx("div",{className:"up-quota-sub",children:c.promo}),c.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(c==null?void 0:c.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:Y3(c.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(d==null?void 0:d.ok)&&d.window7d&&d.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${d.window5h?`
63
- last 5h: ${$t(d.window5h.totalTokens)} tokens · ${d.window5h.sessionCount} session${d.window5h.sessionCount!==1?"s":""}`:""}`,children:[$t(d.window7d.totalTokens)," tokens · ",d.window7d.sessionCount," session",d.window7d.sessionCount!==1?"s":""," (7d)"]})]}),E>0?g.jsxs(g.Fragment,{children:[k&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:ze(N.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(U3,{cost:N})]}),g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),$t(_.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),$t(_.out)]}),_.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),$t(_.cacheR)]}),_.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),$t(_.cacheC)]})]}),C.length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:C.map(O=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:O.model===Bd?"no model reported yet":O.model,children:O.model===Bd?"unknown":di(O.model)}),g.jsx("td",{className:"up-num",children:$t(O.inputTokens+O.outputTokens)}),O.priced?g.jsx("td",{className:"up-num up-cost-val",children:ze(O.cost.total)}):g.jsx("td",{className:"up-num up-unpriced",children:du})]},O.model))})]})]}),I.length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:I.map(O=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${O.state}`,"aria-hidden":!0}),g.jsx("span",{className:"vis-hidden",children:ny(O.state)}),g.jsx("span",{className:"up-session-label",children:O.label}),g.jsx("span",{className:"up-session-tokens",children:$t(O.inputTokens+O.outputTokens)}),O.cost>0?g.jsxs("span",{className:"up-session-cost",title:O.unpricedTokens>0?`${$t(O.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[ze(O.cost),O.unpricedTokens>0?"+":""]}):g.jsx("span",{className:"up-session-cost up-unpriced",children:du})]},O.sessionId))})]}),P&&g.jsxs("div",{className:"up-hint",children:["“",du,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const Jx=18,Z3=1100,Ji=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},J3=Array.from({length:Jx},(e,n)=>{const r=-72+144*n/(Jx-1)+(Ji(n,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Ji(n,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(n%2?1:-1)*(100+Ji(n,3)*260),delay:Math.round(Ji(n,4)*90),dur:760+Math.round(Ji(n,5)*260),scale:.8+Ji(n,6)*.45,hue:n%4,round:n%3===0}});function e_({anchor:e,lifetimeMs:n=Z3}){var l;const[r,i]=R.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return R.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();i({x:c.left+c.width/2,y:c.top+c.height/2});const h=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(h)},[e,n,o]),o||!r?null:zI.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:J3.map((u,c)=>g.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const NC=new Set(["awaiting_url","awaiting_code","registering"]);function eL(e){return e!=null&&NC.has(e)}function CC(e){return e!=null&&e!=="done"&&!NC.has(e)}const tL="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",nL="the sign-in did not complete";function rL({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?tL:nL)}}const sL="done";function iL(){let e=!1;return{shouldAnnounce(n){return n!==sL?(e=!1,!1):e?!1:(e=!0,!0)}}}const t_={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${en}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters"},n_={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},oL=`claude-swap could not read the login keychain — start ${en} from a Terminal window rather than a background service`;function Rv(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ho(e))?oL:e!=null&&e.reason&&n_[e.reason]?n_[e.reason]:(e==null?void 0:e.reason)||n}function ho(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const r_={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},aL="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function lL(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}function uL(e,n){return lL(ho(e))?aL:e!=null&&e.reason&&r_[e.reason]?r_[e.reason]:(e==null?void 0:e.reason)||n}function fu(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&CC(e.state)?e.error:e!=null&&e.reason&&t_[e.reason]?t_[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const cL=1500;async function tu(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const jv=ue.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));jv.displayName="SuccessMark";function dL({onClose:e,onChanged:n}){const[r,i]=R.useState("login"),[o,l]=R.useState(null),[u,c]=R.useState(""),[h,p]=R.useState(""),[d,m]=R.useState(!1),[y,w]=R.useState(null),[N,_]=R.useState(null),b=R.useRef(!1),S=R.useRef(null),k=R.useRef(null),E=R.useRef(null),C=R.useRef(null),I=R.useCallback(()=>{b.current&&tu({action:"login-cancel"}).catch(()=>{}),e()},[e]),P=mo(I,{focusRef:E}),A=R.useCallback(async()=>{m(!0),w(null),b.current=!0;const q=await tu({action:"login"}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){w(fu(q,"could not start the sign-in"));return}l(q)},[]);R.useEffect(()=>{if(!eL(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const $=await fetch("/api/claude-accounts/login");$.ok&&l(await $.json())}catch{}},cL);return()=>window.clearInterval(q)},[o]);const H=R.useRef(n);H.current=n;const z=R.useRef(iL());R.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=S.current)==null||q.focus()),z.current.shouldAnnounce(o==null?void 0:o.state)&&H.current()},[o==null?void 0:o.state]),R.useEffect(()=>{var q;r==="paste"&&((q=k.current)==null||q.focus())},[r]);const L=R.useCallback(async()=>{var $;m(!0),w(null);const q=await tu({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){w(fu(q,"the code was not accepted")),q!=null&&q.state&&l(q),($=S.current)==null||$.select();return}c(""),l(q)},[u,o]),F=R.useCallback(async()=>{m(!0),w(null);const q=await tu({action:"import",blob:h}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){w(fu(q,"the import failed"));return}p(""),_({added:q.added===!0,num:q.num??null,email:q.email??null}),n()},[h,n]),G=(o==null?void 0:o.state)==="done"?o.account:null,O=CC(o==null?void 0:o.state)||!!(y&&b.current&&!d),j=rL({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:I,role:"presentation",children:g.jsxs("div",{ref:P,className:"modal aa-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:I,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?G?g.jsxs("div",{className:"aa-done",children:[g.jsx(jv,{ref:C}),g.jsx(e_,{anchor:C}),g.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:G.email}),G.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:S,type:"text",value:u,onChange:q=>c(q.target.value),onKeyDown:q=>{q.key==="Enter"&&u.trim()&&!d&&L()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:d||!u.trim()||o.state==="registering",onClick:L,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):O?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:j.title}),g.jsx("p",{className:"aa-err",children:j.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,l(null),w(null),A()},children:"Try again"})]}):d||b.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",ref:E,className:"btn primary",onClick:A,disabled:d,children:"Open the sign-in page"})})]}):N?g.jsxs("div",{className:"aa-done",children:[g.jsx(jv,{ref:C}),N.added&&g.jsx(e_,{anchor:C}),g.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:N.added?g.jsxs(g.Fragment,{children:[N.email?g.jsx("strong",{children:N.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:k,type:"text",value:h,onChange:q=>p(q.target.value),onKeyDown:q=>{q.key==="Enter"&&h.trim()&&!d&&F()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:d||!h.trim(),onClick:F,children:d?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}function fL(e,n){const r=new Set(e),i=e.length?Math.max(...e):0;return[...new Set([...e,i+1])].sort((o,l)=>o-l).map(o=>{const l=o===n?"here":r.has(o)?"swap":"free";return{slot:o,kind:l,label:l==="here"?`slot ${o}`:`slot ${o} · ${l}`}})}function hL(e,n,r){if(!(r!=null&&r.ok))return null;const i=Number.isInteger(r.to)?r.to:null;if(i==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const o=r.swapped===!0&&i!==n;return{menuFor:e.menuFor===n?i:o&&e.menuFor===i?n:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:i,displaced:n}:null}}const pL=64;function mL(e,n){const r=e.trim();return{alias:r,commit:r!==(n??"").trim()}}const gL=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function s_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function vL(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=ho(n.body);return{text:Rv(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function i_(e,n){return n?e!=null&&e.reload&&e.text===n.text&&e.raw===n.raw?e:n:e!=null&&e.reload?null:e}const o_=15e3,yL=8e3,wL=1800,xL=3e4,_L=[70,80,85,90,95];function bL(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function a_(e,n){const r=n-Math.floor(e/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function SL(e,n){if(!e)return"";const r=Math.floor(e/1e3)-n;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function kL(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function EL({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?bL(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function NL(e){var r;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(i=>window.setTimeout(()=>i(!1),500))])}catch{n=!1}if(n)return!0;try{const i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(i),i.select(),n=document.execCommand("copy"),i.remove()}catch{n=!1}return n}function CL(e,n){const r=Math.round(e/1e3)-n;return r<=0?{text:"expired",tone:"gone"}:r<60?{text:`expires in ${r}s`,tone:"soon"}:{text:`expires in ${Math.round(r/60)}m`,tone:"ok"}}function TL({onClose:e}){var ne,le,fe;const[n,r]=R.useState(null),[i,o]=R.useState(null),[l,u]=R.useState(null),[c,h]=R.useState(!1),[p,d]=R.useState(null),[m,y]=R.useState(null),[w,N]=R.useState(()=>Math.floor(Date.now()/1e3)),_=R.useRef(null),[b,S]=R.useState(null),[k,E]=R.useState(!1),[C,I]=R.useState(""),[P,A]=R.useState(null),[H,z]=R.useState(null),[L,F]=R.useState(null),[G,O]=R.useState(!1),[j,q]=R.useState(null),$=R.useCallback(async(te=!1)=>{te&&h(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),xL);try{const[ve,je]=await Promise.all([fetch(`/api/claude-accounts${te?"?refresh=1":""}`,{signal:ce.signal}),fetch("/api/cswap-auto",{signal:ce.signal})]);ve.ok&&r(await ve.json()),je.ok&&o(await je.json());const ye=vL([await s_(ve),await s_(je)]);y(ke=>i_(ke,ye))}catch{y(ve=>i_(ve,gL))}finally{window.clearTimeout(Ce),te&&h(!1)}},[]),re=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:Rv(ve,"command failed"),raw:ho(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),J=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:fu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);R.useEffect(()=>($(!0),_.current=window.setInterval(()=>$(!1),o_),()=>{_.current!=null&&window.clearInterval(_.current)}),[$]),R.useEffect(()=>{const te=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const W=((ne=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:ne.value)??"90",Z=(le=n==null?void 0:n.accounts)==null?void 0:le.find(te=>te.active),M=Z!=null&&Z.lanes.length?Math.max(...Z.lanes.map(te=>te.pct)):null,Y=M!=null&&M>=Number(W)-15,U=async te=>{d(te),y(null);try{const Ce=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:te})})).json().catch(()=>null);Ce!=null&&Ce.ok||y({text:Rv(Ce,"the switch failed"),raw:ho(Ce)}),await $(!0)}catch{y({text:"server unreachable"})}finally{d(null)}},B=async(te,ce)=>{const{commit:Ce,alias:ve}=mL(C,ce);if(Ce){const je=await J({action:"alias",account:te,alias:ve},`alias-${te}`);if(await $(!0),!(je!=null&&je.ok))return;I(ve)}A(te),window.setTimeout(()=>A(je=>je===te?null:je),wL)},X=async(te,ce)=>{const Ce=await J({action:"move",account:te,slot:ce},`move-${te}`),ve=hL({menuFor:b,shareFor:(L==null?void 0:L.num)??null},te,Ce);if(await $(!0),ve){S(ve.menuFor),z(ve.confirmRemove),ve.shareFor==null&&(F(null),O(!1)),q(ve.swapNote);const je=ve.swapNote;je&&window.setTimeout(()=>q(ye=>ye===je?null:ye),yL)}};return g.jsxs("div",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>E(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>$(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?m?g.jsxs("div",{className:"ap-empty",role:"alert",children:[g.jsx("span",{title:m.raw||void 0,children:m.text}),g.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",o_/1e3," seconds."]}),g.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>$(!0),children:c?"trying…":"try again"})]}):g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(fe=n.accounts)==null?void 0:fe.map(te=>g.jsxs("div",{className:`ap-account${te.active?" active":""}${te.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:te.num}),te.alias&&g.jsx("span",{className:"ap-alias",title:te.alias,children:te.alias}),g.jsx("span",{className:"ap-email",title:te.org??void 0,children:te.email}),g.jsx("button",{type:"button",className:`ap-more${b===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":b===te.num,"aria-controls":b===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(b===te.num?null:te.num),I(te.alias??""),z(null),F(null),O(!1),q(null),A(null)},children:"⋯"}),te.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:p!=null||te.disabled,onClick:()=>U(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:p===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>g.jsx(EL,{lane:ce,nowSec:w},ce.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=kL(te.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:ce.hint,children:ce.text}),ce.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>E(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!te.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>re({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>$(!0)),title:te.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:te.disabled?"held out":"in rotation"}),te.fetchedAt?g.jsxs("span",{className:`ap-age${te.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",a_(te.fetchedAt,w),SL(te.nextAt,w)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),b===te.num&&g.jsxs("div",{className:"ap-manage",id:`ap-manage-${te.num}`,role:"group","aria-label":`Manage account ${te.num}`,children:[g.jsxs("div",{className:"ap-manage-name",children:[g.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),g.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:C,onChange:ce=>I(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&B(te.num,te.alias)},maxLength:pL,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:()=>B(te.num,te.alias),title:"A short name to show instead of the email",children:P===te.num?"saved":"save"})]}),g.jsxs("div",{className:"ap-manage-acts",children:[g.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${te.num}`,children:"Slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{id:`ap-slot-${te.num}`,value:String(te.num),disabled:l!=null,onChange:ce=>X(te.num,Number(ce.target.value)),children:fL((n.accounts??[]).map(ce=>ce.num),te.num).map(ce=>g.jsx("option",{value:ce.slot,children:ce.label},ce.slot))})}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:`Copy this account to another ${en}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{O(!1);const ce=await J({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&F({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${H===te.num?" armed":""}`,disabled:l!=null,title:H===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(H!==te.num){z(te.num),window.setTimeout(()=>z(ce=>ce===te.num?null:ce),4e3);return}z(null),J({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{S(null),$(!0)})},children:H===te.num?"confirm":"remove"})]}),(j==null?void 0:j.at)===te.num&&(()=>{var ve;const ce=(ve=n.accounts)==null?void 0:ve.find(je=>je.num===j.displaced),Ce=(ce==null?void 0:ce.alias)??(ce==null?void 0:ce.email)??"the account that was there";return g.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${j.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${j.displaced}.`,children:["swapped with slot ",j.displaced]})})(),(L==null?void 0:L.num)===te.num&&(()=>{const ce=CL(L.expiresAt,w),Ce=ce.tone==="gone";return g.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:L.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Ce){O(!1);const ve=await J({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&F({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await NL(L.blob)&&(O(!0),window.setTimeout(()=>O(!1),1800))},children:Ce?"make a new share":G?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[g.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",g.jsx("span",{className:`ap-share-expiry ${ce.tone}`,children:ce.text})]})]})]})})()]})]},te.num)),(i==null?void 0:i.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[M!=null&&g.jsxs("span",{className:`ap-auto-now${Y?" near":""}`,children:[Math.round(M),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:W,disabled:l!=null,onChange:te=>re({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>$(!0)),children:_L.map(te=>g.jsxs("option",{value:te,children:[te,"%"]},te))})}),g.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:l!=null,onClick:()=>re({action:"enable",enabled:!i.enabled},"enable").then(()=>$(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",i.enabled?" — this toggle takes over when you stop it.":"."]}),i.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",a_(i.lastTick.at,w)]})})]}),m&&g.jsxs("div",{className:"ap-failure",role:"alert",children:[g.jsx("span",{className:"ap-failure-text",title:m.raw||void 0,children:m.text}),g.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),k&&g.jsx(dL,{onClose:()=>E(!1),onChanged:()=>$(!0)})]})}const RL=3e4;function jL({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function AL({bundle:e,running:n,pending:r,lastTried:i}){return n?jL({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function IL(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function ML({asked:e,reported:n}){return n?n!==e:!1}function OL(e){const n=e.thresholdMs??RL;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=n}}function PL({agentCount:e,onConfirm:n,onCancel:r}){const i=R.useRef(null),o=mo(r,{focusRef:i,layer:CP}),l=e===0?"This deletes the server's event log":`This removes ${e===1?"the one agent":`all ${e} agents`} on the canvas and deletes the server's event log`;return g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"status-dot err","aria-hidden":!0}),g.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("p",{className:"modal-note",children:[l," — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone."]}),g.jsxs("div",{className:"cc-actions",children:[g.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),g.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function LL(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function qL(e){return e.slice().sort((n,r)=>n.y-r.y||n.x-r.x)}function $L(e,n,r){var u;if(e.length===0)return null;const i=qL(e),o=n?i.findIndex(c=>c.id===n):-1,l=o===-1?r===1?0:i.length-1:(o+r+i.length)%i.length;return((u=i[l])==null?void 0:u.id)??null}const DL=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function FL(e,n){return n==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:n,additive:e.shiftKey}:DL.has(e.key)?{kind:"node",nodeId:n}:{kind:"deck",nodeId:n}}const zL=new Set(["","BODY","HTML","#DOCUMENT"]);function BL(e){return!e||ty(e)?!1:!zL.has(String(e.tagName??"").toUpperCase())}function nu(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function UL(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function TC(e,n,r){return!n.has(e)||r.has(e)}function HL(e,n,r,i){return!n.has(e)&&TC(e,r,i)}function WL(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function VL(e,n,r,i){r.set(e,n),i.delete(e)}const GL=40,YL=120;function KL(e,n){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(h,p,d)=>{if(r!=null){if(i<=h)return;u()}const m=Math.min(d,Math.max(0,h-p));i=h,r=n.setTimeout(l,m)};return{live(h=GL){const p=n.now(),d=Math.max(o+h,p);if(d<=p){u(),l();return}c(d,p,h)},replay(h=YL){u(),i=n.now()+h,r=n.setTimeout(l,h)},flush(){u(),l()},cancel(){u()}}}function XL(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const i=n;return n=[],i}}}const QL="1",l_="agent-dag.schema",ZL=["agent-dag.layout","agent-dag.viewport"];function RC(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function JL(e,n=QL){let r=null;try{r=e.getItem(l_)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of ZL)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(l_,n)}catch{}return i}const jC="agent-dag.theme";function eq(e){return e==="light"?"light":"dark"}function tq(){return eq(RC(jC))}function nq({waiting:e,running:n}){return{title:e>0?`(${e}) ${en}`:en,icon:e>0?"waiting":n>0?"running":"idle"}}const Ud={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Hd(e,n){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${n==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"/>`+(n==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const rq=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Hd(Ud.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Hd(Ud.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Hd(Ud.idle,"idle"))}`}),sq="No sessions are waiting for you.";function iq(e){if(e.length===0)return"";const[n,...r]=e;if(r.length===0)return`${n.label} is waiting for your permission.`;const i=`${r.length} more session${r.length===1?"":"s"}`;return`${n.label} and ${i} are waiting for your permission.`}function oq(e,n){return n!==""?n:e===""?"":sq}function aq(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function lq(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function uq(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function ru(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}const cq=[7,14,30,90];function dq(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(aq()).current,u=(c=!1)=>{const h=l.begin(),p=e;o(!0);const m=`/api/ccusage?since=${lq(p)}${c?"&refresh=1":""}`;fetch(m).then(y=>y.json()).then(y=>{h()&&r({range:p,resp:y})}).catch(()=>{h()&&r({range:p,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{h()&&o(!1)})};return R.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function fq({onClose:e}){var C,I,P;const[n,r]=R.useState(30),[i,o]=R.useState(null),{landed:l,loading:u,reload:c}=dq(n),h=R.useRef(null),p=mo(e,{focusRef:h}),d=uq({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((C=l.resp.days)==null?void 0:C.length)??0}}),m=d.phase==="chart"?l.resp.days??[]:[],y=R.useMemo(()=>m.reduce((A,H)=>Math.max(A,H.totalCost),0),[m]),{totalCost:w,totalTok:N,inOut:_,cacheRead:b,modelCosts:S}=R.useMemo(()=>{let A=0,H=0,z=0,L=0;const F=new Map;for(const G of m){A+=G.totalCost,H+=G.totalTokens,z+=G.inputTokens+G.outputTokens,L+=G.cacheReadTokens;for(const O of G.modelBreakdowns)F.set(O.modelName,(F.get(O.modelName)??0)+O.cost)}return{totalCost:A,totalTok:H,inOut:z,cacheRead:L,modelCosts:F}},[m]),k=R.useMemo(()=>Array.from(S.entries()).sort((A,H)=>H[1]-A[1]),[S]),E=i?m.find(A=>A.period===i)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{ref:p,className:"uh-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:cq.map(A=>g.jsxs("button",{role:"tab","aria-selected":n===A,className:`uh-range-btn${n===A?" on":""}`,onClick:()=>{r(A),o(null)},children:[A,"d"]},A))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,disabled:u,title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),g.jsx("button",{ref:h,className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),d.phase==="busy"?g.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):d.phase==="error"?g.jsxs("div",{className:"uh-status uh-err",title:ho(l.resp)||void 0,children:[uL(l.resp,"ccusage did not report usage"),g.jsx("div",{children:g.jsx("button",{className:"btn uh-retry",onClick:c,disabled:u,children:u?"trying…":"Try again"})})]}):d.phase==="empty"?g.jsx("div",{className:`uh-status${d.stale?" uh-stale":""}`,"aria-busy":d.stale||void 0,children:"no usage in this range"}):g.jsxs("div",{className:d.stale?"uh-stale":void 0,"aria-busy":d.stale||void 0,children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(su,{label:"total cost",val:ze(w),accent:!0}),g.jsx(su,{label:"tokens",val:$t(N)}),g.jsx(su,{label:"input+output",val:$t(_)}),g.jsx(su,{label:"cache reads",val:$t(b)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:m.map(A=>{const H=y>0?A.totalCost/y*100:0,z=A.period===i;return g.jsxs("button",{className:`uh-bar-col${z?" sel":""}`,onClick:()=>o(z?null:A.period),title:`${A.period} · ${ze(A.totalCost)}`,style:{flexBasis:`${100/m.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(H,A.totalCost>0?2:0)}%`},children:A.modelBreakdowns.slice().sort((L,F)=>F.cost-L.cost).map(L=>{const F=A.totalCost>0?L.cost/A.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${F}%`,background:ru(L.modelName)}},L.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:A.period.slice(5)})]},A.period)})}),g.jsx("div",{className:"uh-legend",children:k.map(([A,H])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:ru(A)}}),di(A)," ",g.jsx("span",{className:"uh-legend-cost",children:ze(H)})]},A))}),E&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:E.period}),g.jsx("span",{className:"uh-detail-cost",children:ze(E.totalCost)}),(P=(I=E.metadata)==null?void 0:I.agents)!=null&&P.length?g.jsx("span",{className:"uh-detail-agents",children:E.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(iu,{label:"input",val:$t(E.inputTokens)}),g.jsx(iu,{label:"output",val:$t(E.outputTokens)}),g.jsx(iu,{label:"cache write",val:$t(E.cacheCreationTokens)}),g.jsx(iu,{label:"cache read",val:$t(E.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:E.modelBreakdowns.slice().sort((A,H)=>H.cost-A.cost).map(A=>{const H=E.totalCost>0?A.cost/E.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:ru(A.modelName)}}),di(A.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${H}%`,background:ru(A.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:ze(A.cost)})]},A.modelName)})})]})]})]})})}function su({label:e,val:n,accent:r}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function iu({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function sy(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Wd,u_;function hq(){if(u_)return Wd;u_=1;function e(){this.__data__=[],this.size=0}return Wd=e,Wd}var Vd,c_;function go(){if(c_)return Vd;c_=1;function e(n,r){return n===r||n!==n&&r!==r}return Vd=e,Vd}var Gd,d_;function Pu(){if(d_)return Gd;d_=1;var e=go();function n(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return Gd=n,Gd}var Yd,f_;function pq(){if(f_)return Yd;f_=1;var e=Pu(),n=Array.prototype,r=n.splice;function i(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return Yd=i,Yd}var Kd,h_;function mq(){if(h_)return Kd;h_=1;var e=Pu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Kd=n,Kd}var Xd,p_;function gq(){if(p_)return Xd;p_=1;var e=Pu();function n(r){return e(this.__data__,r)>-1}return Xd=n,Xd}var Qd,m_;function vq(){if(m_)return Qd;m_=1;var e=Pu();function n(r,i){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,i])):o[l][1]=i,this}return Qd=n,Qd}var Zd,g_;function Lu(){if(g_)return Zd;g_=1;var e=hq(),n=pq(),r=mq(),i=gq(),o=vq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Zd=l,Zd}var Jd,v_;function yq(){if(v_)return Jd;v_=1;var e=Lu();function n(){this.__data__=new e,this.size=0}return Jd=n,Jd}var ef,y_;function wq(){if(y_)return ef;y_=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return ef=e,ef}var tf,w_;function xq(){if(w_)return tf;w_=1;function e(n){return this.__data__.get(n)}return tf=e,tf}var nf,x_;function _q(){if(x_)return nf;x_=1;function e(n){return this.__data__.has(n)}return nf=e,nf}var rf,__;function AC(){if(__)return rf;__=1;var e=typeof Bl=="object"&&Bl&&Bl.Object===Object&&Bl;return rf=e,rf}var sf,b_;function sr(){if(b_)return sf;b_=1;var e=AC(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return sf=r,sf}var of,S_;function vo(){if(S_)return of;S_=1;var e=sr(),n=e.Symbol;return of=n,of}var af,k_;function bq(){if(k_)return af;k_=1;var e=vo(),n=Object.prototype,r=n.hasOwnProperty,i=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),h=u[o];try{u[o]=void 0;var p=!0}catch{}var d=i.call(u);return p&&(c?u[o]=h:delete u[o]),d}return af=l,af}var lf,E_;function Sq(){if(E_)return lf;E_=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return lf=r,lf}var uf,N_;function fi(){if(N_)return uf;N_=1;var e=vo(),n=bq(),r=Sq(),i="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:l&&l in Object(c)?n(c):r(c)}return uf=u,uf}var cf,C_;function $n(){if(C_)return cf;C_=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return cf=e,cf}var df,T_;function ja(){if(T_)return df;T_=1;var e=fi(),n=$n(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var h=e(c);return h==i||h==o||h==r||h==l}return df=u,df}var ff,R_;function kq(){if(R_)return ff;R_=1;var e=sr(),n=e["__core-js_shared__"];return ff=n,ff}var hf,j_;function Eq(){if(j_)return hf;j_=1;var e=kq(),n=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!n&&n in i}return hf=r,hf}var pf,A_;function IC(){if(A_)return pf;A_=1;var e=Function.prototype,n=e.toString;function r(i){if(i!=null){try{return n.call(i)}catch{}try{return i+""}catch{}}return""}return pf=r,pf}var mf,I_;function Nq(){if(I_)return mf;I_=1;var e=ja(),n=Eq(),r=$n(),i=IC(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,h=u.toString,p=c.hasOwnProperty,d=RegExp("^"+h.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var w=e(y)?d:l;return w.test(i(y))}return mf=m,mf}var gf,M_;function Cq(){if(M_)return gf;M_=1;function e(n,r){return n==null?void 0:n[r]}return gf=e,gf}var vf,O_;function hi(){if(O_)return vf;O_=1;var e=Nq(),n=Cq();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return vf=r,vf}var yf,P_;function iy(){if(P_)return yf;P_=1;var e=hi(),n=sr(),r=e(n,"Map");return yf=r,yf}var wf,L_;function qu(){if(L_)return wf;L_=1;var e=hi(),n=e(Object,"create");return wf=n,wf}var xf,q_;function Tq(){if(q_)return xf;q_=1;var e=qu();function n(){this.__data__=e?e(null):{},this.size=0}return xf=n,xf}var _f,$_;function Rq(){if($_)return _f;$_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return _f=e,_f}var bf,D_;function jq(){if(D_)return bf;D_=1;var e=qu(),n="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return i.call(u,l)?u[l]:void 0}return bf=o,bf}var Sf,F_;function Aq(){if(F_)return Sf;F_=1;var e=qu(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Sf=i,Sf}var kf,z_;function Iq(){if(z_)return kf;z_=1;var e=qu(),n="__lodash_hash_undefined__";function r(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=e&&o===void 0?n:o,this}return kf=r,kf}var Ef,B_;function Mq(){if(B_)return Ef;B_=1;var e=Tq(),n=Rq(),r=jq(),i=Aq(),o=Iq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Ef=l,Ef}var Nf,U_;function Oq(){if(U_)return Nf;U_=1;var e=Mq(),n=Lu(),r=iy();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Nf=i,Nf}var Cf,H_;function Pq(){if(H_)return Cf;H_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Cf=e,Cf}var Tf,W_;function $u(){if(W_)return Tf;W_=1;var e=Pq();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return Tf=n,Tf}var Rf,V_;function Lq(){if(V_)return Rf;V_=1;var e=$u();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return Rf=n,Rf}var jf,G_;function qq(){if(G_)return jf;G_=1;var e=$u();function n(r){return e(this,r).get(r)}return jf=n,jf}var Af,Y_;function $q(){if(Y_)return Af;Y_=1;var e=$u();function n(r){return e(this,r).has(r)}return Af=n,Af}var If,K_;function Dq(){if(K_)return If;K_=1;var e=$u();function n(r,i){var o=e(this,r),l=o.size;return o.set(r,i),this.size+=o.size==l?0:1,this}return If=n,If}var Mf,X_;function oy(){if(X_)return Mf;X_=1;var e=Oq(),n=Lq(),r=qq(),i=$q(),o=Dq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Mf=l,Mf}var Of,Q_;function Fq(){if(Q_)return Of;Q_=1;var e=Lu(),n=iy(),r=oy(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var h=c.__data__;if(!n||h.length<i-1)return h.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(h)}return c.set(l,u),this.size=c.size,this}return Of=o,Of}var Pf,Z_;function Du(){if(Z_)return Pf;Z_=1;var e=Lu(),n=yq(),r=wq(),i=xq(),o=_q(),l=Fq();function u(c){var h=this.__data__=new e(c);this.size=h.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=l,Pf=u,Pf}var Lf,J_;function ay(){if(J_)return Lf;J_=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o&&r(n[i],i,n)!==!1;);return n}return Lf=e,Lf}var qf,e1;function MC(){if(e1)return qf;e1=1;var e=hi(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return qf=n,qf}var $f,t1;function Fu(){if(t1)return $f;t1=1;var e=MC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return $f=n,$f}var Df,n1;function zu(){if(n1)return Df;n1=1;var e=Fu(),n=go(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var h=l[u];(!(i.call(l,u)&&n(h,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Df=o,Df}var Ff,r1;function Aa(){if(r1)return Ff;r1=1;var e=zu(),n=Fu();function r(i,o,l,u){var c=!l;l||(l={});for(var h=-1,p=o.length;++h<p;){var d=o[h],m=u?u(l[d],i[d],d,l,i):void 0;m===void 0&&(m=i[d]),c?n(l,d,m):e(l,d,m)}return l}return Ff=r,Ff}var zf,s1;function zq(){if(s1)return zf;s1=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return zf=e,zf}var Bf,i1;function mr(){if(i1)return Bf;i1=1;function e(n){return n!=null&&typeof n=="object"}return Bf=e,Bf}var Uf,o1;function Bq(){if(o1)return Uf;o1=1;var e=fi(),n=mr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return Uf=i,Uf}var Hf,a1;function Ia(){if(a1)return Hf;a1=1;var e=Bq(),n=mr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return Hf=l,Hf}var Wf,l1;function bt(){if(l1)return Wf;l1=1;var e=Array.isArray;return Wf=e,Wf}var ca={exports:{}},Vf,u1;function Uq(){if(u1)return Vf;u1=1;function e(){return!1}return Vf=e,Vf}ca.exports;var c1;function yo(){return c1||(c1=1,(function(e,n){var r=sr(),i=Uq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,h=c?c.isBuffer:void 0,p=h||i;e.exports=p})(ca,ca.exports)),ca.exports}var Gf,d1;function Bu(){if(d1)return Gf;d1=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(i,o){var l=typeof i;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(i))&&i>-1&&i%1==0&&i<o}return Gf=r,Gf}var Yf,f1;function ly(){if(f1)return Yf;f1=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Yf=n,Yf}var Kf,h1;function Hq(){if(h1)return Kf;h1=1;var e=fi(),n=ly(),r=mr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",h="[object Function]",p="[object Map]",d="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",N="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",P="[object Int32Array]",A="[object Uint8Array]",H="[object Uint8ClampedArray]",z="[object Uint16Array]",L="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[I]=F[P]=F[A]=F[H]=F[z]=F[L]=!0,F[i]=F[o]=F[b]=F[l]=F[S]=F[u]=F[c]=F[h]=F[p]=F[d]=F[m]=F[y]=F[w]=F[N]=F[_]=!1;function G(O){return r(O)&&n(O.length)&&!!F[e(O)]}return Kf=G,Kf}var Xf,p1;function Uu(){if(p1)return Xf;p1=1;function e(n){return function(r){return n(r)}}return Xf=e,Xf}var da={exports:{}};da.exports;var m1;function uy(){return m1||(m1=1,(function(e,n){var r=AC(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l&&r.process,c=(function(){try{var h=o&&o.require&&o.require("util").types;return h||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(da,da.exports)),da.exports}var Qf,g1;function Ma(){if(g1)return Qf;g1=1;var e=Hq(),n=Uu(),r=uy(),i=r&&r.isTypedArray,o=i?n(i):e;return Qf=o,Qf}var Zf,v1;function OC(){if(v1)return Zf;v1=1;var e=zq(),n=Ia(),r=bt(),i=yo(),o=Bu(),l=Ma(),u=Object.prototype,c=u.hasOwnProperty;function h(p,d){var m=r(p),y=!m&&n(p),w=!m&&!y&&i(p),N=!m&&!y&&!w&&l(p),_=m||y||w||N,b=_?e(p.length,String):[],S=b.length;for(var k in p)(d||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return Zf=h,Zf}var Jf,y1;function Hu(){if(y1)return Jf;y1=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return Jf=n,Jf}var eh,w1;function PC(){if(w1)return eh;w1=1;function e(n,r){return function(i){return n(r(i))}}return eh=e,eh}var th,x1;function Wq(){if(x1)return th;x1=1;var e=PC(),n=e(Object.keys,Object);return th=n,th}var nh,_1;function cy(){if(_1)return nh;_1=1;var e=Hu(),n=Wq(),r=Object.prototype,i=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))i.call(l,c)&&c!="constructor"&&u.push(c);return u}return nh=o,nh}var rh,b1;function Ur(){if(b1)return rh;b1=1;var e=ja(),n=ly();function r(i){return i!=null&&n(i.length)&&!e(i)}return rh=r,rh}var sh,S1;function Ns(){if(S1)return sh;S1=1;var e=OC(),n=cy(),r=Ur();function i(o){return r(o)?e(o):n(o)}return sh=i,sh}var ih,k1;function Vq(){if(k1)return ih;k1=1;var e=Aa(),n=Ns();function r(i,o){return i&&e(o,n(o),i)}return ih=r,ih}var oh,E1;function Gq(){if(E1)return oh;E1=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return oh=e,oh}var ah,N1;function Yq(){if(N1)return ah;N1=1;var e=$n(),n=Hu(),r=Gq(),i=Object.prototype,o=i.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),h=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||h.push(p);return h}return ah=l,ah}var lh,C1;function pi(){if(C1)return lh;C1=1;var e=OC(),n=Yq(),r=Ur();function i(o){return r(o)?e(o,!0):n(o)}return lh=i,lh}var uh,T1;function Kq(){if(T1)return uh;T1=1;var e=Aa(),n=pi();function r(i,o){return i&&e(o,n(o),i)}return uh=r,uh}var fa={exports:{}};fa.exports;var R1;function LC(){return R1||(R1=1,(function(e,n){var r=sr(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function h(p,d){if(d)return p.slice();var m=p.length,y=c?c(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(fa,fa.exports)),fa.exports}var ch,j1;function qC(){if(j1)return ch;j1=1;function e(n,r){var i=-1,o=n.length;for(r||(r=Array(o));++i<o;)r[i]=n[i];return r}return ch=e,ch}var dh,A1;function $C(){if(A1)return dh;A1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=0,u=[];++i<o;){var c=n[i];r(c,i,n)&&(u[l++]=c)}return u}return dh=e,dh}var fh,I1;function DC(){if(I1)return fh;I1=1;function e(){return[]}return fh=e,fh}var hh,M1;function dy(){if(M1)return hh;M1=1;var e=$C(),n=DC(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:n;return hh=l,hh}var ph,O1;function Xq(){if(O1)return ph;O1=1;var e=Aa(),n=dy();function r(i,o){return e(i,n(i),o)}return ph=r,ph}var mh,P1;function fy(){if(P1)return mh;P1=1;function e(n,r){for(var i=-1,o=r.length,l=n.length;++i<o;)n[l+i]=r[i];return n}return mh=e,mh}var gh,L1;function Wu(){if(L1)return gh;L1=1;var e=PC(),n=e(Object.getPrototypeOf,Object);return gh=n,gh}var vh,q1;function FC(){if(q1)return vh;q1=1;var e=fy(),n=Wu(),r=dy(),i=DC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return vh=l,vh}var yh,$1;function Qq(){if($1)return yh;$1=1;var e=Aa(),n=FC();function r(i,o){return e(i,n(i),o)}return yh=r,yh}var wh,D1;function zC(){if(D1)return wh;D1=1;var e=fy(),n=bt();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return wh=r,wh}var xh,F1;function BC(){if(F1)return xh;F1=1;var e=zC(),n=dy(),r=Ns();function i(o){return e(o,r,n)}return xh=i,xh}var _h,z1;function Zq(){if(z1)return _h;z1=1;var e=zC(),n=FC(),r=pi();function i(o){return e(o,r,n)}return _h=i,_h}var bh,B1;function Jq(){if(B1)return bh;B1=1;var e=hi(),n=sr(),r=e(n,"DataView");return bh=r,bh}var Sh,U1;function e$(){if(U1)return Sh;U1=1;var e=hi(),n=sr(),r=e(n,"Promise");return Sh=r,Sh}var kh,H1;function UC(){if(H1)return kh;H1=1;var e=hi(),n=sr(),r=e(n,"Set");return kh=r,kh}var Eh,W1;function t$(){if(W1)return Eh;W1=1;var e=hi(),n=sr(),r=e(n,"WeakMap");return Eh=r,Eh}var Nh,V1;function wo(){if(V1)return Nh;V1=1;var e=Jq(),n=iy(),r=e$(),i=UC(),o=t$(),l=fi(),u=IC(),c="[object Map]",h="[object Object]",p="[object Promise]",d="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),N=u(n),_=u(r),b=u(i),S=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=p||i&&k(new i)!=d||o&&k(new o)!=m)&&(k=function(E){var C=l(E),I=C==h?E.constructor:void 0,P=I?u(I):"";if(P)switch(P){case w:return y;case N:return c;case _:return p;case b:return d;case S:return m}return C}),Nh=k,Nh}var Ch,G1;function n$(){if(G1)return Ch;G1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&n.call(i,"index")&&(l.index=i.index,l.input=i.input),l}return Ch=r,Ch}var Th,Y1;function HC(){if(Y1)return Th;Y1=1;var e=sr(),n=e.Uint8Array;return Th=n,Th}var Rh,K1;function hy(){if(K1)return Rh;K1=1;var e=HC();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return Rh=n,Rh}var jh,X1;function r$(){if(X1)return jh;X1=1;var e=hy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return jh=n,jh}var Ah,Q1;function s$(){if(Q1)return Ah;Q1=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return Ah=n,Ah}var Ih,Z1;function i$(){if(Z1)return Ih;Z1=1;var e=vo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return Ih=i,Ih}var Mh,J1;function WC(){if(J1)return Mh;J1=1;var e=hy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Mh=n,Mh}var Oh,eb;function o$(){if(eb)return Oh;eb=1;var e=hy(),n=r$(),r=s$(),i=i$(),o=WC(),l="[object Boolean]",u="[object Date]",c="[object Map]",h="[object Number]",p="[object RegExp]",d="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",I="[object Uint8ClampedArray]",P="[object Uint16Array]",A="[object Uint32Array]";function H(z,L,F){var G=z.constructor;switch(L){case w:return e(z);case l:case u:return new G(+z);case N:return n(z,F);case _:case b:case S:case k:case E:case C:case I:case P:case A:return o(z,F);case c:return new G;case h:case m:return new G(z);case p:return r(z);case d:return new G;case y:return i(z)}}return Oh=H,Oh}var Ph,tb;function VC(){if(tb)return Ph;tb=1;var e=$n(),n=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(n)return n(o);i.prototype=o;var l=new i;return i.prototype=void 0,l}})();return Ph=r,Ph}var Lh,nb;function GC(){if(nb)return Lh;nb=1;var e=VC(),n=Wu(),r=Hu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Lh=i,Lh}var qh,rb;function a$(){if(rb)return qh;rb=1;var e=wo(),n=mr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return qh=i,qh}var $h,sb;function l$(){if(sb)return $h;sb=1;var e=a$(),n=Uu(),r=uy(),i=r&&r.isMap,o=i?n(i):e;return $h=o,$h}var Dh,ib;function u$(){if(ib)return Dh;ib=1;var e=wo(),n=mr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return Dh=i,Dh}var Fh,ob;function c$(){if(ob)return Fh;ob=1;var e=u$(),n=Uu(),r=uy(),i=r&&r.isSet,o=i?n(i):e;return Fh=o,Fh}var zh,ab;function YC(){if(ab)return zh;ab=1;var e=Du(),n=ay(),r=zu(),i=Vq(),o=Kq(),l=LC(),u=qC(),c=Xq(),h=Qq(),p=BC(),d=Zq(),m=wo(),y=n$(),w=o$(),N=GC(),_=bt(),b=yo(),S=l$(),k=$n(),E=c$(),C=Ns(),I=pi(),P=1,A=2,H=4,z="[object Arguments]",L="[object Array]",F="[object Boolean]",G="[object Date]",O="[object Error]",j="[object Function]",q="[object GeneratorFunction]",$="[object Map]",re="[object Number]",J="[object Object]",W="[object RegExp]",Z="[object Set]",M="[object String]",Y="[object Symbol]",U="[object WeakMap]",B="[object ArrayBuffer]",X="[object DataView]",ne="[object Float32Array]",le="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",je="[object Uint16Array]",ye="[object Uint32Array]",ke={};ke[z]=ke[L]=ke[B]=ke[X]=ke[F]=ke[G]=ke[ne]=ke[le]=ke[fe]=ke[te]=ke[ce]=ke[$]=ke[re]=ke[J]=ke[W]=ke[Z]=ke[M]=ke[Y]=ke[Ce]=ke[ve]=ke[je]=ke[ye]=!0,ke[O]=ke[j]=ke[U]=!1;function Ye(we,_e,Be,it,yt,Ze){var De,Je=_e&P,Xe=_e&A,Mt=_e&H;if(Be&&(De=yt?Be(we,it,yt,Ze):Be(we)),De!==void 0)return De;if(!k(we))return we;var ut=_(we);if(ut){if(De=y(we),!Je)return u(we,De)}else{var Qe=m(we),Ot=Qe==j||Qe==q;if(b(we))return l(we,Je);if(Qe==J||Qe==z||Ot&&!yt){if(De=Xe||Ot?{}:N(we),!Je)return Xe?h(we,o(De,we)):c(we,i(De,we))}else{if(!ke[Qe])return yt?we:{};De=w(we,Qe,Je)}}Ze||(Ze=new e);var Ft=Ze.get(we);if(Ft)return Ft;Ze.set(we,De),E(we)?we.forEach(function(pt){De.add(Ye(pt,_e,Be,pt,we,Ze))}):S(we)&&we.forEach(function(pt,wt){De.set(wt,Ye(pt,_e,Be,wt,we,Ze))});var et=Mt?Xe?d:p:Xe?I:C,St=ut?void 0:et(we);return n(St||we,function(pt,wt){St&&(wt=pt,pt=we[wt]),r(De,wt,Ye(pt,_e,Be,wt,we,Ze))}),De}return zh=Ye,zh}var Bh,lb;function d$(){if(lb)return Bh;lb=1;var e=YC(),n=4;function r(i){return e(i,n)}return Bh=r,Bh}var Uh,ub;function py(){if(ub)return Uh;ub=1;function e(n){return function(){return n}}return Uh=e,Uh}var Hh,cb;function f$(){if(cb)return Hh;cb=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),h=c.length;h--;){var p=c[n?h:++l];if(i(u[p],p,u)===!1)break}return r}}return Hh=e,Hh}var Wh,db;function my(){if(db)return Wh;db=1;var e=f$(),n=e();return Wh=n,Wh}var Vh,fb;function gy(){if(fb)return Vh;fb=1;var e=my(),n=Ns();function r(i,o){return i&&e(i,o,n)}return Vh=r,Vh}var Gh,hb;function h$(){if(hb)return Gh;hb=1;var e=Ur();function n(r,i){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=i?u:-1,h=Object(o);(i?c--:++c<u)&&l(h[c],c,h)!==!1;);return o}}return Gh=n,Gh}var Yh,pb;function Vu(){if(pb)return Yh;pb=1;var e=gy(),n=h$(),r=n(e);return Yh=r,Yh}var Kh,mb;function mi(){if(mb)return Kh;mb=1;function e(n){return n}return Kh=e,Kh}var Xh,gb;function KC(){if(gb)return Xh;gb=1;var e=mi();function n(r){return typeof r=="function"?r:e}return Xh=n,Xh}var Qh,vb;function XC(){if(vb)return Qh;vb=1;var e=ay(),n=Vu(),r=KC(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return Qh=o,Qh}var Zh,yb;function QC(){return yb||(yb=1,Zh=XC()),Zh}var Jh,wb;function p$(){if(wb)return Jh;wb=1;var e=Vu();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return Jh=n,Jh}var ep,xb;function m$(){if(xb)return ep;xb=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return ep=n,ep}var tp,_b;function g$(){if(_b)return tp;_b=1;function e(n){return this.__data__.has(n)}return tp=e,tp}var np,bb;function ZC(){if(bb)return np;bb=1;var e=oy(),n=m$(),r=g$();function i(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return i.prototype.add=i.prototype.push=n,i.prototype.has=r,np=i,np}var rp,Sb;function v$(){if(Sb)return rp;Sb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o;)if(r(n[i],i,n))return!0;return!1}return rp=e,rp}var sp,kb;function JC(){if(kb)return sp;kb=1;function e(n,r){return n.has(r)}return sp=e,sp}var ip,Eb;function eT(){if(Eb)return ip;Eb=1;var e=ZC(),n=v$(),r=JC(),i=1,o=2;function l(u,c,h,p,d,m){var y=h&i,w=u.length,N=c.length;if(w!=N&&!(y&&N>w))return!1;var _=m.get(u),b=m.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,E=h&o?new e:void 0;for(m.set(u,c),m.set(c,u);++S<w;){var C=u[S],I=c[S];if(p)var P=y?p(I,C,S,c,u,m):p(C,I,S,u,c,m);if(P!==void 0){if(P)continue;k=!1;break}if(E){if(!n(c,function(A,H){if(!r(E,H)&&(C===A||d(C,A,h,p,m)))return E.push(H)})){k=!1;break}}else if(!(C===I||d(C,I,h,p,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return ip=l,ip}var op,Nb;function y$(){if(Nb)return op;Nb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return op=e,op}var ap,Cb;function vy(){if(Cb)return ap;Cb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return ap=e,ap}var lp,Tb;function w$(){if(Tb)return lp;Tb=1;var e=vo(),n=HC(),r=go(),i=eT(),o=y$(),l=vy(),u=1,c=2,h="[object Boolean]",p="[object Date]",d="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",N="[object Set]",_="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function I(P,A,H,z,L,F,G){switch(H){case k:if(P.byteLength!=A.byteLength||P.byteOffset!=A.byteOffset)return!1;P=P.buffer,A=A.buffer;case S:return!(P.byteLength!=A.byteLength||!F(new n(P),new n(A)));case h:case p:case y:return r(+P,+A);case d:return P.name==A.name&&P.message==A.message;case w:case _:return P==A+"";case m:var O=o;case N:var j=z&u;if(O||(O=l),P.size!=A.size&&!j)return!1;var q=G.get(P);if(q)return q==A;z|=c,G.set(P,A);var $=i(O(P),O(A),z,L,F,G);return G.delete(P),$;case b:if(C)return C.call(P)==C.call(A)}return!1}return lp=I,lp}var up,Rb;function x$(){if(Rb)return up;Rb=1;var e=BC(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,h,p,d){var m=c&n,y=e(l),w=y.length,N=e(u),_=N.length;if(w!=_&&!m)return!1;for(var b=w;b--;){var S=y[b];if(!(m?S in u:i.call(u,S)))return!1}var k=d.get(l),E=d.get(u);if(k&&E)return k==u&&E==l;var C=!0;d.set(l,u),d.set(u,l);for(var I=m;++b<w;){S=y[b];var P=l[S],A=u[S];if(h)var H=m?h(A,P,S,u,l,d):h(P,A,S,l,u,d);if(!(H===void 0?P===A||p(P,A,c,h,d):H)){C=!1;break}I||(I=S=="constructor")}if(C&&!I){var z=l.constructor,L=u.constructor;z!=L&&"constructor"in l&&"constructor"in u&&!(typeof z=="function"&&z instanceof z&&typeof L=="function"&&L instanceof L)&&(C=!1)}return d.delete(l),d.delete(u),C}return up=o,up}var cp,jb;function _$(){if(jb)return cp;jb=1;var e=Du(),n=eT(),r=w$(),i=x$(),o=wo(),l=bt(),u=yo(),c=Ma(),h=1,p="[object Arguments]",d="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function N(_,b,S,k,E,C){var I=l(_),P=l(b),A=I?d:o(_),H=P?d:o(b);A=A==p?m:A,H=H==p?m:H;var z=A==m,L=H==m,F=A==H;if(F&&u(_)){if(!u(b))return!1;I=!0,z=!1}if(F&&!z)return C||(C=new e),I||c(_)?n(_,b,S,k,E,C):r(_,b,A,S,k,E,C);if(!(S&h)){var G=z&&w.call(_,"__wrapped__"),O=L&&w.call(b,"__wrapped__");if(G||O){var j=G?_.value():_,q=O?b.value():b;return C||(C=new e),E(j,q,S,k,C)}}return F?(C||(C=new e),i(_,b,S,k,E,C)):!1}return cp=N,cp}var dp,Ab;function tT(){if(Ab)return dp;Ab=1;var e=_$(),n=mr();function r(i,o,l,u,c){return i===o?!0:i==null||o==null||!n(i)&&!n(o)?i!==i&&o!==o:e(i,o,l,u,r,c)}return dp=r,dp}var fp,Ib;function b$(){if(Ib)return fp;Ib=1;var e=Du(),n=tT(),r=1,i=2;function o(l,u,c,h){var p=c.length,d=p,m=!h;if(l==null)return!d;for(l=Object(l);p--;){var y=c[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<d;){y=c[p];var w=y[0],N=l[w],_=y[1];if(m&&y[2]){if(N===void 0&&!(w in l))return!1}else{var b=new e;if(h)var S=h(N,_,w,l,u,b);if(!(S===void 0?n(_,N,r|i,h,b):S))return!1}}return!0}return fp=o,fp}var hp,Mb;function nT(){if(Mb)return hp;Mb=1;var e=$n();function n(r){return r===r&&!e(r)}return hp=n,hp}var pp,Ob;function S$(){if(Ob)return pp;Ob=1;var e=nT(),n=Ns();function r(i){for(var o=n(i),l=o.length;l--;){var u=o[l],c=i[u];o[l]=[u,c,e(c)]}return o}return pp=r,pp}var mp,Pb;function rT(){if(Pb)return mp;Pb=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return mp=e,mp}var gp,Lb;function k$(){if(Lb)return gp;Lb=1;var e=b$(),n=S$(),r=rT();function i(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return gp=i,gp}var vp,qb;function xo(){if(qb)return vp;qb=1;var e=fi(),n=mr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return vp=i,vp}var yp,$b;function yy(){if($b)return yp;$b=1;var e=bt(),n=xo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:i.test(l)||!r.test(l)||u!=null&&l in Object(u)}return yp=o,yp}var wp,Db;function E$(){if(Db)return wp;Db=1;var e=oy(),n="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],h=l.cache;if(h.has(c))return h.get(c);var p=i.apply(this,u);return l.cache=h.set(c,p)||h,p};return l.cache=new(r.Cache||e),l}return r.Cache=e,wp=r,wp}var xp,Fb;function N$(){if(Fb)return xp;Fb=1;var e=E$(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return xp=r,xp}var _p,zb;function C$(){if(zb)return _p;zb=1;var e=N$(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,h,p){l.push(h?p.replace(r,"$1"):c||u)}),l});return _p=i,_p}var bp,Bb;function Gu(){if(Bb)return bp;Bb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=Array(o);++i<o;)l[i]=r(n[i],i,n);return l}return bp=e,bp}var Sp,Ub;function T$(){if(Ub)return Sp;Ub=1;var e=vo(),n=Gu(),r=bt(),i=xo(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(i(c))return l?l.call(c):"";var h=c+"";return h=="0"&&1/c==-1/0?"-0":h}return Sp=u,Sp}var kp,Hb;function sT(){if(Hb)return kp;Hb=1;var e=T$();function n(r){return r==null?"":e(r)}return kp=n,kp}var Ep,Wb;function Yu(){if(Wb)return Ep;Wb=1;var e=bt(),n=yy(),r=C$(),i=sT();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return Ep=o,Ep}var Np,Vb;function Oa(){if(Vb)return Np;Vb=1;var e=xo();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return Np=n,Np}var Cp,Gb;function Ku(){if(Gb)return Cp;Gb=1;var e=Yu(),n=Oa();function r(i,o){o=e(o,i);for(var l=0,u=o.length;i!=null&&l<u;)i=i[n(o[l++])];return l&&l==u?i:void 0}return Cp=r,Cp}var Tp,Yb;function R$(){if(Yb)return Tp;Yb=1;var e=Ku();function n(r,i,o){var l=r==null?void 0:e(r,i);return l===void 0?o:l}return Tp=n,Tp}var Rp,Kb;function j$(){if(Kb)return Rp;Kb=1;function e(n,r){return n!=null&&r in Object(n)}return Rp=e,Rp}var jp,Xb;function iT(){if(Xb)return jp;Xb=1;var e=Yu(),n=Ia(),r=bt(),i=Bu(),o=ly(),l=Oa();function u(c,h,p){h=e(h,c);for(var d=-1,m=h.length,y=!1;++d<m;){var w=l(h[d]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++d!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&i(w,m)&&(r(c)||n(c)))}return jp=u,jp}var Ap,Qb;function oT(){if(Qb)return Ap;Qb=1;var e=j$(),n=iT();function r(i,o){return i!=null&&n(i,o,e)}return Ap=r,Ap}var Ip,Zb;function A$(){if(Zb)return Ip;Zb=1;var e=tT(),n=R$(),r=oT(),i=yy(),o=nT(),l=rT(),u=Oa(),c=1,h=2;function p(d,m){return i(d)&&o(m)?l(u(d),m):function(y){var w=n(y,d);return w===void 0&&w===m?r(y,d):e(m,w,c|h)}}return Ip=p,Ip}var Mp,Jb;function aT(){if(Jb)return Mp;Jb=1;function e(n){return function(r){return r==null?void 0:r[n]}}return Mp=e,Mp}var Op,eS;function I$(){if(eS)return Op;eS=1;var e=Ku();function n(r){return function(i){return e(i,r)}}return Op=n,Op}var Pp,tS;function M$(){if(tS)return Pp;tS=1;var e=aT(),n=I$(),r=yy(),i=Oa();function o(l){return r(l)?e(i(l)):n(l)}return Pp=o,Pp}var Lp,nS;function Hr(){if(nS)return Lp;nS=1;var e=k$(),n=A$(),r=mi(),i=bt(),o=M$();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?n(u[0],u[1]):e(u):o(u)}return Lp=l,Lp}var qp,rS;function lT(){if(rS)return qp;rS=1;var e=$C(),n=p$(),r=Hr(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return qp=o,qp}var $p,sS;function O$(){if(sS)return $p;sS=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return $p=r,$p}var Dp,iS;function uT(){if(iS)return Dp;iS=1;var e=O$(),n=iT();function r(i,o){return i!=null&&n(i,o,e)}return Dp=r,Dp}var Fp,oS;function P$(){if(oS)return Fp;oS=1;var e=cy(),n=wo(),r=Ia(),i=bt(),o=Ur(),l=yo(),u=Hu(),c=Ma(),h="[object Map]",p="[object Set]",d=Object.prototype,m=d.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(i(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||r(w)))return!w.length;var N=n(w);if(N==h||N==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return Fp=y,Fp}var zp,aS;function cT(){if(aS)return zp;aS=1;function e(n){return n===void 0}return zp=e,zp}var Bp,lS;function dT(){if(lS)return Bp;lS=1;var e=Vu(),n=Ur();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,h,p){u[++l]=o(c,h,p)}),u}return Bp=r,Bp}var Up,uS;function fT(){if(uS)return Up;uS=1;var e=Gu(),n=Hr(),r=dT(),i=bt();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return Up=o,Up}var Hp,cS;function L$(){if(cS)return Hp;cS=1;function e(n,r,i,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(i=n[++l]);++l<u;)i=r(i,n[l],l,n);return i}return Hp=e,Hp}var Wp,dS;function q$(){if(dS)return Wp;dS=1;function e(n,r,i,o,l){return l(n,function(u,c,h){i=o?(o=!1,u):r(i,u,c,h)}),i}return Wp=e,Wp}var Vp,fS;function hT(){if(fS)return Vp;fS=1;var e=L$(),n=Vu(),r=Hr(),i=q$(),o=bt();function l(u,c,h){var p=o(u)?e:i,d=arguments.length<3;return p(u,r(c,4),h,d,n)}return Vp=l,Vp}var Gp,hS;function $$(){if(hS)return Gp;hS=1;var e=fi(),n=bt(),r=mr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return Gp=o,Gp}var Yp,pS;function D$(){if(pS)return Yp;pS=1;var e=aT(),n=e("length");return Yp=n,Yp}var Kp,mS;function F$(){if(mS)return Kp;mS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function h(p){return c.test(p)}return Kp=h,Kp}var Xp,gS;function z$(){if(gS)return Xp;gS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+h+")",d="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",N=p+"?",_="["+l+"]?",b="(?:"+w+"(?:"+[d,m,y].join("|")+")"+_+N+")*",S=_+N+b,k="(?:"+[d+c+"?",c,m,y,u].join("|")+")",E=RegExp(h+"(?="+h+")|"+k+S,"g");function C(I){for(var P=E.lastIndex=0;E.test(I);)++P;return P}return Xp=C,Xp}var Qp,vS;function B$(){if(vS)return Qp;vS=1;var e=D$(),n=F$(),r=z$();function i(o){return n(o)?r(o):e(o)}return Qp=i,Qp}var Zp,yS;function U$(){if(yS)return Zp;yS=1;var e=cy(),n=wo(),r=Ur(),i=$$(),o=B$(),l="[object Map]",u="[object Set]";function c(h){if(h==null)return 0;if(r(h))return i(h)?o(h):h.length;var p=n(h);return p==l||p==u?h.size:e(h).length}return Zp=c,Zp}var Jp,wS;function H$(){if(wS)return Jp;wS=1;var e=ay(),n=VC(),r=gy(),i=Hr(),o=Wu(),l=bt(),u=yo(),c=ja(),h=$n(),p=Ma();function d(m,y,w){var N=l(m),_=N||u(m)||p(m);if(y=i(y,4),w==null){var b=m&&m.constructor;_?w=N?new b:[]:h(m)?w=c(b)?n(o(m)):{}:w={}}return(_?e:r)(m,function(S,k,E){return y(w,S,k,E)}),w}return Jp=d,Jp}var em,xS;function W$(){if(xS)return em;xS=1;var e=vo(),n=Ia(),r=bt(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return em=o,em}var tm,_S;function wy(){if(_S)return tm;_S=1;var e=fy(),n=W$();function r(i,o,l,u,c){var h=-1,p=i.length;for(l||(l=n),c||(c=[]);++h<p;){var d=i[h];o>0&&l(d)?o>1?r(d,o-1,l,u,c):e(c,d):u||(c[c.length]=d)}return c}return tm=r,tm}var nm,bS;function V$(){if(bS)return nm;bS=1;function e(n,r,i){switch(i.length){case 0:return n.call(r);case 1:return n.call(r,i[0]);case 2:return n.call(r,i[0],i[1]);case 3:return n.call(r,i[0],i[1],i[2])}return n.apply(r,i)}return nm=e,nm}var rm,SS;function pT(){if(SS)return rm;SS=1;var e=V$(),n=Math.max;function r(i,o,l){return o=n(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,h=n(u.length-o,0),p=Array(h);++c<h;)p[c]=u[o+c];c=-1;for(var d=Array(o+1);++c<o;)d[c]=u[c];return d[o]=l(p),e(i,this,d)}}return rm=r,rm}var sm,kS;function G$(){if(kS)return sm;kS=1;var e=py(),n=MC(),r=mi(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return sm=i,sm}var im,ES;function Y$(){if(ES)return im;ES=1;var e=800,n=16,r=Date.now;function i(o){var l=0,u=0;return function(){var c=r(),h=n-(c-u);if(u=c,h>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return im=i,im}var om,NS;function mT(){if(NS)return om;NS=1;var e=G$(),n=Y$(),r=n(e);return om=r,om}var am,CS;function Xu(){if(CS)return am;CS=1;var e=mi(),n=pT(),r=mT();function i(o,l){return r(n(o,l,e),o+"")}return am=i,am}var lm,TS;function gT(){if(TS)return lm;TS=1;function e(n,r,i,o){for(var l=n.length,u=i+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return lm=e,lm}var um,RS;function K$(){if(RS)return um;RS=1;function e(n){return n!==n}return um=e,um}var cm,jS;function X$(){if(jS)return cm;jS=1;function e(n,r,i){for(var o=i-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return cm=e,cm}var dm,AS;function Q$(){if(AS)return dm;AS=1;var e=gT(),n=K$(),r=X$();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return dm=i,dm}var fm,IS;function Z$(){if(IS)return fm;IS=1;var e=Q$();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return fm=n,fm}var hm,MS;function J$(){if(MS)return hm;MS=1;function e(n,r,i){for(var o=-1,l=n==null?0:n.length;++o<l;)if(i(r,n[o]))return!0;return!1}return hm=e,hm}var pm,OS;function eD(){if(OS)return pm;OS=1;function e(){}return pm=e,pm}var mm,PS;function tD(){if(PS)return mm;PS=1;var e=UC(),n=eD(),r=vy(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return mm=o,mm}var gm,LS;function nD(){if(LS)return gm;LS=1;var e=ZC(),n=Z$(),r=J$(),i=JC(),o=tD(),l=vy(),u=200;function c(h,p,d){var m=-1,y=n,w=h.length,N=!0,_=[],b=_;if(d)N=!1,y=r;else if(w>=u){var S=p?null:o(h);if(S)return l(S);N=!1,y=i,b=new e}else b=p?[]:_;e:for(;++m<w;){var k=h[m],E=p?p(k):k;if(k=d||k!==0?k:0,N&&E===E){for(var C=b.length;C--;)if(b[C]===E)continue e;p&&b.push(E),_.push(k)}else y(b,E,d)||(b!==_&&b.push(E),_.push(k))}return _}return gm=c,gm}var vm,qS;function vT(){if(qS)return vm;qS=1;var e=Ur(),n=mr();function r(i){return n(i)&&e(i)}return vm=r,vm}var ym,$S;function rD(){if($S)return ym;$S=1;var e=wy(),n=Xu(),r=nD(),i=vT(),o=n(function(l){return r(e(l,1,i,!0))});return ym=o,ym}var wm,DS;function sD(){if(DS)return wm;DS=1;var e=Gu();function n(r,i){return e(i,function(o){return r[o]})}return wm=n,wm}var xm,FS;function yT(){if(FS)return xm;FS=1;var e=sD(),n=Ns();function r(i){return i==null?[]:e(i,n(i))}return xm=r,xm}var _m,zS;function Dn(){if(zS)return _m;zS=1;var e;if(typeof sy=="function")try{e={clone:d$(),constant:py(),each:QC(),filter:lT(),has:uT(),isArray:bt(),isEmpty:P$(),isFunction:ja(),isUndefined:cT(),keys:Ns(),map:fT(),reduce:hT(),size:U$(),transform:H$(),union:rD(),values:yT()}}catch{}return e||(e=window._),_m=e,_m}var bm,BS;function xy(){if(BS)return bm;BS=1;var e=Dn();bm=o;var n="\0",r="\0",i="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._in[m])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._out[m])})},o.prototype.setNodes=function(d,m){var y=arguments,w=this;return e.each(d,function(N){y.length>1?w.setNode(N,m):w.setNode(N)}),this},o.prototype.setNode=function(d,m){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=m),this):(this._nodes[d]=arguments.length>1?m:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var m=this;if(e.has(this._nodes,d)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(w){m.setParent(w)}),delete this._children[d]),e.each(e.keys(this._in[d]),y),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),y),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=r;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===d)throw new Error("Setting "+m+" as parent of "+d+" would create a cycle");this.setNode(m)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=m,this._children[m][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var m=this._parent[d];if(m!==r)return m}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var m=this._children[d];if(m)return e.keys(m)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var m=this._preds[d];if(m)return e.keys(m)},o.prototype.successors=function(d){var m=this._sucs[d];if(m)return e.keys(m)},o.prototype.neighbors=function(d){var m=this.predecessors(d);if(m)return e.union(m,this.successors(d))},o.prototype.isLeaf=function(d){var m;return this.isDirected()?m=this.successors(d):m=this.neighbors(d),m.length===0},o.prototype.filterNodes=function(d){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,b){d(b)&&m.setNode(b,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function N(_){var b=y.parent(_);return b===void 0||m.hasNode(b)?(w[_]=b,b):b in w?w[b]:N(b)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,m){var y=this,w=arguments;return e.reduce(d,function(N,_){return w.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var d,m,y,w,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(d=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],N=!0)):(d=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],N=!0)),d=""+d,m=""+m,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,d,m,y);if(e.has(this._edgeLabels,b))return N&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(m),this._edgeLabels[b]=N?w:this._defaultEdgeLabelFn(d,m,y);var S=h(this._isDirected,d,m,y);return d=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,l(this._preds[m],d),l(this._sucs[d],m),this._in[m][b]=S,this._out[d][b]=S,this._edgeCount++,this},o.prototype.edge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y),N=this._edgeObjs[w];return N&&(d=N.v,m=N.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],d),u(this._sucs[d],m),delete this._in[m][w],delete this._out[d][w],this._edgeCount--),this},o.prototype.inEdges=function(d,m){var y=this._in[d];if(y){var w=e.values(y);return m?e.filter(w,function(N){return N.v===m}):w}},o.prototype.outEdges=function(d,m){var y=this._out[d];if(y){var w=e.values(y);return m?e.filter(w,function(N){return N.w===m}):w}},o.prototype.nodeEdges=function(d,m){var y=this.inEdges(d,m);if(y)return y.concat(this.outEdges(d,m))};function l(d,m){d[m]?d[m]++:d[m]=1}function u(d,m){--d[m]||delete d[m]}function c(d,m,y,w){var N=""+m,_=""+y;if(!d&&N>_){var b=N;N=_,_=b}return N+i+_+i+(e.isUndefined(w)?n:w)}function h(d,m,y,w){var N=""+m,_=""+y;if(!d&&N>_){var b=N;N=_,_=b}var S={v:N,w:_};return w&&(S.name=w),S}function p(d,m){return c(d,m.v,m.w,m.name)}return bm}var Sm,US;function iD(){return US||(US=1,Sm="2.1.8"),Sm}var km,HS;function oD(){return HS||(HS=1,km={Graph:xy(),version:iD()}),km}var Em,WS;function aD(){if(WS)return Em;WS=1;var e=Dn(),n=xy();Em={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:i(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function i(u){return e.map(u.nodes(),function(c){var h=u.node(c),p=u.parent(c),d={v:c};return e.isUndefined(h)||(d.value=h),e.isUndefined(p)||(d.parent=p),d})}function o(u){return e.map(u.edges(),function(c){var h=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(h)||(p.value=h),p})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(h){c.setNode(h.v,h.value),h.parent&&c.setParent(h.v,h.parent)}),e.each(u.edges,function(h){c.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),c}return Em}var Nm,VS;function lD(){if(VS)return Nm;VS=1;var e=Dn();Nm=n;function n(r){var i={},o=[],l;function u(c){e.has(i,c)||(i[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Nm}var Cm,GS;function wT(){if(GS)return Cm;GS=1;var e=Dn();Cm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:i}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,i){var o=this._keyIndices[r];if(i>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+i);this._arr[o].priority=i,this._decrease(o)},n.prototype._heapify=function(r){var i=this._arr,o=2*r,l=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,l<i.length&&(u=i[l].priority<i[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,l;r!==0&&(l=r>>1,!(i[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,i){var o=this._arr,l=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,l[c.key]=r,l[u.key]=i},Cm}var Tm,YS;function xT(){if(YS)return Tm;YS=1;var e=Dn(),n=wT();Tm=i;var r=e.constant(1);function i(l,u,c,h){return o(l,String(u),c||r,h||function(p){return l.outEdges(p)})}function o(l,u,c,h){var p={},d=new n,m,y,w=function(N){var _=N.v!==m?N.v:N.w,b=p[_],S=c(N),k=y.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+S);k<b.distance&&(b.distance=k,b.predecessor=m,d.decrease(_,k))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;p[N]={distance:_},d.add(N,_)});d.size()>0&&(m=d.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(w);return p}return Tm}var Rm,KS;function uD(){if(KS)return Rm;KS=1;var e=xT(),n=Dn();Rm=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return Rm}var jm,XS;function _T(){if(XS)return jm;XS=1;var e=Dn();jm=n;function n(r){var i=0,o=[],l={},u=[];function c(h){var p=l[h]={onStack:!0,lowlink:i,index:i++};if(o.push(h),r.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var d=[],m;do m=o.pop(),l[m].onStack=!1,d.push(m);while(h!==m);u.push(d)}}return r.nodes().forEach(function(h){e.has(l,h)||c(h)}),u}return jm}var Am,QS;function cD(){if(QS)return Am;QS=1;var e=Dn(),n=_T();Am=r;function r(i){return e.filter(n(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return Am}var Im,ZS;function dD(){if(ZS)return Im;ZS=1;var e=Dn();Im=r;var n=e.constant(1);function r(o,l,u){return i(o,l||n,u||function(c){return o.outEdges(c)})}function i(o,l,u){var c={},h=o.nodes();return h.forEach(function(p){c[p]={},c[p][p]={distance:0},h.forEach(function(d){p!==d&&(c[p][d]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(d){var m=d.v===p?d.w:d.v,y=l(d);c[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var d=c[p];h.forEach(function(m){var y=c[m];h.forEach(function(w){var N=y[p],_=d[w],b=y[w],S=N.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return Im}var Mm,JS;function bT(){if(JS)return Mm;JS=1;var e=Dn();Mm=n,n.CycleException=r;function n(i){var o={},l={},u=[];function c(h){if(e.has(l,h))throw new r;e.has(o,h)||(l[h]=!0,o[h]=!0,e.each(i.predecessors(h),c),delete l[h],u.push(h))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Mm}var Om,ek;function fD(){if(ek)return Om;ek=1;var e=bT();Om=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return Om}var Pm,tk;function ST(){if(tk)return Pm;tk=1;var e=Dn();Pm=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],h={};return e.each(o,function(p){if(!i.hasNode(p))throw new Error("Graph does not have node: "+p);r(i,p,l==="post",h,u,c)}),c}function r(i,o,l,u,c,h){e.has(u,o)||(u[o]=!0,l||h.push(o),e.each(c(o),function(p){r(i,p,l,u,c,h)}),l&&h.push(o))}return Pm}var Lm,nk;function hD(){if(nk)return Lm;nk=1;var e=ST();Lm=n;function n(r,i){return e(r,i,"post")}return Lm}var qm,rk;function pD(){if(rk)return qm;rk=1;var e=ST();qm=n;function n(r,i){return e(r,i,"pre")}return qm}var $m,sk;function mD(){if(sk)return $m;sk=1;var e=Dn(),n=xy(),r=wT();$m=i;function i(o,l){var u=new n,c={},h=new r,p;function d(y){var w=y.v===p?y.w:y.v,N=h.priority(w);if(N!==void 0){var _=l(y);_<N&&(c[w]=p,h.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),h.decrease(o.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(p).forEach(d)}return u}return $m}var Dm,ik;function gD(){return ik||(ik=1,Dm={components:lD(),dijkstra:xT(),dijkstraAll:uD(),findCycles:cD(),floydWarshall:dD(),isAcyclic:fD(),postorder:hD(),preorder:pD(),prim:mD(),tarjan:_T(),topsort:bT()}),Dm}var Fm,ok;function vD(){if(ok)return Fm;ok=1;var e=oD();return Fm={Graph:e.Graph,json:aD(),alg:gD(),version:e.version},Fm}var zm,ak;function nr(){if(ak)return zm;ak=1;var e;if(typeof sy=="function")try{e=vD()}catch{}return e||(e=window.graphlib),zm=e,zm}var Bm,lk;function yD(){if(lk)return Bm;lk=1;var e=YC(),n=1,r=4;function i(o){return e(o,n|r)}return Bm=i,Bm}var Um,uk;function Qu(){if(uk)return Um;uk=1;var e=go(),n=Ur(),r=Bu(),i=$n();function o(l,u,c){if(!i(c))return!1;var h=typeof u;return(h=="number"?n(c)&&r(u,c.length):h=="string"&&u in c)?e(c[u],l):!1}return Um=o,Um}var Hm,ck;function wD(){if(ck)return Hm;ck=1;var e=Xu(),n=go(),r=Qu(),i=pi(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,h){c=Object(c);var p=-1,d=h.length,m=d>2?h[2]:void 0;for(m&&r(h[0],h[1],m)&&(d=1);++p<d;)for(var y=h[p],w=i(y),N=-1,_=w.length;++N<_;){var b=w[N],S=c[b];(S===void 0||n(S,o[b])&&!l.call(c,b))&&(c[b]=y[b])}return c});return Hm=u,Hm}var Wm,dk;function xD(){if(dk)return Wm;dk=1;var e=Hr(),n=Ur(),r=Ns();function i(o){return function(l,u,c){var h=Object(l);if(!n(l)){var p=e(u,3);l=r(l),u=function(m){return p(h[m],m,h)}}var d=o(l,u,c);return d>-1?h[p?l[d]:d]:void 0}}return Wm=i,Wm}var Vm,fk;function _D(){if(fk)return Vm;fk=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return Vm=n,Vm}var Gm,hk;function bD(){if(hk)return Gm;hk=1;var e=_D(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return Gm=r,Gm}var Ym,pk;function SD(){if(pk)return Ym;pk=1;var e=bD(),n=$n(),r=xo(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function h(p){if(typeof p=="number")return p;if(r(p))return i;if(n(p)){var d=typeof p.valueOf=="function"?p.valueOf():p;p=n(d)?d+"":d}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||u.test(p)?c(p.slice(2),m?2:8):o.test(p)?i:+p}return Ym=h,Ym}var Km,mk;function kT(){if(mk)return Km;mk=1;var e=SD(),n=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Km=i,Km}var Xm,gk;function kD(){if(gk)return Xm;gk=1;var e=kT();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return Xm=n,Xm}var Qm,vk;function ED(){if(vk)return Qm;vk=1;var e=gT(),n=Hr(),r=kD(),i=Math.max;function o(l,u,c){var h=l==null?0:l.length;if(!h)return-1;var p=c==null?0:r(c);return p<0&&(p=i(h+p,0)),e(l,n(u,3),p)}return Qm=o,Qm}var Zm,yk;function ND(){if(yk)return Zm;yk=1;var e=xD(),n=ED(),r=e(n);return Zm=r,Zm}var Jm,wk;function ET(){if(wk)return Jm;wk=1;var e=wy();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return Jm=n,Jm}var eg,xk;function CD(){if(xk)return eg;xk=1;var e=my(),n=KC(),r=pi();function i(o,l){return o==null?o:e(o,n(l),r)}return eg=i,eg}var tg,_k;function TD(){if(_k)return tg;_k=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return tg=e,tg}var ng,bk;function RD(){if(bk)return ng;bk=1;var e=Fu(),n=gy(),r=Hr();function i(o,l){var u={};return l=r(l,3),n(o,function(c,h,p){e(u,h,l(c,h,p))}),u}return ng=i,ng}var rg,Sk;function _y(){if(Sk)return rg;Sk=1;var e=xo();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],h=i(c);if(h!=null&&(p===void 0?h===h&&!e(h):o(h,p)))var p=h,d=c}return d}return rg=n,rg}var sg,kk;function jD(){if(kk)return sg;kk=1;function e(n,r){return n>r}return sg=e,sg}var ig,Ek;function AD(){if(Ek)return ig;Ek=1;var e=_y(),n=jD(),r=mi();function i(o){return o&&o.length?e(o,r,n):void 0}return ig=i,ig}var og,Nk;function NT(){if(Nk)return og;Nk=1;var e=Fu(),n=go();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return og=r,og}var ag,Ck;function ID(){if(Ck)return ag;Ck=1;var e=fi(),n=Wu(),r=mr(),i="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,h=u.call(Object);function p(d){if(!r(d)||e(d)!=i)return!1;var m=n(d);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==h}return ag=p,ag}var lg,Tk;function CT(){if(Tk)return lg;Tk=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return lg=e,lg}var ug,Rk;function MD(){if(Rk)return ug;Rk=1;var e=Aa(),n=pi();function r(i){return e(i,n(i))}return ug=r,ug}var cg,jk;function OD(){if(jk)return cg;jk=1;var e=NT(),n=LC(),r=WC(),i=qC(),o=GC(),l=Ia(),u=bt(),c=vT(),h=yo(),p=ja(),d=$n(),m=ID(),y=Ma(),w=CT(),N=MD();function _(b,S,k,E,C,I,P){var A=w(b,k),H=w(S,k),z=P.get(H);if(z){e(b,k,z);return}var L=I?I(A,H,k+"",b,S,P):void 0,F=L===void 0;if(F){var G=u(H),O=!G&&h(H),j=!G&&!O&&y(H);L=H,G||O||j?u(A)?L=A:c(A)?L=i(A):O?(F=!1,L=n(H,!0)):j?(F=!1,L=r(H,!0)):L=[]:m(H)||l(H)?(L=A,l(A)?L=N(A):(!d(A)||p(A))&&(L=o(H))):F=!1}F&&(P.set(H,L),C(L,H,E,I,P),P.delete(H)),e(b,k,L)}return cg=_,cg}var dg,Ak;function PD(){if(Ak)return dg;Ak=1;var e=Du(),n=NT(),r=my(),i=OD(),o=$n(),l=pi(),u=CT();function c(h,p,d,m,y){h!==p&&r(p,function(w,N){if(y||(y=new e),o(w))i(h,p,N,d,c,m,y);else{var _=m?m(u(h,N),w,N+"",h,p,y):void 0;_===void 0&&(_=w),n(h,N,_)}},l)}return dg=c,dg}var fg,Ik;function LD(){if(Ik)return fg;Ik=1;var e=Xu(),n=Qu();function r(i){return e(function(o,l){var u=-1,c=l.length,h=c>1?l[c-1]:void 0,p=c>2?l[2]:void 0;for(h=i.length>3&&typeof h=="function"?(c--,h):void 0,p&&n(l[0],l[1],p)&&(h=c<3?void 0:h,c=1),o=Object(o);++u<c;){var d=l[u];d&&i(o,d,u,h)}return o})}return fg=r,fg}var hg,Mk;function qD(){if(Mk)return hg;Mk=1;var e=PD(),n=LD(),r=n(function(i,o,l){e(i,o,l)});return hg=r,hg}var pg,Ok;function TT(){if(Ok)return pg;Ok=1;function e(n,r){return n<r}return pg=e,pg}var mg,Pk;function $D(){if(Pk)return mg;Pk=1;var e=_y(),n=TT(),r=mi();function i(o){return o&&o.length?e(o,r,n):void 0}return mg=i,mg}var gg,Lk;function DD(){if(Lk)return gg;Lk=1;var e=_y(),n=Hr(),r=TT();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return gg=i,gg}var vg,qk;function FD(){if(qk)return vg;qk=1;var e=sr(),n=function(){return e.Date.now()};return vg=n,vg}var yg,$k;function zD(){if($k)return yg;$k=1;var e=zu(),n=Yu(),r=Bu(),i=$n(),o=Oa();function l(u,c,h,p){if(!i(u))return u;c=n(c,u);for(var d=-1,m=c.length,y=m-1,w=u;w!=null&&++d<m;){var N=o(c[d]),_=h;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(d!=y){var b=w[N];_=p?p(b,N,w):void 0,_===void 0&&(_=i(b)?b:r(c[d+1])?[]:{})}e(w,N,_),w=w[N]}return u}return yg=l,yg}var wg,Dk;function BD(){if(Dk)return wg;Dk=1;var e=Ku(),n=zD(),r=Yu();function i(o,l,u){for(var c=-1,h=l.length,p={};++c<h;){var d=l[c],m=e(o,d);u(m,d)&&n(p,r(d,o),m)}return p}return wg=i,wg}var xg,Fk;function UD(){if(Fk)return xg;Fk=1;var e=BD(),n=oT();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return xg=r,xg}var _g,zk;function HD(){if(zk)return _g;zk=1;var e=ET(),n=pT(),r=mT();function i(o){return r(n(o,void 0,e),o+"")}return _g=i,_g}var bg,Bk;function WD(){if(Bk)return bg;Bk=1;var e=UD(),n=HD(),r=n(function(i,o){return i==null?{}:e(i,o)});return bg=r,bg}var Sg,Uk;function VD(){if(Uk)return Sg;Uk=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,h=n(e((o-i)/(l||1)),0),p=Array(h);h--;)p[u?h:++c]=i,i+=l;return p}return Sg=r,Sg}var kg,Hk;function GD(){if(Hk)return kg;Hk=1;var e=VD(),n=Qu(),r=kT();function i(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return kg=i,kg}var Eg,Wk;function YD(){if(Wk)return Eg;Wk=1;var e=GD(),n=e();return Eg=n,Eg}var Ng,Vk;function KD(){if(Vk)return Ng;Vk=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return Ng=e,Ng}var Cg,Gk;function XD(){if(Gk)return Cg;Gk=1;var e=xo();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),h=i!==void 0,p=i===null,d=i===i,m=e(i);if(!p&&!m&&!c&&r>i||c&&h&&d&&!p&&!m||l&&h&&d||!o&&d||!u)return 1;if(!l&&!c&&!m&&r<i||m&&o&&u&&!l&&!c||p&&o&&u||!h&&u||!d)return-1}return 0}return Cg=n,Cg}var Tg,Yk;function QD(){if(Yk)return Tg;Yk=1;var e=XD();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,h=u.length,p=o.length;++l<h;){var d=e(u[l],c[l]);if(d){if(l>=p)return d;var m=o[l];return d*(m=="desc"?-1:1)}}return r.index-i.index}return Tg=n,Tg}var Rg,Kk;function ZD(){if(Kk)return Rg;Kk=1;var e=Gu(),n=Ku(),r=Hr(),i=dT(),o=KD(),l=Uu(),u=QD(),c=mi(),h=bt();function p(d,m,y){m.length?m=e(m,function(_){return h(_)?function(b){return n(b,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(r));var N=i(d,function(_,b,S){var k=e(m,function(E){return E(_)});return{criteria:k,index:++w,value:_}});return o(N,function(_,b){return u(_,b,y)})}return Rg=p,Rg}var jg,Xk;function JD(){if(Xk)return jg;Xk=1;var e=wy(),n=ZD(),r=Xu(),i=Qu(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&i(l,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return jg=o,jg}var Ag,Qk;function e4(){if(Qk)return Ag;Qk=1;var e=sT(),n=0;function r(i){var o=++n;return e(i)+o}return Ag=r,Ag}var Ig,Zk;function t4(){if(Zk)return Ig;Zk=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var h=o<u?r[o]:void 0;i(c,n[o],h)}return c}return Ig=e,Ig}var Mg,Jk;function n4(){if(Jk)return Mg;Jk=1;var e=zu(),n=t4();function r(i,o){return n(i||[],o||[],e)}return Mg=r,Mg}var Og,eE;function lt(){if(eE)return Og;eE=1;var e;if(typeof sy=="function")try{e={cloneDeep:yD(),constant:py(),defaults:wD(),each:QC(),filter:lT(),find:ND(),flatten:ET(),forEach:XC(),forIn:CD(),has:uT(),isUndefined:cT(),last:TD(),map:fT(),mapValues:RD(),max:AD(),merge:qD(),min:$D(),minBy:DD(),now:FD(),pick:WD(),range:YD(),reduce:hT(),sortBy:JD(),uniqueId:e4(),values:yT(),zipObject:n4()}}catch{}return e||(e=window._),Og=e,Og}var Pg,tE;function r4(){if(tE)return Pg;tE=1,Pg=e;function e(){var i={};i._next=i._prev=i,this._sentinel=i}e.prototype.dequeue=function(){var i=this._sentinel,o=i._prev;if(o!==i)return n(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&n(i),i._next=o._next,o._next._prev=i,o._next=i,i._prev=o},e.prototype.toString=function(){for(var i=[],o=this._sentinel,l=o._prev;l!==o;)i.push(JSON.stringify(l,r)),l=l._prev;return"["+i.join(", ")+"]"};function n(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function r(i,o){if(i!=="_next"&&i!=="_prev")return o}return Pg}var Lg,nE;function s4(){if(nE)return Lg;nE=1;var e=lt(),n=nr().Graph,r=r4();Lg=o;var i=e.constant(1);function o(p,d){if(p.nodeCount()<=1)return[];var m=c(p,d||i),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,d,m){for(var y=[],w=d[d.length-1],N=d[0],_;p.nodeCount();){for(;_=N.dequeue();)u(p,d,m,_);for(;_=w.dequeue();)u(p,d,m,_);if(p.nodeCount()){for(var b=d.length-2;b>0;--b)if(_=d[b].dequeue(),_){y=y.concat(u(p,d,m,_,!0));break}}}return y}function u(p,d,m,y,w){var N=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var b=p.edge(_),S=p.node(_.v);w&&N.push({v:_.v,w:_.w}),S.out-=b,h(d,m,S)}),e.forEach(p.outEdges(y.v),function(_){var b=p.edge(_),S=_.w,k=p.node(S);k.in-=b,h(d,m,k)}),p.removeNode(y.v),N}function c(p,d){var m=new n,y=0,w=0;e.forEach(p.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(p.edges(),function(b){var S=m.edge(b.v,b.w)||0,k=d(b),E=S+k;m.setEdge(b.v,b.w,E),w=Math.max(w,m.node(b.v).out+=k),y=Math.max(y,m.node(b.w).in+=k)});var N=e.range(w+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(b){h(N,_,m.node(b))}),{graph:m,buckets:N,zeroIdx:_}}function h(p,d,m){m.out?m.in?p[m.out-m.in+d].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Lg}var qg,rE;function i4(){if(rE)return qg;rE=1;var e=lt(),n=s4();qg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(l);e.forEach(u,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function c(h){return function(p){return h.edge(p).weight}}}function i(l){var u=[],c={},h={};function p(d){e.has(h,d)||(h[d]=!0,c[d]=!0,e.forEach(l.outEdges(d),function(m){e.has(c,m.w)?u.push(m):p(m.w)}),delete c[d])}return e.forEach(l.nodes(),p),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var h=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,h)}})}return qg}var $g,sE;function fn(){if(sE)return $g;sE=1;var e=lt(),n=nr().Graph;$g={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:d,addBorderNode:m,maxRank:y,partition:w,time:N,notime:_};function r(b,S,k,E){var C;do C=e.uniqueId(E);while(b.hasNode(C));return k.dummy=S,b.setNode(C,k),C}function i(b){var S=new n().setGraph(b.graph());return e.forEach(b.nodes(),function(k){S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){var E=S.edge(k.v,k.w)||{weight:0,minlen:1},C=b.edge(k);S.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),S}function o(b){var S=new n({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(k){b.children(k).length||S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){S.setEdge(k,b.edge(k))}),S}function l(b){var S=e.map(b.nodes(),function(k){var E={};return e.forEach(b.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+b.edge(C).weight}),E});return e.zipObject(b.nodes(),S)}function u(b){var S=e.map(b.nodes(),function(k){var E={};return e.forEach(b.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+b.edge(C).weight}),E});return e.zipObject(b.nodes(),S)}function c(b,S){var k=b.x,E=b.y,C=S.x-k,I=S.y-E,P=b.width/2,A=b.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var H,z;return Math.abs(I)*P>Math.abs(C)*A?(I<0&&(A=-A),H=A*C/I,z=A):(C<0&&(P=-P),H=P,z=P*I/C),{x:k+H,y:E+z}}function h(b){var S=e.map(e.range(y(b)+1),function(){return[]});return e.forEach(b.nodes(),function(k){var E=b.node(k),C=E.rank;e.isUndefined(C)||(S[C][E.order]=k)}),S}function p(b){var S=e.min(e.map(b.nodes(),function(k){return b.node(k).rank}));e.forEach(b.nodes(),function(k){var E=b.node(k);e.has(E,"rank")&&(E.rank-=S)})}function d(b){var S=e.min(e.map(b.nodes(),function(I){return b.node(I).rank})),k=[];e.forEach(b.nodes(),function(I){var P=b.node(I).rank-S;k[P]||(k[P]=[]),k[P].push(I)});var E=0,C=b.graph().nodeRankFactor;e.forEach(k,function(I,P){e.isUndefined(I)&&P%C!==0?--E:E&&e.forEach(I,function(A){b.node(A).rank+=E})})}function m(b,S,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),r(b,"border",C,S)}function y(b){return e.max(e.map(b.nodes(),function(S){var k=b.node(S).rank;if(!e.isUndefined(k))return k}))}function w(b,S){var k={lhs:[],rhs:[]};return e.forEach(b,function(E){S(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(b,S){var k=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-k)+"ms")}}function _(b,S){return S()}return $g}var Dg,iE;function o4(){if(iE)return Dg;iE=1;var e=lt(),n=fn();Dg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){i(l,u)})}function i(l,u){var c=u.v,h=l.node(c).rank,p=u.w,d=l.node(p).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(d!==h+1){l.removeEdge(u);var N,_,b;for(b=0,++h;h<d;++b,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:h},N=n.addDummyNode(l,"edge",_,"_d"),h===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,N,{weight:y.weight},m),b===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,p,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),h=c.edgeLabel,p;for(l.setEdge(c.edgeObj,h);c.dummy;)p=l.successors(u)[0],l.removeNode(u),h.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(h.x=c.x,h.y=c.y,h.width=c.width,h.height=c.height),u=p,c=l.node(u)})}return Dg}var Fg,oE;function Eu(){if(oE)return Fg;oE=1;var e=lt();Fg={longestPath:n,slack:r};function n(i){var o={};function l(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var h=e.min(e.map(i.outEdges(u),function(p){return l(p.w)-i.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),c.rank=h}e.forEach(i.sources(),l)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return Fg}var zg,aE;function RT(){if(aE)return zg;aE=1;var e=lt(),n=nr().Graph,r=Eu().slack;zg=i;function i(c){var h=new n({directed:!1}),p=c.nodes()[0],d=c.nodeCount();h.setNode(p,{});for(var m,y;o(h,c)<d;)m=l(h,c),y=h.hasNode(m.v)?r(c,m):-r(c,m),u(h,c,y);return h}function o(c,h){function p(d){e.forEach(h.nodeEdges(d),function(m){var y=m.v,w=d===y?m.w:y;!c.hasNode(w)&&!r(h,m)&&(c.setNode(w,{}),c.setEdge(d,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function l(c,h){return e.minBy(h.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return r(h,p)})}function u(c,h,p){e.forEach(c.nodes(),function(d){h.node(d).rank+=p})}return zg}var Bg,lE;function a4(){if(lE)return Bg;lE=1;var e=lt(),n=RT(),r=Eu().slack,i=Eu().longestPath,o=nr().alg.preorder,l=nr().alg.postorder,u=fn().simplify;Bg=c,c.initLowLimValues=m,c.initCutValues=h,c.calcCutValue=d,c.leaveEdge=w,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),i(E);var C=n(E);m(C),h(C,E);for(var I,P;I=w(C);)P=N(C,E,I),_(C,E,I,P)}function h(E,C){var I=l(E,E.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(P){p(E,C,P)})}function p(E,C,I){var P=E.node(I),A=P.parent;E.edge(I,A).cutvalue=d(E,C,I)}function d(E,C,I){var P=E.node(I),A=P.parent,H=!0,z=C.edge(I,A),L=0;return z||(H=!1,z=C.edge(A,I)),L=z.weight,e.forEach(C.nodeEdges(I),function(F){var G=F.v===I,O=G?F.w:F.v;if(O!==A){var j=G===H,q=C.edge(F).weight;if(L+=j?q:-q,S(E,I,O)){var $=E.edge(I,O).cutvalue;L+=j?-$:$}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,I,P,A){var H=I,z=E.node(P);return C[P]=!0,e.forEach(E.neighbors(P),function(L){e.has(C,L)||(I=y(E,C,I,L,P))}),z.low=H,z.lim=I++,A?z.parent=A:delete z.parent,I}function w(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,I){var P=I.v,A=I.w;C.hasEdge(P,A)||(P=I.w,A=I.v);var H=E.node(P),z=E.node(A),L=H,F=!1;H.lim>z.lim&&(L=z,F=!0);var G=e.filter(C.edges(),function(O){return F===k(E,E.node(O.v),L)&&F!==k(E,E.node(O.w),L)});return e.minBy(G,function(O){return r(C,O)})}function _(E,C,I,P){var A=I.v,H=I.w;E.removeEdge(A,H),E.setEdge(P.v,P.w,{}),m(E),h(E,C),b(E,C)}function b(E,C){var I=e.find(E.nodes(),function(A){return!C.node(A).parent}),P=o(E,I);P=P.slice(1),e.forEach(P,function(A){var H=E.node(A).parent,z=C.edge(A,H),L=!1;z||(z=C.edge(H,A),L=!0),C.node(A).rank=C.node(H).rank+(L?z.minlen:-z.minlen)})}function S(E,C,I){return E.hasEdge(C,I)}function k(E,C,I){return I.low<=C.lim&&C.lim<=I.lim}return Bg}var Ug,uE;function l4(){if(uE)return Ug;uE=1;var e=Eu(),n=e.longestPath,r=RT(),i=a4();Ug=o;function o(h){switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":u(h);break;case"longest-path":l(h);break;default:c(h)}}var l=n;function u(h){n(h),r(h)}function c(h){i(h)}return Ug}var Hg,cE;function u4(){if(cE)return Hg;cE=1;var e=lt();Hg=n;function n(o){var l=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),h=c.edgeObj,p=r(o,l,h.v,h.w),d=p.path,m=p.lca,y=0,w=d[y],N=!0;u!==h.w;){if(c=o.node(u),N){for(;(w=d[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(N=!1)}if(!N){for(;y<d.length-1&&o.node(w=d[y+1]).minRank<=c.rank;)y++;w=d[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function r(o,l,u,c){var h=[],p=[],d=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),h.push(y);while(y&&(l[y].low>d||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:h.concat(p.reverse()),lca:w}}function i(o){var l={},u=0;function c(h){var p=u;e.forEach(o.children(h),c),l[h]={low:p,lim:u++}}return e.forEach(o.children(),c),l}return Hg}var Wg,dE;function c4(){if(dE)return Wg;dE=1;var e=lt(),n=fn();Wg={run:r,cleanup:u};function r(c){var h=n.addDummyNode(c,"root",{},"_root"),p=o(c),d=e.max(e.values(p))-1,m=2*d+1;c.graph().nestingRoot=h,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){i(c,h,m,y,d,p,w)}),c.graph().nodeRankFactor=m}function i(c,h,p,d,m,y,w){var N=c.children(w);if(!N.length){w!==h&&c.setEdge(h,w,{weight:0,minlen:p});return}var _=n.addBorderNode(c,"_bt"),b=n.addBorderNode(c,"_bb"),S=c.node(w);c.setParent(_,w),S.borderTop=_,c.setParent(b,w),S.borderBottom=b,e.forEach(N,function(k){i(c,h,p,d,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,I=E.borderBottom?E.borderBottom:k,P=E.borderTop?d:2*d,A=C!==I?1:m-y[w]+1;c.setEdge(_,C,{weight:P,minlen:A,nestingEdge:!0}),c.setEdge(I,b,{weight:P,minlen:A,nestingEdge:!0})}),c.parent(w)||c.setEdge(h,_,{weight:0,minlen:m+y[w]})}function o(c){var h={};function p(d,m){var y=c.children(d);y&&y.length&&e.forEach(y,function(w){p(w,m+1)}),h[d]=m}return e.forEach(c.children(),function(d){p(d,1)}),h}function l(c){return e.reduce(c.edges(),function(h,p){return h+c.edge(p).weight},0)}function u(c){var h=c.graph();c.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(c.edges(),function(p){var d=c.edge(p);d.nestingEdge&&c.removeEdge(p)})}return Wg}var Vg,fE;function d4(){if(fE)return Vg;fE=1;var e=lt(),n=fn();Vg=r;function r(o){function l(u){var c=o.children(u),h=o.node(u);if(c.length&&e.forEach(c,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,d=h.maxRank+1;p<d;++p)i(o,"borderLeft","_bl",u,h,p),i(o,"borderRight","_br",u,h,p)}}e.forEach(o.children(),l)}function i(o,l,u,c,h,p){var d={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=n.addDummyNode(o,"border",d,u);h[l][p]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return Vg}var Gg,hE;function f4(){if(hE)return Gg;hE=1;var e=lt();Gg={adjust:n,undo:r};function n(p){var d=p.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(p)}function r(p){var d=p.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&l(p),(d==="lr"||d==="rl")&&(c(p),i(p))}function i(p){e.forEach(p.nodes(),function(d){o(p.node(d))}),e.forEach(p.edges(),function(d){o(p.edge(d))})}function o(p){var d=p.width;p.width=p.height,p.height=d}function l(p){e.forEach(p.nodes(),function(d){u(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(d){h(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var d=p.x;p.x=p.y,p.y=d}return Gg}var Yg,pE;function h4(){if(pE)return Yg;pE=1;var e=lt();Yg=n;function n(r){var i={},o=e.filter(r.nodes(),function(p){return!r.children(p).length}),l=e.max(e.map(o,function(p){return r.node(p).rank})),u=e.map(e.range(l+1),function(){return[]});function c(p){if(!e.has(i,p)){i[p]=!0;var d=r.node(p);u[d.rank].push(p),e.forEach(r.successors(p),c)}}var h=e.sortBy(o,function(p){return r.node(p).rank});return e.forEach(h,c),u}return Yg}var Kg,mE;function p4(){if(mE)return Kg;mE=1;var e=lt();Kg=n;function n(i,o){for(var l=0,u=1;u<o.length;++u)l+=r(i,o[u-1],o[u]);return l}function r(i,o,l){for(var u=e.zipObject(l,e.map(l,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(w){return{pos:u[w.w],weight:i.edge(w).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var d=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+h;d[w]+=y.weight;for(var N=0;w>0;)w%2&&(N+=d[w+1]),w=w-1>>1,d[w]+=y.weight;m+=y.weight*N})),m}return Kg}var Xg,gE;function m4(){if(gE)return Xg;gE=1;var e=lt();Xg=n;function n(r,i){return e.map(i,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,h){var p=r.edge(h),d=r.node(h.v);return{sum:c.sum+p.weight*d.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return Xg}var Qg,vE;function g4(){if(vE)return Qg;vE=1;var e=lt();Qg=n;function n(o,l){var u={};e.forEach(o,function(h,p){var d=u[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(d.barycenter=h.barycenter,d.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=u[h.v],d=u[h.w];!e.isUndefined(p)&&!e.isUndefined(d)&&(d.indegree++,p.out.push(u[h.w]))});var c=e.filter(u,function(h){return!h.indegree});return r(c)}function r(o){var l=[];function u(p){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(p.barycenter)||d.barycenter>=p.barycenter)&&i(p,d)}}function c(p){return function(d){d.in.push(p),--d.indegree===0&&o.push(d)}}for(;o.length;){var h=o.pop();l.push(h),e.forEach(h.in.reverse(),u(h)),e.forEach(h.out,c(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function i(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return Qg}var Zg,yE;function v4(){if(yE)return Zg;yE=1;var e=lt(),n=fn();Zg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),h=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),d=[],m=0,y=0,w=0;h.sort(o(!!u)),w=i(d,p,w),e.forEach(h,function(_){w+=_.vs.length,d.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=i(d,p,w)});var N={vs:e.flatten(d,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function i(l,u,c){for(var h;u.length&&(h=e.last(u)).i<=c;)u.pop(),l.push(h.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return Zg}var Jg,wE;function y4(){if(wE)return Jg;wE=1;var e=lt(),n=m4(),r=g4(),i=v4();Jg=o;function o(c,h,p,d){var m=c.children(h),y=c.node(h),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(I){return I!==w&&I!==N}));var b=n(c,m);e.forEach(b,function(I){if(c.children(I.v).length){var P=o(c,I.v,p,d);_[I.v]=P,e.has(P,"barycenter")&&u(I,P)}});var S=r(b,p);l(S,_);var k=i(S,d);if(w&&(k.vs=e.flatten([w,k.vs,N],!0),c.predecessors(w).length)){var E=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function l(c,h){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(d){return h[d]?h[d].vs:d}),!0)})}function u(c,h){e.isUndefined(c.barycenter)?(c.barycenter=h.barycenter,c.weight=h.weight):(c.barycenter=(c.barycenter*c.weight+h.barycenter*h.weight)/(c.weight+h.weight),c.weight+=h.weight)}return Jg}var ev,xE;function w4(){if(xE)return ev;xE=1;var e=lt(),n=nr().Graph;ev=r;function r(o,l,u){var c=i(o),h=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var d=o.node(p),m=o.parent(p);(d.rank===l||d.minRank<=l&&l<=d.maxRank)&&(h.setNode(p),h.setParent(p,m||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,N=h.edge(w,p),_=e.isUndefined(N)?0:N.weight;h.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(d,"minRank")&&h.setNode(p,{borderLeft:d.borderLeft[l],borderRight:d.borderRight[l]}))}),h}function i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return ev}var tv,_E;function x4(){if(_E)return tv;_E=1;var e=lt();tv=n;function n(r,i,o){var l={},u;e.forEach(o,function(c){for(var h=r.parent(c),p,d;h;){if(p=r.parent(h),p?(d=l[p],l[p]=h):(d=u,u=h),d&&d!==h){i.setEdge(d,h);return}h=p}})}return tv}var nv,bE;function _4(){if(bE)return nv;bE=1;var e=lt(),n=h4(),r=p4(),i=y4(),o=w4(),l=x4(),u=nr().Graph,c=fn();nv=h;function h(y){var w=c.maxRank(y),N=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),b=n(y);m(y,b);for(var S=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){d(E%2?N:_,E%4>=2),b=c.buildLayerMatrix(y);var I=r(y,b);I<S&&(C=0,k=e.cloneDeep(b),S=I)}m(y,k)}function p(y,w,N){return e.map(w,function(_){return o(y,_,N)})}function d(y,w){var N=new u;e.forEach(y,function(_){var b=_.graph().root,S=i(_,b,N,w);e.forEach(S.vs,function(k,E){_.node(k).order=E}),l(_,N,S.vs)})}function m(y,w){e.forEach(w,function(N){e.forEach(N,function(_,b){y.node(_).order=b})})}return nv}var rv,SE;function b4(){if(SE)return rv;SE=1;var e=lt(),n=nr().Graph,r=fn();rv={positionX:N,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function i(S,k){var E={};function C(I,P){var A=0,H=0,z=I.length,L=e.last(P);return e.forEach(P,function(F,G){var O=l(S,F),j=O?S.node(O).order:z;(O||F===L)&&(e.forEach(P.slice(H,G+1),function(q){e.forEach(S.predecessors(q),function($){var re=S.node($),J=re.order;(J<A||j<J)&&!(re.dummy&&S.node(q).dummy)&&u(E,$,q)})}),H=G+1,A=j)}),P}return e.reduce(k,C),E}function o(S,k){var E={};function C(P,A,H,z,L){var F;e.forEach(e.range(A,H),function(G){F=P[G],S.node(F).dummy&&e.forEach(S.predecessors(F),function(O){var j=S.node(O);j.dummy&&(j.order<z||j.order>L)&&u(E,O,F)})})}function I(P,A){var H=-1,z,L=0;return e.forEach(A,function(F,G){if(S.node(F).dummy==="border"){var O=S.predecessors(F);O.length&&(z=S.node(O[0]).order,C(A,L,G,H,z),L=G,H=z)}C(A,L,A.length,z,P.length)}),A}return e.reduce(k,I),E}function l(S,k){if(S.node(k).dummy)return e.find(S.predecessors(k),function(E){return S.node(E).dummy})}function u(S,k,E){if(k>E){var C=k;k=E,E=C}var I=S[k];I||(S[k]=I={}),I[E]=!0}function c(S,k,E){if(k>E){var C=k;k=E,E=C}return e.has(S[k],E)}function h(S,k,E,C){var I={},P={},A={};return e.forEach(k,function(H){e.forEach(H,function(z,L){I[z]=z,P[z]=z,A[z]=L})}),e.forEach(k,function(H){var z=-1;e.forEach(H,function(L){var F=C(L);if(F.length){F=e.sortBy(F,function($){return A[$]});for(var G=(F.length-1)/2,O=Math.floor(G),j=Math.ceil(G);O<=j;++O){var q=F[O];P[L]===L&&z<A[q]&&!c(E,L,q)&&(P[q]=L,P[L]=I[L]=I[q],z=A[q])}}})}),{root:I,align:P}}function p(S,k,E,C,I){var P={},A=d(S,k,E,I),H=I?"borderLeft":"borderRight";function z(G,O){for(var j=A.nodes(),q=j.pop(),$={};q;)$[q]?G(q):($[q]=!0,j.push(q),j=j.concat(O(q))),q=j.pop()}function L(G){P[G]=A.inEdges(G).reduce(function(O,j){return Math.max(O,P[j.v]+A.edge(j))},0)}function F(G){var O=A.outEdges(G).reduce(function(q,$){return Math.min(q,P[$.w]-A.edge($))},Number.POSITIVE_INFINITY),j=S.node(G);O!==Number.POSITIVE_INFINITY&&j.borderType!==H&&(P[G]=Math.max(P[G],O))}return z(L,A.predecessors.bind(A)),z(F,A.successors.bind(A)),e.forEach(C,function(G){P[G]=P[E[G]]}),P}function d(S,k,E,C){var I=new n,P=S.graph(),A=_(P.nodesep,P.edgesep,C);return e.forEach(k,function(H){var z;e.forEach(H,function(L){var F=E[L];if(I.setNode(F),z){var G=E[z],O=I.edge(G,F);I.setEdge(G,F,Math.max(A(S,L,z),O||0))}z=L})}),I}function m(S,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(E,function(P,A){var H=b(S,A)/2;C=Math.max(P+H,C),I=Math.min(P-H,I)}),C-I})}function y(S,k){var E=e.values(k),C=e.min(E),I=e.max(E);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(A){var H=P+A,z=S[H],L;if(z!==k){var F=e.values(z);L=A==="l"?C-e.min(F):I-e.max(F),L&&(S[H]=e.mapValues(z,function(G){return G+L}))}})})}function w(S,k){return e.mapValues(S.ul,function(E,C){if(k)return S[k.toLowerCase()][C];var I=e.sortBy(e.map(S,C));return(I[1]+I[2])/2})}function N(S){var k=r.buildLayerMatrix(S),E=e.merge(i(S,k),o(S,k)),C={},I;e.forEach(["u","d"],function(A){I=A==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(I=e.map(I,function(G){return e.values(G).reverse()}));var z=(A==="u"?S.predecessors:S.successors).bind(S),L=h(S,I,E,z),F=p(S,I,L.root,L.align,H==="r");H==="r"&&(F=e.mapValues(F,function(G){return-G})),C[A+H]=F})});var P=m(S,C);return y(C,P),w(C,S.graph().align)}function _(S,k,E){return function(C,I,P){var A=C.node(I),H=C.node(P),z=0,L;if(z+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":L=-A.width/2;break;case"r":L=A.width/2;break}if(L&&(z+=E?L:-L),L=0,z+=(A.dummy?k:S)/2,z+=(H.dummy?k:S)/2,z+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":L=H.width/2;break;case"r":L=-H.width/2;break}return L&&(z+=E?L:-L),L=0,z}}function b(S,k){return S.node(k).width}return rv}var sv,kE;function S4(){if(kE)return sv;kE=1;var e=lt(),n=fn(),r=b4().positionX;sv=i;function i(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,h=0;e.forEach(u,function(p){var d=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+d/2}),h+=d+c})}return sv}var iv,EE;function k4(){if(EE)return iv;EE=1;var e=lt(),n=i4(),r=o4(),i=l4(),o=fn().normalizeRanks,l=u4(),u=fn().removeEmptyRanks,c=c4(),h=d4(),p=f4(),d=_4(),m=S4(),y=fn(),w=nr().Graph;iv=N;function N(B,X){var ne=X&&X.debugTiming?y.time:y.notime;ne("layout",function(){var le=ne(" buildLayoutGraph",function(){return z(B)});ne(" runLayout",function(){_(le,ne)}),ne(" updateInputGraph",function(){b(B,le)})})}function _(B,X){X(" makeSpaceForEdgeLabels",function(){L(B)}),X(" removeSelfEdges",function(){W(B)}),X(" acyclic",function(){n.run(B)}),X(" nestingGraph.run",function(){c.run(B)}),X(" rank",function(){i(y.asNonCompoundGraph(B))}),X(" injectEdgeLabelProxies",function(){F(B)}),X(" removeEmptyRanks",function(){u(B)}),X(" nestingGraph.cleanup",function(){c.cleanup(B)}),X(" normalizeRanks",function(){o(B)}),X(" assignRankMinMax",function(){G(B)}),X(" removeEdgeLabelProxies",function(){O(B)}),X(" normalize.run",function(){r.run(B)}),X(" parentDummyChains",function(){l(B)}),X(" addBorderSegments",function(){h(B)}),X(" order",function(){d(B)}),X(" insertSelfEdges",function(){Z(B)}),X(" adjustCoordinateSystem",function(){p.adjust(B)}),X(" position",function(){m(B)}),X(" positionSelfEdges",function(){M(B)}),X(" removeBorderNodes",function(){J(B)}),X(" normalize.undo",function(){r.undo(B)}),X(" fixupEdgeLabelCoords",function(){$(B)}),X(" undoCoordinateSystem",function(){p.undo(B)}),X(" translateGraph",function(){j(B)}),X(" assignNodeIntersects",function(){q(B)}),X(" reversePoints",function(){re(B)}),X(" acyclic.undo",function(){n.undo(B)})}function b(B,X){e.forEach(B.nodes(),function(ne){var le=B.node(ne),fe=X.node(ne);le&&(le.x=fe.x,le.y=fe.y,X.children(ne).length&&(le.width=fe.width,le.height=fe.height))}),e.forEach(B.edges(),function(ne){var le=B.edge(ne),fe=X.edge(ne);le.points=fe.points,e.has(fe,"x")&&(le.x=fe.x,le.y=fe.y)}),B.graph().width=X.graph().width,B.graph().height=X.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],I={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function z(B){var X=new w({multigraph:!0,compound:!0}),ne=U(B.graph());return X.setGraph(e.merge({},k,Y(ne,S),e.pick(ne,E))),e.forEach(B.nodes(),function(le){var fe=U(B.node(le));X.setNode(le,e.defaults(Y(fe,C),I)),X.setParent(le,B.parent(le))}),e.forEach(B.edges(),function(le){var fe=U(B.edge(le));X.setEdge(le,e.merge({},A,Y(fe,P),e.pick(fe,H)))}),X}function L(B){var X=B.graph();X.ranksep/=2,e.forEach(B.edges(),function(ne){var le=B.edge(ne);le.minlen*=2,le.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?le.width+=le.labeloffset:le.height+=le.labeloffset)})}function F(B){e.forEach(B.edges(),function(X){var ne=B.edge(X);if(ne.width&&ne.height){var le=B.node(X.v),fe=B.node(X.w),te={rank:(fe.rank-le.rank)/2+le.rank,e:X};y.addDummyNode(B,"edge-proxy",te,"_ep")}})}function G(B){var X=0;e.forEach(B.nodes(),function(ne){var le=B.node(ne);le.borderTop&&(le.minRank=B.node(le.borderTop).rank,le.maxRank=B.node(le.borderBottom).rank,X=e.max(X,le.maxRank))}),B.graph().maxRank=X}function O(B){e.forEach(B.nodes(),function(X){var ne=B.node(X);ne.dummy==="edge-proxy"&&(B.edge(ne.e).labelRank=ne.rank,B.removeNode(X))})}function j(B){var X=Number.POSITIVE_INFINITY,ne=0,le=Number.POSITIVE_INFINITY,fe=0,te=B.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(je){var ye=je.x,ke=je.y,Ye=je.width,we=je.height;X=Math.min(X,ye-Ye/2),ne=Math.max(ne,ye+Ye/2),le=Math.min(le,ke-we/2),fe=Math.max(fe,ke+we/2)}e.forEach(B.nodes(),function(je){ve(B.node(je))}),e.forEach(B.edges(),function(je){var ye=B.edge(je);e.has(ye,"x")&&ve(ye)}),X-=ce,le-=Ce,e.forEach(B.nodes(),function(je){var ye=B.node(je);ye.x-=X,ye.y-=le}),e.forEach(B.edges(),function(je){var ye=B.edge(je);e.forEach(ye.points,function(ke){ke.x-=X,ke.y-=le}),e.has(ye,"x")&&(ye.x-=X),e.has(ye,"y")&&(ye.y-=le)}),te.width=ne-X+ce,te.height=fe-le+Ce}function q(B){e.forEach(B.edges(),function(X){var ne=B.edge(X),le=B.node(X.v),fe=B.node(X.w),te,ce;ne.points?(te=ne.points[0],ce=ne.points[ne.points.length-1]):(ne.points=[],te=fe,ce=le),ne.points.unshift(y.intersectRect(le,te)),ne.points.push(y.intersectRect(fe,ce))})}function $(B){e.forEach(B.edges(),function(X){var ne=B.edge(X);if(e.has(ne,"x"))switch((ne.labelpos==="l"||ne.labelpos==="r")&&(ne.width-=ne.labeloffset),ne.labelpos){case"l":ne.x-=ne.width/2+ne.labeloffset;break;case"r":ne.x+=ne.width/2+ne.labeloffset;break}})}function re(B){e.forEach(B.edges(),function(X){var ne=B.edge(X);ne.reversed&&ne.points.reverse()})}function J(B){e.forEach(B.nodes(),function(X){if(B.children(X).length){var ne=B.node(X),le=B.node(ne.borderTop),fe=B.node(ne.borderBottom),te=B.node(e.last(ne.borderLeft)),ce=B.node(e.last(ne.borderRight));ne.width=Math.abs(ce.x-te.x),ne.height=Math.abs(fe.y-le.y),ne.x=te.x+ne.width/2,ne.y=le.y+ne.height/2}}),e.forEach(B.nodes(),function(X){B.node(X).dummy==="border"&&B.removeNode(X)})}function W(B){e.forEach(B.edges(),function(X){if(X.v===X.w){var ne=B.node(X.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:X,label:B.edge(X)}),B.removeEdge(X)}})}function Z(B){var X=y.buildLayerMatrix(B);e.forEach(X,function(ne){var le=0;e.forEach(ne,function(fe,te){var ce=B.node(fe);ce.order=te+le,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(B,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++le,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function M(B){e.forEach(B.nodes(),function(X){var ne=B.node(X);if(ne.dummy==="selfedge"){var le=B.node(ne.e.v),fe=le.x+le.width/2,te=le.y,ce=ne.x-fe,Ce=le.height/2;B.setEdge(ne.e,ne.label),B.removeNode(X),ne.label.points=[{x:fe+2*ce/3,y:te-Ce},{x:fe+5*ce/6,y:te-Ce},{x:fe+ce,y:te},{x:fe+5*ce/6,y:te+Ce},{x:fe+2*ce/3,y:te+Ce}],ne.label.x=ne.x,ne.label.y=ne.y}})}function Y(B,X){return e.mapValues(e.pick(B,X),Number)}function U(B){var X={};return e.forEach(B,function(ne,le){X[le.toLowerCase()]=ne}),X}return iv}var ov,NE;function E4(){if(NE)return ov;NE=1;var e=lt(),n=fn(),r=nr().Graph;ov={debugOrdering:i};function i(o){var l=n.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,h){var p="layer"+h;u.setNode(p,{rank:"same"}),e.reduce(c,function(d,m){return u.setEdge(d,m,{style:"invis"}),m})}),u}return ov}var av,CE;function N4(){return CE||(CE=1,av="0.8.5"),av}var lv,TE;function C4(){return TE||(TE=1,lv={graphlib:nr(),layout:k4(),debug:E4(),util:{time:fn().time,notime:fn().notime},version:N4()}),lv}var T4=C4();const RE=Lv(T4),po=240,Nu=130,oo=74,Zu=72,jE=oo+Zu;function R4(e,n){var i;let r=po;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??po);return r}const jT=420,j4=2;function ba(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function A4(e,n){return((n==null?void 0:n.get(e))??0)>0?jT:0}function I4(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function Sa(e,n,r){const i=n.get(e);return{w:((i==null?void 0:i.width)??po)+A4(e,r),h:Math.max((i==null?void 0:i.height)??Nu,I4(e,r))}}function M4(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function O4(e,n,r,i,o,l){const u=new RE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),h=new Set(c);for(const S of c){const{w:k,h:E}=Sa(S,i,l);u.setNode(S,{width:k,height:E})}for(const S of n)h.has(S.source)&&h.has(S.target)&&u.setEdge(S.source,S.target);RE.layout(u);const p=new Map;let d=1/0,m=1/0,y=-1/0,w=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const E=i.get(S),C=(E==null?void 0:E.width)??po,I=(E==null?void 0:E.height)??Nu,P=Sa(S,i,l),A=k.x-P.w/2,H=k.y-P.h/2;p.set(S,{x:A,y:H}),A<d&&(d=A),H<m&&(m=H),A+C>y&&(y=A+C),H+I>w&&(w=H+I)}if(Number.isFinite(d)&&Number.isFinite(m))for(const[S,k]of p)p.set(S,{x:k.x-d,y:k.y-m});const N=Number.isFinite(y)?y-d:0,_=Number.isFinite(w)?w-m:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const E=i.get(S),C=(E==null?void 0:E.width)??po,I=(E==null?void 0:E.height)??Nu;b=b===null?{minX:k.x,minY:k.y,maxX:k.x+C,maxY:k.y+I}:{minX:Math.min(b.minX,k.x),minY:Math.min(b.minY,k.y),maxX:Math.max(b.maxX,k.x+C),maxY:Math.max(b.maxY,k.y+I)}}return{positions:p,width:N,height:_,pinnedBox:b}}function P4(e,n,r={}){const i=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const S of e){const k=ba(S),E=c.get(k);E?E.push(S.id):c.set(k,[S.id])}const p=Array.from(c.keys()).sort().map(S=>({sid:S,...O4(c.get(S),n,i,l,o,u)})),d=R4(e,l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let E=0;for(const C of p)k.length<S&&E>0&&E+C.height>m&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+jE;return k},w=S=>S.reduce((k,E)=>Math.max(k,E.width),0)+jT;let N=y(r.availableWidth?j4:1);N.length>1&&N.reduce((k,E)=>k+w(E),0)+d*(N.length-1)>(r.availableWidth??0)&&(N=y(1));const _=new Map;let b=0;for(const S of N){const k=w(S);let E=0;for(const{positions:C,height:I,pinnedBox:P}of S){for(const[H,z]of C)_.set(H,{x:z.x+b,y:z.y+E});let A=E+I;P&&P.maxY>A&&P.minX<b+k&&b<P.maxX&&(A=P.maxY),E=A+jE}b+=k+d}return e.map(S=>{const k=o.get(S.id);if(k)return{...S,position:k};const E=_.get(S.id);return E?{...S,position:E}:S})}function L4(e,n,r,i,o){const u=oo+Zu,c=60,h=w=>Sa(w,i,o),p=new Map(e.map(w=>[w.id,ba(w)])),d=[],m=e.map(w=>({id:w.id,pos:r.get(w.id)??n.get(w.id)})).filter(w=>w.pos!=null).sort((w,N)=>w.pos.y-N.pos.y||w.pos.x-N.pos.x||w.id.localeCompare(N.id)),y=[];for(const{id:w,pos:N}of m){const{w:_,h:b}=h(w),S=p.get(w)??"_default";if(r.has(w)){d.push({x:N.x,y:N.y,w:_,h:b,sid:S});continue}let k=N.y;for(let E=0;E<d.length+1;E++){const C=d.find(I=>{const P=I.sid===S?24:c,A=I.sid===S?24:u;return N.x<I.x+I.w+P&&I.x<N.x+_+P&&k<I.y+I.h+A&&I.y<k+b+A});if(!C)break;k=C.y+C.h+(C.sid===S?24:u)}k!==N.y&&(n.set(w,{x:N.x,y:k}),y.push(w)),d.push({x:N.x,y:k,w:_,h:b,sid:S})}return y}function q4(e,n,r,i,o,l){const u=_=>Sa(_,i,l),c=_=>r.get(_)??n.get(_),h=new Map;for(const _ of e){if(!c(_.id))continue;const b=ba(_),S=h.get(b);S?S.push(_):h.set(b,[_])}const p=new Set;for(const[_,b]of h)b.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(_);const d=new Map,m=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),E=ba(_);p.has(E)?(d.get(E)??d.set(E,[]).get(E)).push(_):m.push({x:b.x,y:b.y,w:S,h:k})}if(d.size===0)return[];const y=oo+Zu,w=(_,b,S,k)=>m.some(E=>_<E.x+E.w+oo&&E.x<_+S+oo&&b<E.y+E.h+y&&E.y<b+k+y),N=[];for(const _ of[...d.keys()].sort()){const b=d.get(_);let S=1/0,k=1/0,E=-1/0,C=-1/0;for(const F of b){const G=c(F.id),{w:O,h:j}=u(F.id);S=Math.min(S,G.x),k=Math.min(k,G.y),E=Math.max(E,G.x+O),C=Math.max(C,G.y+j)}const I=E-S,P=C-k,A=[...new Set(m.map(F=>Math.round(F.x)))].sort((F,G)=>F-G),H=A.length?A:[S],z=[0,...m.map(F=>F.y+F.h+y)].sort((F,G)=>F-G);let L=null;e:for(const F of H)for(const G of z){if(G>=k)break;if(!w(F,G,I,P)){L={x:F,y:G};break e}}if(L){const F=L.x-S,G=L.y-k;for(const O of b){const j=c(O.id);n.set(O.id,{x:j.x+F,y:j.y+G})}N.push(_)}for(const F of b){const G=c(F.id),{w:O,h:j}=u(F.id);m.push({x:G.x,y:G.y,w:O,h:j})}}return N}function $4(e,n,r,i,o,l=!1,u){const p=oo+Zu+1,d=8,m=1.75,y=200,w=.7,N=.01,_=L=>Sa(L,i,u),b=L=>r.get(L)??n.get(L),S=new Map;for(const L of e){if(!b(L.id))continue;const F=ba(L),G=S.get(F);G?G.push(L):S.set(F,[L])}const k=[],E=new Set,C=new Set,I=o.size===0;for(const L of[...S.keys()].sort()){const F=S.get(L);let G=1/0,O=1/0,j=-1/0,q=-1/0,$=!1;for(const Z of F){const M=b(Z.id),{w:Y,h:U}=_(Z.id);G=Math.min(G,M.x),O=Math.min(O,M.y),j=Math.max(j,M.x+Y),q=Math.max(q,M.y+U),r.has(Z.id)&&($=!0)}const re=j-G,J=q-O;C.add(L);const W=o.get(L);W&&(re>W.w+d||J>W.h+d)&&E.add(L),o.set(L,{w:re,h:J}),k.push({sid:L,members:F.map(Z=>Z.id),x:G,y:O,w:re,h:J,anchored:$,mass:1})}for(const L of[...o.keys()])C.has(L)||o.delete(L);if(l||I)return[];let P=!1;for(let L=0;L<k.length&&!P;L++)for(let F=L+1;F<k.length;F++){const G=k[L],O=k[F];if(!(G.anchored&&O.anchored)&&Math.abs(G.x+G.w/2-(O.x+O.w/2))<(G.w+O.w)/2+61&&Math.abs(G.y+G.h/2-(O.y+O.h/2))<(G.h+O.h)/2+p){P=!0;break}}if(E.size===0&&!P)return[];if(E.size>0)for(const L of k)E.has(L.sid)&&(L.mass=8);else for(const L of k)L.mass=Math.max(1,L.w*L.h/(po*Nu));const A=new Map(k.map(L=>[L.sid,L.x])),H=new Map(k.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const F=new Map,G=new Map;let O=0;for(let j=0;j<k.length;j++)for(let q=j+1;q<k.length;q++){const $=k[j],re=k[q];if($.anchored&&re.anchored)continue;const J=$.x+$.w/2,W=$.y+$.h/2,Z=re.x+re.w/2,M=re.y+re.h/2,Y=($.w+re.w)/2+61-Math.abs(J-Z),U=($.h+re.h)/2+p-Math.abs(W-M);if(Y<=0||U<=0)continue;const B=(De,Je)=>!De.anchored&&!(Je<0&&De.x<=0),X=(De,Je)=>!De.anchored&&!(Je<0&&De.y<=0),ne=(De,Je,Xe)=>{const Mt=De===Je,ut=Mt?$.sid<re.sid?-1:1:Math.sign(De-Je);return Xe($,ut)||Xe(re,-ut)?ut:Mt&&(Xe($,-ut)||Xe(re,ut))?-ut:0},le=ne(J,Z,B),fe=ne(W,M,X),te=le!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||Y*m<U),[ve,je,ye,ke]=Ce?[le,Y,F,B]:[fe,U,G,X],Ye=ke($,ve),we=ke(re,-ve),_e=$.mass,Be=re.mass,it=Ye?we?Be/(_e+Be):1:0,yt=we?Ye?_e/(_e+Be):1:0,Ze=je*w;ye.set($.sid,(ye.get($.sid)??0)+ve*Ze*it),ye.set(re.sid,(ye.get(re.sid)??0)-ve*Ze*yt),O+=Ze}for(const j of k)j.anchored||(j.x=Math.max(0,j.x+(F.get(j.sid)??0)),j.y=Math.max(0,j.y+(G.get(j.sid)??0)));if(O<N)break}const z=[];for(const L of k){const F=L.x-A.get(L.sid),G=L.y-H.get(L.sid);if(!(Math.abs(F)<1&&Math.abs(G)<1)){for(const O of L.members){if(r.has(O))continue;const j=n.get(O);j&&n.set(O,{x:j.x+F,y:j.y+G})}z.push(L.sid)}}return z}const D4=600;function Av(e,n){return!(e.exitAt!=null&&n-e.exitAt>D4||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function F4(e,n){const r=new Set;for(const i of e.agents.values())Av(i,n)&&r.add(i.id);return r}function z4(e,n,r=0){return e.right+r>n.left&&e.left-r<n.right&&e.bottom+r>n.top&&e.top-r<n.bottom}function B4(e,n,r=0){if(!e)return!1;for(const i of n)if(z4(e,i,r))return!0;return!1}const AT="sessionGroup";function U4(e,n){var i;if(e.type===AT)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const H4="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function W4(e){if(e.checkDisabled)return H4;if(e.checking)return"Asking npm for the newest release…";const n=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",r=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${n}${r} · re-checked periodically · click to check npm now`}function V4(e){const n=`Version v${e.running}`;return e.checkDisabled?`${n}, update checks are off`:e.checking?`${n}, checking npm for a newer release`:`${n}, check npm for a newer release`}function G4(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as its first hook fires.",workspace:null,tail:""};const n=e.trim();return n===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:n,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Iv={kind:"assumed",claude:!0,codex:!0};function Y4(e){if(!e||typeof e!="object")return Iv;const n=e.providers;if(!n||typeof n!="object")return Iv;const r=n;return{kind:"reported",claude:r.claude!==!1,codex:r.codex!==!1}}function IT(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function K4(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${IT(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 X4(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:`${IT(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 MT(e,n){return e!==""&&n>0}function Q4(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:MT(e,n)}}function Mv(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 Z4(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function J4(e,n,r){const i=new Date(e),o=Mv(n-e);return{label:Z4(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function aa(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const e5={agent:HP,sessionGroup:s3},OT="react-flow__node";function AE(e){var n,r;return!!e&&((r=(n=e.classList)==null?void 0:n.contains)==null?void 0:r.call(n,OT))===!0}function t5(e){try{const n=document.querySelector(`.${OT}[data-id="${CSS.escape(e)}"]`);n==null||n.focus({preventScroll:!0})}catch{}}const n5=420,ou=18,r5=9e4,s5=200,i5=5*6e4,o5=6,a5=2*6e4,by="agent-dag.layout",Sy="agent-dag.viewport",PT="agent-dag.summariesDismissed",LT="agent-dag.sessionListOpen",qT="agent-dag.detailOpen",$T="agent-dag.usagePanelOpen",IE="agent-dag.accountsPanelOpen",ME="agent-dag.versionNoticeDismissed",OE="agent-dag.oldNameNoticeDismissed",l5=15*6e4,PE={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:"},LE="agent-dag.autoRestart",qE="agent-dag.bundleReloadedFor";function u5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(LT)==="1"}catch{return!1}}function c5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(LT,e?"1":"0")}catch{}}function d5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qT)==="1"}catch{return!1}}function f5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qT,e?"1":"0")}catch{}}function h5(){const e=RC($T);return e===null?!0:e==="1"}function p5(e){if(!(typeof window>"u"))try{window.localStorage.setItem($T,e?"1":"0")}catch{}}function m5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(PT);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 $E(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(PT,JSON.stringify(r))}catch{}}function g5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(by);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 uv(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(by,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function v5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Sy);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 y5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Sy,JSON.stringify(e))}catch{}}function DE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(by)}catch{}try{window.localStorage.removeItem(Sy)}catch{}}}function w5(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=`${en}-${p}-${n.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ov={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Pv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},x5={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function DT(e){return e.startsWith("mcp__")?"mcp":x5[e]??"other"}function FT(e,n){var i,o,l;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))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function _5(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 b5(e,n,r,i,o,l,u,c,h,p,d,m,y,w,N,_,b,S,k){const E=[],C=[],I=new Set;if(l)for(const O of e.agents.values())S.has(O.id)&&FT(O,l)&&I.add(O.id);const P=MT(l,I.size);for(const O of e.agents.values()){if(!S.has(O.id))continue;const j=P&&!I.has(O.id),q=O.exitAt!=null,$=b!=null&&!b.has(O.id),re=[j?"rf-dim":"",q?"rf-exiting":"",$?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(O.id);if(E.push({id:O.id,type:"agent",position:{x:0,y:0},data:{...O,now:n,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),O.parentId&&S.has(O.parentId)){const W=ey(O.sessionId),Z=l&&!I.has(O.id)&&!I.has(O.parentId),M=q,Y=_.size>0&&(_.has(O.id)||_.has(O.parentId)),U=b!=null&&!b.has(O.id)&&!b.has(O.parentId),B=O.state==="active"?2:1.5,X=Y?B+1.5:B,ne=Z||M?.2:U?.12:1,le=["sess-edge",O.state==="active"?"sess-live":"sess-idle",M?"rf-edge-exiting":"",Y?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${O.parentId}->${O.id}`,source:O.parentId,target:O.id,animated:(O.state==="active"||Y)&&!Z&&!M,type:"smoothstep",style:{"--session-hue":W,strokeWidth:X,opacity:ne,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:le})}}const A=new Map;for(const O of e.agents.values())O.tools.length>0&&A.set(O.id,Math.min(4,O.tools.length));const H=`${w}#lanes:${M4(A)}`,z=E.filter(O=>HL(O.id,o,m,y));if(z.length>0||H!==N.current){if(z.length>0){const O=P4(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:A});for(const j of O)TC(j.id,m,y)&&VL(j.id,j.position,m,y);q4(E,m,o,u,new Set(z.map(j=>j.id)),A)}L4(E,m,o,u,A),N.current=H}const L=$4(E,m,o,u,c,!p||d,A);L.length>0&&h(L),nu(m,e.agents),nu(y,e.agents),nu(o,e.agents),nu(u,UL(e.agents.values()));const F=[];let G=!1;for(const O of E){let j=o.get(O.id)??m.get(O.id);j||(j=WL(O.id,m,y),G=!0),F.push({...O,position:j})}return G&&(N.current=""),{nodes:F,edges:C}}function S5(){return g.jsx(Jv,{children:g.jsx(k5,{})})}function k5(){var Ha,Wa,Va,Ga;const e=Ta(),n=R.useRef(Nv()),[,r]=R.useState(0),i=R.useCallback(()=>r(V=>V+1),[]),[o,l]=R.useState(()=>new Set),[u,c]=R.useState(null),[h,p]=R.useState(null),d=R.useCallback((V,K)=>{l(ae=>{if(!K)return new Set([V]);const de=new Set(ae);return de.has(V)?de.delete(V):de.add(V),de}),c(ae=>K&&ae===V?ae:V)},[]),m=R.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=R.useState(null),[N,_]=R.useState(null),b=R.useCallback(V=>_(V),[]),[S,k]=R.useState(!1),E=R.useRef(m5()),[C,I]=R.useState(u5);R.useEffect(()=>{c5(C)},[C]);const[P,A]=R.useState(d5);R.useEffect(()=>{f5(P)},[P]);const[H,z]=R.useState(h5);R.useEffect(()=>{p5(H)},[H]);const[L,F]=R.useState(()=>{try{const V=window.localStorage.getItem(IE);return V===null?!0:V==="1"}catch{return!0}});R.useEffect(()=>{try{window.localStorage.setItem(IE,L?"1":"0")}catch{}},[L]);const[G,O]=R.useState(null),[j,q]=R.useState(!1),[$,re]=R.useState(0),[J,W]=R.useState(0);R.useEffect(()=>{fetch("/api/sound-hook").then(V=>V.ok?V.json():null).then(V=>{V!=null&&V.ok&&(O(V.enabled===!0),re((V.foreign??[]).filter(K=>K.worksHere).length),W(typeof V.parked=="number"?V.parked:0))}).catch(()=>{})},[]);const Z=R.useCallback(async()=>{q(!0);try{const K=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!G})})).json().catch(()=>null);K!=null&&K.ok&&O(K.enabled===!0),fetch("/api/sound-hook").then(ae=>ae.ok?ae.json():null).then(ae=>{ae!=null&&ae.ok&&(re((ae.foreign??[]).filter(de=>de.worksHere).length),W(typeof ae.parked=="number"?ae.parked:0))}).catch(()=>{})}catch{}finally{q(!1)}},[G]),[M,Y]=R.useState(!1),[U,B]=R.useState(null),[X,ne]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(ME)??""}catch{return""}}),[le,fe]=R.useState(!1),te=R.useRef(0),[ce,Ce]=R.useState(!1),ve=R.useCallback((V=!1)=>{V&&(te.current=Date.now(),Ce(!0)),fetch(V?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&B(K)}).catch(()=>{}).finally(()=>{V&&Ce(!1)})},[]),je=R.useCallback(()=>{ve(Date.now()-te.current>=l5)},[ve]);R.useEffect(()=>{ve();const V=window.setInterval(je,5*6e4),K=()=>{document.visibilityState==="visible"&&je()};return document.addEventListener("visibilitychange",K),()=>{window.clearInterval(V),document.removeEventListener("visibilitychange",K)}},[ve,je]),R.useEffect(()=>{M&&ve()},[M,ve]);const ye=(U==null?void 0:U.notice)??null,[ke,Ye]=R.useState(null),[we,_e]=R.useState(Iv);R.useEffect(()=>{let V=!1;return fetch("/api/health").then(K=>K.ok?K.json():null).then(K=>{V||(_e(Y4(K)),!(!K||typeof K.workspace!="string")&&Ye(K.workspace))}).catch(()=>{}),()=>{V=!0}},[M]);const Be=R.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",yt=ye!=null&&X!==it,Ze=R.useCallback(()=>{if(!ye)return;const V=X===it?"":it;ne(V);try{window.localStorage.setItem(ME,V)}catch{}},[ye,it,X]),[De,Je]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(OE)??""}catch{return""}}),Xe=U!=null&&U.invokedAs&&U.invokedAs!==en?U.invokedAs:null,Mt=Xe!=null&&De!==Xe,ut=R.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(OE,Xe)}catch{}}},[Xe]),Qe=((Ha=U==null?void 0:U.upgrade)==null?void 0:Ha.state)??"idle",Ot=IL(U==null?void 0:U.upgrade),Ft=R.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);R.useEffect(()=>{if(Qe!=="running")return;const V=window.setInterval(ve,3e3);return()=>window.clearInterval(V)},[Qe,ve]);const et=R.useCallback(async()=>{var ae;const V=U==null?void 0:U.command;if(!V)return;let K=!1;try{K=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(V).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{K=!1}if(!K)try{const de=document.createElement("textarea");de.value=V,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),K=document.execCommand("copy"),de.remove()}catch{K=!1}K&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[U==null?void 0:U.command]),St=R.useCallback(()=>{I(V=>(V||F(!1),!V))},[]),pt=R.useCallback(()=>{F(V=>(V||I(!1),!V))},[]),[wt,hn]=R.useState(!1),[Yt,Pt]=R.useState(0),Sn=R.useRef(null),[gr,kn]=R.useState(!1),zt=R.useRef(null),[Fn,pn]=R.useState(0),vr=R.useRef(XL()),[Wr,gi]=R.useState(!1),Vr=R.useCallback(()=>{const V=vr.current,K=V.setPaused(!V.paused);for(const ae of K)n.current=qx(n.current,ae);gi(V.paused)},[]),[ct,vi]=R.useState(Date.now()),[mn,Cs]=R.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(LE)!=="0"}catch{return!0}}),yr=R.useCallback(()=>{Cs(V=>{const K=!V;try{window.localStorage.setItem(LE,K?"1":"0")}catch{}return K})},[]),[zn,En]=R.useState(!1),[Gr,Yr]=R.useState("restart"),[Kr,yi]=R.useState(null),ir=R.useRef(!1),Ts=R.useRef(null),Nn=R.useRef(0),wr=R.useCallback(async V=>{if(ir.current)return;const K=(V==null?void 0:V.upgrade)===!0;ir.current=!0,Ts.current=Ot;const ae=++Nn.current;Yr(K?"npx":"restart"),En(!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:K})})}catch{}window.setTimeout(()=>{if(Nn.current===ae&&ir.current){ir.current=!1,En(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},K?18e4:3e4)},[ye==null?void 0:ye.to,Ot]),Rs=R.useRef(null);R.useEffect(()=>{let V=!1;for(const ae of n.current.agents.values())if(ae.state==="active"){V=!0;break}const K=OL({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(U==null?void 0:U.canRestart)===!0,busy:V,idleSince:Rs.current,now:ct});Rs.current=K.idleSince,K.restart&&wr()},[mn,ye==null?void 0:ye.kind,U==null?void 0:U.canRestart,ct,wr]),R.useEffect(()=>{const V=U==null?void 0:U.running;let K=null,ae=null;try{K=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(qE)}catch{return}const de=AL({bundle:"1.35.2",running:V,pending:K,lastTried:ae});if(de==="reload"){try{window.sessionStorage.setItem(qE,V??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}ir.current=!1,En(!1),yi(V??null);const xe=window.setTimeout(()=>yi(null),6e3);return()=>window.clearTimeout(xe)},[U==null?void 0:U.running]),R.useEffect(()=>{if(zn&&ML({asked:Ts.current,reported:Ot})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}ir.current=!1,En(!1)}},[zn,Ot]);const js=R.useRef(g5()).current;R.useRef(!1);const Rt=R.useRef(new Map(js.positions.filter(([V])=>js.pins.includes(V)))),xr=R.useRef(null),_r=R.useState(()=>v5())[0],[Kt,Xr]=R.useState(""),[wi,nt]=R.useState(()=>new Set),[br,Qr]=R.useState(tq),[As,Zr]=R.useState(!1),Jr=R.useRef(null);R.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(jC,br)}catch{}},[br]),R.useEffect(()=>{if(!_r)return;const V=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(V)},[e,_r]);const Is=R.useRef(!0);R.useEffect(()=>{const V=new EventSource("/events"),K=KL(i,{now:()=>Date.now(),setTimeout:(ae,de)=>window.setTimeout(ae,de),clearTimeout:ae=>window.clearTimeout(ae)});return V.addEventListener("open",()=>{Y(!0),Zr(!0)}),V.addEventListener("error",()=>Y(!1)),V.addEventListener("replay-end",()=>{Is.current=!1,K.flush()}),V.addEventListener("hook",ae=>{try{const de=JSON.parse(ae.data);if(!vr.current.accept(de))return;n.current=qx(n.current,de),de.replay===!0||Is.current||Date.now()-de.receivedAt>3e4?K.replay():K.live()}catch{}}),()=>{V.close(),K.cancel()}},[i]),R.useEffect(()=>{const V=setInterval(()=>{const K=Date.now();vi(K);let ae=dP(n.current,K,r5);hP(n.current,K,fP)&&(ae=!0),uP(n.current,K,s5,i5)&&(ae=!0),cP(n.current,K,o5,a5)&&(ae=!0),ae&&i()},250);return()=>clearInterval(V)},[i]);const or=R.useRef(null),kt=R.useRef(0),Ms=420,mt=R.useCallback((V=500)=>{try{const Ee=document.querySelector(".canvas-wrap"),Oe=Array.from(document.querySelectorAll(".react-flow__node")).filter(ot=>ot.offsetWidth>0);if(!Ee||Oe.length===0)return;const Fe=Ee.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const Ve=ot=>(ot-Fe.left-Ge.x)/Ge.zoom,$e=ot=>(ot-Fe.top-Ge.y)/Ge.zoom,Tn=Oe.map(ot=>ot.getBoundingClientRect()),Us=Math.min(...Tn.map(ot=>Ve(ot.left))),jo=Math.max(...Tn.map(ot=>Ve(ot.right))),Hs=Math.min(...Tn.map(ot=>$e(ot.top))),Ao=Math.max(...Tn.map(ot=>$e(ot.bottom))),Ya=jo-Us,Ci=Ao-Hs;if(!(Ya>0&&Ci>0))return;const yn=Math.max(.2,Math.min(1,(Fe.width-160)/(Ya+Ms)*.86,(Fe.height-160)/Ci*.86));e.setViewport({x:80-Us*yn,y:Math.max(80,(Fe.height-Ci*yn)/2)-Hs*yn,zoom:yn},{duration:V}),kt.current=Date.now(),window.setTimeout(()=>{try{const ot={x:80-Us*yn,y:Math.max(80,(Fe.height-Ci*yn)/2)-Hs*yn,zoom:yn},Ka=e.getViewport();(Math.abs(Ka.zoom-yn)>.01||Math.abs(Ka.x-ot.x)>2)&&e.setViewport(ot,{duration:0})}catch{}},V+60)}catch{}},[e]),_o=R.useRef(""),bo=R.useRef(null),Pa=R.useRef(0),Sr=R.useCallback(()=>{Pa.current=Date.now()},[]),es="agent-dag.autoFitDisabled",gn=R.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(es)==="1"}catch{return!1}})()),[Os,La]=R.useState(gn.current),qa=R.useCallback(()=>{if(!gn.current){gn.current=!0,La(!0);try{window.localStorage.setItem(es,"1")}catch{}}},[]),So=R.useCallback(()=>{gn.current=!1,La(!1);try{window.localStorage.removeItem(es)}catch{}mt(400)},[e,mt]);R.useEffect(()=>{const V=setInterval(()=>{if(gn.current||Date.now()-Pa.current<800)return;const K=n.current,ae=Date.now(),de=[];for(const Ve of K.agents.values())Av(Ve,ae)&&de.push({id:Ve.id});if(de.length===0)return;const xe=e.getViewport(),Ee=window.innerWidth-360,Oe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:Ve}of de){const $e=ar.current.get(Ve),Tn=Rt.current.get(Ve)??Xt.current.get(Ve);if(!$e||!Tn)continue;Ge=!0;const Us=Tn.x*xe.zoom+xe.x,jo=Tn.y*xe.zoom+xe.y,Hs=(Tn.x+$e.width)*xe.zoom+xe.x,Ao=(Tn.y+$e.height)*xe.zoom+xe.y;if(Hs>0&&Us<Ee&&Ao>0&&jo<Oe){Fe=!0;break}}Ge&&!Fe&&mt(600)},1500);return()=>clearInterval(V)},[e]);const xi=R.useRef(!1),ar=R.useRef(new Map),ts=R.useRef(0),Ju=R.useCallback(V=>{const K=ar.current;let ae=!1;for(const de of V.nodeInternals.values()){const xe=de.width,Ee=de.height;if(xe==null||Ee==null)continue;const Oe=K.get(de.id);Oe?(Math.abs(Oe.height-Ee)>4||Math.abs(Oe.width-xe)>4)&&(K.set(de.id,{width:xe,height:Ee}),ae=!0):(K.set(de.id,{width:xe,height:Ee}),ae=!0)}return ae&&(ts.current+=1),ts.current},[]),_i=Ke(Ju),[He,$a]=R.useState(0);R.useEffect(()=>{let V=0;const K=()=>{const de=ar.current;let xe=!1;for(const Ee of document.querySelectorAll(".react-flow__node[data-id]")){const Oe=Ee.getAttribute("data-id");if(!Oe)continue;const Fe=Ee.offsetWidth,Ge=Ee.offsetHeight;if(!Fe||!Ge)continue;const Ve=de.get(Oe);(!Ve||Math.abs(Ve.width-Fe)>4||Math.abs(Ve.height-Ge)>4)&&(de.set(Oe,{width:Fe,height:Ge}),xe=!0)}xe&&$a(Ee=>Ee+1)};if(xi.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(K,32):V=requestAnimationFrame(K),()=>{cancelAnimationFrame(V),window.clearTimeout(ae)}});const Xt=R.useRef(new Map(js.positions)),ko=R.useRef(new Set),bi=R.useRef(""),kr=R.useMemo(()=>{const V=[];for(const K of n.current.agents.values())Av(K,ct)&&V.push(K.id+(K.parentId?`>${K.parentId}`:""));return V.sort(),`${V.join("|")}#sv${_i}.${He}`},[n.current,n.current.lastSeq,ct,_i,He]),ns=R.useRef(null);R.useEffect(()=>(ns.current!=null&&window.clearTimeout(ns.current),ns.current=window.setTimeout(()=>{uv(Xt.current,Rt.current)},1500),()=>{ns.current!=null&&window.clearTimeout(ns.current)}),[kr]),R.useEffect(()=>{if(_o.current===kr)return;const V=_o.current;if(_o.current=kr,!V||gn.current)return;Date.now()-kt.current>1200&&mt(400),or.current&&window.clearTimeout(or.current),or.current=window.setTimeout(()=>{gn.current||mt(500)},280)},[kr,e,mt]);const Ps=R.useMemo(()=>{if(o.size===0)return null;const V=new Set;for(const K of o){const ae=_5(n.current,K);if(ae)for(const de of ae)V.add(de)}return V.size>0?V:null},[n.current,n.current.lastSeq,o]),Cn=R.useMemo(()=>F4(n.current,ct),[n.current,n.current.lastSeq,ct]),Bn=R.useRef(null),[vn,Un]=R.useState({w:0,h:0});R.useEffect(()=>{const V=Bn.current;if(!V||typeof ResizeObserver>"u")return;const K=new ResizeObserver(ae=>{var xe;const de=(xe=ae[0])==null?void 0:xe.contentRect;de&&Un(Ee=>Math.abs(Ee.w-de.width)>40||Math.abs(Ee.h-de.height)>40?{w:de.width,h:de.height}:Ee)});return K.observe(V),Un({w:V.clientWidth,h:V.clientHeight}),()=>K.disconnect()},[]);const Ls=R.useRef(new Map),[rs,lr]=R.useState(!1);R.useEffect(()=>{const V=window.setTimeout(()=>lr(!0),2500);return()=>window.clearTimeout(V)},[]);const[ec,Si]=R.useState(!1),tn=R.useRef(null),[Eo,No]=R.useState(!1),ki=R.useCallback(()=>{tn.current&&(window.clearTimeout(tn.current),tn.current=null),Si(!1)},[]),Da=R.useCallback(V=>{V.length!==0&&queueMicrotask(()=>{Si(!0),tn.current&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>Si(!1),n5+80)})},[]);R.useEffect(()=>()=>{tn.current&&window.clearTimeout(tn.current)},[]);const Fa=vn.w>0?vn.w*.92:0,ss=vn.h>0?vn.h:0,{nodes:nn,edges:is}=R.useMemo(()=>b5(n.current,ct,Fa,ss,Rt.current,Kt,ar.current,Ls.current,Da,rs,Eo,Xt.current,ko.current,kr,bi,o,Ps,Cn,b),[n.current,n.current.lastSeq,ct,Fa,ss,rs,Eo,Kt,kr,o,Ps,Cn,b,Yt]),qs=R.useMemo(()=>{const V=new Map;for(const ae of nn){const de=ae.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=ae.width,Ee=ae.height;if(xe==null||Ee==null)continue;const Oe=ae.position.x,Fe=ae.position.y,Ge=Oe+xe,Ve=Fe+Ee,$e=V.get(de.sessionId);$e?($e.minX=Math.min($e.minX,Oe),$e.minY=Math.min($e.minY,Fe),$e.maxX=Math.max($e.maxX,Ge),$e.maxY=Math.max($e.maxY,Ve)):V.set(de.sessionId,{minX:Oe,minY:Fe,maxX:Ge,maxY:Ve})}const K=[];for(const[ae,de]of V){const xe=de.maxX-de.minX+ou*2,Ee=de.maxY-de.minY+ou*2;K.push({id:`group:${ae}`,type:AT,position:{x:de.minX-ou,y:de.minY-ou},data:{sessionId:ae,w:xe,h:Ee},width:xe,height:Ee,style:{width:xe,height:Ee},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return K},[nn,ct]),tc=R.useMemo(()=>{const V=[...qs,...nn],K=zt.current;return!K||K.size===0?V:V.map(ae=>{const de=K.get(ae.id);return de?{...ae,position:de}:ae})},[qs,nn,Fn]),$s=R.useMemo(()=>{if(!Kt)return null;const V=new Set;for(const K of n.current.agents.values())Cn.has(K.id)&&FT(K,Kt)&&V.add(K.id);return V},[n.current,n.current.lastSeq,Kt,Cn]),Hn=R.useMemo(()=>Q4(Kt,($s==null?void 0:$s.size)??0,Cn.size),[Kt,$s,Cn]),Er=R.useMemo(()=>{const V=new Set;for(const K of n.current.agents.values())for(const ae of K.tools)V.add(DT(ae.name));return Object.keys(Ov).filter(K=>V.has(K))},[n.current,n.current.lastSeq]);R.useEffect(()=>{if(Er.length<=1){kn(!1);return}let V=0;const K=()=>{const ae=Sn.current;if(ae&&!document.hidden){const de=ae.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Oe=>Oe.getBoundingClientRect()),Ee=B4(de,xe,8);kn(Oe=>Oe===Ee?Oe:Ee)}V=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(V)},[Er.length]);const Nr=R.useMemo(()=>{const V=new Map;for(const ae of n.current.agents.values())for(const de of ae.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Ee=xe.indexOf("__"),Oe=Ee>0?xe.slice(0,Ee):xe;V.set(Oe,(V.get(Oe)??0)+1)}const K=[];for(const[ae,de]of V){let xe=5381;for(let Ee=0;Ee<ae.length;Ee++)xe=(xe<<5)+xe^ae.charCodeAt(Ee);K.push({server:ae,count:de,hue:Math.abs(xe)%360})}return K.sort((ae,de)=>de.count-ae.count),K},[n.current,n.current.lastSeq]),za=R.useCallback(V=>{nt(K=>{const ae=new Set(K);return ae.has(V)?ae.delete(V):ae.add(V),ae})},[]),dt=u?n.current.agents.get(u):null,Ds=h?Array.from(n.current.agents.values()).flatMap(V=>V.tools).find(V=>V.id===h)??null:null,Fs=R.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Nv(),Rt.current.clear(),ar.current.clear(),Xt.current.clear(),bi.current="",DE(),m(),i()},[i,m]),Co=R.useRef(S);Co.current=S;const zs=R.useRef(!1);zs.current=Ds!=null||wt||N!=null||y!=null;const Cr=R.useCallback(V=>{const K=LL(V,{confirmOpen:Co.current,modalOpen:zs.current});K==="confirm"?k(!0):K==="clear"&&(k(!1),Fs())},[Fs]),Ei=R.useCallback(()=>{Rt.current.clear(),Xt.current.clear(),bi.current="",DE(),i(),window.setTimeout(()=>mt(500),80)},[i,e,mt]),Bt=R.useCallback(()=>mt(500),[mt]),Wn=R.useRef(nn);Wn.current=nn;const Ni=R.useRef(u);Ni.current=u;const Tr=R.useCallback(V=>{const K=Wn.current,ae=$L(K.map(Ee=>({id:Ee.id,x:Ee.position.x,y:Ee.position.y})),Ni.current,V),de=ae?K.find(Ee=>Ee.id===ae):void 0;if(!de)return;const xe=AE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}kt.current=Date.now(),xe&&t5(de.id)},30)},[d,e]),Ba=R.useCallback(V=>{d(V,!1),window.setTimeout(()=>{try{const K=Wn.current.find(ae=>ae.id===V);K&&e.fitView({padding:.3,duration:500,nodes:[K]}),kt.current=Date.now()}catch{}},60)},[d,e]);R.useEffect(()=>{const V=K=>{var Fe,Ge,Ve;const ae=K.target,de={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(Fe=ae==null?void 0:ae.getAttribute)==null?void 0:Fe.call(ae,"role"),type:ae==null?void 0:ae.type};if(K.key==="Escape"){const $e=RP({overlayOpen:ku.depth()>0,typing:ty(de)});$e==="dismiss"?ku.dismissTop():$e==="blur"?ae==null||ae.blur():(BL(de)&&(ae==null||ae.blur()),m());return}if(yC(K))return;const xe=AE(ae)?(Ge=ae==null?void 0:ae.getAttribute)==null?void 0:Ge.call(ae,"data-id"):null,Ee=xe&&Wn.current.some($e=>$e.id===xe)?xe:null,Oe=FL(K,Ee);if(Oe.kind==="activate"){K.preventDefault(),d(Oe.nodeId,Oe.additive);return}if(Oe.kind!=="node"&&!(Oe.nodeId==null&&qP(de))){if(K.key==="/"){K.preventDefault(),(Ve=Jr.current)==null||Ve.focus();return}K.key===" "&&(K.preventDefault(),Vr()),(K.key==="c"||K.key==="C")&&Cr("shortcut"),(K.key==="r"||K.key==="R")&&Ei(),(K.key==="f"||K.key==="F")&&Bt(),(K.key==="l"||K.key==="L")&&St(),(K.key==="h"||K.key==="H")&&hn($e=>!$e),(K.key==="u"||K.key==="U")&&z($e=>!$e),(K.key==="a"||K.key==="A")&&Be.current.claude&&pt(),(K.key==="j"||K.key==="J")&&Tr(1),(K.key==="k"||K.key==="K")&&Tr(-1),(K.key==="t"||K.key==="T")&&Qr($e=>$e==="dark"?"light":"dark")}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Cr,Ei,Bt,m,d,Tr,Vr]);const Rr=n.current.agents.size,To=new Set(Array.from(n.current.agents.values()).map(V=>V.sessionId)).size,Qt=R.useMemo(()=>$3(n.current.agents.values()),[n.current,n.current.lastSeq]),Bs=R.useMemo(()=>D3(n.current.agents.values()),[n.current,n.current.lastSeq]),Ro=R.useRef(null);R.useEffect(()=>{const V=nq({waiting:Qt.length,running:Bs}),K=Ro.current;if(Ro.current=V,(K==null?void 0:K.title)!==V.title&&(document.title=V.title),(K==null?void 0:K.icon)!==V.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=rq[V.icon])}},[Qt.length,Bs]);const[nc,rc]=R.useState(""),Ua=iq(Qt);R.useEffect(()=>{rc(V=>oq(V,Ua))},[Ua]);const Ut=R.useMemo(()=>{let V=0,K=0,ae=0,de=0,xe=0,Ee=0,Oe=0,Fe=0,Ge=0;for(const Ve of n.current.agents.values()){V+=Ve.usage.inputTokens,K+=Ve.usage.outputTokens,ae+=Ve.usage.cacheReadTokens,de+=Ve.usage.cacheCreateTokens;const $e=dn(Ve.usage,Ve.model);xe+=$e.total,Ee+=$e.input,Oe+=$e.output,Fe+=$e.cacheRead,Ge+=$e.cacheWrite}return{inT:V,outT:K,cacheR:ae,cacheC:de,sum:V+K,cost:{total:xe,input:Ee,output:Oe,cacheRead:Fe,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),en,ye?g.jsxs("button",{type:"button",className:"v stale",onClick:Ze,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 V={running:(U==null?void 0:U.running)??"1.35.2",latest:U==null?void 0:U.latest,latestPending:U==null?void 0:U.latestPending,checkedAgo:U!=null&&U.checkedAt?Mv(ct-U.checkedAt):null,checkDisabled:U==null?void 0:U.checkDisabled,checking:ce};return g.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":V4(V),title:W4(V),children:["v",V.running]})})()]}),dt&&(()=>{const V=dn(dt.usage,dt.model),K=Math.max(0,((dt.endedAt??ct)-dt.startedAt)/1e3),ae=dt.state==="active"?Su(V.total,K):null,de=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${dt.label}`,onClick:()=>{try{const xe=nn.find(Ee=>Ee.id===dt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),kt.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${dt.state}`,children:dt.state==="active"?"live":dt.state}),g.jsx("span",{className:"selected-label",children:dt.label}),V.total>0&&g.jsxs("span",{className:"selected-cost",children:[ze(V.total),ae?g.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):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:Jr,type:"text",placeholder:"Search agents, cwd, tools…",value:Kt,onChange:V=>Xr(V.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Xr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Hn.count&&g.jsx("span",{className:`search-count${Hn.empty?" none":""}`,"aria-live":"polite",title:`${Hn.count} agents on the canvas match “${Kt}”`,children:Hn.count})]}),g.jsxs("span",{className:"status",children:[(()=>{const V=K4({connected:M,paused:Wr,held:vr.current.size});return g.jsx("span",{className:`pill ${V.tone}`,title:V.title,children:V.label})})(),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:To}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Rr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),Ut.sum>0&&g.jsxs("span",{className:"stat",title:`in:${Ut.inT.toLocaleString()} out:${Ut.outT.toLocaleString()} cache-r:${Ut.cacheR.toLocaleString()} cache-c:${Ut.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:$t(Ut.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),Nr.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
63
+ last 5h: ${$t(d.window5h.totalTokens)} tokens · ${d.window5h.sessionCount} session${d.window5h.sessionCount!==1?"s":""}`:""}`,children:[$t(d.window7d.totalTokens)," tokens · ",d.window7d.sessionCount," session",d.window7d.sessionCount!==1?"s":""," (7d)"]})]}),E>0?g.jsxs(g.Fragment,{children:[k&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:ze(N.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(U3,{cost:N})]}),g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),$t(_.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),$t(_.out)]}),_.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),$t(_.cacheR)]}),_.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),$t(_.cacheC)]})]}),C.length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By model"}),g.jsxs("table",{className:"up-table",children:[g.jsx("thead",{children:g.jsxs("tr",{children:[g.jsx("th",{children:"Model"}),g.jsx("th",{children:"Tokens"}),g.jsx("th",{children:"Cost"})]})}),g.jsx("tbody",{children:C.map(O=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:O.model===Bd?"no model reported yet":O.model,children:O.model===Bd?"unknown":di(O.model)}),g.jsx("td",{className:"up-num",children:$t(O.inputTokens+O.outputTokens)}),O.priced?g.jsx("td",{className:"up-num up-cost-val",children:ze(O.cost.total)}):g.jsx("td",{className:"up-num up-unpriced",children:du})]},O.model))})]})]}),I.length>0&&g.jsxs("section",{className:"up-section",children:[g.jsx("h4",{className:"up-section-title",children:"By session"}),g.jsx("div",{className:"up-sessions",children:I.map(O=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${O.state}`,"aria-hidden":!0}),g.jsx("span",{className:"vis-hidden",children:ny(O.state)}),g.jsx("span",{className:"up-session-label",children:O.label}),g.jsx("span",{className:"up-session-tokens",children:$t(O.inputTokens+O.outputTokens)}),O.cost>0?g.jsxs("span",{className:"up-session-cost",title:O.unpricedTokens>0?`${$t(O.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[ze(O.cost),O.unpricedTokens>0?"+":""]}):g.jsx("span",{className:"up-session-cost up-unpriced",children:du})]},O.sessionId))})]}),P&&g.jsxs("div",{className:"up-hint",children:["“",du,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const Jx=18,Z3=1100,Ji=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},J3=Array.from({length:Jx},(e,n)=>{const r=-72+144*n/(Jx-1)+(Ji(n,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Ji(n,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(n%2?1:-1)*(100+Ji(n,3)*260),delay:Math.round(Ji(n,4)*90),dur:760+Math.round(Ji(n,5)*260),scale:.8+Ji(n,6)*.45,hue:n%4,round:n%3===0}});function e_({anchor:e,lifetimeMs:n=Z3}){var l;const[r,i]=R.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return R.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();i({x:c.left+c.width/2,y:c.top+c.height/2});const h=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(h)},[e,n,o]),o||!r?null:zI.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:J3.map((u,c)=>g.jsx("span",{className:`confetti-bit${u.round?" round":""}`,"data-hue":u.hue,style:{"--dx":`${u.dx.toFixed(1)}px`,"--dy":`${u.dy.toFixed(1)}px`,"--rot":`${u.rot}deg`,"--s":u.scale.toFixed(2),animationDelay:`${u.delay}ms`,animationDuration:`${u.dur}ms, ${u.dur}ms`}},c))}),document.body)}const NC=new Set(["awaiting_url","awaiting_code","registering"]);function eL(e){return e!=null&&NC.has(e)}function CC(e){return e!=null&&e!=="done"&&!NC.has(e)}const tL="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",nL="the sign-in did not complete";function rL({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?tL:nL)}}const sL="done";function iL(){let e=!1;return{shouldAnnounce(n){return n!==sL?(e=!1,!1):e?!1:(e=!0,!0)}}}const t_={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck1:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${en}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters"},n_={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},oL=`claude-swap could not read the login keychain — start ${en} from a Terminal window rather than a background service`;function Rv(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ho(e))?oL:e!=null&&e.reason&&n_[e.reason]?n_[e.reason]:(e==null?void 0:e.reason)||n}function ho(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const r_={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},aL="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function lL(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}function uL(e,n){return lL(ho(e))?aL:e!=null&&e.reason&&r_[e.reason]?r_[e.reason]:(e==null?void 0:e.reason)||n}function fu(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&CC(e.state)?e.error:e!=null&&e.reason&&t_[e.reason]?t_[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const cL=1500;async function tu(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const jv=ue.forwardRef((e,n)=>g.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[g.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),g.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));jv.displayName="SuccessMark";function dL({onClose:e,onChanged:n}){const[r,i]=R.useState("login"),[o,l]=R.useState(null),[u,c]=R.useState(""),[h,p]=R.useState(""),[d,m]=R.useState(!1),[y,w]=R.useState(null),[N,_]=R.useState(null),b=R.useRef(!1),S=R.useRef(null),k=R.useRef(null),E=R.useRef(null),C=R.useRef(null),I=R.useCallback(()=>{b.current&&tu({action:"login-cancel"}).catch(()=>{}),e()},[e]),P=mo(I,{focusRef:E}),A=R.useCallback(async()=>{m(!0),w(null),b.current=!0;const q=await tu({action:"login"}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){w(fu(q,"could not start the sign-in"));return}l(q)},[]);R.useEffect(()=>{if(!eL(o==null?void 0:o.state))return;const q=window.setInterval(async()=>{try{const $=await fetch("/api/claude-accounts/login");$.ok&&l(await $.json())}catch{}},cL);return()=>window.clearInterval(q)},[o]);const H=R.useRef(n);H.current=n;const z=R.useRef(iL());R.useEffect(()=>{var q;(o==null?void 0:o.state)==="awaiting_code"&&((q=S.current)==null||q.focus()),z.current.shouldAnnounce(o==null?void 0:o.state)&&H.current()},[o==null?void 0:o.state]),R.useEffect(()=>{var q;r==="paste"&&((q=k.current)==null||q.focus())},[r]);const L=R.useCallback(async()=>{var $;m(!0),w(null);const q=await tu({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){w(fu(q,"the code was not accepted")),q!=null&&q.state&&l(q),($=S.current)==null||$.select();return}c(""),l(q)},[u,o]),F=R.useCallback(async()=>{m(!0),w(null);const q=await tu({action:"import",blob:h}).catch(()=>null);if(m(!1),!(q!=null&&q.ok)){w(fu(q,"the import failed"));return}p(""),_({added:q.added===!0,num:q.num??null,email:q.email??null}),n()},[h,n]),G=(o==null?void 0:o.state)==="done"?o.account:null,O=CC(o==null?void 0:o.state)||!!(y&&b.current&&!d),j=rL({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:I,role:"presentation",children:g.jsxs("div",{ref:P,className:"modal aa-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[g.jsxs("header",{className:"modal-head",children:[g.jsx("div",{className:"modal-title",children:g.jsxs("span",{className:"aa-tabs",role:"tablist",children:[g.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:I,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?G?g.jsxs("div",{className:"aa-done",children:[g.jsx(jv,{ref:C}),g.jsx(e_,{anchor:C}),g.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:G.email}),G.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"})]}):(o==null?void 0:o.state)==="awaiting_code"||(o==null?void 0:o.state)==="registering"?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"1 · Approve in the browser"}),g.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),g.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"2 · Paste the code it gives you"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:S,type:"text",value:u,onChange:q=>c(q.target.value),onKeyDown:q=>{q.key==="Enter"&&u.trim()&&!d&&L()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),g.jsx("button",{type:"button",className:"btn primary",disabled:d||!u.trim()||o.state==="registering",onClick:L,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&g.jsx("p",{className:"aa-err",children:y??o.error}),g.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):O?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:j.title}),g.jsx("p",{className:"aa-err",children:j.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,l(null),w(null),A()},children:"Try again"})]}):d||b.current?g.jsx("div",{className:"aa-step",children:g.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):g.jsxs("div",{className:"aa-step aa-primer",children:[g.jsx("h4",{children:"Sign in to Anthropic"}),g.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in, then asks for the code it shows you. claude-swap records the account when it completes, and the account you are using now stays active."}),g.jsx("div",{className:"aa-actions",children:g.jsx("button",{type:"button",ref:E,className:"btn primary",onClick:A,disabled:d,children:"Open the sign-in page"})})]}):N?g.jsxs("div",{className:"aa-done",children:[g.jsx(jv,{ref:C}),N.added&&g.jsx(e_,{anchor:C}),g.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),g.jsx("p",{className:"aa-note",children:N.added?g.jsxs(g.Fragment,{children:[N.email?g.jsx("strong",{children:N.email}):"That account"," is in the rotation now. Nothing changed on the deck you copied it from."]}):"This deck already holds that account, so nothing changed."}),g.jsxs("div",{className:"aa-actions",children:[g.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),g.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:"Paste an account shared from another deck"}),g.jsxs("div",{className:"aa-field",children:[g.jsx("input",{ref:k,type:"text",value:h,onChange:q=>p(q.target.value),onKeyDown:q=>{q.key==="Enter"&&h.trim()&&!d&&F()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:d||!h.trim(),onClick:F,children:d?"importing…":"Import"})]}),y&&g.jsx("p",{className:"aa-err",children:y}),g.jsxs("p",{className:"aa-note",children:["Use ",g.jsx("strong",{children:"share"})," on an account in the other deck. A share carries a live login and expires ten minutes after it is made."]})]})})]})})}function fL(e,n){const r=new Set(e),i=e.length?Math.max(...e):0;return[...new Set([...e,i+1])].sort((o,l)=>o-l).map(o=>{const l=o===n?"here":r.has(o)?"swap":"free";return{slot:o,kind:l,label:l==="here"?`slot ${o}`:`slot ${o} · ${l}`}})}function hL(e,n,r){if(!(r!=null&&r.ok))return null;const i=Number.isInteger(r.to)?r.to:null;if(i==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const o=r.swapped===!0&&i!==n;return{menuFor:e.menuFor===n?i:o&&e.menuFor===i?n:e.menuFor,confirmRemove:null,shareFor:null,swapNote:o?{at:i,displaced:n}:null}}const pL=64;function mL(e,n){const r=e.trim();return{alias:r,commit:r!==(n??"").trim()}}const gL=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function s_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function vL(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=ho(n.body);return{text:Rv(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function i_(e,n){return n?e!=null&&e.reload&&e.text===n.text&&e.raw===n.raw?e:n:e!=null&&e.reload?null:e}const o_=15e3,yL=8e3,wL=1800,xL=3e4,_L=[70,80,85,90,95];function bL(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function a_(e,n){const r=n-Math.floor(e/1e3);return r<60?"just now":r<3600?`${Math.floor(r/60)}m ago`:r<86400?`${Math.floor(r/3600)}h ago`:`${Math.floor(r/86400)}d ago`}function SL(e,n){if(!e)return"";const r=Math.floor(e/1e3)-n;return r<=0?" · due":r<60?` · next in ${r}s`:` · next in ${Math.round(r/60)}m`}function kL(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function EL({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?bL(e.resetAt,n):null;return g.jsxs("div",{className:"ap-lane",children:[g.jsx("span",{className:"ap-lane-label",children:e.label}),g.jsx("div",{className:"ap-lane-track",children:g.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}async function NL(e){var r;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(i=>window.setTimeout(()=>i(!1),500))])}catch{n=!1}if(n)return!0;try{const i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(i),i.select(),n=document.execCommand("copy"),i.remove()}catch{n=!1}return n}function CL(e,n){const r=Math.round(e/1e3)-n;return r<=0?{text:"expired",tone:"gone"}:r<60?{text:`expires in ${r}s`,tone:"soon"}:{text:`expires in ${Math.round(r/60)}m`,tone:"ok"}}function TL({onClose:e}){var ne,le,fe;const[n,r]=R.useState(null),[i,o]=R.useState(null),[l,u]=R.useState(null),[c,h]=R.useState(!1),[p,d]=R.useState(null),[m,y]=R.useState(null),[w,N]=R.useState(()=>Math.floor(Date.now()/1e3)),_=R.useRef(null),[b,S]=R.useState(null),[k,E]=R.useState(!1),[C,I]=R.useState(""),[P,A]=R.useState(null),[H,z]=R.useState(null),[L,F]=R.useState(null),[G,O]=R.useState(!1),[j,q]=R.useState(null),$=R.useCallback(async(te=!1)=>{te&&h(!0);const ce=new AbortController,Ce=window.setTimeout(()=>ce.abort(),xL);try{const[ve,je]=await Promise.all([fetch(`/api/claude-accounts${te?"?refresh=1":""}`,{signal:ce.signal}),fetch("/api/cswap-auto",{signal:ce.signal})]);ve.ok&&r(await ve.json()),je.ok&&o(await je.json());const ye=vL([await s_(ve),await s_(je)]);y(ke=>i_(ke,ye))}catch{y(ve=>i_(ve,gL))}finally{window.clearTimeout(Ce),te&&h(!1)}},[]),re=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:Rv(ve,"command failed"),raw:ho(ve)}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),J=R.useCallback(async(te,ce)=>{u(ce),y(null);try{const ve=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(te)})).json().catch(()=>null);return ve!=null&&ve.ok||y({text:fu(ve,"command failed")}),ve}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);R.useEffect(()=>($(!0),_.current=window.setInterval(()=>$(!1),o_),()=>{_.current!=null&&window.clearInterval(_.current)}),[$]),R.useEffect(()=>{const te=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(te)},[]);const W=((ne=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:ne.value)??"90",Z=(le=n==null?void 0:n.accounts)==null?void 0:le.find(te=>te.active),M=Z!=null&&Z.lanes.length?Math.max(...Z.lanes.map(te=>te.pct)):null,Y=M!=null&&M>=Number(W)-15,U=async te=>{d(te),y(null);try{const Ce=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:te})})).json().catch(()=>null);Ce!=null&&Ce.ok||y({text:Rv(Ce,"the switch failed"),raw:ho(Ce)}),await $(!0)}catch{y({text:"server unreachable"})}finally{d(null)}},B=async(te,ce)=>{const{commit:Ce,alias:ve}=mL(C,ce);if(Ce){const je=await J({action:"alias",account:te,alias:ve},`alias-${te}`);if(await $(!0),!(je!=null&&je.ok))return;I(ve)}A(te),window.setTimeout(()=>A(je=>je===te?null:je),wL)},X=async(te,ce)=>{const Ce=await J({action:"move",account:te,slot:ce},`move-${te}`),ve=hL({menuFor:b,shareFor:(L==null?void 0:L.num)??null},te,Ce);if(await $(!0),ve){S(ve.menuFor),z(ve.confirmRemove),ve.shareFor==null&&(F(null),O(!1)),q(ve.swapNote);const je=ve.swapNote;je&&window.setTimeout(()=>q(ye=>ye===je?null:ye),yL)}};return g.jsxs("div",{className:"accounts-panel",id:"accounts-panel","aria-label":"Claude accounts",children:[g.jsxs("div",{className:"ap-header",children:[g.jsx("h3",{children:"Accounts"}),g.jsxs("div",{className:"ap-header-right",children:[g.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>E(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),g.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>$(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?m?g.jsxs("div",{className:"ap-empty",role:"alert",children:[g.jsx("span",{title:m.raw||void 0,children:m.text}),g.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",o_/1e3," seconds."]}),g.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>$(!0),children:c?"trying…":"try again"})]}):g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(fe=n.accounts)==null?void 0:fe.map(te=>g.jsxs("div",{className:`ap-account${te.active?" active":""}${te.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:te.num}),te.alias&&g.jsx("span",{className:"ap-alias",title:te.alias,children:te.alias}),g.jsx("span",{className:"ap-email",title:te.org??void 0,children:te.email}),g.jsx("button",{type:"button",className:`ap-more${b===te.num?" on":""}`,"aria-label":`Manage account ${te.num}`,"aria-expanded":b===te.num,"aria-controls":b===te.num?`ap-manage-${te.num}`:void 0,title:"Share, rename, move, remove",onClick:()=>{S(b===te.num?null:te.num),I(te.alias??""),z(null),F(null),O(!1),q(null),A(null)},children:"⋯"}),te.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:p!=null||te.disabled,onClick:()=>U(te.num),title:te.disabled?"Held out of rotation":`Switch to ${te.alias??te.email}`,children:p===te.num?"…":"switch"})]}),te.lanes.length>0?te.lanes.map(ce=>g.jsx(EL,{lane:ce,nowSec:w},ce.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[te.error&&(()=>{const ce=kL(te.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:ce.hint,children:ce.text}),ce.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>E(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!te.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>re({action:"account",account:te.num,enabled:te.disabled},`rot-${te.num}`).then(()=>$(!0)),title:te.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:te.disabled?"held out":"in rotation"}),te.fetchedAt?g.jsxs("span",{className:`ap-age${te.stale?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",a_(te.fetchedAt,w),SL(te.nextAt,w)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),b===te.num&&g.jsxs("div",{className:"ap-manage",id:`ap-manage-${te.num}`,role:"group","aria-label":`Manage account ${te.num}`,children:[g.jsxs("div",{className:"ap-manage-name",children:[g.jsx("label",{className:"vis-hidden",htmlFor:`ap-alias-${te.num}`,children:"Alias"}),g.jsx("input",{id:`ap-alias-${te.num}`,className:"ap-manage-input",type:"text",value:C,onChange:ce=>I(ce.target.value),onKeyDown:ce=>{ce.key==="Enter"&&B(te.num,te.alias)},maxLength:pL,placeholder:"e.g. work",spellCheck:!1,autoFocus:!0}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:()=>B(te.num,te.alias),title:"A short name to show instead of the email",children:P===te.num?"saved":"save"})]}),g.jsxs("div",{className:"ap-manage-acts",children:[g.jsx("label",{className:"vis-hidden",htmlFor:`ap-slot-${te.num}`,children:"Slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{id:`ap-slot-${te.num}`,value:String(te.num),disabled:l!=null,onChange:ce=>X(te.num,Number(ce.target.value)),children:fL((n.accounts??[]).map(ce=>ce.num),te.num).map(ce=>g.jsx("option",{value:ce.slot,children:ce.label},ce.slot))})}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:`Copy this account to another ${en}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:async()=>{O(!1);const ce=await J({action:"share",account:te.num},`share-${te.num}`);ce!=null&&ce.ok&&F({num:te.num,blob:ce.blob,expiresAt:ce.expiresAt})},children:"share"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${H===te.num?" armed":""}`,disabled:l!=null,title:H===te.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(H!==te.num){z(te.num),window.setTimeout(()=>z(ce=>ce===te.num?null:ce),4e3);return}z(null),J({action:"remove",account:te.num},`rm-${te.num}`).then(()=>{S(null),$(!0)})},children:H===te.num?"confirm":"remove"})]}),(j==null?void 0:j.at)===te.num&&(()=>{var ve;const ce=(ve=n.accounts)==null?void 0:ve.find(je=>je.num===j.displaced),Ce=(ce==null?void 0:ce.alias)??(ce==null?void 0:ce.email)??"the account that was there";return g.jsxs("span",{className:"ap-manage-hint ap-manage-swap",title:`Slot ${j.at} was taken, so the two accounts traded places: ${Ce} now holds slot ${j.displaced}.`,children:["swapped with slot ",j.displaced]})})(),(L==null?void 0:L.num)===te.num&&(()=>{const ce=CL(L.expiresAt,w),Ce=ce.tone==="gone";return g.jsxs("div",{className:`ap-share${Ce?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:L.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Ce){O(!1);const ve=await J({action:"share",account:te.num},`share-${te.num}`);ve!=null&&ve.ok&&F({num:te.num,blob:ve.blob,expiresAt:ve.expiresAt});return}await NL(L.blob)&&(O(!0),window.setTimeout(()=>O(!1),1800))},children:Ce?"make a new share":G?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[g.jsx("span",{className:"ap-share-warn",children:"this is the password"})," · ",g.jsx("span",{className:`ap-share-expiry ${ce.tone}`,children:ce.text})]})]})]})})()]})]},te.num)),(i==null?void 0:i.ok)&&g.jsxs("div",{className:"ap-auto",children:[g.jsxs("div",{className:"ap-auto-head",children:[g.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),g.jsxs("span",{className:"ap-auto-ctl",children:[M!=null&&g.jsxs("span",{className:`ap-auto-now${Y?" near":""}`,children:[Math.round(M),"%"]}),g.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:g.jsx("select",{"aria-label":"Switch threshold",value:W,disabled:l!=null,onChange:te=>re({action:"setting",key:"autoswitch.threshold",value:te.target.value},"threshold").then(()=>$(!0)),children:_L.map(te=>g.jsxs("option",{value:te,children:[te,"%"]},te))})}),g.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:l!=null,onClick:()=>re({action:"enable",enabled:!i.enabled},"enable").then(()=>$(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&g.jsxs("p",{className:"ap-auto-note",children:[g.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",g.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",i.enabled?" — this toggle takes over when you stop it.":"."]}),i.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",a_(i.lastTick.at,w)]})})]}),m&&g.jsxs("div",{className:"ap-failure",role:"alert",children:[g.jsx("span",{className:"ap-failure-text",title:m.raw||void 0,children:m.text}),g.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),g.jsx("p",{className:"ap-footnote",title:"Anthropic's usage endpoint allows roughly 28–30 requests per hour per account, shared by every tool on this machine — polling it from here would rate-limit your account. So the deck never fetches: it asks claude-swap to collect while this panel is open, at most once every three minutes, and claude-swap decides whether that touches the network at all.",children:"Collected by claude-swap while this panel is open."})]}):g.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"claude-swap isn't installed."}),g.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),n.hint&&g.jsx("code",{className:"ap-cmd",children:n.hint}),g.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",g.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"No accounts added yet."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",g.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{children:"Couldn't read the account store."}),g.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),k&&g.jsx(dL,{onClose:()=>E(!1),onChanged:()=>$(!0)})]})}const RL=3e4;function jL({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function AL({bundle:e,running:n,pending:r,lastTried:i}){return n?jL({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function IL(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function ML({asked:e,reported:n}){return n?n!==e:!1}function OL(e){const n=e.thresholdMs??RL;return!e.enabled||e.kind!=="restart"||!e.canRestart?{idleSince:null,restart:!1}:e.busy?{idleSince:null,restart:!1}:e.idleSince==null?{idleSince:e.now,restart:!1}:e.now<e.idleSince?{idleSince:e.now,restart:!1}:{idleSince:e.idleSince,restart:e.now-e.idleSince>=n}}function PL({agentCount:e,onConfirm:n,onCancel:r}){const i=R.useRef(null),o=mo(r,{focusRef:i,layer:CP}),l=e===0?"This deletes the server's event log":`This removes ${e===1?"the one agent":`all ${e} agents`} on the canvas and deletes the server's event log`;return g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{ref:o,className:"modal clear-confirm",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[g.jsxs("header",{className:"modal-head",children:[g.jsxs("div",{className:"modal-title",children:[g.jsx("span",{className:"status-dot err","aria-hidden":!0}),g.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),g.jsxs("section",{className:"modal-body",children:[g.jsxs("p",{className:"modal-note",children:[l," — the file a restarted deck replays to rebuild what you see. Layout, pins and selection go with it. This cannot be undone."]}),g.jsxs("div",{className:"cc-actions",children:[g.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),g.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function LL(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function qL(e){return e.slice().sort((n,r)=>n.y-r.y||n.x-r.x)}function $L(e,n,r){var u;if(e.length===0)return null;const i=qL(e),o=n?i.findIndex(c=>c.id===n):-1,l=o===-1?r===1?0:i.length-1:(o+r+i.length)%i.length;return((u=i[l])==null?void 0:u.id)??null}const DL=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function FL(e,n){return n==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:n,additive:e.shiftKey}:DL.has(e.key)?{kind:"node",nodeId:n}:{kind:"deck",nodeId:n}}const zL=new Set(["","BODY","HTML","#DOCUMENT"]);function BL(e){return!e||ty(e)?!1:!zL.has(String(e.tagName??"").toUpperCase())}function nu(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function UL(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function TC(e,n,r){return!n.has(e)||r.has(e)}function HL(e,n,r,i){return!n.has(e)&&TC(e,r,i)}function WL(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function VL(e,n,r,i){r.set(e,n),i.delete(e)}const GL=40,YL=120;function KL(e,n){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(h,p,d)=>{if(r!=null){if(i<=h)return;u()}const m=Math.min(d,Math.max(0,h-p));i=h,r=n.setTimeout(l,m)};return{live(h=GL){const p=n.now(),d=Math.max(o+h,p);if(d<=p){u(),l();return}c(d,p,h)},replay(h=YL){u(),i=n.now()+h,r=n.setTimeout(l,h)},flush(){u(),l()},cancel(){u()}}}function XL(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const i=n;return n=[],i}}}const QL="1",l_="agent-dag.schema",ZL=["agent-dag.layout","agent-dag.viewport"];function RC(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function JL(e,n=QL){let r=null;try{r=e.getItem(l_)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of ZL)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(l_,n)}catch{}return i}const jC="agent-dag.theme";function eq(e){return e==="light"?"light":"dark"}function tq(){return eq(RC(jC))}function nq({waiting:e,running:n}){return{title:e>0?`(${e}) ${en}`:en,icon:e>0?"waiting":n>0?"running":"idle"}}const Ud={waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Hd(e,n){return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${n==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"/>`+(n==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const rq=Object.freeze({waiting:`data:image/svg+xml,${encodeURIComponent(Hd(Ud.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Hd(Ud.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Hd(Ud.idle,"idle"))}`}),sq="No sessions are waiting for you.";function iq(e){if(e.length===0)return"";const[n,...r]=e;if(r.length===0)return`${n.label} is waiting for your permission.`;const i=`${r.length} more session${r.length===1?"":"s"}`;return`${n.label} and ${i} are waiting for your permission.`}function oq(e,n){return n!==""?n:e===""?"":sq}function aq(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function lq(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function uq(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function ru(e){const n=e.toLowerCase();return n.includes("opus")?"#c4b5fd":n.includes("sonnet")?"#7dd3fc":n.includes("haiku")?"#86efac":n.includes("gpt-5")||n.includes("gpt5")?"#fcd34d":n.includes("gpt")?"#fca5a5":n.includes("gemini")?"#a5b4fc":n.includes("codex")?"#fdba74":"#94a3b8"}const cq=[7,14,30,90];function dq(e){const[n,r]=R.useState(null),[i,o]=R.useState(!1),l=R.useRef(aq()).current,u=(c=!1)=>{const h=l.begin(),p=e;o(!0);const m=`/api/ccusage?since=${lq(p)}${c?"&refresh=1":""}`;fetch(m).then(y=>y.json()).then(y=>{h()&&r({range:p,resp:y})}).catch(()=>{h()&&r({range:p,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{h()&&o(!1)})};return R.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function fq({onClose:e}){var C,I,P;const[n,r]=R.useState(30),[i,o]=R.useState(null),{landed:l,loading:u,reload:c}=dq(n),h=R.useRef(null),p=mo(e,{focusRef:h}),d=uq({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((C=l.resp.days)==null?void 0:C.length)??0}}),m=d.phase==="chart"?l.resp.days??[]:[],y=R.useMemo(()=>m.reduce((A,H)=>Math.max(A,H.totalCost),0),[m]),{totalCost:w,totalTok:N,inOut:_,cacheRead:b,modelCosts:S}=R.useMemo(()=>{let A=0,H=0,z=0,L=0;const F=new Map;for(const G of m){A+=G.totalCost,H+=G.totalTokens,z+=G.inputTokens+G.outputTokens,L+=G.cacheReadTokens;for(const O of G.modelBreakdowns)F.set(O.modelName,(F.get(O.modelName)??0)+O.cost)}return{totalCost:A,totalTok:H,inOut:z,cacheRead:L,modelCosts:F}},[m]),k=R.useMemo(()=>Array.from(S.entries()).sort((A,H)=>H[1]-A[1]),[S]),E=i?m.find(A=>A.period===i)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{ref:p,className:"uh-modal",onClick:A=>A.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Usage history",children:[g.jsxs("header",{className:"uh-head",children:[g.jsxs("div",{className:"uh-titlewrap",children:[g.jsx("div",{className:"uh-title",children:"Usage history"}),g.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),g.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:cq.map(A=>g.jsxs("button",{role:"tab","aria-selected":n===A,className:`uh-range-btn${n===A?" on":""}`,onClick:()=>{r(A),o(null)},children:[A,"d"]},A))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,disabled:u,title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),g.jsx("button",{ref:h,className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),d.phase==="busy"?g.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):d.phase==="error"?g.jsxs("div",{className:"uh-status uh-err",title:ho(l.resp)||void 0,children:[uL(l.resp,"ccusage did not report usage"),g.jsx("div",{children:g.jsx("button",{className:"btn uh-retry",onClick:c,disabled:u,children:u?"trying…":"Try again"})})]}):d.phase==="empty"?g.jsx("div",{className:`uh-status${d.stale?" uh-stale":""}`,"aria-busy":d.stale||void 0,children:"no usage in this range"}):g.jsxs("div",{className:d.stale?"uh-stale":void 0,"aria-busy":d.stale||void 0,children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(su,{label:"total cost",val:ze(w),accent:!0}),g.jsx(su,{label:"tokens",val:$t(N)}),g.jsx(su,{label:"input+output",val:$t(_)}),g.jsx(su,{label:"cache reads",val:$t(b)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:m.map(A=>{const H=y>0?A.totalCost/y*100:0,z=A.period===i;return g.jsxs("button",{className:`uh-bar-col${z?" sel":""}`,onClick:()=>o(z?null:A.period),title:`${A.period} · ${ze(A.totalCost)}`,style:{flexBasis:`${100/m.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(H,A.totalCost>0?2:0)}%`},children:A.modelBreakdowns.slice().sort((L,F)=>F.cost-L.cost).map(L=>{const F=A.totalCost>0?L.cost/A.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${F}%`,background:ru(L.modelName)}},L.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:A.period.slice(5)})]},A.period)})}),g.jsx("div",{className:"uh-legend",children:k.map(([A,H])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:ru(A)}}),di(A)," ",g.jsx("span",{className:"uh-legend-cost",children:ze(H)})]},A))}),E&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:E.period}),g.jsx("span",{className:"uh-detail-cost",children:ze(E.totalCost)}),(P=(I=E.metadata)==null?void 0:I.agents)!=null&&P.length?g.jsx("span",{className:"uh-detail-agents",children:E.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(iu,{label:"input",val:$t(E.inputTokens)}),g.jsx(iu,{label:"output",val:$t(E.outputTokens)}),g.jsx(iu,{label:"cache write",val:$t(E.cacheCreationTokens)}),g.jsx(iu,{label:"cache read",val:$t(E.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:E.modelBreakdowns.slice().sort((A,H)=>H.cost-A.cost).map(A=>{const H=E.totalCost>0?A.cost/E.totalCost*100:0;return g.jsxs("div",{className:"uh-model-row",children:[g.jsxs("span",{className:"uh-model-name",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:ru(A.modelName)}}),di(A.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${H}%`,background:ru(A.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:ze(A.cost)})]},A.modelName)})})]})]})]})})}function su({label:e,val:n,accent:r}){return g.jsxs("div",{className:"uh-stat",children:[g.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),g.jsx("span",{className:"uh-stat-label",children:e})]})}function iu({label:e,val:n}){return g.jsxs("div",{className:"uh-ministat",children:[g.jsx("span",{className:"uh-ministat-val",children:n}),g.jsx("span",{className:"uh-ministat-label",children:e})]})}function sy(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var Wd,u_;function hq(){if(u_)return Wd;u_=1;function e(){this.__data__=[],this.size=0}return Wd=e,Wd}var Vd,c_;function go(){if(c_)return Vd;c_=1;function e(n,r){return n===r||n!==n&&r!==r}return Vd=e,Vd}var Gd,d_;function Pu(){if(d_)return Gd;d_=1;var e=go();function n(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return Gd=n,Gd}var Yd,f_;function pq(){if(f_)return Yd;f_=1;var e=Pu(),n=Array.prototype,r=n.splice;function i(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return Yd=i,Yd}var Kd,h_;function mq(){if(h_)return Kd;h_=1;var e=Pu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Kd=n,Kd}var Xd,p_;function gq(){if(p_)return Xd;p_=1;var e=Pu();function n(r){return e(this.__data__,r)>-1}return Xd=n,Xd}var Qd,m_;function vq(){if(m_)return Qd;m_=1;var e=Pu();function n(r,i){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,i])):o[l][1]=i,this}return Qd=n,Qd}var Zd,g_;function Lu(){if(g_)return Zd;g_=1;var e=hq(),n=pq(),r=mq(),i=gq(),o=vq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Zd=l,Zd}var Jd,v_;function yq(){if(v_)return Jd;v_=1;var e=Lu();function n(){this.__data__=new e,this.size=0}return Jd=n,Jd}var ef,y_;function wq(){if(y_)return ef;y_=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return ef=e,ef}var tf,w_;function xq(){if(w_)return tf;w_=1;function e(n){return this.__data__.get(n)}return tf=e,tf}var nf,x_;function _q(){if(x_)return nf;x_=1;function e(n){return this.__data__.has(n)}return nf=e,nf}var rf,__;function AC(){if(__)return rf;__=1;var e=typeof Bl=="object"&&Bl&&Bl.Object===Object&&Bl;return rf=e,rf}var sf,b_;function sr(){if(b_)return sf;b_=1;var e=AC(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return sf=r,sf}var of,S_;function vo(){if(S_)return of;S_=1;var e=sr(),n=e.Symbol;return of=n,of}var af,k_;function bq(){if(k_)return af;k_=1;var e=vo(),n=Object.prototype,r=n.hasOwnProperty,i=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),h=u[o];try{u[o]=void 0;var p=!0}catch{}var d=i.call(u);return p&&(c?u[o]=h:delete u[o]),d}return af=l,af}var lf,E_;function Sq(){if(E_)return lf;E_=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return lf=r,lf}var uf,N_;function fi(){if(N_)return uf;N_=1;var e=vo(),n=bq(),r=Sq(),i="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:l&&l in Object(c)?n(c):r(c)}return uf=u,uf}var cf,C_;function $n(){if(C_)return cf;C_=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return cf=e,cf}var df,T_;function ja(){if(T_)return df;T_=1;var e=fi(),n=$n(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var h=e(c);return h==i||h==o||h==r||h==l}return df=u,df}var ff,R_;function kq(){if(R_)return ff;R_=1;var e=sr(),n=e["__core-js_shared__"];return ff=n,ff}var hf,j_;function Eq(){if(j_)return hf;j_=1;var e=kq(),n=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!n&&n in i}return hf=r,hf}var pf,A_;function IC(){if(A_)return pf;A_=1;var e=Function.prototype,n=e.toString;function r(i){if(i!=null){try{return n.call(i)}catch{}try{return i+""}catch{}}return""}return pf=r,pf}var mf,I_;function Nq(){if(I_)return mf;I_=1;var e=ja(),n=Eq(),r=$n(),i=IC(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,h=u.toString,p=c.hasOwnProperty,d=RegExp("^"+h.call(p).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var w=e(y)?d:l;return w.test(i(y))}return mf=m,mf}var gf,M_;function Cq(){if(M_)return gf;M_=1;function e(n,r){return n==null?void 0:n[r]}return gf=e,gf}var vf,O_;function hi(){if(O_)return vf;O_=1;var e=Nq(),n=Cq();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return vf=r,vf}var yf,P_;function iy(){if(P_)return yf;P_=1;var e=hi(),n=sr(),r=e(n,"Map");return yf=r,yf}var wf,L_;function qu(){if(L_)return wf;L_=1;var e=hi(),n=e(Object,"create");return wf=n,wf}var xf,q_;function Tq(){if(q_)return xf;q_=1;var e=qu();function n(){this.__data__=e?e(null):{},this.size=0}return xf=n,xf}var _f,$_;function Rq(){if($_)return _f;$_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return _f=e,_f}var bf,D_;function jq(){if(D_)return bf;D_=1;var e=qu(),n="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return i.call(u,l)?u[l]:void 0}return bf=o,bf}var Sf,F_;function Aq(){if(F_)return Sf;F_=1;var e=qu(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Sf=i,Sf}var kf,z_;function Iq(){if(z_)return kf;z_=1;var e=qu(),n="__lodash_hash_undefined__";function r(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=e&&o===void 0?n:o,this}return kf=r,kf}var Ef,B_;function Mq(){if(B_)return Ef;B_=1;var e=Tq(),n=Rq(),r=jq(),i=Aq(),o=Iq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Ef=l,Ef}var Nf,U_;function Oq(){if(U_)return Nf;U_=1;var e=Mq(),n=Lu(),r=iy();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Nf=i,Nf}var Cf,H_;function Pq(){if(H_)return Cf;H_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return Cf=e,Cf}var Tf,W_;function $u(){if(W_)return Tf;W_=1;var e=Pq();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return Tf=n,Tf}var Rf,V_;function Lq(){if(V_)return Rf;V_=1;var e=$u();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return Rf=n,Rf}var jf,G_;function qq(){if(G_)return jf;G_=1;var e=$u();function n(r){return e(this,r).get(r)}return jf=n,jf}var Af,Y_;function $q(){if(Y_)return Af;Y_=1;var e=$u();function n(r){return e(this,r).has(r)}return Af=n,Af}var If,K_;function Dq(){if(K_)return If;K_=1;var e=$u();function n(r,i){var o=e(this,r),l=o.size;return o.set(r,i),this.size+=o.size==l?0:1,this}return If=n,If}var Mf,X_;function oy(){if(X_)return Mf;X_=1;var e=Oq(),n=Lq(),r=qq(),i=$q(),o=Dq();function l(u){var c=-1,h=u==null?0:u.length;for(this.clear();++c<h;){var p=u[c];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=i,l.prototype.set=o,Mf=l,Mf}var Of,Q_;function Fq(){if(Q_)return Of;Q_=1;var e=Lu(),n=iy(),r=oy(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var h=c.__data__;if(!n||h.length<i-1)return h.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(h)}return c.set(l,u),this.size=c.size,this}return Of=o,Of}var Pf,Z_;function Du(){if(Z_)return Pf;Z_=1;var e=Lu(),n=yq(),r=wq(),i=xq(),o=_q(),l=Fq();function u(c){var h=this.__data__=new e(c);this.size=h.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=i,u.prototype.has=o,u.prototype.set=l,Pf=u,Pf}var Lf,J_;function ay(){if(J_)return Lf;J_=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o&&r(n[i],i,n)!==!1;);return n}return Lf=e,Lf}var qf,e1;function MC(){if(e1)return qf;e1=1;var e=hi(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return qf=n,qf}var $f,t1;function Fu(){if(t1)return $f;t1=1;var e=MC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return $f=n,$f}var Df,n1;function zu(){if(n1)return Df;n1=1;var e=Fu(),n=go(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var h=l[u];(!(i.call(l,u)&&n(h,c))||c===void 0&&!(u in l))&&e(l,u,c)}return Df=o,Df}var Ff,r1;function Aa(){if(r1)return Ff;r1=1;var e=zu(),n=Fu();function r(i,o,l,u){var c=!l;l||(l={});for(var h=-1,p=o.length;++h<p;){var d=o[h],m=u?u(l[d],i[d],d,l,i):void 0;m===void 0&&(m=i[d]),c?n(l,d,m):e(l,d,m)}return l}return Ff=r,Ff}var zf,s1;function zq(){if(s1)return zf;s1=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return zf=e,zf}var Bf,i1;function mr(){if(i1)return Bf;i1=1;function e(n){return n!=null&&typeof n=="object"}return Bf=e,Bf}var Uf,o1;function Bq(){if(o1)return Uf;o1=1;var e=fi(),n=mr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return Uf=i,Uf}var Hf,a1;function Ia(){if(a1)return Hf;a1=1;var e=Bq(),n=mr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return Hf=l,Hf}var Wf,l1;function bt(){if(l1)return Wf;l1=1;var e=Array.isArray;return Wf=e,Wf}var ca={exports:{}},Vf,u1;function Uq(){if(u1)return Vf;u1=1;function e(){return!1}return Vf=e,Vf}ca.exports;var c1;function yo(){return c1||(c1=1,(function(e,n){var r=sr(),i=Uq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,h=c?c.isBuffer:void 0,p=h||i;e.exports=p})(ca,ca.exports)),ca.exports}var Gf,d1;function Bu(){if(d1)return Gf;d1=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(i,o){var l=typeof i;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(i))&&i>-1&&i%1==0&&i<o}return Gf=r,Gf}var Yf,f1;function ly(){if(f1)return Yf;f1=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Yf=n,Yf}var Kf,h1;function Hq(){if(h1)return Kf;h1=1;var e=fi(),n=ly(),r=mr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",h="[object Function]",p="[object Map]",d="[object Number]",m="[object Object]",y="[object RegExp]",w="[object Set]",N="[object String]",_="[object WeakMap]",b="[object ArrayBuffer]",S="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",I="[object Int16Array]",P="[object Int32Array]",A="[object Uint8Array]",H="[object Uint8ClampedArray]",z="[object Uint16Array]",L="[object Uint32Array]",F={};F[k]=F[E]=F[C]=F[I]=F[P]=F[A]=F[H]=F[z]=F[L]=!0,F[i]=F[o]=F[b]=F[l]=F[S]=F[u]=F[c]=F[h]=F[p]=F[d]=F[m]=F[y]=F[w]=F[N]=F[_]=!1;function G(O){return r(O)&&n(O.length)&&!!F[e(O)]}return Kf=G,Kf}var Xf,p1;function Uu(){if(p1)return Xf;p1=1;function e(n){return function(r){return n(r)}}return Xf=e,Xf}var da={exports:{}};da.exports;var m1;function uy(){return m1||(m1=1,(function(e,n){var r=AC(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l&&r.process,c=(function(){try{var h=o&&o.require&&o.require("util").types;return h||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(da,da.exports)),da.exports}var Qf,g1;function Ma(){if(g1)return Qf;g1=1;var e=Hq(),n=Uu(),r=uy(),i=r&&r.isTypedArray,o=i?n(i):e;return Qf=o,Qf}var Zf,v1;function OC(){if(v1)return Zf;v1=1;var e=zq(),n=Ia(),r=bt(),i=yo(),o=Bu(),l=Ma(),u=Object.prototype,c=u.hasOwnProperty;function h(p,d){var m=r(p),y=!m&&n(p),w=!m&&!y&&i(p),N=!m&&!y&&!w&&l(p),_=m||y||w||N,b=_?e(p.length,String):[],S=b.length;for(var k in p)(d||c.call(p,k))&&!(_&&(k=="length"||w&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return Zf=h,Zf}var Jf,y1;function Hu(){if(y1)return Jf;y1=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return Jf=n,Jf}var eh,w1;function PC(){if(w1)return eh;w1=1;function e(n,r){return function(i){return n(r(i))}}return eh=e,eh}var th,x1;function Wq(){if(x1)return th;x1=1;var e=PC(),n=e(Object.keys,Object);return th=n,th}var nh,_1;function cy(){if(_1)return nh;_1=1;var e=Hu(),n=Wq(),r=Object.prototype,i=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))i.call(l,c)&&c!="constructor"&&u.push(c);return u}return nh=o,nh}var rh,b1;function Ur(){if(b1)return rh;b1=1;var e=ja(),n=ly();function r(i){return i!=null&&n(i.length)&&!e(i)}return rh=r,rh}var sh,S1;function Ns(){if(S1)return sh;S1=1;var e=OC(),n=cy(),r=Ur();function i(o){return r(o)?e(o):n(o)}return sh=i,sh}var ih,k1;function Vq(){if(k1)return ih;k1=1;var e=Aa(),n=Ns();function r(i,o){return i&&e(o,n(o),i)}return ih=r,ih}var oh,E1;function Gq(){if(E1)return oh;E1=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return oh=e,oh}var ah,N1;function Yq(){if(N1)return ah;N1=1;var e=$n(),n=Hu(),r=Gq(),i=Object.prototype,o=i.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),h=[];for(var p in u)p=="constructor"&&(c||!o.call(u,p))||h.push(p);return h}return ah=l,ah}var lh,C1;function pi(){if(C1)return lh;C1=1;var e=OC(),n=Yq(),r=Ur();function i(o){return r(o)?e(o,!0):n(o)}return lh=i,lh}var uh,T1;function Kq(){if(T1)return uh;T1=1;var e=Aa(),n=pi();function r(i,o){return i&&e(o,n(o),i)}return uh=r,uh}var fa={exports:{}};fa.exports;var R1;function LC(){return R1||(R1=1,(function(e,n){var r=sr(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function h(p,d){if(d)return p.slice();var m=p.length,y=c?c(m):new p.constructor(m);return p.copy(y),y}e.exports=h})(fa,fa.exports)),fa.exports}var ch,j1;function qC(){if(j1)return ch;j1=1;function e(n,r){var i=-1,o=n.length;for(r||(r=Array(o));++i<o;)r[i]=n[i];return r}return ch=e,ch}var dh,A1;function $C(){if(A1)return dh;A1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=0,u=[];++i<o;){var c=n[i];r(c,i,n)&&(u[l++]=c)}return u}return dh=e,dh}var fh,I1;function DC(){if(I1)return fh;I1=1;function e(){return[]}return fh=e,fh}var hh,M1;function dy(){if(M1)return hh;M1=1;var e=$C(),n=DC(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:n;return hh=l,hh}var ph,O1;function Xq(){if(O1)return ph;O1=1;var e=Aa(),n=dy();function r(i,o){return e(i,n(i),o)}return ph=r,ph}var mh,P1;function fy(){if(P1)return mh;P1=1;function e(n,r){for(var i=-1,o=r.length,l=n.length;++i<o;)n[l+i]=r[i];return n}return mh=e,mh}var gh,L1;function Wu(){if(L1)return gh;L1=1;var e=PC(),n=e(Object.getPrototypeOf,Object);return gh=n,gh}var vh,q1;function FC(){if(q1)return vh;q1=1;var e=fy(),n=Wu(),r=dy(),i=DC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return vh=l,vh}var yh,$1;function Qq(){if($1)return yh;$1=1;var e=Aa(),n=FC();function r(i,o){return e(i,n(i),o)}return yh=r,yh}var wh,D1;function zC(){if(D1)return wh;D1=1;var e=fy(),n=bt();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return wh=r,wh}var xh,F1;function BC(){if(F1)return xh;F1=1;var e=zC(),n=dy(),r=Ns();function i(o){return e(o,r,n)}return xh=i,xh}var _h,z1;function Zq(){if(z1)return _h;z1=1;var e=zC(),n=FC(),r=pi();function i(o){return e(o,r,n)}return _h=i,_h}var bh,B1;function Jq(){if(B1)return bh;B1=1;var e=hi(),n=sr(),r=e(n,"DataView");return bh=r,bh}var Sh,U1;function e$(){if(U1)return Sh;U1=1;var e=hi(),n=sr(),r=e(n,"Promise");return Sh=r,Sh}var kh,H1;function UC(){if(H1)return kh;H1=1;var e=hi(),n=sr(),r=e(n,"Set");return kh=r,kh}var Eh,W1;function t$(){if(W1)return Eh;W1=1;var e=hi(),n=sr(),r=e(n,"WeakMap");return Eh=r,Eh}var Nh,V1;function wo(){if(V1)return Nh;V1=1;var e=Jq(),n=iy(),r=e$(),i=UC(),o=t$(),l=fi(),u=IC(),c="[object Map]",h="[object Object]",p="[object Promise]",d="[object Set]",m="[object WeakMap]",y="[object DataView]",w=u(e),N=u(n),_=u(r),b=u(i),S=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=p||i&&k(new i)!=d||o&&k(new o)!=m)&&(k=function(E){var C=l(E),I=C==h?E.constructor:void 0,P=I?u(I):"";if(P)switch(P){case w:return y;case N:return c;case _:return p;case b:return d;case S:return m}return C}),Nh=k,Nh}var Ch,G1;function n$(){if(G1)return Ch;G1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&n.call(i,"index")&&(l.index=i.index,l.input=i.input),l}return Ch=r,Ch}var Th,Y1;function HC(){if(Y1)return Th;Y1=1;var e=sr(),n=e.Uint8Array;return Th=n,Th}var Rh,K1;function hy(){if(K1)return Rh;K1=1;var e=HC();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return Rh=n,Rh}var jh,X1;function r$(){if(X1)return jh;X1=1;var e=hy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return jh=n,jh}var Ah,Q1;function s$(){if(Q1)return Ah;Q1=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return Ah=n,Ah}var Ih,Z1;function i$(){if(Z1)return Ih;Z1=1;var e=vo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return Ih=i,Ih}var Mh,J1;function WC(){if(J1)return Mh;J1=1;var e=hy();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return Mh=n,Mh}var Oh,eb;function o$(){if(eb)return Oh;eb=1;var e=hy(),n=r$(),r=s$(),i=i$(),o=WC(),l="[object Boolean]",u="[object Date]",c="[object Map]",h="[object Number]",p="[object RegExp]",d="[object Set]",m="[object String]",y="[object Symbol]",w="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",b="[object Float64Array]",S="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",I="[object Uint8ClampedArray]",P="[object Uint16Array]",A="[object Uint32Array]";function H(z,L,F){var G=z.constructor;switch(L){case w:return e(z);case l:case u:return new G(+z);case N:return n(z,F);case _:case b:case S:case k:case E:case C:case I:case P:case A:return o(z,F);case c:return new G;case h:case m:return new G(z);case p:return r(z);case d:return new G;case y:return i(z)}}return Oh=H,Oh}var Ph,tb;function VC(){if(tb)return Ph;tb=1;var e=$n(),n=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(n)return n(o);i.prototype=o;var l=new i;return i.prototype=void 0,l}})();return Ph=r,Ph}var Lh,nb;function GC(){if(nb)return Lh;nb=1;var e=VC(),n=Wu(),r=Hu();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return Lh=i,Lh}var qh,rb;function a$(){if(rb)return qh;rb=1;var e=wo(),n=mr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return qh=i,qh}var $h,sb;function l$(){if(sb)return $h;sb=1;var e=a$(),n=Uu(),r=uy(),i=r&&r.isMap,o=i?n(i):e;return $h=o,$h}var Dh,ib;function u$(){if(ib)return Dh;ib=1;var e=wo(),n=mr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return Dh=i,Dh}var Fh,ob;function c$(){if(ob)return Fh;ob=1;var e=u$(),n=Uu(),r=uy(),i=r&&r.isSet,o=i?n(i):e;return Fh=o,Fh}var zh,ab;function YC(){if(ab)return zh;ab=1;var e=Du(),n=ay(),r=zu(),i=Vq(),o=Kq(),l=LC(),u=qC(),c=Xq(),h=Qq(),p=BC(),d=Zq(),m=wo(),y=n$(),w=o$(),N=GC(),_=bt(),b=yo(),S=l$(),k=$n(),E=c$(),C=Ns(),I=pi(),P=1,A=2,H=4,z="[object Arguments]",L="[object Array]",F="[object Boolean]",G="[object Date]",O="[object Error]",j="[object Function]",q="[object GeneratorFunction]",$="[object Map]",re="[object Number]",J="[object Object]",W="[object RegExp]",Z="[object Set]",M="[object String]",Y="[object Symbol]",U="[object WeakMap]",B="[object ArrayBuffer]",X="[object DataView]",ne="[object Float32Array]",le="[object Float64Array]",fe="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",Ce="[object Uint8Array]",ve="[object Uint8ClampedArray]",je="[object Uint16Array]",ye="[object Uint32Array]",ke={};ke[z]=ke[L]=ke[B]=ke[X]=ke[F]=ke[G]=ke[ne]=ke[le]=ke[fe]=ke[te]=ke[ce]=ke[$]=ke[re]=ke[J]=ke[W]=ke[Z]=ke[M]=ke[Y]=ke[Ce]=ke[ve]=ke[je]=ke[ye]=!0,ke[O]=ke[j]=ke[U]=!1;function Ye(we,_e,Be,it,yt,Ze){var De,Je=_e&P,Xe=_e&A,Mt=_e&H;if(Be&&(De=yt?Be(we,it,yt,Ze):Be(we)),De!==void 0)return De;if(!k(we))return we;var ut=_(we);if(ut){if(De=y(we),!Je)return u(we,De)}else{var Qe=m(we),Ot=Qe==j||Qe==q;if(b(we))return l(we,Je);if(Qe==J||Qe==z||Ot&&!yt){if(De=Xe||Ot?{}:N(we),!Je)return Xe?h(we,o(De,we)):c(we,i(De,we))}else{if(!ke[Qe])return yt?we:{};De=w(we,Qe,Je)}}Ze||(Ze=new e);var Ft=Ze.get(we);if(Ft)return Ft;Ze.set(we,De),E(we)?we.forEach(function(pt){De.add(Ye(pt,_e,Be,pt,we,Ze))}):S(we)&&we.forEach(function(pt,wt){De.set(wt,Ye(pt,_e,Be,wt,we,Ze))});var et=Mt?Xe?d:p:Xe?I:C,St=ut?void 0:et(we);return n(St||we,function(pt,wt){St&&(wt=pt,pt=we[wt]),r(De,wt,Ye(pt,_e,Be,wt,we,Ze))}),De}return zh=Ye,zh}var Bh,lb;function d$(){if(lb)return Bh;lb=1;var e=YC(),n=4;function r(i){return e(i,n)}return Bh=r,Bh}var Uh,ub;function py(){if(ub)return Uh;ub=1;function e(n){return function(){return n}}return Uh=e,Uh}var Hh,cb;function f$(){if(cb)return Hh;cb=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),h=c.length;h--;){var p=c[n?h:++l];if(i(u[p],p,u)===!1)break}return r}}return Hh=e,Hh}var Wh,db;function my(){if(db)return Wh;db=1;var e=f$(),n=e();return Wh=n,Wh}var Vh,fb;function gy(){if(fb)return Vh;fb=1;var e=my(),n=Ns();function r(i,o){return i&&e(i,o,n)}return Vh=r,Vh}var Gh,hb;function h$(){if(hb)return Gh;hb=1;var e=Ur();function n(r,i){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=i?u:-1,h=Object(o);(i?c--:++c<u)&&l(h[c],c,h)!==!1;);return o}}return Gh=n,Gh}var Yh,pb;function Vu(){if(pb)return Yh;pb=1;var e=gy(),n=h$(),r=n(e);return Yh=r,Yh}var Kh,mb;function mi(){if(mb)return Kh;mb=1;function e(n){return n}return Kh=e,Kh}var Xh,gb;function KC(){if(gb)return Xh;gb=1;var e=mi();function n(r){return typeof r=="function"?r:e}return Xh=n,Xh}var Qh,vb;function XC(){if(vb)return Qh;vb=1;var e=ay(),n=Vu(),r=KC(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return Qh=o,Qh}var Zh,yb;function QC(){return yb||(yb=1,Zh=XC()),Zh}var Jh,wb;function p$(){if(wb)return Jh;wb=1;var e=Vu();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return Jh=n,Jh}var ep,xb;function m$(){if(xb)return ep;xb=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return ep=n,ep}var tp,_b;function g$(){if(_b)return tp;_b=1;function e(n){return this.__data__.has(n)}return tp=e,tp}var np,bb;function ZC(){if(bb)return np;bb=1;var e=oy(),n=m$(),r=g$();function i(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return i.prototype.add=i.prototype.push=n,i.prototype.has=r,np=i,np}var rp,Sb;function v$(){if(Sb)return rp;Sb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o;)if(r(n[i],i,n))return!0;return!1}return rp=e,rp}var sp,kb;function JC(){if(kb)return sp;kb=1;function e(n,r){return n.has(r)}return sp=e,sp}var ip,Eb;function eT(){if(Eb)return ip;Eb=1;var e=ZC(),n=v$(),r=JC(),i=1,o=2;function l(u,c,h,p,d,m){var y=h&i,w=u.length,N=c.length;if(w!=N&&!(y&&N>w))return!1;var _=m.get(u),b=m.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,E=h&o?new e:void 0;for(m.set(u,c),m.set(c,u);++S<w;){var C=u[S],I=c[S];if(p)var P=y?p(I,C,S,c,u,m):p(C,I,S,u,c,m);if(P!==void 0){if(P)continue;k=!1;break}if(E){if(!n(c,function(A,H){if(!r(E,H)&&(C===A||d(C,A,h,p,m)))return E.push(H)})){k=!1;break}}else if(!(C===I||d(C,I,h,p,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return ip=l,ip}var op,Nb;function y$(){if(Nb)return op;Nb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return op=e,op}var ap,Cb;function vy(){if(Cb)return ap;Cb=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return ap=e,ap}var lp,Tb;function w$(){if(Tb)return lp;Tb=1;var e=vo(),n=HC(),r=go(),i=eT(),o=y$(),l=vy(),u=1,c=2,h="[object Boolean]",p="[object Date]",d="[object Error]",m="[object Map]",y="[object Number]",w="[object RegExp]",N="[object Set]",_="[object String]",b="[object Symbol]",S="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function I(P,A,H,z,L,F,G){switch(H){case k:if(P.byteLength!=A.byteLength||P.byteOffset!=A.byteOffset)return!1;P=P.buffer,A=A.buffer;case S:return!(P.byteLength!=A.byteLength||!F(new n(P),new n(A)));case h:case p:case y:return r(+P,+A);case d:return P.name==A.name&&P.message==A.message;case w:case _:return P==A+"";case m:var O=o;case N:var j=z&u;if(O||(O=l),P.size!=A.size&&!j)return!1;var q=G.get(P);if(q)return q==A;z|=c,G.set(P,A);var $=i(O(P),O(A),z,L,F,G);return G.delete(P),$;case b:if(C)return C.call(P)==C.call(A)}return!1}return lp=I,lp}var up,Rb;function x$(){if(Rb)return up;Rb=1;var e=BC(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,h,p,d){var m=c&n,y=e(l),w=y.length,N=e(u),_=N.length;if(w!=_&&!m)return!1;for(var b=w;b--;){var S=y[b];if(!(m?S in u:i.call(u,S)))return!1}var k=d.get(l),E=d.get(u);if(k&&E)return k==u&&E==l;var C=!0;d.set(l,u),d.set(u,l);for(var I=m;++b<w;){S=y[b];var P=l[S],A=u[S];if(h)var H=m?h(A,P,S,u,l,d):h(P,A,S,l,u,d);if(!(H===void 0?P===A||p(P,A,c,h,d):H)){C=!1;break}I||(I=S=="constructor")}if(C&&!I){var z=l.constructor,L=u.constructor;z!=L&&"constructor"in l&&"constructor"in u&&!(typeof z=="function"&&z instanceof z&&typeof L=="function"&&L instanceof L)&&(C=!1)}return d.delete(l),d.delete(u),C}return up=o,up}var cp,jb;function _$(){if(jb)return cp;jb=1;var e=Du(),n=eT(),r=w$(),i=x$(),o=wo(),l=bt(),u=yo(),c=Ma(),h=1,p="[object Arguments]",d="[object Array]",m="[object Object]",y=Object.prototype,w=y.hasOwnProperty;function N(_,b,S,k,E,C){var I=l(_),P=l(b),A=I?d:o(_),H=P?d:o(b);A=A==p?m:A,H=H==p?m:H;var z=A==m,L=H==m,F=A==H;if(F&&u(_)){if(!u(b))return!1;I=!0,z=!1}if(F&&!z)return C||(C=new e),I||c(_)?n(_,b,S,k,E,C):r(_,b,A,S,k,E,C);if(!(S&h)){var G=z&&w.call(_,"__wrapped__"),O=L&&w.call(b,"__wrapped__");if(G||O){var j=G?_.value():_,q=O?b.value():b;return C||(C=new e),E(j,q,S,k,C)}}return F?(C||(C=new e),i(_,b,S,k,E,C)):!1}return cp=N,cp}var dp,Ab;function tT(){if(Ab)return dp;Ab=1;var e=_$(),n=mr();function r(i,o,l,u,c){return i===o?!0:i==null||o==null||!n(i)&&!n(o)?i!==i&&o!==o:e(i,o,l,u,r,c)}return dp=r,dp}var fp,Ib;function b$(){if(Ib)return fp;Ib=1;var e=Du(),n=tT(),r=1,i=2;function o(l,u,c,h){var p=c.length,d=p,m=!h;if(l==null)return!d;for(l=Object(l);p--;){var y=c[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<d;){y=c[p];var w=y[0],N=l[w],_=y[1];if(m&&y[2]){if(N===void 0&&!(w in l))return!1}else{var b=new e;if(h)var S=h(N,_,w,l,u,b);if(!(S===void 0?n(_,N,r|i,h,b):S))return!1}}return!0}return fp=o,fp}var hp,Mb;function nT(){if(Mb)return hp;Mb=1;var e=$n();function n(r){return r===r&&!e(r)}return hp=n,hp}var pp,Ob;function S$(){if(Ob)return pp;Ob=1;var e=nT(),n=Ns();function r(i){for(var o=n(i),l=o.length;l--;){var u=o[l],c=i[u];o[l]=[u,c,e(c)]}return o}return pp=r,pp}var mp,Pb;function rT(){if(Pb)return mp;Pb=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return mp=e,mp}var gp,Lb;function k$(){if(Lb)return gp;Lb=1;var e=b$(),n=S$(),r=rT();function i(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return gp=i,gp}var vp,qb;function xo(){if(qb)return vp;qb=1;var e=fi(),n=mr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return vp=i,vp}var yp,$b;function yy(){if($b)return yp;$b=1;var e=bt(),n=xo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:i.test(l)||!r.test(l)||u!=null&&l in Object(u)}return yp=o,yp}var wp,Db;function E$(){if(Db)return wp;Db=1;var e=oy(),n="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],h=l.cache;if(h.has(c))return h.get(c);var p=i.apply(this,u);return l.cache=h.set(c,p)||h,p};return l.cache=new(r.Cache||e),l}return r.Cache=e,wp=r,wp}var xp,Fb;function N$(){if(Fb)return xp;Fb=1;var e=E$(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return xp=r,xp}var _p,zb;function C$(){if(zb)return _p;zb=1;var e=N$(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,h,p){l.push(h?p.replace(r,"$1"):c||u)}),l});return _p=i,_p}var bp,Bb;function Gu(){if(Bb)return bp;Bb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=Array(o);++i<o;)l[i]=r(n[i],i,n);return l}return bp=e,bp}var Sp,Ub;function T$(){if(Ub)return Sp;Ub=1;var e=vo(),n=Gu(),r=bt(),i=xo(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(i(c))return l?l.call(c):"";var h=c+"";return h=="0"&&1/c==-1/0?"-0":h}return Sp=u,Sp}var kp,Hb;function sT(){if(Hb)return kp;Hb=1;var e=T$();function n(r){return r==null?"":e(r)}return kp=n,kp}var Ep,Wb;function Yu(){if(Wb)return Ep;Wb=1;var e=bt(),n=yy(),r=C$(),i=sT();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return Ep=o,Ep}var Np,Vb;function Oa(){if(Vb)return Np;Vb=1;var e=xo();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return Np=n,Np}var Cp,Gb;function Ku(){if(Gb)return Cp;Gb=1;var e=Yu(),n=Oa();function r(i,o){o=e(o,i);for(var l=0,u=o.length;i!=null&&l<u;)i=i[n(o[l++])];return l&&l==u?i:void 0}return Cp=r,Cp}var Tp,Yb;function R$(){if(Yb)return Tp;Yb=1;var e=Ku();function n(r,i,o){var l=r==null?void 0:e(r,i);return l===void 0?o:l}return Tp=n,Tp}var Rp,Kb;function j$(){if(Kb)return Rp;Kb=1;function e(n,r){return n!=null&&r in Object(n)}return Rp=e,Rp}var jp,Xb;function iT(){if(Xb)return jp;Xb=1;var e=Yu(),n=Ia(),r=bt(),i=Bu(),o=ly(),l=Oa();function u(c,h,p){h=e(h,c);for(var d=-1,m=h.length,y=!1;++d<m;){var w=l(h[d]);if(!(y=c!=null&&p(c,w)))break;c=c[w]}return y||++d!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&i(w,m)&&(r(c)||n(c)))}return jp=u,jp}var Ap,Qb;function oT(){if(Qb)return Ap;Qb=1;var e=j$(),n=iT();function r(i,o){return i!=null&&n(i,o,e)}return Ap=r,Ap}var Ip,Zb;function A$(){if(Zb)return Ip;Zb=1;var e=tT(),n=R$(),r=oT(),i=yy(),o=nT(),l=rT(),u=Oa(),c=1,h=2;function p(d,m){return i(d)&&o(m)?l(u(d),m):function(y){var w=n(y,d);return w===void 0&&w===m?r(y,d):e(m,w,c|h)}}return Ip=p,Ip}var Mp,Jb;function aT(){if(Jb)return Mp;Jb=1;function e(n){return function(r){return r==null?void 0:r[n]}}return Mp=e,Mp}var Op,eS;function I$(){if(eS)return Op;eS=1;var e=Ku();function n(r){return function(i){return e(i,r)}}return Op=n,Op}var Pp,tS;function M$(){if(tS)return Pp;tS=1;var e=aT(),n=I$(),r=yy(),i=Oa();function o(l){return r(l)?e(i(l)):n(l)}return Pp=o,Pp}var Lp,nS;function Hr(){if(nS)return Lp;nS=1;var e=k$(),n=A$(),r=mi(),i=bt(),o=M$();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?n(u[0],u[1]):e(u):o(u)}return Lp=l,Lp}var qp,rS;function lT(){if(rS)return qp;rS=1;var e=$C(),n=p$(),r=Hr(),i=bt();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return qp=o,qp}var $p,sS;function O$(){if(sS)return $p;sS=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return $p=r,$p}var Dp,iS;function uT(){if(iS)return Dp;iS=1;var e=O$(),n=iT();function r(i,o){return i!=null&&n(i,o,e)}return Dp=r,Dp}var Fp,oS;function P$(){if(oS)return Fp;oS=1;var e=cy(),n=wo(),r=Ia(),i=bt(),o=Ur(),l=yo(),u=Hu(),c=Ma(),h="[object Map]",p="[object Set]",d=Object.prototype,m=d.hasOwnProperty;function y(w){if(w==null)return!0;if(o(w)&&(i(w)||typeof w=="string"||typeof w.splice=="function"||l(w)||c(w)||r(w)))return!w.length;var N=n(w);if(N==h||N==p)return!w.size;if(u(w))return!e(w).length;for(var _ in w)if(m.call(w,_))return!1;return!0}return Fp=y,Fp}var zp,aS;function cT(){if(aS)return zp;aS=1;function e(n){return n===void 0}return zp=e,zp}var Bp,lS;function dT(){if(lS)return Bp;lS=1;var e=Vu(),n=Ur();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,h,p){u[++l]=o(c,h,p)}),u}return Bp=r,Bp}var Up,uS;function fT(){if(uS)return Up;uS=1;var e=Gu(),n=Hr(),r=dT(),i=bt();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return Up=o,Up}var Hp,cS;function L$(){if(cS)return Hp;cS=1;function e(n,r,i,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(i=n[++l]);++l<u;)i=r(i,n[l],l,n);return i}return Hp=e,Hp}var Wp,dS;function q$(){if(dS)return Wp;dS=1;function e(n,r,i,o,l){return l(n,function(u,c,h){i=o?(o=!1,u):r(i,u,c,h)}),i}return Wp=e,Wp}var Vp,fS;function hT(){if(fS)return Vp;fS=1;var e=L$(),n=Vu(),r=Hr(),i=q$(),o=bt();function l(u,c,h){var p=o(u)?e:i,d=arguments.length<3;return p(u,r(c,4),h,d,n)}return Vp=l,Vp}var Gp,hS;function $$(){if(hS)return Gp;hS=1;var e=fi(),n=bt(),r=mr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return Gp=o,Gp}var Yp,pS;function D$(){if(pS)return Yp;pS=1;var e=aT(),n=e("length");return Yp=n,Yp}var Kp,mS;function F$(){if(mS)return Kp;mS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function h(p){return c.test(p)}return Kp=h,Kp}var Xp,gS;function z$(){if(gS)return Xp;gS=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",h="\\ud83c[\\udffb-\\udfff]",p="(?:"+c+"|"+h+")",d="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",N=p+"?",_="["+l+"]?",b="(?:"+w+"(?:"+[d,m,y].join("|")+")"+_+N+")*",S=_+N+b,k="(?:"+[d+c+"?",c,m,y,u].join("|")+")",E=RegExp(h+"(?="+h+")|"+k+S,"g");function C(I){for(var P=E.lastIndex=0;E.test(I);)++P;return P}return Xp=C,Xp}var Qp,vS;function B$(){if(vS)return Qp;vS=1;var e=D$(),n=F$(),r=z$();function i(o){return n(o)?r(o):e(o)}return Qp=i,Qp}var Zp,yS;function U$(){if(yS)return Zp;yS=1;var e=cy(),n=wo(),r=Ur(),i=$$(),o=B$(),l="[object Map]",u="[object Set]";function c(h){if(h==null)return 0;if(r(h))return i(h)?o(h):h.length;var p=n(h);return p==l||p==u?h.size:e(h).length}return Zp=c,Zp}var Jp,wS;function H$(){if(wS)return Jp;wS=1;var e=ay(),n=VC(),r=gy(),i=Hr(),o=Wu(),l=bt(),u=yo(),c=ja(),h=$n(),p=Ma();function d(m,y,w){var N=l(m),_=N||u(m)||p(m);if(y=i(y,4),w==null){var b=m&&m.constructor;_?w=N?new b:[]:h(m)?w=c(b)?n(o(m)):{}:w={}}return(_?e:r)(m,function(S,k,E){return y(w,S,k,E)}),w}return Jp=d,Jp}var em,xS;function W$(){if(xS)return em;xS=1;var e=vo(),n=Ia(),r=bt(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return em=o,em}var tm,_S;function wy(){if(_S)return tm;_S=1;var e=fy(),n=W$();function r(i,o,l,u,c){var h=-1,p=i.length;for(l||(l=n),c||(c=[]);++h<p;){var d=i[h];o>0&&l(d)?o>1?r(d,o-1,l,u,c):e(c,d):u||(c[c.length]=d)}return c}return tm=r,tm}var nm,bS;function V$(){if(bS)return nm;bS=1;function e(n,r,i){switch(i.length){case 0:return n.call(r);case 1:return n.call(r,i[0]);case 2:return n.call(r,i[0],i[1]);case 3:return n.call(r,i[0],i[1],i[2])}return n.apply(r,i)}return nm=e,nm}var rm,SS;function pT(){if(SS)return rm;SS=1;var e=V$(),n=Math.max;function r(i,o,l){return o=n(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,h=n(u.length-o,0),p=Array(h);++c<h;)p[c]=u[o+c];c=-1;for(var d=Array(o+1);++c<o;)d[c]=u[c];return d[o]=l(p),e(i,this,d)}}return rm=r,rm}var sm,kS;function G$(){if(kS)return sm;kS=1;var e=py(),n=MC(),r=mi(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return sm=i,sm}var im,ES;function Y$(){if(ES)return im;ES=1;var e=800,n=16,r=Date.now;function i(o){var l=0,u=0;return function(){var c=r(),h=n-(c-u);if(u=c,h>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return im=i,im}var om,NS;function mT(){if(NS)return om;NS=1;var e=G$(),n=Y$(),r=n(e);return om=r,om}var am,CS;function Xu(){if(CS)return am;CS=1;var e=mi(),n=pT(),r=mT();function i(o,l){return r(n(o,l,e),o+"")}return am=i,am}var lm,TS;function gT(){if(TS)return lm;TS=1;function e(n,r,i,o){for(var l=n.length,u=i+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return lm=e,lm}var um,RS;function K$(){if(RS)return um;RS=1;function e(n){return n!==n}return um=e,um}var cm,jS;function X$(){if(jS)return cm;jS=1;function e(n,r,i){for(var o=i-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return cm=e,cm}var dm,AS;function Q$(){if(AS)return dm;AS=1;var e=gT(),n=K$(),r=X$();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return dm=i,dm}var fm,IS;function Z$(){if(IS)return fm;IS=1;var e=Q$();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return fm=n,fm}var hm,MS;function J$(){if(MS)return hm;MS=1;function e(n,r,i){for(var o=-1,l=n==null?0:n.length;++o<l;)if(i(r,n[o]))return!0;return!1}return hm=e,hm}var pm,OS;function eD(){if(OS)return pm;OS=1;function e(){}return pm=e,pm}var mm,PS;function tD(){if(PS)return mm;PS=1;var e=UC(),n=eD(),r=vy(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return mm=o,mm}var gm,LS;function nD(){if(LS)return gm;LS=1;var e=ZC(),n=Z$(),r=J$(),i=JC(),o=tD(),l=vy(),u=200;function c(h,p,d){var m=-1,y=n,w=h.length,N=!0,_=[],b=_;if(d)N=!1,y=r;else if(w>=u){var S=p?null:o(h);if(S)return l(S);N=!1,y=i,b=new e}else b=p?[]:_;e:for(;++m<w;){var k=h[m],E=p?p(k):k;if(k=d||k!==0?k:0,N&&E===E){for(var C=b.length;C--;)if(b[C]===E)continue e;p&&b.push(E),_.push(k)}else y(b,E,d)||(b!==_&&b.push(E),_.push(k))}return _}return gm=c,gm}var vm,qS;function vT(){if(qS)return vm;qS=1;var e=Ur(),n=mr();function r(i){return n(i)&&e(i)}return vm=r,vm}var ym,$S;function rD(){if($S)return ym;$S=1;var e=wy(),n=Xu(),r=nD(),i=vT(),o=n(function(l){return r(e(l,1,i,!0))});return ym=o,ym}var wm,DS;function sD(){if(DS)return wm;DS=1;var e=Gu();function n(r,i){return e(i,function(o){return r[o]})}return wm=n,wm}var xm,FS;function yT(){if(FS)return xm;FS=1;var e=sD(),n=Ns();function r(i){return i==null?[]:e(i,n(i))}return xm=r,xm}var _m,zS;function Dn(){if(zS)return _m;zS=1;var e;if(typeof sy=="function")try{e={clone:d$(),constant:py(),each:QC(),filter:lT(),has:uT(),isArray:bt(),isEmpty:P$(),isFunction:ja(),isUndefined:cT(),keys:Ns(),map:fT(),reduce:hT(),size:U$(),transform:H$(),union:rD(),values:yT()}}catch{}return e||(e=window._),_m=e,_m}var bm,BS;function xy(){if(BS)return bm;BS=1;var e=Dn();bm=o;var n="\0",r="\0",i="";function o(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(d){return this._label=d,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._in[m])})},o.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(m){return e.isEmpty(d._out[m])})},o.prototype.setNodes=function(d,m){var y=arguments,w=this;return e.each(d,function(N){y.length>1?w.setNode(N,m):w.setNode(N)}),this},o.prototype.setNode=function(d,m){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=m),this):(this._nodes[d]=arguments.length>1?m:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},o.prototype.node=function(d){return this._nodes[d]},o.prototype.hasNode=function(d){return e.has(this._nodes,d)},o.prototype.removeNode=function(d){var m=this;if(e.has(this._nodes,d)){var y=function(w){m.removeEdge(m._edgeObjs[w])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(w){m.setParent(w)}),delete this._children[d]),e.each(e.keys(this._in[d]),y),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),y),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},o.prototype.setParent=function(d,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=r;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===d)throw new Error("Setting "+m+" as parent of "+d+" would create a cycle");this.setNode(m)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=m,this._children[m][d]=!0,this},o.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},o.prototype.parent=function(d){if(this._isCompound){var m=this._parent[d];if(m!==r)return m}},o.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var m=this._children[d];if(m)return e.keys(m)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},o.prototype.predecessors=function(d){var m=this._preds[d];if(m)return e.keys(m)},o.prototype.successors=function(d){var m=this._sucs[d];if(m)return e.keys(m)},o.prototype.neighbors=function(d){var m=this.predecessors(d);if(m)return e.union(m,this.successors(d))},o.prototype.isLeaf=function(d){var m;return this.isDirected()?m=this.successors(d):m=this.neighbors(d),m.length===0},o.prototype.filterNodes=function(d){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,b){d(b)&&m.setNode(b,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var w={};function N(_){var b=y.parent(_);return b===void 0||m.hasNode(b)?(w[_]=b,b):b in w?w[b]:N(b)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(d,m){var y=this,w=arguments;return e.reduce(d,function(N,_){return w.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var d,m,y,w,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(d=_.v,m=_.w,y=_.name,arguments.length===2&&(w=arguments[1],N=!0)):(d=_,m=arguments[1],y=arguments[3],arguments.length>2&&(w=arguments[2],N=!0)),d=""+d,m=""+m,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,d,m,y);if(e.has(this._edgeLabels,b))return N&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(m),this._edgeLabels[b]=N?w:this._defaultEdgeLabelFn(d,m,y);var S=h(this._isDirected,d,m,y);return d=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,l(this._preds[m],d),l(this._sucs[d],m),this._in[m][b]=S,this._out[d][b]=S,this._edgeCount++,this},o.prototype.edge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return this._edgeLabels[w]},o.prototype.hasEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y);return e.has(this._edgeLabels,w)},o.prototype.removeEdge=function(d,m,y){var w=arguments.length===1?p(this._isDirected,arguments[0]):c(this._isDirected,d,m,y),N=this._edgeObjs[w];return N&&(d=N.v,m=N.w,delete this._edgeLabels[w],delete this._edgeObjs[w],u(this._preds[m],d),u(this._sucs[d],m),delete this._in[m][w],delete this._out[d][w],this._edgeCount--),this},o.prototype.inEdges=function(d,m){var y=this._in[d];if(y){var w=e.values(y);return m?e.filter(w,function(N){return N.v===m}):w}},o.prototype.outEdges=function(d,m){var y=this._out[d];if(y){var w=e.values(y);return m?e.filter(w,function(N){return N.w===m}):w}},o.prototype.nodeEdges=function(d,m){var y=this.inEdges(d,m);if(y)return y.concat(this.outEdges(d,m))};function l(d,m){d[m]?d[m]++:d[m]=1}function u(d,m){--d[m]||delete d[m]}function c(d,m,y,w){var N=""+m,_=""+y;if(!d&&N>_){var b=N;N=_,_=b}return N+i+_+i+(e.isUndefined(w)?n:w)}function h(d,m,y,w){var N=""+m,_=""+y;if(!d&&N>_){var b=N;N=_,_=b}var S={v:N,w:_};return w&&(S.name=w),S}function p(d,m){return c(d,m.v,m.w,m.name)}return bm}var Sm,US;function iD(){return US||(US=1,Sm="2.1.8"),Sm}var km,HS;function oD(){return HS||(HS=1,km={Graph:xy(),version:iD()}),km}var Em,WS;function aD(){if(WS)return Em;WS=1;var e=Dn(),n=xy();Em={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:i(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function i(u){return e.map(u.nodes(),function(c){var h=u.node(c),p=u.parent(c),d={v:c};return e.isUndefined(h)||(d.value=h),e.isUndefined(p)||(d.parent=p),d})}function o(u){return e.map(u.edges(),function(c){var h=u.edge(c),p={v:c.v,w:c.w};return e.isUndefined(c.name)||(p.name=c.name),e.isUndefined(h)||(p.value=h),p})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(h){c.setNode(h.v,h.value),h.parent&&c.setParent(h.v,h.parent)}),e.each(u.edges,function(h){c.setEdge({v:h.v,w:h.w,name:h.name},h.value)}),c}return Em}var Nm,VS;function lD(){if(VS)return Nm;VS=1;var e=Dn();Nm=n;function n(r){var i={},o=[],l;function u(c){e.has(i,c)||(i[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return Nm}var Cm,GS;function wT(){if(GS)return Cm;GS=1;var e=Dn();Cm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:i}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,i){var o=this._keyIndices[r];if(i>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+i);this._arr[o].priority=i,this._decrease(o)},n.prototype._heapify=function(r){var i=this._arr,o=2*r,l=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,l<i.length&&(u=i[l].priority<i[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,l;r!==0&&(l=r>>1,!(i[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,i){var o=this._arr,l=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,l[c.key]=r,l[u.key]=i},Cm}var Tm,YS;function xT(){if(YS)return Tm;YS=1;var e=Dn(),n=wT();Tm=i;var r=e.constant(1);function i(l,u,c,h){return o(l,String(u),c||r,h||function(p){return l.outEdges(p)})}function o(l,u,c,h){var p={},d=new n,m,y,w=function(N){var _=N.v!==m?N.v:N.w,b=p[_],S=c(N),k=y.distance+S;if(S<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+S);k<b.distance&&(b.distance=k,b.predecessor=m,d.decrease(_,k))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;p[N]={distance:_},d.add(N,_)});d.size()>0&&(m=d.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)h(m).forEach(w);return p}return Tm}var Rm,KS;function uD(){if(KS)return Rm;KS=1;var e=xT(),n=Dn();Rm=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return Rm}var jm,XS;function _T(){if(XS)return jm;XS=1;var e=Dn();jm=n;function n(r){var i=0,o=[],l={},u=[];function c(h){var p=l[h]={onStack:!0,lowlink:i,index:i++};if(o.push(h),r.successors(h).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(c(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var d=[],m;do m=o.pop(),l[m].onStack=!1,d.push(m);while(h!==m);u.push(d)}}return r.nodes().forEach(function(h){e.has(l,h)||c(h)}),u}return jm}var Am,QS;function cD(){if(QS)return Am;QS=1;var e=Dn(),n=_T();Am=r;function r(i){return e.filter(n(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return Am}var Im,ZS;function dD(){if(ZS)return Im;ZS=1;var e=Dn();Im=r;var n=e.constant(1);function r(o,l,u){return i(o,l||n,u||function(c){return o.outEdges(c)})}function i(o,l,u){var c={},h=o.nodes();return h.forEach(function(p){c[p]={},c[p][p]={distance:0},h.forEach(function(d){p!==d&&(c[p][d]={distance:Number.POSITIVE_INFINITY})}),u(p).forEach(function(d){var m=d.v===p?d.w:d.v,y=l(d);c[p][m]={distance:y,predecessor:p}})}),h.forEach(function(p){var d=c[p];h.forEach(function(m){var y=c[m];h.forEach(function(w){var N=y[p],_=d[w],b=y[w],S=N.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return Im}var Mm,JS;function bT(){if(JS)return Mm;JS=1;var e=Dn();Mm=n,n.CycleException=r;function n(i){var o={},l={},u=[];function c(h){if(e.has(l,h))throw new r;e.has(o,h)||(l[h]=!0,o[h]=!0,e.each(i.predecessors(h),c),delete l[h],u.push(h))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,Mm}var Om,ek;function fD(){if(ek)return Om;ek=1;var e=bT();Om=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return Om}var Pm,tk;function ST(){if(tk)return Pm;tk=1;var e=Dn();Pm=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],h={};return e.each(o,function(p){if(!i.hasNode(p))throw new Error("Graph does not have node: "+p);r(i,p,l==="post",h,u,c)}),c}function r(i,o,l,u,c,h){e.has(u,o)||(u[o]=!0,l||h.push(o),e.each(c(o),function(p){r(i,p,l,u,c,h)}),l&&h.push(o))}return Pm}var Lm,nk;function hD(){if(nk)return Lm;nk=1;var e=ST();Lm=n;function n(r,i){return e(r,i,"post")}return Lm}var qm,rk;function pD(){if(rk)return qm;rk=1;var e=ST();qm=n;function n(r,i){return e(r,i,"pre")}return qm}var $m,sk;function mD(){if(sk)return $m;sk=1;var e=Dn(),n=xy(),r=wT();$m=i;function i(o,l){var u=new n,c={},h=new r,p;function d(y){var w=y.v===p?y.w:y.v,N=h.priority(w);if(N!==void 0){var _=l(y);_<N&&(c[w]=p,h.decrease(w,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){h.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),h.decrease(o.nodes()[0],0);for(var m=!1;h.size()>0;){if(p=h.removeMin(),e.has(c,p))u.setEdge(p,c[p]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(p).forEach(d)}return u}return $m}var Dm,ik;function gD(){return ik||(ik=1,Dm={components:lD(),dijkstra:xT(),dijkstraAll:uD(),findCycles:cD(),floydWarshall:dD(),isAcyclic:fD(),postorder:hD(),preorder:pD(),prim:mD(),tarjan:_T(),topsort:bT()}),Dm}var Fm,ok;function vD(){if(ok)return Fm;ok=1;var e=oD();return Fm={Graph:e.Graph,json:aD(),alg:gD(),version:e.version},Fm}var zm,ak;function nr(){if(ak)return zm;ak=1;var e;if(typeof sy=="function")try{e=vD()}catch{}return e||(e=window.graphlib),zm=e,zm}var Bm,lk;function yD(){if(lk)return Bm;lk=1;var e=YC(),n=1,r=4;function i(o){return e(o,n|r)}return Bm=i,Bm}var Um,uk;function Qu(){if(uk)return Um;uk=1;var e=go(),n=Ur(),r=Bu(),i=$n();function o(l,u,c){if(!i(c))return!1;var h=typeof u;return(h=="number"?n(c)&&r(u,c.length):h=="string"&&u in c)?e(c[u],l):!1}return Um=o,Um}var Hm,ck;function wD(){if(ck)return Hm;ck=1;var e=Xu(),n=go(),r=Qu(),i=pi(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,h){c=Object(c);var p=-1,d=h.length,m=d>2?h[2]:void 0;for(m&&r(h[0],h[1],m)&&(d=1);++p<d;)for(var y=h[p],w=i(y),N=-1,_=w.length;++N<_;){var b=w[N],S=c[b];(S===void 0||n(S,o[b])&&!l.call(c,b))&&(c[b]=y[b])}return c});return Hm=u,Hm}var Wm,dk;function xD(){if(dk)return Wm;dk=1;var e=Hr(),n=Ur(),r=Ns();function i(o){return function(l,u,c){var h=Object(l);if(!n(l)){var p=e(u,3);l=r(l),u=function(m){return p(h[m],m,h)}}var d=o(l,u,c);return d>-1?h[p?l[d]:d]:void 0}}return Wm=i,Wm}var Vm,fk;function _D(){if(fk)return Vm;fk=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return Vm=n,Vm}var Gm,hk;function bD(){if(hk)return Gm;hk=1;var e=_D(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return Gm=r,Gm}var Ym,pk;function SD(){if(pk)return Ym;pk=1;var e=bD(),n=$n(),r=xo(),i=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function h(p){if(typeof p=="number")return p;if(r(p))return i;if(n(p)){var d=typeof p.valueOf=="function"?p.valueOf():p;p=n(d)?d+"":d}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||u.test(p)?c(p.slice(2),m?2:8):o.test(p)?i:+p}return Ym=h,Ym}var Km,mk;function kT(){if(mk)return Km;mk=1;var e=SD(),n=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Km=i,Km}var Xm,gk;function kD(){if(gk)return Xm;gk=1;var e=kT();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return Xm=n,Xm}var Qm,vk;function ED(){if(vk)return Qm;vk=1;var e=gT(),n=Hr(),r=kD(),i=Math.max;function o(l,u,c){var h=l==null?0:l.length;if(!h)return-1;var p=c==null?0:r(c);return p<0&&(p=i(h+p,0)),e(l,n(u,3),p)}return Qm=o,Qm}var Zm,yk;function ND(){if(yk)return Zm;yk=1;var e=xD(),n=ED(),r=e(n);return Zm=r,Zm}var Jm,wk;function ET(){if(wk)return Jm;wk=1;var e=wy();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return Jm=n,Jm}var eg,xk;function CD(){if(xk)return eg;xk=1;var e=my(),n=KC(),r=pi();function i(o,l){return o==null?o:e(o,n(l),r)}return eg=i,eg}var tg,_k;function TD(){if(_k)return tg;_k=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return tg=e,tg}var ng,bk;function RD(){if(bk)return ng;bk=1;var e=Fu(),n=gy(),r=Hr();function i(o,l){var u={};return l=r(l,3),n(o,function(c,h,p){e(u,h,l(c,h,p))}),u}return ng=i,ng}var rg,Sk;function _y(){if(Sk)return rg;Sk=1;var e=xo();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],h=i(c);if(h!=null&&(p===void 0?h===h&&!e(h):o(h,p)))var p=h,d=c}return d}return rg=n,rg}var sg,kk;function jD(){if(kk)return sg;kk=1;function e(n,r){return n>r}return sg=e,sg}var ig,Ek;function AD(){if(Ek)return ig;Ek=1;var e=_y(),n=jD(),r=mi();function i(o){return o&&o.length?e(o,r,n):void 0}return ig=i,ig}var og,Nk;function NT(){if(Nk)return og;Nk=1;var e=Fu(),n=go();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return og=r,og}var ag,Ck;function ID(){if(Ck)return ag;Ck=1;var e=fi(),n=Wu(),r=mr(),i="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,h=u.call(Object);function p(d){if(!r(d)||e(d)!=i)return!1;var m=n(d);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==h}return ag=p,ag}var lg,Tk;function CT(){if(Tk)return lg;Tk=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return lg=e,lg}var ug,Rk;function MD(){if(Rk)return ug;Rk=1;var e=Aa(),n=pi();function r(i){return e(i,n(i))}return ug=r,ug}var cg,jk;function OD(){if(jk)return cg;jk=1;var e=NT(),n=LC(),r=WC(),i=qC(),o=GC(),l=Ia(),u=bt(),c=vT(),h=yo(),p=ja(),d=$n(),m=ID(),y=Ma(),w=CT(),N=MD();function _(b,S,k,E,C,I,P){var A=w(b,k),H=w(S,k),z=P.get(H);if(z){e(b,k,z);return}var L=I?I(A,H,k+"",b,S,P):void 0,F=L===void 0;if(F){var G=u(H),O=!G&&h(H),j=!G&&!O&&y(H);L=H,G||O||j?u(A)?L=A:c(A)?L=i(A):O?(F=!1,L=n(H,!0)):j?(F=!1,L=r(H,!0)):L=[]:m(H)||l(H)?(L=A,l(A)?L=N(A):(!d(A)||p(A))&&(L=o(H))):F=!1}F&&(P.set(H,L),C(L,H,E,I,P),P.delete(H)),e(b,k,L)}return cg=_,cg}var dg,Ak;function PD(){if(Ak)return dg;Ak=1;var e=Du(),n=NT(),r=my(),i=OD(),o=$n(),l=pi(),u=CT();function c(h,p,d,m,y){h!==p&&r(p,function(w,N){if(y||(y=new e),o(w))i(h,p,N,d,c,m,y);else{var _=m?m(u(h,N),w,N+"",h,p,y):void 0;_===void 0&&(_=w),n(h,N,_)}},l)}return dg=c,dg}var fg,Ik;function LD(){if(Ik)return fg;Ik=1;var e=Xu(),n=Qu();function r(i){return e(function(o,l){var u=-1,c=l.length,h=c>1?l[c-1]:void 0,p=c>2?l[2]:void 0;for(h=i.length>3&&typeof h=="function"?(c--,h):void 0,p&&n(l[0],l[1],p)&&(h=c<3?void 0:h,c=1),o=Object(o);++u<c;){var d=l[u];d&&i(o,d,u,h)}return o})}return fg=r,fg}var hg,Mk;function qD(){if(Mk)return hg;Mk=1;var e=PD(),n=LD(),r=n(function(i,o,l){e(i,o,l)});return hg=r,hg}var pg,Ok;function TT(){if(Ok)return pg;Ok=1;function e(n,r){return n<r}return pg=e,pg}var mg,Pk;function $D(){if(Pk)return mg;Pk=1;var e=_y(),n=TT(),r=mi();function i(o){return o&&o.length?e(o,r,n):void 0}return mg=i,mg}var gg,Lk;function DD(){if(Lk)return gg;Lk=1;var e=_y(),n=Hr(),r=TT();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return gg=i,gg}var vg,qk;function FD(){if(qk)return vg;qk=1;var e=sr(),n=function(){return e.Date.now()};return vg=n,vg}var yg,$k;function zD(){if($k)return yg;$k=1;var e=zu(),n=Yu(),r=Bu(),i=$n(),o=Oa();function l(u,c,h,p){if(!i(u))return u;c=n(c,u);for(var d=-1,m=c.length,y=m-1,w=u;w!=null&&++d<m;){var N=o(c[d]),_=h;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(d!=y){var b=w[N];_=p?p(b,N,w):void 0,_===void 0&&(_=i(b)?b:r(c[d+1])?[]:{})}e(w,N,_),w=w[N]}return u}return yg=l,yg}var wg,Dk;function BD(){if(Dk)return wg;Dk=1;var e=Ku(),n=zD(),r=Yu();function i(o,l,u){for(var c=-1,h=l.length,p={};++c<h;){var d=l[c],m=e(o,d);u(m,d)&&n(p,r(d,o),m)}return p}return wg=i,wg}var xg,Fk;function UD(){if(Fk)return xg;Fk=1;var e=BD(),n=oT();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return xg=r,xg}var _g,zk;function HD(){if(zk)return _g;zk=1;var e=ET(),n=pT(),r=mT();function i(o){return r(n(o,void 0,e),o+"")}return _g=i,_g}var bg,Bk;function WD(){if(Bk)return bg;Bk=1;var e=UD(),n=HD(),r=n(function(i,o){return i==null?{}:e(i,o)});return bg=r,bg}var Sg,Uk;function VD(){if(Uk)return Sg;Uk=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,h=n(e((o-i)/(l||1)),0),p=Array(h);h--;)p[u?h:++c]=i,i+=l;return p}return Sg=r,Sg}var kg,Hk;function GD(){if(Hk)return kg;Hk=1;var e=VD(),n=Qu(),r=kT();function i(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return kg=i,kg}var Eg,Wk;function YD(){if(Wk)return Eg;Wk=1;var e=GD(),n=e();return Eg=n,Eg}var Ng,Vk;function KD(){if(Vk)return Ng;Vk=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return Ng=e,Ng}var Cg,Gk;function XD(){if(Gk)return Cg;Gk=1;var e=xo();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),h=i!==void 0,p=i===null,d=i===i,m=e(i);if(!p&&!m&&!c&&r>i||c&&h&&d&&!p&&!m||l&&h&&d||!o&&d||!u)return 1;if(!l&&!c&&!m&&r<i||m&&o&&u&&!l&&!c||p&&o&&u||!h&&u||!d)return-1}return 0}return Cg=n,Cg}var Tg,Yk;function QD(){if(Yk)return Tg;Yk=1;var e=XD();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,h=u.length,p=o.length;++l<h;){var d=e(u[l],c[l]);if(d){if(l>=p)return d;var m=o[l];return d*(m=="desc"?-1:1)}}return r.index-i.index}return Tg=n,Tg}var Rg,Kk;function ZD(){if(Kk)return Rg;Kk=1;var e=Gu(),n=Ku(),r=Hr(),i=dT(),o=KD(),l=Uu(),u=QD(),c=mi(),h=bt();function p(d,m,y){m.length?m=e(m,function(_){return h(_)?function(b){return n(b,_.length===1?_[0]:_)}:_}):m=[c];var w=-1;m=e(m,l(r));var N=i(d,function(_,b,S){var k=e(m,function(E){return E(_)});return{criteria:k,index:++w,value:_}});return o(N,function(_,b){return u(_,b,y)})}return Rg=p,Rg}var jg,Xk;function JD(){if(Xk)return jg;Xk=1;var e=wy(),n=ZD(),r=Xu(),i=Qu(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&i(l,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return jg=o,jg}var Ag,Qk;function e4(){if(Qk)return Ag;Qk=1;var e=sT(),n=0;function r(i){var o=++n;return e(i)+o}return Ag=r,Ag}var Ig,Zk;function t4(){if(Zk)return Ig;Zk=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var h=o<u?r[o]:void 0;i(c,n[o],h)}return c}return Ig=e,Ig}var Mg,Jk;function n4(){if(Jk)return Mg;Jk=1;var e=zu(),n=t4();function r(i,o){return n(i||[],o||[],e)}return Mg=r,Mg}var Og,eE;function lt(){if(eE)return Og;eE=1;var e;if(typeof sy=="function")try{e={cloneDeep:yD(),constant:py(),defaults:wD(),each:QC(),filter:lT(),find:ND(),flatten:ET(),forEach:XC(),forIn:CD(),has:uT(),isUndefined:cT(),last:TD(),map:fT(),mapValues:RD(),max:AD(),merge:qD(),min:$D(),minBy:DD(),now:FD(),pick:WD(),range:YD(),reduce:hT(),sortBy:JD(),uniqueId:e4(),values:yT(),zipObject:n4()}}catch{}return e||(e=window._),Og=e,Og}var Pg,tE;function r4(){if(tE)return Pg;tE=1,Pg=e;function e(){var i={};i._next=i._prev=i,this._sentinel=i}e.prototype.dequeue=function(){var i=this._sentinel,o=i._prev;if(o!==i)return n(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&n(i),i._next=o._next,o._next._prev=i,o._next=i,i._prev=o},e.prototype.toString=function(){for(var i=[],o=this._sentinel,l=o._prev;l!==o;)i.push(JSON.stringify(l,r)),l=l._prev;return"["+i.join(", ")+"]"};function n(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function r(i,o){if(i!=="_next"&&i!=="_prev")return o}return Pg}var Lg,nE;function s4(){if(nE)return Lg;nE=1;var e=lt(),n=nr().Graph,r=r4();Lg=o;var i=e.constant(1);function o(p,d){if(p.nodeCount()<=1)return[];var m=c(p,d||i),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(w){return p.outEdges(w.v,w.w)}),!0)}function l(p,d,m){for(var y=[],w=d[d.length-1],N=d[0],_;p.nodeCount();){for(;_=N.dequeue();)u(p,d,m,_);for(;_=w.dequeue();)u(p,d,m,_);if(p.nodeCount()){for(var b=d.length-2;b>0;--b)if(_=d[b].dequeue(),_){y=y.concat(u(p,d,m,_,!0));break}}}return y}function u(p,d,m,y,w){var N=w?[]:void 0;return e.forEach(p.inEdges(y.v),function(_){var b=p.edge(_),S=p.node(_.v);w&&N.push({v:_.v,w:_.w}),S.out-=b,h(d,m,S)}),e.forEach(p.outEdges(y.v),function(_){var b=p.edge(_),S=_.w,k=p.node(S);k.in-=b,h(d,m,k)}),p.removeNode(y.v),N}function c(p,d){var m=new n,y=0,w=0;e.forEach(p.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(p.edges(),function(b){var S=m.edge(b.v,b.w)||0,k=d(b),E=S+k;m.setEdge(b.v,b.w,E),w=Math.max(w,m.node(b.v).out+=k),y=Math.max(y,m.node(b.w).in+=k)});var N=e.range(w+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(b){h(N,_,m.node(b))}),{graph:m,buckets:N,zeroIdx:_}}function h(p,d,m){m.out?m.in?p[m.out-m.in+d].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return Lg}var qg,rE;function i4(){if(rE)return qg;rE=1;var e=lt(),n=s4();qg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(l);e.forEach(u,function(h){var p=l.edge(h);l.removeEdge(h),p.forwardName=h.name,p.reversed=!0,l.setEdge(h.w,h.v,p,e.uniqueId("rev"))});function c(h){return function(p){return h.edge(p).weight}}}function i(l){var u=[],c={},h={};function p(d){e.has(h,d)||(h[d]=!0,c[d]=!0,e.forEach(l.outEdges(d),function(m){e.has(c,m.w)?u.push(m):p(m.w)}),delete c[d])}return e.forEach(l.nodes(),p),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var h=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,h)}})}return qg}var $g,sE;function fn(){if(sE)return $g;sE=1;var e=lt(),n=nr().Graph;$g={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:h,normalizeRanks:p,removeEmptyRanks:d,addBorderNode:m,maxRank:y,partition:w,time:N,notime:_};function r(b,S,k,E){var C;do C=e.uniqueId(E);while(b.hasNode(C));return k.dummy=S,b.setNode(C,k),C}function i(b){var S=new n().setGraph(b.graph());return e.forEach(b.nodes(),function(k){S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){var E=S.edge(k.v,k.w)||{weight:0,minlen:1},C=b.edge(k);S.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),S}function o(b){var S=new n({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(k){b.children(k).length||S.setNode(k,b.node(k))}),e.forEach(b.edges(),function(k){S.setEdge(k,b.edge(k))}),S}function l(b){var S=e.map(b.nodes(),function(k){var E={};return e.forEach(b.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+b.edge(C).weight}),E});return e.zipObject(b.nodes(),S)}function u(b){var S=e.map(b.nodes(),function(k){var E={};return e.forEach(b.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+b.edge(C).weight}),E});return e.zipObject(b.nodes(),S)}function c(b,S){var k=b.x,E=b.y,C=S.x-k,I=S.y-E,P=b.width/2,A=b.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var H,z;return Math.abs(I)*P>Math.abs(C)*A?(I<0&&(A=-A),H=A*C/I,z=A):(C<0&&(P=-P),H=P,z=P*I/C),{x:k+H,y:E+z}}function h(b){var S=e.map(e.range(y(b)+1),function(){return[]});return e.forEach(b.nodes(),function(k){var E=b.node(k),C=E.rank;e.isUndefined(C)||(S[C][E.order]=k)}),S}function p(b){var S=e.min(e.map(b.nodes(),function(k){return b.node(k).rank}));e.forEach(b.nodes(),function(k){var E=b.node(k);e.has(E,"rank")&&(E.rank-=S)})}function d(b){var S=e.min(e.map(b.nodes(),function(I){return b.node(I).rank})),k=[];e.forEach(b.nodes(),function(I){var P=b.node(I).rank-S;k[P]||(k[P]=[]),k[P].push(I)});var E=0,C=b.graph().nodeRankFactor;e.forEach(k,function(I,P){e.isUndefined(I)&&P%C!==0?--E:E&&e.forEach(I,function(A){b.node(A).rank+=E})})}function m(b,S,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),r(b,"border",C,S)}function y(b){return e.max(e.map(b.nodes(),function(S){var k=b.node(S).rank;if(!e.isUndefined(k))return k}))}function w(b,S){var k={lhs:[],rhs:[]};return e.forEach(b,function(E){S(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(b,S){var k=e.now();try{return S()}finally{console.log(b+" time: "+(e.now()-k)+"ms")}}function _(b,S){return S()}return $g}var Dg,iE;function o4(){if(iE)return Dg;iE=1;var e=lt(),n=fn();Dg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){i(l,u)})}function i(l,u){var c=u.v,h=l.node(c).rank,p=u.w,d=l.node(p).rank,m=u.name,y=l.edge(u),w=y.labelRank;if(d!==h+1){l.removeEdge(u);var N,_,b;for(b=0,++h;h<d;++b,++h)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:h},N=n.addDummyNode(l,"edge",_,"_d"),h===w&&(_.width=y.width,_.height=y.height,_.dummy="edge-label",_.labelpos=y.labelpos),l.setEdge(c,N,{weight:y.weight},m),b===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,p,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),h=c.edgeLabel,p;for(l.setEdge(c.edgeObj,h);c.dummy;)p=l.successors(u)[0],l.removeNode(u),h.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(h.x=c.x,h.y=c.y,h.width=c.width,h.height=c.height),u=p,c=l.node(u)})}return Dg}var Fg,oE;function Eu(){if(oE)return Fg;oE=1;var e=lt();Fg={longestPath:n,slack:r};function n(i){var o={};function l(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var h=e.min(e.map(i.outEdges(u),function(p){return l(p.w)-i.edge(p).minlen}));return(h===Number.POSITIVE_INFINITY||h===void 0||h===null)&&(h=0),c.rank=h}e.forEach(i.sources(),l)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return Fg}var zg,aE;function RT(){if(aE)return zg;aE=1;var e=lt(),n=nr().Graph,r=Eu().slack;zg=i;function i(c){var h=new n({directed:!1}),p=c.nodes()[0],d=c.nodeCount();h.setNode(p,{});for(var m,y;o(h,c)<d;)m=l(h,c),y=h.hasNode(m.v)?r(c,m):-r(c,m),u(h,c,y);return h}function o(c,h){function p(d){e.forEach(h.nodeEdges(d),function(m){var y=m.v,w=d===y?m.w:y;!c.hasNode(w)&&!r(h,m)&&(c.setNode(w,{}),c.setEdge(d,w,{}),p(w))})}return e.forEach(c.nodes(),p),c.nodeCount()}function l(c,h){return e.minBy(h.edges(),function(p){if(c.hasNode(p.v)!==c.hasNode(p.w))return r(h,p)})}function u(c,h,p){e.forEach(c.nodes(),function(d){h.node(d).rank+=p})}return zg}var Bg,lE;function a4(){if(lE)return Bg;lE=1;var e=lt(),n=RT(),r=Eu().slack,i=Eu().longestPath,o=nr().alg.preorder,l=nr().alg.postorder,u=fn().simplify;Bg=c,c.initLowLimValues=m,c.initCutValues=h,c.calcCutValue=d,c.leaveEdge=w,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),i(E);var C=n(E);m(C),h(C,E);for(var I,P;I=w(C);)P=N(C,E,I),_(C,E,I,P)}function h(E,C){var I=l(E,E.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(P){p(E,C,P)})}function p(E,C,I){var P=E.node(I),A=P.parent;E.edge(I,A).cutvalue=d(E,C,I)}function d(E,C,I){var P=E.node(I),A=P.parent,H=!0,z=C.edge(I,A),L=0;return z||(H=!1,z=C.edge(A,I)),L=z.weight,e.forEach(C.nodeEdges(I),function(F){var G=F.v===I,O=G?F.w:F.v;if(O!==A){var j=G===H,q=C.edge(F).weight;if(L+=j?q:-q,S(E,I,O)){var $=E.edge(I,O).cutvalue;L+=j?-$:$}}}),L}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,I,P,A){var H=I,z=E.node(P);return C[P]=!0,e.forEach(E.neighbors(P),function(L){e.has(C,L)||(I=y(E,C,I,L,P))}),z.low=H,z.lim=I++,A?z.parent=A:delete z.parent,I}function w(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,I){var P=I.v,A=I.w;C.hasEdge(P,A)||(P=I.w,A=I.v);var H=E.node(P),z=E.node(A),L=H,F=!1;H.lim>z.lim&&(L=z,F=!0);var G=e.filter(C.edges(),function(O){return F===k(E,E.node(O.v),L)&&F!==k(E,E.node(O.w),L)});return e.minBy(G,function(O){return r(C,O)})}function _(E,C,I,P){var A=I.v,H=I.w;E.removeEdge(A,H),E.setEdge(P.v,P.w,{}),m(E),h(E,C),b(E,C)}function b(E,C){var I=e.find(E.nodes(),function(A){return!C.node(A).parent}),P=o(E,I);P=P.slice(1),e.forEach(P,function(A){var H=E.node(A).parent,z=C.edge(A,H),L=!1;z||(z=C.edge(H,A),L=!0),C.node(A).rank=C.node(H).rank+(L?z.minlen:-z.minlen)})}function S(E,C,I){return E.hasEdge(C,I)}function k(E,C,I){return I.low<=C.lim&&C.lim<=I.lim}return Bg}var Ug,uE;function l4(){if(uE)return Ug;uE=1;var e=Eu(),n=e.longestPath,r=RT(),i=a4();Ug=o;function o(h){switch(h.graph().ranker){case"network-simplex":c(h);break;case"tight-tree":u(h);break;case"longest-path":l(h);break;default:c(h)}}var l=n;function u(h){n(h),r(h)}function c(h){i(h)}return Ug}var Hg,cE;function u4(){if(cE)return Hg;cE=1;var e=lt();Hg=n;function n(o){var l=i(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),h=c.edgeObj,p=r(o,l,h.v,h.w),d=p.path,m=p.lca,y=0,w=d[y],N=!0;u!==h.w;){if(c=o.node(u),N){for(;(w=d[y])!==m&&o.node(w).maxRank<c.rank;)y++;w===m&&(N=!1)}if(!N){for(;y<d.length-1&&o.node(w=d[y+1]).minRank<=c.rank;)y++;w=d[y]}o.setParent(u,w),u=o.successors(u)[0]}})}function r(o,l,u,c){var h=[],p=[],d=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,w;y=u;do y=o.parent(y),h.push(y);while(y&&(l[y].low>d||m>l[y].lim));for(w=y,y=c;(y=o.parent(y))!==w;)p.push(y);return{path:h.concat(p.reverse()),lca:w}}function i(o){var l={},u=0;function c(h){var p=u;e.forEach(o.children(h),c),l[h]={low:p,lim:u++}}return e.forEach(o.children(),c),l}return Hg}var Wg,dE;function c4(){if(dE)return Wg;dE=1;var e=lt(),n=fn();Wg={run:r,cleanup:u};function r(c){var h=n.addDummyNode(c,"root",{},"_root"),p=o(c),d=e.max(e.values(p))-1,m=2*d+1;c.graph().nestingRoot=h,e.forEach(c.edges(),function(w){c.edge(w).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(w){i(c,h,m,y,d,p,w)}),c.graph().nodeRankFactor=m}function i(c,h,p,d,m,y,w){var N=c.children(w);if(!N.length){w!==h&&c.setEdge(h,w,{weight:0,minlen:p});return}var _=n.addBorderNode(c,"_bt"),b=n.addBorderNode(c,"_bb"),S=c.node(w);c.setParent(_,w),S.borderTop=_,c.setParent(b,w),S.borderBottom=b,e.forEach(N,function(k){i(c,h,p,d,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,I=E.borderBottom?E.borderBottom:k,P=E.borderTop?d:2*d,A=C!==I?1:m-y[w]+1;c.setEdge(_,C,{weight:P,minlen:A,nestingEdge:!0}),c.setEdge(I,b,{weight:P,minlen:A,nestingEdge:!0})}),c.parent(w)||c.setEdge(h,_,{weight:0,minlen:m+y[w]})}function o(c){var h={};function p(d,m){var y=c.children(d);y&&y.length&&e.forEach(y,function(w){p(w,m+1)}),h[d]=m}return e.forEach(c.children(),function(d){p(d,1)}),h}function l(c){return e.reduce(c.edges(),function(h,p){return h+c.edge(p).weight},0)}function u(c){var h=c.graph();c.removeNode(h.nestingRoot),delete h.nestingRoot,e.forEach(c.edges(),function(p){var d=c.edge(p);d.nestingEdge&&c.removeEdge(p)})}return Wg}var Vg,fE;function d4(){if(fE)return Vg;fE=1;var e=lt(),n=fn();Vg=r;function r(o){function l(u){var c=o.children(u),h=o.node(u);if(c.length&&e.forEach(c,l),e.has(h,"minRank")){h.borderLeft=[],h.borderRight=[];for(var p=h.minRank,d=h.maxRank+1;p<d;++p)i(o,"borderLeft","_bl",u,h,p),i(o,"borderRight","_br",u,h,p)}}e.forEach(o.children(),l)}function i(o,l,u,c,h,p){var d={width:0,height:0,rank:p,borderType:l},m=h[l][p-1],y=n.addDummyNode(o,"border",d,u);h[l][p]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return Vg}var Gg,hE;function f4(){if(hE)return Gg;hE=1;var e=lt();Gg={adjust:n,undo:r};function n(p){var d=p.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&i(p)}function r(p){var d=p.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&l(p),(d==="lr"||d==="rl")&&(c(p),i(p))}function i(p){e.forEach(p.nodes(),function(d){o(p.node(d))}),e.forEach(p.edges(),function(d){o(p.edge(d))})}function o(p){var d=p.width;p.width=p.height,p.height=d}function l(p){e.forEach(p.nodes(),function(d){u(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(p){p.y=-p.y}function c(p){e.forEach(p.nodes(),function(d){h(p.node(d))}),e.forEach(p.edges(),function(d){var m=p.edge(d);e.forEach(m.points,h),e.has(m,"x")&&h(m)})}function h(p){var d=p.x;p.x=p.y,p.y=d}return Gg}var Yg,pE;function h4(){if(pE)return Yg;pE=1;var e=lt();Yg=n;function n(r){var i={},o=e.filter(r.nodes(),function(p){return!r.children(p).length}),l=e.max(e.map(o,function(p){return r.node(p).rank})),u=e.map(e.range(l+1),function(){return[]});function c(p){if(!e.has(i,p)){i[p]=!0;var d=r.node(p);u[d.rank].push(p),e.forEach(r.successors(p),c)}}var h=e.sortBy(o,function(p){return r.node(p).rank});return e.forEach(h,c),u}return Yg}var Kg,mE;function p4(){if(mE)return Kg;mE=1;var e=lt();Kg=n;function n(i,o){for(var l=0,u=1;u<o.length;++u)l+=r(i,o[u-1],o[u]);return l}function r(i,o,l){for(var u=e.zipObject(l,e.map(l,function(y,w){return w})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(w){return{pos:u[w.w],weight:i.edge(w).weight}}),"pos")}),!0),h=1;h<l.length;)h<<=1;var p=2*h-1;h-=1;var d=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var w=y.pos+h;d[w]+=y.weight;for(var N=0;w>0;)w%2&&(N+=d[w+1]),w=w-1>>1,d[w]+=y.weight;m+=y.weight*N})),m}return Kg}var Xg,gE;function m4(){if(gE)return Xg;gE=1;var e=lt();Xg=n;function n(r,i){return e.map(i,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,h){var p=r.edge(h),d=r.node(h.v);return{sum:c.sum+p.weight*d.order,weight:c.weight+p.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return Xg}var Qg,vE;function g4(){if(vE)return Qg;vE=1;var e=lt();Qg=n;function n(o,l){var u={};e.forEach(o,function(h,p){var d=u[h.v]={indegree:0,in:[],out:[],vs:[h.v],i:p};e.isUndefined(h.barycenter)||(d.barycenter=h.barycenter,d.weight=h.weight)}),e.forEach(l.edges(),function(h){var p=u[h.v],d=u[h.w];!e.isUndefined(p)&&!e.isUndefined(d)&&(d.indegree++,p.out.push(u[h.w]))});var c=e.filter(u,function(h){return!h.indegree});return r(c)}function r(o){var l=[];function u(p){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(p.barycenter)||d.barycenter>=p.barycenter)&&i(p,d)}}function c(p){return function(d){d.in.push(p),--d.indegree===0&&o.push(d)}}for(;o.length;){var h=o.pop();l.push(h),e.forEach(h.in.reverse(),u(h)),e.forEach(h.out,c(h))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function i(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return Qg}var Zg,yE;function v4(){if(yE)return Zg;yE=1;var e=lt(),n=fn();Zg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),h=c.lhs,p=e.sortBy(c.rhs,function(_){return-_.i}),d=[],m=0,y=0,w=0;h.sort(o(!!u)),w=i(d,p,w),e.forEach(h,function(_){w+=_.vs.length,d.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,w=i(d,p,w)});var N={vs:e.flatten(d,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function i(l,u,c){for(var h;u.length&&(h=e.last(u)).i<=c;)u.pop(),l.push(h.vs),c++;return c}function o(l){return function(u,c){return u.barycenter<c.barycenter?-1:u.barycenter>c.barycenter?1:l?c.i-u.i:u.i-c.i}}return Zg}var Jg,wE;function y4(){if(wE)return Jg;wE=1;var e=lt(),n=m4(),r=g4(),i=v4();Jg=o;function o(c,h,p,d){var m=c.children(h),y=c.node(h),w=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};w&&(m=e.filter(m,function(I){return I!==w&&I!==N}));var b=n(c,m);e.forEach(b,function(I){if(c.children(I.v).length){var P=o(c,I.v,p,d);_[I.v]=P,e.has(P,"barycenter")&&u(I,P)}});var S=r(b,p);l(S,_);var k=i(S,d);if(w&&(k.vs=e.flatten([w,k.vs,N],!0),c.predecessors(w).length)){var E=c.node(c.predecessors(w)[0]),C=c.node(c.predecessors(N)[0]);e.has(k,"barycenter")||(k.barycenter=0,k.weight=0),k.barycenter=(k.barycenter*k.weight+E.order+C.order)/(k.weight+2),k.weight+=2}return k}function l(c,h){e.forEach(c,function(p){p.vs=e.flatten(p.vs.map(function(d){return h[d]?h[d].vs:d}),!0)})}function u(c,h){e.isUndefined(c.barycenter)?(c.barycenter=h.barycenter,c.weight=h.weight):(c.barycenter=(c.barycenter*c.weight+h.barycenter*h.weight)/(c.weight+h.weight),c.weight+=h.weight)}return Jg}var ev,xE;function w4(){if(xE)return ev;xE=1;var e=lt(),n=nr().Graph;ev=r;function r(o,l,u){var c=i(o),h=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(p){return o.node(p)});return e.forEach(o.nodes(),function(p){var d=o.node(p),m=o.parent(p);(d.rank===l||d.minRank<=l&&l<=d.maxRank)&&(h.setNode(p),h.setParent(p,m||c),e.forEach(o[u](p),function(y){var w=y.v===p?y.w:y.v,N=h.edge(w,p),_=e.isUndefined(N)?0:N.weight;h.setEdge(w,p,{weight:o.edge(y).weight+_})}),e.has(d,"minRank")&&h.setNode(p,{borderLeft:d.borderLeft[l],borderRight:d.borderRight[l]}))}),h}function i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return ev}var tv,_E;function x4(){if(_E)return tv;_E=1;var e=lt();tv=n;function n(r,i,o){var l={},u;e.forEach(o,function(c){for(var h=r.parent(c),p,d;h;){if(p=r.parent(h),p?(d=l[p],l[p]=h):(d=u,u=h),d&&d!==h){i.setEdge(d,h);return}h=p}})}return tv}var nv,bE;function _4(){if(bE)return nv;bE=1;var e=lt(),n=h4(),r=p4(),i=y4(),o=w4(),l=x4(),u=nr().Graph,c=fn();nv=h;function h(y){var w=c.maxRank(y),N=p(y,e.range(1,w+1),"inEdges"),_=p(y,e.range(w-1,-1,-1),"outEdges"),b=n(y);m(y,b);for(var S=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){d(E%2?N:_,E%4>=2),b=c.buildLayerMatrix(y);var I=r(y,b);I<S&&(C=0,k=e.cloneDeep(b),S=I)}m(y,k)}function p(y,w,N){return e.map(w,function(_){return o(y,_,N)})}function d(y,w){var N=new u;e.forEach(y,function(_){var b=_.graph().root,S=i(_,b,N,w);e.forEach(S.vs,function(k,E){_.node(k).order=E}),l(_,N,S.vs)})}function m(y,w){e.forEach(w,function(N){e.forEach(N,function(_,b){y.node(_).order=b})})}return nv}var rv,SE;function b4(){if(SE)return rv;SE=1;var e=lt(),n=nr().Graph,r=fn();rv={positionX:N,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:h,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:w};function i(S,k){var E={};function C(I,P){var A=0,H=0,z=I.length,L=e.last(P);return e.forEach(P,function(F,G){var O=l(S,F),j=O?S.node(O).order:z;(O||F===L)&&(e.forEach(P.slice(H,G+1),function(q){e.forEach(S.predecessors(q),function($){var re=S.node($),J=re.order;(J<A||j<J)&&!(re.dummy&&S.node(q).dummy)&&u(E,$,q)})}),H=G+1,A=j)}),P}return e.reduce(k,C),E}function o(S,k){var E={};function C(P,A,H,z,L){var F;e.forEach(e.range(A,H),function(G){F=P[G],S.node(F).dummy&&e.forEach(S.predecessors(F),function(O){var j=S.node(O);j.dummy&&(j.order<z||j.order>L)&&u(E,O,F)})})}function I(P,A){var H=-1,z,L=0;return e.forEach(A,function(F,G){if(S.node(F).dummy==="border"){var O=S.predecessors(F);O.length&&(z=S.node(O[0]).order,C(A,L,G,H,z),L=G,H=z)}C(A,L,A.length,z,P.length)}),A}return e.reduce(k,I),E}function l(S,k){if(S.node(k).dummy)return e.find(S.predecessors(k),function(E){return S.node(E).dummy})}function u(S,k,E){if(k>E){var C=k;k=E,E=C}var I=S[k];I||(S[k]=I={}),I[E]=!0}function c(S,k,E){if(k>E){var C=k;k=E,E=C}return e.has(S[k],E)}function h(S,k,E,C){var I={},P={},A={};return e.forEach(k,function(H){e.forEach(H,function(z,L){I[z]=z,P[z]=z,A[z]=L})}),e.forEach(k,function(H){var z=-1;e.forEach(H,function(L){var F=C(L);if(F.length){F=e.sortBy(F,function($){return A[$]});for(var G=(F.length-1)/2,O=Math.floor(G),j=Math.ceil(G);O<=j;++O){var q=F[O];P[L]===L&&z<A[q]&&!c(E,L,q)&&(P[q]=L,P[L]=I[L]=I[q],z=A[q])}}})}),{root:I,align:P}}function p(S,k,E,C,I){var P={},A=d(S,k,E,I),H=I?"borderLeft":"borderRight";function z(G,O){for(var j=A.nodes(),q=j.pop(),$={};q;)$[q]?G(q):($[q]=!0,j.push(q),j=j.concat(O(q))),q=j.pop()}function L(G){P[G]=A.inEdges(G).reduce(function(O,j){return Math.max(O,P[j.v]+A.edge(j))},0)}function F(G){var O=A.outEdges(G).reduce(function(q,$){return Math.min(q,P[$.w]-A.edge($))},Number.POSITIVE_INFINITY),j=S.node(G);O!==Number.POSITIVE_INFINITY&&j.borderType!==H&&(P[G]=Math.max(P[G],O))}return z(L,A.predecessors.bind(A)),z(F,A.successors.bind(A)),e.forEach(C,function(G){P[G]=P[E[G]]}),P}function d(S,k,E,C){var I=new n,P=S.graph(),A=_(P.nodesep,P.edgesep,C);return e.forEach(k,function(H){var z;e.forEach(H,function(L){var F=E[L];if(I.setNode(F),z){var G=E[z],O=I.edge(G,F);I.setEdge(G,F,Math.max(A(S,L,z),O||0))}z=L})}),I}function m(S,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,I=Number.POSITIVE_INFINITY;return e.forIn(E,function(P,A){var H=b(S,A)/2;C=Math.max(P+H,C),I=Math.min(P-H,I)}),C-I})}function y(S,k){var E=e.values(k),C=e.min(E),I=e.max(E);e.forEach(["u","d"],function(P){e.forEach(["l","r"],function(A){var H=P+A,z=S[H],L;if(z!==k){var F=e.values(z);L=A==="l"?C-e.min(F):I-e.max(F),L&&(S[H]=e.mapValues(z,function(G){return G+L}))}})})}function w(S,k){return e.mapValues(S.ul,function(E,C){if(k)return S[k.toLowerCase()][C];var I=e.sortBy(e.map(S,C));return(I[1]+I[2])/2})}function N(S){var k=r.buildLayerMatrix(S),E=e.merge(i(S,k),o(S,k)),C={},I;e.forEach(["u","d"],function(A){I=A==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(I=e.map(I,function(G){return e.values(G).reverse()}));var z=(A==="u"?S.predecessors:S.successors).bind(S),L=h(S,I,E,z),F=p(S,I,L.root,L.align,H==="r");H==="r"&&(F=e.mapValues(F,function(G){return-G})),C[A+H]=F})});var P=m(S,C);return y(C,P),w(C,S.graph().align)}function _(S,k,E){return function(C,I,P){var A=C.node(I),H=C.node(P),z=0,L;if(z+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":L=-A.width/2;break;case"r":L=A.width/2;break}if(L&&(z+=E?L:-L),L=0,z+=(A.dummy?k:S)/2,z+=(H.dummy?k:S)/2,z+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":L=H.width/2;break;case"r":L=-H.width/2;break}return L&&(z+=E?L:-L),L=0,z}}function b(S,k){return S.node(k).width}return rv}var sv,kE;function S4(){if(kE)return sv;kE=1;var e=lt(),n=fn(),r=b4().positionX;sv=i;function i(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,h=0;e.forEach(u,function(p){var d=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=h+d/2}),h+=d+c})}return sv}var iv,EE;function k4(){if(EE)return iv;EE=1;var e=lt(),n=i4(),r=o4(),i=l4(),o=fn().normalizeRanks,l=u4(),u=fn().removeEmptyRanks,c=c4(),h=d4(),p=f4(),d=_4(),m=S4(),y=fn(),w=nr().Graph;iv=N;function N(B,X){var ne=X&&X.debugTiming?y.time:y.notime;ne("layout",function(){var le=ne(" buildLayoutGraph",function(){return z(B)});ne(" runLayout",function(){_(le,ne)}),ne(" updateInputGraph",function(){b(B,le)})})}function _(B,X){X(" makeSpaceForEdgeLabels",function(){L(B)}),X(" removeSelfEdges",function(){W(B)}),X(" acyclic",function(){n.run(B)}),X(" nestingGraph.run",function(){c.run(B)}),X(" rank",function(){i(y.asNonCompoundGraph(B))}),X(" injectEdgeLabelProxies",function(){F(B)}),X(" removeEmptyRanks",function(){u(B)}),X(" nestingGraph.cleanup",function(){c.cleanup(B)}),X(" normalizeRanks",function(){o(B)}),X(" assignRankMinMax",function(){G(B)}),X(" removeEdgeLabelProxies",function(){O(B)}),X(" normalize.run",function(){r.run(B)}),X(" parentDummyChains",function(){l(B)}),X(" addBorderSegments",function(){h(B)}),X(" order",function(){d(B)}),X(" insertSelfEdges",function(){Z(B)}),X(" adjustCoordinateSystem",function(){p.adjust(B)}),X(" position",function(){m(B)}),X(" positionSelfEdges",function(){M(B)}),X(" removeBorderNodes",function(){J(B)}),X(" normalize.undo",function(){r.undo(B)}),X(" fixupEdgeLabelCoords",function(){$(B)}),X(" undoCoordinateSystem",function(){p.undo(B)}),X(" translateGraph",function(){j(B)}),X(" assignNodeIntersects",function(){q(B)}),X(" reversePoints",function(){re(B)}),X(" acyclic.undo",function(){n.undo(B)})}function b(B,X){e.forEach(B.nodes(),function(ne){var le=B.node(ne),fe=X.node(ne);le&&(le.x=fe.x,le.y=fe.y,X.children(ne).length&&(le.width=fe.width,le.height=fe.height))}),e.forEach(B.edges(),function(ne){var le=B.edge(ne),fe=X.edge(ne);le.points=fe.points,e.has(fe,"x")&&(le.x=fe.x,le.y=fe.y)}),B.graph().width=X.graph().width,B.graph().height=X.graph().height}var S=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],I={width:0,height:0},P=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function z(B){var X=new w({multigraph:!0,compound:!0}),ne=U(B.graph());return X.setGraph(e.merge({},k,Y(ne,S),e.pick(ne,E))),e.forEach(B.nodes(),function(le){var fe=U(B.node(le));X.setNode(le,e.defaults(Y(fe,C),I)),X.setParent(le,B.parent(le))}),e.forEach(B.edges(),function(le){var fe=U(B.edge(le));X.setEdge(le,e.merge({},A,Y(fe,P),e.pick(fe,H)))}),X}function L(B){var X=B.graph();X.ranksep/=2,e.forEach(B.edges(),function(ne){var le=B.edge(ne);le.minlen*=2,le.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?le.width+=le.labeloffset:le.height+=le.labeloffset)})}function F(B){e.forEach(B.edges(),function(X){var ne=B.edge(X);if(ne.width&&ne.height){var le=B.node(X.v),fe=B.node(X.w),te={rank:(fe.rank-le.rank)/2+le.rank,e:X};y.addDummyNode(B,"edge-proxy",te,"_ep")}})}function G(B){var X=0;e.forEach(B.nodes(),function(ne){var le=B.node(ne);le.borderTop&&(le.minRank=B.node(le.borderTop).rank,le.maxRank=B.node(le.borderBottom).rank,X=e.max(X,le.maxRank))}),B.graph().maxRank=X}function O(B){e.forEach(B.nodes(),function(X){var ne=B.node(X);ne.dummy==="edge-proxy"&&(B.edge(ne.e).labelRank=ne.rank,B.removeNode(X))})}function j(B){var X=Number.POSITIVE_INFINITY,ne=0,le=Number.POSITIVE_INFINITY,fe=0,te=B.graph(),ce=te.marginx||0,Ce=te.marginy||0;function ve(je){var ye=je.x,ke=je.y,Ye=je.width,we=je.height;X=Math.min(X,ye-Ye/2),ne=Math.max(ne,ye+Ye/2),le=Math.min(le,ke-we/2),fe=Math.max(fe,ke+we/2)}e.forEach(B.nodes(),function(je){ve(B.node(je))}),e.forEach(B.edges(),function(je){var ye=B.edge(je);e.has(ye,"x")&&ve(ye)}),X-=ce,le-=Ce,e.forEach(B.nodes(),function(je){var ye=B.node(je);ye.x-=X,ye.y-=le}),e.forEach(B.edges(),function(je){var ye=B.edge(je);e.forEach(ye.points,function(ke){ke.x-=X,ke.y-=le}),e.has(ye,"x")&&(ye.x-=X),e.has(ye,"y")&&(ye.y-=le)}),te.width=ne-X+ce,te.height=fe-le+Ce}function q(B){e.forEach(B.edges(),function(X){var ne=B.edge(X),le=B.node(X.v),fe=B.node(X.w),te,ce;ne.points?(te=ne.points[0],ce=ne.points[ne.points.length-1]):(ne.points=[],te=fe,ce=le),ne.points.unshift(y.intersectRect(le,te)),ne.points.push(y.intersectRect(fe,ce))})}function $(B){e.forEach(B.edges(),function(X){var ne=B.edge(X);if(e.has(ne,"x"))switch((ne.labelpos==="l"||ne.labelpos==="r")&&(ne.width-=ne.labeloffset),ne.labelpos){case"l":ne.x-=ne.width/2+ne.labeloffset;break;case"r":ne.x+=ne.width/2+ne.labeloffset;break}})}function re(B){e.forEach(B.edges(),function(X){var ne=B.edge(X);ne.reversed&&ne.points.reverse()})}function J(B){e.forEach(B.nodes(),function(X){if(B.children(X).length){var ne=B.node(X),le=B.node(ne.borderTop),fe=B.node(ne.borderBottom),te=B.node(e.last(ne.borderLeft)),ce=B.node(e.last(ne.borderRight));ne.width=Math.abs(ce.x-te.x),ne.height=Math.abs(fe.y-le.y),ne.x=te.x+ne.width/2,ne.y=le.y+ne.height/2}}),e.forEach(B.nodes(),function(X){B.node(X).dummy==="border"&&B.removeNode(X)})}function W(B){e.forEach(B.edges(),function(X){if(X.v===X.w){var ne=B.node(X.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:X,label:B.edge(X)}),B.removeEdge(X)}})}function Z(B){var X=y.buildLayerMatrix(B);e.forEach(X,function(ne){var le=0;e.forEach(ne,function(fe,te){var ce=B.node(fe);ce.order=te+le,e.forEach(ce.selfEdges,function(Ce){y.addDummyNode(B,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:ce.rank,order:te+ ++le,e:Ce.e,label:Ce.label},"_se")}),delete ce.selfEdges})})}function M(B){e.forEach(B.nodes(),function(X){var ne=B.node(X);if(ne.dummy==="selfedge"){var le=B.node(ne.e.v),fe=le.x+le.width/2,te=le.y,ce=ne.x-fe,Ce=le.height/2;B.setEdge(ne.e,ne.label),B.removeNode(X),ne.label.points=[{x:fe+2*ce/3,y:te-Ce},{x:fe+5*ce/6,y:te-Ce},{x:fe+ce,y:te},{x:fe+5*ce/6,y:te+Ce},{x:fe+2*ce/3,y:te+Ce}],ne.label.x=ne.x,ne.label.y=ne.y}})}function Y(B,X){return e.mapValues(e.pick(B,X),Number)}function U(B){var X={};return e.forEach(B,function(ne,le){X[le.toLowerCase()]=ne}),X}return iv}var ov,NE;function E4(){if(NE)return ov;NE=1;var e=lt(),n=fn(),r=nr().Graph;ov={debugOrdering:i};function i(o){var l=n.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,h){var p="layer"+h;u.setNode(p,{rank:"same"}),e.reduce(c,function(d,m){return u.setEdge(d,m,{style:"invis"}),m})}),u}return ov}var av,CE;function N4(){return CE||(CE=1,av="0.8.5"),av}var lv,TE;function C4(){return TE||(TE=1,lv={graphlib:nr(),layout:k4(),debug:E4(),util:{time:fn().time,notime:fn().notime},version:N4()}),lv}var T4=C4();const RE=Lv(T4),po=240,Nu=130,oo=74,Zu=72,jE=oo+Zu;function R4(e,n){var i;let r=po;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??po);return r}const jT=420,j4=2;function ba(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function A4(e,n){return((n==null?void 0:n.get(e))??0)>0?jT:0}function I4(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function Sa(e,n,r){const i=n.get(e);return{w:((i==null?void 0:i.width)??po)+A4(e,r),h:Math.max((i==null?void 0:i.height)??Nu,I4(e,r))}}function M4(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function O4(e,n,r,i,o,l){const u=new RE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(S=>!o.has(S)),h=new Set(c);for(const S of c){const{w:k,h:E}=Sa(S,i,l);u.setNode(S,{width:k,height:E})}for(const S of n)h.has(S.source)&&h.has(S.target)&&u.setEdge(S.source,S.target);RE.layout(u);const p=new Map;let d=1/0,m=1/0,y=-1/0,w=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const E=i.get(S),C=(E==null?void 0:E.width)??po,I=(E==null?void 0:E.height)??Nu,P=Sa(S,i,l),A=k.x-P.w/2,H=k.y-P.h/2;p.set(S,{x:A,y:H}),A<d&&(d=A),H<m&&(m=H),A+C>y&&(y=A+C),H+I>w&&(w=H+I)}if(Number.isFinite(d)&&Number.isFinite(m))for(const[S,k]of p)p.set(S,{x:k.x-d,y:k.y-m});const N=Number.isFinite(y)?y-d:0,_=Number.isFinite(w)?w-m:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const E=i.get(S),C=(E==null?void 0:E.width)??po,I=(E==null?void 0:E.height)??Nu;b=b===null?{minX:k.x,minY:k.y,maxX:k.x+C,maxY:k.y+I}:{minX:Math.min(b.minX,k.x),minY:Math.min(b.minY,k.y),maxX:Math.max(b.maxX,k.x+C),maxY:Math.max(b.maxY,k.y+I)}}return{positions:p,width:N,height:_,pinnedBox:b}}function P4(e,n,r={}){const i=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const S of e){const k=ba(S),E=c.get(k);E?E.push(S.id):c.set(k,[S.id])}const p=Array.from(c.keys()).sort().map(S=>({sid:S,...O4(c.get(S),n,i,l,o,u)})),d=R4(e,l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let E=0;for(const C of p)k.length<S&&E>0&&E+C.height>m&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+jE;return k},w=S=>S.reduce((k,E)=>Math.max(k,E.width),0)+jT;let N=y(r.availableWidth?j4:1);N.length>1&&N.reduce((k,E)=>k+w(E),0)+d*(N.length-1)>(r.availableWidth??0)&&(N=y(1));const _=new Map;let b=0;for(const S of N){const k=w(S);let E=0;for(const{positions:C,height:I,pinnedBox:P}of S){for(const[H,z]of C)_.set(H,{x:z.x+b,y:z.y+E});let A=E+I;P&&P.maxY>A&&P.minX<b+k&&b<P.maxX&&(A=P.maxY),E=A+jE}b+=k+d}return e.map(S=>{const k=o.get(S.id);if(k)return{...S,position:k};const E=_.get(S.id);return E?{...S,position:E}:S})}function L4(e,n,r,i,o){const u=oo+Zu,c=60,h=w=>Sa(w,i,o),p=new Map(e.map(w=>[w.id,ba(w)])),d=[],m=e.map(w=>({id:w.id,pos:r.get(w.id)??n.get(w.id)})).filter(w=>w.pos!=null).sort((w,N)=>w.pos.y-N.pos.y||w.pos.x-N.pos.x||w.id.localeCompare(N.id)),y=[];for(const{id:w,pos:N}of m){const{w:_,h:b}=h(w),S=p.get(w)??"_default";if(r.has(w)){d.push({x:N.x,y:N.y,w:_,h:b,sid:S});continue}let k=N.y;for(let E=0;E<d.length+1;E++){const C=d.find(I=>{const P=I.sid===S?24:c,A=I.sid===S?24:u;return N.x<I.x+I.w+P&&I.x<N.x+_+P&&k<I.y+I.h+A&&I.y<k+b+A});if(!C)break;k=C.y+C.h+(C.sid===S?24:u)}k!==N.y&&(n.set(w,{x:N.x,y:k}),y.push(w)),d.push({x:N.x,y:k,w:_,h:b,sid:S})}return y}function q4(e,n,r,i,o,l){const u=_=>Sa(_,i,l),c=_=>r.get(_)??n.get(_),h=new Map;for(const _ of e){if(!c(_.id))continue;const b=ba(_),S=h.get(b);S?S.push(_):h.set(b,[_])}const p=new Set;for(const[_,b]of h)b.every(S=>o.has(S.id)&&!r.has(S.id))&&p.add(_);const d=new Map,m=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),E=ba(_);p.has(E)?(d.get(E)??d.set(E,[]).get(E)).push(_):m.push({x:b.x,y:b.y,w:S,h:k})}if(d.size===0)return[];const y=oo+Zu,w=(_,b,S,k)=>m.some(E=>_<E.x+E.w+oo&&E.x<_+S+oo&&b<E.y+E.h+y&&E.y<b+k+y),N=[];for(const _ of[...d.keys()].sort()){const b=d.get(_);let S=1/0,k=1/0,E=-1/0,C=-1/0;for(const F of b){const G=c(F.id),{w:O,h:j}=u(F.id);S=Math.min(S,G.x),k=Math.min(k,G.y),E=Math.max(E,G.x+O),C=Math.max(C,G.y+j)}const I=E-S,P=C-k,A=[...new Set(m.map(F=>Math.round(F.x)))].sort((F,G)=>F-G),H=A.length?A:[S],z=[0,...m.map(F=>F.y+F.h+y)].sort((F,G)=>F-G);let L=null;e:for(const F of H)for(const G of z){if(G>=k)break;if(!w(F,G,I,P)){L={x:F,y:G};break e}}if(L){const F=L.x-S,G=L.y-k;for(const O of b){const j=c(O.id);n.set(O.id,{x:j.x+F,y:j.y+G})}N.push(_)}for(const F of b){const G=c(F.id),{w:O,h:j}=u(F.id);m.push({x:G.x,y:G.y,w:O,h:j})}}return N}function $4(e,n,r,i,o,l=!1,u){const p=oo+Zu+1,d=8,m=1.75,y=200,w=.7,N=.01,_=L=>Sa(L,i,u),b=L=>r.get(L)??n.get(L),S=new Map;for(const L of e){if(!b(L.id))continue;const F=ba(L),G=S.get(F);G?G.push(L):S.set(F,[L])}const k=[],E=new Set,C=new Set,I=o.size===0;for(const L of[...S.keys()].sort()){const F=S.get(L);let G=1/0,O=1/0,j=-1/0,q=-1/0,$=!1;for(const Z of F){const M=b(Z.id),{w:Y,h:U}=_(Z.id);G=Math.min(G,M.x),O=Math.min(O,M.y),j=Math.max(j,M.x+Y),q=Math.max(q,M.y+U),r.has(Z.id)&&($=!0)}const re=j-G,J=q-O;C.add(L);const W=o.get(L);W&&(re>W.w+d||J>W.h+d)&&E.add(L),o.set(L,{w:re,h:J}),k.push({sid:L,members:F.map(Z=>Z.id),x:G,y:O,w:re,h:J,anchored:$,mass:1})}for(const L of[...o.keys()])C.has(L)||o.delete(L);if(l||I)return[];let P=!1;for(let L=0;L<k.length&&!P;L++)for(let F=L+1;F<k.length;F++){const G=k[L],O=k[F];if(!(G.anchored&&O.anchored)&&Math.abs(G.x+G.w/2-(O.x+O.w/2))<(G.w+O.w)/2+61&&Math.abs(G.y+G.h/2-(O.y+O.h/2))<(G.h+O.h)/2+p){P=!0;break}}if(E.size===0&&!P)return[];if(E.size>0)for(const L of k)E.has(L.sid)&&(L.mass=8);else for(const L of k)L.mass=Math.max(1,L.w*L.h/(po*Nu));const A=new Map(k.map(L=>[L.sid,L.x])),H=new Map(k.map(L=>[L.sid,L.y]));for(let L=0;L<y;L++){const F=new Map,G=new Map;let O=0;for(let j=0;j<k.length;j++)for(let q=j+1;q<k.length;q++){const $=k[j],re=k[q];if($.anchored&&re.anchored)continue;const J=$.x+$.w/2,W=$.y+$.h/2,Z=re.x+re.w/2,M=re.y+re.h/2,Y=($.w+re.w)/2+61-Math.abs(J-Z),U=($.h+re.h)/2+p-Math.abs(W-M);if(Y<=0||U<=0)continue;const B=(De,Je)=>!De.anchored&&!(Je<0&&De.x<=0),X=(De,Je)=>!De.anchored&&!(Je<0&&De.y<=0),ne=(De,Je,Xe)=>{const Mt=De===Je,ut=Mt?$.sid<re.sid?-1:1:Math.sign(De-Je);return Xe($,ut)||Xe(re,-ut)?ut:Mt&&(Xe($,-ut)||Xe(re,ut))?-ut:0},le=ne(J,Z,B),fe=ne(W,M,X),te=le!==0,ce=fe!==0;if(!te&&!ce)continue;const Ce=te&&(!ce||Y*m<U),[ve,je,ye,ke]=Ce?[le,Y,F,B]:[fe,U,G,X],Ye=ke($,ve),we=ke(re,-ve),_e=$.mass,Be=re.mass,it=Ye?we?Be/(_e+Be):1:0,yt=we?Ye?_e/(_e+Be):1:0,Ze=je*w;ye.set($.sid,(ye.get($.sid)??0)+ve*Ze*it),ye.set(re.sid,(ye.get(re.sid)??0)-ve*Ze*yt),O+=Ze}for(const j of k)j.anchored||(j.x=Math.max(0,j.x+(F.get(j.sid)??0)),j.y=Math.max(0,j.y+(G.get(j.sid)??0)));if(O<N)break}const z=[];for(const L of k){const F=L.x-A.get(L.sid),G=L.y-H.get(L.sid);if(!(Math.abs(F)<1&&Math.abs(G)<1)){for(const O of L.members){if(r.has(O))continue;const j=n.get(O);j&&n.set(O,{x:j.x+F,y:j.y+G})}z.push(L.sid)}}return z}const D4=600;function Av(e,n){return!(e.exitAt!=null&&n-e.exitAt>D4||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function F4(e,n){const r=new Set;for(const i of e.agents.values())Av(i,n)&&r.add(i.id);return r}function z4(e,n,r=0){return e.right+r>n.left&&e.left-r<n.right&&e.bottom+r>n.top&&e.top-r<n.bottom}function B4(e,n,r=0){if(!e)return!1;for(const i of n)if(z4(e,i,r))return!0;return!1}const AT="sessionGroup";function U4(e,n){var i;if(e.type===AT)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const H4="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function W4(e){if(e.checkDisabled)return H4;if(e.checking)return"Asking npm for the newest release…";const n=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",r=e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${n}${r} · re-checked periodically · click to check npm now`}function V4(e){const n=`Version v${e.running}`;return e.checkDisabled?`${n}, update checks are off`:e.checking?`${n}, checking npm for a newer release`:`${n}, check npm for a newer release`}function G4(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as its first hook fires.",workspace:null,tail:""};const n=e.trim();return n===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:n,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}const Iv={kind:"assumed",claude:!0,codex:!0};function Y4(e){if(!e||typeof e!="object")return Iv;const n=e.providers;if(!n||typeof n!="object")return Iv;const r=n;return{kind:"reported",claude:r.claude!==!1,codex:r.codex!==!1}}function IT(e){const n=Math.max(0,Math.floor(e));return`${n} event${n===1?"":"s"}`}function K4(e){return e.connected?e.paused?{tone:"paused",label:"paused",title:e.held>0?`Connected — ${IT(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 X4(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:`${IT(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 MT(e,n){return e!==""&&n>0}function Q4(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:MT(e,n)}}function Mv(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 Z4(e,n){return e.getFullYear()===n.getFullYear()&&e.getMonth()===n.getMonth()&&e.getDate()===n.getDate()}function J4(e,n,r){const i=new Date(e),o=Mv(n-e);return{label:Z4(i,new Date(n))?o:`${o} · ${i.toLocaleDateString(r,{month:"short",day:"numeric"})}`,title:i.toLocaleString(r,{dateStyle:"medium",timeStyle:"medium"})}}function aa(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const e5={agent:HP,sessionGroup:s3},OT="react-flow__node";function AE(e){var n,r;return!!e&&((r=(n=e.classList)==null?void 0:n.contains)==null?void 0:r.call(n,OT))===!0}function t5(e){try{const n=document.querySelector(`.${OT}[data-id="${CSS.escape(e)}"]`);n==null||n.focus({preventScroll:!0})}catch{}}const n5=420,ou=18,r5=9e4,s5=200,i5=5*6e4,o5=6,a5=2*6e4,by="agent-dag.layout",Sy="agent-dag.viewport",PT="agent-dag.summariesDismissed",LT="agent-dag.sessionListOpen",qT="agent-dag.detailOpen",$T="agent-dag.usagePanelOpen",IE="agent-dag.accountsPanelOpen",ME="agent-dag.versionNoticeDismissed",OE="agent-dag.oldNameNoticeDismissed",l5=15*6e4,PE={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:"},LE="agent-dag.autoRestart",qE="agent-dag.bundleReloadedFor";function u5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(LT)==="1"}catch{return!1}}function c5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(LT,e?"1":"0")}catch{}}function d5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(qT)==="1"}catch{return!1}}function f5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(qT,e?"1":"0")}catch{}}function h5(){const e=RC($T);return e===null?!0:e==="1"}function p5(e){if(!(typeof window>"u"))try{window.localStorage.setItem($T,e?"1":"0")}catch{}}function m5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(PT);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 $E(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(PT,JSON.stringify(r))}catch{}}function g5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(by);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 uv(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(by,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function v5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Sy);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 y5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Sy,JSON.stringify(e))}catch{}}function DE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(by)}catch{}try{window.localStorage.removeItem(Sy)}catch{}}}function w5(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=`${en}-${p}-${n.slice(0,8)}.json`,document.body.appendChild(h),h.click(),document.body.removeChild(h),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const Ov={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Pv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},x5={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",shell:"shell",exec_command:"shell",shell_command:"shell",write_stdin:"shell",wait:"shell",apply_patch:"file",update_plan:"task",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan"};function DT(e){return e.startsWith("mcp__")?"mcp":x5[e]??"other"}function FT(e,n){var i,o,l;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))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function _5(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 b5(e,n,r,i,o,l,u,c,h,p,d,m,y,w,N,_,b,S,k){const E=[],C=[],I=new Set;if(l)for(const O of e.agents.values())S.has(O.id)&&FT(O,l)&&I.add(O.id);const P=MT(l,I.size);for(const O of e.agents.values()){if(!S.has(O.id))continue;const j=P&&!I.has(O.id),q=O.exitAt!=null,$=b!=null&&!b.has(O.id),re=[j?"rf-dim":"",q?"rf-exiting":"",$?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,J=u.get(O.id);if(E.push({id:O.id,type:"agent",position:{x:0,y:0},data:{...O,now:n,onOpenContext:k},className:re,...J?{width:J.width,height:J.height}:null}),O.parentId&&S.has(O.parentId)){const W=ey(O.sessionId),Z=l&&!I.has(O.id)&&!I.has(O.parentId),M=q,Y=_.size>0&&(_.has(O.id)||_.has(O.parentId)),U=b!=null&&!b.has(O.id)&&!b.has(O.parentId),B=O.state==="active"?2:1.5,X=Y?B+1.5:B,ne=Z||M?.2:U?.12:1,le=["sess-edge",O.state==="active"?"sess-live":"sess-idle",M?"rf-edge-exiting":"",Y?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${O.parentId}->${O.id}`,source:O.parentId,target:O.id,animated:(O.state==="active"||Y)&&!Z&&!M,type:"smoothstep",style:{"--session-hue":W,strokeWidth:X,opacity:ne,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:le})}}const A=new Map;for(const O of e.agents.values())O.tools.length>0&&A.set(O.id,Math.min(4,O.tools.length));const H=`${w}#lanes:${M4(A)}`,z=E.filter(O=>HL(O.id,o,m,y));if(z.length>0||H!==N.current){if(z.length>0){const O=P4(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:A});for(const j of O)TC(j.id,m,y)&&VL(j.id,j.position,m,y);q4(E,m,o,u,new Set(z.map(j=>j.id)),A)}L4(E,m,o,u,A),N.current=H}const L=$4(E,m,o,u,c,!p||d,A);L.length>0&&h(L),nu(m,e.agents),nu(y,e.agents),nu(o,e.agents),nu(u,UL(e.agents.values()));const F=[];let G=!1;for(const O of E){let j=o.get(O.id)??m.get(O.id);j||(j=WL(O.id,m,y),G=!0),F.push({...O,position:j})}return G&&(N.current=""),{nodes:F,edges:C}}function S5(){return g.jsx(Jv,{children:g.jsx(k5,{})})}function k5(){var Ha,Wa,Va,Ga;const e=Ta(),n=R.useRef(Nv()),[,r]=R.useState(0),i=R.useCallback(()=>r(V=>V+1),[]),[o,l]=R.useState(()=>new Set),[u,c]=R.useState(null),[h,p]=R.useState(null),d=R.useCallback((V,K)=>{l(ae=>{if(!K)return new Set([V]);const de=new Set(ae);return de.has(V)?de.delete(V):de.add(V),de}),c(ae=>K&&ae===V?ae:V)},[]),m=R.useCallback(()=>{l(new Set),c(null)},[]),[y,w]=R.useState(null),[N,_]=R.useState(null),b=R.useCallback(V=>_(V),[]),[S,k]=R.useState(!1),E=R.useRef(m5()),[C,I]=R.useState(u5);R.useEffect(()=>{c5(C)},[C]);const[P,A]=R.useState(d5);R.useEffect(()=>{f5(P)},[P]);const[H,z]=R.useState(h5);R.useEffect(()=>{p5(H)},[H]);const[L,F]=R.useState(()=>{try{const V=window.localStorage.getItem(IE);return V===null?!0:V==="1"}catch{return!0}});R.useEffect(()=>{try{window.localStorage.setItem(IE,L?"1":"0")}catch{}},[L]);const[G,O]=R.useState(null),[j,q]=R.useState(!1),[$,re]=R.useState(0),[J,W]=R.useState(0);R.useEffect(()=>{fetch("/api/sound-hook").then(V=>V.ok?V.json():null).then(V=>{V!=null&&V.ok&&(O(V.enabled===!0),re((V.foreign??[]).filter(K=>K.worksHere).length),W(typeof V.parked=="number"?V.parked:0))}).catch(()=>{})},[]);const Z=R.useCallback(async()=>{q(!0);try{const K=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!G})})).json().catch(()=>null);K!=null&&K.ok&&O(K.enabled===!0),fetch("/api/sound-hook").then(ae=>ae.ok?ae.json():null).then(ae=>{ae!=null&&ae.ok&&(re((ae.foreign??[]).filter(de=>de.worksHere).length),W(typeof ae.parked=="number"?ae.parked:0))}).catch(()=>{})}catch{}finally{q(!1)}},[G]),[M,Y]=R.useState(!1),[U,B]=R.useState(null),[X,ne]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(ME)??""}catch{return""}}),[le,fe]=R.useState(!1),te=R.useRef(0),[ce,Ce]=R.useState(!1),ve=R.useCallback((V=!1)=>{V&&(te.current=Date.now(),Ce(!0)),fetch(V?"/api/version?refresh=1":"/api/version").then(K=>K.ok?K.json():null).then(K=>{K&&B(K)}).catch(()=>{}).finally(()=>{V&&Ce(!1)})},[]),je=R.useCallback(()=>{ve(Date.now()-te.current>=l5)},[ve]);R.useEffect(()=>{ve();const V=window.setInterval(je,5*6e4),K=()=>{document.visibilityState==="visible"&&je()};return document.addEventListener("visibilitychange",K),()=>{window.clearInterval(V),document.removeEventListener("visibilitychange",K)}},[ve,je]),R.useEffect(()=>{M&&ve()},[M,ve]);const ye=(U==null?void 0:U.notice)??null,[ke,Ye]=R.useState(null),[we,_e]=R.useState(Iv);R.useEffect(()=>{let V=!1;return fetch("/api/health").then(K=>K.ok?K.json():null).then(K=>{V||(_e(Y4(K)),!(!K||typeof K.workspace!="string")&&Ye(K.workspace))}).catch(()=>{}),()=>{V=!0}},[M]);const Be=R.useRef(we);Be.current=we;const it=ye?`${ye.kind}:${ye.to}`:"",yt=ye!=null&&X!==it,Ze=R.useCallback(()=>{if(!ye)return;const V=X===it?"":it;ne(V);try{window.localStorage.setItem(ME,V)}catch{}},[ye,it,X]),[De,Je]=R.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(OE)??""}catch{return""}}),Xe=U!=null&&U.invokedAs&&U.invokedAs!==en?U.invokedAs:null,Mt=Xe!=null&&De!==Xe,ut=R.useCallback(()=>{if(Xe){Je(Xe);try{window.localStorage.setItem(OE,Xe)}catch{}}},[Xe]),Qe=((Ha=U==null?void 0:U.upgrade)==null?void 0:Ha.state)??"idle",Ot=IL(U==null?void 0:U.upgrade),Ft=R.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}ve()},[ve]);R.useEffect(()=>{if(Qe!=="running")return;const V=window.setInterval(ve,3e3);return()=>window.clearInterval(V)},[Qe,ve]);const et=R.useCallback(async()=>{var ae;const V=U==null?void 0:U.command;if(!V)return;let K=!1;try{K=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(V).then(()=>!0))??Promise.resolve(!1),new Promise(de=>window.setTimeout(()=>de(!1),500))])}catch{K=!1}if(!K)try{const de=document.createElement("textarea");de.value=V,de.setAttribute("readonly",""),de.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(de),de.select(),K=document.execCommand("copy"),de.remove()}catch{K=!1}K&&(fe(!0),window.setTimeout(()=>fe(!1),1600))},[U==null?void 0:U.command]),St=R.useCallback(()=>{I(V=>(V||F(!1),!V))},[]),pt=R.useCallback(()=>{F(V=>(V||I(!1),!V))},[]),[wt,hn]=R.useState(!1),[Yt,Pt]=R.useState(0),Sn=R.useRef(null),[gr,kn]=R.useState(!1),zt=R.useRef(null),[Fn,pn]=R.useState(0),vr=R.useRef(XL()),[Wr,gi]=R.useState(!1),Vr=R.useCallback(()=>{const V=vr.current,K=V.setPaused(!V.paused);for(const ae of K)n.current=qx(n.current,ae);gi(V.paused)},[]),[ct,vi]=R.useState(Date.now()),[mn,Cs]=R.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(LE)!=="0"}catch{return!0}}),yr=R.useCallback(()=>{Cs(V=>{const K=!V;try{window.localStorage.setItem(LE,K?"1":"0")}catch{}return K})},[]),[zn,En]=R.useState(!1),[Gr,Yr]=R.useState("restart"),[Kr,yi]=R.useState(null),ir=R.useRef(!1),Ts=R.useRef(null),Nn=R.useRef(0),wr=R.useCallback(async V=>{if(ir.current)return;const K=(V==null?void 0:V.upgrade)===!0;ir.current=!0,Ts.current=Ot;const ae=++Nn.current;Yr(K?"npx":"restart"),En(!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:K})})}catch{}window.setTimeout(()=>{if(Nn.current===ae&&ir.current){ir.current=!1,En(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},K?18e4:3e4)},[ye==null?void 0:ye.to,Ot]),Rs=R.useRef(null);R.useEffect(()=>{let V=!1;for(const ae of n.current.agents.values())if(ae.state==="active"){V=!0;break}const K=OL({enabled:mn,kind:ye==null?void 0:ye.kind,canRestart:(U==null?void 0:U.canRestart)===!0,busy:V,idleSince:Rs.current,now:ct});Rs.current=K.idleSince,K.restart&&wr()},[mn,ye==null?void 0:ye.kind,U==null?void 0:U.canRestart,ct,wr]),R.useEffect(()=>{const V=U==null?void 0:U.running;let K=null,ae=null;try{K=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(qE)}catch{return}const de=AL({bundle:"1.35.4",running:V,pending:K,lastTried:ae});if(de==="reload"){try{window.sessionStorage.setItem(qE,V??"")}catch{return}window.location.reload();return}if(de!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}ir.current=!1,En(!1),yi(V??null);const xe=window.setTimeout(()=>yi(null),6e3);return()=>window.clearTimeout(xe)},[U==null?void 0:U.running]),R.useEffect(()=>{if(zn&&ML({asked:Ts.current,reported:Ot})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}ir.current=!1,En(!1)}},[zn,Ot]);const js=R.useRef(g5()).current;R.useRef(!1);const Rt=R.useRef(new Map(js.positions.filter(([V])=>js.pins.includes(V)))),xr=R.useRef(null),_r=R.useState(()=>v5())[0],[Kt,Xr]=R.useState(""),[wi,nt]=R.useState(()=>new Set),[br,Qr]=R.useState(tq),[As,Zr]=R.useState(!1),Jr=R.useRef(null);R.useEffect(()=>{document.documentElement.dataset.theme=br;try{window.localStorage.setItem(jC,br)}catch{}},[br]),R.useEffect(()=>{if(!_r)return;const V=window.setTimeout(()=>{try{e.setViewport(_r,{duration:0})}catch{}},60);return()=>window.clearTimeout(V)},[e,_r]);const Is=R.useRef(!0);R.useEffect(()=>{const V=new EventSource("/events"),K=KL(i,{now:()=>Date.now(),setTimeout:(ae,de)=>window.setTimeout(ae,de),clearTimeout:ae=>window.clearTimeout(ae)});return V.addEventListener("open",()=>{Y(!0),Zr(!0)}),V.addEventListener("error",()=>Y(!1)),V.addEventListener("replay-end",()=>{Is.current=!1,K.flush()}),V.addEventListener("hook",ae=>{try{const de=JSON.parse(ae.data);if(!vr.current.accept(de))return;n.current=qx(n.current,de),de.replay===!0||Is.current||Date.now()-de.receivedAt>3e4?K.replay():K.live()}catch{}}),()=>{V.close(),K.cancel()}},[i]),R.useEffect(()=>{const V=setInterval(()=>{const K=Date.now();vi(K);let ae=dP(n.current,K,r5);hP(n.current,K,fP)&&(ae=!0),uP(n.current,K,s5,i5)&&(ae=!0),cP(n.current,K,o5,a5)&&(ae=!0),ae&&i()},250);return()=>clearInterval(V)},[i]);const or=R.useRef(null),kt=R.useRef(0),Ms=420,mt=R.useCallback((V=500)=>{try{const Ee=document.querySelector(".canvas-wrap"),Oe=Array.from(document.querySelectorAll(".react-flow__node")).filter(ot=>ot.offsetWidth>0);if(!Ee||Oe.length===0)return;const Fe=Ee.getBoundingClientRect(),Ge=e.getViewport();if(!Number.isFinite(Ge.zoom)||Ge.zoom<=0)return;const Ve=ot=>(ot-Fe.left-Ge.x)/Ge.zoom,$e=ot=>(ot-Fe.top-Ge.y)/Ge.zoom,Tn=Oe.map(ot=>ot.getBoundingClientRect()),Us=Math.min(...Tn.map(ot=>Ve(ot.left))),jo=Math.max(...Tn.map(ot=>Ve(ot.right))),Hs=Math.min(...Tn.map(ot=>$e(ot.top))),Ao=Math.max(...Tn.map(ot=>$e(ot.bottom))),Ya=jo-Us,Ci=Ao-Hs;if(!(Ya>0&&Ci>0))return;const yn=Math.max(.2,Math.min(1,(Fe.width-160)/(Ya+Ms)*.86,(Fe.height-160)/Ci*.86));e.setViewport({x:80-Us*yn,y:Math.max(80,(Fe.height-Ci*yn)/2)-Hs*yn,zoom:yn},{duration:V}),kt.current=Date.now(),window.setTimeout(()=>{try{const ot={x:80-Us*yn,y:Math.max(80,(Fe.height-Ci*yn)/2)-Hs*yn,zoom:yn},Ka=e.getViewport();(Math.abs(Ka.zoom-yn)>.01||Math.abs(Ka.x-ot.x)>2)&&e.setViewport(ot,{duration:0})}catch{}},V+60)}catch{}},[e]),_o=R.useRef(""),bo=R.useRef(null),Pa=R.useRef(0),Sr=R.useCallback(()=>{Pa.current=Date.now()},[]),es="agent-dag.autoFitDisabled",gn=R.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(es)==="1"}catch{return!1}})()),[Os,La]=R.useState(gn.current),qa=R.useCallback(()=>{if(!gn.current){gn.current=!0,La(!0);try{window.localStorage.setItem(es,"1")}catch{}}},[]),So=R.useCallback(()=>{gn.current=!1,La(!1);try{window.localStorage.removeItem(es)}catch{}mt(400)},[e,mt]);R.useEffect(()=>{const V=setInterval(()=>{if(gn.current||Date.now()-Pa.current<800)return;const K=n.current,ae=Date.now(),de=[];for(const Ve of K.agents.values())Av(Ve,ae)&&de.push({id:Ve.id});if(de.length===0)return;const xe=e.getViewport(),Ee=window.innerWidth-360,Oe=window.innerHeight-52;let Fe=!1,Ge=!1;for(const{id:Ve}of de){const $e=ar.current.get(Ve),Tn=Rt.current.get(Ve)??Xt.current.get(Ve);if(!$e||!Tn)continue;Ge=!0;const Us=Tn.x*xe.zoom+xe.x,jo=Tn.y*xe.zoom+xe.y,Hs=(Tn.x+$e.width)*xe.zoom+xe.x,Ao=(Tn.y+$e.height)*xe.zoom+xe.y;if(Hs>0&&Us<Ee&&Ao>0&&jo<Oe){Fe=!0;break}}Ge&&!Fe&&mt(600)},1500);return()=>clearInterval(V)},[e]);const xi=R.useRef(!1),ar=R.useRef(new Map),ts=R.useRef(0),Ju=R.useCallback(V=>{const K=ar.current;let ae=!1;for(const de of V.nodeInternals.values()){const xe=de.width,Ee=de.height;if(xe==null||Ee==null)continue;const Oe=K.get(de.id);Oe?(Math.abs(Oe.height-Ee)>4||Math.abs(Oe.width-xe)>4)&&(K.set(de.id,{width:xe,height:Ee}),ae=!0):(K.set(de.id,{width:xe,height:Ee}),ae=!0)}return ae&&(ts.current+=1),ts.current},[]),_i=Ke(Ju),[He,$a]=R.useState(0);R.useEffect(()=>{let V=0;const K=()=>{const de=ar.current;let xe=!1;for(const Ee of document.querySelectorAll(".react-flow__node[data-id]")){const Oe=Ee.getAttribute("data-id");if(!Oe)continue;const Fe=Ee.offsetWidth,Ge=Ee.offsetHeight;if(!Fe||!Ge)continue;const Ve=de.get(Oe);(!Ve||Math.abs(Ve.width-Fe)>4||Math.abs(Ve.height-Ge)>4)&&(de.set(Oe,{width:Fe,height:Ge}),xe=!0)}xe&&$a(Ee=>Ee+1)};if(xi.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(K,32):V=requestAnimationFrame(K),()=>{cancelAnimationFrame(V),window.clearTimeout(ae)}});const Xt=R.useRef(new Map(js.positions)),ko=R.useRef(new Set),bi=R.useRef(""),kr=R.useMemo(()=>{const V=[];for(const K of n.current.agents.values())Av(K,ct)&&V.push(K.id+(K.parentId?`>${K.parentId}`:""));return V.sort(),`${V.join("|")}#sv${_i}.${He}`},[n.current,n.current.lastSeq,ct,_i,He]),ns=R.useRef(null);R.useEffect(()=>(ns.current!=null&&window.clearTimeout(ns.current),ns.current=window.setTimeout(()=>{uv(Xt.current,Rt.current)},1500),()=>{ns.current!=null&&window.clearTimeout(ns.current)}),[kr]),R.useEffect(()=>{if(_o.current===kr)return;const V=_o.current;if(_o.current=kr,!V||gn.current)return;Date.now()-kt.current>1200&&mt(400),or.current&&window.clearTimeout(or.current),or.current=window.setTimeout(()=>{gn.current||mt(500)},280)},[kr,e,mt]);const Ps=R.useMemo(()=>{if(o.size===0)return null;const V=new Set;for(const K of o){const ae=_5(n.current,K);if(ae)for(const de of ae)V.add(de)}return V.size>0?V:null},[n.current,n.current.lastSeq,o]),Cn=R.useMemo(()=>F4(n.current,ct),[n.current,n.current.lastSeq,ct]),Bn=R.useRef(null),[vn,Un]=R.useState({w:0,h:0});R.useEffect(()=>{const V=Bn.current;if(!V||typeof ResizeObserver>"u")return;const K=new ResizeObserver(ae=>{var xe;const de=(xe=ae[0])==null?void 0:xe.contentRect;de&&Un(Ee=>Math.abs(Ee.w-de.width)>40||Math.abs(Ee.h-de.height)>40?{w:de.width,h:de.height}:Ee)});return K.observe(V),Un({w:V.clientWidth,h:V.clientHeight}),()=>K.disconnect()},[]);const Ls=R.useRef(new Map),[rs,lr]=R.useState(!1);R.useEffect(()=>{const V=window.setTimeout(()=>lr(!0),2500);return()=>window.clearTimeout(V)},[]);const[ec,Si]=R.useState(!1),tn=R.useRef(null),[Eo,No]=R.useState(!1),ki=R.useCallback(()=>{tn.current&&(window.clearTimeout(tn.current),tn.current=null),Si(!1)},[]),Da=R.useCallback(V=>{V.length!==0&&queueMicrotask(()=>{Si(!0),tn.current&&window.clearTimeout(tn.current),tn.current=window.setTimeout(()=>Si(!1),n5+80)})},[]);R.useEffect(()=>()=>{tn.current&&window.clearTimeout(tn.current)},[]);const Fa=vn.w>0?vn.w*.92:0,ss=vn.h>0?vn.h:0,{nodes:nn,edges:is}=R.useMemo(()=>b5(n.current,ct,Fa,ss,Rt.current,Kt,ar.current,Ls.current,Da,rs,Eo,Xt.current,ko.current,kr,bi,o,Ps,Cn,b),[n.current,n.current.lastSeq,ct,Fa,ss,rs,Eo,Kt,kr,o,Ps,Cn,b,Yt]),qs=R.useMemo(()=>{const V=new Map;for(const ae of nn){const de=ae.data;if(!(de!=null&&de.sessionId)||de.exitAt!=null)continue;const xe=ae.width,Ee=ae.height;if(xe==null||Ee==null)continue;const Oe=ae.position.x,Fe=ae.position.y,Ge=Oe+xe,Ve=Fe+Ee,$e=V.get(de.sessionId);$e?($e.minX=Math.min($e.minX,Oe),$e.minY=Math.min($e.minY,Fe),$e.maxX=Math.max($e.maxX,Ge),$e.maxY=Math.max($e.maxY,Ve)):V.set(de.sessionId,{minX:Oe,minY:Fe,maxX:Ge,maxY:Ve})}const K=[];for(const[ae,de]of V){const xe=de.maxX-de.minX+ou*2,Ee=de.maxY-de.minY+ou*2;K.push({id:`group:${ae}`,type:AT,position:{x:de.minX-ou,y:de.minY-ou},data:{sessionId:ae,w:xe,h:Ee},width:xe,height:Ee,style:{width:xe,height:Ee},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return K},[nn,ct]),tc=R.useMemo(()=>{const V=[...qs,...nn],K=zt.current;return!K||K.size===0?V:V.map(ae=>{const de=K.get(ae.id);return de?{...ae,position:de}:ae})},[qs,nn,Fn]),$s=R.useMemo(()=>{if(!Kt)return null;const V=new Set;for(const K of n.current.agents.values())Cn.has(K.id)&&FT(K,Kt)&&V.add(K.id);return V},[n.current,n.current.lastSeq,Kt,Cn]),Hn=R.useMemo(()=>Q4(Kt,($s==null?void 0:$s.size)??0,Cn.size),[Kt,$s,Cn]),Er=R.useMemo(()=>{const V=new Set;for(const K of n.current.agents.values())for(const ae of K.tools)V.add(DT(ae.name));return Object.keys(Ov).filter(K=>V.has(K))},[n.current,n.current.lastSeq]);R.useEffect(()=>{if(Er.length<=1){kn(!1);return}let V=0;const K=()=>{const ae=Sn.current;if(ae&&!document.hidden){const de=ae.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Oe=>Oe.getBoundingClientRect()),Ee=B4(de,xe,8);kn(Oe=>Oe===Ee?Oe:Ee)}V=window.setTimeout(K,300)};return K(),()=>window.clearTimeout(V)},[Er.length]);const Nr=R.useMemo(()=>{const V=new Map;for(const ae of n.current.agents.values())for(const de of ae.tools){if(!de.name.startsWith("mcp__"))continue;const xe=de.name.slice(5),Ee=xe.indexOf("__"),Oe=Ee>0?xe.slice(0,Ee):xe;V.set(Oe,(V.get(Oe)??0)+1)}const K=[];for(const[ae,de]of V){let xe=5381;for(let Ee=0;Ee<ae.length;Ee++)xe=(xe<<5)+xe^ae.charCodeAt(Ee);K.push({server:ae,count:de,hue:Math.abs(xe)%360})}return K.sort((ae,de)=>de.count-ae.count),K},[n.current,n.current.lastSeq]),za=R.useCallback(V=>{nt(K=>{const ae=new Set(K);return ae.has(V)?ae.delete(V):ae.add(V),ae})},[]),dt=u?n.current.agents.get(u):null,Ds=h?Array.from(n.current.agents.values()).flatMap(V=>V.tools).find(V=>V.id===h)??null:null,Fs=R.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=Nv(),Rt.current.clear(),ar.current.clear(),Xt.current.clear(),bi.current="",DE(),m(),i()},[i,m]),Co=R.useRef(S);Co.current=S;const zs=R.useRef(!1);zs.current=Ds!=null||wt||N!=null||y!=null;const Cr=R.useCallback(V=>{const K=LL(V,{confirmOpen:Co.current,modalOpen:zs.current});K==="confirm"?k(!0):K==="clear"&&(k(!1),Fs())},[Fs]),Ei=R.useCallback(()=>{Rt.current.clear(),Xt.current.clear(),bi.current="",DE(),i(),window.setTimeout(()=>mt(500),80)},[i,e,mt]),Bt=R.useCallback(()=>mt(500),[mt]),Wn=R.useRef(nn);Wn.current=nn;const Ni=R.useRef(u);Ni.current=u;const Tr=R.useCallback(V=>{const K=Wn.current,ae=$L(K.map(Ee=>({id:Ee.id,x:Ee.position.x,y:Ee.position.y})),Ni.current,V),de=ae?K.find(Ee=>Ee.id===ae):void 0;if(!de)return;const xe=AE(document.activeElement);d(de.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[de]})}catch{}kt.current=Date.now(),xe&&t5(de.id)},30)},[d,e]),Ba=R.useCallback(V=>{d(V,!1),window.setTimeout(()=>{try{const K=Wn.current.find(ae=>ae.id===V);K&&e.fitView({padding:.3,duration:500,nodes:[K]}),kt.current=Date.now()}catch{}},60)},[d,e]);R.useEffect(()=>{const V=K=>{var Fe,Ge,Ve;const ae=K.target,de={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(Fe=ae==null?void 0:ae.getAttribute)==null?void 0:Fe.call(ae,"role"),type:ae==null?void 0:ae.type};if(K.key==="Escape"){const $e=RP({overlayOpen:ku.depth()>0,typing:ty(de)});$e==="dismiss"?ku.dismissTop():$e==="blur"?ae==null||ae.blur():(BL(de)&&(ae==null||ae.blur()),m());return}if(yC(K))return;const xe=AE(ae)?(Ge=ae==null?void 0:ae.getAttribute)==null?void 0:Ge.call(ae,"data-id"):null,Ee=xe&&Wn.current.some($e=>$e.id===xe)?xe:null,Oe=FL(K,Ee);if(Oe.kind==="activate"){K.preventDefault(),d(Oe.nodeId,Oe.additive);return}if(Oe.kind!=="node"&&!(Oe.nodeId==null&&qP(de))){if(K.key==="/"){K.preventDefault(),(Ve=Jr.current)==null||Ve.focus();return}K.key===" "&&(K.preventDefault(),Vr()),(K.key==="c"||K.key==="C")&&Cr("shortcut"),(K.key==="r"||K.key==="R")&&Ei(),(K.key==="f"||K.key==="F")&&Bt(),(K.key==="l"||K.key==="L")&&St(),(K.key==="h"||K.key==="H")&&hn($e=>!$e),(K.key==="u"||K.key==="U")&&z($e=>!$e),(K.key==="a"||K.key==="A")&&Be.current.claude&&pt(),(K.key==="j"||K.key==="J")&&Tr(1),(K.key==="k"||K.key==="K")&&Tr(-1),(K.key==="t"||K.key==="T")&&Qr($e=>$e==="dark"?"light":"dark")}};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[Cr,Ei,Bt,m,d,Tr,Vr]);const Rr=n.current.agents.size,To=new Set(Array.from(n.current.agents.values()).map(V=>V.sessionId)).size,Qt=R.useMemo(()=>$3(n.current.agents.values()),[n.current,n.current.lastSeq]),Bs=R.useMemo(()=>D3(n.current.agents.values()),[n.current,n.current.lastSeq]),Ro=R.useRef(null);R.useEffect(()=>{const V=nq({waiting:Qt.length,running:Bs}),K=Ro.current;if(Ro.current=V,(K==null?void 0:K.title)!==V.title&&(document.title=V.title),(K==null?void 0:K.icon)!==V.icon){const ae=document.querySelector('link[rel="icon"]');ae&&(ae.href=rq[V.icon])}},[Qt.length,Bs]);const[nc,rc]=R.useState(""),Ua=iq(Qt);R.useEffect(()=>{rc(V=>oq(V,Ua))},[Ua]);const Ut=R.useMemo(()=>{let V=0,K=0,ae=0,de=0,xe=0,Ee=0,Oe=0,Fe=0,Ge=0;for(const Ve of n.current.agents.values()){V+=Ve.usage.inputTokens,K+=Ve.usage.outputTokens,ae+=Ve.usage.cacheReadTokens,de+=Ve.usage.cacheCreateTokens;const $e=dn(Ve.usage,Ve.model);xe+=$e.total,Ee+=$e.input,Oe+=$e.output,Fe+=$e.cacheRead,Ge+=$e.cacheWrite}return{inT:V,outT:K,cacheR:ae,cacheC:de,sum:V+K,cost:{total:xe,input:Ee,output:Oe,cacheRead:Fe,cacheWrite:Ge}}},[n.current,n.current.lastSeq]);return g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("div",{className:"brand",children:[g.jsx("span",{className:"logo"}),en,ye?g.jsxs("button",{type:"button",className:"v stale",onClick:Ze,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 V={running:(U==null?void 0:U.running)??"1.35.4",latest:U==null?void 0:U.latest,latestPending:U==null?void 0:U.latestPending,checkedAgo:U!=null&&U.checkedAt?Mv(ct-U.checkedAt):null,checkDisabled:U==null?void 0:U.checkDisabled,checking:ce};return g.jsxs("button",{type:"button",className:ce?"v checking":"v",onClick:()=>ve(!0),"aria-busy":ce||void 0,"aria-label":V4(V),title:W4(V),children:["v",V.running]})})()]}),dt&&(()=>{const V=dn(dt.usage,dt.model),K=Math.max(0,((dt.endedAt??ct)-dt.startedAt)/1e3),ae=dt.state==="active"?Su(V.total,K):null,de=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${dt.label}`,onClick:()=>{try{const xe=nn.find(Ee=>Ee.id===dt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),kt.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${dt.state}`,children:dt.state==="active"?"live":dt.state}),g.jsx("span",{className:"selected-label",children:dt.label}),V.total>0&&g.jsxs("span",{className:"selected-cost",children:[ze(V.total),ae?g.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):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:Jr,type:"text",placeholder:"Search agents, cwd, tools…",value:Kt,onChange:V=>Xr(V.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Kt?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>Xr(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"}),Hn.count&&g.jsx("span",{className:`search-count${Hn.empty?" none":""}`,"aria-live":"polite",title:`${Hn.count} agents on the canvas match “${Kt}”`,children:Hn.count})]}),g.jsxs("span",{className:"status",children:[(()=>{const V=K4({connected:M,paused:Wr,held:vr.current.size});return g.jsx("span",{className:`pill ${V.tone}`,title:V.title,children:V.label})})(),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:To}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Rr}),g.jsx("span",{className:"lbl",children:"agents"})]}),g.jsxs("span",{className:"stat",title:"Total hook events received",children:[g.jsx("span",{className:"count",children:n.current.totalEvents}),g.jsx("span",{className:"lbl",children:"events"})]}),Ut.sum>0&&g.jsxs("span",{className:"stat",title:`in:${Ut.inT.toLocaleString()} out:${Ut.outT.toLocaleString()} cache-r:${Ut.cacheR.toLocaleString()} cache-c:${Ut.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:$t(Ut.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),Nr.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
64
64
  ${Nr.map(V=>` ${V.server}: ${V.count} call${V.count===1?"":"s"}`).join(`
65
65
  `)}`,children:[Nr.slice(0,6).map(V=>g.jsx("span",{className:"mcp-dot",style:{"--mcp-hue":V.hue}},V.server)),Nr.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",Nr.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),Ut.cost.total>0&&(()=>{let V=0,K=0;for(const xe of n.current.agents.values()){if(xe.state!=="active")continue;const Ee=dn(xe.usage,xe.model);V+=Ee.total,K=Math.max(K,((xe.endedAt??ct)-xe.startedAt)/1e3)}const ae=K>0?Su(V,K):null,de=`input ${ze(Ut.cost.input)} + output ${ze(Ut.cost.output)} + cache r ${ze(Ut.cost.cacheRead)} + cache w ${ze(Ut.cost.cacheWrite)}${ae?`
66
66
  active burn: ${ae}`:""}`;return g.jsxs("span",{className:"stat",title:de,children:[g.jsx("span",{className:"count",children:ze(Ut.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",ae?` · ${ae}`:""]})]})})()]}),g.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:nc}),Qt.length>0&&g.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>Ba(Qt[0].id),title:`Blocked waiting for you — click to go to the one that has been stuck longest: