agent-dag 1.33.123 → 1.33.124
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.
|
@@ -56,7 +56,7 @@ Error generating stack: `+w.message+`
|
|
|
56
56
|
*/var yw;function IR(){if(yw)return ld;yw=1;var e=ma(),n=AR();function r(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var i=typeof Object.is=="function"?Object.is:r,o=n.useSyncExternalStore,l=e.useRef,u=e.useEffect,c=e.useMemo,p=e.useDebugValue;return ld.useSyncExternalStoreWithSelector=function(h,f,g,y,x){var N=l(null);if(N.current===null){var _={hasValue:!1,value:null};N.current=_}else _=N.current;N=c(function(){function b(I){if(!k){if(k=!0,E=I,I=y(I),x!==void 0&&_.hasValue){var L=_.value;if(x(L,I))return C=L}return C=I}if(L=C,i(E,I))return L;var H=y(I);return x!==void 0&&x(L,H)?(E=I,L):(E=I,C=H)}var k=!1,E,C,R=g===void 0?null:g;return[function(){return b(f())},R===null?void 0:function(){return b(R())}]},[f,g,y,x]);var S=o(h,N[0],N[1]);return u(function(){_.hasValue=!0,_.value=S},[S]),p(S),S},ld}var ww;function MR(){return ww||(ww=1,ad.exports=IR()),ad.exports}var PR=MR();const OR=dv(PR),LR={},xw=e=>{let n;const r=new Set,i=(f,g)=>{const y=typeof f=="function"?f(n):f;if(!Object.is(y,n)){const x=n;n=g??(typeof y!="object"||y===null)?y:Object.assign({},n,y),r.forEach(N=>N(n,x))}},o=()=>n,p={setState:i,getState:o,getInitialState:()=>h,subscribe:f=>(r.add(f),()=>r.delete(f)),destroy:()=>{(LR?"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(i,o,p);return p},qR=e=>e?xw(e):xw,{useDebugValue:$R}=le,{useSyncExternalStoreWithSelector:DR}=OR,FR=e=>e;function cE(e,n=FR,r){const i=DR(e.subscribe,e.getState,e.getServerState||e.getInitialState,n,r);return $R(i),i}const _w=(e,n)=>{const r=qR(e),i=(o,l=n)=>cE(r,o,l);return Object.assign(i,r),i},zR=(e,n)=>e?_w(e,n):_w;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[i,o]of e)if(!Object.is(o,n.get(i)))return!1;return!0}if(e instanceof Set&&n instanceof Set){if(e.size!==n.size)return!1;for(const i of e)if(!n.has(i))return!1;return!0}const r=Object.keys(e);if(r.length!==Object.keys(n).length)return!1;for(const i of r)if(!Object.prototype.hasOwnProperty.call(n,i)||!Object.is(e[i],n[i]))return!1;return!0}var BR={value:()=>{}};function au(){for(var e=0,n=arguments.length,r={},i;e<n;++e){if(!(i=arguments[e]+"")||i in r||/[\s.]/.test(i))throw new Error("illegal type: "+i);r[i]=[]}return new Ul(r)}function Ul(e){this._=e}function UR(e,n){return e.trim().split(/^|\s+/).map(function(r){var i="",o=r.indexOf(".");if(o>=0&&(i=r.slice(o+1),r=r.slice(0,o)),r&&!n.hasOwnProperty(r))throw new Error("unknown type: "+r);return{type:r,name:i}})}Ul.prototype=au.prototype={constructor:Ul,on:function(e,n){var r=this._,i=UR(e+"",r),o,l=-1,u=i.length;if(arguments.length<2){for(;++l<u;)if((o=(e=i[l]).type)&&(o=HR(r[o],e.name)))return o;return}if(n!=null&&typeof n!="function")throw new Error("invalid callback: "+n);for(;++l<u;)if(o=(e=i[l]).type)r[o]=bw(r[o],e.name,n);else if(n==null)for(o in r)r[o]=bw(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 Ul(e)},call:function(e,n){if((o=arguments.length-2)>0)for(var r=new Array(o),i=0,o,l;i<o;++i)r[i]=arguments[i+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],i=0,o=l.length;i<o;++i)l[i].value.apply(n,r)},apply:function(e,n,r){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var i=this._[e],o=0,l=i.length;o<l;++o)i[o].value.apply(n,r)}};function HR(e,n){for(var r=0,i=e.length,o;r<i;++r)if((o=e[r]).name===n)return o.value}function bw(e,n,r){for(var i=0,o=e.length;i<o;++i)if(e[i].name===n){e[i]=BR,e=e.slice(0,i).concat(e.slice(i+1));break}return r!=null&&e.push({name:n,value:r}),e}var Fg="http://www.w3.org/1999/xhtml";const Sw={svg:"http://www.w3.org/2000/svg",xhtml:Fg,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function lu(e){var n=e+="",r=n.indexOf(":");return r>=0&&(n=e.slice(0,r))!=="xmlns"&&(e=e.slice(r+1)),Sw.hasOwnProperty(n)?{space:Sw[n],local:e}:e}function WR(e){return function(){var n=this.ownerDocument,r=this.namespaceURI;return r===Fg&&n.documentElement.namespaceURI===Fg?n.createElement(e):n.createElementNS(r,e)}}function VR(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function dE(e){var n=lu(e);return(n.local?VR:WR)(n)}function GR(){}function fv(e){return e==null?GR:function(){return this.querySelector(e)}}function YR(e){typeof e!="function"&&(e=fv(e));for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=i[o]=new Array(u),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 fn(i,this._parents)}function KR(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function XR(){return[]}function fE(e){return e==null?XR:function(){return this.querySelectorAll(e)}}function QR(e){return function(){return KR(e.apply(this,arguments))}}function ZR(e){typeof e=="function"?e=QR(e):e=fE(e);for(var n=this._groups,r=n.length,i=[],o=[],l=0;l<r;++l)for(var u=n[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&(i.push(e.call(p,p.__data__,h,u)),o.push(p));return new fn(i,o)}function hE(e){return function(){return this.matches(e)}}function pE(e){return function(n){return n.matches(e)}}var JR=Array.prototype.find;function ej(e){return function(){return JR.call(this.children,e)}}function tj(){return this.firstElementChild}function nj(e){return this.select(e==null?tj:ej(typeof e=="function"?e:pE(e)))}var rj=Array.prototype.filter;function sj(){return Array.from(this.children)}function ij(e){return function(){return rj.call(this.children,e)}}function oj(e){return this.selectAll(e==null?sj:ij(typeof e=="function"?e:pE(e)))}function aj(e){typeof e!="function"&&(e=hE(e));for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=i[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new fn(i,this._parents)}function mE(e){return new Array(e.length)}function lj(){return new fn(this._enter||this._groups.map(mE),this._parents)}function Yl(e,n){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=n}Yl.prototype={constructor:Yl,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 uj(e){return function(){return e}}function cj(e,n,r,i,o,l){for(var u=0,c,p=n.length,h=l.length;u<h;++u)(c=n[u])?(c.__data__=l[u],i[u]=c):r[u]=new Yl(e,l[u]);for(;u<p;++u)(c=n[u])&&(o[u]=c)}function dj(e,n,r,i,o,l,u){var c,p,h=new Map,f=n.length,g=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<g;++c)x=u.call(e,l[c],c,l)+"",(p=h.get(x))?(i[c]=p,p.__data__=l[c],h.delete(x)):r[c]=new Yl(e,l[c]);for(c=0;c<f;++c)(p=n[c])&&h.get(y[c])===p&&(o[c]=p)}function fj(e){return e.__data__}function hj(e,n){if(!arguments.length)return Array.from(this,fj);var r=n?dj:cj,i=this._parents,o=this._groups;typeof e!="function"&&(e=uj(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=i[h],g=o[h],y=g.length,x=pj(e.call(f,f&&f.__data__,h,i)),N=x.length,_=c[h]=new Array(N),S=u[h]=new Array(N),b=p[h]=new Array(y);r(f,g,_,S,b,x,n);for(var k=0,E=0,C,R;k<N;++k)if(C=_[k]){for(k>=E&&(E=k+1);!(R=S[E])&&++E<N;);C._next=R||null}}return u=new fn(u,i),u._enter=c,u._exit=p,u}function pj(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function mj(){return new fn(this._exit||this._groups.map(mE),this._parents)}function gj(e,n,r){var i=this.enter(),o=this,l=this.exit();return typeof e=="function"?(i=e(i),i&&(i=i.selection())):i=i.append(e+""),n!=null&&(o=n(o),o&&(o=o.selection())),r==null?l.remove():r(l),i&&o?i.merge(o).order():o}function vj(e){for(var n=e.selection?e.selection():e,r=this._groups,i=n._groups,o=r.length,l=i.length,u=Math.min(o,l),c=new Array(o),p=0;p<u;++p)for(var h=r[p],f=i[p],g=h.length,y=c[p]=new Array(g),x,N=0;N<g;++N)(x=h[N]||f[N])&&(y[N]=x);for(;p<o;++p)c[p]=r[p];return new fn(c,this._parents)}function yj(){for(var e=this._groups,n=-1,r=e.length;++n<r;)for(var i=e[n],o=i.length-1,l=i[o],u;--o>=0;)(u=i[o])&&(l&&u.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(u,l),l=u);return this}function wj(e){e||(e=xj);function n(g,y){return g&&y?e(g.__data__,y.__data__):!g-!y}for(var r=this._groups,i=r.length,o=new Array(i),l=0;l<i;++l){for(var u=r[l],c=u.length,p=o[l]=new Array(c),h,f=0;f<c;++f)(h=u[f])&&(p[f]=h);p.sort(n)}return new fn(o,this._parents).order()}function xj(e,n){return e<n?-1:e>n?1:e>=n?0:NaN}function _j(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function bj(){return Array.from(this)}function Sj(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,l=i.length;o<l;++o){var u=i[o];if(u)return u}return null}function kj(){let e=0;for(const n of this)++e;return e}function Ej(){return!this.node()}function Nj(e){for(var n=this._groups,r=0,i=n.length;r<i;++r)for(var o=n[r],l=0,u=o.length,c;l<u;++l)(c=o[l])&&e.call(c,c.__data__,l,o);return this}function Cj(e){return function(){this.removeAttribute(e)}}function Tj(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Rj(e,n){return function(){this.setAttribute(e,n)}}function jj(e,n){return function(){this.setAttributeNS(e.space,e.local,n)}}function Aj(e,n){return function(){var r=n.apply(this,arguments);r==null?this.removeAttribute(e):this.setAttribute(e,r)}}function Ij(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 Mj(e,n){var r=lu(e);if(arguments.length<2){var i=this.node();return r.local?i.getAttributeNS(r.space,r.local):i.getAttribute(r)}return this.each((n==null?r.local?Tj:Cj:typeof n=="function"?r.local?Ij:Aj:r.local?jj:Rj)(r,n))}function gE(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Pj(e){return function(){this.style.removeProperty(e)}}function Oj(e,n,r){return function(){this.style.setProperty(e,n,r)}}function Lj(e,n,r){return function(){var i=n.apply(this,arguments);i==null?this.style.removeProperty(e):this.style.setProperty(e,i,r)}}function qj(e,n,r){return arguments.length>1?this.each((n==null?Pj:typeof n=="function"?Lj:Oj)(e,n,r??"")):Ji(this.node(),e)}function Ji(e,n){return e.style.getPropertyValue(n)||gE(e).getComputedStyle(e,null).getPropertyValue(n)}function $j(e){return function(){delete this[e]}}function Dj(e,n){return function(){this[e]=n}}function Fj(e,n){return function(){var r=n.apply(this,arguments);r==null?delete this[e]:this[e]=r}}function zj(e,n){return arguments.length>1?this.each((n==null?$j:typeof n=="function"?Fj:Dj)(e,n)):this.node()[e]}function vE(e){return e.trim().split(/^|\s+/)}function hv(e){return e.classList||new yE(e)}function yE(e){this._node=e,this._names=vE(e.getAttribute("class")||"")}yE.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 wE(e,n){for(var r=hv(e),i=-1,o=n.length;++i<o;)r.add(n[i])}function xE(e,n){for(var r=hv(e),i=-1,o=n.length;++i<o;)r.remove(n[i])}function Bj(e){return function(){wE(this,e)}}function Uj(e){return function(){xE(this,e)}}function Hj(e,n){return function(){(n.apply(this,arguments)?wE:xE)(this,e)}}function Wj(e,n){var r=vE(e+"");if(arguments.length<2){for(var i=hv(this.node()),o=-1,l=r.length;++o<l;)if(!i.contains(r[o]))return!1;return!0}return this.each((typeof n=="function"?Hj:n?Bj:Uj)(r,n))}function Vj(){this.textContent=""}function Gj(e){return function(){this.textContent=e}}function Yj(e){return function(){var n=e.apply(this,arguments);this.textContent=n??""}}function Kj(e){return arguments.length?this.each(e==null?Vj:(typeof e=="function"?Yj:Gj)(e)):this.node().textContent}function Xj(){this.innerHTML=""}function Qj(e){return function(){this.innerHTML=e}}function Zj(e){return function(){var n=e.apply(this,arguments);this.innerHTML=n??""}}function Jj(e){return arguments.length?this.each(e==null?Xj:(typeof e=="function"?Zj:Qj)(e)):this.node().innerHTML}function e2(){this.nextSibling&&this.parentNode.appendChild(this)}function t2(){return this.each(e2)}function n2(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function r2(){return this.each(n2)}function s2(e){var n=typeof e=="function"?e:dE(e);return this.select(function(){return this.appendChild(n.apply(this,arguments))})}function i2(){return null}function o2(e,n){var r=typeof e=="function"?e:dE(e),i=n==null?i2:typeof n=="function"?n:fv(n);return this.select(function(){return this.insertBefore(r.apply(this,arguments),i.apply(this,arguments)||null)})}function a2(){var e=this.parentNode;e&&e.removeChild(this)}function l2(){return this.each(a2)}function u2(){var e=this.cloneNode(!1),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function c2(){var e=this.cloneNode(!0),n=this.parentNode;return n?n.insertBefore(e,this.nextSibling):e}function d2(e){return this.select(e?c2:u2)}function f2(e){return arguments.length?this.property("__data__",e):this.node().__data__}function h2(e){return function(n){e.call(this,n,this.__data__)}}function p2(e){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");return i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),{type:n,name:r}})}function m2(e){return function(){var n=this.__on;if(n){for(var r=0,i=-1,o=n.length,l;r<o;++r)l=n[r],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):n[++i]=l;++i?n.length=i:delete this.__on}}}function g2(e,n,r){return function(){var i=this.__on,o,l=h2(n);if(i){for(var u=0,c=i.length;u<c;++u)if((o=i[u]).type===e.type&&o.name===e.name){this.removeEventListener(o.type,o.listener,o.options),this.addEventListener(o.type,o.listener=l,o.options=r),o.value=n;return}}this.addEventListener(e.type,l,r),o={type:e.type,name:e.name,value:n,listener:l,options:r},i?i.push(o):this.__on=[o]}}function v2(e,n,r){var i=p2(e+""),o,l=i.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=i[o]).type===f.type&&u.name===f.name)return f.value}return}for(c=n?g2:m2,o=0;o<l;++o)this.each(c(i[o],n,r));return this}function _E(e,n,r){var i=gE(e),o=i.CustomEvent;typeof o=="function"?o=new o(n,r):(o=i.document.createEvent("Event"),r?(o.initEvent(n,r.bubbles,r.cancelable),o.detail=r.detail):o.initEvent(n,!1,!1)),e.dispatchEvent(o)}function y2(e,n){return function(){return _E(this,e,n)}}function w2(e,n){return function(){return _E(this,e,n.apply(this,arguments))}}function x2(e,n){return this.each((typeof n=="function"?w2:y2)(e,n))}function*_2(){for(var e=this._groups,n=0,r=e.length;n<r;++n)for(var i=e[n],o=0,l=i.length,u;o<l;++o)(u=i[o])&&(yield u)}var bE=[null];function fn(e,n){this._groups=e,this._parents=n}function ga(){return new fn([[document.documentElement]],bE)}function b2(){return this}fn.prototype=ga.prototype={constructor:fn,select:YR,selectAll:ZR,selectChild:nj,selectChildren:oj,filter:aj,data:hj,enter:lj,exit:mj,join:gj,merge:vj,selection:b2,order:yj,sort:wj,call:_j,nodes:bj,node:Sj,size:kj,empty:Ej,each:Nj,attr:Mj,style:qj,property:zj,classed:Wj,text:Kj,html:Jj,raise:t2,lower:r2,append:s2,insert:o2,remove:l2,clone:d2,datum:f2,on:v2,dispatch:x2,[Symbol.iterator]:_2};function Nn(e){return typeof e=="string"?new fn([[document.querySelector(e)]],[document.documentElement]):new fn([[e]],bE)}function S2(e){let n;for(;n=e.sourceEvent;)e=n;return e}function Gn(e,n){if(e=S2(e),n===void 0&&(n=e.currentTarget),n){var r=n.ownerSVGElement||n;if(r.createSVGPoint){var i=r.createSVGPoint();return i.x=e.clientX,i.y=e.clientY,i=i.matrixTransform(n.getScreenCTM().inverse()),[i.x,i.y]}if(n.getBoundingClientRect){var o=n.getBoundingClientRect();return[e.clientX-o.left-n.clientLeft,e.clientY-o.top-n.clientTop]}}return[e.pageX,e.pageY]}const k2={passive:!1},ia={capture:!0,passive:!1};function dd(e){e.stopImmediatePropagation()}function Ki(e){e.preventDefault(),e.stopImmediatePropagation()}function SE(e){var n=e.document.documentElement,r=Nn(e).on("dragstart.drag",Ki,ia);"onselectstart"in n?r.on("selectstart.drag",Ki,ia):(n.__noselect=n.style.MozUserSelect,n.style.MozUserSelect="none")}function kE(e,n){var r=e.document.documentElement,i=Nn(e).on("dragstart.drag",null);n&&(i.on("click.drag",Ki,ia),setTimeout(function(){i.on("click.drag",null)},0)),"onselectstart"in r?i.on("selectstart.drag",null):(r.style.MozUserSelect=r.__noselect,delete r.__noselect)}const Nl=e=>()=>e;function zg(e,{sourceEvent:n,subject:r,target:i,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:i,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:l,enumerable:!0,configurable:!0},x:{value:u,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:p,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}zg.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function E2(e){return!e.ctrlKey&&!e.button}function N2(){return this.parentNode}function C2(e,n){return n??{x:e.x,y:e.y}}function T2(){return navigator.maxTouchPoints||"ontouchstart"in this}function R2(){var e=E2,n=N2,r=C2,i=T2,o={},l=au("start","drag","end"),u=0,c,p,h,f,g=0;function y(C){C.on("mousedown.drag",x).filter(i).on("touchstart.drag",S).on("touchmove.drag",b,k2).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function x(C,R){if(!(f||!e.call(this,C,R))){var I=E(this,n.call(this,C,R),C,R,"mouse");I&&(Nn(C.view).on("mousemove.drag",N,ia).on("mouseup.drag",_,ia),SE(C.view),dd(C),h=!1,c=C.clientX,p=C.clientY,I("start",C))}}function N(C){if(Ki(C),!h){var R=C.clientX-c,I=C.clientY-p;h=R*R+I*I>g}o.mouse("drag",C)}function _(C){Nn(C.view).on("mousemove.drag mouseup.drag",null),kE(C.view,h),Ki(C),o.mouse("end",C)}function S(C,R){if(e.call(this,C,R)){var I=C.changedTouches,L=n.call(this,C,R),H=I.length,P,q;for(P=0;P<H;++P)(q=E(this,L,C,R,I[P].identifier,I[P]))&&(dd(C),q("start",C,I[P]))}}function b(C){var R=C.changedTouches,I=R.length,L,H;for(L=0;L<I;++L)(H=o[R[L].identifier])&&(Ki(C),H("drag",C,R[L]))}function k(C){var R=C.changedTouches,I=R.length,L,H;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),L=0;L<I;++L)(H=o[R[L].identifier])&&(dd(C),H("end",C,R[L]))}function E(C,R,I,L,H,P){var q=l.copy(),B=Gn(P||I,R),D,F,j;if((j=r.call(C,new zg("beforestart",{sourceEvent:I,target:y,identifier:H,active:u,x:B[0],y:B[1],dx:0,dy:0,dispatch:q}),L))!=null)return D=j.x-B[0]||0,F=j.y-B[1]||0,function Z(W,ne,J){var U=B,X;switch(W){case"start":o[H]=Z,X=u++;break;case"end":delete o[H],--u;case"drag":B=Gn(J||ne,R),X=u;break}q.call(W,C,new zg(W,{sourceEvent:ne,subject:j,target:y,identifier:H,active:X,x:B[0]+D,y:B[1]+F,dx:B[0]-U[0],dy:B[1]-U[1],dispatch:q}),L)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Nl(!!C),y):e},y.container=function(C){return arguments.length?(n=typeof C=="function"?C:Nl(C),y):n},y.subject=function(C){return arguments.length?(r=typeof C=="function"?C:Nl(C),y):r},y.touchable=function(C){return arguments.length?(i=typeof C=="function"?C:Nl(!!C),y):i},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(g=(C=+C)*C,y):Math.sqrt(g)},y}function pv(e,n,r){e.prototype=n.prototype=r,r.constructor=e}function EE(e,n){var r=Object.create(e.prototype);for(var i in n)r[i]=n[i];return r}function va(){}var oa=.7,Kl=1/oa,Xi="\\s*([+-]?\\d+)\\s*",aa="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",ur="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",j2=/^#([0-9a-f]{3,8})$/,A2=new RegExp(`^rgb\\(${Xi},${Xi},${Xi}\\)$`),I2=new RegExp(`^rgb\\(${ur},${ur},${ur}\\)$`),M2=new RegExp(`^rgba\\(${Xi},${Xi},${Xi},${aa}\\)$`),P2=new RegExp(`^rgba\\(${ur},${ur},${ur},${aa}\\)$`),O2=new RegExp(`^hsl\\(${aa},${ur},${ur}\\)$`),L2=new RegExp(`^hsla\\(${aa},${ur},${ur},${aa}\\)$`),kw={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};pv(va,la,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:Ew,formatHex:Ew,formatHex8:q2,formatHsl:$2,formatRgb:Nw,toString:Nw});function Ew(){return this.rgb().formatHex()}function q2(){return this.rgb().formatHex8()}function $2(){return NE(this).formatHsl()}function Nw(){return this.rgb().formatRgb()}function la(e){var n,r;return e=(e+"").trim().toLowerCase(),(n=j2.exec(e))?(r=n[1].length,n=parseInt(n[1],16),r===6?Cw(n):r===3?new rn(n>>8&15|n>>4&240,n>>4&15|n&240,(n&15)<<4|n&15,1):r===8?Cl(n>>24&255,n>>16&255,n>>8&255,(n&255)/255):r===4?Cl(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=A2.exec(e))?new rn(n[1],n[2],n[3],1):(n=I2.exec(e))?new rn(n[1]*255/100,n[2]*255/100,n[3]*255/100,1):(n=M2.exec(e))?Cl(n[1],n[2],n[3],n[4]):(n=P2.exec(e))?Cl(n[1]*255/100,n[2]*255/100,n[3]*255/100,n[4]):(n=O2.exec(e))?jw(n[1],n[2]/100,n[3]/100,1):(n=L2.exec(e))?jw(n[1],n[2]/100,n[3]/100,n[4]):kw.hasOwnProperty(e)?Cw(kw[e]):e==="transparent"?new rn(NaN,NaN,NaN,0):null}function Cw(e){return new rn(e>>16&255,e>>8&255,e&255,1)}function Cl(e,n,r,i){return i<=0&&(e=n=r=NaN),new rn(e,n,r,i)}function D2(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 Bg(e,n,r,i){return arguments.length===1?D2(e):new rn(e,n,r,i??1)}function rn(e,n,r,i){this.r=+e,this.g=+n,this.b=+r,this.opacity=+i}pv(rn,Bg,EE(va,{brighter(e){return e=e==null?Kl:Math.pow(Kl,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(Xs(this.r),Xs(this.g),Xs(this.b),Xl(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:Tw,formatHex:Tw,formatHex8:F2,formatRgb:Rw,toString:Rw}));function Tw(){return`#${Ys(this.r)}${Ys(this.g)}${Ys(this.b)}`}function F2(){return`#${Ys(this.r)}${Ys(this.g)}${Ys(this.b)}${Ys((isNaN(this.opacity)?1:this.opacity)*255)}`}function Rw(){const e=Xl(this.opacity);return`${e===1?"rgb(":"rgba("}${Xs(this.r)}, ${Xs(this.g)}, ${Xs(this.b)}${e===1?")":`, ${e})`}`}function Xl(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Xs(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ys(e){return e=Xs(e),(e<16?"0":"")+e.toString(16)}function jw(e,n,r,i){return i<=0?e=n=r=NaN:r<=0||r>=1?e=n=NaN:n<=0&&(e=NaN),new Yn(e,n,r,i)}function NE(e){if(e instanceof Yn)return new Yn(e.h,e.s,e.l,e.opacity);if(e instanceof va||(e=la(e)),!e)return new Yn;if(e instanceof Yn)return e;e=e.rgb();var n=e.r/255,r=e.g/255,i=e.b/255,o=Math.min(n,r,i),l=Math.max(n,r,i),u=NaN,c=l-o,p=(l+o)/2;return c?(n===l?u=(r-i)/c+(r<i)*6:r===l?u=(i-n)/c+2:u=(n-r)/c+4,c/=p<.5?l+o:2-l-o,u*=60):c=p>0&&p<1?0:u,new Yn(u,c,p,e.opacity)}function z2(e,n,r,i){return arguments.length===1?NE(e):new Yn(e,n,r,i??1)}function Yn(e,n,r,i){this.h=+e,this.s=+n,this.l=+r,this.opacity=+i}pv(Yn,z2,EE(va,{brighter(e){return e=e==null?Kl:Math.pow(Kl,e),new Yn(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?oa:Math.pow(oa,e),new Yn(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,n=isNaN(e)||isNaN(this.s)?0:this.s,r=this.l,i=r+(r<.5?r:1-r)*n,o=2*r-i;return new rn(fd(e>=240?e-240:e+120,o,i),fd(e,o,i),fd(e<120?e+240:e-120,o,i),this.opacity)},clamp(){return new Yn(Aw(this.h),Tl(this.s),Tl(this.l),Xl(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=Xl(this.opacity);return`${e===1?"hsl(":"hsla("}${Aw(this.h)}, ${Tl(this.s)*100}%, ${Tl(this.l)*100}%${e===1?")":`, ${e})`}`}}));function Aw(e){return e=(e||0)%360,e<0?e+360:e}function Tl(e){return Math.max(0,Math.min(1,e||0))}function fd(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 CE=e=>()=>e;function B2(e,n){return function(r){return e+r*n}}function U2(e,n,r){return e=Math.pow(e,r),n=Math.pow(n,r)-e,r=1/r,function(i){return Math.pow(e+i*n,r)}}function H2(e){return(e=+e)==1?TE:function(n,r){return r-n?U2(n,r,e):CE(isNaN(n)?r:n)}}function TE(e,n){var r=n-e;return r?B2(e,r):CE(isNaN(e)?n:e)}const Iw=(function e(n){var r=H2(n);function i(o,l){var u=r((o=Bg(o)).r,(l=Bg(l)).r),c=r(o.g,l.g),p=r(o.b,l.b),h=TE(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 i.gamma=e,i})(1);function us(e,n){return e=+e,n=+n,function(r){return e*(1-r)+n*r}}var Ug=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,hd=new RegExp(Ug.source,"g");function W2(e){return function(){return e}}function V2(e){return function(n){return e(n)+""}}function G2(e,n){var r=Ug.lastIndex=hd.lastIndex=0,i,o,l,u=-1,c=[],p=[];for(e=e+"",n=n+"";(i=Ug.exec(e))&&(o=hd.exec(n));)(l=o.index)>r&&(l=n.slice(r,l),c[u]?c[u]+=l:c[++u]=l),(i=i[0])===(o=o[0])?c[u]?c[u]+=o:c[++u]=o:(c[++u]=null,p.push({i:u,x:us(i,o)})),r=hd.lastIndex;return r<n.length&&(l=n.slice(r),c[u]?c[u]+=l:c[++u]=l),c.length<2?p[0]?V2(p[0].x):W2(n):(n=p.length,function(h){for(var f=0,g;f<n;++f)c[(g=p[f]).i]=g.x(h);return c.join("")})}var Mw=180/Math.PI,Hg={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function RE(e,n,r,i,o,l){var u,c,p;return(u=Math.sqrt(e*e+n*n))&&(e/=u,n/=u),(p=e*r+n*i)&&(r-=e*p,i-=n*p),(c=Math.sqrt(r*r+i*i))&&(r/=c,i/=c,p/=c),e*i<n*r&&(e=-e,n=-n,p=-p,u=-u),{translateX:o,translateY:l,rotate:Math.atan2(n,e)*Mw,skewX:Math.atan(p)*Mw,scaleX:u,scaleY:c}}var Rl;function Y2(e){const n=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return n.isIdentity?Hg:RE(n.a,n.b,n.c,n.d,n.e,n.f)}function K2(e){return e==null||(Rl||(Rl=document.createElementNS("http://www.w3.org/2000/svg","g")),Rl.setAttribute("transform",e),!(e=Rl.transform.baseVal.consolidate()))?Hg:(e=e.matrix,RE(e.a,e.b,e.c,e.d,e.e,e.f))}function jE(e,n,r,i){function o(h){return h.length?h.pop()+" ":""}function l(h,f,g,y,x,N){if(h!==g||f!==y){var _=x.push("translate(",null,n,null,r);N.push({i:_-4,x:us(h,g)},{i:_-2,x:us(f,y)})}else(g||y)&&x.push("translate("+g+n+y+r)}function u(h,f,g,y){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),y.push({i:g.push(o(g)+"rotate(",null,i)-2,x:us(h,f)})):f&&g.push(o(g)+"rotate("+f+i)}function c(h,f,g,y){h!==f?y.push({i:g.push(o(g)+"skewX(",null,i)-2,x:us(h,f)}):f&&g.push(o(g)+"skewX("+f+i)}function p(h,f,g,y,x,N){if(h!==g||f!==y){var _=x.push(o(x)+"scale(",null,",",null,")");N.push({i:_-4,x:us(h,g)},{i:_-2,x:us(f,y)})}else(g!==1||y!==1)&&x.push(o(x)+"scale("+g+","+y+")")}return function(h,f){var g=[],y=[];return h=e(h),f=e(f),l(h.translateX,h.translateY,f.translateX,f.translateY,g,y),u(h.rotate,f.rotate,g,y),c(h.skewX,f.skewX,g,y),p(h.scaleX,h.scaleY,f.scaleX,f.scaleY,g,y),h=f=null,function(x){for(var N=-1,_=y.length,S;++N<_;)g[(S=y[N]).i]=S.x(x);return g.join("")}}}var X2=jE(Y2,"px, ","px)","deg)"),Q2=jE(K2,", ",")",")"),Z2=1e-12;function Pw(e){return((e=Math.exp(e))+1/e)/2}function J2(e){return((e=Math.exp(e))-1/e)/2}function eA(e){return((e=Math.exp(2*e))-1)/(e+1)}const tA=(function e(n,r,i){function o(l,u){var c=l[0],p=l[1],h=l[2],f=u[0],g=u[1],y=u[2],x=f-c,N=g-p,_=x*x+N*N,S,b;if(_<Z2)b=Math.log(y/h)/n,S=function(L){return[c+L*x,p+L*N,h*Math.exp(n*L*b)]};else{var k=Math.sqrt(_),E=(y*y-h*h+i*_)/(2*h*r*k),C=(y*y-h*h-i*_)/(2*y*r*k),R=Math.log(Math.sqrt(E*E+1)-E),I=Math.log(Math.sqrt(C*C+1)-C);b=(I-R)/n,S=function(L){var H=L*b,P=Pw(R),q=h/(r*k)*(P*eA(n*H+R)-J2(R));return[c+q*x,p+q*N,h*P/Pw(n*H+R)]}}return S.duration=b*1e3*n/Math.SQRT2,S}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,AE=1e3,Ql,ea,Zl=0,Zs=0,uu=0,ua=typeof performance=="object"&&performance.now?performance:Date,IE=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function mv(){return Zs||(IE(nA),Zs=ua.now()+uu)}function nA(){Zs=0}function Jl(){this._call=this._time=this._next=null}Jl.prototype=ME.prototype={constructor:Jl,restart:function(e,n,r){if(typeof e!="function")throw new TypeError("callback is not a function");r=(r==null?mv():+r)+(n==null?0:+n),!this._next&&ea!==this&&(ea?ea._next=this:Ql=this,ea=this),this._call=e,this._time=r,Wg()},stop:function(){this._call&&(this._call=null,this._time=1/0,Wg())}};function ME(e,n,r){var i=new Jl;return i.restart(e,n,r),i}function rA(){mv(),++eo;for(var e=Ql,n;e;)(n=Zs-e._time)>=0&&e._call.call(void 0,n),e=e._next;--eo}function Ow(){Zs=(Zl=ua.now())+uu,eo=Jo=0;try{rA()}finally{eo=0,iA(),Zs=0}}function sA(){var e=ua.now(),n=e-Zl;n>AE&&(uu-=n,Zl=e)}function iA(){for(var e,n=Ql,r,i=1/0;n;)n._call?(i>n._time&&(i=n._time),e=n,n=n._next):(r=n._next,n._next=null,n=e?e._next=r:Ql=r);ea=e,Wg(i)}function Wg(e){if(!eo){Jo&&(Jo=clearTimeout(Jo));var n=e-Zs;n>24?(e<1/0&&(Jo=setTimeout(Ow,e-ua.now()-uu)),Go&&(Go=clearInterval(Go))):(Go||(Zl=ua.now(),Go=setInterval(sA,AE)),eo=1,IE(Ow))}}function Lw(e,n,r){var i=new Jl;return n=n==null?0:+n,i.restart(o=>{i.stop(),e(o+n)},n,r),i}var oA=au("start","end","cancel","interrupt"),aA=[],PE=0,qw=1,Vg=2,Hl=3,$w=4,Gg=5,Wl=6;function cu(e,n,r,i,o,l){var u=e.__transition;if(!u)e.__transition={};else if(r in u)return;lA(e,r,{name:n,index:i,group:o,on:oA,tween:aA,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:PE})}function gv(e,n){var r=Qn(e,n);if(r.state>PE)throw new Error("too late; already scheduled");return r}function cr(e,n){var r=Qn(e,n);if(r.state>Hl)throw new Error("too late; already running");return r}function Qn(e,n){var r=e.__transition;if(!r||!(r=r[n]))throw new Error("transition not found");return r}function lA(e,n,r){var i=e.__transition,o;i[n]=r,r.timer=ME(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,g,y,x;if(r.state!==qw)return p();for(f in i)if(x=i[f],x.name===r.name){if(x.state===Hl)return Lw(u);x.state===$w?(x.state=Wl,x.timer.stop(),x.on.call("interrupt",e,e.__data__,x.index,x.group),delete i[f]):+f<n&&(x.state=Wl,x.timer.stop(),x.on.call("cancel",e,e.__data__,x.index,x.group),delete i[f])}if(Lw(function(){r.state===Hl&&(r.state=$w,r.timer.restart(c,r.delay,r.time),c(h))}),r.state=Vg,r.on.call("start",e,e.__data__,r.index,r.group),r.state===Vg){for(r.state=Hl,o=new Array(y=r.tween.length),f=0,g=-1;f<y;++f)(x=r.tween[f].value.call(e,e.__data__,r.index,r.group))&&(o[++g]=x);o.length=g+1}}function c(h){for(var f=h<r.duration?r.ease.call(null,h/r.duration):(r.timer.restart(p),r.state=Gg,1),g=-1,y=o.length;++g<y;)o[g].call(e,f);r.state===Gg&&(r.on.call("end",e,e.__data__,r.index,r.group),p())}function p(){r.state=Wl,r.timer.stop(),delete i[n];for(var h in i)return;delete e.__transition}}function Vl(e,n){var r=e.__transition,i,o,l=!0,u;if(r){n=n==null?null:n+"";for(u in r){if((i=r[u]).name!==n){l=!1;continue}o=i.state>Vg&&i.state<Gg,i.state=Wl,i.timer.stop(),i.on.call(o?"interrupt":"cancel",e,e.__data__,i.index,i.group),delete r[u]}l&&delete e.__transition}}function uA(e){return this.each(function(){Vl(this,e)})}function cA(e,n){var r,i;return function(){var o=cr(this,e),l=o.tween;if(l!==r){i=r=l;for(var u=0,c=i.length;u<c;++u)if(i[u].name===n){i=i.slice(),i.splice(u,1);break}}o.tween=i}}function dA(e,n,r){var i,o;if(typeof r!="function")throw new Error;return function(){var l=cr(this,e),u=l.tween;if(u!==i){o=(i=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 fA(e,n){var r=this._id;if(e+="",arguments.length<2){for(var i=Qn(this.node(),r).tween,o=0,l=i.length,u;o<l;++o)if((u=i[o]).name===e)return u.value;return null}return this.each((n==null?cA:dA)(r,e,n))}function vv(e,n,r){var i=e._id;return e.each(function(){var o=cr(this,i);(o.value||(o.value={}))[n]=r.apply(this,arguments)}),function(o){return Qn(o,i).value[n]}}function OE(e,n){var r;return(typeof n=="number"?us:n instanceof la?Iw:(r=la(n))?(n=r,Iw):G2)(e,n)}function hA(e){return function(){this.removeAttribute(e)}}function pA(e){return function(){this.removeAttributeNS(e.space,e.local)}}function mA(e,n,r){var i,o=r+"",l;return function(){var u=this.getAttribute(e);return u===o?null:u===i?l:l=n(i=u,r)}}function gA(e,n,r){var i,o=r+"",l;return function(){var u=this.getAttributeNS(e.space,e.local);return u===o?null:u===i?l:l=n(i=u,r)}}function vA(e,n,r){var i,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===i&&p===o?l:(o=p,l=n(i=u,c)))}}function yA(e,n,r){var i,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===i&&p===o?l:(o=p,l=n(i=u,c)))}}function wA(e,n){var r=lu(e),i=r==="transform"?Q2:OE;return this.attrTween(e,typeof n=="function"?(r.local?yA:vA)(r,i,vv(this,"attr."+e,n)):n==null?(r.local?pA:hA)(r):(r.local?gA:mA)(r,i,n))}function xA(e,n){return function(r){this.setAttribute(e,n.call(this,r))}}function _A(e,n){return function(r){this.setAttributeNS(e.space,e.local,n.call(this,r))}}function bA(e,n){var r,i;function o(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&_A(e,l)),r}return o._value=n,o}function SA(e,n){var r,i;function o(){var l=n.apply(this,arguments);return l!==i&&(r=(i=l)&&xA(e,l)),r}return o._value=n,o}function kA(e,n){var r="attr."+e;if(arguments.length<2)return(r=this.tween(r))&&r._value;if(n==null)return this.tween(r,null);if(typeof n!="function")throw new Error;var i=lu(e);return this.tween(r,(i.local?bA:SA)(i,n))}function EA(e,n){return function(){gv(this,e).delay=+n.apply(this,arguments)}}function NA(e,n){return n=+n,function(){gv(this,e).delay=n}}function CA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?EA:NA)(n,e)):Qn(this.node(),n).delay}function TA(e,n){return function(){cr(this,e).duration=+n.apply(this,arguments)}}function RA(e,n){return n=+n,function(){cr(this,e).duration=n}}function jA(e){var n=this._id;return arguments.length?this.each((typeof e=="function"?TA:RA)(n,e)):Qn(this.node(),n).duration}function AA(e,n){if(typeof n!="function")throw new Error;return function(){cr(this,e).ease=n}}function IA(e){var n=this._id;return arguments.length?this.each(AA(n,e)):Qn(this.node(),n).ease}function MA(e,n){return function(){var r=n.apply(this,arguments);if(typeof r!="function")throw new Error;cr(this,e).ease=r}}function PA(e){if(typeof e!="function")throw new Error;return this.each(MA(this._id,e))}function OA(e){typeof e!="function"&&(e=hE(e));for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o)for(var l=n[o],u=l.length,c=i[o]=[],p,h=0;h<u;++h)(p=l[h])&&e.call(p,p.__data__,h,l)&&c.push(p);return new Mr(i,this._parents,this._name,this._id)}function LA(e){if(e._id!==this._id)throw new Error;for(var n=this._groups,r=e._groups,i=n.length,o=r.length,l=Math.min(i,o),u=new Array(i),c=0;c<l;++c)for(var p=n[c],h=r[c],f=p.length,g=u[c]=new Array(f),y,x=0;x<f;++x)(y=p[x]||h[x])&&(g[x]=y);for(;c<i;++c)u[c]=n[c];return new Mr(u,this._parents,this._name,this._id)}function qA(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 $A(e,n,r){var i,o,l=qA(n)?gv:cr;return function(){var u=l(this,e),c=u.on;c!==i&&(o=(i=c).copy()).on(n,r),u.on=o}}function DA(e,n){var r=this._id;return arguments.length<2?Qn(this.node(),r).on.on(e):this.each($A(r,e,n))}function FA(e){return function(){var n=this.parentNode;for(var r in this.__transition)if(+r!==e)return;n&&n.removeChild(this)}}function zA(){return this.on("end.remove",FA(this._id))}function BA(e){var n=this._name,r=this._id;typeof e!="function"&&(e=fv(e));for(var i=this._groups,o=i.length,l=new Array(o),u=0;u<o;++u)for(var c=i[u],p=c.length,h=l[u]=new Array(p),f,g,y=0;y<p;++y)(f=c[y])&&(g=e.call(f,f.__data__,y,c))&&("__data__"in f&&(g.__data__=f.__data__),h[y]=g,cu(h[y],n,r,y,h,Qn(f,r)));return new Mr(l,this._parents,n,r)}function UA(e){var n=this._name,r=this._id;typeof e!="function"&&(e=fE(e));for(var i=this._groups,o=i.length,l=[],u=[],c=0;c<o;++c)for(var p=i[c],h=p.length,f,g=0;g<h;++g)if(f=p[g]){for(var y=e.call(f,f.__data__,g,p),x,N=Qn(f,r),_=0,S=y.length;_<S;++_)(x=y[_])&&cu(x,n,r,_,y,N);l.push(y),u.push(f)}return new Mr(l,u,n,r)}var HA=ga.prototype.constructor;function WA(){return new HA(this._groups,this._parents)}function VA(e,n){var r,i,o;return function(){var l=Ji(this,e),u=(this.style.removeProperty(e),Ji(this,e));return l===u?null:l===r&&u===i?o:o=n(r=l,i=u)}}function LE(e){return function(){this.style.removeProperty(e)}}function GA(e,n,r){var i,o=r+"",l;return function(){var u=Ji(this,e);return u===o?null:u===i?l:l=n(i=u,r)}}function YA(e,n,r){var i,o,l;return function(){var u=Ji(this,e),c=r(this),p=c+"";return c==null&&(p=c=(this.style.removeProperty(e),Ji(this,e))),u===p?null:u===i&&p===o?l:(o=p,l=n(i=u,c))}}function KA(e,n){var r,i,o,l="style."+n,u="end."+l,c;return function(){var p=cr(this,e),h=p.on,f=p.value[l]==null?c||(c=LE(n)):void 0;(h!==r||o!==f)&&(i=(r=h).copy()).on(u,o=f),p.on=i}}function XA(e,n,r){var i=(e+="")=="transform"?X2:OE;return n==null?this.styleTween(e,VA(e,i)).on("end.style."+e,LE(e)):typeof n=="function"?this.styleTween(e,YA(e,i,vv(this,"style."+e,n))).each(KA(this._id,e)):this.styleTween(e,GA(e,i,n),r).on("end.style."+e,null)}function QA(e,n,r){return function(i){this.style.setProperty(e,n.call(this,i),r)}}function ZA(e,n,r){var i,o;function l(){var u=n.apply(this,arguments);return u!==o&&(i=(o=u)&&QA(e,u,r)),i}return l._value=n,l}function JA(e,n,r){var i="style."+(e+="");if(arguments.length<2)return(i=this.tween(i))&&i._value;if(n==null)return this.tween(i,null);if(typeof n!="function")throw new Error;return this.tween(i,ZA(e,n,r??""))}function eI(e){return function(){this.textContent=e}}function tI(e){return function(){var n=e(this);this.textContent=n??""}}function nI(e){return this.tween("text",typeof e=="function"?tI(vv(this,"text",e)):eI(e==null?"":e+""))}function rI(e){return function(n){this.textContent=e.call(this,n)}}function sI(e){var n,r;function i(){var o=e.apply(this,arguments);return o!==r&&(n=(r=o)&&rI(o)),n}return i._value=e,i}function iI(e){var n="text";if(arguments.length<1)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,sI(e))}function oI(){for(var e=this._name,n=this._id,r=qE(),i=this._groups,o=i.length,l=0;l<o;++l)for(var u=i[l],c=u.length,p,h=0;h<c;++h)if(p=u[h]){var f=Qn(p,n);cu(p,e,r,h,u,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Mr(i,this._parents,e,r)}function aI(){var e,n,r=this,i=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=cr(this,i),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 lI=0;function Mr(e,n,r,i){this._groups=e,this._parents=n,this._name=r,this._id=i}function qE(){return++lI}var Rr=ga.prototype;Mr.prototype={constructor:Mr,select:BA,selectAll:UA,selectChild:Rr.selectChild,selectChildren:Rr.selectChildren,filter:OA,merge:LA,selection:WA,transition:oI,call:Rr.call,nodes:Rr.nodes,node:Rr.node,size:Rr.size,empty:Rr.empty,each:Rr.each,on:DA,attr:wA,attrTween:kA,style:XA,styleTween:JA,text:nI,textTween:iI,remove:zA,tween:fA,delay:CA,duration:jA,ease:IA,easeVarying:PA,end:aI,[Symbol.iterator]:Rr[Symbol.iterator]};function uI(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cI={time:null,delay:0,duration:250,ease:uI};function dI(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 fI(e){var n,r;e instanceof Mr?(n=e._id,e=e._name):(n=qE(),(r=cI).time=mv(),e=e==null?null:e+"");for(var i=this._groups,o=i.length,l=0;l<o;++l)for(var u=i[l],c=u.length,p,h=0;h<c;++h)(p=u[h])&&cu(p,e,n,h,u,r||dI(p,n));return new Mr(i,this._parents,e,n)}ga.prototype.interrupt=uA;ga.prototype.transition=fI;const jl=e=>()=>e;function hI(e,{sourceEvent:n,target:r,transform:i,dispatch:o}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},transform:{value:i,enumerable:!0,configurable:!0},_:{value:o}})}function 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 pd(e){e.stopImmediatePropagation()}function Yo(e){e.preventDefault(),e.stopImmediatePropagation()}function pI(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function mI(){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 Dw(){return this.__zoom||Ir}function gI(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vI(){return navigator.maxTouchPoints||"ontouchstart"in this}function yI(e,n,r){var i=e.invertX(n[0][0])-r[0][0],o=e.invertX(n[1][0])-r[1][0],l=e.invertY(n[0][1])-r[0][1],u=e.invertY(n[1][1])-r[1][1];return e.translate(o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o),u>l?(l+u)/2:Math.min(0,l)||Math.max(0,u))}function $E(){var e=pI,n=mI,r=yI,i=gI,o=vI,l=[0,1/0],u=[[-1/0,-1/0],[1/0,1/0]],c=250,p=tA,h=au("start","zoom","end"),f,g,y,x=500,N=150,_=0,S=10;function b(j){j.property("__zoom",Dw).on("wheel.zoom",H,{passive:!1}).on("mousedown.zoom",P).on("dblclick.zoom",q).filter(o).on("touchstart.zoom",B).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(j,Z,W,ne){var J=j.selection?j.selection():j;J.property("__zoom",Dw),j!==J?R(j,Z,W,ne):J.interrupt().each(function(){I(this,arguments).event(ne).start().zoom(null,typeof Z=="function"?Z.apply(this,arguments):Z).end()})},b.scaleBy=function(j,Z,W,ne){b.scaleTo(j,function(){var J=this.__zoom.k,U=typeof Z=="function"?Z.apply(this,arguments):Z;return J*U},W,ne)},b.scaleTo=function(j,Z,W,ne){b.transform(j,function(){var J=n.apply(this,arguments),U=this.__zoom,X=W==null?C(J):typeof W=="function"?W.apply(this,arguments):W,M=U.invert(X),V=typeof Z=="function"?Z.apply(this,arguments):Z;return r(E(k(U,V),X,M),J,u)},W,ne)},b.translateBy=function(j,Z,W,ne){b.transform(j,function(){return r(this.__zoom.translate(typeof Z=="function"?Z.apply(this,arguments):Z,typeof W=="function"?W.apply(this,arguments):W),n.apply(this,arguments),u)},null,ne)},b.translateTo=function(j,Z,W,ne,J){b.transform(j,function(){var U=n.apply(this,arguments),X=this.__zoom,M=ne==null?C(U):typeof ne=="function"?ne.apply(this,arguments):ne;return r(Ir.translate(M[0],M[1]).scale(X.k).translate(typeof Z=="function"?-Z.apply(this,arguments):-Z,typeof W=="function"?-W.apply(this,arguments):-W),U,u)},ne,J)};function k(j,Z){return Z=Math.max(l[0],Math.min(l[1],Z)),Z===j.k?j:new Ar(Z,j.x,j.y)}function E(j,Z,W){var ne=Z[0]-W[0]*j.k,J=Z[1]-W[1]*j.k;return ne===j.x&&J===j.y?j:new Ar(j.k,ne,J)}function C(j){return[(+j[0][0]+ +j[1][0])/2,(+j[0][1]+ +j[1][1])/2]}function R(j,Z,W,ne){j.on("start.zoom",function(){I(this,arguments).event(ne).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(ne).end()}).tween("zoom",function(){var J=this,U=arguments,X=I(J,U).event(ne),M=n.apply(J,U),V=W==null?C(M):typeof W=="function"?W.apply(J,U):W,O=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),$=J.__zoom,Y=typeof Z=="function"?Z.apply(J,U):Z,te=p($.invert(V).concat(O/$.k),Y.invert(V).concat(O/Y.k));return function(oe){if(oe===1)oe=Y;else{var ce=te(oe),pe=O/ce[2];oe=new Ar(pe,V[0]-ce[0]*pe,V[1]-ce[1]*pe)}X.zoom(null,oe)}})}function I(j,Z,W){return!W&&j.__zooming||new L(j,Z)}function L(j,Z){this.that=j,this.args=Z,this.active=0,this.sourceEvent=null,this.extent=n.apply(j,Z),this.taps=0}L.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,Z){return this.mouse&&j!=="mouse"&&(this.mouse[1]=Z.invert(this.mouse[0])),this.touch0&&j!=="touch"&&(this.touch0[1]=Z.invert(this.touch0[0])),this.touch1&&j!=="touch"&&(this.touch1[1]=Z.invert(this.touch1[0])),this.that.__zoom=Z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(j){var Z=Nn(this.that).datum();h.call(j,this.that,new hI(j,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),Z)}};function H(j,...Z){if(!e.apply(this,arguments))return;var W=I(this,Z).event(j),ne=this.__zoom,J=Math.max(l[0],Math.min(l[1],ne.k*Math.pow(2,i.apply(this,arguments)))),U=Gn(j);if(W.wheel)(W.mouse[0][0]!==U[0]||W.mouse[0][1]!==U[1])&&(W.mouse[1]=ne.invert(W.mouse[0]=U)),clearTimeout(W.wheel);else{if(ne.k===J)return;W.mouse=[U,ne.invert(U)],Vl(this),W.start()}Yo(j),W.wheel=setTimeout(X,N),W.zoom("mouse",r(E(k(ne,J),W.mouse[0],W.mouse[1]),W.extent,u));function X(){W.wheel=null,W.end()}}function P(j,...Z){if(y||!e.apply(this,arguments))return;var W=j.currentTarget,ne=I(this,Z,!0).event(j),J=Nn(j.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",O,!0),U=Gn(j,W),X=j.clientX,M=j.clientY;SE(j.view),pd(j),ne.mouse=[U,this.__zoom.invert(U)],Vl(this),ne.start();function V($){if(Yo($),!ne.moved){var Y=$.clientX-X,te=$.clientY-M;ne.moved=Y*Y+te*te>_}ne.event($).zoom("mouse",r(E(ne.that.__zoom,ne.mouse[0]=Gn($,W),ne.mouse[1]),ne.extent,u))}function O($){J.on("mousemove.zoom mouseup.zoom",null),kE($.view,ne.moved),Yo($),ne.event($).end()}}function q(j,...Z){if(e.apply(this,arguments)){var W=this.__zoom,ne=Gn(j.changedTouches?j.changedTouches[0]:j,this),J=W.invert(ne),U=W.k*(j.shiftKey?.5:2),X=r(E(k(W,U),ne,J),n.apply(this,Z),u);Yo(j),c>0?Nn(this).transition().duration(c).call(R,X,ne,j):Nn(this).call(b.transform,X,ne,j)}}function B(j,...Z){if(e.apply(this,arguments)){var W=j.touches,ne=W.length,J=I(this,Z,j.changedTouches.length===ne).event(j),U,X,M,V;for(pd(j),X=0;X<ne;++X)M=W[X],V=Gn(M,this),V=[V,this.__zoom.invert(V),M.identifier],J.touch0?!J.touch1&&J.touch0[2]!==V[2]&&(J.touch1=V,J.taps=0):(J.touch0=V,U=!0,J.taps=1+!!f);f&&(f=clearTimeout(f)),U&&(J.taps<2&&(g=V[0],f=setTimeout(function(){f=null},x)),Vl(this),J.start())}}function D(j,...Z){if(this.__zooming){var W=I(this,Z).event(j),ne=j.changedTouches,J=ne.length,U,X,M,V;for(Yo(j),U=0;U<J;++U)X=ne[U],M=Gn(X,this),W.touch0&&W.touch0[2]===X.identifier?W.touch0[0]=M:W.touch1&&W.touch1[2]===X.identifier&&(W.touch1[0]=M);if(X=W.that.__zoom,W.touch1){var O=W.touch0[0],$=W.touch0[1],Y=W.touch1[0],te=W.touch1[1],oe=(oe=Y[0]-O[0])*oe+(oe=Y[1]-O[1])*oe,ce=(ce=te[0]-$[0])*ce+(ce=te[1]-$[1])*ce;X=k(X,Math.sqrt(oe/ce)),M=[(O[0]+Y[0])/2,(O[1]+Y[1])/2],V=[($[0]+te[0])/2,($[1]+te[1])/2]}else if(W.touch0)M=W.touch0[0],V=W.touch0[1];else return;W.zoom("touch",r(E(X,M,V),W.extent,u))}}function F(j,...Z){if(this.__zooming){var W=I(this,Z).event(j),ne=j.changedTouches,J=ne.length,U,X;for(pd(j),y&&clearTimeout(y),y=setTimeout(function(){y=null},x),U=0;U<J;++U)X=ne[U],W.touch0&&W.touch0[2]===X.identifier?delete W.touch0:W.touch1&&W.touch1[2]===X.identifier&&delete W.touch1;if(W.touch1&&!W.touch0&&(W.touch0=W.touch1,delete W.touch1),W.touch0)W.touch0[1]=this.__zoom.invert(W.touch0[0]);else if(W.end(),W.taps===2&&(X=Gn(X,this),Math.hypot(g[0]-X[0],g[1]-X[1])<S)){var M=Nn(this).on("dblclick.zoom");M&&M.apply(this,arguments)}}}return b.wheelDelta=function(j){return arguments.length?(i=typeof j=="function"?j:jl(+j),b):i},b.filter=function(j){return arguments.length?(e=typeof j=="function"?j:jl(!!j),b):e},b.touchable=function(j){return arguments.length?(o=typeof j=="function"?j:jl(!!j),b):o},b.extent=function(j){return arguments.length?(n=typeof j=="function"?j:jl([[+j[0][0],+j[0][1]],[+j[1][0],+j[1][1]]]),b):n},b.scaleExtent=function(j){return arguments.length?(l[0]=+j[0],l[1]=+j[1],b):[l[0],l[1]]},b.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],b):[[u[0][0],u[0][1]],[u[1][0],u[1][1]]]},b.constrain=function(j){return arguments.length?(r=j,b):r},b.duration=function(j){return arguments.length?(c=+j,b):c},b.interpolate=function(j){return arguments.length?(p=j,b):p},b.on=function(){var j=h.on.apply(h,arguments);return j===h?b:j},b.clickDistance=function(j){return arguments.length?(_=(j=+j)*j,b):Math.sqrt(_)},b.tapDistance=function(j){return arguments.length?(S=+j,b):S},b}var wI=uE();const du=A.createContext(null),xI=du.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.`},DE=Pr.error001();function Xe(e,n){const r=A.useContext(du);if(r===null)throw new Error(DE);return cE(r,e,n)}const Et=()=>{const e=A.useContext(du);if(e===null)throw new Error(DE);return A.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},_I=e=>e.userSelectionActive?"none":"all";function yv({position:e,children:n,className:r,style:i,...o}){const l=Xe(_I),u=`${e}`.split("-");return le.createElement("div",{className:$t(["react-flow__panel",r,...u]),style:{...i,pointerEvents:l},...o},n)}function bI({proOptions:e,position:n="bottom-right"}){return e!=null&&e.hideAttribution?null:le.createElement(yv,{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"},le.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const SI=({x:e,y:n,label:r,labelStyle:i={},labelShowBg:o=!0,labelBgStyle:l={},labelBgPadding:u=[2,4],labelBgBorderRadius:c=2,children:p,className:h,...f})=>{const g=A.useRef(null),[y,x]=A.useState({x:0,y:0,width:0,height:0}),N=$t(["react-flow__edge-textwrapper",h]);return A.useEffect(()=>{if(g.current){const _=g.current.getBBox();x({x:_.x,y:_.y,width:_.width,height:_.height})}},[r]),typeof r>"u"||!r?null:le.createElement("g",{transform:`translate(${e-y.width/2} ${n-y.height/2})`,className:N,visibility:y.width?"visible":"hidden",...f},o&&le.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}),le.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:g,style:i},r),p)};var kI=A.memo(SI);const wv=e=>({width:e.offsetWidth,height:e.offsetHeight}),to=(e,n=0,r=1)=>Math.min(Math.max(e,n),r),xv=(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])}),Fw=(e,n,r)=>e<n?to(Math.abs(e-n),1,50)/50:e>r?-to(Math.abs(e-r),1,50)/50:0,FE=(e,n)=>{const r=Fw(e.x,35,n.width-35)*20,i=Fw(e.y,35,n.height-35)*20;return[r,i]},zE=e=>{var n;return((n=e.getRootNode)==null?void 0:n.call(e))||(window==null?void 0:window.document)},BE=(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:i})=>({x:e,y:n,x2:e+r,y2:n+i}),UE=({x:e,y:n,x2:r,y2:i})=>({x:e,y:n,width:r-e,height:i-n}),zw=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),EI=(e,n)=>UE(BE(ca(e),ca(n))),Yg=(e,n)=>{const r=Math.max(0,Math.min(e.x+e.width,n.x+n.width)-Math.max(e.x,n.x)),i=Math.max(0,Math.min(e.y+e.height,n.y+n.height)-Math.max(e.y,n.y));return Math.ceil(r*i)},NI=e=>Cn(e.width)&&Cn(e.height)&&Cn(e.x)&&Cn(e.y),Cn=e=>!isNaN(e)&&isFinite(e),ht=Symbol.for("internals"),HE=["Enter"," ","Escape"],CI=(e,n)=>{},TI=e=>"nativeEvent"in e;function Kg(e){var o,l;const n=TI(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 WE=e=>"clientX"in e,fs=(e,n)=>{var l,u;const r=WE(e),i=r?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,o=r?e.clientY:(u=e.touches)==null?void 0:u[0].clientY;return{x:i-((n==null?void 0:n.left)??0),y:o-((n==null?void 0:n.top)??0)}},eu=()=>{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:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:y,interactionWidth:x=20})=>le.createElement(le.Fragment,null,le.createElement("path",{id:e,style:f,d:n,fill:"none",className:"react-flow__edge-path",markerEnd:g,markerStart:y}),x&&le.createElement("path",{d:n,fill:"none",strokeOpacity:0,strokeWidth:x,className:"react-flow__edge-interaction"}),o&&Cn(r)&&Cn(i)?le.createElement(kI,{x:r,y:i,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:i=>{const o=n().edges.find(l=>l.id===e);o&&r(i,{...o})}}function VE({sourceX:e,sourceY:n,targetX:r,targetY:i}){const o=Math.abs(r-e)/2,l=r<e?r+o:r-o,u=Math.abs(i-n)/2,c=i<n?i+u:i-u;return[l,c,o,u]}function GE({sourceX:e,sourceY:n,targetX:r,targetY:i,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+i*.125,f=Math.abs(p-e),g=Math.abs(h-n);return[p,h,f,g]}var Js;(function(e){e.Strict="strict",e.Loose="loose"})(Js||(Js={}));var Ks;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ks||(Ks={}));var da;(function(e){e.Partial="partial",e.Full="full"})(da||(da={}));var ds;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ds||(ds={}));var tu;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(tu||(tu={}));var Te;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Te||(Te={}));function Bw({pos:e,x1:n,y1:r,x2:i,y2:o}){return e===Te.Left||e===Te.Right?[.5*(n+i),r]:[n,.5*(r+o)]}function YE({sourceX:e,sourceY:n,sourcePosition:r=Te.Bottom,targetX:i,targetY:o,targetPosition:l=Te.Top}){const[u,c]=Bw({pos:r,x1:e,y1:n,x2:i,y2:o}),[p,h]=Bw({pos:l,x1:i,y1:o,x2:e,y2:n}),[f,g,y,x]=GE({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:u,sourceControlY:c,targetControlX:p,targetControlY:h});return[`M${e},${n} C${u},${c} ${p},${h} ${i},${o}`,f,g,y,x]}const _v=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,sourcePosition:o=Te.Bottom,targetPosition:l=Te.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:N,interactionWidth:_})=>{const[S,b,k]=YE({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:l});return le.createElement(ya,{path:S,labelX:b,labelY:k,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:N,interactionWidth:_})});_v.displayName="SimpleBezierEdge";const Uw={[Te.Left]:{x:-1,y:0},[Te.Right]:{x:1,y:0},[Te.Top]:{x:0,y:-1},[Te.Bottom]:{x:0,y:1}},RI=({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},Hw=(e,n)=>Math.sqrt(Math.pow(n.x-e.x,2)+Math.pow(n.y-e.y,2));function jI({source:e,sourcePosition:n=Te.Bottom,target:r,targetPosition:i=Te.Top,center:o,offset:l}){const u=Uw[n],c=Uw[i],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=RI({source:p,sourcePosition:n,target:h}),g=f.x!==0?"x":"y",y=f[g];let x=[],N,_;const S={x:0,y:0},b={x:0,y:0},[k,E,C,R]=VE({sourceX:e.x,sourceY:e.y,targetX:r.x,targetY:r.y});if(u[g]*c[g]===-1){N=o.x??k,_=o.y??E;const L=[{x:N,y:p.y},{x:N,y:h.y}],H=[{x:p.x,y:_},{x:h.x,y:_}];u[g]===y?x=g==="x"?L:H:x=g==="x"?H:L}else{const L=[{x:p.x,y:h.y}],H=[{x:h.x,y:p.y}];if(g==="x"?x=u.x===y?H:L:x=u.y===y?L:H,n===i){const F=Math.abs(e[g]-r[g]);if(F<=l){const j=Math.min(l-1,l-F);u[g]===y?S[g]=(p[g]>e[g]?-1:1)*j:b[g]=(h[g]>r[g]?-1:1)*j}}if(n!==i){const F=g==="x"?"y":"x",j=u[g]===c[F],Z=p[F]>h[F],W=p[F]<h[F];(u[g]===1&&(!j&&Z||j&&W)||u[g]!==1&&(!j&&W||j&&Z))&&(x=g==="x"?L:H)}const P={x:p.x+S.x,y:p.y+S.y},q={x:h.x+b.x,y:h.y+b.y},B=Math.max(Math.abs(P.x-x[0].x),Math.abs(q.x-x[0].x)),D=Math.max(Math.abs(P.y-x[0].y),Math.abs(q.y-x[0].y));B>=D?(N=(P.x+q.x)/2,_=x[0].y):(N=x[0].x,_=(P.y+q.y)/2)}return[[e,{x:p.x+S.x,y:p.y+S.y},...x,{x:h.x+b.x,y:h.y+b.y},r],N,_,C,R]}function AI(e,n,r,i){const o=Math.min(Hw(e,n)/2,Hw(n,r)/2,i),{x:l,y:u}=n;if(e.x===l&&l===r.x||e.y===u&&u===r.y)return`L${l} ${u}`;if(e.y===u){const 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 Xg({sourceX:e,sourceY:n,sourcePosition:r=Te.Bottom,targetX:i,targetY:o,targetPosition:l=Te.Top,borderRadius:u=5,centerX:c,centerY:p,offset:h=20}){const[f,g,y,x,N]=jI({source:{x:e,y:n},sourcePosition:r,target:{x:i,y:o},targetPosition:l,center:{x:c,y:p},offset:h});return[f.reduce((S,b,k)=>{let E="";return k>0&&k<f.length-1?E=AI(f[k-1],b,f[k+1],u):E=`${k===0?"M":"L"}${b.x} ${b.y}`,S+=E,S},""),g,y,x,N]}const fu=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,sourcePosition:g=Te.Bottom,targetPosition:y=Te.Top,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=Xg({sourceX:e,sourceY:n,sourcePosition:g,targetX:r,targetY:i,targetPosition:y,borderRadius:_==null?void 0:_.borderRadius,offset:_==null?void 0:_.offset});return le.createElement(ya,{path:b,labelX:k,labelY:E,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:x,markerStart:N,interactionWidth:S})});fu.displayName="SmoothStepEdge";const bv=A.memo(e=>{var n;return le.createElement(fu,{...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])})});bv.displayName="StepEdge";function II({sourceX:e,sourceY:n,targetX:r,targetY:i}){const[o,l,u,c]=VE({sourceX:e,sourceY:n,targetX:r,targetY:i});return[`M ${e},${n}L ${r},${i}`,o,l,u,c]}const Sv=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:y,interactionWidth:x})=>{const[N,_,S]=II({sourceX:e,sourceY:n,targetX:r,targetY:i});return le.createElement(ya,{path:N,labelX:_,labelY:S,label:o,labelStyle:l,labelShowBg:u,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:h,style:f,markerEnd:g,markerStart:y,interactionWidth:x})});Sv.displayName="StraightEdge";function Al(e,n){return e>=0?.5*e:n*25*Math.sqrt(-e)}function Ww({pos:e,x1:n,y1:r,x2:i,y2:o,c:l}){switch(e){case Te.Left:return[n-Al(n-i,l),r];case Te.Right:return[n+Al(i-n,l),r];case Te.Top:return[n,r-Al(r-o,l)];case Te.Bottom:return[n,r+Al(o-r,l)]}}function KE({sourceX:e,sourceY:n,sourcePosition:r=Te.Bottom,targetX:i,targetY:o,targetPosition:l=Te.Top,curvature:u=.25}){const[c,p]=Ww({pos:r,x1:e,y1:n,x2:i,y2:o,c:u}),[h,f]=Ww({pos:l,x1:i,y1:o,x2:e,y2:n,c:u}),[g,y,x,N]=GE({sourceX:e,sourceY:n,targetX:i,targetY:o,sourceControlX:c,sourceControlY:p,targetControlX:h,targetControlY:f});return[`M${e},${n} C${c},${p} ${h},${f} ${i},${o}`,g,y,x,N]}const nu=A.memo(({sourceX:e,sourceY:n,targetX:r,targetY:i,sourcePosition:o=Te.Bottom,targetPosition:l=Te.Top,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:N,pathOptions:_,interactionWidth:S})=>{const[b,k,E]=KE({sourceX:e,sourceY:n,sourcePosition:o,targetX:r,targetY:i,targetPosition:l,curvature:_==null?void 0:_.curvature});return le.createElement(ya,{path:b,labelX:k,labelY:E,label:u,labelStyle:c,labelShowBg:p,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:g,style:y,markerEnd:x,markerStart:N,interactionWidth:S})});nu.displayName="BezierEdge";const kv=A.createContext(null),MI=kv.Provider;kv.Consumer;const PI=()=>A.useContext(kv),OI=e=>"id"in e&&"source"in e&&"target"in e,LI=({source:e,sourceHandle:n,target:r,targetHandle:i})=>`reactflow__edge-${e}${n||""}-${r}${i||""}`,Qg=(e,n)=>typeof e>"u"?"":typeof e=="string"?e:`${n?`${n}__`:""}${Object.keys(e).sort().map(i=>`${i}=${e[i]}`).join("&")}`,qI=(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)),$I=(e,n)=>{if(!e.source||!e.target)return n;let r;return OI(e)?r={...e}:r={...e,id:LI(e)},qI(r,n)?n:n.concat(r)},Zg=({x:e,y:n},[r,i,o],l,[u,c])=>{const p={x:(e-r)/o,y:(n-i)/o};return l?{x:u*Math.round(p.x/u),y:c*Math.round(p.y/c)}:p},XE=({x:e,y:n},[r,i,o])=>({x:e*o+r,y:n*o+i}),Qs=(e,n=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const r=(e.width??0)*n[0],i=(e.height??0)*n[1],o={x:e.position.x-r,y:e.position.y-i};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-r,y:e.positionAbsolute.y-i}:o}},hu=(e,n=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const r=e.reduce((i,o)=>{const{x:l,y:u}=Qs(o,n).positionAbsolute;return BE(i,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 UE(r)},QE=(e,n,[r,i,o]=[0,0,1],l=!1,u=!1,c=[0,0])=>{const p={x:(n.x-r)/o,y:(n.y-i)/o,width:n.width/o,height:n.height/o},h=[];return e.forEach(f=>{const{width:g,height:y,selectable:x=!0,hidden:N=!1}=f;if(u&&!x||N)return!1;const{positionAbsolute:_}=Qs(f,c),S={x:_.x,y:_.y,width:g||0,height:y||0},b=Yg(p,S),k=typeof g>"u"||typeof y>"u"||g===null||y===null,E=l&&b>0,C=(g||0)*(y||0);(k||E||b>=C||f.dragging)&&h.push(f)}),h},ZE=(e,n)=>{const r=e.map(i=>i.id);return n.filter(i=>r.includes(i.source)||r.includes(i.target))},JE=(e,n,r,i,o,l=.1)=>{const u=n/(e.width*(1+l)),c=r/(e.height*(1+l)),p=Math.min(u,c),h=to(p,i,o),f=e.x+e.width/2,g=e.y+e.height/2,y=n/2-f*h,x=r/2-g*h;return{x:y,y:x,zoom:h}},Gs=(e,n=0)=>e.transition().duration(n);function Vw(e,n,r,i){return(n[r]||[]).reduce((o,l)=>{var u,c;return`${e.id}-${l.id}-${r}`!==i&&o.push({id:l.id||null,type:r,nodeId:e.id,x:(((u=e.positionAbsolute)==null?void 0:u.x)??0)+l.x+l.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+l.y+l.height/2}),o},[])}function DI(e,n,r,i,o,l){const{x:u,y:c}=fs(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 _=Ev(void 0,h),S=h.getAttribute("data-handleid"),b=l({nodeId:N,id:S,type:_});if(b){const k=o.find(E=>E.nodeId===N&&E.type===_&&E.id===S);return{handle:{id:S,type:_,nodeId:N,x:(k==null?void 0:k.x)||r.x,y:(k==null?void 0:k.y)||r.y},validHandleResult:b}}}}let f=[],g=1/0;if(o.forEach(N=>{const _=Math.sqrt((N.x-r.x)**2+(N.y-r.y)**2);if(_<=i){const S=l(N);_<=g&&(_<g?f=[{handle:N,validHandleResult:S}]:_===g&&f.push({handle:N,validHandleResult:S}),g=_)}}),!f.length)return{handle:null,validHandleResult:eN()};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 FI={source:null,target:null,sourceHandle:null,targetHandle:null},eN=()=>({handleDomNode:null,isValid:!1,connection:FI,endHandle:null});function tN(e,n,r,i,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={...eN(),handleDomNode:p};if(p){const f=Ev(void 0,p),g=p.getAttribute("data-nodeid"),y=p.getAttribute("data-handleid"),x=p.classList.contains("connectable"),N=p.classList.contains("connectableend"),_={source:c?g:r,sourceHandle:c?y:i,target:c?r:g,targetHandle:c?i:y};h.connection=_,x&&N&&(n===Js.Strict?c&&f==="source"||!c&&f==="target":g!==r||y!==i)&&(h.endHandle={nodeId:g,handleId:y,type:f},h.isValid=l(_))}return h}function zI({nodes:e,nodeId:n,handleId:r,handleType:i}){return e.reduce((o,l)=>{if(l[ht]){const{handleBounds:u}=l[ht];let c=[],p=[];u&&(c=Vw(l,u,"source",`${n}-${r}-${i}`),p=Vw(l,u,"target",`${n}-${r}-${i}`)),o.push(...c,...p)}return o},[])}function Ev(e,n){return e||(n!=null&&n.classList.contains("target")?"target":n!=null&&n.classList.contains("source")?"source":null)}function md(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function BI(e,n){let r=null;return n?r="valid":e&&!n&&(r="invalid"),r}function nN({event:e,handleId:n,nodeId:r,onConnect:i,isTarget:o,getState:l,setState:u,isValidConnection:c,edgeUpdaterType:p,onReconnectEnd:h}){const f=zE(e.target),{connectionMode:g,domNode:y,autoPanOnConnect:x,connectionRadius:N,onConnectStart:_,panBy:S,getNodes:b,cancelConnection:k}=l();let E=0,C;const{x:R,y:I}=fs(e),L=f==null?void 0:f.elementFromPoint(R,I),H=Ev(p,L),P=y==null?void 0:y.getBoundingClientRect();if(!P||!H)return;let q,B=fs(e,P),D=!1,F=null,j=!1,Z=null;const W=zI({nodes:b(),nodeId:r,handleId:n,handleType:H}),ne=()=>{if(!x)return;const[X,M]=FE(B,P);S({x:X,y:M}),E=requestAnimationFrame(ne)};u({connectionPosition:B,connectionStatus:null,connectionNodeId:r,connectionHandleId:n,connectionHandleType:H,connectionStartHandle:{nodeId:r,handleId:n,type:H},connectionEndHandle:null}),_==null||_(e,{nodeId:r,handleId:n,handleType:H});function J(X){const{transform:M}=l();B=fs(X,P);const{handle:V,validHandleResult:O}=DI(X,f,Zg(B,M,!1,[1,1]),N,W,$=>tN($,g,r,n,o?"target":"source",c,f));if(C=V,D||(ne(),D=!0),Z=O.handleDomNode,F=O.connection,j=O.isValid,u({connectionPosition:C&&j?XE({x:C.x,y:C.y},M):B,connectionStatus:BI(!!C,j),connectionEndHandle:O.endHandle}),!C&&!j&&!Z)return md(q);F.source!==F.target&&Z&&(md(q),q=Z,Z.classList.add("connecting","react-flow__handle-connecting"),Z.classList.toggle("valid",j),Z.classList.toggle("react-flow__handle-valid",j))}function U(X){var M,V;(C||Z)&&F&&j&&(i==null||i(F)),(V=(M=l()).onConnectEnd)==null||V.call(M,X),p&&(h==null||h(X)),md(q),k(),cancelAnimationFrame(E),D=!1,j=!1,F=null,Z=null,f.removeEventListener("mousemove",J),f.removeEventListener("mouseup",U),f.removeEventListener("touchmove",J),f.removeEventListener("touchend",U)}f.addEventListener("mousemove",J),f.addEventListener("mouseup",U),f.addEventListener("touchmove",J),f.addEventListener("touchend",U)}const Gw=()=>!0,UI=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),HI=(e,n,r)=>i=>{const{connectionStartHandle:o,connectionEndHandle:l,connectionClickStartHandle:u}=i;return{connecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===n&&(o==null?void 0:o.type)===r||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===n&&(l==null?void 0:l.type)===r,clickConnecting:(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.handleId)===n&&(u==null?void 0:u.type)===r}},rN=A.forwardRef(({type:e="source",position:n=Te.Top,isValidConnection:r,isConnectable:i=!0,isConnectableStart:o=!0,isConnectableEnd:l=!0,id:u,onConnect:c,children:p,className:h,onMouseDown:f,onTouchStart:g,...y},x)=>{var P,q;const N=u||null,_=e==="target",S=Et(),b=PI(),{connectOnClick:k,noPanClassName:E}=Xe(UI,kt),{connecting:C,clickConnecting:R}=Xe(HI(b,N,e),kt);b||(q=(P=S.getState()).onError)==null||q.call(P,"010",Pr.error010());const I=B=>{const{defaultEdgeOptions:D,onConnect:F,hasDefaultEdges:j}=S.getState(),Z={...D,...B};if(j){const{edges:W,setEdges:ne}=S.getState();ne($I(Z,W))}F==null||F(Z),c==null||c(Z)},L=B=>{if(!b)return;const D=WE(B);o&&(D&&B.button===0||!D)&&nN({event:B,handleId:N,nodeId:b,onConnect:I,isTarget:_,getState:S.getState,setState:S.setState,isValidConnection:r||S.getState().isValidConnection||Gw}),D?f==null||f(B):g==null||g(B)},H=B=>{const{onClickConnectStart:D,onClickConnectEnd:F,connectionClickStartHandle:j,connectionMode:Z,isValidConnection:W}=S.getState();if(!b||!j&&!o)return;if(!j){D==null||D(B,{nodeId:b,handleId:N,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:N}});return}const ne=zE(B.target),J=r||W||Gw,{connection:U,isValid:X}=tN({nodeId:b,id:N,type:e},Z,j.nodeId,j.handleId||null,j.type,J,ne);X&&I(U),F==null||F(B),S.setState({connectionClickStartHandle:null})};return le.createElement("div",{"data-handleid":N,"data-nodeid":b,"data-handlepos":n,"data-id":`${b}-${N}-${e}`,className:$t(["react-flow__handle",`react-flow__handle-${n}`,"nodrag",E,h,{source:!_,target:_,connectable:i,connectablestart:o,connectableend:l,connecting:R,connectionindicator:i&&(o&&!C||l&&C)}]),onMouseDown:L,onTouchStart:L,onClick:k?H:void 0,ref:x,...y},p)});rN.displayName="Handle";var no=A.memo(rN);const sN=({data:e,isConnectable:n,targetPosition:r=Te.Top,sourcePosition:i=Te.Bottom})=>le.createElement(le.Fragment,null,le.createElement(no,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label,le.createElement(no,{type:"source",position:i,isConnectable:n}));sN.displayName="DefaultNode";var Jg=A.memo(sN);const iN=({data:e,isConnectable:n,sourcePosition:r=Te.Bottom})=>le.createElement(le.Fragment,null,e==null?void 0:e.label,le.createElement(no,{type:"source",position:r,isConnectable:n}));iN.displayName="InputNode";var oN=A.memo(iN);const aN=({data:e,isConnectable:n,targetPosition:r=Te.Top})=>le.createElement(le.Fragment,null,le.createElement(no,{type:"target",position:r,isConnectable:n}),e==null?void 0:e.label);aN.displayName="OutputNode";var lN=A.memo(aN);const Nv=()=>null;Nv.displayName="GroupNode";const WI=e=>({selectedNodes:e.getNodes().filter(n=>n.selected),selectedEdges:e.edges.filter(n=>n.selected).map(n=>({...n}))}),Il=e=>e.id;function VI(e,n){return kt(e.selectedNodes.map(Il),n.selectedNodes.map(Il))&&kt(e.selectedEdges.map(Il),n.selectedEdges.map(Il))}const uN=A.memo(({onSelectionChange:e})=>{const n=Et(),{selectedNodes:r,selectedEdges:i}=Xe(WI,VI);return A.useEffect(()=>{const o={nodes:r,edges:i};e==null||e(o),n.getState().onSelectionChange.forEach(l=>l(o))},[r,i,e]),null});uN.displayName="SelectionListener";const GI=e=>!!e.onSelectionChange;function YI({onSelectionChange:e}){const n=Xe(GI);return e||n?le.createElement(uN,{onSelectionChange:e}):null}const KI=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 zi(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 XI=({nodes:e,edges:n,defaultNodes:r,defaultEdges:i,onConnect:o,onConnectStart:l,onConnectEnd:u,onClickConnectStart:c,onClickConnectEnd:p,nodesDraggable:h,nodesConnectable:f,nodesFocusable:g,edgesFocusable:y,edgesUpdatable:x,elevateNodesOnSelect:N,minZoom:_,maxZoom:S,nodeExtent:b,onNodesChange:k,onEdgesChange:E,elementsSelectable:C,connectionMode:R,snapGrid:I,snapToGrid:L,translateExtent:H,connectOnClick:P,defaultEdgeOptions:q,fitView:B,fitViewOptions:D,onNodesDelete:F,onEdgesDelete:j,onNodeDrag:Z,onNodeDragStart:W,onNodeDragStop:ne,onSelectionDrag:J,onSelectionDragStart:U,onSelectionDragStop:X,noPanClassName:M,nodeOrigin:V,rfId:O,autoPanOnConnect:$,autoPanOnNodeDrag:Y,onError:te,connectionRadius:oe,isValidConnection:ce,nodeDragThreshold:pe})=>{const{setNodes:ve,setEdges:Pe,setDefaultNodesAndEdges:Me,setMinZoom:Oe,setMaxZoom:ye,setTranslateExtent:Se,setNodeExtent:Ye,reset:we}=Xe(KI,kt),ge=Et();return A.useEffect(()=>{const Fe=i==null?void 0:i.map(pt=>({...pt,...q}));return Me(r,Fe),()=>{we()}},[]),$e("defaultEdgeOptions",q,ge.setState),$e("connectionMode",R,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",g,ge.setState),$e("edgesFocusable",y,ge.setState),$e("edgesUpdatable",x,ge.setState),$e("elementsSelectable",C,ge.setState),$e("elevateNodesOnSelect",N,ge.setState),$e("snapToGrid",L,ge.setState),$e("snapGrid",I,ge.setState),$e("onNodesChange",k,ge.setState),$e("onEdgesChange",E,ge.setState),$e("connectOnClick",P,ge.setState),$e("fitViewOnInit",B,ge.setState),$e("fitViewOnInitOptions",D,ge.setState),$e("onNodesDelete",F,ge.setState),$e("onEdgesDelete",j,ge.setState),$e("onNodeDrag",Z,ge.setState),$e("onNodeDragStart",W,ge.setState),$e("onNodeDragStop",ne,ge.setState),$e("onSelectionDrag",J,ge.setState),$e("onSelectionDragStart",U,ge.setState),$e("onSelectionDragStop",X,ge.setState),$e("noPanClassName",M,ge.setState),$e("nodeOrigin",V,ge.setState),$e("rfId",O,ge.setState),$e("autoPanOnConnect",$,ge.setState),$e("autoPanOnNodeDrag",Y,ge.setState),$e("onError",te,ge.setState),$e("connectionRadius",oe,ge.setState),$e("isValidConnection",ce,ge.setState),$e("nodeDragThreshold",pe,ge.setState),zi(e,ve),zi(n,Pe),zi(_,Oe),zi(S,ye),zi(H,Se),zi(b,Ye),null},Yw={display:"none"},QI={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},cN="react-flow__node-desc",dN="react-flow__edge-desc",ZI="react-flow__aria-live",JI=e=>e.ariaLiveMessage;function eM({rfId:e}){const n=Xe(JI);return le.createElement("div",{id:`${ZI}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:QI},n)}function tM({rfId:e,disableKeyboardA11y:n}){return le.createElement(le.Fragment,null,le.createElement("div",{id:`${cN}-${e}`,style:Yw},"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."," "),le.createElement("div",{id:`${dN}-${e}`,style:Yw},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!n&&le.createElement(eM,{rfId:e}))}var fa=(e=null,n={actInsideInputWithModifier:!0})=>{const[r,i]=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(g=>typeof g=="string").map(g=>g.split("+")),f=h.reduce((g,y)=>g.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)&&Kg(x))return!1;const _=Xw(x.code,c);l.current.add(x[_]),Kw(u,l.current,!1)&&(x.preventDefault(),i(!0))},g=x=>{if((!o.current||o.current&&!n.actInsideInputWithModifier)&&Kg(x))return!1;const _=Xw(x.code,c);Kw(u,l.current,!0)?(i(!1),l.current.clear()):l.current.delete(x[_]),x.key==="Meta"&&l.current.clear(),o.current=!1},y=()=>{l.current.clear(),i(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",g),window.addEventListener("blur",y),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",g),window.removeEventListener("blur",y)}}},[e,i]),r};function Kw(e,n,r){return e.filter(i=>r||i.length===n.size).some(i=>i.every(o=>n.has(o)))}function Xw(e,n){return n.includes(e)?"code":"key"}function fN(e,n,r,i){var c,p;const o=e.parentNode||e.parentId;if(!o)return r;const l=n.get(o),u=Qs(l,i);return fN(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},i)}function hN(e,n,r){e.forEach(i=>{var l;const o=i.parentNode||i.parentId;if(o&&!e.has(o))throw new Error(`Parent node ${o} not found`);if(o||r!=null&&r[i.id]){const{x:u,y:c,z:p}=fN(i,e,{...i.position,z:((l=i[ht])==null?void 0:l.z)??0},n);i.positionAbsolute={x:u,y:c},i[ht].z=p,r!=null&&r[i.id]&&(i[ht].isParent=!0)}})}function gd(e,n,r,i){const o=new Map,l={},u=i?1e3:0;return e.forEach(c=>{var x;const p=(Cn(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}},g=c.parentNode||c.parentId;g&&(l[g]=!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)}),hN(o,r,l),o}function pN(e,n={}){const{getNodes:r,width:i,height:o,minZoom:l,maxZoom:u,d3Zoom:c,d3Selection:p,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:g}=e(),y=n.initial&&!h&&f;if(c&&p&&(y||!n.initial)){const N=r().filter(S=>{var k;const b=n.includeHiddenNodes?S.width&&S.height:!S.hidden;return(k=n.nodes)!=null&&k.length?b&&n.nodes.some(E=>E.id===S.id):b}),_=N.every(S=>S.width&&S.height);if(N.length>0&&_){const S=hu(N,g),{x:b,y:k,zoom:E}=JE(S,i,o,n.minZoom??l,n.maxZoom??u,n.padding??.1),C=Ir.translate(b,k).scale(E);return typeof n.duration=="number"&&n.duration>0?c.transform(Gs(p,n.duration),C):c.transform(p,C),!0}}return!1}function nM(e,n){return e.forEach(r=>{const i=n.get(r.id);i&&n.set(i.id,{...i,[ht]:i[ht],selected:r.selected})}),new Map(n)}function rM(e,n){return n.map(r=>{const i=e.find(o=>o.id===r.id);return i&&(r.selected=i.selected),r})}function Ml({changedNodes:e,changedEdges:n,get:r,set:i}){const{nodeInternals:o,edges:l,onNodesChange:u,onEdgesChange:c,hasDefaultNodes:p,hasDefaultEdges:h}=r();e!=null&&e.length&&(p&&i({nodeInternals:nM(e,o)}),u==null||u(e)),n!=null&&n.length&&(h&&i({edges:rM(n,l)}),c==null||c(n))}const Bi=()=>{},sM={zoomIn:Bi,zoomOut:Bi,zoomTo:Bi,getZoom:()=>1,setViewport:Bi,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Bi,fitBounds:Bi,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},iM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),oM=()=>{const e=Et(),{d3Zoom:n,d3Selection:r}=Xe(iM,kt);return A.useMemo(()=>r&&n?{zoomIn:o=>n.scaleBy(Gs(r,o==null?void 0:o.duration),1.2),zoomOut:o=>n.scaleBy(Gs(r,o==null?void 0:o.duration),1/1.2),zoomTo:(o,l)=>n.scaleTo(Gs(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(Gs(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=>pN(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,g=c/2-o*f,y=p/2-l*f,x=Ir.translate(g,y).scale(f);n.transform(Gs(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:g,zoom:y}=JE(o,u,c,p,h,(l==null?void 0:l.padding)??.1),x=Ir.translate(f,g).scale(y);n.transform(Gs(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"),Zg(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(),g={x:o.x-h,y:o.y-f};return Zg(g,l,u,c)},flowToScreenPosition:o=>{const{transform:l,domNode:u}=e.getState();if(!u)return o;const{x:c,y:p}=u.getBoundingClientRect(),h=XE(o,l);return{x:h.x+c,y:h.y+p}},viewportInitialized:!0}:sM,[n,r])};function wa(){const e=oM(),n=Et(),r=A.useCallback(()=>n.getState().getNodes().map(_=>({..._})),[]),i=A.useCallback(_=>n.getState().nodeInternals.get(_),[]),o=A.useCallback(()=>{const{edges:_=[]}=n.getState();return _.map(S=>({...S}))},[]),l=A.useCallback(_=>{const{edges:S=[]}=n.getState();return S.find(b=>b.id===_)},[]),u=A.useCallback(_=>{const{getNodes:S,setNodes:b,hasDefaultNodes:k,onNodesChange:E}=n.getState(),C=S(),R=typeof _=="function"?_(C):_;if(k)b(R);else if(E){const I=R.length===0?C.map(L=>({type:"remove",id:L.id})):R.map(L=>({item:L,type:"reset"}));E(I)}},[]),c=A.useCallback(_=>{const{edges:S=[],setEdges:b,hasDefaultEdges:k,onEdgesChange:E}=n.getState(),C=typeof _=="function"?_(S):_;if(k)b(C);else if(E){const R=C.length===0?S.map(I=>({type:"remove",id:I.id})):C.map(I=>({item:I,type:"reset"}));E(R)}},[]),p=A.useCallback(_=>{const S=Array.isArray(_)?_:[_],{getNodes:b,setNodes:k,hasDefaultNodes:E,onNodesChange:C}=n.getState();if(E){const I=[...b(),...S];k(I)}else if(C){const R=S.map(I=>({item:I,type:"add"}));C(R)}},[]),h=A.useCallback(_=>{const S=Array.isArray(_)?_:[_],{edges:b=[],setEdges:k,hasDefaultEdges:E,onEdgesChange:C}=n.getState();if(E)k([...b,...S]);else if(C){const R=S.map(I=>({item:I,type:"add"}));C(R)}},[]),f=A.useCallback(()=>{const{getNodes:_,edges:S=[],transform:b}=n.getState(),[k,E,C]=b;return{nodes:_().map(R=>({...R})),edges:S.map(R=>({...R})),viewport:{x:k,y:E,zoom:C}}},[]),g=A.useCallback(({nodes:_,edges:S})=>{const{nodeInternals:b,getNodes:k,edges:E,hasDefaultNodes:C,hasDefaultEdges:R,onNodesDelete:I,onEdgesDelete:L,onNodesChange:H,onEdgesChange:P}=n.getState(),q=(_||[]).map(Z=>Z.id),B=(S||[]).map(Z=>Z.id),D=k().reduce((Z,W)=>{const ne=W.parentNode||W.parentId,J=!q.includes(W.id)&&ne&&Z.find(X=>X.id===ne);return(typeof W.deletable=="boolean"?W.deletable:!0)&&(q.includes(W.id)||J)&&Z.push(W),Z},[]),F=E.filter(Z=>typeof Z.deletable=="boolean"?Z.deletable:!0),j=F.filter(Z=>B.includes(Z.id));if(D||j){const Z=ZE(D,F),W=[...j,...Z],ne=W.reduce((J,U)=>(J.includes(U.id)||J.push(U.id),J),[]);if((R||C)&&(R&&n.setState({edges:E.filter(J=>!ne.includes(J.id))}),C&&(D.forEach(J=>{b.delete(J.id)}),n.setState({nodeInternals:new Map(b)}))),ne.length>0&&(L==null||L(W),P&&P(ne.map(J=>({id:J,type:"remove"})))),D.length>0&&(I==null||I(D),H)){const J=D.map(U=>({id:U.id,type:"remove"}));H(J)}}},[]),y=A.useCallback(_=>{const S=NI(_),b=S?null:n.getState().nodeInternals.get(_.id);return!S&&!b?[null,null,S]:[S?_:zw(b),b,S]},[]),x=A.useCallback((_,S=!0,b)=>{const[k,E,C]=y(_);return k?(b||n.getState().getNodes()).filter(R=>{if(!C&&(R.id===E.id||!R.positionAbsolute))return!1;const I=zw(R),L=Yg(I,k);return S&&L>0||L>=k.width*k.height}):[]},[]),N=A.useCallback((_,S,b=!0)=>{const[k]=y(_);if(!k)return!1;const E=Yg(k,S);return b&&E>0||E>=k.width*k.height},[]);return A.useMemo(()=>({...e,getNodes:r,getNode:i,getEdges:o,getEdge:l,setNodes:u,setEdges:c,addNodes:p,addEdges:h,toObject:f,deleteElements:g,getIntersectingNodes:x,isNodeIntersecting:N}),[e,r,i,o,l,u,c,p,h,f,g,x,N])}const aM={actInsideInputWithModifier:!1};var lM=({deleteKeyCode:e,multiSelectionKeyCode:n})=>{const r=Et(),{deleteElements:i}=wa(),o=fa(e,aM),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);i({nodes:p,edges:h}),r.setState({nodesSelectionActive:!1})}},[o]),A.useEffect(()=>{r.setState({multiSelectionActive:l})},[l])};function uM(e){const n=Et();A.useEffect(()=>{let r;const i=()=>{var l,u;if(!e.current)return;const o=wv(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 i(),window.addEventListener("resize",i),e.current&&(r=new ResizeObserver(()=>i()),r.observe(e.current)),()=>{window.removeEventListener("resize",i),r&&e.current&&r.unobserve(e.current)}},[])}const Cv={position:"absolute",width:"100%",height:"100%",top:0,left:0},cM=(e,n)=>e.x!==n.x||e.y!==n.y||e.zoom!==n.k,Pl=e=>({x:e.x,y:e.y,zoom:e.k}),Ui=(e,n)=>e.target.closest(`.${n}`),Qw=(e,n)=>n===2&&Array.isArray(e)&&e.includes(2),Zw=e=>{const n=e.ctrlKey&&eu()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*n},dM=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),fM=({onMove:e,onMoveStart:n,onMoveEnd:r,onPaneContextMenu:i,zoomOnScroll:o=!0,zoomOnPinch:l=!0,panOnScroll:u=!1,panOnScrollSpeed:c=.5,panOnScrollMode:p=Ks.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:g=!0,defaultViewport:y,translateExtent:x,minZoom:N,maxZoom:_,zoomActivationKeyCode:S,preventScrolling:b=!0,children:k,noWheelClassName:E,noPanClassName:C})=>{const R=A.useRef(),I=Et(),L=A.useRef(!1),H=A.useRef(!1),P=A.useRef(null),q=A.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:D,d3ZoomHandler:F,userSelectionActive:j}=Xe(dM,kt),Z=fa(S),W=A.useRef(0),ne=A.useRef(!1),J=A.useRef();return uM(P),A.useEffect(()=>{if(P.current){const U=P.current.getBoundingClientRect(),X=$E().scaleExtent([N,_]).translateExtent(x),M=Nn(P.current).call(X),V=Ir.translate(y.x,y.y).scale(to(y.zoom,N,_)),O=[[0,0],[U.width,U.height]],$=X.constrain()(V,O,x);X.transform(M,$),X.wheelDelta(Zw),I.setState({d3Zoom:X,d3Selection:M,d3ZoomHandler:M.on("wheel.zoom"),transform:[$.x,$.y,$.k],domNode:P.current.closest(".react-flow")})}},[]),A.useEffect(()=>{D&&B&&(u&&!Z&&!j?D.on("wheel.zoom",U=>{if(Ui(U,E))return!1;U.preventDefault(),U.stopImmediatePropagation();const X=D.property("__zoom").k||1;if(U.ctrlKey&&l){const ce=Gn(U),pe=Zw(U),ve=X*Math.pow(2,pe);B.scaleTo(D,ve,ce,U);return}const M=U.deltaMode===1?20:1;let V=p===Ks.Vertical?0:U.deltaX*M,O=p===Ks.Horizontal?0:U.deltaY*M;!eu()&&U.shiftKey&&p!==Ks.Vertical&&(V=U.deltaY*M,O=0),B.translateBy(D,-(V/X)*c,-(O/X)*c,{internal:!0});const $=Pl(D.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:te,onViewportChangeEnd:oe}=I.getState();clearTimeout(J.current),ne.current||(ne.current=!0,n==null||n(U,$),Y==null||Y($)),ne.current&&(e==null||e(U,$),te==null||te($),J.current=setTimeout(()=>{r==null||r(U,$),oe==null||oe($),ne.current=!1},150))},{passive:!1}):typeof F<"u"&&D.on("wheel.zoom",function(U,X){if(!b&&U.type==="wheel"&&!U.ctrlKey||Ui(U,E))return null;U.preventDefault(),F.call(this,U,X)},{passive:!1}))},[j,u,p,D,B,F,Z,l,b,E,n,e,r]),A.useEffect(()=>{B&&B.on("start",U=>{var V,O;if(!U.sourceEvent||U.sourceEvent.internal)return null;W.current=(V=U.sourceEvent)==null?void 0:V.button;const{onViewportChangeStart:X}=I.getState(),M=Pl(U.transform);L.current=!0,q.current=M,((O=U.sourceEvent)==null?void 0:O.type)==="mousedown"&&I.setState({paneDragging:!0}),X==null||X(M),n==null||n(U.sourceEvent,M)})},[B,n]),A.useEffect(()=>{B&&(j&&!L.current?B.on("zoom",null):j||B.on("zoom",U=>{var M;const{onViewportChange:X}=I.getState();if(I.setState({transform:[U.transform.x,U.transform.y,U.transform.k]}),H.current=!!(i&&Qw(g,W.current??0)),(e||X)&&!((M=U.sourceEvent)!=null&&M.internal)){const V=Pl(U.transform);X==null||X(V),e==null||e(U.sourceEvent,V)}}))},[j,B,e,g,i]),A.useEffect(()=>{B&&B.on("end",U=>{if(!U.sourceEvent||U.sourceEvent.internal)return null;const{onViewportChangeEnd:X}=I.getState();if(L.current=!1,I.setState({paneDragging:!1}),i&&Qw(g,W.current??0)&&!H.current&&i(U.sourceEvent),H.current=!1,(r||X)&&cM(q.current,U.transform)){const M=Pl(U.transform);q.current=M,clearTimeout(R.current),R.current=setTimeout(()=>{X==null||X(M),r==null||r(U.sourceEvent,M)},u?150:0)}})},[B,u,g,r,i]),A.useEffect(()=>{B&&B.filter(U=>{const X=Z||o,M=l&&U.ctrlKey;if((g===!0||Array.isArray(g)&&g.includes(1))&&U.button===1&&U.type==="mousedown"&&(Ui(U,"react-flow__node")||Ui(U,"react-flow__edge")))return!0;if(!g&&!X&&!u&&!h&&!l||j||!h&&U.type==="dblclick"||Ui(U,E)&&U.type==="wheel"||Ui(U,C)&&(U.type!=="wheel"||u&&U.type==="wheel"&&!Z)||!l&&U.ctrlKey&&U.type==="wheel"||!X&&!u&&!M&&U.type==="wheel"||!g&&(U.type==="mousedown"||U.type==="touchstart")||Array.isArray(g)&&!g.includes(U.button)&&U.type==="mousedown")return!1;const V=Array.isArray(g)&&g.includes(U.button)||!U.button||U.button<=1;return(!U.ctrlKey||U.type==="wheel")&&V})},[j,B,o,l,u,h,g,f,Z]),le.createElement("div",{className:"react-flow__renderer",ref:P,style:Cv},k)},hM=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function pM(){const{userSelectionActive:e,userSelectionRect:n}=Xe(hM,kt);return e&&n?le.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 Jw(e,n){const r=n.parentNode||n.parentId,i=e.find(o=>o.id===r);if(i){const o=n.position.x+n.width-i.width,l=n.position.y+n.height-i.height;if(o>0||l>0||n.position.x<0||n.position.y<0){if(i.style={...i.style},i.style.width=i.style.width??i.width,i.style.height=i.style.height??i.height,o>0&&(i.style.width+=o),l>0&&(i.style.height+=l),n.position.x<0){const u=Math.abs(n.position.x);i.position.x=i.position.x-u,i.style.width+=u,n.position.x=0}if(n.position.y<0){const u=Math.abs(n.position.y);i.position.y=i.position.y-u,i.style.height+=u,n.position.y=0}i.width=i.style.width,i.height=i.style.height}}}function mM(e,n){if(e.some(i=>i.type==="reset"))return e.filter(i=>i.type==="reset").map(i=>i.item);const r=e.filter(i=>i.type==="add").map(i=>i.item);return n.reduce((i,o)=>{const l=e.filter(c=>c.id===o.id);if(l.length===0)return i.push(o),i;const u={...o};for(const c of l)if(c)switch(c.type){case"select":{u.selected=c.selected;break}case"position":{typeof c.position<"u"&&(u.position=c.position),typeof c.positionAbsolute<"u"&&(u.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(u.dragging=c.dragging),u.expandParent&&Jw(i,u);break}case"dimensions":{typeof c.dimensions<"u"&&(u.width=c.dimensions.width,u.height=c.dimensions.height),typeof c.updateStyle<"u"&&(u.style={...u.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(u.resizing=c.resizing),u.expandParent&&Jw(i,u);break}case"remove":return i}return i.push(u),i},r)}function gM(e,n){return mM(e,n)}const cs=(e,n)=>({id:e,type:"select",selected:n});function Gi(e,n){return e.reduce((r,i)=>{const o=n.includes(i.id);return!i.selected&&o?(i.selected=!0,r.push(cs(i.id,!0))):i.selected&&!o&&(i.selected=!1,r.push(cs(i.id,!1))),r},[])}const vd=(e,n)=>r=>{r.target===n.current&&(e==null||e(r))},vM=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),mN=A.memo(({isSelecting:e,selectionMode:n=da.Full,panOnDrag:r,onSelectionStart:i,onSelectionEnd:o,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:c,onPaneMouseEnter:p,onPaneMouseMove:h,onPaneMouseLeave:f,children:g})=>{const y=A.useRef(null),x=Et(),N=A.useRef(0),_=A.useRef(0),S=A.useRef(),{userSelectionActive:b,elementsSelectable:k,dragging:E}=Xe(vM,kt),C=()=>{x.setState({userSelectionActive:!1,userSelectionRect:null}),N.current=0,_.current=0},R=F=>{l==null||l(F),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},I=F=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){F.preventDefault();return}u==null||u(F)},L=c?F=>c(F):void 0,H=F=>{const{resetSelectedElements:j,domNode:Z}=x.getState();if(S.current=Z==null?void 0:Z.getBoundingClientRect(),!k||!e||F.button!==0||F.target!==y.current||!S.current)return;const{x:W,y:ne}=fs(F,S.current);j(),x.setState({userSelectionRect:{width:0,height:0,startX:W,startY:ne,x:W,y:ne}}),i==null||i(F)},P=F=>{const{userSelectionRect:j,nodeInternals:Z,edges:W,transform:ne,onNodesChange:J,onEdgesChange:U,nodeOrigin:X,getNodes:M}=x.getState();if(!e||!S.current||!j)return;x.setState({userSelectionActive:!0,nodesSelectionActive:!1});const V=fs(F,S.current),O=j.startX??0,$=j.startY??0,Y={...j,x:V.x<O?V.x:O,y:V.y<$?V.y:$,width:Math.abs(V.x-O),height:Math.abs(V.y-$)},te=M(),oe=QE(Z,Y,ne,n===da.Partial,!0,X),ce=ZE(oe,W).map(ve=>ve.id),pe=oe.map(ve=>ve.id);if(N.current!==pe.length){N.current=pe.length;const ve=Gi(te,pe);ve.length&&(J==null||J(ve))}if(_.current!==ce.length){_.current=ce.length;const ve=Gi(W,ce);ve.length&&(U==null||U(ve))}x.setState({userSelectionRect:Y})},q=F=>{if(F.button!==0)return;const{userSelectionRect:j}=x.getState();!b&&j&&F.target===y.current&&(R==null||R(F)),x.setState({nodesSelectionActive:N.current>0}),C(),o==null||o(F)},B=F=>{b&&(x.setState({nodesSelectionActive:N.current>0}),o==null||o(F)),C()},D=k&&(e||b);return le.createElement("div",{className:$t(["react-flow__pane",{dragging:E,selection:e}]),onClick:D?void 0:vd(R,y),onContextMenu:vd(I,y),onWheel:vd(L,y),onMouseEnter:D?void 0:p,onMouseDown:D?H:void 0,onMouseMove:D?P:h,onMouseUp:D?q:void 0,onMouseLeave:D?B:f,ref:y,style:Cv},g,le.createElement(pM,null))});mN.displayName="Pane";function gN(e,n){const r=e.parentNode||e.parentId;if(!r)return!1;const i=n.get(r);return i?i.selected?!0:gN(i,n):!1}function ex(e,n,r){let i=e;do{if(i!=null&&i.matches(n))return!0;if(i===r.current)return!1;i=i.parentElement}while(i);return!1}function yM(e,n,r,i){return Array.from(e.values()).filter(o=>(o.selected||o.id===i)&&(!o.parentNode||o.parentId||!gN(o,e))&&(o.draggable||n&&typeof o.draggable>"u")).map(o=>{var l,u;return{id:o.id,position:o.position||{x:0,y:0},positionAbsolute:o.positionAbsolute||{x:0,y:0},distance:{x:r.x-(((l=o.positionAbsolute)==null?void 0:l.x)??0),y:r.y-(((u=o.positionAbsolute)==null?void 0:u.y)??0)},delta:{x:0,y:0},extent:o.extent,parentNode:o.parentNode||o.parentId,parentId:o.parentNode||o.parentId,width:o.width,height:o.height,expandParent:o.expandParent}})}function wM(e,n){return!n||n==="parent"?n:[n[0],[n[1][0]-(e.width||0),n[1][1]-(e.height||0)]]}function vN(e,n,r,i,o=[0,0],l){const u=wM(e,e.extent||i);let c=u;const p=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(p&&e.width&&e.height){const g=r.get(p),{x:y,y:x}=Qs(g,o).positionAbsolute;c=g&&Cn(y)&&Cn(x)&&Cn(g.width)&&Cn(g.height)?[[y+e.width*o[0],x+e.height*o[1]],[y+g.width-e.width+e.width*o[0],x+g.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 g=r.get(p),{x:y,y:x}=Qs(g,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 g=r.get(p);h=Qs(g,o).positionAbsolute}const f=c&&c!=="parent"?xv(n,c):n;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function yd({nodeId:e,dragItems:n,nodeInternals:r}){const i=n.map(o=>({...r.get(o.id),position:o.position,positionAbsolute:o.positionAbsolute}));return[e?i.find(o=>o.id===e):i[0],i]}const tx=(e,n,r,i)=>{const o=n.querySelectorAll(e);if(!o||!o.length)return null;const l=Array.from(o),u=n.getBoundingClientRect(),c={x:u.width*i[0],y:u.height*i[1]};return l.map(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,...wv(p)}})};function Xo(e,n,r){return r===void 0?r:i=>{const o=n().nodeInternals.get(e);o&&r(i,{...o})}}function ev({id:e,store:n,unselect:r=!1,nodeRef:i}){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=i==null?void 0:i.current)==null?void 0:f.blur()})):o([e])}function xM(){const e=Et();return A.useCallback(({sourceEvent:r})=>{const{transform:i,snapGrid:o,snapToGrid:l}=e.getState(),u=r.touches?r.touches[0].clientX:r.clientX,c=r.touches?r.touches[0].clientY:r.clientY,p={x:(u-i[0])/i[2],y:(c-i[1])/i[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 wd(e){return(n,r,i)=>e==null?void 0:e(n,i)}function yN({nodeRef:e,disabled:n=!1,noDragClassName:r,handleSelector:i,nodeId:o,isSelectable:l,selectNodesOnDrag:u}){const c=Et(),[p,h]=A.useState(!1),f=A.useRef([]),g=A.useRef({x:null,y:null}),y=A.useRef(0),x=A.useRef(null),N=A.useRef({x:0,y:0}),_=A.useRef(null),S=A.useRef(!1),b=A.useRef(!1),k=A.useRef(!1),E=xM();return A.useEffect(()=>{if(e!=null&&e.current){const C=Nn(e.current),R=({x:H,y:P})=>{const{nodeInternals:q,onNodeDrag:B,onSelectionDrag:D,updateNodePositions:F,nodeExtent:j,snapGrid:Z,snapToGrid:W,nodeOrigin:ne,onError:J}=c.getState();g.current={x:H,y:P};let U=!1,X={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&j){const V=hu(f.current,ne);X=ca(V)}if(f.current=f.current.map(V=>{const O={x:H-V.distance.x,y:P-V.distance.y};W&&(O.x=Z[0]*Math.round(O.x/Z[0]),O.y=Z[1]*Math.round(O.y/Z[1]));const $=[[j[0][0],j[0][1]],[j[1][0],j[1][1]]];f.current.length>1&&j&&!V.extent&&($[0][0]=V.positionAbsolute.x-X.x+j[0][0],$[1][0]=V.positionAbsolute.x+(V.width??0)-X.x2+j[1][0],$[0][1]=V.positionAbsolute.y-X.y+j[0][1],$[1][1]=V.positionAbsolute.y+(V.height??0)-X.y2+j[1][1]);const Y=vN(V,O,q,$,ne,J);return U=U||V.position.x!==Y.position.x||V.position.y!==Y.position.y,V.position=Y.position,V.positionAbsolute=Y.positionAbsolute,V}),!U)return;F(f.current,!0,!0),h(!0);const M=o?B:wd(D);if(M&&_.current){const[V,O]=yd({nodeId:o,dragItems:f.current,nodeInternals:q});M(_.current,V,O)}},I=()=>{if(!x.current)return;const[H,P]=FE(N.current,x.current);if(H!==0||P!==0){const{transform:q,panBy:B}=c.getState();g.current.x=(g.current.x??0)-H/q[2],g.current.y=(g.current.y??0)-P/q[2],B({x:H,y:P})&&R(g.current)}y.current=requestAnimationFrame(I)},L=H=>{var ne;const{nodeInternals:P,multiSelectionActive:q,nodesDraggable:B,unselectNodesAndEdges:D,onNodeDragStart:F,onSelectionDragStart:j}=c.getState();b.current=!0;const Z=o?F:wd(j);(!u||!l)&&!q&&o&&((ne=P.get(o))!=null&&ne.selected||D()),o&&l&&u&&ev({id:o,store:c,nodeRef:e});const W=E(H);if(g.current=W,f.current=yM(P,B,W,o),Z&&f.current){const[J,U]=yd({nodeId:o,dragItems:f.current,nodeInternals:P});Z(H.sourceEvent,J,U)}};if(n)C.on(".drag",null);else{const H=R2().on("start",P=>{const{domNode:q,nodeDragThreshold:B}=c.getState();B===0&&L(P),k.current=!1;const D=E(P);g.current=D,x.current=(q==null?void 0:q.getBoundingClientRect())||null,N.current=fs(P.sourceEvent,x.current)}).on("drag",P=>{var F,j;const q=E(P),{autoPanOnNodeDrag:B,nodeDragThreshold:D}=c.getState();if(P.sourceEvent.type==="touchmove"&&P.sourceEvent.touches.length>1&&(k.current=!0),!k.current){if(!S.current&&b.current&&B&&(S.current=!0,I()),!b.current){const Z=q.xSnapped-(((F=g==null?void 0:g.current)==null?void 0:F.x)??0),W=q.ySnapped-(((j=g==null?void 0:g.current)==null?void 0:j.y)??0);Math.sqrt(Z*Z+W*W)>D&&L(P)}(g.current.x!==q.xSnapped||g.current.y!==q.ySnapped)&&f.current&&b.current&&(_.current=P.sourceEvent,N.current=fs(P.sourceEvent,x.current),R(q))}}).on("end",P=>{if(!(!b.current||k.current)&&(h(!1),S.current=!1,b.current=!1,cancelAnimationFrame(y.current),f.current)){const{updateNodePositions:q,nodeInternals:B,onNodeDragStop:D,onSelectionDragStop:F}=c.getState(),j=o?D:wd(F);if(q(f.current,!1,!1),j){const[Z,W]=yd({nodeId:o,dragItems:f.current,nodeInternals:B});j(P.sourceEvent,Z,W)}}}).filter(P=>{const q=P.target;return!P.button&&(!r||!ex(q,`.${r}`,e))&&(!i||ex(q,i,e))});return C.call(H),()=>{C.on(".drag",null)}}}},[e,n,r,i,l,c,o,u,E]),p}function wN(){const e=Et();return A.useCallback(r=>{const{nodeInternals:i,nodeExtent:o,updateNodePositions:l,getNodes:u,snapToGrid:c,snapGrid:p,onError:h,nodesDraggable:f}=e.getState(),g=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,S=r.y*x*N,b=g.map(k=>{if(k.positionAbsolute){const E={x:k.positionAbsolute.x+_,y:k.positionAbsolute.y+S};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:R}=vN(k,E,i,o,void 0,h);k.position=R,k.positionAbsolute=C}return k});l(b,!0,!1)},[])}const Qi={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:i,data:o,xPos:l,yPos:u,xPosOrigin:c,yPosOrigin:p,selected:h,onClick:f,onMouseEnter:g,onMouseMove:y,onMouseLeave:x,onContextMenu:N,onDoubleClick:_,style:S,className:b,isDraggable:k,isSelectable:E,isConnectable:C,isFocusable:R,selectNodesOnDrag:I,sourcePosition:L,targetPosition:H,hidden:P,resizeObserver:q,dragHandle:B,zIndex:D,isParent:F,noDragClassName:j,noPanClassName:Z,initialized:W,disableKeyboardA11y:ne,ariaLabel:J,rfId:U,hasHandleBounds:X})=>{const M=Et(),V=A.useRef(null),O=A.useRef(null),$=A.useRef(L),Y=A.useRef(H),te=A.useRef(i),oe=E||k||f||g||y||x,ce=wN(),pe=Xo(r,M.getState,g),ve=Xo(r,M.getState,y),Pe=Xo(r,M.getState,x),Me=Xo(r,M.getState,N),Oe=Xo(r,M.getState,_),ye=we=>{const{nodeDragThreshold:ge}=M.getState();if(E&&(!I||!k||ge>0)&&ev({id:r,store:M,nodeRef:V}),f){const Fe=M.getState().nodeInternals.get(r);Fe&&f(we,{...Fe})}},Se=we=>{if(!Kg(we)&&!ne)if(HE.includes(we.key)&&E){const ge=we.key==="Escape";ev({id:r,store:M,unselect:ge,nodeRef:V})}else k&&h&&Object.prototype.hasOwnProperty.call(Qi,we.key)&&(M.setState({ariaLiveMessage:`Moved selected node ${we.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~u}`}),ce({x:Qi[we.key].x,y:Qi[we.key].y,isShiftPressed:we.shiftKey}))};A.useEffect(()=>()=>{O.current&&(q==null||q.unobserve(O.current),O.current=null)},[]),A.useEffect(()=>{if(V.current&&!P){const we=V.current;(!W||!X||O.current!==we)&&(O.current&&(q==null||q.unobserve(O.current)),q==null||q.observe(we),O.current=we)}},[P,W,X]),A.useEffect(()=>{const we=te.current!==i,ge=$.current!==L,Fe=Y.current!==H;V.current&&(we||ge||Fe)&&(we&&(te.current=i),ge&&($.current=L),Fe&&(Y.current=H),M.getState().updateNodeDimensions([{id:r,nodeElement:V.current,forceUpdate:!0}]))},[r,i,L,H]);const Ye=yN({nodeRef:V,disabled:P||!k,noDragClassName:j,handleSelector:B,nodeId:r,isSelectable:E,selectNodesOnDrag:I});return P?null:le.createElement("div",{className:$t(["react-flow__node",`react-flow__node-${i}`,{[Z]:k},b,{selected:h,selectable:E,parent:F,dragging:Ye}]),ref:V,style:{zIndex:D,transform:`translate(${c}px,${p}px)`,pointerEvents:oe?"all":"none",visibility:W?"visible":"hidden",...S},"data-id":r,"data-testid":`rf__node-${r}`,onMouseEnter:pe,onMouseMove:ve,onMouseLeave:Pe,onContextMenu:Me,onClick:ye,onDoubleClick:Oe,onKeyDown:R?Se:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":ne?void 0:`${cN}-${U}`,"aria-label":J},le.createElement(MI,{value:r},le.createElement(e,{id:r,data:o,type:i,xPos:l,yPos:u,selected:h,isConnectable:C,sourcePosition:L,targetPosition:H,dragging:Ye,dragHandle:B,zIndex:D})))};return n.displayName="NodeWrapper",A.memo(n)};const _M=e=>{const n=e.getNodes().filter(r=>r.selected);return{...hu(n,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function bM({onSelectionContextMenu:e,noPanClassName:n,disableKeyboardA11y:r}){const i=Et(),{width:o,height:l,x:u,y:c,transformString:p,userSelectionActive:h}=Xe(_M,kt),f=wN(),g=A.useRef(null);if(A.useEffect(()=>{var N;r||(N=g.current)==null||N.focus({preventScroll:!0})},[r]),yN({nodeRef:g}),h||!o||!l)return null;const y=e?N=>{const _=i.getState().getNodes().filter(S=>S.selected);e(N,_)}:void 0,x=N=>{Object.prototype.hasOwnProperty.call(Qi,N.key)&&f({x:Qi[N.key].x,y:Qi[N.key].y,isShiftPressed:N.shiftKey})};return le.createElement("div",{className:$t(["react-flow__nodesselection","react-flow__container",n]),style:{transform:p}},le.createElement("div",{ref:g,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 SM=A.memo(bM);const kM=e=>e.nodesSelectionActive,xN=({children:e,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,deleteKeyCode:c,onMove:p,onMoveStart:h,onMoveEnd:f,selectionKeyCode:g,selectionOnDrag:y,selectionMode:x,onSelectionStart:N,onSelectionEnd:_,multiSelectionKeyCode:S,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:I,panOnScrollSpeed:L,panOnScrollMode:H,zoomOnDoubleClick:P,panOnDrag:q,defaultViewport:B,translateExtent:D,minZoom:F,maxZoom:j,preventScrolling:Z,onSelectionContextMenu:W,noWheelClassName:ne,noPanClassName:J,disableKeyboardA11y:U})=>{const X=Xe(kM),M=fa(g),V=fa(b),O=V||q,$=V||I,Y=M||y&&O!==!0;return lM({deleteKeyCode:c,multiSelectionKeyCode:S}),le.createElement(fM,{onMove:p,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:$,panOnScrollSpeed:L,panOnScrollMode:H,zoomOnDoubleClick:P,panOnDrag:!M&&O,defaultViewport:B,translateExtent:D,minZoom:F,maxZoom:j,zoomActivationKeyCode:k,preventScrolling:Z,noWheelClassName:ne,noPanClassName:J},le.createElement(mN,{onSelectionStart:N,onSelectionEnd:_,onPaneClick:n,onPaneMouseEnter:r,onPaneMouseMove:i,onPaneMouseLeave:o,onPaneContextMenu:l,onPaneScroll:u,panOnDrag:O,isSelecting:!!Y,selectionMode:x},e,X&&le.createElement(SM,{onSelectionContextMenu:W,noPanClassName:J,disableKeyboardA11y:U})))};xN.displayName="FlowRenderer";var EM=A.memo(xN);function NM(e){return Xe(A.useCallback(r=>e?QE(r.nodeInternals,{x:0,y:0,width:r.width,height:r.height},r.transform,!0):r.getNodes(),[e]))}function CM(e){const n={input:Qo(e.input||oN),default:Qo(e.default||Jg),output:Qo(e.output||lN),group:Qo(e.group||Nv)},r={},i=Object.keys(e).filter(o=>!["input","default","output","group"].includes(o)).reduce((o,l)=>(o[l]=Qo(e[l]||Jg),o),r);return{...n,...i}}const TM=({x:e,y:n,width:r,height:i,origin:o})=>!r||!i?{x:e,y:n}:o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:n}:{x:e-r*o[0],y:n-i*o[1]},RM=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),_N=e=>{const{nodesDraggable:n,nodesConnectable:r,nodesFocusable:i,elementsSelectable:o,updateNodeDimensions:l,onError:u}=Xe(RM,kt),c=NM(e.onlyRenderVisibleElements),p=A.useRef(),h=A.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(g=>{const y=g.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()},[]),le.createElement("div",{className:"react-flow__nodes",style:Cv},c.map(f=>{var R,I,L;let g=f.type||"default";e.nodeTypes[g]||(u==null||u("003",Pr.error003(g)),g="default");const y=e.nodeTypes[g]||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"),S=!!(f.focusable||i&&typeof f.focusable>"u"),b=e.nodeExtent?xv(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,k=(b==null?void 0:b.x)??0,E=(b==null?void 0:b.y)??0,C=TM({x:k,y:E,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return le.createElement(y,{key:f.id,id:f.id,className:f.className,style:f.style,type:g,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:S,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((R=f[ht])==null?void 0:R.z)??0,isParent:!!((I=f[ht])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((L=f[ht])!=null&&L.handleBounds)})}))};_N.displayName="NodeRenderer";var jM=A.memo(_N);const AM=(e,n,r)=>r===Te.Left?e-n:r===Te.Right?e+n:e,IM=(e,n,r)=>r===Te.Top?e-n:r===Te.Bottom?e+n:e,nx="react-flow__edgeupdater",rx=({position:e,centerX:n,centerY:r,radius:i=10,onMouseDown:o,onMouseEnter:l,onMouseOut:u,type:c})=>le.createElement("circle",{onMouseDown:o,onMouseEnter:l,onMouseOut:u,className:$t([nx,`${nx}-${c}`]),cx:AM(n,i,e),cy:IM(r,i,e),r:i,stroke:"transparent",fill:"transparent"}),MM=()=>!0;var Hi=e=>{const n=({id:r,className:i,type:o,data:l,onClick:u,onEdgeDoubleClick:c,selected:p,animated:h,label:f,labelStyle:g,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,style:S,source:b,target:k,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:L,targetPosition:H,elementsSelectable:P,hidden:q,sourceHandleId:B,targetHandleId:D,onContextMenu:F,onMouseEnter:j,onMouseMove:Z,onMouseLeave:W,reconnectRadius:ne,onReconnect:J,onReconnectStart:U,onReconnectEnd:X,markerEnd:M,markerStart:V,rfId:O,ariaLabel:$,isFocusable:Y,isReconnectable:te,pathOptions:oe,interactionWidth:ce,disableKeyboardA11y:pe})=>{const ve=A.useRef(null),[Pe,Me]=A.useState(!1),[Oe,ye]=A.useState(!1),Se=Et(),Ye=A.useMemo(()=>`url('#${Qg(V,O)}')`,[V,O]),we=A.useMemo(()=>`url('#${Qg(M,O)}')`,[M,O]);if(q)return null;const ge=Ge=>{var Ct;const{edges:Nt,addSelectedEdges:dt,unselectNodesAndEdges:lt,multiSelectionActive:hn}=Se.getState(),Ht=Nt.find(Je=>Je.id===r);Ht&&(P&&(Se.setState({nodesSelectionActive:!1}),Ht.selected&&hn?(lt({nodes:[],edges:[Ht]}),(Ct=ve.current)==null||Ct.blur()):dt([r])),u&&u(Ge,Ht))},Fe=Ko(r,Se.getState,c),pt=Ko(r,Se.getState,F),mt=Ko(r,Se.getState,j),Ze=Ko(r,Se.getState,Z),De=Ko(r,Se.getState,W),Qe=(Ge,Nt)=>{if(Ge.button!==0)return;const{edges:dt,isValidConnection:lt}=Se.getState(),hn=Nt?k:b,Ht=(Nt?D:B)||null,Ct=Nt?"target":"source",Je=lt||MM,fr=Nt,Wt=dt.find(Tt=>Tt.id===r);ye(!0),U==null||U(Ge,Wt,Ct);const pn=Tt=>{ye(!1),X==null||X(Tt,Wt,Ct)};nN({event:Ge,handleId:Ht,nodeId:hn,onConnect:Tt=>J==null?void 0:J(Wt,Tt),isTarget:fr,getState:Se.getState,setState:Se.setState,isValidConnection:Je,edgeUpdaterType:Ct,onReconnectEnd:pn})},at=Ge=>Qe(Ge,!0),Mt=Ge=>Qe(Ge,!1),rt=()=>Me(!0),gt=()=>Me(!1),Kt=!P&&!u,Pt=Ge=>{var Nt;if(!pe&&HE.includes(Ge.key)&&P){const{unselectNodesAndEdges:dt,addSelectedEdges:lt,edges:hn}=Se.getState();Ge.key==="Escape"?((Nt=ve.current)==null||Nt.blur(),dt({edges:[hn.find(Ct=>Ct.id===r)]})):lt([r])}};return le.createElement("g",{className:$t(["react-flow__edge",`react-flow__edge-${o}`,i,{selected:p,animated:h,inactive:Kt,updating:Pe}]),onClick:ge,onDoubleClick:Fe,onContextMenu:pt,onMouseEnter:mt,onMouseMove:Ze,onMouseLeave:De,onKeyDown:Y?Pt:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${r}`,"aria-label":$===null?void 0:$||`Edge from ${b} to ${k}`,"aria-describedby":Y?`${dN}-${O}`:void 0,ref:ve},!Oe&&le.createElement(e,{id:r,source:b,target:k,selected:p,animated:h,label:f,labelStyle:g,labelShowBg:y,labelBgStyle:x,labelBgPadding:N,labelBgBorderRadius:_,data:l,style:S,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:L,targetPosition:H,sourceHandleId:B,targetHandleId:D,markerStart:Ye,markerEnd:we,pathOptions:oe,interactionWidth:ce}),te&&le.createElement(le.Fragment,null,(te==="source"||te===!0)&&le.createElement(rx,{position:L,centerX:E,centerY:C,radius:ne,onMouseDown:at,onMouseEnter:rt,onMouseOut:gt,type:"source"}),(te==="target"||te===!0)&&le.createElement(rx,{position:H,centerX:R,centerY:I,radius:ne,onMouseDown:Mt,onMouseEnter:rt,onMouseOut:gt,type:"target"})))};return n.displayName="EdgeWrapper",A.memo(n)};function PM(e){const n={default:Hi(e.default||nu),straight:Hi(e.bezier||Sv),step:Hi(e.step||bv),smoothstep:Hi(e.step||fu),simplebezier:Hi(e.simplebezier||_v)},r={},i=Object.keys(e).filter(o=>!["default","bezier"].includes(o)).reduce((o,l)=>(o[l]=Hi(e[l]||nu),o),r);return{...n,...i}}function sx(e,n,r=null){const i=((r==null?void 0:r.x)||0)+n.x,o=((r==null?void 0:r.y)||0)+n.y,l=(r==null?void 0:r.width)||n.width,u=(r==null?void 0:r.height)||n.height;switch(e){case Te.Top:return{x:i+l/2,y:o};case Te.Right:return{x:i+l,y:o+u/2};case Te.Bottom:return{x:i+l/2,y:o+u};case Te.Left:return{x:i,y:o+u/2}}}function ix(e,n){return e?e.length===1||!n?e[0]:n&&e.find(r=>r.id===n)||null:null}const OM=(e,n,r,i,o,l)=>{const u=sx(r,e,n),c=sx(l,i,o);return{sourceX:u.x,sourceY:u.y,targetX:c.x,targetY:c.y}};function LM({sourcePos:e,targetPos:n,sourceWidth:r,sourceHeight:i,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+i,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]}),g=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(g*y)>0}function ox(e){var i,o,l,u,c;const n=((i=e==null?void 0:e[ht])==null?void 0:i.handleBounds)||null,r=n&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.x)<"u"&&typeof((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},n,!!r]}const qM=[{level:0,isMaxLevel:!0,edges:[]}];function $M(e,n,r=!1){let i=-1;const o=e.reduce((u,c)=>{var f,g;const p=Cn(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,((g=y==null?void 0:y[ht])==null?void 0:g.z)||0,1e3);h=(p?c.zIndex:0)+(N?_:0)}return u[h]?u[h].push(c):u[h]=[c],i=h>i?h:i,u},{}),l=Object.entries(o).map(([u,c])=>{const p=+u;return{edges:c,level:p,isMaxLevel:p===i}});return l.length===0?qM:l}function DM(e,n,r){const i=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)&&LM({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 $M(i,n,r)}const FM=({color:e="none",strokeWidth:n=1})=>le.createElement("polyline",{style:{stroke:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),zM=({color:e="none",strokeWidth:n=1})=>le.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:n},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),ax={[tu.Arrow]:FM,[tu.ArrowClosed]:zM};function BM(e){const n=Et();return A.useMemo(()=>{var o,l;return Object.prototype.hasOwnProperty.call(ax,e)?ax[e]:((l=(o=n.getState()).onError)==null||l.call(o,"009",Pr.error009(e)),null)},[e])}const UM=({id:e,type:n,color:r,width:i=12.5,height:o=12.5,markerUnits:l="strokeWidth",strokeWidth:u,orient:c="auto-start-reverse"})=>{const p=BM(n);return p?le.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${i}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:c,refX:"0",refY:"0"},le.createElement(p,{color:r,strokeWidth:u})):null},HM=({defaultColor:e,rfId:n})=>r=>{const i=[];return r.edges.reduce((o,l)=>([l.markerStart,l.markerEnd].forEach(u=>{if(u&&typeof u=="object"){const c=Qg(u,n);i.includes(c)||(o.push({id:c,color:u.color||e,...u}),i.push(c))}}),o),[]).sort((o,l)=>o.id.localeCompare(l.id))},bN=({defaultColor:e,rfId:n})=>{const r=Xe(A.useCallback(HM({defaultColor:e,rfId:n}),[e,n]),(i,o)=>!(i.length!==o.length||i.some((l,u)=>l.id!==o[u].id)));return le.createElement("defs",null,r.map(i=>le.createElement(UM,{id:i.id,key:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient})))};bN.displayName="MarkerDefinitions";var WM=A.memo(bN);const VM=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}),SN=({defaultMarkerColor:e,onlyRenderVisibleElements:n,elevateEdgesOnSelect:r,rfId:i,edgeTypes:o,noPanClassName:l,onEdgeContextMenu:u,onEdgeMouseEnter:c,onEdgeMouseMove:p,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:g,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,children:S,disableKeyboardA11y:b})=>{const{edgesFocusable:k,edgesUpdatable:E,elementsSelectable:C,width:R,height:I,connectionMode:L,nodeInternals:H,onError:P}=Xe(VM,kt),q=DM(n,H,r);return R?le.createElement(le.Fragment,null,q.map(({level:B,edges:D,isMaxLevel:F})=>le.createElement("svg",{key:B,style:{zIndex:B},width:R,height:I,className:"react-flow__edges react-flow__container"},F&&le.createElement(WM,{defaultColor:e,rfId:i}),le.createElement("g",null,D.map(j=>{const[Z,W,ne]=ox(H.get(j.source)),[J,U,X]=ox(H.get(j.target));if(!ne||!X)return null;let M=j.type||"default";o[M]||(P==null||P("011",Pr.error011(M)),M="default");const V=o[M]||o.default,O=L===Js.Strict?U.target:(U.target??[]).concat(U.source??[]),$=ix(W.source,j.sourceHandle),Y=ix(O,j.targetHandle),te=($==null?void 0:$.position)||Te.Bottom,oe=(Y==null?void 0:Y.position)||Te.Top,ce=!!(j.focusable||k&&typeof j.focusable>"u"),pe=j.reconnectable||j.updatable,ve=typeof y<"u"&&(pe||E&&typeof pe>"u");if(!$||!Y)return P==null||P("008",Pr.error008($,j)),null;const{sourceX:Pe,sourceY:Me,targetX:Oe,targetY:ye}=OM(Z,$,te,J,Y,oe);return le.createElement(V,{key:j.id,id:j.id,className:$t([j.className,l]),type:M,data:j.data,selected:!!j.selected,animated:!!j.animated,hidden:!!j.hidden,label:j.label,labelStyle:j.labelStyle,labelShowBg:j.labelShowBg,labelBgStyle:j.labelBgStyle,labelBgPadding:j.labelBgPadding,labelBgBorderRadius:j.labelBgBorderRadius,style:j.style,source:j.source,target:j.target,sourceHandleId:j.sourceHandle,targetHandleId:j.targetHandle,markerEnd:j.markerEnd,markerStart:j.markerStart,sourceX:Pe,sourceY:Me,targetX:Oe,targetY:ye,sourcePosition:te,targetPosition:oe,elementsSelectable:C,onContextMenu:u,onMouseEnter:c,onMouseMove:p,onMouseLeave:h,onClick:f,onEdgeDoubleClick:g,onReconnect:y,onReconnectStart:x,onReconnectEnd:N,reconnectRadius:_,rfId:i,ariaLabel:j.ariaLabel,isFocusable:ce,isReconnectable:ve,pathOptions:"pathOptions"in j?j.pathOptions:void 0,interactionWidth:j.interactionWidth,disableKeyboardA11y:b})})))),S):null};SN.displayName="EdgeRenderer";var GM=A.memo(SN);const YM=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function KM({children:e}){const n=Xe(YM);return le.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:n}},e)}function XM(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 QM={[Te.Left]:Te.Right,[Te.Right]:Te.Left,[Te.Top]:Te.Bottom,[Te.Bottom]:Te.Top},kN=({nodeId:e,handleType:n,style:r,type:i=ds.Bezier,CustomComponent:o,connectionStatus:l})=>{var I,L,H;const{fromNode:u,handleId:c,toX:p,toY:h,connectionMode:f}=Xe(A.useCallback(P=>({fromNode:P.nodeInternals.get(e),handleId:P.connectionHandleId,toX:(P.connectionPosition.x-P.transform[0])/P.transform[2],toY:(P.connectionPosition.y-P.transform[1])/P.transform[2],connectionMode:P.connectionMode}),[e]),kt),g=(I=u==null?void 0:u[ht])==null?void 0:I.handleBounds;let y=g==null?void 0:g[n];if(f===Js.Loose&&(y=y||(g==null?void 0:g[n==="source"?"target":"source"])),!u||!y)return null;const x=c?y.find(P=>P.id===c):y[0],N=x?x.x+x.width/2:(u.width??0)/2,_=x?x.y+x.height/2:u.height??0,S=(((L=u.positionAbsolute)==null?void 0:L.x)??0)+N,b=(((H=u.positionAbsolute)==null?void 0:H.y)??0)+_,k=x==null?void 0:x.position,E=k?QM[k]:null;if(!k||!E)return null;if(o)return le.createElement(o,{connectionLineType:i,connectionLineStyle:r,fromNode:u,fromHandle:x,fromX:S,fromY:b,toX:p,toY:h,fromPosition:k,toPosition:E,connectionStatus:l});let C="";const R={sourceX:S,sourceY:b,sourcePosition:k,targetX:p,targetY:h,targetPosition:E};return i===ds.Bezier?[C]=KE(R):i===ds.Step?[C]=Xg({...R,borderRadius:0}):i===ds.SmoothStep?[C]=Xg(R):i===ds.SimpleBezier?[C]=YE(R):C=`M${S},${b} ${p},${h}`,le.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:r})};kN.displayName="ConnectionLine";const ZM=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function JM({containerStyle:e,style:n,type:r,component:i}){const{nodeId:o,handleType:l,nodesConnectable:u,width:c,height:p,connectionStatus:h}=Xe(ZM,kt);return!(o&&l&&c&&u)?null:le.createElement("svg",{style:e,width:c,height:p,className:"react-flow__edges react-flow__connectionline react-flow__container"},le.createElement("g",{className:$t(["react-flow__connection",h])},le.createElement(kN,{nodeId:o,handleType:l,style:n,type:r,CustomComponent:i,connectionStatus:h})))}function lx(e,n){return A.useRef(null),Et(),A.useMemo(()=>n(e),[e])}const EN=({nodeTypes:e,edgeTypes:n,onMove:r,onMoveStart:i,onMoveEnd:o,onInit:l,onNodeClick:u,onEdgeClick:c,onNodeDoubleClick:p,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:x,onSelectionContextMenu:N,onSelectionStart:_,onSelectionEnd:S,connectionLineType:b,connectionLineStyle:k,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:R,selectionOnDrag:I,selectionMode:L,multiSelectionKeyCode:H,panActivationKeyCode:P,zoomActivationKeyCode:q,deleteKeyCode:B,onlyRenderVisibleElements:D,elementsSelectable:F,selectNodesOnDrag:j,defaultViewport:Z,translateExtent:W,minZoom:ne,maxZoom:J,preventScrolling:U,defaultMarkerColor:X,zoomOnScroll:M,zoomOnPinch:V,panOnScroll:O,panOnScrollSpeed:$,panOnScrollMode:Y,zoomOnDoubleClick:te,panOnDrag:oe,onPaneClick:ce,onPaneMouseEnter:pe,onPaneMouseMove:ve,onPaneMouseLeave:Pe,onPaneScroll:Me,onPaneContextMenu:Oe,onEdgeContextMenu:ye,onEdgeMouseEnter:Se,onEdgeMouseMove:Ye,onEdgeMouseLeave:we,onReconnect:ge,onReconnectStart:Fe,onReconnectEnd:pt,reconnectRadius:mt,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Qe,elevateEdgesOnSelect:at,disableKeyboardA11y:Mt,nodeOrigin:rt,nodeExtent:gt,rfId:Kt})=>{const Pt=lx(e,CM),Ge=lx(n,PM);return XM(l),le.createElement(EM,{onPaneClick:ce,onPaneMouseEnter:pe,onPaneMouseMove:ve,onPaneMouseLeave:Pe,onPaneContextMenu:Oe,onPaneScroll:Me,deleteKeyCode:B,selectionKeyCode:R,selectionOnDrag:I,selectionMode:L,onSelectionStart:_,onSelectionEnd:S,multiSelectionKeyCode:H,panActivationKeyCode:P,zoomActivationKeyCode:q,elementsSelectable:F,onMove:r,onMoveStart:i,onMoveEnd:o,zoomOnScroll:M,zoomOnPinch:V,zoomOnDoubleClick:te,panOnScroll:O,panOnScrollSpeed:$,panOnScrollMode:Y,panOnDrag:oe,defaultViewport:Z,translateExtent:W,minZoom:ne,maxZoom:J,onSelectionContextMenu:N,preventScrolling:U,noDragClassName:Ze,noWheelClassName:De,noPanClassName:Qe,disableKeyboardA11y:Mt},le.createElement(KM,null,le.createElement(GM,{edgeTypes:Ge,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:D,onEdgeContextMenu:ye,onEdgeMouseEnter:Se,onEdgeMouseMove:Ye,onEdgeMouseLeave:we,onReconnect:ge,onReconnectStart:Fe,onReconnectEnd:pt,reconnectRadius:mt,defaultMarkerColor:X,noPanClassName:Qe,elevateEdgesOnSelect:!!at,disableKeyboardA11y:Mt,rfId:Kt},le.createElement(JM,{style:k,type:b,component:E,containerStyle:C})),le.createElement("div",{className:"react-flow__edgelabel-renderer"}),le.createElement(jM,{nodeTypes:Pt,onNodeClick:u,onNodeDoubleClick:p,onNodeMouseEnter:f,onNodeMouseMove:g,onNodeMouseLeave:y,onNodeContextMenu:x,selectNodesOnDrag:j,onlyRenderVisibleElements:D,noPanClassName:Qe,noDragClassName:Ze,disableKeyboardA11y:Mt,nodeOrigin:rt,nodeExtent:gt,rfId:Kt})))};EN.displayName="GraphView";var eP=A.memo(EN);const tv=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ls={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:tv,nodeExtent:tv,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Js.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:CI,isValidConnection:void 0},tP=()=>zR((e,n)=>({...ls,setNodes:r=>{const{nodeInternals:i,nodeOrigin:o,elevateNodesOnSelect:l}=n();e({nodeInternals:gd(r,i,o,l)})},getNodes:()=>Array.from(n().nodeInternals.values()),setEdges:r=>{const{defaultEdgeOptions:i={}}=n();e({edges:r.map(o=>({...i,...o}))})},setDefaultNodesAndEdges:(r,i)=>{const o=typeof r<"u",l=typeof i<"u",u=o?gd(r,new Map,n().nodeOrigin,n().elevateNodesOnSelect):new Map;e({nodeInternals:u,edges:l?i:[],hasDefaultNodes:o,hasDefaultEdges:l})},updateNodeDimensions:r=>{const{onNodesChange:i,nodeInternals:o,fitViewOnInit:l,fitViewOnInitDone:u,fitViewOnInitOptions:c,domNode:p,nodeOrigin:h}=n(),f=p==null?void 0:p.querySelector(".react-flow__viewport");if(!f)return;const g=window.getComputedStyle(f),{m22:y}=new window.DOMMatrixReadOnly(g.transform),x=r.reduce((_,S)=>{const b=o.get(S.id);if(b!=null&&b.hidden)o.set(b.id,{...b,[ht]:{...b[ht],handleBounds:void 0}});else if(b){const k=wv(S.nodeElement);!!(k.width&&k.height&&(b.width!==k.width||b.height!==k.height||S.forceUpdate))&&(o.set(b.id,{...b,[ht]:{...b[ht],handleBounds:{source:tx(".source",S.nodeElement,y,h),target:tx(".target",S.nodeElement,y,h)}},...k}),_.push({id:b.id,type:"dimensions",dimensions:k}))}return _},[]);hN(o,h);const N=u||l&&!u&&pN(n,{initial:!0,...c});e({nodeInternals:new Map(o),fitViewOnInitDone:N}),(x==null?void 0:x.length)>0&&(i==null||i(x))},updateNodePositions:(r,i=!0,o=!1)=>{const{triggerNodeChanges:l}=n(),u=r.map(c=>{const p={id:c.id,type:"position",dragging:o};return i&&(p.positionAbsolute=c.positionAbsolute,p.position=c.position),p});l(u)},triggerNodeChanges:r=>{const{onNodesChange:i,nodeInternals:o,hasDefaultNodes:l,nodeOrigin:u,getNodes:c,elevateNodesOnSelect:p}=n();if(r!=null&&r.length){if(l){const h=gM(r,c()),f=gd(h,o,u,p);e({nodeInternals:f})}i==null||i(r)}},addSelectedNodes:r=>{const{multiSelectionActive:i,edges:o,getNodes:l}=n();let u,c=null;i?u=r.map(p=>cs(p,!0)):(u=Gi(l(),r),c=Gi(o,[])),Ml({changedNodes:u,changedEdges:c,get:n,set:e})},addSelectedEdges:r=>{const{multiSelectionActive:i,edges:o,getNodes:l}=n();let u,c=null;i?u=r.map(p=>cs(p,!0)):(u=Gi(o,r),c=Gi(l(),[])),Ml({changedNodes:c,changedEdges:u,get:n,set:e})},unselectNodesAndEdges:({nodes:r,edges:i}={})=>{const{edges:o,getNodes:l}=n(),u=r||l(),c=i||o,p=u.map(f=>(f.selected=!1,cs(f.id,!1))),h=c.map(f=>cs(f.id,!1));Ml({changedNodes:p,changedEdges:h,get:n,set:e})},setMinZoom:r=>{const{d3Zoom:i,maxZoom:o}=n();i==null||i.scaleExtent([r,o]),e({minZoom:r})},setMaxZoom:r=>{const{d3Zoom:i,minZoom:o}=n();i==null||i.scaleExtent([o,r]),e({maxZoom:r})},setTranslateExtent:r=>{var i;(i=n().d3Zoom)==null||i.translateExtent(r),e({translateExtent:r})},resetSelectedElements:()=>{const{edges:r,getNodes:i}=n(),l=i().filter(c=>c.selected).map(c=>cs(c.id,!1)),u=r.filter(c=>c.selected).map(c=>cs(c.id,!1));Ml({changedNodes:l,changedEdges:u,get:n,set:e})},setNodeExtent:r=>{const{nodeInternals:i}=n();i.forEach(o=>{o.positionAbsolute=xv(o.position,r)}),e({nodeExtent:r,nodeInternals:new Map(i)})},panBy:r=>{const{transform:i,width:o,height:l,d3Zoom:u,d3Selection:c,translateExtent:p}=n();if(!u||!c||!r.x&&!r.y)return!1;const h=Ir.translate(i[0]+r.x,i[1]+r.y).scale(i[2]),f=[[0,0],[o,l]],g=u==null?void 0:u.constrain()(h,f,p);return u.transform(c,g),i[0]!==g.x||i[1]!==g.y||i[2]!==g.k},cancelConnection:()=>e({connectionNodeId:ls.connectionNodeId,connectionHandleId:ls.connectionHandleId,connectionHandleType:ls.connectionHandleType,connectionStatus:ls.connectionStatus,connectionStartHandle:ls.connectionStartHandle,connectionEndHandle:ls.connectionEndHandle}),reset:()=>e({...ls})}),Object.is),Tv=({children:e})=>{const n=A.useRef(null);return n.current||(n.current=tP()),le.createElement(xI,{value:n.current},e)};Tv.displayName="ReactFlowProvider";const NN=({children:e})=>A.useContext(du)?le.createElement(le.Fragment,null,e):le.createElement(Tv,null,e);NN.displayName="ReactFlowWrapper";const nP={input:oN,default:Jg,output:lN,group:Nv},rP={default:nu,straight:Sv,step:bv,smoothstep:fu,simplebezier:_v},sP=[0,0],iP=[15,15],oP={x:0,y:0,zoom:1},aP={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},CN=A.forwardRef(({nodes:e,edges:n,defaultNodes:r,defaultEdges:i,className:o,nodeTypes:l=nP,edgeTypes:u=rP,onNodeClick:c,onEdgeClick:p,onInit:h,onMove:f,onMoveStart:g,onMoveEnd:y,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,onNodeDragStart:L,onNodeDrag:H,onNodeDragStop:P,onNodesDelete:q,onEdgesDelete:B,onSelectionChange:D,onSelectionDragStart:F,onSelectionDrag:j,onSelectionDragStop:Z,onSelectionContextMenu:W,onSelectionStart:ne,onSelectionEnd:J,connectionMode:U=Js.Strict,connectionLineType:X=ds.Bezier,connectionLineStyle:M,connectionLineComponent:V,connectionLineContainerStyle:O,deleteKeyCode:$="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:te=!1,selectionMode:oe=da.Full,panActivationKeyCode:ce="Space",multiSelectionKeyCode:pe=eu()?"Meta":"Control",zoomActivationKeyCode:ve=eu()?"Meta":"Control",snapToGrid:Pe=!1,snapGrid:Me=iP,onlyRenderVisibleElements:Oe=!1,selectNodesOnDrag:ye=!0,nodesDraggable:Se,nodesConnectable:Ye,nodesFocusable:we,nodeOrigin:ge=sP,edgesFocusable:Fe,edgesUpdatable:pt,elementsSelectable:mt,defaultViewport:Ze=oP,minZoom:De=.5,maxZoom:Qe=2,translateExtent:at=tv,preventScrolling:Mt=!0,nodeExtent:rt,defaultMarkerColor:gt="#b1b1b7",zoomOnScroll:Kt=!0,zoomOnPinch:Pt=!0,panOnScroll:Ge=!1,panOnScrollSpeed:Nt=.5,panOnScrollMode:dt=Ks.Free,zoomOnDoubleClick:lt=!0,panOnDrag:hn=!0,onPaneClick:Ht,onPaneMouseEnter:Ct,onPaneMouseMove:Je,onPaneMouseLeave:fr,onPaneScroll:Wt,onPaneContextMenu:pn,children:jn,onEdgeContextMenu:Tt,onEdgeDoubleClick:hr,onEdgeMouseEnter:ii,onEdgeMouseMove:oi,onEdgeMouseLeave:ms,onEdgeUpdate:qr,onEdgeUpdateStart:An,onEdgeUpdateEnd:Jn,onReconnect:$r,onReconnectStart:mn,onReconnectEnd:ai,reconnectRadius:In=10,edgeUpdaterRadius:wt=10,onNodesChange:Mn,onEdgesChange:er,noDragClassName:Pn="nodrag",noWheelClassName:li="nowheel",noPanClassName:gs="nopan",fitView:On=!1,fitViewOptions:tr,connectOnClick:vs=!0,attributionPosition:ui,proOptions:ci,defaultEdgeOptions:ys,elevateNodesOnSelect:ws=!0,elevateEdgesOnSelect:Dr=!1,disableKeyboardA11y:Ln=!1,autoPanOnConnect:fo=!0,autoPanOnNodeDrag:Be=!0,connectionRadius:xs=20,isValidConnection:pr,onError:_s,style:qn,id:Fr,nodeDragThreshold:gn,...mr},Vt)=>{const zr=Fr||"1";return le.createElement("div",{...mr,style:{...qn,...aP},ref:Vt,className:$t(["react-flow",o]),"data-testid":"rf__wrapper",id:Fr},le.createElement(NN,null,le.createElement(eP,{onInit:h,onMove:f,onMoveStart:g,onMoveEnd:y,onNodeClick:c,onEdgeClick:p,onNodeMouseEnter:k,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,nodeTypes:l,edgeTypes:u,connectionLineType:X,connectionLineStyle:M,connectionLineComponent:V,connectionLineContainerStyle:O,selectionKeyCode:Y,selectionOnDrag:te,selectionMode:oe,deleteKeyCode:$,multiSelectionKeyCode:pe,panActivationKeyCode:ce,zoomActivationKeyCode:ve,onlyRenderVisibleElements:Oe,selectNodesOnDrag:ye,defaultViewport:Ze,translateExtent:at,minZoom:De,maxZoom:Qe,preventScrolling:Mt,zoomOnScroll:Kt,zoomOnPinch:Pt,zoomOnDoubleClick:lt,panOnScroll:Ge,panOnScrollSpeed:Nt,panOnScrollMode:dt,panOnDrag:hn,onPaneClick:Ht,onPaneMouseEnter:Ct,onPaneMouseMove:Je,onPaneMouseLeave:fr,onPaneScroll:Wt,onPaneContextMenu:pn,onSelectionContextMenu:W,onSelectionStart:ne,onSelectionEnd:J,onEdgeContextMenu:Tt,onEdgeDoubleClick:hr,onEdgeMouseEnter:ii,onEdgeMouseMove:oi,onEdgeMouseLeave:ms,onReconnect:$r??qr,onReconnectStart:mn??An,onReconnectEnd:ai??Jn,reconnectRadius:In??wt,defaultMarkerColor:gt,noDragClassName:Pn,noWheelClassName:li,noPanClassName:gs,elevateEdgesOnSelect:Dr,rfId:zr,disableKeyboardA11y:Ln,nodeOrigin:ge,nodeExtent:rt}),le.createElement(XI,{nodes:e,edges:n,defaultNodes:r,defaultEdges:i,onConnect:x,onConnectStart:N,onConnectEnd:_,onClickConnectStart:S,onClickConnectEnd:b,nodesDraggable:Se,nodesConnectable:Ye,nodesFocusable:we,edgesFocusable:Fe,edgesUpdatable:pt,elementsSelectable:mt,elevateNodesOnSelect:ws,minZoom:De,maxZoom:Qe,nodeExtent:rt,onNodesChange:Mn,onEdgesChange:er,snapToGrid:Pe,snapGrid:Me,connectionMode:U,translateExtent:at,connectOnClick:vs,defaultEdgeOptions:ys,fitView:On,fitViewOptions:tr,onNodesDelete:q,onEdgesDelete:B,onNodeDragStart:L,onNodeDrag:H,onNodeDragStop:P,onSelectionDrag:j,onSelectionDragStart:F,onSelectionDragStop:Z,noPanClassName:gs,nodeOrigin:ge,rfId:zr,autoPanOnConnect:fo,autoPanOnNodeDrag:Be,onError:_s,connectionRadius:xs,isValidConnection:pr,nodeDragThreshold:gn}),le.createElement(YI,{onSelectionChange:D}),jn,le.createElement(bI,{proOptions:ci,position:ui}),le.createElement(tM,{rfId:zr,disableKeyboardA11y:Ln})))});CN.displayName="ReactFlow";const lP=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function TN(){return Xe(lP,kt)}const RN=({id:e,x:n,y:r,width:i,height:o,style:l,color:u,strokeColor:c,strokeWidth:p,className:h,borderRadius:f,shapeRendering:g,onClick:y,selected:x})=>{const{background:N,backgroundColor:_}=l||{},S=u||N||_;return le.createElement("rect",{className:$t(["react-flow__minimap-node",{selected:x},h]),x:n,y:r,rx:f,ry:f,width:i,height:o,fill:S,stroke:c,strokeWidth:p,shapeRendering:g,onClick:y?b=>y(b,e):void 0})};RN.displayName="MiniMapNode";var uP=A.memo(RN);const cP=e=>e.nodeOrigin,dP=e=>e.getNodes().filter(n=>!n.hidden&&n.width&&n.height),xd=e=>e instanceof Function?e:()=>e;function fP({nodeStrokeColor:e="transparent",nodeColor:n="#e2e2e2",nodeClassName:r="",nodeBorderRadius:i=5,nodeStrokeWidth:o=2,nodeComponent:l=uP,onClick:u}){const c=Xe(dP,kt),p=Xe(cP),h=xd(n),f=xd(e),g=xd(r),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return le.createElement(le.Fragment,null,c.map(x=>{const{x:N,y:_}=Qs(x,p).positionAbsolute;return le.createElement(l,{key:x.id,x:N,y:_,width:x.width,height:x.height,style:x.style,selected:x.selected,className:g(x),color:h(x),borderRadius:i,strokeColor:f(x),strokeWidth:o,shapeRendering:y,onClick:u,id:x.id})}))}var hP=A.memo(fP);const pP=200,mP=150,gP=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?EI(hu(n,e.nodeOrigin),r):r,rfId:e.rfId}},vP="react-flow__minimap-desc";function jN({style:e,className:n,nodeStrokeColor:r="transparent",nodeColor:i="#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:g="bottom-right",onClick:y,onNodeClick:x,pannable:N=!1,zoomable:_=!1,ariaLabel:S="React Flow mini map",inversePan:b=!1,zoomStep:k=10,offsetScale:E=5}){const C=Et(),R=A.useRef(null),{boundingRect:I,viewBB:L,rfId:H}=Xe(gP,kt),P=(e==null?void 0:e.width)??pP,q=(e==null?void 0:e.height)??mP,B=I.width/P,D=I.height/q,F=Math.max(B,D),j=F*P,Z=F*q,W=E*F,ne=I.x-(j-I.width)/2-W,J=I.y-(Z-I.height)/2-W,U=j+W*2,X=Z+W*2,M=`${vP}-${H}`,V=A.useRef(0);V.current=F,A.useEffect(()=>{if(R.current){const Y=Nn(R.current),te=pe=>{const{transform:ve,d3Selection:Pe,d3Zoom:Me}=C.getState();if(pe.sourceEvent.type!=="wheel"||!Pe||!Me)return;const Oe=-pe.sourceEvent.deltaY*(pe.sourceEvent.deltaMode===1?.05:pe.sourceEvent.deltaMode?1:.002)*k,ye=ve[2]*Math.pow(2,Oe);Me.scaleTo(Pe,ye)},oe=pe=>{const{transform:ve,d3Selection:Pe,d3Zoom:Me,translateExtent:Oe,width:ye,height:Se}=C.getState();if(pe.sourceEvent.type!=="mousemove"||!Pe||!Me)return;const Ye=V.current*Math.max(1,ve[2])*(b?-1:1),we={x:ve[0]-pe.sourceEvent.movementX*Ye,y:ve[1]-pe.sourceEvent.movementY*Ye},ge=[[0,0],[ye,Se]],Fe=Ir.translate(we.x,we.y).scale(ve[2]),pt=Me.constrain()(Fe,ge,Oe);Me.transform(Pe,pt)},ce=$E().on("zoom",N?oe:null).on("zoom.wheel",_?te:null);return Y.call(ce),()=>{Y.on("zoom",null)}}},[N,_,b,k]);const O=y?Y=>{const te=Gn(Y);y(Y,{x:te[0],y:te[1]})}:void 0,$=x?(Y,te)=>{const oe=C.getState().nodeInternals.get(te);x(Y,oe)}:void 0;return le.createElement(yv,{position:g,style:e,className:$t(["react-flow__minimap",n]),"data-testid":"rf__minimap"},le.createElement("svg",{width:P,height:q,viewBox:`${ne} ${J} ${U} ${X}`,role:"img","aria-labelledby":M,ref:R,onClick:O},S&&le.createElement("title",{id:M},S),le.createElement(hP,{onClick:$,nodeColor:i,nodeStrokeColor:r,nodeBorderRadius:l,nodeClassName:o,nodeStrokeWidth:u,nodeComponent:c}),le.createElement("path",{className:"react-flow__minimap-mask",d:`M${ne-W},${J-W}h${U+W*2}v${X+W*2}h${-U-W*2}z
|
|
57
57
|
M${L.x},${L.y}h${L.width}v${L.height}h${-L.width}z`,fill:p,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}jN.displayName="MiniMap";var yP=A.memo(jN);function wP(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},le.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function xP(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},le.createElement("path",{d:"M0 0h32v4.2H0z"}))}function _P(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},le.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 bP(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.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 SP(){return le.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},le.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 Yi=({children:e,className:n,...r})=>le.createElement("button",{type:"button",className:$t(["react-flow__controls-button",n]),...r},e);Yi.displayName="ControlButton";const kP=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),AN=({style:e,showZoom:n=!0,showFitView:r=!0,showInteractive:i=!0,fitViewOptions:o,onZoomIn:l,onZoomOut:u,onFitView:c,onInteractiveChange:p,className:h,children:f,position:g="bottom-left"})=>{const y=Et(),[x,N]=A.useState(!1),{isInteractive:_,minZoomReached:S,maxZoomReached:b}=Xe(kP,kt),{zoomIn:k,zoomOut:E,fitView:C}=wa();if(A.useEffect(()=>{N(!0)},[]),!x)return null;const R=()=>{k(),l==null||l()},I=()=>{E(),u==null||u()},L=()=>{C(o),c==null||c()},H=()=>{y.setState({nodesDraggable:!_,nodesConnectable:!_,elementsSelectable:!_}),p==null||p(!_)};return le.createElement(yv,{className:$t(["react-flow__controls",h]),position:g,style:e,"data-testid":"rf__controls"},n&&le.createElement(le.Fragment,null,le.createElement(Yi,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},le.createElement(wP,null)),le.createElement(Yi,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:S},le.createElement(xP,null))),r&&le.createElement(Yi,{className:"react-flow__controls-fitview",onClick:L,title:"fit view","aria-label":"fit view"},le.createElement(_P,null)),i&&le.createElement(Yi,{className:"react-flow__controls-interactive",onClick:H,title:"toggle interactivity","aria-label":"toggle interactivity"},_?le.createElement(SP,null):le.createElement(bP,null)),f)};AN.displayName="Controls";var EP=A.memo(AN),Kn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Kn||(Kn={}));function NP({color:e,dimensions:n,lineWidth:r}){return le.createElement("path",{stroke:e,strokeWidth:r,d:`M${n[0]/2} 0 V${n[1]} M0 ${n[1]/2} H${n[0]}`})}function CP({color:e,radius:n}){return le.createElement("circle",{cx:n,cy:n,r:n,fill:e})}const TP={[Kn.Dots]:"#91919a",[Kn.Lines]:"#eee",[Kn.Cross]:"#e2e2e2"},RP={[Kn.Dots]:1,[Kn.Lines]:1,[Kn.Cross]:6},jP=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function IN({id:e,variant:n=Kn.Dots,gap:r=20,size:i,lineWidth:o=1,offset:l=2,color:u,style:c,className:p}){const h=A.useRef(null),{transform:f,patternId:g}=Xe(jP,kt),y=u||TP[n],x=i||RP[n],N=n===Kn.Dots,_=n===Kn.Cross,S=Array.isArray(r)?r:[r,r],b=[S[0]*f[2]||1,S[1]*f[2]||1],k=x*f[2],E=_?[k,k]:b,C=N?[k/l,k/l]:[E[0]/l,E[1]/l];return le.createElement("svg",{className:$t(["react-flow__background",p]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},le.createElement("pattern",{id:g+e,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},N?le.createElement(CP,{color:y,radius:k/l}):le.createElement(NP,{dimensions:E,color:y,lineWidth:o})),le.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${g+e})`}))}IN.displayName="Background";var AP=A.memo(IN);function MN(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function PN(e){const n=e.cache_creation,r=n&&typeof n=="object"?n:e,i=r.ephemeral_1h_input_tokens,o=r.ephemeral_5m_input_tokens;return typeof i!="number"&&typeof o!="number"?{}:{cacheCreate1hTokens:Number(i??0),cacheCreate5mTokens:Number(o??0)}}function ON(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),...PN(r)};for(const i of Object.values(r)){const o=ON(i,n+1);if(o)return o}return null}function IP(e,n){e.inputTokens+=n.inputTokens,e.outputTokens+=n.outputTokens,e.cacheReadTokens+=n.cacheReadTokens,e.cacheCreateTokens+=n.cacheCreateTokens,(n.cacheCreate1hTokens!==void 0||n.cacheCreate5mTokens!==void 0)&&(e.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(n.cacheCreate1hTokens??0),e.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(n.cacheCreate5mTokens??0))}const MP=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i;function LN(e,n=0){if(!e||typeof e!="object"||n>6)return null;const r=e;if(typeof r.model=="string"&&MP.test(r.model))return r.model;for(const i of Object.values(r)){const o=LN(i,n+1);if(o)return o}return null}function nv(){return{agents:new Map,toolIndex:new Map,toolOwner:new Map,activeSubagentStack:new Map,lastSeq:0,seqEpoch:null,totalEvents:0}}function hs(e){if(!e)return;const n=e.replace(/\\/g,"/").split("/").filter(Boolean);return n[n.length-1]}function Rv(e,n){return`${e}::${n}`}function ru(e){return e.agent_type??e.subagent_type??"subagent"}function rv(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function sa(e,n,r,i){const o=n;let l=e.agents.get(o);return l||(l={id:o,sessionId:n,label:"session",kind:"root",state:"active",startedAt:r,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:i,usage:MN()},e.agents.set(o,l),l)}function qN(e,n,r,i){const o=Rv(n,r),l=e.agents.get(o);if(!l)return null;!l.cwd&&i.cwd&&(l.cwd=i.cwd,l.cwdBasename=hs(i.cwd));const u=ru(i);return u&&(l.label==="subagent"||!l.label)&&(l.label=u),l}function ux(e,n,r){const i=n.session_id??"unknown",o=rv(n);if(o){const p=qN(e,i,o,n);if(p)return p}const l=e.activeSubagentStack.get(i),u=l&&l.length>0?l[l.length-1]:null;if(u){const p=e.agents.get(Rv(i,u));if(p)return!p.cwd&&n.cwd&&(p.cwd=n.cwd,p.cwdBasename=hs(n.cwd)),p}const c=sa(e,i,r,!1);return c.synthetic&&(c.synthetic=!1,c.startedAt=r),!c.cwd&&n.cwd&&(c.cwd=n.cwd,c.cwdBasename=hs(n.cwd)),c.label==="session"&&n.cwd&&(c.label=hs(n.cwd)??"session"),c}function PP(e,n,r,i,o){const l=Rv(n,r),u=sa(e,n,o,!0);let c=e.agents.get(l);if(c){!c.cwd&&i.cwd&&(c.cwd=i.cwd,c.cwdBasename=hs(i.cwd));const p=ru(i);return p&&(c.label==="subagent"||!c.label)&&(c.label=p),c}return c={id:l,sessionId:n,label:ru(i),kind:"subagent",parentId:u.id,state:"active",startedAt:o,tools:[],prompts:[],cwd:i.cwd,cwdBasename:hs(i.cwd),toolCount:0,childCount:0,usage:MN()},e.agents.set(l,c),u.childCount+=1,c}function OP(e,n,r){const i=e.activeSubagentStack.get(n)??[];i.includes(r)||(i.push(r),e.activeSubagentStack.set(n,i))}function LP(e,n,r){const i=e.activeSubagentStack.get(n);if(i){for(let o=i.length-1;o>=0;o--)if(i[o]===r){i.splice(o,1);break}i.length===0&&e.activeSubagentStack.delete(n)}}function Ol(e,n=80){if(e==null)return"";if(typeof e=="string")return e.length>n?e.slice(0,n-1)+"…":e;try{const r=JSON.stringify(e);return r.length>n?r.slice(0,n-1)+"…":r}catch{return String(e)}}const cx=200,qP=25;function $P(e,n){const r=n.tools;if(r.length>cx){const i=r.splice(0,r.length-cx);for(const o of i)e.toolIndex.delete(o.id),e.toolOwner.delete(o.id)}for(let i=r.length-qP-1;i>=0;i--){const o=r[i];if(o.trimmed)break;o.input=void 0,o.response=void 0,o.trimmed=!0}}function DP(e,n,r){const i=e.toolIndex.get(r);if(i)return i;for(let o=n.tools.length-1;o>=0;o--)if(n.tools[o].id===r)return n.tools[o];return null}const dx=2e3;function FP(e,n,r){for(let i=e.prompts.length-1;i>=0;i--){const o=e.prompts[i];if(o.at<n-dx)return!1;if(o.text===r&&o.at<=n+dx)return!0}return!1}function zP(e,n,r,i){if(e.agents.size<=r)return!1;const o=[];for(const[u,c]of e.agents)c.state==="done"&&c.endedAt!=null&&n-c.endedAt>i&&o.push({id:u,endedAt:c.endedAt});if(o.length===0)return!1;o.sort((u,c)=>u.endedAt-c.endedAt);let l=0;for(const u of o){if(e.agents.size<=r)break;e.agents.delete(u.id),l++}return l>0}function BP(e,n,r,i){const o=new Map;for(const[h,f]of e.agents){let g=o.get(f.sessionId);g||(g={ids:[],endedAt:0,live:!1},o.set(f.sessionId,g)),g.ids.push(h),f.state==="done"&&f.endedAt!=null?g.endedAt=Math.max(g.endedAt,f.endedAt):g.live=!0}const l=[...o.values()].filter(h=>!h.live&&h.endedAt>0&&n-h.endedAt>i).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 UP(e,n,r){let i=!1;for(const o of e.agents.values())for(const l of o.tools)l.endedAt==null&&n-l.startedAt>r&&(l.endedAt=l.startedAt+r,l.ok=!1,l.errorPreview="stale (no PostToolUse received)",e.toolIndex.delete(l.id),e.toolOwner.delete(l.id),i=!0);return i}function fx(e,n){const r=n.epoch??null;if(r!==null&&r!==e.seqEpoch)e.seqEpoch=r,e.lastSeq=0;else if(n.seq<=e.lastSeq)return e;const i=n.payload??{},o=n.receivedAt,l=i.hook_event_name??"Unknown";if(l==="__clear")return{...nv(),lastSeq:n.seq,seqEpoch:e.seqEpoch};e.totalEvents+=1,e.lastSeq=n.seq;const u=i.session_id??"unknown";if(typeof i.model_context_window=="number"&&i.model_context_window>0){const h=e.agents.get(u);h&&(h.contextWindow=i.model_context_window)}if(l==="ModelObserved"){const h=typeof i.model=="string"?i.model:null;if(h){const g=e.agents.get(u);g&&(g.model=h)}const f=i.subagentModels;if(f&&typeof f=="object")for(const[g,y]of Object.entries(f)){if(typeof y!="string")continue;const x=`${u}::${g}`,N=e.agents.get(x);N&&(N.model=y)}return e}if(l==="ContextObserved"){const h=i.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=i.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 g=PN(h);f.usage.cacheCreate1hTokens=g.cacheCreate1hTokens,f.usage.cacheCreate5mTokens=g.cacheCreate5mTokens,typeof h.reasoning_output_tokens=="number"&&(f.usage.reasoningOutputTokens=Number(h.reasoning_output_tokens))}}return e}const c=ux(e,i,o);c.provider||(c.provider=i.provider==="codex"?"codex":"claude");const p=LN(i);switch(p&&(c.model=p),l){case"SessionStart":{const h=sa(e,u,o,!1);h.synthetic=!1,h.state="active",h.startedAt=h.startedAt||o,!h.cwd&&i.cwd&&(h.cwd=i.cwd,h.cwdBasename=hs(i.cwd)),h.label==="session"&&i.cwd&&(h.label=hs(i.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=sa(e,u,o,!1);h.state="active",h.endedAt=void 0,h.exitAt=void 0;const f=ux(e,i,o);f.state="active",f.exitAt=void 0,f.endedAt=void 0;const g=(typeof i.prompt=="string"?i.prompt:typeof i.message=="string"?i.message:"")??"";g&&!FP(f,o,g)&&(f.prompts.push({at:o,text:g}),f.firstPrompt||(f.firstPrompt=Ol(g,120)));break}case"PreToolUse":{const h=i.tool_use_id?DP(e,c,i.tool_use_id):null;if(h){i.tool_name&&h.name==="?"&&(h.name=i.tool_name),h.endedAt==null&&!h.trimmed&&i.tool_input!==void 0&&(h.input=i.tool_input,h.inputPreview=Ol(i.tool_input));break}const f=i.tool_use_id??`${c.id}:${c.toolCount}`,g={id:f,name:i.tool_name??"?",input:i.tool_input,inputPreview:Ol(i.tool_input),agentId:c.id,startedAt:o};c.tools.push(g),c.toolCount+=1,c.state="active",e.toolIndex.set(f,g),e.toolOwner.set(f,c.id),$P(e,c);break}case"PostToolUse":case"PostToolUseFailure":{const h=i.tool_use_id;if(!h)break;let f=e.toolIndex.get(h),g=!1;if(!f)for(const N of e.agents.values()){const _=N.tools.find(S=>S.id===h);if(_){f=_,g=!0;break}}if(!f)break;f.endedAt=o,f.ok=l==="PostToolUse",f.trimmed||(f.response=i.tool_response),l==="PostToolUseFailure"?f.errorPreview=Ol(i.tool_response):g&&(f.errorPreview=void 0);const y=ON(i.tool_response);y&&(f.usage=y),e.toolIndex.delete(h);const x=e.toolOwner.get(h)??f.agentId;if(e.toolOwner.delete(h),x&&y){const N=e.agents.get(x);N&&IP(N.usage,y)}break}case"SubagentStart":{const h=rv(i);if(!h)break;const f=PP(e,u,h,i,o);f.state="active",f.startedAt=f.startedAt||o,f.exitAt=void 0,f.endedAt=void 0;const g=ru(i);g&&(f.label=g),OP(e,u,h);break}case"SubagentStop":{const h=rv(i);if(!h)break;const f=qN(e,u,h,i);if(!f)break;f.state="done",f.endedAt=o,LP(e,u,h);break}case"Stop":case"SessionEnd":{const h=sa(e,u,o,!1);h.state="done",h.endedAt=o,e.activeSubagentStack.delete(u);break}}return e}function jv(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 HP=Date.UTC(2026,8,1);function WP(e){return e<HP?{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}}const VP=[{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:WP},{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 GP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Av(e,n=Date.now()){if(!e)return null;for(const r of VP)if(r.match.test(e))return typeof r.rates=="function"?r.rates(n):r.rates;return null}function $N(e,n){const r=Math.max(0,e.cacheCreate1hTokens??0),i=Math.max(0,e.cacheCreate5mTokens??0),o=Math.max(0,e.cacheCreateTokens-r-i),l=i+o,u=n.cacheWrite1h??n.cacheWrite;return{tokens5m:l,tokens1h:r,usd5m:l*n.cacheWrite/1e6,usd1h:r*u/1e6}}function DN(e,n){return GP(n)?Math.max(0,e.inputTokens-e.cacheReadTokens):e.inputTokens}function sn(e,n,r=Date.now()){const i=Av(n,r);if(!i)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=DN(e,n)*i.input/1e6,l=e.outputTokens*i.output/1e6,u=e.cacheReadTokens*i.cacheRead/1e6,c=$N(e,i),p=c.usd5m+c.usd1h;return{input:o,output:l,cacheRead:u,cacheWrite:p,total:o+l+u+p}}const hx=2e5,YP=1e6,KP=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],XP=[{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 QP(e){if(!e)return hx;for(const n of KP)if(n.test(e))return YP;for(const n of XP)if(n.match.test(e))return n.window;return hx}function FN(e,n){return typeof e=="number"&&e>0?e:QP(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,i=r*60;return i>=.01?`${ze(i)}/min`:`${ze(r*3600)}/hr`}const ZP=1;function JP(){const e=[];let n=0;return{push(r,i=0){const o={dismiss:r,layer:i,seq:n++};return e.push(o),()=>{const l=e.indexOf(o);l!==-1&&e.splice(l,1)}},dismissTop(){let r;for(const i of e)(!r||i.layer>r.layer||i.layer===r.layer&&i.seq>r.seq)&&(r=i);return r?(r.dismiss(),!0):!1},depth(){return e.length}}}const sv=JP();function eO(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function px(e){return String(e.tagName??"").toUpperCase()==="BODY"}function tO(e,n){return!e||!e.isConnected||px(e)?!1:n==null||px(n)}function io(e,n={}){const{focusRef:r,layer:i}=n,o=A.useRef(e);o.current=e,A.useEffect(()=>sv.push(()=>o.current(),i),[i]),A.useEffect(()=>{var u;const l=document.activeElement;return(u=r==null?void 0:r.current)==null||u.focus(),()=>{tO(l,document.activeElement)&&l.focus()}},[])}function En(e){return e.toLocaleString()}function nO(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const rO=60;function sO(e,n=rO){if(e.length<=n)return e;const r=e.slice(e.length-(n-1)),i=r.search(/[/\\]/);return"…"+(i===-1?r:r.slice(i))}function iO({agent:e,onClose:n}){var f;const r=A.useRef(null);io(n,{focusRef:r});const i=e.context,o=e.usage,l=(i==null?void 0:i.currentContextTokens)??0,u=FN(e.contextWindow,e.model),c=Math.min(100,l/u*100),p=sn(o,e.model),h=o.inputTokens+o.cacheReadTokens+o.cacheCreateTokens;return m.jsx("div",{className:"ctx-modal-backdrop",onClick:n,role:"presentation",children:m.jsxs("div",{className:"ctx-modal",onClick:g=>g.stopPropagation(),role:"dialog","aria-label":"Context breakdown",children:[m.jsxs("header",{className:"ctx-modal-head",children:[m.jsxs("div",{children:[m.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),m.jsx("div",{className:"ctx-modal-sub",children:"approximation — CC's /context isn't hook-exposed"})]}),m.jsx("button",{type:"button",ref:r,className:"ctx-modal-close",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),m.jsxs("section",{className:"ctx-window-row",children:[m.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(c),children:m.jsx("div",{className:"ctx-window-fill",style:{width:`${c}%`}})}),m.jsxs("div",{className:"ctx-window-meta",children:[m.jsxs("span",{className:"ctx-window-pct",children:[c.toFixed(1),"%"]}),m.jsxs("span",{children:[En(l)," / ",En(u)," tok (current turn)"]})]})]}),m.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),m.jsxs("div",{className:"ctx-grid",children:[m.jsx(Vn,{label:"input tokens",val:En(o.inputTokens)}),m.jsx(Vn,{label:"output tokens",val:En(o.outputTokens)}),m.jsx(Vn,{label:"cache reads",val:En(o.cacheReadTokens)}),m.jsx(Vn,{label:"cache writes",val:En(o.cacheCreateTokens)}),m.jsx(Vn,{label:"cumulative total",val:En(h)}),m.jsx(Vn,{label:"estimated cost",val:ze(p.total),accent:!0})]}),m.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.jsxs("div",{className:"ctx-grid",children:[m.jsx(Vn,{label:"user messages",val:En((i==null?void 0:i.msgsUser)??0)}),m.jsx(Vn,{label:"assistant messages",val:En((i==null?void 0:i.msgsAssistant)??0)}),m.jsx(Vn,{label:"tool uses",val:En((i==null?void 0:i.toolUses)??0)}),m.jsx(Vn,{label:"tool results",val:En((i==null?void 0:i.toolResults)??0)}),m.jsx(Vn,{label:"system-reminders",val:En((i==null?void 0:i.systemReminders)??0)})]}),m.jsx("h3",{className:"ctx-section-title",children:"CLAUDE.md files in scope"}),(((f=i==null?void 0:i.claudeMdFiles)==null?void 0:f.length)??0)===0?m.jsx("div",{className:"ctx-empty",children:"No CLAUDE.md files found on the path from cwd to ~/.claude."}):m.jsx("ul",{className:"ctx-md-list",children:i.claudeMdFiles.map(g=>m.jsxs("li",{children:[m.jsx("span",{className:"ctx-md-path",title:g.path,children:sO(g.path)}),m.jsx("span",{className:"ctx-md-size",children:nO(g.bytes)})]},g.path))})]})})}function Vn({label:e,val:n,accent:r}){return m.jsxs("div",{className:`ctx-row${r?" accent":""}`,children:[m.jsx("span",{className:"ctx-row-label",children:e}),m.jsx("span",{className:"ctx-row-val",children:n})]})}function oO({currentContextTokens:e,modelId:n,contextWindow:r,size:i=26,onClick:o,title:l}){const u=FN(r,n),c=Math.min(1,e/u),p=i/2-3,h=i/2,f=2*Math.PI*p,g=f*c,y=c>.9?"var(--err)":c>.7?"var(--inflight)":"var(--accent)";return m.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:m.jsxs("svg",{width:i,height:i,viewBox:`0 0 ${i} ${i}`,children:[m.jsx("circle",{cx:h,cy:h,r:p,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),m.jsx("circle",{cx:h,cy:h,r:p,stroke:y,strokeWidth:"2.5",fill:"none",strokeDasharray:`${g} ${f-g}`,strokeDashoffset:f/4,strokeLinecap:"round",style:{transition:"stroke-dasharray 400ms ease"}}),m.jsx("text",{x:h,y:h+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}function aO(e,n){const r=Av(n);if(!r)return"no rates for this model";const i=f=>f.toLocaleString(),o=f=>`$${f}/MTok`,l=sn(e,n),u=$N(e,r),c=u.tokens1h>0?[`cache w5m${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`,`cache w1h${i(u.tokens1h).padStart(14)} × ${o(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${ze(u.usd1h)}`]:[`cache w ${i(u.tokens5m).padStart(14)} × ${o(r.cacheWrite).padEnd(11)} = ${ze(u.usd5m)}`],p=DN(e,n),h=p===e.inputTokens?"input":"uncached";return[`model: ${n}`,`${h.padEnd(9)}${i(p).padStart(14)} × ${o(r.input).padEnd(11)} = ${ze(l.input)}`,`output ${i(e.outputTokens).padStart(14)} × ${o(r.output).padEnd(11)} = ${ze(l.output)}`,`cache r ${i(e.cacheReadTokens).padStart(14)} × ${o(r.cacheRead).padEnd(11)} = ${ze(l.cacheRead)}`,...c,"─────────────────────────────────────────",`total = ${ze(l.total)}`].join(`
|
|
58
58
|
`)}function lO(e,n,r){const i=(n??r)-e;if(i<1e3)return`${Math.max(0,i)}ms`;const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60),u=o%60;return`${l}m ${String(u).padStart(2,"0")}s`}function uO({data:e,selected:n}){var h;const r=e.now??Date.now(),i=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",n?"selected":""].filter(Boolean).join(" "),o=e.tools.filter(f=>!f.endedAt).length,u=`hsl(${jv(e.sessionId)} 70% 60%)`,c=((h=e.context)==null?void 0:h.currentContextTokens)??0,p=e.kind==="root"&&c>0;return m.jsxs("div",{className:i,style:{"--accent":u},children:[m.jsx("span",{className:"accent-stripe"}),m.jsx(no,{type:"target",position:Te.Left,style:{background:"transparent",border:"none"}}),m.jsxs("div",{className:"head",children:[m.jsxs("div",{className:"title",children:[m.jsx(cO,{state:e.state}),m.jsx("span",{className:"label",title:e.cwd,children:e.label}),e.synthetic&&m.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"})]}),m.jsxs("div",{className:"head-right",children:[p&&e.onOpenContext&&m.jsx(oO,{currentContextTokens:c,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),m.jsx("div",{className:"time",title:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:lO(e.startedAt,e.endedAt,r)})]})]}),m.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&m.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model&&m.jsx("span",{className:"model-chip",title:e.model,children:ei(e.model)})]}),e.tools.length>0&&m.jsx(fO,{tools:e.tools,now:r}),m.jsxs("div",{className:"meta",children:[m.jsxs("span",{children:[m.jsx("b",{children:e.toolCount})," tools"]}),o>0&&m.jsxs("span",{className:"inflight-meta",children:[m.jsx("b",{children:o})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&m.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:[m.jsx("b",{children:dO(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&Av(e.model)&&(()=>{const f=sn(e.usage,e.model);if(f.total<=0)return null;const g=Math.max(0,((e.endedAt??r)-e.startedAt)/1e3),y=e.state==="active"?su(f.total,g):null,x=aO(e.usage,e.model)+(y?`
|
|
59
|
-
burn: ${y}`:"");return m.jsxs("span",{className:"cost-meta",title:x,children:[m.jsx("b",{children:ze(f.total)}),y&&m.jsx("span",{className:"cost-rate",children:y})]})})()]}),m.jsx(no,{type:"source",position:Te.Right,style:{background:"transparent",border:"none"}})]})}function cO({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return m.jsx("span",{className:`state-pill state-${e}`,children:n})}function dO(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function fO({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,g=c/(2500/1e3);return m.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[m.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,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return m.jsx("rect",{x:x*f+.4,y:h-N,width:Math.max(.5,f-1),height:N,rx:.8,className:b},x)})}),m.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function ei(e){const n=e.replace(/^anthropic\./,"").replace(/[-_]\d{8}(?!\d)/,""),r=n.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(r){const l=r[1][0].toUpperCase()+r[1].slice(1).toLowerCase(),u=r[2].replace(/[-_]/g,".");return`${l} ${u}`}const i=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const o=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return o?`GPT-${o[1].replace(/[-_]/g,".")}`:e}function mx(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function hO(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 pO({tool:e,onClose:n}){io(n);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return m.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:m.jsxs("div",{className:"modal",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:`status-dot ${r}`}),m.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),m.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",children:hO(e)}),m.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("section",{className:"modal-body",children:[e.trimmed&&m.jsx("div",{className:"modal-section",children:m.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),m.jsxs("div",{className:"modal-section",children:[m.jsx("h4",{children:"Input"}),m.jsx("pre",{children:mx(e.input??e.inputPreview)})]}),m.jsxs("div",{className:"modal-section",children:[m.jsxs("h4",{children:["Response ",r==="err"&&m.jsx("span",{className:"err-tag",children:"error"})]}),m.jsx("pre",{children:e.endedAt==null?"(waiting…)":mx(e.response??e.errorPreview)})]})]})]})})}const Ll=18,gx=26,mO=12;function gO(e){return vO(e.nodeInternals.values())}function vO(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=vx(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:vx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const i=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${yO(o)}`:l.label;i.push({sessionId:o,label:c,x:l.minX-Ll,y:l.minY-Ll-gx,w:l.maxX-l.minX+Ll*2,h:l.maxY-l.minY+Ll*2+gx})}return i}function yO(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function vx(e){if(e.kind==="root")return e.label}function wO(){const{x:e,y:n,zoom:r}=TN(),i=wa(),o=Xe(gO,xO);if(o.length<=1)return null;const l=u=>{try{const c=i.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;i.fitView({padding:.3,duration:500,nodes:c})}catch{}};return m.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=jv(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-mO)*r+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top"};return m.jsxs(le.Fragment,{children:[m.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),m.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 xO(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(i.sessionId!==o.sessionId||i.label!==o.label||i.x!==o.x||i.y!==o.y||i.w!==o.w||i.h!==o.h)return!1}return!0}function _O({data:e}){return m.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const zN=600,bO=4,SO=36,iv=16,kO=60,EO=6,yx=220,wx=96,NO=28,CO={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 TO(e){return e.startsWith("mcp__")?"mcp":CO[e]??"other"}const RO={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 xx(e){return e.startsWith("mcp__")?"🔌":RO[e]??"✨"}const jO={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 BN(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 BN(r[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const i=n.match(/^([^\s|;&<>(]+)/);if(!i)return null;let o=i[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function AO(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(r=>typeof r=="string")){const r=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const i=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(i>=0&&i+1<r.length)return r[i+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const IO=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),MO=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function PO(e,n){return MO.has(e)||e.startsWith("mcp__")?Math.max(wx,34+n.length*7.5):wx}function OO(e,n){if(!IO.has(e))return null;const r=AO(n);if(!r)return null;const i=BN(r);return i?{emoji:jO[i]??"⚙️",label:i,category:"shell",detail:r}:null}const LO=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),_x={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:"🗄️"},bx={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 qO(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function $O(e){const n=e.toLowerCase();if(bx[n])return bx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const r=n.lastIndexOf(".");if(r>0&&r<n.length-1){const i=n.slice(r+1);if(_x[i])return _x[i]}return"📄"}function DO(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const i=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return i?i[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function FO(e,n){if(!LO.has(e))return null;const r=DO(e,n);if(!r)return null;const i=qO(r);return i?{emoji:e==="LS"?"📂":$O(i),label:i,category:"file",detail:r}:null}const UN={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 HN(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 zO(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 BO(e,n){const r=HN(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const l=UN[i.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${i} · ${o}`}}function UO(e,n){return OO(e,n)??FO(e,n)??BO(e)}const HO={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function WO(e){const n=HN(e);if(n){const i=UN[n.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:n.server,hue:zO(n.server)}}const r=HO[e];return r?{emoji:xx(e),label:r}:{emoji:xx(e),label:e}}function VO(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function GO(e,n,r){if(r==null)return 1;const i=n-r;return i<0?1:Math.max(0,1-i/zN)}function YO(e,n){const r=[],i=new Set;for(let o=e.length-1;o>=0&&r.length<n;o--){const l=e[o];i.has(l.id)||(i.add(l.id),r.push(l))}return r.reverse()}function KO(e,n,r,i,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>zN)continue;const p=i.get(c.id)??r.get(c.id);if(!p)continue;const h=YO(c.tools,bO);if(h.length===0)continue;const f=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??yx,yx),x=(g==null?void 0:g.height)??130,N=p.x,_=p.y,S=N+y,b=_+x/2;h.forEach((k,E)=>{const C=E*SO,R=N+y+kO,I=_+EO+C,L=GO(k,l,f),H=k.inputPreview??"",P=VO(k),q=L<.999,B=WO(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:B.label,emoji:B.emoji,status:P,category:TO(k.name),mcpHue:B.hue,inputPreview:H,fade:L,fading:q,worldX:R,worldY:I,anchorX:S,anchorY:b,spawnDx:S-R,spawnDy:b-(I+iv)});const D=UO(k.name,k.input);if(D){const F=PO(k.name,B.label),j=R+F+NO,Z=I,W=R+F,ne=I+iv;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:D.label,emoji:D.emoji,isSub:!0,status:P,category:D.category,inputPreview:D.detail??H,fade:L,fading:q,worldX:j,worldY:Z,anchorX:W,anchorY:ne,spawnDx:W-j,spawnDy:0})}})}return u}function XO({agents:e,visibleAgentIds:n,positions:r,pinned:i,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const f=KO(e,n,r,i,o,p),g=c&&c.size>0?f.filter(y=>!c.has(y.category)):f;return m.jsx(QO,{bursts:g,dimUnmatched:l,spotlight:u,onOpenTool:h})}function QO({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:i}){const{x:o,y:l,zoom:u}=TN();return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.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,g=(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 m.jsx("path",{d:`M ${p} ${h} Q ${y} ${h}, ${f} ${g}`,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`},g=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${g} · ${c.inputPreview}`:g,x=i!=null,N=c.mcpHue!=null?{"--cat-accent":`hsl(${c.mcpHue} 65% 65%)`}:{},_=n!=null&&!n.has(c.agentId),S=r!=null&&!r.has(c.agentId),b=_||S?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:f,children:m.jsxs("div",{className:`tool-burst cat-${c.category} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${b}`,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?()=>i(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),i(c.toolId))}:void 0,children:[m.jsx("span",{className:"tb-emoji",children:c.emoji}),m.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&m.jsx("span",{className:"tb-spin"}),c.status==="done"&&m.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&m.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function ZO({state:e,sessionId:n,onClose:r}){const i=A.useMemo(()=>e3(e,n),[e,n]),o=A.useRef(null);return io(r,{focusRef:o}),i?m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[m.jsxs("div",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),m.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),m.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",title:"Total wall time",children:i.durationLabel}),m.jsx("button",{type:"button",ref:o,className:"btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("div",{className:"modal-body",children:[m.jsxs("section",{className:"ss-hero",children:[m.jsxs("div",{className:"ss-hero-left",children:[m.jsx("div",{className:"ss-cost-label",children:"total spend"}),m.jsx("div",{className:"ss-cost",children:ze(i.cost.total)}),i.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:i.modelChips.map(l=>m.jsx("span",{className:"model-chip",title:l,children:ei(l)},l))})]}),m.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(JO,{cost:i.cost}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:ze(i.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:ze(i.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:ze(i.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:ze(i.cost.cacheWrite)})]})]})]})})]}),m.jsxs("section",{className:"ss-stats",children:[m.jsx(Wi,{label:"agents",value:i.agentCount}),m.jsx(Wi,{label:"subagents",value:i.subagentCount}),m.jsx(Wi,{label:"tool calls",value:i.toolCount}),m.jsx(Wi,{label:"prompts",value:i.promptCount}),m.jsx(Wi,{label:"tokens",value:i.tokensSum.toLocaleString()}),i.errCount>0&&m.jsx(Wi,{label:"errors",value:i.errCount,tone:"err"})]}),i.topTools.length>0&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Most-used tools"}),m.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([l,u])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:l}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/i.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),i.firstPrompt&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Opening prompt"}),m.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function Wi({label:e,value:n,tone:r}){return m.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:n}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function JO({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(i)} (${u.toFixed(0)}%)`},o)};return m.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 e3(e,n){const r=e.agents.get(n);if(!r)return null;const i=[];for(const E of e.agents.values())E.sessionId===n&&i.push(E);if(i.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,p=0,h=0,f=0,g=0,y,x=1/0,N=0;for(const E of i){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"&&g++,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 R of E.tools)u.set(R.name,(u.get(R.name)??0)+1),R.ok===!1&&f++}const _=Math.max(0,N-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%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:b,cost:o,modelChips:Array.from(l),agentCount:i.length,subagentCount:g,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:k,firstPrompt:y}}function t3(e,n){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,l=sn(i.usage,i.model).total,u=i.endedAt??i.startedAt;for(const c of e.agents.values()){if(c.sessionId!==i.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=sn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}r.push({sessionId:i.sessionId,label:i.label||i.cwdBasename||"session",cwdBasename:i.cwdBasename,state:i.state,modelId:i.model,toolCount:o,cost:l,startedAt:i.startedAt,lastActivity:u})}return r.sort((i,o)=>{if(i.state!==o.state){if(i.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-i.lastActivity}),r}function n3(e,n,r){const i=(n??r)-e;if(i<1e3)return"<1s";const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function r3({state:e,now:n,selectedIds:r,onSelect:i,onClose:o}){const l=A.useMemo(()=>t3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return m.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h3",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&m.jsxs("span",{className:"sl-live-count",children:[u," live"]}),m.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),m.jsxs("div",{className:"sl-rows",children:[l.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const p=r.has(c.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>i(c.sessionId),title:`Focus ${c.label}`,children:[m.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&m.jsx("span",{className:"model-chip",title:c.modelId,children:ei(c.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:ze(c.cost)})}),m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:n3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function Sx(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 s3(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 i3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(i)} (${u.toFixed(0)}%)`},o)};return m.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 o3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/3600),o=Math.floor(r%3600/60);if(i>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return i>0?`${i}h ${o}m`:`${o}m`}function a3(e,n,r,i){const o=Math.max(0,n-i),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,g={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);g.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return g}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Ws({pct:e,label:n,reset:r,resetAt:i,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}%`,g=c===0?2:c,y=i?o3(i,u):null,x=i&&o?a3(c,i,o,u):null;return m.jsxs("div",{className:"qb-row",children:[m.jsxs("div",{className:"qb-meta",children:[m.jsxs("span",{className:"qb-label",children:[n,l&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:h},children:f})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:h,opacity:c===0?.4:1}}),x&&m.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`})]}),m.jsxs("div",{className:"qb-reset-row",children:[y?m.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?m.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,x&&m.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const l3=6e4;function u3(){const[e,n]=A.useState(null),[r,i]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&i(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),l3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function c3(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 WN=6e4;function d3(){const[e,n]=A.useState(null),[r,i]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&i(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),WN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function f3(){const[e,n]=A.useState(null),r=A.useRef(null),i=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(i(),r.current=window.setInterval(i,WN),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function h3({state:e,now:n,onClose:r}){var L,H;const{quota:i,loading:o,refresh:l}=u3(),{data:u,loading:c,refresh:p}=d3(),{data:h}=f3(),[f,g]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const P=window.setInterval(()=>g(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(P)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=A.useMemo(()=>{const P=new Map,q={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,D=0,F=0,j=0;for(const U of e.agents.values()){const X=U.model??"__unknown__",M=sn(U.usage,U.model),V=P.get(X);V?(V.inputTokens+=U.usage.inputTokens,V.outputTokens+=U.usage.outputTokens,V.cacheReadTokens+=U.usage.cacheReadTokens,V.cacheCreateTokens+=U.usage.cacheCreateTokens,V.cost.total+=M.total,V.cost.input+=M.input,V.cost.output+=M.output,V.cost.cacheRead+=M.cacheRead,V.cost.cacheWrite+=M.cacheWrite,V.agentCount++):P.set(X,{model:X,inputTokens:U.usage.inputTokens,outputTokens:U.usage.outputTokens,cacheReadTokens:U.usage.cacheReadTokens,cacheCreateTokens:U.usage.cacheCreateTokens,cost:{...M},agentCount:1}),q.total+=M.total,q.input+=M.input,q.output+=M.output,q.cacheRead+=M.cacheRead,q.cacheWrite+=M.cacheWrite,B+=U.usage.inputTokens,D+=U.usage.outputTokens,F+=U.usage.cacheReadTokens,j+=U.usage.cacheCreateTokens}const Z=Array.from(P.values()).sort((U,X)=>X.cost.total-U.cost.total);let W=0,ne=0;for(const U of e.agents.values()){if(U.state!=="active")continue;const X=sn(U.usage,U.model);W+=X.total,ne=Math.max(ne,((U.endedAt??n)-U.startedAt)/1e3)}const J=ne>0?su(W,ne):null;return{byModel:Z,totalCost:q,totalTokens:{in:B,out:D,cacheR:F,cacheC:j},burnRate:J}},[e,e.lastSeq,n]),S=A.useMemo(()=>{const P=[];for(const q of e.agents.values()){if(q.kind!=="root")continue;let B=sn(q.usage,q.model).total,D=q.usage.inputTokens,F=q.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==q.sessionId||j.kind==="root"||(B+=sn(j.usage,j.model).total,D+=j.usage.inputTokens,F+=j.usage.outputTokens);P.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:B,inputTokens:D,outputTokens:F})}return P.sort((q,B)=>B.cost-q.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Sx(i==null?void 0:i.fetchedAt,f),R=Sx(u==null?void 0:u.fetchedAt,f),I=()=>{l(),p()};return m.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h3",{children:"Usage"}),_&&m.jsx("span",{className:"up-rate",children:_}),m.jsxs("div",{className:"up-header-right",children:[m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:I,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&m.jsx("span",{className:"up-section-age",title:s3(i==null?void 0:i.source),children:C})]}),i!=null&&i.ok?m.jsxs("div",{className:"up-quota-bars",children:[i.session5hPct!=null&&m.jsx(Ws,{label:"5-hour window",pct:i.session5hPct,reset:i.session5hReset,resetAt:i.session5hResetAt,windowSec:i.session5hWindowSec,nowSec:f}),i.week7dPct!=null&&m.jsx(Ws,{label:"7-day window",pct:i.week7dPct,reset:i.week7dReset,resetAt:i.week7dResetAt,windowSec:i.week7dWindowSec,nowSec:f}),i.weekSonnetPct!=null&&m.jsx(Ws,{label:"Sonnet (7d)",pct:i.weekSonnetPct,nowSec:f}),i.weekOpusPct!=null&&m.jsx(Ws,{label:"Opus (7d)",pct:i.weekOpusPct,nowSec:f})]}):(i==null?void 0:i.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsxs("span",{className:"up-quota-hint",children:["Run ",m.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&m.jsx("span",{className:"up-plan-badge",children:u.planLabel}),R&&!c&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:R})]}),u!=null&&u.ok?m.jsxs("div",{className:"up-quota-bars",children:[(L=u.windows)==null?void 0:L.map(P=>m.jsx(Ws,{label:P.label,pct:P.pct,reset:P.reset??void 0,resetAt:P.resetAt??void 0,windowSec:P.windowSec??void 0,limitReached:u.limitReached&&P.pct>=100,nowSec:f},P.id)),(H=u.extraWindows)==null?void 0:H.map(P=>m.jsx(Ws,{label:P.label,pct:P.pct,reset:P.reset??void 0,resetAt:P.resetAt??void 0,windowSec:P.windowSec??void 0,nowSec:f},P.id)),u.creditLimit&&m.jsx(Ws,{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&&m.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&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&m.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&&m.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&m.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?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:c3(u.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:ze(x.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(i3,{cost:x}),k>0&&m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]}),N.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),jr(N.cacheR)]}),N.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),jr(N.cacheC)]})]}),y.filter(P=>P.cost.total>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By model"}),m.jsxs("table",{className:"up-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Model"}),m.jsx("th",{children:"Tokens"}),m.jsx("th",{children:"Cost"})]})}),m.jsx("tbody",{children:y.filter(P=>P.cost.total>0).map(P=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:P.model,children:ei(P.model)}),m.jsx("td",{className:"up-num",children:jr(P.inputTokens+P.outputTokens)}),m.jsx("td",{className:"up-num up-cost-val",children:ze(P.cost.total)})]},P.model))})]})]}),S.filter(P=>P.cost>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:S.filter(P=>P.cost>0).map(P=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${P.state}`,"aria-hidden":!0}),m.jsx("span",{className:"up-session-label",children:P.label}),m.jsx("span",{className:"up-session-tokens",children:jr(P.inputTokens+P.outputTokens)}),m.jsx("span",{className:"up-session-cost",children:ze(P.cost)})]},P.sessionId))})]})]}):k>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]})]}),m.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const kx=18,p3=1100,Vi=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},m3=Array.from({length:kx},(e,n)=>{const r=-72+144*n/(kx-1)+(Vi(n,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Vi(n,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(n%2?1:-1)*(100+Vi(n,3)*260),delay:Math.round(Vi(n,4)*90),dur:760+Math.round(Vi(n,5)*260),scale:.8+Vi(n,6)*.45,hue:n%4,round:n%3===0}});function Ex({anchor:e,lifetimeMs:n=p3}){var l;const[r,i]=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();i({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:wI.createPortal(m.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:m3.map((u,c)=>m.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 VN=new Set(["awaiting_url","awaiting_code","registering"]);function g3(e){return e!=null&&VN.has(e)}function GN(e){return e!=null&&e!=="done"&&!VN.has(e)}const v3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",y3="the sign-in did not complete";function w3({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?v3:y3)}}const x3="done";function _3(){let e=!1;return{shouldAnnounce(n){return n!==x3?(e=!1,!1):e?!1:(e=!0,!0)}}}const Nx={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"},Cx={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"},b3="claude-swap could not read the login keychain — start agents-deck from a Terminal window rather than a background service";function ov(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ro(e))?b3:e!=null&&e.reason&&Cx[e.reason]?Cx[e.reason]:(e==null?void 0:e.reason)||n}function ro(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Tx={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",unreachable:"the deck did not answer — check it is still running, then try again"},S3="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function k3(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}function E3(e,n){return k3(ro(e))?S3:e!=null&&e.reason&&Tx[e.reason]?Tx[e.reason]:(e==null?void 0:e.reason)||n}function Gl(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&GN(e.state)?e.error:e!=null&&e.reason&&Nx[e.reason]?Nx[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const N3=1500;async function ql(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const av=le.forwardRef((e,n)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[m.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),m.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));av.displayName="SuccessMark";function C3({onClose:e,onChanged:n}){const[r,i]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,g]=A.useState(!1),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useRef(!1),b=A.useRef(null),k=A.useRef(null),E=A.useRef(null),C=A.useCallback(()=>{S.current&&ql({action:"login-cancel"}).catch(()=>{}),e()},[e]);io(C);const R=A.useCallback(async()=>{g(!0),x(null),S.current=!0;const F=await ql({action:"login"}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){x(Gl(F,"could not start the sign-in"));return}l(F)},[]);A.useEffect(()=>{if(!g3(o==null?void 0:o.state))return;const F=window.setInterval(async()=>{try{const j=await fetch("/api/claude-accounts/login");j.ok&&l(await j.json())}catch{}},N3);return()=>window.clearInterval(F)},[o]);const I=A.useRef(n);I.current=n;const L=A.useRef(_3());A.useEffect(()=>{var F;(o==null?void 0:o.state)==="awaiting_code"&&((F=b.current)==null||F.focus()),L.current.shouldAnnounce(o==null?void 0:o.state)&&I.current()},[o==null?void 0:o.state]),A.useEffect(()=>{var F;r==="paste"&&((F=k.current)==null||F.focus())},[r]);const H=A.useCallback(async()=>{var j;g(!0),x(null);const F=await ql({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){x(Gl(F,"the code was not accepted")),F!=null&&F.state&&l(F),(j=b.current)==null||j.select();return}c(""),l(F)},[u,o]),P=A.useCallback(async()=>{g(!0),x(null);const F=await ql({action:"import",blob:p}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){x(Gl(F,"the import failed"));return}h(""),_({added:F.added===!0,num:F.num??null,email:F.email??null}),n()},[p,n]),q=(o==null?void 0:o.state)==="done"?o.account:null,B=GN(o==null?void 0:o.state)||!!(y&&S.current&&!f),D=w3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return m.jsx("div",{className:"modal-backdrop",onClick:C,role:"presentation",children:m.jsxs("div",{className:"modal aa-modal",onClick:F=>F.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[m.jsxs("header",{className:"modal-head",children:[m.jsx("div",{className:"modal-title",children:m.jsxs("span",{className:"aa-tabs",role:"tablist",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),m.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:C,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:r==="login"?q?m.jsxs("div",{className:"aa-done",children:[m.jsx(av,{ref:E}),m.jsx(Ex,{anchor:E}),m.jsx("h4",{children:q.added?`Account ${q.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:q.email}),q.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),m.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"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"1 · Approve in the browser"}),m.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),m.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"2 · Paste the code it gives you"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:b,type:"text",value:u,onChange:F=>c(F.target.value),onKeyDown:F=>{F.key==="Enter"&&u.trim()&&!f&&H()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),m.jsx("button",{type:"button",className:"btn primary",disabled:f||!u.trim()||o.state==="registering",onClick:H,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&m.jsx("p",{className:"aa-err",children:y??o.error}),m.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."})]})]}):B?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:D.title}),m.jsx("p",{className:"aa-err",children:D.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),R()},children:"Try again"})]}):f||S.current?m.jsx("div",{className:"aa-step",children:m.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):m.jsxs("div",{className:"aa-step aa-primer",children:[m.jsx("h4",{children:"Sign in to Anthropic"}),m.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."}),m.jsx("div",{className:"aa-actions",children:m.jsx("button",{type:"button",className:"btn primary",onClick:R,disabled:f,children:"Open the sign-in page"})})]}):N?m.jsxs("div",{className:"aa-done",children:[m.jsx(av,{ref:E}),N.added&&m.jsx(Ex,{anchor:E}),m.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:N.added?m.jsxs(m.Fragment,{children:[N.email?m.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."}),m.jsxs("div",{className:"aa-actions",children:[m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),m.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Paste an account shared from another deck"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:k,type:"text",value:p,onChange:F=>h(F.target.value),onKeyDown:F=>{F.key==="Enter"&&p.trim()&&!f&&P()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:P,children:f?"importing…":"Import"})]}),y&&m.jsx("p",{className:"aa-err",children:y}),m.jsxs("p",{className:"aa-note",children:["Use ",m.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 T3=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function Rx(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function R3(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=ro(n.body);return{text:ov(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function jx(e,n){return n?e!=null&&e.reload&&e.text===n.text&&e.raw===n.raw?e:n:e!=null&&e.reload?null:e}const Ax=15e3,j3=3e4,A3=[70,80,85,90,95];function I3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function Ix(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 M3(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 P3(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 O3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?I3(e.resetAt,n):null;return m.jsxs("div",{className:"ap-lane",children:[m.jsx("span",{className:"ap-lane-label",children:e.label}),m.jsx("div",{className:"ap-lane-track",children:m.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),m.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),m.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function L3(e){const n=e.map(i=>i.num),r=n.length?Math.max(...n):0;return[...new Set([...n,r+1])].sort((i,o)=>i-o)}async function q3(e){var r;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(i=>window.setTimeout(()=>i(!1),500))])}catch{n=!1}if(n)return!0;try{const i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(i),i.select(),n=document.execCommand("copy"),i.remove()}catch{n=!1}return n}function $3(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 D3({onClose:e}){var X,M,V;const[n,r]=A.useState(null),[i,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(!1),[h,f]=A.useState(null),[g,y]=A.useState(null),[x,N]=A.useState(()=>Math.floor(Date.now()/1e3)),_=A.useRef(null),[S,b]=A.useState(null),[k,E]=A.useState(!1),[C,R]=A.useState(""),[I,L]=A.useState(null),[H,P]=A.useState(null),[q,B]=A.useState(!1),D=A.useCallback(async(O=!1)=>{O&&p(!0);const $=new AbortController,Y=window.setTimeout(()=>$.abort(),j3);try{const[te,oe]=await Promise.all([fetch(`/api/claude-accounts${O?"?refresh=1":""}`,{signal:$.signal}),fetch("/api/cswap-auto",{signal:$.signal})]);te.ok&&r(await te.json()),oe.ok&&o(await oe.json());const ce=R3([await Rx(te),await Rx(oe)]);y(pe=>jx(pe,ce))}catch{y(te=>jx(te,T3))}finally{window.clearTimeout(Y),O&&p(!1)}},[]),F=A.useCallback(async(O,$)=>{u($),y(null);try{const te=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).json().catch(()=>null);return te!=null&&te.ok||y({text:ov(te,"command failed"),raw:ro(te)}),te}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),j=A.useCallback(async(O,$)=>{u($),y(null);try{const te=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).json().catch(()=>null);return te!=null&&te.ok||y({text:Gl(te,"command failed")}),te}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);A.useEffect(()=>(D(!0),_.current=window.setInterval(()=>D(!1),Ax),()=>{_.current!=null&&window.clearInterval(_.current)}),[D]),A.useEffect(()=>{const O=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const Z=((X=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:X.value)??"90",W=(M=n==null?void 0:n.accounts)==null?void 0:M.find(O=>O.active),ne=W!=null&&W.lanes.length?Math.max(...W.lanes.map(O=>O.pct)):null,J=ne!=null&&ne>=Number(Z)-15,U=async O=>{f(O),y(null);try{const Y=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:O})})).json().catch(()=>null);Y!=null&&Y.ok||y({text:ov(Y,"the switch failed"),raw:ro(Y)}),await D(!0)}catch{y({text:"server unreachable"})}finally{f(null)}};return m.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h3",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>E(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),m.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>D(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g?m.jsxs("div",{className:"ap-empty",role:"alert",children:[m.jsx("span",{title:g.raw||void 0,children:g.text}),m.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",Ax/1e3," seconds."]}),m.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>D(!0),children:c?"trying…":"try again"})]}):m.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?m.jsxs(m.Fragment,{children:[(V=n.accounts)==null?void 0:V.map(O=>m.jsxs("div",{className:`ap-account${O.active?" active":""}${O.disabled?" disabled":""}`,children:[m.jsxs("div",{className:"ap-account-head",children:[m.jsx("span",{className:"ap-num",children:O.num}),O.alias&&m.jsx("span",{className:"ap-alias",children:O.alias}),m.jsx("span",{className:"ap-email",title:O.org??void 0,children:O.email}),m.jsx("button",{type:"button",className:`ap-more${S===O.num?" on":""}`,"aria-label":`Manage account ${O.num}`,"aria-expanded":S===O.num,title:"Share, rename, move, remove",onClick:()=>{b(S===O.num?null:O.num),R(O.alias??""),L(null),P(null),B(!1)},children:"⋯"}),O.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.jsx("button",{type:"button",className:"btn ap-switch",disabled:h!=null||O.disabled,onClick:()=>U(O.num),title:O.disabled?"Held out of rotation":`Switch to ${O.alias??O.email}`,children:h===O.num?"…":"switch"})]}),O.lanes.length>0?O.lanes.map($=>m.jsx(O3,{lane:$,nowSec:x},$.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[O.error&&(()=>{const $=P3(O.error);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ap-err",title:$.hint,children:$.text}),$.fixable&&m.jsx("button",{type:"button",className:"ap-fix",onClick:()=>E(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!O.active&&m.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>F({action:"account",account:O.num,enabled:O.disabled},`rot-${O.num}`).then(()=>D(!0)),title:O.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:O.disabled?"held out":"in rotation"}),O.fetchedAt?m.jsxs("span",{className:`ap-age${O.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 ",Ix(O.fetchedAt,x),M3(O.nextAt,x)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),S===O.num&&m.jsxs("div",{className:"ap-manage",children:[m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"name"}),m.jsx("input",{className:"ap-manage-input",type:"text",value:C,onChange:$=>R($.target.value),onKeyDown:$=>{$.key==="Enter"&&j({action:"alias",account:O.num,alias:C},`alias-${O.num}`).then(()=>D(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${O.num}`}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||C.trim()===(O.alias??""),onClick:()=>j({action:"alias",account:O.num,alias:C},`alias-${O.num}`).then(()=>D(!0)),title:"A short name to show instead of the email",children:"save"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"slot"}),m.jsx("span",{className:"ap-field",children:m.jsx("select",{"aria-label":`Slot for account ${O.num}`,value:String(O.num),disabled:l!=null,onChange:$=>j({action:"move",account:O.num,slot:Number($.target.value)},`move-${O.num}`).then(()=>D(!0)),children:L3(n.accounts??[]).map($=>m.jsx("option",{value:$,children:$},$))})}),m.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.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()=>{B(!1);const $=await j({action:"share",account:O.num},`share-${O.num}`);$!=null&&$.ok&&P({num:O.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),m.jsx("button",{type:"button",className:`ap-manage-btn danger${I===O.num?" armed":""}`,disabled:l!=null,title:I===O.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(I!==O.num){L(O.num),window.setTimeout(()=>L($=>$===O.num?null:$),4e3);return}L(null),j({action:"remove",account:O.num},`rm-${O.num}`).then(()=>{b(null),D(!0)})},children:I===O.num?"confirm remove":"remove"})]}),(H==null?void 0:H.num)===O.num&&(()=>{const $=$3(H.expiresAt,x),Y=$.tone==="gone";return m.jsxs("div",{className:`ap-share${Y?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:H.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Y){B(!1);const te=await j({action:"share",account:O.num},`share-${O.num}`);te!=null&&te.ok&&P({num:O.num,blob:te.blob,expiresAt:te.expiresAt});return}await q3(H.blob)&&(B(!0),window.setTimeout(()=>B(!1),1800))},children:Y?"make a new share":q?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",m.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]})]})]})})()]})]},O.num)),(i==null?void 0:i.ok)&&m.jsxs("div",{className:"ap-auto",children:[m.jsxs("div",{className:"ap-auto-head",children:[m.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),m.jsxs("span",{className:"ap-auto-ctl",children:[ne!=null&&m.jsxs("span",{className:`ap-auto-now${J?" near":""}`,children:[Math.round(ne),"%"]}),m.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:m.jsx("select",{"aria-label":"Switch threshold",value:Z,disabled:l!=null,onChange:O=>F({action:"setting",key:"autoswitch.threshold",value:O.target.value},"threshold").then(()=>D(!0)),children:A3.map(O=>m.jsxs("option",{value:O,children:[O,"%"]},O))})}),m.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:l!=null,onClick:()=>F({action:"enable",enabled:!i.enabled},"enable").then(()=>D(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[m.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&m.jsxs("p",{className:"ap-auto-note",children:[m.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",m.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",i.enabled?" — this toggle takes over when you stop it.":"."]}),i.lastTick&&m.jsx("div",{className:"ap-auto-foot",children:m.jsxs("span",{className:"ap-auto-result",children:["checked ",Ix(i.lastTick.at,x)]})})]}),g&&m.jsxs("div",{className:"ap-failure",role:"alert",children:[m.jsx("span",{className:"ap-failure-text",title:g.raw||void 0,children:g.text}),m.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),m.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."})]}):m.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"claude-swap isn't installed."}),m.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&&m.jsx("code",{className:"ap-cmd",children:n.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"No accounts added yet."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",m.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"Couldn't read the account store."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),k&&m.jsx(C3,{onClose:()=>E(!1),onChanged:()=>D(!0)})]})}const F3=3e4;function z3({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function B3({bundle:e,running:n,pending:r,lastTried:i}){return n?z3({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function U3(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function H3({asked:e,reported:n}){return n?n!==e:!1}function W3(e){const n=e.thresholdMs??F3;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 V3(e){return e.ctrlKey||e.metaKey||e.altKey}const G3=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),Y3=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),K3=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function YN(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function KN(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=YN(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!G3.has(String(e.type??"text").toLowerCase())}function X3(e){if(!e)return!1;if(KN(e)||Y3.has(YN(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>K3.has(r))}function Q3({agentCount:e,onConfirm:n,onCancel:r}){const i=A.useRef(null);io(r,{focusRef:i,layer:ZP});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 m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{className:"modal clear-confirm",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"status-dot err","aria-hidden":!0}),m.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),m.jsxs("section",{className:"modal-body",children:[m.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."]}),m.jsxs("div",{className:"cc-actions",children:[m.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function Z3(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function $l(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function J3(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function XN(e,n,r){return!n.has(e)||r.has(e)}function eL(e,n,r,i){return!n.has(e)&&XN(e,r,i)}function tL(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function nL(e,n,r,i){r.set(e,n),i.delete(e)}const rL=40,sL=120;function iL(e,n){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,h,f)=>{if(r!=null){if(i<=p)return;u()}const g=Math.min(f,Math.max(0,p-h));i=p,r=n.setTimeout(l,g)};return{live(p=rL){const h=n.now(),f=Math.max(o+p,h);if(f<=h){u(),l();return}c(f,h,p)},replay(p=sL){u(),i=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function oL(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const i=n;return n=[],i}}}const aL="1",Mx="agent-dag.schema",lL=["agent-dag.layout","agent-dag.viewport"];function QN(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function uL(e,n=aL){let r=null;try{r=e.getItem(Mx)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of lL)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(Mx,n)}catch{}return i}function cL(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function dL(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function fL(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function Vs(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 Dl(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 hL=[7,14,30,90];function pL(e){const[n,r]=A.useState(null),[i,o]=A.useState(!1),l=A.useRef(cL()).current,u=(c=!1)=>{const p=l.begin(),h=e;o(!0);const g=`/api/ccusage?since=${dL(h)}${c?"&refresh=1":""}`;fetch(g).then(y=>y.json()).then(y=>{p()&&r({range:h,resp:y})}).catch(()=>{p()&&r({range:h,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function mL({onClose:e}){var k,E,C;const[n,r]=A.useState(30),[i,o]=A.useState(null),{landed:l,loading:u,reload:c}=pL(n);io(e);const p=fL({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((k=l.resp.days)==null?void 0:k.length)??0}}),h=p.phase==="chart"?l.resp.days??[]:[],f=A.useMemo(()=>h.reduce((R,I)=>Math.max(R,I.totalCost),0),[h]),{totalCost:g,totalTok:y,inOut:x,cacheRead:N,modelCosts:_}=A.useMemo(()=>{let R=0,I=0,L=0,H=0;const P=new Map;for(const q of h){R+=q.totalCost,I+=q.totalTokens,L+=q.inputTokens+q.outputTokens,H+=q.cacheReadTokens;for(const B of q.modelBreakdowns)P.set(B.modelName,(P.get(B.modelName)??0)+B.cost)}return{totalCost:R,totalTok:I,inOut:L,cacheRead:H,modelCosts:P}},[h]),S=A.useMemo(()=>Array.from(_.entries()).sort((R,I)=>I[1]-R[1]),[_]),b=i?h.find(R=>R.period===i)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{className:"uh-modal",onClick:R=>R.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[m.jsxs("header",{className:"uh-head",children:[m.jsxs("div",{className:"uh-titlewrap",children:[m.jsx("div",{className:"uh-title",children:"Usage history"}),m.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),m.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:hL.map(R=>m.jsxs("button",{role:"tab","aria-selected":n===R,className:`uh-range-btn${n===R?" on":""}`,onClick:()=>{r(R),o(null)},children:[R,"d"]},R))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,disabled:u,title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),m.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),p.phase==="busy"?m.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):p.phase==="error"?m.jsxs("div",{className:"uh-status uh-err",title:ro(l.resp)||void 0,children:[E3(l.resp,"ccusage did not report usage"),m.jsx("div",{children:m.jsx("button",{className:"btn uh-retry",onClick:c,disabled:u,children:u?"trying…":"Try again"})})]}):p.phase==="empty"?m.jsx("div",{className:`uh-status${p.stale?" uh-stale":""}`,"aria-busy":p.stale||void 0,children:"no usage in this range"}):m.jsxs("div",{className:p.stale?"uh-stale":void 0,"aria-busy":p.stale||void 0,children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(Fl,{label:"total cost",val:ze(g),accent:!0}),m.jsx(Fl,{label:"tokens",val:Vs(y)}),m.jsx(Fl,{label:"input+output",val:Vs(x)}),m.jsx(Fl,{label:"cache reads",val:Vs(N)})]}),m.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:h.map(R=>{const I=f>0?R.totalCost/f*100:0,L=R.period===i;return m.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>o(L?null:R.period),title:`${R.period} · ${ze(R.totalCost)}`,style:{flexBasis:`${100/h.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(I,R.totalCost>0?2:0)}%`},children:R.modelBreakdowns.slice().sort((H,P)=>P.cost-H.cost).map(H=>{const P=R.totalCost>0?H.cost/R.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${P}%`,background:Dl(H.modelName)}},H.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:R.period.slice(5)})]},R.period)})}),m.jsx("div",{className:"uh-legend",children:S.map(([R,I])=>m.jsxs("span",{className:"uh-legend-item",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Dl(R)}}),ei(R)," ",m.jsx("span",{className:"uh-legend-cost",children:ze(I)})]},R))}),b&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:b.period}),m.jsx("span",{className:"uh-detail-cost",children:ze(b.totalCost)}),(C=(E=b.metadata)==null?void 0:E.agents)!=null&&C.length?m.jsx("span",{className:"uh-detail-agents",children:b.metadata.agents.join(" · ")}):null]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(zl,{label:"input",val:Vs(b.inputTokens)}),m.jsx(zl,{label:"output",val:Vs(b.outputTokens)}),m.jsx(zl,{label:"cache write",val:Vs(b.cacheCreationTokens)}),m.jsx(zl,{label:"cache read",val:Vs(b.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:b.modelBreakdowns.slice().sort((R,I)=>I.cost-R.cost).map(R=>{const I=b.totalCost>0?R.cost/b.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Dl(R.modelName)}}),ei(R.modelName)]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${I}%`,background:Dl(R.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:ze(R.cost)})]},R.modelName)})})]})]})]})})}function Fl({label:e,val:n,accent:r}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function zl({label:e,val:n}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:n}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function Iv(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 _d,Px;function gL(){if(Px)return _d;Px=1;function e(){this.__data__=[],this.size=0}return _d=e,_d}var bd,Ox;function oo(){if(Ox)return bd;Ox=1;function e(n,r){return n===r||n!==n&&r!==r}return bd=e,bd}var Sd,Lx;function pu(){if(Lx)return Sd;Lx=1;var e=oo();function n(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return Sd=n,Sd}var kd,qx;function vL(){if(qx)return kd;qx=1;var e=pu(),n=Array.prototype,r=n.splice;function i(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return kd=i,kd}var Ed,$x;function yL(){if($x)return Ed;$x=1;var e=pu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Ed=n,Ed}var Nd,Dx;function wL(){if(Dx)return Nd;Dx=1;var e=pu();function n(r){return e(this.__data__,r)>-1}return Nd=n,Nd}var Cd,Fx;function xL(){if(Fx)return Cd;Fx=1;var e=pu();function n(r,i){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,i])):o[l][1]=i,this}return Cd=n,Cd}var Td,zx;function mu(){if(zx)return Td;zx=1;var e=gL(),n=vL(),r=yL(),i=wL(),o=xL();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=i,l.prototype.set=o,Td=l,Td}var Rd,Bx;function _L(){if(Bx)return Rd;Bx=1;var e=mu();function n(){this.__data__=new e,this.size=0}return Rd=n,Rd}var jd,Ux;function bL(){if(Ux)return jd;Ux=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return jd=e,jd}var Ad,Hx;function SL(){if(Hx)return Ad;Hx=1;function e(n){return this.__data__.get(n)}return Ad=e,Ad}var Id,Wx;function kL(){if(Wx)return Id;Wx=1;function e(n){return this.__data__.has(n)}return Id=e,Id}var Md,Vx;function ZN(){if(Vx)return Md;Vx=1;var e=typeof kl=="object"&&kl&&kl.Object===Object&&kl;return Md=e,Md}var Pd,Gx;function Zn(){if(Gx)return Pd;Gx=1;var e=ZN(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return Pd=r,Pd}var Od,Yx;function ao(){if(Yx)return Od;Yx=1;var e=Zn(),n=e.Symbol;return Od=n,Od}var Ld,Kx;function EL(){if(Kx)return Ld;Kx=1;var e=ao(),n=Object.prototype,r=n.hasOwnProperty,i=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=i.call(u);return h&&(c?u[o]=p:delete u[o]),f}return Ld=l,Ld}var qd,Xx;function NL(){if(Xx)return qd;Xx=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return qd=r,qd}var $d,Qx;function ti(){if(Qx)return $d;Qx=1;var e=ao(),n=EL(),r=NL(),i="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:l&&l in Object(c)?n(c):r(c)}return $d=u,$d}var Dd,Zx;function Tn(){if(Zx)return Dd;Zx=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return Dd=e,Dd}var Fd,Jx;function xa(){if(Jx)return Fd;Jx=1;var e=ti(),n=Tn(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==i||p==o||p==r||p==l}return Fd=u,Fd}var zd,e_;function CL(){if(e_)return zd;e_=1;var e=Zn(),n=e["__core-js_shared__"];return zd=n,zd}var Bd,t_;function TL(){if(t_)return Bd;t_=1;var e=CL(),n=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!n&&n in i}return Bd=r,Bd}var Ud,n_;function JN(){if(n_)return Ud;n_=1;var e=Function.prototype,n=e.toString;function r(i){if(i!=null){try{return n.call(i)}catch{}try{return i+""}catch{}}return""}return Ud=r,Ud}var Hd,r_;function RL(){if(r_)return Hd;r_=1;var e=xa(),n=TL(),r=Tn(),i=JN(),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 g(y){if(!r(y)||n(y))return!1;var x=e(y)?f:l;return x.test(i(y))}return Hd=g,Hd}var Wd,s_;function jL(){if(s_)return Wd;s_=1;function e(n,r){return n==null?void 0:n[r]}return Wd=e,Wd}var Vd,i_;function ni(){if(i_)return Vd;i_=1;var e=RL(),n=jL();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return Vd=r,Vd}var Gd,o_;function Mv(){if(o_)return Gd;o_=1;var e=ni(),n=Zn(),r=e(n,"Map");return Gd=r,Gd}var Yd,a_;function gu(){if(a_)return Yd;a_=1;var e=ni(),n=e(Object,"create");return Yd=n,Yd}var Kd,l_;function AL(){if(l_)return Kd;l_=1;var e=gu();function n(){this.__data__=e?e(null):{},this.size=0}return Kd=n,Kd}var Xd,u_;function IL(){if(u_)return Xd;u_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Xd=e,Xd}var Qd,c_;function ML(){if(c_)return Qd;c_=1;var e=gu(),n="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return i.call(u,l)?u[l]:void 0}return Qd=o,Qd}var Zd,d_;function PL(){if(d_)return Zd;d_=1;var e=gu(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Zd=i,Zd}var Jd,f_;function OL(){if(f_)return Jd;f_=1;var e=gu(),n="__lodash_hash_undefined__";function r(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=e&&o===void 0?n:o,this}return Jd=r,Jd}var ef,h_;function LL(){if(h_)return ef;h_=1;var e=AL(),n=IL(),r=ML(),i=PL(),o=OL();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=i,l.prototype.set=o,ef=l,ef}var tf,p_;function qL(){if(p_)return tf;p_=1;var e=LL(),n=mu(),r=Mv();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return tf=i,tf}var nf,m_;function $L(){if(m_)return nf;m_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return nf=e,nf}var rf,g_;function vu(){if(g_)return rf;g_=1;var e=$L();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return rf=n,rf}var sf,v_;function DL(){if(v_)return sf;v_=1;var e=vu();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return sf=n,sf}var of,y_;function FL(){if(y_)return of;y_=1;var e=vu();function n(r){return e(this,r).get(r)}return of=n,of}var af,w_;function zL(){if(w_)return af;w_=1;var e=vu();function n(r){return e(this,r).has(r)}return af=n,af}var lf,x_;function BL(){if(x_)return lf;x_=1;var e=vu();function n(r,i){var o=e(this,r),l=o.size;return o.set(r,i),this.size+=o.size==l?0:1,this}return lf=n,lf}var uf,__;function Pv(){if(__)return uf;__=1;var e=qL(),n=DL(),r=FL(),i=zL(),o=BL();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=i,l.prototype.set=o,uf=l,uf}var cf,b_;function UL(){if(b_)return cf;b_=1;var e=mu(),n=Mv(),r=Pv(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<i-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 cf=o,cf}var df,S_;function yu(){if(S_)return df;S_=1;var e=mu(),n=_L(),r=bL(),i=SL(),o=kL(),l=UL();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=i,u.prototype.has=o,u.prototype.set=l,df=u,df}var ff,k_;function Ov(){if(k_)return ff;k_=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o&&r(n[i],i,n)!==!1;);return n}return ff=e,ff}var hf,E_;function eC(){if(E_)return hf;E_=1;var e=ni(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return hf=n,hf}var pf,N_;function wu(){if(N_)return pf;N_=1;var e=eC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return pf=n,pf}var mf,C_;function xu(){if(C_)return mf;C_=1;var e=wu(),n=oo(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(i.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return mf=o,mf}var gf,T_;function _a(){if(T_)return gf;T_=1;var e=xu(),n=wu();function r(i,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],g=u?u(l[f],i[f],f,l,i):void 0;g===void 0&&(g=i[f]),c?n(l,f,g):e(l,f,g)}return l}return gf=r,gf}var vf,R_;function HL(){if(R_)return vf;R_=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return vf=e,vf}var yf,j_;function dr(){if(j_)return yf;j_=1;function e(n){return n!=null&&typeof n=="object"}return yf=e,yf}var wf,A_;function WL(){if(A_)return wf;A_=1;var e=ti(),n=dr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return wf=i,wf}var xf,I_;function ba(){if(I_)return xf;I_=1;var e=WL(),n=dr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return xf=l,xf}var _f,M_;function _t(){if(M_)return _f;M_=1;var e=Array.isArray;return _f=e,_f}var ta={exports:{}},bf,P_;function VL(){if(P_)return bf;P_=1;function e(){return!1}return bf=e,bf}ta.exports;var O_;function lo(){return O_||(O_=1,(function(e,n){var r=Zn(),i=VL(),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||i;e.exports=h})(ta,ta.exports)),ta.exports}var Sf,L_;function _u(){if(L_)return Sf;L_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(i,o){var l=typeof i;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(i))&&i>-1&&i%1==0&&i<o}return Sf=r,Sf}var kf,q_;function Lv(){if(q_)return kf;q_=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return kf=n,kf}var Ef,$_;function GL(){if($_)return Ef;$_=1;var e=ti(),n=Lv(),r=dr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",g="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",L="[object Uint8Array]",H="[object Uint8ClampedArray]",P="[object Uint16Array]",q="[object Uint32Array]",B={};B[k]=B[E]=B[C]=B[R]=B[I]=B[L]=B[H]=B[P]=B[q]=!0,B[i]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[p]=B[h]=B[f]=B[g]=B[y]=B[x]=B[N]=B[_]=!1;function D(F){return r(F)&&n(F.length)&&!!B[e(F)]}return Ef=D,Ef}var Nf,D_;function bu(){if(D_)return Nf;D_=1;function e(n){return function(r){return n(r)}}return Nf=e,Nf}var na={exports:{}};na.exports;var F_;function qv(){return F_||(F_=1,(function(e,n){var r=ZN(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l&&r.process,c=(function(){try{var 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 Cf,z_;function Sa(){if(z_)return Cf;z_=1;var e=GL(),n=bu(),r=qv(),i=r&&r.isTypedArray,o=i?n(i):e;return Cf=o,Cf}var Tf,B_;function tC(){if(B_)return Tf;B_=1;var e=HL(),n=ba(),r=_t(),i=lo(),o=_u(),l=Sa(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var g=r(h),y=!g&&n(h),x=!g&&!y&&i(h),N=!g&&!y&&!x&&l(h),_=g||y||x||N,S=_?e(h.length,String):[],b=S.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,b)))&&S.push(k);return S}return Tf=p,Tf}var Rf,U_;function Su(){if(U_)return Rf;U_=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return Rf=n,Rf}var jf,H_;function nC(){if(H_)return jf;H_=1;function e(n,r){return function(i){return n(r(i))}}return jf=e,jf}var Af,W_;function YL(){if(W_)return Af;W_=1;var e=nC(),n=e(Object.keys,Object);return Af=n,Af}var If,V_;function $v(){if(V_)return If;V_=1;var e=Su(),n=YL(),r=Object.prototype,i=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))i.call(l,c)&&c!="constructor"&&u.push(c);return u}return If=o,If}var Mf,G_;function Or(){if(G_)return Mf;G_=1;var e=xa(),n=Lv();function r(i){return i!=null&&n(i.length)&&!e(i)}return Mf=r,Mf}var Pf,Y_;function ps(){if(Y_)return Pf;Y_=1;var e=tC(),n=$v(),r=Or();function i(o){return r(o)?e(o):n(o)}return Pf=i,Pf}var Of,K_;function KL(){if(K_)return Of;K_=1;var e=_a(),n=ps();function r(i,o){return i&&e(o,n(o),i)}return Of=r,Of}var Lf,X_;function XL(){if(X_)return Lf;X_=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return Lf=e,Lf}var qf,Q_;function QL(){if(Q_)return qf;Q_=1;var e=Tn(),n=Su(),r=XL(),i=Object.prototype,o=i.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 $f,Z_;function ri(){if(Z_)return $f;Z_=1;var e=tC(),n=QL(),r=Or();function i(o){return r(o)?e(o,!0):n(o)}return $f=i,$f}var Df,J_;function ZL(){if(J_)return Df;J_=1;var e=_a(),n=ri();function r(i,o){return i&&e(o,n(o),i)}return Df=r,Df}var ra={exports:{}};ra.exports;var e1;function rC(){return e1||(e1=1,(function(e,n){var r=Zn(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var g=h.length,y=c?c(g):new h.constructor(g);return h.copy(y),y}e.exports=p})(ra,ra.exports)),ra.exports}var Ff,t1;function sC(){if(t1)return Ff;t1=1;function e(n,r){var i=-1,o=n.length;for(r||(r=Array(o));++i<o;)r[i]=n[i];return r}return Ff=e,Ff}var zf,n1;function iC(){if(n1)return zf;n1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=0,u=[];++i<o;){var c=n[i];r(c,i,n)&&(u[l++]=c)}return u}return zf=e,zf}var Bf,r1;function oC(){if(r1)return Bf;r1=1;function e(){return[]}return Bf=e,Bf}var Uf,s1;function Dv(){if(s1)return Uf;s1=1;var e=iC(),n=oC(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:n;return Uf=l,Uf}var Hf,i1;function JL(){if(i1)return Hf;i1=1;var e=_a(),n=Dv();function r(i,o){return e(i,n(i),o)}return Hf=r,Hf}var Wf,o1;function Fv(){if(o1)return Wf;o1=1;function e(n,r){for(var i=-1,o=r.length,l=n.length;++i<o;)n[l+i]=r[i];return n}return Wf=e,Wf}var Vf,a1;function ku(){if(a1)return Vf;a1=1;var e=nC(),n=e(Object.getPrototypeOf,Object);return Vf=n,Vf}var Gf,l1;function aC(){if(l1)return Gf;l1=1;var e=Fv(),n=ku(),r=Dv(),i=oC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return Gf=l,Gf}var Yf,u1;function eq(){if(u1)return Yf;u1=1;var e=_a(),n=aC();function r(i,o){return e(i,n(i),o)}return Yf=r,Yf}var Kf,c1;function lC(){if(c1)return Kf;c1=1;var e=Fv(),n=_t();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return Kf=r,Kf}var Xf,d1;function uC(){if(d1)return Xf;d1=1;var e=lC(),n=Dv(),r=ps();function i(o){return e(o,r,n)}return Xf=i,Xf}var Qf,f1;function tq(){if(f1)return Qf;f1=1;var e=lC(),n=aC(),r=ri();function i(o){return e(o,r,n)}return Qf=i,Qf}var Zf,h1;function nq(){if(h1)return Zf;h1=1;var e=ni(),n=Zn(),r=e(n,"DataView");return Zf=r,Zf}var Jf,p1;function rq(){if(p1)return Jf;p1=1;var e=ni(),n=Zn(),r=e(n,"Promise");return Jf=r,Jf}var eh,m1;function cC(){if(m1)return eh;m1=1;var e=ni(),n=Zn(),r=e(n,"Set");return eh=r,eh}var th,g1;function sq(){if(g1)return th;g1=1;var e=ni(),n=Zn(),r=e(n,"WeakMap");return th=r,th}var nh,v1;function uo(){if(v1)return nh;v1=1;var e=nq(),n=Mv(),r=rq(),i=cC(),o=sq(),l=ti(),u=JN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",g="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(r),S=u(i),b=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=h||i&&k(new i)!=f||o&&k(new o)!=g)&&(k=function(E){var C=l(E),R=C==p?E.constructor:void 0,I=R?u(R):"";if(I)switch(I){case x:return y;case N:return c;case _:return h;case S:return f;case b:return g}return C}),nh=k,nh}var rh,y1;function iq(){if(y1)return rh;y1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&n.call(i,"index")&&(l.index=i.index,l.input=i.input),l}return rh=r,rh}var sh,w1;function dC(){if(w1)return sh;w1=1;var e=Zn(),n=e.Uint8Array;return sh=n,sh}var ih,x1;function zv(){if(x1)return ih;x1=1;var e=dC();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return ih=n,ih}var oh,_1;function oq(){if(_1)return oh;_1=1;var e=zv();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return oh=n,oh}var ah,b1;function aq(){if(b1)return ah;b1=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return ah=n,ah}var lh,S1;function lq(){if(S1)return lh;S1=1;var e=ao(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return lh=i,lh}var uh,k1;function fC(){if(k1)return uh;k1=1;var e=zv();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return uh=n,uh}var ch,E1;function uq(){if(E1)return ch;E1=1;var e=zv(),n=oq(),r=aq(),i=lq(),o=fC(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",g="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",L="[object Uint32Array]";function H(P,q,B){var D=P.constructor;switch(q){case x:return e(P);case l:case u:return new D(+P);case N:return n(P,B);case _:case S:case b:case k:case E:case C:case R:case I:case L:return o(P,B);case c:return new D;case p:case g:return new D(P);case h:return r(P);case f:return new D;case y:return i(P)}}return ch=H,ch}var dh,N1;function hC(){if(N1)return dh;N1=1;var e=Tn(),n=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(n)return n(o);i.prototype=o;var l=new i;return i.prototype=void 0,l}})();return dh=r,dh}var fh,C1;function pC(){if(C1)return fh;C1=1;var e=hC(),n=ku(),r=Su();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return fh=i,fh}var hh,T1;function cq(){if(T1)return hh;T1=1;var e=uo(),n=dr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return hh=i,hh}var ph,R1;function dq(){if(R1)return ph;R1=1;var e=cq(),n=bu(),r=qv(),i=r&&r.isMap,o=i?n(i):e;return ph=o,ph}var mh,j1;function fq(){if(j1)return mh;j1=1;var e=uo(),n=dr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return mh=i,mh}var gh,A1;function hq(){if(A1)return gh;A1=1;var e=fq(),n=bu(),r=qv(),i=r&&r.isSet,o=i?n(i):e;return gh=o,gh}var vh,I1;function mC(){if(I1)return vh;I1=1;var e=yu(),n=Ov(),r=xu(),i=KL(),o=ZL(),l=rC(),u=sC(),c=JL(),p=eq(),h=uC(),f=tq(),g=uo(),y=iq(),x=uq(),N=pC(),_=_t(),S=lo(),b=dq(),k=Tn(),E=hq(),C=ps(),R=ri(),I=1,L=2,H=4,P="[object Arguments]",q="[object Array]",B="[object Boolean]",D="[object Date]",F="[object Error]",j="[object Function]",Z="[object GeneratorFunction]",W="[object Map]",ne="[object Number]",J="[object Object]",U="[object RegExp]",X="[object Set]",M="[object String]",V="[object Symbol]",O="[object WeakMap]",$="[object ArrayBuffer]",Y="[object DataView]",te="[object Float32Array]",oe="[object Float64Array]",ce="[object Int8Array]",pe="[object Int16Array]",ve="[object Int32Array]",Pe="[object Uint8Array]",Me="[object Uint8ClampedArray]",Oe="[object Uint16Array]",ye="[object Uint32Array]",Se={};Se[P]=Se[q]=Se[$]=Se[Y]=Se[B]=Se[D]=Se[te]=Se[oe]=Se[ce]=Se[pe]=Se[ve]=Se[W]=Se[ne]=Se[J]=Se[U]=Se[X]=Se[M]=Se[V]=Se[Pe]=Se[Me]=Se[Oe]=Se[ye]=!0,Se[F]=Se[j]=Se[O]=!1;function Ye(we,ge,Fe,pt,mt,Ze){var De,Qe=ge&I,at=ge&L,Mt=ge&H;if(Fe&&(De=mt?Fe(we,pt,mt,Ze):Fe(we)),De!==void 0)return De;if(!k(we))return we;var rt=_(we);if(rt){if(De=y(we),!Qe)return u(we,De)}else{var gt=g(we),Kt=gt==j||gt==Z;if(S(we))return l(we,Qe);if(gt==J||gt==P||Kt&&!mt){if(De=at||Kt?{}:N(we),!Qe)return at?p(we,o(De,we)):c(we,i(De,we))}else{if(!Se[gt])return mt?we:{};De=x(we,gt,Qe)}}Ze||(Ze=new e);var Pt=Ze.get(we);if(Pt)return Pt;Ze.set(we,De),E(we)?we.forEach(function(dt){De.add(Ye(dt,ge,Fe,dt,we,Ze))}):b(we)&&we.forEach(function(dt,lt){De.set(lt,Ye(dt,ge,Fe,lt,we,Ze))});var Ge=Mt?at?f:h:at?R:C,Nt=rt?void 0:Ge(we);return n(Nt||we,function(dt,lt){Nt&&(lt=dt,dt=we[lt]),r(De,lt,Ye(dt,ge,Fe,lt,we,Ze))}),De}return vh=Ye,vh}var yh,M1;function pq(){if(M1)return yh;M1=1;var e=mC(),n=4;function r(i){return e(i,n)}return yh=r,yh}var wh,P1;function Bv(){if(P1)return wh;P1=1;function e(n){return function(){return n}}return wh=e,wh}var xh,O1;function mq(){if(O1)return xh;O1=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var h=c[n?p:++l];if(i(u[h],h,u)===!1)break}return r}}return xh=e,xh}var _h,L1;function Uv(){if(L1)return _h;L1=1;var e=mq(),n=e();return _h=n,_h}var bh,q1;function Hv(){if(q1)return bh;q1=1;var e=Uv(),n=ps();function r(i,o){return i&&e(i,o,n)}return bh=r,bh}var Sh,$1;function gq(){if($1)return Sh;$1=1;var e=Or();function n(r,i){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=i?u:-1,p=Object(o);(i?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return Sh=n,Sh}var kh,D1;function Eu(){if(D1)return kh;D1=1;var e=Hv(),n=gq(),r=n(e);return kh=r,kh}var Eh,F1;function si(){if(F1)return Eh;F1=1;function e(n){return n}return Eh=e,Eh}var Nh,z1;function gC(){if(z1)return Nh;z1=1;var e=si();function n(r){return typeof r=="function"?r:e}return Nh=n,Nh}var Ch,B1;function vC(){if(B1)return Ch;B1=1;var e=Ov(),n=Eu(),r=gC(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return Ch=o,Ch}var Th,U1;function yC(){return U1||(U1=1,Th=vC()),Th}var Rh,H1;function vq(){if(H1)return Rh;H1=1;var e=Eu();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return Rh=n,Rh}var jh,W1;function yq(){if(W1)return jh;W1=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return jh=n,jh}var Ah,V1;function wq(){if(V1)return Ah;V1=1;function e(n){return this.__data__.has(n)}return Ah=e,Ah}var Ih,G1;function wC(){if(G1)return Ih;G1=1;var e=Pv(),n=yq(),r=wq();function i(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return i.prototype.add=i.prototype.push=n,i.prototype.has=r,Ih=i,Ih}var Mh,Y1;function xq(){if(Y1)return Mh;Y1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o;)if(r(n[i],i,n))return!0;return!1}return Mh=e,Mh}var Ph,K1;function xC(){if(K1)return Ph;K1=1;function e(n,r){return n.has(r)}return Ph=e,Ph}var Oh,X1;function _C(){if(X1)return Oh;X1=1;var e=wC(),n=xq(),r=xC(),i=1,o=2;function l(u,c,p,h,f,g){var y=p&i,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=g.get(u),S=g.get(c);if(_&&S)return _==c&&S==u;var b=-1,k=!0,E=p&o?new e:void 0;for(g.set(u,c),g.set(c,u);++b<x;){var C=u[b],R=c[b];if(h)var I=y?h(R,C,b,c,u,g):h(C,R,b,u,c,g);if(I!==void 0){if(I)continue;k=!1;break}if(E){if(!n(c,function(L,H){if(!r(E,H)&&(C===L||f(C,L,p,h,g)))return E.push(H)})){k=!1;break}}else if(!(C===R||f(C,R,p,h,g))){k=!1;break}}return g.delete(u),g.delete(c),k}return Oh=l,Oh}var Lh,Q1;function _q(){if(Q1)return Lh;Q1=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return Lh=e,Lh}var qh,Z1;function Wv(){if(Z1)return qh;Z1=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return qh=e,qh}var $h,J1;function bq(){if(J1)return $h;J1=1;var e=ao(),n=dC(),r=oo(),i=_C(),o=_q(),l=Wv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",g="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,L,H,P,q,B,D){switch(H){case k:if(I.byteLength!=L.byteLength||I.byteOffset!=L.byteOffset)return!1;I=I.buffer,L=L.buffer;case b:return!(I.byteLength!=L.byteLength||!B(new n(I),new n(L)));case p:case h:case y:return r(+I,+L);case f:return I.name==L.name&&I.message==L.message;case x:case _:return I==L+"";case g:var F=o;case N:var j=P&u;if(F||(F=l),I.size!=L.size&&!j)return!1;var Z=D.get(I);if(Z)return Z==L;P|=c,D.set(I,L);var W=i(F(I),F(L),P,q,B,D);return D.delete(I),W;case S:if(C)return C.call(I)==C.call(L)}return!1}return $h=R,$h}var Dh,eb;function Sq(){if(eb)return Dh;eb=1;var e=uC(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,p,h,f){var g=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!g)return!1;for(var S=x;S--;){var b=y[S];if(!(g?b in u:i.call(u,b)))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 R=g;++S<x;){b=y[S];var I=l[b],L=u[b];if(p)var H=g?p(L,I,b,u,l,f):p(I,L,b,l,u,f);if(!(H===void 0?I===L||h(I,L,c,p,f):H)){C=!1;break}R||(R=b=="constructor")}if(C&&!R){var P=l.constructor,q=u.constructor;P!=q&&"constructor"in l&&"constructor"in u&&!(typeof P=="function"&&P instanceof P&&typeof q=="function"&&q instanceof q)&&(C=!1)}return f.delete(l),f.delete(u),C}return Dh=o,Dh}var Fh,tb;function kq(){if(tb)return Fh;tb=1;var e=yu(),n=_C(),r=bq(),i=Sq(),o=uo(),l=_t(),u=lo(),c=Sa(),p=1,h="[object Arguments]",f="[object Array]",g="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var R=l(_),I=l(S),L=R?f:o(_),H=I?f:o(S);L=L==h?g:L,H=H==h?g:H;var P=L==g,q=H==g,B=L==H;if(B&&u(_)){if(!u(S))return!1;R=!0,P=!1}if(B&&!P)return C||(C=new e),R||c(_)?n(_,S,b,k,E,C):r(_,S,L,b,k,E,C);if(!(b&p)){var D=P&&x.call(_,"__wrapped__"),F=q&&x.call(S,"__wrapped__");if(D||F){var j=D?_.value():_,Z=F?S.value():S;return C||(C=new e),E(j,Z,b,k,C)}}return B?(C||(C=new e),i(_,S,b,k,E,C)):!1}return Fh=N,Fh}var zh,nb;function bC(){if(nb)return zh;nb=1;var e=kq(),n=dr();function r(i,o,l,u,c){return i===o?!0:i==null||o==null||!n(i)&&!n(o)?i!==i&&o!==o:e(i,o,l,u,r,c)}return zh=r,zh}var Bh,rb;function Eq(){if(rb)return Bh;rb=1;var e=yu(),n=bC(),r=1,i=2;function o(l,u,c,p){var h=c.length,f=h,g=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(g&&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(g&&y[2]){if(N===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(N,_,x,l,u,S);if(!(b===void 0?n(_,N,r|i,p,S):b))return!1}}return!0}return Bh=o,Bh}var Uh,sb;function SC(){if(sb)return Uh;sb=1;var e=Tn();function n(r){return r===r&&!e(r)}return Uh=n,Uh}var Hh,ib;function Nq(){if(ib)return Hh;ib=1;var e=SC(),n=ps();function r(i){for(var o=n(i),l=o.length;l--;){var u=o[l],c=i[u];o[l]=[u,c,e(c)]}return o}return Hh=r,Hh}var Wh,ob;function kC(){if(ob)return Wh;ob=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return Wh=e,Wh}var Vh,ab;function Cq(){if(ab)return Vh;ab=1;var e=Eq(),n=Nq(),r=kC();function i(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Vh=i,Vh}var Gh,lb;function co(){if(lb)return Gh;lb=1;var e=ti(),n=dr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return Gh=i,Gh}var Yh,ub;function Vv(){if(ub)return Yh;ub=1;var e=_t(),n=co(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:i.test(l)||!r.test(l)||u!=null&&l in Object(u)}return Yh=o,Yh}var Kh,cb;function Tq(){if(cb)return Kh;cb=1;var e=Pv(),n="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=i.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(r.Cache||e),l}return r.Cache=e,Kh=r,Kh}var Xh,db;function Rq(){if(db)return Xh;db=1;var e=Tq(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Xh=r,Xh}var Qh,fb;function jq(){if(fb)return Qh;fb=1;var e=Rq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(r,"$1"):c||u)}),l});return Qh=i,Qh}var Zh,hb;function Nu(){if(hb)return Zh;hb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=Array(o);++i<o;)l[i]=r(n[i],i,n);return l}return Zh=e,Zh}var Jh,pb;function Aq(){if(pb)return Jh;pb=1;var e=ao(),n=Nu(),r=_t(),i=co(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(i(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Jh=u,Jh}var ep,mb;function EC(){if(mb)return ep;mb=1;var e=Aq();function n(r){return r==null?"":e(r)}return ep=n,ep}var tp,gb;function Cu(){if(gb)return tp;gb=1;var e=_t(),n=Vv(),r=jq(),i=EC();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return tp=o,tp}var np,vb;function ka(){if(vb)return np;vb=1;var e=co();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return np=n,np}var rp,yb;function Tu(){if(yb)return rp;yb=1;var e=Cu(),n=ka();function r(i,o){o=e(o,i);for(var l=0,u=o.length;i!=null&&l<u;)i=i[n(o[l++])];return l&&l==u?i:void 0}return rp=r,rp}var sp,wb;function Iq(){if(wb)return sp;wb=1;var e=Tu();function n(r,i,o){var l=r==null?void 0:e(r,i);return l===void 0?o:l}return sp=n,sp}var ip,xb;function Mq(){if(xb)return ip;xb=1;function e(n,r){return n!=null&&r in Object(n)}return ip=e,ip}var op,_b;function NC(){if(_b)return op;_b=1;var e=Cu(),n=ba(),r=_t(),i=_u(),o=Lv(),l=ka();function u(c,p,h){p=e(p,c);for(var f=-1,g=p.length,y=!1;++f<g;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&i(x,g)&&(r(c)||n(c)))}return op=u,op}var ap,bb;function CC(){if(bb)return ap;bb=1;var e=Mq(),n=NC();function r(i,o){return i!=null&&n(i,o,e)}return ap=r,ap}var lp,Sb;function Pq(){if(Sb)return lp;Sb=1;var e=bC(),n=Iq(),r=CC(),i=Vv(),o=SC(),l=kC(),u=ka(),c=1,p=2;function h(f,g){return i(f)&&o(g)?l(u(f),g):function(y){var x=n(y,f);return x===void 0&&x===g?r(y,f):e(g,x,c|p)}}return lp=h,lp}var up,kb;function TC(){if(kb)return up;kb=1;function e(n){return function(r){return r==null?void 0:r[n]}}return up=e,up}var cp,Eb;function Oq(){if(Eb)return cp;Eb=1;var e=Tu();function n(r){return function(i){return e(i,r)}}return cp=n,cp}var dp,Nb;function Lq(){if(Nb)return dp;Nb=1;var e=TC(),n=Oq(),r=Vv(),i=ka();function o(l){return r(l)?e(i(l)):n(l)}return dp=o,dp}var fp,Cb;function Lr(){if(Cb)return fp;Cb=1;var e=Cq(),n=Pq(),r=si(),i=_t(),o=Lq();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?n(u[0],u[1]):e(u):o(u)}return fp=l,fp}var hp,Tb;function RC(){if(Tb)return hp;Tb=1;var e=iC(),n=vq(),r=Lr(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return hp=o,hp}var pp,Rb;function qq(){if(Rb)return pp;Rb=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return pp=r,pp}var mp,jb;function jC(){if(jb)return mp;jb=1;var e=qq(),n=NC();function r(i,o){return i!=null&&n(i,o,e)}return mp=r,mp}var gp,Ab;function $q(){if(Ab)return gp;Ab=1;var e=$v(),n=uo(),r=ba(),i=_t(),o=Or(),l=lo(),u=Su(),c=Sa(),p="[object Map]",h="[object Set]",f=Object.prototype,g=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(i(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(g.call(x,_))return!1;return!0}return gp=y,gp}var vp,Ib;function AC(){if(Ib)return vp;Ib=1;function e(n){return n===void 0}return vp=e,vp}var yp,Mb;function IC(){if(Mb)return yp;Mb=1;var e=Eu(),n=Or();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,p,h){u[++l]=o(c,p,h)}),u}return yp=r,yp}var wp,Pb;function MC(){if(Pb)return wp;Pb=1;var e=Nu(),n=Lr(),r=IC(),i=_t();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return wp=o,wp}var xp,Ob;function Dq(){if(Ob)return xp;Ob=1;function e(n,r,i,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(i=n[++l]);++l<u;)i=r(i,n[l],l,n);return i}return xp=e,xp}var _p,Lb;function Fq(){if(Lb)return _p;Lb=1;function e(n,r,i,o,l){return l(n,function(u,c,p){i=o?(o=!1,u):r(i,u,c,p)}),i}return _p=e,_p}var bp,qb;function PC(){if(qb)return bp;qb=1;var e=Dq(),n=Eu(),r=Lr(),i=Fq(),o=_t();function l(u,c,p){var h=o(u)?e:i,f=arguments.length<3;return h(u,r(c,4),p,f,n)}return bp=l,bp}var Sp,$b;function zq(){if($b)return Sp;$b=1;var e=ti(),n=_t(),r=dr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return Sp=o,Sp}var kp,Db;function Bq(){if(Db)return kp;Db=1;var e=TC(),n=e("length");return kp=n,kp}var Ep,Fb;function Uq(){if(Fb)return Ep;Fb=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return Ep=p,Ep}var Np,zb;function Hq(){if(zb)return Np;zb=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[f,g,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[f+c+"?",c,g,y,u].join("|")+")",E=RegExp(p+"(?="+p+")|"+k+b,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return Np=C,Np}var Cp,Bb;function Wq(){if(Bb)return Cp;Bb=1;var e=Bq(),n=Uq(),r=Hq();function i(o){return n(o)?r(o):e(o)}return Cp=i,Cp}var Tp,Ub;function Vq(){if(Ub)return Tp;Ub=1;var e=$v(),n=uo(),r=Or(),i=zq(),o=Wq(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return i(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return Tp=c,Tp}var Rp,Hb;function Gq(){if(Hb)return Rp;Hb=1;var e=Ov(),n=hC(),r=Hv(),i=Lr(),o=ku(),l=_t(),u=lo(),c=xa(),p=Tn(),h=Sa();function f(g,y,x){var N=l(g),_=N||u(g)||h(g);if(y=i(y,4),x==null){var S=g&&g.constructor;_?x=N?new S:[]:p(g)?x=c(S)?n(o(g)):{}:x={}}return(_?e:r)(g,function(b,k,E){return y(x,b,k,E)}),x}return Rp=f,Rp}var jp,Wb;function Yq(){if(Wb)return jp;Wb=1;var e=ao(),n=ba(),r=_t(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return jp=o,jp}var Ap,Vb;function Gv(){if(Vb)return Ap;Vb=1;var e=Fv(),n=Yq();function r(i,o,l,u,c){var p=-1,h=i.length;for(l||(l=n),c||(c=[]);++p<h;){var f=i[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 Ap=r,Ap}var Ip,Gb;function Kq(){if(Gb)return Ip;Gb=1;function e(n,r,i){switch(i.length){case 0:return n.call(r);case 1:return n.call(r,i[0]);case 2:return n.call(r,i[0],i[1]);case 3:return n.call(r,i[0],i[1],i[2])}return n.apply(r,i)}return Ip=e,Ip}var Mp,Yb;function OC(){if(Yb)return Mp;Yb=1;var e=Kq(),n=Math.max;function r(i,o,l){return o=n(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,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(i,this,f)}}return Mp=r,Mp}var Pp,Kb;function Xq(){if(Kb)return Pp;Kb=1;var e=Bv(),n=eC(),r=si(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return Pp=i,Pp}var Op,Xb;function Qq(){if(Xb)return Op;Xb=1;var e=800,n=16,r=Date.now;function i(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 Op=i,Op}var Lp,Qb;function LC(){if(Qb)return Lp;Qb=1;var e=Xq(),n=Qq(),r=n(e);return Lp=r,Lp}var qp,Zb;function Ru(){if(Zb)return qp;Zb=1;var e=si(),n=OC(),r=LC();function i(o,l){return r(n(o,l,e),o+"")}return qp=i,qp}var $p,Jb;function qC(){if(Jb)return $p;Jb=1;function e(n,r,i,o){for(var l=n.length,u=i+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return $p=e,$p}var Dp,eS;function Zq(){if(eS)return Dp;eS=1;function e(n){return n!==n}return Dp=e,Dp}var Fp,tS;function Jq(){if(tS)return Fp;tS=1;function e(n,r,i){for(var o=i-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return Fp=e,Fp}var zp,nS;function e$(){if(nS)return zp;nS=1;var e=qC(),n=Zq(),r=Jq();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return zp=i,zp}var Bp,rS;function t$(){if(rS)return Bp;rS=1;var e=e$();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return Bp=n,Bp}var Up,sS;function n$(){if(sS)return Up;sS=1;function e(n,r,i){for(var o=-1,l=n==null?0:n.length;++o<l;)if(i(r,n[o]))return!0;return!1}return Up=e,Up}var Hp,iS;function r$(){if(iS)return Hp;iS=1;function e(){}return Hp=e,Hp}var Wp,oS;function s$(){if(oS)return Wp;oS=1;var e=cC(),n=r$(),r=Wv(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return Wp=o,Wp}var Vp,aS;function i$(){if(aS)return Vp;aS=1;var e=wC(),n=t$(),r=n$(),i=xC(),o=s$(),l=Wv(),u=200;function c(p,h,f){var g=-1,y=n,x=p.length,N=!0,_=[],S=_;if(f)N=!1,y=r;else if(x>=u){var b=h?null:o(p);if(b)return l(b);N=!1,y=i,S=new e}else S=h?[]:_;e:for(;++g<x;){var k=p[g],E=h?h(k):k;if(k=f||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;h&&S.push(E),_.push(k)}else y(S,E,f)||(S!==_&&S.push(E),_.push(k))}return _}return Vp=c,Vp}var Gp,lS;function $C(){if(lS)return Gp;lS=1;var e=Or(),n=dr();function r(i){return n(i)&&e(i)}return Gp=r,Gp}var Yp,uS;function o$(){if(uS)return Yp;uS=1;var e=Gv(),n=Ru(),r=i$(),i=$C(),o=n(function(l){return r(e(l,1,i,!0))});return Yp=o,Yp}var Kp,cS;function a$(){if(cS)return Kp;cS=1;var e=Nu();function n(r,i){return e(i,function(o){return r[o]})}return Kp=n,Kp}var Xp,dS;function DC(){if(dS)return Xp;dS=1;var e=a$(),n=ps();function r(i){return i==null?[]:e(i,n(i))}return Xp=r,Xp}var Qp,fS;function Rn(){if(fS)return Qp;fS=1;var e;if(typeof Iv=="function")try{e={clone:pq(),constant:Bv(),each:yC(),filter:RC(),has:jC(),isArray:_t(),isEmpty:$q(),isFunction:xa(),isUndefined:AC(),keys:ps(),map:MC(),reduce:PC(),size:Vq(),transform:Gq(),union:o$(),values:DC()}}catch{}return e||(e=window._),Qp=e,Qp}var Zp,hS;function Yv(){if(hS)return Zp;hS=1;var e=Rn();Zp=o;var n="\0",r="\0",i="";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(g){return e.isEmpty(f._in[g])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._out[g])})},o.prototype.setNodes=function(f,g){var y=arguments,x=this;return e.each(f,function(N){y.length>1?x.setNode(N,g):x.setNode(N)}),this},o.prototype.setNode=function(f,g){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=g),this):(this._nodes[f]=arguments.length>1?g: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 g=this;if(e.has(this._nodes,f)){var y=function(x){g.removeEdge(g._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){g.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,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=r;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+g+" as parent of "+f+" would create a cycle");this.setNode(g)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=g,this._children[g][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var g=this._parent[f];if(g!==r)return g}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=r),this._isCompound){var g=this._children[f];if(g)return e.keys(g)}else{if(f===r)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var g=this._preds[f];if(g)return e.keys(g)},o.prototype.successors=function(f){var g=this._sucs[f];if(g)return e.keys(g)},o.prototype.neighbors=function(f){var g=this.predecessors(f);if(g)return e.union(g,this.successors(f))},o.prototype.isLeaf=function(f){var g;return this.isDirected()?g=this.successors(f):g=this.neighbors(f),g.length===0},o.prototype.filterNodes=function(f){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&g.setNode(S,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||g.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,N(_))}),g},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,g){var y=this,x=arguments;return e.reduce(f,function(N,_){return x.length>1?y.setEdge(N,_,g):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var f,g,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,g=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(f=_,g=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),f=""+f,g=""+g,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,f,g,y);if(e.has(this._edgeLabels,S))return N&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(g),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(f,g,y);var b=p(this._isDirected,f,g,y);return f=b.v,g=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[g],f),l(this._sucs[f],g),this._in[g][S]=b,this._out[f][S]=b,this._edgeCount++,this},o.prototype.edge=function(f,g,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,g,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,g,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,g,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,g,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,g,y),N=this._edgeObjs[x];return N&&(f=N.v,g=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[g],f),u(this._sucs[f],g),delete this._in[g][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,g){var y=this._in[f];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.v===g}):x}},o.prototype.outEdges=function(f,g){var y=this._out[f];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.w===g}):x}},o.prototype.nodeEdges=function(f,g){var y=this.inEdges(f,g);if(y)return y.concat(this.outEdges(f,g))};function l(f,g){f[g]?f[g]++:f[g]=1}function u(f,g){--f[g]||delete f[g]}function c(f,g,y,x){var N=""+g,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}return N+i+_+i+(e.isUndefined(x)?n:x)}function p(f,g,y,x){var N=""+g,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(f,g){return c(f,g.v,g.w,g.name)}return Zp}var Jp,pS;function l$(){return pS||(pS=1,Jp="2.1.8"),Jp}var em,mS;function u$(){return mS||(mS=1,em={Graph:Yv(),version:l$()}),em}var tm,gS;function c$(){if(gS)return tm;gS=1;var e=Rn(),n=Yv();tm={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:i(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function i(u){return e.map(u.nodes(),function(c){var 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 tm}var nm,vS;function d$(){if(vS)return nm;vS=1;var e=Rn();nm=n;function n(r){var i={},o=[],l;function u(c){e.has(i,c)||(i[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return nm}var rm,yS;function FC(){if(yS)return rm;yS=1;var e=Rn();rm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:i}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,i){var o=this._keyIndices[r];if(i>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+i);this._arr[o].priority=i,this._decrease(o)},n.prototype._heapify=function(r){var i=this._arr,o=2*r,l=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,l<i.length&&(u=i[l].priority<i[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,l;r!==0&&(l=r>>1,!(i[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,i){var o=this._arr,l=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,l[c.key]=r,l[u.key]=i},rm}var sm,wS;function zC(){if(wS)return sm;wS=1;var e=Rn(),n=FC();sm=i;var r=e.constant(1);function i(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,g,y,x=function(N){var _=N.v!==g?N.v:N.w,S=h[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=g,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&&(g=f.removeMin(),y=h[g],y.distance!==Number.POSITIVE_INFINITY);)p(g).forEach(x);return h}return sm}var im,xS;function f$(){if(xS)return im;xS=1;var e=zC(),n=Rn();im=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return im}var om,_S;function BC(){if(_S)return om;_S=1;var e=Rn();om=n;function n(r){var i=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:i,index:i++};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=[],g;do g=o.pop(),l[g].onStack=!1,f.push(g);while(p!==g);u.push(f)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return om}var am,bS;function h$(){if(bS)return am;bS=1;var e=Rn(),n=BC();am=r;function r(i){return e.filter(n(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return am}var lm,SS;function p$(){if(SS)return lm;SS=1;var e=Rn();lm=r;var n=e.constant(1);function r(o,l,u){return i(o,l||n,u||function(c){return o.outEdges(c)})}function i(o,l,u){var c={},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 g=f.v===h?f.w:f.v,y=l(f);c[h][g]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(g){var y=c[g];p.forEach(function(x){var N=y[h],_=f[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return lm}var um,kS;function UC(){if(kS)return um;kS=1;var e=Rn();um=n,n.CycleException=r;function n(i){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(i.predecessors(p),c),delete l[p],u.push(p))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,um}var cm,ES;function m$(){if(ES)return cm;ES=1;var e=UC();cm=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return cm}var dm,NS;function HC(){if(NS)return dm;NS=1;var e=Rn();dm=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],p={};return e.each(o,function(h){if(!i.hasNode(h))throw new Error("Graph does not have node: "+h);r(i,h,l==="post",p,u,c)}),c}function r(i,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){r(i,h,l,u,c,p)}),l&&p.push(o))}return dm}var fm,CS;function g$(){if(CS)return fm;CS=1;var e=HC();fm=n;function n(r,i){return e(r,i,"post")}return fm}var hm,TS;function v$(){if(TS)return hm;TS=1;var e=HC();hm=n;function n(r,i){return e(r,i,"pre")}return hm}var pm,RS;function y$(){if(RS)return pm;RS=1;var e=Rn(),n=Yv(),r=FC();pm=i;function i(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 g=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(h).forEach(f)}return u}return pm}var mm,jS;function w$(){return jS||(jS=1,mm={components:d$(),dijkstra:zC(),dijkstraAll:f$(),findCycles:h$(),floydWarshall:p$(),isAcyclic:m$(),postorder:g$(),preorder:v$(),prim:y$(),tarjan:BC(),topsort:UC()}),mm}var gm,AS;function x$(){if(AS)return gm;AS=1;var e=u$();return gm={Graph:e.Graph,json:c$(),alg:w$(),version:e.version},gm}var vm,IS;function Xn(){if(IS)return vm;IS=1;var e;if(typeof Iv=="function")try{e=x$()}catch{}return e||(e=window.graphlib),vm=e,vm}var ym,MS;function _$(){if(MS)return ym;MS=1;var e=mC(),n=1,r=4;function i(o){return e(o,n|r)}return ym=i,ym}var wm,PS;function ju(){if(PS)return wm;PS=1;var e=oo(),n=Or(),r=_u(),i=Tn();function o(l,u,c){if(!i(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 wm=o,wm}var xm,OS;function b$(){if(OS)return xm;OS=1;var e=Ru(),n=oo(),r=ju(),i=ri(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,g=f>2?p[2]:void 0;for(g&&r(p[0],p[1],g)&&(f=1);++h<f;)for(var y=p[h],x=i(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return xm=u,xm}var _m,LS;function S$(){if(LS)return _m;LS=1;var e=Lr(),n=Or(),r=ps();function i(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=r(l),u=function(g){return h(p[g],g,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return _m=i,_m}var bm,qS;function k$(){if(qS)return bm;qS=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return bm=n,bm}var Sm,$S;function E$(){if($S)return Sm;$S=1;var e=k$(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return Sm=r,Sm}var km,DS;function N$(){if(DS)return km;DS=1;var e=E$(),n=Tn(),r=co(),i=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 i;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 g=l.test(h);return g||u.test(h)?c(h.slice(2),g?2:8):o.test(h)?i:+h}return km=p,km}var Em,FS;function WC(){if(FS)return Em;FS=1;var e=N$(),n=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Em=i,Em}var Nm,zS;function C$(){if(zS)return Nm;zS=1;var e=WC();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return Nm=n,Nm}var Cm,BS;function T$(){if(BS)return Cm;BS=1;var e=qC(),n=Lr(),r=C$(),i=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=i(p+h,0)),e(l,n(u,3),h)}return Cm=o,Cm}var Tm,US;function R$(){if(US)return Tm;US=1;var e=S$(),n=T$(),r=e(n);return Tm=r,Tm}var Rm,HS;function VC(){if(HS)return Rm;HS=1;var e=Gv();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return Rm=n,Rm}var jm,WS;function j$(){if(WS)return jm;WS=1;var e=Uv(),n=gC(),r=ri();function i(o,l){return o==null?o:e(o,n(l),r)}return jm=i,jm}var Am,VS;function A$(){if(VS)return Am;VS=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return Am=e,Am}var Im,GS;function I$(){if(GS)return Im;GS=1;var e=wu(),n=Hv(),r=Lr();function i(o,l){var u={};return l=r(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return Im=i,Im}var Mm,YS;function Kv(){if(YS)return Mm;YS=1;var e=co();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=i(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return Mm=n,Mm}var Pm,KS;function M$(){if(KS)return Pm;KS=1;function e(n,r){return n>r}return Pm=e,Pm}var Om,XS;function P$(){if(XS)return Om;XS=1;var e=Kv(),n=M$(),r=si();function i(o){return o&&o.length?e(o,r,n):void 0}return Om=i,Om}var Lm,QS;function GC(){if(QS)return Lm;QS=1;var e=wu(),n=oo();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return Lm=r,Lm}var qm,ZS;function O$(){if(ZS)return qm;ZS=1;var e=ti(),n=ku(),r=dr(),i="[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)!=i)return!1;var g=n(f);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return qm=h,qm}var $m,JS;function YC(){if(JS)return $m;JS=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return $m=e,$m}var Dm,ek;function L$(){if(ek)return Dm;ek=1;var e=_a(),n=ri();function r(i){return e(i,n(i))}return Dm=r,Dm}var Fm,tk;function q$(){if(tk)return Fm;tk=1;var e=GC(),n=rC(),r=fC(),i=sC(),o=pC(),l=ba(),u=_t(),c=$C(),p=lo(),h=xa(),f=Tn(),g=O$(),y=Sa(),x=YC(),N=L$();function _(S,b,k,E,C,R,I){var L=x(S,k),H=x(b,k),P=I.get(H);if(P){e(S,k,P);return}var q=R?R(L,H,k+"",S,b,I):void 0,B=q===void 0;if(B){var D=u(H),F=!D&&p(H),j=!D&&!F&&y(H);q=H,D||F||j?u(L)?q=L:c(L)?q=i(L):F?(B=!1,q=n(H,!0)):j?(B=!1,q=r(H,!0)):q=[]:g(H)||l(H)?(q=L,l(L)?q=N(L):(!f(L)||h(L))&&(q=o(H))):B=!1}B&&(I.set(H,q),C(q,H,E,R,I),I.delete(H)),e(S,k,q)}return Fm=_,Fm}var zm,nk;function $$(){if(nk)return zm;nk=1;var e=yu(),n=GC(),r=Uv(),i=q$(),o=Tn(),l=ri(),u=YC();function c(p,h,f,g,y){p!==h&&r(h,function(x,N){if(y||(y=new e),o(x))i(p,h,N,f,c,g,y);else{var _=g?g(u(p,N),x,N+"",p,h,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return zm=c,zm}var Bm,rk;function D$(){if(rk)return Bm;rk=1;var e=Ru(),n=ju();function r(i){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=i.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&&i(o,f,u,p)}return o})}return Bm=r,Bm}var Um,sk;function F$(){if(sk)return Um;sk=1;var e=$$(),n=D$(),r=n(function(i,o,l){e(i,o,l)});return Um=r,Um}var Hm,ik;function KC(){if(ik)return Hm;ik=1;function e(n,r){return n<r}return Hm=e,Hm}var Wm,ok;function z$(){if(ok)return Wm;ok=1;var e=Kv(),n=KC(),r=si();function i(o){return o&&o.length?e(o,r,n):void 0}return Wm=i,Wm}var Vm,ak;function B$(){if(ak)return Vm;ak=1;var e=Kv(),n=Lr(),r=KC();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return Vm=i,Vm}var Gm,lk;function U$(){if(lk)return Gm;lk=1;var e=Zn(),n=function(){return e.Date.now()};return Gm=n,Gm}var Ym,uk;function H$(){if(uk)return Ym;uk=1;var e=xu(),n=Cu(),r=_u(),i=Tn(),o=ka();function l(u,c,p,h){if(!i(u))return u;c=n(c,u);for(var f=-1,g=c.length,y=g-1,x=u;x!=null&&++f<g;){var N=o(c[f]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(f!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=i(S)?S:r(c[f+1])?[]:{})}e(x,N,_),x=x[N]}return u}return Ym=l,Ym}var Km,ck;function W$(){if(ck)return Km;ck=1;var e=Tu(),n=H$(),r=Cu();function i(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],g=e(o,f);u(g,f)&&n(h,r(f,o),g)}return h}return Km=i,Km}var Xm,dk;function V$(){if(dk)return Xm;dk=1;var e=W$(),n=CC();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return Xm=r,Xm}var Qm,fk;function G$(){if(fk)return Qm;fk=1;var e=VC(),n=OC(),r=LC();function i(o){return r(n(o,void 0,e),o+"")}return Qm=i,Qm}var Zm,hk;function Y$(){if(hk)return Zm;hk=1;var e=V$(),n=G$(),r=n(function(i,o){return i==null?{}:e(i,o)});return Zm=r,Zm}var Jm,pk;function K$(){if(pk)return Jm;pk=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,p=n(e((o-i)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=i,i+=l;return h}return Jm=r,Jm}var eg,mk;function X$(){if(mk)return eg;mk=1;var e=K$(),n=ju(),r=WC();function i(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return eg=i,eg}var tg,gk;function Q$(){if(gk)return tg;gk=1;var e=X$(),n=e();return tg=n,tg}var ng,vk;function Z$(){if(vk)return ng;vk=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return ng=e,ng}var rg,yk;function J$(){if(yk)return rg;yk=1;var e=co();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=i!==void 0,h=i===null,f=i===i,g=e(i);if(!h&&!g&&!c&&r>i||c&&p&&f&&!h&&!g||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!g&&r<i||g&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return rg=n,rg}var sg,wk;function e4(){if(wk)return sg;wk=1;var e=J$();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var g=o[l];return f*(g=="desc"?-1:1)}}return r.index-i.index}return sg=n,sg}var ig,xk;function t4(){if(xk)return ig;xk=1;var e=Nu(),n=Tu(),r=Lr(),i=IC(),o=Z$(),l=bu(),u=e4(),c=si(),p=_t();function h(f,g,y){g.length?g=e(g,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):g=[c];var x=-1;g=e(g,l(r));var N=i(f,function(_,S,b){var k=e(g,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return u(_,S,y)})}return ig=h,ig}var og,_k;function n4(){if(_k)return og;_k=1;var e=Gv(),n=t4(),r=Ru(),i=ju(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&i(l,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return og=o,og}var ag,bk;function r4(){if(bk)return ag;bk=1;var e=EC(),n=0;function r(i){var o=++n;return e(i)+o}return ag=r,ag}var lg,Sk;function s4(){if(Sk)return lg;Sk=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;i(c,n[o],p)}return c}return lg=e,lg}var ug,kk;function i4(){if(kk)return ug;kk=1;var e=xu(),n=s4();function r(i,o){return n(i||[],o||[],e)}return ug=r,ug}var cg,Ek;function ot(){if(Ek)return cg;Ek=1;var e;if(typeof Iv=="function")try{e={cloneDeep:_$(),constant:Bv(),defaults:b$(),each:yC(),filter:RC(),find:R$(),flatten:VC(),forEach:vC(),forIn:j$(),has:jC(),isUndefined:AC(),last:A$(),map:MC(),mapValues:I$(),max:P$(),merge:F$(),min:z$(),minBy:B$(),now:U$(),pick:Y$(),range:Q$(),reduce:PC(),sortBy:n4(),uniqueId:r4(),values:DC(),zipObject:i4()}}catch{}return e||(e=window._),cg=e,cg}var dg,Nk;function o4(){if(Nk)return dg;Nk=1,dg=e;function e(){var i={};i._next=i._prev=i,this._sentinel=i}e.prototype.dequeue=function(){var i=this._sentinel,o=i._prev;if(o!==i)return n(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&n(i),i._next=o._next,o._next._prev=i,o._next=i,i._prev=o},e.prototype.toString=function(){for(var i=[],o=this._sentinel,l=o._prev;l!==o;)i.push(JSON.stringify(l,r)),l=l._prev;return"["+i.join(", ")+"]"};function n(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function r(i,o){if(i!=="_next"&&i!=="_prev")return o}return dg}var fg,Ck;function a4(){if(Ck)return fg;Ck=1;var e=ot(),n=Xn().Graph,r=o4();fg=o;var i=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var g=c(h,f||i),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,g){for(var y=[],x=f[f.length-1],N=f[0],_;h.nodeCount();){for(;_=N.dequeue();)u(h,f,g,_);for(;_=x.dequeue();)u(h,f,g,_);if(h.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(u(h,f,g,_,!0));break}}}return y}function u(h,f,g,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,p(f,g,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,p(f,g,k)}),h.removeNode(y.v),N}function c(h,f){var g=new n,y=0,x=0;e.forEach(h.nodes(),function(S){g.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=g.edge(S.v,S.w)||0,k=f(S),E=b+k;g.setEdge(S.v,S.w,E),x=Math.max(x,g.node(S.v).out+=k),y=Math.max(y,g.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(g.nodes(),function(S){p(N,_,g.node(S))}),{graph:g,buckets:N,zeroIdx:_}}function p(h,f,g){g.out?g.in?h[g.out-g.in+f].enqueue(g):h[h.length-1].enqueue(g):h[0].enqueue(g)}return fg}var hg,Tk;function l4(){if(Tk)return hg;Tk=1;var e=ot(),n=a4();hg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(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 i(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(g){e.has(c,g.w)?u.push(g):h(g.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 hg}var pg,Rk;function on(){if(Rk)return pg;Rk=1;var e=ot(),n=Xn().Graph;pg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:g,maxRank:y,partition:x,time:N,notime:_};function r(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function i(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,R=b.y-E,I=S.width/2,L=S.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var H,P;return Math.abs(R)*I>Math.abs(C)*L?(R<0&&(L=-L),H=L*C/R,P=L):(C<0&&(I=-I),H=I,P=I*R/C),{x:k+H,y:E+P}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function f(S){var b=e.min(e.map(S.nodes(),function(R){return S.node(R).rank})),k=[];e.forEach(S.nodes(),function(R){var I=S.node(R).rank-b;k[I]||(k[I]=[]),k[I].push(R)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function(L){S.node(L).rank+=E})})}function g(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),r(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return pg}var mg,jk;function u4(){if(jk)return mg;jk=1;var e=ot(),n=on();mg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){i(l,u)})}function i(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,g=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var N,_,S;for(S=0,++p;p<f;++S,++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},g),S===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,h,{weight:y.weight},g)}}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 mg}var gg,Ak;function iu(){if(Ak)return gg;Ak=1;var e=ot();gg={longestPath:n,slack:r};function n(i){var o={};function l(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(i.outEdges(u),function(h){return l(h.w)-i.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(i.sources(),l)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return gg}var vg,Ik;function XC(){if(Ik)return vg;Ik=1;var e=ot(),n=Xn().Graph,r=iu().slack;vg=i;function i(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var g,y;o(p,c)<f;)g=l(p,c),y=p.hasNode(g.v)?r(c,g):-r(c,g),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(g){var y=g.v,x=f===y?g.w:y;!c.hasNode(x)&&!r(p,g)&&(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 vg}var yg,Mk;function c4(){if(Mk)return yg;Mk=1;var e=ot(),n=XC(),r=iu().slack,i=iu().longestPath,o=Xn().alg.preorder,l=Xn().alg.postorder,u=on().simplify;yg=c,c.initLowLimValues=g,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),i(E);var C=n(E);g(C),p(C,E);for(var R,I;R=x(C);)I=N(C,E,R),_(C,E,R,I)}function p(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){h(E,C,I)})}function h(E,C,R){var I=E.node(R),L=I.parent;E.edge(R,L).cutvalue=f(E,C,R)}function f(E,C,R){var I=E.node(R),L=I.parent,H=!0,P=C.edge(R,L),q=0;return P||(H=!1,P=C.edge(L,R)),q=P.weight,e.forEach(C.nodeEdges(R),function(B){var D=B.v===R,F=D?B.w:B.v;if(F!==L){var j=D===H,Z=C.edge(B).weight;if(q+=j?Z:-Z,b(E,R,F)){var W=E.edge(R,F).cutvalue;q+=j?-W:W}}}),q}function g(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,L){var H=R,P=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function(q){e.has(C,q)||(R=y(E,C,R,q,I))}),P.low=H,P.lim=R++,L?P.parent=L:delete P.parent,R}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,R){var I=R.v,L=R.w;C.hasEdge(I,L)||(I=R.w,L=R.v);var H=E.node(I),P=E.node(L),q=H,B=!1;H.lim>P.lim&&(q=P,B=!0);var D=e.filter(C.edges(),function(F){return B===k(E,E.node(F.v),q)&&B!==k(E,E.node(F.w),q)});return e.minBy(D,function(F){return r(C,F)})}function _(E,C,R,I){var L=R.v,H=R.w;E.removeEdge(L,H),E.setEdge(I.v,I.w,{}),g(E),p(E,C),S(E,C)}function S(E,C){var R=e.find(E.nodes(),function(L){return!C.node(L).parent}),I=o(E,R);I=I.slice(1),e.forEach(I,function(L){var H=E.node(L).parent,P=C.edge(L,H),q=!1;P||(P=C.edge(H,L),q=!0),C.node(L).rank=C.node(H).rank+(q?P.minlen:-P.minlen)})}function b(E,C,R){return E.hasEdge(C,R)}function k(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return yg}var wg,Pk;function d4(){if(Pk)return wg;Pk=1;var e=iu(),n=e.longestPath,r=XC(),i=c4();wg=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){i(p)}return wg}var xg,Ok;function f4(){if(Ok)return xg;Ok=1;var e=ot();xg=n;function n(o){var l=i(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,g=h.lca,y=0,x=f[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=f[y])!==g&&o.node(x).maxRank<c.rank;)y++;x===g&&(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),g=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||g>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 i(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 xg}var _g,Lk;function h4(){if(Lk)return _g;Lk=1;var e=ot(),n=on();_g={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,g=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=g});var y=l(c)+1;e.forEach(c.children(),function(x){i(c,p,g,y,f,h,x)}),c.graph().nodeRankFactor=g}function i(c,p,h,f,g,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"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){i(c,p,h,f,g,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,R=E.borderBottom?E.borderBottom:k,I=E.borderTop?f:2*f,L=C!==R?1:g-y[x]+1;c.setEdge(_,C,{weight:I,minlen:L,nestingEdge:!0}),c.setEdge(R,S,{weight:I,minlen:L,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:g+y[x]})}function o(c){var p={};function h(f,g){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,g+1)}),p[f]=g}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 _g}var bg,qk;function p4(){if(qk)return bg;qk=1;var e=ot(),n=on();bg=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)i(o,"borderLeft","_bl",u,p,h),i(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function i(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},g=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return bg}var Sg,$k;function m4(){if($k)return Sg;$k=1;var e=ot();Sg={adjust:n,undo:r};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&i(h)}function r(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),i(h))}function i(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 g=h.edge(f);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}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 g=h.edge(f);e.forEach(g.points,p),e.has(g,"x")&&p(g)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return Sg}var kg,Dk;function g4(){if(Dk)return kg;Dk=1;var e=ot();kg=n;function n(r){var i={},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(i,h)){i[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 kg}var Eg,Fk;function v4(){if(Fk)return Eg;Fk=1;var e=ot();Eg=n;function n(i,o){for(var l=0,u=1;u<o.length;++u)l+=r(i,o[u-1],o[u]);return l}function r(i,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(x){return{pos:u[x.w],weight:i.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}),g=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;g+=y.weight*N})),g}return Eg}var Ng,zk;function y4(){if(zk)return Ng;zk=1;var e=ot();Ng=n;function n(r,i){return e.map(i,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,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 Ng}var Cg,Bk;function w4(){if(Bk)return Cg;Bk=1;var e=ot();Cg=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)&&i(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 i(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return Cg}var Tg,Uk;function x4(){if(Uk)return Tg;Uk=1;var e=ot(),n=on();Tg=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=[],g=0,y=0,x=0;p.sort(o(!!u)),x=i(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,x=i(f,h,x)});var N={vs:e.flatten(f,!0)};return y&&(N.barycenter=g/y,N.weight=y),N}function i(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 Tg}var Rg,Hk;function _4(){if(Hk)return Rg;Hk=1;var e=ot(),n=y4(),r=w4(),i=x4();Rg=o;function o(c,p,h,f){var g=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(g=e.filter(g,function(R){return R!==x&&R!==N}));var S=n(c,g);e.forEach(S,function(R){if(c.children(R.v).length){var I=o(c,R.v,h,f);_[R.v]=I,e.has(I,"barycenter")&&u(R,I)}});var b=r(S,h);l(b,_);var k=i(b,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 Rg}var jg,Wk;function b4(){if(Wk)return jg;Wk=1;var e=ot(),n=Xn().Graph;jg=r;function r(o,l,u){var c=i(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),g=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,g||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 i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return jg}var Ag,Vk;function S4(){if(Vk)return Ag;Vk=1;var e=ot();Ag=n;function n(r,i,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){i.setEdge(f,p);return}p=h}})}return Ag}var Ig,Gk;function k4(){if(Gk)return Ig;Gk=1;var e=ot(),n=g4(),r=v4(),i=_4(),o=b4(),l=S4(),u=Xn().Graph,c=on();Ig=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"),S=n(y);g(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){f(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var R=r(y,S);R<b&&(C=0,k=e.cloneDeep(S),b=R)}g(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 S=_.graph().root,b=i(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),l(_,N,b.vs)})}function g(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return Ig}var Mg,Yk;function E4(){if(Yk)return Mg;Yk=1;var e=ot(),n=Xn().Graph,r=on();Mg={positionX:N,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:g,balance:x};function i(b,k){var E={};function C(R,I){var L=0,H=0,P=R.length,q=e.last(I);return e.forEach(I,function(B,D){var F=l(b,B),j=F?b.node(F).order:P;(F||B===q)&&(e.forEach(I.slice(H,D+1),function(Z){e.forEach(b.predecessors(Z),function(W){var ne=b.node(W),J=ne.order;(J<L||j<J)&&!(ne.dummy&&b.node(Z).dummy)&&u(E,W,Z)})}),H=D+1,L=j)}),I}return e.reduce(k,C),E}function o(b,k){var E={};function C(I,L,H,P,q){var B;e.forEach(e.range(L,H),function(D){B=I[D],b.node(B).dummy&&e.forEach(b.predecessors(B),function(F){var j=b.node(F);j.dummy&&(j.order<P||j.order>q)&&u(E,F,B)})})}function R(I,L){var H=-1,P,q=0;return e.forEach(L,function(B,D){if(b.node(B).dummy==="border"){var F=b.predecessors(B);F.length&&(P=b.node(F[0]).order,C(L,q,D,H,P),q=D,H=P)}C(L,q,L.length,P,I.length)}),L}return e.reduce(k,R),E}function l(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function u(b,k,E){if(k>E){var C=k;k=E,E=C}var R=b[k];R||(b[k]=R={}),R[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function p(b,k,E,C){var R={},I={},L={};return e.forEach(k,function(H){e.forEach(H,function(P,q){R[P]=P,I[P]=P,L[P]=q})}),e.forEach(k,function(H){var P=-1;e.forEach(H,function(q){var B=C(q);if(B.length){B=e.sortBy(B,function(W){return L[W]});for(var D=(B.length-1)/2,F=Math.floor(D),j=Math.ceil(D);F<=j;++F){var Z=B[F];I[q]===q&&P<L[Z]&&!c(E,q,Z)&&(I[Z]=q,I[q]=R[q]=R[Z],P=L[Z])}}})}),{root:R,align:I}}function h(b,k,E,C,R){var I={},L=f(b,k,E,R),H=R?"borderLeft":"borderRight";function P(D,F){for(var j=L.nodes(),Z=j.pop(),W={};Z;)W[Z]?D(Z):(W[Z]=!0,j.push(Z),j=j.concat(F(Z))),Z=j.pop()}function q(D){I[D]=L.inEdges(D).reduce(function(F,j){return Math.max(F,I[j.v]+L.edge(j))},0)}function B(D){var F=L.outEdges(D).reduce(function(Z,W){return Math.min(Z,I[W.w]-L.edge(W))},Number.POSITIVE_INFINITY),j=b.node(D);F!==Number.POSITIVE_INFINITY&&j.borderType!==H&&(I[D]=Math.max(I[D],F))}return P(q,L.predecessors.bind(L)),P(B,L.successors.bind(L)),e.forEach(C,function(D){I[D]=I[E[D]]}),I}function f(b,k,E,C){var R=new n,I=b.graph(),L=_(I.nodesep,I.edgesep,C);return e.forEach(k,function(H){var P;e.forEach(H,function(q){var B=E[q];if(R.setNode(B),P){var D=E[P],F=R.edge(D,B);R.setEdge(D,B,Math.max(L(b,q,P),F||0))}P=q})}),R}function g(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,L){var H=S(b,L)/2;C=Math.max(I+H,C),R=Math.min(I-H,R)}),C-R})}function y(b,k){var E=e.values(k),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function(L){var H=I+L,P=b[H],q;if(P!==k){var B=e.values(P);q=L==="l"?C-e.min(B):R-e.max(B),q&&(b[H]=e.mapValues(P,function(D){return D+q}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var R=e.sortBy(e.map(b,C));return(R[1]+R[2])/2})}function N(b){var k=r.buildLayerMatrix(b),E=e.merge(i(b,k),o(b,k)),C={},R;e.forEach(["u","d"],function(L){R=L==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(R=e.map(R,function(D){return e.values(D).reverse()}));var P=(L==="u"?b.predecessors:b.successors).bind(b),q=p(b,R,E,P),B=h(b,R,q.root,q.align,H==="r");H==="r"&&(B=e.mapValues(B,function(D){return-D})),C[L+H]=B})});var I=g(b,C);return y(C,I),x(C,b.graph().align)}function _(b,k,E){return function(C,R,I){var L=C.node(R),H=C.node(I),P=0,q;if(P+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":q=-L.width/2;break;case"r":q=L.width/2;break}if(q&&(P+=E?q:-q),q=0,P+=(L.dummy?k:b)/2,P+=(H.dummy?k:b)/2,P+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":q=H.width/2;break;case"r":q=-H.width/2;break}return q&&(P+=E?q:-q),q=0,P}}function S(b,k){return b.node(k).width}return Mg}var Pg,Kk;function N4(){if(Kk)return Pg;Kk=1;var e=ot(),n=on(),r=E4().positionX;Pg=i;function i(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(g){return l.node(g).height}));e.forEach(h,function(g){l.node(g).y=p+f/2}),p+=f+c})}return Pg}var Og,Xk;function C4(){if(Xk)return Og;Xk=1;var e=ot(),n=l4(),r=u4(),i=d4(),o=on().normalizeRanks,l=f4(),u=on().removeEmptyRanks,c=h4(),p=p4(),h=m4(),f=k4(),g=N4(),y=on(),x=Xn().Graph;Og=N;function N($,Y){var te=Y&&Y.debugTiming?y.time:y.notime;te("layout",function(){var oe=te(" buildLayoutGraph",function(){return P($)});te(" runLayout",function(){_(oe,te)}),te(" updateInputGraph",function(){S($,oe)})})}function _($,Y){Y(" makeSpaceForEdgeLabels",function(){q($)}),Y(" removeSelfEdges",function(){U($)}),Y(" acyclic",function(){n.run($)}),Y(" nestingGraph.run",function(){c.run($)}),Y(" rank",function(){i(y.asNonCompoundGraph($))}),Y(" injectEdgeLabelProxies",function(){B($)}),Y(" removeEmptyRanks",function(){u($)}),Y(" nestingGraph.cleanup",function(){c.cleanup($)}),Y(" normalizeRanks",function(){o($)}),Y(" assignRankMinMax",function(){D($)}),Y(" removeEdgeLabelProxies",function(){F($)}),Y(" normalize.run",function(){r.run($)}),Y(" parentDummyChains",function(){l($)}),Y(" addBorderSegments",function(){p($)}),Y(" order",function(){f($)}),Y(" insertSelfEdges",function(){X($)}),Y(" adjustCoordinateSystem",function(){h.adjust($)}),Y(" position",function(){g($)}),Y(" positionSelfEdges",function(){M($)}),Y(" removeBorderNodes",function(){J($)}),Y(" normalize.undo",function(){r.undo($)}),Y(" fixupEdgeLabelCoords",function(){W($)}),Y(" undoCoordinateSystem",function(){h.undo($)}),Y(" translateGraph",function(){j($)}),Y(" assignNodeIntersects",function(){Z($)}),Y(" reversePoints",function(){ne($)}),Y(" acyclic.undo",function(){n.undo($)})}function S($,Y){e.forEach($.nodes(),function(te){var oe=$.node(te),ce=Y.node(te);oe&&(oe.x=ce.x,oe.y=ce.y,Y.children(te).length&&(oe.width=ce.width,oe.height=ce.height))}),e.forEach($.edges(),function(te){var oe=$.edge(te),ce=Y.edge(te);oe.points=ce.points,e.has(ce,"x")&&(oe.x=ce.x,oe.y=ce.y)}),$.graph().width=Y.graph().width,$.graph().height=Y.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],L={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function P($){var Y=new x({multigraph:!0,compound:!0}),te=O($.graph());return Y.setGraph(e.merge({},k,V(te,b),e.pick(te,E))),e.forEach($.nodes(),function(oe){var ce=O($.node(oe));Y.setNode(oe,e.defaults(V(ce,C),R)),Y.setParent(oe,$.parent(oe))}),e.forEach($.edges(),function(oe){var ce=O($.edge(oe));Y.setEdge(oe,e.merge({},L,V(ce,I),e.pick(ce,H)))}),Y}function q($){var Y=$.graph();Y.ranksep/=2,e.forEach($.edges(),function(te){var oe=$.edge(te);oe.minlen*=2,oe.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?oe.width+=oe.labeloffset:oe.height+=oe.labeloffset)})}function B($){e.forEach($.edges(),function(Y){var te=$.edge(Y);if(te.width&&te.height){var oe=$.node(Y.v),ce=$.node(Y.w),pe={rank:(ce.rank-oe.rank)/2+oe.rank,e:Y};y.addDummyNode($,"edge-proxy",pe,"_ep")}})}function D($){var Y=0;e.forEach($.nodes(),function(te){var oe=$.node(te);oe.borderTop&&(oe.minRank=$.node(oe.borderTop).rank,oe.maxRank=$.node(oe.borderBottom).rank,Y=e.max(Y,oe.maxRank))}),$.graph().maxRank=Y}function F($){e.forEach($.nodes(),function(Y){var te=$.node(Y);te.dummy==="edge-proxy"&&($.edge(te.e).labelRank=te.rank,$.removeNode(Y))})}function j($){var Y=Number.POSITIVE_INFINITY,te=0,oe=Number.POSITIVE_INFINITY,ce=0,pe=$.graph(),ve=pe.marginx||0,Pe=pe.marginy||0;function Me(Oe){var ye=Oe.x,Se=Oe.y,Ye=Oe.width,we=Oe.height;Y=Math.min(Y,ye-Ye/2),te=Math.max(te,ye+Ye/2),oe=Math.min(oe,Se-we/2),ce=Math.max(ce,Se+we/2)}e.forEach($.nodes(),function(Oe){Me($.node(Oe))}),e.forEach($.edges(),function(Oe){var ye=$.edge(Oe);e.has(ye,"x")&&Me(ye)}),Y-=ve,oe-=Pe,e.forEach($.nodes(),function(Oe){var ye=$.node(Oe);ye.x-=Y,ye.y-=oe}),e.forEach($.edges(),function(Oe){var ye=$.edge(Oe);e.forEach(ye.points,function(Se){Se.x-=Y,Se.y-=oe}),e.has(ye,"x")&&(ye.x-=Y),e.has(ye,"y")&&(ye.y-=oe)}),pe.width=te-Y+ve,pe.height=ce-oe+Pe}function Z($){e.forEach($.edges(),function(Y){var te=$.edge(Y),oe=$.node(Y.v),ce=$.node(Y.w),pe,ve;te.points?(pe=te.points[0],ve=te.points[te.points.length-1]):(te.points=[],pe=ce,ve=oe),te.points.unshift(y.intersectRect(oe,pe)),te.points.push(y.intersectRect(ce,ve))})}function W($){e.forEach($.edges(),function(Y){var te=$.edge(Y);if(e.has(te,"x"))switch((te.labelpos==="l"||te.labelpos==="r")&&(te.width-=te.labeloffset),te.labelpos){case"l":te.x-=te.width/2+te.labeloffset;break;case"r":te.x+=te.width/2+te.labeloffset;break}})}function ne($){e.forEach($.edges(),function(Y){var te=$.edge(Y);te.reversed&&te.points.reverse()})}function J($){e.forEach($.nodes(),function(Y){if($.children(Y).length){var te=$.node(Y),oe=$.node(te.borderTop),ce=$.node(te.borderBottom),pe=$.node(e.last(te.borderLeft)),ve=$.node(e.last(te.borderRight));te.width=Math.abs(ve.x-pe.x),te.height=Math.abs(ce.y-oe.y),te.x=pe.x+te.width/2,te.y=oe.y+te.height/2}}),e.forEach($.nodes(),function(Y){$.node(Y).dummy==="border"&&$.removeNode(Y)})}function U($){e.forEach($.edges(),function(Y){if(Y.v===Y.w){var te=$.node(Y.v);te.selfEdges||(te.selfEdges=[]),te.selfEdges.push({e:Y,label:$.edge(Y)}),$.removeEdge(Y)}})}function X($){var Y=y.buildLayerMatrix($);e.forEach(Y,function(te){var oe=0;e.forEach(te,function(ce,pe){var ve=$.node(ce);ve.order=pe+oe,e.forEach(ve.selfEdges,function(Pe){y.addDummyNode($,"selfedge",{width:Pe.label.width,height:Pe.label.height,rank:ve.rank,order:pe+ ++oe,e:Pe.e,label:Pe.label},"_se")}),delete ve.selfEdges})})}function M($){e.forEach($.nodes(),function(Y){var te=$.node(Y);if(te.dummy==="selfedge"){var oe=$.node(te.e.v),ce=oe.x+oe.width/2,pe=oe.y,ve=te.x-ce,Pe=oe.height/2;$.setEdge(te.e,te.label),$.removeNode(Y),te.label.points=[{x:ce+2*ve/3,y:pe-Pe},{x:ce+5*ve/6,y:pe-Pe},{x:ce+ve,y:pe},{x:ce+5*ve/6,y:pe+Pe},{x:ce+2*ve/3,y:pe+Pe}],te.label.x=te.x,te.label.y=te.y}})}function V($,Y){return e.mapValues(e.pick($,Y),Number)}function O($){var Y={};return e.forEach($,function(te,oe){Y[oe.toLowerCase()]=te}),Y}return Og}var Lg,Qk;function T4(){if(Qk)return Lg;Qk=1;var e=ot(),n=on(),r=Xn().Graph;Lg={debugOrdering:i};function i(o){var l=n.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,g){return u.setEdge(f,g,{style:"invis"}),g})}),u}return Lg}var qg,Zk;function R4(){return Zk||(Zk=1,qg="0.8.5"),qg}var $g,Jk;function j4(){return Jk||(Jk=1,$g={graphlib:Xn(),layout:C4(),debug:T4(),util:{time:on().time,notime:on().notime},version:R4()}),$g}var A4=j4();const eE=dv(A4),so=240,ou=130,Zi=74,Au=72,tE=Zi+Au;function I4(e,n){var i;let r=so;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??so);return r}const QC=420,M4=2;function ha(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function P4(e,n){return((n==null?void 0:n.get(e))??0)>0?QC:0}function O4(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 i=n.get(e);return{w:((i==null?void 0:i.width)??so)+P4(e,r),h:Math.max((i==null?void 0:i.height)??ou,O4(e,r))}}function L4(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function q4(e,n,r,i,o,l){const u=new eE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!o.has(b)),p=new Set(c);for(const b of c){const{w:k,h:E}=pa(b,i,l);u.setNode(b,{width:k,height:E})}for(const b of n)p.has(b.source)&&p.has(b.target)&&u.setEdge(b.source,b.target);eE.layout(u);const h=new Map;let f=1/0,g=1/0,y=-1/0,x=-1/0;for(const b of c){const k=u.node(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??so,R=(E==null?void 0:E.height)??ou,I=pa(b,i,l),L=k.x-I.w/2,H=k.y-I.h/2;h.set(b,{x:L,y:H}),L<f&&(f=L),H<g&&(g=H),L+C>y&&(y=L+C),H+R>x&&(x=H+R)}if(Number.isFinite(f)&&Number.isFinite(g))for(const[b,k]of h)h.set(b,{x:k.x-f,y:k.y-g});const N=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-g:0;let S=null;for(const b of e){const k=o.get(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??so,R=(E==null?void 0:E.height)??ou;S=S===null?{minX:k.x,minY:k.y,maxX:k.x+C,maxY:k.y+R}:{minX:Math.min(S.minX,k.x),minY:Math.min(S.minY,k.y),maxX:Math.max(S.maxX,k.x+C),maxY:Math.max(S.maxY,k.y+R)}}return{positions:h,width:N,height:_,pinnedBox:S}}function $4(e,n,r={}){const i=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const b of e){const k=ha(b),E=c.get(k);E?E.push(b.id):c.set(k,[b.id])}const h=Array.from(c.keys()).sort().map(b=>({sid:b,...q4(c.get(b),n,i,l,o,u)})),f=I4(e,l),g=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const k=[[]];let E=0;for(const C of h)k.length<b&&E>0&&E+C.height>g&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+tE;return k},x=b=>b.reduce((k,E)=>Math.max(k,E.width),0)+QC;let N=y(r.availableWidth?M4: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 S=0;for(const b of N){const k=x(b);let E=0;for(const{positions:C,height:R,pinnedBox:I}of b){for(const[H,P]of C)_.set(H,{x:P.x+S,y:P.y+E});let L=E+R;I&&I.maxY>L&&I.minX<S+k&&S<I.maxX&&(L=I.maxY),E=L+tE}S+=k+f}return e.map(b=>{const k=o.get(b.id);if(k)return{...b,position:k};const E=_.get(b.id);return E?{...b,position:E}:b})}function D4(e,n,r,i,o){const u=Zi+Au,c=60,p=x=>pa(x,i,o),h=new Map(e.map(x=>[x.id,ha(x)])),f=[],g=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 g){const{w:_,h:S}=p(x),b=h.get(x)??"_default";if(r.has(x)){f.push({x:N.x,y:N.y,w:_,h:S,sid:b});continue}let k=N.y;for(let E=0;E<f.length+1;E++){const C=f.find(R=>{const I=R.sid===b?24:c,L=R.sid===b?24:u;return N.x<R.x+R.w+I&&R.x<N.x+_+I&&k<R.y+R.h+L&&R.y<k+S+L});if(!C)break;k=C.y+C.h+(C.sid===b?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:S,sid:b})}return y}function F4(e,n,r,i,o,l){const u=_=>pa(_,i,l),c=_=>r.get(_)??n.get(_),p=new Map;for(const _ of e){if(!c(_.id))continue;const S=ha(_),b=p.get(S);b?b.push(_):p.set(S,[_])}const h=new Set;for(const[_,S]of p)S.every(b=>o.has(b.id)&&!r.has(b.id))&&h.add(_);const f=new Map,g=[];for(const _ of e){const S=c(_.id);if(!S)continue;const{w:b,h:k}=u(_.id),E=ha(_);h.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):g.push({x:S.x,y:S.y,w:b,h:k})}if(f.size===0)return[];const y=Zi+Au,x=(_,S,b,k)=>g.some(E=>_<E.x+E.w+Zi&&E.x<_+b+Zi&&S<E.y+E.h+y&&E.y<S+k+y),N=[];for(const _ of[...f.keys()].sort()){const S=f.get(_);let b=1/0,k=1/0,E=-1/0,C=-1/0;for(const B of S){const D=c(B.id),{w:F,h:j}=u(B.id);b=Math.min(b,D.x),k=Math.min(k,D.y),E=Math.max(E,D.x+F),C=Math.max(C,D.y+j)}const R=E-b,I=C-k,L=[...new Set(g.map(B=>Math.round(B.x)))].sort((B,D)=>B-D),H=L.length?L:[b],P=[0,...g.map(B=>B.y+B.h+y)].sort((B,D)=>B-D);let q=null;e:for(const B of H)for(const D of P){if(D>=k)break;if(!x(B,D,R,I)){q={x:B,y:D};break e}}if(q){const B=q.x-b,D=q.y-k;for(const F of S){const j=c(F.id);n.set(F.id,{x:j.x+B,y:j.y+D})}N.push(_)}for(const B of S){const D=c(B.id),{w:F,h:j}=u(B.id);g.push({x:D.x,y:D.y,w:F,h:j})}}return N}function z4(e,n,r,i,o,l=!1,u){const h=Zi+Au+1,f=8,g=1.75,y=200,x=.7,N=.01,_=q=>pa(q,i,u),S=q=>r.get(q)??n.get(q),b=new Map;for(const q of e){if(!S(q.id))continue;const B=ha(q),D=b.get(B);D?D.push(q):b.set(B,[q])}const k=[],E=new Set,C=new Set,R=o.size===0;for(const q of[...b.keys()].sort()){const B=b.get(q);let D=1/0,F=1/0,j=-1/0,Z=-1/0,W=!1;for(const X of B){const M=S(X.id),{w:V,h:O}=_(X.id);D=Math.min(D,M.x),F=Math.min(F,M.y),j=Math.max(j,M.x+V),Z=Math.max(Z,M.y+O),r.has(X.id)&&(W=!0)}const ne=j-D,J=Z-F;C.add(q);const U=o.get(q);U&&(ne>U.w+f||J>U.h+f)&&E.add(q),o.set(q,{w:ne,h:J}),k.push({sid:q,members:B.map(X=>X.id),x:D,y:F,w:ne,h:J,anchored:W,mass:1})}for(const q of[...o.keys()])C.has(q)||o.delete(q);if(l||R)return[];let I=!1;for(let q=0;q<k.length&&!I;q++)for(let B=q+1;B<k.length;B++){const D=k[q],F=k[B];if(!(D.anchored&&F.anchored)&&Math.abs(D.x+D.w/2-(F.x+F.w/2))<(D.w+F.w)/2+61&&Math.abs(D.y+D.h/2-(F.y+F.h/2))<(D.h+F.h)/2+h){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const q of k)E.has(q.sid)&&(q.mass=8);else for(const q of k)q.mass=Math.max(1,q.w*q.h/(so*ou));const L=new Map(k.map(q=>[q.sid,q.x])),H=new Map(k.map(q=>[q.sid,q.y]));for(let q=0;q<y;q++){const B=new Map,D=new Map;let F=0;for(let j=0;j<k.length;j++)for(let Z=j+1;Z<k.length;Z++){const W=k[j],ne=k[Z];if(W.anchored&&ne.anchored)continue;const J=W.x+W.w/2,U=W.y+W.h/2,X=ne.x+ne.w/2,M=ne.y+ne.h/2,V=(W.w+ne.w)/2+61-Math.abs(J-X),O=(W.h+ne.h)/2+h-Math.abs(U-M);if(V<=0||O<=0)continue;const $=(De,Qe)=>!De.anchored&&!(Qe<0&&De.x<=0),Y=(De,Qe)=>!De.anchored&&!(Qe<0&&De.y<=0),te=(De,Qe,at)=>{const Mt=De===Qe,rt=Mt?W.sid<ne.sid?-1:1:Math.sign(De-Qe);return at(W,rt)||at(ne,-rt)?rt:Mt&&(at(W,-rt)||at(ne,rt))?-rt:0},oe=te(J,X,$),ce=te(U,M,Y),pe=oe!==0,ve=ce!==0;if(!pe&&!ve)continue;const Pe=pe&&(!ve||V*g<O),[Me,Oe,ye,Se]=Pe?[oe,V,B,$]:[ce,O,D,Y],Ye=Se(W,Me),we=Se(ne,-Me),ge=W.mass,Fe=ne.mass,pt=Ye?we?Fe/(ge+Fe):1:0,mt=we?Ye?ge/(ge+Fe):1:0,Ze=Oe*x;ye.set(W.sid,(ye.get(W.sid)??0)+Me*Ze*pt),ye.set(ne.sid,(ye.get(ne.sid)??0)-Me*Ze*mt),F+=Ze}for(const j of k)j.anchored||(j.x=Math.max(0,j.x+(B.get(j.sid)??0)),j.y=Math.max(0,j.y+(D.get(j.sid)??0)));if(F<N)break}const P=[];for(const q of k){const B=q.x-L.get(q.sid),D=q.y-H.get(q.sid);if(!(Math.abs(B)<1&&Math.abs(D)<1)){for(const F of q.members){if(r.has(F))continue;const j=n.get(F);j&&n.set(F,{x:j.x+B,y:j.y+D})}P.push(q.sid)}}return P}const B4=600;function lv(e,n){return!(e.exitAt!=null&&n-e.exitAt>B4||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function U4(e,n){const r=new Set;for(const i of e.agents.values())lv(i,n)&&r.add(i.id);return r}function H4(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 W4(e,n,r=0){if(!e)return!1;for(const i of n)if(H4(e,i,r))return!0;return!1}const ZC="sessionGroup";function V4(e,n){var i;if(e.type===ZC)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const G4="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function Y4(e){if(e.checkDisabled)return G4;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 K4(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 X4(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const Q4={agent:uO,sessionGroup:_O},Z4=420,Bl=18,J4=9e4,e5=200,t5=5*6e4,n5=6,r5=2*6e4,Xv="agent-dag.layout",Qv="agent-dag.viewport",JC="agent-dag.summariesDismissed",eT="agent-dag.sessionListOpen",tT="agent-dag.detailOpen",nT="agent-dag.usagePanelOpen",nE="agent-dag.accountsPanelOpen",rE="agent-dag.versionNoticeDismissed",s5=15*6e4,sE={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 i5(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 iE="agent-dag.autoRestart",oE="agent-dag.bundleReloadedFor";function o5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eT)==="1"}catch{return!1}}function a5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eT,e?"1":"0")}catch{}}function l5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tT)==="1"}catch{return!1}}function u5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tT,e?"1":"0")}catch{}}function c5(){const e=QN(nT);return e===null?!0:e==="1"}function d5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(nT,e?"1":"0")}catch{}}function f5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(JC);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 aE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(JC,JSON.stringify(r))}catch{}}function h5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Xv);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 Dg(e,n){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of n)r[i]=o;window.localStorage.setItem(Xv,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function p5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Qv);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 m5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Qv,JSON.stringify(e))}catch{}}function lE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Xv)}catch{}try{window.localStorage.removeItem(Qv)}catch{}}}function g5(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const f of e.agents.values())f.sessionId===n&&i.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:i.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(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.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 uv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},cv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},v5={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 rT(e){return e.startsWith("mcp__")?"mcp":v5[e]??"other"}function sT(e,n){var i,o,l;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(i=e.cwd)!=null&&i.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function y5(e,n){if(!n)return null;const r=new Set([n]);let i=n;for(;i;){const l=e.agents.get(i);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),i=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function w5(e,n,r,i,o,l,u,c,p,h,f,g,y,x,N,_,S,b,k){const E=[],C=[],R=new Set;if(l)for(const D of e.agents.values())sT(D,l)&&R.add(D.id);for(const D of e.agents.values()){if(!b.has(D.id))continue;const F=l?!R.has(D.id):!1,j=D.exitAt!=null,Z=S!=null&&!S.has(D.id),W=[F?"rf-dim":"",j?"rf-exiting":"",Z?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,ne=u.get(D.id);if(E.push({id:D.id,type:"agent",position:{x:0,y:0},data:{...D,now:n,onOpenContext:k},className:W,...ne?{width:ne.width,height:ne.height}:null}),D.parentId&&b.has(D.parentId)){const J=jv(D.sessionId),U=D.state==="active"?`hsl(${J} 80% 72%)`:`hsl(${J} 50% 55%)`,X=l&&!R.has(D.id)&&!R.has(D.parentId),M=j,V=_.size>0&&(_.has(D.id)||_.has(D.parentId)),O=S!=null&&!S.has(D.id)&&!S.has(D.parentId),$=D.state==="active"?2:1.5,Y=V?$+1.5:$,te=X||M?.2:O?.12:1,oe=[M?"rf-edge-exiting":"",V?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;C.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||V)&&!X&&!M,type:"smoothstep",style:{stroke:U,strokeWidth:Y,opacity:te,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:oe})}}const I=new Map;for(const D of e.agents.values())D.tools.length>0&&I.set(D.id,Math.min(4,D.tools.length));const L=`${x}#lanes:${L4(I)}`,H=E.filter(D=>eL(D.id,o,g,y));if(H.length>0||L!==N.current){if(H.length>0){const D=$4(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:I});for(const F of D)XN(F.id,g,y)&&nL(F.id,F.position,g,y);F4(E,g,o,u,new Set(H.map(F=>F.id)),I)}D4(E,g,o,u,I),N.current=L}const P=z4(E,g,o,u,c,!h||f,I);P.length>0&&p(P),$l(g,e.agents),$l(y,e.agents),$l(o,e.agents),$l(u,J3(e.agents.values()));const q=[];let B=!1;for(const D of E){let F=o.get(D.id)??g.get(D.id);F||(F=tL(D.id,g,y),B=!0),q.push({...D,position:F})}return B&&(N.current=""),{nodes:q,edges:C}}function x5(){return m.jsx(Tv,{children:m.jsx(_5,{})})}function _5(){var wo,Ts,Rs,xo;const e=wa(),n=A.useRef(nv()),[,r]=A.useState(0),i=A.useCallback(()=>r(G=>G+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((G,Q)=>{l(ae=>{if(!Q)return new Set([G]);const ue=new Set(ae);return ue.has(G)?ue.delete(G):ue.add(G),ue}),c(ae=>Q&&ae===G?ae:G)},[]),g=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useCallback(G=>_(G),[]),[b,k]=A.useState(!1),E=A.useRef(f5()),[C,R]=A.useState(o5);A.useEffect(()=>{a5(C)},[C]);const[I,L]=A.useState(l5);A.useEffect(()=>{u5(I)},[I]);const[H,P]=A.useState(c5);A.useEffect(()=>{d5(H)},[H]);const[q,B]=A.useState(()=>{try{const G=window.localStorage.getItem(nE);return G===null?!0:G==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(nE,q?"1":"0")}catch{}},[q]);const[D,F]=A.useState(null),[j,Z]=A.useState(!1),[W,ne]=A.useState(0),[J,U]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(G=>G.ok?G.json():null).then(G=>{G!=null&&G.ok&&(F(G.enabled===!0),ne((G.foreign??[]).filter(Q=>Q.worksHere).length),U(typeof G.parked=="number"?G.parked:0))}).catch(()=>{})},[]);const X=A.useCallback(async()=>{Z(!0);try{const Q=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!D})})).json().catch(()=>null);Q!=null&&Q.ok&&F(Q.enabled===!0),fetch("/api/sound-hook").then(ae=>ae.ok?ae.json():null).then(ae=>{ae!=null&&ae.ok&&(ne((ae.foreign??[]).filter(ue=>ue.worksHere).length),U(typeof ae.parked=="number"?ae.parked:0))}).catch(()=>{})}catch{}finally{Z(!1)}},[D]),[M,V]=A.useState(!1),[O,$]=A.useState(null),[Y,te]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(rE)??""}catch{return""}}),[oe,ce]=A.useState(!1),pe=A.useRef(0),[ve,Pe]=A.useState(!1),Me=A.useCallback((G=!1)=>{G&&(pe.current=Date.now(),Pe(!0)),fetch(G?"/api/version?refresh=1":"/api/version").then(Q=>Q.ok?Q.json():null).then(Q=>{Q&&$(Q)}).catch(()=>{}).finally(()=>{G&&Pe(!1)})},[]),Oe=A.useCallback(()=>{Me(Date.now()-pe.current>=s5)},[Me]);A.useEffect(()=>{Me();const G=window.setInterval(Oe,5*6e4),Q=()=>{document.visibilityState==="visible"&&Oe()};return document.addEventListener("visibilitychange",Q),()=>{window.clearInterval(G),document.removeEventListener("visibilitychange",Q)}},[Me,Oe]),A.useEffect(()=>{M&&Me()},[M,Me]);const ye=(O==null?void 0:O.notice)??null,Se=ye?`${ye.kind}:${ye.to}`:"",Ye=ye!=null&&Y!==Se,we=A.useCallback(()=>{if(!ye)return;const G=Y===Se?"":Se;te(G);try{window.localStorage.setItem(rE,G)}catch{}},[ye,Se,Y]),ge=((wo=O==null?void 0:O.upgrade)==null?void 0:wo.state)??"idle",Fe=U3(O==null?void 0:O.upgrade),pt=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}Me()},[Me]);A.useEffect(()=>{if(ge!=="running")return;const G=window.setInterval(Me,3e3);return()=>window.clearInterval(G)},[ge,Me]);const mt=A.useCallback(async()=>{var ae;const G=O==null?void 0:O.command;if(!G)return;let Q=!1;try{Q=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(G).then(()=>!0))??Promise.resolve(!1),new Promise(ue=>window.setTimeout(()=>ue(!1),500))])}catch{Q=!1}if(!Q)try{const ue=document.createElement("textarea");ue.value=G,ue.setAttribute("readonly",""),ue.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(ue),ue.select(),Q=document.execCommand("copy"),ue.remove()}catch{Q=!1}Q&&(ce(!0),window.setTimeout(()=>ce(!1),1600))},[O==null?void 0:O.command]),Ze=A.useCallback(()=>{R(G=>(G||B(!1),!G))},[]),De=A.useCallback(()=>{B(G=>(G||R(!1),!G))},[]),[Qe,at]=A.useState(!1),[Mt,rt]=A.useState(0),gt=A.useRef(null),[Kt,Pt]=A.useState(!1),Ge=A.useRef(null),[Nt,dt]=A.useState(0),lt=A.useRef(oL()),[hn,Ht]=A.useState(!1),Ct=A.useCallback(()=>{const G=lt.current,Q=G.setPaused(!G.paused);for(const ae of Q)n.current=fx(n.current,ae);Ht(G.paused)},[]),[Je,fr]=A.useState(Date.now()),[Wt,pn]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(iE)!=="0"}catch{return!0}}),jn=A.useCallback(()=>{pn(G=>{const Q=!G;try{window.localStorage.setItem(iE,Q?"1":"0")}catch{}return Q})},[]),[Tt,hr]=A.useState(!1),[ii,oi]=A.useState("restart"),[ms,qr]=A.useState(null),An=A.useRef(!1),Jn=A.useRef(null),$r=A.useRef(0),mn=A.useCallback(async G=>{if(An.current)return;const Q=(G==null?void 0:G.upgrade)===!0;An.current=!0,Jn.current=Fe;const ae=++$r.current;oi(Q?"npx":"restart"),hr(!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:Q})})}catch{}window.setTimeout(()=>{if($r.current===ae&&An.current){An.current=!1,hr(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Q?18e4:3e4)},[ye==null?void 0:ye.to,Fe]),ai=A.useRef(null);A.useEffect(()=>{let G=!1;for(const ae of n.current.agents.values())if(ae.state==="active"){G=!0;break}const Q=W3({enabled:Wt,kind:ye==null?void 0:ye.kind,canRestart:(O==null?void 0:O.canRestart)===!0,busy:G,idleSince:ai.current,now:Je});ai.current=Q.idleSince,Q.restart&&mn()},[Wt,ye==null?void 0:ye.kind,O==null?void 0:O.canRestart,Je,mn]),A.useEffect(()=>{const G=O==null?void 0:O.running;let Q=null,ae=null;try{Q=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(oE)}catch{return}const ue=B3({bundle:"1.33.123",running:G,pending:Q,lastTried:ae});if(ue==="reload"){try{window.sessionStorage.setItem(oE,G??"")}catch{return}window.location.reload();return}if(ue!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}An.current=!1,hr(!1),qr(G??null);const xe=window.setTimeout(()=>qr(null),6e3);return()=>window.clearTimeout(xe)},[O==null?void 0:O.running]),A.useEffect(()=>{if(Tt&&H3({asked:Jn.current,reported:Fe})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}An.current=!1,hr(!1)}},[Tt,Fe]);const In=A.useRef(h5()).current;A.useRef(!1);const wt=A.useRef(new Map(In.positions.filter(([G])=>In.pins.includes(G)))),Mn=A.useRef(null),er=A.useState(()=>p5())[0],[Pn,li]=A.useState(""),[gs,On]=A.useState(()=>new Set),[tr,vs]=A.useState(()=>QN("agent-dag.theme")??"dark"),[ui,ci]=A.useState(!1),ys=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=tr;try{window.localStorage.setItem("agent-dag.theme",tr)}catch{}},[tr]),A.useEffect(()=>{if(!er)return;const G=window.setTimeout(()=>{try{e.setViewport(er,{duration:0})}catch{}},60);return()=>window.clearTimeout(G)},[e,er]);const ws=A.useRef(!0);A.useEffect(()=>{const G=new EventSource("/events"),Q=iL(i,{now:()=>Date.now(),setTimeout:(ae,ue)=>window.setTimeout(ae,ue),clearTimeout:ae=>window.clearTimeout(ae)});return G.addEventListener("open",()=>{V(!0),ci(!0)}),G.addEventListener("error",()=>V(!1)),G.addEventListener("replay-end",()=>{ws.current=!1,Q.flush()}),G.addEventListener("hook",ae=>{try{const ue=JSON.parse(ae.data);if(!lt.current.accept(ue))return;n.current=fx(n.current,ue),ue.replay===!0||ws.current||Date.now()-ue.receivedAt>3e4?Q.replay():Q.live()}catch{}}),()=>{G.close(),Q.cancel()}},[i]),A.useEffect(()=>{const G=setInterval(()=>{const Q=Date.now();fr(Q);let ae=UP(n.current,Q,J4);zP(n.current,Q,e5,t5)&&(ae=!0),BP(n.current,Q,n5,r5)&&(ae=!0),ae&&i()},250);return()=>clearInterval(G)},[i]);const Dr=A.useRef(null),Ln=A.useRef(0),fo=420,Be=A.useCallback((G=500)=>{try{const ke=document.querySelector(".canvas-wrap"),Re=Array.from(document.querySelectorAll(".react-flow__node")).filter(vt=>vt.offsetWidth>0);if(!ke||Re.length===0)return;const Le=ke.getBoundingClientRect(),He=e.getViewport();if(!Number.isFinite(He.zoom)||He.zoom<=0)return;const Ke=vt=>(vt-Le.left-He.x)/He.zoom,st=vt=>(vt-Le.top-He.y)/He.zoom,yn=Re.map(vt=>vt.getBoundingClientRect()),js=Math.min(...yn.map(vt=>Ke(vt.left))),As=Math.max(...yn.map(vt=>Ke(vt.right))),Is=Math.min(...yn.map(vt=>st(vt.top))),_o=Math.max(...yn.map(vt=>st(vt.bottom))),ja=As-js,xi=_o-Is;if(!(ja>0&&xi>0))return;const Dn=Math.max(.2,Math.min(1,(Le.width-160)/(ja+fo)*.86,(Le.height-160)/xi*.86));e.setViewport({x:80-js*Dn,y:Math.max(80,(Le.height-xi*Dn)/2)-Is*Dn,zoom:Dn},{duration:G}),Ln.current=Date.now(),window.setTimeout(()=>{try{const vt={x:80-js*Dn,y:Math.max(80,(Le.height-xi*Dn)/2)-Is*Dn,zoom:Dn},Aa=e.getViewport();(Math.abs(Aa.zoom-Dn)>.01||Math.abs(Aa.x-vt.x)>2)&&e.setViewport(vt,{duration:0})}catch{}},G+60)}catch{}},[e]),xs=A.useRef(""),pr=A.useRef(null),_s=A.useRef(0),qn=A.useCallback(()=>{_s.current=Date.now()},[]),Fr="agent-dag.autoFitDisabled",gn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fr)==="1"}catch{return!1}})()),[mr,Vt]=A.useState(gn.current),zr=A.useCallback(()=>{if(!gn.current){gn.current=!0,Vt(!0);try{window.localStorage.setItem(Fr,"1")}catch{}}},[]),an=A.useCallback(()=>{gn.current=!1,Vt(!1);try{window.localStorage.removeItem(Fr)}catch{}Be(400)},[e,Be]);A.useEffect(()=>{const G=setInterval(()=>{if(gn.current||Date.now()-_s.current<800)return;const Q=n.current,ae=Date.now(),ue=[];for(const Ke of Q.agents.values())lv(Ke,ae)&&ue.push({id:Ke.id});if(ue.length===0)return;const xe=e.getViewport(),ke=window.innerWidth-360,Re=window.innerHeight-52;let Le=!1,He=!1;for(const{id:Ke}of ue){const st=Br.current.get(Ke),yn=wt.current.get(Ke)??Xt.current.get(Ke);if(!st||!yn)continue;He=!0;const js=yn.x*xe.zoom+xe.x,As=yn.y*xe.zoom+xe.y,Is=(yn.x+st.width)*xe.zoom+xe.x,_o=(yn.y+st.height)*xe.zoom+xe.y;if(Is>0&&js<ke&&_o>0&&As<Re){Le=!0;break}}He&&!Le&&Be(600)},1500);return()=>clearInterval(G)},[e]);const ho=A.useRef(!1),Br=A.useRef(new Map),Ea=A.useRef(0),di=A.useCallback(G=>{const Q=Br.current;let ae=!1;for(const ue of G.nodeInternals.values()){const xe=ue.width,ke=ue.height;if(xe==null||ke==null)continue;const Re=Q.get(ue.id);Re?(Math.abs(Re.height-ke)>4||Math.abs(Re.width-xe)>4)&&(Q.set(ue.id,{width:xe,height:ke}),ae=!0):(Q.set(ue.id,{width:xe,height:ke}),ae=!0)}return ae&&(Ea.current+=1),Ea.current},[]),bs=Xe(di),[Ur,fi]=A.useState(0);A.useEffect(()=>{let G=0;const Q=()=>{const ue=Br.current;let xe=!1;for(const ke of document.querySelectorAll(".react-flow__node[data-id]")){const Re=ke.getAttribute("data-id");if(!Re)continue;const Le=ke.offsetWidth,He=ke.offsetHeight;if(!Le||!He)continue;const Ke=ue.get(Re);(!Ke||Math.abs(Ke.width-Le)>4||Math.abs(Ke.height-He)>4)&&(ue.set(Re,{width:Le,height:He}),xe=!0)}xe&&fi(ke=>ke+1)};if(ho.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(Q,32):G=requestAnimationFrame(Q),()=>{cancelAnimationFrame(G),window.clearTimeout(ae)}});const Xt=A.useRef(new Map(In.positions)),Iu=A.useRef(new Set),Ss=A.useRef(""),gr=A.useMemo(()=>{const G=[];for(const Q of n.current.agents.values())lv(Q,Je)&&G.push(Q.id+(Q.parentId?`>${Q.parentId}`:""));return G.sort(),`${G.join("|")}#sv${bs}.${Ur}`},[n.current,n.current.lastSeq,Je,bs,Ur]),vr=A.useRef(null);A.useEffect(()=>(vr.current!=null&&window.clearTimeout(vr.current),vr.current=window.setTimeout(()=>{Dg(Xt.current,wt.current)},1500),()=>{vr.current!=null&&window.clearTimeout(vr.current)}),[gr]),A.useEffect(()=>{if(xs.current===gr)return;const G=xs.current;if(xs.current=gr,!G||gn.current)return;Date.now()-Ln.current>1200&&Be(400),Dr.current&&window.clearTimeout(Dr.current),Dr.current=window.setTimeout(()=>{gn.current||Be(500)},280)},[gr,e,Be]);const yr=A.useMemo(()=>{if(o.size===0)return null;const G=new Set;for(const Q of o){const ae=y5(n.current,Q);if(ae)for(const ue of ae)G.add(ue)}return G.size>0?G:null},[n.current,n.current.lastSeq,o]),po=A.useMemo(()=>U4(n.current,Je),[n.current,n.current.lastSeq,Je]),hi=A.useRef(null),[Ue,mo]=A.useState({w:0,h:0});A.useEffect(()=>{const G=hi.current;if(!G||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(ae=>{var xe;const ue=(xe=ae[0])==null?void 0:xe.contentRect;ue&&mo(ke=>Math.abs(ke.w-ue.width)>40||Math.abs(ke.h-ue.height)>40?{w:ue.width,h:ue.height}:ke)});return Q.observe(G),mo({w:G.clientWidth,h:G.clientHeight}),()=>Q.disconnect()},[]);const Na=A.useRef(new Map),[pi,Ca]=A.useState(!1);A.useEffect(()=>{const G=window.setTimeout(()=>Ca(!0),2500);return()=>window.clearTimeout(G)},[]);const[Ta,mi]=A.useState(!1),vn=A.useRef(null),[Hr,$n]=A.useState(!1),nr=A.useCallback(()=>{vn.current&&(window.clearTimeout(vn.current),vn.current=null),mi(!1)},[]),rr=A.useCallback(G=>{G.length!==0&&queueMicrotask(()=>{mi(!0),vn.current&&window.clearTimeout(vn.current),vn.current=window.setTimeout(()=>mi(!1),Z4+80)})},[]);A.useEffect(()=>()=>{vn.current&&window.clearTimeout(vn.current)},[]);const Wr=Ue.w>0?Ue.w*.92:0,Vr=Ue.h>0?Ue.h:0,{nodes:Rt,edges:Mu}=A.useMemo(()=>w5(n.current,Je,Wr,Vr,wt.current,Pn,Br.current,Na.current,rr,pi,Hr,Xt.current,Iu.current,gr,Ss,o,yr,po,S),[n.current,n.current.lastSeq,Je,Wr,Vr,pi,Hr,Pn,gr,o,yr,po,S,Mt]),go=A.useMemo(()=>{const G=new Map;for(const ae of Rt){const ue=ae.data;if(!(ue!=null&&ue.sessionId)||ue.exitAt!=null)continue;const xe=ae.width,ke=ae.height;if(xe==null||ke==null)continue;const Re=ae.position.x,Le=ae.position.y,He=Re+xe,Ke=Le+ke,st=G.get(ue.sessionId);st?(st.minX=Math.min(st.minX,Re),st.minY=Math.min(st.minY,Le),st.maxX=Math.max(st.maxX,He),st.maxY=Math.max(st.maxY,Ke)):G.set(ue.sessionId,{minX:Re,minY:Le,maxX:He,maxY:Ke})}const Q=[];for(const[ae,ue]of G){const xe=ue.maxX-ue.minX+Bl*2,ke=ue.maxY-ue.minY+Bl*2;Q.push({id:`group:${ae}`,type:ZC,position:{x:ue.minX-Bl,y:ue.minY-Bl},data:{sessionId:ae,w:xe,h:ke},width:xe,height:ke,style:{width:xe,height:ke},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Q},[Rt,Je]),ks=A.useMemo(()=>{const G=[...go,...Rt],Q=Ge.current;return!Q||Q.size===0?G:G.map(ae=>{const ue=Q.get(ae.id);return ue?{...ae,position:ue}:ae})},[go,Rt,Nt]),Pu=A.useMemo(()=>{if(!Pn)return null;const G=new Set;for(const Q of n.current.agents.values())sT(Q,Pn)&&G.add(Q.id);return G},[n.current,n.current.lastSeq,Pn]),Es=A.useMemo(()=>{const G=new Set;for(const Q of n.current.agents.values())for(const ae of Q.tools)G.add(rT(ae.name));return Object.keys(uv).filter(Q=>G.has(Q))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(Es.length<=1){Pt(!1);return}let G=0;const Q=()=>{const ae=gt.current;if(ae&&!document.hidden){const ue=ae.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Re=>Re.getBoundingClientRect()),ke=W4(ue,xe,8);Pt(Re=>Re===ke?Re:ke)}G=window.setTimeout(Q,300)};return Q(),()=>window.clearTimeout(G)},[Es.length]);const sr=A.useMemo(()=>{const G=new Map;for(const ae of n.current.agents.values())for(const ue of ae.tools){if(!ue.name.startsWith("mcp__"))continue;const xe=ue.name.slice(5),ke=xe.indexOf("__"),Re=ke>0?xe.slice(0,ke):xe;G.set(Re,(G.get(Re)??0)+1)}const Q=[];for(const[ae,ue]of G){let xe=5381;for(let ke=0;ke<ae.length;ke++)xe=(xe<<5)+xe^ae.charCodeAt(ke);Q.push({server:ae,count:ue,hue:Math.abs(xe)%360})}return Q.sort((ae,ue)=>ue.count-ae.count),Q},[n.current,n.current.lastSeq]),Ra=A.useCallback(G=>{On(Q=>{const ae=new Set(Q);return ae.has(G)?ae.delete(G):ae.add(G),ae})},[]),Dt=u?n.current.agents.get(u):null,wr=p?Array.from(n.current.agents.values()).flatMap(G=>G.tools).find(G=>G.id===p)??null:null,Gr=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=nv(),wt.current.clear(),Br.current.clear(),Xt.current.clear(),Ss.current="",lE(),g(),i()},[i,g]),xr=A.useRef(b);xr.current=b;const Ns=A.useRef(!1);Ns.current=wr!=null||Qe||N!=null||y!=null;const gi=A.useCallback(G=>{const Q=Z3(G,{confirmOpen:xr.current,modalOpen:Ns.current});Q==="confirm"?k(!0):Q==="clear"&&(k(!1),Gr())},[Gr]),vo=A.useCallback(()=>{wt.current.clear(),Xt.current.clear(),Ss.current="",lE(),i(),window.setTimeout(()=>Be(500),80)},[i,e,Be]),vi=A.useCallback(()=>Be(500),[Be]),Cs=A.useRef(Rt);Cs.current=Rt;const yi=A.useRef(u);yi.current=u;const wi=A.useCallback(G=>{const Q=Cs.current;if(Q.length===0)return;const ae=Q.slice().sort((Le,He)=>Le.position.y-He.position.y||Le.position.x-He.position.x),ue=yi.current,xe=ue?ae.findIndex(Le=>Le.id===ue):-1;let ke;xe===-1?ke=G===1?0:ae.length-1:ke=(xe+G+ae.length)%ae.length;const Re=ae[ke];Re&&(f(Re.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[Re]})}catch{}Ln.current=Date.now()},30))},[f,e]);A.useEffect(()=>{const G=Q=>{var xe,ke;const ae=Q.target,ue={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(xe=ae==null?void 0:ae.getAttribute)==null?void 0:xe.call(ae,"role"),type:ae==null?void 0:ae.type};if(Q.key==="Escape"){const Re=eO({overlayOpen:sv.depth()>0,typing:KN(ue)});Re==="dismiss"?sv.dismissTop():Re==="blur"?ae==null||ae.blur():g();return}if(!X3(ue)&&!V3(Q)){if(Q.key==="/"){Q.preventDefault(),(ke=ys.current)==null||ke.focus();return}Q.key===" "&&(Q.preventDefault(),Ct()),(Q.key==="c"||Q.key==="C")&&gi("shortcut"),(Q.key==="r"||Q.key==="R")&&vo(),(Q.key==="f"||Q.key==="F")&&vi(),(Q.key==="l"||Q.key==="L")&&Ze(),(Q.key==="h"||Q.key==="H")&&at(Re=>!Re),(Q.key==="u"||Q.key==="U")&&P(Re=>!Re),(Q.key==="a"||Q.key==="A")&&De(),(Q.key==="j"||Q.key==="J")&&wi(1),(Q.key==="k"||Q.key==="K")&&wi(-1),(Q.key==="t"||Q.key==="T")&&vs(Re=>Re==="dark"?"light":"dark")}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[gi,vo,vi,g,wi,Ct]);const ln=n.current.agents.size,yo=new Set(Array.from(n.current.agents.values()).map(G=>G.sessionId)).size,Ot=A.useMemo(()=>{let G=0,Q=0,ae=0,ue=0,xe=0,ke=0,Re=0,Le=0,He=0;for(const Ke of n.current.agents.values()){G+=Ke.usage.inputTokens,Q+=Ke.usage.outputTokens,ae+=Ke.usage.cacheReadTokens,ue+=Ke.usage.cacheCreateTokens;const st=sn(Ke.usage,Ke.model);xe+=st.total,ke+=st.input,Re+=st.output,Le+=st.cacheRead,He+=st.cacheWrite}return{inT:G,outT:Q,cacheR:ae,cacheC:ue,sum:G+Q,cost:{total:xe,input:ke,output:Re,cacheRead:Le,cacheWrite:He}}},[n.current,n.current.lastSeq]);return m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),"agents-deck",ye?m.jsxs("button",{type:"button",className:"v stale",onClick:we,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,m.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const G={running:(O==null?void 0:O.running)??"1.33.123",latest:O==null?void 0:O.latest,latestPending:O==null?void 0:O.latestPending,checkedAgo:O!=null&&O.checkedAt?i5(Je-O.checkedAt):null,checkDisabled:O==null?void 0:O.checkDisabled,checking:ve};return m.jsxs("button",{type:"button",className:ve?"v checking":"v",onClick:()=>Me(!0),"aria-busy":ve||void 0,"aria-label":K4(G),title:Y4(G),children:["v",G.running]})})()]}),Dt&&(()=>{const G=sn(Dt.usage,Dt.model),Q=Math.max(0,((Dt.endedAt??Je)-Dt.startedAt)/1e3),ae=Dt.state==="active"?su(G.total,Q):null,ue=o.size-1;return m.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Dt.label}`,onClick:()=>{try{const xe=Rt.find(ke=>ke.id===Dt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),Ln.current=Date.now()}catch{}},children:[m.jsx("span",{className:`state-pill state-${Dt.state}`,children:Dt.state==="active"?"live":Dt.state}),m.jsx("span",{className:"selected-label",children:Dt.label}),G.total>0&&m.jsxs("span",{className:"selected-cost",children:[ze(G.total),ae?m.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),ue>0&&m.jsxs("span",{className:"selected-extra",children:["+",ue]}),m.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:xe=>{xe.stopPropagation(),g()},children:"×"})]})})(),m.jsxs("div",{className:"actions",children:[m.jsxs("div",{className:"search",children:[m.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),m.jsx("input",{ref:ys,type:"text",placeholder:"Search agents, cwd, tools…",value:Pn,onChange:G=>li(G.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Pn?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>li(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),m.jsxs("span",{className:"status",role:"status",children:[m.jsx("span",{className:`pill ${M?"live":"dead"}`,title:M?"Receiving events":"SSE disconnected",children:M?"live":"offline"}),m.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[m.jsx("span",{className:"count",children:yo}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:ln}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:"Total hook events received",children:[m.jsx("span",{className:"count",children:n.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),Ot.sum>0&&m.jsxs("span",{className:"stat",title:`in:${Ot.inT.toLocaleString()} out:${Ot.outT.toLocaleString()} cache-r:${Ot.cacheR.toLocaleString()} cache-c:${Ot.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:X4(Ot.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),sr.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
59
|
+
burn: ${y}`:"");return m.jsxs("span",{className:"cost-meta",title:x,children:[m.jsx("b",{children:ze(f.total)}),y&&m.jsx("span",{className:"cost-rate",children:y})]})})()]}),m.jsx(no,{type:"source",position:Te.Right,style:{background:"transparent",border:"none"}})]})}function cO({state:e}){const n=e==="active"?"live":e==="done"?"done":"err";return m.jsx("span",{className:`state-pill state-${e}`,children:n})}function dO(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function fO({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,g=c/(2500/1e3);return m.jsxs("div",{className:"tool-spark-row",title:`${u} tool calls in last 60s · peak ${g.toFixed(1)}/s`,children:[m.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,b=`tool-spark-bar${y>0?" active":""}${_?" latest":""}`;return m.jsx("rect",{x:x*f+.4,y:h-N,width:Math.max(.5,f-1),height:N,rx:.8,className:b},x)})}),m.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function ei(e){const n=e.replace(/^anthropic\./,"").replace(/[-_]\d{8}(?!\d)/,""),r=n.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(r){const l=r[1][0].toUpperCase()+r[1].slice(1).toLowerCase(),u=r[2].replace(/[-_]/g,".");return`${l} ${u}`}const i=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)[-_]codex\b/i);if(i)return`GPT-${i[1].replace(/[-_]/g,".")} Codex`;const o=n.match(/^gpt[-_](\d+(?:[-_.]\d+)*)/i);return o?`GPT-${o[1].replace(/[-_]/g,".")}`:e}function mx(e){if(e==null)return"(none)";if(typeof e=="string")return e;try{return JSON.stringify(e,null,2)}catch{return String(e)}}function hO(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 pO({tool:e,onClose:n}){io(n);const r=e.endedAt==null?"inflight":e.ok===!1?"err":"done";return m.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:m.jsxs("div",{className:"modal",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:`status-dot ${r}`}),m.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),m.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",children:hO(e)}),m.jsx("button",{className:"btn icon-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("section",{className:"modal-body",children:[e.trimmed&&m.jsx("div",{className:"modal-section",children:m.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),m.jsxs("div",{className:"modal-section",children:[m.jsx("h4",{children:"Input"}),m.jsx("pre",{children:mx(e.input??e.inputPreview)})]}),m.jsxs("div",{className:"modal-section",children:[m.jsxs("h4",{children:["Response ",r==="err"&&m.jsx("span",{className:"err-tag",children:"error"})]}),m.jsx("pre",{children:e.endedAt==null?"(waiting…)":mx(e.response??e.errorPreview)})]})]})]})})}const Ll=18,gx=26,mO=12;function gO(e){return vO(e.nodeInternals.values())}function vO(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=vx(l)??f.label)):n.set(l.sessionId,{minX:u,minY:c,maxX:p,maxY:h,label:vx(l)??l.sessionId})}const r=new Map;for(const o of n.values())r.set(o.label,(r.get(o.label)??0)+1);const i=[];for(const[o,l]of n){const c=(r.get(l.label)??0)>1?`${l.label} · ${yO(o)}`:l.label;i.push({sessionId:o,label:c,x:l.minX-Ll,y:l.minY-Ll-gx,w:l.maxX-l.minX+Ll*2,h:l.maxY-l.minY+Ll*2+gx})}return i}function yO(e){const n=e.match(/[a-zA-Z0-9]{4}/);return n?n[0]:e.slice(0,4)}function vx(e){if(e.kind==="root")return e.label}function wO(){const{x:e,y:n,zoom:r}=TN(),i=wa(),o=Xe(gO,xO);if(o.length<=1)return null;const l=u=>{try{const c=i.getNodes().filter(p=>{const h=p.data;return(h==null?void 0:h.sessionId)===u});if(c.length===0)return;i.fitView({padding:.3,duration:500,nodes:c})}catch{}};return m.jsx("div",{className:"session-clusters",children:o.map(u=>{const c=jv(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-mO)*r+n,color:`hsl(${c} 70% 78%)`,borderColor:`hsl(${c} 65% 55% / 0.5)`,transform:`scale(${Math.min(1,r)})`,transformOrigin:"left top"};return m.jsxs(le.Fragment,{children:[m.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),m.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 xO(e,n){if(e.length!==n.length)return!1;for(let r=0;r<e.length;r++){const i=e[r],o=n[r];if(i.sessionId!==o.sessionId||i.label!==o.label||i.x!==o.x||i.y!==o.y||i.w!==o.w||i.h!==o.h)return!1}return!0}function _O({data:e}){return m.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const zN=600,bO=4,SO=36,iv=16,kO=60,EO=6,yx=220,wx=96,NO=28,CO={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 TO(e){return e.startsWith("mcp__")?"mcp":CO[e]??"other"}const RO={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 xx(e){return e.startsWith("mcp__")?"🔌":RO[e]??"✨"}const jO={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 BN(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 BN(r[1]);for(;;){const l=n.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;n=n.slice(l[0].length)}n=n.replace(/^sudo(?:\s+-\S+)*\s+/,""),n=n.replace(/^(?:time|nohup|xargs)\s+/,"");const i=n.match(/^([^\s|;&<>(]+)/);if(!i)return null;let o=i[1];return o=o.replace(/^.*[/\\]/,""),o=o.replace(/\.(exe|cmd|bat|ps1)$/i,""),o||null}function AO(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const n=e;if(typeof n.cmd=="string")return n.cmd;if(typeof n.command=="string")return n.command;if(Array.isArray(n.command)&&n.command.every(r=>typeof r=="string")){const r=n.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(r[0]??"")){const i=r.findIndex(o=>/^(-Command|-c)$/i.test(o));if(i>=0&&i+1<r.length)return r[i+1]}return r.join(" ")}return typeof n.script=="string"?n.script:null}const IO=new Set(["Bash","PowerShell","shell","exec_command","shell_command","write_stdin","wait"]),MO=new Set(["shell","exec_command","shell_command","write_stdin","wait","apply_patch","update_plan"]);function PO(e,n){return MO.has(e)||e.startsWith("mcp__")?Math.max(wx,34+n.length*7.5):wx}function OO(e,n){if(!IO.has(e))return null;const r=AO(n);if(!r)return null;const i=BN(r);return i?{emoji:jO[i]??"⚙️",label:i,category:"shell",detail:r}:null}const LO=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),_x={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:"🗄️"},bx={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 qO(e){const r=e.replace(/\\/g,"/").replace(/\/+$/,""),i=r.lastIndexOf("/");return i>=0?r.slice(i+1):r}function $O(e){const n=e.toLowerCase();if(bx[n])return bx[n];if(n.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(n))return"🧪";const r=n.lastIndexOf(".");if(r>0&&r<n.length-1){const i=n.slice(r+1);if(_x[i])return _x[i]}return"📄"}function DO(e,n){if(!n||typeof n!="object")return null;const r=n;if(e==="apply_patch"&&typeof r.patch=="string"){const i=r.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return i?i[1].trim():null}return typeof r.file_path=="string"?r.file_path:typeof r.notebook_path=="string"?r.notebook_path:typeof r.path=="string"?r.path:e==="Glob"&&typeof r.pattern=="string"?r.pattern:null}function FO(e,n){if(!LO.has(e))return null;const r=DO(e,n);if(!r)return null;const i=qO(r);return i?{emoji:e==="LS"?"📂":$O(i),label:i,category:"file",detail:r}:null}const UN={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 HN(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 zO(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 BO(e,n){const r=HN(e);if(!r)return null;const{server:i,method:o}=r;if(!o)return null;const l=UN[i.toLowerCase()];return{emoji:(l==null?void 0:l.emoji)??"🔌",label:o,category:"mcp",detail:l?`${l.name} · ${o}`:`${i} · ${o}`}}function UO(e,n){return OO(e,n)??FO(e,n)??BO(e)}const HO={shell:"Shell",exec_command:"Shell",shell_command:"Shell",write_stdin:"stdin",wait:"wait",apply_patch:"Edit",update_plan:"Plan"};function WO(e){const n=HN(e);if(n){const i=UN[n.server.toLowerCase()];return i?{emoji:i.emoji,label:i.name}:{emoji:"🔌",label:n.server,hue:zO(n.server)}}const r=HO[e];return r?{emoji:xx(e),label:r}:{emoji:xx(e),label:e}}function VO(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function GO(e,n,r){if(r==null)return 1;const i=n-r;return i<0?1:Math.max(0,1-i/zN)}function YO(e,n){const r=[],i=new Set;for(let o=e.length-1;o>=0&&r.length<n;o--){const l=e[o];i.has(l.id)||(i.add(l.id),r.push(l))}return r.reverse()}function KO(e,n,r,i,o,l){const u=[];for(const c of e.values()){if(!n.has(c.id)||c.exitAt!=null&&l-c.exitAt>zN)continue;const p=i.get(c.id)??r.get(c.id);if(!p)continue;const h=YO(c.tools,bO);if(h.length===0)continue;const f=c.exitAt??null,g=o.get(c.id),y=Math.max((g==null?void 0:g.width)??yx,yx),x=(g==null?void 0:g.height)??130,N=p.x,_=p.y,S=N+y,b=_+x/2;h.forEach((k,E)=>{const C=E*SO,R=N+y+kO,I=_+EO+C,L=GO(k,l,f),H=k.inputPreview??"",P=VO(k),q=L<.999,B=WO(k.name);u.push({id:`${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:B.label,emoji:B.emoji,status:P,category:TO(k.name),mcpHue:B.hue,inputPreview:H,fade:L,fading:q,worldX:R,worldY:I,anchorX:S,anchorY:b,spawnDx:S-R,spawnDy:b-(I+iv)});const D=UO(k.name,k.input);if(D){const F=PO(k.name,B.label),j=R+F+NO,Z=I,W=R+F,ne=I+iv;u.push({id:`sub:${c.id}::${k.id}`,toolId:k.id,agentId:c.id,toolName:k.name,name:D.label,emoji:D.emoji,isSub:!0,status:P,category:D.category,inputPreview:D.detail??H,fade:L,fading:q,worldX:j,worldY:Z,anchorX:W,anchorY:ne,spawnDx:W-j,spawnDy:0})}})}return u}function XO({agents:e,visibleAgentIds:n,positions:r,pinned:i,measured:o,dimUnmatched:l,spotlight:u,hiddenCategories:c,now:p,onOpenTool:h}){const f=KO(e,n,r,i,o,p),g=c&&c.size>0?f.filter(y=>!c.has(y.category)):f;return m.jsx(QO,{bursts:g,dimUnmatched:l,spotlight:u,onOpenTool:h})}function QO({bursts:e,dimUnmatched:n,spotlight:r,onOpenTool:i}){const{x:o,y:l,zoom:u}=TN();return m.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[m.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,g=(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 m.jsx("path",{d:`M ${p} ${h} Q ${y} ${h}, ${f} ${g}`,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`},g=c.isSub?`${c.toolName} · ${c.name}`:c.toolName,y=c.inputPreview?`${g} · ${c.inputPreview}`:g,x=i!=null,N=c.mcpHue!=null?{"--cat-accent":`hsl(${c.mcpHue} 65% 65%)`}:{},_=n!=null&&!n.has(c.agentId),S=r!=null&&!r.has(c.agentId),b=_||S?" dim":"";return m.jsx("div",{className:"tool-burst-wrap",style:f,children:m.jsxs("div",{className:`tool-burst cat-${c.category} status-${c.status}${c.fading?" fading":""}${x?" clickable":""}${c.isSub?" sub":""}${b}`,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?()=>i(c.toolId):void 0,onKeyDown:x?k=>{(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),i(c.toolId))}:void 0,children:[m.jsx("span",{className:"tb-emoji",children:c.emoji}),m.jsx("span",{className:"tb-name",children:c.name}),c.status==="inflight"&&m.jsx("span",{className:"tb-spin"}),c.status==="done"&&m.jsx("span",{className:"tb-mark done",children:"✓"}),c.status==="err"&&m.jsx("span",{className:"tb-mark err",children:"×"})]})},c.id)})]})}function ZO({state:e,sessionId:n,onClose:r}){const i=A.useMemo(()=>e3(e,n),[e,n]),o=A.useRef(null);return io(r,{focusRef:o}),i?m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[m.jsxs("div",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),m.jsx("span",{id:"ss-title",className:"modal-tool-name",title:i.cwd??i.sessionId,children:i.label}),m.jsxs("span",{className:"modal-tool-id",children:["· ",i.sessionId.slice(0,8)]})]}),m.jsxs("div",{className:"modal-actions",children:[m.jsx("span",{className:"modal-dur",title:"Total wall time",children:i.durationLabel}),m.jsx("button",{type:"button",ref:o,className:"btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),m.jsxs("div",{className:"modal-body",children:[m.jsxs("section",{className:"ss-hero",children:[m.jsxs("div",{className:"ss-hero-left",children:[m.jsx("div",{className:"ss-cost-label",children:"total spend"}),m.jsx("div",{className:"ss-cost",children:ze(i.cost.total)}),i.modelChips.length>0&&m.jsx("div",{className:"ss-models",children:i.modelChips.map(l=>m.jsx("span",{className:"model-chip",title:l,children:ei(l)},l))})]}),m.jsx("div",{className:"ss-hero-right",children:i.cost.total>0&&m.jsxs(m.Fragment,{children:[m.jsx(JO,{cost:i.cost}),m.jsxs("div",{className:"ss-cost-legend",children:[m.jsxs("span",{className:"ssl ssl-in",children:["input ",m.jsx("b",{children:ze(i.cost.input)})]}),m.jsxs("span",{className:"ssl ssl-out",children:["output ",m.jsx("b",{children:ze(i.cost.output)})]}),m.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",m.jsx("b",{children:ze(i.cost.cacheRead)})]}),m.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",m.jsx("b",{children:ze(i.cost.cacheWrite)})]})]})]})})]}),m.jsxs("section",{className:"ss-stats",children:[m.jsx(Wi,{label:"agents",value:i.agentCount}),m.jsx(Wi,{label:"subagents",value:i.subagentCount}),m.jsx(Wi,{label:"tool calls",value:i.toolCount}),m.jsx(Wi,{label:"prompts",value:i.promptCount}),m.jsx(Wi,{label:"tokens",value:i.tokensSum.toLocaleString()}),i.errCount>0&&m.jsx(Wi,{label:"errors",value:i.errCount,tone:"err"})]}),i.topTools.length>0&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Most-used tools"}),m.jsx("div",{className:"ss-top-tools",children:i.topTools.map(([l,u])=>m.jsxs("div",{className:"ss-tt",children:[m.jsx("span",{className:"ss-tt-name",children:l}),m.jsx("span",{className:"ss-tt-bar",children:m.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/i.topTools[0][1]*100}%`}})}),m.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),i.firstPrompt&&m.jsxs("section",{className:"modal-section",children:[m.jsx("h4",{children:"Opening prompt"}),m.jsx("div",{className:"ss-prompt",children:i.firstPrompt})]})]})]})}):null}function Wi({label:e,value:n,tone:r}){return m.jsxs("div",{className:`ss-stat${r?` tone-${r}`:""}`,children:[m.jsx("div",{className:"ss-stat-value",children:n}),m.jsx("div",{className:"ss-stat-label",children:e})]})}function JO({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(i)} (${u.toFixed(0)}%)`},o)};return m.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 e3(e,n){const r=e.agents.get(n);if(!r)return null;const i=[];for(const E of e.agents.values())E.sessionId===n&&i.push(E);if(i.length===0)return null;const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,u=new Map;let c=0,p=0,h=0,f=0,g=0,y,x=1/0,N=0;for(const E of i){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"&&g++,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 R of E.tools)u.set(R.name,(u.get(R.name)??0)+1),R.ok===!1&&f++}const _=Math.max(0,N-x),S=Math.floor(_/1e3),b=S<60?`${S}s`:S<3600?`${Math.floor(S/60)}m ${String(S%60).padStart(2,"0")}s`:`${Math.floor(S/3600)}h ${Math.floor(S%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:b,cost:o,modelChips:Array.from(l),agentCount:i.length,subagentCount:g,toolCount:c,promptCount:p,tokensSum:h,errCount:f,topTools:k,firstPrompt:y}}function t3(e,n){const r=[];for(const i of e.agents.values()){if(i.kind!=="root")continue;let o=i.toolCount,l=sn(i.usage,i.model).total,u=i.endedAt??i.startedAt;for(const c of e.agents.values()){if(c.sessionId!==i.sessionId||c.kind==="root")continue;o+=c.toolCount,l+=sn(c.usage,c.model).total;const p=c.endedAt??c.startedAt;p>u&&(u=p)}r.push({sessionId:i.sessionId,label:i.label||i.cwdBasename||"session",cwdBasename:i.cwdBasename,state:i.state,modelId:i.model,toolCount:o,cost:l,startedAt:i.startedAt,lastActivity:u})}return r.sort((i,o)=>{if(i.state!==o.state){if(i.state==="active")return-1;if(o.state==="active")return 1}return o.lastActivity-i.lastActivity}),r}function n3(e,n,r){const i=(n??r)-e;if(i<1e3)return"<1s";const o=Math.floor(i/1e3);if(o<60)return`${o}s`;const l=Math.floor(o/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function r3({state:e,now:n,selectedIds:r,onSelect:i,onClose:o}){const l=A.useMemo(()=>t3(e),[e,e.lastSeq,n]),u=l.filter(c=>c.state==="active").length;return m.jsxs("aside",{className:"session-list","aria-label":"Sessions",children:[m.jsxs("div",{className:"sl-header",children:[m.jsxs("h3",{children:["Sessions ",m.jsx("span",{className:"sl-count",children:l.length})]}),u>0&&m.jsxs("span",{className:"sl-live-count",children:[u," live"]}),m.jsx("button",{className:"btn icon-btn sl-close",onClick:o,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),m.jsxs("div",{className:"sl-rows",children:[l.length===0&&m.jsx("div",{className:"sl-empty",children:"No sessions yet."}),l.map(c=>{const p=r.has(c.sessionId);return m.jsxs("button",{type:"button",className:`sl-row state-${c.state}${p?" selected":""}`,onClick:()=>i(c.sessionId),title:`Focus ${c.label}`,children:[m.jsx("span",{className:`sl-dot state-${c.state}`,"aria-hidden":!0}),m.jsxs("div",{className:"sl-row-body",children:[m.jsxs("div",{className:"sl-row-head",children:[m.jsx("span",{className:"sl-label",children:c.label}),c.modelId&&m.jsx("span",{className:"model-chip",title:c.modelId,children:ei(c.modelId)})]}),m.jsxs("div",{className:"sl-row-meta",children:[m.jsxs("span",{title:"tool calls",children:[m.jsx("b",{children:c.toolCount})," tools"]}),c.cost>0&&m.jsx("span",{className:"sl-cost",title:"total spend",children:m.jsx("b",{children:ze(c.cost)})}),m.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(c.startedAt).toLocaleString()}`,children:n3(c.startedAt,c.state==="active"?void 0:c.lastActivity,n)})]})]})]},c.sessionId)})]})]})}function Sx(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 s3(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 i3({cost:e}){const n=e.total;if(n<=0)return null;const r=(i,o,l)=>{if(i<=0)return null;const u=i/n*100;return m.jsx("span",{className:`cb-seg ${o}`,style:{width:`${u}%`},title:`${l}: ${ze(i)} (${u.toFixed(0)}%)`},o)};return m.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 o3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/3600),o=Math.floor(r%3600/60);if(i>23){const l=Math.floor(r/86400),u=Math.floor(r%86400/3600);return`${l}d ${u}h`}return i>0?`${i}h ${o}m`:`${o}m`}function a3(e,n,r,i){const o=Math.max(0,n-i),l=Math.max(0,r-o);if(l<120)return null;const u=Math.min(100,l/r*100),c=e-u;if(Math.abs(c)<3)return{label:"on pace",color:"var(--ok)",expectedPct:u,isDeficit:!1};if(c>0){const p=100-e,h=l>0?e/l:0,f=h>0?p/h:1/0,g={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);g.runsOutIn=y>0?`${y}h ${x}m`:`${x}m`}return g}return{label:`${Math.round(-c)}% reserve`,color:"var(--ok)",expectedPct:u,isDeficit:!1}}function Ws({pct:e,label:n,reset:r,resetAt:i,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}%`,g=c===0?2:c,y=i?o3(i,u):null,x=i&&o?a3(c,i,o,u):null;return m.jsxs("div",{className:"qb-row",children:[m.jsxs("div",{className:"qb-meta",children:[m.jsxs("span",{className:"qb-label",children:[n,l&&m.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),m.jsx("span",{className:"qb-pct",style:{color:h},children:f})]}),m.jsxs("div",{className:"qb-track",children:[m.jsx("div",{className:"qb-fill",style:{width:`${g}%`,background:h,opacity:c===0?.4:1}}),x&&m.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`})]}),m.jsxs("div",{className:"qb-reset-row",children:[y?m.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):r?m.jsxs("span",{className:"qb-reset",children:["resets ",r]}):null,x&&m.jsx("span",{className:"qb-pace",style:{color:x.color},children:x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label})]})]})}const l3=6e4;function u3(){const[e,n]=A.useState(null),[r,i]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const h=await fetch(c?"/api/quota?refresh=1":"/api/quota");h.ok&&n(await h.json())}catch{}finally{c&&i(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),l3),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{quota:e,loading:r,refresh:()=>l(!0)}}function c3(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 WN=6e4;function d3(){const[e,n]=A.useState(null),[r,i]=A.useState(!1),o=A.useRef(null),l=async(c=!1)=>{c&&i(!0);try{const h=await fetch(c?"/api/codex-quota?refresh=1":"/api/codex-quota");h.ok&&n(await h.json())}catch{}finally{c&&i(!1)}};return A.useEffect(()=>(l(!0),o.current=window.setInterval(()=>l(!1),WN),()=>{o.current!=null&&window.clearInterval(o.current)}),[]),{data:e,loading:r,refresh:()=>l(!0)}}function f3(){const[e,n]=A.useState(null),r=A.useRef(null),i=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return A.useEffect(()=>(i(),r.current=window.setInterval(i,WN),()=>{r.current!=null&&window.clearInterval(r.current)}),[]),{data:e}}function h3({state:e,now:n,onClose:r}){var L,H;const{quota:i,loading:o,refresh:l}=u3(),{data:u,loading:c,refresh:p}=d3(),{data:h}=f3(),[f,g]=A.useState(()=>Math.floor(Date.now()/1e3));A.useEffect(()=>{const P=window.setInterval(()=>g(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(P)},[]);const{byModel:y,totalCost:x,totalTokens:N,burnRate:_}=A.useMemo(()=>{const P=new Map,q={total:0,input:0,output:0,cacheRead:0,cacheWrite:0};let B=0,D=0,F=0,j=0;for(const U of e.agents.values()){const X=U.model??"__unknown__",M=sn(U.usage,U.model),V=P.get(X);V?(V.inputTokens+=U.usage.inputTokens,V.outputTokens+=U.usage.outputTokens,V.cacheReadTokens+=U.usage.cacheReadTokens,V.cacheCreateTokens+=U.usage.cacheCreateTokens,V.cost.total+=M.total,V.cost.input+=M.input,V.cost.output+=M.output,V.cost.cacheRead+=M.cacheRead,V.cost.cacheWrite+=M.cacheWrite,V.agentCount++):P.set(X,{model:X,inputTokens:U.usage.inputTokens,outputTokens:U.usage.outputTokens,cacheReadTokens:U.usage.cacheReadTokens,cacheCreateTokens:U.usage.cacheCreateTokens,cost:{...M},agentCount:1}),q.total+=M.total,q.input+=M.input,q.output+=M.output,q.cacheRead+=M.cacheRead,q.cacheWrite+=M.cacheWrite,B+=U.usage.inputTokens,D+=U.usage.outputTokens,F+=U.usage.cacheReadTokens,j+=U.usage.cacheCreateTokens}const Z=Array.from(P.values()).sort((U,X)=>X.cost.total-U.cost.total);let W=0,ne=0;for(const U of e.agents.values()){if(U.state!=="active")continue;const X=sn(U.usage,U.model);W+=X.total,ne=Math.max(ne,((U.endedAt??n)-U.startedAt)/1e3)}const J=ne>0?su(W,ne):null;return{byModel:Z,totalCost:q,totalTokens:{in:B,out:D,cacheR:F,cacheC:j},burnRate:J}},[e,e.lastSeq,n]),S=A.useMemo(()=>{const P=[];for(const q of e.agents.values()){if(q.kind!=="root")continue;let B=sn(q.usage,q.model).total,D=q.usage.inputTokens,F=q.usage.outputTokens;for(const j of e.agents.values())j.sessionId!==q.sessionId||j.kind==="root"||(B+=sn(j.usage,j.model).total,D+=j.usage.inputTokens,F+=j.usage.outputTokens);P.push({sessionId:q.sessionId,label:q.label||q.cwdBasename||"session",state:q.state,cost:B,inputTokens:D,outputTokens:F})}return P.sort((q,B)=>B.cost-q.cost).slice(0,12)},[e,e.lastSeq]),b=x.total>0,k=N.in+N.out,E=o||c,C=Sx(i==null?void 0:i.fetchedAt,f),R=Sx(u==null?void 0:u.fetchedAt,f),I=()=>{l(),p()};return m.jsxs("div",{className:"usage-panel","aria-label":"Usage",children:[m.jsxs("div",{className:"up-header",children:[m.jsx("h3",{children:"Usage"}),_&&m.jsx("span",{className:"up-rate",children:_}),m.jsxs("div",{className:"up-header-right",children:[m.jsx("button",{type:"button",className:"btn up-refresh-btn",onClick:I,disabled:E,title:"Refresh Claude + Codex quota",children:E?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn up-close",onClick:r,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Claude quota",C&&!o&&m.jsx("span",{className:"up-section-age",title:s3(i==null?void 0:i.source),children:C})]}),i!=null&&i.ok?m.jsxs("div",{className:"up-quota-bars",children:[i.session5hPct!=null&&m.jsx(Ws,{label:"5-hour window",pct:i.session5hPct,reset:i.session5hReset,resetAt:i.session5hResetAt,windowSec:i.session5hWindowSec,nowSec:f}),i.week7dPct!=null&&m.jsx(Ws,{label:"7-day window",pct:i.week7dPct,reset:i.week7dReset,resetAt:i.week7dResetAt,windowSec:i.week7dWindowSec,nowSec:f}),i.weekSonnetPct!=null&&m.jsx(Ws,{label:"Sonnet (7d)",pct:i.weekSonnetPct,nowSec:f}),i.weekOpusPct!=null&&m.jsx(Ws,{label:"Opus (7d)",pct:i.weekOpusPct,nowSec:f})]}):(i==null?void 0:i.ok)===!1?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsxs("span",{className:"up-quota-hint",children:["Run ",m.jsx("code",{children:"/usage"})," in a claude session, then click ↻"]})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),m.jsxs("section",{className:"up-section up-quota-section",children:[m.jsxs("h4",{className:"up-section-title",children:["Codex quota",(u==null?void 0:u.ok)&&u.planLabel&&m.jsx("span",{className:"up-plan-badge",children:u.planLabel}),R&&!c&&m.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:R})]}),u!=null&&u.ok?m.jsxs("div",{className:"up-quota-bars",children:[(L=u.windows)==null?void 0:L.map(P=>m.jsx(Ws,{label:P.label,pct:P.pct,reset:P.reset??void 0,resetAt:P.resetAt??void 0,windowSec:P.windowSec??void 0,limitReached:u.limitReached&&P.pct>=100,nowSec:f},P.id)),(H=u.extraWindows)==null?void 0:H.map(P=>m.jsx(Ws,{label:P.label,pct:P.pct,reset:P.reset??void 0,resetAt:P.resetAt??void 0,windowSec:P.windowSec??void 0,nowSec:f},P.id)),u.creditLimit&&m.jsx(Ws,{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&&m.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&&m.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",u.creditsBalance,u.overageReached&&" · overage limit reached"]}),u.creditsUnlimited&&m.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),u.resetCredits&&u.resetCredits.availableCount>0&&m.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&&m.jsx("div",{className:"up-quota-sub",children:u.promo}),u.partial&&m.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?m.jsxs("div",{className:"up-quota-na",children:[m.jsx("span",{children:"Quota unavailable."}),m.jsx("span",{className:"up-quota-hint",children:c3(u.reason)})]}):m.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),b?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-total",children:[m.jsx("span",{className:"up-total-value",children:ze(x.total)}),m.jsx("span",{className:"up-total-label",children:"total spend"})]}),m.jsx(i3,{cost:x}),k>0&&m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]}),N.cacheR>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache r"}),jr(N.cacheR)]}),N.cacheC>0&&m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"cache c"}),jr(N.cacheC)]})]}),y.filter(P=>P.cost.total>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By model"}),m.jsxs("table",{className:"up-table",children:[m.jsx("thead",{children:m.jsxs("tr",{children:[m.jsx("th",{children:"Model"}),m.jsx("th",{children:"Tokens"}),m.jsx("th",{children:"Cost"})]})}),m.jsx("tbody",{children:y.filter(P=>P.cost.total>0).map(P=>m.jsxs("tr",{children:[m.jsx("td",{className:"up-model-name",title:P.model,children:ei(P.model)}),m.jsx("td",{className:"up-num",children:jr(P.inputTokens+P.outputTokens)}),m.jsx("td",{className:"up-num up-cost-val",children:ze(P.cost.total)})]},P.model))})]})]}),S.filter(P=>P.cost>0).length>0&&m.jsxs("section",{className:"up-section",children:[m.jsx("h4",{className:"up-section-title",children:"By session"}),m.jsx("div",{className:"up-sessions",children:S.filter(P=>P.cost>0).map(P=>m.jsxs("div",{className:"up-session-row",children:[m.jsx("span",{className:`sl-dot state-${P.state}`,"aria-hidden":!0}),m.jsx("span",{className:"up-session-label",children:P.label}),m.jsx("span",{className:"up-session-tokens",children:jr(P.inputTokens+P.outputTokens)}),m.jsx("span",{className:"up-session-cost",children:ze(P.cost)})]},P.sessionId))})]})]}):k>0?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"up-tokens-row",children:[m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"in"}),jr(N.in)]}),m.jsxs("span",{className:"up-tok",children:[m.jsx("span",{className:"up-k",children:"out"}),jr(N.out)]})]}),m.jsx("div",{className:"up-hint",children:"Cost appears once a known model is detected."})]}):m.jsxs("div",{className:"up-empty",children:["No usage data yet.",m.jsx("br",{}),"Start a Claude Code or Codex session."]})]})}const kx=18,p3=1100,Vi=(e,n)=>{const r=Math.sin(e*12.9898+n*78.233)*43758.5453;return r-Math.floor(r)},m3=Array.from({length:kx},(e,n)=>{const r=-72+144*n/(kx-1)+(Vi(n,1)-.5)*9,i=(r-90)*(Math.PI/180),o=(54+32*Math.cos(r*Math.PI/180))*(.74+Vi(n,2)*.52);return{dx:Math.cos(i)*o,dy:Math.sin(i)*o,rot:(n%2?1:-1)*(100+Vi(n,3)*260),delay:Math.round(Vi(n,4)*90),dur:760+Math.round(Vi(n,5)*260),scale:.8+Vi(n,6)*.45,hue:n%4,round:n%3===0}});function Ex({anchor:e,lifetimeMs:n=p3}){var l;const[r,i]=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();i({x:c.left+c.width/2,y:c.top+c.height/2});const p=window.setTimeout(()=>i(null),n);return()=>window.clearTimeout(p)},[e,n,o]),o||!r?null:wI.createPortal(m.jsx("div",{className:"confetti",style:{left:`${r.x}px`,top:`${r.y}px`},"aria-hidden":!0,children:m3.map((u,c)=>m.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 VN=new Set(["awaiting_url","awaiting_code","registering"]);function g3(e){return e!=null&&VN.has(e)}function GN(e){return e!=null&&e!=="done"&&!VN.has(e)}const v3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",y3="the sign-in did not complete";function w3({state:e,serverError:n,localError:r}){const i=e==="idle";return{title:i?"Sign-in ended":"Sign-in failed",message:r||n||(i?v3:y3)}}const x3="done";function _3(){let e=!1;return{shouldAnnounce(n){return n!==x3?(e=!1,!1):e?!1:(e=!0,!0)}}}const Nx={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"},Cx={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"},b3="claude-swap could not read the login keychain — start agents-deck from a Terminal window rather than a background service";function ov(e,n){return(e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ro(e))?b3:e!=null&&e.reason&&Cx[e.reason]?Cx[e.reason]:(e==null?void 0:e.reason)||n}function ro(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Tx={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",unreachable:"the deck did not answer — check it is still running, then try again"},S3="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function k3(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}function E3(e,n){return k3(ro(e))?S3:e!=null&&e.reason&&Tx[e.reason]?Tx[e.reason]:(e==null?void 0:e.reason)||n}function Gl(e,n){return e!=null&&e.detail?e.detail:e!=null&&e.error&&GN(e.state)?e.error:e!=null&&e.reason&&Nx[e.reason]?Nx[e.reason]:e!=null&&e.error?e.error:(e==null?void 0:e.reason)||n}const N3=1500;async function ql(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const av=le.forwardRef((e,n)=>m.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:n,children:[m.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),m.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));av.displayName="SuccessMark";function C3({onClose:e,onChanged:n}){const[r,i]=A.useState("login"),[o,l]=A.useState(null),[u,c]=A.useState(""),[p,h]=A.useState(""),[f,g]=A.useState(!1),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useRef(!1),b=A.useRef(null),k=A.useRef(null),E=A.useRef(null),C=A.useCallback(()=>{S.current&&ql({action:"login-cancel"}).catch(()=>{}),e()},[e]);io(C);const R=A.useCallback(async()=>{g(!0),x(null),S.current=!0;const F=await ql({action:"login"}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){x(Gl(F,"could not start the sign-in"));return}l(F)},[]);A.useEffect(()=>{if(!g3(o==null?void 0:o.state))return;const F=window.setInterval(async()=>{try{const j=await fetch("/api/claude-accounts/login");j.ok&&l(await j.json())}catch{}},N3);return()=>window.clearInterval(F)},[o]);const I=A.useRef(n);I.current=n;const L=A.useRef(_3());A.useEffect(()=>{var F;(o==null?void 0:o.state)==="awaiting_code"&&((F=b.current)==null||F.focus()),L.current.shouldAnnounce(o==null?void 0:o.state)&&I.current()},[o==null?void 0:o.state]),A.useEffect(()=>{var F;r==="paste"&&((F=k.current)==null||F.focus())},[r]);const H=A.useCallback(async()=>{var j;g(!0),x(null);const F=await ql({action:"login-code",code:u}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){x(Gl(F,"the code was not accepted")),F!=null&&F.state&&l(F),(j=b.current)==null||j.select();return}c(""),l(F)},[u,o]),P=A.useCallback(async()=>{g(!0),x(null);const F=await ql({action:"import",blob:p}).catch(()=>null);if(g(!1),!(F!=null&&F.ok)){x(Gl(F,"the import failed"));return}h(""),_({added:F.added===!0,num:F.num??null,email:F.email??null}),n()},[p,n]),q=(o==null?void 0:o.state)==="done"?o.account:null,B=GN(o==null?void 0:o.state)||!!(y&&S.current&&!f),D=w3({state:o==null?void 0:o.state,serverError:o==null?void 0:o.error,localError:y});return m.jsx("div",{className:"modal-backdrop",onClick:C,role:"presentation",children:m.jsxs("div",{className:"modal aa-modal",onClick:F=>F.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[m.jsxs("header",{className:"modal-head",children:[m.jsx("div",{className:"modal-title",children:m.jsxs("span",{className:"aa-tabs",role:"tablist",children:[m.jsx("button",{type:"button",role:"tab","aria-selected":r==="login",className:`aa-tab${r==="login"?" on":""}`,onClick:()=>i("login"),children:"Sign in"}),m.jsx("button",{type:"button",role:"tab","aria-selected":r==="paste",className:`aa-tab${r==="paste"?" on":""}`,onClick:()=>i("paste"),children:"Paste a share"})]})}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:C,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),m.jsx("section",{className:"modal-body aa-body",children:r==="login"?q?m.jsxs("div",{className:"aa-done",children:[m.jsx(av,{ref:E}),m.jsx(Ex,{anchor:E}),m.jsx("h4",{children:q.added?`Account ${q.num} added`:"Credentials refreshed"}),m.jsxs("p",{className:"aa-note",children:[m.jsx("strong",{children:q.email}),q.added?" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),m.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"?m.jsxs(m.Fragment,{children:[m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"1 · Approve in the browser"}),m.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),m.jsx("a",{className:"aa-link",href:o.url??"#",target:"_blank",rel:"noreferrer noopener",children:o.url})]}),m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"2 · Paste the code it gives you"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:b,type:"text",value:u,onChange:F=>c(F.target.value),onKeyDown:F=>{F.key==="Enter"&&u.trim()&&!f&&H()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:o.state==="registering"}),m.jsx("button",{type:"button",className:"btn primary",disabled:f||!u.trim()||o.state==="registering",onClick:H,children:o.state==="registering"?"registering…":"Continue"})]}),(y||o.error)&&m.jsx("p",{className:"aa-err",children:y??o.error}),m.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."})]})]}):B?m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:D.title}),m.jsx("p",{className:"aa-err",children:D.message}),m.jsx("button",{type:"button",className:"btn",onClick:()=>{S.current=!1,l(null),x(null),R()},children:"Try again"})]}):f||S.current?m.jsx("div",{className:"aa-step",children:m.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):m.jsxs("div",{className:"aa-step aa-primer",children:[m.jsx("h4",{children:"Sign in to Anthropic"}),m.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."}),m.jsx("div",{className:"aa-actions",children:m.jsx("button",{type:"button",className:"btn primary",onClick:R,disabled:f,children:"Open the sign-in page"})})]}):N?m.jsxs("div",{className:"aa-done",children:[m.jsx(av,{ref:E}),N.added&&m.jsx(Ex,{anchor:E}),m.jsx("h4",{children:N.added?`Account ${N.num} imported`:"Already here"}),m.jsx("p",{className:"aa-note",children:N.added?m.jsxs(m.Fragment,{children:[N.email?m.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."}),m.jsxs("div",{className:"aa-actions",children:[m.jsx("button",{type:"button",className:"btn primary",onClick:e,children:"Done"}),m.jsx("button",{type:"button",className:"btn",onClick:()=>_(null),children:"Import another"})]})]}):m.jsxs("div",{className:"aa-step",children:[m.jsx("h4",{children:"Paste an account shared from another deck"}),m.jsxs("div",{className:"aa-field",children:[m.jsx("input",{ref:k,type:"text",value:p,onChange:F=>h(F.target.value),onKeyDown:F=>{F.key==="Enter"&&p.trim()&&!f&&P()},placeholder:"ccdeck1:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),m.jsx("button",{type:"button",className:"btn primary",disabled:f||!p.trim(),onClick:P,children:f?"importing…":"Import"})]}),y&&m.jsx("p",{className:"aa-err",children:y}),m.jsxs("p",{className:"aa-note",children:["Use ",m.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 T3=Object.freeze({text:"couldn't reach the deck server",reload:!0});async function Rx(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function R3(e){const n=e.find(i=>!i.ok);if(!n)return null;const r=ro(n.body);return{text:ov(n.body,`the deck server answered ${n.status}`),...r?{raw:r}:{},reload:!0}}function jx(e,n){return n?e!=null&&e.reload&&e.text===n.text&&e.raw===n.raw?e:n:e!=null&&e.reload?null:e}const Ax=15e3,j3=3e4,A3=[70,80,85,90,95];function I3(e,n){const r=e-n;if(r<=0)return null;const i=Math.floor(r/86400),o=Math.floor(r%86400/3600),l=Math.floor(r%3600/60);return i>0?`${i}d ${o}h`:o>0?`${o}h ${l}m`:`${l}m`}function Ix(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 M3(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 P3(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 O3({lane:e,nowSec:n}){const r=Math.min(100,Math.max(0,e.pct)),i=r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",o=e.resetAt?I3(e.resetAt,n):null;return m.jsxs("div",{className:"ap-lane",children:[m.jsx("span",{className:"ap-lane-label",children:e.label}),m.jsx("div",{className:"ap-lane-track",children:m.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:i,opacity:r===0?.4:1}})}),m.jsxs("span",{className:"ap-lane-pct",style:{color:i},children:[r,"%"]}),m.jsx("span",{className:"ap-lane-reset",children:o?`resets ${o}`:""})]})}function L3(e){const n=e.map(i=>i.num),r=n.length?Math.max(...n):0;return[...new Set([...n,r+1])].sort((i,o)=>i-o)}async function q3(e){var r;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(i=>window.setTimeout(()=>i(!1),500))])}catch{n=!1}if(n)return!0;try{const i=document.createElement("textarea");i.value=e,i.setAttribute("readonly",""),i.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(i),i.select(),n=document.execCommand("copy"),i.remove()}catch{n=!1}return n}function $3(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 D3({onClose:e}){var X,M,V;const[n,r]=A.useState(null),[i,o]=A.useState(null),[l,u]=A.useState(null),[c,p]=A.useState(!1),[h,f]=A.useState(null),[g,y]=A.useState(null),[x,N]=A.useState(()=>Math.floor(Date.now()/1e3)),_=A.useRef(null),[S,b]=A.useState(null),[k,E]=A.useState(!1),[C,R]=A.useState(""),[I,L]=A.useState(null),[H,P]=A.useState(null),[q,B]=A.useState(!1),D=A.useCallback(async(O=!1)=>{O&&p(!0);const $=new AbortController,Y=window.setTimeout(()=>$.abort(),j3);try{const[te,oe]=await Promise.all([fetch(`/api/claude-accounts${O?"?refresh=1":""}`,{signal:$.signal}),fetch("/api/cswap-auto",{signal:$.signal})]);te.ok&&r(await te.json()),oe.ok&&o(await oe.json());const ce=R3([await Rx(te),await Rx(oe)]);y(pe=>jx(pe,ce))}catch{y(te=>jx(te,T3))}finally{window.clearTimeout(Y),O&&p(!1)}},[]),F=A.useCallback(async(O,$)=>{u($),y(null);try{const te=await(await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).json().catch(()=>null);return te!=null&&te.ok||y({text:ov(te,"command failed"),raw:ro(te)}),te}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]),j=A.useCallback(async(O,$)=>{u($),y(null);try{const te=await(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(O)})).json().catch(()=>null);return te!=null&&te.ok||y({text:Gl(te,"command failed")}),te}catch{return y({text:"server unreachable"}),null}finally{u(null)}},[]);A.useEffect(()=>(D(!0),_.current=window.setInterval(()=>D(!1),Ax),()=>{_.current!=null&&window.clearInterval(_.current)}),[D]),A.useEffect(()=>{const O=window.setInterval(()=>N(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(O)},[]);const Z=((X=i==null?void 0:i.settings["autoswitch.threshold"])==null?void 0:X.value)??"90",W=(M=n==null?void 0:n.accounts)==null?void 0:M.find(O=>O.active),ne=W!=null&&W.lanes.length?Math.max(...W.lanes.map(O=>O.pct)):null,J=ne!=null&&ne>=Number(Z)-15,U=async O=>{f(O),y(null);try{const Y=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:O})})).json().catch(()=>null);Y!=null&&Y.ok||y({text:ov(Y,"the switch failed"),raw:ro(Y)}),await D(!0)}catch{y({text:"server unreachable"})}finally{f(null)}};return m.jsxs("div",{className:"accounts-panel","aria-label":"Claude accounts",children:[m.jsxs("div",{className:"ap-header",children:[m.jsx("h3",{children:"Accounts"}),m.jsxs("div",{className:"ap-header-right",children:[m.jsx("button",{type:"button",className:"btn ap-add",onClick:()=>E(!0),title:"Sign in to another Claude account, or paste one shared from another deck",children:"+"}),m.jsx("button",{type:"button",className:"btn ap-refresh",onClick:()=>D(!0),disabled:c,"aria-label":"Reload accounts",title:"Reload from claude-swap",children:c?"…":"↻"}),m.jsx("button",{type:"button",className:"btn icon-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:"×"})]})]}),n==null?g?m.jsxs("div",{className:"ap-empty",role:"alert",children:[m.jsx("span",{title:g.raw||void 0,children:g.text}),m.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",Ax/1e3," seconds."]}),m.jsx("button",{type:"button",className:"ap-fix",disabled:c,onClick:()=>D(!0),children:c?"trying…":"try again"})]}):m.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?m.jsxs(m.Fragment,{children:[(V=n.accounts)==null?void 0:V.map(O=>m.jsxs("div",{className:`ap-account${O.active?" active":""}${O.disabled?" disabled":""}`,children:[m.jsxs("div",{className:"ap-account-head",children:[m.jsx("span",{className:"ap-num",children:O.num}),O.alias&&m.jsx("span",{className:"ap-alias",children:O.alias}),m.jsx("span",{className:"ap-email",title:O.org??void 0,children:O.email}),m.jsx("button",{type:"button",className:`ap-more${S===O.num?" on":""}`,"aria-label":`Manage account ${O.num}`,"aria-expanded":S===O.num,title:"Share, rename, move, remove",onClick:()=>{b(S===O.num?null:O.num),R(O.alias??""),L(null),P(null),B(!1)},children:"⋯"}),O.active?m.jsx("span",{className:"ap-badge-active",children:"● active"}):m.jsx("button",{type:"button",className:"btn ap-switch",disabled:h!=null||O.disabled,onClick:()=>U(O.num),title:O.disabled?"Held out of rotation":`Switch to ${O.alias??O.email}`,children:h===O.num?"…":"switch"})]}),O.lanes.length>0?O.lanes.map($=>m.jsx(O3,{lane:$,nowSec:x},$.id)):m.jsx("div",{className:"ap-hint",children:"No usage recorded yet."}),m.jsxs("div",{className:"ap-meta",children:[O.error&&(()=>{const $=P3(O.error);return m.jsxs(m.Fragment,{children:[m.jsx("span",{className:"ap-err",title:$.hint,children:$.text}),$.fixable&&m.jsx("button",{type:"button",className:"ap-fix",onClick:()=>E(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"sign in again"})]})})(),((i==null?void 0:i.enabled)||(i==null?void 0:i.external))&&!O.active&&m.jsx("button",{type:"button",className:"ap-rotate",disabled:l!=null,onClick:()=>F({action:"account",account:O.num,enabled:O.disabled},`rot-${O.num}`).then(()=>D(!0)),title:O.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",children:O.disabled?"held out":"in rotation"}),O.fetchedAt?m.jsxs("span",{className:`ap-age${O.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 ",Ix(O.fetchedAt,x),M3(O.nextAt,x)]}):m.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})]}),S===O.num&&m.jsxs("div",{className:"ap-manage",children:[m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"name"}),m.jsx("input",{className:"ap-manage-input",type:"text",value:C,onChange:$=>R($.target.value),onKeyDown:$=>{$.key==="Enter"&&j({action:"alias",account:O.num,alias:C},`alias-${O.num}`).then(()=>D(!0))},placeholder:"no alias",spellCheck:!1,"aria-label":`Alias for account ${O.num}`}),m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null||C.trim()===(O.alias??""),onClick:()=>j({action:"alias",account:O.num,alias:C},`alias-${O.num}`).then(()=>D(!0)),title:"A short name to show instead of the email",children:"save"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.jsx("span",{className:"ap-manage-label",children:"slot"}),m.jsx("span",{className:"ap-field",children:m.jsx("select",{"aria-label":`Slot for account ${O.num}`,value:String(O.num),disabled:l!=null,onChange:$=>j({action:"move",account:O.num,slot:Number($.target.value)},`move-${O.num}`).then(()=>D(!0)),children:L3(n.accounts??[]).map($=>m.jsx("option",{value:$,children:$},$))})}),m.jsx("span",{className:"ap-manage-hint",children:"rotation order"})]}),m.jsxs("div",{className:"ap-manage-row",children:[m.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()=>{B(!1);const $=await j({action:"share",account:O.num},`share-${O.num}`);$!=null&&$.ok&&P({num:O.num,blob:$.blob,expiresAt:$.expiresAt})},children:"share…"}),m.jsx("button",{type:"button",className:`ap-manage-btn danger${I===O.num?" armed":""}`,disabled:l!=null,title:I===O.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{if(I!==O.num){L(O.num),window.setTimeout(()=>L($=>$===O.num?null:$),4e3);return}L(null),j({action:"remove",account:O.num},`rm-${O.num}`).then(()=>{b(null),D(!0)})},children:I===O.num?"confirm remove":"remove"})]}),(H==null?void 0:H.num)===O.num&&(()=>{const $=$3(H.expiresAt,x),Y=$.tone==="gone";return m.jsxs("div",{className:`ap-share${Y?" expired":""}`,children:[m.jsx("code",{className:"ap-share-blob",children:H.blob}),m.jsxs("div",{className:"ap-share-foot",children:[m.jsx("button",{type:"button",className:"ap-manage-btn",disabled:l!=null,onClick:async()=>{if(Y){B(!1);const te=await j({action:"share",account:O.num},`share-${O.num}`);te!=null&&te.ok&&P({num:O.num,blob:te.blob,expiresAt:te.expiresAt});return}await q3(H.blob)&&(B(!0),window.setTimeout(()=>B(!1),1800))},children:Y?"make a new share":q?"copied":"copy"}),m.jsxs("span",{className:"ap-manage-hint",children:["carries a live login · ",m.jsx("span",{className:`ap-share-expiry ${$.tone}`,children:$.text})]})]})]})})()]})]},O.num)),(i==null?void 0:i.ok)&&m.jsxs("div",{className:"ap-auto",children:[m.jsxs("div",{className:"ap-auto-head",children:[m.jsx("span",{className:"ap-auto-title",children:"Auto-switch"}),m.jsxs("span",{className:"ap-auto-ctl",children:[ne!=null&&m.jsxs("span",{className:`ap-auto-now${J?" near":""}`,children:[Math.round(ne),"%"]}),m.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:m.jsx("select",{"aria-label":"Switch threshold",value:Z,disabled:l!=null,onChange:O=>F({action:"setting",key:"autoswitch.threshold",value:O.target.value},"threshold").then(()=>D(!0)),children:A3.map(O=>m.jsxs("option",{value:O,children:[O,"%"]},O))})}),m.jsxs("button",{type:"button",className:`ap-auto-state${i.enabled?" live":""}`,role:"switch","aria-checked":i.enabled,disabled:l!=null,onClick:()=>F({action:"enable",enabled:!i.enabled},"enable").then(()=>D(!0)),title:i.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:[m.jsx("i",{className:i.enabled?"ap-pulse":"ap-dot","aria-hidden":!0}),i.enabled?"on":"off"]})]})]}),i.external&&m.jsxs("p",{className:"ap-auto-note",children:[m.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",m.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",i.enabled?" — this toggle takes over when you stop it.":"."]}),i.lastTick&&m.jsx("div",{className:"ap-auto-foot",children:m.jsxs("span",{className:"ap-auto-result",children:["checked ",Ix(i.lastTick.at,x)]})})]}),g&&m.jsxs("div",{className:"ap-failure",role:"alert",children:[m.jsx("span",{className:"ap-failure-text",title:g.raw||void 0,children:g.text}),m.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>y(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),m.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."})]}):m.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"claude-swap isn't installed."}),m.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&&m.jsx("code",{className:"ap-cmd",children:n.hint}),m.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",m.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"No accounts added yet."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",m.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):m.jsxs(m.Fragment,{children:[m.jsx("span",{children:"Couldn't read the account store."}),m.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})}),k&&m.jsx(C3,{onClose:()=>E(!1),onChanged:()=>D(!0)})]})}const F3=3e4;function z3({bundle:e,running:n,lastTried:r}){return!n||e===n?!1:r!==n}function B3({bundle:e,running:n,pending:r,lastTried:i}){return n?z3({bundle:e,running:n,lastTried:i})?"reload":r==null||r&&r!==n?"wait":"confirm":"wait"}function U3(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function H3({asked:e,reported:n}){return n?n!==e:!1}function W3(e){const n=e.thresholdMs??F3;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 V3(e){return e.ctrlKey||e.metaKey||e.altKey}const G3=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),Y3=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),K3=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function YN(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function KN(e){if(!e)return!1;if(e.isContentEditable)return!0;const n=YN(e);return n==="TEXTAREA"?!0:n!=="INPUT"?!1:!G3.has(String(e.type??"text").toLowerCase())}function X3(e){if(!e)return!1;if(KN(e)||Y3.has(YN(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>K3.has(r))}function Q3({agentCount:e,onConfirm:n,onCancel:r}){const i=A.useRef(null);io(r,{focusRef:i,layer:ZP});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 m.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:m.jsxs("div",{className:"modal clear-confirm",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[m.jsxs("header",{className:"modal-head",children:[m.jsxs("div",{className:"modal-title",children:[m.jsx("span",{className:"status-dot err","aria-hidden":!0}),m.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),m.jsx("div",{className:"modal-actions",children:m.jsx("button",{type:"button",className:"btn icon-btn",onClick:r,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),m.jsxs("section",{className:"modal-body",children:[m.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."]}),m.jsxs("div",{className:"cc-actions",children:[m.jsx("button",{type:"button",ref:i,className:"btn",onClick:r,children:"Cancel"}),m.jsx("button",{type:"button",className:"btn danger",onClick:n,children:"Clear everything"})]})]})]})})}function Z3(e,n){return e==="confirmation"?n.confirmOpen?"clear":"ignore":n.modalOpen||n.confirmOpen?"ignore":"confirm"}function $l(e,n){if(n.size!==0)for(const r of Array.from(e.keys()))n.has(r)||e.delete(r)}function J3(e){const n=new Set;for(const r of e)n.add(r.id),n.add(`group:${r.sessionId}`);return n}function XN(e,n,r){return!n.has(e)||r.has(e)}function eL(e,n,r,i){return!n.has(e)&&XN(e,r,i)}function tL(e,n,r){const i={x:0,y:0};return n.set(e,i),r.add(e),i}function nL(e,n,r,i){r.set(e,n),i.delete(e)}const rL=40,sL=120;function iL(e,n){let r=null,i=0,o=Number.NEGATIVE_INFINITY;const l=()=>{r=null,o=n.now(),e()},u=()=>{r!=null&&(n.clearTimeout(r),r=null)},c=(p,h,f)=>{if(r!=null){if(i<=p)return;u()}const g=Math.min(f,Math.max(0,p-h));i=p,r=n.setTimeout(l,g)};return{live(p=rL){const h=n.now(),f=Math.max(o+p,h);if(f<=h){u(),l();return}c(f,h,p)},replay(p=sL){u(),i=n.now()+p,r=n.setTimeout(l,p)},flush(){u(),l()},cancel(){u()}}}function oL(){let e=!1,n=[];return{get paused(){return e},get size(){return n.length},accept(r){return e?(n.push(r),!1):!0},setPaused(r){if(e=r,r||n.length===0)return[];const i=n;return n=[],i}}}const aL="1",Mx="agent-dag.schema",lL=["agent-dag.layout","agent-dag.viewport"];function QN(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function uL(e,n=aL){let r=null;try{r=e.getItem(Mx)}catch{return[]}if(r===n)return[];const i=[];if(r!==null)for(const o of lL)try{e.getItem(o)!==null&&(e.removeItem(o),i.push(o))}catch{}try{e.setItem(Mx,n)}catch{}return i}function cL(){let e=0;return{begin(){const n=++e;return()=>n===e},cancel(){e++}}}function dL(e,n=new Date){return new Date(Date.UTC(n.getFullYear(),n.getMonth(),n.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}function fL(e){return!e.answer||e.answer.range!==e.want?{phase:"busy",stale:!1}:e.answer.ok?{phase:e.answer.days>0?"chart":"empty",stale:e.loading}:{phase:"error",stale:e.loading}}function Vs(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 Dl(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 hL=[7,14,30,90];function pL(e){const[n,r]=A.useState(null),[i,o]=A.useState(!1),l=A.useRef(cL()).current,u=(c=!1)=>{const p=l.begin(),h=e;o(!0);const g=`/api/ccusage?since=${dL(h)}${c?"&refresh=1":""}`;fetch(g).then(y=>y.json()).then(y=>{p()&&r({range:h,resp:y})}).catch(()=>{p()&&r({range:h,resp:{ok:!1,reason:"unreachable"}})}).finally(()=>{p()&&o(!1)})};return A.useEffect(()=>(u(!1),()=>l.cancel()),[e]),{landed:n,loading:i,reload:()=>u(!0)}}function mL({onClose:e}){var k,E,C;const[n,r]=A.useState(30),[i,o]=A.useState(null),{landed:l,loading:u,reload:c}=pL(n);io(e);const p=fL({loading:u,want:n,answer:l&&{range:l.range,ok:l.resp.ok===!0,days:((k=l.resp.days)==null?void 0:k.length)??0}}),h=p.phase==="chart"?l.resp.days??[]:[],f=A.useMemo(()=>h.reduce((R,I)=>Math.max(R,I.totalCost),0),[h]),{totalCost:g,totalTok:y,inOut:x,cacheRead:N,modelCosts:_}=A.useMemo(()=>{let R=0,I=0,L=0,H=0;const P=new Map;for(const q of h){R+=q.totalCost,I+=q.totalTokens,L+=q.inputTokens+q.outputTokens,H+=q.cacheReadTokens;for(const B of q.modelBreakdowns)P.set(B.modelName,(P.get(B.modelName)??0)+B.cost)}return{totalCost:R,totalTok:I,inOut:L,cacheRead:H,modelCosts:P}},[h]),S=A.useMemo(()=>Array.from(_.entries()).sort((R,I)=>I[1]-R[1]),[_]),b=i?h.find(R=>R.period===i)??null:null;return m.jsx("div",{className:"uh-backdrop",onClick:e,role:"presentation",children:m.jsxs("div",{className:"uh-modal",onClick:R=>R.stopPropagation(),role:"dialog","aria-label":"Usage history",children:[m.jsxs("header",{className:"uh-head",children:[m.jsxs("div",{className:"uh-titlewrap",children:[m.jsx("div",{className:"uh-title",children:"Usage history"}),m.jsx("div",{className:"uh-sub",children:"via ccusage · local Claude / Codex logs"})]}),m.jsx("div",{className:"uh-range",role:"tablist","aria-label":"Range",children:hL.map(R=>m.jsxs("button",{role:"tab","aria-selected":n===R,className:`uh-range-btn${n===R?" on":""}`,onClick:()=>{r(R),o(null)},children:[R,"d"]},R))}),m.jsx("button",{className:"btn icon-btn uh-reload",onClick:c,disabled:u,title:"Re-run ccusage","aria-label":"Reload",children:u?"…":"↻"}),m.jsx("button",{className:"uh-close",onClick:e,"aria-label":"Close",children:"×"})]}),p.phase==="busy"?m.jsx("div",{className:"uh-status","aria-busy":"true",children:l?"running ccusage…":"running ccusage… (first run downloads the package)"}):p.phase==="error"?m.jsxs("div",{className:"uh-status uh-err",title:ro(l.resp)||void 0,children:[E3(l.resp,"ccusage did not report usage"),m.jsx("div",{children:m.jsx("button",{className:"btn uh-retry",onClick:c,disabled:u,children:u?"trying…":"Try again"})})]}):p.phase==="empty"?m.jsx("div",{className:`uh-status${p.stale?" uh-stale":""}`,"aria-busy":p.stale||void 0,children:"no usage in this range"}):m.jsxs("div",{className:p.stale?"uh-stale":void 0,"aria-busy":p.stale||void 0,children:[m.jsxs("div",{className:"uh-totals",children:[m.jsx(Fl,{label:"total cost",val:ze(g),accent:!0}),m.jsx(Fl,{label:"tokens",val:Vs(y)}),m.jsx(Fl,{label:"input+output",val:Vs(x)}),m.jsx(Fl,{label:"cache reads",val:Vs(N)})]}),m.jsx("div",{className:"uh-chart",role:"img","aria-label":"Daily cost by model",children:h.map(R=>{const I=f>0?R.totalCost/f*100:0,L=R.period===i;return m.jsxs("button",{className:`uh-bar-col${L?" sel":""}`,onClick:()=>o(L?null:R.period),title:`${R.period} · ${ze(R.totalCost)}`,style:{flexBasis:`${100/h.length}%`},children:[m.jsx("div",{className:"uh-bar",style:{height:`${Math.max(I,R.totalCost>0?2:0)}%`},children:R.modelBreakdowns.slice().sort((H,P)=>P.cost-H.cost).map(H=>{const P=R.totalCost>0?H.cost/R.totalCost*100:0;return m.jsx("div",{className:"uh-bar-seg",style:{height:`${P}%`,background:Dl(H.modelName)}},H.modelName)})}),m.jsx("span",{className:"uh-bar-label",children:R.period.slice(5)})]},R.period)})}),m.jsx("div",{className:"uh-legend",children:S.map(([R,I])=>m.jsxs("span",{className:"uh-legend-item",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Dl(R)}}),ei(R)," ",m.jsx("span",{className:"uh-legend-cost",children:ze(I)})]},R))}),b&&m.jsxs("div",{className:"uh-detail",children:[m.jsxs("div",{className:"uh-detail-head",children:[m.jsx("span",{className:"uh-detail-date",children:b.period}),m.jsx("span",{className:"uh-detail-cost",children:ze(b.totalCost)}),(C=(E=b.metadata)==null?void 0:E.agents)!=null&&C.length?m.jsx("span",{className:"uh-detail-agents",children:b.metadata.agents.join(" · ")}):null]}),m.jsxs("div",{className:"uh-detail-mini",children:[m.jsx(zl,{label:"input",val:Vs(b.inputTokens)}),m.jsx(zl,{label:"output",val:Vs(b.outputTokens)}),m.jsx(zl,{label:"cache write",val:Vs(b.cacheCreationTokens)}),m.jsx(zl,{label:"cache read",val:Vs(b.cacheReadTokens)})]}),m.jsx("div",{className:"uh-detail-models",children:b.modelBreakdowns.slice().sort((R,I)=>I.cost-R.cost).map(R=>{const I=b.totalCost>0?R.cost/b.totalCost*100:0;return m.jsxs("div",{className:"uh-model-row",children:[m.jsxs("span",{className:"uh-model-name",children:[m.jsx("span",{className:"uh-legend-dot",style:{background:Dl(R.modelName)}}),ei(R.modelName)]}),m.jsx("span",{className:"uh-model-bar",children:m.jsx("span",{className:"uh-model-bar-fill",style:{width:`${I}%`,background:Dl(R.modelName)}})}),m.jsx("span",{className:"uh-model-cost",children:ze(R.cost)})]},R.modelName)})})]})]})]})})}function Fl({label:e,val:n,accent:r}){return m.jsxs("div",{className:"uh-stat",children:[m.jsx("span",{className:`uh-stat-val${r?" accent":""}`,children:n}),m.jsx("span",{className:"uh-stat-label",children:e})]})}function zl({label:e,val:n}){return m.jsxs("div",{className:"uh-ministat",children:[m.jsx("span",{className:"uh-ministat-val",children:n}),m.jsx("span",{className:"uh-ministat-label",children:e})]})}function Iv(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 _d,Px;function gL(){if(Px)return _d;Px=1;function e(){this.__data__=[],this.size=0}return _d=e,_d}var bd,Ox;function oo(){if(Ox)return bd;Ox=1;function e(n,r){return n===r||n!==n&&r!==r}return bd=e,bd}var Sd,Lx;function pu(){if(Lx)return Sd;Lx=1;var e=oo();function n(r,i){for(var o=r.length;o--;)if(e(r[o][0],i))return o;return-1}return Sd=n,Sd}var kd,qx;function vL(){if(qx)return kd;qx=1;var e=pu(),n=Array.prototype,r=n.splice;function i(o){var l=this.__data__,u=e(l,o);if(u<0)return!1;var c=l.length-1;return u==c?l.pop():r.call(l,u,1),--this.size,!0}return kd=i,kd}var Ed,$x;function yL(){if($x)return Ed;$x=1;var e=pu();function n(r){var i=this.__data__,o=e(i,r);return o<0?void 0:i[o][1]}return Ed=n,Ed}var Nd,Dx;function wL(){if(Dx)return Nd;Dx=1;var e=pu();function n(r){return e(this.__data__,r)>-1}return Nd=n,Nd}var Cd,Fx;function xL(){if(Fx)return Cd;Fx=1;var e=pu();function n(r,i){var o=this.__data__,l=e(o,r);return l<0?(++this.size,o.push([r,i])):o[l][1]=i,this}return Cd=n,Cd}var Td,zx;function mu(){if(zx)return Td;zx=1;var e=gL(),n=vL(),r=yL(),i=wL(),o=xL();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=i,l.prototype.set=o,Td=l,Td}var Rd,Bx;function _L(){if(Bx)return Rd;Bx=1;var e=mu();function n(){this.__data__=new e,this.size=0}return Rd=n,Rd}var jd,Ux;function bL(){if(Ux)return jd;Ux=1;function e(n){var r=this.__data__,i=r.delete(n);return this.size=r.size,i}return jd=e,jd}var Ad,Hx;function SL(){if(Hx)return Ad;Hx=1;function e(n){return this.__data__.get(n)}return Ad=e,Ad}var Id,Wx;function kL(){if(Wx)return Id;Wx=1;function e(n){return this.__data__.has(n)}return Id=e,Id}var Md,Vx;function ZN(){if(Vx)return Md;Vx=1;var e=typeof kl=="object"&&kl&&kl.Object===Object&&kl;return Md=e,Md}var Pd,Gx;function Zn(){if(Gx)return Pd;Gx=1;var e=ZN(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return Pd=r,Pd}var Od,Yx;function ao(){if(Yx)return Od;Yx=1;var e=Zn(),n=e.Symbol;return Od=n,Od}var Ld,Kx;function EL(){if(Kx)return Ld;Kx=1;var e=ao(),n=Object.prototype,r=n.hasOwnProperty,i=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=i.call(u);return h&&(c?u[o]=p:delete u[o]),f}return Ld=l,Ld}var qd,Xx;function NL(){if(Xx)return qd;Xx=1;var e=Object.prototype,n=e.toString;function r(i){return n.call(i)}return qd=r,qd}var $d,Qx;function ti(){if(Qx)return $d;Qx=1;var e=ao(),n=EL(),r=NL(),i="[object Null]",o="[object Undefined]",l=e?e.toStringTag:void 0;function u(c){return c==null?c===void 0?o:i:l&&l in Object(c)?n(c):r(c)}return $d=u,$d}var Dd,Zx;function Tn(){if(Zx)return Dd;Zx=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return Dd=e,Dd}var Fd,Jx;function xa(){if(Jx)return Fd;Jx=1;var e=ti(),n=Tn(),r="[object AsyncFunction]",i="[object Function]",o="[object GeneratorFunction]",l="[object Proxy]";function u(c){if(!n(c))return!1;var p=e(c);return p==i||p==o||p==r||p==l}return Fd=u,Fd}var zd,e_;function CL(){if(e_)return zd;e_=1;var e=Zn(),n=e["__core-js_shared__"];return zd=n,zd}var Bd,t_;function TL(){if(t_)return Bd;t_=1;var e=CL(),n=(function(){var i=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return i?"Symbol(src)_1."+i:""})();function r(i){return!!n&&n in i}return Bd=r,Bd}var Ud,n_;function JN(){if(n_)return Ud;n_=1;var e=Function.prototype,n=e.toString;function r(i){if(i!=null){try{return n.call(i)}catch{}try{return i+""}catch{}}return""}return Ud=r,Ud}var Hd,r_;function RL(){if(r_)return Hd;r_=1;var e=xa(),n=TL(),r=Tn(),i=JN(),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 g(y){if(!r(y)||n(y))return!1;var x=e(y)?f:l;return x.test(i(y))}return Hd=g,Hd}var Wd,s_;function jL(){if(s_)return Wd;s_=1;function e(n,r){return n==null?void 0:n[r]}return Wd=e,Wd}var Vd,i_;function ni(){if(i_)return Vd;i_=1;var e=RL(),n=jL();function r(i,o){var l=n(i,o);return e(l)?l:void 0}return Vd=r,Vd}var Gd,o_;function Mv(){if(o_)return Gd;o_=1;var e=ni(),n=Zn(),r=e(n,"Map");return Gd=r,Gd}var Yd,a_;function gu(){if(a_)return Yd;a_=1;var e=ni(),n=e(Object,"create");return Yd=n,Yd}var Kd,l_;function AL(){if(l_)return Kd;l_=1;var e=gu();function n(){this.__data__=e?e(null):{},this.size=0}return Kd=n,Kd}var Xd,u_;function IL(){if(u_)return Xd;u_=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return Xd=e,Xd}var Qd,c_;function ML(){if(c_)return Qd;c_=1;var e=gu(),n="__lodash_hash_undefined__",r=Object.prototype,i=r.hasOwnProperty;function o(l){var u=this.__data__;if(e){var c=u[l];return c===n?void 0:c}return i.call(u,l)?u[l]:void 0}return Qd=o,Qd}var Zd,d_;function PL(){if(d_)return Zd;d_=1;var e=gu(),n=Object.prototype,r=n.hasOwnProperty;function i(o){var l=this.__data__;return e?l[o]!==void 0:r.call(l,o)}return Zd=i,Zd}var Jd,f_;function OL(){if(f_)return Jd;f_=1;var e=gu(),n="__lodash_hash_undefined__";function r(i,o){var l=this.__data__;return this.size+=this.has(i)?0:1,l[i]=e&&o===void 0?n:o,this}return Jd=r,Jd}var ef,h_;function LL(){if(h_)return ef;h_=1;var e=AL(),n=IL(),r=ML(),i=PL(),o=OL();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=i,l.prototype.set=o,ef=l,ef}var tf,p_;function qL(){if(p_)return tf;p_=1;var e=LL(),n=mu(),r=Mv();function i(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return tf=i,tf}var nf,m_;function $L(){if(m_)return nf;m_=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return nf=e,nf}var rf,g_;function vu(){if(g_)return rf;g_=1;var e=$L();function n(r,i){var o=r.__data__;return e(i)?o[typeof i=="string"?"string":"hash"]:o.map}return rf=n,rf}var sf,v_;function DL(){if(v_)return sf;v_=1;var e=vu();function n(r){var i=e(this,r).delete(r);return this.size-=i?1:0,i}return sf=n,sf}var of,y_;function FL(){if(y_)return of;y_=1;var e=vu();function n(r){return e(this,r).get(r)}return of=n,of}var af,w_;function zL(){if(w_)return af;w_=1;var e=vu();function n(r){return e(this,r).has(r)}return af=n,af}var lf,x_;function BL(){if(x_)return lf;x_=1;var e=vu();function n(r,i){var o=e(this,r),l=o.size;return o.set(r,i),this.size+=o.size==l?0:1,this}return lf=n,lf}var uf,__;function Pv(){if(__)return uf;__=1;var e=qL(),n=DL(),r=FL(),i=zL(),o=BL();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=i,l.prototype.set=o,uf=l,uf}var cf,b_;function UL(){if(b_)return cf;b_=1;var e=mu(),n=Mv(),r=Pv(),i=200;function o(l,u){var c=this.__data__;if(c instanceof e){var p=c.__data__;if(!n||p.length<i-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 cf=o,cf}var df,S_;function yu(){if(S_)return df;S_=1;var e=mu(),n=_L(),r=bL(),i=SL(),o=kL(),l=UL();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=i,u.prototype.has=o,u.prototype.set=l,df=u,df}var ff,k_;function Ov(){if(k_)return ff;k_=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o&&r(n[i],i,n)!==!1;);return n}return ff=e,ff}var hf,E_;function eC(){if(E_)return hf;E_=1;var e=ni(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return hf=n,hf}var pf,N_;function wu(){if(N_)return pf;N_=1;var e=eC();function n(r,i,o){i=="__proto__"&&e?e(r,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):r[i]=o}return pf=n,pf}var mf,C_;function xu(){if(C_)return mf;C_=1;var e=wu(),n=oo(),r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c){var p=l[u];(!(i.call(l,u)&&n(p,c))||c===void 0&&!(u in l))&&e(l,u,c)}return mf=o,mf}var gf,T_;function _a(){if(T_)return gf;T_=1;var e=xu(),n=wu();function r(i,o,l,u){var c=!l;l||(l={});for(var p=-1,h=o.length;++p<h;){var f=o[p],g=u?u(l[f],i[f],f,l,i):void 0;g===void 0&&(g=i[f]),c?n(l,f,g):e(l,f,g)}return l}return gf=r,gf}var vf,R_;function HL(){if(R_)return vf;R_=1;function e(n,r){for(var i=-1,o=Array(n);++i<n;)o[i]=r(i);return o}return vf=e,vf}var yf,j_;function dr(){if(j_)return yf;j_=1;function e(n){return n!=null&&typeof n=="object"}return yf=e,yf}var wf,A_;function WL(){if(A_)return wf;A_=1;var e=ti(),n=dr(),r="[object Arguments]";function i(o){return n(o)&&e(o)==r}return wf=i,wf}var xf,I_;function ba(){if(I_)return xf;I_=1;var e=WL(),n=dr(),r=Object.prototype,i=r.hasOwnProperty,o=r.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(u){return n(u)&&i.call(u,"callee")&&!o.call(u,"callee")};return xf=l,xf}var _f,M_;function _t(){if(M_)return _f;M_=1;var e=Array.isArray;return _f=e,_f}var ta={exports:{}},bf,P_;function VL(){if(P_)return bf;P_=1;function e(){return!1}return bf=e,bf}ta.exports;var O_;function lo(){return O_||(O_=1,(function(e,n){var r=Zn(),i=VL(),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||i;e.exports=h})(ta,ta.exports)),ta.exports}var Sf,L_;function _u(){if(L_)return Sf;L_=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(i,o){var l=typeof i;return o=o??e,!!o&&(l=="number"||l!="symbol"&&n.test(i))&&i>-1&&i%1==0&&i<o}return Sf=r,Sf}var kf,q_;function Lv(){if(q_)return kf;q_=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return kf=n,kf}var Ef,$_;function GL(){if($_)return Ef;$_=1;var e=ti(),n=Lv(),r=dr(),i="[object Arguments]",o="[object Array]",l="[object Boolean]",u="[object Date]",c="[object Error]",p="[object Function]",h="[object Map]",f="[object Number]",g="[object Object]",y="[object RegExp]",x="[object Set]",N="[object String]",_="[object WeakMap]",S="[object ArrayBuffer]",b="[object DataView]",k="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",L="[object Uint8Array]",H="[object Uint8ClampedArray]",P="[object Uint16Array]",q="[object Uint32Array]",B={};B[k]=B[E]=B[C]=B[R]=B[I]=B[L]=B[H]=B[P]=B[q]=!0,B[i]=B[o]=B[S]=B[l]=B[b]=B[u]=B[c]=B[p]=B[h]=B[f]=B[g]=B[y]=B[x]=B[N]=B[_]=!1;function D(F){return r(F)&&n(F.length)&&!!B[e(F)]}return Ef=D,Ef}var Nf,D_;function bu(){if(D_)return Nf;D_=1;function e(n){return function(r){return n(r)}}return Nf=e,Nf}var na={exports:{}};na.exports;var F_;function qv(){return F_||(F_=1,(function(e,n){var r=ZN(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l&&r.process,c=(function(){try{var 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 Cf,z_;function Sa(){if(z_)return Cf;z_=1;var e=GL(),n=bu(),r=qv(),i=r&&r.isTypedArray,o=i?n(i):e;return Cf=o,Cf}var Tf,B_;function tC(){if(B_)return Tf;B_=1;var e=HL(),n=ba(),r=_t(),i=lo(),o=_u(),l=Sa(),u=Object.prototype,c=u.hasOwnProperty;function p(h,f){var g=r(h),y=!g&&n(h),x=!g&&!y&&i(h),N=!g&&!y&&!x&&l(h),_=g||y||x||N,S=_?e(h.length,String):[],b=S.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,b)))&&S.push(k);return S}return Tf=p,Tf}var Rf,U_;function Su(){if(U_)return Rf;U_=1;var e=Object.prototype;function n(r){var i=r&&r.constructor,o=typeof i=="function"&&i.prototype||e;return r===o}return Rf=n,Rf}var jf,H_;function nC(){if(H_)return jf;H_=1;function e(n,r){return function(i){return n(r(i))}}return jf=e,jf}var Af,W_;function YL(){if(W_)return Af;W_=1;var e=nC(),n=e(Object.keys,Object);return Af=n,Af}var If,V_;function $v(){if(V_)return If;V_=1;var e=Su(),n=YL(),r=Object.prototype,i=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var u=[];for(var c in Object(l))i.call(l,c)&&c!="constructor"&&u.push(c);return u}return If=o,If}var Mf,G_;function Or(){if(G_)return Mf;G_=1;var e=xa(),n=Lv();function r(i){return i!=null&&n(i.length)&&!e(i)}return Mf=r,Mf}var Pf,Y_;function ps(){if(Y_)return Pf;Y_=1;var e=tC(),n=$v(),r=Or();function i(o){return r(o)?e(o):n(o)}return Pf=i,Pf}var Of,K_;function KL(){if(K_)return Of;K_=1;var e=_a(),n=ps();function r(i,o){return i&&e(o,n(o),i)}return Of=r,Of}var Lf,X_;function XL(){if(X_)return Lf;X_=1;function e(n){var r=[];if(n!=null)for(var i in Object(n))r.push(i);return r}return Lf=e,Lf}var qf,Q_;function QL(){if(Q_)return qf;Q_=1;var e=Tn(),n=Su(),r=XL(),i=Object.prototype,o=i.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 $f,Z_;function ri(){if(Z_)return $f;Z_=1;var e=tC(),n=QL(),r=Or();function i(o){return r(o)?e(o,!0):n(o)}return $f=i,$f}var Df,J_;function ZL(){if(J_)return Df;J_=1;var e=_a(),n=ri();function r(i,o){return i&&e(o,n(o),i)}return Df=r,Df}var ra={exports:{}};ra.exports;var e1;function rC(){return e1||(e1=1,(function(e,n){var r=Zn(),i=n&&!n.nodeType&&n,o=i&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===i,u=l?r.Buffer:void 0,c=u?u.allocUnsafe:void 0;function p(h,f){if(f)return h.slice();var g=h.length,y=c?c(g):new h.constructor(g);return h.copy(y),y}e.exports=p})(ra,ra.exports)),ra.exports}var Ff,t1;function sC(){if(t1)return Ff;t1=1;function e(n,r){var i=-1,o=n.length;for(r||(r=Array(o));++i<o;)r[i]=n[i];return r}return Ff=e,Ff}var zf,n1;function iC(){if(n1)return zf;n1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=0,u=[];++i<o;){var c=n[i];r(c,i,n)&&(u[l++]=c)}return u}return zf=e,zf}var Bf,r1;function oC(){if(r1)return Bf;r1=1;function e(){return[]}return Bf=e,Bf}var Uf,s1;function Dv(){if(s1)return Uf;s1=1;var e=iC(),n=oC(),r=Object.prototype,i=r.propertyIsEnumerable,o=Object.getOwnPropertySymbols,l=o?function(u){return u==null?[]:(u=Object(u),e(o(u),function(c){return i.call(u,c)}))}:n;return Uf=l,Uf}var Hf,i1;function JL(){if(i1)return Hf;i1=1;var e=_a(),n=Dv();function r(i,o){return e(i,n(i),o)}return Hf=r,Hf}var Wf,o1;function Fv(){if(o1)return Wf;o1=1;function e(n,r){for(var i=-1,o=r.length,l=n.length;++i<o;)n[l+i]=r[i];return n}return Wf=e,Wf}var Vf,a1;function ku(){if(a1)return Vf;a1=1;var e=nC(),n=e(Object.getPrototypeOf,Object);return Vf=n,Vf}var Gf,l1;function aC(){if(l1)return Gf;l1=1;var e=Fv(),n=ku(),r=Dv(),i=oC(),o=Object.getOwnPropertySymbols,l=o?function(u){for(var c=[];u;)e(c,r(u)),u=n(u);return c}:i;return Gf=l,Gf}var Yf,u1;function eq(){if(u1)return Yf;u1=1;var e=_a(),n=aC();function r(i,o){return e(i,n(i),o)}return Yf=r,Yf}var Kf,c1;function lC(){if(c1)return Kf;c1=1;var e=Fv(),n=_t();function r(i,o,l){var u=o(i);return n(i)?u:e(u,l(i))}return Kf=r,Kf}var Xf,d1;function uC(){if(d1)return Xf;d1=1;var e=lC(),n=Dv(),r=ps();function i(o){return e(o,r,n)}return Xf=i,Xf}var Qf,f1;function tq(){if(f1)return Qf;f1=1;var e=lC(),n=aC(),r=ri();function i(o){return e(o,r,n)}return Qf=i,Qf}var Zf,h1;function nq(){if(h1)return Zf;h1=1;var e=ni(),n=Zn(),r=e(n,"DataView");return Zf=r,Zf}var Jf,p1;function rq(){if(p1)return Jf;p1=1;var e=ni(),n=Zn(),r=e(n,"Promise");return Jf=r,Jf}var eh,m1;function cC(){if(m1)return eh;m1=1;var e=ni(),n=Zn(),r=e(n,"Set");return eh=r,eh}var th,g1;function sq(){if(g1)return th;g1=1;var e=ni(),n=Zn(),r=e(n,"WeakMap");return th=r,th}var nh,v1;function uo(){if(v1)return nh;v1=1;var e=nq(),n=Mv(),r=rq(),i=cC(),o=sq(),l=ti(),u=JN(),c="[object Map]",p="[object Object]",h="[object Promise]",f="[object Set]",g="[object WeakMap]",y="[object DataView]",x=u(e),N=u(n),_=u(r),S=u(i),b=u(o),k=l;return(e&&k(new e(new ArrayBuffer(1)))!=y||n&&k(new n)!=c||r&&k(r.resolve())!=h||i&&k(new i)!=f||o&&k(new o)!=g)&&(k=function(E){var C=l(E),R=C==p?E.constructor:void 0,I=R?u(R):"";if(I)switch(I){case x:return y;case N:return c;case _:return h;case S:return f;case b:return g}return C}),nh=k,nh}var rh,y1;function iq(){if(y1)return rh;y1=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i){var o=i.length,l=new i.constructor(o);return o&&typeof i[0]=="string"&&n.call(i,"index")&&(l.index=i.index,l.input=i.input),l}return rh=r,rh}var sh,w1;function dC(){if(w1)return sh;w1=1;var e=Zn(),n=e.Uint8Array;return sh=n,sh}var ih,x1;function zv(){if(x1)return ih;x1=1;var e=dC();function n(r){var i=new r.constructor(r.byteLength);return new e(i).set(new e(r)),i}return ih=n,ih}var oh,_1;function oq(){if(_1)return oh;_1=1;var e=zv();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.byteLength)}return oh=n,oh}var ah,b1;function aq(){if(b1)return ah;b1=1;var e=/\w*$/;function n(r){var i=new r.constructor(r.source,e.exec(r));return i.lastIndex=r.lastIndex,i}return ah=n,ah}var lh,S1;function lq(){if(S1)return lh;S1=1;var e=ao(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function i(o){return r?Object(r.call(o)):{}}return lh=i,lh}var uh,k1;function fC(){if(k1)return uh;k1=1;var e=zv();function n(r,i){var o=i?e(r.buffer):r.buffer;return new r.constructor(o,r.byteOffset,r.length)}return uh=n,uh}var ch,E1;function uq(){if(E1)return ch;E1=1;var e=zv(),n=oq(),r=aq(),i=lq(),o=fC(),l="[object Boolean]",u="[object Date]",c="[object Map]",p="[object Number]",h="[object RegExp]",f="[object Set]",g="[object String]",y="[object Symbol]",x="[object ArrayBuffer]",N="[object DataView]",_="[object Float32Array]",S="[object Float64Array]",b="[object Int8Array]",k="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",L="[object Uint32Array]";function H(P,q,B){var D=P.constructor;switch(q){case x:return e(P);case l:case u:return new D(+P);case N:return n(P,B);case _:case S:case b:case k:case E:case C:case R:case I:case L:return o(P,B);case c:return new D;case p:case g:return new D(P);case h:return r(P);case f:return new D;case y:return i(P)}}return ch=H,ch}var dh,N1;function hC(){if(N1)return dh;N1=1;var e=Tn(),n=Object.create,r=(function(){function i(){}return function(o){if(!e(o))return{};if(n)return n(o);i.prototype=o;var l=new i;return i.prototype=void 0,l}})();return dh=r,dh}var fh,C1;function pC(){if(C1)return fh;C1=1;var e=hC(),n=ku(),r=Su();function i(o){return typeof o.constructor=="function"&&!r(o)?e(n(o)):{}}return fh=i,fh}var hh,T1;function cq(){if(T1)return hh;T1=1;var e=uo(),n=dr(),r="[object Map]";function i(o){return n(o)&&e(o)==r}return hh=i,hh}var ph,R1;function dq(){if(R1)return ph;R1=1;var e=cq(),n=bu(),r=qv(),i=r&&r.isMap,o=i?n(i):e;return ph=o,ph}var mh,j1;function fq(){if(j1)return mh;j1=1;var e=uo(),n=dr(),r="[object Set]";function i(o){return n(o)&&e(o)==r}return mh=i,mh}var gh,A1;function hq(){if(A1)return gh;A1=1;var e=fq(),n=bu(),r=qv(),i=r&&r.isSet,o=i?n(i):e;return gh=o,gh}var vh,I1;function mC(){if(I1)return vh;I1=1;var e=yu(),n=Ov(),r=xu(),i=KL(),o=ZL(),l=rC(),u=sC(),c=JL(),p=eq(),h=uC(),f=tq(),g=uo(),y=iq(),x=uq(),N=pC(),_=_t(),S=lo(),b=dq(),k=Tn(),E=hq(),C=ps(),R=ri(),I=1,L=2,H=4,P="[object Arguments]",q="[object Array]",B="[object Boolean]",D="[object Date]",F="[object Error]",j="[object Function]",Z="[object GeneratorFunction]",W="[object Map]",ne="[object Number]",J="[object Object]",U="[object RegExp]",X="[object Set]",M="[object String]",V="[object Symbol]",O="[object WeakMap]",$="[object ArrayBuffer]",Y="[object DataView]",te="[object Float32Array]",oe="[object Float64Array]",ce="[object Int8Array]",pe="[object Int16Array]",ve="[object Int32Array]",Pe="[object Uint8Array]",Me="[object Uint8ClampedArray]",Oe="[object Uint16Array]",ye="[object Uint32Array]",Se={};Se[P]=Se[q]=Se[$]=Se[Y]=Se[B]=Se[D]=Se[te]=Se[oe]=Se[ce]=Se[pe]=Se[ve]=Se[W]=Se[ne]=Se[J]=Se[U]=Se[X]=Se[M]=Se[V]=Se[Pe]=Se[Me]=Se[Oe]=Se[ye]=!0,Se[F]=Se[j]=Se[O]=!1;function Ye(we,ge,Fe,pt,mt,Ze){var De,Qe=ge&I,at=ge&L,Mt=ge&H;if(Fe&&(De=mt?Fe(we,pt,mt,Ze):Fe(we)),De!==void 0)return De;if(!k(we))return we;var rt=_(we);if(rt){if(De=y(we),!Qe)return u(we,De)}else{var gt=g(we),Kt=gt==j||gt==Z;if(S(we))return l(we,Qe);if(gt==J||gt==P||Kt&&!mt){if(De=at||Kt?{}:N(we),!Qe)return at?p(we,o(De,we)):c(we,i(De,we))}else{if(!Se[gt])return mt?we:{};De=x(we,gt,Qe)}}Ze||(Ze=new e);var Pt=Ze.get(we);if(Pt)return Pt;Ze.set(we,De),E(we)?we.forEach(function(dt){De.add(Ye(dt,ge,Fe,dt,we,Ze))}):b(we)&&we.forEach(function(dt,lt){De.set(lt,Ye(dt,ge,Fe,lt,we,Ze))});var Ge=Mt?at?f:h:at?R:C,Nt=rt?void 0:Ge(we);return n(Nt||we,function(dt,lt){Nt&&(lt=dt,dt=we[lt]),r(De,lt,Ye(dt,ge,Fe,lt,we,Ze))}),De}return vh=Ye,vh}var yh,M1;function pq(){if(M1)return yh;M1=1;var e=mC(),n=4;function r(i){return e(i,n)}return yh=r,yh}var wh,P1;function Bv(){if(P1)return wh;P1=1;function e(n){return function(){return n}}return wh=e,wh}var xh,O1;function mq(){if(O1)return xh;O1=1;function e(n){return function(r,i,o){for(var l=-1,u=Object(r),c=o(r),p=c.length;p--;){var h=c[n?p:++l];if(i(u[h],h,u)===!1)break}return r}}return xh=e,xh}var _h,L1;function Uv(){if(L1)return _h;L1=1;var e=mq(),n=e();return _h=n,_h}var bh,q1;function Hv(){if(q1)return bh;q1=1;var e=Uv(),n=ps();function r(i,o){return i&&e(i,o,n)}return bh=r,bh}var Sh,$1;function gq(){if($1)return Sh;$1=1;var e=Or();function n(r,i){return function(o,l){if(o==null)return o;if(!e(o))return r(o,l);for(var u=o.length,c=i?u:-1,p=Object(o);(i?c--:++c<u)&&l(p[c],c,p)!==!1;);return o}}return Sh=n,Sh}var kh,D1;function Eu(){if(D1)return kh;D1=1;var e=Hv(),n=gq(),r=n(e);return kh=r,kh}var Eh,F1;function si(){if(F1)return Eh;F1=1;function e(n){return n}return Eh=e,Eh}var Nh,z1;function gC(){if(z1)return Nh;z1=1;var e=si();function n(r){return typeof r=="function"?r:e}return Nh=n,Nh}var Ch,B1;function vC(){if(B1)return Ch;B1=1;var e=Ov(),n=Eu(),r=gC(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u))}return Ch=o,Ch}var Th,U1;function yC(){return U1||(U1=1,Th=vC()),Th}var Rh,H1;function vq(){if(H1)return Rh;H1=1;var e=Eu();function n(r,i){var o=[];return e(r,function(l,u,c){i(l,u,c)&&o.push(l)}),o}return Rh=n,Rh}var jh,W1;function yq(){if(W1)return jh;W1=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return jh=n,jh}var Ah,V1;function wq(){if(V1)return Ah;V1=1;function e(n){return this.__data__.has(n)}return Ah=e,Ah}var Ih,G1;function wC(){if(G1)return Ih;G1=1;var e=Pv(),n=yq(),r=wq();function i(o){var l=-1,u=o==null?0:o.length;for(this.__data__=new e;++l<u;)this.add(o[l])}return i.prototype.add=i.prototype.push=n,i.prototype.has=r,Ih=i,Ih}var Mh,Y1;function xq(){if(Y1)return Mh;Y1=1;function e(n,r){for(var i=-1,o=n==null?0:n.length;++i<o;)if(r(n[i],i,n))return!0;return!1}return Mh=e,Mh}var Ph,K1;function xC(){if(K1)return Ph;K1=1;function e(n,r){return n.has(r)}return Ph=e,Ph}var Oh,X1;function _C(){if(X1)return Oh;X1=1;var e=wC(),n=xq(),r=xC(),i=1,o=2;function l(u,c,p,h,f,g){var y=p&i,x=u.length,N=c.length;if(x!=N&&!(y&&N>x))return!1;var _=g.get(u),S=g.get(c);if(_&&S)return _==c&&S==u;var b=-1,k=!0,E=p&o?new e:void 0;for(g.set(u,c),g.set(c,u);++b<x;){var C=u[b],R=c[b];if(h)var I=y?h(R,C,b,c,u,g):h(C,R,b,u,c,g);if(I!==void 0){if(I)continue;k=!1;break}if(E){if(!n(c,function(L,H){if(!r(E,H)&&(C===L||f(C,L,p,h,g)))return E.push(H)})){k=!1;break}}else if(!(C===R||f(C,R,p,h,g))){k=!1;break}}return g.delete(u),g.delete(c),k}return Oh=l,Oh}var Lh,Q1;function _q(){if(Q1)return Lh;Q1=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o,l){i[++r]=[l,o]}),i}return Lh=e,Lh}var qh,Z1;function Wv(){if(Z1)return qh;Z1=1;function e(n){var r=-1,i=Array(n.size);return n.forEach(function(o){i[++r]=o}),i}return qh=e,qh}var $h,J1;function bq(){if(J1)return $h;J1=1;var e=ao(),n=dC(),r=oo(),i=_C(),o=_q(),l=Wv(),u=1,c=2,p="[object Boolean]",h="[object Date]",f="[object Error]",g="[object Map]",y="[object Number]",x="[object RegExp]",N="[object Set]",_="[object String]",S="[object Symbol]",b="[object ArrayBuffer]",k="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,L,H,P,q,B,D){switch(H){case k:if(I.byteLength!=L.byteLength||I.byteOffset!=L.byteOffset)return!1;I=I.buffer,L=L.buffer;case b:return!(I.byteLength!=L.byteLength||!B(new n(I),new n(L)));case p:case h:case y:return r(+I,+L);case f:return I.name==L.name&&I.message==L.message;case x:case _:return I==L+"";case g:var F=o;case N:var j=P&u;if(F||(F=l),I.size!=L.size&&!j)return!1;var Z=D.get(I);if(Z)return Z==L;P|=c,D.set(I,L);var W=i(F(I),F(L),P,q,B,D);return D.delete(I),W;case S:if(C)return C.call(I)==C.call(L)}return!1}return $h=R,$h}var Dh,eb;function Sq(){if(eb)return Dh;eb=1;var e=uC(),n=1,r=Object.prototype,i=r.hasOwnProperty;function o(l,u,c,p,h,f){var g=c&n,y=e(l),x=y.length,N=e(u),_=N.length;if(x!=_&&!g)return!1;for(var S=x;S--;){var b=y[S];if(!(g?b in u:i.call(u,b)))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 R=g;++S<x;){b=y[S];var I=l[b],L=u[b];if(p)var H=g?p(L,I,b,u,l,f):p(I,L,b,l,u,f);if(!(H===void 0?I===L||h(I,L,c,p,f):H)){C=!1;break}R||(R=b=="constructor")}if(C&&!R){var P=l.constructor,q=u.constructor;P!=q&&"constructor"in l&&"constructor"in u&&!(typeof P=="function"&&P instanceof P&&typeof q=="function"&&q instanceof q)&&(C=!1)}return f.delete(l),f.delete(u),C}return Dh=o,Dh}var Fh,tb;function kq(){if(tb)return Fh;tb=1;var e=yu(),n=_C(),r=bq(),i=Sq(),o=uo(),l=_t(),u=lo(),c=Sa(),p=1,h="[object Arguments]",f="[object Array]",g="[object Object]",y=Object.prototype,x=y.hasOwnProperty;function N(_,S,b,k,E,C){var R=l(_),I=l(S),L=R?f:o(_),H=I?f:o(S);L=L==h?g:L,H=H==h?g:H;var P=L==g,q=H==g,B=L==H;if(B&&u(_)){if(!u(S))return!1;R=!0,P=!1}if(B&&!P)return C||(C=new e),R||c(_)?n(_,S,b,k,E,C):r(_,S,L,b,k,E,C);if(!(b&p)){var D=P&&x.call(_,"__wrapped__"),F=q&&x.call(S,"__wrapped__");if(D||F){var j=D?_.value():_,Z=F?S.value():S;return C||(C=new e),E(j,Z,b,k,C)}}return B?(C||(C=new e),i(_,S,b,k,E,C)):!1}return Fh=N,Fh}var zh,nb;function bC(){if(nb)return zh;nb=1;var e=kq(),n=dr();function r(i,o,l,u,c){return i===o?!0:i==null||o==null||!n(i)&&!n(o)?i!==i&&o!==o:e(i,o,l,u,r,c)}return zh=r,zh}var Bh,rb;function Eq(){if(rb)return Bh;rb=1;var e=yu(),n=bC(),r=1,i=2;function o(l,u,c,p){var h=c.length,f=h,g=!p;if(l==null)return!f;for(l=Object(l);h--;){var y=c[h];if(g&&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(g&&y[2]){if(N===void 0&&!(x in l))return!1}else{var S=new e;if(p)var b=p(N,_,x,l,u,S);if(!(b===void 0?n(_,N,r|i,p,S):b))return!1}}return!0}return Bh=o,Bh}var Uh,sb;function SC(){if(sb)return Uh;sb=1;var e=Tn();function n(r){return r===r&&!e(r)}return Uh=n,Uh}var Hh,ib;function Nq(){if(ib)return Hh;ib=1;var e=SC(),n=ps();function r(i){for(var o=n(i),l=o.length;l--;){var u=o[l],c=i[u];o[l]=[u,c,e(c)]}return o}return Hh=r,Hh}var Wh,ob;function kC(){if(ob)return Wh;ob=1;function e(n,r){return function(i){return i==null?!1:i[n]===r&&(r!==void 0||n in Object(i))}}return Wh=e,Wh}var Vh,ab;function Cq(){if(ab)return Vh;ab=1;var e=Eq(),n=Nq(),r=kC();function i(o){var l=n(o);return l.length==1&&l[0][2]?r(l[0][0],l[0][1]):function(u){return u===o||e(u,o,l)}}return Vh=i,Vh}var Gh,lb;function co(){if(lb)return Gh;lb=1;var e=ti(),n=dr(),r="[object Symbol]";function i(o){return typeof o=="symbol"||n(o)&&e(o)==r}return Gh=i,Gh}var Yh,ub;function Vv(){if(ub)return Yh;ub=1;var e=_t(),n=co(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;function o(l,u){if(e(l))return!1;var c=typeof l;return c=="number"||c=="symbol"||c=="boolean"||l==null||n(l)?!0:i.test(l)||!r.test(l)||u!=null&&l in Object(u)}return Yh=o,Yh}var Kh,cb;function Tq(){if(cb)return Kh;cb=1;var e=Pv(),n="Expected a function";function r(i,o){if(typeof i!="function"||o!=null&&typeof o!="function")throw new TypeError(n);var l=function(){var u=arguments,c=o?o.apply(this,u):u[0],p=l.cache;if(p.has(c))return p.get(c);var h=i.apply(this,u);return l.cache=p.set(c,h)||p,h};return l.cache=new(r.Cache||e),l}return r.Cache=e,Kh=r,Kh}var Xh,db;function Rq(){if(db)return Xh;db=1;var e=Tq(),n=500;function r(i){var o=e(i,function(u){return l.size===n&&l.clear(),u}),l=o.cache;return o}return Xh=r,Xh}var Qh,fb;function jq(){if(fb)return Qh;fb=1;var e=Rq(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,i=e(function(o){var l=[];return o.charCodeAt(0)===46&&l.push(""),o.replace(n,function(u,c,p,h){l.push(p?h.replace(r,"$1"):c||u)}),l});return Qh=i,Qh}var Zh,hb;function Nu(){if(hb)return Zh;hb=1;function e(n,r){for(var i=-1,o=n==null?0:n.length,l=Array(o);++i<o;)l[i]=r(n[i],i,n);return l}return Zh=e,Zh}var Jh,pb;function Aq(){if(pb)return Jh;pb=1;var e=ao(),n=Nu(),r=_t(),i=co(),o=e?e.prototype:void 0,l=o?o.toString:void 0;function u(c){if(typeof c=="string")return c;if(r(c))return n(c,u)+"";if(i(c))return l?l.call(c):"";var p=c+"";return p=="0"&&1/c==-1/0?"-0":p}return Jh=u,Jh}var ep,mb;function EC(){if(mb)return ep;mb=1;var e=Aq();function n(r){return r==null?"":e(r)}return ep=n,ep}var tp,gb;function Cu(){if(gb)return tp;gb=1;var e=_t(),n=Vv(),r=jq(),i=EC();function o(l,u){return e(l)?l:n(l,u)?[l]:r(i(l))}return tp=o,tp}var np,vb;function ka(){if(vb)return np;vb=1;var e=co();function n(r){if(typeof r=="string"||e(r))return r;var i=r+"";return i=="0"&&1/r==-1/0?"-0":i}return np=n,np}var rp,yb;function Tu(){if(yb)return rp;yb=1;var e=Cu(),n=ka();function r(i,o){o=e(o,i);for(var l=0,u=o.length;i!=null&&l<u;)i=i[n(o[l++])];return l&&l==u?i:void 0}return rp=r,rp}var sp,wb;function Iq(){if(wb)return sp;wb=1;var e=Tu();function n(r,i,o){var l=r==null?void 0:e(r,i);return l===void 0?o:l}return sp=n,sp}var ip,xb;function Mq(){if(xb)return ip;xb=1;function e(n,r){return n!=null&&r in Object(n)}return ip=e,ip}var op,_b;function NC(){if(_b)return op;_b=1;var e=Cu(),n=ba(),r=_t(),i=_u(),o=Lv(),l=ka();function u(c,p,h){p=e(p,c);for(var f=-1,g=p.length,y=!1;++f<g;){var x=l(p[f]);if(!(y=c!=null&&h(c,x)))break;c=c[x]}return y||++f!=g?y:(g=c==null?0:c.length,!!g&&o(g)&&i(x,g)&&(r(c)||n(c)))}return op=u,op}var ap,bb;function CC(){if(bb)return ap;bb=1;var e=Mq(),n=NC();function r(i,o){return i!=null&&n(i,o,e)}return ap=r,ap}var lp,Sb;function Pq(){if(Sb)return lp;Sb=1;var e=bC(),n=Iq(),r=CC(),i=Vv(),o=SC(),l=kC(),u=ka(),c=1,p=2;function h(f,g){return i(f)&&o(g)?l(u(f),g):function(y){var x=n(y,f);return x===void 0&&x===g?r(y,f):e(g,x,c|p)}}return lp=h,lp}var up,kb;function TC(){if(kb)return up;kb=1;function e(n){return function(r){return r==null?void 0:r[n]}}return up=e,up}var cp,Eb;function Oq(){if(Eb)return cp;Eb=1;var e=Tu();function n(r){return function(i){return e(i,r)}}return cp=n,cp}var dp,Nb;function Lq(){if(Nb)return dp;Nb=1;var e=TC(),n=Oq(),r=Vv(),i=ka();function o(l){return r(l)?e(i(l)):n(l)}return dp=o,dp}var fp,Cb;function Lr(){if(Cb)return fp;Cb=1;var e=Cq(),n=Pq(),r=si(),i=_t(),o=Lq();function l(u){return typeof u=="function"?u:u==null?r:typeof u=="object"?i(u)?n(u[0],u[1]):e(u):o(u)}return fp=l,fp}var hp,Tb;function RC(){if(Tb)return hp;Tb=1;var e=iC(),n=vq(),r=Lr(),i=_t();function o(l,u){var c=i(l)?e:n;return c(l,r(u,3))}return hp=o,hp}var pp,Rb;function qq(){if(Rb)return pp;Rb=1;var e=Object.prototype,n=e.hasOwnProperty;function r(i,o){return i!=null&&n.call(i,o)}return pp=r,pp}var mp,jb;function jC(){if(jb)return mp;jb=1;var e=qq(),n=NC();function r(i,o){return i!=null&&n(i,o,e)}return mp=r,mp}var gp,Ab;function $q(){if(Ab)return gp;Ab=1;var e=$v(),n=uo(),r=ba(),i=_t(),o=Or(),l=lo(),u=Su(),c=Sa(),p="[object Map]",h="[object Set]",f=Object.prototype,g=f.hasOwnProperty;function y(x){if(x==null)return!0;if(o(x)&&(i(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(g.call(x,_))return!1;return!0}return gp=y,gp}var vp,Ib;function AC(){if(Ib)return vp;Ib=1;function e(n){return n===void 0}return vp=e,vp}var yp,Mb;function IC(){if(Mb)return yp;Mb=1;var e=Eu(),n=Or();function r(i,o){var l=-1,u=n(i)?Array(i.length):[];return e(i,function(c,p,h){u[++l]=o(c,p,h)}),u}return yp=r,yp}var wp,Pb;function MC(){if(Pb)return wp;Pb=1;var e=Nu(),n=Lr(),r=IC(),i=_t();function o(l,u){var c=i(l)?e:r;return c(l,n(u,3))}return wp=o,wp}var xp,Ob;function Dq(){if(Ob)return xp;Ob=1;function e(n,r,i,o){var l=-1,u=n==null?0:n.length;for(o&&u&&(i=n[++l]);++l<u;)i=r(i,n[l],l,n);return i}return xp=e,xp}var _p,Lb;function Fq(){if(Lb)return _p;Lb=1;function e(n,r,i,o,l){return l(n,function(u,c,p){i=o?(o=!1,u):r(i,u,c,p)}),i}return _p=e,_p}var bp,qb;function PC(){if(qb)return bp;qb=1;var e=Dq(),n=Eu(),r=Lr(),i=Fq(),o=_t();function l(u,c,p){var h=o(u)?e:i,f=arguments.length<3;return h(u,r(c,4),p,f,n)}return bp=l,bp}var Sp,$b;function zq(){if($b)return Sp;$b=1;var e=ti(),n=_t(),r=dr(),i="[object String]";function o(l){return typeof l=="string"||!n(l)&&r(l)&&e(l)==i}return Sp=o,Sp}var kp,Db;function Bq(){if(Db)return kp;Db=1;var e=TC(),n=e("length");return kp=n,kp}var Ep,Fb;function Uq(){if(Fb)return Ep;Fb=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="\\u200d",c=RegExp("["+u+e+o+l+"]");function p(h){return c.test(h)}return Ep=p,Ep}var Np,zb;function Hq(){if(zb)return Np;zb=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",i="\\u20d0-\\u20ff",o=n+r+i,l="\\ufe0e\\ufe0f",u="["+e+"]",c="["+o+"]",p="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+p+")",f="[^"+e+"]",g="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",x="\\u200d",N=h+"?",_="["+l+"]?",S="(?:"+x+"(?:"+[f,g,y].join("|")+")"+_+N+")*",b=_+N+S,k="(?:"+[f+c+"?",c,g,y,u].join("|")+")",E=RegExp(p+"(?="+p+")|"+k+b,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return Np=C,Np}var Cp,Bb;function Wq(){if(Bb)return Cp;Bb=1;var e=Bq(),n=Uq(),r=Hq();function i(o){return n(o)?r(o):e(o)}return Cp=i,Cp}var Tp,Ub;function Vq(){if(Ub)return Tp;Ub=1;var e=$v(),n=uo(),r=Or(),i=zq(),o=Wq(),l="[object Map]",u="[object Set]";function c(p){if(p==null)return 0;if(r(p))return i(p)?o(p):p.length;var h=n(p);return h==l||h==u?p.size:e(p).length}return Tp=c,Tp}var Rp,Hb;function Gq(){if(Hb)return Rp;Hb=1;var e=Ov(),n=hC(),r=Hv(),i=Lr(),o=ku(),l=_t(),u=lo(),c=xa(),p=Tn(),h=Sa();function f(g,y,x){var N=l(g),_=N||u(g)||h(g);if(y=i(y,4),x==null){var S=g&&g.constructor;_?x=N?new S:[]:p(g)?x=c(S)?n(o(g)):{}:x={}}return(_?e:r)(g,function(b,k,E){return y(x,b,k,E)}),x}return Rp=f,Rp}var jp,Wb;function Yq(){if(Wb)return jp;Wb=1;var e=ao(),n=ba(),r=_t(),i=e?e.isConcatSpreadable:void 0;function o(l){return r(l)||n(l)||!!(i&&l&&l[i])}return jp=o,jp}var Ap,Vb;function Gv(){if(Vb)return Ap;Vb=1;var e=Fv(),n=Yq();function r(i,o,l,u,c){var p=-1,h=i.length;for(l||(l=n),c||(c=[]);++p<h;){var f=i[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 Ap=r,Ap}var Ip,Gb;function Kq(){if(Gb)return Ip;Gb=1;function e(n,r,i){switch(i.length){case 0:return n.call(r);case 1:return n.call(r,i[0]);case 2:return n.call(r,i[0],i[1]);case 3:return n.call(r,i[0],i[1],i[2])}return n.apply(r,i)}return Ip=e,Ip}var Mp,Yb;function OC(){if(Yb)return Mp;Yb=1;var e=Kq(),n=Math.max;function r(i,o,l){return o=n(o===void 0?i.length-1:o,0),function(){for(var u=arguments,c=-1,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(i,this,f)}}return Mp=r,Mp}var Pp,Kb;function Xq(){if(Kb)return Pp;Kb=1;var e=Bv(),n=eC(),r=si(),i=n?function(o,l){return n(o,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:r;return Pp=i,Pp}var Op,Xb;function Qq(){if(Xb)return Op;Xb=1;var e=800,n=16,r=Date.now;function i(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 Op=i,Op}var Lp,Qb;function LC(){if(Qb)return Lp;Qb=1;var e=Xq(),n=Qq(),r=n(e);return Lp=r,Lp}var qp,Zb;function Ru(){if(Zb)return qp;Zb=1;var e=si(),n=OC(),r=LC();function i(o,l){return r(n(o,l,e),o+"")}return qp=i,qp}var $p,Jb;function qC(){if(Jb)return $p;Jb=1;function e(n,r,i,o){for(var l=n.length,u=i+(o?1:-1);o?u--:++u<l;)if(r(n[u],u,n))return u;return-1}return $p=e,$p}var Dp,eS;function Zq(){if(eS)return Dp;eS=1;function e(n){return n!==n}return Dp=e,Dp}var Fp,tS;function Jq(){if(tS)return Fp;tS=1;function e(n,r,i){for(var o=i-1,l=n.length;++o<l;)if(n[o]===r)return o;return-1}return Fp=e,Fp}var zp,nS;function e$(){if(nS)return zp;nS=1;var e=qC(),n=Zq(),r=Jq();function i(o,l,u){return l===l?r(o,l,u):e(o,n,u)}return zp=i,zp}var Bp,rS;function t$(){if(rS)return Bp;rS=1;var e=e$();function n(r,i){var o=r==null?0:r.length;return!!o&&e(r,i,0)>-1}return Bp=n,Bp}var Up,sS;function n$(){if(sS)return Up;sS=1;function e(n,r,i){for(var o=-1,l=n==null?0:n.length;++o<l;)if(i(r,n[o]))return!0;return!1}return Up=e,Up}var Hp,iS;function r$(){if(iS)return Hp;iS=1;function e(){}return Hp=e,Hp}var Wp,oS;function s$(){if(oS)return Wp;oS=1;var e=cC(),n=r$(),r=Wv(),i=1/0,o=e&&1/r(new e([,-0]))[1]==i?function(l){return new e(l)}:n;return Wp=o,Wp}var Vp,aS;function i$(){if(aS)return Vp;aS=1;var e=wC(),n=t$(),r=n$(),i=xC(),o=s$(),l=Wv(),u=200;function c(p,h,f){var g=-1,y=n,x=p.length,N=!0,_=[],S=_;if(f)N=!1,y=r;else if(x>=u){var b=h?null:o(p);if(b)return l(b);N=!1,y=i,S=new e}else S=h?[]:_;e:for(;++g<x;){var k=p[g],E=h?h(k):k;if(k=f||k!==0?k:0,N&&E===E){for(var C=S.length;C--;)if(S[C]===E)continue e;h&&S.push(E),_.push(k)}else y(S,E,f)||(S!==_&&S.push(E),_.push(k))}return _}return Vp=c,Vp}var Gp,lS;function $C(){if(lS)return Gp;lS=1;var e=Or(),n=dr();function r(i){return n(i)&&e(i)}return Gp=r,Gp}var Yp,uS;function o$(){if(uS)return Yp;uS=1;var e=Gv(),n=Ru(),r=i$(),i=$C(),o=n(function(l){return r(e(l,1,i,!0))});return Yp=o,Yp}var Kp,cS;function a$(){if(cS)return Kp;cS=1;var e=Nu();function n(r,i){return e(i,function(o){return r[o]})}return Kp=n,Kp}var Xp,dS;function DC(){if(dS)return Xp;dS=1;var e=a$(),n=ps();function r(i){return i==null?[]:e(i,n(i))}return Xp=r,Xp}var Qp,fS;function Rn(){if(fS)return Qp;fS=1;var e;if(typeof Iv=="function")try{e={clone:pq(),constant:Bv(),each:yC(),filter:RC(),has:jC(),isArray:_t(),isEmpty:$q(),isFunction:xa(),isUndefined:AC(),keys:ps(),map:MC(),reduce:PC(),size:Vq(),transform:Gq(),union:o$(),values:DC()}}catch{}return e||(e=window._),Qp=e,Qp}var Zp,hS;function Yv(){if(hS)return Zp;hS=1;var e=Rn();Zp=o;var n="\0",r="\0",i="";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(g){return e.isEmpty(f._in[g])})},o.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(g){return e.isEmpty(f._out[g])})},o.prototype.setNodes=function(f,g){var y=arguments,x=this;return e.each(f,function(N){y.length>1?x.setNode(N,g):x.setNode(N)}),this},o.prototype.setNode=function(f,g){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=g),this):(this._nodes[f]=arguments.length>1?g: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 g=this;if(e.has(this._nodes,f)){var y=function(x){g.removeEdge(g._edgeObjs[x])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(x){g.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,g){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(g))g=r;else{g+="";for(var y=g;!e.isUndefined(y);y=this.parent(y))if(y===f)throw new Error("Setting "+g+" as parent of "+f+" would create a cycle");this.setNode(g)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=g,this._children[g][f]=!0,this},o.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},o.prototype.parent=function(f){if(this._isCompound){var g=this._parent[f];if(g!==r)return g}},o.prototype.children=function(f){if(e.isUndefined(f)&&(f=r),this._isCompound){var g=this._children[f];if(g)return e.keys(g)}else{if(f===r)return this.nodes();if(this.hasNode(f))return[]}},o.prototype.predecessors=function(f){var g=this._preds[f];if(g)return e.keys(g)},o.prototype.successors=function(f){var g=this._sucs[f];if(g)return e.keys(g)},o.prototype.neighbors=function(f){var g=this.predecessors(f);if(g)return e.union(g,this.successors(f))},o.prototype.isLeaf=function(f){var g;return this.isDirected()?g=this.successors(f):g=this.neighbors(f),g.length===0},o.prototype.filterNodes=function(f){var g=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});g.setGraph(this.graph());var y=this;e.each(this._nodes,function(_,S){f(S)&&g.setNode(S,_)}),e.each(this._edgeObjs,function(_){g.hasNode(_.v)&&g.hasNode(_.w)&&g.setEdge(_,y.edge(_))});var x={};function N(_){var S=y.parent(_);return S===void 0||g.hasNode(S)?(x[_]=S,S):S in x?x[S]:N(S)}return this._isCompound&&e.each(g.nodes(),function(_){g.setParent(_,N(_))}),g},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,g){var y=this,x=arguments;return e.reduce(f,function(N,_){return x.length>1?y.setEdge(N,_,g):y.setEdge(N,_),_}),this},o.prototype.setEdge=function(){var f,g,y,x,N=!1,_=arguments[0];typeof _=="object"&&_!==null&&"v"in _?(f=_.v,g=_.w,y=_.name,arguments.length===2&&(x=arguments[1],N=!0)):(f=_,g=arguments[1],y=arguments[3],arguments.length>2&&(x=arguments[2],N=!0)),f=""+f,g=""+g,e.isUndefined(y)||(y=""+y);var S=c(this._isDirected,f,g,y);if(e.has(this._edgeLabels,S))return N&&(this._edgeLabels[S]=x),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(g),this._edgeLabels[S]=N?x:this._defaultEdgeLabelFn(f,g,y);var b=p(this._isDirected,f,g,y);return f=b.v,g=b.w,Object.freeze(b),this._edgeObjs[S]=b,l(this._preds[g],f),l(this._sucs[f],g),this._in[g][S]=b,this._out[f][S]=b,this._edgeCount++,this},o.prototype.edge=function(f,g,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,g,y);return this._edgeLabels[x]},o.prototype.hasEdge=function(f,g,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,g,y);return e.has(this._edgeLabels,x)},o.prototype.removeEdge=function(f,g,y){var x=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,g,y),N=this._edgeObjs[x];return N&&(f=N.v,g=N.w,delete this._edgeLabels[x],delete this._edgeObjs[x],u(this._preds[g],f),u(this._sucs[f],g),delete this._in[g][x],delete this._out[f][x],this._edgeCount--),this},o.prototype.inEdges=function(f,g){var y=this._in[f];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.v===g}):x}},o.prototype.outEdges=function(f,g){var y=this._out[f];if(y){var x=e.values(y);return g?e.filter(x,function(N){return N.w===g}):x}},o.prototype.nodeEdges=function(f,g){var y=this.inEdges(f,g);if(y)return y.concat(this.outEdges(f,g))};function l(f,g){f[g]?f[g]++:f[g]=1}function u(f,g){--f[g]||delete f[g]}function c(f,g,y,x){var N=""+g,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}return N+i+_+i+(e.isUndefined(x)?n:x)}function p(f,g,y,x){var N=""+g,_=""+y;if(!f&&N>_){var S=N;N=_,_=S}var b={v:N,w:_};return x&&(b.name=x),b}function h(f,g){return c(f,g.v,g.w,g.name)}return Zp}var Jp,pS;function l$(){return pS||(pS=1,Jp="2.1.8"),Jp}var em,mS;function u$(){return mS||(mS=1,em={Graph:Yv(),version:l$()}),em}var tm,gS;function c$(){if(gS)return tm;gS=1;var e=Rn(),n=Yv();tm={write:r,read:l};function r(u){var c={options:{directed:u.isDirected(),multigraph:u.isMultigraph(),compound:u.isCompound()},nodes:i(u),edges:o(u)};return e.isUndefined(u.graph())||(c.value=e.clone(u.graph())),c}function i(u){return e.map(u.nodes(),function(c){var 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 tm}var nm,vS;function d$(){if(vS)return nm;vS=1;var e=Rn();nm=n;function n(r){var i={},o=[],l;function u(c){e.has(i,c)||(i[c]=!0,l.push(c),e.each(r.successors(c),u),e.each(r.predecessors(c),u))}return e.each(r.nodes(),function(c){l=[],u(c),l.length&&o.push(l)}),o}return nm}var rm,yS;function FC(){if(yS)return rm;yS=1;var e=Rn();rm=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var i=this._keyIndices[r];if(i!==void 0)return this._arr[i].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,i){var o=this._keyIndices;if(r=String(r),!e.has(o,r)){var l=this._arr,u=l.length;return o[r]=u,l.push({key:r,priority:i}),this._decrease(u),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,i){var o=this._keyIndices[r];if(i>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[o].priority+" New: "+i);this._arr[o].priority=i,this._decrease(o)},n.prototype._heapify=function(r){var i=this._arr,o=2*r,l=o+1,u=r;o<i.length&&(u=i[o].priority<i[u].priority?o:u,l<i.length&&(u=i[l].priority<i[u].priority?l:u),u!==r&&(this._swap(r,u),this._heapify(u)))},n.prototype._decrease=function(r){for(var i=this._arr,o=i[r].priority,l;r!==0&&(l=r>>1,!(i[l].priority<o));)this._swap(r,l),r=l},n.prototype._swap=function(r,i){var o=this._arr,l=this._keyIndices,u=o[r],c=o[i];o[r]=c,o[i]=u,l[c.key]=r,l[u.key]=i},rm}var sm,wS;function zC(){if(wS)return sm;wS=1;var e=Rn(),n=FC();sm=i;var r=e.constant(1);function i(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,g,y,x=function(N){var _=N.v!==g?N.v:N.w,S=h[_],b=c(N),k=y.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+N+" Weight: "+b);k<S.distance&&(S.distance=k,S.predecessor=g,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&&(g=f.removeMin(),y=h[g],y.distance!==Number.POSITIVE_INFINITY);)p(g).forEach(x);return h}return sm}var im,xS;function f$(){if(xS)return im;xS=1;var e=zC(),n=Rn();im=r;function r(i,o,l){return n.transform(i.nodes(),function(u,c){u[c]=e(i,c,o,l)},{})}return im}var om,_S;function BC(){if(_S)return om;_S=1;var e=Rn();om=n;function n(r){var i=0,o=[],l={},u=[];function c(p){var h=l[p]={onStack:!0,lowlink:i,index:i++};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=[],g;do g=o.pop(),l[g].onStack=!1,f.push(g);while(p!==g);u.push(f)}}return r.nodes().forEach(function(p){e.has(l,p)||c(p)}),u}return om}var am,bS;function h$(){if(bS)return am;bS=1;var e=Rn(),n=BC();am=r;function r(i){return e.filter(n(i),function(o){return o.length>1||o.length===1&&i.hasEdge(o[0],o[0])})}return am}var lm,SS;function p$(){if(SS)return lm;SS=1;var e=Rn();lm=r;var n=e.constant(1);function r(o,l,u){return i(o,l||n,u||function(c){return o.outEdges(c)})}function i(o,l,u){var c={},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 g=f.v===h?f.w:f.v,y=l(f);c[h][g]={distance:y,predecessor:h}})}),p.forEach(function(h){var f=c[h];p.forEach(function(g){var y=c[g];p.forEach(function(x){var N=y[h],_=f[x],S=y[x],b=N.distance+_.distance;b<S.distance&&(S.distance=b,S.predecessor=_.predecessor)})})}),c}return lm}var um,kS;function UC(){if(kS)return um;kS=1;var e=Rn();um=n,n.CycleException=r;function n(i){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(i.predecessors(p),c),delete l[p],u.push(p))}if(e.each(i.sinks(),c),e.size(o)!==i.nodeCount())throw new r;return u}function r(){}return r.prototype=new Error,um}var cm,ES;function m$(){if(ES)return cm;ES=1;var e=UC();cm=n;function n(r){try{e(r)}catch(i){if(i instanceof e.CycleException)return!1;throw i}return!0}return cm}var dm,NS;function HC(){if(NS)return dm;NS=1;var e=Rn();dm=n;function n(i,o,l){e.isArray(o)||(o=[o]);var u=(i.isDirected()?i.successors:i.neighbors).bind(i),c=[],p={};return e.each(o,function(h){if(!i.hasNode(h))throw new Error("Graph does not have node: "+h);r(i,h,l==="post",p,u,c)}),c}function r(i,o,l,u,c,p){e.has(u,o)||(u[o]=!0,l||p.push(o),e.each(c(o),function(h){r(i,h,l,u,c,p)}),l&&p.push(o))}return dm}var fm,CS;function g$(){if(CS)return fm;CS=1;var e=HC();fm=n;function n(r,i){return e(r,i,"post")}return fm}var hm,TS;function v$(){if(TS)return hm;TS=1;var e=HC();hm=n;function n(r,i){return e(r,i,"pre")}return hm}var pm,RS;function y$(){if(RS)return pm;RS=1;var e=Rn(),n=Yv(),r=FC();pm=i;function i(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 g=!1;p.size()>0;){if(h=p.removeMin(),e.has(c,h))u.setEdge(h,c[h]);else{if(g)throw new Error("Input graph is not connected: "+o);g=!0}o.nodeEdges(h).forEach(f)}return u}return pm}var mm,jS;function w$(){return jS||(jS=1,mm={components:d$(),dijkstra:zC(),dijkstraAll:f$(),findCycles:h$(),floydWarshall:p$(),isAcyclic:m$(),postorder:g$(),preorder:v$(),prim:y$(),tarjan:BC(),topsort:UC()}),mm}var gm,AS;function x$(){if(AS)return gm;AS=1;var e=u$();return gm={Graph:e.Graph,json:c$(),alg:w$(),version:e.version},gm}var vm,IS;function Xn(){if(IS)return vm;IS=1;var e;if(typeof Iv=="function")try{e=x$()}catch{}return e||(e=window.graphlib),vm=e,vm}var ym,MS;function _$(){if(MS)return ym;MS=1;var e=mC(),n=1,r=4;function i(o){return e(o,n|r)}return ym=i,ym}var wm,PS;function ju(){if(PS)return wm;PS=1;var e=oo(),n=Or(),r=_u(),i=Tn();function o(l,u,c){if(!i(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 wm=o,wm}var xm,OS;function b$(){if(OS)return xm;OS=1;var e=Ru(),n=oo(),r=ju(),i=ri(),o=Object.prototype,l=o.hasOwnProperty,u=e(function(c,p){c=Object(c);var h=-1,f=p.length,g=f>2?p[2]:void 0;for(g&&r(p[0],p[1],g)&&(f=1);++h<f;)for(var y=p[h],x=i(y),N=-1,_=x.length;++N<_;){var S=x[N],b=c[S];(b===void 0||n(b,o[S])&&!l.call(c,S))&&(c[S]=y[S])}return c});return xm=u,xm}var _m,LS;function S$(){if(LS)return _m;LS=1;var e=Lr(),n=Or(),r=ps();function i(o){return function(l,u,c){var p=Object(l);if(!n(l)){var h=e(u,3);l=r(l),u=function(g){return h(p[g],g,p)}}var f=o(l,u,c);return f>-1?p[h?l[f]:f]:void 0}}return _m=i,_m}var bm,qS;function k$(){if(qS)return bm;qS=1;var e=/\s/;function n(r){for(var i=r.length;i--&&e.test(r.charAt(i)););return i}return bm=n,bm}var Sm,$S;function E$(){if($S)return Sm;$S=1;var e=k$(),n=/^\s+/;function r(i){return i&&i.slice(0,e(i)+1).replace(n,"")}return Sm=r,Sm}var km,DS;function N$(){if(DS)return km;DS=1;var e=E$(),n=Tn(),r=co(),i=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 i;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 g=l.test(h);return g||u.test(h)?c(h.slice(2),g?2:8):o.test(h)?i:+h}return km=p,km}var Em,FS;function WC(){if(FS)return Em;FS=1;var e=N$(),n=1/0,r=17976931348623157e292;function i(o){if(!o)return o===0?o:0;if(o=e(o),o===n||o===-n){var l=o<0?-1:1;return l*r}return o===o?o:0}return Em=i,Em}var Nm,zS;function C$(){if(zS)return Nm;zS=1;var e=WC();function n(r){var i=e(r),o=i%1;return i===i?o?i-o:i:0}return Nm=n,Nm}var Cm,BS;function T$(){if(BS)return Cm;BS=1;var e=qC(),n=Lr(),r=C$(),i=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=i(p+h,0)),e(l,n(u,3),h)}return Cm=o,Cm}var Tm,US;function R$(){if(US)return Tm;US=1;var e=S$(),n=T$(),r=e(n);return Tm=r,Tm}var Rm,HS;function VC(){if(HS)return Rm;HS=1;var e=Gv();function n(r){var i=r==null?0:r.length;return i?e(r,1):[]}return Rm=n,Rm}var jm,WS;function j$(){if(WS)return jm;WS=1;var e=Uv(),n=gC(),r=ri();function i(o,l){return o==null?o:e(o,n(l),r)}return jm=i,jm}var Am,VS;function A$(){if(VS)return Am;VS=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return Am=e,Am}var Im,GS;function I$(){if(GS)return Im;GS=1;var e=wu(),n=Hv(),r=Lr();function i(o,l){var u={};return l=r(l,3),n(o,function(c,p,h){e(u,p,l(c,p,h))}),u}return Im=i,Im}var Mm,YS;function Kv(){if(YS)return Mm;YS=1;var e=co();function n(r,i,o){for(var l=-1,u=r.length;++l<u;){var c=r[l],p=i(c);if(p!=null&&(h===void 0?p===p&&!e(p):o(p,h)))var h=p,f=c}return f}return Mm=n,Mm}var Pm,KS;function M$(){if(KS)return Pm;KS=1;function e(n,r){return n>r}return Pm=e,Pm}var Om,XS;function P$(){if(XS)return Om;XS=1;var e=Kv(),n=M$(),r=si();function i(o){return o&&o.length?e(o,r,n):void 0}return Om=i,Om}var Lm,QS;function GC(){if(QS)return Lm;QS=1;var e=wu(),n=oo();function r(i,o,l){(l!==void 0&&!n(i[o],l)||l===void 0&&!(o in i))&&e(i,o,l)}return Lm=r,Lm}var qm,ZS;function O$(){if(ZS)return qm;ZS=1;var e=ti(),n=ku(),r=dr(),i="[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)!=i)return!1;var g=n(f);if(g===null)return!0;var y=c.call(g,"constructor")&&g.constructor;return typeof y=="function"&&y instanceof y&&u.call(y)==p}return qm=h,qm}var $m,JS;function YC(){if(JS)return $m;JS=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return $m=e,$m}var Dm,ek;function L$(){if(ek)return Dm;ek=1;var e=_a(),n=ri();function r(i){return e(i,n(i))}return Dm=r,Dm}var Fm,tk;function q$(){if(tk)return Fm;tk=1;var e=GC(),n=rC(),r=fC(),i=sC(),o=pC(),l=ba(),u=_t(),c=$C(),p=lo(),h=xa(),f=Tn(),g=O$(),y=Sa(),x=YC(),N=L$();function _(S,b,k,E,C,R,I){var L=x(S,k),H=x(b,k),P=I.get(H);if(P){e(S,k,P);return}var q=R?R(L,H,k+"",S,b,I):void 0,B=q===void 0;if(B){var D=u(H),F=!D&&p(H),j=!D&&!F&&y(H);q=H,D||F||j?u(L)?q=L:c(L)?q=i(L):F?(B=!1,q=n(H,!0)):j?(B=!1,q=r(H,!0)):q=[]:g(H)||l(H)?(q=L,l(L)?q=N(L):(!f(L)||h(L))&&(q=o(H))):B=!1}B&&(I.set(H,q),C(q,H,E,R,I),I.delete(H)),e(S,k,q)}return Fm=_,Fm}var zm,nk;function $$(){if(nk)return zm;nk=1;var e=yu(),n=GC(),r=Uv(),i=q$(),o=Tn(),l=ri(),u=YC();function c(p,h,f,g,y){p!==h&&r(h,function(x,N){if(y||(y=new e),o(x))i(p,h,N,f,c,g,y);else{var _=g?g(u(p,N),x,N+"",p,h,y):void 0;_===void 0&&(_=x),n(p,N,_)}},l)}return zm=c,zm}var Bm,rk;function D$(){if(rk)return Bm;rk=1;var e=Ru(),n=ju();function r(i){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=i.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&&i(o,f,u,p)}return o})}return Bm=r,Bm}var Um,sk;function F$(){if(sk)return Um;sk=1;var e=$$(),n=D$(),r=n(function(i,o,l){e(i,o,l)});return Um=r,Um}var Hm,ik;function KC(){if(ik)return Hm;ik=1;function e(n,r){return n<r}return Hm=e,Hm}var Wm,ok;function z$(){if(ok)return Wm;ok=1;var e=Kv(),n=KC(),r=si();function i(o){return o&&o.length?e(o,r,n):void 0}return Wm=i,Wm}var Vm,ak;function B$(){if(ak)return Vm;ak=1;var e=Kv(),n=Lr(),r=KC();function i(o,l){return o&&o.length?e(o,n(l,2),r):void 0}return Vm=i,Vm}var Gm,lk;function U$(){if(lk)return Gm;lk=1;var e=Zn(),n=function(){return e.Date.now()};return Gm=n,Gm}var Ym,uk;function H$(){if(uk)return Ym;uk=1;var e=xu(),n=Cu(),r=_u(),i=Tn(),o=ka();function l(u,c,p,h){if(!i(u))return u;c=n(c,u);for(var f=-1,g=c.length,y=g-1,x=u;x!=null&&++f<g;){var N=o(c[f]),_=p;if(N==="__proto__"||N==="constructor"||N==="prototype")return u;if(f!=y){var S=x[N];_=h?h(S,N,x):void 0,_===void 0&&(_=i(S)?S:r(c[f+1])?[]:{})}e(x,N,_),x=x[N]}return u}return Ym=l,Ym}var Km,ck;function W$(){if(ck)return Km;ck=1;var e=Tu(),n=H$(),r=Cu();function i(o,l,u){for(var c=-1,p=l.length,h={};++c<p;){var f=l[c],g=e(o,f);u(g,f)&&n(h,r(f,o),g)}return h}return Km=i,Km}var Xm,dk;function V$(){if(dk)return Xm;dk=1;var e=W$(),n=CC();function r(i,o){return e(i,o,function(l,u){return n(i,u)})}return Xm=r,Xm}var Qm,fk;function G$(){if(fk)return Qm;fk=1;var e=VC(),n=OC(),r=LC();function i(o){return r(n(o,void 0,e),o+"")}return Qm=i,Qm}var Zm,hk;function Y$(){if(hk)return Zm;hk=1;var e=V$(),n=G$(),r=n(function(i,o){return i==null?{}:e(i,o)});return Zm=r,Zm}var Jm,pk;function K$(){if(pk)return Jm;pk=1;var e=Math.ceil,n=Math.max;function r(i,o,l,u){for(var c=-1,p=n(e((o-i)/(l||1)),0),h=Array(p);p--;)h[u?p:++c]=i,i+=l;return h}return Jm=r,Jm}var eg,mk;function X$(){if(mk)return eg;mk=1;var e=K$(),n=ju(),r=WC();function i(o){return function(l,u,c){return c&&typeof c!="number"&&n(l,u,c)&&(u=c=void 0),l=r(l),u===void 0?(u=l,l=0):u=r(u),c=c===void 0?l<u?1:-1:r(c),e(l,u,c,o)}}return eg=i,eg}var tg,gk;function Q$(){if(gk)return tg;gk=1;var e=X$(),n=e();return tg=n,tg}var ng,vk;function Z$(){if(vk)return ng;vk=1;function e(n,r){var i=n.length;for(n.sort(r);i--;)n[i]=n[i].value;return n}return ng=e,ng}var rg,yk;function J$(){if(yk)return rg;yk=1;var e=co();function n(r,i){if(r!==i){var o=r!==void 0,l=r===null,u=r===r,c=e(r),p=i!==void 0,h=i===null,f=i===i,g=e(i);if(!h&&!g&&!c&&r>i||c&&p&&f&&!h&&!g||l&&p&&f||!o&&f||!u)return 1;if(!l&&!c&&!g&&r<i||g&&o&&u&&!l&&!c||h&&o&&u||!p&&u||!f)return-1}return 0}return rg=n,rg}var sg,wk;function e4(){if(wk)return sg;wk=1;var e=J$();function n(r,i,o){for(var l=-1,u=r.criteria,c=i.criteria,p=u.length,h=o.length;++l<p;){var f=e(u[l],c[l]);if(f){if(l>=h)return f;var g=o[l];return f*(g=="desc"?-1:1)}}return r.index-i.index}return sg=n,sg}var ig,xk;function t4(){if(xk)return ig;xk=1;var e=Nu(),n=Tu(),r=Lr(),i=IC(),o=Z$(),l=bu(),u=e4(),c=si(),p=_t();function h(f,g,y){g.length?g=e(g,function(_){return p(_)?function(S){return n(S,_.length===1?_[0]:_)}:_}):g=[c];var x=-1;g=e(g,l(r));var N=i(f,function(_,S,b){var k=e(g,function(E){return E(_)});return{criteria:k,index:++x,value:_}});return o(N,function(_,S){return u(_,S,y)})}return ig=h,ig}var og,_k;function n4(){if(_k)return og;_k=1;var e=Gv(),n=t4(),r=Ru(),i=ju(),o=r(function(l,u){if(l==null)return[];var c=u.length;return c>1&&i(l,u[0],u[1])?u=[]:c>2&&i(u[0],u[1],u[2])&&(u=[u[0]]),n(l,e(u,1),[])});return og=o,og}var ag,bk;function r4(){if(bk)return ag;bk=1;var e=EC(),n=0;function r(i){var o=++n;return e(i)+o}return ag=r,ag}var lg,Sk;function s4(){if(Sk)return lg;Sk=1;function e(n,r,i){for(var o=-1,l=n.length,u=r.length,c={};++o<l;){var p=o<u?r[o]:void 0;i(c,n[o],p)}return c}return lg=e,lg}var ug,kk;function i4(){if(kk)return ug;kk=1;var e=xu(),n=s4();function r(i,o){return n(i||[],o||[],e)}return ug=r,ug}var cg,Ek;function ot(){if(Ek)return cg;Ek=1;var e;if(typeof Iv=="function")try{e={cloneDeep:_$(),constant:Bv(),defaults:b$(),each:yC(),filter:RC(),find:R$(),flatten:VC(),forEach:vC(),forIn:j$(),has:jC(),isUndefined:AC(),last:A$(),map:MC(),mapValues:I$(),max:P$(),merge:F$(),min:z$(),minBy:B$(),now:U$(),pick:Y$(),range:Q$(),reduce:PC(),sortBy:n4(),uniqueId:r4(),values:DC(),zipObject:i4()}}catch{}return e||(e=window._),cg=e,cg}var dg,Nk;function o4(){if(Nk)return dg;Nk=1,dg=e;function e(){var i={};i._next=i._prev=i,this._sentinel=i}e.prototype.dequeue=function(){var i=this._sentinel,o=i._prev;if(o!==i)return n(o),o},e.prototype.enqueue=function(i){var o=this._sentinel;i._prev&&i._next&&n(i),i._next=o._next,o._next._prev=i,o._next=i,i._prev=o},e.prototype.toString=function(){for(var i=[],o=this._sentinel,l=o._prev;l!==o;)i.push(JSON.stringify(l,r)),l=l._prev;return"["+i.join(", ")+"]"};function n(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function r(i,o){if(i!=="_next"&&i!=="_prev")return o}return dg}var fg,Ck;function a4(){if(Ck)return fg;Ck=1;var e=ot(),n=Xn().Graph,r=o4();fg=o;var i=e.constant(1);function o(h,f){if(h.nodeCount()<=1)return[];var g=c(h,f||i),y=l(g.graph,g.buckets,g.zeroIdx);return e.flatten(e.map(y,function(x){return h.outEdges(x.v,x.w)}),!0)}function l(h,f,g){for(var y=[],x=f[f.length-1],N=f[0],_;h.nodeCount();){for(;_=N.dequeue();)u(h,f,g,_);for(;_=x.dequeue();)u(h,f,g,_);if(h.nodeCount()){for(var S=f.length-2;S>0;--S)if(_=f[S].dequeue(),_){y=y.concat(u(h,f,g,_,!0));break}}}return y}function u(h,f,g,y,x){var N=x?[]:void 0;return e.forEach(h.inEdges(y.v),function(_){var S=h.edge(_),b=h.node(_.v);x&&N.push({v:_.v,w:_.w}),b.out-=S,p(f,g,b)}),e.forEach(h.outEdges(y.v),function(_){var S=h.edge(_),b=_.w,k=h.node(b);k.in-=S,p(f,g,k)}),h.removeNode(y.v),N}function c(h,f){var g=new n,y=0,x=0;e.forEach(h.nodes(),function(S){g.setNode(S,{v:S,in:0,out:0})}),e.forEach(h.edges(),function(S){var b=g.edge(S.v,S.w)||0,k=f(S),E=b+k;g.setEdge(S.v,S.w,E),x=Math.max(x,g.node(S.v).out+=k),y=Math.max(y,g.node(S.w).in+=k)});var N=e.range(x+y+3).map(function(){return new r}),_=y+1;return e.forEach(g.nodes(),function(S){p(N,_,g.node(S))}),{graph:g,buckets:N,zeroIdx:_}}function p(h,f,g){g.out?g.in?h[g.out-g.in+f].enqueue(g):h[h.length-1].enqueue(g):h[0].enqueue(g)}return fg}var hg,Tk;function l4(){if(Tk)return hg;Tk=1;var e=ot(),n=a4();hg={run:r,undo:o};function r(l){var u=l.graph().acyclicer==="greedy"?n(l,c(l)):i(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 i(l){var u=[],c={},p={};function h(f){e.has(p,f)||(p[f]=!0,c[f]=!0,e.forEach(l.outEdges(f),function(g){e.has(c,g.w)?u.push(g):h(g.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 hg}var pg,Rk;function on(){if(Rk)return pg;Rk=1;var e=ot(),n=Xn().Graph;pg={addDummyNode:r,simplify:i,asNonCompoundGraph:o,successorWeights:l,predecessorWeights:u,intersectRect:c,buildLayerMatrix:p,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:g,maxRank:y,partition:x,time:N,notime:_};function r(S,b,k,E){var C;do C=e.uniqueId(E);while(S.hasNode(C));return k.dummy=b,S.setNode(C,k),C}function i(S){var b=new n().setGraph(S.graph());return e.forEach(S.nodes(),function(k){b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){var E=b.edge(k.v,k.w)||{weight:0,minlen:1},C=S.edge(k);b.setEdge(k.v,k.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),b}function o(S){var b=new n({multigraph:S.isMultigraph()}).setGraph(S.graph());return e.forEach(S.nodes(),function(k){S.children(k).length||b.setNode(k,S.node(k))}),e.forEach(S.edges(),function(k){b.setEdge(k,S.edge(k))}),b}function l(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.outEdges(k),function(C){E[C.w]=(E[C.w]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function u(S){var b=e.map(S.nodes(),function(k){var E={};return e.forEach(S.inEdges(k),function(C){E[C.v]=(E[C.v]||0)+S.edge(C).weight}),E});return e.zipObject(S.nodes(),b)}function c(S,b){var k=S.x,E=S.y,C=b.x-k,R=b.y-E,I=S.width/2,L=S.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var H,P;return Math.abs(R)*I>Math.abs(C)*L?(R<0&&(L=-L),H=L*C/R,P=L):(C<0&&(I=-I),H=I,P=I*R/C),{x:k+H,y:E+P}}function p(S){var b=e.map(e.range(y(S)+1),function(){return[]});return e.forEach(S.nodes(),function(k){var E=S.node(k),C=E.rank;e.isUndefined(C)||(b[C][E.order]=k)}),b}function h(S){var b=e.min(e.map(S.nodes(),function(k){return S.node(k).rank}));e.forEach(S.nodes(),function(k){var E=S.node(k);e.has(E,"rank")&&(E.rank-=b)})}function f(S){var b=e.min(e.map(S.nodes(),function(R){return S.node(R).rank})),k=[];e.forEach(S.nodes(),function(R){var I=S.node(R).rank-b;k[I]||(k[I]=[]),k[I].push(R)});var E=0,C=S.graph().nodeRankFactor;e.forEach(k,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function(L){S.node(L).rank+=E})})}function g(S,b,k,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=k,C.order=E),r(S,"border",C,b)}function y(S){return e.max(e.map(S.nodes(),function(b){var k=S.node(b).rank;if(!e.isUndefined(k))return k}))}function x(S,b){var k={lhs:[],rhs:[]};return e.forEach(S,function(E){b(E)?k.lhs.push(E):k.rhs.push(E)}),k}function N(S,b){var k=e.now();try{return b()}finally{console.log(S+" time: "+(e.now()-k)+"ms")}}function _(S,b){return b()}return pg}var mg,jk;function u4(){if(jk)return mg;jk=1;var e=ot(),n=on();mg={run:r,undo:o};function r(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(u){i(l,u)})}function i(l,u){var c=u.v,p=l.node(c).rank,h=u.w,f=l.node(h).rank,g=u.name,y=l.edge(u),x=y.labelRank;if(f!==p+1){l.removeEdge(u);var N,_,S;for(S=0,++p;p<f;++S,++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},g),S===0&&l.graph().dummyChains.push(N),c=N;l.setEdge(c,h,{weight:y.weight},g)}}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 mg}var gg,Ak;function iu(){if(Ak)return gg;Ak=1;var e=ot();gg={longestPath:n,slack:r};function n(i){var o={};function l(u){var c=i.node(u);if(e.has(o,u))return c.rank;o[u]=!0;var p=e.min(e.map(i.outEdges(u),function(h){return l(h.w)-i.edge(h).minlen}));return(p===Number.POSITIVE_INFINITY||p===void 0||p===null)&&(p=0),c.rank=p}e.forEach(i.sources(),l)}function r(i,o){return i.node(o.w).rank-i.node(o.v).rank-i.edge(o).minlen}return gg}var vg,Ik;function XC(){if(Ik)return vg;Ik=1;var e=ot(),n=Xn().Graph,r=iu().slack;vg=i;function i(c){var p=new n({directed:!1}),h=c.nodes()[0],f=c.nodeCount();p.setNode(h,{});for(var g,y;o(p,c)<f;)g=l(p,c),y=p.hasNode(g.v)?r(c,g):-r(c,g),u(p,c,y);return p}function o(c,p){function h(f){e.forEach(p.nodeEdges(f),function(g){var y=g.v,x=f===y?g.w:y;!c.hasNode(x)&&!r(p,g)&&(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 vg}var yg,Mk;function c4(){if(Mk)return yg;Mk=1;var e=ot(),n=XC(),r=iu().slack,i=iu().longestPath,o=Xn().alg.preorder,l=Xn().alg.postorder,u=on().simplify;yg=c,c.initLowLimValues=g,c.initCutValues=p,c.calcCutValue=f,c.leaveEdge=x,c.enterEdge=N,c.exchangeEdges=_;function c(E){E=u(E),i(E);var C=n(E);g(C),p(C,E);for(var R,I;R=x(C);)I=N(C,E,R),_(C,E,R,I)}function p(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){h(E,C,I)})}function h(E,C,R){var I=E.node(R),L=I.parent;E.edge(R,L).cutvalue=f(E,C,R)}function f(E,C,R){var I=E.node(R),L=I.parent,H=!0,P=C.edge(R,L),q=0;return P||(H=!1,P=C.edge(L,R)),q=P.weight,e.forEach(C.nodeEdges(R),function(B){var D=B.v===R,F=D?B.w:B.v;if(F!==L){var j=D===H,Z=C.edge(B).weight;if(q+=j?Z:-Z,b(E,R,F)){var W=E.edge(R,F).cutvalue;q+=j?-W:W}}}),q}function g(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,L){var H=R,P=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function(q){e.has(C,q)||(R=y(E,C,R,q,I))}),P.low=H,P.lim=R++,L?P.parent=L:delete P.parent,R}function x(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function N(E,C,R){var I=R.v,L=R.w;C.hasEdge(I,L)||(I=R.w,L=R.v);var H=E.node(I),P=E.node(L),q=H,B=!1;H.lim>P.lim&&(q=P,B=!0);var D=e.filter(C.edges(),function(F){return B===k(E,E.node(F.v),q)&&B!==k(E,E.node(F.w),q)});return e.minBy(D,function(F){return r(C,F)})}function _(E,C,R,I){var L=R.v,H=R.w;E.removeEdge(L,H),E.setEdge(I.v,I.w,{}),g(E),p(E,C),S(E,C)}function S(E,C){var R=e.find(E.nodes(),function(L){return!C.node(L).parent}),I=o(E,R);I=I.slice(1),e.forEach(I,function(L){var H=E.node(L).parent,P=C.edge(L,H),q=!1;P||(P=C.edge(H,L),q=!0),C.node(L).rank=C.node(H).rank+(q?P.minlen:-P.minlen)})}function b(E,C,R){return E.hasEdge(C,R)}function k(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return yg}var wg,Pk;function d4(){if(Pk)return wg;Pk=1;var e=iu(),n=e.longestPath,r=XC(),i=c4();wg=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){i(p)}return wg}var xg,Ok;function f4(){if(Ok)return xg;Ok=1;var e=ot();xg=n;function n(o){var l=i(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,g=h.lca,y=0,x=f[y],N=!0;u!==p.w;){if(c=o.node(u),N){for(;(x=f[y])!==g&&o.node(x).maxRank<c.rank;)y++;x===g&&(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),g=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||g>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 i(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 xg}var _g,Lk;function h4(){if(Lk)return _g;Lk=1;var e=ot(),n=on();_g={run:r,cleanup:u};function r(c){var p=n.addDummyNode(c,"root",{},"_root"),h=o(c),f=e.max(e.values(h))-1,g=2*f+1;c.graph().nestingRoot=p,e.forEach(c.edges(),function(x){c.edge(x).minlen*=g});var y=l(c)+1;e.forEach(c.children(),function(x){i(c,p,g,y,f,h,x)}),c.graph().nodeRankFactor=g}function i(c,p,h,f,g,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"),S=n.addBorderNode(c,"_bb"),b=c.node(x);c.setParent(_,x),b.borderTop=_,c.setParent(S,x),b.borderBottom=S,e.forEach(N,function(k){i(c,p,h,f,g,y,k);var E=c.node(k),C=E.borderTop?E.borderTop:k,R=E.borderBottom?E.borderBottom:k,I=E.borderTop?f:2*f,L=C!==R?1:g-y[x]+1;c.setEdge(_,C,{weight:I,minlen:L,nestingEdge:!0}),c.setEdge(R,S,{weight:I,minlen:L,nestingEdge:!0})}),c.parent(x)||c.setEdge(p,_,{weight:0,minlen:g+y[x]})}function o(c){var p={};function h(f,g){var y=c.children(f);y&&y.length&&e.forEach(y,function(x){h(x,g+1)}),p[f]=g}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 _g}var bg,qk;function p4(){if(qk)return bg;qk=1;var e=ot(),n=on();bg=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)i(o,"borderLeft","_bl",u,p,h),i(o,"borderRight","_br",u,p,h)}}e.forEach(o.children(),l)}function i(o,l,u,c,p,h){var f={width:0,height:0,rank:h,borderType:l},g=p[l][h-1],y=n.addDummyNode(o,"border",f,u);p[l][h]=y,o.setParent(y,c),g&&o.setEdge(g,y,{weight:1})}return bg}var Sg,$k;function m4(){if($k)return Sg;$k=1;var e=ot();Sg={adjust:n,undo:r};function n(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&i(h)}function r(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&l(h),(f==="lr"||f==="rl")&&(c(h),i(h))}function i(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 g=h.edge(f);e.forEach(g.points,u),e.has(g,"y")&&u(g)})}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 g=h.edge(f);e.forEach(g.points,p),e.has(g,"x")&&p(g)})}function p(h){var f=h.x;h.x=h.y,h.y=f}return Sg}var kg,Dk;function g4(){if(Dk)return kg;Dk=1;var e=ot();kg=n;function n(r){var i={},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(i,h)){i[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 kg}var Eg,Fk;function v4(){if(Fk)return Eg;Fk=1;var e=ot();Eg=n;function n(i,o){for(var l=0,u=1;u<o.length;++u)l+=r(i,o[u-1],o[u]);return l}function r(i,o,l){for(var u=e.zipObject(l,e.map(l,function(y,x){return x})),c=e.flatten(e.map(o,function(y){return e.sortBy(e.map(i.outEdges(y),function(x){return{pos:u[x.w],weight:i.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}),g=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;g+=y.weight*N})),g}return Eg}var Ng,zk;function y4(){if(zk)return Ng;zk=1;var e=ot();Ng=n;function n(r,i){return e.map(i,function(o){var l=r.inEdges(o);if(l.length){var u=e.reduce(l,function(c,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 Ng}var Cg,Bk;function w4(){if(Bk)return Cg;Bk=1;var e=ot();Cg=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)&&i(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 i(o,l){var u=0,c=0;o.weight&&(u+=o.barycenter*o.weight,c+=o.weight),l.weight&&(u+=l.barycenter*l.weight,c+=l.weight),o.vs=l.vs.concat(o.vs),o.barycenter=u/c,o.weight=c,o.i=Math.min(l.i,o.i),l.merged=!0}return Cg}var Tg,Uk;function x4(){if(Uk)return Tg;Uk=1;var e=ot(),n=on();Tg=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=[],g=0,y=0,x=0;p.sort(o(!!u)),x=i(f,h,x),e.forEach(p,function(_){x+=_.vs.length,f.push(_.vs),g+=_.barycenter*_.weight,y+=_.weight,x=i(f,h,x)});var N={vs:e.flatten(f,!0)};return y&&(N.barycenter=g/y,N.weight=y),N}function i(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 Tg}var Rg,Hk;function _4(){if(Hk)return Rg;Hk=1;var e=ot(),n=y4(),r=w4(),i=x4();Rg=o;function o(c,p,h,f){var g=c.children(p),y=c.node(p),x=y?y.borderLeft:void 0,N=y?y.borderRight:void 0,_={};x&&(g=e.filter(g,function(R){return R!==x&&R!==N}));var S=n(c,g);e.forEach(S,function(R){if(c.children(R.v).length){var I=o(c,R.v,h,f);_[R.v]=I,e.has(I,"barycenter")&&u(R,I)}});var b=r(S,h);l(b,_);var k=i(b,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 Rg}var jg,Wk;function b4(){if(Wk)return jg;Wk=1;var e=ot(),n=Xn().Graph;jg=r;function r(o,l,u){var c=i(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),g=o.parent(h);(f.rank===l||f.minRank<=l&&l<=f.maxRank)&&(p.setNode(h),p.setParent(h,g||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 i(o){for(var l;o.hasNode(l=e.uniqueId("_root")););return l}return jg}var Ag,Vk;function S4(){if(Vk)return Ag;Vk=1;var e=ot();Ag=n;function n(r,i,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){i.setEdge(f,p);return}p=h}})}return Ag}var Ig,Gk;function k4(){if(Gk)return Ig;Gk=1;var e=ot(),n=g4(),r=v4(),i=_4(),o=b4(),l=S4(),u=Xn().Graph,c=on();Ig=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"),S=n(y);g(y,S);for(var b=Number.POSITIVE_INFINITY,k,E=0,C=0;C<4;++E,++C){f(E%2?N:_,E%4>=2),S=c.buildLayerMatrix(y);var R=r(y,S);R<b&&(C=0,k=e.cloneDeep(S),b=R)}g(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 S=_.graph().root,b=i(_,S,N,x);e.forEach(b.vs,function(k,E){_.node(k).order=E}),l(_,N,b.vs)})}function g(y,x){e.forEach(x,function(N){e.forEach(N,function(_,S){y.node(_).order=S})})}return Ig}var Mg,Yk;function E4(){if(Yk)return Mg;Yk=1;var e=ot(),n=Xn().Graph,r=on();Mg={positionX:N,findType1Conflicts:i,findType2Conflicts:o,addConflict:u,hasConflict:c,verticalAlignment:p,horizontalCompaction:h,alignCoordinates:y,findSmallestWidthAlignment:g,balance:x};function i(b,k){var E={};function C(R,I){var L=0,H=0,P=R.length,q=e.last(I);return e.forEach(I,function(B,D){var F=l(b,B),j=F?b.node(F).order:P;(F||B===q)&&(e.forEach(I.slice(H,D+1),function(Z){e.forEach(b.predecessors(Z),function(W){var ne=b.node(W),J=ne.order;(J<L||j<J)&&!(ne.dummy&&b.node(Z).dummy)&&u(E,W,Z)})}),H=D+1,L=j)}),I}return e.reduce(k,C),E}function o(b,k){var E={};function C(I,L,H,P,q){var B;e.forEach(e.range(L,H),function(D){B=I[D],b.node(B).dummy&&e.forEach(b.predecessors(B),function(F){var j=b.node(F);j.dummy&&(j.order<P||j.order>q)&&u(E,F,B)})})}function R(I,L){var H=-1,P,q=0;return e.forEach(L,function(B,D){if(b.node(B).dummy==="border"){var F=b.predecessors(B);F.length&&(P=b.node(F[0]).order,C(L,q,D,H,P),q=D,H=P)}C(L,q,L.length,P,I.length)}),L}return e.reduce(k,R),E}function l(b,k){if(b.node(k).dummy)return e.find(b.predecessors(k),function(E){return b.node(E).dummy})}function u(b,k,E){if(k>E){var C=k;k=E,E=C}var R=b[k];R||(b[k]=R={}),R[E]=!0}function c(b,k,E){if(k>E){var C=k;k=E,E=C}return e.has(b[k],E)}function p(b,k,E,C){var R={},I={},L={};return e.forEach(k,function(H){e.forEach(H,function(P,q){R[P]=P,I[P]=P,L[P]=q})}),e.forEach(k,function(H){var P=-1;e.forEach(H,function(q){var B=C(q);if(B.length){B=e.sortBy(B,function(W){return L[W]});for(var D=(B.length-1)/2,F=Math.floor(D),j=Math.ceil(D);F<=j;++F){var Z=B[F];I[q]===q&&P<L[Z]&&!c(E,q,Z)&&(I[Z]=q,I[q]=R[q]=R[Z],P=L[Z])}}})}),{root:R,align:I}}function h(b,k,E,C,R){var I={},L=f(b,k,E,R),H=R?"borderLeft":"borderRight";function P(D,F){for(var j=L.nodes(),Z=j.pop(),W={};Z;)W[Z]?D(Z):(W[Z]=!0,j.push(Z),j=j.concat(F(Z))),Z=j.pop()}function q(D){I[D]=L.inEdges(D).reduce(function(F,j){return Math.max(F,I[j.v]+L.edge(j))},0)}function B(D){var F=L.outEdges(D).reduce(function(Z,W){return Math.min(Z,I[W.w]-L.edge(W))},Number.POSITIVE_INFINITY),j=b.node(D);F!==Number.POSITIVE_INFINITY&&j.borderType!==H&&(I[D]=Math.max(I[D],F))}return P(q,L.predecessors.bind(L)),P(B,L.successors.bind(L)),e.forEach(C,function(D){I[D]=I[E[D]]}),I}function f(b,k,E,C){var R=new n,I=b.graph(),L=_(I.nodesep,I.edgesep,C);return e.forEach(k,function(H){var P;e.forEach(H,function(q){var B=E[q];if(R.setNode(B),P){var D=E[P],F=R.edge(D,B);R.setEdge(D,B,Math.max(L(b,q,P),F||0))}P=q})}),R}function g(b,k){return e.minBy(e.values(k),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,L){var H=S(b,L)/2;C=Math.max(I+H,C),R=Math.min(I-H,R)}),C-R})}function y(b,k){var E=e.values(k),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function(L){var H=I+L,P=b[H],q;if(P!==k){var B=e.values(P);q=L==="l"?C-e.min(B):R-e.max(B),q&&(b[H]=e.mapValues(P,function(D){return D+q}))}})})}function x(b,k){return e.mapValues(b.ul,function(E,C){if(k)return b[k.toLowerCase()][C];var R=e.sortBy(e.map(b,C));return(R[1]+R[2])/2})}function N(b){var k=r.buildLayerMatrix(b),E=e.merge(i(b,k),o(b,k)),C={},R;e.forEach(["u","d"],function(L){R=L==="u"?k:e.values(k).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(R=e.map(R,function(D){return e.values(D).reverse()}));var P=(L==="u"?b.predecessors:b.successors).bind(b),q=p(b,R,E,P),B=h(b,R,q.root,q.align,H==="r");H==="r"&&(B=e.mapValues(B,function(D){return-D})),C[L+H]=B})});var I=g(b,C);return y(C,I),x(C,b.graph().align)}function _(b,k,E){return function(C,R,I){var L=C.node(R),H=C.node(I),P=0,q;if(P+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":q=-L.width/2;break;case"r":q=L.width/2;break}if(q&&(P+=E?q:-q),q=0,P+=(L.dummy?k:b)/2,P+=(H.dummy?k:b)/2,P+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":q=H.width/2;break;case"r":q=-H.width/2;break}return q&&(P+=E?q:-q),q=0,P}}function S(b,k){return b.node(k).width}return Mg}var Pg,Kk;function N4(){if(Kk)return Pg;Kk=1;var e=ot(),n=on(),r=E4().positionX;Pg=i;function i(l){l=n.asNonCompoundGraph(l),o(l),e.forEach(r(l),function(u,c){l.node(c).x=u})}function o(l){var u=n.buildLayerMatrix(l),c=l.graph().ranksep,p=0;e.forEach(u,function(h){var f=e.max(e.map(h,function(g){return l.node(g).height}));e.forEach(h,function(g){l.node(g).y=p+f/2}),p+=f+c})}return Pg}var Og,Xk;function C4(){if(Xk)return Og;Xk=1;var e=ot(),n=l4(),r=u4(),i=d4(),o=on().normalizeRanks,l=f4(),u=on().removeEmptyRanks,c=h4(),p=p4(),h=m4(),f=k4(),g=N4(),y=on(),x=Xn().Graph;Og=N;function N($,Y){var te=Y&&Y.debugTiming?y.time:y.notime;te("layout",function(){var oe=te(" buildLayoutGraph",function(){return P($)});te(" runLayout",function(){_(oe,te)}),te(" updateInputGraph",function(){S($,oe)})})}function _($,Y){Y(" makeSpaceForEdgeLabels",function(){q($)}),Y(" removeSelfEdges",function(){U($)}),Y(" acyclic",function(){n.run($)}),Y(" nestingGraph.run",function(){c.run($)}),Y(" rank",function(){i(y.asNonCompoundGraph($))}),Y(" injectEdgeLabelProxies",function(){B($)}),Y(" removeEmptyRanks",function(){u($)}),Y(" nestingGraph.cleanup",function(){c.cleanup($)}),Y(" normalizeRanks",function(){o($)}),Y(" assignRankMinMax",function(){D($)}),Y(" removeEdgeLabelProxies",function(){F($)}),Y(" normalize.run",function(){r.run($)}),Y(" parentDummyChains",function(){l($)}),Y(" addBorderSegments",function(){p($)}),Y(" order",function(){f($)}),Y(" insertSelfEdges",function(){X($)}),Y(" adjustCoordinateSystem",function(){h.adjust($)}),Y(" position",function(){g($)}),Y(" positionSelfEdges",function(){M($)}),Y(" removeBorderNodes",function(){J($)}),Y(" normalize.undo",function(){r.undo($)}),Y(" fixupEdgeLabelCoords",function(){W($)}),Y(" undoCoordinateSystem",function(){h.undo($)}),Y(" translateGraph",function(){j($)}),Y(" assignNodeIntersects",function(){Z($)}),Y(" reversePoints",function(){ne($)}),Y(" acyclic.undo",function(){n.undo($)})}function S($,Y){e.forEach($.nodes(),function(te){var oe=$.node(te),ce=Y.node(te);oe&&(oe.x=ce.x,oe.y=ce.y,Y.children(te).length&&(oe.width=ce.width,oe.height=ce.height))}),e.forEach($.edges(),function(te){var oe=$.edge(te),ce=Y.edge(te);oe.points=ce.points,e.has(ce,"x")&&(oe.x=ce.x,oe.y=ce.y)}),$.graph().width=Y.graph().width,$.graph().height=Y.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],k={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],L={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function P($){var Y=new x({multigraph:!0,compound:!0}),te=O($.graph());return Y.setGraph(e.merge({},k,V(te,b),e.pick(te,E))),e.forEach($.nodes(),function(oe){var ce=O($.node(oe));Y.setNode(oe,e.defaults(V(ce,C),R)),Y.setParent(oe,$.parent(oe))}),e.forEach($.edges(),function(oe){var ce=O($.edge(oe));Y.setEdge(oe,e.merge({},L,V(ce,I),e.pick(ce,H)))}),Y}function q($){var Y=$.graph();Y.ranksep/=2,e.forEach($.edges(),function(te){var oe=$.edge(te);oe.minlen*=2,oe.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?oe.width+=oe.labeloffset:oe.height+=oe.labeloffset)})}function B($){e.forEach($.edges(),function(Y){var te=$.edge(Y);if(te.width&&te.height){var oe=$.node(Y.v),ce=$.node(Y.w),pe={rank:(ce.rank-oe.rank)/2+oe.rank,e:Y};y.addDummyNode($,"edge-proxy",pe,"_ep")}})}function D($){var Y=0;e.forEach($.nodes(),function(te){var oe=$.node(te);oe.borderTop&&(oe.minRank=$.node(oe.borderTop).rank,oe.maxRank=$.node(oe.borderBottom).rank,Y=e.max(Y,oe.maxRank))}),$.graph().maxRank=Y}function F($){e.forEach($.nodes(),function(Y){var te=$.node(Y);te.dummy==="edge-proxy"&&($.edge(te.e).labelRank=te.rank,$.removeNode(Y))})}function j($){var Y=Number.POSITIVE_INFINITY,te=0,oe=Number.POSITIVE_INFINITY,ce=0,pe=$.graph(),ve=pe.marginx||0,Pe=pe.marginy||0;function Me(Oe){var ye=Oe.x,Se=Oe.y,Ye=Oe.width,we=Oe.height;Y=Math.min(Y,ye-Ye/2),te=Math.max(te,ye+Ye/2),oe=Math.min(oe,Se-we/2),ce=Math.max(ce,Se+we/2)}e.forEach($.nodes(),function(Oe){Me($.node(Oe))}),e.forEach($.edges(),function(Oe){var ye=$.edge(Oe);e.has(ye,"x")&&Me(ye)}),Y-=ve,oe-=Pe,e.forEach($.nodes(),function(Oe){var ye=$.node(Oe);ye.x-=Y,ye.y-=oe}),e.forEach($.edges(),function(Oe){var ye=$.edge(Oe);e.forEach(ye.points,function(Se){Se.x-=Y,Se.y-=oe}),e.has(ye,"x")&&(ye.x-=Y),e.has(ye,"y")&&(ye.y-=oe)}),pe.width=te-Y+ve,pe.height=ce-oe+Pe}function Z($){e.forEach($.edges(),function(Y){var te=$.edge(Y),oe=$.node(Y.v),ce=$.node(Y.w),pe,ve;te.points?(pe=te.points[0],ve=te.points[te.points.length-1]):(te.points=[],pe=ce,ve=oe),te.points.unshift(y.intersectRect(oe,pe)),te.points.push(y.intersectRect(ce,ve))})}function W($){e.forEach($.edges(),function(Y){var te=$.edge(Y);if(e.has(te,"x"))switch((te.labelpos==="l"||te.labelpos==="r")&&(te.width-=te.labeloffset),te.labelpos){case"l":te.x-=te.width/2+te.labeloffset;break;case"r":te.x+=te.width/2+te.labeloffset;break}})}function ne($){e.forEach($.edges(),function(Y){var te=$.edge(Y);te.reversed&&te.points.reverse()})}function J($){e.forEach($.nodes(),function(Y){if($.children(Y).length){var te=$.node(Y),oe=$.node(te.borderTop),ce=$.node(te.borderBottom),pe=$.node(e.last(te.borderLeft)),ve=$.node(e.last(te.borderRight));te.width=Math.abs(ve.x-pe.x),te.height=Math.abs(ce.y-oe.y),te.x=pe.x+te.width/2,te.y=oe.y+te.height/2}}),e.forEach($.nodes(),function(Y){$.node(Y).dummy==="border"&&$.removeNode(Y)})}function U($){e.forEach($.edges(),function(Y){if(Y.v===Y.w){var te=$.node(Y.v);te.selfEdges||(te.selfEdges=[]),te.selfEdges.push({e:Y,label:$.edge(Y)}),$.removeEdge(Y)}})}function X($){var Y=y.buildLayerMatrix($);e.forEach(Y,function(te){var oe=0;e.forEach(te,function(ce,pe){var ve=$.node(ce);ve.order=pe+oe,e.forEach(ve.selfEdges,function(Pe){y.addDummyNode($,"selfedge",{width:Pe.label.width,height:Pe.label.height,rank:ve.rank,order:pe+ ++oe,e:Pe.e,label:Pe.label},"_se")}),delete ve.selfEdges})})}function M($){e.forEach($.nodes(),function(Y){var te=$.node(Y);if(te.dummy==="selfedge"){var oe=$.node(te.e.v),ce=oe.x+oe.width/2,pe=oe.y,ve=te.x-ce,Pe=oe.height/2;$.setEdge(te.e,te.label),$.removeNode(Y),te.label.points=[{x:ce+2*ve/3,y:pe-Pe},{x:ce+5*ve/6,y:pe-Pe},{x:ce+ve,y:pe},{x:ce+5*ve/6,y:pe+Pe},{x:ce+2*ve/3,y:pe+Pe}],te.label.x=te.x,te.label.y=te.y}})}function V($,Y){return e.mapValues(e.pick($,Y),Number)}function O($){var Y={};return e.forEach($,function(te,oe){Y[oe.toLowerCase()]=te}),Y}return Og}var Lg,Qk;function T4(){if(Qk)return Lg;Qk=1;var e=ot(),n=on(),r=Xn().Graph;Lg={debugOrdering:i};function i(o){var l=n.buildLayerMatrix(o),u=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(o.nodes(),function(c){u.setNode(c,{label:c}),u.setParent(c,"layer"+o.node(c).rank)}),e.forEach(o.edges(),function(c){u.setEdge(c.v,c.w,{},c.name)}),e.forEach(l,function(c,p){var h="layer"+p;u.setNode(h,{rank:"same"}),e.reduce(c,function(f,g){return u.setEdge(f,g,{style:"invis"}),g})}),u}return Lg}var qg,Zk;function R4(){return Zk||(Zk=1,qg="0.8.5"),qg}var $g,Jk;function j4(){return Jk||(Jk=1,$g={graphlib:Xn(),layout:C4(),debug:T4(),util:{time:on().time,notime:on().notime},version:R4()}),$g}var A4=j4();const eE=dv(A4),so=240,ou=130,Zi=74,Au=72,tE=Zi+Au;function I4(e,n){var i;let r=so;for(const o of e)r=Math.max(r,((i=n.get(o.id))==null?void 0:i.width)??so);return r}const QC=420,M4=2;function ha(e){var r;return((r=e.data)==null?void 0:r.sessionId)??"_default"}function P4(e,n){return((n==null?void 0:n.get(e))??0)>0?QC:0}function O4(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 i=n.get(e);return{w:((i==null?void 0:i.width)??so)+P4(e,r),h:Math.max((i==null?void 0:i.height)??ou,O4(e,r))}}function L4(e){return[...e.keys()].sort().map(n=>`${n}:${e.get(n)}`).join("|")}function q4(e,n,r,i,o,l){const u=new eE.graphlib.Graph;u.setDefaultEdgeLabel(()=>({})),u.setGraph({rankdir:r,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!o.has(b)),p=new Set(c);for(const b of c){const{w:k,h:E}=pa(b,i,l);u.setNode(b,{width:k,height:E})}for(const b of n)p.has(b.source)&&p.has(b.target)&&u.setEdge(b.source,b.target);eE.layout(u);const h=new Map;let f=1/0,g=1/0,y=-1/0,x=-1/0;for(const b of c){const k=u.node(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??so,R=(E==null?void 0:E.height)??ou,I=pa(b,i,l),L=k.x-I.w/2,H=k.y-I.h/2;h.set(b,{x:L,y:H}),L<f&&(f=L),H<g&&(g=H),L+C>y&&(y=L+C),H+R>x&&(x=H+R)}if(Number.isFinite(f)&&Number.isFinite(g))for(const[b,k]of h)h.set(b,{x:k.x-f,y:k.y-g});const N=Number.isFinite(y)?y-f:0,_=Number.isFinite(x)?x-g:0;let S=null;for(const b of e){const k=o.get(b);if(!k)continue;const E=i.get(b),C=(E==null?void 0:E.width)??so,R=(E==null?void 0:E.height)??ou;S=S===null?{minX:k.x,minY:k.y,maxX:k.x+C,maxY:k.y+R}:{minX:Math.min(S.minX,k.x),minY:Math.min(S.minY,k.y),maxX:Math.max(S.maxX,k.x+C),maxY:Math.max(S.maxY,k.y+R)}}return{positions:h,width:N,height:_,pinnedBox:S}}function $4(e,n,r={}){const i=r.direction??"LR",o=r.pinned??new Map,l=r.measured??new Map,u=r.lanes,c=new Map;for(const b of e){const k=ha(b),E=c.get(k);E?E.push(b.id):c.set(k,[b.id])}const h=Array.from(c.keys()).sort().map(b=>({sid:b,...q4(c.get(b),n,i,l,o,u)})),f=I4(e,l),g=r.availableHeight&&r.availableHeight>0?r.availableHeight:Number.POSITIVE_INFINITY,y=b=>{const k=[[]];let E=0;for(const C of h)k.length<b&&E>0&&E+C.height>g&&(k.push([]),E=0),k[k.length-1].push(C),E+=C.height+tE;return k},x=b=>b.reduce((k,E)=>Math.max(k,E.width),0)+QC;let N=y(r.availableWidth?M4: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 S=0;for(const b of N){const k=x(b);let E=0;for(const{positions:C,height:R,pinnedBox:I}of b){for(const[H,P]of C)_.set(H,{x:P.x+S,y:P.y+E});let L=E+R;I&&I.maxY>L&&I.minX<S+k&&S<I.maxX&&(L=I.maxY),E=L+tE}S+=k+f}return e.map(b=>{const k=o.get(b.id);if(k)return{...b,position:k};const E=_.get(b.id);return E?{...b,position:E}:b})}function D4(e,n,r,i,o){const u=Zi+Au,c=60,p=x=>pa(x,i,o),h=new Map(e.map(x=>[x.id,ha(x)])),f=[],g=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 g){const{w:_,h:S}=p(x),b=h.get(x)??"_default";if(r.has(x)){f.push({x:N.x,y:N.y,w:_,h:S,sid:b});continue}let k=N.y;for(let E=0;E<f.length+1;E++){const C=f.find(R=>{const I=R.sid===b?24:c,L=R.sid===b?24:u;return N.x<R.x+R.w+I&&R.x<N.x+_+I&&k<R.y+R.h+L&&R.y<k+S+L});if(!C)break;k=C.y+C.h+(C.sid===b?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:S,sid:b})}return y}function F4(e,n,r,i,o,l){const u=_=>pa(_,i,l),c=_=>r.get(_)??n.get(_),p=new Map;for(const _ of e){if(!c(_.id))continue;const S=ha(_),b=p.get(S);b?b.push(_):p.set(S,[_])}const h=new Set;for(const[_,S]of p)S.every(b=>o.has(b.id)&&!r.has(b.id))&&h.add(_);const f=new Map,g=[];for(const _ of e){const S=c(_.id);if(!S)continue;const{w:b,h:k}=u(_.id),E=ha(_);h.has(E)?(f.get(E)??f.set(E,[]).get(E)).push(_):g.push({x:S.x,y:S.y,w:b,h:k})}if(f.size===0)return[];const y=Zi+Au,x=(_,S,b,k)=>g.some(E=>_<E.x+E.w+Zi&&E.x<_+b+Zi&&S<E.y+E.h+y&&E.y<S+k+y),N=[];for(const _ of[...f.keys()].sort()){const S=f.get(_);let b=1/0,k=1/0,E=-1/0,C=-1/0;for(const B of S){const D=c(B.id),{w:F,h:j}=u(B.id);b=Math.min(b,D.x),k=Math.min(k,D.y),E=Math.max(E,D.x+F),C=Math.max(C,D.y+j)}const R=E-b,I=C-k,L=[...new Set(g.map(B=>Math.round(B.x)))].sort((B,D)=>B-D),H=L.length?L:[b],P=[0,...g.map(B=>B.y+B.h+y)].sort((B,D)=>B-D);let q=null;e:for(const B of H)for(const D of P){if(D>=k)break;if(!x(B,D,R,I)){q={x:B,y:D};break e}}if(q){const B=q.x-b,D=q.y-k;for(const F of S){const j=c(F.id);n.set(F.id,{x:j.x+B,y:j.y+D})}N.push(_)}for(const B of S){const D=c(B.id),{w:F,h:j}=u(B.id);g.push({x:D.x,y:D.y,w:F,h:j})}}return N}function z4(e,n,r,i,o,l=!1,u){const h=Zi+Au+1,f=8,g=1.75,y=200,x=.7,N=.01,_=q=>pa(q,i,u),S=q=>r.get(q)??n.get(q),b=new Map;for(const q of e){if(!S(q.id))continue;const B=ha(q),D=b.get(B);D?D.push(q):b.set(B,[q])}const k=[],E=new Set,C=new Set,R=o.size===0;for(const q of[...b.keys()].sort()){const B=b.get(q);let D=1/0,F=1/0,j=-1/0,Z=-1/0,W=!1;for(const X of B){const M=S(X.id),{w:V,h:O}=_(X.id);D=Math.min(D,M.x),F=Math.min(F,M.y),j=Math.max(j,M.x+V),Z=Math.max(Z,M.y+O),r.has(X.id)&&(W=!0)}const ne=j-D,J=Z-F;C.add(q);const U=o.get(q);U&&(ne>U.w+f||J>U.h+f)&&E.add(q),o.set(q,{w:ne,h:J}),k.push({sid:q,members:B.map(X=>X.id),x:D,y:F,w:ne,h:J,anchored:W,mass:1})}for(const q of[...o.keys()])C.has(q)||o.delete(q);if(l||R)return[];let I=!1;for(let q=0;q<k.length&&!I;q++)for(let B=q+1;B<k.length;B++){const D=k[q],F=k[B];if(!(D.anchored&&F.anchored)&&Math.abs(D.x+D.w/2-(F.x+F.w/2))<(D.w+F.w)/2+61&&Math.abs(D.y+D.h/2-(F.y+F.h/2))<(D.h+F.h)/2+h){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const q of k)E.has(q.sid)&&(q.mass=8);else for(const q of k)q.mass=Math.max(1,q.w*q.h/(so*ou));const L=new Map(k.map(q=>[q.sid,q.x])),H=new Map(k.map(q=>[q.sid,q.y]));for(let q=0;q<y;q++){const B=new Map,D=new Map;let F=0;for(let j=0;j<k.length;j++)for(let Z=j+1;Z<k.length;Z++){const W=k[j],ne=k[Z];if(W.anchored&&ne.anchored)continue;const J=W.x+W.w/2,U=W.y+W.h/2,X=ne.x+ne.w/2,M=ne.y+ne.h/2,V=(W.w+ne.w)/2+61-Math.abs(J-X),O=(W.h+ne.h)/2+h-Math.abs(U-M);if(V<=0||O<=0)continue;const $=(De,Qe)=>!De.anchored&&!(Qe<0&&De.x<=0),Y=(De,Qe)=>!De.anchored&&!(Qe<0&&De.y<=0),te=(De,Qe,at)=>{const Mt=De===Qe,rt=Mt?W.sid<ne.sid?-1:1:Math.sign(De-Qe);return at(W,rt)||at(ne,-rt)?rt:Mt&&(at(W,-rt)||at(ne,rt))?-rt:0},oe=te(J,X,$),ce=te(U,M,Y),pe=oe!==0,ve=ce!==0;if(!pe&&!ve)continue;const Pe=pe&&(!ve||V*g<O),[Me,Oe,ye,Se]=Pe?[oe,V,B,$]:[ce,O,D,Y],Ye=Se(W,Me),we=Se(ne,-Me),ge=W.mass,Fe=ne.mass,pt=Ye?we?Fe/(ge+Fe):1:0,mt=we?Ye?ge/(ge+Fe):1:0,Ze=Oe*x;ye.set(W.sid,(ye.get(W.sid)??0)+Me*Ze*pt),ye.set(ne.sid,(ye.get(ne.sid)??0)-Me*Ze*mt),F+=Ze}for(const j of k)j.anchored||(j.x=Math.max(0,j.x+(B.get(j.sid)??0)),j.y=Math.max(0,j.y+(D.get(j.sid)??0)));if(F<N)break}const P=[];for(const q of k){const B=q.x-L.get(q.sid),D=q.y-H.get(q.sid);if(!(Math.abs(B)<1&&Math.abs(D)<1)){for(const F of q.members){if(r.has(F))continue;const j=n.get(F);j&&n.set(F,{x:j.x+B,y:j.y+D})}P.push(q.sid)}}return P}const B4=600;function lv(e,n){return!(e.exitAt!=null&&n-e.exitAt>B4||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function U4(e,n){const r=new Set;for(const i of e.agents.values())lv(i,n)&&r.add(i.id);return r}function H4(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 W4(e,n,r=0){if(!e)return!1;for(const i of n)if(H4(e,i,r))return!0;return!1}const ZC="sessionGroup";function V4(e,n){var i;if(e.type===ZC)return"transparent";const r=(i=e.data)==null?void 0:i.state;return n(r==="err"?"--err":r==="active"?"--inflight":"--ok")}const G4="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1).";function Y4(e){if(e.checkDisabled)return G4;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 K4(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 X4(e){return e<1e3?`${e}`:e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}const Q4={agent:uO,sessionGroup:_O},Z4=420,Bl=18,J4=9e4,e5=200,t5=5*6e4,n5=6,r5=2*6e4,Xv="agent-dag.layout",Qv="agent-dag.viewport",JC="agent-dag.summariesDismissed",eT="agent-dag.sessionListOpen",tT="agent-dag.detailOpen",nT="agent-dag.usagePanelOpen",nE="agent-dag.accountsPanelOpen",rE="agent-dag.versionNoticeDismissed",s5=15*6e4,sE={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 i5(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 iE="agent-dag.autoRestart",oE="agent-dag.bundleReloadedFor";function o5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(eT)==="1"}catch{return!1}}function a5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(eT,e?"1":"0")}catch{}}function l5(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(tT)==="1"}catch{return!1}}function u5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(tT,e?"1":"0")}catch{}}function c5(){const e=QN(nT);return e===null?!0:e==="1"}function d5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(nT,e?"1":"0")}catch{}}function f5(){if(typeof window>"u")return new Set;try{const e=window.localStorage.getItem(JC);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 aE(e){if(!(typeof window>"u"))try{const n=Array.from(e),r=n.length>200?n.slice(-200):n;window.localStorage.setItem(JC,JSON.stringify(r))}catch{}}function h5(){const e={positions:[],pins:[]};if(typeof window>"u")return e;try{const n=window.localStorage.getItem(Xv);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 Dg(e,n){if(!(typeof window>"u"))try{const r={};for(const[i,o]of e)r[i]=o;for(const[i,o]of n)r[i]=o;window.localStorage.setItem(Xv,JSON.stringify({v:2,positions:r,pins:Array.from(n.keys())}))}catch{}}function p5(){if(typeof window>"u")return null;try{const e=window.localStorage.getItem(Qv);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 m5(e){if(!(typeof window>"u"))try{window.localStorage.setItem(Qv,JSON.stringify(e))}catch{}}function lE(){if(!(typeof window>"u")){try{window.localStorage.removeItem(Xv)}catch{}try{window.localStorage.removeItem(Qv)}catch{}}}function g5(e,n){const r=e.agents.get(n);if(!r)return;const i=[];for(const f of e.agents.values())f.sessionId===n&&i.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:i.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(g=>({id:g.id,name:g.name,inputPreview:g.inputPreview,startedAt:g.startedAt,endedAt:g.endedAt,ok:g.ok,errorPreview:g.errorPreview,usage:g.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 uv={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},cv={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},v5={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 rT(e){return e.startsWith("mcp__")?"mcp":v5[e]??"other"}function sT(e,n){var i,o,l;if(!n)return!0;const r=n.toLowerCase();if(e.label.toLowerCase().includes(r)||(i=e.cwd)!=null&&i.toLowerCase().includes(r)||(o=e.cwdBasename)!=null&&o.toLowerCase().includes(r)||e.sessionId.toLowerCase().includes(r)||(l=e.firstPrompt)!=null&&l.toLowerCase().includes(r))return!0;for(const u of e.tools)if(u.name.toLowerCase().includes(r))return!0;return!1}function y5(e,n){if(!n)return null;const r=new Set([n]);let i=n;for(;i;){const l=e.agents.get(i);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),i=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function w5(e,n,r,i,o,l,u,c,p,h,f,g,y,x,N,_,S,b,k){const E=[],C=[],R=new Set;if(l)for(const D of e.agents.values())sT(D,l)&&R.add(D.id);for(const D of e.agents.values()){if(!b.has(D.id))continue;const F=l?!R.has(D.id):!1,j=D.exitAt!=null,Z=S!=null&&!S.has(D.id),W=[F?"rf-dim":"",j?"rf-exiting":"",Z?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,ne=u.get(D.id);if(E.push({id:D.id,type:"agent",position:{x:0,y:0},data:{...D,now:n,onOpenContext:k},className:W,...ne?{width:ne.width,height:ne.height}:null}),D.parentId&&b.has(D.parentId)){const J=jv(D.sessionId),U=D.state==="active"?`hsl(${J} 80% 72%)`:`hsl(${J} 50% 55%)`,X=l&&!R.has(D.id)&&!R.has(D.parentId),M=j,V=_.size>0&&(_.has(D.id)||_.has(D.parentId)),O=S!=null&&!S.has(D.id)&&!S.has(D.parentId),$=D.state==="active"?2:1.5,Y=V?$+1.5:$,te=X||M?.2:O?.12:1,oe=[M?"rf-edge-exiting":"",V?"rf-edge-selected":""].filter(Boolean).join(" ")||void 0;C.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||V)&&!X&&!M,type:"smoothstep",style:{stroke:U,strokeWidth:Y,opacity:te,transition:"opacity 500ms ease, stroke-width 200ms ease"},className:oe})}}const I=new Map;for(const D of e.agents.values())D.tools.length>0&&I.set(D.id,Math.min(4,D.tools.length));const L=`${x}#lanes:${L4(I)}`,H=E.filter(D=>eL(D.id,o,g,y));if(H.length>0||L!==N.current){if(H.length>0){const D=$4(E,C,{direction:"LR",pinned:o,measured:u,availableWidth:r,availableHeight:i,lanes:I});for(const F of D)XN(F.id,g,y)&&nL(F.id,F.position,g,y);F4(E,g,o,u,new Set(H.map(F=>F.id)),I)}D4(E,g,o,u,I),N.current=L}const P=z4(E,g,o,u,c,!h||f,I);P.length>0&&p(P),$l(g,e.agents),$l(y,e.agents),$l(o,e.agents),$l(u,J3(e.agents.values()));const q=[];let B=!1;for(const D of E){let F=o.get(D.id)??g.get(D.id);F||(F=tL(D.id,g,y),B=!0),q.push({...D,position:F})}return B&&(N.current=""),{nodes:q,edges:C}}function x5(){return m.jsx(Tv,{children:m.jsx(_5,{})})}function _5(){var wo,Ts,Rs,xo;const e=wa(),n=A.useRef(nv()),[,r]=A.useState(0),i=A.useCallback(()=>r(G=>G+1),[]),[o,l]=A.useState(()=>new Set),[u,c]=A.useState(null),[p,h]=A.useState(null),f=A.useCallback((G,Q)=>{l(ae=>{if(!Q)return new Set([G]);const ue=new Set(ae);return ue.has(G)?ue.delete(G):ue.add(G),ue}),c(ae=>Q&&ae===G?ae:G)},[]),g=A.useCallback(()=>{l(new Set),c(null)},[]),[y,x]=A.useState(null),[N,_]=A.useState(null),S=A.useCallback(G=>_(G),[]),[b,k]=A.useState(!1),E=A.useRef(f5()),[C,R]=A.useState(o5);A.useEffect(()=>{a5(C)},[C]);const[I,L]=A.useState(l5);A.useEffect(()=>{u5(I)},[I]);const[H,P]=A.useState(c5);A.useEffect(()=>{d5(H)},[H]);const[q,B]=A.useState(()=>{try{const G=window.localStorage.getItem(nE);return G===null?!0:G==="1"}catch{return!0}});A.useEffect(()=>{try{window.localStorage.setItem(nE,q?"1":"0")}catch{}},[q]);const[D,F]=A.useState(null),[j,Z]=A.useState(!1),[W,ne]=A.useState(0),[J,U]=A.useState(0);A.useEffect(()=>{fetch("/api/sound-hook").then(G=>G.ok?G.json():null).then(G=>{G!=null&&G.ok&&(F(G.enabled===!0),ne((G.foreign??[]).filter(Q=>Q.worksHere).length),U(typeof G.parked=="number"?G.parked:0))}).catch(()=>{})},[]);const X=A.useCallback(async()=>{Z(!0);try{const Q=await(await fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:!D})})).json().catch(()=>null);Q!=null&&Q.ok&&F(Q.enabled===!0),fetch("/api/sound-hook").then(ae=>ae.ok?ae.json():null).then(ae=>{ae!=null&&ae.ok&&(ne((ae.foreign??[]).filter(ue=>ue.worksHere).length),U(typeof ae.parked=="number"?ae.parked:0))}).catch(()=>{})}catch{}finally{Z(!1)}},[D]),[M,V]=A.useState(!1),[O,$]=A.useState(null),[Y,te]=A.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(rE)??""}catch{return""}}),[oe,ce]=A.useState(!1),pe=A.useRef(0),[ve,Pe]=A.useState(!1),Me=A.useCallback((G=!1)=>{G&&(pe.current=Date.now(),Pe(!0)),fetch(G?"/api/version?refresh=1":"/api/version").then(Q=>Q.ok?Q.json():null).then(Q=>{Q&&$(Q)}).catch(()=>{}).finally(()=>{G&&Pe(!1)})},[]),Oe=A.useCallback(()=>{Me(Date.now()-pe.current>=s5)},[Me]);A.useEffect(()=>{Me();const G=window.setInterval(Oe,5*6e4),Q=()=>{document.visibilityState==="visible"&&Oe()};return document.addEventListener("visibilitychange",Q),()=>{window.clearInterval(G),document.removeEventListener("visibilitychange",Q)}},[Me,Oe]),A.useEffect(()=>{M&&Me()},[M,Me]);const ye=(O==null?void 0:O.notice)??null,Se=ye?`${ye.kind}:${ye.to}`:"",Ye=ye!=null&&Y!==Se,we=A.useCallback(()=>{if(!ye)return;const G=Y===Se?"":Se;te(G);try{window.localStorage.setItem(rE,G)}catch{}},[ye,Se,Y]),ge=((wo=O==null?void 0:O.upgrade)==null?void 0:wo.state)??"idle",Fe=U3(O==null?void 0:O.upgrade),pt=A.useCallback(async()=>{try{await fetch("/api/upgrade",{method:"POST"})}catch{}Me()},[Me]);A.useEffect(()=>{if(ge!=="running")return;const G=window.setInterval(Me,3e3);return()=>window.clearInterval(G)},[ge,Me]);const mt=A.useCallback(async()=>{var ae;const G=O==null?void 0:O.command;if(!G)return;let Q=!1;try{Q=await Promise.race([((ae=navigator.clipboard)==null?void 0:ae.writeText(G).then(()=>!0))??Promise.resolve(!1),new Promise(ue=>window.setTimeout(()=>ue(!1),500))])}catch{Q=!1}if(!Q)try{const ue=document.createElement("textarea");ue.value=G,ue.setAttribute("readonly",""),ue.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(ue),ue.select(),Q=document.execCommand("copy"),ue.remove()}catch{Q=!1}Q&&(ce(!0),window.setTimeout(()=>ce(!1),1600))},[O==null?void 0:O.command]),Ze=A.useCallback(()=>{R(G=>(G||B(!1),!G))},[]),De=A.useCallback(()=>{B(G=>(G||R(!1),!G))},[]),[Qe,at]=A.useState(!1),[Mt,rt]=A.useState(0),gt=A.useRef(null),[Kt,Pt]=A.useState(!1),Ge=A.useRef(null),[Nt,dt]=A.useState(0),lt=A.useRef(oL()),[hn,Ht]=A.useState(!1),Ct=A.useCallback(()=>{const G=lt.current,Q=G.setPaused(!G.paused);for(const ae of Q)n.current=fx(n.current,ae);Ht(G.paused)},[]),[Je,fr]=A.useState(Date.now()),[Wt,pn]=A.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(iE)!=="0"}catch{return!0}}),jn=A.useCallback(()=>{pn(G=>{const Q=!G;try{window.localStorage.setItem(iE,Q?"1":"0")}catch{}return Q})},[]),[Tt,hr]=A.useState(!1),[ii,oi]=A.useState("restart"),[ms,qr]=A.useState(null),An=A.useRef(!1),Jn=A.useRef(null),$r=A.useRef(0),mn=A.useCallback(async G=>{if(An.current)return;const Q=(G==null?void 0:G.upgrade)===!0;An.current=!0,Jn.current=Fe;const ae=++$r.current;oi(Q?"npx":"restart"),hr(!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:Q})})}catch{}window.setTimeout(()=>{if($r.current===ae&&An.current){An.current=!1,hr(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},Q?18e4:3e4)},[ye==null?void 0:ye.to,Fe]),ai=A.useRef(null);A.useEffect(()=>{let G=!1;for(const ae of n.current.agents.values())if(ae.state==="active"){G=!0;break}const Q=W3({enabled:Wt,kind:ye==null?void 0:ye.kind,canRestart:(O==null?void 0:O.canRestart)===!0,busy:G,idleSince:ai.current,now:Je});ai.current=Q.idleSince,Q.restart&&mn()},[Wt,ye==null?void 0:ye.kind,O==null?void 0:O.canRestart,Je,mn]),A.useEffect(()=>{const G=O==null?void 0:O.running;let Q=null,ae=null;try{Q=window.sessionStorage.getItem("agent-dag.restartPending"),ae=window.sessionStorage.getItem(oE)}catch{return}const ue=B3({bundle:"1.33.124",running:G,pending:Q,lastTried:ae});if(ue==="reload"){try{window.sessionStorage.setItem(oE,G??"")}catch{return}window.location.reload();return}if(ue!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}An.current=!1,hr(!1),qr(G??null);const xe=window.setTimeout(()=>qr(null),6e3);return()=>window.clearTimeout(xe)},[O==null?void 0:O.running]),A.useEffect(()=>{if(Tt&&H3({asked:Jn.current,reported:Fe})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}An.current=!1,hr(!1)}},[Tt,Fe]);const In=A.useRef(h5()).current;A.useRef(!1);const wt=A.useRef(new Map(In.positions.filter(([G])=>In.pins.includes(G)))),Mn=A.useRef(null),er=A.useState(()=>p5())[0],[Pn,li]=A.useState(""),[gs,On]=A.useState(()=>new Set),[tr,vs]=A.useState(()=>QN("agent-dag.theme")??"dark"),[ui,ci]=A.useState(!1),ys=A.useRef(null);A.useEffect(()=>{document.documentElement.dataset.theme=tr;try{window.localStorage.setItem("agent-dag.theme",tr)}catch{}},[tr]),A.useEffect(()=>{if(!er)return;const G=window.setTimeout(()=>{try{e.setViewport(er,{duration:0})}catch{}},60);return()=>window.clearTimeout(G)},[e,er]);const ws=A.useRef(!0);A.useEffect(()=>{const G=new EventSource("/events"),Q=iL(i,{now:()=>Date.now(),setTimeout:(ae,ue)=>window.setTimeout(ae,ue),clearTimeout:ae=>window.clearTimeout(ae)});return G.addEventListener("open",()=>{V(!0),ci(!0)}),G.addEventListener("error",()=>V(!1)),G.addEventListener("replay-end",()=>{ws.current=!1,Q.flush()}),G.addEventListener("hook",ae=>{try{const ue=JSON.parse(ae.data);if(!lt.current.accept(ue))return;n.current=fx(n.current,ue),ue.replay===!0||ws.current||Date.now()-ue.receivedAt>3e4?Q.replay():Q.live()}catch{}}),()=>{G.close(),Q.cancel()}},[i]),A.useEffect(()=>{const G=setInterval(()=>{const Q=Date.now();fr(Q);let ae=UP(n.current,Q,J4);zP(n.current,Q,e5,t5)&&(ae=!0),BP(n.current,Q,n5,r5)&&(ae=!0),ae&&i()},250);return()=>clearInterval(G)},[i]);const Dr=A.useRef(null),Ln=A.useRef(0),fo=420,Be=A.useCallback((G=500)=>{try{const ke=document.querySelector(".canvas-wrap"),Re=Array.from(document.querySelectorAll(".react-flow__node")).filter(vt=>vt.offsetWidth>0);if(!ke||Re.length===0)return;const Le=ke.getBoundingClientRect(),He=e.getViewport();if(!Number.isFinite(He.zoom)||He.zoom<=0)return;const Ke=vt=>(vt-Le.left-He.x)/He.zoom,st=vt=>(vt-Le.top-He.y)/He.zoom,yn=Re.map(vt=>vt.getBoundingClientRect()),js=Math.min(...yn.map(vt=>Ke(vt.left))),As=Math.max(...yn.map(vt=>Ke(vt.right))),Is=Math.min(...yn.map(vt=>st(vt.top))),_o=Math.max(...yn.map(vt=>st(vt.bottom))),ja=As-js,xi=_o-Is;if(!(ja>0&&xi>0))return;const Dn=Math.max(.2,Math.min(1,(Le.width-160)/(ja+fo)*.86,(Le.height-160)/xi*.86));e.setViewport({x:80-js*Dn,y:Math.max(80,(Le.height-xi*Dn)/2)-Is*Dn,zoom:Dn},{duration:G}),Ln.current=Date.now(),window.setTimeout(()=>{try{const vt={x:80-js*Dn,y:Math.max(80,(Le.height-xi*Dn)/2)-Is*Dn,zoom:Dn},Aa=e.getViewport();(Math.abs(Aa.zoom-Dn)>.01||Math.abs(Aa.x-vt.x)>2)&&e.setViewport(vt,{duration:0})}catch{}},G+60)}catch{}},[e]),xs=A.useRef(""),pr=A.useRef(null),_s=A.useRef(0),qn=A.useCallback(()=>{_s.current=Date.now()},[]),Fr="agent-dag.autoFitDisabled",gn=A.useRef((()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Fr)==="1"}catch{return!1}})()),[mr,Vt]=A.useState(gn.current),zr=A.useCallback(()=>{if(!gn.current){gn.current=!0,Vt(!0);try{window.localStorage.setItem(Fr,"1")}catch{}}},[]),an=A.useCallback(()=>{gn.current=!1,Vt(!1);try{window.localStorage.removeItem(Fr)}catch{}Be(400)},[e,Be]);A.useEffect(()=>{const G=setInterval(()=>{if(gn.current||Date.now()-_s.current<800)return;const Q=n.current,ae=Date.now(),ue=[];for(const Ke of Q.agents.values())lv(Ke,ae)&&ue.push({id:Ke.id});if(ue.length===0)return;const xe=e.getViewport(),ke=window.innerWidth-360,Re=window.innerHeight-52;let Le=!1,He=!1;for(const{id:Ke}of ue){const st=Br.current.get(Ke),yn=wt.current.get(Ke)??Xt.current.get(Ke);if(!st||!yn)continue;He=!0;const js=yn.x*xe.zoom+xe.x,As=yn.y*xe.zoom+xe.y,Is=(yn.x+st.width)*xe.zoom+xe.x,_o=(yn.y+st.height)*xe.zoom+xe.y;if(Is>0&&js<ke&&_o>0&&As<Re){Le=!0;break}}He&&!Le&&Be(600)},1500);return()=>clearInterval(G)},[e]);const ho=A.useRef(!1),Br=A.useRef(new Map),Ea=A.useRef(0),di=A.useCallback(G=>{const Q=Br.current;let ae=!1;for(const ue of G.nodeInternals.values()){const xe=ue.width,ke=ue.height;if(xe==null||ke==null)continue;const Re=Q.get(ue.id);Re?(Math.abs(Re.height-ke)>4||Math.abs(Re.width-xe)>4)&&(Q.set(ue.id,{width:xe,height:ke}),ae=!0):(Q.set(ue.id,{width:xe,height:ke}),ae=!0)}return ae&&(Ea.current+=1),Ea.current},[]),bs=Xe(di),[Ur,fi]=A.useState(0);A.useEffect(()=>{let G=0;const Q=()=>{const ue=Br.current;let xe=!1;for(const ke of document.querySelectorAll(".react-flow__node[data-id]")){const Re=ke.getAttribute("data-id");if(!Re)continue;const Le=ke.offsetWidth,He=ke.offsetHeight;if(!Le||!He)continue;const Ke=ue.get(Re);(!Ke||Math.abs(Ke.width-Le)>4||Math.abs(Ke.height-He)>4)&&(ue.set(Re,{width:Le,height:He}),xe=!0)}xe&&fi(ke=>ke+1)};if(ho.current)return;let ae=0;return document.visibilityState==="hidden"?ae=window.setTimeout(Q,32):G=requestAnimationFrame(Q),()=>{cancelAnimationFrame(G),window.clearTimeout(ae)}});const Xt=A.useRef(new Map(In.positions)),Iu=A.useRef(new Set),Ss=A.useRef(""),gr=A.useMemo(()=>{const G=[];for(const Q of n.current.agents.values())lv(Q,Je)&&G.push(Q.id+(Q.parentId?`>${Q.parentId}`:""));return G.sort(),`${G.join("|")}#sv${bs}.${Ur}`},[n.current,n.current.lastSeq,Je,bs,Ur]),vr=A.useRef(null);A.useEffect(()=>(vr.current!=null&&window.clearTimeout(vr.current),vr.current=window.setTimeout(()=>{Dg(Xt.current,wt.current)},1500),()=>{vr.current!=null&&window.clearTimeout(vr.current)}),[gr]),A.useEffect(()=>{if(xs.current===gr)return;const G=xs.current;if(xs.current=gr,!G||gn.current)return;Date.now()-Ln.current>1200&&Be(400),Dr.current&&window.clearTimeout(Dr.current),Dr.current=window.setTimeout(()=>{gn.current||Be(500)},280)},[gr,e,Be]);const yr=A.useMemo(()=>{if(o.size===0)return null;const G=new Set;for(const Q of o){const ae=y5(n.current,Q);if(ae)for(const ue of ae)G.add(ue)}return G.size>0?G:null},[n.current,n.current.lastSeq,o]),po=A.useMemo(()=>U4(n.current,Je),[n.current,n.current.lastSeq,Je]),hi=A.useRef(null),[Ue,mo]=A.useState({w:0,h:0});A.useEffect(()=>{const G=hi.current;if(!G||typeof ResizeObserver>"u")return;const Q=new ResizeObserver(ae=>{var xe;const ue=(xe=ae[0])==null?void 0:xe.contentRect;ue&&mo(ke=>Math.abs(ke.w-ue.width)>40||Math.abs(ke.h-ue.height)>40?{w:ue.width,h:ue.height}:ke)});return Q.observe(G),mo({w:G.clientWidth,h:G.clientHeight}),()=>Q.disconnect()},[]);const Na=A.useRef(new Map),[pi,Ca]=A.useState(!1);A.useEffect(()=>{const G=window.setTimeout(()=>Ca(!0),2500);return()=>window.clearTimeout(G)},[]);const[Ta,mi]=A.useState(!1),vn=A.useRef(null),[Hr,$n]=A.useState(!1),nr=A.useCallback(()=>{vn.current&&(window.clearTimeout(vn.current),vn.current=null),mi(!1)},[]),rr=A.useCallback(G=>{G.length!==0&&queueMicrotask(()=>{mi(!0),vn.current&&window.clearTimeout(vn.current),vn.current=window.setTimeout(()=>mi(!1),Z4+80)})},[]);A.useEffect(()=>()=>{vn.current&&window.clearTimeout(vn.current)},[]);const Wr=Ue.w>0?Ue.w*.92:0,Vr=Ue.h>0?Ue.h:0,{nodes:Rt,edges:Mu}=A.useMemo(()=>w5(n.current,Je,Wr,Vr,wt.current,Pn,Br.current,Na.current,rr,pi,Hr,Xt.current,Iu.current,gr,Ss,o,yr,po,S),[n.current,n.current.lastSeq,Je,Wr,Vr,pi,Hr,Pn,gr,o,yr,po,S,Mt]),go=A.useMemo(()=>{const G=new Map;for(const ae of Rt){const ue=ae.data;if(!(ue!=null&&ue.sessionId)||ue.exitAt!=null)continue;const xe=ae.width,ke=ae.height;if(xe==null||ke==null)continue;const Re=ae.position.x,Le=ae.position.y,He=Re+xe,Ke=Le+ke,st=G.get(ue.sessionId);st?(st.minX=Math.min(st.minX,Re),st.minY=Math.min(st.minY,Le),st.maxX=Math.max(st.maxX,He),st.maxY=Math.max(st.maxY,Ke)):G.set(ue.sessionId,{minX:Re,minY:Le,maxX:He,maxY:Ke})}const Q=[];for(const[ae,ue]of G){const xe=ue.maxX-ue.minX+Bl*2,ke=ue.maxY-ue.minY+Bl*2;Q.push({id:`group:${ae}`,type:ZC,position:{x:ue.minX-Bl,y:ue.minY-Bl},data:{sessionId:ae,w:xe,h:ke},width:xe,height:ke,style:{width:xe,height:ke},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return Q},[Rt,Je]),ks=A.useMemo(()=>{const G=[...go,...Rt],Q=Ge.current;return!Q||Q.size===0?G:G.map(ae=>{const ue=Q.get(ae.id);return ue?{...ae,position:ue}:ae})},[go,Rt,Nt]),Pu=A.useMemo(()=>{if(!Pn)return null;const G=new Set;for(const Q of n.current.agents.values())sT(Q,Pn)&&G.add(Q.id);return G},[n.current,n.current.lastSeq,Pn]),Es=A.useMemo(()=>{const G=new Set;for(const Q of n.current.agents.values())for(const ae of Q.tools)G.add(rT(ae.name));return Object.keys(uv).filter(Q=>G.has(Q))},[n.current,n.current.lastSeq]);A.useEffect(()=>{if(Es.length<=1){Pt(!1);return}let G=0;const Q=()=>{const ae=gt.current;if(ae&&!document.hidden){const ue=ae.getBoundingClientRect(),xe=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Re=>Re.getBoundingClientRect()),ke=W4(ue,xe,8);Pt(Re=>Re===ke?Re:ke)}G=window.setTimeout(Q,300)};return Q(),()=>window.clearTimeout(G)},[Es.length]);const sr=A.useMemo(()=>{const G=new Map;for(const ae of n.current.agents.values())for(const ue of ae.tools){if(!ue.name.startsWith("mcp__"))continue;const xe=ue.name.slice(5),ke=xe.indexOf("__"),Re=ke>0?xe.slice(0,ke):xe;G.set(Re,(G.get(Re)??0)+1)}const Q=[];for(const[ae,ue]of G){let xe=5381;for(let ke=0;ke<ae.length;ke++)xe=(xe<<5)+xe^ae.charCodeAt(ke);Q.push({server:ae,count:ue,hue:Math.abs(xe)%360})}return Q.sort((ae,ue)=>ue.count-ae.count),Q},[n.current,n.current.lastSeq]),Ra=A.useCallback(G=>{On(Q=>{const ae=new Set(Q);return ae.has(G)?ae.delete(G):ae.add(G),ae})},[]),Dt=u?n.current.agents.get(u):null,wr=p?Array.from(n.current.agents.values()).flatMap(G=>G.tools).find(G=>G.id===p)??null:null,Gr=A.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}n.current=nv(),wt.current.clear(),Br.current.clear(),Xt.current.clear(),Ss.current="",lE(),g(),i()},[i,g]),xr=A.useRef(b);xr.current=b;const Ns=A.useRef(!1);Ns.current=wr!=null||Qe||N!=null||y!=null;const gi=A.useCallback(G=>{const Q=Z3(G,{confirmOpen:xr.current,modalOpen:Ns.current});Q==="confirm"?k(!0):Q==="clear"&&(k(!1),Gr())},[Gr]),vo=A.useCallback(()=>{wt.current.clear(),Xt.current.clear(),Ss.current="",lE(),i(),window.setTimeout(()=>Be(500),80)},[i,e,Be]),vi=A.useCallback(()=>Be(500),[Be]),Cs=A.useRef(Rt);Cs.current=Rt;const yi=A.useRef(u);yi.current=u;const wi=A.useCallback(G=>{const Q=Cs.current;if(Q.length===0)return;const ae=Q.slice().sort((Le,He)=>Le.position.y-He.position.y||Le.position.x-He.position.x),ue=yi.current,xe=ue?ae.findIndex(Le=>Le.id===ue):-1;let ke;xe===-1?ke=G===1?0:ae.length-1:ke=(xe+G+ae.length)%ae.length;const Re=ae[ke];Re&&(f(Re.id,!1),window.setTimeout(()=>{try{e.fitView({padding:.35,duration:350,nodes:[Re]})}catch{}Ln.current=Date.now()},30))},[f,e]);A.useEffect(()=>{const G=Q=>{var xe,ke;const ae=Q.target,ue={tagName:ae==null?void 0:ae.tagName,isContentEditable:ae==null?void 0:ae.isContentEditable,role:(xe=ae==null?void 0:ae.getAttribute)==null?void 0:xe.call(ae,"role"),type:ae==null?void 0:ae.type};if(Q.key==="Escape"){const Re=eO({overlayOpen:sv.depth()>0,typing:KN(ue)});Re==="dismiss"?sv.dismissTop():Re==="blur"?ae==null||ae.blur():g();return}if(!X3(ue)&&!V3(Q)){if(Q.key==="/"){Q.preventDefault(),(ke=ys.current)==null||ke.focus();return}Q.key===" "&&(Q.preventDefault(),Ct()),(Q.key==="c"||Q.key==="C")&&gi("shortcut"),(Q.key==="r"||Q.key==="R")&&vo(),(Q.key==="f"||Q.key==="F")&&vi(),(Q.key==="l"||Q.key==="L")&&Ze(),(Q.key==="h"||Q.key==="H")&&at(Re=>!Re),(Q.key==="u"||Q.key==="U")&&P(Re=>!Re),(Q.key==="a"||Q.key==="A")&&De(),(Q.key==="j"||Q.key==="J")&&wi(1),(Q.key==="k"||Q.key==="K")&&wi(-1),(Q.key==="t"||Q.key==="T")&&vs(Re=>Re==="dark"?"light":"dark")}};return window.addEventListener("keydown",G),()=>window.removeEventListener("keydown",G)},[gi,vo,vi,g,wi,Ct]);const ln=n.current.agents.size,yo=new Set(Array.from(n.current.agents.values()).map(G=>G.sessionId)).size,Ot=A.useMemo(()=>{let G=0,Q=0,ae=0,ue=0,xe=0,ke=0,Re=0,Le=0,He=0;for(const Ke of n.current.agents.values()){G+=Ke.usage.inputTokens,Q+=Ke.usage.outputTokens,ae+=Ke.usage.cacheReadTokens,ue+=Ke.usage.cacheCreateTokens;const st=sn(Ke.usage,Ke.model);xe+=st.total,ke+=st.input,Re+=st.output,Le+=st.cacheRead,He+=st.cacheWrite}return{inT:G,outT:Q,cacheR:ae,cacheC:ue,sum:G+Q,cost:{total:xe,input:ke,output:Re,cacheRead:Le,cacheWrite:He}}},[n.current,n.current.lastSeq]);return m.jsxs("div",{className:"app",children:[m.jsxs("header",{className:"topbar",children:[m.jsxs("div",{className:"brand",children:[m.jsx("span",{className:"logo"}),"agents-deck",ye?m.jsxs("button",{type:"button",className:"v stale",onClick:we,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,m.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const G={running:(O==null?void 0:O.running)??"1.33.124",latest:O==null?void 0:O.latest,latestPending:O==null?void 0:O.latestPending,checkedAgo:O!=null&&O.checkedAt?i5(Je-O.checkedAt):null,checkDisabled:O==null?void 0:O.checkDisabled,checking:ve};return m.jsxs("button",{type:"button",className:ve?"v checking":"v",onClick:()=>Me(!0),"aria-busy":ve||void 0,"aria-label":K4(G),title:Y4(G),children:["v",G.running]})})()]}),Dt&&(()=>{const G=sn(Dt.usage,Dt.model),Q=Math.max(0,((Dt.endedAt??Je)-Dt.startedAt)/1e3),ae=Dt.state==="active"?su(G.total,Q):null,ue=o.size-1;return m.jsxs("button",{type:"button",className:"selected-ribbon",title:`Fit view to ${Dt.label}`,onClick:()=>{try{const xe=Rt.find(ke=>ke.id===Dt.id);xe&&e.fitView({padding:.35,duration:500,nodes:[xe]}),Ln.current=Date.now()}catch{}},children:[m.jsx("span",{className:`state-pill state-${Dt.state}`,children:Dt.state==="active"?"live":Dt.state}),m.jsx("span",{className:"selected-label",children:Dt.label}),G.total>0&&m.jsxs("span",{className:"selected-cost",children:[ze(G.total),ae?m.jsxs("span",{className:"selected-rate",children:[" · ",ae]}):null]}),ue>0&&m.jsxs("span",{className:"selected-extra",children:["+",ue]}),m.jsx("span",{role:"button","aria-label":"Deselect",className:"selected-close",onClick:xe=>{xe.stopPropagation(),g()},children:"×"})]})})(),m.jsxs("div",{className:"actions",children:[m.jsxs("div",{className:"search",children:[m.jsx("span",{className:"search-icon","aria-hidden":!0,children:"⌕"}),m.jsx("input",{ref:ys,type:"text",placeholder:"Search agents, cwd, tools…",value:Pn,onChange:G=>li(G.target.value),spellCheck:!1,"aria-label":"Filter the graph"}),Pn?m.jsx("button",{className:"search-clear","aria-label":"Clear search",onClick:()=>li(""),children:"×"}):m.jsx("kbd",{className:"search-kbd","aria-hidden":!0,children:"/"})]}),m.jsxs("span",{className:"status",role:"status",children:[m.jsx("span",{className:`pill ${M?"live":"dead"}`,title:M?"Receiving events":"SSE disconnected",children:M?"live":"offline"}),m.jsxs("span",{className:"stat",title:"Distinct CC sessions",children:[m.jsx("span",{className:"count",children:yo}),m.jsx("span",{className:"lbl",children:"sessions"})]}),m.jsxs("span",{className:"stat",title:"Total agents (root + subagents)",children:[m.jsx("span",{className:"count",children:ln}),m.jsx("span",{className:"lbl",children:"agents"})]}),m.jsxs("span",{className:"stat",title:"Total hook events received",children:[m.jsx("span",{className:"count",children:n.current.totalEvents}),m.jsx("span",{className:"lbl",children:"events"})]}),Ot.sum>0&&m.jsxs("span",{className:"stat",title:`in:${Ot.inT.toLocaleString()} out:${Ot.outT.toLocaleString()} cache-r:${Ot.cacheR.toLocaleString()} cache-c:${Ot.cacheC.toLocaleString()}`,children:[m.jsx("span",{className:"count",children:X4(Ot.sum)}),m.jsx("span",{className:"lbl",children:"tokens"})]}),sr.length>0&&m.jsxs("span",{className:"stat mcp-legend",title:`MCP servers seen this session:
|
|
60
60
|
${sr.map(G=>` ${G.server}: ${G.count} call${G.count===1?"":"s"}`).join(`
|
|
61
61
|
`)}`,children:[sr.slice(0,6).map(G=>m.jsx("span",{className:"mcp-dot",style:{background:`hsl(${G.hue} 65% 65%)`}},G.server)),sr.length>6&&m.jsxs("span",{className:"mcp-more",children:["+",sr.length-6]}),m.jsx("span",{className:"lbl",children:"mcp"})]}),Ot.cost.total>0&&(()=>{let G=0,Q=0;for(const xe of n.current.agents.values()){if(xe.state!=="active")continue;const ke=sn(xe.usage,xe.model);G+=ke.total,Q=Math.max(Q,((xe.endedAt??Je)-xe.startedAt)/1e3)}const ae=Q>0?su(G,Q):null,ue=`input ${ze(Ot.cost.input)} + output ${ze(Ot.cost.output)} + cache r ${ze(Ot.cost.cacheRead)} + cache w ${ze(Ot.cost.cacheWrite)}${ae?`
|
|
62
62
|
active burn: ${ae}`:""}`;return m.jsxs("span",{className:"stat",title:ue,children:[m.jsx("span",{className:"count",children:ze(Ot.cost.total)}),m.jsxs("span",{className:"lbl",children:["cost",ae?` · ${ae}`:""]})]})})()]}),m.jsx("button",{className:`btn ${hn?"warn":""}`,onClick:Ct,title:"Pause/resume live updates (Space)",children:hn?`Resume${lt.current.size?` · ${lt.current.size}`:""}`:"Pause"}),m.jsx("button",{className:`btn icon-btn ${H?"primary":""}`,onClick:()=>P(G=>!G),title:`${H?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel",children:"$"}),D!==null&&m.jsx("button",{className:`btn icon-btn ${D?"primary":""}`,onClick:G=>{if(G.shiftKey&&J>0){Z(!0),fetch("/api/sound-hook",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"restore"})}).then(()=>fetch("/api/sound-hook")).then(Q=>Q.ok?Q.json():null).then(Q=>{Q!=null&&Q.ok&&(F(Q.enabled===!0),U(Q.parked??0))}).catch(()=>{}).finally(()=>Z(!1));return}X()},disabled:j,title:(D?"Sound on turn finish: on — click to remove the hook":"Sound on turn finish: off — click to add a Stop hook")+(W>0?`
|