agent-dag 1.33.116 → 1.33.117
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,9 +54,9 @@ Error generating stack: `+w.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 vw;function RR(){if(vw)return od;vw=1;var e=ma(),n=TR();function r(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:r,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,p=e.useDebugValue;return od.useSyncExternalStoreWithSelector=function(h,f,m,y,x){var N=l(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function S(M){if(!k){if(k=!0,E=M,M=y(M),x!==void 0&&_.hasValue){var O=_.value;if(x(O,M))return C=O}return C=M}if(O=C,s(E,M))return O;var W=y(M);return x!==void 0&&x(O,W)?(E=M,O):(E=M,C=W)}var k=!1,E,C,I=m===void 0?null:m;return[function(){return S(f())},I===null?void 0:function(){return S(I())}]},[f,m,y,x]);var b=o(h,N[0],N[1]);return u(function(){_.hasValue=!0,_.value=b},[b]),p(b),b},od}var yw;function jR(){return yw||(yw=1,sd.exports=RR()),sd.exports}var AR=jR();const IR=cv(AR),MR={},ww=e=>{let n;const r=new Set,s=(f,m)=>{const y=typeof f=="function"?f(n):f;if(!Object.is(y,n)){const x=n;n=m??(typeof y!="object"||y===null)?y:Object.assign({},n,y),r.forEach(N=>N(n,x))}},o=()=>n,p={setState:s,getState:o,getInitialState:()=>h,subscribe:f=>(r.add(f),()=>r.delete(f)),destroy:()=>{(MR?"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()}},h=n=e(s,o,p);return p},PR=e=>e?ww(e):ww,{useDebugValue:OR}=ae,{useSyncExternalStoreWithSelector:qR}=IR,LR=e=>e;function aE(e,n=LR,r){const s=qR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,r);return OR(s),s}const xw=(e,n)=>{const r=PR(e),s=(o,l=n)=>aE(r,o,l);return Object.assign(s,r),s},$R=(e,n)=>e?xw(e,n):xw;function kt(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[s,o]of e)if(!Object.is(o,n.get(s)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const s of e)if(!n.has(s))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(n).length)return!1;for(const s of r)if(!Object.prototype.hasOwnProperty.call(n,s)||!Object.is(e[s],n[s]))return!1;return!0}var DR={value:()=>{}};function lu(){for(var e=0,n=arguments.length,r={},s;e<n;++e){if(!(s=arguments[e]+"")||s in r||/[\s.]/.test(s))throw new Error("illegal type: "+s);r[s]=[]}return new Hl(r)}function Hl(e){this._=e}function FR(e,n){return e.trim().split(/^|\s+/).map(function(r){var s="",o=r.indexOf(".");if(o>=0&&(s=r.slice(o+1),r=r.slice(0,o)),r&&!n.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:s}})}Hl.prototype=lu.prototype={constructor:Hl,on:function(e,n){var r=this._,s=FR(e+"",r),o,l=-1,u=s.length;if(arguments.length<2){for(;++l<u;)if((o=(e=s[l]).type)&&(o=zR(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=s[l]).type)r[o]=_w(r[o],e.name,n);else if(n==null)for(o in r)r[o]=_w(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 Hl(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var r=new Array(o),s=0,o,l;s<o;++s)r[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],s=0,o=l.length;s<o;++s)l[s].value.apply(n,r)},apply:function(e,n,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],o=0,l=s.length;o<l;++o)s[o].value.apply(n,r)}};function zR(e,n){for(var r=0,s=e.length,o;r<s;++r)if((o=e[r]).name===n)return o.value}function _w(e,n,r){for(var s=0,o=e.length;s<o;++s)if(e[s].name===n){e[s]=DR,e=e.slice(0,s).concat(e.slice(s+1));break}return r!=null&&e.push({name:n,value:r}),e}var Dg="http://www.w3.org/1999/xhtml";const bw={svg:"http://www.w3.org/2000/svg",xhtml:Dg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function uu(e){var n=e+="",r=n.indexOf(":");return r>=0&&(n=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),bw.hasOwnProperty(n)?{space:bw[n],local:e}:e}function BR(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===Dg&&n.documentElement.namespaceURI===Dg?n.createElement(e):n.createElementNS(r,e)}}function UR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function lE(e){var n=uu(e);return(n.local?UR:BR)(n)}function HR(){}function dv(e){return e==null?HR:function(){return this.querySelector(e)}}function WR(e){typeof e!="function"&&(e=dv(e));for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=s[o]=new Array(u),p,h,f=0;f<u;++f)(p=l[f])&&(h=e.call(p,p.__data__,f,l))&&("__data__"in p&&(h.__data__=p.__data__),c[f]=h);return new dn(s,this._parents)}function VR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function GR(){return[]}function uE(e){return e==null?GR:function(){return this.querySelectorAll(e)}}function YR(e){return function(){return VR(e.apply(this,arguments))}}function KR(e){typeof e=="function"?e=YR(e):e=uE(e);for(var n=this._groups,r=n.length,s=[],o=[],l=0;l<r;++l)for(var u=n[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&(s.push(e.call(p,p.__data__,h,u)),o.push(p));return new dn(s,o)}function cE(e){return function(){return this.matches(e)}}function dE(e){return function(n){return n.matches(e)}}var XR=Array.prototype.find;function QR(e){return function(){return XR.call(this.children,e)}}function ZR(){return this.firstElementChild}function JR(e){return this.select(e==null?ZR:QR(typeof e=="function"?e:dE(e)))}var ej=Array.prototype.filter;function tj(){return Array.from(this.children)}function nj(e){return function(){return ej.call(this.children,e)}}function rj(e){return this.selectAll(e==null?tj:nj(typeof e=="function"?e:dE(e)))}function ij(e){typeof e!="function"&&(e=cE(e));for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=s[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new dn(s,this._parents)}function fE(e){return new Array(e.length)}function sj(){return new dn(this._enter||this._groups.map(fE),this._parents)}function Kl(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Kl.prototype={constructor:Kl,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 oj(e){return function(){return e}}function aj(e,n,r,s,o,l){for(var u=0,c,p=n.length,h=l.length;u<h;++u)(c=n[u])?(c.__data__=l[u],s[u]=c):r[u]=new Kl(e,l[u]);for(;u<p;++u)(c=n[u])&&(o[u]=c)}function lj(e,n,r,s,o,l,u){var c,p,h=new Map,f=n.length,m=l.length,y=new Array(f),x;for(c=0;c<f;++c)(p=n[c])&&(y[c]=x=u.call(p,p.__data__,c,n)+"",h.has(x)?o[c]=p:h.set(x,p));for(c=0;c<m;++c)x=u.call(e,l[c],c,l)+"",(p=h.get(x))?(s[c]=p,p.__data__=l[c],h.delete(x)):r[c]=new Kl(e,l[c]);for(c=0;c<f;++c)(p=n[c])&&h.get(y[c])===p&&(o[c]=p)}function uj(e){return e.__data__}function cj(e,n){if(!arguments.length)return Array.from(this,uj);var r=n?lj:aj,s=this._parents,o=this._groups;typeof e!="function"&&(e=oj(e));for(var l=o.length,u=new Array(l),c=new Array(l),p=new Array(l),h=0;h<l;++h){var f=s[h],m=o[h],y=m.length,x=dj(e.call(f,f&&f.__data__,h,s)),N=x.length,_=c[h]=new Array(N),b=u[h]=new Array(N),S=p[h]=new Array(y);r(f,m,_,b,S,x,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 dn(u,s),u._enter=c,u._exit=p,u}function dj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function fj(){return new dn(this._exit||this._groups.map(fE),this._parents)}function hj(e,n,r){var s=this.enter(),o=this,l=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),r==null?l.remove():r(l),s&&o?s.merge(o).order():o}function pj(e){for(var n=e.selection?e.selection():e,r=this._groups,s=n._groups,o=r.length,l=s.length,u=Math.min(o,l),c=new Array(o),p=0;p<u;++p)for(var h=r[p],f=s[p],m=h.length,y=c[p]=new Array(m),x,N=0;N<m;++N)(x=h[N]||f[N])&&(y[N]=x);for(;p<o;++p)c[p]=r[p];return new dn(c,this._parents)}function mj(){for(var e=this._groups,n=-1,r=e.length;++n<r;)for(var s=e[n],o=s.length-1,l=s[o],u;--o>=0;)(u=s[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function gj(e){e||(e=vj);function n(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var r=this._groups,s=r.length,o=new Array(s),l=0;l<s;++l){for(var u=r[l],c=u.length,p=o[l]=new Array(c),h,f=0;f<c;++f)(h=u[f])&&(p[f]=h);p.sort(n)}return new dn(o,this._parents).order()}function vj(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function yj(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function wj(){return Array.from(this)}function xj(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,l=s.length;o<l;++o){var u=s[o];if(u)return u}return null}function _j(){let e=0;for(const n of this)++e;return e}function bj(){return!this.node()}function Sj(e){for(var n=this._groups,r=0,s=n.length;r<s;++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 Ej(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Nj(e,n){return function(){this.setAttribute(e,n)}}function Cj(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function Tj(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function Rj(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 jj(e,n){var r=uu(e);if(arguments.length<2){var s=this.node();return r.local?s.getAttributeNS(r.space,r.local):s.getAttribute(r)}return this.each((n==null?r.local?Ej:kj:typeof n=="function"?r.local?Rj:Tj:r.local?Cj:Nj)(r,n))}function hE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Aj(e){return function(){this.style.removeProperty(e)}}function Ij(e,n,r){return function(){this.style.setProperty(e,n,r)}}function Mj(e,n,r){return function(){var s=n.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,r)}}function Pj(e,n,r){return arguments.length>1?this.each((n==null?Aj:typeof n=="function"?Mj:Ij)(e,n,r??"")):Js(this.node(),e)}function Js(e,n){return e.style.getPropertyValue(n)||hE(e).getComputedStyle(e,null).getPropertyValue(n)}function Oj(e){return function(){delete this[e]}}function qj(e,n){return function(){this[e]=n}}function Lj(e,n){return function(){var r=n.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function $j(e,n){return arguments.length>1?this.each((n==null?Oj:typeof n=="function"?Lj:qj)(e,n)):this.node()[e]}function pE(e){return e.trim().split(/^|\s+/)}function fv(e){return e.classList||new mE(e)}function mE(e){this._node=e,this._names=pE(e.getAttribute("class")||"")}mE.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 gE(e,n){for(var r=fv(e),s=-1,o=n.length;++s<o;)r.add(n[s])}function vE(e,n){for(var r=fv(e),s=-1,o=n.length;++s<o;)r.remove(n[s])}function Dj(e){return function(){gE(this,e)}}function Fj(e){return function(){vE(this,e)}}function zj(e,n){return function(){(n.apply(this,arguments)?gE:vE)(this,e)}}function Bj(e,n){var r=pE(e+"");if(arguments.length<2){for(var s=fv(this.node()),o=-1,l=r.length;++o<l;)if(!s.contains(r[o]))return!1;return!0}return this.each((typeof n=="function"?zj:n?Dj:Fj)(r,n))}function Uj(){this.textContent=""}function Hj(e){return function(){this.textContent=e}}function Wj(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function Vj(e){return arguments.length?this.each(e==null?Uj:(typeof e=="function"?Wj:Hj)(e)):this.node().textContent}function Gj(){this.innerHTML=""}function Yj(e){return function(){this.innerHTML=e}}function Kj(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function Xj(e){return arguments.length?this.each(e==null?Gj:(typeof e=="function"?Kj:Yj)(e)):this.node().innerHTML}function Qj(){this.nextSibling&&this.parentNode.appendChild(this)}function Zj(){return this.each(Qj)}function Jj(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function e2(){return this.each(Jj)}function t2(e){var n=typeof e=="function"?e:lE(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function n2(){return null}function r2(e,n){var r=typeof e=="function"?e:lE(e),s=n==null?n2:typeof n=="function"?n:dv(n);return this.select(function(){return this.insertBefore(r.apply(this,arguments),s.apply(this,arguments)||null)})}function i2(){var e=this.parentNode;e&&e.removeChild(this)}function s2(){return this.each(i2)}function o2(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function a2(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function l2(e){return this.select(e?a2:o2)}function u2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function c2(e){return function(n){e.call(this,n,this.__data__)}}function d2(e){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");return s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),{type:n,name:r}})}function f2(e){return function(){var n=this.__on;if(n){for(var r=0,s=-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[++s]=l;++s?n.length=s:delete this.__on}}}function h2(e,n,r){return function(){var s=this.__on,o,l=c2(n);if(s){for(var u=0,c=s.length;u<c;++u)if((o=s[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},s?s.push(o):this.__on=[o]}}function p2(e,n,r){var s=d2(e+""),o,l=s.length,u;if(arguments.length<2){var c=this.node().__on;if(c){for(var p=0,h=c.length,f;p<h;++p)for(o=0,f=c[p];o<l;++o)if((u=s[o]).type===f.type&&u.name===f.name)return f.value}return}for(c=n?h2:f2,o=0;o<l;++o)this.each(c(s[o],n,r));return this}function yE(e,n,r){var s=hE(e),o=s.CustomEvent;typeof o=="function"?o=new o(n,r):(o=s.document.createEvent("Event"),r?(o.initEvent(n,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function m2(e,n){return function(){return yE(this,e,n)}}function g2(e,n){return function(){return yE(this,e,n.apply(this,arguments))}}function v2(e,n){return this.each((typeof n=="function"?g2:m2)(e,n))}function*y2(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var s=e[n],o=0,l=s.length,u;o<l;++o)(u=s[o])&&(yield u)}var wE=[null];function dn(e,n){this._groups=e,this._parents=n}function ga(){return new dn([[document.documentElement]],wE)}function w2(){return this}dn.prototype=ga.prototype={constructor:dn,select:WR,selectAll:KR,selectChild:JR,selectChildren:rj,filter:ij,data:cj,enter:sj,exit:fj,join:hj,merge:pj,selection:w2,order:mj,sort:gj,call:yj,nodes:wj,node:xj,size:_j,empty:bj,each:Sj,attr:jj,style:Pj,property:$j,classed:Bj,text:Vj,html:Xj,raise:Zj,lower:e2,append:t2,insert:r2,remove:s2,clone:l2,datum:u2,on:p2,dispatch:v2,[Symbol.iterator]:y2};function kn(e){return typeof e=="string"?new dn([[document.querySelector(e)]],[document.documentElement]):new dn([[e]],wE)}function x2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Vn(e,n){if(e=x2(e),n===void 0&&(n=e.currentTarget),n){var r=n.ownerSVGElement||n;if(r.createSVGPoint){var s=r.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(n.getScreenCTM().inverse()),[s.x,s.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 _2={passive:!1},sa={capture:!0,passive:!1};function ud(e){e.stopImmediatePropagation()}function Ks(e){e.preventDefault(),e.stopImmediatePropagation()}function xE(e){var n=e.document.documentElement,r=kn(e).on("dragstart.drag",Ks,sa);"onselectstart"in n?r.on("selectstart.drag",Ks,sa):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function _E(e,n){var r=e.document.documentElement,s=kn(e).on("dragstart.drag",null);n&&(s.on("click.drag",Ks,sa),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in r?s.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Tl=e=>()=>e;function Fg(e,{sourceEvent:n,subject:r,target:s,identifier:o,active:l,x:u,y:c,dx:p,dy:h,dispatch:f}){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:s,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:p,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Fg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function b2(e){return!e.ctrlKey&&!e.button}function S2(){return this.parentNode}function k2(e,n){return n??{x:e.x,y:e.y}}function E2(){return navigator.maxTouchPoints||"ontouchstart"in this}function N2(){var e=b2,n=S2,r=k2,s=E2,o={},l=lu("start","drag","end"),u=0,c,p,h,f,m=0;function y(C){C.on("mousedown.drag",x).filter(s).on("touchstart.drag",b).on("touchmove.drag",S,_2).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(C,I){if(!(f||!e.call(this,C,I))){var M=E(this,n.call(this,C,I),C,I,"mouse");M&&(kn(C.view).on("mousemove.drag",N,sa).on("mouseup.drag",_,sa),xE(C.view),ud(C),h=!1,c=C.clientX,p=C.clientY,M("start",C))}}function N(C){if(Ks(C),!h){var I=C.clientX-c,M=C.clientY-p;h=I*I+M*M>m}o.mouse("drag",C)}function _(C){kn(C.view).on("mousemove.drag mouseup.drag",null),_E(C.view,h),Ks(C),o.mouse("end",C)}function b(C,I){if(e.call(this,C,I)){var M=C.changedTouches,O=n.call(this,C,I),W=M.length,q,P;for(q=0;q<W;++q)(P=E(this,O,C,I,M[q].identifier,M[q]))&&(ud(C),P("start",C,M[q]))}}function S(C){var I=C.changedTouches,M=I.length,O,W;for(O=0;O<M;++O)(W=o[I[O].identifier])&&(Ks(C),W("drag",C,I[O]))}function k(C){var I=C.changedTouches,M=I.length,O,W;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),O=0;O<M;++O)(W=o[I[O].identifier])&&(ud(C),W("end",C,I[O]))}function E(C,I,M,O,W,q){var P=l.copy(),L=Vn(q||M,I),U,B,j;if((j=r.call(C,new Fg("beforestart",{sourceEvent:M,target:y,identifier:W,active:u,x:L[0],y:L[1],dx:0,dy:0,dispatch:P}),O))!=null)return U=j.x-L[0]||0,B=j.y-L[1]||0,function Q(H,te,Z){var D=L,X;switch(H){case"start":o[W]=Q,X=u++;break;case"end":delete o[W],--u;case"drag":L=Vn(Z||te,I),X=u;break}P.call(H,C,new Fg(H,{sourceEvent:te,subject:j,target:y,identifier:W,active:X,x:L[0]+U,y:L[1]+B,dx:L[0]-D[0],dy:L[1]-D[1],dispatch:P}),O)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Tl(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:Tl(C),y):n},y.subject=function(C){return arguments.length?(r=typeof C=="function"?C:Tl(C),y):r},y.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:Tl(!!C),y):s},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 hv(e,n,r){e.prototype=n.prototype=r,r.constructor=e}function bE(e,n){var r=Object.create(e.prototype);for(var s in n)r[s]=n[s];return r}function va(){}var oa=.7,Xl=1/oa,Xs="\\s*([+-]?\\d+)\\s*",aa="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",cr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",C2=/^#([0-9a-f]{3,8})$/,T2=new RegExp(`^rgb\\(${Xs},${Xs},${Xs}\\)$`),R2=new RegExp(`^rgb\\(${cr},${cr},${cr}\\)$`),j2=new RegExp(`^rgba\\(${Xs},${Xs},${Xs},${aa}\\)$`),A2=new RegExp(`^rgba\\(${cr},${cr},${cr},${aa}\\)$`),I2=new RegExp(`^hsl\\(${aa},${cr},${cr}\\)$`),M2=new RegExp(`^hsla\\(${aa},${cr},${cr},${aa}\\)$`),Sw={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};hv(va,la,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:kw,formatHex:kw,formatHex8:P2,formatHsl:O2,formatRgb:Ew,toString:Ew});function kw(){return this.rgb().formatHex()}function P2(){return this.rgb().formatHex8()}function O2(){return SE(this).formatHsl()}function Ew(){return this.rgb().formatRgb()}function la(e){var n,r;return e=(e+"").trim().toLowerCase(),(n=C2.exec(e))?(r=n[1].length,n=parseInt(n[1],16),r===6?Nw(n):r===3?new rn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?Rl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?Rl(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=T2.exec(e))?new rn(n[1],n[2],n[3],1):(n=R2.exec(e))?new rn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=j2.exec(e))?Rl(n[1],n[2],n[3],n[4]):(n=A2.exec(e))?Rl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=I2.exec(e))?Rw(n[1],n[2]/100,n[3]/100,1):(n=M2.exec(e))?Rw(n[1],n[2]/100,n[3]/100,n[4]):Sw.hasOwnProperty(e)?Nw(Sw[e]):e==="transparent"?new rn(NaN,NaN,NaN,0):null}function Nw(e){return new rn(e>>16&255,e>>8&255,e&255,1)}function Rl(e,n,r,s){return s<=0&&(e=n=r=NaN),new rn(e,n,r,s)}function q2(e){return e instanceof va||(e=la(e)),e?(e=e.rgb(),new rn(e.r,e.g,e.b,e.opacity)):new rn}function zg(e,n,r,s){return arguments.length===1?q2(e):new rn(e,n,r,s??1)}function rn(e,n,r,s){this.r=+e,this.g=+n,this.b=+r,this.opacity=+s}hv(rn,zg,bE(va,{brighter(e){return e=e==null?Xl:Math.pow(Xl,e),new rn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?oa:Math.pow(oa,e),new rn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new rn(Ji(this.r),Ji(this.g),Ji(this.b),Ql(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:Cw,formatHex:Cw,formatHex8:L2,formatRgb:Tw,toString:Tw}));function Cw(){return`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}`}function L2(){return`#${Qi(this.r)}${Qi(this.g)}${Qi(this.b)}${Qi((isNaN(this.opacity)?1:this.opacity)*255)}`}function Tw(){const e=Ql(this.opacity);return`${e===1?"rgb(":"rgba("}${Ji(this.r)}, ${Ji(this.g)}, ${Ji(this.b)}${e===1?")":`, ${e})`}`}function Ql(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ji(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Qi(e){return e=Ji(e),(e<16?"0":"")+e.toString(16)}function Rw(e,n,r,s){return s<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new Gn(e,n,r,s)}function SE(e){if(e instanceof Gn)return new Gn(e.h,e.s,e.l,e.opacity);if(e instanceof va||(e=la(e)),!e)return new Gn;if(e instanceof Gn)return e;e=e.rgb();var n=e.r/255,r=e.g/255,s=e.b/255,o=Math.min(n,r,s),l=Math.max(n,r,s),u=NaN,c=l-o,p=(l+o)/2;return c?(n===l?u=(r-s)/c+(r<s)*6:r===l?u=(s-n)/c+2:u=(n-r)/c+4,c/=p<.5?l+o:2-l-o,u*=60):c=p>0&&p<1?0:u,new Gn(u,c,p,e.opacity)}function $2(e,n,r,s){return arguments.length===1?SE(e):new Gn(e,n,r,s??1)}function Gn(e,n,r,s){this.h=+e,this.s=+n,this.l=+r,this.opacity=+s}hv(Gn,$2,bE(va,{brighter(e){return e=e==null?Xl:Math.pow(Xl,e),new Gn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oa:Math.pow(oa,e),new Gn(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,s=r+(r<.5?r:1-r)*n,o=2*r-s;return new rn(cd(e>=240?e-240:e+120,o,s),cd(e,o,s),cd(e<120?e+240:e-120,o,s),this.opacity)},clamp(){return new Gn(jw(this.h),jl(this.s),jl(this.l),Ql(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=Ql(this.opacity);return`${e===1?"hsl(":"hsla("}${jw(this.h)}, ${jl(this.s)*100}%, ${jl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function jw(e){return e=(e||0)%360,e<0?e+360:e}function jl(e){return Math.max(0,Math.min(1,e||0))}function cd(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 kE=e=>()=>e;function D2(e,n){return function(r){return e+r*n}}function F2(e,n,r){return e=Math.pow(e,r),n=Math.pow(n,r)-e,r=1/r,function(s){return Math.pow(e+s*n,r)}}function z2(e){return(e=+e)==1?EE:function(n,r){return r-n?F2(n,r,e):kE(isNaN(n)?r:n)}}function EE(e,n){var r=n-e;return r?D2(e,r):kE(isNaN(e)?n:e)}const Aw=(function e(n){var r=z2(n);function s(o,l){var u=r((o=zg(o)).r,(l=zg(l)).r),c=r(o.g,l.g),p=r(o.b,l.b),h=EE(o.opacity,l.opacity);return function(f){return o.r=u(f),o.g=c(f),o.b=p(f),o.opacity=h(f),o+""}}return s.gamma=e,s})(1);function di(e,n){return e=+e,n=+n,function(r){return e*(1-r)+n*r}}var Bg=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,dd=new RegExp(Bg.source,"g");function B2(e){return function(){return e}}function U2(e){return function(n){return e(n)+""}}function H2(e,n){var r=Bg.lastIndex=dd.lastIndex=0,s,o,l,u=-1,c=[],p=[];for(e=e+"",n=n+"";(s=Bg.exec(e))&&(o=dd.exec(n));)(l=o.index)>r&&(l=n.slice(r,l),c[u]?c[u]+=l:c[++u]=l),(s=s[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,p.push({i:u,x:di(s,o)})),r=dd.lastIndex;return r<n.length&&(l=n.slice(r),c[u]?c[u]+=l:c[++u]=l),c.length<2?p[0]?U2(p[0].x):B2(n):(n=p.length,function(h){for(var f=0,m;f<n;++f)c[(m=p[f]).i]=m.x(h);return c.join("")})}var Iw=180/Math.PI,Ug={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function NE(e,n,r,s,o,l){var u,c,p;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(p=e*r+n*s)&&(r-=e*p,s-=n*p),(c=Math.sqrt(r*r+s*s))&&(r/=c,s/=c,p/=c),e*s<n*r&&(e=-e,n=-n,p=-p,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*Iw,skewX:Math.atan(p)*Iw,scaleX:u,scaleY:c}}var Al;function W2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Ug:NE(n.a,n.b,n.c,n.d,n.e,n.f)}function V2(e){return e==null||(Al||(Al=document.createElementNS("http://www.w3.org/2000/svg","g")),Al.setAttribute("transform",e),!(e=Al.transform.baseVal.consolidate()))?Ug:(e=e.matrix,NE(e.a,e.b,e.c,e.d,e.e,e.f))}function CE(e,n,r,s){function o(h){return h.length?h.pop()+" ":""}function l(h,f,m,y,x,N){if(h!==m||f!==y){var _=x.push("translate(",null,n,null,r);N.push({i:_-4,x:di(h,m)},{i:_-2,x:di(f,y)})}else(m||y)&&x.push("translate("+m+n+y+r)}function u(h,f,m,y){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),y.push({i:m.push(o(m)+"rotate(",null,s)-2,x:di(h,f)})):f&&m.push(o(m)+"rotate("+f+s)}function c(h,f,m,y){h!==f?y.push({i:m.push(o(m)+"skewX(",null,s)-2,x:di(h,f)}):f&&m.push(o(m)+"skewX("+f+s)}function p(h,f,m,y,x,N){if(h!==m||f!==y){var _=x.push(o(x)+"scale(",null,",",null,")");N.push({i:_-4,x:di(h,m)},{i:_-2,x:di(f,y)})}else(m!==1||y!==1)&&x.push(o(x)+"scale("+m+","+y+")")}return function(h,f){var m=[],y=[];return h=e(h),f=e(f),l(h.translateX,h.translateY,f.translateX,f.translateY,m,y),u(h.rotate,f.rotate,m,y),c(h.skewX,f.skewX,m,y),p(h.scaleX,h.scaleY,f.scaleX,f.scaleY,m,y),h=f=null,function(x){for(var N=-1,_=y.length,b;++N<_;)m[(b=y[N]).i]=b.x(x);return m.join("")}}}var G2=CE(W2,"px, ","px)","deg)"),Y2=CE(V2,", ",")",")"),K2=1e-12;function Mw(e){return((e=Math.exp(e))+1/e)/2}function X2(e){return((e=Math.exp(e))-1/e)/2}function Q2(e){return((e=Math.exp(2*e))-1)/(e+1)}const Z2=(function e(n,r,s){function o(l,u){var c=l[0],p=l[1],h=l[2],f=u[0],m=u[1],y=u[2],x=f-c,N=m-p,_=x*x+N*N,b,S;if(_<K2)S=Math.log(y/h)/n,b=function(O){return[c+O*x,p+O*N,h*Math.exp(n*O*S)]};else{var k=Math.sqrt(_),E=(y*y-h*h+s*_)/(2*h*r*k),C=(y*y-h*h-s*_)/(2*y*r*k),I=Math.log(Math.sqrt(E*E+1)-E),M=Math.log(Math.sqrt(C*C+1)-C);S=(M-I)/n,b=function(O){var W=O*S,q=Mw(I),P=h/(r*k)*(q*Q2(n*W+I)-X2(I));return[c+P*x,p+P*N,h*q/Mw(n*W+I)]}}return b.duration=S*1e3*n/Math.SQRT2,b}return o.rho=function(l){var u=Math.max(.001,+l),c=u*u,p=c*c;return e(u,c,p)},o})(Math.SQRT2,2,4);var eo=0,Jo=0,Go=0,TE=1e3,Zl,ea,Jl=0,ts=0,cu=0,ua=typeof performance=="object"&&performance.now?performance:Date,RE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function pv(){return ts||(RE(J2),ts=ua.now()+cu)}function J2(){ts=0}function eu(){this._call=this._time=this._next=null}eu.prototype=jE.prototype={constructor:eu,restart:function(e,n,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?pv():+r)+(n==null?0:+n),!this._next&&ea!==this&&(ea?ea._next=this:Zl=this,ea=this),this._call=e,this._time=r,Hg()},stop:function(){this._call&&(this._call=null,this._time=1/0,Hg())}};function jE(e,n,r){var s=new eu;return s.restart(e,n,r),s}function eA(){pv(),++eo;for(var e=Zl,n;e;)(n=ts-e._time)>=0&&e._call.call(void 0,n),e=e._next;--eo}function Pw(){ts=(Jl=ua.now())+cu,eo=Jo=0;try{eA()}finally{eo=0,nA(),ts=0}}function tA(){var e=ua.now(),n=e-Jl;n>TE&&(cu-=n,Jl=e)}function nA(){for(var e,n=Zl,r,s=1/0;n;)n._call?(s>n._time&&(s=n._time),e=n,n=n._next):(r=n._next,n._next=null,n=e?e._next=r:Zl=r);ea=e,Hg(s)}function Hg(e){if(!eo){Jo&&(Jo=clearTimeout(Jo));var n=e-ts;n>24?(e<1/0&&(Jo=setTimeout(Pw,e-ua.now()-cu)),Go&&(Go=clearInterval(Go))):(Go||(Jl=ua.now(),Go=setInterval(tA,TE)),eo=1,RE(Pw))}}function Ow(e,n,r){var s=new eu;return n=n==null?0:+n,s.restart(o=>{s.stop(),e(o+n)},n,r),s}var rA=lu("start","end","cancel","interrupt"),iA=[],AE=0,qw=1,Wg=2,Wl=3,Lw=4,Vg=5,Vl=6;function du(e,n,r,s,o,l){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;sA(e,r,{name:n,index:s,group:o,on:rA,tween:iA,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:AE})}function mv(e,n){var r=Xn(e,n);if(r.state>AE)throw new Error("too late; already scheduled");return r}function dr(e,n){var r=Xn(e,n);if(r.state>Wl)throw new Error("too late; already running");return r}function Xn(e,n){var r=e.__transition;if(!r||!(r=r[n]))throw new Error("transition not found");return r}function sA(e,n,r){var s=e.__transition,o;s[n]=r,r.timer=jE(l,0,r.time);function l(h){r.state=qw,r.timer.restart(u,r.delay,r.time),r.delay<=h&&u(h-r.delay)}function u(h){var f,m,y,x;if(r.state!==qw)return p();for(f in s)if(x=s[f],x.name===r.name){if(x.state===Wl)return Ow(u);x.state===Lw?(x.state=Vl,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete s[f]):+f<n&&(x.state=Vl,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete s[f])}if(Ow(function(){r.state===Wl&&(r.state=Lw,r.timer.restart(c,r.delay,r.time),c(h))}),r.state=Wg,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Wg){for(r.state=Wl,o=new Array(y=r.tween.length),f=0,m=-1;f<y;++f)(x=r.tween[f].value.call(e,e.__data__,r.index,r.group))&&(o[++m]=x);o.length=m+1}}function c(h){for(var f=h<r.duration?r.ease.call(null,h/r.duration):(r.timer.restart(p),r.state=Vg,1),m=-1,y=o.length;++m<y;)o[m].call(e,f);r.state===Vg&&(r.on.call("end",e,e.__data__,r.index,r.group),p())}function p(){r.state=Vl,r.timer.stop(),delete s[n];for(var h in s)return;delete e.__transition}}function Gl(e,n){var r=e.__transition,s,o,l=!0,u;if(r){n=n==null?null:n+"";for(u in r){if((s=r[u]).name!==n){l=!1;continue}o=s.state>Wg&&s.state<Vg,s.state=Vl,s.timer.stop(),s.on.call(o?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete r[u]}l&&delete e.__transition}}function oA(e){return this.each(function(){Gl(this,e)})}function aA(e,n){var r,s;return function(){var o=dr(this,e),l=o.tween;if(l!==r){s=r=l;for(var u=0,c=s.length;u<c;++u)if(s[u].name===n){s=s.slice(),s.splice(u,1);break}}o.tween=s}}function lA(e,n,r){var s,o;if(typeof r!="function")throw new Error;return function(){var l=dr(this,e),u=l.tween;if(u!==s){o=(s=u).slice();for(var c={name:n,value:r},p=0,h=o.length;p<h;++p)if(o[p].name===n){o[p]=c;break}p===h&&o.push(c)}l.tween=o}}function uA(e,n){var r=this._id;if(e+="",arguments.length<2){for(var s=Xn(this.node(),r).tween,o=0,l=s.length,u;o<l;++o)if((u=s[o]).name===e)return u.value;return null}return this.each((n==null?aA:lA)(r,e,n))}function gv(e,n,r){var s=e._id;return e.each(function(){var o=dr(this,s);(o.value||(o.value={}))[n]=r.apply(this,arguments)}),function(o){return Xn(o,s).value[n]}}function IE(e,n){var r;return(typeof n=="number"?di:n instanceof la?Aw:(r=la(n))?(n=r,Aw):H2)(e,n)}function cA(e){return function(){this.removeAttribute(e)}}function dA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fA(e,n,r){var s,o=r+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===s?l:l=n(s=u,r)}}function hA(e,n,r){var s,o=r+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===s?l:l=n(s=u,r)}}function pA(e,n,r){var s,o,l;return function(){var u,c=r(this),p;return c==null?void this.removeAttribute(e):(u=this.getAttribute(e),p=c+"",u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c)))}}function mA(e,n,r){var s,o,l;return function(){var u,c=r(this),p;return c==null?void this.removeAttributeNS(e.space,e.local):(u=this.getAttributeNS(e.space,e.local),p=c+"",u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c)))}}function gA(e,n){var r=uu(e),s=r==="transform"?Y2:IE;return this.attrTween(e,typeof n=="function"?(r.local?mA:pA)(r,s,gv(this,"attr."+e,n)):n==null?(r.local?dA:cA)(r):(r.local?hA:fA)(r,s,n))}function vA(e,n){return function(r){this.setAttribute(e,n.call(this,r))}}function yA(e,n){return function(r){this.setAttributeNS(e.space,e.local,n.call(this,r))}}function wA(e,n){var r,s;function o(){var l=n.apply(this,arguments);return l!==s&&(r=(s=l)&&yA(e,l)),r}return o._value=n,o}function xA(e,n){var r,s;function o(){var l=n.apply(this,arguments);return l!==s&&(r=(s=l)&&vA(e,l)),r}return o._value=n,o}function _A(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 s=uu(e);return this.tween(r,(s.local?wA:xA)(s,n))}function bA(e,n){return function(){mv(this,e).delay=+n.apply(this,arguments)}}function SA(e,n){return n=+n,function(){mv(this,e).delay=n}}function kA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?bA:SA)(n,e)):Xn(this.node(),n).delay}function EA(e,n){return function(){dr(this,e).duration=+n.apply(this,arguments)}}function NA(e,n){return n=+n,function(){dr(this,e).duration=n}}function CA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?EA:NA)(n,e)):Xn(this.node(),n).duration}function TA(e,n){if(typeof n!="function")throw new Error;return function(){dr(this,e).ease=n}}function RA(e){var n=this._id;return arguments.length?this.each(TA(n,e)):Xn(this.node(),n).ease}function jA(e,n){return function(){var r=n.apply(this,arguments);if(typeof r!="function")throw new Error;dr(this,e).ease=r}}function AA(e){if(typeof e!="function")throw new Error;return this.each(jA(this._id,e))}function IA(e){typeof e!="function"&&(e=cE(e));for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=s[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new Mr(s,this._parents,this._name,this._id)}function MA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,r=e._groups,s=n.length,o=r.length,l=Math.min(s,o),u=new Array(s),c=0;c<l;++c)for(var p=n[c],h=r[c],f=p.length,m=u[c]=new Array(f),y,x=0;x<f;++x)(y=p[x]||h[x])&&(m[x]=y);for(;c<s;++c)u[c]=n[c];return new Mr(u,this._parents,this._name,this._id)}function PA(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 OA(e,n,r){var s,o,l=PA(n)?mv:dr;return function(){var u=l(this,e),c=u.on;c!==s&&(o=(s=c).copy()).on(n,r),u.on=o}}function qA(e,n){var r=this._id;return arguments.length<2?Xn(this.node(),r).on.on(e):this.each(OA(r,e,n))}function LA(e){return function(){var n=this.parentNode;for(var r in this.__transition)if(+r!==e)return;n&&n.removeChild(this)}}function $A(){return this.on("end.remove",LA(this._id))}function DA(e){var n=this._name,r=this._id;typeof e!="function"&&(e=dv(e));for(var s=this._groups,o=s.length,l=new Array(o),u=0;u<o;++u)for(var c=s[u],p=c.length,h=l[u]=new Array(p),f,m,y=0;y<p;++y)(f=c[y])&&(m=e.call(f,f.__data__,y,c))&&("__data__"in f&&(m.__data__=f.__data__),h[y]=m,du(h[y],n,r,y,h,Xn(f,r)));return new Mr(l,this._parents,n,r)}function FA(e){var n=this._name,r=this._id;typeof e!="function"&&(e=uE(e));for(var s=this._groups,o=s.length,l=[],u=[],c=0;c<o;++c)for(var p=s[c],h=p.length,f,m=0;m<h;++m)if(f=p[m]){for(var y=e.call(f,f.__data__,m,p),x,N=Xn(f,r),_=0,b=y.length;_<b;++_)(x=y[_])&&du(x,n,r,_,y,N);l.push(y),u.push(f)}return new Mr(l,u,n,r)}var zA=ga.prototype.constructor;function BA(){return new zA(this._groups,this._parents)}function UA(e,n){var r,s,o;return function(){var l=Js(this,e),u=(this.style.removeProperty(e),Js(this,e));return l===u?null:l===r&&u===s?o:o=n(r=l,s=u)}}function ME(e){return function(){this.style.removeProperty(e)}}function HA(e,n,r){var s,o=r+"",l;return function(){var u=Js(this,e);return u===o?null:u===s?l:l=n(s=u,r)}}function WA(e,n,r){var s,o,l;return function(){var u=Js(this,e),c=r(this),p=c+"";return c==null&&(p=c=(this.style.removeProperty(e),Js(this,e))),u===p?null:u===s&&p===o?l:(o=p,l=n(s=u,c))}}function VA(e,n){var r,s,o,l="style."+n,u="end."+l,c;return function(){var p=dr(this,e),h=p.on,f=p.value[l]==null?c||(c=ME(n)):void 0;(h!==r||o!==f)&&(s=(r=h).copy()).on(u,o=f),p.on=s}}function GA(e,n,r){var s=(e+="")=="transform"?G2:IE;return n==null?this.styleTween(e,UA(e,s)).on("end.style."+e,ME(e)):typeof n=="function"?this.styleTween(e,WA(e,s,gv(this,"style."+e,n))).each(VA(this._id,e)):this.styleTween(e,HA(e,s,n),r).on("end.style."+e,null)}function YA(e,n,r){return function(s){this.style.setProperty(e,n.call(this,s),r)}}function KA(e,n,r){var s,o;function l(){var u=n.apply(this,arguments);return u!==o&&(s=(o=u)&&YA(e,u,r)),s}return l._value=n,l}function XA(e,n,r){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(n==null)return this.tween(s,null);if(typeof n!="function")throw new Error;return this.tween(s,KA(e,n,r??""))}function QA(e){return function(){this.textContent=e}}function ZA(e){return function(){var n=e(this);this.textContent=n??""}}function JA(e){return this.tween("text",typeof e=="function"?ZA(gv(this,"text",e)):QA(e==null?"":e+""))}function eI(e){return function(n){this.textContent=e.call(this,n)}}function tI(e){var n,r;function s(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&eI(o)),n}return s._value=e,s}function nI(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,tI(e))}function rI(){for(var e=this._name,n=this._id,r=PE(),s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,p,h=0;h<c;++h)if(p=u[h]){var f=Xn(p,n);du(p,e,r,h,u,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Mr(s,this._parents,e,r)}function iI(){var e,n,r=this,s=r._id,o=r.size();return new Promise(function(l,u){var c={value:u},p={value:function(){--o===0&&l()}};r.each(function(){var h=dr(this,s),f=h.on;f!==e&&(n=(e=f).copy(),n._.cancel.push(c),n._.interrupt.push(c),n._.end.push(p)),h.on=n}),o===0&&l()})}var sI=0;function Mr(e,n,r,s){this._groups=e,this._parents=n,this._name=r,this._id=s}function PE(){return++sI}var Rr=ga.prototype;Mr.prototype={constructor:Mr,select:DA,selectAll:FA,selectChild:Rr.selectChild,selectChildren:Rr.selectChildren,filter:IA,merge:MA,selection:BA,transition:rI,call:Rr.call,nodes:Rr.nodes,node:Rr.node,size:Rr.size,empty:Rr.empty,each:Rr.each,on:qA,attr:gA,attrTween:_A,style:GA,styleTween:XA,text:JA,textTween:nI,remove:$A,tween:uA,delay:kA,duration:CA,ease:RA,easeVarying:AA,end:iI,[Symbol.iterator]:Rr[Symbol.iterator]};function oI(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var aI={time:null,delay:0,duration:250,ease:oI};function lI(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 uI(e){var n,r;e instanceof Mr?(n=e._id,e=e._name):(n=PE(),(r=aI).time=pv(),e=e==null?null:e+"");for(var s=this._groups,o=s.length,l=0;l<o;++l)for(var u=s[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&du(p,e,n,h,u,r||lI(p,n));return new Mr(s,this._parents,e,n)}ga.prototype.interrupt=oA;ga.prototype.transition=uI;const Il=e=>()=>e;function cI(e,{sourceEvent:n,target:r,transform:s,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:s,enumerable:!0,configurable:!0},_:{value:o}})}function Ar(e,n,r){this.k=e,this.x=n,this.y=r}Ar.prototype={constructor:Ar,scale:function(e){return e===1?this:new Ar(this.k*e,this.x,this.y)},translate:function(e,n){return e===0&n===0?this:new Ar(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 Ir=new Ar(1,0,0);Ar.prototype;function fd(e){e.stopImmediatePropagation()}function Yo(e){e.preventDefault(),e.stopImmediatePropagation()}function dI(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function fI(){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 $w(){return this.__zoom||Ir}function hI(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function pI(){return navigator.maxTouchPoints||"ontouchstart"in this}function mI(e,n,r){var s=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>s?(s+o)/2:Math.min(0,s)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function OE(){var e=dI,n=fI,r=mI,s=hI,o=pI,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,p=Z2,h=lu("start","zoom","end"),f,m,y,x=500,N=150,_=0,b=10;function S(j){j.property("__zoom",$w).on("wheel.zoom",W,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",P).filter(o).on("touchstart.zoom",L).on("touchmove.zoom",U).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}S.transform=function(j,Q,H,te){var Z=j.selection?j.selection():j;Z.property("__zoom",$w),j!==Z?I(j,Q,H,te):Z.interrupt().each(function(){M(this,arguments).event(te).start().zoom(null,typeof Q=="function"?Q.apply(this,arguments):Q).end()})},S.scaleBy=function(j,Q,H,te){S.scaleTo(j,function(){var Z=this.__zoom.k,D=typeof Q=="function"?Q.apply(this,arguments):Q;return Z*D},H,te)},S.scaleTo=function(j,Q,H,te){S.transform(j,function(){var Z=n.apply(this,arguments),D=this.__zoom,X=H==null?C(Z):typeof H=="function"?H.apply(this,arguments):H,R=D.invert(X),$=typeof Q=="function"?Q.apply(this,arguments):Q;return r(E(k(D,$),X,R),Z,u)},H,te)},S.translateBy=function(j,Q,H,te){S.transform(j,function(){return r(this.__zoom.translate(typeof Q=="function"?Q.apply(this,arguments):Q,typeof H=="function"?H.apply(this,arguments):H),n.apply(this,arguments),u)},null,te)},S.translateTo=function(j,Q,H,te,Z){S.transform(j,function(){var D=n.apply(this,arguments),X=this.__zoom,R=te==null?C(D):typeof te=="function"?te.apply(this,arguments):te;return r(Ir.translate(R[0],R[1]).scale(X.k).translate(typeof Q=="function"?-Q.apply(this,arguments):-Q,typeof H=="function"?-H.apply(this,arguments):-H),D,u)},te,Z)};function k(j,Q){return Q=Math.max(l[0],Math.min(l[1],Q)),Q===j.k?j:new Ar(Q,j.x,j.y)}function E(j,Q,H){var te=Q[0]-H[0]*j.k,Z=Q[1]-H[1]*j.k;return te===j.x&&Z===j.y?j:new Ar(j.k,te,Z)}function C(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function I(j,Q,H,te){j.on("start.zoom",function(){M(this,arguments).event(te).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(te).end()}).tween("zoom",function(){var Z=this,D=arguments,X=M(Z,D).event(te),R=n.apply(Z,D),$=H==null?C(R):typeof H=="function"?H.apply(Z,D):H,V=Math.max(R[1][0]-R[0][0],R[1][1]-R[0][1]),F=Z.__zoom,J=typeof Q=="function"?Q.apply(Z,D):Q,ne=p(F.invert($).concat(V/F.k),J.invert($).concat(V/J.k));return function(le){if(le===1)le=J;else{var de=ne(le),me=V/de[2];le=new Ar(me,$[0]-de[0]*me,$[1]-de[1]*me)}X.zoom(null,le)}})}function M(j,Q,H){return!H&&j.__zooming||new O(j,Q)}function O(j,Q){this.that=j,this.args=Q,this.active=0,this.sourceEvent=null,this.extent=n.apply(j,Q),this.taps=0}O.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=kn(this.that).datum();h.call(j,this.that,new cI(j,{sourceEvent:this.sourceEvent,target:S,transform:this.that.__zoom,dispatch:h}),Q)}};function W(j,...Q){if(!e.apply(this,arguments))return;var H=M(this,Q).event(j),te=this.__zoom,Z=Math.max(l[0],Math.min(l[1],te.k*Math.pow(2,s.apply(this,arguments)))),D=Vn(j);if(H.wheel)(H.mouse[0][0]!==D[0]||H.mouse[0][1]!==D[1])&&(H.mouse[1]=te.invert(H.mouse[0]=D)),clearTimeout(H.wheel);else{if(te.k===Z)return;H.mouse=[D,te.invert(D)],Gl(this),H.start()}Yo(j),H.wheel=setTimeout(X,N),H.zoom("mouse",r(E(k(te,Z),H.mouse[0],H.mouse[1]),H.extent,u));function X(){H.wheel=null,H.end()}}function q(j,...Q){if(y||!e.apply(this,arguments))return;var H=j.currentTarget,te=M(this,Q,!0).event(j),Z=kn(j.view).on("mousemove.zoom",$,!0).on("mouseup.zoom",V,!0),D=Vn(j,H),X=j.clientX,R=j.clientY;xE(j.view),fd(j),te.mouse=[D,this.__zoom.invert(D)],Gl(this),te.start();function $(F){if(Yo(F),!te.moved){var J=F.clientX-X,ne=F.clientY-R;te.moved=J*J+ne*ne>_}te.event(F).zoom("mouse",r(E(te.that.__zoom,te.mouse[0]=Vn(F,H),te.mouse[1]),te.extent,u))}function V(F){Z.on("mousemove.zoom mouseup.zoom",null),_E(F.view,te.moved),Yo(F),te.event(F).end()}}function P(j,...Q){if(e.apply(this,arguments)){var H=this.__zoom,te=Vn(j.changedTouches?j.changedTouches[0]:j,this),Z=H.invert(te),D=H.k*(j.shiftKey?.5:2),X=r(E(k(H,D),te,Z),n.apply(this,Q),u);Yo(j),c>0?kn(this).transition().duration(c).call(I,X,te,j):kn(this).call(S.transform,X,te,j)}}function L(j,...Q){if(e.apply(this,arguments)){var H=j.touches,te=H.length,Z=M(this,Q,j.changedTouches.length===te).event(j),D,X,R,$;for(fd(j),X=0;X<te;++X)R=H[X],$=Vn(R,this),$=[$,this.__zoom.invert($),R.identifier],Z.touch0?!Z.touch1&&Z.touch0[2]!==$[2]&&(Z.touch1=$,Z.taps=0):(Z.touch0=$,D=!0,Z.taps=1+!!f);f&&(f=clearTimeout(f)),D&&(Z.taps<2&&(m=$[0],f=setTimeout(function(){f=null},x)),Gl(this),Z.start())}}function U(j,...Q){if(this.__zooming){var H=M(this,Q).event(j),te=j.changedTouches,Z=te.length,D,X,R,$;for(Yo(j),D=0;D<Z;++D)X=te[D],R=Vn(X,this),H.touch0&&H.touch0[2]===X.identifier?H.touch0[0]=R:H.touch1&&H.touch1[2]===X.identifier&&(H.touch1[0]=R);if(X=H.that.__zoom,H.touch1){var V=H.touch0[0],F=H.touch0[1],J=H.touch1[0],ne=H.touch1[1],le=(le=J[0]-V[0])*le+(le=J[1]-V[1])*le,de=(de=ne[0]-F[0])*de+(de=ne[1]-F[1])*de;X=k(X,Math.sqrt(le/de)),R=[(V[0]+J[0])/2,(V[1]+J[1])/2],$=[(F[0]+ne[0])/2,(F[1]+ne[1])/2]}else if(H.touch0)R=H.touch0[0],$=H.touch0[1];else return;H.zoom("touch",r(E(X,R,$),H.extent,u))}}function B(j,...Q){if(this.__zooming){var H=M(this,Q).event(j),te=j.changedTouches,Z=te.length,D,X;for(fd(j),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),D=0;D<Z;++D)X=te[D],H.touch0&&H.touch0[2]===X.identifier?delete H.touch0:H.touch1&&H.touch1[2]===X.identifier&&delete H.touch1;if(H.touch1&&!H.touch0&&(H.touch0=H.touch1,delete H.touch1),H.touch0)H.touch0[1]=this.__zoom.invert(H.touch0[0]);else if(H.end(),H.taps===2&&(X=Vn(X,this),Math.hypot(m[0]-X[0],m[1]-X[1])<b)){var R=kn(this).on("dblclick.zoom");R&&R.apply(this,arguments)}}}return S.wheelDelta=function(j){return arguments.length?(s=typeof j=="function"?j:Il(+j),S):s},S.filter=function(j){return arguments.length?(e=typeof j=="function"?j:Il(!!j),S):e},S.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:Il(!!j),S):o},S.extent=function(j){return arguments.length?(n=typeof j=="function"?j:Il([[+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?(p=j,S):p},S.on=function(){var j=h.on.apply(h,arguments);return j===h?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 gI=oE();const fu=A.createContext(null),vI=fu.Provider,Pr={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.`},qE=Pr.error001();function Xe(e,n){const r=A.useContext(fu);if(r===null)throw new Error(qE);return aE(r,e,n)}const Et=()=>{const e=A.useContext(fu);if(e===null)throw new Error(qE);return A.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},yI=e=>e.userSelectionActive?"none":"all";function vv({position:e,children:n,className:r,style:s,...o}){const l=Xe(yI),u=`${e}`.split("-");return ae.createElement("div",{className:Lt(["react-flow__panel",r,...u]),style:{...s,pointerEvents:l},...o},n)}function wI({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:ae.createElement(vv,{position:n,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},ae.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const xI=({x:e,y:n,label:r,labelStyle:s={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:p,className:h,...f})=>{const m=A.useRef(null),[y,x]=A.useState({x:0,y:0,width:0,height:0}),N=Lt(["react-flow__edge-textwrapper",h]);return A.useEffect(()=>{if(m.current){const _=m.current.getBBox();x({x:_.x,y:_.y,width:_.width,height:_.height})}},[r]),typeof r>"u"||!r?null:ae.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:N,visibility:y.width?"visible":"hidden",...f},o&&ae.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}),ae.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:s},r),p)};var _I=A.memo(xI);const yv=e=>({width:e.offsetWidth,height:e.offsetHeight}),to=(e,n=0,r=1)=>Math.min(Math.max(e,n),r),wv=(e={x:0,y:0},n)=>({x:to(e.x,n[0][0],n[1][0]),y:to(e.y,n[0][1],n[1][1])}),Dw=(e,n,r)=>e<n?to(Math.abs(e-n),1,50)/50:e>r?-to(Math.abs(e-r),1,50)/50:0,LE=(e,n)=>{const r=Dw(e.x,35,n.width-35)*20,s=Dw(e.y,35,n.height-35)*20;return[r,s]},$E=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},DE=(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)}),ca=({x:e,y:n,width:r,height:s})=>({x:e,y:n,x2:e+r,y2:n+s}),FE=({x:e,y:n,x2:r,y2:s})=>({x:e,y:n,width:r-e,height:s-n}),Fw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),bI=(e,n)=>FE(DE(ca(e),ca(n))),Gg=(e,n)=>{const r=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),s=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(r*s)},SI=e=>En(e.width)&&En(e.height)&&En(e.x)&&En(e.y),En=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),zE=["Enter"," ","Escape"],kI=(e,n)=>{},EI=e=>"nativeEvent"in e;function Yg(e){var o,l;const n=EI(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 BE=e=>"clientX"in e,pi=(e,n)=>{var l,u;const r=BE(e),s=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:s-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},tu=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},ya=({id:e,path:n,labelX:r,labelY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x=20})=>ae.createElement(ae.Fragment,null,ae.createElement("path",{id:e,style:f,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),x&&ae.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),o&&En(r)&&En(s)?ae.createElement(_I,{x:r,y:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h}):null);ya.displayName="BaseEdge";function Ko(e,n,r){return r===void 0?r:s=>{const o=n().edges.find(l=>l.id===e);o&&r(s,{...o})}}function UE({sourceX:e,sourceY:n,targetX:r,targetY:s}){const o=Math.abs(r-e)/2,l=r<e?r+o:r-o,u=Math.abs(s-n)/2,c=s<n?s+u:s-u;return[l,c,o,u]}function HE({sourceX:e,sourceY:n,targetX:r,targetY:s,sourceControlX:o,sourceControlY:l,targetControlX:u,targetControlY:c}){const p=e*.125+o*.375+u*.375+r*.125,h=n*.125+l*.375+c*.375+s*.125,f=Math.abs(p-e),m=Math.abs(h-n);return[p,h,f,m]}var ns;(function(e){e.Strict="strict",e.Loose="loose"})(ns||(ns={}));var Zi;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Zi||(Zi={}));var da;(function(e){e.Partial="partial",e.Full="full"})(da||(da={}));var hi;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(hi||(hi={}));var nu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nu||(nu={}));var Te;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Te||(Te={}));function zw({pos:e,x1:n,y1:r,x2:s,y2:o}){return e===Te.Left||e===Te.Right?[.5*(n+s),r]:[n,.5*(r+o)]}function WE({sourceX:e,sourceY:n,sourcePosition:r=Te.Bottom,targetX:s,targetY:o,targetPosition:l=Te.Top}){const[u,c]=zw({pos:r,x1:e,y1:n,x2:s,y2:o}),[p,h]=zw({pos:l,x1:s,y1:o,x2:e,y2:n}),[f,m,y,x]=HE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:p,targetControlY:h});return[`M${e},${n} C${u},${c} ${p},${h} ${s},${o}`,f,m,y,x]}const xv=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,sourcePosition:o=Te.Bottom,targetPosition:l=Te.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})=>{const[b,S,k]=WE({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:s,targetPosition:l});return ae.createElement(ya,{path:b,labelX:S,labelY:k,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:_})});xv.displayName="SimpleBezierEdge";const Bw={[Te.Left]:{x:-1,y:0},[Te.Right]:{x:1,y:0},[Te.Top]:{x:0,y:-1},[Te.Bottom]:{x:0,y:1}},NI=({source:e,sourcePosition:n=Te.Bottom,target:r})=>n===Te.Left||n===Te.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},Uw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function CI({source:e,sourcePosition:n=Te.Bottom,target:r,targetPosition:s=Te.Top,center:o,offset:l}){const u=Bw[n],c=Bw[s],p={x:e.x+u.x*l,y:e.y+u.y*l},h={x:r.x+c.x*l,y:r.y+c.y*l},f=NI({source:p,sourcePosition:n,target:h}),m=f.x!==0?"x":"y",y=f[m];let x=[],N,_;const b={x:0,y:0},S={x:0,y:0},[k,E,C,I]=UE({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 O=[{x:N,y:p.y},{x:N,y:h.y}],W=[{x:p.x,y:_},{x:h.x,y:_}];u[m]===y?x=m==="x"?O:W:x=m==="x"?W:O}else{const O=[{x:p.x,y:h.y}],W=[{x:h.x,y:p.y}];if(m==="x"?x=u.x===y?W:O:x=u.y===y?O:W,n===s){const B=Math.abs(e[m]-r[m]);if(B<=l){const j=Math.min(l-1,l-B);u[m]===y?b[m]=(p[m]>e[m]?-1:1)*j:S[m]=(h[m]>r[m]?-1:1)*j}}if(n!==s){const B=m==="x"?"y":"x",j=u[m]===c[B],Q=p[B]>h[B],H=p[B]<h[B];(u[m]===1&&(!j&&Q||j&&H)||u[m]!==1&&(!j&&H||j&&Q))&&(x=m==="x"?O:W)}const q={x:p.x+b.x,y:p.y+b.y},P={x:h.x+S.x,y:h.y+S.y},L=Math.max(Math.abs(q.x-x[0].x),Math.abs(P.x-x[0].x)),U=Math.max(Math.abs(q.y-x[0].y),Math.abs(P.y-x[0].y));L>=U?(N=(q.x+P.x)/2,_=x[0].y):(N=x[0].x,_=(q.y+P.y)/2)}return[[e,{x:p.x+b.x,y:p.y+b.y},...x,{x:h.x+S.x,y:h.y+S.y},r],N,_,C,I]}function TI(e,n,r,s){const o=Math.min(Uw(e,n)/2,Uw(n,r)/2,s),{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 h=e.x<r.x?-1:1,f=e.y<r.y?1:-1;return`L ${l+o*h},${u}Q ${l},${u} ${l},${u+o*f}`}const c=e.x<r.x?1:-1,p=e.y<r.y?-1:1;return`L ${l},${u+o*p}Q ${l},${u} ${l+o*c},${u}`}function Kg({sourceX:e,sourceY:n,sourcePosition:r=Te.Bottom,targetX:s,targetY:o,targetPosition:l=Te.Top,borderRadius:u=5,centerX:c,centerY:p,offset:h=20}){const[f,m,y,x,N]=CI({source:{x:e,y:n},sourcePosition:r,target:{x:s,y:o},targetPosition:l,center:{x:c,y:p},offset:h});return[f.reduce((b,S,k)=>{let E="";return k>0&&k<f.length-1?E=TI(f[k-1],S,f[k+1],u):E=`${k===0?"M":"L"}${S.x} ${S.y}`,b+=E,b},""),m,y,x,N]}const hu=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,sourcePosition:m=Te.Bottom,targetPosition:y=Te.Top,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:b})=>{const[S,k,E]=Kg({sourceX:e,sourceY:n,sourcePosition:m,targetX:r,targetY:s,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return ae.createElement(ya,{path:S,labelX:k,labelY:E,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:x,markerStart:N,interactionWidth:b})});hu.displayName="SmoothStepEdge";const _v=A.memo(e=>{var n;return ae.createElement(hu,{...e,pathOptions:A.useMemo(()=>{var r;return{borderRadius:0,offset:(r=e.pathOptions)==null?void 0:r.offset}},[(n=e.pathOptions)==null?void 0:n.offset])})});_v.displayName="StepEdge";function RI({sourceX:e,sourceY:n,targetX:r,targetY:s}){const[o,l,u,c]=UE({sourceX:e,sourceY:n,targetX:r,targetY:s});return[`M ${e},${n}L ${r},${s}`,o,l,u,c]}const bv=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x})=>{const[N,_,b]=RI({sourceX:e,sourceY:n,targetX:r,targetY:s});return ae.createElement(ya,{path:N,labelX:_,labelY:b,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:y,interactionWidth:x})});bv.displayName="StraightEdge";function Ml(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Hw({pos:e,x1:n,y1:r,x2:s,y2:o,c:l}){switch(e){case Te.Left:return[n-Ml(n-s,l),r];case Te.Right:return[n+Ml(s-n,l),r];case Te.Top:return[n,r-Ml(r-o,l)];case Te.Bottom:return[n,r+Ml(o-r,l)]}}function VE({sourceX:e,sourceY:n,sourcePosition:r=Te.Bottom,targetX:s,targetY:o,targetPosition:l=Te.Top,curvature:u=.25}){const[c,p]=Hw({pos:r,x1:e,y1:n,x2:s,y2:o,c:u}),[h,f]=Hw({pos:l,x1:s,y1:o,x2:e,y2:n,c:u}),[m,y,x,N]=HE({sourceX:e,sourceY:n,targetX:s,targetY:o,sourceControlX:c,sourceControlY:p,targetControlX:h,targetControlY:f});return[`M${e},${n} C${c},${p} ${h},${f} ${s},${o}`,m,y,x,N]}const ru=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:s,sourcePosition:o=Te.Bottom,targetPosition:l=Te.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:b})=>{const[S,k,E]=VE({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:s,targetPosition:l,curvature:_==null?void 0:_.curvature});return ae.createElement(ya,{path:S,labelX:k,labelY:E,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:m,style:y,markerEnd:x,markerStart:N,interactionWidth:b})});ru.displayName="BezierEdge";const Sv=A.createContext(null),jI=Sv.Provider;Sv.Consumer;const AI=()=>A.useContext(Sv),II=e=>"id"in e&&"source"in e&&"target"in e,MI=({source:e,sourceHandle:n,target:r,targetHandle:s})=>`reactflow__edge-${e}${n||""}-${r}${s||""}`,Xg=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,PI=(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)),OI=(e,n)=>{if(!e.source||!e.target)return n;let r;return II(e)?r={...e}:r={...e,id:MI(e)},PI(r,n)?n:n.concat(r)},Qg=({x:e,y:n},[r,s,o],l,[u,c])=>{const p={x:(e-r)/o,y:(n-s)/o};return l?{x:u*Math.round(p.x/u),y:c*Math.round(p.y/c)}:p},GE=({x:e,y:n},[r,s,o])=>({x:e*o+r,y:n*o+s}),es=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*n[0],s=(e.height??0)*n[1],o={x:e.position.x-r,y:e.position.y-s};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-s}:o}},pu=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((s,o)=>{const{x:l,y:u}=es(o,n).positionAbsolute;return DE(s,ca({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 FE(r)},YE=(e,n,[r,s,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const p={x:(n.x-r)/o,y:(n.y-s)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(f=>{const{width:m,height:y,selectable:x=!0,hidden:N=!1}=f;if(u&&!x||N)return!1;const{positionAbsolute:_}=es(f,c),b={x:_.x,y:_.y,width:m||0,height:y||0},S=Gg(p,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||f.dragging)&&h.push(f)}),h},KE=(e,n)=>{const r=e.map(s=>s.id);return n.filter(s=>r.includes(s.source)||r.includes(s.target))},XE=(e,n,r,s,o,l=.1)=>{const u=n/(e.width*(1+l)),c=r/(e.height*(1+l)),p=Math.min(u,c),h=to(p,s,o),f=e.x+e.width/2,m=e.y+e.height/2,y=n/2-f*h,x=r/2-m*h;return{x:y,y:x,zoom:h}},Xi=(e,n=0)=>e.transition().duration(n);function Ww(e,n,r,s){return(n[r]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${r}`!==s&&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 qI(e,n,r,s,o,l){const{x:u,y:c}=pi(e),h=n.elementsFromPoint(u,c).find(N=>N.classList.contains("react-flow__handle"));if(h){const N=h.getAttribute("data-nodeid");if(N){const _=kv(void 0,h),b=h.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 f=[],m=1/0;if(o.forEach(N=>{const _=Math.sqrt((N.x-r.x)**2+(N.y-r.y)**2);if(_<=s){const b=l(N);_<=m&&(_<m?f=[{handle:N,validHandleResult:b}]:_===m&&f.push({handle:N,validHandleResult:b}),m=_)}}),!f.length)return{handle:null,validHandleResult:QE()};if(f.length===1)return f[0];const y=f.some(({validHandleResult:N})=>N.isValid),x=f.some(({handle:N})=>N.type==="target");return f.find(({handle:N,validHandleResult:_})=>x?N.type==="target":y?_.isValid:!0)||f[0]}const LI={source:null,target:null,sourceHandle:null,targetHandle:null},QE=()=>({handleDomNode:null,isValid:!1,connection:LI,endHandle:null});function ZE(e,n,r,s,o,l,u){const c=o==="target",p=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}"]`),h={...QE(),handleDomNode:p};if(p){const f=kv(void 0,p),m=p.getAttribute("data-nodeid"),y=p.getAttribute("data-handleid"),x=p.classList.contains("connectable"),N=p.classList.contains("connectableend"),_={source:c?m:r,sourceHandle:c?y:s,target:c?r:m,targetHandle:c?s:y};h.connection=_,x&&N&&(n===ns.Strict?c&&f==="source"||!c&&f==="target":m!==r||y!==s)&&(h.endHandle={nodeId:m,handleId:y,type:f},h.isValid=l(_))}return h}function $I({nodes:e,nodeId:n,handleId:r,handleType:s}){return e.reduce((o,l)=>{if(l[ht]){const{handleBounds:u}=l[ht];let c=[],p=[];u&&(c=Ww(l,u,"source",`${n}-${r}-${s}`),p=Ww(l,u,"target",`${n}-${r}-${s}`)),o.push(...c,...p)}return o},[])}function kv(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function hd(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function DI(e,n){let r=null;return n?r="valid":e&&!n&&(r="invalid"),r}function JE({event:e,handleId:n,nodeId:r,onConnect:s,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:p,onReconnectEnd:h}){const f=$E(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:x,connectionRadius:N,onConnectStart:_,panBy:b,getNodes:S,cancelConnection:k}=l();let E=0,C;const{x:I,y:M}=pi(e),O=f==null?void 0:f.elementFromPoint(I,M),W=kv(p,O),q=y==null?void 0:y.getBoundingClientRect();if(!q||!W)return;let P,L=pi(e,q),U=!1,B=null,j=!1,Q=null;const H=$I({nodes:S(),nodeId:r,handleId:n,handleType:W}),te=()=>{if(!x)return;const[X,R]=LE(L,q);b({x:X,y:R}),E=requestAnimationFrame(te)};u({connectionPosition:L,connectionStatus:null,connectionNodeId:r,connectionHandleId:n,connectionHandleType:W,connectionStartHandle:{nodeId:r,handleId:n,type:W},connectionEndHandle:null}),_==null||_(e,{nodeId:r,handleId:n,handleType:W});function Z(X){const{transform:R}=l();L=pi(X,q);const{handle:$,validHandleResult:V}=qI(X,f,Qg(L,R,!1,[1,1]),N,H,F=>ZE(F,m,r,n,o?"target":"source",c,f));if(C=$,U||(te(),U=!0),Q=V.handleDomNode,B=V.connection,j=V.isValid,u({connectionPosition:C&&j?GE({x:C.x,y:C.y},R):L,connectionStatus:DI(!!C,j),connectionEndHandle:V.endHandle}),!C&&!j&&!Q)return hd(P);B.source!==B.target&&Q&&(hd(P),P=Q,Q.classList.add("connecting","react-flow__handle-connecting"),Q.classList.toggle("valid",j),Q.classList.toggle("react-flow__handle-valid",j))}function D(X){var R,$;(C||Q)&&B&&j&&(s==null||s(B)),($=(R=l()).onConnectEnd)==null||$.call(R,X),p&&(h==null||h(X)),hd(P),k(),cancelAnimationFrame(E),U=!1,j=!1,B=null,Q=null,f.removeEventListener("mousemove",Z),f.removeEventListener("mouseup",D),f.removeEventListener("touchmove",Z),f.removeEventListener("touchend",D)}f.addEventListener("mousemove",Z),f.addEventListener("mouseup",D),f.addEventListener("touchmove",Z),f.addEventListener("touchend",D)}const Vw=()=>!0,FI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),zI=(e,n,r)=>s=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=s;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}},eN=A.forwardRef(({type:e="source",position:n=Te.Top,isValidConnection:r,isConnectable:s=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:p,className:h,onMouseDown:f,onTouchStart:m,...y},x)=>{var q,P;const N=u||null,_=e==="target",b=Et(),S=AI(),{connectOnClick:k,noPanClassName:E}=Xe(FI,kt),{connecting:C,clickConnecting:I}=Xe(zI(S,N,e),kt);S||(P=(q=b.getState()).onError)==null||P.call(q,"010",Pr.error010());const M=L=>{const{defaultEdgeOptions:U,onConnect:B,hasDefaultEdges:j}=b.getState(),Q={...U,...L};if(j){const{edges:H,setEdges:te}=b.getState();te(OI(Q,H))}B==null||B(Q),c==null||c(Q)},O=L=>{if(!S)return;const U=BE(L);o&&(U&&L.button===0||!U)&&JE({event:L,handleId:N,nodeId:S,onConnect:M,isTarget:_,getState:b.getState,setState:b.setState,isValidConnection:r||b.getState().isValidConnection||Vw}),U?f==null||f(L):m==null||m(L)},W=L=>{const{onClickConnectStart:U,onClickConnectEnd:B,connectionClickStartHandle:j,connectionMode:Q,isValidConnection:H}=b.getState();if(!S||!j&&!o)return;if(!j){U==null||U(L,{nodeId:S,handleId:N,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:S,type:e,handleId:N}});return}const te=$E(L.target),Z=r||H||Vw,{connection:D,isValid:X}=ZE({nodeId:S,id:N,type:e},Q,j.nodeId,j.handleId||null,j.type,Z,te);X&&M(D),B==null||B(L),b.setState({connectionClickStartHandle:null})};return ae.createElement("div",{"data-handleid":N,"data-nodeid":S,"data-handlepos":n,"data-id":`${S}-${N}-${e}`,className:Lt(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",E,h,{source:!_,target:_,connectable:s,connectablestart:o,connectableend:l,connecting:I,connectionindicator:s&&(o&&!C||l&&C)}]),onMouseDown:O,onTouchStart:O,onClick:k?W:void 0,ref:x,...y},p)});eN.displayName="Handle";var no=A.memo(eN);const tN=({data:e,isConnectable:n,targetPosition:r=Te.Top,sourcePosition:s=Te.Bottom})=>ae.createElement(ae.Fragment,null,ae.createElement(no,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label,ae.createElement(no,{type:"source",position:s,isConnectable:n}));tN.displayName="DefaultNode";var Zg=A.memo(tN);const nN=({data:e,isConnectable:n,sourcePosition:r=Te.Bottom})=>ae.createElement(ae.Fragment,null,e==null?void 0:e.label,ae.createElement(no,{type:"source",position:r,isConnectable:n}));nN.displayName="InputNode";var rN=A.memo(nN);const iN=({data:e,isConnectable:n,targetPosition:r=Te.Top})=>ae.createElement(ae.Fragment,null,ae.createElement(no,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label);iN.displayName="OutputNode";var sN=A.memo(iN);const Ev=()=>null;Ev.displayName="GroupNode";const BI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),Pl=e=>e.id;function UI(e,n){return kt(e.selectedNodes.map(Pl),n.selectedNodes.map(Pl))&&kt(e.selectedEdges.map(Pl),n.selectedEdges.map(Pl))}const oN=A.memo(({onSelectionChange:e})=>{const n=Et(),{selectedNodes:r,selectedEdges:s}=Xe(BI,UI);return A.useEffect(()=>{const o={nodes:r,edges:s};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[r,s,e]),null});oN.displayName="SelectionListener";const HI=e=>!!e.onSelectionChange;function WI({onSelectionChange:e}){const n=Xe(HI);return e||n?ae.createElement(oN,{onSelectionChange:e}):null}const VI=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 Fs(e,n){A.useEffect(()=>{typeof e<"u"&&n(e)},[e])}function $e(e,n,r){A.useEffect(()=>{typeof n<"u"&&r({[e]:n})},[n])}const GI=({nodes:e,edges:n,defaultNodes:r,defaultEdges:s,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:p,nodesDraggable:h,nodesConnectable:f,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:x,elevateNodesOnSelect:N,minZoom:_,maxZoom:b,nodeExtent:S,onNodesChange:k,onEdgesChange:E,elementsSelectable:C,connectionMode:I,snapGrid:M,snapToGrid:O,translateExtent:W,connectOnClick:q,defaultEdgeOptions:P,fitView:L,fitViewOptions:U,onNodesDelete:B,onEdgesDelete:j,onNodeDrag:Q,onNodeDragStart:H,onNodeDragStop:te,onSelectionDrag:Z,onSelectionDragStart:D,onSelectionDragStop:X,noPanClassName:R,nodeOrigin:$,rfId:V,autoPanOnConnect:F,autoPanOnNodeDrag:J,onError:ne,connectionRadius:le,isValidConnection:de,nodeDragThreshold:me})=>{const{setNodes:ve,setEdges:Pe,setDefaultNodesAndEdges:Me,setMinZoom:Oe,setMaxZoom:ye,setTranslateExtent:Se,setNodeExtent:Ke,reset:xe}=Xe(VI,kt),ge=Et();return A.useEffect(()=>{const Fe=s==null?void 0:s.map(pt=>({...pt,...P}));return Me(r,Fe),()=>{xe()}},[]),$e("defaultEdgeOptions",P,ge.setState),$e("connectionMode",I,ge.setState),$e("onConnect",o,ge.setState),$e("onConnectStart",l,ge.setState),$e("onConnectEnd",u,ge.setState),$e("onClickConnectStart",c,ge.setState),$e("onClickConnectEnd",p,ge.setState),$e("nodesDraggable",h,ge.setState),$e("nodesConnectable",f,ge.setState),$e("nodesFocusable",m,ge.setState),$e("edgesFocusable",y,ge.setState),$e("edgesUpdatable",x,ge.setState),$e("elementsSelectable",C,ge.setState),$e("elevateNodesOnSelect",N,ge.setState),$e("snapToGrid",O,ge.setState),$e("snapGrid",M,ge.setState),$e("onNodesChange",k,ge.setState),$e("onEdgesChange",E,ge.setState),$e("connectOnClick",q,ge.setState),$e("fitViewOnInit",L,ge.setState),$e("fitViewOnInitOptions",U,ge.setState),$e("onNodesDelete",B,ge.setState),$e("onEdgesDelete",j,ge.setState),$e("onNodeDrag",Q,ge.setState),$e("onNodeDragStart",H,ge.setState),$e("onNodeDragStop",te,ge.setState),$e("onSelectionDrag",Z,ge.setState),$e("onSelectionDragStart",D,ge.setState),$e("onSelectionDragStop",X,ge.setState),$e("noPanClassName",R,ge.setState),$e("nodeOrigin",$,ge.setState),$e("rfId",V,ge.setState),$e("autoPanOnConnect",F,ge.setState),$e("autoPanOnNodeDrag",J,ge.setState),$e("onError",ne,ge.setState),$e("connectionRadius",le,ge.setState),$e("isValidConnection",de,ge.setState),$e("nodeDragThreshold",me,ge.setState),Fs(e,ve),Fs(n,Pe),Fs(_,Oe),Fs(b,ye),Fs(W,Se),Fs(S,Ke),null},Gw={display:"none"},YI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},aN="react-flow__node-desc",lN="react-flow__edge-desc",KI="react-flow__aria-live",XI=e=>e.ariaLiveMessage;function QI({rfId:e}){const n=Xe(XI);return ae.createElement("div",{id:`${KI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:YI},n)}function ZI({rfId:e,disableKeyboardA11y:n}){return ae.createElement(ae.Fragment,null,ae.createElement("div",{id:`${aN}-${e}`,style:Gw},"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."," "),ae.createElement("div",{id:`${lN}-${e}`,style:Gw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&ae.createElement(QI,{rfId:e}))}var fa=(e=null,n={actInsideInputWithModifier:!0})=>{const[r,s]=A.useState(!1),o=A.useRef(!1),l=A.useRef(new Set([])),[u,c]=A.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),f=h.reduce((m,y)=>m.concat(...y),[]);return[h,f]}return[[],[]]},[e]);return A.useEffect(()=>{const p=typeof document<"u"?document:null,h=(n==null?void 0:n.target)||p;if(e!==null){const f=x=>{if(o.current=x.ctrlKey||x.metaKey||x.shiftKey,(!o.current||o.current&&!n.actInsideInputWithModifier)&&Yg(x))return!1;const _=Kw(x.code,c);l.current.add(x[_]),Yw(u,l.current,!1)&&(x.preventDefault(),s(!0))},m=x=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Yg(x))return!1;const _=Kw(x.code,c);Yw(u,l.current,!0)?(s(!1),l.current.clear()):l.current.delete(x[_]),x.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,s]),r};function Yw(e,n,r){return e.filter(s=>r||s.length===n.size).some(s=>s.every(o=>n.has(o)))}function Kw(e,n){return n.includes(e)?"code":"key"}function uN(e,n,r,s){var c,p;const o=e.parentNode||e.parentId;if(!o)return r;const l=n.get(o),u=es(l,s);return uN(l,n,{x:(r.x??0)+u.x,y:(r.y??0)+u.y,z:(((c=l[ht])==null?void 0:c.z)??0)>(r.z??0)?((p=l[ht])==null?void 0:p.z)??0:r.z??0},s)}function cN(e,n,r){e.forEach(s=>{var l;const o=s.parentNode||s.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||r!=null&&r[s.id]){const{x:u,y:c,z:p}=uN(s,e,{...s.position,z:((l=s[ht])==null?void 0:l.z)??0},n);s.positionAbsolute={x:u,y:c},s[ht].z=p,r!=null&&r[s.id]&&(s[ht].isParent=!0)}})}function pd(e,n,r,s){const o=new Map,l={},u=s?1e3:0;return e.forEach(c=>{var x;const p=(En(c.zIndex)?c.zIndex:0)+(c.selected?u:0),h=n.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},m=c.parentNode||c.parentId;m&&(l[m]=!0);const y=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,ht,{enumerable:!1,value:{handleBounds:y||(x=h==null?void 0:h[ht])==null?void 0:x.handleBounds,z:p}}),o.set(c.id,f)}),cN(o,r,l),o}function dN(e,n={}){const{getNodes:r,width:s,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:p,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:m}=e(),y=n.initial&&!h&&f;if(c&&p&&(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=pu(N,m),{x:S,y:k,zoom:E}=XE(b,s,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),C=Ir.translate(S,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(Xi(p,n.duration),C):c.transform(p,C),!0}}return!1}function JI(e,n){return e.forEach(r=>{const s=n.get(r.id);s&&n.set(s.id,{...s,[ht]:s[ht],selected:r.selected})}),new Map(n)}function eM(e,n){return n.map(r=>{const s=e.find(o=>o.id===r.id);return s&&(r.selected=s.selected),r})}function Ol({changedNodes:e,changedEdges:n,get:r,set:s}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:p,hasDefaultEdges:h}=r();e!=null&&e.length&&(p&&s({nodeInternals:JI(e,o)}),u==null||u(e)),n!=null&&n.length&&(h&&s({edges:eM(n,l)}),c==null||c(n))}const zs=()=>{},tM={zoomIn:zs,zoomOut:zs,zoomTo:zs,getZoom:()=>1,setViewport:zs,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:zs,fitBounds:zs,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},nM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),rM=()=>{const e=Et(),{d3Zoom:n,d3Selection:r}=Xe(nM,kt);return A.useMemo(()=>r&&n?{zoomIn:o=>n.scaleBy(Xi(r,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Xi(r,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(Xi(r,l==null?void 0:l.duration),o),getZoom:()=>e.getState().transform[2],setViewport:(o,l)=>{const[u,c,p]=e.getState().transform,h=Ir.translate(o.x??u,o.y??c).scale(o.zoom??p);n.transform(Xi(r,l==null?void 0:l.duration),h)},getViewport:()=>{const[o,l,u]=e.getState().transform;return{x:o,y:l,zoom:u}},fitView:o=>dN(e.getState,o),setCenter:(o,l,u)=>{const{width:c,height:p,maxZoom:h}=e.getState(),f=typeof(u==null?void 0:u.zoom)<"u"?u.zoom:h,m=c/2-o*f,y=p/2-l*f,x=Ir.translate(m,y).scale(f);n.transform(Xi(r,u==null?void 0:u.duration),x)},fitBounds:(o,l)=>{const{width:u,height:c,minZoom:p,maxZoom:h}=e.getState(),{x:f,y:m,zoom:y}=XE(o,u,c,p,h,(l==null?void 0:l.padding)??.1),x=Ir.translate(f,m).scale(y);n.transform(Xi(r,l==null?void 0:l.duration),x)},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"),Qg(o,l,u,c)},screenToFlowPosition:o=>{const{transform:l,snapToGrid:u,snapGrid:c,domNode:p}=e.getState();if(!p)return o;const{x:h,y:f}=p.getBoundingClientRect(),m={x:o.x-h,y:o.y-f};return Qg(m,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:p}=u.getBoundingClientRect(),h=GE(o,l);return{x:h.x+c,y:h.y+p}},viewportInitialized:!0}:tM,[n,r])};function wa(){const e=rM(),n=Et(),r=A.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),s=A.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=A.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(b=>({...b}))},[]),l=A.useCallback(_=>{const{edges:b=[]}=n.getState();return b.find(S=>S.id===_)},[]),u=A.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 M=I.length===0?C.map(O=>({type:"remove",id:O.id})):I.map(O=>({item:O,type:"reset"}));E(M)}},[]),c=A.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(M=>({type:"remove",id:M.id})):C.map(M=>({item:M,type:"reset"}));E(I)}},[]),p=A.useCallback(_=>{const b=Array.isArray(_)?_:[_],{getNodes:S,setNodes:k,hasDefaultNodes:E,onNodesChange:C}=n.getState();if(E){const M=[...S(),...b];k(M)}else if(C){const I=b.map(M=>({item:M,type:"add"}));C(I)}},[]),h=A.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(M=>({item:M,type:"add"}));C(I)}},[]),f=A.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=A.useCallback(({nodes:_,edges:b})=>{const{nodeInternals:S,getNodes:k,edges:E,hasDefaultNodes:C,hasDefaultEdges:I,onNodesDelete:M,onEdgesDelete:O,onNodesChange:W,onEdgesChange:q}=n.getState(),P=(_||[]).map(Q=>Q.id),L=(b||[]).map(Q=>Q.id),U=k().reduce((Q,H)=>{const te=H.parentNode||H.parentId,Z=!P.includes(H.id)&&te&&Q.find(X=>X.id===te);return(typeof H.deletable=="boolean"?H.deletable:!0)&&(P.includes(H.id)||Z)&&Q.push(H),Q},[]),B=E.filter(Q=>typeof Q.deletable=="boolean"?Q.deletable:!0),j=B.filter(Q=>L.includes(Q.id));if(U||j){const Q=KE(U,B),H=[...j,...Q],te=H.reduce((Z,D)=>(Z.includes(D.id)||Z.push(D.id),Z),[]);if((I||C)&&(I&&n.setState({edges:E.filter(Z=>!te.includes(Z.id))}),C&&(U.forEach(Z=>{S.delete(Z.id)}),n.setState({nodeInternals:new Map(S)}))),te.length>0&&(O==null||O(H),q&&q(te.map(Z=>({id:Z,type:"remove"})))),U.length>0&&(M==null||M(U),W)){const Z=U.map(D=>({id:D.id,type:"remove"}));W(Z)}}},[]),y=A.useCallback(_=>{const b=SI(_),S=b?null:n.getState().nodeInternals.get(_.id);return!b&&!S?[null,null,b]:[b?_:Fw(S),S,b]},[]),x=A.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 M=Fw(I),O=Gg(M,k);return b&&O>0||O>=k.width*k.height}):[]},[]),N=A.useCallback((_,b,S=!0)=>{const[k]=y(_);if(!k)return!1;const E=Gg(k,b);return S&&E>0||E>=k.width*k.height},[]);return A.useMemo(()=>({...e,getNodes:r,getNode:s,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:p,addEdges:h,toObject:f,deleteElements:m,getIntersectingNodes:x,isNodeIntersecting:N}),[e,r,s,o,l,u,c,p,h,f,m,x,N])}const iM={actInsideInputWithModifier:!1};var sM=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const r=Et(),{deleteElements:s}=wa(),o=fa(e,iM),l=fa(n);A.useEffect(()=>{if(o){const{edges:u,getNodes:c}=r.getState(),p=c().filter(f=>f.selected),h=u.filter(f=>f.selected);s({nodes:p,edges:h}),r.setState({nodesSelectionActive:!1})}},[o]),A.useEffect(()=>{r.setState({multiSelectionActive:l})},[l])};function oM(e){const n=Et();A.useEffect(()=>{let r;const s=()=>{var l,u;if(!e.current)return;const o=yv(e.current);(o.height===0||o.width===0)&&((u=(l=n.getState()).onError)==null||u.call(l,"004",Pr.error004())),n.setState({width:o.width||500,height:o.height||500})};return s(),window.addEventListener("resize",s),e.current&&(r=new ResizeObserver(()=>s()),r.observe(e.current)),()=>{window.removeEventListener("resize",s),r&&e.current&&r.unobserve(e.current)}},[])}const Nv={position:"absolute",width:"100%",height:"100%",top:0,left:0},aM=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,ql=e=>({x:e.x,y:e.y,zoom:e.k}),Bs=(e,n)=>e.target.closest(`.${n}`),Xw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Qw=e=>{const n=e.ctrlKey&&tu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},lM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),uM=({onMove:e,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:s,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:p=Zi.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:m=!0,defaultViewport:y,translateExtent:x,minZoom:N,maxZoom:_,zoomActivationKeyCode:b,preventScrolling:S=!0,children:k,noWheelClassName:E,noPanClassName:C})=>{const I=A.useRef(),M=Et(),O=A.useRef(!1),W=A.useRef(!1),q=A.useRef(null),P=A.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:U,d3ZoomHandler:B,userSelectionActive:j}=Xe(lM,kt),Q=fa(b),H=A.useRef(0),te=A.useRef(!1),Z=A.useRef();return oM(q),A.useEffect(()=>{if(q.current){const D=q.current.getBoundingClientRect(),X=OE().scaleExtent([N,_]).translateExtent(x),R=kn(q.current).call(X),$=Ir.translate(y.x,y.y).scale(to(y.zoom,N,_)),V=[[0,0],[D.width,D.height]],F=X.constrain()($,V,x);X.transform(R,F),X.wheelDelta(Qw),M.setState({d3Zoom:X,d3Selection:R,d3ZoomHandler:R.on("wheel.zoom"),transform:[F.x,F.y,F.k],domNode:q.current.closest(".react-flow")})}},[]),A.useEffect(()=>{U&&L&&(u&&!Q&&!j?U.on("wheel.zoom",D=>{if(Bs(D,E))return!1;D.preventDefault(),D.stopImmediatePropagation();const X=U.property("__zoom").k||1;if(D.ctrlKey&&l){const de=Vn(D),me=Qw(D),ve=X*Math.pow(2,me);L.scaleTo(U,ve,de,D);return}const R=D.deltaMode===1?20:1;let $=p===Zi.Vertical?0:D.deltaX*R,V=p===Zi.Horizontal?0:D.deltaY*R;!tu()&&D.shiftKey&&p!==Zi.Vertical&&($=D.deltaY*R,V=0),L.translateBy(U,-($/X)*c,-(V/X)*c,{internal:!0});const F=ql(U.property("__zoom")),{onViewportChangeStart:J,onViewportChange:ne,onViewportChangeEnd:le}=M.getState();clearTimeout(Z.current),te.current||(te.current=!0,n==null||n(D,F),J==null||J(F)),te.current&&(e==null||e(D,F),ne==null||ne(F),Z.current=setTimeout(()=>{r==null||r(D,F),le==null||le(F),te.current=!1},150))},{passive:!1}):typeof B<"u"&&U.on("wheel.zoom",function(D,X){if(!S&&D.type==="wheel"&&!D.ctrlKey||Bs(D,E))return null;D.preventDefault(),B.call(this,D,X)},{passive:!1}))},[j,u,p,U,L,B,Q,l,S,E,n,e,r]),A.useEffect(()=>{L&&L.on("start",D=>{var $,V;if(!D.sourceEvent||D.sourceEvent.internal)return null;H.current=($=D.sourceEvent)==null?void 0:$.button;const{onViewportChangeStart:X}=M.getState(),R=ql(D.transform);O.current=!0,P.current=R,((V=D.sourceEvent)==null?void 0:V.type)==="mousedown"&&M.setState({paneDragging:!0}),X==null||X(R),n==null||n(D.sourceEvent,R)})},[L,n]),A.useEffect(()=>{L&&(j&&!O.current?L.on("zoom",null):j||L.on("zoom",D=>{var R;const{onViewportChange:X}=M.getState();if(M.setState({transform:[D.transform.x,D.transform.y,D.transform.k]}),W.current=!!(s&&Xw(m,H.current??0)),(e||X)&&!((R=D.sourceEvent)!=null&&R.internal)){const $=ql(D.transform);X==null||X($),e==null||e(D.sourceEvent,$)}}))},[j,L,e,m,s]),A.useEffect(()=>{L&&L.on("end",D=>{if(!D.sourceEvent||D.sourceEvent.internal)return null;const{onViewportChangeEnd:X}=M.getState();if(O.current=!1,M.setState({paneDragging:!1}),s&&Xw(m,H.current??0)&&!W.current&&s(D.sourceEvent),W.current=!1,(r||X)&&aM(P.current,D.transform)){const R=ql(D.transform);P.current=R,clearTimeout(I.current),I.current=setTimeout(()=>{X==null||X(R),r==null||r(D.sourceEvent,R)},u?150:0)}})},[L,u,m,r,s]),A.useEffect(()=>{L&&L.filter(D=>{const X=Q||o,R=l&&D.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&D.button===1&&D.type==="mousedown"&&(Bs(D,"react-flow__node")||Bs(D,"react-flow__edge")))return!0;if(!m&&!X&&!u&&!h&&!l||j||!h&&D.type==="dblclick"||Bs(D,E)&&D.type==="wheel"||Bs(D,C)&&(D.type!=="wheel"||u&&D.type==="wheel"&&!Q)||!l&&D.ctrlKey&&D.type==="wheel"||!X&&!u&&!R&&D.type==="wheel"||!m&&(D.type==="mousedown"||D.type==="touchstart")||Array.isArray(m)&&!m.includes(D.button)&&D.type==="mousedown")return!1;const $=Array.isArray(m)&&m.includes(D.button)||!D.button||D.button<=1;return(!D.ctrlKey||D.type==="wheel")&&$})},[j,L,o,l,u,h,m,f,Q]),ae.createElement("div",{className:"react-flow__renderer",ref:q,style:Nv},k)},cM=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function dM(){const{userSelectionActive:e,userSelectionRect:n}=Xe(cM,kt);return e&&n?ae.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 Zw(e,n){const r=n.parentNode||n.parentId,s=e.find(o=>o.id===r);if(s){const o=n.position.x+n.width-s.width,l=n.position.y+n.height-s.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,o>0&&(s.style.width+=o),l>0&&(s.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);s.position.x=s.position.x-u,s.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);s.position.y=s.position.y-u,s.style.height+=u,n.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function fM(e,n){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const r=e.filter(s=>s.type==="add").map(s=>s.item);return n.reduce((s,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return s.push(o),s;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&&Zw(s,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&&Zw(s,u);break}case"remove":return s}return s.push(u),s},r)}function hM(e,n){return fM(e,n)}const fi=(e,n)=>({id:e,type:"select",selected:n});function Vs(e,n){return e.reduce((r,s)=>{const o=n.includes(s.id);return!s.selected&&o?(s.selected=!0,r.push(fi(s.id,!0))):s.selected&&!o&&(s.selected=!1,r.push(fi(s.id,!1))),r},[])}const md=(e,n)=>r=>{r.target===n.current&&(e==null||e(r))},pM=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),fN=A.memo(({isSelecting:e,selectionMode:n=da.Full,panOnDrag:r,onSelectionStart:s,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:f,children:m})=>{const y=A.useRef(null),x=Et(),N=A.useRef(0),_=A.useRef(0),b=A.useRef(),{userSelectionActive:S,elementsSelectable:k,dragging:E}=Xe(pM,kt),C=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},I=B=>{l==null||l(B),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},M=B=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){B.preventDefault();return}u==null||u(B)},O=c?B=>c(B):void 0,W=B=>{const{resetSelectedElements:j,domNode:Q}=x.getState();if(b.current=Q==null?void 0:Q.getBoundingClientRect(),!k||!e||B.button!==0||B.target!==y.current||!b.current)return;const{x:H,y:te}=pi(B,b.current);j(),x.setState({userSelectionRect:{width:0,height:0,startX:H,startY:te,x:H,y:te}}),s==null||s(B)},q=B=>{const{userSelectionRect:j,nodeInternals:Q,edges:H,transform:te,onNodesChange:Z,onEdgesChange:D,nodeOrigin:X,getNodes:R}=x.getState();if(!e||!b.current||!j)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const $=pi(B,b.current),V=j.startX??0,F=j.startY??0,J={...j,x:$.x<V?$.x:V,y:$.y<F?$.y:F,width:Math.abs($.x-V),height:Math.abs($.y-F)},ne=R(),le=YE(Q,J,te,n===da.Partial,!0,X),de=KE(le,H).map(ve=>ve.id),me=le.map(ve=>ve.id);if(N.current!==me.length){N.current=me.length;const ve=Vs(ne,me);ve.length&&(Z==null||Z(ve))}if(_.current!==de.length){_.current=de.length;const ve=Vs(H,de);ve.length&&(D==null||D(ve))}x.setState({userSelectionRect:J})},P=B=>{if(B.button!==0)return;const{userSelectionRect:j}=x.getState();!S&&j&&B.target===y.current&&(I==null||I(B)),x.setState({nodesSelectionActive:N.current>0}),C(),o==null||o(B)},L=B=>{S&&(x.setState({nodesSelectionActive:N.current>0}),o==null||o(B)),C()},U=k&&(e||S);return ae.createElement("div",{className:Lt(["react-flow__pane",{dragging:E,selection:e}]),onClick:U?void 0:md(I,y),onContextMenu:md(M,y),onWheel:md(O,y),onMouseEnter:U?void 0:p,onMouseDown:U?W:void 0,onMouseMove:U?q:h,onMouseUp:U?P:void 0,onMouseLeave:U?L:f,ref:y,style:Nv},m,ae.createElement(dM,null))});fN.displayName="Pane";function hN(e,n){const r=e.parentNode||e.parentId;if(!r)return!1;const s=n.get(r);return s?s.selected?!0:hN(s,n):!1}function Jw(e,n,r){let s=e;do{if(s!=null&&s.matches(n))return!0;if(s===r.current)return!1;s=s.parentElement}while(s);return!1}function mM(e,n,r,s){return Array.from(e.values()).filter(o=>(o.selected||o.id===s)&&(!o.parentNode||o.parentId||!hN(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 gM(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function pN(e,n,r,s,o=[0,0],l){const u=gM(e,e.extent||s);let c=u;const p=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(p&&e.width&&e.height){const m=r.get(p),{x:y,y:x}=es(m,o).positionAbsolute;c=m&&En(y)&&En(x)&&En(m.width)&&En(m.height)?[[y+e.width*o[0],x+e.height*o[1]],[y+m.width-e.width+e.width*o[0],x+m.height-e.height+e.height*o[1]]]:c}else l==null||l("005",Pr.error005()),c=u;else if(e.extent&&p&&e.extent!=="parent"){const m=r.get(p),{x:y,y:x}=es(m,o).positionAbsolute;c=[[e.extent[0][0]+y,e.extent[0][1]+x],[e.extent[1][0]+y,e.extent[1][1]+x]]}let h={x:0,y:0};if(p){const m=r.get(p);h=es(m,o).positionAbsolute}const f=c&&c!=="parent"?wv(n,c):n;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function gd({nodeId:e,dragItems:n,nodeInternals:r}){const s=n.map(o=>({...r.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?s.find(o=>o.id===e):s[0],s]}const ex=(e,n,r,s)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*s[0],y:u.height*s[1]};return l.map(p=>{const h=p.getBoundingClientRect();return{id:p.getAttribute("data-handleid"),position:p.getAttribute("data-handlepos"),x:(h.left-u.left-c.x)/r,y:(h.top-u.top-c.y)/r,...yv(p)}})};function Xo(e,n,r){return r===void 0?r:s=>{const o=n().nodeInternals.get(e);o&&r(s,{...o})}}function Jg({id:e,store:n,unselect:r=!1,nodeRef:s}){const{addSelectedNodes:o,unselectNodesAndEdges:l,multiSelectionActive:u,nodeInternals:c,onError:p}=n.getState(),h=c.get(e);if(!h){p==null||p("012",Pr.error012(e));return}n.setState({nodesSelectionActive:!1}),h.selected?(r||h.selected&&u)&&(l({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):o([e])}function vM(){const e=Et();return A.useCallback(({sourceEvent:r})=>{const{transform:s,snapGrid:o,snapToGrid:l}=e.getState(),u=r.touches?r.touches[0].clientX:r.clientX,c=r.touches?r.touches[0].clientY:r.clientY,p={x:(u-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:l?o[0]*Math.round(p.x/o[0]):p.x,ySnapped:l?o[1]*Math.round(p.y/o[1]):p.y,...p}},[])}function vd(e){return(n,r,s)=>e==null?void 0:e(n,s)}function mN({nodeRef:e,disabled:n=!1,noDragClassName:r,handleSelector:s,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=Et(),[p,h]=A.useState(!1),f=A.useRef([]),m=A.useRef({x:null,y:null}),y=A.useRef(0),x=A.useRef(null),N=A.useRef({x:0,y:0}),_=A.useRef(null),b=A.useRef(!1),S=A.useRef(!1),k=A.useRef(!1),E=vM();return A.useEffect(()=>{if(e!=null&&e.current){const C=kn(e.current),I=({x:W,y:q})=>{const{nodeInternals:P,onNodeDrag:L,onSelectionDrag:U,updateNodePositions:B,nodeExtent:j,snapGrid:Q,snapToGrid:H,nodeOrigin:te,onError:Z}=c.getState();m.current={x:W,y:q};let D=!1,X={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&j){const $=pu(f.current,te);X=ca($)}if(f.current=f.current.map($=>{const V={x:W-$.distance.x,y:q-$.distance.y};H&&(V.x=Q[0]*Math.round(V.x/Q[0]),V.y=Q[1]*Math.round(V.y/Q[1]));const F=[[j[0][0],j[0][1]],[j[1][0],j[1][1]]];f.current.length>1&&j&&!$.extent&&(F[0][0]=$.positionAbsolute.x-X.x+j[0][0],F[1][0]=$.positionAbsolute.x+($.width??0)-X.x2+j[1][0],F[0][1]=$.positionAbsolute.y-X.y+j[0][1],F[1][1]=$.positionAbsolute.y+($.height??0)-X.y2+j[1][1]);const J=pN($,V,P,F,te,Z);return D=D||$.position.x!==J.position.x||$.position.y!==J.position.y,$.position=J.position,$.positionAbsolute=J.positionAbsolute,$}),!D)return;B(f.current,!0,!0),h(!0);const R=o?L:vd(U);if(R&&_.current){const[$,V]=gd({nodeId:o,dragItems:f.current,nodeInternals:P});R(_.current,$,V)}},M=()=>{if(!x.current)return;const[W,q]=LE(N.current,x.current);if(W!==0||q!==0){const{transform:P,panBy:L}=c.getState();m.current.x=(m.current.x??0)-W/P[2],m.current.y=(m.current.y??0)-q/P[2],L({x:W,y:q})&&I(m.current)}y.current=requestAnimationFrame(M)},O=W=>{var te;const{nodeInternals:q,multiSelectionActive:P,nodesDraggable:L,unselectNodesAndEdges:U,onNodeDragStart:B,onSelectionDragStart:j}=c.getState();S.current=!0;const Q=o?B:vd(j);(!u||!l)&&!P&&o&&((te=q.get(o))!=null&&te.selected||U()),o&&l&&u&&Jg({id:o,store:c,nodeRef:e});const H=E(W);if(m.current=H,f.current=mM(q,L,H,o),Q&&f.current){const[Z,D]=gd({nodeId:o,dragItems:f.current,nodeInternals:q});Q(W.sourceEvent,Z,D)}};if(n)C.on(".drag",null);else{const W=N2().on("start",q=>{const{domNode:P,nodeDragThreshold:L}=c.getState();L===0&&O(q),k.current=!1;const U=E(q);m.current=U,x.current=(P==null?void 0:P.getBoundingClientRect())||null,N.current=pi(q.sourceEvent,x.current)}).on("drag",q=>{var B,j;const P=E(q),{autoPanOnNodeDrag:L,nodeDragThreshold:U}=c.getState();if(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!b.current&&S.current&&L&&(b.current=!0,M()),!S.current){const Q=P.xSnapped-(((B=m==null?void 0:m.current)==null?void 0:B.x)??0),H=P.ySnapped-(((j=m==null?void 0:m.current)==null?void 0:j.y)??0);Math.sqrt(Q*Q+H*H)>U&&O(q)}(m.current.x!==P.xSnapped||m.current.y!==P.ySnapped)&&f.current&&S.current&&(_.current=q.sourceEvent,N.current=pi(q.sourceEvent,x.current),I(P))}}).on("end",q=>{if(!(!S.current||k.current)&&(h(!1),b.current=!1,S.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:P,nodeInternals:L,onNodeDragStop:U,onSelectionDragStop:B}=c.getState(),j=o?U:vd(B);if(P(f.current,!1,!1),j){const[Q,H]=gd({nodeId:o,dragItems:f.current,nodeInternals:L});j(q.sourceEvent,Q,H)}}}).filter(q=>{const P=q.target;return!q.button&&(!r||!Jw(P,`.${r}`,e))&&(!s||Jw(P,s,e))});return C.call(W),()=>{C.on(".drag",null)}}}},[e,n,r,s,l,c,o,u,E]),p}function gN(){const e=Et();return A.useCallback(r=>{const{nodeInternals:s,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:p,onError:h,nodesDraggable:f}=e.getState(),m=u().filter(k=>k.selected&&(k.draggable||f&&typeof k.draggable>"u")),y=c?p[0]:5,x=c?p[1]:5,N=r.isShiftPressed?4:1,_=r.x*y*N,b=r.y*x*N,S=m.map(k=>{if(k.positionAbsolute){const E={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+b};c&&(E.x=p[0]*Math.round(E.x/p[0]),E.y=p[1]*Math.round(E.y/p[1]));const{positionAbsolute:C,position:I}=pN(k,E,s,o,void 0,h);k.position=I,k.positionAbsolute=C}return k});l(S,!0,!1)},[])}const Qs={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Qo=e=>{const n=({id:r,type:s,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:p,selected:h,onClick:f,onMouseEnter:m,onMouseMove:y,onMouseLeave:x,onContextMenu:N,onDoubleClick:_,style:b,className:S,isDraggable:k,isSelectable:E,isConnectable:C,isFocusable:I,selectNodesOnDrag:M,sourcePosition:O,targetPosition:W,hidden:q,resizeObserver:P,dragHandle:L,zIndex:U,isParent:B,noDragClassName:j,noPanClassName:Q,initialized:H,disableKeyboardA11y:te,ariaLabel:Z,rfId:D,hasHandleBounds:X})=>{const R=Et(),$=A.useRef(null),V=A.useRef(null),F=A.useRef(O),J=A.useRef(W),ne=A.useRef(s),le=E||k||f||m||y||x,de=gN(),me=Xo(r,R.getState,m),ve=Xo(r,R.getState,y),Pe=Xo(r,R.getState,x),Me=Xo(r,R.getState,N),Oe=Xo(r,R.getState,_),ye=xe=>{const{nodeDragThreshold:ge}=R.getState();if(E&&(!M||!k||ge>0)&&Jg({id:r,store:R,nodeRef:$}),f){const Fe=R.getState().nodeInternals.get(r);Fe&&f(xe,{...Fe})}},Se=xe=>{if(!Yg(xe)&&!te)if(zE.includes(xe.key)&&E){const ge=xe.key==="Escape";Jg({id:r,store:R,unselect:ge,nodeRef:$})}else k&&h&&Object.prototype.hasOwnProperty.call(Qs,xe.key)&&(R.setState({ariaLiveMessage:`Moved selected node ${xe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),de({x:Qs[xe.key].x,y:Qs[xe.key].y,isShiftPressed:xe.shiftKey}))};A.useEffect(()=>()=>{V.current&&(P==null||P.unobserve(V.current),V.current=null)},[]),A.useEffect(()=>{if($.current&&!q){const xe=$.current;(!H||!X||V.current!==xe)&&(V.current&&(P==null||P.unobserve(V.current)),P==null||P.observe(xe),V.current=xe)}},[q,H,X]),A.useEffect(()=>{const xe=ne.current!==s,ge=F.current!==O,Fe=J.current!==W;$.current&&(xe||ge||Fe)&&(xe&&(ne.current=s),ge&&(F.current=O),Fe&&(J.current=W),R.getState().updateNodeDimensions([{id:r,nodeElement:$.current,forceUpdate:!0}]))},[r,s,O,W]);const Ke=mN({nodeRef:$,disabled:q||!k,noDragClassName:j,handleSelector:L,nodeId:r,isSelectable:E,selectNodesOnDrag:M});return q?null:ae.createElement("div",{className:Lt(["react-flow__node",`react-flow__node-${s}`,{[Q]:k},S,{selected:h,selectable:E,parent:B,dragging:Ke}]),ref:$,style:{zIndex:U,transform:`translate(${c}px,${p}px)`,pointerEvents:le?"all":"none",visibility:H?"visible":"hidden",...b},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:me,onMouseMove:ve,onMouseLeave:Pe,onContextMenu:Me,onClick:ye,onDoubleClick:Oe,onKeyDown:I?Se:void 0,tabIndex:I?0:void 0,role:I?"button":void 0,"aria-describedby":te?void 0:`${aN}-${D}`,"aria-label":Z},ae.createElement(jI,{value:r},ae.createElement(e,{id:r,data:o,type:s,xPos:l,yPos:u,selected:h,isConnectable:C,sourcePosition:O,targetPosition:W,dragging:Ke,dragHandle:L,zIndex:U})))};return n.displayName="NodeWrapper",A.memo(n)};const yM=e=>{const n=e.getNodes().filter(r=>r.selected);return{...pu(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function wM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:r}){const s=Et(),{width:o,height:l,x:u,y:c,transformString:p,userSelectionActive:h}=Xe(yM,kt),f=gN(),m=A.useRef(null);if(A.useEffect(()=>{var N;r||(N=m.current)==null||N.focus({preventScroll:!0})},[r]),mN({nodeRef:m}),h||!o||!l)return null;const y=e?N=>{const _=s.getState().getNodes().filter(b=>b.selected);e(N,_)}:void 0,x=N=>{Object.prototype.hasOwnProperty.call(Qs,N.key)&&f({x:Qs[N.key].x,y:Qs[N.key].y,isShiftPressed:N.shiftKey})};return ae.createElement("div",{className:Lt(["react-flow__nodesselection","react-flow__container",n]),style:{transform:p}},ae.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:r?void 0:-1,onKeyDown:r?void 0:x,style:{width:o,height:l,top:c,left:u}}))}var xM=A.memo(wM);const _M=e=>e.nodesSelectionActive,vN=({children:e,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:p,onMoveStart:h,onMoveEnd:f,selectionKeyCode:m,selectionOnDrag:y,selectionMode:x,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:b,panActivationKeyCode:S,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:M,panOnScrollSpeed:O,panOnScrollMode:W,zoomOnDoubleClick:q,panOnDrag:P,defaultViewport:L,translateExtent:U,minZoom:B,maxZoom:j,preventScrolling:Q,onSelectionContextMenu:H,noWheelClassName:te,noPanClassName:Z,disableKeyboardA11y:D})=>{const X=Xe(_M),R=fa(m),$=fa(S),V=$||P,F=$||M,J=R||y&&V!==!0;return sM({deleteKeyCode:c,multiSelectionKeyCode:b}),ae.createElement(uM,{onMove:p,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:I,panOnScroll:F,panOnScrollSpeed:O,panOnScrollMode:W,zoomOnDoubleClick:q,panOnDrag:!R&&V,defaultViewport:L,translateExtent:U,minZoom:B,maxZoom:j,zoomActivationKeyCode:k,preventScrolling:Q,noWheelClassName:te,noPanClassName:Z},ae.createElement(fN,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:s,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:V,isSelecting:!!J,selectionMode:x},e,X&&ae.createElement(xM,{onSelectionContextMenu:H,noPanClassName:Z,disableKeyboardA11y:D})))};vN.displayName="FlowRenderer";var bM=A.memo(vN);function SM(e){return Xe(A.useCallback(r=>e?YE(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function kM(e){const n={input:Qo(e.input||rN),default:Qo(e.default||Zg),output:Qo(e.output||sN),group:Qo(e.group||Ev)},r={},s=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=Qo(e[l]||Zg),o),r);return{...n,...s}}const EM=({x:e,y:n,width:r,height:s,origin:o})=>!r||!s?{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-s*o[1]},NM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),yN=e=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:s,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Xe(NM,kt),c=SM(e.onlyRenderVisibleElements),p=A.useRef(),h=A.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(m=>{const y=m.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));l(y)});return p.current=f,f},[]);return A.useEffect(()=>()=>{var f;(f=p==null?void 0:p.current)==null||f.disconnect()},[]),ae.createElement("div",{className:"react-flow__nodes",style:Nv},c.map(f=>{var I,M,O;let m=f.type||"default";e.nodeTypes[m]||(u==null||u("003",Pr.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,x=!!(f.draggable||n&&typeof f.draggable>"u"),N=!!(f.selectable||o&&typeof f.selectable>"u"),_=!!(f.connectable||r&&typeof f.connectable>"u"),b=!!(f.focusable||s&&typeof f.focusable>"u"),S=e.nodeExtent?wv(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,k=(S==null?void 0:S.x)??0,E=(S==null?void 0:S.y)??0,C=EM({x:k,y:E,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return ae.createElement(y,{key:f.id,id:f.id,className:f.className,style:f.style,type:m,data:f.data,sourcePosition:f.sourcePosition||Te.Bottom,targetPosition:f.targetPosition||Te.Top,hidden:f.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:!!f.selected,isDraggable:x,isSelectable:N,isConnectable:_,isFocusable:b,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((I=f[ht])==null?void 0:I.z)??0,isParent:!!((M=f[ht])!=null&&M.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((O=f[ht])!=null&&O.handleBounds)})}))};yN.displayName="NodeRenderer";var CM=A.memo(yN);const TM=(e,n,r)=>r===Te.Left?e-n:r===Te.Right?e+n:e,RM=(e,n,r)=>r===Te.Top?e-n:r===Te.Bottom?e+n:e,tx="react-flow__edgeupdater",nx=({position:e,centerX:n,centerY:r,radius:s=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>ae.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:Lt([tx,`${tx}-${c}`]),cx:TM(n,s,e),cy:RM(r,s,e),r:s,stroke:"transparent",fill:"transparent"}),jM=()=>!0;var Us=e=>{const n=({id:r,className:s,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:p,animated:h,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,style:b,source:S,target:k,sourceX:E,sourceY:C,targetX:I,targetY:M,sourcePosition:O,targetPosition:W,elementsSelectable:q,hidden:P,sourceHandleId:L,targetHandleId:U,onContextMenu:B,onMouseEnter:j,onMouseMove:Q,onMouseLeave:H,reconnectRadius:te,onReconnect:Z,onReconnectStart:D,onReconnectEnd:X,markerEnd:R,markerStart:$,rfId:V,ariaLabel:F,isFocusable:J,isReconnectable:ne,pathOptions:le,interactionWidth:de,disableKeyboardA11y:me})=>{const ve=A.useRef(null),[Pe,Me]=A.useState(!1),[Oe,ye]=A.useState(!1),Se=Et(),Ke=A.useMemo(()=>`url('#${Xg($,V)}')`,[$,V]),xe=A.useMemo(()=>`url('#${Xg(R,V)}')`,[R,V]);if(P)return null;const ge=Ye=>{var Ct;const{edges:Nt,addSelectedEdges:dt,unselectNodesAndEdges:lt,multiSelectionActive:fn}=Se.getState(),Ut=Nt.find(Je=>Je.id===r);Ut&&(q&&(Se.setState({nodesSelectionActive:!1}),Ut.selected&&fn?(lt({nodes:[],edges:[Ut]}),(Ct=ve.current)==null||Ct.blur()):dt([r])),u&&u(Ye,Ut))},Fe=Ko(r,Se.getState,c),pt=Ko(r,Se.getState,B),mt=Ko(r,Se.getState,j),Ze=Ko(r,Se.getState,Q),De=Ko(r,Se.getState,H),Qe=(Ye,Nt)=>{if(Ye.button!==0)return;const{edges:dt,isValidConnection:lt}=Se.getState(),fn=Nt?k:S,Ut=(Nt?U:L)||null,Ct=Nt?"target":"source",Je=lt||jM,hr=Nt,Ht=dt.find(Tt=>Tt.id===r);ye(!0),D==null||D(Ye,Ht,Ct);const hn=Tt=>{ye(!1),X==null||X(Tt,Ht,Ct)};JE({event:Ye,handleId:Ut,nodeId:fn,onConnect:Tt=>Z==null?void 0:Z(Ht,Tt),isTarget:hr,getState:Se.getState,setState:Se.setState,isValidConnection:Je,edgeUpdaterType:Ct,onReconnectEnd:hn})},at=Ye=>Qe(Ye,!0),It=Ye=>Qe(Ye,!1),it=()=>Me(!0),gt=()=>Me(!1),Kt=!q&&!u,Mt=Ye=>{var Nt;if(!me&&zE.includes(Ye.key)&&q){const{unselectNodesAndEdges:dt,addSelectedEdges:lt,edges:fn}=Se.getState();Ye.key==="Escape"?((Nt=ve.current)==null||Nt.blur(),dt({edges:[fn.find(Ct=>Ct.id===r)]})):lt([r])}};return ae.createElement("g",{className:Lt(["react-flow__edge",`react-flow__edge-${o}`,s,{selected:p,animated:h,inactive:Kt,updating:Pe}]),onClick:ge,onDoubleClick:Fe,onContextMenu:pt,onMouseEnter:mt,onMouseMove:Ze,onMouseLeave:De,onKeyDown:J?Mt:void 0,tabIndex:J?0:void 0,role:J?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":F===null?void 0:F||`Edge from ${S} to ${k}`,"aria-describedby":J?`${lN}-${V}`:void 0,ref:ve},!Oe&&ae.createElement(e,{id:r,source:S,target:k,selected:p,animated:h,label:f,labelStyle:m,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,data:l,style:b,sourceX:E,sourceY:C,targetX:I,targetY:M,sourcePosition:O,targetPosition:W,sourceHandleId:L,targetHandleId:U,markerStart:Ke,markerEnd:xe,pathOptions:le,interactionWidth:de}),ne&&ae.createElement(ae.Fragment,null,(ne==="source"||ne===!0)&&ae.createElement(nx,{position:O,centerX:E,centerY:C,radius:te,onMouseDown:at,onMouseEnter:it,onMouseOut:gt,type:"source"}),(ne==="target"||ne===!0)&&ae.createElement(nx,{position:W,centerX:I,centerY:M,radius:te,onMouseDown:It,onMouseEnter:it,onMouseOut:gt,type:"target"})))};return n.displayName="EdgeWrapper",A.memo(n)};function AM(e){const n={default:Us(e.default||ru),straight:Us(e.bezier||bv),step:Us(e.step||_v),smoothstep:Us(e.step||hu),simplebezier:Us(e.simplebezier||xv)},r={},s=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Us(e[l]||ru),o),r);return{...n,...s}}function rx(e,n,r=null){const s=((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 Te.Top:return{x:s+l/2,y:o};case Te.Right:return{x:s+l,y:o+u/2};case Te.Bottom:return{x:s+l/2,y:o+u};case Te.Left:return{x:s,y:o+u/2}}}function ix(e,n){return e?e.length===1||!n?e[0]:n&&e.find(r=>r.id===n)||null:null}const IM=(e,n,r,s,o,l)=>{const u=rx(r,e,n),c=rx(l,s,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function MM({sourcePos:e,targetPos:n,sourceWidth:r,sourceHeight:s,targetWidth:o,targetHeight:l,width:u,height:c,transform:p}){const h={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+s,n.y+l)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=ca({x:(0-p[0])/p[2],y:(0-p[1])/p[2],width:u/p[2],height:c/p[2]}),m=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),y=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(m*y)>0}function sx(e){var s,o,l,u,c;const n=((s=e==null?void 0:e[ht])==null?void 0:s.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 PM=[{level:0,isMaxLevel:!0,edges:[]}];function OM(e,n,r=!1){let s=-1;const o=e.reduce((u,c)=>{var f,m;const p=En(c.zIndex);let h=p?c.zIndex:0;if(r){const y=n.get(c.target),x=n.get(c.source),N=c.selected||(y==null?void 0:y.selected)||(x==null?void 0:x.selected),_=Math.max(((f=x==null?void 0:x[ht])==null?void 0:f.z)||0,((m=y==null?void 0:y[ht])==null?void 0:m.z)||0,1e3);h=(p?c.zIndex:0)+(N?_:0)}return u[h]?u[h].push(c):u[h]=[c],s=h>s?h:s,u},{}),l=Object.entries(o).map(([u,c])=>{const p=+u;return{edges:c,level:p,isMaxLevel:p===s}});return l.length===0?PM:l}function qM(e,n,r){const s=Xe(A.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)&&MM({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 OM(s,n,r)}const LM=({color:e="none",strokeWidth:n=1})=>ae.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),$M=({color:e="none",strokeWidth:n=1})=>ae.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),ox={[nu.Arrow]:LM,[nu.ArrowClosed]:$M};function DM(e){const n=Et();return A.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(ox,e)?ox[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Pr.error009(e)),null)},[e])}const FM=({id:e,type:n,color:r,width:s=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const p=DM(n);return p?ae.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},ae.createElement(p,{color:r,strokeWidth:u})):null},zM=({defaultColor:e,rfId:n})=>r=>{const s=[];return r.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=Xg(u,n);s.includes(c)||(o.push({id:c,color:u.color||e,...u}),s.push(c))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))},wN=({defaultColor:e,rfId:n})=>{const r=Xe(A.useCallback(zM({defaultColor:e,rfId:n}),[e,n]),(s,o)=>!(s.length!==o.length||s.some((l,u)=>l.id!==o[u].id)));return ae.createElement("defs",null,r.map(s=>ae.createElement(FM,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};wN.displayName="MarkerDefinitions";var BM=A.memo(wN);const UM=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}),xN=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:r,rfId:s,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:p,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,children:b,disableKeyboardA11y:S})=>{const{edgesFocusable:k,edgesUpdatable:E,elementsSelectable:C,width:I,height:M,connectionMode:O,nodeInternals:W,onError:q}=Xe(UM,kt),P=qM(n,W,r);return I?ae.createElement(ae.Fragment,null,P.map(({level:L,edges:U,isMaxLevel:B})=>ae.createElement("svg",{key:L,style:{zIndex:L},width:I,height:M,className:"react-flow__edges react-flow__container"},B&&ae.createElement(BM,{defaultColor:e,rfId:s}),ae.createElement("g",null,U.map(j=>{const[Q,H,te]=sx(W.get(j.source)),[Z,D,X]=sx(W.get(j.target));if(!te||!X)return null;let R=j.type||"default";o[R]||(q==null||q("011",Pr.error011(R)),R="default");const $=o[R]||o.default,V=O===ns.Strict?D.target:(D.target??[]).concat(D.source??[]),F=ix(H.source,j.sourceHandle),J=ix(V,j.targetHandle),ne=(F==null?void 0:F.position)||Te.Bottom,le=(J==null?void 0:J.position)||Te.Top,de=!!(j.focusable||k&&typeof j.focusable>"u"),me=j.reconnectable||j.updatable,ve=typeof y<"u"&&(me||E&&typeof me>"u");if(!F||!J)return q==null||q("008",Pr.error008(F,j)),null;const{sourceX:Pe,sourceY:Me,targetX:Oe,targetY:ye}=IM(Q,F,ne,Z,J,le);return ae.createElement($,{key:j.id,id:j.id,className:Lt([j.className,l]),type:R,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:Pe,sourceY:Me,targetX:Oe,targetY:ye,sourcePosition:ne,targetPosition:le,elementsSelectable:C,onContextMenu:u,onMouseEnter:c,onMouseMove:p,onMouseLeave:h,onClick:f,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,rfId:s,ariaLabel:j.ariaLabel,isFocusable:de,isReconnectable:ve,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth,disableKeyboardA11y:S})})))),b):null};xN.displayName="EdgeRenderer";var HM=A.memo(xN);const WM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function VM({children:e}){const n=Xe(WM);return ae.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function GM(e){const n=wa(),r=A.useRef(!1);A.useEffect(()=>{!r.current&&n.viewportInitialized&&e&&(setTimeout(()=>e(n),1),r.current=!0)},[e,n.viewportInitialized])}const YM={[Te.Left]:Te.Right,[Te.Right]:Te.Left,[Te.Top]:Te.Bottom,[Te.Bottom]:Te.Top},_N=({nodeId:e,handleType:n,style:r,type:s=hi.Bezier,CustomComponent:o,connectionStatus:l})=>{var M,O,W;const{fromNode:u,handleId:c,toX:p,toY:h,connectionMode:f}=Xe(A.useCallback(q=>({fromNode:q.nodeInternals.get(e),handleId:q.connectionHandleId,toX:(q.connectionPosition.x-q.transform[0])/q.transform[2],toY:(q.connectionPosition.y-q.transform[1])/q.transform[2],connectionMode:q.connectionMode}),[e]),kt),m=(M=u==null?void 0:u[ht])==null?void 0:M.handleBounds;let y=m==null?void 0:m[n];if(f===ns.Loose&&(y=y||(m==null?void 0:m[n==="source"?"target":"source"])),!u||!y)return null;const x=c?y.find(q=>q.id===c):y[0],N=x?x.x+x.width/2:(u.width??0)/2,_=x?x.y+x.height/2:u.height??0,b=(((O=u.positionAbsolute)==null?void 0:O.x)??0)+N,S=(((W=u.positionAbsolute)==null?void 0:W.y)??0)+_,k=x==null?void 0:x.position,E=k?YM[k]:null;if(!k||!E)return null;if(o)return ae.createElement(o,{connectionLineType:s,connectionLineStyle:r,fromNode:u,fromHandle:x,fromX:b,fromY:S,toX:p,toY:h,fromPosition:k,toPosition:E,connectionStatus:l});let C="";const I={sourceX:b,sourceY:S,sourcePosition:k,targetX:p,targetY:h,targetPosition:E};return s===hi.Bezier?[C]=VE(I):s===hi.Step?[C]=Kg({...I,borderRadius:0}):s===hi.SmoothStep?[C]=Kg(I):s===hi.SimpleBezier?[C]=WE(I):C=`M${b},${S} ${p},${h}`,ae.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:r})};_N.displayName="ConnectionLine";const KM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function XM({containerStyle:e,style:n,type:r,component:s}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:p,connectionStatus:h}=Xe(KM,kt);return!(o&&l&&c&&u)?null:ae.createElement("svg",{style:e,width:c,height:p,className:"react-flow__edges react-flow__connectionline react-flow__container"},ae.createElement("g",{className:Lt(["react-flow__connection",h])},ae.createElement(_N,{nodeId:o,handleType:l,style:n,type:r,CustomComponent:s,connectionStatus:h})))}function ax(e,n){return A.useRef(null),Et(),A.useMemo(()=>n(e),[e])}const bN=({nodeTypes:e,edgeTypes:n,onMove:r,onMoveStart:s,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:p,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:b,connectionLineType:S,connectionLineStyle:k,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:I,selectionOnDrag:M,selectionMode:O,multiSelectionKeyCode:W,panActivationKeyCode:q,zoomActivationKeyCode:P,deleteKeyCode:L,onlyRenderVisibleElements:U,elementsSelectable:B,selectNodesOnDrag:j,defaultViewport:Q,translateExtent:H,minZoom:te,maxZoom:Z,preventScrolling:D,defaultMarkerColor:X,zoomOnScroll:R,zoomOnPinch:$,panOnScroll:V,panOnScrollSpeed:F,panOnScrollMode:J,zoomOnDoubleClick:ne,panOnDrag:le,onPaneClick:de,onPaneMouseEnter:me,onPaneMouseMove:ve,onPaneMouseLeave:Pe,onPaneScroll:Me,onPaneContextMenu:Oe,onEdgeContextMenu:ye,onEdgeMouseEnter:Se,onEdgeMouseMove:Ke,onEdgeMouseLeave:xe,onReconnect:ge,onReconnectStart:Fe,onReconnectEnd:pt,reconnectRadius:mt,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Qe,elevateEdgesOnSelect:at,disableKeyboardA11y:It,nodeOrigin:it,nodeExtent:gt,rfId:Kt})=>{const Mt=ax(e,kM),Ye=ax(n,AM);return GM(l),ae.createElement(bM,{onPaneClick:de,onPaneMouseEnter:me,onPaneMouseMove:ve,onPaneMouseLeave:Pe,onPaneContextMenu:Oe,onPaneScroll:Me,deleteKeyCode:L,selectionKeyCode:I,selectionOnDrag:M,selectionMode:O,onSelectionStart:_,onSelectionEnd:b,multiSelectionKeyCode:W,panActivationKeyCode:q,zoomActivationKeyCode:P,elementsSelectable:B,onMove:r,onMoveStart:s,onMoveEnd:o,zoomOnScroll:R,zoomOnPinch:$,zoomOnDoubleClick:ne,panOnScroll:V,panOnScrollSpeed:F,panOnScrollMode:J,panOnDrag:le,defaultViewport:Q,translateExtent:H,minZoom:te,maxZoom:Z,onSelectionContextMenu:N,preventScrolling:D,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Qe,disableKeyboardA11y:It},ae.createElement(VM,null,ae.createElement(HM,{edgeTypes:Ye,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:U,onEdgeContextMenu:ye,onEdgeMouseEnter:Se,onEdgeMouseMove:Ke,onEdgeMouseLeave:xe,onReconnect:ge,onReconnectStart:Fe,onReconnectEnd:pt,reconnectRadius:mt,defaultMarkerColor:X,noPanClassName:Qe,elevateEdgesOnSelect:!!at,disableKeyboardA11y:It,rfId:Kt},ae.createElement(XM,{style:k,type:S,component:E,containerStyle:C})),ae.createElement("div",{className:"react-flow__edgelabel-renderer"}),ae.createElement(CM,{nodeTypes:Mt,onNodeClick:u,onNodeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:x,selectNodesOnDrag:j,onlyRenderVisibleElements:U,noPanClassName:Qe,noDragClassName:Ze,disableKeyboardA11y:It,nodeOrigin:it,nodeExtent:gt,rfId:Kt})))};bN.displayName="GraphView";var QM=A.memo(bN);const ev=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ci={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:ns.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},ZM=()=>$R((e,n)=>({...ci,setNodes:r=>{const{nodeInternals:s,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:pd(r,s,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:s={}}=n();e({edges:r.map(o=>({...s,...o}))})},setDefaultNodesAndEdges:(r,s)=>{const o=typeof r<"u",l=typeof s<"u",u=o?pd(r,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?s:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:r=>{const{onNodesChange:s,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:p,nodeOrigin:h}=n(),f=p==null?void 0:p.querySelector(".react-flow__viewport");if(!f)return;const m=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(m.transform),x=r.reduce((_,b)=>{const S=o.get(b.id);if(S!=null&&S.hidden)o.set(S.id,{...S,[ht]:{...S[ht],handleBounds:void 0}});else if(S){const k=yv(b.nodeElement);!!(k.width&&k.height&&(S.width!==k.width||S.height!==k.height||b.forceUpdate))&&(o.set(S.id,{...S,[ht]:{...S[ht],handleBounds:{source:ex(".source",b.nodeElement,y,h),target:ex(".target",b.nodeElement,y,h)}},...k}),_.push({id:S.id,type:"dimensions",dimensions:k}))}return _},[]);cN(o,h);const N=u||l&&!u&&dN(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:N}),(x==null?void 0:x.length)>0&&(s==null||s(x))},updateNodePositions:(r,s=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=r.map(c=>{const p={id:c.id,type:"position",dragging:o};return s&&(p.positionAbsolute=c.positionAbsolute,p.position=c.position),p});l(u)},triggerNodeChanges:r=>{const{onNodesChange:s,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:p}=n();if(r!=null&&r.length){if(l){const h=hM(r,c()),f=pd(h,o,u,p);e({nodeInternals:f})}s==null||s(r)}},addSelectedNodes:r=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=r.map(p=>fi(p,!0)):(u=Vs(l(),r),c=Vs(o,[])),Ol({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:s,edges:o,getNodes:l}=n();let u,c=null;s?u=r.map(p=>fi(p,!0)):(u=Vs(o,r),c=Vs(l(),[])),Ol({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:r,edges:s}={})=>{const{edges:o,getNodes:l}=n(),u=r||l(),c=s||o,p=u.map(f=>(f.selected=!1,fi(f.id,!1))),h=c.map(f=>fi(f.id,!1));Ol({changedNodes:p,changedEdges:h,get:n,set:e})},setMinZoom:r=>{const{d3Zoom:s,maxZoom:o}=n();s==null||s.scaleExtent([r,o]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:s,minZoom:o}=n();s==null||s.scaleExtent([o,r]),e({maxZoom:r})},setTranslateExtent:r=>{var s;(s=n().d3Zoom)==null||s.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:s}=n(),l=s().filter(c=>c.selected).map(c=>fi(c.id,!1)),u=r.filter(c=>c.selected).map(c=>fi(c.id,!1));Ol({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:r=>{const{nodeInternals:s}=n();s.forEach(o=>{o.positionAbsolute=wv(o.position,r)}),e({nodeExtent:r,nodeInternals:new Map(s)})},panBy:r=>{const{transform:s,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:p}=n();if(!u||!c||!r.x&&!r.y)return!1;const h=Ir.translate(s[0]+r.x,s[1]+r.y).scale(s[2]),f=[[0,0],[o,l]],m=u==null?void 0:u.constrain()(h,f,p);return u.transform(c,m),s[0]!==m.x||s[1]!==m.y||s[2]!==m.k},cancelConnection:()=>e({connectionNodeId:ci.connectionNodeId,connectionHandleId:ci.connectionHandleId,connectionHandleType:ci.connectionHandleType,connectionStatus:ci.connectionStatus,connectionStartHandle:ci.connectionStartHandle,connectionEndHandle:ci.connectionEndHandle}),reset:()=>e({...ci})}),Object.is),Cv=({children:e})=>{const n=A.useRef(null);return n.current||(n.current=ZM()),ae.createElement(vI,{value:n.current},e)};Cv.displayName="ReactFlowProvider";const SN=({children:e})=>A.useContext(fu)?ae.createElement(ae.Fragment,null,e):ae.createElement(Cv,null,e);SN.displayName="ReactFlowWrapper";const JM={input:rN,default:Zg,output:sN,group:Ev},eP={default:ru,straight:bv,step:_v,smoothstep:hu,simplebezier:xv},tP=[0,0],nP=[15,15],rP={x:0,y:0,zoom:1},iP={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},kN=A.forwardRef(({nodes:e,edges:n,defaultNodes:r,defaultEdges:s,className:o,nodeTypes:l=JM,edgeTypes:u=eP,onNodeClick:c,onEdgeClick:p,onInit:h,onMove:f,onMoveStart:m,onMoveEnd:y,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:b,onClickConnectEnd:S,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:M,onNodeDragStart:O,onNodeDrag:W,onNodeDragStop:q,onNodesDelete:P,onEdgesDelete:L,onSelectionChange:U,onSelectionDragStart:B,onSelectionDrag:j,onSelectionDragStop:Q,onSelectionContextMenu:H,onSelectionStart:te,onSelectionEnd:Z,connectionMode:D=ns.Strict,connectionLineType:X=hi.Bezier,connectionLineStyle:R,connectionLineComponent:$,connectionLineContainerStyle:V,deleteKeyCode:F="Backspace",selectionKeyCode:J="Shift",selectionOnDrag:ne=!1,selectionMode:le=da.Full,panActivationKeyCode:de="Space",multiSelectionKeyCode:me=tu()?"Meta":"Control",zoomActivationKeyCode:ve=tu()?"Meta":"Control",snapToGrid:Pe=!1,snapGrid:Me=nP,onlyRenderVisibleElements:Oe=!1,selectNodesOnDrag:ye=!0,nodesDraggable:Se,nodesConnectable:Ke,nodesFocusable:xe,nodeOrigin:ge=tP,edgesFocusable:Fe,edgesUpdatable:pt,elementsSelectable:mt,defaultViewport:Ze=rP,minZoom:De=.5,maxZoom:Qe=2,translateExtent:at=ev,preventScrolling:It=!0,nodeExtent:it,defaultMarkerColor:gt="#b1b1b7",zoomOnScroll:Kt=!0,zoomOnPinch:Mt=!0,panOnScroll:Ye=!1,panOnScrollSpeed:Nt=.5,panOnScrollMode:dt=Zi.Free,zoomOnDoubleClick:lt=!0,panOnDrag:fn=!0,onPaneClick:Ut,onPaneMouseEnter:Ct,onPaneMouseMove:Je,onPaneMouseLeave:hr,onPaneScroll:Ht,onPaneContextMenu:hn,children:Tn,onEdgeContextMenu:Tt,onEdgeDoubleClick:pr,onEdgeMouseEnter:as,onEdgeMouseMove:ls,onEdgeMouseLeave:vi,onEdgeUpdate:Lr,onEdgeUpdateStart:Rn,onEdgeUpdateEnd:Zn,onReconnect:$r,onReconnectStart:pn,onReconnectEnd:us,reconnectRadius:jn=10,edgeUpdaterRadius:yt=10,onNodesChange:An,onEdgesChange:Jn,noDragClassName:In="nodrag",noWheelClassName:cs="nowheel",noPanClassName:yi="nopan",fitView:Mn=!1,fitViewOptions:er,connectOnClick:wi=!0,attributionPosition:ds,proOptions:fs,defaultEdgeOptions:xi,elevateNodesOnSelect:_i=!0,elevateEdgesOnSelect:Dr=!1,disableKeyboardA11y:Pn=!1,autoPanOnConnect:co=!0,autoPanOnNodeDrag:Be=!0,connectionRadius:bi=20,isValidConnection:mr,onError:Si,style:On,id:Fr,nodeDragThreshold:mn,...gr},Wt)=>{const zr=Fr||"1";return ae.createElement("div",{...gr,style:{...On,...iP},ref:Wt,className:Lt(["react-flow",o]),"data-testid":"rf__wrapper",id:Fr},ae.createElement(SN,null,ae.createElement(QM,{onInit:h,onMove:f,onMoveStart:m,onMoveEnd:y,onNodeClick:c,onEdgeClick:p,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:I,onNodeDoubleClick:M,nodeTypes:l,edgeTypes:u,connectionLineType:X,connectionLineStyle:R,connectionLineComponent:$,connectionLineContainerStyle:V,selectionKeyCode:J,selectionOnDrag:ne,selectionMode:le,deleteKeyCode:F,multiSelectionKeyCode:me,panActivationKeyCode:de,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Oe,selectNodesOnDrag:ye,defaultViewport:Ze,translateExtent:at,minZoom:De,maxZoom:Qe,preventScrolling:It,zoomOnScroll:Kt,zoomOnPinch:Mt,zoomOnDoubleClick:lt,panOnScroll:Ye,panOnScrollSpeed:Nt,panOnScrollMode:dt,panOnDrag:fn,onPaneClick:Ut,onPaneMouseEnter:Ct,onPaneMouseMove:Je,onPaneMouseLeave:hr,onPaneScroll:Ht,onPaneContextMenu:hn,onSelectionContextMenu:H,onSelectionStart:te,onSelectionEnd:Z,onEdgeContextMenu:Tt,onEdgeDoubleClick:pr,onEdgeMouseEnter:as,onEdgeMouseMove:ls,onEdgeMouseLeave:vi,onReconnect:$r??Lr,onReconnectStart:pn??Rn,onReconnectEnd:us??Zn,reconnectRadius:jn??yt,defaultMarkerColor:gt,noDragClassName:In,noWheelClassName:cs,noPanClassName:yi,elevateEdgesOnSelect:Dr,rfId:zr,disableKeyboardA11y:Pn,nodeOrigin:ge,nodeExtent:it}),ae.createElement(GI,{nodes:e,edges:n,defaultNodes:r,defaultEdges:s,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:b,onClickConnectEnd:S,nodesDraggable:Se,nodesConnectable:Ke,nodesFocusable:xe,edgesFocusable:Fe,edgesUpdatable:pt,elementsSelectable:mt,elevateNodesOnSelect:_i,minZoom:De,maxZoom:Qe,nodeExtent:it,onNodesChange:An,onEdgesChange:Jn,snapToGrid:Pe,snapGrid:Me,connectionMode:D,translateExtent:at,connectOnClick:wi,defaultEdgeOptions:xi,fitView:Mn,fitViewOptions:er,onNodesDelete:P,onEdgesDelete:L,onNodeDragStart:O,onNodeDrag:W,onNodeDragStop:q,onSelectionDrag:j,onSelectionDragStart:B,onSelectionDragStop:Q,noPanClassName:yi,nodeOrigin:ge,rfId:zr,autoPanOnConnect:co,autoPanOnNodeDrag:Be,onError:Si,connectionRadius:bi,isValidConnection:mr,nodeDragThreshold:mn}),ae.createElement(WI,{onSelectionChange:U}),Tn,ae.createElement(wI,{proOptions:fs,position:ds}),ae.createElement(ZI,{rfId:zr,disableKeyboardA11y:Pn})))});kN.displayName="ReactFlow";const sP=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function EN(){return Xe(sP,kt)}const NN=({id:e,x:n,y:r,width:s,height:o,style:l,color:u,strokeColor:c,strokeWidth:p,className:h,borderRadius:f,shapeRendering:m,onClick:y,selected:x})=>{const{background:N,backgroundColor:_}=l||{},b=u||N||_;return ae.createElement("rect",{className:Lt(["react-flow__minimap-node",{selected:x},h]),x:n,y:r,rx:f,ry:f,width:s,height:o,fill:b,stroke:c,strokeWidth:p,shapeRendering:m,onClick:y?S=>y(S,e):void 0})};NN.displayName="MiniMapNode";var oP=A.memo(NN);const aP=e=>e.nodeOrigin,lP=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),yd=e=>e instanceof Function?e:()=>e;function uP({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:s=5,nodeStrokeWidth:o=2,nodeComponent:l=oP,onClick:u}){const c=Xe(lP,kt),p=Xe(aP),h=yd(n),f=yd(e),m=yd(r),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ae.createElement(ae.Fragment,null,c.map(x=>{const{x:N,y:_}=es(x,p).positionAbsolute;return ae.createElement(l,{key:x.id,x:N,y:_,width:x.width,height:x.height,style:x.style,selected:x.selected,className:m(x),color:h(x),borderRadius:s,strokeColor:f(x),strokeWidth:o,shapeRendering:y,onClick:u,id:x.id})}))}var cP=A.memo(uP);const dP=200,fP=150,hP=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?bI(pu(n,e.nodeOrigin),r):r,rfId:e.rfId}},pP="react-flow__minimap-desc";function CN({style:e,className:n,nodeStrokeColor:r="transparent",nodeColor:s="#e2e2e2",nodeClassName:o="",nodeBorderRadius:l=5,nodeStrokeWidth:u=2,nodeComponent:c,maskColor:p="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:m="bottom-right",onClick:y,onNodeClick:x,pannable:N=!1,zoomable:_=!1,ariaLabel:b="React Flow mini map",inversePan:S=!1,zoomStep:k=10,offsetScale:E=5}){const C=Et(),I=A.useRef(null),{boundingRect:M,viewBB:O,rfId:W}=Xe(hP,kt),q=(e==null?void 0:e.width)??dP,P=(e==null?void 0:e.height)??fP,L=M.width/q,U=M.height/P,B=Math.max(L,U),j=B*q,Q=B*P,H=E*B,te=M.x-(j-M.width)/2-H,Z=M.y-(Q-M.height)/2-H,D=j+H*2,X=Q+H*2,R=`${pP}-${W}`,$=A.useRef(0);$.current=B,A.useEffect(()=>{if(I.current){const J=kn(I.current),ne=me=>{const{transform:ve,d3Selection:Pe,d3Zoom:Me}=C.getState();if(me.sourceEvent.type!=="wheel"||!Pe||!Me)return;const Oe=-me.sourceEvent.deltaY*(me.sourceEvent.deltaMode===1?.05:me.sourceEvent.deltaMode?1:.002)*k,ye=ve[2]*Math.pow(2,Oe);Me.scaleTo(Pe,ye)},le=me=>{const{transform:ve,d3Selection:Pe,d3Zoom:Me,translateExtent:Oe,width:ye,height:Se}=C.getState();if(me.sourceEvent.type!=="mousemove"||!Pe||!Me)return;const Ke=$.current*Math.max(1,ve[2])*(S?-1:1),xe={x:ve[0]-me.sourceEvent.movementX*Ke,y:ve[1]-me.sourceEvent.movementY*Ke},ge=[[0,0],[ye,Se]],Fe=Ir.translate(xe.x,xe.y).scale(ve[2]),pt=Me.constrain()(Fe,ge,Oe);Me.transform(Pe,pt)},de=OE().on("zoom",N?le:null).on("zoom.wheel",_?ne:null);return J.call(de),()=>{J.on("zoom",null)}}},[N,_,S,k]);const V=y?J=>{const ne=Vn(J);y(J,{x:ne[0],y:ne[1]})}:void 0,F=x?(J,ne)=>{const le=C.getState().nodeInternals.get(ne);x(J,le)}:void 0;return ae.createElement(vv,{position:m,style:e,className:Lt(["react-flow__minimap",n]),"data-testid":"rf__minimap"},ae.createElement("svg",{width:q,height:P,viewBox:`${te} ${Z} ${D} ${X}`,role:"img","aria-labelledby":R,ref:I,onClick:V},b&&ae.createElement("title",{id:R},b),ae.createElement(cP,{onClick:F,nodeColor:s,nodeStrokeColor:r,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),ae.createElement("path",{className:"react-flow__minimap-mask",d:`M${te-H},${Z-H}h${D+H*2}v${X+H*2}h${-D-H*2}z
|
|
57
|
-
M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fill:p,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}CN.displayName="MiniMap";var mP=A.memo(CN);function gP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ae.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function vP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ae.createElement("path",{d:"M0 0h32v4.2H0z"}))}function yP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ae.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 wP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ae.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 xP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ae.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 Gs=({children:e,className:n,...r})=>ae.createElement("button",{type:"button",className:Lt(["react-flow__controls-button",n]),...r},e);Gs.displayName="ControlButton";const _P=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),TN=({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:p,className:h,children:f,position:m="bottom-left"})=>{const y=Et(),[x,N]=A.useState(!1),{isInteractive:_,minZoomReached:b,maxZoomReached:S}=Xe(_P,kt),{zoomIn:k,zoomOut:E,fitView:C}=wa();if(A.useEffect(()=>{N(!0)},[]),!x)return null;const I=()=>{k(),l==null||l()},M=()=>{E(),u==null||u()},O=()=>{C(o),c==null||c()},W=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),p==null||p(!_)};return ae.createElement(vv,{className:Lt(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&ae.createElement(ae.Fragment,null,ae.createElement(Gs,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ae.createElement(gP,null)),ae.createElement(Gs,{onClick:M,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ae.createElement(vP,null))),r&&ae.createElement(Gs,{className:"react-flow__controls-fitview",onClick:O,title:"fit view","aria-label":"fit view"},ae.createElement(yP,null)),s&&ae.createElement(Gs,{className:"react-flow__controls-interactive",onClick:W,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ae.createElement(xP,null):ae.createElement(wP,null)),f)};TN.displayName="Controls";var bP=A.memo(TN),Yn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Yn||(Yn={}));function SP({color:e,dimensions:n,lineWidth:r}){return ae.createElement("path",{stroke:e,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function kP({color:e,radius:n}){return ae.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const EP={[Yn.Dots]:"#91919a",[Yn.Lines]:"#eee",[Yn.Cross]:"#e2e2e2"},NP={[Yn.Dots]:1,[Yn.Lines]:1,[Yn.Cross]:6},CP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function RN({id:e,variant:n=Yn.Dots,gap:r=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:p}){const h=A.useRef(null),{transform:f,patternId:m}=Xe(CP,kt),y=u||EP[n],x=s||NP[n],N=n===Yn.Dots,_=n===Yn.Cross,b=Array.isArray(r)?r:[r,r],S=[b[0]*f[2]||1,b[1]*f[2]||1],k=x*f[2],E=_?[k,k]:S,C=N?[k/l,k/l]:[E[0]/l,E[1]/l];return ae.createElement("svg",{className:Lt(["react-flow__background",p]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},ae.createElement("pattern",{id:m+e,x:f[0]%S[0],y:f[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},N?ae.createElement(kP,{color:y,radius:k/l}):ae.createElement(SP,{dimensions:E,color:y,lineWidth:o})),ae.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}RN.displayName="Background";var TP=A.memo(RN);function jN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function AN(e){const n=e.cache_creation,r=n&&typeof n=="object"?n:e,s=r.ephemeral_1h_input_tokens,o=r.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(o??0)}}function IN(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),...AN(r)};for(const s of Object.values(r)){const o=IN(s,n+1);if(o)return o}return null}function RP(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 jP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function MN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&jP.test(r.model))return r.model;for(const s of Object.values(r)){const o=MN(s,n+1);if(o)return o}return null}function tv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function mi(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Tv(e,n){return`${e}::${n}`}function iu(e){return e.agent_type??e.subagent_type??"subagent"}function nv(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function ia(e,n,r,s){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:r,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:jN()},e.agents.set(o,l),l)}function PN(e,n,r,s){const o=Tv(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=mi(s.cwd));const u=iu(s);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function lx(e,n,r){const s=n.session_id??"unknown",o=nv(n);if(o){const p=PN(e,s,o,n);if(p)return p}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const p=e.agents.get(Tv(s,u));if(p)return!p.cwd&&n.cwd&&(p.cwd=n.cwd,p.cwdBasename=mi(n.cwd)),p}const c=ia(e,s,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=mi(n.cwd)),c.label==="session"&&n.cwd&&(c.label=mi(n.cwd)??"session"),c}function AP(e,n,r,s,o){const l=Tv(n,r),u=ia(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=mi(s.cwd));const p=iu(s);return p&&(c.label==="subagent"||!c.label)&&(c.label=p),c}return c={id:l,sessionId:n,label:iu(s),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:mi(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:jN()},e.agents.set(l,c),u.childCount+=1,c}function IP(e,n,r){const s=e.activeSubagentStack.get(n)??[];s.includes(r)||(s.push(r),e.activeSubagentStack.set(n,s))}function MP(e,n,r){const s=e.activeSubagentStack.get(n);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===r){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(n)}}function Ll(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)}}function Ys(e){let n=null;for(let r=e.tools.length-1;r>=0;r--){const s=e.tools[r];if(s.endedAt==null){n=s;break}}e.inFlightTool=n}const ux=200,PP=25;function OP(e,n){const r=n.tools;if(r.length>ux){const s=r.splice(0,r.length-ux);let o=!1;for(const l of s)e.toolIndex.delete(l.id)&&(o=!0),e.toolOwner.delete(l.id);o&&Ys(n)}for(let s=r.length-PP-1;s>=0;s--){const o=r[s];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function qP(e,n,r){const s=e.toolIndex.get(r);if(s)return s;for(let o=n.tools.length-1;o>=0;o--)if(n.tools[o].id===r)return n.tools[o];return null}const cx=2e3;function LP(e,n,r){for(let s=e.prompts.length-1;s>=0;s--){const o=e.prompts[s];if(o.at<n-cx)return!1;if(o.text===r&&o.at<=n+cx)return!0}return!1}function $P(e,n,r,s){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>s&&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 DP(e,n,r,s){const o=new Map;for(const[h,f]of e.agents){let m=o.get(f.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(f.sessionId,m)),m.ids.push(h),f.state==="done"&&f.endedAt!=null?m.endedAt=Math.max(m.endedAt,f.endedAt):m.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>s).sort((h,f)=>h.endedAt-f.endedAt);let c=[...o.values()].filter(h=>!h.live).length-r;if(c<=0)return!1;let p=!1;for(const h of l){if(c<=0)break;for(const f of h.ids)e.agents.delete(f);c--,p=!0}return p}function FP(e,n,r){let s=!1;for(const o of e.agents.values()){let l=!1;for(const u of o.tools)u.endedAt==null&&n-u.startedAt>r&&(u.endedAt=u.startedAt+r,u.ok=!1,u.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),l=!0,s=!0);l&&Ys(o)}return s}function dx(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 s=n.payload??{},o=n.receivedAt,l=s.hook_event_name??"Unknown";if(l==="__clear")return{...tv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=s.session_id??"unknown";if(typeof s.model_context_window=="number"&&s.model_context_window>0){const h=e.agents.get(u);h&&(h.contextWindow=s.model_context_window)}if(l==="ModelObserved"){const h=typeof s.model=="string"?s.model:null;if(h){const m=e.agents.get(u);m&&(m.model=h)}const f=s.subagentModels;if(f&&typeof f=="object")for(const[m,y]of Object.entries(f)){if(typeof y!="string")continue;const x=`${u}::${m}`,N=e.agents.get(x);N&&(N.model=y)}return e}if(l==="ContextObserved"){const h=s.context??null;if(h){const f=e.agents.get(u);f&&(f.context={msgsUser:Number(h.msgsUser??0),msgsAssistant:Number(h.msgsAssistant??0),toolUses:Number(h.toolUses??0),toolResults:Number(h.toolResults??0),systemReminders:Number(h.systemReminders??0),currentContextTokens:Number(h.currentContextTokens??0),claudeMdFiles:Array.isArray(h.claudeMdFiles)?h.claudeMdFiles:[]})}return e}if(l==="UsageObserved"){const h=s.usage??null;if(h){const f=e.agents.get(u);if(f){f.usage.inputTokens=Number(h.input_tokens??0),f.usage.outputTokens=Number(h.output_tokens??0),f.usage.cacheReadTokens=Number(h.cache_read_input_tokens??h.cached_input_tokens??0),f.usage.cacheCreateTokens=Number(h.cache_creation_input_tokens??0);const m=AN(h);f.usage.cacheCreate1hTokens=m.cacheCreate1hTokens,f.usage.cacheCreate5mTokens=m.cacheCreate5mTokens,typeof h.reasoning_output_tokens=="number"&&(f.usage.reasoningOutputTokens=Number(h.reasoning_output_tokens))}}return e}const c=lx(e,s,o);c.provider||(c.provider=s.provider==="codex"?"codex":"claude");const p=MN(s);switch(p&&(c.model=p),l){case"SessionStart":{const h=ia(e,u,o,!1);h.synthetic=!1,h.state="active",h.startedAt=h.startedAt||o,!h.cwd&&s.cwd&&(h.cwd=s.cwd,h.cwdBasename=mi(s.cwd)),h.label==="session"&&s.cwd&&(h.label=mi(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===u&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<o&&(y.exitAt=o);const h=ia(e,u,o,!1);h.state="active",h.endedAt=void 0,h.exitAt=void 0;const f=lx(e,s,o);f.state="active",f.exitAt=void 0,f.endedAt=void 0;const m=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";m&&!LP(f,o,m)&&(f.prompts.push({at:o,text:m}),f.firstPrompt||(f.firstPrompt=Ll(m,120)));break}case"PreToolUse":{const h=s.tool_use_id?qP(e,c,s.tool_use_id):null;if(h){s.tool_name&&h.name==="?"&&(h.name=s.tool_name),h.endedAt==null&&!h.trimmed&&s.tool_input!==void 0&&(h.input=s.tool_input,h.inputPreview=Ll(s.tool_input));break}const f=s.tool_use_id??`${c.id}:${c.toolCount}`,m={id:f,name:s.tool_name??"?",input:s.tool_input,inputPreview:Ll(s.tool_input),agentId:c.id,startedAt:o};c.tools.push(m),c.toolCount+=1,c.state="active",e.toolIndex.set(f,m),e.toolOwner.set(f,c.id),Ys(c),OP(e,c);break}case"PostToolUse":case"PostToolUseFailure":{const h=s.tool_use_id;if(!h)break;let f=e.toolIndex.get(h),m=!1;if(!f)for(const N of e.agents.values()){const _=N.tools.find(b=>b.id===h);if(_){f=_,m=!0;break}}if(!f)break;f.endedAt=o,f.ok=l==="PostToolUse",f.trimmed||(f.response=s.tool_response),l==="PostToolUseFailure"?f.errorPreview=Ll(s.tool_response):m&&(f.errorPreview=void 0);const y=IN(s.tool_response);y&&(f.usage=y),e.toolIndex.delete(h);const x=e.toolOwner.get(h)??f.agentId;if(e.toolOwner.delete(h),x){const N=e.agents.get(x);N&&(y&&RP(N.usage,y),Ys(N))}break}case"SubagentStart":{const h=nv(s);if(!h)break;const f=AP(e,u,h,s,o);f.state="active",f.startedAt=f.startedAt||o,f.exitAt=void 0,f.endedAt=void 0;const m=iu(s);m&&(f.label=m),IP(e,u,h);break}case"SubagentStop":{const h=nv(s);if(!h)break;const f=PN(e,u,h,s);if(!f)break;f.state="done",f.endedAt=o,Ys(f),MP(e,u,h);break}case"Stop":case"SessionEnd":{const h=ia(e,u,o,!1);h.state="done",h.endedAt=o,Ys(h),e.activeSubagentStack.delete(u);break}}return e}function Rv(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 zP=Date.UTC(2026,8,1);function BP(e){return e<zP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const UP=[{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:BP},{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:/^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 HP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function jv(e,n=Date.now()){if(!e)return null;for(const r of UP)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function ON(e,n){const r=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-r-s),l=s+o,u=n.cacheWrite1h??n.cacheWrite;return{tokens5m:l,tokens1h:r,usd5m:l*n.cacheWrite/1e6,usd1h:r*u/1e6}}function qN(e,n){return HP(n)?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens}function sn(e,n,r=Date.now()){const s=jv(n,r);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=qN(e,n)*s.input/1e6,l=e.outputTokens*s.output/1e6,u=e.cacheReadTokens*s.cacheRead/1e6,c=ON(e,s),p=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:p,total:o+l+u+p}}const fx=2e5,WP=1e6,VP=[/\[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],GP=[{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 YP(e){if(!e)return fx;for(const n of VP)if(n.test(e))return WP;for(const n of GP)if(n.match.test(e))return n.window;return fx}function LN(e,n){return typeof e=="number"&&e>0?e:YP(n)}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,s=r*60;return s>=.01?`${ze(s)}/min`:`${ze(r*3600)}/hr`}const KP=1;function XP(){const e=[];let n=0;return{push(r,s=0){const o={dismiss:r,layer:s,seq:n++};return e.push(o),()=>{const l=e.indexOf(o);l!==-1&&e.splice(l,1)}},dismissTop(){let r;for(const s of e)(!r||s.layer>r.layer||s.layer===r.layer&&s.seq>r.seq)&&(r=s);return r?(r.dismiss(),!0):!1},depth(){return e.length}}}const rv=XP();function QP(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function hx(e){return String(e.tagName??"").toUpperCase()==="BODY"}function ZP(e,n){return!e||!e.isConnected||hx(e)?!1:n==null||hx(n)}function io(e,n={}){const{focusRef:r,layer:s}=n,o=A.useRef(e);o.current=e,A.useEffect(()=>rv.push(()=>o.current(),s),[s]),A.useEffect(()=>{var u;const l=document.activeElement;return(u=r==null?void 0:r.current)==null||u.focus(),()=>{ZP(l,document.activeElement)&&l.focus()}},[])}function Sn(e){return e.toLocaleString()}function JP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const eO=60;function tO(e,n=eO){if(e.length<=n)return e;const r=e.slice(e.length-(n-1)),s=r.search(/[/\\]/);return"…"+(s===-1?r:r.slice(s))}function nO({agent:e,onClose:n}){var f;const r=A.useRef(null);io(n,{focusRef:r});const s=e.context,o=e.usage,l=(s==null?void 0:s.currentContextTokens)??0,u=LN(e.contextWindow,e.model),c=Math.min(100,l/u*100),p=sn(o,e.model),h=o.inputTokens+o.cacheReadTokens+o.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"ctx-modal",onClick:m=>m.stopPropagation(),role:"dialog","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(c),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${c}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[c.toFixed(1),"%"]}),g.jsxs("span",{className:"ctx-window-num",children:[Sn(l)," / ",Sn(u)," tok (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Wn,{label:"input tokens",val:Sn(o.inputTokens)}),g.jsx(Wn,{label:"output tokens",val:Sn(o.outputTokens)}),g.jsx(Wn,{label:"cache reads",val:Sn(o.cacheReadTokens)}),g.jsx(Wn,{label:"cache writes",val:Sn(o.cacheCreateTokens)}),g.jsx(Wn,{label:"cumulative total",val:Sn(h)}),g.jsx(Wn,{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(Wn,{label:"user messages",val:Sn((s==null?void 0:s.msgsUser)??0)}),g.jsx(Wn,{label:"assistant messages",val:Sn((s==null?void 0:s.msgsAssistant)??0)}),g.jsx(Wn,{label:"tool uses",val:Sn((s==null?void 0:s.toolUses)??0)}),g.jsx(Wn,{label:"tool results",val:Sn((s==null?void 0:s.toolResults)??0)}),g.jsx(Wn,{label:"system-reminders",val:Sn((s==null?void 0:s.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((f=s==null?void 0:s.claudeMdFiles)==null?void 0:f.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:s.claudeMdFiles.map(m=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:m.path,children:tO(m.path)}),g.jsx("span",{className:"ctx-md-size",children:JP(m.bytes)})]},m.path))})]})})}function Wn({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 rO({currentContextTokens:e,modelId:n,contextWindow:r,size:s=26,onClick:o,title:l}){const u=LN(r,n),c=Math.min(1,e/u),p=s/2-3,h=s/2,f=2*Math.PI*p,m=f*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:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[g.jsx("circle",{cx:h,cy:h,r:p,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:h,cy:h,r:p,stroke:y,strokeWidth:"2.5",fill:"none",strokeDasharray:`${m} ${f-m}`,strokeDashoffset:f/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:h,y:h+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function iO(e,n){const r=jv(n);if(!r)return"no rates for this model";const s=f=>f.toLocaleString(),o=f=>`$${f}/MTok`,l=sn(e,n),u=ON(e,r),c=u.tokens1h>0?[`cache w5m${s(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`,`cache w1h${s(u.tokens1h).padStart(14)} × ${o(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${ze(u.usd1h)}`]:[`cache w ${s(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`],p=qN(e,n),h=p===e.inputTokens?"input":"uncached";return[`model: ${n}`,`${h.padEnd(9)}${s(p).padStart(14)} × ${o(r.input).padEnd(11)} = ${ze(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${ze(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${ze(l.cacheRead)}`,...c,"─────────────────────────────────────────",`total = ${ze(l.total)}`].join(`
|
|
57
|
+
M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fill:p,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}CN.displayName="MiniMap";var mP=A.memo(CN);function gP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ae.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function vP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ae.createElement("path",{d:"M0 0h32v4.2H0z"}))}function yP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ae.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 wP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ae.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 xP(){return ae.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ae.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 Gs=({children:e,className:n,...r})=>ae.createElement("button",{type:"button",className:Lt(["react-flow__controls-button",n]),...r},e);Gs.displayName="ControlButton";const _P=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),TN=({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:s=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:p,className:h,children:f,position:m="bottom-left"})=>{const y=Et(),[x,N]=A.useState(!1),{isInteractive:_,minZoomReached:b,maxZoomReached:S}=Xe(_P,kt),{zoomIn:k,zoomOut:E,fitView:C}=wa();if(A.useEffect(()=>{N(!0)},[]),!x)return null;const I=()=>{k(),l==null||l()},M=()=>{E(),u==null||u()},O=()=>{C(o),c==null||c()},W=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),p==null||p(!_)};return ae.createElement(vv,{className:Lt(["react-flow__controls",h]),position:m,style:e,"data-testid":"rf__controls"},n&&ae.createElement(ae.Fragment,null,ae.createElement(Gs,{onClick:I,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:S},ae.createElement(gP,null)),ae.createElement(Gs,{onClick:M,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},ae.createElement(vP,null))),r&&ae.createElement(Gs,{className:"react-flow__controls-fitview",onClick:O,title:"fit view","aria-label":"fit view"},ae.createElement(yP,null)),s&&ae.createElement(Gs,{className:"react-flow__controls-interactive",onClick:W,title:"toggle interactivity","aria-label":"toggle interactivity"},_?ae.createElement(xP,null):ae.createElement(wP,null)),f)};TN.displayName="Controls";var bP=A.memo(TN),Yn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Yn||(Yn={}));function SP({color:e,dimensions:n,lineWidth:r}){return ae.createElement("path",{stroke:e,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function kP({color:e,radius:n}){return ae.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const EP={[Yn.Dots]:"#91919a",[Yn.Lines]:"#eee",[Yn.Cross]:"#e2e2e2"},NP={[Yn.Dots]:1,[Yn.Lines]:1,[Yn.Cross]:6},CP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function RN({id:e,variant:n=Yn.Dots,gap:r=20,size:s,lineWidth:o=1,offset:l=2,color:u,style:c,className:p}){const h=A.useRef(null),{transform:f,patternId:m}=Xe(CP,kt),y=u||EP[n],x=s||NP[n],N=n===Yn.Dots,_=n===Yn.Cross,b=Array.isArray(r)?r:[r,r],S=[b[0]*f[2]||1,b[1]*f[2]||1],k=x*f[2],E=_?[k,k]:S,C=N?[k/l,k/l]:[E[0]/l,E[1]/l];return ae.createElement("svg",{className:Lt(["react-flow__background",p]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},ae.createElement("pattern",{id:m+e,x:f[0]%S[0],y:f[1]%S[1],width:S[0],height:S[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},N?ae.createElement(kP,{color:y,radius:k/l}):ae.createElement(SP,{dimensions:E,color:y,lineWidth:o})),ae.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}RN.displayName="Background";var TP=A.memo(RN);function jN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function AN(e){const n=e.cache_creation,r=n&&typeof n=="object"?n:e,s=r.ephemeral_1h_input_tokens,o=r.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(o??0)}}function IN(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),...AN(r)};for(const s of Object.values(r)){const o=IN(s,n+1);if(o)return o}return null}function RP(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 jP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function MN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&jP.test(r.model))return r.model;for(const s of Object.values(r)){const o=MN(s,n+1);if(o)return o}return null}function tv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function mi(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Tv(e,n){return`${e}::${n}`}function iu(e){return e.agent_type??e.subagent_type??"subagent"}function nv(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function ia(e,n,r,s){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:r,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,inFlightTool:null,usage:jN()},e.agents.set(o,l),l)}function PN(e,n,r,s){const o=Tv(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&s.cwd&&(l.cwd=s.cwd,l.cwdBasename=mi(s.cwd));const u=iu(s);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function lx(e,n,r){const s=n.session_id??"unknown",o=nv(n);if(o){const p=PN(e,s,o,n);if(p)return p}const l=e.activeSubagentStack.get(s),u=l&&l.length>0?l[l.length-1]:null;if(u){const p=e.agents.get(Tv(s,u));if(p)return!p.cwd&&n.cwd&&(p.cwd=n.cwd,p.cwdBasename=mi(n.cwd)),p}const c=ia(e,s,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=mi(n.cwd)),c.label==="session"&&n.cwd&&(c.label=mi(n.cwd)??"session"),c}function AP(e,n,r,s,o){const l=Tv(n,r),u=ia(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&s.cwd&&(c.cwd=s.cwd,c.cwdBasename=mi(s.cwd));const p=iu(s);return p&&(c.label==="subagent"||!c.label)&&(c.label=p),c}return c={id:l,sessionId:n,label:iu(s),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:s.cwd,cwdBasename:mi(s.cwd),toolCount:0,childCount:0,inFlightTool:null,usage:jN()},e.agents.set(l,c),u.childCount+=1,c}function IP(e,n,r){const s=e.activeSubagentStack.get(n)??[];s.includes(r)||(s.push(r),e.activeSubagentStack.set(n,s))}function MP(e,n,r){const s=e.activeSubagentStack.get(n);if(s){for(let o=s.length-1;o>=0;o--)if(s[o]===r){s.splice(o,1);break}s.length===0&&e.activeSubagentStack.delete(n)}}function Ll(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)}}function Ys(e){let n=null;for(let r=e.tools.length-1;r>=0;r--){const s=e.tools[r];if(s.endedAt==null){n=s;break}}e.inFlightTool=n}const ux=200,PP=25;function OP(e,n){const r=n.tools;if(r.length>ux){const s=r.splice(0,r.length-ux);let o=!1;for(const l of s)e.toolIndex.delete(l.id)&&(o=!0),e.toolOwner.delete(l.id);o&&Ys(n)}for(let s=r.length-PP-1;s>=0;s--){const o=r[s];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function qP(e,n,r){const s=e.toolIndex.get(r);if(s)return s;for(let o=n.tools.length-1;o>=0;o--)if(n.tools[o].id===r)return n.tools[o];return null}const cx=2e3;function LP(e,n,r){for(let s=e.prompts.length-1;s>=0;s--){const o=e.prompts[s];if(o.at<n-cx)return!1;if(o.text===r&&o.at<=n+cx)return!0}return!1}function $P(e,n,r,s){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>s&&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 DP(e,n,r,s){const o=new Map;for(const[h,f]of e.agents){let m=o.get(f.sessionId);m||(m={ids:[],endedAt:0,live:!1},o.set(f.sessionId,m)),m.ids.push(h),f.state==="done"&&f.endedAt!=null?m.endedAt=Math.max(m.endedAt,f.endedAt):m.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>s).sort((h,f)=>h.endedAt-f.endedAt);let c=[...o.values()].filter(h=>!h.live).length-r;if(c<=0)return!1;let p=!1;for(const h of l){if(c<=0)break;for(const f of h.ids)e.agents.delete(f);c--,p=!0}return p}function FP(e,n,r){let s=!1;for(const o of e.agents.values()){let l=!1;for(const u of o.tools)u.endedAt==null&&n-u.startedAt>r&&(u.endedAt=u.startedAt+r,u.ok=!1,u.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(u.id),e.toolOwner.delete(u.id),l=!0,s=!0);l&&Ys(o)}return s}function dx(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 s=n.payload??{},o=n.receivedAt,l=s.hook_event_name??"Unknown";if(l==="__clear")return{...tv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=s.session_id??"unknown";if(typeof s.model_context_window=="number"&&s.model_context_window>0){const h=e.agents.get(u);h&&(h.contextWindow=s.model_context_window)}if(l==="ModelObserved"){const h=typeof s.model=="string"?s.model:null;if(h){const m=e.agents.get(u);m&&(m.model=h)}const f=s.subagentModels;if(f&&typeof f=="object")for(const[m,y]of Object.entries(f)){if(typeof y!="string")continue;const x=`${u}::${m}`,N=e.agents.get(x);N&&(N.model=y)}return e}if(l==="ContextObserved"){const h=s.context??null;if(h){const f=e.agents.get(u);f&&(f.context={msgsUser:Number(h.msgsUser??0),msgsAssistant:Number(h.msgsAssistant??0),toolUses:Number(h.toolUses??0),toolResults:Number(h.toolResults??0),systemReminders:Number(h.systemReminders??0),currentContextTokens:Number(h.currentContextTokens??0),claudeMdFiles:Array.isArray(h.claudeMdFiles)?h.claudeMdFiles:[]})}return e}if(l==="UsageObserved"){const h=s.usage??null;if(h){const f=e.agents.get(u);if(f){f.usage.inputTokens=Number(h.input_tokens??0),f.usage.outputTokens=Number(h.output_tokens??0),f.usage.cacheReadTokens=Number(h.cache_read_input_tokens??h.cached_input_tokens??0),f.usage.cacheCreateTokens=Number(h.cache_creation_input_tokens??0);const m=AN(h);f.usage.cacheCreate1hTokens=m.cacheCreate1hTokens,f.usage.cacheCreate5mTokens=m.cacheCreate5mTokens,typeof h.reasoning_output_tokens=="number"&&(f.usage.reasoningOutputTokens=Number(h.reasoning_output_tokens))}}return e}const c=lx(e,s,o);c.provider||(c.provider=s.provider==="codex"?"codex":"claude");const p=MN(s);switch(p&&(c.model=p),l){case"SessionStart":{const h=ia(e,u,o,!1);h.synthetic=!1,h.state="active",h.startedAt=h.startedAt||o,!h.cwd&&s.cwd&&(h.cwd=s.cwd,h.cwdBasename=mi(s.cwd)),h.label==="session"&&s.cwd&&(h.label=mi(s.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===u&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<o&&(y.exitAt=o);const h=ia(e,u,o,!1);h.state="active",h.endedAt=void 0,h.exitAt=void 0;const f=lx(e,s,o);f.state="active",f.exitAt=void 0,f.endedAt=void 0;const m=(typeof s.prompt=="string"?s.prompt:typeof s.message=="string"?s.message:"")??"";m&&!LP(f,o,m)&&(f.prompts.push({at:o,text:m}),f.firstPrompt||(f.firstPrompt=Ll(m,120)));break}case"PreToolUse":{const h=s.tool_use_id?qP(e,c,s.tool_use_id):null;if(h){s.tool_name&&h.name==="?"&&(h.name=s.tool_name),h.endedAt==null&&!h.trimmed&&s.tool_input!==void 0&&(h.input=s.tool_input,h.inputPreview=Ll(s.tool_input));break}const f=s.tool_use_id??`${c.id}:${c.toolCount}`,m={id:f,name:s.tool_name??"?",input:s.tool_input,inputPreview:Ll(s.tool_input),agentId:c.id,startedAt:o};c.tools.push(m),c.toolCount+=1,c.state="active",e.toolIndex.set(f,m),e.toolOwner.set(f,c.id),Ys(c),OP(e,c);break}case"PostToolUse":case"PostToolUseFailure":{const h=s.tool_use_id;if(!h)break;let f=e.toolIndex.get(h),m=!1;if(!f)for(const N of e.agents.values()){const _=N.tools.find(b=>b.id===h);if(_){f=_,m=!0;break}}if(!f)break;f.endedAt=o,f.ok=l==="PostToolUse",f.trimmed||(f.response=s.tool_response),l==="PostToolUseFailure"?f.errorPreview=Ll(s.tool_response):m&&(f.errorPreview=void 0);const y=IN(s.tool_response);y&&(f.usage=y),e.toolIndex.delete(h);const x=e.toolOwner.get(h)??f.agentId;if(e.toolOwner.delete(h),x){const N=e.agents.get(x);N&&(y&&RP(N.usage,y),Ys(N))}break}case"SubagentStart":{const h=nv(s);if(!h)break;const f=AP(e,u,h,s,o);f.state="active",f.startedAt=f.startedAt||o,f.exitAt=void 0,f.endedAt=void 0;const m=iu(s);m&&(f.label=m),IP(e,u,h);break}case"SubagentStop":{const h=nv(s);if(!h)break;const f=PN(e,u,h,s);if(!f)break;f.state="done",f.endedAt=o,Ys(f),MP(e,u,h);break}case"Stop":case"SessionEnd":{const h=ia(e,u,o,!1);h.state="done",h.endedAt=o,Ys(h),e.activeSubagentStack.delete(u);break}}return e}function Rv(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 zP=Date.UTC(2026,8,1);function BP(e){return e<zP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const UP=[{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:BP},{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:/^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 HP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function jv(e,n=Date.now()){if(!e)return null;for(const r of UP)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function ON(e,n){const r=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-r-s),l=s+o,u=n.cacheWrite1h??n.cacheWrite;return{tokens5m:l,tokens1h:r,usd5m:l*n.cacheWrite/1e6,usd1h:r*u/1e6}}function qN(e,n){return HP(n)?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens}function sn(e,n,r=Date.now()){const s=jv(n,r);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=qN(e,n)*s.input/1e6,l=e.outputTokens*s.output/1e6,u=e.cacheReadTokens*s.cacheRead/1e6,c=ON(e,s),p=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:p,total:o+l+u+p}}const fx=2e5,WP=1e6,VP=[/\[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],GP=[{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 YP(e){if(!e)return fx;for(const n of VP)if(n.test(e))return WP;for(const n of GP)if(n.match.test(e))return n.window;return fx}function LN(e,n){return typeof e=="number"&&e>0?e:YP(n)}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,s=r*60;return s>=.01?`${ze(s)}/min`:`${ze(r*3600)}/hr`}const KP=1;function XP(){const e=[];let n=0;return{push(r,s=0){const o={dismiss:r,layer:s,seq:n++};return e.push(o),()=>{const l=e.indexOf(o);l!==-1&&e.splice(l,1)}},dismissTop(){let r;for(const s of e)(!r||s.layer>r.layer||s.layer===r.layer&&s.seq>r.seq)&&(r=s);return r?(r.dismiss(),!0):!1},depth(){return e.length}}}const rv=XP();function QP(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function hx(e){return String(e.tagName??"").toUpperCase()==="BODY"}function ZP(e,n){return!e||!e.isConnected||hx(e)?!1:n==null||hx(n)}function io(e,n={}){const{focusRef:r,layer:s}=n,o=A.useRef(e);o.current=e,A.useEffect(()=>rv.push(()=>o.current(),s),[s]),A.useEffect(()=>{var u;const l=document.activeElement;return(u=r==null?void 0:r.current)==null||u.focus(),()=>{ZP(l,document.activeElement)&&l.focus()}},[])}function Sn(e){return e.toLocaleString()}function JP(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const eO=60;function tO(e,n=eO){if(e.length<=n)return e;const r=e.slice(e.length-(n-1)),s=r.search(/[/\\]/);return"…"+(s===-1?r:r.slice(s))}function nO({agent:e,onClose:n}){var f;const r=A.useRef(null);io(n,{focusRef:r});const s=e.context,o=e.usage,l=(s==null?void 0:s.currentContextTokens)??0,u=LN(e.contextWindow,e.model),c=Math.min(100,l/u*100),p=sn(o,e.model),h=o.inputTokens+o.cacheReadTokens+o.cacheCreateTokens;return g.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"ctx-modal",onClick:m=>m.stopPropagation(),role:"dialog","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(c),children:g.jsx("div",{className:"ctx-window-fill",style:{width:`${c}%`}})}),g.jsxs("div",{className:"ctx-window-meta",children:[g.jsxs("span",{className:"ctx-window-pct",children:[c.toFixed(1),"%"]}),g.jsxs("span",{children:[Sn(l)," / ",Sn(u)," tok (current turn)"]})]})]}),g.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),g.jsxs("div",{className:"ctx-grid",children:[g.jsx(Wn,{label:"input tokens",val:Sn(o.inputTokens)}),g.jsx(Wn,{label:"output tokens",val:Sn(o.outputTokens)}),g.jsx(Wn,{label:"cache reads",val:Sn(o.cacheReadTokens)}),g.jsx(Wn,{label:"cache writes",val:Sn(o.cacheCreateTokens)}),g.jsx(Wn,{label:"cumulative total",val:Sn(h)}),g.jsx(Wn,{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(Wn,{label:"user messages",val:Sn((s==null?void 0:s.msgsUser)??0)}),g.jsx(Wn,{label:"assistant messages",val:Sn((s==null?void 0:s.msgsAssistant)??0)}),g.jsx(Wn,{label:"tool uses",val:Sn((s==null?void 0:s.toolUses)??0)}),g.jsx(Wn,{label:"tool results",val:Sn((s==null?void 0:s.toolResults)??0)}),g.jsx(Wn,{label:"system-reminders",val:Sn((s==null?void 0:s.systemReminders)??0)})]}),g.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((f=s==null?void 0:s.claudeMdFiles)==null?void 0:f.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:s.claudeMdFiles.map(m=>g.jsxs("li",{children:[g.jsx("span",{className:"ctx-md-path",title:m.path,children:tO(m.path)}),g.jsx("span",{className:"ctx-md-size",children:JP(m.bytes)})]},m.path))})]})})}function Wn({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 rO({currentContextTokens:e,modelId:n,contextWindow:r,size:s=26,onClick:o,title:l}){const u=LN(r,n),c=Math.min(1,e/u),p=s/2-3,h=s/2,f=2*Math.PI*p,m=f*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:s,height:s,viewBox:`0 0 ${s} ${s}`,children:[g.jsx("circle",{cx:h,cy:h,r:p,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),g.jsx("circle",{cx:h,cy:h,r:p,stroke:y,strokeWidth:"2.5",fill:"none",strokeDasharray:`${m} ${f-m}`,strokeDashoffset:f/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),g.jsx("text",{x:h,y:h+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function iO(e,n){const r=jv(n);if(!r)return"no rates for this model";const s=f=>f.toLocaleString(),o=f=>`$${f}/MTok`,l=sn(e,n),u=ON(e,r),c=u.tokens1h>0?[`cache w5m${s(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`,`cache w1h${s(u.tokens1h).padStart(14)} × ${o(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${ze(u.usd1h)}`]:[`cache w ${s(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`],p=qN(e,n),h=p===e.inputTokens?"input":"uncached";return[`model: ${n}`,`${h.padEnd(9)}${s(p).padStart(14)} × ${o(r.input).padEnd(11)} = ${ze(l.input)}`,`output ${s(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${ze(l.output)}`,`cache r ${s(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${ze(l.cacheRead)}`,...c,"─────────────────────────────────────────",`total = ${ze(l.total)}`].join(`
|
|
58
58
|
`)}function sO(e,n,r){const s=(n??r)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const o=Math.floor(s/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 oO({data:e,selected:n}){var h;const r=e.now??Date.now(),s=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(f=>!f.endedAt).length,u=`hsl(${Rv(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,p=e.kind==="root"&&c>0;return g.jsxs("div",{className:s,style:{"--accent":u},children:[g.jsx("span",{className:"accent-stripe"}),g.jsx(no,{type:"target",position:Te.Left,style:{background:"transparent",border:"none"}}),g.jsxs("div",{className:"head",children:[g.jsxs("div",{className:"title",children:[g.jsx(aO,{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:[p&&e.onOpenContext&&g.jsx(rO,{currentContextTokens:c,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),g.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:sO(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:xa(e.model)})]}),e.tools.length>0&&g.jsx(uO,{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:lO(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&jv(e.model)&&(()=>{const f=sn(e.usage,e.model);if(f.total<=0)return null;const m=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),y=e.state==="active"?su(f.total,m):null,x=iO(e.usage,e.model)+(y?`
|
|
59
|
-
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:x,children:[g.jsx("b",{children:ze(f.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(no,{type:"source",position:Te.Right,style:{background:"transparent",border:"none"}})]})}function aO({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function lO(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function uO({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(l[N]+=1,u+=1)}const c=Math.max(1,...l),p=132,h=14,f=p/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:p,height:h,viewBox:`0 0 ${p} ${h}`,"aria-hidden":!0,children:l.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,S=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:x*f+.4,y:h-N,width:Math.max(.5,f-1),height:N,rx:.8,className:S},x)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function xa(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const r=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(r)return`GPT-${r[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function px(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function cO(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 dO({tool:e,onClose:n}){io(n);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"modal",onClick:s=>s.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 ${r}`}),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:cO(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:px(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",r==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":px(e.response??e.errorPreview)})]})]})]})})}const $l=18,mx=26,fO=12;function hO(e){return pO(e.nodeInternals.values())}function pO(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,p=u+o.width,h=c+o.height,f=n.get(l.sessionId);f?(f.minX=Math.min(f.minX,u),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,p),f.maxY=Math.max(f.maxY,h),l.kind==="root"&&(f.label=gx(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:gx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${mO(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-$l,y:l.minY-$l-mx,w:l.maxX-l.minX+$l*2,h:l.maxY-l.minY+$l*2+mx})}return s}function mO(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function gx(e){if(e.kind==="root")return e.label}function gO(){const{x:e,y:n,zoom:r}=EN(),s=wa(),o=Xe(hO,vO);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=Rv(u.sessionId),p={position:"absolute",left:u.x*r+e,top:u.y*r+n,width:u.w*r,height:u.h*r,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*r+e+16*r,top:(u.y-fO)*r+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top"};return g.jsxs(ae.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function vO(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=n[r];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function yO({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 $N=600,wO=4,xO=36,iv=16,_O=60,bO=6,vx=220,yx=96,SO=28,kO={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 EO(e){return e.startsWith("mcp__")?"mcp":kO[e]??"other"}const NO={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 wx(e){return e.startsWith("mcp__")?"🔌":NO[e]??"✨"}const CO={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 DN(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 DN(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 s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function TO(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 s=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<r.length)return r[s+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const RO=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),jO=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function AO(e,n){return jO.has(e)||e.startsWith("mcp__")?Math.max(yx,34+n.length*7.5):yx}function IO(e,n){if(!RO.has(e))return null;const r=TO(n);if(!r)return null;const s=DN(r);return s?{emoji:CO[s]??"⚙️",label:s,category:"shell",detail:r}:null}const MO=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),xx={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:"🗄️"},_x={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 PO(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),s=r.lastIndexOf("/");return s>=0?r.slice(s+1):r}function OO(e){const n=e.toLowerCase();if(_x[n])return _x[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 s=n.slice(r+1);if(xx[s])return xx[s]}return"📄"}function qO(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const s=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[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 LO(e,n){if(!MO.has(e))return null;const r=qO(e,n);if(!r)return null;const s=PO(r);return s?{emoji:e==="LS"?"📂":OO(s),label:s,category:"file",detail:r}:null}const FN={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 zN(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 $O(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 DO(e,n){const r=zN(e);if(!r)return null;const{server:s,method:o}=r;if(!o)return null;const l=FN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function FO(e,n){return IO(e,n)??LO(e,n)??DO(e)}const zO={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function BO(e){const n=zN(e);if(n){const s=FN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:$O(n.server)}}const r=zO[e];return r?{emoji:wx(e),label:r}:{emoji:wx(e),label:e}}function UO(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function HO(e,n,r){if(r==null)return 1;const s=n-r;return s<0?1:Math.max(0,1-s/$N)}function WO(e,n){const r=[],s=new Set;for(let o=e.length-1;o>=0&&r.length<n;o--){const l=e[o];s.has(l.id)||(s.add(l.id),r.push(l))}return r.reverse()}function VO(e,n,r,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>$N)continue;const p=s.get(c.id)??r.get(c.id);if(!p)continue;const h=WO(c.tools,wO);if(h.length===0)continue;const f=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??vx,vx),x=(m==null?void 0:m.height)??130,N=p.x,_=p.y,b=N+y,S=_+x/2;h.forEach((k,E)=>{const C=E*xO,I=N+y+_O,M=_+bO+C,O=HO(k,l,f),W=k.inputPreview??"",q=UO(k),P=O<.999,L=BO(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:L.label,emoji:L.emoji,status:q,category:EO(k.name),mcpHue:L.hue,inputPreview:W,fade:O,fading:P,worldX:I,worldY:M,anchorX:b,anchorY:S,spawnDx:b-I,spawnDy:S-(M+iv)});const U=FO(k.name,k.input);if(U){const B=AO(k.name,L.label),j=I+B+SO,Q=M,H=I+B,te=M+iv;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,isSub:!0,status:q,category:U.category,inputPreview:U.detail??W,fade:O,fading:P,worldX:j,worldY:Q,anchorX:H,anchorY:te,spawnDx:H-j,spawnDy:0})}})}return u}function GO({agents:e,visibleAgentIds:n,positions:r,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const f=VO(e,n,r,s,o,p),m=c&&c.size>0?f.filter(y=>!c.has(y.category)):f;return g.jsx(YO,{bursts:m,dimUnmatched:l,spotlight:u,onOpenTool:h})}function YO({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:s}){const{x:o,y:l,zoom:u}=EN();return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const p=c.anchorX*u+o,h=c.anchorY*u+l,f=(c.worldX+6)*u+o,m=(c.worldY+iv)*u+l,y=p+(f-p)*.55,x=n!=null&&!n.has(c.agentId),N=r!=null&&!r.has(c.agentId),_=c.fade*(x||N?.14:1);return g.jsx("path",{d:`M ${p} ${h} Q ${y} ${h}, ${f} ${m}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const p=c.worldX*u+o,h=c.worldY*u+l,f={left:`${p}px`,top:`${h}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,x=s!=null,N=c.mcpHue!=null?{"--cat-accent":`hsl(${c.mcpHue} 65% 65%)`}:{},_=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:f,children:g.jsxs("div",{className:`tool-burst cat-${c.category} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${S}`,style:N,title:y,role:x?"button":void 0,tabIndex:x?0:void 0,"aria-label":x?`Open ${c.toolName} ${c.status==="inflight"?"in flight":c.status} — click for details`:void 0,onClick:x?()=>s(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),s(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 KO({state:e,sessionId:n,onClose:r}){const s=A.useMemo(()=>QO(e,n),[e,n]),o=A.useRef(null);return io(r,{focusRef:o}),s?g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:l=>l.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:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.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(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>g.jsx("span",{className:"model-chip",title:l,children:xa(l)},l))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(XO,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:ze(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:ze(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:ze(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:ze(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Hs,{label:"agents",value:s.agentCount}),g.jsx(Hs,{label:"subagents",value:s.subagentCount}),g.jsx(Hs,{label:"tool calls",value:s.toolCount}),g.jsx(Hs,{label:"prompts",value:s.promptCount}),g.jsx(Hs,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Hs,{label:"errors",value:s.errCount,tone:"err"})]}),s.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:s.topTools.map(([l,u])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:l}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Hs({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 XO({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${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 QO(e,n){const r=e.agents.get(n);if(!r)return null;const s=[];for(const E of e.agents.values())E.sessionId===n&&s.push(E);if(s.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,p=0,h=0,f=0,m=0,y,x=1/0,N=0;for(const E of s){const C=sn(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++,p+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),h+=E.usage.inputTokens+E.usage.outputTokens,c+=E.toolCount,x=Math.min(x,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&&f++}const _=Math.max(0,N-x),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:s.length,subagentCount:m,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:k,firstPrompt:y}}function ZO(e,n){const r=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.toolCount,l=sn(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=sn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return r.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),r}function JO(e,n,r){const s=(n??r)-e;if(s<1e3)return"<1s";const o=Math.floor(s/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 e3({state:e,now:n,selectedIds:r,onSelect:s,onClose:o}){const l=A.useMemo(()=>ZO(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"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})]}),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(c=>{const p=r.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:xa(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:ze(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:JO(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function bx(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 t3(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"}function jr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function n3({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${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 r3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/3600),o=Math.floor(r%3600/60);if(s>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function i3(e,n,r,s){const o=Math.max(0,n-s),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 p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),x=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Yi({pct:e,label:n,reset:r,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",f=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?r3(s,u):null,x=s&&o?i3(c,s,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:h},children:f})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.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,x&&g.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const s3=6e4;function o3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),s3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function a3(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.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const BN=6e4;function l3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),BN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function u3(){const[e,n]=A.useState(null),r=A.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(s(),r.current=window.setInterval(s,BN),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function c3({state:e,now:n,onClose:r}){var O,W;const{quota:s,loading:o,refresh:l}=o3(),{data:u,loading:c,refresh:p}=l3(),{data:h}=u3(),[f,m]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const q=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(q)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=A.useMemo(()=>{const q=new Map,P={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let L=0,U=0,B=0,j=0;for(const D of e.agents.values()){const X=D.model??"__unknown__",R=sn(D.usage,D.model),$=q.get(X);$?($.inputTokens+=D.usage.inputTokens,$.outputTokens+=D.usage.outputTokens,$.cacheReadTokens+=D.usage.cacheReadTokens,$.cacheCreateTokens+=D.usage.cacheCreateTokens,$.cost.total+=R.total,$.cost.input+=R.input,$.cost.output+=R.output,$.cost.cacheRead+=R.cacheRead,$.cost.cacheWrite+=R.cacheWrite,$.agentCount++):q.set(X,{model:X,inputTokens:D.usage.inputTokens,outputTokens:D.usage.outputTokens,cacheReadTokens:D.usage.cacheReadTokens,cacheCreateTokens:D.usage.cacheCreateTokens,cost:{...R},agentCount:1}),P.total+=R.total,P.input+=R.input,P.output+=R.output,P.cacheRead+=R.cacheRead,P.cacheWrite+=R.cacheWrite,L+=D.usage.inputTokens,U+=D.usage.outputTokens,B+=D.usage.cacheReadTokens,j+=D.usage.cacheCreateTokens}const Q=Array.from(q.values()).sort((D,X)=>X.cost.total-D.cost.total);let H=0,te=0;for(const D of e.agents.values()){if(D.state!=="active")continue;const X=sn(D.usage,D.model);H+=X.total,te=Math.max(te,((D.endedAt??n)-D.startedAt)/1e3)}const Z=te>0?su(H,te):null;return{byModel:Q,totalCost:P,totalTokens:{in:L,out:U,cacheR:B,cacheC:j},burnRate:Z}},[e,e.lastSeq,n]),b=A.useMemo(()=>{const q=[];for(const P of e.agents.values()){if(P.kind!=="root")continue;let L=sn(P.usage,P.model).total,U=P.usage.inputTokens,B=P.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==P.sessionId||j.kind==="root"||(L+=sn(j.usage,j.model).total,U+=j.usage.inputTokens,B+=j.usage.outputTokens);q.push({sessionId:P.sessionId,label:P.label||P.cwdBasename||"session",state:P.state,cost:L,inputTokens:U,outputTokens:B})}return q.sort((P,L)=>L.cost-P.cost).slice(0,12)},[e,e.lastSeq]),S=x.total>0,k=N.in+N.out,E=o||c,C=bx(s==null?void 0:s.fetchedAt,f),I=bx(u==null?void 0:u.fetchedAt,f),M=()=>{l(),p()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:M,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&g.jsx("span",{className:"up-section-age",title:t3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(Yi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:f}),s.week7dPct!=null&&g.jsx(Yi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:f}),s.weekSonnetPct!=null&&g.jsx(Yi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:f}),s.weekOpusPct!=null&&g.jsx(Yi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:f})]}):(s==null?void 0:s.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…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),I&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:I})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(O=u.windows)==null?void 0:O.map(q=>g.jsx(Yi,{label:q.label,pct:q.pct,reset:q.reset??void 0,resetAt:q.resetAt??void 0,windowSec:q.windowSec??void 0,limitReached:u.limitReached&&q.pct>=100,nowSec:f},q.id)),(W=u.extraWindows)==null?void 0:W.map(q=>g.jsx(Yi,{label:q.label,pct:q.pct,reset:q.reset??void 0,resetAt:q.resetAt??void 0,windowSec:q.windowSec??void 0,nowSec:f},q.id)),u.creditLimit&&g.jsx(Yi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:f}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[jr(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:a3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),S?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:ze(x.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(n3,{cost:x}),k>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]}),N.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),jr(N.cacheR)]}),N.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),jr(N.cacheC)]})]}),y.filter(q=>q.cost.total>0).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:y.filter(q=>q.cost.total>0).map(q=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:q.model,children:xa(q.model)}),g.jsx("td",{className:"up-num",children:jr(q.inputTokens+q.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:ze(q.cost.total)})]},q.model))})]})]}),b.filter(q=>q.cost>0).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:b.filter(q=>q.cost>0).map(q=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${q.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:q.label}),g.jsx("span",{className:"up-session-tokens",children:jr(q.inputTokens+q.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:ze(q.cost)})]},q.sessionId))})]})]}):k>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const Sx=18,d3=1100,Ws=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},f3=Array.from({length:Sx},(e,n)=>{const r=-72+144*n/(Sx-1)+(Ws(n,1)-.5)*9,s=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Ws(n,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(n%2?1:-1)*(100+Ws(n,3)*260),delay:Math.round(Ws(n,4)*90),dur:760+Math.round(Ws(n,5)*260),scale:.8+Ws(n,6)*.45,hue:n%4,round:n%3===0}});function kx({anchor:e,lifetimeMs:n=d3}){var l;const[r,s]=A.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return A.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();s({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:gI.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:f3.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 UN=new Set(["awaiting_url","awaiting_code","registering"]);function h3(e){return e!=null&&UN.has(e)}function HN(e){return e!=null&&e!=="done"&&!UN.has(e)}const p3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",m3="the sign-in did not complete";function g3({state:e,serverError:n,localError:r}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:r||n||(s?p3:m3)}}const v3="done";function y3(){let e=!1;return{shouldAnnounce(n){return n!==v3?(e=!1,!1):e?!1:(e=!0,!0)}}}const Ex={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 agents-deck",expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import"},Nx={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"},w3="claude-swap could not read the login keychain — start agents-deck from a Terminal window rather than a background service";function Cx(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(sv(e))?w3:e!=null&&e.reason&&Nx[e.reason]?Nx[e.reason]:(e==null?void 0:e.reason)||n}function sv(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||"").trim()}function Yl(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&HN(e.state)?e.error:e!=null&&e.reason&&Ex[e.reason]?Ex[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const x3=1500;async function Dl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const ov=ae.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"})]}));ov.displayName="SuccessMark";function _3({onClose:e,onChanged:n}){const[r,s]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,m]=A.useState(!1),[y,x]=A.useState(null),[N,_]=A.useState(null),b=A.useRef(!1),S=A.useRef(null),k=A.useRef(null),E=A.useRef(null),C=A.useCallback(()=>{b.current&&Dl({action:"login-cancel"}).catch(()=>{}),e()},[e]);io(C);const I=A.useCallback(async()=>{m(!0),x(null),b.current=!0;const B=await Dl({action:"login"}).catch(()=>null);if(m(!1),!(B!=null&&B.ok)){x(Yl(B,"could not start the sign-in"));return}l(B)},[]);A.useEffect(()=>{if(!h3(o==null?void 0:o.state))return;const B=window.setInterval(async()=>{try{const j=await fetch("/api/claude-accounts/login");j.ok&&l(await j.json())}catch{}},x3);return()=>window.clearInterval(B)},[o]);const M=A.useRef(n);M.current=n;const O=A.useRef(y3());A.useEffect(()=>{var B;(o==null?void 0:o.state)==="awaiting_code"&&((B=S.current)==null||B.focus()),O.current.shouldAnnounce(o==null?void 0:o.state)&&M.current()},[o==null?void 0:o.state]),A.useEffect(()=>{var B;r==="paste"&&((B=k.current)==null||B.focus())},[r]);const W=A.useCallback(async()=>{var j;m(!0),x(null);const B=await Dl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(B!=null&&B.ok)){x(Yl(B,"the code was not accepted")),B!=null&&B.state&&l(B),(j=S.current)==null||j.select();return}c(""),l(B)},[u,o]),q=A.useCallback(async()=>{m(!0),x(null);const B=await Dl({action:"import",blob:p}).catch(()=>null);if(m(!1),!(B!=null&&B.ok)){x(Yl(B,"the import failed"));return}h(""),_({added:B.added===!0,num:B.num??null,email:B.email??null}),n()},[p,n]),P=(o==null?void 0:o.state)==="done"?o.account:null,L=HN(o==null?void 0:o.state)||!!(y&&b.current&&!f),U=g3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:C,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:B=>B.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:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:C,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?P?g.jsxs("div",{className:"aa-done",children:[g.jsx(ov,{ref:E}),g.jsx(kx,{anchor:E}),g.jsx("h4",{children:P.added?`Account ${P.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:P.email}),P.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:B=>c(B.target.value),onKeyDown:B=>{B.key==="Enter"&&u.trim()&&!f&&W()},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:f||!u.trim()||o.state==="registering",onClick:W,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."})]})]}):L?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:U.title}),g.jsx("p",{className:"aa-err",children:U.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,l(null),x(null),I()},children:"Try again"})]}):f||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",className:"btn primary",onClick:I,disabled:f,children:"Open the sign-in page"})})]}):N?g.jsxs("div",{className:"aa-done",children:[g.jsx(ov,{ref:E}),N.added&&g.jsx(kx,{anchor:E}),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:p,onChange:B=>h(B.target.value),onKeyDown:B=>{B.key==="Enter"&&p.trim()&&!f&&q()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:q,children:f?"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."]})]})})]})})}const b3=15e3,S3=[70,80,85,90,95];function k3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function Tx(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 E3(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 N3(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 C3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),s=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?k3(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:s,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function T3(e){const n=e.map(s=>s.num),r=n.length?Math.max(...n):0;return[...new Set([...n,r+1])].sort((s,o)=>s-o)}async function R3(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(s=>window.setTimeout(()=>s(!1),500))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function j3(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 A3({onClose:e}){var Z,D,X;const[n,r]=A.useState(null),[s,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(null),[h,f]=A.useState(null),[m,y]=A.useState(()=>Math.floor(Date.now()/1e3)),x=A.useRef(null),[N,_]=A.useState(null),[b,S]=A.useState(!1),[k,E]=A.useState(""),[C,I]=A.useState(null),[M,O]=A.useState(null),[W,q]=A.useState(!1),P=A.useCallback(async(R=!1)=>{try{const[$,V]=await Promise.all([fetch(`/api/claude-accounts${R?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&r(await $.json()),V.ok&&o(await V.json())}catch{}},[]),L=A.useCallback(async(R,$)=>{u($),f(null);try{const F=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).json().catch(()=>null);return F!=null&&F.ok||f({text:Cx(F,"command failed"),raw:sv(F)}),F}catch{return f({text:"server unreachable"}),null}finally{u(null)}},[]),U=A.useCallback(async(R,$)=>{u($),f(null);try{const F=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).json().catch(()=>null);return F!=null&&F.ok||f({text:Yl(F,"command failed")}),F}catch{return f({text:"server unreachable"}),null}finally{u(null)}},[]);A.useEffect(()=>(P(!0),x.current=window.setInterval(()=>P(!1),b3),()=>{x.current!=null&&window.clearInterval(x.current)}),[P]),A.useEffect(()=>{const R=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(R)},[]);const B=((Z=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Z.value)??"90",j=(D=n==null?void 0:n.accounts)==null?void 0:D.find(R=>R.active),Q=j!=null&&j.lanes.length?Math.max(...j.lanes.map(R=>R.pct)):null,H=Q!=null&&Q>=Number(B)-15,te=async R=>{p(R),f(null);try{const V=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:R})})).json().catch(()=>null);V!=null&&V.ok||f({text:Cx(V,"the switch failed"),raw:sv(V)}),await P(!0)}catch{f({text:"server unreachable"})}finally{p(null)}};return g.jsxs("div",{className:"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:()=>S(!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:()=>P(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(X=n.accounts)==null?void 0:X.map(R=>g.jsxs("div",{className:`ap-account${R.active?" active":""}${R.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:R.num}),R.alias&&g.jsx("span",{className:"ap-alias",children:R.alias}),g.jsx("span",{className:"ap-email",title:R.org??void 0,children:R.email}),g.jsx("button",{type:"button",className:`ap-more${N===R.num?" on":""}`,"aria-label":`Manage account ${R.num}`,"aria-expanded":N===R.num,title:"Share, rename, move, remove",onClick:()=>{_(N===R.num?null:R.num),E(R.alias??""),I(null),O(null),q(!1)},children:"⋯"}),R.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||R.disabled,onClick:()=>te(R.num),title:R.disabled?"Held out of rotation":`Switch to ${R.alias??R.email}`,children:c===R.num?"…":"switch"})]}),R.lanes.length>0?R.lanes.map($=>g.jsx(C3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[R.error&&(()=>{const $=N3(R.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:$.hint,children:$.text}),$.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>S(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!R.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>L({action:"account",account:R.num,enabled:R.disabled},`rot-${R.num}`).then(()=>P(!0)),title:R.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:R.disabled?"held out":"in rotation"}),R.fetchedAt?g.jsxs("span",{className:`ap-age${R.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 ",Tx(R.fetchedAt,m),E3(R.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),N===R.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:k,onChange:$=>E($.target.value),onKeyDown:$=>{$.key==="Enter"&&U({action:"alias",account:R.num,alias:k},`alias-${R.num}`).then(()=>P(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${R.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||k.trim()===(R.alias??""),onClick:()=>U({action:"alias",account:R.num,alias:k},`alias-${R.num}`).then(()=>P(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${R.num}`,value:String(R.num),disabled:l!=null,onChange:$=>U({action:"move",account:R.num,slot:Number($.target.value)},`move-${R.num}`).then(()=>P(!0)),children:T3(n.accounts??[]).map($=>g.jsx("option",{value:$,children:$},$))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{q(!1);const $=await U({action:"share",account:R.num},`share-${R.num}`);$!=null&&$.ok&&O({num:R.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${C===R.num?" armed":""}`,disabled:l!=null,title:C===R.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(C!==R.num){I(R.num),window.setTimeout(()=>I($=>$===R.num?null:$),4e3);return}I(null),U({action:"remove",account:R.num},`rm-${R.num}`).then(()=>{_(null),P(!0)})},children:C===R.num?"confirm remove":"remove"})]}),(M==null?void 0:M.num)===R.num&&(()=>{const $=j3(M.expiresAt,m),V=$.tone==="gone";return g.jsxs("div",{className:`ap-share${V?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:M.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(V){q(!1);const F=await U({action:"share",account:R.num},`share-${R.num}`);F!=null&&F.ok&&O({num:R.num,blob:F.blob,expiresAt:F.expiresAt});return}await R3(M.blob)&&(q(!0),window.setTimeout(()=>q(!1),1800))},children:V?"make a new share":W?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",g.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]})]})]})})()]})]},R.num)),(s==null?void 0:s.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:[Q!=null&&g.jsxs("span",{className:`ap-auto-now${H?" near":""}`,children:[Math.round(Q),"%"]}),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:B,disabled:l!=null,onChange:R=>L({action:"setting",key:"autoswitch.threshold",value:R.target.value},"threshold").then(()=>P(!0)),children:S3.map(R=>g.jsxs("option",{value:R,children:[R,"%"]},R))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>L({action:"enable",enabled:!s.enabled},"enable").then(()=>P(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.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",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",Tx(s.lastTick.at,m)]})})]}),h&&g.jsxs("div",{className:"ap-failure",role:"alert",children:[g.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),g.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(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})`:"","."]})]})}),b&&g.jsx(_3,{onClose:()=>S(!1),onChanged:()=>P(!0)})]})}const I3=3e4;function M3({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function P3({bundle:e,running:n,pending:r,lastTried:s}){return n?M3({bundle:e,running:n,lastTried:s})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function O3(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function q3({asked:e,reported:n}){return n?n!==e:!1}function L3(e){const n=e.thresholdMs??I3;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 $3(e){return e.ctrlKey||e.metaKey||e.altKey}const D3=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),F3=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),z3=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function WN(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function VN(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=WN(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!D3.has(String(e.type??"text").toLowerCase())}function B3(e){if(!e)return!1;if(VN(e)||F3.has(WN(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>z3.has(r))}function U3({agentCount:e,onConfirm:n,onCancel:r}){const s=A.useRef(null);io(r,{focusRef:s,layer:KP});const o=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",{className:"modal clear-confirm",onClick:l=>l.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:[o," — 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:s,className:"btn",onClick:r,children:"Cancel"}),g.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function H3(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function wd(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function W3(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}const V3=40,G3=120;function Y3(e,n){let r=null,s=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,h,f)=>{if(r!=null){if(s<=p)return;u()}const m=Math.min(f,Math.max(0,p-h));s=p,r=n.setTimeout(l,m)};return{live(p=V3){const h=n.now(),f=Math.max(o+p,h);if(f<=h){u(),l();return}c(f,h,p)},replay(p=G3){u(),s=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function K3(){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 s=n;return n=[],s}}}const X3="1",Rx="agent-dag.schema",Q3=["agent-dag.layout","agent-dag.viewport"];function GN(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Z3(e,n=X3){let r=null;try{r=e.getItem(Rx)}catch{return[]}if(r===n)return[];const s=[];if(r!==null)for(const o of Q3)try{e.getItem(o)!==null&&(e.removeItem(o),s.push(o))}catch{}try{e.setItem(Rx,n)}catch{}return s}function J3(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function eq(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function Ki(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 jx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function Fl(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 tq=[7,14,30,90];function nq(e){const[n,r]=A.useState(null),[s,o]=A.useState(!1),l=A.useRef(J3()).current,u=(c=!1)=>{const p=l.begin();o(!0);const f=`/api/ccusage?since=${eq(e)}${c?"&refresh=1":""}`;fetch(f).then(m=>m.json()).then(m=>{p()&&r(m)}).catch(()=>{p()&&r({ok:!1,error:"request failed"})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{data:n,loading:s,reload:()=>u(!0)}}function rq({onClose:e}){var S,k;const[n,r]=A.useState(30),[s,o]=A.useState(null),{data:l,loading:u,reload:c}=nq(n);io(e);const p=l!=null&&l.ok?l.days??[]:[],h=A.useMemo(()=>p.reduce((E,C)=>Math.max(E,C.totalCost),0),[p]),{totalCost:f,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=A.useMemo(()=>{let E=0,C=0,I=0,M=0;const O=new Map;for(const W of p){E+=W.totalCost,C+=W.totalTokens,I+=W.inputTokens+W.outputTokens,M+=W.cacheReadTokens;for(const q of W.modelBreakdowns)O.set(q.modelName,(O.get(q.modelName)??0)+q.cost)}return{totalCost:E,totalTok:C,inOut:I,cacheRead:M,modelCosts:O}},[p]),_=A.useMemo(()=>Array.from(N.entries()).sort((E,C)=>C[1]-E[1]),[N]),b=s?p.find(E=>E.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:E=>E.stopPropagation(),role:"dialog","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:tq.map(E=>g.jsxs("button",{role:"tab","aria-selected":n===E,className:`uh-range-btn${n===E?" on":""}`,onClick:()=>{r(E),o(null)},children:[E,"d"]},E))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&p.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):p.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(zl,{label:"total cost",val:ze(f),accent:!0}),g.jsx(zl,{label:"tokens",val:Ki(m)}),g.jsx(zl,{label:"input+output",val:Ki(y)}),g.jsx(zl,{label:"cache reads",val:Ki(x)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:p.map(E=>{const C=h>0?E.totalCost/h*100:0,I=E.period===s;return g.jsxs("button",{className:`uh-bar-col${I?" sel":""}`,onClick:()=>o(I?null:E.period),title:`${E.period} · ${ze(E.totalCost)}`,style:{flexBasis:`${100/p.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((M,O)=>O.cost-M.cost).map(M=>{const O=E.totalCost>0?M.cost/E.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${O}%`,background:Fl(M.modelName)}},M.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([E,C])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:Fl(E)}}),jx(E)," ",g.jsx("span",{className:"uh-legend-cost",children:ze(C)})]},E))}),b&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:b.period}),g.jsx("span",{className:"uh-detail-cost",children:ze(b.totalCost)}),(k=(S=b.metadata)==null?void 0:S.agents)!=null&&k.length?g.jsx("span",{className:"uh-detail-agents",children:b.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Bl,{label:"input",val:Ki(b.inputTokens)}),g.jsx(Bl,{label:"output",val:Ki(b.outputTokens)}),g.jsx(Bl,{label:"cache write",val:Ki(b.cacheCreationTokens)}),g.jsx(Bl,{label:"cache read",val:Ki(b.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:b.modelBreakdowns.slice().sort((E,C)=>C.cost-E.cost).map(E=>{const C=b.totalCost>0?E.cost/b.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:Fl(E.modelName)}}),jx(E.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:Fl(E.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:ze(E.cost)})]},E.modelName)})})]})]})]})})}function zl({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 Bl({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 Av(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 xd,Ax;function iq(){if(Ax)return xd;Ax=1;function e(){this.__data__=[],this.size=0}return xd=e,xd}var _d,Ix;function so(){if(Ix)return _d;Ix=1;function e(n,r){return n===r||n!==n&&r!==r}return _d=e,_d}var bd,Mx;function mu(){if(Mx)return bd;Mx=1;var e=so();function n(r,s){for(var o=r.length;o--;)if(e(r[o][0],s))return o;return-1}return bd=n,bd}var Sd,Px;function sq(){if(Px)return Sd;Px=1;var e=mu(),n=Array.prototype,r=n.splice;function s(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 Sd=s,Sd}var kd,Ox;function oq(){if(Ox)return kd;Ox=1;var e=mu();function n(r){var s=this.__data__,o=e(s,r);return o<0?void 0:s[o][1]}return kd=n,kd}var Ed,qx;function aq(){if(qx)return Ed;qx=1;var e=mu();function n(r){return e(this.__data__,r)>-1}return Ed=n,Ed}var Nd,Lx;function lq(){if(Lx)return Nd;Lx=1;var e=mu();function n(r,s){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,s])):o[l][1]=s,this}return Nd=n,Nd}var Cd,$x;function gu(){if($x)return Cd;$x=1;var e=iq(),n=sq(),r=oq(),s=aq(),o=lq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Cd=l,Cd}var Td,Dx;function uq(){if(Dx)return Td;Dx=1;var e=gu();function n(){this.__data__=new e,this.size=0}return Td=n,Td}var Rd,Fx;function cq(){if(Fx)return Rd;Fx=1;function e(n){var r=this.__data__,s=r.delete(n);return this.size=r.size,s}return Rd=e,Rd}var jd,zx;function dq(){if(zx)return jd;zx=1;function e(n){return this.__data__.get(n)}return jd=e,jd}var Ad,Bx;function fq(){if(Bx)return Ad;Bx=1;function e(n){return this.__data__.has(n)}return Ad=e,Ad}var Id,Ux;function YN(){if(Ux)return Id;Ux=1;var e=typeof Nl=="object"&&Nl&&Nl.Object===Object&&Nl;return Id=e,Id}var Md,Hx;function Qn(){if(Hx)return Md;Hx=1;var e=YN(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return Md=r,Md}var Pd,Wx;function oo(){if(Wx)return Pd;Wx=1;var e=Qn(),n=e.Symbol;return Pd=n,Pd}var Od,Vx;function hq(){if(Vx)return Od;Vx=1;var e=oo(),n=Object.prototype,r=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),p=u[o];try{u[o]=void 0;var h=!0}catch{}var f=s.call(u);return h&&(c?u[o]=p:delete u[o]),f}return Od=l,Od}var qd,Gx;function pq(){if(Gx)return qd;Gx=1;var e=Object.prototype,n=e.toString;function r(s){return n.call(s)}return qd=r,qd}var Ld,Yx;function rs(){if(Yx)return Ld;Yx=1;var e=oo(),n=hq(),r=pq(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):r(c)}return Ld=u,Ld}var $d,Kx;function Nn(){if(Kx)return $d;Kx=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return $d=e,$d}var Dd,Xx;function _a(){if(Xx)return Dd;Xx=1;var e=rs(),n=Nn(),r="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==s||p==o||p==r||p==l}return Dd=u,Dd}var Fd,Qx;function mq(){if(Qx)return Fd;Qx=1;var e=Qn(),n=e["__core-js_shared__"];return Fd=n,Fd}var zd,Zx;function gq(){if(Zx)return zd;Zx=1;var e=mq(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function r(s){return!!n&&n in s}return zd=r,zd}var Bd,Jx;function KN(){if(Jx)return Bd;Jx=1;var e=Function.prototype,n=e.toString;function r(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Bd=r,Bd}var Ud,e_;function vq(){if(e_)return Ud;e_=1;var e=_a(),n=gq(),r=Nn(),s=KN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,h=c.hasOwnProperty,f=RegExp("^"+p.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var x=e(y)?f:l;return x.test(s(y))}return Ud=m,Ud}var Hd,t_;function yq(){if(t_)return Hd;t_=1;function e(n,r){return n==null?void 0:n[r]}return Hd=e,Hd}var Wd,n_;function is(){if(n_)return Wd;n_=1;var e=vq(),n=yq();function r(s,o){var l=n(s,o);return e(l)?l:void 0}return Wd=r,Wd}var Vd,r_;function Iv(){if(r_)return Vd;r_=1;var e=is(),n=Qn(),r=e(n,"Map");return Vd=r,Vd}var Gd,i_;function vu(){if(i_)return Gd;i_=1;var e=is(),n=e(Object,"create");return Gd=n,Gd}var Yd,s_;function wq(){if(s_)return Yd;s_=1;var e=vu();function n(){this.__data__=e?e(null):{},this.size=0}return Yd=n,Yd}var Kd,o_;function xq(){if(o_)return Kd;o_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Kd=e,Kd}var Xd,a_;function _q(){if(a_)return Xd;a_=1;var e=vu(),n="__lodash_hash_undefined__",r=Object.prototype,s=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Xd=o,Xd}var Qd,l_;function bq(){if(l_)return Qd;l_=1;var e=vu(),n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Qd=s,Qd}var Zd,u_;function Sq(){if(u_)return Zd;u_=1;var e=vu(),n="__lodash_hash_undefined__";function r(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Zd=r,Zd}var Jd,c_;function kq(){if(c_)return Jd;c_=1;var e=wq(),n=xq(),r=_q(),s=bq(),o=Sq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Jd=l,Jd}var ef,d_;function Eq(){if(d_)return ef;d_=1;var e=kq(),n=gu(),r=Iv();function s(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return ef=s,ef}var tf,f_;function Nq(){if(f_)return tf;f_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return tf=e,tf}var nf,h_;function yu(){if(h_)return nf;h_=1;var e=Nq();function n(r,s){var o=r.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return nf=n,nf}var rf,p_;function Cq(){if(p_)return rf;p_=1;var e=yu();function n(r){var s=e(this,r).delete(r);return this.size-=s?1:0,s}return rf=n,rf}var sf,m_;function Tq(){if(m_)return sf;m_=1;var e=yu();function n(r){return e(this,r).get(r)}return sf=n,sf}var of,g_;function Rq(){if(g_)return of;g_=1;var e=yu();function n(r){return e(this,r).has(r)}return of=n,of}var af,v_;function jq(){if(v_)return af;v_=1;var e=yu();function n(r,s){var o=e(this,r),l=o.size;return o.set(r,s),this.size+=o.size==l?0:1,this}return af=n,af}var lf,y_;function Mv(){if(y_)return lf;y_=1;var e=Eq(),n=Cq(),r=Tq(),s=Rq(),o=jq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,lf=l,lf}var uf,w_;function Aq(){if(w_)return uf;w_=1;var e=gu(),n=Iv(),r=Mv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<s-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(p)}return c.set(l,u),this.size=c.size,this}return uf=o,uf}var cf,x_;function wu(){if(x_)return cf;x_=1;var e=gu(),n=uq(),r=cq(),s=dq(),o=fq(),l=Aq();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,cf=u,cf}var df,__;function Pv(){if(__)return df;__=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o&&r(n[s],s,n)!==!1;);return n}return df=e,df}var ff,b_;function XN(){if(b_)return ff;b_=1;var e=is(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return ff=n,ff}var hf,S_;function xu(){if(S_)return hf;S_=1;var e=XN();function n(r,s,o){s=="__proto__"&&e?e(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[s]=o}return hf=n,hf}var pf,k_;function _u(){if(k_)return pf;k_=1;var e=xu(),n=so(),r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(s.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return pf=o,pf}var mf,E_;function ba(){if(E_)return mf;E_=1;var e=_u(),n=xu();function r(s,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],m=u?u(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),c?n(l,f,m):e(l,f,m)}return l}return mf=r,mf}var gf,N_;function Iq(){if(N_)return gf;N_=1;function e(n,r){for(var s=-1,o=Array(n);++s<n;)o[s]=r(s);return o}return gf=e,gf}var vf,C_;function fr(){if(C_)return vf;C_=1;function e(n){return n!=null&&typeof n=="object"}return vf=e,vf}var yf,T_;function Mq(){if(T_)return yf;T_=1;var e=rs(),n=fr(),r="[object Arguments]";function s(o){return n(o)&&e(o)==r}return yf=s,yf}var wf,R_;function Sa(){if(R_)return wf;R_=1;var e=Mq(),n=fr(),r=Object.prototype,s=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return wf=l,wf}var xf,j_;function _t(){if(j_)return xf;j_=1;var e=Array.isArray;return xf=e,xf}var ta={exports:{}},_f,A_;function Pq(){if(A_)return _f;A_=1;function e(){return!1}return _f=e,_f}ta.exports;var I_;function ao(){return I_||(I_=1,(function(e,n){var r=Qn(),s=Pq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,p=c?c.isBuffer:void 0,h=p||s;e.exports=h})(ta,ta.exports)),ta.exports}var bf,M_;function bu(){if(M_)return bf;M_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return bf=r,bf}var Sf,P_;function Ov(){if(P_)return Sf;P_=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Sf=n,Sf}var kf,O_;function Oq(){if(O_)return kf;O_=1;var e=rs(),n=Ov(),r=fr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",x="[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]",M="[object Int32Array]",O="[object Uint8Array]",W="[object Uint8ClampedArray]",q="[object Uint16Array]",P="[object Uint32Array]",L={};L[k]=L[E]=L[C]=L[I]=L[M]=L[O]=L[W]=L[q]=L[P]=!0,L[s]=L[o]=L[b]=L[l]=L[S]=L[u]=L[c]=L[p]=L[h]=L[f]=L[m]=L[y]=L[x]=L[N]=L[_]=!1;function U(B){return r(B)&&n(B.length)&&!!L[e(B)]}return kf=U,kf}var Ef,q_;function Su(){if(q_)return Ef;q_=1;function e(n){return function(r){return n(r)}}return Ef=e,Ef}var na={exports:{}};na.exports;var L_;function qv(){return L_||(L_=1,(function(e,n){var r=YN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&r.process,c=(function(){try{var p=o&&o.require&&o.require("util").types;return p||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(na,na.exports)),na.exports}var Nf,$_;function ka(){if($_)return Nf;$_=1;var e=Oq(),n=Su(),r=qv(),s=r&&r.isTypedArray,o=s?n(s):e;return Nf=o,Nf}var Cf,D_;function QN(){if(D_)return Cf;D_=1;var e=Iq(),n=Sa(),r=_t(),s=ao(),o=bu(),l=ka(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var m=r(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&l(h),_=m||y||x||N,b=_?e(h.length,String):[],S=b.length;for(var k in h)(f||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return Cf=p,Cf}var Tf,F_;function ku(){if(F_)return Tf;F_=1;var e=Object.prototype;function n(r){var s=r&&r.constructor,o=typeof s=="function"&&s.prototype||e;return r===o}return Tf=n,Tf}var Rf,z_;function ZN(){if(z_)return Rf;z_=1;function e(n,r){return function(s){return n(r(s))}}return Rf=e,Rf}var jf,B_;function qq(){if(B_)return jf;B_=1;var e=ZN(),n=e(Object.keys,Object);return jf=n,jf}var Af,U_;function Lv(){if(U_)return Af;U_=1;var e=ku(),n=qq(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return Af=o,Af}var If,H_;function Or(){if(H_)return If;H_=1;var e=_a(),n=Ov();function r(s){return s!=null&&n(s.length)&&!e(s)}return If=r,If}var Mf,W_;function gi(){if(W_)return Mf;W_=1;var e=QN(),n=Lv(),r=Or();function s(o){return r(o)?e(o):n(o)}return Mf=s,Mf}var Pf,V_;function Lq(){if(V_)return Pf;V_=1;var e=ba(),n=gi();function r(s,o){return s&&e(o,n(o),s)}return Pf=r,Pf}var Of,G_;function $q(){if(G_)return Of;G_=1;function e(n){var r=[];if(n!=null)for(var s in Object(n))r.push(s);return r}return Of=e,Of}var qf,Y_;function Dq(){if(Y_)return qf;Y_=1;var e=Nn(),n=ku(),r=$q(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),p=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||p.push(h);return p}return qf=l,qf}var Lf,K_;function ss(){if(K_)return Lf;K_=1;var e=QN(),n=Dq(),r=Or();function s(o){return r(o)?e(o,!0):n(o)}return Lf=s,Lf}var $f,X_;function Fq(){if(X_)return $f;X_=1;var e=ba(),n=ss();function r(s,o){return s&&e(o,n(o),s)}return $f=r,$f}var ra={exports:{}};ra.exports;var Q_;function JN(){return Q_||(Q_=1,(function(e,n){var r=Qn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=p})(ra,ra.exports)),ra.exports}var Df,Z_;function eC(){if(Z_)return Df;Z_=1;function e(n,r){var s=-1,o=n.length;for(r||(r=Array(o));++s<o;)r[s]=n[s];return r}return Df=e,Df}var Ff,J_;function tC(){if(J_)return Ff;J_=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];r(c,s,n)&&(u[l++]=c)}return u}return Ff=e,Ff}var zf,e1;function nC(){if(e1)return zf;e1=1;function e(){return[]}return zf=e,zf}var Bf,t1;function $v(){if(t1)return Bf;t1=1;var e=tC(),n=nC(),r=Object.prototype,s=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Bf=l,Bf}var Uf,n1;function zq(){if(n1)return Uf;n1=1;var e=ba(),n=$v();function r(s,o){return e(s,n(s),o)}return Uf=r,Uf}var Hf,r1;function Dv(){if(r1)return Hf;r1=1;function e(n,r){for(var s=-1,o=r.length,l=n.length;++s<o;)n[l+s]=r[s];return n}return Hf=e,Hf}var Wf,i1;function Eu(){if(i1)return Wf;i1=1;var e=ZN(),n=e(Object.getPrototypeOf,Object);return Wf=n,Wf}var Vf,s1;function rC(){if(s1)return Vf;s1=1;var e=Dv(),n=Eu(),r=$v(),s=nC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:s;return Vf=l,Vf}var Gf,o1;function Bq(){if(o1)return Gf;o1=1;var e=ba(),n=rC();function r(s,o){return e(s,n(s),o)}return Gf=r,Gf}var Yf,a1;function iC(){if(a1)return Yf;a1=1;var e=Dv(),n=_t();function r(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Yf=r,Yf}var Kf,l1;function sC(){if(l1)return Kf;l1=1;var e=iC(),n=$v(),r=gi();function s(o){return e(o,r,n)}return Kf=s,Kf}var Xf,u1;function Uq(){if(u1)return Xf;u1=1;var e=iC(),n=rC(),r=ss();function s(o){return e(o,r,n)}return Xf=s,Xf}var Qf,c1;function Hq(){if(c1)return Qf;c1=1;var e=is(),n=Qn(),r=e(n,"DataView");return Qf=r,Qf}var Zf,d1;function Wq(){if(d1)return Zf;d1=1;var e=is(),n=Qn(),r=e(n,"Promise");return Zf=r,Zf}var Jf,f1;function oC(){if(f1)return Jf;f1=1;var e=is(),n=Qn(),r=e(n,"Set");return Jf=r,Jf}var eh,h1;function Vq(){if(h1)return eh;h1=1;var e=is(),n=Qn(),r=e(n,"WeakMap");return eh=r,eh}var th,p1;function lo(){if(p1)return th;p1=1;var e=Hq(),n=Iv(),r=Wq(),s=oC(),o=Vq(),l=rs(),u=KN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(r),b=u(s),S=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=h||s&&k(new s)!=f||o&&k(new o)!=m)&&(k=function(E){var C=l(E),I=C==p?E.constructor:void 0,M=I?u(I):"";if(M)switch(M){case x:return y;case N:return c;case _:return h;case b:return f;case S:return m}return C}),th=k,th}var nh,m1;function Gq(){if(m1)return nh;m1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return nh=r,nh}var rh,g1;function aC(){if(g1)return rh;g1=1;var e=Qn(),n=e.Uint8Array;return rh=n,rh}var ih,v1;function Fv(){if(v1)return ih;v1=1;var e=aC();function n(r){var s=new r.constructor(r.byteLength);return new e(s).set(new e(r)),s}return ih=n,ih}var sh,y1;function Yq(){if(y1)return sh;y1=1;var e=Fv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return sh=n,sh}var oh,w1;function Kq(){if(w1)return oh;w1=1;var e=/\w*$/;function n(r){var s=new r.constructor(r.source,e.exec(r));return s.lastIndex=r.lastIndex,s}return oh=n,oh}var ah,x1;function Xq(){if(x1)return ah;x1=1;var e=oo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function s(o){return r?Object(r.call(o)):{}}return ah=s,ah}var lh,_1;function lC(){if(_1)return lh;_1=1;var e=Fv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return lh=n,lh}var uh,b1;function Qq(){if(b1)return uh;b1=1;var e=Fv(),n=Yq(),r=Kq(),s=Xq(),o=lC(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",x="[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]",M="[object Uint16Array]",O="[object Uint32Array]";function W(q,P,L){var U=q.constructor;switch(P){case x:return e(q);case l:case u:return new U(+q);case N:return n(q,L);case _:case b:case S:case k:case E:case C:case I:case M:case O:return o(q,L);case c:return new U;case p:case m:return new U(q);case h:return r(q);case f:return new U;case y:return s(q)}}return uh=W,uh}var ch,S1;function uC(){if(S1)return ch;S1=1;var e=Nn(),n=Object.create,r=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return ch=r,ch}var dh,k1;function cC(){if(k1)return dh;k1=1;var e=uC(),n=Eu(),r=ku();function s(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return dh=s,dh}var fh,E1;function Zq(){if(E1)return fh;E1=1;var e=lo(),n=fr(),r="[object Map]";function s(o){return n(o)&&e(o)==r}return fh=s,fh}var hh,N1;function Jq(){if(N1)return hh;N1=1;var e=Zq(),n=Su(),r=qv(),s=r&&r.isMap,o=s?n(s):e;return hh=o,hh}var ph,C1;function eL(){if(C1)return ph;C1=1;var e=lo(),n=fr(),r="[object Set]";function s(o){return n(o)&&e(o)==r}return ph=s,ph}var mh,T1;function tL(){if(T1)return mh;T1=1;var e=eL(),n=Su(),r=qv(),s=r&&r.isSet,o=s?n(s):e;return mh=o,mh}var gh,R1;function dC(){if(R1)return gh;R1=1;var e=wu(),n=Pv(),r=_u(),s=Lq(),o=Fq(),l=JN(),u=eC(),c=zq(),p=Bq(),h=sC(),f=Uq(),m=lo(),y=Gq(),x=Qq(),N=cC(),_=_t(),b=ao(),S=Jq(),k=Nn(),E=tL(),C=gi(),I=ss(),M=1,O=2,W=4,q="[object Arguments]",P="[object Array]",L="[object Boolean]",U="[object Date]",B="[object Error]",j="[object Function]",Q="[object GeneratorFunction]",H="[object Map]",te="[object Number]",Z="[object Object]",D="[object RegExp]",X="[object Set]",R="[object String]",$="[object Symbol]",V="[object WeakMap]",F="[object ArrayBuffer]",J="[object DataView]",ne="[object Float32Array]",le="[object Float64Array]",de="[object Int8Array]",me="[object Int16Array]",ve="[object Int32Array]",Pe="[object Uint8Array]",Me="[object Uint8ClampedArray]",Oe="[object Uint16Array]",ye="[object Uint32Array]",Se={};Se[q]=Se[P]=Se[F]=Se[J]=Se[L]=Se[U]=Se[ne]=Se[le]=Se[de]=Se[me]=Se[ve]=Se[H]=Se[te]=Se[Z]=Se[D]=Se[X]=Se[R]=Se[$]=Se[Pe]=Se[Me]=Se[Oe]=Se[ye]=!0,Se[B]=Se[j]=Se[V]=!1;function Ke(xe,ge,Fe,pt,mt,Ze){var De,Qe=ge&M,at=ge&O,It=ge&W;if(Fe&&(De=mt?Fe(xe,pt,mt,Ze):Fe(xe)),De!==void 0)return De;if(!k(xe))return xe;var it=_(xe);if(it){if(De=y(xe),!Qe)return u(xe,De)}else{var gt=m(xe),Kt=gt==j||gt==Q;if(b(xe))return l(xe,Qe);if(gt==Z||gt==q||Kt&&!mt){if(De=at||Kt?{}:N(xe),!Qe)return at?p(xe,o(De,xe)):c(xe,s(De,xe))}else{if(!Se[gt])return mt?xe:{};De=x(xe,gt,Qe)}}Ze||(Ze=new e);var Mt=Ze.get(xe);if(Mt)return Mt;Ze.set(xe,De),E(xe)?xe.forEach(function(dt){De.add(Ke(dt,ge,Fe,dt,xe,Ze))}):S(xe)&&xe.forEach(function(dt,lt){De.set(lt,Ke(dt,ge,Fe,lt,xe,Ze))});var Ye=It?at?f:h:at?I:C,Nt=it?void 0:Ye(xe);return n(Nt||xe,function(dt,lt){Nt&&(lt=dt,dt=xe[lt]),r(De,lt,Ke(dt,ge,Fe,lt,xe,Ze))}),De}return gh=Ke,gh}var vh,j1;function nL(){if(j1)return vh;j1=1;var e=dC(),n=4;function r(s){return e(s,n)}return vh=r,vh}var yh,A1;function zv(){if(A1)return yh;A1=1;function e(n){return function(){return n}}return yh=e,yh}var wh,I1;function rL(){if(I1)return wh;I1=1;function e(n){return function(r,s,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var h=c[n?p:++l];if(s(u[h],h,u)===!1)break}return r}}return wh=e,wh}var xh,M1;function Bv(){if(M1)return xh;M1=1;var e=rL(),n=e();return xh=n,xh}var _h,P1;function Uv(){if(P1)return _h;P1=1;var e=Bv(),n=gi();function r(s,o){return s&&e(s,o,n)}return _h=r,_h}var bh,O1;function iL(){if(O1)return bh;O1=1;var e=Or();function n(r,s){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=s?u:-1,p=Object(o);(s?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return bh=n,bh}var Sh,q1;function Nu(){if(q1)return Sh;q1=1;var e=Uv(),n=iL(),r=n(e);return Sh=r,Sh}var kh,L1;function os(){if(L1)return kh;L1=1;function e(n){return n}return kh=e,kh}var Eh,$1;function fC(){if($1)return Eh;$1=1;var e=os();function n(r){return typeof r=="function"?r:e}return Eh=n,Eh}var Nh,D1;function hC(){if(D1)return Nh;D1=1;var e=Pv(),n=Nu(),r=fC(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u))}return Nh=o,Nh}var Ch,F1;function pC(){return F1||(F1=1,Ch=hC()),Ch}var Th,z1;function sL(){if(z1)return Th;z1=1;var e=Nu();function n(r,s){var o=[];return e(r,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return Th=n,Th}var Rh,B1;function oL(){if(B1)return Rh;B1=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return Rh=n,Rh}var jh,U1;function aL(){if(U1)return jh;U1=1;function e(n){return this.__data__.has(n)}return jh=e,jh}var Ah,H1;function mC(){if(H1)return Ah;H1=1;var e=Mv(),n=oL(),r=aL();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=r,Ah=s,Ah}var Ih,W1;function lL(){if(W1)return Ih;W1=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o;)if(r(n[s],s,n))return!0;return!1}return Ih=e,Ih}var Mh,V1;function gC(){if(V1)return Mh;V1=1;function e(n,r){return n.has(r)}return Mh=e,Mh}var Ph,G1;function vC(){if(G1)return Ph;G1=1;var e=mC(),n=lL(),r=gC(),s=1,o=2;function l(u,c,p,h,f,m){var y=p&s,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(u),b=m.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,E=p&o?new e:void 0;for(m.set(u,c),m.set(c,u);++S<x;){var C=u[S],I=c[S];if(h)var M=y?h(I,C,S,c,u,m):h(C,I,S,u,c,m);if(M!==void 0){if(M)continue;k=!1;break}if(E){if(!n(c,function(O,W){if(!r(E,W)&&(C===O||f(C,O,p,h,m)))return E.push(W)})){k=!1;break}}else if(!(C===I||f(C,I,p,h,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return Ph=l,Ph}var Oh,Y1;function uL(){if(Y1)return Oh;Y1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o,l){s[++r]=[l,o]}),s}return Oh=e,Oh}var qh,K1;function Hv(){if(K1)return qh;K1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o){s[++r]=o}),s}return qh=e,qh}var Lh,X1;function cL(){if(X1)return Lh;X1=1;var e=oo(),n=aC(),r=so(),s=vC(),o=uL(),l=Hv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",x="[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(M,O,W,q,P,L,U){switch(W){case k:if(M.byteLength!=O.byteLength||M.byteOffset!=O.byteOffset)return!1;M=M.buffer,O=O.buffer;case S:return!(M.byteLength!=O.byteLength||!L(new n(M),new n(O)));case p:case h:case y:return r(+M,+O);case f:return M.name==O.name&&M.message==O.message;case x:case _:return M==O+"";case m:var B=o;case N:var j=q&u;if(B||(B=l),M.size!=O.size&&!j)return!1;var Q=U.get(M);if(Q)return Q==O;q|=c,U.set(M,O);var H=s(B(M),B(O),q,P,L,U);return U.delete(M),H;case b:if(C)return C.call(M)==C.call(O)}return!1}return Lh=I,Lh}var $h,Q1;function dL(){if(Q1)return $h;Q1=1;var e=sC(),n=1,r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c,p,h,f){var m=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!m)return!1;for(var b=x;b--;){var S=y[b];if(!(m?S in u:s.call(u,S)))return!1}var k=f.get(l),E=f.get(u);if(k&&E)return k==u&&E==l;var C=!0;f.set(l,u),f.set(u,l);for(var I=m;++b<x;){S=y[b];var M=l[S],O=u[S];if(p)var W=m?p(O,M,S,u,l,f):p(M,O,S,l,u,f);if(!(W===void 0?M===O||h(M,O,c,p,f):W)){C=!1;break}I||(I=S=="constructor")}if(C&&!I){var q=l.constructor,P=u.constructor;q!=P&&"constructor"in l&&"constructor"in u&&!(typeof q=="function"&&q instanceof q&&typeof P=="function"&&P instanceof P)&&(C=!1)}return f.delete(l),f.delete(u),C}return $h=o,$h}var Dh,Z1;function fL(){if(Z1)return Dh;Z1=1;var e=wu(),n=vC(),r=cL(),s=dL(),o=lo(),l=_t(),u=ao(),c=ka(),p=1,h="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,b,S,k,E,C){var I=l(_),M=l(b),O=I?f:o(_),W=M?f:o(b);O=O==h?m:O,W=W==h?m:W;var q=O==m,P=W==m,L=O==W;if(L&&u(_)){if(!u(b))return!1;I=!0,q=!1}if(L&&!q)return C||(C=new e),I||c(_)?n(_,b,S,k,E,C):r(_,b,O,S,k,E,C);if(!(S&p)){var U=q&&x.call(_,"__wrapped__"),B=P&&x.call(b,"__wrapped__");if(U||B){var j=U?_.value():_,Q=B?b.value():b;return C||(C=new e),E(j,Q,S,k,C)}}return L?(C||(C=new e),s(_,b,S,k,E,C)):!1}return Dh=N,Dh}var Fh,J1;function yC(){if(J1)return Fh;J1=1;var e=fL(),n=fr();function r(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,r,c)}return Fh=r,Fh}var zh,eb;function hL(){if(eb)return zh;eb=1;var e=wu(),n=yC(),r=1,s=2;function o(l,u,c,p){var h=c.length,f=h,m=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<f;){y=c[h];var x=y[0],N=l[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in l))return!1}else{var b=new e;if(p)var S=p(N,_,x,l,u,b);if(!(S===void 0?n(_,N,r|s,p,b):S))return!1}}return!0}return zh=o,zh}var Bh,tb;function wC(){if(tb)return Bh;tb=1;var e=Nn();function n(r){return r===r&&!e(r)}return Bh=n,Bh}var Uh,nb;function pL(){if(nb)return Uh;nb=1;var e=wC(),n=gi();function r(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return Uh=r,Uh}var Hh,rb;function xC(){if(rb)return Hh;rb=1;function e(n,r){return function(s){return s==null?!1:s[n]===r&&(r!==void 0||n in Object(s))}}return Hh=e,Hh}var Wh,ib;function mL(){if(ib)return Wh;ib=1;var e=hL(),n=pL(),r=xC();function s(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 Wh=s,Wh}var Vh,sb;function uo(){if(sb)return Vh;sb=1;var e=rs(),n=fr(),r="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==r}return Vh=s,Vh}var Gh,ob;function Wv(){if(ob)return Gh;ob=1;var e=_t(),n=uo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\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:s.test(l)||!r.test(l)||u!=null&&l in Object(u)}return Gh=o,Gh}var Yh,ab;function gL(){if(ab)return Yh;ab=1;var e=Mv(),n="Expected a function";function r(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=s.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(r.Cache||e),l}return r.Cache=e,Yh=r,Yh}var Kh,lb;function vL(){if(lb)return Kh;lb=1;var e=gL(),n=500;function r(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Kh=r,Kh}var Xh,ub;function yL(){if(ub)return Xh;ub=1;var e=vL(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(r,"$1"):c||u)}),l});return Xh=s,Xh}var Qh,cb;function Cu(){if(cb)return Qh;cb=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=r(n[s],s,n);return l}return Qh=e,Qh}var Zh,db;function wL(){if(db)return Zh;db=1;var e=oo(),n=Cu(),r=_t(),s=uo(),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(s(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Zh=u,Zh}var Jh,fb;function _C(){if(fb)return Jh;fb=1;var e=wL();function n(r){return r==null?"":e(r)}return Jh=n,Jh}var ep,hb;function Tu(){if(hb)return ep;hb=1;var e=_t(),n=Wv(),r=yL(),s=_C();function o(l,u){return e(l)?l:n(l,u)?[l]:r(s(l))}return ep=o,ep}var tp,pb;function Ea(){if(pb)return tp;pb=1;var e=uo();function n(r){if(typeof r=="string"||e(r))return r;var s=r+"";return s=="0"&&1/r==-1/0?"-0":s}return tp=n,tp}var np,mb;function Ru(){if(mb)return np;mb=1;var e=Tu(),n=Ea();function r(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return np=r,np}var rp,gb;function xL(){if(gb)return rp;gb=1;var e=Ru();function n(r,s,o){var l=r==null?void 0:e(r,s);return l===void 0?o:l}return rp=n,rp}var ip,vb;function _L(){if(vb)return ip;vb=1;function e(n,r){return n!=null&&r in Object(n)}return ip=e,ip}var sp,yb;function bC(){if(yb)return sp;yb=1;var e=Tu(),n=Sa(),r=_t(),s=bu(),o=Ov(),l=Ea();function u(c,p,h){p=e(p,c);for(var f=-1,m=p.length,y=!1;++f<m;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(r(c)||n(c)))}return sp=u,sp}var op,wb;function SC(){if(wb)return op;wb=1;var e=_L(),n=bC();function r(s,o){return s!=null&&n(s,o,e)}return op=r,op}var ap,xb;function bL(){if(xb)return ap;xb=1;var e=yC(),n=xL(),r=SC(),s=Wv(),o=wC(),l=xC(),u=Ea(),c=1,p=2;function h(f,m){return s(f)&&o(m)?l(u(f),m):function(y){var x=n(y,f);return x===void 0&&x===m?r(y,f):e(m,x,c|p)}}return ap=h,ap}var lp,_b;function kC(){if(_b)return lp;_b=1;function e(n){return function(r){return r==null?void 0:r[n]}}return lp=e,lp}var up,bb;function SL(){if(bb)return up;bb=1;var e=Ru();function n(r){return function(s){return e(s,r)}}return up=n,up}var cp,Sb;function kL(){if(Sb)return cp;Sb=1;var e=kC(),n=SL(),r=Wv(),s=Ea();function o(l){return r(l)?e(s(l)):n(l)}return cp=o,cp}var dp,kb;function qr(){if(kb)return dp;kb=1;var e=mL(),n=bL(),r=os(),s=_t(),o=kL();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return dp=l,dp}var fp,Eb;function EC(){if(Eb)return fp;Eb=1;var e=tC(),n=sL(),r=qr(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u,3))}return fp=o,fp}var hp,Nb;function EL(){if(Nb)return hp;Nb=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s,o){return s!=null&&n.call(s,o)}return hp=r,hp}var pp,Cb;function NC(){if(Cb)return pp;Cb=1;var e=EL(),n=bC();function r(s,o){return s!=null&&n(s,o,e)}return pp=r,pp}var mp,Tb;function NL(){if(Tb)return mp;Tb=1;var e=Lv(),n=lo(),r=Sa(),s=_t(),o=Or(),l=ao(),u=ku(),c=ka(),p="[object Map]",h="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||r(x)))return!x.length;var N=n(x);if(N==p||N==h)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return mp=y,mp}var gp,Rb;function CC(){if(Rb)return gp;Rb=1;function e(n){return n===void 0}return gp=e,gp}var vp,jb;function TC(){if(jb)return vp;jb=1;var e=Nu(),n=Or();function r(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,p,h){u[++l]=o(c,p,h)}),u}return vp=r,vp}var yp,Ab;function RC(){if(Ab)return yp;Ab=1;var e=Cu(),n=qr(),r=TC(),s=_t();function o(l,u){var c=s(l)?e:r;return c(l,n(u,3))}return yp=o,yp}var wp,Ib;function CL(){if(Ib)return wp;Ib=1;function e(n,r,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=r(s,n[l],l,n);return s}return wp=e,wp}var xp,Mb;function TL(){if(Mb)return xp;Mb=1;function e(n,r,s,o,l){return l(n,function(u,c,p){s=o?(o=!1,u):r(s,u,c,p)}),s}return xp=e,xp}var _p,Pb;function jC(){if(Pb)return _p;Pb=1;var e=CL(),n=Nu(),r=qr(),s=TL(),o=_t();function l(u,c,p){var h=o(u)?e:s,f=arguments.length<3;return h(u,r(c,4),p,f,n)}return _p=l,_p}var bp,Ob;function RL(){if(Ob)return bp;Ob=1;var e=rs(),n=_t(),r=fr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==s}return bp=o,bp}var Sp,qb;function jL(){if(qb)return Sp;qb=1;var e=kC(),n=e("length");return Sp=n,Sp}var kp,Lb;function AL(){if(Lb)return kp;Lb=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return kp=p,kp}var Ep,$b;function IL(){if($b)return Ep;$b=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+l+"]?",b="(?:"+x+"(?:"+[f,m,y].join("|")+")"+_+N+")*",S=_+N+b,k="(?:"+[f+c+"?",c,m,y,u].join("|")+")",E=RegExp(p+"(?="+p+")|"+k+S,"g");function C(I){for(var M=E.lastIndex=0;E.test(I);)++M;return M}return Ep=C,Ep}var Np,Db;function ML(){if(Db)return Np;Db=1;var e=jL(),n=AL(),r=IL();function s(o){return n(o)?r(o):e(o)}return Np=s,Np}var Cp,Fb;function PL(){if(Fb)return Cp;Fb=1;var e=Lv(),n=lo(),r=Or(),s=RL(),o=ML(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return s(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return Cp=c,Cp}var Tp,zb;function OL(){if(zb)return Tp;zb=1;var e=Pv(),n=uC(),r=Uv(),s=qr(),o=Eu(),l=_t(),u=ao(),c=_a(),p=Nn(),h=ka();function f(m,y,x){var N=l(m),_=N||u(m)||h(m);if(y=s(y,4),x==null){var b=m&&m.constructor;_?x=N?new b:[]:p(m)?x=c(b)?n(o(m)):{}:x={}}return(_?e:r)(m,function(S,k,E){return y(x,S,k,E)}),x}return Tp=f,Tp}var Rp,Bb;function qL(){if(Bb)return Rp;Bb=1;var e=oo(),n=Sa(),r=_t(),s=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(s&&l&&l[s])}return Rp=o,Rp}var jp,Ub;function Vv(){if(Ub)return jp;Ub=1;var e=Dv(),n=qL();function r(s,o,l,u,c){var p=-1,h=s.length;for(l||(l=n),c||(c=[]);++p<h;){var f=s[p];o>0&&l(f)?o>1?r(f,o-1,l,u,c):e(c,f):u||(c[c.length]=f)}return c}return jp=r,jp}var Ap,Hb;function LL(){if(Hb)return Ap;Hb=1;function e(n,r,s){switch(s.length){case 0:return n.call(r);case 1:return n.call(r,s[0]);case 2:return n.call(r,s[0],s[1]);case 3:return n.call(r,s[0],s[1],s[2])}return n.apply(r,s)}return Ap=e,Ap}var Ip,Wb;function AC(){if(Wb)return Ip;Wb=1;var e=LL(),n=Math.max;function r(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),h=Array(p);++c<p;)h[c]=u[o+c];c=-1;for(var f=Array(o+1);++c<o;)f[c]=u[c];return f[o]=l(h),e(s,this,f)}}return Ip=r,Ip}var Mp,Vb;function $L(){if(Vb)return Mp;Vb=1;var e=zv(),n=XN(),r=os(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return Mp=s,Mp}var Pp,Gb;function DL(){if(Gb)return Pp;Gb=1;var e=800,n=16,r=Date.now;function s(o){var l=0,u=0;return function(){var c=r(),p=n-(c-u);if(u=c,p>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return Pp=s,Pp}var Op,Yb;function IC(){if(Yb)return Op;Yb=1;var e=$L(),n=DL(),r=n(e);return Op=r,Op}var qp,Kb;function ju(){if(Kb)return qp;Kb=1;var e=os(),n=AC(),r=IC();function s(o,l){return r(n(o,l,e),o+"")}return qp=s,qp}var Lp,Xb;function MC(){if(Xb)return Lp;Xb=1;function e(n,r,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return Lp=e,Lp}var $p,Qb;function FL(){if(Qb)return $p;Qb=1;function e(n){return n!==n}return $p=e,$p}var Dp,Zb;function zL(){if(Zb)return Dp;Zb=1;function e(n,r,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return Dp=e,Dp}var Fp,Jb;function BL(){if(Jb)return Fp;Jb=1;var e=MC(),n=FL(),r=zL();function s(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return Fp=s,Fp}var zp,eS;function UL(){if(eS)return zp;eS=1;var e=BL();function n(r,s){var o=r==null?0:r.length;return!!o&&e(r,s,0)>-1}return zp=n,zp}var Bp,tS;function HL(){if(tS)return Bp;tS=1;function e(n,r,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(r,n[o]))return!0;return!1}return Bp=e,Bp}var Up,nS;function WL(){if(nS)return Up;nS=1;function e(){}return Up=e,Up}var Hp,rS;function VL(){if(rS)return Hp;rS=1;var e=oC(),n=WL(),r=Hv(),s=1/0,o=e&&1/r(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Hp=o,Hp}var Wp,iS;function GL(){if(iS)return Wp;iS=1;var e=mC(),n=UL(),r=HL(),s=gC(),o=VL(),l=Hv(),u=200;function c(p,h,f){var m=-1,y=n,x=p.length,N=!0,_=[],b=_;if(f)N=!1,y=r;else if(x>=u){var S=h?null:o(p);if(S)return l(S);N=!1,y=s,b=new e}else b=h?[]:_;e:for(;++m<x;){var k=p[m],E=h?h(k):k;if(k=f||k!==0?k:0,N&&E===E){for(var C=b.length;C--;)if(b[C]===E)continue e;h&&b.push(E),_.push(k)}else y(b,E,f)||(b!==_&&b.push(E),_.push(k))}return _}return Wp=c,Wp}var Vp,sS;function PC(){if(sS)return Vp;sS=1;var e=Or(),n=fr();function r(s){return n(s)&&e(s)}return Vp=r,Vp}var Gp,oS;function YL(){if(oS)return Gp;oS=1;var e=Vv(),n=ju(),r=GL(),s=PC(),o=n(function(l){return r(e(l,1,s,!0))});return Gp=o,Gp}var Yp,aS;function KL(){if(aS)return Yp;aS=1;var e=Cu();function n(r,s){return e(s,function(o){return r[o]})}return Yp=n,Yp}var Kp,lS;function OC(){if(lS)return Kp;lS=1;var e=KL(),n=gi();function r(s){return s==null?[]:e(s,n(s))}return Kp=r,Kp}var Xp,uS;function Cn(){if(uS)return Xp;uS=1;var e;if(typeof Av=="function")try{e={clone:nL(),constant:zv(),each:pC(),filter:EC(),has:NC(),isArray:_t(),isEmpty:NL(),isFunction:_a(),isUndefined:CC(),keys:gi(),map:RC(),reduce:jC(),size:PL(),transform:OL(),union:YL(),values:OC()}}catch{}return e||(e=window._),Xp=e,Xp}var Qp,cS;function Gv(){if(cS)return Qp;cS=1;var e=Cn();Qp=o;var n="\0",r="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.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(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},o.prototype.setNodes=function(f,m){var y=arguments,x=this;return e.each(f,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),this},o.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=r,this._children[f]={},this._children[r][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){m.setParent(x)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,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===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==r)return m}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=r),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===r)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},o.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},o.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},o.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},o.prototype.filterNodes=function(f){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){f(b)&&m.setNode(b,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function N(_){var b=y.parent(_);return b===void 0||m.hasNode(b)?(x[_]=b,b):b in x?x[b]:N(b)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,m){var y=this,x=arguments;return e.reduce(f,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var f,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,f,m,y);if(e.has(this._edgeLabels,b))return N&&(this._edgeLabels[b]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[b]=N?x:this._defaultEdgeLabelFn(f,m,y);var S=p(this._isDirected,f,m,y);return f=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][b]=S,this._out[f][b]=S,this._edgeCount++,this},o.prototype.edge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y),N=this._edgeObjs[x];return N&&(f=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[m],f),u(this._sucs[f],m),delete this._in[m][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function u(f,m){--f[m]||delete f[m]}function c(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var b=N;N=_,_=b}return N+s+_+s+(e.isUndefined(x)?n:x)}function p(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var b=N;N=_,_=b}var S={v:N,w:_};return x&&(S.name=x),S}function h(f,m){return c(f,m.v,m.w,m.name)}return Qp}var Zp,dS;function XL(){return dS||(dS=1,Zp="2.1.8"),Zp}var Jp,fS;function QL(){return fS||(fS=1,Jp={Graph:Gv(),version:XL()}),Jp}var em,hS;function ZL(){if(hS)return em;hS=1;var e=Cn(),n=Gv();em={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var p=u.node(c),h=u.parent(c),f={v:c};return e.isUndefined(p)||(f.value=p),e.isUndefined(h)||(f.parent=h),f})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(p)||(h.value=p),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return em}var tm,pS;function JL(){if(pS)return tm;pS=1;var e=Cn();tm=n;function n(r){var s={},o=[],l;function u(c){e.has(s,c)||(s[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 tm}var nm,mS;function qC(){if(mS)return nm;mS=1;var e=Cn();nm=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 s=this._keyIndices[r];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,s){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:s}),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,s){var o=this._keyIndices[r];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(r){var s=this._arr,o=2*r,l=o+1,u=r;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var s=this._arr,o=s[r].priority,l;r!==0&&(l=r>>1,!(s[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,s){var o=this._arr,l=this._keyIndices,u=o[r],c=o[s];o[r]=c,o[s]=u,l[c.key]=r,l[u.key]=s},nm}var rm,gS;function LC(){if(gS)return rm;gS=1;var e=Cn(),n=qC();rm=s;var r=e.constant(1);function s(l,u,c,p){return o(l,String(u),c||r,p||function(h){return l.outEdges(h)})}function o(l,u,c,p){var h={},f=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,b=h[_],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,f.decrease(_,k))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;h[N]={distance:_},f.add(N,_)});f.size()>0&&(m=f.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)p(m).forEach(x);return h}return rm}var im,vS;function e$(){if(vS)return im;vS=1;var e=LC(),n=Cn();im=r;function r(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return im}var sm,yS;function $C(){if(yS)return sm;yS=1;var e=Cn();sm=n;function n(r){var s=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:s,index:s++};if(o.push(p),r.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var f=[],m;do m=o.pop(),l[m].onStack=!1,f.push(m);while(p!==m);u.push(f)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return sm}var om,wS;function t$(){if(wS)return om;wS=1;var e=Cn(),n=$C();om=r;function r(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return om}var am,xS;function n$(){if(xS)return am;xS=1;var e=Cn();am=r;var n=e.constant(1);function r(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},p=o.nodes();return p.forEach(function(h){c[h]={},c[h][h]={distance:0},p.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(f){var m=f.v===h?f.w:f.v,y=l(f);c[h][m]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(m){var y=c[m];p.forEach(function(x){var N=y[h],_=f[x],b=y[x],S=N.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return am}var lm,_S;function DC(){if(_S)return lm;_S=1;var e=Cn();lm=n,n.CycleException=r;function n(s){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new r;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(s.predecessors(p),c),delete l[p],u.push(p))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,lm}var um,bS;function r$(){if(bS)return um;bS=1;var e=DC();um=n;function n(r){try{e(r)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return um}var cm,SS;function FC(){if(SS)return cm;SS=1;var e=Cn();cm=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],p={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);r(s,h,l==="post",p,u,c)}),c}function r(s,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){r(s,h,l,u,c,p)}),l&&p.push(o))}return cm}var dm,kS;function i$(){if(kS)return dm;kS=1;var e=FC();dm=n;function n(r,s){return e(r,s,"post")}return dm}var fm,ES;function s$(){if(ES)return fm;ES=1;var e=FC();fm=n;function n(r,s){return e(r,s,"pre")}return fm}var hm,NS;function o$(){if(NS)return hm;NS=1;var e=Cn(),n=Gv(),r=qC();hm=s;function s(o,l){var u=new n,c={},p=new r,h;function f(y){var x=y.v===h?y.w:y.v,N=p.priority(x);if(N!==void 0){var _=l(y);_<N&&(c[x]=h,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var m=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(f)}return u}return hm}var pm,CS;function a$(){return CS||(CS=1,pm={components:JL(),dijkstra:LC(),dijkstraAll:e$(),findCycles:t$(),floydWarshall:n$(),isAcyclic:r$(),postorder:i$(),preorder:s$(),prim:o$(),tarjan:$C(),topsort:DC()}),pm}var mm,TS;function l$(){if(TS)return mm;TS=1;var e=QL();return mm={Graph:e.Graph,json:ZL(),alg:a$(),version:e.version},mm}var gm,RS;function Kn(){if(RS)return gm;RS=1;var e;if(typeof Av=="function")try{e=l$()}catch{}return e||(e=window.graphlib),gm=e,gm}var vm,jS;function u$(){if(jS)return vm;jS=1;var e=dC(),n=1,r=4;function s(o){return e(o,n|r)}return vm=s,vm}var ym,AS;function Au(){if(AS)return ym;AS=1;var e=so(),n=Or(),r=bu(),s=Nn();function o(l,u,c){if(!s(c))return!1;var p=typeof u;return(p=="number"?n(c)&&r(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return ym=o,ym}var wm,IS;function c$(){if(IS)return wm;IS=1;var e=ju(),n=so(),r=Au(),s=ss(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,m=f>2?p[2]:void 0;for(m&&r(p[0],p[1],m)&&(f=1);++h<f;)for(var y=p[h],x=s(y),N=-1,_=x.length;++N<_;){var b=x[N],S=c[b];(S===void 0||n(S,o[b])&&!l.call(c,b))&&(c[b]=y[b])}return c});return wm=u,wm}var xm,MS;function d$(){if(MS)return xm;MS=1;var e=qr(),n=Or(),r=gi();function s(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=r(l),u=function(m){return h(p[m],m,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return xm=s,xm}var _m,PS;function f$(){if(PS)return _m;PS=1;var e=/\s/;function n(r){for(var s=r.length;s--&&e.test(r.charAt(s)););return s}return _m=n,_m}var bm,OS;function h$(){if(OS)return bm;OS=1;var e=f$(),n=/^\s+/;function r(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return bm=r,bm}var Sm,qS;function p$(){if(qS)return Sm;qS=1;var e=h$(),n=Nn(),r=uo(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(h){if(typeof h=="number")return h;if(r(h))return s;if(n(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=n(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return Sm=p,Sm}var km,LS;function zC(){if(LS)return km;LS=1;var e=p$(),n=1/0,r=17976931348623157e292;function s(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=s,km}var Em,$S;function m$(){if($S)return Em;$S=1;var e=zC();function n(r){var s=e(r),o=s%1;return s===s?o?s-o:s:0}return Em=n,Em}var Nm,DS;function g$(){if(DS)return Nm;DS=1;var e=MC(),n=qr(),r=m$(),s=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var h=c==null?0:r(c);return h<0&&(h=s(p+h,0)),e(l,n(u,3),h)}return Nm=o,Nm}var Cm,FS;function v$(){if(FS)return Cm;FS=1;var e=d$(),n=g$(),r=e(n);return Cm=r,Cm}var Tm,zS;function BC(){if(zS)return Tm;zS=1;var e=Vv();function n(r){var s=r==null?0:r.length;return s?e(r,1):[]}return Tm=n,Tm}var Rm,BS;function y$(){if(BS)return Rm;BS=1;var e=Bv(),n=fC(),r=ss();function s(o,l){return o==null?o:e(o,n(l),r)}return Rm=s,Rm}var jm,US;function w$(){if(US)return jm;US=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return jm=e,jm}var Am,HS;function x$(){if(HS)return Am;HS=1;var e=xu(),n=Uv(),r=qr();function s(o,l){var u={};return l=r(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return Am=s,Am}var Im,WS;function Yv(){if(WS)return Im;WS=1;var e=uo();function n(r,s,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=s(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return Im=n,Im}var Mm,VS;function _$(){if(VS)return Mm;VS=1;function e(n,r){return n>r}return Mm=e,Mm}var Pm,GS;function b$(){if(GS)return Pm;GS=1;var e=Yv(),n=_$(),r=os();function s(o){return o&&o.length?e(o,r,n):void 0}return Pm=s,Pm}var Om,YS;function UC(){if(YS)return Om;YS=1;var e=xu(),n=so();function r(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return Om=r,Om}var qm,KS;function S$(){if(KS)return qm;KS=1;var e=rs(),n=Eu(),r=fr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function h(f){if(!r(f)||e(f)!=s)return!1;var m=n(f);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return qm=h,qm}var Lm,XS;function HC(){if(XS)return Lm;XS=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Lm=e,Lm}var $m,QS;function k$(){if(QS)return $m;QS=1;var e=ba(),n=ss();function r(s){return e(s,n(s))}return $m=r,$m}var Dm,ZS;function E$(){if(ZS)return Dm;ZS=1;var e=UC(),n=JN(),r=lC(),s=eC(),o=cC(),l=Sa(),u=_t(),c=PC(),p=ao(),h=_a(),f=Nn(),m=S$(),y=ka(),x=HC(),N=k$();function _(b,S,k,E,C,I,M){var O=x(b,k),W=x(S,k),q=M.get(W);if(q){e(b,k,q);return}var P=I?I(O,W,k+"",b,S,M):void 0,L=P===void 0;if(L){var U=u(W),B=!U&&p(W),j=!U&&!B&&y(W);P=W,U||B||j?u(O)?P=O:c(O)?P=s(O):B?(L=!1,P=n(W,!0)):j?(L=!1,P=r(W,!0)):P=[]:m(W)||l(W)?(P=O,l(O)?P=N(O):(!f(O)||h(O))&&(P=o(W))):L=!1}L&&(M.set(W,P),C(P,W,E,I,M),M.delete(W)),e(b,k,P)}return Dm=_,Dm}var Fm,JS;function N$(){if(JS)return Fm;JS=1;var e=wu(),n=UC(),r=Bv(),s=E$(),o=Nn(),l=ss(),u=HC();function c(p,h,f,m,y){p!==h&&r(h,function(x,N){if(y||(y=new e),o(x))s(p,h,N,f,c,m,y);else{var _=m?m(u(p,N),x,N+"",p,h,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return Fm=c,Fm}var zm,ek;function C$(){if(ek)return zm;ek=1;var e=ju(),n=Au();function r(s){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(p=s.length>3&&typeof p=="function"?(c--,p):void 0,h&&n(l[0],l[1],h)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var f=l[u];f&&s(o,f,u,p)}return o})}return zm=r,zm}var Bm,tk;function T$(){if(tk)return Bm;tk=1;var e=N$(),n=C$(),r=n(function(s,o,l){e(s,o,l)});return Bm=r,Bm}var Um,nk;function WC(){if(nk)return Um;nk=1;function e(n,r){return n<r}return Um=e,Um}var Hm,rk;function R$(){if(rk)return Hm;rk=1;var e=Yv(),n=WC(),r=os();function s(o){return o&&o.length?e(o,r,n):void 0}return Hm=s,Hm}var Wm,ik;function j$(){if(ik)return Wm;ik=1;var e=Yv(),n=qr(),r=WC();function s(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return Wm=s,Wm}var Vm,sk;function A$(){if(sk)return Vm;sk=1;var e=Qn(),n=function(){return e.Date.now()};return Vm=n,Vm}var Gm,ok;function I$(){if(ok)return Gm;ok=1;var e=_u(),n=Tu(),r=bu(),s=Nn(),o=Ea();function l(u,c,p,h){if(!s(u))return u;c=n(c,u);for(var f=-1,m=c.length,y=m-1,x=u;x!=null&&++f<m;){var N=o(c[f]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(f!=y){var b=x[N];_=h?h(b,N,x):void 0,_===void 0&&(_=s(b)?b:r(c[f+1])?[]:{})}e(x,N,_),x=x[N]}return u}return Gm=l,Gm}var Ym,ak;function M$(){if(ak)return Ym;ak=1;var e=Ru(),n=I$(),r=Tu();function s(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],m=e(o,f);u(m,f)&&n(h,r(f,o),m)}return h}return Ym=s,Ym}var Km,lk;function P$(){if(lk)return Km;lk=1;var e=M$(),n=SC();function r(s,o){return e(s,o,function(l,u){return n(s,u)})}return Km=r,Km}var Xm,uk;function O$(){if(uk)return Xm;uk=1;var e=BC(),n=AC(),r=IC();function s(o){return r(n(o,void 0,e),o+"")}return Xm=s,Xm}var Qm,ck;function q$(){if(ck)return Qm;ck=1;var e=P$(),n=O$(),r=n(function(s,o){return s==null?{}:e(s,o)});return Qm=r,Qm}var Zm,dk;function L$(){if(dk)return Zm;dk=1;var e=Math.ceil,n=Math.max;function r(s,o,l,u){for(var c=-1,p=n(e((o-s)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=s,s+=l;return h}return Zm=r,Zm}var Jm,fk;function $$(){if(fk)return Jm;fk=1;var e=L$(),n=Au(),r=zC();function s(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 Jm=s,Jm}var eg,hk;function D$(){if(hk)return eg;hk=1;var e=$$(),n=e();return eg=n,eg}var tg,pk;function F$(){if(pk)return tg;pk=1;function e(n,r){var s=n.length;for(n.sort(r);s--;)n[s]=n[s].value;return n}return tg=e,tg}var ng,mk;function z$(){if(mk)return ng;mk=1;var e=uo();function n(r,s){if(r!==s){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=s!==void 0,h=s===null,f=s===s,m=e(s);if(!h&&!m&&!c&&r>s||c&&p&&f&&!h&&!m||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!m&&r<s||m&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return ng=n,ng}var rg,gk;function B$(){if(gk)return rg;gk=1;var e=z$();function n(r,s,o){for(var l=-1,u=r.criteria,c=s.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var m=o[l];return f*(m=="desc"?-1:1)}}return r.index-s.index}return rg=n,rg}var ig,vk;function U$(){if(vk)return ig;vk=1;var e=Cu(),n=Ru(),r=qr(),s=TC(),o=F$(),l=Su(),u=B$(),c=os(),p=_t();function h(f,m,y){m.length?m=e(m,function(_){return p(_)?function(b){return n(b,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,l(r));var N=s(f,function(_,b,S){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,b){return u(_,b,y)})}return ig=h,ig}var sg,yk;function H$(){if(yk)return sg;yk=1;var e=Vv(),n=U$(),r=ju(),s=Au(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return sg=o,sg}var og,wk;function W$(){if(wk)return og;wk=1;var e=_C(),n=0;function r(s){var o=++n;return e(s)+o}return og=r,og}var ag,xk;function V$(){if(xk)return ag;xk=1;function e(n,r,s){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;s(c,n[o],p)}return c}return ag=e,ag}var lg,_k;function G$(){if(_k)return lg;_k=1;var e=_u(),n=V$();function r(s,o){return n(s||[],o||[],e)}return lg=r,lg}var ug,bk;function ot(){if(bk)return ug;bk=1;var e;if(typeof Av=="function")try{e={cloneDeep:u$(),constant:zv(),defaults:c$(),each:pC(),filter:EC(),find:v$(),flatten:BC(),forEach:hC(),forIn:y$(),has:NC(),isUndefined:CC(),last:w$(),map:RC(),mapValues:x$(),max:b$(),merge:T$(),min:R$(),minBy:j$(),now:A$(),pick:q$(),range:D$(),reduce:jC(),sortBy:H$(),uniqueId:W$(),values:OC(),zipObject:G$()}}catch{}return e||(e=window._),ug=e,ug}var cg,Sk;function Y$(){if(Sk)return cg;Sk=1,cg=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,r)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function r(s,o){if(s!=="_next"&&s!=="_prev")return o}return cg}var dg,kk;function K$(){if(kk)return dg;kk=1;var e=ot(),n=Kn().Graph,r=Y$();dg=o;var s=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var m=c(h,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,m){for(var y=[],x=f[f.length-1],N=f[0],_;h.nodeCount();){for(;_=N.dequeue();)u(h,f,m,_);for(;_=x.dequeue();)u(h,f,m,_);if(h.nodeCount()){for(var b=f.length-2;b>0;--b)if(_=f[b].dequeue(),_){y=y.concat(u(h,f,m,_,!0));break}}}return y}function u(h,f,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var b=h.edge(_),S=h.node(_.v);x&&N.push({v:_.v,w:_.w}),S.out-=b,p(f,m,S)}),e.forEach(h.outEdges(y.v),function(_){var b=h.edge(_),S=_.w,k=h.node(S);k.in-=b,p(f,m,k)}),h.removeNode(y.v),N}function c(h,f){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(h.edges(),function(b){var S=m.edge(b.v,b.w)||0,k=f(b),E=S+k;m.setEdge(b.v,b.w,E),x=Math.max(x,m.node(b.v).out+=k),y=Math.max(y,m.node(b.w).in+=k)});var N=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(b){p(N,_,m.node(b))}),{graph:m,buckets:N,zeroIdx:_}}function p(h,f,m){m.out?m.in?h[m.out-m.in+f].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return dg}var fg,Ek;function X$(){if(Ek)return fg;Ek=1;var e=ot(),n=K$();fg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function c(p){return function(h){return p.edge(h).weight}}}function s(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[f])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return fg}var hg,Nk;function on(){if(Nk)return hg;Nk=1;var e=ot(),n=Kn().Graph;hg={addDummyNode:r,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:x,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 s(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,M=b.width/2,O=b.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var W,q;return Math.abs(I)*M>Math.abs(C)*O?(I<0&&(O=-O),W=O*C/I,q=O):(C<0&&(M=-M),W=M,q=M*I/C),{x:k+W,y:E+q}}function p(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 h(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 f(b){var S=e.min(e.map(b.nodes(),function(I){return b.node(I).rank})),k=[];e.forEach(b.nodes(),function(I){var M=b.node(I).rank-S;k[M]||(k[M]=[]),k[M].push(I)});var E=0,C=b.graph().nodeRankFactor;e.forEach(k,function(I,M){e.isUndefined(I)&&M%C!==0?--E:E&&e.forEach(I,function(O){b.node(O).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 x(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 hg}var pg,Ck;function Q$(){if(Ck)return pg;Ck=1;var e=ot(),n=on();pg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,m=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var N,_,b;for(b=0,++p;p<f;++b,++p)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:p},N=n.addDummyNode(l,"edge",_,"_d"),p===x&&(_.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,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,h;for(l.setEdge(c.edgeObj,p);c.dummy;)h=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=h,c=l.node(u)})}return pg}var mg,Tk;function ou(){if(Tk)return mg;Tk=1;var e=ot();mg={longestPath:n,slack:r};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(s.sources(),l)}function r(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return mg}var gg,Rk;function VC(){if(Rk)return gg;Rk=1;var e=ot(),n=Kn().Graph,r=ou().slack;gg=s;function s(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var m,y;o(p,c)<f;)m=l(p,c),y=p.hasNode(m.v)?r(c,m):-r(c,m),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(m){var y=m.v,x=f===y?m.w:y;!c.hasNode(x)&&!r(p,m)&&(c.setNode(x,{}),c.setEdge(f,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return r(p,h)})}function u(c,p,h){e.forEach(c.nodes(),function(f){p.node(f).rank+=h})}return gg}var vg,jk;function Z$(){if(jk)return vg;jk=1;var e=ot(),n=VC(),r=ou().slack,s=ou().longestPath,o=Kn().alg.preorder,l=Kn().alg.postorder,u=on().simplify;vg=c,c.initLowLimValues=m,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),s(E);var C=n(E);m(C),p(C,E);for(var I,M;I=x(C);)M=N(C,E,I),_(C,E,I,M)}function p(E,C){var I=l(E,E.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(M){h(E,C,M)})}function h(E,C,I){var M=E.node(I),O=M.parent;E.edge(I,O).cutvalue=f(E,C,I)}function f(E,C,I){var M=E.node(I),O=M.parent,W=!0,q=C.edge(I,O),P=0;return q||(W=!1,q=C.edge(O,I)),P=q.weight,e.forEach(C.nodeEdges(I),function(L){var U=L.v===I,B=U?L.w:L.v;if(B!==O){var j=U===W,Q=C.edge(L).weight;if(P+=j?Q:-Q,S(E,I,B)){var H=E.edge(I,B).cutvalue;P+=j?-H:H}}}),P}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,I,M,O){var W=I,q=E.node(M);return C[M]=!0,e.forEach(E.neighbors(M),function(P){e.has(C,P)||(I=y(E,C,I,P,M))}),q.low=W,q.lim=I++,O?q.parent=O:delete q.parent,I}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,I){var M=I.v,O=I.w;C.hasEdge(M,O)||(M=I.w,O=I.v);var W=E.node(M),q=E.node(O),P=W,L=!1;W.lim>q.lim&&(P=q,L=!0);var U=e.filter(C.edges(),function(B){return L===k(E,E.node(B.v),P)&&L!==k(E,E.node(B.w),P)});return e.minBy(U,function(B){return r(C,B)})}function _(E,C,I,M){var O=I.v,W=I.w;E.removeEdge(O,W),E.setEdge(M.v,M.w,{}),m(E),p(E,C),b(E,C)}function b(E,C){var I=e.find(E.nodes(),function(O){return!C.node(O).parent}),M=o(E,I);M=M.slice(1),e.forEach(M,function(O){var W=E.node(O).parent,q=C.edge(O,W),P=!1;q||(q=C.edge(W,O),P=!0),C.node(O).rank=C.node(W).rank+(P?q.minlen:-q.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 vg}var yg,Ak;function J$(){if(Ak)return yg;Ak=1;var e=ou(),n=e.longestPath,r=VC(),s=Z$();yg=o;function o(p){switch(p.graph().ranker){case"network-simplex":c(p);break;case"tight-tree":u(p);break;case"longest-path":l(p);break;default:c(p)}}var l=n;function u(p){n(p),r(p)}function c(p){s(p)}return yg}var wg,Ik;function e4(){if(Ik)return wg;Ik=1;var e=ot();wg=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,h=r(o,l,p.v,p.w),f=h.path,m=h.lca,y=0,x=f[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=f[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<f.length-1&&o.node(x=f[y+1]).minRank<=c.rank;)y++;x=f[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function r(o,l,u,c){var p=[],h=[],f=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:p.concat(h.reverse()),lca:x}}function s(o){var l={},u=0;function c(p){var h=u;e.forEach(o.children(p),c),l[p]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return wg}var xg,Mk;function t4(){if(Mk)return xg;Mk=1;var e=ot(),n=on();xg={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,m=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(x){s(c,p,m,y,f,h,x)}),c.graph().nodeRankFactor=m}function s(c,p,h,f,m,y,x){var N=c.children(x);if(!N.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),b=n.addBorderNode(c,"_bb"),S=c.node(x);c.setParent(_,x),S.borderTop=_,c.setParent(b,x),S.borderBottom=b,e.forEach(N,function(k){s(c,p,h,f,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,I=E.borderBottom?E.borderBottom:k,M=E.borderTop?f:2*f,O=C!==I?1:m-y[x]+1;c.setEdge(_,C,{weight:M,minlen:O,nestingEdge:!0}),c.setEdge(I,b,{weight:M,minlen:O,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:m+y[x]})}function o(c){var p={};function h(f,m){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),p[f]=m}return e.forEach(c.children(),function(f){h(f,1)}),p}function l(c){return e.reduce(c.edges(),function(p,h){return p+c.edge(h).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return xg}var _g,Pk;function n4(){if(Pk)return _g;Pk=1;var e=ot(),n=on();_g=r;function r(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,f=p.maxRank+1;h<f;++h)s(o,"borderLeft","_bl",u,p,h),s(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},m=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return _g}var bg,Ok;function r4(){if(Ok)return bg;Ok=1;var e=ot();bg={adjust:n,undo:r};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function r(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){o(h.node(f))}),e.forEach(h.edges(),function(f){o(h.edge(f))})}function o(h){var f=h.width;h.width=h.height,h.height=f}function l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){p(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,p),e.has(m,"x")&&p(m)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return bg}var Sg,qk;function i4(){if(qk)return Sg;qk=1;var e=ot();Sg=n;function n(r){var s={},o=e.filter(r.nodes(),function(h){return!r.children(h).length}),l=e.max(e.map(o,function(h){return r.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=r.node(h);u[f.rank].push(h),e.forEach(r.successors(h),c)}}var p=e.sortBy(o,function(h){return r.node(h).rank});return e.forEach(p,c),u}return Sg}var kg,Lk;function s4(){if(Lk)return kg;Lk=1;var e=ot();kg=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=r(s,o[u-1],o[u]);return l}function r(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:u[x.w],weight:s.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var h=2*p-1;p-=1;var f=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;f[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=f[x+1]),x=x-1>>1,f[x]+=y.weight;m+=y.weight*N})),m}return kg}var Eg,$k;function o4(){if($k)return Eg;$k=1;var e=ot();Eg=n;function n(r,s){return e.map(s,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var h=r.edge(p),f=r.node(p.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return Eg}var Ng,Dk;function a4(){if(Dk)return Ng;Dk=1;var e=ot();Ng=n;function n(o,l){var u={};e.forEach(o,function(p,h){var f=u[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:h};e.isUndefined(p.barycenter)||(f.barycenter=p.barycenter,f.weight=p.weight)}),e.forEach(l.edges(),function(p){var h=u[p.v],f=u[p.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(u[p.w]))});var c=e.filter(u,function(p){return!p.indegree});return r(c)}function r(o){var l=[];function u(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&o.push(f)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(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 Ng}var Cg,Fk;function l4(){if(Fk)return Cg;Fk=1;var e=ot(),n=on();Cg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),f=[],m=0,y=0,x=0;p.sort(o(!!u)),x=s(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(f,h,x)});var N={vs:e.flatten(f,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.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 Cg}var Tg,zk;function u4(){if(zk)return Tg;zk=1;var e=ot(),n=o4(),r=a4(),s=l4();Tg=o;function o(c,p,h,f){var m=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(I){return I!==x&&I!==N}));var b=n(c,m);e.forEach(b,function(I){if(c.children(I.v).length){var M=o(c,I.v,h,f);_[I.v]=M,e.has(M,"barycenter")&&u(I,M)}});var S=r(b,h);l(S,_);var k=s(S,f);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[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,p){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return p[f]?p[f].vs:f}),!0)})}function u(c,p){e.isUndefined(c.barycenter)?(c.barycenter=p.barycenter,c.weight=p.weight):(c.barycenter=(c.barycenter*c.weight+p.barycenter*p.weight)/(c.weight+p.weight),c.weight+=p.weight)}return Tg}var Rg,Bk;function c4(){if(Bk)return Rg;Bk=1;var e=ot(),n=Kn().Graph;Rg=r;function r(o,l,u){var c=s(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var f=o.node(h),m=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,m||c),e.forEach(o[u](h),function(y){var x=y.v===h?y.w:y.v,N=p.edge(x,h),_=e.isUndefined(N)?0:N.weight;p.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(f,"minRank")&&p.setNode(h,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),p}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return Rg}var jg,Uk;function d4(){if(Uk)return jg;Uk=1;var e=ot();jg=n;function n(r,s,o){var l={},u;e.forEach(o,function(c){for(var p=r.parent(c),h,f;p;){if(h=r.parent(p),h?(f=l[h],l[h]=p):(f=u,u=p),f&&f!==p){s.setEdge(f,p);return}p=h}})}return jg}var Ag,Hk;function f4(){if(Hk)return Ag;Hk=1;var e=ot(),n=i4(),r=s4(),s=u4(),o=c4(),l=d4(),u=Kn().Graph,c=on();Ag=p;function p(y){var x=c.maxRank(y),N=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-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){f(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 h(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function f(y,x){var N=new u;e.forEach(y,function(_){var b=_.graph().root,S=s(_,b,N,x);e.forEach(S.vs,function(k,E){_.node(k).order=E}),l(_,N,S.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,b){y.node(_).order=b})})}return Ag}var Ig,Wk;function h4(){if(Wk)return Ig;Wk=1;var e=ot(),n=Kn().Graph,r=on();Ig={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(S,k){var E={};function C(I,M){var O=0,W=0,q=I.length,P=e.last(M);return e.forEach(M,function(L,U){var B=l(S,L),j=B?S.node(B).order:q;(B||L===P)&&(e.forEach(M.slice(W,U+1),function(Q){e.forEach(S.predecessors(Q),function(H){var te=S.node(H),Z=te.order;(Z<O||j<Z)&&!(te.dummy&&S.node(Q).dummy)&&u(E,H,Q)})}),W=U+1,O=j)}),M}return e.reduce(k,C),E}function o(S,k){var E={};function C(M,O,W,q,P){var L;e.forEach(e.range(O,W),function(U){L=M[U],S.node(L).dummy&&e.forEach(S.predecessors(L),function(B){var j=S.node(B);j.dummy&&(j.order<q||j.order>P)&&u(E,B,L)})})}function I(M,O){var W=-1,q,P=0;return e.forEach(O,function(L,U){if(S.node(L).dummy==="border"){var B=S.predecessors(L);B.length&&(q=S.node(B[0]).order,C(O,P,U,W,q),P=U,W=q)}C(O,P,O.length,q,M.length)}),O}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 p(S,k,E,C){var I={},M={},O={};return e.forEach(k,function(W){e.forEach(W,function(q,P){I[q]=q,M[q]=q,O[q]=P})}),e.forEach(k,function(W){var q=-1;e.forEach(W,function(P){var L=C(P);if(L.length){L=e.sortBy(L,function(H){return O[H]});for(var U=(L.length-1)/2,B=Math.floor(U),j=Math.ceil(U);B<=j;++B){var Q=L[B];M[P]===P&&q<O[Q]&&!c(E,P,Q)&&(M[Q]=P,M[P]=I[P]=I[Q],q=O[Q])}}})}),{root:I,align:M}}function h(S,k,E,C,I){var M={},O=f(S,k,E,I),W=I?"borderLeft":"borderRight";function q(U,B){for(var j=O.nodes(),Q=j.pop(),H={};Q;)H[Q]?U(Q):(H[Q]=!0,j.push(Q),j=j.concat(B(Q))),Q=j.pop()}function P(U){M[U]=O.inEdges(U).reduce(function(B,j){return Math.max(B,M[j.v]+O.edge(j))},0)}function L(U){var B=O.outEdges(U).reduce(function(Q,H){return Math.min(Q,M[H.w]-O.edge(H))},Number.POSITIVE_INFINITY),j=S.node(U);B!==Number.POSITIVE_INFINITY&&j.borderType!==W&&(M[U]=Math.max(M[U],B))}return q(P,O.predecessors.bind(O)),q(L,O.successors.bind(O)),e.forEach(C,function(U){M[U]=M[E[U]]}),M}function f(S,k,E,C){var I=new n,M=S.graph(),O=_(M.nodesep,M.edgesep,C);return e.forEach(k,function(W){var q;e.forEach(W,function(P){var L=E[P];if(I.setNode(L),q){var U=E[q],B=I.edge(U,L);I.setEdge(U,L,Math.max(O(S,P,q),B||0))}q=P})}),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(M,O){var W=b(S,O)/2;C=Math.max(M+W,C),I=Math.min(M-W,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(M){e.forEach(["l","r"],function(O){var W=M+O,q=S[W],P;if(q!==k){var L=e.values(q);P=O==="l"?C-e.min(L):I-e.max(L),P&&(S[W]=e.mapValues(q,function(U){return U+P}))}})})}function x(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(s(S,k),o(S,k)),C={},I;e.forEach(["u","d"],function(O){I=O==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(W){W==="r"&&(I=e.map(I,function(U){return e.values(U).reverse()}));var q=(O==="u"?S.predecessors:S.successors).bind(S),P=p(S,I,E,q),L=h(S,I,P.root,P.align,W==="r");W==="r"&&(L=e.mapValues(L,function(U){return-U})),C[O+W]=L})});var M=m(S,C);return y(C,M),x(C,S.graph().align)}function _(S,k,E){return function(C,I,M){var O=C.node(I),W=C.node(M),q=0,P;if(q+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":P=-O.width/2;break;case"r":P=O.width/2;break}if(P&&(q+=E?P:-P),P=0,q+=(O.dummy?k:S)/2,q+=(W.dummy?k:S)/2,q+=W.width/2,e.has(W,"labelpos"))switch(W.labelpos.toLowerCase()){case"l":P=W.width/2;break;case"r":P=-W.width/2;break}return P&&(q+=E?P:-P),P=0,q}}function b(S,k){return S.node(k).width}return Ig}var Mg,Vk;function p4(){if(Vk)return Mg;Vk=1;var e=ot(),n=on(),r=h4().positionX;Mg=s;function s(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,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=p+f/2}),p+=f+c})}return Mg}var Pg,Gk;function m4(){if(Gk)return Pg;Gk=1;var e=ot(),n=X$(),r=Q$(),s=J$(),o=on().normalizeRanks,l=e4(),u=on().removeEmptyRanks,c=t4(),p=n4(),h=r4(),f=f4(),m=p4(),y=on(),x=Kn().Graph;Pg=N;function N(F,J){var ne=J&&J.debugTiming?y.time:y.notime;ne("layout",function(){var le=ne(" buildLayoutGraph",function(){return q(F)});ne(" runLayout",function(){_(le,ne)}),ne(" updateInputGraph",function(){b(F,le)})})}function _(F,J){J(" makeSpaceForEdgeLabels",function(){P(F)}),J(" removeSelfEdges",function(){D(F)}),J(" acyclic",function(){n.run(F)}),J(" nestingGraph.run",function(){c.run(F)}),J(" rank",function(){s(y.asNonCompoundGraph(F))}),J(" injectEdgeLabelProxies",function(){L(F)}),J(" removeEmptyRanks",function(){u(F)}),J(" nestingGraph.cleanup",function(){c.cleanup(F)}),J(" normalizeRanks",function(){o(F)}),J(" assignRankMinMax",function(){U(F)}),J(" removeEdgeLabelProxies",function(){B(F)}),J(" normalize.run",function(){r.run(F)}),J(" parentDummyChains",function(){l(F)}),J(" addBorderSegments",function(){p(F)}),J(" order",function(){f(F)}),J(" insertSelfEdges",function(){X(F)}),J(" adjustCoordinateSystem",function(){h.adjust(F)}),J(" position",function(){m(F)}),J(" positionSelfEdges",function(){R(F)}),J(" removeBorderNodes",function(){Z(F)}),J(" normalize.undo",function(){r.undo(F)}),J(" fixupEdgeLabelCoords",function(){H(F)}),J(" undoCoordinateSystem",function(){h.undo(F)}),J(" translateGraph",function(){j(F)}),J(" assignNodeIntersects",function(){Q(F)}),J(" reversePoints",function(){te(F)}),J(" acyclic.undo",function(){n.undo(F)})}function b(F,J){e.forEach(F.nodes(),function(ne){var le=F.node(ne),de=J.node(ne);le&&(le.x=de.x,le.y=de.y,J.children(ne).length&&(le.width=de.width,le.height=de.height))}),e.forEach(F.edges(),function(ne){var le=F.edge(ne),de=J.edge(ne);le.points=de.points,e.has(de,"x")&&(le.x=de.x,le.y=de.y)}),F.graph().width=J.graph().width,F.graph().height=J.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},M=["minlen","weight","width","height","labeloffset"],O={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},W=["labelpos"];function q(F){var J=new x({multigraph:!0,compound:!0}),ne=V(F.graph());return J.setGraph(e.merge({},k,$(ne,S),e.pick(ne,E))),e.forEach(F.nodes(),function(le){var de=V(F.node(le));J.setNode(le,e.defaults($(de,C),I)),J.setParent(le,F.parent(le))}),e.forEach(F.edges(),function(le){var de=V(F.edge(le));J.setEdge(le,e.merge({},O,$(de,M),e.pick(de,W)))}),J}function P(F){var J=F.graph();J.ranksep/=2,e.forEach(F.edges(),function(ne){var le=F.edge(ne);le.minlen*=2,le.labelpos.toLowerCase()!=="c"&&(J.rankdir==="TB"||J.rankdir==="BT"?le.width+=le.labeloffset:le.height+=le.labeloffset)})}function L(F){e.forEach(F.edges(),function(J){var ne=F.edge(J);if(ne.width&&ne.height){var le=F.node(J.v),de=F.node(J.w),me={rank:(de.rank-le.rank)/2+le.rank,e:J};y.addDummyNode(F,"edge-proxy",me,"_ep")}})}function U(F){var J=0;e.forEach(F.nodes(),function(ne){var le=F.node(ne);le.borderTop&&(le.minRank=F.node(le.borderTop).rank,le.maxRank=F.node(le.borderBottom).rank,J=e.max(J,le.maxRank))}),F.graph().maxRank=J}function B(F){e.forEach(F.nodes(),function(J){var ne=F.node(J);ne.dummy==="edge-proxy"&&(F.edge(ne.e).labelRank=ne.rank,F.removeNode(J))})}function j(F){var J=Number.POSITIVE_INFINITY,ne=0,le=Number.POSITIVE_INFINITY,de=0,me=F.graph(),ve=me.marginx||0,Pe=me.marginy||0;function Me(Oe){var ye=Oe.x,Se=Oe.y,Ke=Oe.width,xe=Oe.height;J=Math.min(J,ye-Ke/2),ne=Math.max(ne,ye+Ke/2),le=Math.min(le,Se-xe/2),de=Math.max(de,Se+xe/2)}e.forEach(F.nodes(),function(Oe){Me(F.node(Oe))}),e.forEach(F.edges(),function(Oe){var ye=F.edge(Oe);e.has(ye,"x")&&Me(ye)}),J-=ve,le-=Pe,e.forEach(F.nodes(),function(Oe){var ye=F.node(Oe);ye.x-=J,ye.y-=le}),e.forEach(F.edges(),function(Oe){var ye=F.edge(Oe);e.forEach(ye.points,function(Se){Se.x-=J,Se.y-=le}),e.has(ye,"x")&&(ye.x-=J),e.has(ye,"y")&&(ye.y-=le)}),me.width=ne-J+ve,me.height=de-le+Pe}function Q(F){e.forEach(F.edges(),function(J){var ne=F.edge(J),le=F.node(J.v),de=F.node(J.w),me,ve;ne.points?(me=ne.points[0],ve=ne.points[ne.points.length-1]):(ne.points=[],me=de,ve=le),ne.points.unshift(y.intersectRect(le,me)),ne.points.push(y.intersectRect(de,ve))})}function H(F){e.forEach(F.edges(),function(J){var ne=F.edge(J);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 te(F){e.forEach(F.edges(),function(J){var ne=F.edge(J);ne.reversed&&ne.points.reverse()})}function Z(F){e.forEach(F.nodes(),function(J){if(F.children(J).length){var ne=F.node(J),le=F.node(ne.borderTop),de=F.node(ne.borderBottom),me=F.node(e.last(ne.borderLeft)),ve=F.node(e.last(ne.borderRight));ne.width=Math.abs(ve.x-me.x),ne.height=Math.abs(de.y-le.y),ne.x=me.x+ne.width/2,ne.y=le.y+ne.height/2}}),e.forEach(F.nodes(),function(J){F.node(J).dummy==="border"&&F.removeNode(J)})}function D(F){e.forEach(F.edges(),function(J){if(J.v===J.w){var ne=F.node(J.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:J,label:F.edge(J)}),F.removeEdge(J)}})}function X(F){var J=y.buildLayerMatrix(F);e.forEach(J,function(ne){var le=0;e.forEach(ne,function(de,me){var ve=F.node(de);ve.order=me+le,e.forEach(ve.selfEdges,function(Pe){y.addDummyNode(F,"selfedge",{width:Pe.label.width,height:Pe.label.height,rank:ve.rank,order:me+ ++le,e:Pe.e,label:Pe.label},"_se")}),delete ve.selfEdges})})}function R(F){e.forEach(F.nodes(),function(J){var ne=F.node(J);if(ne.dummy==="selfedge"){var le=F.node(ne.e.v),de=le.x+le.width/2,me=le.y,ve=ne.x-de,Pe=le.height/2;F.setEdge(ne.e,ne.label),F.removeNode(J),ne.label.points=[{x:de+2*ve/3,y:me-Pe},{x:de+5*ve/6,y:me-Pe},{x:de+ve,y:me},{x:de+5*ve/6,y:me+Pe},{x:de+2*ve/3,y:me+Pe}],ne.label.x=ne.x,ne.label.y=ne.y}})}function $(F,J){return e.mapValues(e.pick(F,J),Number)}function V(F){var J={};return e.forEach(F,function(ne,le){J[le.toLowerCase()]=ne}),J}return Pg}var Og,Yk;function g4(){if(Yk)return Og;Yk=1;var e=ot(),n=on(),r=Kn().Graph;Og={debugOrdering:s};function s(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,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,m){return u.setEdge(f,m,{style:"invis"}),m})}),u}return Og}var qg,Kk;function v4(){return Kk||(Kk=1,qg="0.8.5"),qg}var Lg,Xk;function y4(){return Xk||(Xk=1,Lg={graphlib:Kn(),layout:m4(),debug:g4(),util:{time:on().time,notime:on().notime},version:v4()}),Lg}var w4=y4();const Qk=cv(w4),ro=240,au=130,Zs=74,Iu=72,Zk=Zs+Iu;function x4(e,n){var s;let r=ro;for(const o of e)r=Math.max(r,((s=n.get(o.id))==null?void 0:s.width)??ro);return r}const GC=420,_4=2;function ha(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function b4(e,n){return((n==null?void 0:n.get(e))??0)>0?GC:0}function S4(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function pa(e,n,r){const s=n.get(e);return{w:((s==null?void 0:s.width)??ro)+b4(e,r),h:Math.max((s==null?void 0:s.height)??au,S4(e,r))}}function k4(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function E4(e,n,r,s,o,l){const u=new Qk.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)),p=new Set(c);for(const S of c){const{w:k,h:E}=pa(S,s,l);u.setNode(S,{width:k,height:E})}for(const S of n)p.has(S.source)&&p.has(S.target)&&u.setEdge(S.source,S.target);Qk.layout(u);const h=new Map;let f=1/0,m=1/0,y=-1/0,x=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const E=s.get(S),C=(E==null?void 0:E.width)??ro,I=(E==null?void 0:E.height)??au,M=pa(S,s,l),O=k.x-M.w/2,W=k.y-M.h/2;h.set(S,{x:O,y:W}),O<f&&(f=O),W<m&&(m=W),O+C>y&&(y=O+C),W+I>x&&(x=W+I)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[S,k]of h)h.set(S,{x:k.x-f,y:k.y-m});const N=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-m:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const E=s.get(S),C=(E==null?void 0:E.width)??ro,I=(E==null?void 0:E.height)??au;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:h,width:N,height:_,pinnedBox:b}}function N4(e,n,r={}){const s=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=ha(S),E=c.get(k);E?E.push(S.id):c.set(k,[S.id])}const h=Array.from(c.keys()).sort().map(S=>({sid:S,...E4(c.get(S),n,s,l,o,u)})),f=x4(e,l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let E=0;for(const C of h)k.length<S&&E>0&&E+C.height>m&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+Zk;return k},x=S=>S.reduce((k,E)=>Math.max(k,E.width),0)+GC;let N=y(r.availableWidth?_4:1);N.length>1&&N.reduce((k,E)=>k+x(E),0)+f*(N.length-1)>(r.availableWidth??0)&&(N=y(1));const _=new Map;let b=0;for(const S of N){const k=x(S);let E=0;for(const{positions:C,height:I,pinnedBox:M}of S){for(const[W,q]of C)_.set(W,{x:q.x+b,y:q.y+E});let O=E+I;M&&M.maxY>O&&M.minX<b+k&&b<M.maxX&&(O=M.maxY),E=O+Zk}b+=k+f}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 C4(e,n,r,s,o){const u=Zs+Iu,c=60,p=x=>pa(x,s,o),h=new Map(e.map(x=>[x.id,ha(x)])),f=[],m=e.map(x=>({id:x.id,pos:r.get(x.id)??n.get(x.id)})).filter(x=>x.pos!=null).sort((x,N)=>x.pos.y-N.pos.y||x.pos.x-N.pos.x||x.id.localeCompare(N.id)),y=[];for(const{id:x,pos:N}of m){const{w:_,h:b}=p(x),S=h.get(x)??"_default";if(r.has(x)){f.push({x:N.x,y:N.y,w:_,h:b,sid:S});continue}let k=N.y;for(let E=0;E<f.length+1;E++){const C=f.find(I=>{const M=I.sid===S?24:c,O=I.sid===S?24:u;return N.x<I.x+I.w+M&&I.x<N.x+_+M&&k<I.y+I.h+O&&I.y<k+b+O});if(!C)break;k=C.y+C.h+(C.sid===S?24:u)}k!==N.y&&(n.set(x,{x:N.x,y:k}),y.push(x)),f.push({x:N.x,y:k,w:_,h:b,sid:S})}return y}function T4(e,n,r,s,o,l){const u=_=>pa(_,s,l),c=_=>r.get(_)??n.get(_),p=new Map;for(const _ of e){if(!c(_.id))continue;const b=ha(_),S=p.get(b);S?S.push(_):p.set(b,[_])}const h=new Set;for(const[_,b]of p)b.every(S=>o.has(S.id)&&!r.has(S.id))&&h.add(_);const f=new Map,m=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),E=ha(_);h.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):m.push({x:b.x,y:b.y,w:S,h:k})}if(f.size===0)return[];const y=Zs+Iu,x=(_,b,S,k)=>m.some(E=>_<E.x+E.w+Zs&&E.x<_+S+Zs&&b<E.y+E.h+y&&E.y<b+k+y),N=[];for(const _ of[...f.keys()].sort()){const b=f.get(_);let S=1/0,k=1/0,E=-1/0,C=-1/0;for(const L of b){const U=c(L.id),{w:B,h:j}=u(L.id);S=Math.min(S,U.x),k=Math.min(k,U.y),E=Math.max(E,U.x+B),C=Math.max(C,U.y+j)}const I=E-S,M=C-k,O=[...new Set(m.map(L=>Math.round(L.x)))].sort((L,U)=>L-U),W=O.length?O:[S],q=[0,...m.map(L=>L.y+L.h+y)].sort((L,U)=>L-U);let P=null;e:for(const L of W)for(const U of q){if(U>=k)break;if(!x(L,U,I,M)){P={x:L,y:U};break e}}if(P){const L=P.x-S,U=P.y-k;for(const B of b){const j=c(B.id);n.set(B.id,{x:j.x+L,y:j.y+U})}N.push(_)}for(const L of b){const U=c(L.id),{w:B,h:j}=u(L.id);m.push({x:U.x,y:U.y,w:B,h:j})}}return N}function R4(e,n,r,s,o,l=!1,u){const h=Zs+Iu+1,f=8,m=1.75,y=200,x=.7,N=.01,_=P=>pa(P,s,u),b=P=>r.get(P)??n.get(P),S=new Map;for(const P of e){if(!b(P.id))continue;const L=ha(P),U=S.get(L);U?U.push(P):S.set(L,[P])}const k=[],E=new Set,C=new Set,I=o.size===0;for(const P of[...S.keys()].sort()){const L=S.get(P);let U=1/0,B=1/0,j=-1/0,Q=-1/0,H=!1;for(const X of L){const R=b(X.id),{w:$,h:V}=_(X.id);U=Math.min(U,R.x),B=Math.min(B,R.y),j=Math.max(j,R.x+$),Q=Math.max(Q,R.y+V),r.has(X.id)&&(H=!0)}const te=j-U,Z=Q-B;C.add(P);const D=o.get(P);D&&(te>D.w+f||Z>D.h+f)&&E.add(P),o.set(P,{w:te,h:Z}),k.push({sid:P,members:L.map(X=>X.id),x:U,y:B,w:te,h:Z,anchored:H,mass:1})}for(const P of[...o.keys()])C.has(P)||o.delete(P);if(l||I)return[];let M=!1;for(let P=0;P<k.length&&!M;P++)for(let L=P+1;L<k.length;L++){const U=k[P],B=k[L];if(!(U.anchored&&B.anchored)&&Math.abs(U.x+U.w/2-(B.x+B.w/2))<(U.w+B.w)/2+61&&Math.abs(U.y+U.h/2-(B.y+B.h/2))<(U.h+B.h)/2+h){M=!0;break}}if(E.size===0&&!M)return[];if(E.size>0)for(const P of k)E.has(P.sid)&&(P.mass=8);else for(const P of k)P.mass=Math.max(1,P.w*P.h/(ro*au));const O=new Map(k.map(P=>[P.sid,P.x])),W=new Map(k.map(P=>[P.sid,P.y]));for(let P=0;P<y;P++){const L=new Map,U=new Map;let B=0;for(let j=0;j<k.length;j++)for(let Q=j+1;Q<k.length;Q++){const H=k[j],te=k[Q];if(H.anchored&&te.anchored)continue;const Z=H.x+H.w/2,D=H.y+H.h/2,X=te.x+te.w/2,R=te.y+te.h/2,$=(H.w+te.w)/2+61-Math.abs(Z-X),V=(H.h+te.h)/2+h-Math.abs(D-R);if($<=0||V<=0)continue;const F=(De,Qe)=>!De.anchored&&!(Qe<0&&De.x<=0),J=(De,Qe)=>!De.anchored&&!(Qe<0&&De.y<=0),ne=(De,Qe,at)=>{const It=De===Qe,it=It?H.sid<te.sid?-1:1:Math.sign(De-Qe);return at(H,it)||at(te,-it)?it:It&&(at(H,-it)||at(te,it))?-it:0},le=ne(Z,X,F),de=ne(D,R,J),me=le!==0,ve=de!==0;if(!me&&!ve)continue;const Pe=me&&(!ve||$*m<V),[Me,Oe,ye,Se]=Pe?[le,$,L,F]:[de,V,U,J],Ke=Se(H,Me),xe=Se(te,-Me),ge=H.mass,Fe=te.mass,pt=Ke?xe?Fe/(ge+Fe):1:0,mt=xe?Ke?ge/(ge+Fe):1:0,Ze=Oe*x;ye.set(H.sid,(ye.get(H.sid)??0)+Me*Ze*pt),ye.set(te.sid,(ye.get(te.sid)??0)-Me*Ze*mt),B+=Ze}for(const j of k)j.anchored||(j.x=Math.max(0,j.x+(L.get(j.sid)??0)),j.y=Math.max(0,j.y+(U.get(j.sid)??0)));if(B<N)break}const q=[];for(const P of k){const L=P.x-O.get(P.sid),U=P.y-W.get(P.sid);if(!(Math.abs(L)<1&&Math.abs(U)<1)){for(const B of P.members){if(r.has(B))continue;const j=n.get(B);j&&n.set(B,{x:j.x+L,y:j.y+U})}q.push(P.sid)}}return q}const j4=600;function av(e,n){return!(e.exitAt!=null&&n-e.exitAt>j4||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function A4(e,n){const r=new Set;for(const s of e.agents.values())av(s,n)&&r.add(s.id);return r}function I4(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 M4(e,n,r=0){if(!e)return!1;for(const s of n)if(I4(e,s,r))return!0;return!1}const YC="sessionGroup";function P4(e,n){var s;if(e.type===YC)return"transparent";const r=(s=e.data)==null?void 0:s.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const O4="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function q4(e){if(e.checkDisabled)return O4;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 L4(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 Zo(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function $4(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const D4={agent:oO,sessionGroup:yO},F4=420,Ul=18,z4=9e4,B4=200,U4=5*6e4,H4=6,W4=2*6e4,Kv="agent-dag.layout",Xv="agent-dag.viewport",KC="agent-dag.summariesDismissed",XC="agent-dag.sessionListOpen",QC="agent-dag.detailOpen",ZC="agent-dag.usagePanelOpen",Jk="agent-dag.accountsPanelOpen",eE="agent-dag.versionNoticeDismissed",V4=15*6e4,tE={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:"};function G4(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`}const nE="agent-dag.autoRestart",rE="agent-dag.bundleReloadedFor";function Y4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(XC)==="1"}catch{return!1}}function K4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(XC,e?"1":"0")}catch{}}function X4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(QC)==="1"}catch{return!1}}function Q4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(QC,e?"1":"0")}catch{}}function Z4(){const e=GN(ZC);return e===null?!0:e==="1"}function J4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ZC,e?"1":"0")}catch{}}function e5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(KC);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 iE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(KC,JSON.stringify(r))}catch{}}function t5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Kv);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 $g(e,n){if(!(typeof window>"u"))try{const r={};for(const[s,o]of e)r[s]=o;for(const[s,o]of n)r[s]=o;window.localStorage.setItem(Kv,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function n5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Xv);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 r5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Xv,JSON.stringify(e))}catch{}}function sE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Kv)}catch{}try{window.localStorage.removeItem(Xv)}catch{}}}function i5(e,n){const r=e.agents.get(n);if(!r)return;const s=[];for(const f of e.agents.values())f.sessionId===n&&s.push(f);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:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.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),p=document.createElement("a"),h=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");p.href=c,p.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const lv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},uv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},s5={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 JC(e){return e.startsWith("mcp__")?"mcp":s5[e]??"other"}function eT(e,n){var s,o,l;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(s=e.cwd)!=null&&s.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 o5(e,n){if(!n)return null;const r=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=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 a5(e,n,r,s,o,l,u,c,p,h,f,m,y,x,N,_,b,S){const k=[],E=[],C=new Set;if(l)for(const L of e.agents.values())eT(L,l)&&C.add(L.id);for(const L of e.agents.values()){if(!b.has(L.id))continue;const U=l?!C.has(L.id):!1,B=L.exitAt!=null,j=_!=null&&!_.has(L.id),Q=[U?"rf-dim":"",B?"rf-exiting":"",j?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,H=u.get(L.id);if(k.push({id:L.id,type:"agent",position:{x:0,y:0},data:{...L,now:n,dim:U,onOpenContext:S},className:Q,...H?{width:H.width,height:H.height}:null}),L.parentId&&b.has(L.parentId)){const te=Rv(L.sessionId),Z=L.state==="active"?`hsl(${te} 80% 72%)`:`hsl(${te} 50% 55%)`,D=l&&!C.has(L.id)&&!C.has(L.parentId),X=B,R=N.size>0&&(N.has(L.id)||N.has(L.parentId)),$=_!=null&&!_.has(L.id)&&!_.has(L.parentId),V=L.state==="active"?2:1.5,F=R?V+1.5:V,J=D||X?.2:$?.12:1,ne=[X?"rf-edge-exiting":"",R?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;E.push({id:`e:${L.parentId}->${L.id}`,source:L.parentId,target:L.id,animated:(L.state==="active"||R)&&!D&&!X,type:"smoothstep",style:{stroke:Z,strokeWidth:F,opacity:J,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:ne})}}const I=new Map;for(const L of e.agents.values())L.tools.length>0&&I.set(L.id,Math.min(4,L.tools.length));const M=`${y}#lanes:${k4(I)}`,O=k.filter(L=>!o.has(L.id)&&!m.has(L.id));if(O.length>0||M!==x.current){if(O.length>0){const L=N4(k,E,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:s,lanes:I});for(const U of L)m.has(U.id)||m.set(U.id,U.position);T4(k,m,o,u,new Set(O.map(U=>U.id)),I)}C4(k,m,o,u,I),x.current=M}const W=R4(k,m,o,u,c,!h||f,I);W.length>0&&p(W),wd(m,e.agents),wd(o,e.agents),wd(u,W3(e.agents.values()));const q=[];let P=!1;for(const L of k){let U=o.get(L.id)??m.get(L.id);U||(U={x:0,y:0},m.set(L.id,U),P=!0),q.push({...L,position:U})}return P&&(x.current=""),{nodes:q,edges:E}}function l5(){return g.jsx(Cv,{children:g.jsx(u5,{})})}function u5(){var Ii,yo,Mi,Pi;const e=wa(),n=A.useRef(tv()),[,r]=A.useState(0),s=A.useCallback(()=>r(K=>K+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((K,Y)=>{l(oe=>{if(!Y)return new Set([K]);const ue=new Set(oe);return ue.has(K)?ue.delete(K):ue.add(K),ue}),c(oe=>Y&&oe===K?oe:K)},[]),m=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[N,_]=A.useState(null),b=A.useCallback(K=>_(K),[]),[S,k]=A.useState(!1),E=A.useRef(e5()),[C,I]=A.useState(Y4);A.useEffect(()=>{K4(C)},[C]);const[M,O]=A.useState(X4);A.useEffect(()=>{Q4(M)},[M]);const[W,q]=A.useState(Z4);A.useEffect(()=>{J4(W)},[W]);const[P,L]=A.useState(()=>{try{const K=window.localStorage.getItem(Jk);return K===null?!0:K==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(Jk,P?"1":"0")}catch{}},[P]);const[U,B]=A.useState(null),[j,Q]=A.useState(!1),[H,te]=A.useState(0),[Z,D]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(K=>K.ok?K.json():null).then(K=>{K!=null&&K.ok&&(B(K.enabled===!0),te((K.foreign??[]).filter(Y=>Y.worksHere).length),D(typeof K.parked=="number"?K.parked:0))}).catch(()=>{})},[]);const X=A.useCallback(async()=>{Q(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!U})})).json().catch(()=>null);Y!=null&&Y.ok&&B(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(te((oe.foreign??[]).filter(ue=>ue.worksHere).length),D(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[U]),[R,$]=A.useState(!1),[V,F]=A.useState(null),[J,ne]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(eE)??""}catch{return""}}),[le,de]=A.useState(!1),me=A.useRef(0),[ve,Pe]=A.useState(!1),Me=A.useCallback((K=!1)=>{K&&(me.current=Date.now(),Pe(!0)),fetch(K?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&F(Y)}).catch(()=>{}).finally(()=>{K&&Pe(!1)})},[]),Oe=A.useCallback(()=>{Me(Date.now()-me.current>=V4)},[Me]);A.useEffect(()=>{Me();const K=window.setInterval(Oe,5*6e4),Y=()=>{document.visibilityState==="visible"&&Oe()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(K),document.removeEventListener("visibilitychange",Y)}},[Me,Oe]),A.useEffect(()=>{R&&Me()},[R,Me]);const ye=(V==null?void 0:V.notice)??null,Se=ye?`${ye.kind}:${ye.to}`:"",Ke=ye!=null&&J!==Se,xe=A.useCallback(()=>{if(!ye)return;const K=J===Se?"":Se;ne(K);try{window.localStorage.setItem(eE,K)}catch{}},[ye,Se,J]),ge=((Ii=V==null?void 0:V.upgrade)==null?void 0:Ii.state)??"idle",Fe=O3(V==null?void 0:V.upgrade),pt=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}Me()},[Me]);A.useEffect(()=>{if(ge!=="running")return;const K=window.setInterval(Me,3e3);return()=>window.clearInterval(K)},[ge,Me]);const mt=A.useCallback(async()=>{var oe;const K=V==null?void 0:V.command;if(!K)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(K).then(()=>!0))??Promise.resolve(!1),new Promise(ue=>window.setTimeout(()=>ue(!1),500))])}catch{Y=!1}if(!Y)try{const ue=document.createElement("textarea");ue.value=K,ue.setAttribute("readonly",""),ue.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(ue),ue.select(),Y=document.execCommand("copy"),ue.remove()}catch{Y=!1}Y&&(de(!0),window.setTimeout(()=>de(!1),1600))},[V==null?void 0:V.command]),Ze=A.useCallback(()=>{I(K=>(K||L(!1),!K))},[]),De=A.useCallback(()=>{L(K=>(K||I(!1),!K))},[]),[Qe,at]=A.useState(!1),[It,it]=A.useState(0),gt=A.useRef(null),[Kt,Mt]=A.useState(!1),Ye=A.useRef(null),[Nt,dt]=A.useState(0),lt=A.useRef(K3()),[fn,Ut]=A.useState(!1),Ct=A.useCallback(()=>{const K=lt.current,Y=K.setPaused(!K.paused);for(const oe of Y)n.current=dx(n.current,oe);Ut(K.paused)},[]),[Je,hr]=A.useState(Date.now()),[Ht,hn]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(nE)!=="0"}catch{return!0}}),Tn=A.useCallback(()=>{hn(K=>{const Y=!K;try{window.localStorage.setItem(nE,Y?"1":"0")}catch{}return Y})},[]),[Tt,pr]=A.useState(!1),[as,ls]=A.useState("restart"),[vi,Lr]=A.useState(null),Rn=A.useRef(!1),Zn=A.useRef(null),$r=A.useRef(0),pn=A.useCallback(async K=>{if(Rn.current)return;const Y=(K==null?void 0:K.upgrade)===!0;Rn.current=!0,Zn.current=Fe;const oe=++$r.current;ls(Y?"npx":"restart"),pr(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if($r.current===oe&&Rn.current){Rn.current=!1,pr(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Fe]),us=A.useRef(null);A.useEffect(()=>{let K=!1;for(const oe of n.current.agents.values())if(oe.state==="active"){K=!0;break}const Y=L3({enabled:Ht,kind:ye==null?void 0:ye.kind,canRestart:(V==null?void 0:V.canRestart)===!0,busy:K,idleSince:us.current,now:Je});us.current=Y.idleSince,Y.restart&&pn()},[Ht,ye==null?void 0:ye.kind,V==null?void 0:V.canRestart,Je,pn]),A.useEffect(()=>{const K=V==null?void 0:V.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(rE)}catch{return}const ue=P3({bundle:"1.33.116",running:K,pending:Y,lastTried:oe});if(ue==="reload"){try{window.sessionStorage.setItem(rE,K??"")}catch{return}window.location.reload();return}if(ue!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Rn.current=!1,pr(!1),Lr(K??null);const we=window.setTimeout(()=>Lr(null),6e3);return()=>window.clearTimeout(we)},[V==null?void 0:V.running]),A.useEffect(()=>{if(Tt&&q3({asked:Zn.current,reported:Fe})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Rn.current=!1,pr(!1)}},[Tt,Fe]);const jn=A.useRef(t5()).current;A.useRef(!1);const yt=A.useRef(new Map(jn.positions.filter(([K])=>jn.pins.includes(K)))),An=A.useRef(null),Jn=A.useState(()=>n5())[0],[In,cs]=A.useState(""),[yi,Mn]=A.useState(()=>new Set),[er,wi]=A.useState(()=>GN("agent-dag.theme")??"dark"),[ds,fs]=A.useState(!1),xi=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=er;try{window.localStorage.setItem("agent-dag.theme",er)}catch{}},[er]),A.useEffect(()=>{if(!Jn)return;const K=window.setTimeout(()=>{try{e.setViewport(Jn,{duration:0})}catch{}},60);return()=>window.clearTimeout(K)},[e,Jn]);const _i=A.useRef(!0);A.useEffect(()=>{const K=new EventSource("/events"),Y=Y3(s,{now:()=>Date.now(),setTimeout:(oe,ue)=>window.setTimeout(oe,ue),clearTimeout:oe=>window.clearTimeout(oe)});return K.addEventListener("open",()=>{$(!0),fs(!0)}),K.addEventListener("error",()=>$(!1)),K.addEventListener("replay-end",()=>{_i.current=!1,Y.flush()}),K.addEventListener("hook",oe=>{try{const ue=JSON.parse(oe.data);if(!lt.current.accept(ue))return;n.current=dx(n.current,ue),ue.replay===!0||_i.current||Date.now()-ue.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{K.close(),Y.cancel()}},[s]),A.useEffect(()=>{const K=setInterval(()=>{const Y=Date.now();hr(Y);let oe=FP(n.current,Y,z4);$P(n.current,Y,B4,U4)&&(oe=!0),DP(n.current,Y,H4,W4)&&(oe=!0),oe&&s()},250);return()=>clearInterval(K)},[s]);const Dr=A.useRef(null),Pn=A.useRef(0),co=420,Be=A.useCallback((K=500)=>{try{const Ee=document.querySelector(".canvas-wrap"),Re=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Ee||Re.length===0)return;const qe=Ee.getBoundingClientRect(),Ue=e.getViewport();if(!Number.isFinite(Ue.zoom)||Ue.zoom<=0)return;const Ge=wt=>(wt-qe.left-Ue.x)/Ue.zoom,tt=wt=>(wt-qe.top-Ue.y)/Ue.zoom,gn=Re.map(wt=>wt.getBoundingClientRect()),Oi=Math.min(...gn.map(wt=>Ge(wt.left))),wo=Math.max(...gn.map(wt=>Ge(wt.right))),xr=Math.min(...gn.map(wt=>tt(wt.top))),xo=Math.max(...gn.map(wt=>tt(wt.bottom))),Ma=wo-Oi,ws=xo-xr;if(!(Ma>0&&ws>0))return;const $n=Math.max(.2,Math.min(1,(qe.width-160)/(Ma+co)*.86,(qe.height-160)/ws*.86));e.setViewport({x:80-Oi*$n,y:Math.max(80,(qe.height-ws*$n)/2)-xr*$n,zoom:$n},{duration:K}),Pn.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Oi*$n,y:Math.max(80,(qe.height-ws*$n)/2)-xr*$n,zoom:$n},_o=e.getViewport();(Math.abs(_o.zoom-$n)>.01||Math.abs(_o.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},K+60)}catch{}},[e]),bi=A.useRef(""),mr=A.useRef(null),Si=A.useRef(0),On=A.useCallback(()=>{Si.current=Date.now()},[]),Fr="agent-dag.autoFitDisabled",mn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fr)==="1"}catch{return!1}})()),[gr,Wt]=A.useState(mn.current),zr=A.useCallback(()=>{if(!mn.current){mn.current=!0,Wt(!0);try{window.localStorage.setItem(Fr,"1")}catch{}}},[]),an=A.useCallback(()=>{mn.current=!1,Wt(!1);try{window.localStorage.removeItem(Fr)}catch{}Be(400)},[e,Be]);A.useEffect(()=>{const K=setInterval(()=>{if(mn.current||Date.now()-Si.current<800)return;const Y=n.current,oe=Date.now(),ue=[];for(const Ge of Y.agents.values())av(Ge,oe)&&ue.push({id:Ge.id});if(ue.length===0)return;const we=e.getViewport(),Ee=window.innerWidth-360,Re=window.innerHeight-52;let qe=!1,Ue=!1;for(const{id:Ge}of ue){const tt=Br.current.get(Ge),gn=yt.current.get(Ge)??Xt.current.get(Ge);if(!tt||!gn)continue;Ue=!0;const Oi=gn.x*we.zoom+we.x,wo=gn.y*we.zoom+we.y,xr=(gn.x+tt.width)*we.zoom+we.x,xo=(gn.y+tt.height)*we.zoom+we.y;if(xr>0&&Oi<Ee&&xo>0&&wo<Re){qe=!0;break}}Ue&&!qe&&Be(600)},1500);return()=>clearInterval(K)},[e]);const fo=A.useRef(!1),Br=A.useRef(new Map),Na=A.useRef(0),hs=A.useCallback(K=>{const Y=Br.current;let oe=!1;for(const ue of K.nodeInternals.values()){const we=ue.width,Ee=ue.height;if(we==null||Ee==null)continue;const Re=Y.get(ue.id);Re?(Math.abs(Re.height-Ee)>4||Math.abs(Re.width-we)>4)&&(Y.set(ue.id,{width:we,height:Ee}),oe=!0):(Y.set(ue.id,{width:we,height:Ee}),oe=!0)}return oe&&(Na.current+=1),Na.current},[]),ki=Xe(hs),[Ur,ps]=A.useState(0);A.useEffect(()=>{let K=0;const Y=()=>{const ue=Br.current;let we=!1;for(const Ee of document.querySelectorAll(".react-flow__node[data-id]")){const Re=Ee.getAttribute("data-id");if(!Re)continue;const qe=Ee.offsetWidth,Ue=Ee.offsetHeight;if(!qe||!Ue)continue;const Ge=ue.get(Re);(!Ge||Math.abs(Ge.width-qe)>4||Math.abs(Ge.height-Ue)>4)&&(ue.set(Re,{width:qe,height:Ue}),we=!0)}we&&ps(Ee=>Ee+1)};if(fo.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):K=requestAnimationFrame(Y),()=>{cancelAnimationFrame(K),window.clearTimeout(oe)}});const Xt=A.useRef(new Map(jn.positions)),ho=A.useRef(""),tr=A.useMemo(()=>{const K=[];for(const Y of n.current.agents.values())av(Y,Je)&&K.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return K.sort(),`${K.join("|")}#sv${ki}.${Ur}`},[n.current,n.current.lastSeq,Je,ki,Ur]),Hr=A.useRef(null);A.useEffect(()=>(Hr.current!=null&&window.clearTimeout(Hr.current),Hr.current=window.setTimeout(()=>{$g(Xt.current,yt.current)},1500),()=>{Hr.current!=null&&window.clearTimeout(Hr.current)}),[tr]),A.useEffect(()=>{if(bi.current===tr)return;const K=bi.current;if(bi.current=tr,!K||mn.current)return;Date.now()-Pn.current>1200&&Be(400),Dr.current&&window.clearTimeout(Dr.current),Dr.current=window.setTimeout(()=>{mn.current||Be(500)},280)},[tr,e,Be]);const Ei=A.useMemo(()=>{if(o.size===0)return null;const K=new Set;for(const Y of o){const oe=o5(n.current,Y);if(oe)for(const ue of oe)K.add(ue)}return K.size>0?K:null},[n.current,n.current.lastSeq,o]),vr=A.useMemo(()=>A4(n.current,Je),[n.current,n.current.lastSeq,Je]),Ca=A.useRef(null),[Wr,We]=A.useState({w:0,h:0});A.useEffect(()=>{const K=Ca.current;if(!K||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var we;const ue=(we=oe[0])==null?void 0:we.contentRect;ue&&We(Ee=>Math.abs(Ee.w-ue.width)>40||Math.abs(Ee.h-ue.height)>40?{w:ue.width,h:ue.height}:Ee)});return Y.observe(K),We({w:K.clientWidth,h:K.clientHeight}),()=>Y.disconnect()},[]);const Ta=A.useRef(new Map),[po,mo]=A.useState(!1);A.useEffect(()=>{const K=window.setTimeout(()=>mo(!0),2500);return()=>window.clearTimeout(K)},[]);const[Ra,ms]=A.useState(!1),qn=A.useRef(null),[Ni,Ci]=A.useState(!1),nr=A.useCallback(()=>{qn.current&&(window.clearTimeout(qn.current),qn.current=null),ms(!1)},[]),rr=A.useCallback(K=>{K.length!==0&&queueMicrotask(()=>{ms(!0),qn.current&&window.clearTimeout(qn.current),qn.current=window.setTimeout(()=>ms(!1),F4+80)})},[]);A.useEffect(()=>()=>{qn.current&&window.clearTimeout(qn.current)},[]);const Ln=Wr.w>0?Wr.w*.92:0,Vr=Wr.h>0?Wr.h:0,{nodes:Vt,edges:ir}=A.useMemo(()=>a5(n.current,Je,Ln,Vr,yt.current,In,Br.current,Ta.current,rr,po,Ni,Xt.current,tr,ho,o,Ei,vr,b),[n.current,n.current.lastSeq,Je,Ln,Vr,po,Ni,In,tr,o,Ei,vr,b,It]),ja=A.useMemo(()=>{const K=new Map;for(const oe of Vt){const ue=oe.data;if(!(ue!=null&&ue.sessionId)||ue.exitAt!=null)continue;const we=oe.width,Ee=oe.height;if(we==null||Ee==null)continue;const Re=oe.position.x,qe=oe.position.y,Ue=Re+we,Ge=qe+Ee,tt=K.get(ue.sessionId);tt?(tt.minX=Math.min(tt.minX,Re),tt.minY=Math.min(tt.minY,qe),tt.maxX=Math.max(tt.maxX,Ue),tt.maxY=Math.max(tt.maxY,Ge)):K.set(ue.sessionId,{minX:Re,minY:qe,maxX:Ue,maxY:Ge})}const Y=[];for(const[oe,ue]of K){const we=ue.maxX-ue.minX+Ul*2,Ee=ue.maxY-ue.minY+Ul*2;Y.push({id:`group:${oe}`,type:YC,position:{x:ue.minX-Ul,y:ue.minY-Ul},data:{sessionId:oe,w:we,h:Ee},width:we,height:Ee,style:{width:we,height:Ee},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Vt,Je]),Aa=A.useMemo(()=>{const K=[...ja,...Vt],Y=Ye.current;return!Y||Y.size===0?K:K.map(oe=>{const ue=Y.get(oe.id);return ue?{...oe,position:ue}:oe})},[ja,Vt,Nt]),Ti=A.useMemo(()=>{if(!In)return null;const K=new Set;for(const Y of n.current.agents.values())eT(Y,In)&&K.add(Y.id);return K},[n.current,n.current.lastSeq,In]),gs=A.useMemo(()=>{const K=new Set;for(const Y of n.current.agents.values())for(const oe of Y.tools)K.add(JC(oe.name));return Object.keys(lv).filter(Y=>K.has(Y))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(gs.length<=1){Mt(!1);return}let K=0;const Y=()=>{const oe=gt.current;if(oe&&!document.hidden){const ue=oe.getBoundingClientRect(),we=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Re=>Re.getBoundingClientRect()),Ee=M4(ue,we,8);Mt(Re=>Re===Ee?Re:Ee)}K=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(K)},[gs.length]);const Gr=A.useMemo(()=>{const K=new Map;for(const oe of n.current.agents.values())for(const ue of oe.tools){if(!ue.name.startsWith("mcp__"))continue;const we=ue.name.slice(5),Ee=we.indexOf("__"),Re=Ee>0?we.slice(0,Ee):we;K.set(Re,(K.get(Re)??0)+1)}const Y=[];for(const[oe,ue]of K){let we=5381;for(let Ee=0;Ee<oe.length;Ee++)we=(we<<5)+we^oe.charCodeAt(Ee);Y.push({server:oe,count:ue,hue:Math.abs(we)%360})}return Y.sort((oe,ue)=>ue.count-oe.count),Y},[n.current,n.current.lastSeq]),vs=A.useCallback(K=>{Mn(Y=>{const oe=new Set(Y);return oe.has(K)?oe.delete(K):oe.add(K),oe})},[]),Pt=u?n.current.agents.get(u):null,go=p?Array.from(n.current.agents.values()).flatMap(K=>K.tools).find(K=>K.id===p)??null:null,Yr=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=tv(),yt.current.clear(),Br.current.clear(),Xt.current.clear(),ho.current="",sE(),m(),s()},[s,m]),Kr=A.useRef(S);Kr.current=S;const yr=A.useRef(!1);yr.current=go!=null||Qe||N!=null||y!=null;const wr=A.useCallback(K=>{const Y=H3(K,{confirmOpen:Kr.current,modalOpen:yr.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),Yr())},[Yr]),vo=A.useCallback(()=>{yt.current.clear(),Xt.current.clear(),ho.current="",sE(),s(),window.setTimeout(()=>Be(500),80)},[s,e,Be]),Ia=A.useCallback(()=>Be(500),[Be]),ys=A.useRef(Vt);ys.current=Vt;const Ri=A.useRef(u);Ri.current=u;const ji=A.useCallback(K=>{const Y=ys.current;if(Y.length===0)return;const oe=Y.slice().sort((qe,Ue)=>qe.position.y-Ue.position.y||qe.position.x-Ue.position.x),ue=Ri.current,we=ue?oe.findIndex(qe=>qe.id===ue):-1;let Ee;we===-1?Ee=K===1?0:oe.length-1:Ee=(we+K+oe.length)%oe.length;const Re=oe[Ee];Re&&(f(Re.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[Re]})}catch{}Pn.current=Date.now()},30))},[f,e]);A.useEffect(()=>{const K=Y=>{var we,Ee;const oe=Y.target,ue={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(we=oe==null?void 0:oe.getAttribute)==null?void 0:we.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const Re=QP({overlayOpen:rv.depth()>0,typing:VN(ue)});Re==="dismiss"?rv.dismissTop():Re==="blur"?oe==null||oe.blur():m();return}if(!B3(ue)&&!$3(Y)){if(Y.key==="/"){Y.preventDefault(),(Ee=xi.current)==null||Ee.focus();return}Y.key===" "&&(Y.preventDefault(),Ct()),(Y.key==="c"||Y.key==="C")&&wr("shortcut"),(Y.key==="r"||Y.key==="R")&&vo(),(Y.key==="f"||Y.key==="F")&&Ia(),(Y.key==="l"||Y.key==="L")&&Ze(),(Y.key==="h"||Y.key==="H")&&at(Re=>!Re),(Y.key==="u"||Y.key==="U")&&q(Re=>!Re),(Y.key==="a"||Y.key==="A")&&De(),(Y.key==="j"||Y.key==="J")&&ji(1),(Y.key==="k"||Y.key==="K")&&ji(-1),(Y.key==="t"||Y.key==="T")&&wi(Re=>Re==="dark"?"light":"dark")}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[wr,vo,Ia,m,ji,Ct]);const Ai=n.current.agents.size,sr=new Set(Array.from(n.current.agents.values()).map(K=>K.sessionId)).size,$t=A.useMemo(()=>{let K=0,Y=0,oe=0,ue=0,we=0,Ee=0,Re=0,qe=0,Ue=0;for(const Ge of n.current.agents.values()){K+=Ge.usage.inputTokens,Y+=Ge.usage.outputTokens,oe+=Ge.usage.cacheReadTokens,ue+=Ge.usage.cacheCreateTokens;const tt=sn(Ge.usage,Ge.model);we+=tt.total,Ee+=tt.input,Re+=tt.output,qe+=tt.cacheRead,Ue+=tt.cacheWrite}return{inT:K,outT:Y,cacheR:oe,cacheC:ue,sum:K+Y,cost:{total:we,input:Ee,output:Re,cacheRead:qe,cacheWrite:Ue}}},[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"}),"agents-deck",ye?g.jsxs("button",{type:"button",className:"v stale",onClick:xe,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 K={running:(V==null?void 0:V.running)??"1.33.116",latest:V==null?void 0:V.latest,latestPending:V==null?void 0:V.latestPending,checkedAgo:V!=null&&V.checkedAt?G4(Je-V.checkedAt):null,checkDisabled:V==null?void 0:V.checkDisabled,checking:ve};return g.jsxs("button",{type:"button",className:ve?"v checking":"v",onClick:()=>Me(!0),"aria-busy":ve||void 0,"aria-label":L4(K),title:q4(K),children:["v",K.running]})})()]}),Pt&&(()=>{const K=sn(Pt.usage,Pt.model),Y=Math.max(0,((Pt.endedAt??Je)-Pt.startedAt)/1e3),oe=Pt.state==="active"?su(K.total,Y):null,ue=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Pt.label}`,onClick:()=>{try{const we=Vt.find(Ee=>Ee.id===Pt.id);we&&e.fitView({padding:.35,duration:500,nodes:[we]}),Pn.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${Pt.state}`,children:Pt.state==="active"?"live":Pt.state}),g.jsx("span",{className:"selected-label",children:Pt.label}),K.total>0&&g.jsxs("span",{className:"selected-cost",children:[ze(K.total),oe?g.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),ue>0&&g.jsxs("span",{className:"selected-extra",children:["+",ue]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:we=>{we.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:xi,type:"text",placeholder:"Search agents, cwd, tools…",value:In,onChange:K=>cs(K.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),In?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>cs(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${R?"live":"dead"}`,title:R?"Receiving events":"SSE disconnected",children:R?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:sr}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Ai}),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"})]}),$t.sum>0&&g.jsxs("span",{className:"stat",title:`in:${$t.inT.toLocaleString()} out:${$t.outT.toLocaleString()} cache-r:${$t.cacheR.toLocaleString()} cache-c:${$t.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:$4($t.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),Gr.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
59
|
+
burn: ${y}`:"");return g.jsxs("span",{className:"cost-meta",title:x,children:[g.jsx("b",{children:ze(f.total)}),y&&g.jsx("span",{className:"cost-rate",children:y})]})})()]}),g.jsx(no,{type:"source",position:Te.Right,style:{background:"transparent",border:"none"}})]})}function aO({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return g.jsx("span",{className:`state-pill state-${e}`,children:n})}function lO(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function uO({tools:e,now:n}){const l=new Array(24).fill(0);let u=0;for(const y of e){const x=n-y.startedAt;if(x<0||x>=6e4)continue;const N=23-Math.floor(x/2500);N>=0&&N<24&&(l[N]+=1,u+=1)}const c=Math.max(1,...l),p=132,h=14,f=p/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:p,height:h,viewBox:`0 0 ${p} ${h}`,"aria-hidden":!0,children:l.map((y,x)=>{const N=y===0?1.5:Math.max(1.5,y/c*h),_=x===23&&y>0,S=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return g.jsx("rect",{x:x*f+.4,y:h-N,width:Math.max(.5,f-1),height:N,rx:.8,className:S},x)})}),g.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function xa(e){const n=e.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const o=n[1][0].toUpperCase()+n[1].slice(1).toLowerCase(),l=n[2].replace(/[-_]/g,".");return`${o} ${l}`}const r=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(r)return`GPT-${r[1].replace(/[-_]/g,".")} Codex`;const s=e.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return s?`GPT-${s[1].replace(/[-_]/g,".")}`:e}function px(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function cO(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 dO({tool:e,onClose:n}){io(n);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return g.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:g.jsxs("div",{className:"modal",onClick:s=>s.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 ${r}`}),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:cO(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:px(e.input??e.inputPreview)})]}),g.jsxs("div",{className:"modal-section",children:[g.jsxs("h4",{children:["Response ",r==="err"&&g.jsx("span",{className:"err-tag",children:"error"})]}),g.jsx("pre",{children:e.endedAt==null?"(waiting…)":px(e.response??e.errorPreview)})]})]})]})})}const $l=18,mx=26,fO=12;function hO(e){return pO(e.nodeInternals.values())}function pO(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,p=u+o.width,h=c+o.height,f=n.get(l.sessionId);f?(f.minX=Math.min(f.minX,u),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,p),f.maxY=Math.max(f.maxY,h),l.kind==="root"&&(f.label=gx(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:gx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const s=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${mO(o)}`:l.label;s.push({sessionId:o,label:c,x:l.minX-$l,y:l.minY-$l-mx,w:l.maxX-l.minX+$l*2,h:l.maxY-l.minY+$l*2+mx})}return s}function mO(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function gx(e){if(e.kind==="root")return e.label}function gO(){const{x:e,y:n,zoom:r}=EN(),s=wa(),o=Xe(hO,vO);if(o.length<=1)return null;const l=u=>{try{const c=s.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;s.fitView({padding:.3,duration:500,nodes:c})}catch{}};return g.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=Rv(u.sessionId),p={position:"absolute",left:u.x*r+e,top:u.y*r+n,width:u.w*r,height:u.h*r,borderColor:`hsl(${c} 65% 55% / 0.32)`,background:`hsl(${c} 70% 50% / 0.04)`},h={position:"absolute",left:u.x*r+e+16*r,top:(u.y-fO)*r+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top"};return g.jsxs(ae.Fragment,{children:[g.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),g.jsx("button",{type:"button",className:"cluster-label",style:h,title:`Fit view to ${u.label} · drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:u.label})]},u.sessionId)})})}function vO(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const s=e[r],o=n[r];if(s.sessionId!==o.sessionId||s.label!==o.label||s.x!==o.x||s.y!==o.y||s.w!==o.w||s.h!==o.h)return!1}return!0}function yO({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 $N=600,wO=4,xO=36,iv=16,_O=60,bO=6,vx=220,yx=96,SO=28,kO={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 EO(e){return e.startsWith("mcp__")?"mcp":kO[e]??"other"}const NO={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 wx(e){return e.startsWith("mcp__")?"🔌":NO[e]??"✨"}const CO={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 DN(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 DN(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 s=n.match(/^([^\s|;&<>(]+)/);if(!s)return null;let o=s[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function TO(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 s=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(s>=0&&s+1<r.length)return r[s+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const RO=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),jO=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function AO(e,n){return jO.has(e)||e.startsWith("mcp__")?Math.max(yx,34+n.length*7.5):yx}function IO(e,n){if(!RO.has(e))return null;const r=TO(n);if(!r)return null;const s=DN(r);return s?{emoji:CO[s]??"⚙️",label:s,category:"shell",detail:r}:null}const MO=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),xx={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:"🗄️"},_x={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 PO(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),s=r.lastIndexOf("/");return s>=0?r.slice(s+1):r}function OO(e){const n=e.toLowerCase();if(_x[n])return _x[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 s=n.slice(r+1);if(xx[s])return xx[s]}return"📄"}function qO(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const s=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[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 LO(e,n){if(!MO.has(e))return null;const r=qO(e,n);if(!r)return null;const s=PO(r);return s?{emoji:e==="LS"?"📂":OO(s),label:s,category:"file",detail:r}:null}const FN={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 zN(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 $O(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 DO(e,n){const r=zN(e);if(!r)return null;const{server:s,method:o}=r;if(!o)return null;const l=FN[s.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${s} · ${o}`}}function FO(e,n){return IO(e,n)??LO(e,n)??DO(e)}const zO={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function BO(e){const n=zN(e);if(n){const s=FN[n.server.toLowerCase()];return s?{emoji:s.emoji,label:s.name}:{emoji:"🔌",label:n.server,hue:$O(n.server)}}const r=zO[e];return r?{emoji:wx(e),label:r}:{emoji:wx(e),label:e}}function UO(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function HO(e,n,r){if(r==null)return 1;const s=n-r;return s<0?1:Math.max(0,1-s/$N)}function WO(e,n){const r=[],s=new Set;for(let o=e.length-1;o>=0&&r.length<n;o--){const l=e[o];s.has(l.id)||(s.add(l.id),r.push(l))}return r.reverse()}function VO(e,n,r,s,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>$N)continue;const p=s.get(c.id)??r.get(c.id);if(!p)continue;const h=WO(c.tools,wO);if(h.length===0)continue;const f=c.exitAt??null,m=o.get(c.id),y=Math.max((m==null?void 0:m.width)??vx,vx),x=(m==null?void 0:m.height)??130,N=p.x,_=p.y,b=N+y,S=_+x/2;h.forEach((k,E)=>{const C=E*xO,I=N+y+_O,M=_+bO+C,O=HO(k,l,f),W=k.inputPreview??"",q=UO(k),P=O<.999,L=BO(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:L.label,emoji:L.emoji,status:q,category:EO(k.name),mcpHue:L.hue,inputPreview:W,fade:O,fading:P,worldX:I,worldY:M,anchorX:b,anchorY:S,spawnDx:b-I,spawnDy:S-(M+iv)});const U=FO(k.name,k.input);if(U){const B=AO(k.name,L.label),j=I+B+SO,Q=M,H=I+B,te=M+iv;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:U.label,emoji:U.emoji,isSub:!0,status:q,category:U.category,inputPreview:U.detail??W,fade:O,fading:P,worldX:j,worldY:Q,anchorX:H,anchorY:te,spawnDx:H-j,spawnDy:0})}})}return u}function GO({agents:e,visibleAgentIds:n,positions:r,pinned:s,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const f=VO(e,n,r,s,o,p),m=c&&c.size>0?f.filter(y=>!c.has(y.category)):f;return g.jsx(YO,{bursts:m,dimUnmatched:l,spotlight:u,onOpenTool:h})}function YO({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:s}){const{x:o,y:l,zoom:u}=EN();return g.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[g.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const p=c.anchorX*u+o,h=c.anchorY*u+l,f=(c.worldX+6)*u+o,m=(c.worldY+iv)*u+l,y=p+(f-p)*.55,x=n!=null&&!n.has(c.agentId),N=r!=null&&!r.has(c.agentId),_=c.fade*(x||N?.14:1);return g.jsx("path",{d:`M ${p} ${h} Q ${y} ${h}, ${f} ${m}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:_},`l:${c.id}`)})}),e.map(c=>{const p=c.worldX*u+o,h=c.worldY*u+l,f={left:`${p}px`,top:`${h}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,x=s!=null,N=c.mcpHue!=null?{"--cat-accent":`hsl(${c.mcpHue} 65% 65%)`}:{},_=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:f,children:g.jsxs("div",{className:`tool-burst cat-${c.category} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${S}`,style:N,title:y,role:x?"button":void 0,tabIndex:x?0:void 0,"aria-label":x?`Open ${c.toolName} ${c.status==="inflight"?"in flight":c.status} — click for details`:void 0,onClick:x?()=>s(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),s(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 KO({state:e,sessionId:n,onClose:r}){const s=A.useMemo(()=>QO(e,n),[e,n]),o=A.useRef(null);return io(r,{focusRef:o}),s?g.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:g.jsxs("div",{className:"modal session-summary",onClick:l=>l.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:s.cwd??s.sessionId,children:s.label}),g.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),g.jsxs("div",{className:"modal-actions",children:[g.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.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(s.cost.total)}),s.modelChips.length>0&&g.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>g.jsx("span",{className:"model-chip",title:l,children:xa(l)},l))})]}),g.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&g.jsxs(g.Fragment,{children:[g.jsx(XO,{cost:s.cost}),g.jsxs("div",{className:"ss-cost-legend",children:[g.jsxs("span",{className:"ssl ssl-in",children:["input ",g.jsx("b",{children:ze(s.cost.input)})]}),g.jsxs("span",{className:"ssl ssl-out",children:["output ",g.jsx("b",{children:ze(s.cost.output)})]}),g.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",g.jsx("b",{children:ze(s.cost.cacheRead)})]}),g.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",g.jsx("b",{children:ze(s.cost.cacheWrite)})]})]})]})})]}),g.jsxs("section",{className:"ss-stats",children:[g.jsx(Hs,{label:"agents",value:s.agentCount}),g.jsx(Hs,{label:"subagents",value:s.subagentCount}),g.jsx(Hs,{label:"tool calls",value:s.toolCount}),g.jsx(Hs,{label:"prompts",value:s.promptCount}),g.jsx(Hs,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&g.jsx(Hs,{label:"errors",value:s.errCount,tone:"err"})]}),s.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:s.topTools.map(([l,u])=>g.jsxs("div",{className:"ss-tt",children:[g.jsx("span",{className:"ss-tt-name",children:l}),g.jsx("span",{className:"ss-tt-bar",children:g.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),g.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),s.firstPrompt&&g.jsxs("section",{className:"modal-section",children:[g.jsx("h4",{children:"Opening prompt"}),g.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Hs({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 XO({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${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 QO(e,n){const r=e.agents.get(n);if(!r)return null;const s=[];for(const E of e.agents.values())E.sessionId===n&&s.push(E);if(s.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,p=0,h=0,f=0,m=0,y,x=1/0,N=0;for(const E of s){const C=sn(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++,p+=E.prompts.length,!y&&E.prompts.length>0&&(y=E.prompts[0].text),h+=E.usage.inputTokens+E.usage.outputTokens,c+=E.toolCount,x=Math.min(x,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&&f++}const _=Math.max(0,N-x),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:s.length,subagentCount:m,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:k,firstPrompt:y}}function ZO(e,n){const r=[];for(const s of e.agents.values()){if(s.kind!=="root")continue;let o=s.toolCount,l=sn(s.usage,s.model).total,u=s.endedAt??s.startedAt;for(const c of e.agents.values()){if(c.sessionId!==s.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=sn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",cwdBasename:s.cwdBasename,state:s.state,modelId:s.model,toolCount:o,cost:l,startedAt:s.startedAt,lastActivity:u})}return r.sort((s,o)=>{if(s.state!==o.state){if(s.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-s.lastActivity}),r}function JO(e,n,r){const s=(n??r)-e;if(s<1e3)return"<1s";const o=Math.floor(s/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 e3({state:e,now:n,selectedIds:r,onSelect:s,onClose:o}){const l=A.useMemo(()=>ZO(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return g.jsxs("aside",{className:"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})]}),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(c=>{const p=r.has(c.sessionId);return g.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>s(c.sessionId),title:`Focus ${c.label}`,children:[g.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),g.jsxs("div",{className:"sl-row-body",children:[g.jsxs("div",{className:"sl-row-head",children:[g.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&g.jsx("span",{className:"model-chip",title:c.modelId,children:xa(c.modelId)})]}),g.jsxs("div",{className:"sl-row-meta",children:[g.jsxs("span",{title:"tool calls",children:[g.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&g.jsx("span",{className:"sl-cost",title:"total spend",children:g.jsx("b",{children:ze(c.cost)})}),g.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:JO(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function bx(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 t3(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"}function jr(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function n3({cost:e}){const n=e.total;if(n<=0)return null;const r=(s,o,l)=>{if(s<=0)return null;const u=s/n*100;return g.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(s)} (${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 r3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/3600),o=Math.floor(r%3600/60);if(s>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return s>0?`${s}h ${o}m`:`${o}m`}function i3(e,n,r,s){const o=Math.max(0,n-s),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 p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,m={label:`${Math.round(c)}% ahead`,color:"var(--warn)",expectedPct:u,isDeficit:!0};if(f<o&&f<86400){const y=Math.floor(f/3600),x=Math.floor(f%3600/60);m.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Yi({pct:e,label:n,reset:r,resetAt:s,windowSec:o,limitReached:l,nowSec:u}){const c=Math.min(100,Math.max(0,e)),h=l||c>=90?"var(--err)":c>=70?"var(--warn)":"var(--accent)",f=c===0?"< 1%":`${c}%`,m=c===0?2:c,y=s?r3(s,u):null,x=s&&o?i3(c,s,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:h},children:f})]}),g.jsxs("div",{className:"qb-track",children:[g.jsx("div",{className:"qb-fill",style:{width:`${m}%`,background:h,opacity:c===0?.4:1}}),x&&g.jsx("div",{className:"qb-pace-marker",style:{left:`${x.expectedPct}%`,background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.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,x&&g.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const s3=6e4;function o3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),s3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function a3(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.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const BN=6e4;function l3(){const[e,n]=A.useState(null),[r,s]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&s(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&s(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),BN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function u3(){const[e,n]=A.useState(null),r=A.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(s(),r.current=window.setInterval(s,BN),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function c3({state:e,now:n,onClose:r}){var O,W;const{quota:s,loading:o,refresh:l}=o3(),{data:u,loading:c,refresh:p}=l3(),{data:h}=u3(),[f,m]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const q=window.setInterval(()=>m(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(q)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=A.useMemo(()=>{const q=new Map,P={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let L=0,U=0,B=0,j=0;for(const D of e.agents.values()){const X=D.model??"__unknown__",R=sn(D.usage,D.model),$=q.get(X);$?($.inputTokens+=D.usage.inputTokens,$.outputTokens+=D.usage.outputTokens,$.cacheReadTokens+=D.usage.cacheReadTokens,$.cacheCreateTokens+=D.usage.cacheCreateTokens,$.cost.total+=R.total,$.cost.input+=R.input,$.cost.output+=R.output,$.cost.cacheRead+=R.cacheRead,$.cost.cacheWrite+=R.cacheWrite,$.agentCount++):q.set(X,{model:X,inputTokens:D.usage.inputTokens,outputTokens:D.usage.outputTokens,cacheReadTokens:D.usage.cacheReadTokens,cacheCreateTokens:D.usage.cacheCreateTokens,cost:{...R},agentCount:1}),P.total+=R.total,P.input+=R.input,P.output+=R.output,P.cacheRead+=R.cacheRead,P.cacheWrite+=R.cacheWrite,L+=D.usage.inputTokens,U+=D.usage.outputTokens,B+=D.usage.cacheReadTokens,j+=D.usage.cacheCreateTokens}const Q=Array.from(q.values()).sort((D,X)=>X.cost.total-D.cost.total);let H=0,te=0;for(const D of e.agents.values()){if(D.state!=="active")continue;const X=sn(D.usage,D.model);H+=X.total,te=Math.max(te,((D.endedAt??n)-D.startedAt)/1e3)}const Z=te>0?su(H,te):null;return{byModel:Q,totalCost:P,totalTokens:{in:L,out:U,cacheR:B,cacheC:j},burnRate:Z}},[e,e.lastSeq,n]),b=A.useMemo(()=>{const q=[];for(const P of e.agents.values()){if(P.kind!=="root")continue;let L=sn(P.usage,P.model).total,U=P.usage.inputTokens,B=P.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==P.sessionId||j.kind==="root"||(L+=sn(j.usage,j.model).total,U+=j.usage.inputTokens,B+=j.usage.outputTokens);q.push({sessionId:P.sessionId,label:P.label||P.cwdBasename||"session",state:P.state,cost:L,inputTokens:U,outputTokens:B})}return q.sort((P,L)=>L.cost-P.cost).slice(0,12)},[e,e.lastSeq]),S=x.total>0,k=N.in+N.out,E=o||c,C=bx(s==null?void 0:s.fetchedAt,f),I=bx(u==null?void 0:u.fetchedAt,f),M=()=>{l(),p()};return g.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[g.jsxs("div",{className:"up-header",children:[g.jsx("h3",{children:"Usage"}),_&&g.jsx("span",{className:"up-rate",children:_}),g.jsxs("div",{className:"up-header-right",children:[g.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:M,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&g.jsx("span",{className:"up-section-age",title:t3(s==null?void 0:s.source),children:C})]}),s!=null&&s.ok?g.jsxs("div",{className:"up-quota-bars",children:[s.session5hPct!=null&&g.jsx(Yi,{label:"5-hour window",pct:s.session5hPct,reset:s.session5hReset,resetAt:s.session5hResetAt,windowSec:s.session5hWindowSec,nowSec:f}),s.week7dPct!=null&&g.jsx(Yi,{label:"7-day window",pct:s.week7dPct,reset:s.week7dReset,resetAt:s.week7dResetAt,windowSec:s.week7dWindowSec,nowSec:f}),s.weekSonnetPct!=null&&g.jsx(Yi,{label:"Sonnet (7d)",pct:s.weekSonnetPct,nowSec:f}),s.weekOpusPct!=null&&g.jsx(Yi,{label:"Opus (7d)",pct:s.weekOpusPct,nowSec:f})]}):(s==null?void 0:s.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…"})]}),g.jsxs("section",{className:"up-section up-quota-section",children:[g.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&g.jsx("span",{className:"up-plan-badge",children:u.planLabel}),I&&!c&&g.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:I})]}),u!=null&&u.ok?g.jsxs("div",{className:"up-quota-bars",children:[(O=u.windows)==null?void 0:O.map(q=>g.jsx(Yi,{label:q.label,pct:q.pct,reset:q.reset??void 0,resetAt:q.resetAt??void 0,windowSec:q.windowSec??void 0,limitReached:u.limitReached&&q.pct>=100,nowSec:f},q.id)),(W=u.extraWindows)==null?void 0:W.map(q=>g.jsx(Yi,{label:q.label,pct:q.pct,reset:q.reset??void 0,resetAt:q.resetAt??void 0,windowSec:q.windowSec??void 0,nowSec:f},q.id)),u.creditLimit&&g.jsx(Yi,{label:`spend cap · $${Math.round(u.creditLimit.used)} of $${Math.round(u.creditLimit.limit)}`,pct:u.creditLimit.usedPct,reset:u.creditLimit.reset??void 0,resetAt:u.creditLimit.resetAt??void 0,limitReached:u.spendControlReached,nowSec:f}),(h==null?void 0:h.ok)&&h.window7d&&h.window7d.sessionCount>0&&g.jsxs("div",{className:"up-quota-sub",children:[jr(h.window7d.totalTokens)," tokens · ",h.window7d.sessionCount," session",h.window7d.sessionCount!==1?"s":""," (7d)"]}),u.creditsBalance&&!u.creditsUnlimited&&g.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&g.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&g.jsxs("div",{className:"up-quota-sub up-reset-credits",title:"Redeem in the Codex CLI or ChatGPT — agents-deck only reports them",children:[u.resetCredits.availableCount," rate-limit reset",u.resetCredits.availableCount!==1?"s":""," available",u.resetCredits.nextExpiryAt&&` · expires ${new Date(u.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),u.promo&&g.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&g.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(u==null?void 0:u.ok)===!1?g.jsxs("div",{className:"up-quota-na",children:[g.jsx("span",{children:"Quota unavailable."}),g.jsx("span",{className:"up-quota-hint",children:a3(u.reason)})]}):g.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),S?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-total",children:[g.jsx("span",{className:"up-total-value",children:ze(x.total)}),g.jsx("span",{className:"up-total-label",children:"total spend"})]}),g.jsx(n3,{cost:x}),k>0&&g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]}),N.cacheR>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache r"}),jr(N.cacheR)]}),N.cacheC>0&&g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"cache c"}),jr(N.cacheC)]})]}),y.filter(q=>q.cost.total>0).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:y.filter(q=>q.cost.total>0).map(q=>g.jsxs("tr",{children:[g.jsx("td",{className:"up-model-name",title:q.model,children:xa(q.model)}),g.jsx("td",{className:"up-num",children:jr(q.inputTokens+q.outputTokens)}),g.jsx("td",{className:"up-num up-cost-val",children:ze(q.cost.total)})]},q.model))})]})]}),b.filter(q=>q.cost>0).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:b.filter(q=>q.cost>0).map(q=>g.jsxs("div",{className:"up-session-row",children:[g.jsx("span",{className:`sl-dot state-${q.state}`,"aria-hidden":!0}),g.jsx("span",{className:"up-session-label",children:q.label}),g.jsx("span",{className:"up-session-tokens",children:jr(q.inputTokens+q.outputTokens)}),g.jsx("span",{className:"up-session-cost",children:ze(q.cost)})]},q.sessionId))})]})]}):k>0?g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"up-tokens-row",children:[g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),g.jsxs("span",{className:"up-tok",children:[g.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]})]}),g.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):g.jsxs("div",{className:"up-empty",children:["No usage data yet.",g.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const Sx=18,d3=1100,Ws=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},f3=Array.from({length:Sx},(e,n)=>{const r=-72+144*n/(Sx-1)+(Ws(n,1)-.5)*9,s=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Ws(n,2)*.52);return{dx:Math.cos(s)*o,dy:Math.sin(s)*o,rot:(n%2?1:-1)*(100+Ws(n,3)*260),delay:Math.round(Ws(n,4)*90),dur:760+Math.round(Ws(n,5)*260),scale:.8+Ws(n,6)*.45,hue:n%4,round:n%3===0}});function kx({anchor:e,lifetimeMs:n=d3}){var l;const[r,s]=A.useState(null),o=typeof window<"u"&&((l=window.matchMedia)==null?void 0:l.call(window,"(prefers-reduced-motion: reduce)").matches);return A.useEffect(()=>{if(o)return;const u=e.current;if(!u)return;const c=u.getBoundingClientRect();s({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>s(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:gI.createPortal(g.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:f3.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 UN=new Set(["awaiting_url","awaiting_code","registering"]);function h3(e){return e!=null&&UN.has(e)}function HN(e){return e!=null&&e!=="done"&&!UN.has(e)}const p3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",m3="the sign-in did not complete";function g3({state:e,serverError:n,localError:r}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:r||n||(s?p3:m3)}}const v3="done";function y3(){let e=!1;return{shouldAnnounce(n){return n!==v3?(e=!1,!1):e?!1:(e=!0,!0)}}}const Ex={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 agents-deck",expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import"},Nx={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"},w3="claude-swap could not read the login keychain — start agents-deck from a Terminal window rather than a background service";function Cx(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(sv(e))?w3:e!=null&&e.reason&&Nx[e.reason]?Nx[e.reason]:(e==null?void 0:e.reason)||n}function sv(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||"").trim()}function Yl(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&HN(e.state)?e.error:e!=null&&e.reason&&Ex[e.reason]?Ex[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const x3=1500;async function Dl(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const ov=ae.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"})]}));ov.displayName="SuccessMark";function _3({onClose:e,onChanged:n}){const[r,s]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,m]=A.useState(!1),[y,x]=A.useState(null),[N,_]=A.useState(null),b=A.useRef(!1),S=A.useRef(null),k=A.useRef(null),E=A.useRef(null),C=A.useCallback(()=>{b.current&&Dl({action:"login-cancel"}).catch(()=>{}),e()},[e]);io(C);const I=A.useCallback(async()=>{m(!0),x(null),b.current=!0;const B=await Dl({action:"login"}).catch(()=>null);if(m(!1),!(B!=null&&B.ok)){x(Yl(B,"could not start the sign-in"));return}l(B)},[]);A.useEffect(()=>{if(!h3(o==null?void 0:o.state))return;const B=window.setInterval(async()=>{try{const j=await fetch("/api/claude-accounts/login");j.ok&&l(await j.json())}catch{}},x3);return()=>window.clearInterval(B)},[o]);const M=A.useRef(n);M.current=n;const O=A.useRef(y3());A.useEffect(()=>{var B;(o==null?void 0:o.state)==="awaiting_code"&&((B=S.current)==null||B.focus()),O.current.shouldAnnounce(o==null?void 0:o.state)&&M.current()},[o==null?void 0:o.state]),A.useEffect(()=>{var B;r==="paste"&&((B=k.current)==null||B.focus())},[r]);const W=A.useCallback(async()=>{var j;m(!0),x(null);const B=await Dl({action:"login-code",code:u}).catch(()=>null);if(m(!1),!(B!=null&&B.ok)){x(Yl(B,"the code was not accepted")),B!=null&&B.state&&l(B),(j=S.current)==null||j.select();return}c(""),l(B)},[u,o]),q=A.useCallback(async()=>{m(!0),x(null);const B=await Dl({action:"import",blob:p}).catch(()=>null);if(m(!1),!(B!=null&&B.ok)){x(Yl(B,"the import failed"));return}h(""),_({added:B.added===!0,num:B.num??null,email:B.email??null}),n()},[p,n]),P=(o==null?void 0:o.state)==="done"?o.account:null,L=HN(o==null?void 0:o.state)||!!(y&&b.current&&!f),U=g3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return g.jsx("div",{className:"modal-backdrop",onClick:C,role:"presentation",children:g.jsxs("div",{className:"modal aa-modal",onClick:B=>B.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:()=>s("login"),children:"Sign in"}),g.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>s("paste"),children:"Paste a share"})]})}),g.jsx("div",{className:"modal-actions",children:g.jsx("button",{type:"button",className:"btn icon-btn",onClick:C,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),g.jsx("section",{className:"modal-body aa-body",children:r==="login"?P?g.jsxs("div",{className:"aa-done",children:[g.jsx(ov,{ref:E}),g.jsx(kx,{anchor:E}),g.jsx("h4",{children:P.added?`Account ${P.num} added`:"Credentials refreshed"}),g.jsxs("p",{className:"aa-note",children:[g.jsx("strong",{children:P.email}),P.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:B=>c(B.target.value),onKeyDown:B=>{B.key==="Enter"&&u.trim()&&!f&&W()},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:f||!u.trim()||o.state==="registering",onClick:W,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."})]})]}):L?g.jsxs("div",{className:"aa-step",children:[g.jsx("h4",{children:U.title}),g.jsx("p",{className:"aa-err",children:U.message}),g.jsx("button",{type:"button",className:"btn",onClick:()=>{b.current=!1,l(null),x(null),I()},children:"Try again"})]}):f||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",className:"btn primary",onClick:I,disabled:f,children:"Open the sign-in page"})})]}):N?g.jsxs("div",{className:"aa-done",children:[g.jsx(ov,{ref:E}),N.added&&g.jsx(kx,{anchor:E}),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:p,onChange:B=>h(B.target.value),onKeyDown:B=>{B.key==="Enter"&&p.trim()&&!f&&q()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),g.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:q,children:f?"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."]})]})})]})})}const b3=15e3,S3=[70,80,85,90,95];function k3(e,n){const r=e-n;if(r<=0)return null;const s=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return s>0?`${s}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function Tx(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 E3(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 N3(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 C3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),s=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?k3(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:s,opacity:r===0?.4:1}})}),g.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[r,"%"]}),g.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function T3(e){const n=e.map(s=>s.num),r=n.length?Math.max(...n):0;return[...new Set([...n,r+1])].sort((s,o)=>s-o)}async function R3(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(s=>window.setTimeout(()=>s(!1),500))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function j3(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 A3({onClose:e}){var Z,D,X;const[n,r]=A.useState(null),[s,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(null),[h,f]=A.useState(null),[m,y]=A.useState(()=>Math.floor(Date.now()/1e3)),x=A.useRef(null),[N,_]=A.useState(null),[b,S]=A.useState(!1),[k,E]=A.useState(""),[C,I]=A.useState(null),[M,O]=A.useState(null),[W,q]=A.useState(!1),P=A.useCallback(async(R=!1)=>{try{const[$,V]=await Promise.all([fetch(`/api/claude-accounts${R?"?refresh=1":""}`),fetch("/api/cswap-auto")]);$.ok&&r(await $.json()),V.ok&&o(await V.json())}catch{}},[]),L=A.useCallback(async(R,$)=>{u($),f(null);try{const F=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).json().catch(()=>null);return F!=null&&F.ok||f({text:Cx(F,"command failed"),raw:sv(F)}),F}catch{return f({text:"server unreachable"}),null}finally{u(null)}},[]),U=A.useCallback(async(R,$)=>{u($),f(null);try{const F=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R)})).json().catch(()=>null);return F!=null&&F.ok||f({text:Yl(F,"command failed")}),F}catch{return f({text:"server unreachable"}),null}finally{u(null)}},[]);A.useEffect(()=>(P(!0),x.current=window.setInterval(()=>P(!1),b3),()=>{x.current!=null&&window.clearInterval(x.current)}),[P]),A.useEffect(()=>{const R=window.setInterval(()=>y(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(R)},[]);const B=((Z=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:Z.value)??"90",j=(D=n==null?void 0:n.accounts)==null?void 0:D.find(R=>R.active),Q=j!=null&&j.lanes.length?Math.max(...j.lanes.map(R=>R.pct)):null,H=Q!=null&&Q>=Number(B)-15,te=async R=>{p(R),f(null);try{const V=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:R})})).json().catch(()=>null);V!=null&&V.ok||f({text:Cx(V,"the switch failed"),raw:sv(V)}),await P(!0)}catch{f({text:"server unreachable"})}finally{p(null)}};return g.jsxs("div",{className:"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:()=>S(!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:()=>P(!0),title:"Reload from claude-swap",children:"↻"}),g.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?g.jsxs(g.Fragment,{children:[(X=n.accounts)==null?void 0:X.map(R=>g.jsxs("div",{className:`ap-account${R.active?" active":""}${R.disabled?" disabled":""}`,children:[g.jsxs("div",{className:"ap-account-head",children:[g.jsx("span",{className:"ap-num",children:R.num}),R.alias&&g.jsx("span",{className:"ap-alias",children:R.alias}),g.jsx("span",{className:"ap-email",title:R.org??void 0,children:R.email}),g.jsx("button",{type:"button",className:`ap-more${N===R.num?" on":""}`,"aria-label":`Manage account ${R.num}`,"aria-expanded":N===R.num,title:"Share, rename, move, remove",onClick:()=>{_(N===R.num?null:R.num),E(R.alias??""),I(null),O(null),q(!1)},children:"⋯"}),R.active?g.jsx("span",{className:"ap-badge-active",children:"● active"}):g.jsx("button",{type:"button",className:"btn ap-switch",disabled:c!=null||R.disabled,onClick:()=>te(R.num),title:R.disabled?"Held out of rotation":`Switch to ${R.alias??R.email}`,children:c===R.num?"…":"switch"})]}),R.lanes.length>0?R.lanes.map($=>g.jsx(C3,{lane:$,nowSec:m},$.id)):g.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),g.jsxs("div",{className:"ap-meta",children:[R.error&&(()=>{const $=N3(R.error);return g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"ap-err",title:$.hint,children:$.text}),$.fixable&&g.jsx("button",{type:"button",className:"ap-fix",onClick:()=>S(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!R.active&&g.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>L({action:"account",account:R.num,enabled:R.disabled},`rot-${R.num}`).then(()=>P(!0)),title:R.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:R.disabled?"held out":"in rotation"}),R.fetchedAt?g.jsxs("span",{className:`ap-age${R.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 ",Tx(R.fetchedAt,m),E3(R.nextAt,m)]}):g.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),N===R.num&&g.jsxs("div",{className:"ap-manage",children:[g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"name"}),g.jsx("input",{className:"ap-manage-input",type:"text",value:k,onChange:$=>E($.target.value),onKeyDown:$=>{$.key==="Enter"&&U({action:"alias",account:R.num,alias:k},`alias-${R.num}`).then(()=>P(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${R.num}`}),g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||k.trim()===(R.alias??""),onClick:()=>U({action:"alias",account:R.num,alias:k},`alias-${R.num}`).then(()=>P(!0)),title:"A short name to show instead of the email",children:"save"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("span",{className:"ap-manage-label",children:"slot"}),g.jsx("span",{className:"ap-field",children:g.jsx("select",{"aria-label":`Slot for account ${R.num}`,value:String(R.num),disabled:l!=null,onChange:$=>U({action:"move",account:R.num,slot:Number($.target.value)},`move-${R.num}`).then(()=>P(!0)),children:T3(n.accounts??[]).map($=>g.jsx("option",{value:$,children:$},$))})}),g.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),g.jsxs("div",{className:"ap-manage-row",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,title:"Copy this account to another agents-deck. The share carries a live login and expires in 10 minutes.",onClick:async()=>{q(!1);const $=await U({action:"share",account:R.num},`share-${R.num}`);$!=null&&$.ok&&O({num:R.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),g.jsx("button",{type:"button",className:`ap-manage-btn danger${C===R.num?" armed":""}`,disabled:l!=null,title:C===R.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(C!==R.num){I(R.num),window.setTimeout(()=>I($=>$===R.num?null:$),4e3);return}I(null),U({action:"remove",account:R.num},`rm-${R.num}`).then(()=>{_(null),P(!0)})},children:C===R.num?"confirm remove":"remove"})]}),(M==null?void 0:M.num)===R.num&&(()=>{const $=j3(M.expiresAt,m),V=$.tone==="gone";return g.jsxs("div",{className:`ap-share${V?" expired":""}`,children:[g.jsx("code",{className:"ap-share-blob",children:M.blob}),g.jsxs("div",{className:"ap-share-foot",children:[g.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(V){q(!1);const F=await U({action:"share",account:R.num},`share-${R.num}`);F!=null&&F.ok&&O({num:R.num,blob:F.blob,expiresAt:F.expiresAt});return}await R3(M.blob)&&(q(!0),window.setTimeout(()=>q(!1),1800))},children:V?"make a new share":W?"copied":"copy"}),g.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",g.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]})]})]})})()]})]},R.num)),(s==null?void 0:s.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:[Q!=null&&g.jsxs("span",{className:`ap-auto-now${H?" near":""}`,children:[Math.round(Q),"%"]}),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:B,disabled:l!=null,onChange:R=>L({action:"setting",key:"autoswitch.threshold",value:R.target.value},"threshold").then(()=>P(!0)),children:S3.map(R=>g.jsxs("option",{value:R,children:[R,"%"]},R))})}),g.jsxs("button",{type:"button",className:`ap-auto-state toggle${s.enabled?" live":""}`,role:"switch","aria-checked":s.enabled,disabled:l!=null,onClick:()=>L({action:"enable",enabled:!s.enabled},"enable").then(()=>P(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[g.jsx("i",{className:s.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),s.enabled?"on":"off"]})]})]}),s.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",s.enabled?" — this toggle takes over when you stop it.":"."]}),s.lastTick&&g.jsx("div",{className:"ap-auto-foot",children:g.jsxs("span",{className:"ap-auto-result",children:["checked ",Tx(s.lastTick.at,m)]})})]}),h&&g.jsxs("div",{className:"ap-failure",role:"alert",children:[g.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),g.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(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})`:"","."]})]})}),b&&g.jsx(_3,{onClose:()=>S(!1),onChanged:()=>P(!0)})]})}const I3=3e4;function M3({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function P3({bundle:e,running:n,pending:r,lastTried:s}){return n?M3({bundle:e,running:n,lastTried:s})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function O3(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function q3({asked:e,reported:n}){return n?n!==e:!1}function L3(e){const n=e.thresholdMs??I3;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 $3(e){return e.ctrlKey||e.metaKey||e.altKey}const D3=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),F3=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),z3=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function WN(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function VN(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=WN(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!D3.has(String(e.type??"text").toLowerCase())}function B3(e){if(!e)return!1;if(VN(e)||F3.has(WN(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>z3.has(r))}function U3({agentCount:e,onConfirm:n,onCancel:r}){const s=A.useRef(null);io(r,{focusRef:s,layer:KP});const o=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",{className:"modal clear-confirm",onClick:l=>l.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:[o," — 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:s,className:"btn",onClick:r,children:"Cancel"}),g.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function H3(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function wd(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function W3(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}const V3=40,G3=120;function Y3(e,n){let r=null,s=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,h,f)=>{if(r!=null){if(s<=p)return;u()}const m=Math.min(f,Math.max(0,p-h));s=p,r=n.setTimeout(l,m)};return{live(p=V3){const h=n.now(),f=Math.max(o+p,h);if(f<=h){u(),l();return}c(f,h,p)},replay(p=G3){u(),s=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function K3(){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 s=n;return n=[],s}}}const X3="1",Rx="agent-dag.schema",Q3=["agent-dag.layout","agent-dag.viewport"];function GN(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Z3(e,n=X3){let r=null;try{r=e.getItem(Rx)}catch{return[]}if(r===n)return[];const s=[];if(r!==null)for(const o of Q3)try{e.getItem(o)!==null&&(e.removeItem(o),s.push(o))}catch{}try{e.setItem(Rx,n)}catch{}return s}function J3(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function eq(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function Ki(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 jx(e){return e.replace(/^anthropic\./,"").replace(/^claude-/,"").replace(/-\d{8}$/,"")}function Fl(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 tq=[7,14,30,90];function nq(e){const[n,r]=A.useState(null),[s,o]=A.useState(!1),l=A.useRef(J3()).current,u=(c=!1)=>{const p=l.begin();o(!0);const f=`/api/ccusage?since=${eq(e)}${c?"&refresh=1":""}`;fetch(f).then(m=>m.json()).then(m=>{p()&&r(m)}).catch(()=>{p()&&r({ok:!1,error:"request failed"})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{data:n,loading:s,reload:()=>u(!0)}}function rq({onClose:e}){var S,k;const[n,r]=A.useState(30),[s,o]=A.useState(null),{data:l,loading:u,reload:c}=nq(n);io(e);const p=l!=null&&l.ok?l.days??[]:[],h=A.useMemo(()=>p.reduce((E,C)=>Math.max(E,C.totalCost),0),[p]),{totalCost:f,totalTok:m,inOut:y,cacheRead:x,modelCosts:N}=A.useMemo(()=>{let E=0,C=0,I=0,M=0;const O=new Map;for(const W of p){E+=W.totalCost,C+=W.totalTokens,I+=W.inputTokens+W.outputTokens,M+=W.cacheReadTokens;for(const q of W.modelBreakdowns)O.set(q.modelName,(O.get(q.modelName)??0)+q.cost)}return{totalCost:E,totalTok:C,inOut:I,cacheRead:M,modelCosts:O}},[p]),_=A.useMemo(()=>Array.from(N.entries()).sort((E,C)=>C[1]-E[1]),[N]),b=s?p.find(E=>E.period===s)??null:null;return g.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:g.jsxs("div",{className:"uh-modal",onClick:E=>E.stopPropagation(),role:"dialog","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:tq.map(E=>g.jsxs("button",{role:"tab","aria-selected":n===E,className:`uh-range-btn${n===E?" on":""}`,onClick:()=>{r(E),o(null)},children:[E,"d"]},E))}),g.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,title:"Re-run ccusage","aria-label":"Reload",children:"↻"}),g.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),u&&p.length===0?g.jsx("div",{className:"uh-status",children:"running ccusage… (first run downloads the package)"}):l&&!l.ok?g.jsxs("div",{className:"uh-status uh-err",children:["ccusage failed: ",l.error]}):p.length===0?g.jsx("div",{className:"uh-status",children:"no usage in this range"}):g.jsxs(g.Fragment,{children:[g.jsxs("div",{className:"uh-totals",children:[g.jsx(zl,{label:"total cost",val:ze(f),accent:!0}),g.jsx(zl,{label:"tokens",val:Ki(m)}),g.jsx(zl,{label:"input+output",val:Ki(y)}),g.jsx(zl,{label:"cache reads",val:Ki(x)})]}),g.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:p.map(E=>{const C=h>0?E.totalCost/h*100:0,I=E.period===s;return g.jsxs("button",{className:`uh-bar-col${I?" sel":""}`,onClick:()=>o(I?null:E.period),title:`${E.period} · ${ze(E.totalCost)}`,style:{flexBasis:`${100/p.length}%`},children:[g.jsx("div",{className:"uh-bar",style:{height:`${Math.max(C,E.totalCost>0?2:0)}%`},children:E.modelBreakdowns.slice().sort((M,O)=>O.cost-M.cost).map(M=>{const O=E.totalCost>0?M.cost/E.totalCost*100:0;return g.jsx("div",{className:"uh-bar-seg",style:{height:`${O}%`,background:Fl(M.modelName)}},M.modelName)})}),g.jsx("span",{className:"uh-bar-label",children:E.period.slice(5)})]},E.period)})}),g.jsx("div",{className:"uh-legend",children:_.map(([E,C])=>g.jsxs("span",{className:"uh-legend-item",children:[g.jsx("span",{className:"uh-legend-dot",style:{background:Fl(E)}}),jx(E)," ",g.jsx("span",{className:"uh-legend-cost",children:ze(C)})]},E))}),b&&g.jsxs("div",{className:"uh-detail",children:[g.jsxs("div",{className:"uh-detail-head",children:[g.jsx("span",{className:"uh-detail-date",children:b.period}),g.jsx("span",{className:"uh-detail-cost",children:ze(b.totalCost)}),(k=(S=b.metadata)==null?void 0:S.agents)!=null&&k.length?g.jsx("span",{className:"uh-detail-agents",children:b.metadata.agents.join(" · ")}):null]}),g.jsxs("div",{className:"uh-detail-mini",children:[g.jsx(Bl,{label:"input",val:Ki(b.inputTokens)}),g.jsx(Bl,{label:"output",val:Ki(b.outputTokens)}),g.jsx(Bl,{label:"cache write",val:Ki(b.cacheCreationTokens)}),g.jsx(Bl,{label:"cache read",val:Ki(b.cacheReadTokens)})]}),g.jsx("div",{className:"uh-detail-models",children:b.modelBreakdowns.slice().sort((E,C)=>C.cost-E.cost).map(E=>{const C=b.totalCost>0?E.cost/b.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:Fl(E.modelName)}}),jx(E.modelName)]}),g.jsx("span",{className:"uh-model-bar",children:g.jsx("span",{className:"uh-model-bar-fill",style:{width:`${C}%`,background:Fl(E.modelName)}})}),g.jsx("span",{className:"uh-model-cost",children:ze(E.cost)})]},E.modelName)})})]})]})]})})}function zl({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 Bl({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 Av(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 xd,Ax;function iq(){if(Ax)return xd;Ax=1;function e(){this.__data__=[],this.size=0}return xd=e,xd}var _d,Ix;function so(){if(Ix)return _d;Ix=1;function e(n,r){return n===r||n!==n&&r!==r}return _d=e,_d}var bd,Mx;function mu(){if(Mx)return bd;Mx=1;var e=so();function n(r,s){for(var o=r.length;o--;)if(e(r[o][0],s))return o;return-1}return bd=n,bd}var Sd,Px;function sq(){if(Px)return Sd;Px=1;var e=mu(),n=Array.prototype,r=n.splice;function s(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 Sd=s,Sd}var kd,Ox;function oq(){if(Ox)return kd;Ox=1;var e=mu();function n(r){var s=this.__data__,o=e(s,r);return o<0?void 0:s[o][1]}return kd=n,kd}var Ed,qx;function aq(){if(qx)return Ed;qx=1;var e=mu();function n(r){return e(this.__data__,r)>-1}return Ed=n,Ed}var Nd,Lx;function lq(){if(Lx)return Nd;Lx=1;var e=mu();function n(r,s){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,s])):o[l][1]=s,this}return Nd=n,Nd}var Cd,$x;function gu(){if($x)return Cd;$x=1;var e=iq(),n=sq(),r=oq(),s=aq(),o=lq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Cd=l,Cd}var Td,Dx;function uq(){if(Dx)return Td;Dx=1;var e=gu();function n(){this.__data__=new e,this.size=0}return Td=n,Td}var Rd,Fx;function cq(){if(Fx)return Rd;Fx=1;function e(n){var r=this.__data__,s=r.delete(n);return this.size=r.size,s}return Rd=e,Rd}var jd,zx;function dq(){if(zx)return jd;zx=1;function e(n){return this.__data__.get(n)}return jd=e,jd}var Ad,Bx;function fq(){if(Bx)return Ad;Bx=1;function e(n){return this.__data__.has(n)}return Ad=e,Ad}var Id,Ux;function YN(){if(Ux)return Id;Ux=1;var e=typeof Nl=="object"&&Nl&&Nl.Object===Object&&Nl;return Id=e,Id}var Md,Hx;function Qn(){if(Hx)return Md;Hx=1;var e=YN(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return Md=r,Md}var Pd,Wx;function oo(){if(Wx)return Pd;Wx=1;var e=Qn(),n=e.Symbol;return Pd=n,Pd}var Od,Vx;function hq(){if(Vx)return Od;Vx=1;var e=oo(),n=Object.prototype,r=n.hasOwnProperty,s=n.toString,o=e?e.toStringTag:void 0;function l(u){var c=r.call(u,o),p=u[o];try{u[o]=void 0;var h=!0}catch{}var f=s.call(u);return h&&(c?u[o]=p:delete u[o]),f}return Od=l,Od}var qd,Gx;function pq(){if(Gx)return qd;Gx=1;var e=Object.prototype,n=e.toString;function r(s){return n.call(s)}return qd=r,qd}var Ld,Yx;function rs(){if(Yx)return Ld;Yx=1;var e=oo(),n=hq(),r=pq(),s="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:s:l&&l in Object(c)?n(c):r(c)}return Ld=u,Ld}var $d,Kx;function Nn(){if(Kx)return $d;Kx=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return $d=e,$d}var Dd,Xx;function _a(){if(Xx)return Dd;Xx=1;var e=rs(),n=Nn(),r="[object AsyncFunction]",s="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==s||p==o||p==r||p==l}return Dd=u,Dd}var Fd,Qx;function mq(){if(Qx)return Fd;Qx=1;var e=Qn(),n=e["__core-js_shared__"];return Fd=n,Fd}var zd,Zx;function gq(){if(Zx)return zd;Zx=1;var e=mq(),n=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function r(s){return!!n&&n in s}return zd=r,zd}var Bd,Jx;function KN(){if(Jx)return Bd;Jx=1;var e=Function.prototype,n=e.toString;function r(s){if(s!=null){try{return n.call(s)}catch{}try{return s+""}catch{}}return""}return Bd=r,Bd}var Ud,e_;function vq(){if(e_)return Ud;e_=1;var e=_a(),n=gq(),r=Nn(),s=KN(),o=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,u=Function.prototype,c=Object.prototype,p=u.toString,h=c.hasOwnProperty,f=RegExp("^"+p.call(h).replace(o,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!r(y)||n(y))return!1;var x=e(y)?f:l;return x.test(s(y))}return Ud=m,Ud}var Hd,t_;function yq(){if(t_)return Hd;t_=1;function e(n,r){return n==null?void 0:n[r]}return Hd=e,Hd}var Wd,n_;function is(){if(n_)return Wd;n_=1;var e=vq(),n=yq();function r(s,o){var l=n(s,o);return e(l)?l:void 0}return Wd=r,Wd}var Vd,r_;function Iv(){if(r_)return Vd;r_=1;var e=is(),n=Qn(),r=e(n,"Map");return Vd=r,Vd}var Gd,i_;function vu(){if(i_)return Gd;i_=1;var e=is(),n=e(Object,"create");return Gd=n,Gd}var Yd,s_;function wq(){if(s_)return Yd;s_=1;var e=vu();function n(){this.__data__=e?e(null):{},this.size=0}return Yd=n,Yd}var Kd,o_;function xq(){if(o_)return Kd;o_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Kd=e,Kd}var Xd,a_;function _q(){if(a_)return Xd;a_=1;var e=vu(),n="__lodash_hash_undefined__",r=Object.prototype,s=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return s.call(u,l)?u[l]:void 0}return Xd=o,Xd}var Qd,l_;function bq(){if(l_)return Qd;l_=1;var e=vu(),n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Qd=s,Qd}var Zd,u_;function Sq(){if(u_)return Zd;u_=1;var e=vu(),n="__lodash_hash_undefined__";function r(s,o){var l=this.__data__;return this.size+=this.has(s)?0:1,l[s]=e&&o===void 0?n:o,this}return Zd=r,Zd}var Jd,c_;function kq(){if(c_)return Jd;c_=1;var e=wq(),n=xq(),r=_q(),s=bq(),o=Sq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Jd=l,Jd}var ef,d_;function Eq(){if(d_)return ef;d_=1;var e=kq(),n=gu(),r=Iv();function s(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return ef=s,ef}var tf,f_;function Nq(){if(f_)return tf;f_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return tf=e,tf}var nf,h_;function yu(){if(h_)return nf;h_=1;var e=Nq();function n(r,s){var o=r.__data__;return e(s)?o[typeof s=="string"?"string":"hash"]:o.map}return nf=n,nf}var rf,p_;function Cq(){if(p_)return rf;p_=1;var e=yu();function n(r){var s=e(this,r).delete(r);return this.size-=s?1:0,s}return rf=n,rf}var sf,m_;function Tq(){if(m_)return sf;m_=1;var e=yu();function n(r){return e(this,r).get(r)}return sf=n,sf}var of,g_;function Rq(){if(g_)return of;g_=1;var e=yu();function n(r){return e(this,r).has(r)}return of=n,of}var af,v_;function jq(){if(v_)return af;v_=1;var e=yu();function n(r,s){var o=e(this,r),l=o.size;return o.set(r,s),this.size+=o.size==l?0:1,this}return af=n,af}var lf,y_;function Mv(){if(y_)return lf;y_=1;var e=Eq(),n=Cq(),r=Tq(),s=Rq(),o=jq();function l(u){var c=-1,p=u==null?0:u.length;for(this.clear();++c<p;){var h=u[c];this.set(h[0],h[1])}}return l.prototype.clear=e,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,lf=l,lf}var uf,w_;function Aq(){if(w_)return uf;w_=1;var e=gu(),n=Iv(),r=Mv(),s=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<s-1)return p.push([l,u]),this.size=++c.size,this;c=this.__data__=new r(p)}return c.set(l,u),this.size=c.size,this}return uf=o,uf}var cf,x_;function wu(){if(x_)return cf;x_=1;var e=gu(),n=uq(),r=cq(),s=dq(),o=fq(),l=Aq();function u(c){var p=this.__data__=new e(c);this.size=p.size}return u.prototype.clear=n,u.prototype.delete=r,u.prototype.get=s,u.prototype.has=o,u.prototype.set=l,cf=u,cf}var df,__;function Pv(){if(__)return df;__=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o&&r(n[s],s,n)!==!1;);return n}return df=e,df}var ff,b_;function XN(){if(b_)return ff;b_=1;var e=is(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return ff=n,ff}var hf,S_;function xu(){if(S_)return hf;S_=1;var e=XN();function n(r,s,o){s=="__proto__"&&e?e(r,s,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[s]=o}return hf=n,hf}var pf,k_;function _u(){if(k_)return pf;k_=1;var e=xu(),n=so(),r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(s.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return pf=o,pf}var mf,E_;function ba(){if(E_)return mf;E_=1;var e=_u(),n=xu();function r(s,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],m=u?u(l[f],s[f],f,l,s):void 0;m===void 0&&(m=s[f]),c?n(l,f,m):e(l,f,m)}return l}return mf=r,mf}var gf,N_;function Iq(){if(N_)return gf;N_=1;function e(n,r){for(var s=-1,o=Array(n);++s<n;)o[s]=r(s);return o}return gf=e,gf}var vf,C_;function fr(){if(C_)return vf;C_=1;function e(n){return n!=null&&typeof n=="object"}return vf=e,vf}var yf,T_;function Mq(){if(T_)return yf;T_=1;var e=rs(),n=fr(),r="[object Arguments]";function s(o){return n(o)&&e(o)==r}return yf=s,yf}var wf,R_;function Sa(){if(R_)return wf;R_=1;var e=Mq(),n=fr(),r=Object.prototype,s=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&s.call(u,"callee")&&!o.call(u,"callee")};return wf=l,wf}var xf,j_;function _t(){if(j_)return xf;j_=1;var e=Array.isArray;return xf=e,xf}var ta={exports:{}},_f,A_;function Pq(){if(A_)return _f;A_=1;function e(){return!1}return _f=e,_f}ta.exports;var I_;function ao(){return I_||(I_=1,(function(e,n){var r=Qn(),s=Pq(),o=n&&!n.nodeType&&n,l=o&&!0&&e&&!e.nodeType&&e,u=l&&l.exports===o,c=u?r.Buffer:void 0,p=c?c.isBuffer:void 0,h=p||s;e.exports=h})(ta,ta.exports)),ta.exports}var bf,M_;function bu(){if(M_)return bf;M_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(s,o){var l=typeof s;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(s))&&s>-1&&s%1==0&&s<o}return bf=r,bf}var Sf,P_;function Ov(){if(P_)return Sf;P_=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Sf=n,Sf}var kf,O_;function Oq(){if(O_)return kf;O_=1;var e=rs(),n=Ov(),r=fr(),s="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",m="[object Object]",y="[object RegExp]",x="[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]",M="[object Int32Array]",O="[object Uint8Array]",W="[object Uint8ClampedArray]",q="[object Uint16Array]",P="[object Uint32Array]",L={};L[k]=L[E]=L[C]=L[I]=L[M]=L[O]=L[W]=L[q]=L[P]=!0,L[s]=L[o]=L[b]=L[l]=L[S]=L[u]=L[c]=L[p]=L[h]=L[f]=L[m]=L[y]=L[x]=L[N]=L[_]=!1;function U(B){return r(B)&&n(B.length)&&!!L[e(B)]}return kf=U,kf}var Ef,q_;function Su(){if(q_)return Ef;q_=1;function e(n){return function(r){return n(r)}}return Ef=e,Ef}var na={exports:{}};na.exports;var L_;function qv(){return L_||(L_=1,(function(e,n){var r=YN(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l&&r.process,c=(function(){try{var p=o&&o.require&&o.require("util").types;return p||u&&u.binding&&u.binding("util")}catch{}})();e.exports=c})(na,na.exports)),na.exports}var Nf,$_;function ka(){if($_)return Nf;$_=1;var e=Oq(),n=Su(),r=qv(),s=r&&r.isTypedArray,o=s?n(s):e;return Nf=o,Nf}var Cf,D_;function QN(){if(D_)return Cf;D_=1;var e=Iq(),n=Sa(),r=_t(),s=ao(),o=bu(),l=ka(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var m=r(h),y=!m&&n(h),x=!m&&!y&&s(h),N=!m&&!y&&!x&&l(h),_=m||y||x||N,b=_?e(h.length,String):[],S=b.length;for(var k in h)(f||c.call(h,k))&&!(_&&(k=="length"||x&&(k=="offset"||k=="parent")||N&&(k=="buffer"||k=="byteLength"||k=="byteOffset")||o(k,S)))&&b.push(k);return b}return Cf=p,Cf}var Tf,F_;function ku(){if(F_)return Tf;F_=1;var e=Object.prototype;function n(r){var s=r&&r.constructor,o=typeof s=="function"&&s.prototype||e;return r===o}return Tf=n,Tf}var Rf,z_;function ZN(){if(z_)return Rf;z_=1;function e(n,r){return function(s){return n(r(s))}}return Rf=e,Rf}var jf,B_;function qq(){if(B_)return jf;B_=1;var e=ZN(),n=e(Object.keys,Object);return jf=n,jf}var Af,U_;function Lv(){if(U_)return Af;U_=1;var e=ku(),n=qq(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))s.call(l,c)&&c!="constructor"&&u.push(c);return u}return Af=o,Af}var If,H_;function Or(){if(H_)return If;H_=1;var e=_a(),n=Ov();function r(s){return s!=null&&n(s.length)&&!e(s)}return If=r,If}var Mf,W_;function gi(){if(W_)return Mf;W_=1;var e=QN(),n=Lv(),r=Or();function s(o){return r(o)?e(o):n(o)}return Mf=s,Mf}var Pf,V_;function Lq(){if(V_)return Pf;V_=1;var e=ba(),n=gi();function r(s,o){return s&&e(o,n(o),s)}return Pf=r,Pf}var Of,G_;function $q(){if(G_)return Of;G_=1;function e(n){var r=[];if(n!=null)for(var s in Object(n))r.push(s);return r}return Of=e,Of}var qf,Y_;function Dq(){if(Y_)return qf;Y_=1;var e=Nn(),n=ku(),r=$q(),s=Object.prototype,o=s.hasOwnProperty;function l(u){if(!e(u))return r(u);var c=n(u),p=[];for(var h in u)h=="constructor"&&(c||!o.call(u,h))||p.push(h);return p}return qf=l,qf}var Lf,K_;function ss(){if(K_)return Lf;K_=1;var e=QN(),n=Dq(),r=Or();function s(o){return r(o)?e(o,!0):n(o)}return Lf=s,Lf}var $f,X_;function Fq(){if(X_)return $f;X_=1;var e=ba(),n=ss();function r(s,o){return s&&e(o,n(o),s)}return $f=r,$f}var ra={exports:{}};ra.exports;var Q_;function JN(){return Q_||(Q_=1,(function(e,n){var r=Qn(),s=n&&!n.nodeType&&n,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var m=h.length,y=c?c(m):new h.constructor(m);return h.copy(y),y}e.exports=p})(ra,ra.exports)),ra.exports}var Df,Z_;function eC(){if(Z_)return Df;Z_=1;function e(n,r){var s=-1,o=n.length;for(r||(r=Array(o));++s<o;)r[s]=n[s];return r}return Df=e,Df}var Ff,J_;function tC(){if(J_)return Ff;J_=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=0,u=[];++s<o;){var c=n[s];r(c,s,n)&&(u[l++]=c)}return u}return Ff=e,Ff}var zf,e1;function nC(){if(e1)return zf;e1=1;function e(){return[]}return zf=e,zf}var Bf,t1;function $v(){if(t1)return Bf;t1=1;var e=tC(),n=nC(),r=Object.prototype,s=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return s.call(u,c)}))}:n;return Bf=l,Bf}var Uf,n1;function zq(){if(n1)return Uf;n1=1;var e=ba(),n=$v();function r(s,o){return e(s,n(s),o)}return Uf=r,Uf}var Hf,r1;function Dv(){if(r1)return Hf;r1=1;function e(n,r){for(var s=-1,o=r.length,l=n.length;++s<o;)n[l+s]=r[s];return n}return Hf=e,Hf}var Wf,i1;function Eu(){if(i1)return Wf;i1=1;var e=ZN(),n=e(Object.getPrototypeOf,Object);return Wf=n,Wf}var Vf,s1;function rC(){if(s1)return Vf;s1=1;var e=Dv(),n=Eu(),r=$v(),s=nC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:s;return Vf=l,Vf}var Gf,o1;function Bq(){if(o1)return Gf;o1=1;var e=ba(),n=rC();function r(s,o){return e(s,n(s),o)}return Gf=r,Gf}var Yf,a1;function iC(){if(a1)return Yf;a1=1;var e=Dv(),n=_t();function r(s,o,l){var u=o(s);return n(s)?u:e(u,l(s))}return Yf=r,Yf}var Kf,l1;function sC(){if(l1)return Kf;l1=1;var e=iC(),n=$v(),r=gi();function s(o){return e(o,r,n)}return Kf=s,Kf}var Xf,u1;function Uq(){if(u1)return Xf;u1=1;var e=iC(),n=rC(),r=ss();function s(o){return e(o,r,n)}return Xf=s,Xf}var Qf,c1;function Hq(){if(c1)return Qf;c1=1;var e=is(),n=Qn(),r=e(n,"DataView");return Qf=r,Qf}var Zf,d1;function Wq(){if(d1)return Zf;d1=1;var e=is(),n=Qn(),r=e(n,"Promise");return Zf=r,Zf}var Jf,f1;function oC(){if(f1)return Jf;f1=1;var e=is(),n=Qn(),r=e(n,"Set");return Jf=r,Jf}var eh,h1;function Vq(){if(h1)return eh;h1=1;var e=is(),n=Qn(),r=e(n,"WeakMap");return eh=r,eh}var th,p1;function lo(){if(p1)return th;p1=1;var e=Hq(),n=Iv(),r=Wq(),s=oC(),o=Vq(),l=rs(),u=KN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",m="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(r),b=u(s),S=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=h||s&&k(new s)!=f||o&&k(new o)!=m)&&(k=function(E){var C=l(E),I=C==p?E.constructor:void 0,M=I?u(I):"";if(M)switch(M){case x:return y;case N:return c;case _:return h;case b:return f;case S:return m}return C}),th=k,th}var nh,m1;function Gq(){if(m1)return nh;m1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s){var o=s.length,l=new s.constructor(o);return o&&typeof s[0]=="string"&&n.call(s,"index")&&(l.index=s.index,l.input=s.input),l}return nh=r,nh}var rh,g1;function aC(){if(g1)return rh;g1=1;var e=Qn(),n=e.Uint8Array;return rh=n,rh}var ih,v1;function Fv(){if(v1)return ih;v1=1;var e=aC();function n(r){var s=new r.constructor(r.byteLength);return new e(s).set(new e(r)),s}return ih=n,ih}var sh,y1;function Yq(){if(y1)return sh;y1=1;var e=Fv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return sh=n,sh}var oh,w1;function Kq(){if(w1)return oh;w1=1;var e=/\w*$/;function n(r){var s=new r.constructor(r.source,e.exec(r));return s.lastIndex=r.lastIndex,s}return oh=n,oh}var ah,x1;function Xq(){if(x1)return ah;x1=1;var e=oo(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function s(o){return r?Object(r.call(o)):{}}return ah=s,ah}var lh,_1;function lC(){if(_1)return lh;_1=1;var e=Fv();function n(r,s){var o=s?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return lh=n,lh}var uh,b1;function Qq(){if(b1)return uh;b1=1;var e=Fv(),n=Yq(),r=Kq(),s=Xq(),o=lC(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object Symbol]",x="[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]",M="[object Uint16Array]",O="[object Uint32Array]";function W(q,P,L){var U=q.constructor;switch(P){case x:return e(q);case l:case u:return new U(+q);case N:return n(q,L);case _:case b:case S:case k:case E:case C:case I:case M:case O:return o(q,L);case c:return new U;case p:case m:return new U(q);case h:return r(q);case f:return new U;case y:return s(q)}}return uh=W,uh}var ch,S1;function uC(){if(S1)return ch;S1=1;var e=Nn(),n=Object.create,r=(function(){function s(){}return function(o){if(!e(o))return{};if(n)return n(o);s.prototype=o;var l=new s;return s.prototype=void 0,l}})();return ch=r,ch}var dh,k1;function cC(){if(k1)return dh;k1=1;var e=uC(),n=Eu(),r=ku();function s(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return dh=s,dh}var fh,E1;function Zq(){if(E1)return fh;E1=1;var e=lo(),n=fr(),r="[object Map]";function s(o){return n(o)&&e(o)==r}return fh=s,fh}var hh,N1;function Jq(){if(N1)return hh;N1=1;var e=Zq(),n=Su(),r=qv(),s=r&&r.isMap,o=s?n(s):e;return hh=o,hh}var ph,C1;function eL(){if(C1)return ph;C1=1;var e=lo(),n=fr(),r="[object Set]";function s(o){return n(o)&&e(o)==r}return ph=s,ph}var mh,T1;function tL(){if(T1)return mh;T1=1;var e=eL(),n=Su(),r=qv(),s=r&&r.isSet,o=s?n(s):e;return mh=o,mh}var gh,R1;function dC(){if(R1)return gh;R1=1;var e=wu(),n=Pv(),r=_u(),s=Lq(),o=Fq(),l=JN(),u=eC(),c=zq(),p=Bq(),h=sC(),f=Uq(),m=lo(),y=Gq(),x=Qq(),N=cC(),_=_t(),b=ao(),S=Jq(),k=Nn(),E=tL(),C=gi(),I=ss(),M=1,O=2,W=4,q="[object Arguments]",P="[object Array]",L="[object Boolean]",U="[object Date]",B="[object Error]",j="[object Function]",Q="[object GeneratorFunction]",H="[object Map]",te="[object Number]",Z="[object Object]",D="[object RegExp]",X="[object Set]",R="[object String]",$="[object Symbol]",V="[object WeakMap]",F="[object ArrayBuffer]",J="[object DataView]",ne="[object Float32Array]",le="[object Float64Array]",de="[object Int8Array]",me="[object Int16Array]",ve="[object Int32Array]",Pe="[object Uint8Array]",Me="[object Uint8ClampedArray]",Oe="[object Uint16Array]",ye="[object Uint32Array]",Se={};Se[q]=Se[P]=Se[F]=Se[J]=Se[L]=Se[U]=Se[ne]=Se[le]=Se[de]=Se[me]=Se[ve]=Se[H]=Se[te]=Se[Z]=Se[D]=Se[X]=Se[R]=Se[$]=Se[Pe]=Se[Me]=Se[Oe]=Se[ye]=!0,Se[B]=Se[j]=Se[V]=!1;function Ke(xe,ge,Fe,pt,mt,Ze){var De,Qe=ge&M,at=ge&O,It=ge&W;if(Fe&&(De=mt?Fe(xe,pt,mt,Ze):Fe(xe)),De!==void 0)return De;if(!k(xe))return xe;var it=_(xe);if(it){if(De=y(xe),!Qe)return u(xe,De)}else{var gt=m(xe),Kt=gt==j||gt==Q;if(b(xe))return l(xe,Qe);if(gt==Z||gt==q||Kt&&!mt){if(De=at||Kt?{}:N(xe),!Qe)return at?p(xe,o(De,xe)):c(xe,s(De,xe))}else{if(!Se[gt])return mt?xe:{};De=x(xe,gt,Qe)}}Ze||(Ze=new e);var Mt=Ze.get(xe);if(Mt)return Mt;Ze.set(xe,De),E(xe)?xe.forEach(function(dt){De.add(Ke(dt,ge,Fe,dt,xe,Ze))}):S(xe)&&xe.forEach(function(dt,lt){De.set(lt,Ke(dt,ge,Fe,lt,xe,Ze))});var Ye=It?at?f:h:at?I:C,Nt=it?void 0:Ye(xe);return n(Nt||xe,function(dt,lt){Nt&&(lt=dt,dt=xe[lt]),r(De,lt,Ke(dt,ge,Fe,lt,xe,Ze))}),De}return gh=Ke,gh}var vh,j1;function nL(){if(j1)return vh;j1=1;var e=dC(),n=4;function r(s){return e(s,n)}return vh=r,vh}var yh,A1;function zv(){if(A1)return yh;A1=1;function e(n){return function(){return n}}return yh=e,yh}var wh,I1;function rL(){if(I1)return wh;I1=1;function e(n){return function(r,s,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var h=c[n?p:++l];if(s(u[h],h,u)===!1)break}return r}}return wh=e,wh}var xh,M1;function Bv(){if(M1)return xh;M1=1;var e=rL(),n=e();return xh=n,xh}var _h,P1;function Uv(){if(P1)return _h;P1=1;var e=Bv(),n=gi();function r(s,o){return s&&e(s,o,n)}return _h=r,_h}var bh,O1;function iL(){if(O1)return bh;O1=1;var e=Or();function n(r,s){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=s?u:-1,p=Object(o);(s?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return bh=n,bh}var Sh,q1;function Nu(){if(q1)return Sh;q1=1;var e=Uv(),n=iL(),r=n(e);return Sh=r,Sh}var kh,L1;function os(){if(L1)return kh;L1=1;function e(n){return n}return kh=e,kh}var Eh,$1;function fC(){if($1)return Eh;$1=1;var e=os();function n(r){return typeof r=="function"?r:e}return Eh=n,Eh}var Nh,D1;function hC(){if(D1)return Nh;D1=1;var e=Pv(),n=Nu(),r=fC(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u))}return Nh=o,Nh}var Ch,F1;function pC(){return F1||(F1=1,Ch=hC()),Ch}var Th,z1;function sL(){if(z1)return Th;z1=1;var e=Nu();function n(r,s){var o=[];return e(r,function(l,u,c){s(l,u,c)&&o.push(l)}),o}return Th=n,Th}var Rh,B1;function oL(){if(B1)return Rh;B1=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return Rh=n,Rh}var jh,U1;function aL(){if(U1)return jh;U1=1;function e(n){return this.__data__.has(n)}return jh=e,jh}var Ah,H1;function mC(){if(H1)return Ah;H1=1;var e=Mv(),n=oL(),r=aL();function s(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return s.prototype.add=s.prototype.push=n,s.prototype.has=r,Ah=s,Ah}var Ih,W1;function lL(){if(W1)return Ih;W1=1;function e(n,r){for(var s=-1,o=n==null?0:n.length;++s<o;)if(r(n[s],s,n))return!0;return!1}return Ih=e,Ih}var Mh,V1;function gC(){if(V1)return Mh;V1=1;function e(n,r){return n.has(r)}return Mh=e,Mh}var Ph,G1;function vC(){if(G1)return Ph;G1=1;var e=mC(),n=lL(),r=gC(),s=1,o=2;function l(u,c,p,h,f,m){var y=p&s,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=m.get(u),b=m.get(c);if(_&&b)return _==c&&b==u;var S=-1,k=!0,E=p&o?new e:void 0;for(m.set(u,c),m.set(c,u);++S<x;){var C=u[S],I=c[S];if(h)var M=y?h(I,C,S,c,u,m):h(C,I,S,u,c,m);if(M!==void 0){if(M)continue;k=!1;break}if(E){if(!n(c,function(O,W){if(!r(E,W)&&(C===O||f(C,O,p,h,m)))return E.push(W)})){k=!1;break}}else if(!(C===I||f(C,I,p,h,m))){k=!1;break}}return m.delete(u),m.delete(c),k}return Ph=l,Ph}var Oh,Y1;function uL(){if(Y1)return Oh;Y1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o,l){s[++r]=[l,o]}),s}return Oh=e,Oh}var qh,K1;function Hv(){if(K1)return qh;K1=1;function e(n){var r=-1,s=Array(n.size);return n.forEach(function(o){s[++r]=o}),s}return qh=e,qh}var Lh,X1;function cL(){if(X1)return Lh;X1=1;var e=oo(),n=aC(),r=so(),s=vC(),o=uL(),l=Hv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",m="[object Map]",y="[object Number]",x="[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(M,O,W,q,P,L,U){switch(W){case k:if(M.byteLength!=O.byteLength||M.byteOffset!=O.byteOffset)return!1;M=M.buffer,O=O.buffer;case S:return!(M.byteLength!=O.byteLength||!L(new n(M),new n(O)));case p:case h:case y:return r(+M,+O);case f:return M.name==O.name&&M.message==O.message;case x:case _:return M==O+"";case m:var B=o;case N:var j=q&u;if(B||(B=l),M.size!=O.size&&!j)return!1;var Q=U.get(M);if(Q)return Q==O;q|=c,U.set(M,O);var H=s(B(M),B(O),q,P,L,U);return U.delete(M),H;case b:if(C)return C.call(M)==C.call(O)}return!1}return Lh=I,Lh}var $h,Q1;function dL(){if(Q1)return $h;Q1=1;var e=sC(),n=1,r=Object.prototype,s=r.hasOwnProperty;function o(l,u,c,p,h,f){var m=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!m)return!1;for(var b=x;b--;){var S=y[b];if(!(m?S in u:s.call(u,S)))return!1}var k=f.get(l),E=f.get(u);if(k&&E)return k==u&&E==l;var C=!0;f.set(l,u),f.set(u,l);for(var I=m;++b<x;){S=y[b];var M=l[S],O=u[S];if(p)var W=m?p(O,M,S,u,l,f):p(M,O,S,l,u,f);if(!(W===void 0?M===O||h(M,O,c,p,f):W)){C=!1;break}I||(I=S=="constructor")}if(C&&!I){var q=l.constructor,P=u.constructor;q!=P&&"constructor"in l&&"constructor"in u&&!(typeof q=="function"&&q instanceof q&&typeof P=="function"&&P instanceof P)&&(C=!1)}return f.delete(l),f.delete(u),C}return $h=o,$h}var Dh,Z1;function fL(){if(Z1)return Dh;Z1=1;var e=wu(),n=vC(),r=cL(),s=dL(),o=lo(),l=_t(),u=ao(),c=ka(),p=1,h="[object Arguments]",f="[object Array]",m="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,b,S,k,E,C){var I=l(_),M=l(b),O=I?f:o(_),W=M?f:o(b);O=O==h?m:O,W=W==h?m:W;var q=O==m,P=W==m,L=O==W;if(L&&u(_)){if(!u(b))return!1;I=!0,q=!1}if(L&&!q)return C||(C=new e),I||c(_)?n(_,b,S,k,E,C):r(_,b,O,S,k,E,C);if(!(S&p)){var U=q&&x.call(_,"__wrapped__"),B=P&&x.call(b,"__wrapped__");if(U||B){var j=U?_.value():_,Q=B?b.value():b;return C||(C=new e),E(j,Q,S,k,C)}}return L?(C||(C=new e),s(_,b,S,k,E,C)):!1}return Dh=N,Dh}var Fh,J1;function yC(){if(J1)return Fh;J1=1;var e=fL(),n=fr();function r(s,o,l,u,c){return s===o?!0:s==null||o==null||!n(s)&&!n(o)?s!==s&&o!==o:e(s,o,l,u,r,c)}return Fh=r,Fh}var zh,eb;function hL(){if(eb)return zh;eb=1;var e=wu(),n=yC(),r=1,s=2;function o(l,u,c,p){var h=c.length,f=h,m=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++h<f;){y=c[h];var x=y[0],N=l[x],_=y[1];if(m&&y[2]){if(N===void 0&&!(x in l))return!1}else{var b=new e;if(p)var S=p(N,_,x,l,u,b);if(!(S===void 0?n(_,N,r|s,p,b):S))return!1}}return!0}return zh=o,zh}var Bh,tb;function wC(){if(tb)return Bh;tb=1;var e=Nn();function n(r){return r===r&&!e(r)}return Bh=n,Bh}var Uh,nb;function pL(){if(nb)return Uh;nb=1;var e=wC(),n=gi();function r(s){for(var o=n(s),l=o.length;l--;){var u=o[l],c=s[u];o[l]=[u,c,e(c)]}return o}return Uh=r,Uh}var Hh,rb;function xC(){if(rb)return Hh;rb=1;function e(n,r){return function(s){return s==null?!1:s[n]===r&&(r!==void 0||n in Object(s))}}return Hh=e,Hh}var Wh,ib;function mL(){if(ib)return Wh;ib=1;var e=hL(),n=pL(),r=xC();function s(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 Wh=s,Wh}var Vh,sb;function uo(){if(sb)return Vh;sb=1;var e=rs(),n=fr(),r="[object Symbol]";function s(o){return typeof o=="symbol"||n(o)&&e(o)==r}return Vh=s,Vh}var Gh,ob;function Wv(){if(ob)return Gh;ob=1;var e=_t(),n=uo(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\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:s.test(l)||!r.test(l)||u!=null&&l in Object(u)}return Gh=o,Gh}var Yh,ab;function gL(){if(ab)return Yh;ab=1;var e=Mv(),n="Expected a function";function r(s,o){if(typeof s!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=s.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(r.Cache||e),l}return r.Cache=e,Yh=r,Yh}var Kh,lb;function vL(){if(lb)return Kh;lb=1;var e=gL(),n=500;function r(s){var o=e(s,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Kh=r,Kh}var Xh,ub;function yL(){if(ub)return Xh;ub=1;var e=vL(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,s=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(r,"$1"):c||u)}),l});return Xh=s,Xh}var Qh,cb;function Cu(){if(cb)return Qh;cb=1;function e(n,r){for(var s=-1,o=n==null?0:n.length,l=Array(o);++s<o;)l[s]=r(n[s],s,n);return l}return Qh=e,Qh}var Zh,db;function wL(){if(db)return Zh;db=1;var e=oo(),n=Cu(),r=_t(),s=uo(),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(s(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Zh=u,Zh}var Jh,fb;function _C(){if(fb)return Jh;fb=1;var e=wL();function n(r){return r==null?"":e(r)}return Jh=n,Jh}var ep,hb;function Tu(){if(hb)return ep;hb=1;var e=_t(),n=Wv(),r=yL(),s=_C();function o(l,u){return e(l)?l:n(l,u)?[l]:r(s(l))}return ep=o,ep}var tp,pb;function Ea(){if(pb)return tp;pb=1;var e=uo();function n(r){if(typeof r=="string"||e(r))return r;var s=r+"";return s=="0"&&1/r==-1/0?"-0":s}return tp=n,tp}var np,mb;function Ru(){if(mb)return np;mb=1;var e=Tu(),n=Ea();function r(s,o){o=e(o,s);for(var l=0,u=o.length;s!=null&&l<u;)s=s[n(o[l++])];return l&&l==u?s:void 0}return np=r,np}var rp,gb;function xL(){if(gb)return rp;gb=1;var e=Ru();function n(r,s,o){var l=r==null?void 0:e(r,s);return l===void 0?o:l}return rp=n,rp}var ip,vb;function _L(){if(vb)return ip;vb=1;function e(n,r){return n!=null&&r in Object(n)}return ip=e,ip}var sp,yb;function bC(){if(yb)return sp;yb=1;var e=Tu(),n=Sa(),r=_t(),s=bu(),o=Ov(),l=Ea();function u(c,p,h){p=e(p,c);for(var f=-1,m=p.length,y=!1;++f<m;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=m?y:(m=c==null?0:c.length,!!m&&o(m)&&s(x,m)&&(r(c)||n(c)))}return sp=u,sp}var op,wb;function SC(){if(wb)return op;wb=1;var e=_L(),n=bC();function r(s,o){return s!=null&&n(s,o,e)}return op=r,op}var ap,xb;function bL(){if(xb)return ap;xb=1;var e=yC(),n=xL(),r=SC(),s=Wv(),o=wC(),l=xC(),u=Ea(),c=1,p=2;function h(f,m){return s(f)&&o(m)?l(u(f),m):function(y){var x=n(y,f);return x===void 0&&x===m?r(y,f):e(m,x,c|p)}}return ap=h,ap}var lp,_b;function kC(){if(_b)return lp;_b=1;function e(n){return function(r){return r==null?void 0:r[n]}}return lp=e,lp}var up,bb;function SL(){if(bb)return up;bb=1;var e=Ru();function n(r){return function(s){return e(s,r)}}return up=n,up}var cp,Sb;function kL(){if(Sb)return cp;Sb=1;var e=kC(),n=SL(),r=Wv(),s=Ea();function o(l){return r(l)?e(s(l)):n(l)}return cp=o,cp}var dp,kb;function qr(){if(kb)return dp;kb=1;var e=mL(),n=bL(),r=os(),s=_t(),o=kL();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?s(u)?n(u[0],u[1]):e(u):o(u)}return dp=l,dp}var fp,Eb;function EC(){if(Eb)return fp;Eb=1;var e=tC(),n=sL(),r=qr(),s=_t();function o(l,u){var c=s(l)?e:n;return c(l,r(u,3))}return fp=o,fp}var hp,Nb;function EL(){if(Nb)return hp;Nb=1;var e=Object.prototype,n=e.hasOwnProperty;function r(s,o){return s!=null&&n.call(s,o)}return hp=r,hp}var pp,Cb;function NC(){if(Cb)return pp;Cb=1;var e=EL(),n=bC();function r(s,o){return s!=null&&n(s,o,e)}return pp=r,pp}var mp,Tb;function NL(){if(Tb)return mp;Tb=1;var e=Lv(),n=lo(),r=Sa(),s=_t(),o=Or(),l=ao(),u=ku(),c=ka(),p="[object Map]",h="[object Set]",f=Object.prototype,m=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(s(x)||typeof x=="string"||typeof x.splice=="function"||l(x)||c(x)||r(x)))return!x.length;var N=n(x);if(N==p||N==h)return!x.size;if(u(x))return!e(x).length;for(var _ in x)if(m.call(x,_))return!1;return!0}return mp=y,mp}var gp,Rb;function CC(){if(Rb)return gp;Rb=1;function e(n){return n===void 0}return gp=e,gp}var vp,jb;function TC(){if(jb)return vp;jb=1;var e=Nu(),n=Or();function r(s,o){var l=-1,u=n(s)?Array(s.length):[];return e(s,function(c,p,h){u[++l]=o(c,p,h)}),u}return vp=r,vp}var yp,Ab;function RC(){if(Ab)return yp;Ab=1;var e=Cu(),n=qr(),r=TC(),s=_t();function o(l,u){var c=s(l)?e:r;return c(l,n(u,3))}return yp=o,yp}var wp,Ib;function CL(){if(Ib)return wp;Ib=1;function e(n,r,s,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(s=n[++l]);++l<u;)s=r(s,n[l],l,n);return s}return wp=e,wp}var xp,Mb;function TL(){if(Mb)return xp;Mb=1;function e(n,r,s,o,l){return l(n,function(u,c,p){s=o?(o=!1,u):r(s,u,c,p)}),s}return xp=e,xp}var _p,Pb;function jC(){if(Pb)return _p;Pb=1;var e=CL(),n=Nu(),r=qr(),s=TL(),o=_t();function l(u,c,p){var h=o(u)?e:s,f=arguments.length<3;return h(u,r(c,4),p,f,n)}return _p=l,_p}var bp,Ob;function RL(){if(Ob)return bp;Ob=1;var e=rs(),n=_t(),r=fr(),s="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==s}return bp=o,bp}var Sp,qb;function jL(){if(qb)return Sp;qb=1;var e=kC(),n=e("length");return Sp=n,Sp}var kp,Lb;function AL(){if(Lb)return kp;Lb=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return kp=p,kp}var Ep,$b;function IL(){if($b)return Ep;$b=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",o=n+r+s,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+l+"]?",b="(?:"+x+"(?:"+[f,m,y].join("|")+")"+_+N+")*",S=_+N+b,k="(?:"+[f+c+"?",c,m,y,u].join("|")+")",E=RegExp(p+"(?="+p+")|"+k+S,"g");function C(I){for(var M=E.lastIndex=0;E.test(I);)++M;return M}return Ep=C,Ep}var Np,Db;function ML(){if(Db)return Np;Db=1;var e=jL(),n=AL(),r=IL();function s(o){return n(o)?r(o):e(o)}return Np=s,Np}var Cp,Fb;function PL(){if(Fb)return Cp;Fb=1;var e=Lv(),n=lo(),r=Or(),s=RL(),o=ML(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return s(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return Cp=c,Cp}var Tp,zb;function OL(){if(zb)return Tp;zb=1;var e=Pv(),n=uC(),r=Uv(),s=qr(),o=Eu(),l=_t(),u=ao(),c=_a(),p=Nn(),h=ka();function f(m,y,x){var N=l(m),_=N||u(m)||h(m);if(y=s(y,4),x==null){var b=m&&m.constructor;_?x=N?new b:[]:p(m)?x=c(b)?n(o(m)):{}:x={}}return(_?e:r)(m,function(S,k,E){return y(x,S,k,E)}),x}return Tp=f,Tp}var Rp,Bb;function qL(){if(Bb)return Rp;Bb=1;var e=oo(),n=Sa(),r=_t(),s=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(s&&l&&l[s])}return Rp=o,Rp}var jp,Ub;function Vv(){if(Ub)return jp;Ub=1;var e=Dv(),n=qL();function r(s,o,l,u,c){var p=-1,h=s.length;for(l||(l=n),c||(c=[]);++p<h;){var f=s[p];o>0&&l(f)?o>1?r(f,o-1,l,u,c):e(c,f):u||(c[c.length]=f)}return c}return jp=r,jp}var Ap,Hb;function LL(){if(Hb)return Ap;Hb=1;function e(n,r,s){switch(s.length){case 0:return n.call(r);case 1:return n.call(r,s[0]);case 2:return n.call(r,s[0],s[1]);case 3:return n.call(r,s[0],s[1],s[2])}return n.apply(r,s)}return Ap=e,Ap}var Ip,Wb;function AC(){if(Wb)return Ip;Wb=1;var e=LL(),n=Math.max;function r(s,o,l){return o=n(o===void 0?s.length-1:o,0),function(){for(var u=arguments,c=-1,p=n(u.length-o,0),h=Array(p);++c<p;)h[c]=u[o+c];c=-1;for(var f=Array(o+1);++c<o;)f[c]=u[c];return f[o]=l(h),e(s,this,f)}}return Ip=r,Ip}var Mp,Vb;function $L(){if(Vb)return Mp;Vb=1;var e=zv(),n=XN(),r=os(),s=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return Mp=s,Mp}var Pp,Gb;function DL(){if(Gb)return Pp;Gb=1;var e=800,n=16,r=Date.now;function s(o){var l=0,u=0;return function(){var c=r(),p=n-(c-u);if(u=c,p>0){if(++l>=e)return arguments[0]}else l=0;return o.apply(void 0,arguments)}}return Pp=s,Pp}var Op,Yb;function IC(){if(Yb)return Op;Yb=1;var e=$L(),n=DL(),r=n(e);return Op=r,Op}var qp,Kb;function ju(){if(Kb)return qp;Kb=1;var e=os(),n=AC(),r=IC();function s(o,l){return r(n(o,l,e),o+"")}return qp=s,qp}var Lp,Xb;function MC(){if(Xb)return Lp;Xb=1;function e(n,r,s,o){for(var l=n.length,u=s+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return Lp=e,Lp}var $p,Qb;function FL(){if(Qb)return $p;Qb=1;function e(n){return n!==n}return $p=e,$p}var Dp,Zb;function zL(){if(Zb)return Dp;Zb=1;function e(n,r,s){for(var o=s-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return Dp=e,Dp}var Fp,Jb;function BL(){if(Jb)return Fp;Jb=1;var e=MC(),n=FL(),r=zL();function s(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return Fp=s,Fp}var zp,eS;function UL(){if(eS)return zp;eS=1;var e=BL();function n(r,s){var o=r==null?0:r.length;return!!o&&e(r,s,0)>-1}return zp=n,zp}var Bp,tS;function HL(){if(tS)return Bp;tS=1;function e(n,r,s){for(var o=-1,l=n==null?0:n.length;++o<l;)if(s(r,n[o]))return!0;return!1}return Bp=e,Bp}var Up,nS;function WL(){if(nS)return Up;nS=1;function e(){}return Up=e,Up}var Hp,rS;function VL(){if(rS)return Hp;rS=1;var e=oC(),n=WL(),r=Hv(),s=1/0,o=e&&1/r(new e([,-0]))[1]==s?function(l){return new e(l)}:n;return Hp=o,Hp}var Wp,iS;function GL(){if(iS)return Wp;iS=1;var e=mC(),n=UL(),r=HL(),s=gC(),o=VL(),l=Hv(),u=200;function c(p,h,f){var m=-1,y=n,x=p.length,N=!0,_=[],b=_;if(f)N=!1,y=r;else if(x>=u){var S=h?null:o(p);if(S)return l(S);N=!1,y=s,b=new e}else b=h?[]:_;e:for(;++m<x;){var k=p[m],E=h?h(k):k;if(k=f||k!==0?k:0,N&&E===E){for(var C=b.length;C--;)if(b[C]===E)continue e;h&&b.push(E),_.push(k)}else y(b,E,f)||(b!==_&&b.push(E),_.push(k))}return _}return Wp=c,Wp}var Vp,sS;function PC(){if(sS)return Vp;sS=1;var e=Or(),n=fr();function r(s){return n(s)&&e(s)}return Vp=r,Vp}var Gp,oS;function YL(){if(oS)return Gp;oS=1;var e=Vv(),n=ju(),r=GL(),s=PC(),o=n(function(l){return r(e(l,1,s,!0))});return Gp=o,Gp}var Yp,aS;function KL(){if(aS)return Yp;aS=1;var e=Cu();function n(r,s){return e(s,function(o){return r[o]})}return Yp=n,Yp}var Kp,lS;function OC(){if(lS)return Kp;lS=1;var e=KL(),n=gi();function r(s){return s==null?[]:e(s,n(s))}return Kp=r,Kp}var Xp,uS;function Cn(){if(uS)return Xp;uS=1;var e;if(typeof Av=="function")try{e={clone:nL(),constant:zv(),each:pC(),filter:EC(),has:NC(),isArray:_t(),isEmpty:NL(),isFunction:_a(),isUndefined:CC(),keys:gi(),map:RC(),reduce:jC(),size:PL(),transform:OL(),union:YL(),values:OC()}}catch{}return e||(e=window._),Xp=e,Xp}var Qp,cS;function Gv(){if(cS)return Qp;cS=1;var e=Cn();Qp=o;var n="\0",r="\0",s="";function o(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.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(f){return this._label=f,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return e.keys(this._nodes)},o.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._in[m])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(m){return e.isEmpty(f._out[m])})},o.prototype.setNodes=function(f,m){var y=arguments,x=this;return e.each(f,function(N){y.length>1?x.setNode(N,m):x.setNode(N)}),this},o.prototype.setNode=function(f,m){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=m),this):(this._nodes[f]=arguments.length>1?m:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=r,this._children[f]={},this._children[r][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},o.prototype.node=function(f){return this._nodes[f]},o.prototype.hasNode=function(f){return e.has(this._nodes,f)},o.prototype.removeNode=function(f){var m=this;if(e.has(this._nodes,f)){var y=function(x){m.removeEdge(m._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){m.setParent(x)}),delete this._children[f]),e.each(e.keys(this._in[f]),y),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),y),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},o.prototype.setParent=function(f,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===f)throw new Error("Setting "+m+" as parent of "+f+" would create a cycle");this.setNode(m)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=m,this._children[m][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var m=this._parent[f];if(m!==r)return m}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=r),this._isCompound){var m=this._children[f];if(m)return e.keys(m)}else{if(f===r)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var m=this._preds[f];if(m)return e.keys(m)},o.prototype.successors=function(f){var m=this._sucs[f];if(m)return e.keys(m)},o.prototype.neighbors=function(f){var m=this.predecessors(f);if(m)return e.union(m,this.successors(f))},o.prototype.isLeaf=function(f){var m;return this.isDirected()?m=this.successors(f):m=this.neighbors(f),m.length===0},o.prototype.filterNodes=function(f){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){f(b)&&m.setNode(b,_)}),e.each(this._edgeObjs,function(_){m.hasNode(_.v)&&m.hasNode(_.w)&&m.setEdge(_,y.edge(_))});var x={};function N(_){var b=y.parent(_);return b===void 0||m.hasNode(b)?(x[_]=b,b):b in x?x[b]:N(b)}return this._isCompound&&e.each(m.nodes(),function(_){m.setParent(_,N(_))}),m},o.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return e.values(this._edgeObjs)},o.prototype.setPath=function(f,m){var y=this,x=arguments;return e.reduce(f,function(N,_){return x.length>1?y.setEdge(N,_,m):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var f,m,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,m=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(f=_,m=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),f=""+f,m=""+m,e.isUndefined(y)||(y=""+y);var b=c(this._isDirected,f,m,y);if(e.has(this._edgeLabels,b))return N&&(this._edgeLabels[b]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(m),this._edgeLabels[b]=N?x:this._defaultEdgeLabelFn(f,m,y);var S=p(this._isDirected,f,m,y);return f=S.v,m=S.w,Object.freeze(S),this._edgeObjs[b]=S,l(this._preds[m],f),l(this._sucs[f],m),this._in[m][b]=S,this._out[f][b]=S,this._edgeCount++,this},o.prototype.edge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,m,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,m,y),N=this._edgeObjs[x];return N&&(f=N.v,m=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[m],f),u(this._sucs[f],m),delete this._in[m][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,m){var y=this._in[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.v===m}):x}},o.prototype.outEdges=function(f,m){var y=this._out[f];if(y){var x=e.values(y);return m?e.filter(x,function(N){return N.w===m}):x}},o.prototype.nodeEdges=function(f,m){var y=this.inEdges(f,m);if(y)return y.concat(this.outEdges(f,m))};function l(f,m){f[m]?f[m]++:f[m]=1}function u(f,m){--f[m]||delete f[m]}function c(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var b=N;N=_,_=b}return N+s+_+s+(e.isUndefined(x)?n:x)}function p(f,m,y,x){var N=""+m,_=""+y;if(!f&&N>_){var b=N;N=_,_=b}var S={v:N,w:_};return x&&(S.name=x),S}function h(f,m){return c(f,m.v,m.w,m.name)}return Qp}var Zp,dS;function XL(){return dS||(dS=1,Zp="2.1.8"),Zp}var Jp,fS;function QL(){return fS||(fS=1,Jp={Graph:Gv(),version:XL()}),Jp}var em,hS;function ZL(){if(hS)return em;hS=1;var e=Cn(),n=Gv();em={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:s(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function s(u){return e.map(u.nodes(),function(c){var p=u.node(c),h=u.parent(c),f={v:c};return e.isUndefined(p)||(f.value=p),e.isUndefined(h)||(f.parent=h),f})}function o(u){return e.map(u.edges(),function(c){var p=u.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(p)||(h.value=p),h})}function l(u){var c=new n(u.options).setGraph(u.value);return e.each(u.nodes,function(p){c.setNode(p.v,p.value),p.parent&&c.setParent(p.v,p.parent)}),e.each(u.edges,function(p){c.setEdge({v:p.v,w:p.w,name:p.name},p.value)}),c}return em}var tm,pS;function JL(){if(pS)return tm;pS=1;var e=Cn();tm=n;function n(r){var s={},o=[],l;function u(c){e.has(s,c)||(s[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 tm}var nm,mS;function qC(){if(mS)return nm;mS=1;var e=Cn();nm=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 s=this._keyIndices[r];if(s!==void 0)return this._arr[s].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,s){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:s}),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,s){var o=this._keyIndices[r];if(s>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+s);this._arr[o].priority=s,this._decrease(o)},n.prototype._heapify=function(r){var s=this._arr,o=2*r,l=o+1,u=r;o<s.length&&(u=s[o].priority<s[u].priority?o:u,l<s.length&&(u=s[l].priority<s[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var s=this._arr,o=s[r].priority,l;r!==0&&(l=r>>1,!(s[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,s){var o=this._arr,l=this._keyIndices,u=o[r],c=o[s];o[r]=c,o[s]=u,l[c.key]=r,l[u.key]=s},nm}var rm,gS;function LC(){if(gS)return rm;gS=1;var e=Cn(),n=qC();rm=s;var r=e.constant(1);function s(l,u,c,p){return o(l,String(u),c||r,p||function(h){return l.outEdges(h)})}function o(l,u,c,p){var h={},f=new n,m,y,x=function(N){var _=N.v!==m?N.v:N.w,b=h[_],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,f.decrease(_,k))};for(l.nodes().forEach(function(N){var _=N===u?0:Number.POSITIVE_INFINITY;h[N]={distance:_},f.add(N,_)});f.size()>0&&(m=f.removeMin(),y=h[m],y.distance!==Number.POSITIVE_INFINITY);)p(m).forEach(x);return h}return rm}var im,vS;function e$(){if(vS)return im;vS=1;var e=LC(),n=Cn();im=r;function r(s,o,l){return n.transform(s.nodes(),function(u,c){u[c]=e(s,c,o,l)},{})}return im}var sm,yS;function $C(){if(yS)return sm;yS=1;var e=Cn();sm=n;function n(r){var s=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:s,index:s++};if(o.push(p),r.successors(p).forEach(function(y){e.has(l,y)?l[y].onStack&&(h.lowlink=Math.min(h.lowlink,l[y].index)):(c(y),h.lowlink=Math.min(h.lowlink,l[y].lowlink))}),h.lowlink===h.index){var f=[],m;do m=o.pop(),l[m].onStack=!1,f.push(m);while(p!==m);u.push(f)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return sm}var om,wS;function t$(){if(wS)return om;wS=1;var e=Cn(),n=$C();om=r;function r(s){return e.filter(n(s),function(o){return o.length>1||o.length===1&&s.hasEdge(o[0],o[0])})}return om}var am,xS;function n$(){if(xS)return am;xS=1;var e=Cn();am=r;var n=e.constant(1);function r(o,l,u){return s(o,l||n,u||function(c){return o.outEdges(c)})}function s(o,l,u){var c={},p=o.nodes();return p.forEach(function(h){c[h]={},c[h][h]={distance:0},p.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),u(h).forEach(function(f){var m=f.v===h?f.w:f.v,y=l(f);c[h][m]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(m){var y=c[m];p.forEach(function(x){var N=y[h],_=f[x],b=y[x],S=N.distance+_.distance;S<b.distance&&(b.distance=S,b.predecessor=_.predecessor)})})}),c}return am}var lm,_S;function DC(){if(_S)return lm;_S=1;var e=Cn();lm=n,n.CycleException=r;function n(s){var o={},l={},u=[];function c(p){if(e.has(l,p))throw new r;e.has(o,p)||(l[p]=!0,o[p]=!0,e.each(s.predecessors(p),c),delete l[p],u.push(p))}if(e.each(s.sinks(),c),e.size(o)!==s.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,lm}var um,bS;function r$(){if(bS)return um;bS=1;var e=DC();um=n;function n(r){try{e(r)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return um}var cm,SS;function FC(){if(SS)return cm;SS=1;var e=Cn();cm=n;function n(s,o,l){e.isArray(o)||(o=[o]);var u=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],p={};return e.each(o,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);r(s,h,l==="post",p,u,c)}),c}function r(s,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){r(s,h,l,u,c,p)}),l&&p.push(o))}return cm}var dm,kS;function i$(){if(kS)return dm;kS=1;var e=FC();dm=n;function n(r,s){return e(r,s,"post")}return dm}var fm,ES;function s$(){if(ES)return fm;ES=1;var e=FC();fm=n;function n(r,s){return e(r,s,"pre")}return fm}var hm,NS;function o$(){if(NS)return hm;NS=1;var e=Cn(),n=Gv(),r=qC();hm=s;function s(o,l){var u=new n,c={},p=new r,h;function f(y){var x=y.v===h?y.w:y.v,N=p.priority(x);if(N!==void 0){var _=l(y);_<N&&(c[x]=h,p.decrease(x,_))}}if(o.nodeCount()===0)return u;e.each(o.nodes(),function(y){p.add(y,Number.POSITIVE_INFINITY),u.setNode(y)}),p.decrease(o.nodes()[0],0);for(var m=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(m)throw new Error("Input graph is not connected: "+o);m=!0}o.nodeEdges(h).forEach(f)}return u}return hm}var pm,CS;function a$(){return CS||(CS=1,pm={components:JL(),dijkstra:LC(),dijkstraAll:e$(),findCycles:t$(),floydWarshall:n$(),isAcyclic:r$(),postorder:i$(),preorder:s$(),prim:o$(),tarjan:$C(),topsort:DC()}),pm}var mm,TS;function l$(){if(TS)return mm;TS=1;var e=QL();return mm={Graph:e.Graph,json:ZL(),alg:a$(),version:e.version},mm}var gm,RS;function Kn(){if(RS)return gm;RS=1;var e;if(typeof Av=="function")try{e=l$()}catch{}return e||(e=window.graphlib),gm=e,gm}var vm,jS;function u$(){if(jS)return vm;jS=1;var e=dC(),n=1,r=4;function s(o){return e(o,n|r)}return vm=s,vm}var ym,AS;function Au(){if(AS)return ym;AS=1;var e=so(),n=Or(),r=bu(),s=Nn();function o(l,u,c){if(!s(c))return!1;var p=typeof u;return(p=="number"?n(c)&&r(u,c.length):p=="string"&&u in c)?e(c[u],l):!1}return ym=o,ym}var wm,IS;function c$(){if(IS)return wm;IS=1;var e=ju(),n=so(),r=Au(),s=ss(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,m=f>2?p[2]:void 0;for(m&&r(p[0],p[1],m)&&(f=1);++h<f;)for(var y=p[h],x=s(y),N=-1,_=x.length;++N<_;){var b=x[N],S=c[b];(S===void 0||n(S,o[b])&&!l.call(c,b))&&(c[b]=y[b])}return c});return wm=u,wm}var xm,MS;function d$(){if(MS)return xm;MS=1;var e=qr(),n=Or(),r=gi();function s(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=r(l),u=function(m){return h(p[m],m,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return xm=s,xm}var _m,PS;function f$(){if(PS)return _m;PS=1;var e=/\s/;function n(r){for(var s=r.length;s--&&e.test(r.charAt(s)););return s}return _m=n,_m}var bm,OS;function h$(){if(OS)return bm;OS=1;var e=f$(),n=/^\s+/;function r(s){return s&&s.slice(0,e(s)+1).replace(n,"")}return bm=r,bm}var Sm,qS;function p$(){if(qS)return Sm;qS=1;var e=h$(),n=Nn(),r=uo(),s=NaN,o=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,u=/^0o[0-7]+$/i,c=parseInt;function p(h){if(typeof h=="number")return h;if(r(h))return s;if(n(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=n(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var m=l.test(h);return m||u.test(h)?c(h.slice(2),m?2:8):o.test(h)?s:+h}return Sm=p,Sm}var km,LS;function zC(){if(LS)return km;LS=1;var e=p$(),n=1/0,r=17976931348623157e292;function s(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=s,km}var Em,$S;function m$(){if($S)return Em;$S=1;var e=zC();function n(r){var s=e(r),o=s%1;return s===s?o?s-o:s:0}return Em=n,Em}var Nm,DS;function g$(){if(DS)return Nm;DS=1;var e=MC(),n=qr(),r=m$(),s=Math.max;function o(l,u,c){var p=l==null?0:l.length;if(!p)return-1;var h=c==null?0:r(c);return h<0&&(h=s(p+h,0)),e(l,n(u,3),h)}return Nm=o,Nm}var Cm,FS;function v$(){if(FS)return Cm;FS=1;var e=d$(),n=g$(),r=e(n);return Cm=r,Cm}var Tm,zS;function BC(){if(zS)return Tm;zS=1;var e=Vv();function n(r){var s=r==null?0:r.length;return s?e(r,1):[]}return Tm=n,Tm}var Rm,BS;function y$(){if(BS)return Rm;BS=1;var e=Bv(),n=fC(),r=ss();function s(o,l){return o==null?o:e(o,n(l),r)}return Rm=s,Rm}var jm,US;function w$(){if(US)return jm;US=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return jm=e,jm}var Am,HS;function x$(){if(HS)return Am;HS=1;var e=xu(),n=Uv(),r=qr();function s(o,l){var u={};return l=r(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return Am=s,Am}var Im,WS;function Yv(){if(WS)return Im;WS=1;var e=uo();function n(r,s,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=s(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return Im=n,Im}var Mm,VS;function _$(){if(VS)return Mm;VS=1;function e(n,r){return n>r}return Mm=e,Mm}var Pm,GS;function b$(){if(GS)return Pm;GS=1;var e=Yv(),n=_$(),r=os();function s(o){return o&&o.length?e(o,r,n):void 0}return Pm=s,Pm}var Om,YS;function UC(){if(YS)return Om;YS=1;var e=xu(),n=so();function r(s,o,l){(l!==void 0&&!n(s[o],l)||l===void 0&&!(o in s))&&e(s,o,l)}return Om=r,Om}var qm,KS;function S$(){if(KS)return qm;KS=1;var e=rs(),n=Eu(),r=fr(),s="[object Object]",o=Function.prototype,l=Object.prototype,u=o.toString,c=l.hasOwnProperty,p=u.call(Object);function h(f){if(!r(f)||e(f)!=s)return!1;var m=n(f);if(m===null)return!0;var y=c.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return qm=h,qm}var Lm,XS;function HC(){if(XS)return Lm;XS=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Lm=e,Lm}var $m,QS;function k$(){if(QS)return $m;QS=1;var e=ba(),n=ss();function r(s){return e(s,n(s))}return $m=r,$m}var Dm,ZS;function E$(){if(ZS)return Dm;ZS=1;var e=UC(),n=JN(),r=lC(),s=eC(),o=cC(),l=Sa(),u=_t(),c=PC(),p=ao(),h=_a(),f=Nn(),m=S$(),y=ka(),x=HC(),N=k$();function _(b,S,k,E,C,I,M){var O=x(b,k),W=x(S,k),q=M.get(W);if(q){e(b,k,q);return}var P=I?I(O,W,k+"",b,S,M):void 0,L=P===void 0;if(L){var U=u(W),B=!U&&p(W),j=!U&&!B&&y(W);P=W,U||B||j?u(O)?P=O:c(O)?P=s(O):B?(L=!1,P=n(W,!0)):j?(L=!1,P=r(W,!0)):P=[]:m(W)||l(W)?(P=O,l(O)?P=N(O):(!f(O)||h(O))&&(P=o(W))):L=!1}L&&(M.set(W,P),C(P,W,E,I,M),M.delete(W)),e(b,k,P)}return Dm=_,Dm}var Fm,JS;function N$(){if(JS)return Fm;JS=1;var e=wu(),n=UC(),r=Bv(),s=E$(),o=Nn(),l=ss(),u=HC();function c(p,h,f,m,y){p!==h&&r(h,function(x,N){if(y||(y=new e),o(x))s(p,h,N,f,c,m,y);else{var _=m?m(u(p,N),x,N+"",p,h,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return Fm=c,Fm}var zm,ek;function C$(){if(ek)return zm;ek=1;var e=ju(),n=Au();function r(s){return e(function(o,l){var u=-1,c=l.length,p=c>1?l[c-1]:void 0,h=c>2?l[2]:void 0;for(p=s.length>3&&typeof p=="function"?(c--,p):void 0,h&&n(l[0],l[1],h)&&(p=c<3?void 0:p,c=1),o=Object(o);++u<c;){var f=l[u];f&&s(o,f,u,p)}return o})}return zm=r,zm}var Bm,tk;function T$(){if(tk)return Bm;tk=1;var e=N$(),n=C$(),r=n(function(s,o,l){e(s,o,l)});return Bm=r,Bm}var Um,nk;function WC(){if(nk)return Um;nk=1;function e(n,r){return n<r}return Um=e,Um}var Hm,rk;function R$(){if(rk)return Hm;rk=1;var e=Yv(),n=WC(),r=os();function s(o){return o&&o.length?e(o,r,n):void 0}return Hm=s,Hm}var Wm,ik;function j$(){if(ik)return Wm;ik=1;var e=Yv(),n=qr(),r=WC();function s(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return Wm=s,Wm}var Vm,sk;function A$(){if(sk)return Vm;sk=1;var e=Qn(),n=function(){return e.Date.now()};return Vm=n,Vm}var Gm,ok;function I$(){if(ok)return Gm;ok=1;var e=_u(),n=Tu(),r=bu(),s=Nn(),o=Ea();function l(u,c,p,h){if(!s(u))return u;c=n(c,u);for(var f=-1,m=c.length,y=m-1,x=u;x!=null&&++f<m;){var N=o(c[f]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(f!=y){var b=x[N];_=h?h(b,N,x):void 0,_===void 0&&(_=s(b)?b:r(c[f+1])?[]:{})}e(x,N,_),x=x[N]}return u}return Gm=l,Gm}var Ym,ak;function M$(){if(ak)return Ym;ak=1;var e=Ru(),n=I$(),r=Tu();function s(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],m=e(o,f);u(m,f)&&n(h,r(f,o),m)}return h}return Ym=s,Ym}var Km,lk;function P$(){if(lk)return Km;lk=1;var e=M$(),n=SC();function r(s,o){return e(s,o,function(l,u){return n(s,u)})}return Km=r,Km}var Xm,uk;function O$(){if(uk)return Xm;uk=1;var e=BC(),n=AC(),r=IC();function s(o){return r(n(o,void 0,e),o+"")}return Xm=s,Xm}var Qm,ck;function q$(){if(ck)return Qm;ck=1;var e=P$(),n=O$(),r=n(function(s,o){return s==null?{}:e(s,o)});return Qm=r,Qm}var Zm,dk;function L$(){if(dk)return Zm;dk=1;var e=Math.ceil,n=Math.max;function r(s,o,l,u){for(var c=-1,p=n(e((o-s)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=s,s+=l;return h}return Zm=r,Zm}var Jm,fk;function $$(){if(fk)return Jm;fk=1;var e=L$(),n=Au(),r=zC();function s(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 Jm=s,Jm}var eg,hk;function D$(){if(hk)return eg;hk=1;var e=$$(),n=e();return eg=n,eg}var tg,pk;function F$(){if(pk)return tg;pk=1;function e(n,r){var s=n.length;for(n.sort(r);s--;)n[s]=n[s].value;return n}return tg=e,tg}var ng,mk;function z$(){if(mk)return ng;mk=1;var e=uo();function n(r,s){if(r!==s){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=s!==void 0,h=s===null,f=s===s,m=e(s);if(!h&&!m&&!c&&r>s||c&&p&&f&&!h&&!m||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!m&&r<s||m&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return ng=n,ng}var rg,gk;function B$(){if(gk)return rg;gk=1;var e=z$();function n(r,s,o){for(var l=-1,u=r.criteria,c=s.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var m=o[l];return f*(m=="desc"?-1:1)}}return r.index-s.index}return rg=n,rg}var ig,vk;function U$(){if(vk)return ig;vk=1;var e=Cu(),n=Ru(),r=qr(),s=TC(),o=F$(),l=Su(),u=B$(),c=os(),p=_t();function h(f,m,y){m.length?m=e(m,function(_){return p(_)?function(b){return n(b,_.length===1?_[0]:_)}:_}):m=[c];var x=-1;m=e(m,l(r));var N=s(f,function(_,b,S){var k=e(m,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,b){return u(_,b,y)})}return ig=h,ig}var sg,yk;function H$(){if(yk)return sg;yk=1;var e=Vv(),n=U$(),r=ju(),s=Au(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&s(l,u[0],u[1])?u=[]:c>2&&s(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return sg=o,sg}var og,wk;function W$(){if(wk)return og;wk=1;var e=_C(),n=0;function r(s){var o=++n;return e(s)+o}return og=r,og}var ag,xk;function V$(){if(xk)return ag;xk=1;function e(n,r,s){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;s(c,n[o],p)}return c}return ag=e,ag}var lg,_k;function G$(){if(_k)return lg;_k=1;var e=_u(),n=V$();function r(s,o){return n(s||[],o||[],e)}return lg=r,lg}var ug,bk;function ot(){if(bk)return ug;bk=1;var e;if(typeof Av=="function")try{e={cloneDeep:u$(),constant:zv(),defaults:c$(),each:pC(),filter:EC(),find:v$(),flatten:BC(),forEach:hC(),forIn:y$(),has:NC(),isUndefined:CC(),last:w$(),map:RC(),mapValues:x$(),max:b$(),merge:T$(),min:R$(),minBy:j$(),now:A$(),pick:q$(),range:D$(),reduce:jC(),sortBy:H$(),uniqueId:W$(),values:OC(),zipObject:G$()}}catch{}return e||(e=window._),ug=e,ug}var cg,Sk;function Y$(){if(Sk)return cg;Sk=1,cg=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,o=s._prev;if(o!==s)return n(o),o},e.prototype.enqueue=function(s){var o=this._sentinel;s._prev&&s._next&&n(s),s._next=o._next,o._next._prev=s,o._next=s,s._prev=o},e.prototype.toString=function(){for(var s=[],o=this._sentinel,l=o._prev;l!==o;)s.push(JSON.stringify(l,r)),l=l._prev;return"["+s.join(", ")+"]"};function n(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function r(s,o){if(s!=="_next"&&s!=="_prev")return o}return cg}var dg,kk;function K$(){if(kk)return dg;kk=1;var e=ot(),n=Kn().Graph,r=Y$();dg=o;var s=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var m=c(h,f||s),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,m){for(var y=[],x=f[f.length-1],N=f[0],_;h.nodeCount();){for(;_=N.dequeue();)u(h,f,m,_);for(;_=x.dequeue();)u(h,f,m,_);if(h.nodeCount()){for(var b=f.length-2;b>0;--b)if(_=f[b].dequeue(),_){y=y.concat(u(h,f,m,_,!0));break}}}return y}function u(h,f,m,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var b=h.edge(_),S=h.node(_.v);x&&N.push({v:_.v,w:_.w}),S.out-=b,p(f,m,S)}),e.forEach(h.outEdges(y.v),function(_){var b=h.edge(_),S=_.w,k=h.node(S);k.in-=b,p(f,m,k)}),h.removeNode(y.v),N}function c(h,f){var m=new n,y=0,x=0;e.forEach(h.nodes(),function(b){m.setNode(b,{v:b,in:0,out:0})}),e.forEach(h.edges(),function(b){var S=m.edge(b.v,b.w)||0,k=f(b),E=S+k;m.setEdge(b.v,b.w,E),x=Math.max(x,m.node(b.v).out+=k),y=Math.max(y,m.node(b.w).in+=k)});var N=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(m.nodes(),function(b){p(N,_,m.node(b))}),{graph:m,buckets:N,zeroIdx:_}}function p(h,f,m){m.out?m.in?h[m.out-m.in+f].enqueue(m):h[h.length-1].enqueue(m):h[0].enqueue(m)}return dg}var fg,Ek;function X$(){if(Ek)return fg;Ek=1;var e=ot(),n=K$();fg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):s(l);e.forEach(u,function(p){var h=l.edge(p);l.removeEdge(p),h.forwardName=p.name,h.reversed=!0,l.setEdge(p.w,p.v,h,e.uniqueId("rev"))});function c(p){return function(h){return p.edge(h).weight}}}function s(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(m){e.has(c,m.w)?u.push(m):h(m.w)}),delete c[f])}return e.forEach(l.nodes(),h),u}function o(l){e.forEach(l.edges(),function(u){var c=l.edge(u);if(c.reversed){l.removeEdge(u);var p=c.forwardName;delete c.reversed,delete c.forwardName,l.setEdge(u.w,u.v,c,p)}})}return fg}var hg,Nk;function on(){if(Nk)return hg;Nk=1;var e=ot(),n=Kn().Graph;hg={addDummyNode:r,simplify:s,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:m,maxRank:y,partition:x,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 s(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,M=b.width/2,O=b.height/2;if(!C&&!I)throw new Error("Not possible to find intersection inside of the rectangle");var W,q;return Math.abs(I)*M>Math.abs(C)*O?(I<0&&(O=-O),W=O*C/I,q=O):(C<0&&(M=-M),W=M,q=M*I/C),{x:k+W,y:E+q}}function p(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 h(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 f(b){var S=e.min(e.map(b.nodes(),function(I){return b.node(I).rank})),k=[];e.forEach(b.nodes(),function(I){var M=b.node(I).rank-S;k[M]||(k[M]=[]),k[M].push(I)});var E=0,C=b.graph().nodeRankFactor;e.forEach(k,function(I,M){e.isUndefined(I)&&M%C!==0?--E:E&&e.forEach(I,function(O){b.node(O).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 x(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 hg}var pg,Ck;function Q$(){if(Ck)return pg;Ck=1;var e=ot(),n=on();pg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){s(l,u)})}function s(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,m=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var N,_,b;for(b=0,++p;p<f;++b,++p)y.points=[],_={width:0,height:0,edgeLabel:y,edgeObj:u,rank:p},N=n.addDummyNode(l,"edge",_,"_d"),p===x&&(_.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,h,{weight:y.weight},m)}}function o(l){e.forEach(l.graph().dummyChains,function(u){var c=l.node(u),p=c.edgeLabel,h;for(l.setEdge(c.edgeObj,p);c.dummy;)h=l.successors(u)[0],l.removeNode(u),p.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(p.x=c.x,p.y=c.y,p.width=c.width,p.height=c.height),u=h,c=l.node(u)})}return pg}var mg,Tk;function ou(){if(Tk)return mg;Tk=1;var e=ot();mg={longestPath:n,slack:r};function n(s){var o={};function l(u){var c=s.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(s.outEdges(u),function(h){return l(h.w)-s.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(s.sources(),l)}function r(s,o){return s.node(o.w).rank-s.node(o.v).rank-s.edge(o).minlen}return mg}var gg,Rk;function VC(){if(Rk)return gg;Rk=1;var e=ot(),n=Kn().Graph,r=ou().slack;gg=s;function s(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var m,y;o(p,c)<f;)m=l(p,c),y=p.hasNode(m.v)?r(c,m):-r(c,m),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(m){var y=m.v,x=f===y?m.w:y;!c.hasNode(x)&&!r(p,m)&&(c.setNode(x,{}),c.setEdge(f,x,{}),h(x))})}return e.forEach(c.nodes(),h),c.nodeCount()}function l(c,p){return e.minBy(p.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return r(p,h)})}function u(c,p,h){e.forEach(c.nodes(),function(f){p.node(f).rank+=h})}return gg}var vg,jk;function Z$(){if(jk)return vg;jk=1;var e=ot(),n=VC(),r=ou().slack,s=ou().longestPath,o=Kn().alg.preorder,l=Kn().alg.postorder,u=on().simplify;vg=c,c.initLowLimValues=m,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),s(E);var C=n(E);m(C),p(C,E);for(var I,M;I=x(C);)M=N(C,E,I),_(C,E,I,M)}function p(E,C){var I=l(E,E.nodes());I=I.slice(0,I.length-1),e.forEach(I,function(M){h(E,C,M)})}function h(E,C,I){var M=E.node(I),O=M.parent;E.edge(I,O).cutvalue=f(E,C,I)}function f(E,C,I){var M=E.node(I),O=M.parent,W=!0,q=C.edge(I,O),P=0;return q||(W=!1,q=C.edge(O,I)),P=q.weight,e.forEach(C.nodeEdges(I),function(L){var U=L.v===I,B=U?L.w:L.v;if(B!==O){var j=U===W,Q=C.edge(L).weight;if(P+=j?Q:-Q,S(E,I,B)){var H=E.edge(I,B).cutvalue;P+=j?-H:H}}}),P}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,I,M,O){var W=I,q=E.node(M);return C[M]=!0,e.forEach(E.neighbors(M),function(P){e.has(C,P)||(I=y(E,C,I,P,M))}),q.low=W,q.lim=I++,O?q.parent=O:delete q.parent,I}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,I){var M=I.v,O=I.w;C.hasEdge(M,O)||(M=I.w,O=I.v);var W=E.node(M),q=E.node(O),P=W,L=!1;W.lim>q.lim&&(P=q,L=!0);var U=e.filter(C.edges(),function(B){return L===k(E,E.node(B.v),P)&&L!==k(E,E.node(B.w),P)});return e.minBy(U,function(B){return r(C,B)})}function _(E,C,I,M){var O=I.v,W=I.w;E.removeEdge(O,W),E.setEdge(M.v,M.w,{}),m(E),p(E,C),b(E,C)}function b(E,C){var I=e.find(E.nodes(),function(O){return!C.node(O).parent}),M=o(E,I);M=M.slice(1),e.forEach(M,function(O){var W=E.node(O).parent,q=C.edge(O,W),P=!1;q||(q=C.edge(W,O),P=!0),C.node(O).rank=C.node(W).rank+(P?q.minlen:-q.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 vg}var yg,Ak;function J$(){if(Ak)return yg;Ak=1;var e=ou(),n=e.longestPath,r=VC(),s=Z$();yg=o;function o(p){switch(p.graph().ranker){case"network-simplex":c(p);break;case"tight-tree":u(p);break;case"longest-path":l(p);break;default:c(p)}}var l=n;function u(p){n(p),r(p)}function c(p){s(p)}return yg}var wg,Ik;function e4(){if(Ik)return wg;Ik=1;var e=ot();wg=n;function n(o){var l=s(o);e.forEach(o.graph().dummyChains,function(u){for(var c=o.node(u),p=c.edgeObj,h=r(o,l,p.v,p.w),f=h.path,m=h.lca,y=0,x=f[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=f[y])!==m&&o.node(x).maxRank<c.rank;)y++;x===m&&(N=!1)}if(!N){for(;y<f.length-1&&o.node(x=f[y+1]).minRank<=c.rank;)y++;x=f[y]}o.setParent(u,x),u=o.successors(u)[0]}})}function r(o,l,u,c){var p=[],h=[],f=Math.min(l[u].low,l[c].low),m=Math.max(l[u].lim,l[c].lim),y,x;y=u;do y=o.parent(y),p.push(y);while(y&&(l[y].low>f||m>l[y].lim));for(x=y,y=c;(y=o.parent(y))!==x;)h.push(y);return{path:p.concat(h.reverse()),lca:x}}function s(o){var l={},u=0;function c(p){var h=u;e.forEach(o.children(p),c),l[p]={low:h,lim:u++}}return e.forEach(o.children(),c),l}return wg}var xg,Mk;function t4(){if(Mk)return xg;Mk=1;var e=ot(),n=on();xg={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,m=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=m});var y=l(c)+1;e.forEach(c.children(),function(x){s(c,p,m,y,f,h,x)}),c.graph().nodeRankFactor=m}function s(c,p,h,f,m,y,x){var N=c.children(x);if(!N.length){x!==p&&c.setEdge(p,x,{weight:0,minlen:h});return}var _=n.addBorderNode(c,"_bt"),b=n.addBorderNode(c,"_bb"),S=c.node(x);c.setParent(_,x),S.borderTop=_,c.setParent(b,x),S.borderBottom=b,e.forEach(N,function(k){s(c,p,h,f,m,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,I=E.borderBottom?E.borderBottom:k,M=E.borderTop?f:2*f,O=C!==I?1:m-y[x]+1;c.setEdge(_,C,{weight:M,minlen:O,nestingEdge:!0}),c.setEdge(I,b,{weight:M,minlen:O,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:m+y[x]})}function o(c){var p={};function h(f,m){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,m+1)}),p[f]=m}return e.forEach(c.children(),function(f){h(f,1)}),p}function l(c){return e.reduce(c.edges(),function(p,h){return p+c.edge(h).weight},0)}function u(c){var p=c.graph();c.removeNode(p.nestingRoot),delete p.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return xg}var _g,Pk;function n4(){if(Pk)return _g;Pk=1;var e=ot(),n=on();_g=r;function r(o){function l(u){var c=o.children(u),p=o.node(u);if(c.length&&e.forEach(c,l),e.has(p,"minRank")){p.borderLeft=[],p.borderRight=[];for(var h=p.minRank,f=p.maxRank+1;h<f;++h)s(o,"borderLeft","_bl",u,p,h),s(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function s(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},m=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),m&&o.setEdge(m,y,{weight:1})}return _g}var bg,Ok;function r4(){if(Ok)return bg;Ok=1;var e=ot();bg={adjust:n,undo:r};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function r(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){o(h.node(f))}),e.forEach(h.edges(),function(f){o(h.edge(f))})}function o(h){var f=h.width;h.width=h.height,h.height=f}function l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,u),e.has(m,"y")&&u(m)})}function u(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){p(h.node(f))}),e.forEach(h.edges(),function(f){var m=h.edge(f);e.forEach(m.points,p),e.has(m,"x")&&p(m)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return bg}var Sg,qk;function i4(){if(qk)return Sg;qk=1;var e=ot();Sg=n;function n(r){var s={},o=e.filter(r.nodes(),function(h){return!r.children(h).length}),l=e.max(e.map(o,function(h){return r.node(h).rank})),u=e.map(e.range(l+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=r.node(h);u[f.rank].push(h),e.forEach(r.successors(h),c)}}var p=e.sortBy(o,function(h){return r.node(h).rank});return e.forEach(p,c),u}return Sg}var kg,Lk;function s4(){if(Lk)return kg;Lk=1;var e=ot();kg=n;function n(s,o){for(var l=0,u=1;u<o.length;++u)l+=r(s,o[u-1],o[u]);return l}function r(s,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(s.outEdges(y),function(x){return{pos:u[x.w],weight:s.edge(x).weight}}),"pos")}),!0),p=1;p<l.length;)p<<=1;var h=2*p-1;p-=1;var f=e.map(new Array(h),function(){return 0}),m=0;return e.forEach(c.forEach(function(y){var x=y.pos+p;f[x]+=y.weight;for(var N=0;x>0;)x%2&&(N+=f[x+1]),x=x-1>>1,f[x]+=y.weight;m+=y.weight*N})),m}return kg}var Eg,$k;function o4(){if($k)return Eg;$k=1;var e=ot();Eg=n;function n(r,s){return e.map(s,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,p){var h=r.edge(p),f=r.node(p.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:o,barycenter:u.sum/u.weight,weight:u.weight}}else return{v:o}})}return Eg}var Ng,Dk;function a4(){if(Dk)return Ng;Dk=1;var e=ot();Ng=n;function n(o,l){var u={};e.forEach(o,function(p,h){var f=u[p.v]={indegree:0,in:[],out:[],vs:[p.v],i:h};e.isUndefined(p.barycenter)||(f.barycenter=p.barycenter,f.weight=p.weight)}),e.forEach(l.edges(),function(p){var h=u[p.v],f=u[p.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(u[p.w]))});var c=e.filter(u,function(p){return!p.indegree});return r(c)}function r(o){var l=[];function u(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&o.push(f)}}for(;o.length;){var p=o.pop();l.push(p),e.forEach(p.in.reverse(),u(p)),e.forEach(p.out,c(p))}return e.map(e.filter(l,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function s(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 Ng}var Cg,Fk;function l4(){if(Fk)return Cg;Fk=1;var e=ot(),n=on();Cg=r;function r(l,u){var c=n.partition(l,function(_){return e.has(_,"barycenter")}),p=c.lhs,h=e.sortBy(c.rhs,function(_){return-_.i}),f=[],m=0,y=0,x=0;p.sort(o(!!u)),x=s(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),m+=_.barycenter*_.weight,y+=_.weight,x=s(f,h,x)});var N={vs:e.flatten(f,!0)};return y&&(N.barycenter=m/y,N.weight=y),N}function s(l,u,c){for(var p;u.length&&(p=e.last(u)).i<=c;)u.pop(),l.push(p.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 Cg}var Tg,zk;function u4(){if(zk)return Tg;zk=1;var e=ot(),n=o4(),r=a4(),s=l4();Tg=o;function o(c,p,h,f){var m=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(m=e.filter(m,function(I){return I!==x&&I!==N}));var b=n(c,m);e.forEach(b,function(I){if(c.children(I.v).length){var M=o(c,I.v,h,f);_[I.v]=M,e.has(M,"barycenter")&&u(I,M)}});var S=r(b,h);l(S,_);var k=s(S,f);if(x&&(k.vs=e.flatten([x,k.vs,N],!0),c.predecessors(x).length)){var E=c.node(c.predecessors(x)[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,p){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return p[f]?p[f].vs:f}),!0)})}function u(c,p){e.isUndefined(c.barycenter)?(c.barycenter=p.barycenter,c.weight=p.weight):(c.barycenter=(c.barycenter*c.weight+p.barycenter*p.weight)/(c.weight+p.weight),c.weight+=p.weight)}return Tg}var Rg,Bk;function c4(){if(Bk)return Rg;Bk=1;var e=ot(),n=Kn().Graph;Rg=r;function r(o,l,u){var c=s(o),p=new n({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return o.node(h)});return e.forEach(o.nodes(),function(h){var f=o.node(h),m=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,m||c),e.forEach(o[u](h),function(y){var x=y.v===h?y.w:y.v,N=p.edge(x,h),_=e.isUndefined(N)?0:N.weight;p.setEdge(x,h,{weight:o.edge(y).weight+_})}),e.has(f,"minRank")&&p.setNode(h,{borderLeft:f.borderLeft[l],borderRight:f.borderRight[l]}))}),p}function s(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return Rg}var jg,Uk;function d4(){if(Uk)return jg;Uk=1;var e=ot();jg=n;function n(r,s,o){var l={},u;e.forEach(o,function(c){for(var p=r.parent(c),h,f;p;){if(h=r.parent(p),h?(f=l[h],l[h]=p):(f=u,u=p),f&&f!==p){s.setEdge(f,p);return}p=h}})}return jg}var Ag,Hk;function f4(){if(Hk)return Ag;Hk=1;var e=ot(),n=i4(),r=s4(),s=u4(),o=c4(),l=d4(),u=Kn().Graph,c=on();Ag=p;function p(y){var x=c.maxRank(y),N=h(y,e.range(1,x+1),"inEdges"),_=h(y,e.range(x-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){f(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 h(y,x,N){return e.map(x,function(_){return o(y,_,N)})}function f(y,x){var N=new u;e.forEach(y,function(_){var b=_.graph().root,S=s(_,b,N,x);e.forEach(S.vs,function(k,E){_.node(k).order=E}),l(_,N,S.vs)})}function m(y,x){e.forEach(x,function(N){e.forEach(N,function(_,b){y.node(_).order=b})})}return Ag}var Ig,Wk;function h4(){if(Wk)return Ig;Wk=1;var e=ot(),n=Kn().Graph,r=on();Ig={positionX:N,findType1Conflicts:s,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:m,balance:x};function s(S,k){var E={};function C(I,M){var O=0,W=0,q=I.length,P=e.last(M);return e.forEach(M,function(L,U){var B=l(S,L),j=B?S.node(B).order:q;(B||L===P)&&(e.forEach(M.slice(W,U+1),function(Q){e.forEach(S.predecessors(Q),function(H){var te=S.node(H),Z=te.order;(Z<O||j<Z)&&!(te.dummy&&S.node(Q).dummy)&&u(E,H,Q)})}),W=U+1,O=j)}),M}return e.reduce(k,C),E}function o(S,k){var E={};function C(M,O,W,q,P){var L;e.forEach(e.range(O,W),function(U){L=M[U],S.node(L).dummy&&e.forEach(S.predecessors(L),function(B){var j=S.node(B);j.dummy&&(j.order<q||j.order>P)&&u(E,B,L)})})}function I(M,O){var W=-1,q,P=0;return e.forEach(O,function(L,U){if(S.node(L).dummy==="border"){var B=S.predecessors(L);B.length&&(q=S.node(B[0]).order,C(O,P,U,W,q),P=U,W=q)}C(O,P,O.length,q,M.length)}),O}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 p(S,k,E,C){var I={},M={},O={};return e.forEach(k,function(W){e.forEach(W,function(q,P){I[q]=q,M[q]=q,O[q]=P})}),e.forEach(k,function(W){var q=-1;e.forEach(W,function(P){var L=C(P);if(L.length){L=e.sortBy(L,function(H){return O[H]});for(var U=(L.length-1)/2,B=Math.floor(U),j=Math.ceil(U);B<=j;++B){var Q=L[B];M[P]===P&&q<O[Q]&&!c(E,P,Q)&&(M[Q]=P,M[P]=I[P]=I[Q],q=O[Q])}}})}),{root:I,align:M}}function h(S,k,E,C,I){var M={},O=f(S,k,E,I),W=I?"borderLeft":"borderRight";function q(U,B){for(var j=O.nodes(),Q=j.pop(),H={};Q;)H[Q]?U(Q):(H[Q]=!0,j.push(Q),j=j.concat(B(Q))),Q=j.pop()}function P(U){M[U]=O.inEdges(U).reduce(function(B,j){return Math.max(B,M[j.v]+O.edge(j))},0)}function L(U){var B=O.outEdges(U).reduce(function(Q,H){return Math.min(Q,M[H.w]-O.edge(H))},Number.POSITIVE_INFINITY),j=S.node(U);B!==Number.POSITIVE_INFINITY&&j.borderType!==W&&(M[U]=Math.max(M[U],B))}return q(P,O.predecessors.bind(O)),q(L,O.successors.bind(O)),e.forEach(C,function(U){M[U]=M[E[U]]}),M}function f(S,k,E,C){var I=new n,M=S.graph(),O=_(M.nodesep,M.edgesep,C);return e.forEach(k,function(W){var q;e.forEach(W,function(P){var L=E[P];if(I.setNode(L),q){var U=E[q],B=I.edge(U,L);I.setEdge(U,L,Math.max(O(S,P,q),B||0))}q=P})}),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(M,O){var W=b(S,O)/2;C=Math.max(M+W,C),I=Math.min(M-W,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(M){e.forEach(["l","r"],function(O){var W=M+O,q=S[W],P;if(q!==k){var L=e.values(q);P=O==="l"?C-e.min(L):I-e.max(L),P&&(S[W]=e.mapValues(q,function(U){return U+P}))}})})}function x(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(s(S,k),o(S,k)),C={},I;e.forEach(["u","d"],function(O){I=O==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(W){W==="r"&&(I=e.map(I,function(U){return e.values(U).reverse()}));var q=(O==="u"?S.predecessors:S.successors).bind(S),P=p(S,I,E,q),L=h(S,I,P.root,P.align,W==="r");W==="r"&&(L=e.mapValues(L,function(U){return-U})),C[O+W]=L})});var M=m(S,C);return y(C,M),x(C,S.graph().align)}function _(S,k,E){return function(C,I,M){var O=C.node(I),W=C.node(M),q=0,P;if(q+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":P=-O.width/2;break;case"r":P=O.width/2;break}if(P&&(q+=E?P:-P),P=0,q+=(O.dummy?k:S)/2,q+=(W.dummy?k:S)/2,q+=W.width/2,e.has(W,"labelpos"))switch(W.labelpos.toLowerCase()){case"l":P=W.width/2;break;case"r":P=-W.width/2;break}return P&&(q+=E?P:-P),P=0,q}}function b(S,k){return S.node(k).width}return Ig}var Mg,Vk;function p4(){if(Vk)return Mg;Vk=1;var e=ot(),n=on(),r=h4().positionX;Mg=s;function s(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,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(m){return l.node(m).height}));e.forEach(h,function(m){l.node(m).y=p+f/2}),p+=f+c})}return Mg}var Pg,Gk;function m4(){if(Gk)return Pg;Gk=1;var e=ot(),n=X$(),r=Q$(),s=J$(),o=on().normalizeRanks,l=e4(),u=on().removeEmptyRanks,c=t4(),p=n4(),h=r4(),f=f4(),m=p4(),y=on(),x=Kn().Graph;Pg=N;function N(F,J){var ne=J&&J.debugTiming?y.time:y.notime;ne("layout",function(){var le=ne(" buildLayoutGraph",function(){return q(F)});ne(" runLayout",function(){_(le,ne)}),ne(" updateInputGraph",function(){b(F,le)})})}function _(F,J){J(" makeSpaceForEdgeLabels",function(){P(F)}),J(" removeSelfEdges",function(){D(F)}),J(" acyclic",function(){n.run(F)}),J(" nestingGraph.run",function(){c.run(F)}),J(" rank",function(){s(y.asNonCompoundGraph(F))}),J(" injectEdgeLabelProxies",function(){L(F)}),J(" removeEmptyRanks",function(){u(F)}),J(" nestingGraph.cleanup",function(){c.cleanup(F)}),J(" normalizeRanks",function(){o(F)}),J(" assignRankMinMax",function(){U(F)}),J(" removeEdgeLabelProxies",function(){B(F)}),J(" normalize.run",function(){r.run(F)}),J(" parentDummyChains",function(){l(F)}),J(" addBorderSegments",function(){p(F)}),J(" order",function(){f(F)}),J(" insertSelfEdges",function(){X(F)}),J(" adjustCoordinateSystem",function(){h.adjust(F)}),J(" position",function(){m(F)}),J(" positionSelfEdges",function(){R(F)}),J(" removeBorderNodes",function(){Z(F)}),J(" normalize.undo",function(){r.undo(F)}),J(" fixupEdgeLabelCoords",function(){H(F)}),J(" undoCoordinateSystem",function(){h.undo(F)}),J(" translateGraph",function(){j(F)}),J(" assignNodeIntersects",function(){Q(F)}),J(" reversePoints",function(){te(F)}),J(" acyclic.undo",function(){n.undo(F)})}function b(F,J){e.forEach(F.nodes(),function(ne){var le=F.node(ne),de=J.node(ne);le&&(le.x=de.x,le.y=de.y,J.children(ne).length&&(le.width=de.width,le.height=de.height))}),e.forEach(F.edges(),function(ne){var le=F.edge(ne),de=J.edge(ne);le.points=de.points,e.has(de,"x")&&(le.x=de.x,le.y=de.y)}),F.graph().width=J.graph().width,F.graph().height=J.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},M=["minlen","weight","width","height","labeloffset"],O={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},W=["labelpos"];function q(F){var J=new x({multigraph:!0,compound:!0}),ne=V(F.graph());return J.setGraph(e.merge({},k,$(ne,S),e.pick(ne,E))),e.forEach(F.nodes(),function(le){var de=V(F.node(le));J.setNode(le,e.defaults($(de,C),I)),J.setParent(le,F.parent(le))}),e.forEach(F.edges(),function(le){var de=V(F.edge(le));J.setEdge(le,e.merge({},O,$(de,M),e.pick(de,W)))}),J}function P(F){var J=F.graph();J.ranksep/=2,e.forEach(F.edges(),function(ne){var le=F.edge(ne);le.minlen*=2,le.labelpos.toLowerCase()!=="c"&&(J.rankdir==="TB"||J.rankdir==="BT"?le.width+=le.labeloffset:le.height+=le.labeloffset)})}function L(F){e.forEach(F.edges(),function(J){var ne=F.edge(J);if(ne.width&&ne.height){var le=F.node(J.v),de=F.node(J.w),me={rank:(de.rank-le.rank)/2+le.rank,e:J};y.addDummyNode(F,"edge-proxy",me,"_ep")}})}function U(F){var J=0;e.forEach(F.nodes(),function(ne){var le=F.node(ne);le.borderTop&&(le.minRank=F.node(le.borderTop).rank,le.maxRank=F.node(le.borderBottom).rank,J=e.max(J,le.maxRank))}),F.graph().maxRank=J}function B(F){e.forEach(F.nodes(),function(J){var ne=F.node(J);ne.dummy==="edge-proxy"&&(F.edge(ne.e).labelRank=ne.rank,F.removeNode(J))})}function j(F){var J=Number.POSITIVE_INFINITY,ne=0,le=Number.POSITIVE_INFINITY,de=0,me=F.graph(),ve=me.marginx||0,Pe=me.marginy||0;function Me(Oe){var ye=Oe.x,Se=Oe.y,Ke=Oe.width,xe=Oe.height;J=Math.min(J,ye-Ke/2),ne=Math.max(ne,ye+Ke/2),le=Math.min(le,Se-xe/2),de=Math.max(de,Se+xe/2)}e.forEach(F.nodes(),function(Oe){Me(F.node(Oe))}),e.forEach(F.edges(),function(Oe){var ye=F.edge(Oe);e.has(ye,"x")&&Me(ye)}),J-=ve,le-=Pe,e.forEach(F.nodes(),function(Oe){var ye=F.node(Oe);ye.x-=J,ye.y-=le}),e.forEach(F.edges(),function(Oe){var ye=F.edge(Oe);e.forEach(ye.points,function(Se){Se.x-=J,Se.y-=le}),e.has(ye,"x")&&(ye.x-=J),e.has(ye,"y")&&(ye.y-=le)}),me.width=ne-J+ve,me.height=de-le+Pe}function Q(F){e.forEach(F.edges(),function(J){var ne=F.edge(J),le=F.node(J.v),de=F.node(J.w),me,ve;ne.points?(me=ne.points[0],ve=ne.points[ne.points.length-1]):(ne.points=[],me=de,ve=le),ne.points.unshift(y.intersectRect(le,me)),ne.points.push(y.intersectRect(de,ve))})}function H(F){e.forEach(F.edges(),function(J){var ne=F.edge(J);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 te(F){e.forEach(F.edges(),function(J){var ne=F.edge(J);ne.reversed&&ne.points.reverse()})}function Z(F){e.forEach(F.nodes(),function(J){if(F.children(J).length){var ne=F.node(J),le=F.node(ne.borderTop),de=F.node(ne.borderBottom),me=F.node(e.last(ne.borderLeft)),ve=F.node(e.last(ne.borderRight));ne.width=Math.abs(ve.x-me.x),ne.height=Math.abs(de.y-le.y),ne.x=me.x+ne.width/2,ne.y=le.y+ne.height/2}}),e.forEach(F.nodes(),function(J){F.node(J).dummy==="border"&&F.removeNode(J)})}function D(F){e.forEach(F.edges(),function(J){if(J.v===J.w){var ne=F.node(J.v);ne.selfEdges||(ne.selfEdges=[]),ne.selfEdges.push({e:J,label:F.edge(J)}),F.removeEdge(J)}})}function X(F){var J=y.buildLayerMatrix(F);e.forEach(J,function(ne){var le=0;e.forEach(ne,function(de,me){var ve=F.node(de);ve.order=me+le,e.forEach(ve.selfEdges,function(Pe){y.addDummyNode(F,"selfedge",{width:Pe.label.width,height:Pe.label.height,rank:ve.rank,order:me+ ++le,e:Pe.e,label:Pe.label},"_se")}),delete ve.selfEdges})})}function R(F){e.forEach(F.nodes(),function(J){var ne=F.node(J);if(ne.dummy==="selfedge"){var le=F.node(ne.e.v),de=le.x+le.width/2,me=le.y,ve=ne.x-de,Pe=le.height/2;F.setEdge(ne.e,ne.label),F.removeNode(J),ne.label.points=[{x:de+2*ve/3,y:me-Pe},{x:de+5*ve/6,y:me-Pe},{x:de+ve,y:me},{x:de+5*ve/6,y:me+Pe},{x:de+2*ve/3,y:me+Pe}],ne.label.x=ne.x,ne.label.y=ne.y}})}function $(F,J){return e.mapValues(e.pick(F,J),Number)}function V(F){var J={};return e.forEach(F,function(ne,le){J[le.toLowerCase()]=ne}),J}return Pg}var Og,Yk;function g4(){if(Yk)return Og;Yk=1;var e=ot(),n=on(),r=Kn().Graph;Og={debugOrdering:s};function s(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,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,m){return u.setEdge(f,m,{style:"invis"}),m})}),u}return Og}var qg,Kk;function v4(){return Kk||(Kk=1,qg="0.8.5"),qg}var Lg,Xk;function y4(){return Xk||(Xk=1,Lg={graphlib:Kn(),layout:m4(),debug:g4(),util:{time:on().time,notime:on().notime},version:v4()}),Lg}var w4=y4();const Qk=cv(w4),ro=240,au=130,Zs=74,Iu=72,Zk=Zs+Iu;function x4(e,n){var s;let r=ro;for(const o of e)r=Math.max(r,((s=n.get(o.id))==null?void 0:s.width)??ro);return r}const GC=420,_4=2;function ha(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function b4(e,n){return((n==null?void 0:n.get(e))??0)>0?GC:0}function S4(e,n){const r=(n==null?void 0:n.get(e))??0;return r>0?6+r*36:0}function pa(e,n,r){const s=n.get(e);return{w:((s==null?void 0:s.width)??ro)+b4(e,r),h:Math.max((s==null?void 0:s.height)??au,S4(e,r))}}function k4(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function E4(e,n,r,s,o,l){const u=new Qk.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)),p=new Set(c);for(const S of c){const{w:k,h:E}=pa(S,s,l);u.setNode(S,{width:k,height:E})}for(const S of n)p.has(S.source)&&p.has(S.target)&&u.setEdge(S.source,S.target);Qk.layout(u);const h=new Map;let f=1/0,m=1/0,y=-1/0,x=-1/0;for(const S of c){const k=u.node(S);if(!k)continue;const E=s.get(S),C=(E==null?void 0:E.width)??ro,I=(E==null?void 0:E.height)??au,M=pa(S,s,l),O=k.x-M.w/2,W=k.y-M.h/2;h.set(S,{x:O,y:W}),O<f&&(f=O),W<m&&(m=W),O+C>y&&(y=O+C),W+I>x&&(x=W+I)}if(Number.isFinite(f)&&Number.isFinite(m))for(const[S,k]of h)h.set(S,{x:k.x-f,y:k.y-m});const N=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-m:0;let b=null;for(const S of e){const k=o.get(S);if(!k)continue;const E=s.get(S),C=(E==null?void 0:E.width)??ro,I=(E==null?void 0:E.height)??au;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:h,width:N,height:_,pinnedBox:b}}function N4(e,n,r={}){const s=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=ha(S),E=c.get(k);E?E.push(S.id):c.set(k,[S.id])}const h=Array.from(c.keys()).sort().map(S=>({sid:S,...E4(c.get(S),n,s,l,o,u)})),f=x4(e,l),m=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=S=>{const k=[[]];let E=0;for(const C of h)k.length<S&&E>0&&E+C.height>m&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+Zk;return k},x=S=>S.reduce((k,E)=>Math.max(k,E.width),0)+GC;let N=y(r.availableWidth?_4:1);N.length>1&&N.reduce((k,E)=>k+x(E),0)+f*(N.length-1)>(r.availableWidth??0)&&(N=y(1));const _=new Map;let b=0;for(const S of N){const k=x(S);let E=0;for(const{positions:C,height:I,pinnedBox:M}of S){for(const[W,q]of C)_.set(W,{x:q.x+b,y:q.y+E});let O=E+I;M&&M.maxY>O&&M.minX<b+k&&b<M.maxX&&(O=M.maxY),E=O+Zk}b+=k+f}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 C4(e,n,r,s,o){const u=Zs+Iu,c=60,p=x=>pa(x,s,o),h=new Map(e.map(x=>[x.id,ha(x)])),f=[],m=e.map(x=>({id:x.id,pos:r.get(x.id)??n.get(x.id)})).filter(x=>x.pos!=null).sort((x,N)=>x.pos.y-N.pos.y||x.pos.x-N.pos.x||x.id.localeCompare(N.id)),y=[];for(const{id:x,pos:N}of m){const{w:_,h:b}=p(x),S=h.get(x)??"_default";if(r.has(x)){f.push({x:N.x,y:N.y,w:_,h:b,sid:S});continue}let k=N.y;for(let E=0;E<f.length+1;E++){const C=f.find(I=>{const M=I.sid===S?24:c,O=I.sid===S?24:u;return N.x<I.x+I.w+M&&I.x<N.x+_+M&&k<I.y+I.h+O&&I.y<k+b+O});if(!C)break;k=C.y+C.h+(C.sid===S?24:u)}k!==N.y&&(n.set(x,{x:N.x,y:k}),y.push(x)),f.push({x:N.x,y:k,w:_,h:b,sid:S})}return y}function T4(e,n,r,s,o,l){const u=_=>pa(_,s,l),c=_=>r.get(_)??n.get(_),p=new Map;for(const _ of e){if(!c(_.id))continue;const b=ha(_),S=p.get(b);S?S.push(_):p.set(b,[_])}const h=new Set;for(const[_,b]of p)b.every(S=>o.has(S.id)&&!r.has(S.id))&&h.add(_);const f=new Map,m=[];for(const _ of e){const b=c(_.id);if(!b)continue;const{w:S,h:k}=u(_.id),E=ha(_);h.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):m.push({x:b.x,y:b.y,w:S,h:k})}if(f.size===0)return[];const y=Zs+Iu,x=(_,b,S,k)=>m.some(E=>_<E.x+E.w+Zs&&E.x<_+S+Zs&&b<E.y+E.h+y&&E.y<b+k+y),N=[];for(const _ of[...f.keys()].sort()){const b=f.get(_);let S=1/0,k=1/0,E=-1/0,C=-1/0;for(const L of b){const U=c(L.id),{w:B,h:j}=u(L.id);S=Math.min(S,U.x),k=Math.min(k,U.y),E=Math.max(E,U.x+B),C=Math.max(C,U.y+j)}const I=E-S,M=C-k,O=[...new Set(m.map(L=>Math.round(L.x)))].sort((L,U)=>L-U),W=O.length?O:[S],q=[0,...m.map(L=>L.y+L.h+y)].sort((L,U)=>L-U);let P=null;e:for(const L of W)for(const U of q){if(U>=k)break;if(!x(L,U,I,M)){P={x:L,y:U};break e}}if(P){const L=P.x-S,U=P.y-k;for(const B of b){const j=c(B.id);n.set(B.id,{x:j.x+L,y:j.y+U})}N.push(_)}for(const L of b){const U=c(L.id),{w:B,h:j}=u(L.id);m.push({x:U.x,y:U.y,w:B,h:j})}}return N}function R4(e,n,r,s,o,l=!1,u){const h=Zs+Iu+1,f=8,m=1.75,y=200,x=.7,N=.01,_=P=>pa(P,s,u),b=P=>r.get(P)??n.get(P),S=new Map;for(const P of e){if(!b(P.id))continue;const L=ha(P),U=S.get(L);U?U.push(P):S.set(L,[P])}const k=[],E=new Set,C=new Set,I=o.size===0;for(const P of[...S.keys()].sort()){const L=S.get(P);let U=1/0,B=1/0,j=-1/0,Q=-1/0,H=!1;for(const X of L){const R=b(X.id),{w:$,h:V}=_(X.id);U=Math.min(U,R.x),B=Math.min(B,R.y),j=Math.max(j,R.x+$),Q=Math.max(Q,R.y+V),r.has(X.id)&&(H=!0)}const te=j-U,Z=Q-B;C.add(P);const D=o.get(P);D&&(te>D.w+f||Z>D.h+f)&&E.add(P),o.set(P,{w:te,h:Z}),k.push({sid:P,members:L.map(X=>X.id),x:U,y:B,w:te,h:Z,anchored:H,mass:1})}for(const P of[...o.keys()])C.has(P)||o.delete(P);if(l||I)return[];let M=!1;for(let P=0;P<k.length&&!M;P++)for(let L=P+1;L<k.length;L++){const U=k[P],B=k[L];if(!(U.anchored&&B.anchored)&&Math.abs(U.x+U.w/2-(B.x+B.w/2))<(U.w+B.w)/2+61&&Math.abs(U.y+U.h/2-(B.y+B.h/2))<(U.h+B.h)/2+h){M=!0;break}}if(E.size===0&&!M)return[];if(E.size>0)for(const P of k)E.has(P.sid)&&(P.mass=8);else for(const P of k)P.mass=Math.max(1,P.w*P.h/(ro*au));const O=new Map(k.map(P=>[P.sid,P.x])),W=new Map(k.map(P=>[P.sid,P.y]));for(let P=0;P<y;P++){const L=new Map,U=new Map;let B=0;for(let j=0;j<k.length;j++)for(let Q=j+1;Q<k.length;Q++){const H=k[j],te=k[Q];if(H.anchored&&te.anchored)continue;const Z=H.x+H.w/2,D=H.y+H.h/2,X=te.x+te.w/2,R=te.y+te.h/2,$=(H.w+te.w)/2+61-Math.abs(Z-X),V=(H.h+te.h)/2+h-Math.abs(D-R);if($<=0||V<=0)continue;const F=(De,Qe)=>!De.anchored&&!(Qe<0&&De.x<=0),J=(De,Qe)=>!De.anchored&&!(Qe<0&&De.y<=0),ne=(De,Qe,at)=>{const It=De===Qe,it=It?H.sid<te.sid?-1:1:Math.sign(De-Qe);return at(H,it)||at(te,-it)?it:It&&(at(H,-it)||at(te,it))?-it:0},le=ne(Z,X,F),de=ne(D,R,J),me=le!==0,ve=de!==0;if(!me&&!ve)continue;const Pe=me&&(!ve||$*m<V),[Me,Oe,ye,Se]=Pe?[le,$,L,F]:[de,V,U,J],Ke=Se(H,Me),xe=Se(te,-Me),ge=H.mass,Fe=te.mass,pt=Ke?xe?Fe/(ge+Fe):1:0,mt=xe?Ke?ge/(ge+Fe):1:0,Ze=Oe*x;ye.set(H.sid,(ye.get(H.sid)??0)+Me*Ze*pt),ye.set(te.sid,(ye.get(te.sid)??0)-Me*Ze*mt),B+=Ze}for(const j of k)j.anchored||(j.x=Math.max(0,j.x+(L.get(j.sid)??0)),j.y=Math.max(0,j.y+(U.get(j.sid)??0)));if(B<N)break}const q=[];for(const P of k){const L=P.x-O.get(P.sid),U=P.y-W.get(P.sid);if(!(Math.abs(L)<1&&Math.abs(U)<1)){for(const B of P.members){if(r.has(B))continue;const j=n.get(B);j&&n.set(B,{x:j.x+L,y:j.y+U})}q.push(P.sid)}}return q}const j4=600;function av(e,n){return!(e.exitAt!=null&&n-e.exitAt>j4||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function A4(e,n){const r=new Set;for(const s of e.agents.values())av(s,n)&&r.add(s.id);return r}function I4(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 M4(e,n,r=0){if(!e)return!1;for(const s of n)if(I4(e,s,r))return!0;return!1}const YC="sessionGroup";function P4(e,n){var s;if(e.type===YC)return"transparent";const r=(s=e.data)==null?void 0:s.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const O4="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function q4(e){if(e.checkDisabled)return O4;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 L4(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 Zo(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function $4(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const D4={agent:oO,sessionGroup:yO},F4=420,Ul=18,z4=9e4,B4=200,U4=5*6e4,H4=6,W4=2*6e4,Kv="agent-dag.layout",Xv="agent-dag.viewport",KC="agent-dag.summariesDismissed",XC="agent-dag.sessionListOpen",QC="agent-dag.detailOpen",ZC="agent-dag.usagePanelOpen",Jk="agent-dag.accountsPanelOpen",eE="agent-dag.versionNoticeDismissed",V4=15*6e4,tE={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:"};function G4(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`}const nE="agent-dag.autoRestart",rE="agent-dag.bundleReloadedFor";function Y4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(XC)==="1"}catch{return!1}}function K4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(XC,e?"1":"0")}catch{}}function X4(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(QC)==="1"}catch{return!1}}function Q4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(QC,e?"1":"0")}catch{}}function Z4(){const e=GN(ZC);return e===null?!0:e==="1"}function J4(e){if(!(typeof window>"u"))try{window.localStorage.setItem(ZC,e?"1":"0")}catch{}}function e5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(KC);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 iE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(KC,JSON.stringify(r))}catch{}}function t5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Kv);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 $g(e,n){if(!(typeof window>"u"))try{const r={};for(const[s,o]of e)r[s]=o;for(const[s,o]of n)r[s]=o;window.localStorage.setItem(Kv,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function n5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Xv);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 r5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Xv,JSON.stringify(e))}catch{}}function sE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Kv)}catch{}try{window.localStorage.removeItem(Xv)}catch{}}}function i5(e,n){const r=e.agents.get(n);if(!r)return;const s=[];for(const f of e.agents.values())f.sessionId===n&&s.push(f);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:s.map(f=>({id:f.id,kind:f.kind,label:f.label,parentId:f.parentId,state:f.state,startedAt:f.startedAt,endedAt:f.endedAt,model:f.model,cwd:f.cwd,usage:f.usage,prompts:f.prompts,tools:f.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),p=document.createElement("a"),h=(r.label||"session").replace(/[^a-z0-9._-]/gi,"_");p.href=c,p.download=`agents-deck-${h}-${n.slice(0,8)}.json`,document.body.appendChild(p),p.click(),document.body.removeChild(p),setTimeout(()=>URL.revokeObjectURL(c),1e3)}const lv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},uv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},s5={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 JC(e){return e.startsWith("mcp__")?"mcp":s5[e]??"other"}function eT(e,n){var s,o,l;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(s=e.cwd)!=null&&s.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 o5(e,n){if(!n)return null;const r=new Set([n]);let s=n;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=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 a5(e,n,r,s,o,l,u,c,p,h,f,m,y,x,N,_,b,S){const k=[],E=[],C=new Set;if(l)for(const L of e.agents.values())eT(L,l)&&C.add(L.id);for(const L of e.agents.values()){if(!b.has(L.id))continue;const U=l?!C.has(L.id):!1,B=L.exitAt!=null,j=_!=null&&!_.has(L.id),Q=[U?"rf-dim":"",B?"rf-exiting":"",j?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,H=u.get(L.id);if(k.push({id:L.id,type:"agent",position:{x:0,y:0},data:{...L,now:n,dim:U,onOpenContext:S},className:Q,...H?{width:H.width,height:H.height}:null}),L.parentId&&b.has(L.parentId)){const te=Rv(L.sessionId),Z=L.state==="active"?`hsl(${te} 80% 72%)`:`hsl(${te} 50% 55%)`,D=l&&!C.has(L.id)&&!C.has(L.parentId),X=B,R=N.size>0&&(N.has(L.id)||N.has(L.parentId)),$=_!=null&&!_.has(L.id)&&!_.has(L.parentId),V=L.state==="active"?2:1.5,F=R?V+1.5:V,J=D||X?.2:$?.12:1,ne=[X?"rf-edge-exiting":"",R?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;E.push({id:`e:${L.parentId}->${L.id}`,source:L.parentId,target:L.id,animated:(L.state==="active"||R)&&!D&&!X,type:"smoothstep",style:{stroke:Z,strokeWidth:F,opacity:J,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:ne})}}const I=new Map;for(const L of e.agents.values())L.tools.length>0&&I.set(L.id,Math.min(4,L.tools.length));const M=`${y}#lanes:${k4(I)}`,O=k.filter(L=>!o.has(L.id)&&!m.has(L.id));if(O.length>0||M!==x.current){if(O.length>0){const L=N4(k,E,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:s,lanes:I});for(const U of L)m.has(U.id)||m.set(U.id,U.position);T4(k,m,o,u,new Set(O.map(U=>U.id)),I)}C4(k,m,o,u,I),x.current=M}const W=R4(k,m,o,u,c,!h||f,I);W.length>0&&p(W),wd(m,e.agents),wd(o,e.agents),wd(u,W3(e.agents.values()));const q=[];let P=!1;for(const L of k){let U=o.get(L.id)??m.get(L.id);U||(U={x:0,y:0},m.set(L.id,U),P=!0),q.push({...L,position:U})}return P&&(x.current=""),{nodes:q,edges:E}}function l5(){return g.jsx(Cv,{children:g.jsx(u5,{})})}function u5(){var Ii,yo,Mi,Pi;const e=wa(),n=A.useRef(tv()),[,r]=A.useState(0),s=A.useCallback(()=>r(K=>K+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((K,Y)=>{l(oe=>{if(!Y)return new Set([K]);const ue=new Set(oe);return ue.has(K)?ue.delete(K):ue.add(K),ue}),c(oe=>Y&&oe===K?oe:K)},[]),m=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[N,_]=A.useState(null),b=A.useCallback(K=>_(K),[]),[S,k]=A.useState(!1),E=A.useRef(e5()),[C,I]=A.useState(Y4);A.useEffect(()=>{K4(C)},[C]);const[M,O]=A.useState(X4);A.useEffect(()=>{Q4(M)},[M]);const[W,q]=A.useState(Z4);A.useEffect(()=>{J4(W)},[W]);const[P,L]=A.useState(()=>{try{const K=window.localStorage.getItem(Jk);return K===null?!0:K==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(Jk,P?"1":"0")}catch{}},[P]);const[U,B]=A.useState(null),[j,Q]=A.useState(!1),[H,te]=A.useState(0),[Z,D]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(K=>K.ok?K.json():null).then(K=>{K!=null&&K.ok&&(B(K.enabled===!0),te((K.foreign??[]).filter(Y=>Y.worksHere).length),D(typeof K.parked=="number"?K.parked:0))}).catch(()=>{})},[]);const X=A.useCallback(async()=>{Q(!0);try{const Y=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!U})})).json().catch(()=>null);Y!=null&&Y.ok&&B(Y.enabled===!0),fetch("/api/sound-hook").then(oe=>oe.ok?oe.json():null).then(oe=>{oe!=null&&oe.ok&&(te((oe.foreign??[]).filter(ue=>ue.worksHere).length),D(typeof oe.parked=="number"?oe.parked:0))}).catch(()=>{})}catch{}finally{Q(!1)}},[U]),[R,$]=A.useState(!1),[V,F]=A.useState(null),[J,ne]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(eE)??""}catch{return""}}),[le,de]=A.useState(!1),me=A.useRef(0),[ve,Pe]=A.useState(!1),Me=A.useCallback((K=!1)=>{K&&(me.current=Date.now(),Pe(!0)),fetch(K?"/api/version?refresh=1":"/api/version").then(Y=>Y.ok?Y.json():null).then(Y=>{Y&&F(Y)}).catch(()=>{}).finally(()=>{K&&Pe(!1)})},[]),Oe=A.useCallback(()=>{Me(Date.now()-me.current>=V4)},[Me]);A.useEffect(()=>{Me();const K=window.setInterval(Oe,5*6e4),Y=()=>{document.visibilityState==="visible"&&Oe()};return document.addEventListener("visibilitychange",Y),()=>{window.clearInterval(K),document.removeEventListener("visibilitychange",Y)}},[Me,Oe]),A.useEffect(()=>{R&&Me()},[R,Me]);const ye=(V==null?void 0:V.notice)??null,Se=ye?`${ye.kind}:${ye.to}`:"",Ke=ye!=null&&J!==Se,xe=A.useCallback(()=>{if(!ye)return;const K=J===Se?"":Se;ne(K);try{window.localStorage.setItem(eE,K)}catch{}},[ye,Se,J]),ge=((Ii=V==null?void 0:V.upgrade)==null?void 0:Ii.state)??"idle",Fe=O3(V==null?void 0:V.upgrade),pt=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}Me()},[Me]);A.useEffect(()=>{if(ge!=="running")return;const K=window.setInterval(Me,3e3);return()=>window.clearInterval(K)},[ge,Me]);const mt=A.useCallback(async()=>{var oe;const K=V==null?void 0:V.command;if(!K)return;let Y=!1;try{Y=await Promise.race([((oe=navigator.clipboard)==null?void 0:oe.writeText(K).then(()=>!0))??Promise.resolve(!1),new Promise(ue=>window.setTimeout(()=>ue(!1),500))])}catch{Y=!1}if(!Y)try{const ue=document.createElement("textarea");ue.value=K,ue.setAttribute("readonly",""),ue.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(ue),ue.select(),Y=document.execCommand("copy"),ue.remove()}catch{Y=!1}Y&&(de(!0),window.setTimeout(()=>de(!1),1600))},[V==null?void 0:V.command]),Ze=A.useCallback(()=>{I(K=>(K||L(!1),!K))},[]),De=A.useCallback(()=>{L(K=>(K||I(!1),!K))},[]),[Qe,at]=A.useState(!1),[It,it]=A.useState(0),gt=A.useRef(null),[Kt,Mt]=A.useState(!1),Ye=A.useRef(null),[Nt,dt]=A.useState(0),lt=A.useRef(K3()),[fn,Ut]=A.useState(!1),Ct=A.useCallback(()=>{const K=lt.current,Y=K.setPaused(!K.paused);for(const oe of Y)n.current=dx(n.current,oe);Ut(K.paused)},[]),[Je,hr]=A.useState(Date.now()),[Ht,hn]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(nE)!=="0"}catch{return!0}}),Tn=A.useCallback(()=>{hn(K=>{const Y=!K;try{window.localStorage.setItem(nE,Y?"1":"0")}catch{}return Y})},[]),[Tt,pr]=A.useState(!1),[as,ls]=A.useState("restart"),[vi,Lr]=A.useState(null),Rn=A.useRef(!1),Zn=A.useRef(null),$r=A.useRef(0),pn=A.useCallback(async K=>{if(Rn.current)return;const Y=(K==null?void 0:K.upgrade)===!0;Rn.current=!0,Zn.current=Fe;const oe=++$r.current;ls(Y?"npx":"restart"),pr(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ye==null?void 0:ye.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:Y})})}catch{}window.setTimeout(()=>{if($r.current===oe&&Rn.current){Rn.current=!1,pr(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Y?18e4:3e4)},[ye==null?void 0:ye.to,Fe]),us=A.useRef(null);A.useEffect(()=>{let K=!1;for(const oe of n.current.agents.values())if(oe.state==="active"){K=!0;break}const Y=L3({enabled:Ht,kind:ye==null?void 0:ye.kind,canRestart:(V==null?void 0:V.canRestart)===!0,busy:K,idleSince:us.current,now:Je});us.current=Y.idleSince,Y.restart&&pn()},[Ht,ye==null?void 0:ye.kind,V==null?void 0:V.canRestart,Je,pn]),A.useEffect(()=>{const K=V==null?void 0:V.running;let Y=null,oe=null;try{Y=window.sessionStorage.getItem("agent-dag.restartPending"),oe=window.sessionStorage.getItem(rE)}catch{return}const ue=P3({bundle:"1.33.117",running:K,pending:Y,lastTried:oe});if(ue==="reload"){try{window.sessionStorage.setItem(rE,K??"")}catch{return}window.location.reload();return}if(ue!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Rn.current=!1,pr(!1),Lr(K??null);const we=window.setTimeout(()=>Lr(null),6e3);return()=>window.clearTimeout(we)},[V==null?void 0:V.running]),A.useEffect(()=>{if(Tt&&q3({asked:Zn.current,reported:Fe})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Rn.current=!1,pr(!1)}},[Tt,Fe]);const jn=A.useRef(t5()).current;A.useRef(!1);const yt=A.useRef(new Map(jn.positions.filter(([K])=>jn.pins.includes(K)))),An=A.useRef(null),Jn=A.useState(()=>n5())[0],[In,cs]=A.useState(""),[yi,Mn]=A.useState(()=>new Set),[er,wi]=A.useState(()=>GN("agent-dag.theme")??"dark"),[ds,fs]=A.useState(!1),xi=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=er;try{window.localStorage.setItem("agent-dag.theme",er)}catch{}},[er]),A.useEffect(()=>{if(!Jn)return;const K=window.setTimeout(()=>{try{e.setViewport(Jn,{duration:0})}catch{}},60);return()=>window.clearTimeout(K)},[e,Jn]);const _i=A.useRef(!0);A.useEffect(()=>{const K=new EventSource("/events"),Y=Y3(s,{now:()=>Date.now(),setTimeout:(oe,ue)=>window.setTimeout(oe,ue),clearTimeout:oe=>window.clearTimeout(oe)});return K.addEventListener("open",()=>{$(!0),fs(!0)}),K.addEventListener("error",()=>$(!1)),K.addEventListener("replay-end",()=>{_i.current=!1,Y.flush()}),K.addEventListener("hook",oe=>{try{const ue=JSON.parse(oe.data);if(!lt.current.accept(ue))return;n.current=dx(n.current,ue),ue.replay===!0||_i.current||Date.now()-ue.receivedAt>3e4?Y.replay():Y.live()}catch{}}),()=>{K.close(),Y.cancel()}},[s]),A.useEffect(()=>{const K=setInterval(()=>{const Y=Date.now();hr(Y);let oe=FP(n.current,Y,z4);$P(n.current,Y,B4,U4)&&(oe=!0),DP(n.current,Y,H4,W4)&&(oe=!0),oe&&s()},250);return()=>clearInterval(K)},[s]);const Dr=A.useRef(null),Pn=A.useRef(0),co=420,Be=A.useCallback((K=500)=>{try{const Ee=document.querySelector(".canvas-wrap"),Re=Array.from(document.querySelectorAll(".react-flow__node")).filter(wt=>wt.offsetWidth>0);if(!Ee||Re.length===0)return;const qe=Ee.getBoundingClientRect(),Ue=e.getViewport();if(!Number.isFinite(Ue.zoom)||Ue.zoom<=0)return;const Ge=wt=>(wt-qe.left-Ue.x)/Ue.zoom,tt=wt=>(wt-qe.top-Ue.y)/Ue.zoom,gn=Re.map(wt=>wt.getBoundingClientRect()),Oi=Math.min(...gn.map(wt=>Ge(wt.left))),wo=Math.max(...gn.map(wt=>Ge(wt.right))),xr=Math.min(...gn.map(wt=>tt(wt.top))),xo=Math.max(...gn.map(wt=>tt(wt.bottom))),Ma=wo-Oi,ws=xo-xr;if(!(Ma>0&&ws>0))return;const $n=Math.max(.2,Math.min(1,(qe.width-160)/(Ma+co)*.86,(qe.height-160)/ws*.86));e.setViewport({x:80-Oi*$n,y:Math.max(80,(qe.height-ws*$n)/2)-xr*$n,zoom:$n},{duration:K}),Pn.current=Date.now(),window.setTimeout(()=>{try{const wt={x:80-Oi*$n,y:Math.max(80,(qe.height-ws*$n)/2)-xr*$n,zoom:$n},_o=e.getViewport();(Math.abs(_o.zoom-$n)>.01||Math.abs(_o.x-wt.x)>2)&&e.setViewport(wt,{duration:0})}catch{}},K+60)}catch{}},[e]),bi=A.useRef(""),mr=A.useRef(null),Si=A.useRef(0),On=A.useCallback(()=>{Si.current=Date.now()},[]),Fr="agent-dag.autoFitDisabled",mn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fr)==="1"}catch{return!1}})()),[gr,Wt]=A.useState(mn.current),zr=A.useCallback(()=>{if(!mn.current){mn.current=!0,Wt(!0);try{window.localStorage.setItem(Fr,"1")}catch{}}},[]),an=A.useCallback(()=>{mn.current=!1,Wt(!1);try{window.localStorage.removeItem(Fr)}catch{}Be(400)},[e,Be]);A.useEffect(()=>{const K=setInterval(()=>{if(mn.current||Date.now()-Si.current<800)return;const Y=n.current,oe=Date.now(),ue=[];for(const Ge of Y.agents.values())av(Ge,oe)&&ue.push({id:Ge.id});if(ue.length===0)return;const we=e.getViewport(),Ee=window.innerWidth-360,Re=window.innerHeight-52;let qe=!1,Ue=!1;for(const{id:Ge}of ue){const tt=Br.current.get(Ge),gn=yt.current.get(Ge)??Xt.current.get(Ge);if(!tt||!gn)continue;Ue=!0;const Oi=gn.x*we.zoom+we.x,wo=gn.y*we.zoom+we.y,xr=(gn.x+tt.width)*we.zoom+we.x,xo=(gn.y+tt.height)*we.zoom+we.y;if(xr>0&&Oi<Ee&&xo>0&&wo<Re){qe=!0;break}}Ue&&!qe&&Be(600)},1500);return()=>clearInterval(K)},[e]);const fo=A.useRef(!1),Br=A.useRef(new Map),Na=A.useRef(0),hs=A.useCallback(K=>{const Y=Br.current;let oe=!1;for(const ue of K.nodeInternals.values()){const we=ue.width,Ee=ue.height;if(we==null||Ee==null)continue;const Re=Y.get(ue.id);Re?(Math.abs(Re.height-Ee)>4||Math.abs(Re.width-we)>4)&&(Y.set(ue.id,{width:we,height:Ee}),oe=!0):(Y.set(ue.id,{width:we,height:Ee}),oe=!0)}return oe&&(Na.current+=1),Na.current},[]),ki=Xe(hs),[Ur,ps]=A.useState(0);A.useEffect(()=>{let K=0;const Y=()=>{const ue=Br.current;let we=!1;for(const Ee of document.querySelectorAll(".react-flow__node[data-id]")){const Re=Ee.getAttribute("data-id");if(!Re)continue;const qe=Ee.offsetWidth,Ue=Ee.offsetHeight;if(!qe||!Ue)continue;const Ge=ue.get(Re);(!Ge||Math.abs(Ge.width-qe)>4||Math.abs(Ge.height-Ue)>4)&&(ue.set(Re,{width:qe,height:Ue}),we=!0)}we&&ps(Ee=>Ee+1)};if(fo.current)return;let oe=0;return document.visibilityState==="hidden"?oe=window.setTimeout(Y,32):K=requestAnimationFrame(Y),()=>{cancelAnimationFrame(K),window.clearTimeout(oe)}});const Xt=A.useRef(new Map(jn.positions)),ho=A.useRef(""),tr=A.useMemo(()=>{const K=[];for(const Y of n.current.agents.values())av(Y,Je)&&K.push(Y.id+(Y.parentId?`>${Y.parentId}`:""));return K.sort(),`${K.join("|")}#sv${ki}.${Ur}`},[n.current,n.current.lastSeq,Je,ki,Ur]),Hr=A.useRef(null);A.useEffect(()=>(Hr.current!=null&&window.clearTimeout(Hr.current),Hr.current=window.setTimeout(()=>{$g(Xt.current,yt.current)},1500),()=>{Hr.current!=null&&window.clearTimeout(Hr.current)}),[tr]),A.useEffect(()=>{if(bi.current===tr)return;const K=bi.current;if(bi.current=tr,!K||mn.current)return;Date.now()-Pn.current>1200&&Be(400),Dr.current&&window.clearTimeout(Dr.current),Dr.current=window.setTimeout(()=>{mn.current||Be(500)},280)},[tr,e,Be]);const Ei=A.useMemo(()=>{if(o.size===0)return null;const K=new Set;for(const Y of o){const oe=o5(n.current,Y);if(oe)for(const ue of oe)K.add(ue)}return K.size>0?K:null},[n.current,n.current.lastSeq,o]),vr=A.useMemo(()=>A4(n.current,Je),[n.current,n.current.lastSeq,Je]),Ca=A.useRef(null),[Wr,We]=A.useState({w:0,h:0});A.useEffect(()=>{const K=Ca.current;if(!K||typeof ResizeObserver>"u")return;const Y=new ResizeObserver(oe=>{var we;const ue=(we=oe[0])==null?void 0:we.contentRect;ue&&We(Ee=>Math.abs(Ee.w-ue.width)>40||Math.abs(Ee.h-ue.height)>40?{w:ue.width,h:ue.height}:Ee)});return Y.observe(K),We({w:K.clientWidth,h:K.clientHeight}),()=>Y.disconnect()},[]);const Ta=A.useRef(new Map),[po,mo]=A.useState(!1);A.useEffect(()=>{const K=window.setTimeout(()=>mo(!0),2500);return()=>window.clearTimeout(K)},[]);const[Ra,ms]=A.useState(!1),qn=A.useRef(null),[Ni,Ci]=A.useState(!1),nr=A.useCallback(()=>{qn.current&&(window.clearTimeout(qn.current),qn.current=null),ms(!1)},[]),rr=A.useCallback(K=>{K.length!==0&&queueMicrotask(()=>{ms(!0),qn.current&&window.clearTimeout(qn.current),qn.current=window.setTimeout(()=>ms(!1),F4+80)})},[]);A.useEffect(()=>()=>{qn.current&&window.clearTimeout(qn.current)},[]);const Ln=Wr.w>0?Wr.w*.92:0,Vr=Wr.h>0?Wr.h:0,{nodes:Vt,edges:ir}=A.useMemo(()=>a5(n.current,Je,Ln,Vr,yt.current,In,Br.current,Ta.current,rr,po,Ni,Xt.current,tr,ho,o,Ei,vr,b),[n.current,n.current.lastSeq,Je,Ln,Vr,po,Ni,In,tr,o,Ei,vr,b,It]),ja=A.useMemo(()=>{const K=new Map;for(const oe of Vt){const ue=oe.data;if(!(ue!=null&&ue.sessionId)||ue.exitAt!=null)continue;const we=oe.width,Ee=oe.height;if(we==null||Ee==null)continue;const Re=oe.position.x,qe=oe.position.y,Ue=Re+we,Ge=qe+Ee,tt=K.get(ue.sessionId);tt?(tt.minX=Math.min(tt.minX,Re),tt.minY=Math.min(tt.minY,qe),tt.maxX=Math.max(tt.maxX,Ue),tt.maxY=Math.max(tt.maxY,Ge)):K.set(ue.sessionId,{minX:Re,minY:qe,maxX:Ue,maxY:Ge})}const Y=[];for(const[oe,ue]of K){const we=ue.maxX-ue.minX+Ul*2,Ee=ue.maxY-ue.minY+Ul*2;Y.push({id:`group:${oe}`,type:YC,position:{x:ue.minX-Ul,y:ue.minY-Ul},data:{sessionId:oe,w:we,h:Ee},width:we,height:Ee,style:{width:we,height:Ee},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Y},[Vt,Je]),Aa=A.useMemo(()=>{const K=[...ja,...Vt],Y=Ye.current;return!Y||Y.size===0?K:K.map(oe=>{const ue=Y.get(oe.id);return ue?{...oe,position:ue}:oe})},[ja,Vt,Nt]),Ti=A.useMemo(()=>{if(!In)return null;const K=new Set;for(const Y of n.current.agents.values())eT(Y,In)&&K.add(Y.id);return K},[n.current,n.current.lastSeq,In]),gs=A.useMemo(()=>{const K=new Set;for(const Y of n.current.agents.values())for(const oe of Y.tools)K.add(JC(oe.name));return Object.keys(lv).filter(Y=>K.has(Y))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(gs.length<=1){Mt(!1);return}let K=0;const Y=()=>{const oe=gt.current;if(oe&&!document.hidden){const ue=oe.getBoundingClientRect(),we=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Re=>Re.getBoundingClientRect()),Ee=M4(ue,we,8);Mt(Re=>Re===Ee?Re:Ee)}K=window.setTimeout(Y,300)};return Y(),()=>window.clearTimeout(K)},[gs.length]);const Gr=A.useMemo(()=>{const K=new Map;for(const oe of n.current.agents.values())for(const ue of oe.tools){if(!ue.name.startsWith("mcp__"))continue;const we=ue.name.slice(5),Ee=we.indexOf("__"),Re=Ee>0?we.slice(0,Ee):we;K.set(Re,(K.get(Re)??0)+1)}const Y=[];for(const[oe,ue]of K){let we=5381;for(let Ee=0;Ee<oe.length;Ee++)we=(we<<5)+we^oe.charCodeAt(Ee);Y.push({server:oe,count:ue,hue:Math.abs(we)%360})}return Y.sort((oe,ue)=>ue.count-oe.count),Y},[n.current,n.current.lastSeq]),vs=A.useCallback(K=>{Mn(Y=>{const oe=new Set(Y);return oe.has(K)?oe.delete(K):oe.add(K),oe})},[]),Pt=u?n.current.agents.get(u):null,go=p?Array.from(n.current.agents.values()).flatMap(K=>K.tools).find(K=>K.id===p)??null:null,Yr=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=tv(),yt.current.clear(),Br.current.clear(),Xt.current.clear(),ho.current="",sE(),m(),s()},[s,m]),Kr=A.useRef(S);Kr.current=S;const yr=A.useRef(!1);yr.current=go!=null||Qe||N!=null||y!=null;const wr=A.useCallback(K=>{const Y=H3(K,{confirmOpen:Kr.current,modalOpen:yr.current});Y==="confirm"?k(!0):Y==="clear"&&(k(!1),Yr())},[Yr]),vo=A.useCallback(()=>{yt.current.clear(),Xt.current.clear(),ho.current="",sE(),s(),window.setTimeout(()=>Be(500),80)},[s,e,Be]),Ia=A.useCallback(()=>Be(500),[Be]),ys=A.useRef(Vt);ys.current=Vt;const Ri=A.useRef(u);Ri.current=u;const ji=A.useCallback(K=>{const Y=ys.current;if(Y.length===0)return;const oe=Y.slice().sort((qe,Ue)=>qe.position.y-Ue.position.y||qe.position.x-Ue.position.x),ue=Ri.current,we=ue?oe.findIndex(qe=>qe.id===ue):-1;let Ee;we===-1?Ee=K===1?0:oe.length-1:Ee=(we+K+oe.length)%oe.length;const Re=oe[Ee];Re&&(f(Re.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[Re]})}catch{}Pn.current=Date.now()},30))},[f,e]);A.useEffect(()=>{const K=Y=>{var we,Ee;const oe=Y.target,ue={tagName:oe==null?void 0:oe.tagName,isContentEditable:oe==null?void 0:oe.isContentEditable,role:(we=oe==null?void 0:oe.getAttribute)==null?void 0:we.call(oe,"role"),type:oe==null?void 0:oe.type};if(Y.key==="Escape"){const Re=QP({overlayOpen:rv.depth()>0,typing:VN(ue)});Re==="dismiss"?rv.dismissTop():Re==="blur"?oe==null||oe.blur():m();return}if(!B3(ue)&&!$3(Y)){if(Y.key==="/"){Y.preventDefault(),(Ee=xi.current)==null||Ee.focus();return}Y.key===" "&&(Y.preventDefault(),Ct()),(Y.key==="c"||Y.key==="C")&&wr("shortcut"),(Y.key==="r"||Y.key==="R")&&vo(),(Y.key==="f"||Y.key==="F")&&Ia(),(Y.key==="l"||Y.key==="L")&&Ze(),(Y.key==="h"||Y.key==="H")&&at(Re=>!Re),(Y.key==="u"||Y.key==="U")&&q(Re=>!Re),(Y.key==="a"||Y.key==="A")&&De(),(Y.key==="j"||Y.key==="J")&&ji(1),(Y.key==="k"||Y.key==="K")&&ji(-1),(Y.key==="t"||Y.key==="T")&&wi(Re=>Re==="dark"?"light":"dark")}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[wr,vo,Ia,m,ji,Ct]);const Ai=n.current.agents.size,sr=new Set(Array.from(n.current.agents.values()).map(K=>K.sessionId)).size,$t=A.useMemo(()=>{let K=0,Y=0,oe=0,ue=0,we=0,Ee=0,Re=0,qe=0,Ue=0;for(const Ge of n.current.agents.values()){K+=Ge.usage.inputTokens,Y+=Ge.usage.outputTokens,oe+=Ge.usage.cacheReadTokens,ue+=Ge.usage.cacheCreateTokens;const tt=sn(Ge.usage,Ge.model);we+=tt.total,Ee+=tt.input,Re+=tt.output,qe+=tt.cacheRead,Ue+=tt.cacheWrite}return{inT:K,outT:Y,cacheR:oe,cacheC:ue,sum:K+Y,cost:{total:we,input:Ee,output:Re,cacheRead:qe,cacheWrite:Ue}}},[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"}),"agents-deck",ye?g.jsxs("button",{type:"button",className:"v stale",onClick:xe,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 K={running:(V==null?void 0:V.running)??"1.33.117",latest:V==null?void 0:V.latest,latestPending:V==null?void 0:V.latestPending,checkedAgo:V!=null&&V.checkedAt?G4(Je-V.checkedAt):null,checkDisabled:V==null?void 0:V.checkDisabled,checking:ve};return g.jsxs("button",{type:"button",className:ve?"v checking":"v",onClick:()=>Me(!0),"aria-busy":ve||void 0,"aria-label":L4(K),title:q4(K),children:["v",K.running]})})()]}),Pt&&(()=>{const K=sn(Pt.usage,Pt.model),Y=Math.max(0,((Pt.endedAt??Je)-Pt.startedAt)/1e3),oe=Pt.state==="active"?su(K.total,Y):null,ue=o.size-1;return g.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Pt.label}`,onClick:()=>{try{const we=Vt.find(Ee=>Ee.id===Pt.id);we&&e.fitView({padding:.35,duration:500,nodes:[we]}),Pn.current=Date.now()}catch{}},children:[g.jsx("span",{className:`state-pill state-${Pt.state}`,children:Pt.state==="active"?"live":Pt.state}),g.jsx("span",{className:"selected-label",children:Pt.label}),K.total>0&&g.jsxs("span",{className:"selected-cost",children:[ze(K.total),oe?g.jsxs("span",{className:"selected-rate",children:[" · ",oe]}):null]}),ue>0&&g.jsxs("span",{className:"selected-extra",children:["+",ue]}),g.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:we=>{we.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:xi,type:"text",placeholder:"Search agents, cwd, tools…",value:In,onChange:K=>cs(K.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),In?g.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>cs(""),children:"×"}):g.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),g.jsxs("span",{className:"status",role:"status",children:[g.jsx("span",{className:`pill ${R?"live":"dead"}`,title:R?"Receiving events":"SSE disconnected",children:R?"live":"offline"}),g.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[g.jsx("span",{className:"count",children:sr}),g.jsx("span",{className:"lbl",children:"sessions"})]}),g.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[g.jsx("span",{className:"count",children:Ai}),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"})]}),$t.sum>0&&g.jsxs("span",{className:"stat",title:`in:${$t.inT.toLocaleString()} out:${$t.outT.toLocaleString()} cache-r:${$t.cacheR.toLocaleString()} cache-c:${$t.cacheC.toLocaleString()}`,children:[g.jsx("span",{className:"count",children:$4($t.sum)}),g.jsx("span",{className:"lbl",children:"tokens"})]}),Gr.length>0&&g.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
60
60
|
${Gr.map(K=>` ${K.server}: ${K.count} call${K.count===1?"":"s"}`).join(`
|
|
61
61
|
`)}`,children:[Gr.slice(0,6).map(K=>g.jsx("span",{className:"mcp-dot",style:{background:`hsl(${K.hue} 65% 65%)`}},K.server)),Gr.length>6&&g.jsxs("span",{className:"mcp-more",children:["+",Gr.length-6]}),g.jsx("span",{className:"lbl",children:"mcp"})]}),$t.cost.total>0&&(()=>{let K=0,Y=0;for(const we of n.current.agents.values()){if(we.state!=="active")continue;const Ee=sn(we.usage,we.model);K+=Ee.total,Y=Math.max(Y,((we.endedAt??Je)-we.startedAt)/1e3)}const oe=Y>0?su(K,Y):null,ue=`input ${ze($t.cost.input)} + output ${ze($t.cost.output)} + cache r ${ze($t.cost.cacheRead)} + cache w ${ze($t.cost.cacheWrite)}${oe?`
|
|
62
62
|
active burn: ${oe}`:""}`;return g.jsxs("span",{className:"stat",title:ue,children:[g.jsx("span",{className:"count",children:ze($t.cost.total)}),g.jsxs("span",{className:"lbl",children:["cost",oe?` · ${oe}`:""]})]})})()]}),g.jsx("button",{className:`btn ${fn?"warn":""}`,onClick:Ct,title:"Pause/resume live updates (Space)",children:fn?`Resume${lt.current.size?` · ${lt.current.size}`:""}`:"Pause"}),g.jsx("button",{className:`btn icon-btn ${W?"primary":""}`,onClick:()=>q(K=>!K),title:`${W?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),U!==null&&g.jsx("button",{className:`btn icon-btn ${U?"primary":""}`,onClick:K=>{if(K.shiftKey&&Z>0){Q(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(Y=>Y.ok?Y.json():null).then(Y=>{Y!=null&&Y.ok&&(B(Y.enabled===!0),D(Y.parked??0))}).catch(()=>{}).finally(()=>Q(!1));return}X()},disabled:j,title:(U?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(H>0?`
|